code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
int[][] G;
G.length = N;
foreach (_; 0..M) {
auto ab = readln.split.to!(int[]);
auto A = ab[0]-... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.range, std.array;
void main() {
auto input = readln.split.to!(int[]);
writeln((input[0] % 3 == 0 || input[1] % 3 == 0 || input.sum % 3 == 0) ? "Possible" : "Impossible");
} | D |
import std.stdio;
import std.string;
import std.conv,std.array,std.datetime;
void main(){
while(1){
auto cs = readln().chomp().split();
if( cs[0]=="0" ){ break; }
final switch( Date( 2004, to!int(cs[0]), to!int(cs[1])).dayOfWeek() ){
case 0:writeln("Sunday");break;
case 1:writeln("Monday");break;
case 2:w... | D |
import std.stdio,
std.conv,
std.array,
std.string;
void main() {
int n = to!int(chomp(readln()));
while(n--) {
string[] l = split(readln());
int a = to!int(l[0]);
int b = to!int(l[1]);
int c = to!int(l[2]);
if(a*a==b*b+c*c
||b*b==c*c+a*a
||c*c==a*a+b*b) {
wr... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
// Cheese-Cracker: cheese-cracker.github.io
void play(){
int n, m;
n = rd!int;
m = rd!int;
int summ = 0, el;
foreach(i; 0..n){
el = rd!int;
summ += el;
}
if(summ == m){
writeln("YES");
}else{
writeln("NO");
}
}
int main(){
long t = 1;
t = rd;... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int l, r, a; rd(l, r, a);
if(l>r) swap(l, r);
if(r-l>=a){writeln((l+a)*2); return;}
a-=(r-l);
if(a&1) a--;
writeln(r*2+a);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto T = readln.chomp;
int[26] cs, ds;
foreach (i; 0..S.length) {
auto s = S[i] - 'a';
auto t = T[i] - 'a';
if (cs[s] == 0 && ds[t] == 0) ... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){ret... | D |
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if... | D |
// import chie template :) {{{
static if (__VERSION__ < 2090) {
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format,
std.bitmanip, std.numeric;
} else {
import std;
}
// }}}
// nep.scanner {{{
class Scanner {
... | D |
import std.stdio, std.algorithm, std.array, std.string, std.conv;
void main() {
auto s = readln.chomp.to!(dchar[]);
if (s.length == 3) s.reverse();
writeln(s);
}
| D |
const int m=10000000+10;
bool[m] pp;
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
if(n==1){
writeln(0);
return;
}
if(n==2){
writeln(0);
return;
}
mp();
int cnt=0;
for(int p=1; p<=n; p++){
if(pp[p] && pp[p+2]){
cnt++;
}
}
wr... | D |
void main() {
while(true) {
auto ip = readAs!(int[]), H = ip[0], W = ip[1];
if(H == 0 && W == 0) return;
foreach(i; 0..H) {
bool flag = i & 1;
foreach(j; 0..W) {
if(flag) {
if(j & 1) write('#');
else write('.');
} else {
if(j & 1) write('.');
else write('#');
}
}
write... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto s = readln.chomp;
auto l_res = new int[](s.length + 1);
a... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;
void main()
{
while (1) {
auto x = readln.chomp.split.map!(to!int).array;
if (x[0] == 0) break;
x[1]--;
int winner, s... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto N = readln.chomp.to!int;
writeln((N+999)/1000 * 1000 - N);
} | D |
void main()
{
long n = readln.chomp.to!long;
long[5] cnts;
string t = "MARCH";
foreach (i; 0 .. n)
{
string s = readln.chomp;
foreach (j, x; t)
{
if (x == s[0]) ++cnts[j];
}
}
long result;
foreach (i; 0 .. 3)
{
foreach (j; i+1 .. ... | D |
void main() {
auto s = rs.to!(dchar[]);
s[5] = s[13] = ' ';
s.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.c... | D |
void main()
{
int n = readln.chomp.to!int;
int h = readln.chomp.to!int;
int w = readln.chomp.to!int;
writeln((n - h + 1) * (n - w + 1));
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.con... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
auto ... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
iota(1, readln.chomp.to!(int)+1).count!(x => x % 2 == 1 && iota(1,x+1).count!(i => x % i == 0) == 8).writeln;
}
| D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
string[] ss = readln.split;
foreach (i, ref arg ; args) ar... | D |
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
/*
桁の数字の和 digit sum
------... | D |
import std.algorithm;
import std.string;
import std.stdio;
void main() {
readln;
string s = readln.chomp;
if (s.length < 3) {
writeln("0");
return;
}
auto c = count(s, 'R') * count(s, 'G') * count(s, 'B');
foreach (i;1..(s.length + 1) / 2) {
for (size_t j = 0;j + i + i < s.length;++j) {
if (cast(int... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;
alias Node = Tuple!(long, "sum", long, "lmax", long, "rmax... | D |
import std.stdio, std.string;
void main() {
string s = readln.chomp;
bool ok = true;
foreach (i; 1 .. 4) {
if (s[i] == s[i-1]) ok = false;
}
writeln(ok ? "Good" : "Bad");
} | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
struct Path { long begin, end; }
Path[] pathList;
foreach (i; 0..3) {
const tmp = readln.split.to!(long[]);
pathList ~= Path(tmp[0], tmp[1]);
}
foreach (start; 1..5) {
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
foreach(i; 0..n) pred();
}
auto ... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{
auto tokens = my_readln().split();
auto N = tokens[0].to!uint;
long[] a;
foreach (token; my_readln.sp... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto x = readln.chomp.to!long;
long r = x / 11L * 2;
if (x%11L >= 7) {
r += 2;
} else if (x%11L >= 1) {
r += 1;
}
writeln(r);
} | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main()
{
auto ip = readln.split.to!(int[]);
if(ip[0] == ip[1]) writeln("a ==... | D |
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.array;
void main(){
int N = readln().chomp().to!int();
int[] nums;
int[] primes;
for(int i = 0; i < N; i++){ nums ~= readln().chomp().to!int(); }
foreach(int n; nums){
bool isPrime = true;
for(int i = ... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.format;
import std.algorithm;
import std.math;
//string lines = q"[
//abcdeffg]";
long INF = pow(10, 9);
long[] H = [0L];
long cost(int i, int j)
{
return abs(H[i]-H[j]).to!long;
}
void main()
{
string lines;
string buf;
while (!stdin.eof) ... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
auto x = new long[](10 ^^ 6 + 10);
foreach (i; 1 .. 101)
{
foreach (j; 1 .. 101)
{
foreach (k; ... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
import std.array;
int n;
rd(n);
auto a = readln.split.map!((s) => (s == "T" ? 1 : 0)).array;
int f(int x, int y) {
return (x - y <= 0);
}
//
auto t = f(a[0], a[1]);
foreach (i; 2 .. n) {
t = f(t, a[i]);
}
if (t) {
... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(readln.chomp.to!int.among(7,5,3) ? "YES" : "NO");
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
import core.bitop : popcnt;
alias Generator ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto N = readln.chomp.to!int;
auto as = readln.split.to!(int[]);
writeln(as.sum - N);
} | D |
import std.stdio, std.conv, std.algorithm, std.string, std.container;
void main(){
SList!int list;
while(true){
auto line = readln.chomp;
if(line.length == 0){
break;
}
auto input = line.to!int;
if(input){
list.insertFront(input);
}else{
... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;
void main(){
int n = readln().chomp().to!int;
for(int i=0;i<n;i++){
auto s = readln().chomp().split(':');
int h = s[0... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;
alias sread = () => readln.chomp();
alias Point... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return r... | D |
void main() {
string s = readln.chomp;
int diff = 1000;
foreach (i; 2 .. s.length) {
int x;
foreach_reverse (j; 0 .. 3) {
x += (s[i-j] - '0') * 10 ^^ j;
}
diff = min(diff, abs(x-753));
}
diff.writeln;
}
import std.stdio;
import std.string;
import std.arra... | D |
import std;
long calc(long[] a) {
long ans = 0;
long[long] d;
for (int i = 0; i < a.length; i++) {
if (i + 1 >= a[i]) {
ans += d.get(i + 1 - a[i], 0);
}
d[i + 1 + a[i]]++;
}
return ans;
}
void main() {
readint;
auto a = reads!long;
writeln(calc(a));
... | D |
void main() {
auto c = readMatrix!char(3, 3);
foreach(i; 0..3) c[i][i].write;
writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
i... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto abn = readln.split.to!(long[]);
auto A = abn[0];
auto B = abn[1];
auto N = abn[2];
auto x = min(N, B-1);
writeln((A*x)/B - A*(x/B));
} | D |
void main() {
int[] ab = readln.split.to!(int[]);
writeln(ab.all!"a % 2 == 1" ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons; | D |
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
bool[char] set;
foreach (c; readln.chomp)
{
set[c] = true;
}
fo... | D |
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.array;
void main() {
int n = readln.chomp.to!int;
int[] c = new int[](n), s = new int[](n), f = new int[](n);
for (int i = 0; i < n - 1; ++i) {
auto l = readln.chomp.split.map!(to!int).array;
c[i] = l[... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv,
std.format,
std.math;
void main()
{
while(true){
auto ip = readl... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
string s = readln.chomp;
string t = "CF";
while (!t.empty) {
if (s.empty) {
w... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
int n, m;
{
int[] tmp = readln.chomp.split.map!(to!int).array;
n = tmp[0], m = tmp[1];
}
bool[] flag = new bool[n];
flag[0] = 1;
int[] count = new ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;
void main()
{
while (1) {
auto x = readln.chomp.split.map!(to!int);
if (!x[0]) break;
auto area = new char[][](x[0], x... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.math;
int n, k; rd(n, k);
auto a=new long[n];
auto b=new long[n];
foreach(i; 0..n) rd(a[i], b[i]);
long mx=0;
foreach(pos; 0..32){
long vsum=0;
if(k&(1<<pos))foreach(i; 0..n){
if(a[i]&(1<<pos)) continue;
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_... | D |
void main(){
ulong x = _scan!ulong();
ulong dep = 100;
ulong yy = 0;
while( 1 ){
if( dep >= x ){
yy.writeln();
return;
}
yy++;
dep += dep/100;
}
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1... | D |
import std.stdio, std.conv, std.array,std.string;
void main()
{
auto a=readln;
int aa=0;
if(a[0]=='1')aa++;
if(a[1]=='1')aa++;
if(a[2]=='1')aa++;
writeln(aa);
} | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;
void main(){
auto nm=readln.split.map!(to!int).array;
int[][] abs;
foreach(i;0..nm[1])abs~=readln.split.map!(to!int).arra... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
ulong gcd(ulong a, ulong b) {
if(b == 0) return a;
return gcd(b, a % b);
}
ulong lcm(ulong a, ulong b) {
return (a * b) / gcd(a, b);
}
void main() {
auto input = readln.split.to!(ulong[... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int N;
scan(N);
auto x = new in... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
int bubbleSort(int n, int[] x) {
int cnt = 0;
bool flag = true;
for (int i = 0; flag; ++i) {
flag = false;
for (int j = n - 1; j >= i + 1; --j) {
if (x[j] < x[j-1]) {
swap(x[j], x[j-1]);
... | D |
import std.stdio,std.string,std.algorithm;
void main(){
string[] a = readln().chomp().split();
sort(a);
writeln( join(a," " ));
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;
void main()
{
auto si = readln.split;
auto st = SList!int();
int a, b;
foreach (s; si) {
switch(s) {
case "+":
st.getOperands(a, b);
st.insert(b + a);
break;
case "-":
st.getOperands(a, ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
int a, b, c;
foreach (s; readln.chomp) {
switch (s) {
case 'a': ++a; break;
case 'b': ++b; break;
case 'c': ++c; break;
default:
}... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;
int calc(int a) {
return (a + a + 1 + a + 2 + a + 7 + a + 8 + a + 9 + a + 14 + a + 15 + a + 16) % 11;
}
void main() {
... | D |
void main() {
(rs.count('o')*100+700).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.type... | D |
void main() {
auto w = readln.chomp.to!(dchar[]).sort!"a < b".group.assocArray;
writeln(w.values.all!(t => t % 2 == 0) ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
im... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;
int n, m;
bool[] a;
bool[] b;
void main() {
scan(n, m);
a = new bool[](n + 1);
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto as = "abcdefghij";
char[] ss;
ss.length = N;
void solve(int i, int j) {
if (i == N) {
writeln(ss);
return;
... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range, std.math;
void main()
{
auto n = readln.chomp.to!int;
auto as = readln.chomp.split(" ").map!(to!int).array;
auto av = as.reduce!"a+b" / n.to!double;
auto av1 = ceil(av);
auto ret1 = as.dup.map!(i => ((i - av1) ^^ 2).to!lo... | D |
void main()
{
long n = rdElem;
long[] a = n.rdCol;
if (a[0])
{
writeln(-1);
return;
}
long[] x = new long[n];
x[n-1] = a[n-1];
long cnt = x[n-1];
foreach_reverse (i; 0 .. n-1)
{
if (x[i+1]) x[i] = x[i+1] - 1;
if (i < x[i] || x[i] > a[i])
... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
immutable INF = 1<<30;
long impl(long n, long v, const ref long[] ws, const ref long[] vs, ref long[][] dp) {
if(dp[n][v] == INF) {
const auto yes = {
const auto prev_v = v-vs[n-1];
return prev_v >= 0 ? impl(n-1, p... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(int);
auto a = readln.strip.map !(q{a - '0'}).array;
auto b = readln.strip.map !(q{a - '0'}).array;
int mex... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
void main()
{
auto N = readln.chomp.to!long;
long r;
foreach (i; 1..N+1) {
auto d = N/i;
r += d * (d+1) / 2 * i;
}
writeln(r);
} | D |
import std.stdio, std.string, std.algorithm, std.array;
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(i; 0..t){
auto str = readln.strip();
string result;
while (str.length > 0)
{
result ~= str[0];
str = str.stripLeft(str[0]);
}
if (result.length > 3)
writeln(2);
else if (result ... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
int[] S;
int n;
char last;
foreach (c; readln.chomp) {
if (last && last == c) {
++n;
} else {
if (n) S ~= n;
last = c;
n =... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable inf = 10^^9 + 7;
int c, v0, v1, a, l;
void main() {
scan(c, v0, v1, a, l);
int r;
int cnt;
whil... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
int a, b; scan(a, b);
int ans = (a - 1) + (a <= b);
writeln(ans);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto tmp = readln.split.to!(long[]);
auto K = tmp[0], A = tmp[1], B = tmp[2];
if (B - A <= 2) {
writeln(1 + K);
} else {
// A-1回最初に叩く
const tataki = max(0, A-1);
... | D |
module sigod.codeforces.p298C;
import std.algorithm;
import std.stdio;
import std.string;
void main()
{
string a = stdin.readln().strip();
string b = stdin.readln().strip();
size_t a_count = a.count('1');
if (a_count % 2 == 1) ++a_count;
size_t b_count = b.count('1');
stdout.writeln(a_count >= b_count ? "YES... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
void main() {
while (true) {
int N = readln.chomp.to!int;
if (N =... | D |
import std.stdio, std.conv, std.array, std.math;
void main() {
string[] input = readln.split;
int m = input[0].to!int;
int k = input[1].to!int;
int n = pow(2, m);
if(n == 1) {
if(k == 0) {
writeln(0, " ", 0);
} else{
writeln(-1);
}
return;
... | D |
void main()
{
long n, k;
rdVals(n, k);
long[] x = rdRow;
long result = inf;
foreach (i; 0 .. n-k+1)
{
long time = abs(x[i]-x[i+k-1]) + min(x[i].abs, x[i+k-1].abs);
result = min(result, time);
}
result.writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T r... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
long ... | D |
import std.algorithm;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;
void main() {
auto input = readln.chomp.split.map!(to!long... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
while (true) {
int r0, w0, c, r;
scan(r0, w0, c, r);
if (!r0) return;
int ans;
while (r0 < w0*c) {
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.