code
stringlengths
4
1.01M
language
stringclasses
2 values
void main() { auto N = ri; ulong cnt; foreach(i; 0..N) { if(rs == "E869120") cnt++; } cnt.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.bi...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; void main() { string input; while ((input = readln.chomp).length != 0) { while (input.length > 1) { string output; for (int i = 0; i < input.length-1; i++) { ...
D
void main(){ int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); writeln(max(a*b, c*d)); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod = 10^^9+7; // 1要素のみの入力 T inelm(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] inl...
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container; import core.bitop, std.datetime; void main(){ auto s = readln.chomp; auto stack = new Stack!(char)(s.length.to!int); foreach(c;s){ if(c == 'B'){ if(!stack.isEmpty) stack.po...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; struct P {int first; int second;} int main() { while (true) { string[] str = readln().chomp().split(); int h = str[0].to!int(); int w = str[1].to!int(); if (h == 0 && w == 0) break; string t; ...
D
//prewritten code: https://github.com/antma/algo import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; final class InputReader { private: ubyte[] p, buffer; bool eof; bool rawRead () { if (eof) { return fals...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp.to!int; foreach (_; 0..T) { auto xnm = readln.split.to!(int[]); auto X = xnm[0]; auto N = xnm[1]; auto M = xnm[2]; while (N > 0 && ...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, 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 main() { int x, t; readV(x, t); writeln(max(0, x-t)); }
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 main(){ auto ip = readln.split.to!(int[]); if(ip[0] + ip[1...
D
import std.stdio; void main() { long l, r; scanf("%ld%ld", &l, &r); auto ans = 0; for (long a2=1; a2<=r; a2*=2) { for (long a3=1; a3<=r/a2; a3*=3) { if (a2 * a3 >= l) ans++; } } writeln(ans); }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { import std.math; int x, a, b; scan(x, a, b); writeln(abs(x-a) < abs(x-b) ? "A" : "B"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std...
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 x, y; scan(x, y); writeln(x + y / 2); } void scan(T...)(ref T args) { import std.stdio : readln; import ...
D
void main(){ auto K = readLine!()()[0]; auto AB = readLine!()(); foreach( i ; 1..1000 ){ if( AB[0] <= K*i && K*i <= AB[1] ){ writeln("OK"); return; } if( K*i > 1001 ){break;} } writeln("NG"); return; } import std.stdio, std.string, std.conv; import std.math, std.algorithm, std.array; import ...
D
import std.stdio; import std.string; import std.conv; void main() { auto l = readln.chomp; auto fst = l[0..2].to!int; auto snd = l[2..4].to!int; auto fM = fst > 0 && fst <= 12; auto sM = snd > 0 && snd <= 12; if (fM && sM) write("AMBIGUOUS"); else if (sM) write("YYMM"); else if (fM) write("MMYY"); else ...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; import std.typecons; void main(){ auto hw = readln().chomp().split().map!(to!int).array(); string[] grids; foreach(i; 0..(hw[0])){ grids ~= readln().chomp(); } solve(grids).writel...
D
import std.stdio; import std.algorithm; import std.math; import std.string; import std.conv; import std.range; void main() { foreach (string line; stdin.lines) { string s = line.chomp; int joi = 0; int ioi = 0; for (int i = 0; i < s.length - 2; i++) { if (s[i..i+3] == "J...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); foreach(i; 0..10){ char[] t; foreach(_; 0..3) t~=i+'0'; if(s[0..($-1)]==t){writeln("Yes"); return;} if(s[1..$]==t){writeln("Yes"); return;} } writeln("No"); } void rd(T...)(ref T x){ impo...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; template bsearch(alias fun) { import std.functional: unaryFun; alias f = unaryFun!fun; int bsearch(T)(T[] arr) { if (arr.empty) return -1; if (!f(arr[0])) return -1; if (f(arr[...
D
import std.stdio, std.string, std.conv; import std.typecons; import std.algorithm, std.array, std.range, std.container; import std.math; void main() { auto a = readln.split[0].to!int; auto b = readln.split[0].to!int; auto c = readln.split[0].to!int; auto d = readln.split[0].to!int; auto e = readln.split[0].to!int...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math; void main(){ auto s=readln().chomp().split().map!(to!int); int a=s[0],b=s[1],c=s[2],ans=0; if(a>b && a>c) ans=b*c/2; else if(b>a && b>c) ans=c*a/2; else ans=a*b/2; writeln(int(ans)); }
D
import std.stdio,std.regex; void main(){ auto next = readln().chomp().to!size_t; auto list = [111,222,333,444,555,666,777,888,999]; foreach( val; list ){ if( next <= val ){ writeln(val); break; } continue; } return; } import std.string,std.conv;
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons; import std.math, std.numeric; void main() { long n, x; scan(n, x); if (x > n - x) { x = n - x; } if (x == n - x) { writeln(3*x); return; } long ans = n; void dfs(lon...
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; void main() { auto ip = readln.split.to!(int[]); int count; fo...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional; void main() { auto s = readln.chomp; auto n = s.length; foreach (c; s) { if (c == 'A') break; --n; } foreach_reverse (c; s) { if (c == 'Z') break; --n; } writeln(n); }
D
import std.algorithm; import std.array; import std.bigint; import std.bitmanip; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; // 差の絶対値 @nogc @safe pure T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } // 切り上げ除算 @nogc @safe pur...
D
import std.stdio, std.algorithm, std.conv, std.array, std.range, std.string, std.math, std.typecons; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; long cnt; foreach (long i; 0..N) { if (i < K) continue; else { cnt += N / (i...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.format; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 ...
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; void main() { auto abc = readln.chomp.split(" ").map!(to!int); writeln( abc.count!"a==5" == 2 && abc.count!"a==7" == 1 ? "YES" : "NO" ); }
D
/+ dub.sdl: name "C" dependency "dunkelheit" version="1.0.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.math; // import dkh.foundation, dkh.scanner; immutable int MD = 3*(10^^5); immutable int S = MD/2; int main() { Scanner sc = new Scanner(stdin); scope(exit) assert(!sc.hasNext); ...
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.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; string S; scan(N); s...
D
import std.stdio, std.string, std.conv, std.algorithm, std.range; void main(){ int m, f, r; string rs; while(true){ scanf("%d %d %d", &m, &f, &r); if (m == -1 && f == -1 && r == -1) break; if (m == -1 || f == -1){ rs ~= "F"; } else if (m+f>=80){ rs ~= "A"; } else if (m...
D
import core.bitop; import core.checkedint; import core.simd; import core.stdc.stdio; import core.stdc.stdlib; import core.stdc.string; import std.algorithm; import std.array; import std.ascii; import std.bigint; import std.bitmanip; import std.complex; import std.container; import std.conv; import std.datetime; import ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[10^^5*2+2] LR, DU; void main() { auto hwn = readln.split.to!(int[]); auto H = hwn[0]; auto W = hwn[1]; auto N = hwn[2]; auto rc = readln.split.to!(int[]); auto SR = rc[0]; auto SC = r...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int[] buf = readln.chomp.split.to!(int[]); int a = buf[0], b = buf[1]; if (a + b == 15) { writeln("+"); } else if (a * b == 15) { writeln("*"); } else { writeln("x"); } }
D
void main() { problem(); } void problem() { auto X = scan!long; long solve() { long answer; auto num500 = X / 500; auto num5 = (X - num500 * 500) / 5; return num500 * 1000 + num5 * 5; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std....
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b; char op; scan(a, op, b); if (op == '+') { writeln(a+b); } else { writeln(a-b); } } void scan(T...)(ref T args) { import std.stdio : readln; import std.algo...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; auto l = new long[](n+1); l[0] = 2; l[1] = 1; foreach (i; 2..n+1) l[i] = l[i-1]+l[i-2]; writeln(l[n]); }
D
import std.stdio; import std.range; import std.array; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.container; import std.typecons; import std.random; import std.csv; import std.regex; import std.math; import core.time; import std.ascii; import std.digest.sha; import std.outb...
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.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 int M = 30; long x, y; int cnt = 0; int ask(long c, long d) { debug { cnt += 1; if ((x^c) >...
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.string, std.conv, std.array, std.algorithm; void main() { while (true) { auto a = readln.split.map!(to!int); if (a[0] == 0 && a[1] == 0) break; if (a[0] < a[1]) writeln(a[0], " ", a[1]); else writeln(a[1], " ", a[0]); } }
D
import std.stdio; immutable mod = 4294967311L; long[] inv; void main(){ long x; int n, y, op; scanf("%d", &n); inv = new long[1_000_001]; inv[1] = 1; foreach(_; 0..n){ scanf("%d%d", &op, &y); if(op >= 3 && y < 0) x = -x, y = -y; if(op == 1) x += y; else if(op == 2) x -= y; else if(op == 3) x *= y; e...
D
import std.stdio, std.string, std.conv; void main() { foreach (i; 1 .. 10001) { int x = readln.chomp.to!int; if (x == 0) break; writeln("Case ", i, ": ", x); } }
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { ret...
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 main() { int n; readV(n); writeln(n < 100...
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[] lreads(T = long)(long n){return generate(()=>readln.c...
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, R; scan(N, R); auto ans ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nab = readln.split.to!(long[]); auto N = nab[0]; auto A = nab[1]; auto B = nab[2]; if ((B-A)%2 == 0) { writeln((B-A)/2); } else { writeln(min(A + (B-A)/2, N...
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int[] a; for(int x=6; x<=n; x*=6) a~=x; for(int x=9; x<=n; x*=9) a~=x; a~=1; auto dp=new int[](n+1); const int inf=1_000_000_000; fill(dp, inf); dp[0]=0; foreach(i; 0..n)foreach(e; a){ if(i+e<=n) dp[i+e]=min...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.typecons; import std.numeric, std.math; import core.bitop; string FMT_F = "%.10f"; T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.t...
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.datetime; void main() { auto S = readln.chomp; auto s = readln.split.map!(to!int); auto X = s[0]; auto Y = s[1]; int...
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!ulong; auto M = tokens[1].to!ulong; ulong[][...
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() { int d...
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.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.conv, std.stdio, std.typecons; void main() { auto x = readln.chomp.to!int; writeln(x ^^ 3); }
D
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; int n; int[] a; int dfs(int depth, bool gu) { if (depth == n) { return gu; } int cnt = 0; for (in...
D
import std.stdio; import std.algorithm; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() {//try{ auto tokens = split(my_readln()); auto S = to!string(tokens[0]); ulong ans, cnt_b; foreach (i, e; S) { if (e...
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 abc=readln.split.map!(to!int).array; auto gcd=gcd(abc[0],abc[1]); writeln(abc[2]%gcd==0?"YES":"NO"); }
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.stdio; void main() { auto T = readln.chomp.to!int; while (T--) { auto s = readln.split.map!(to!long); auto...
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 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[] lreads(T = long)(long n){return generate(()=>readln.c...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to void main() { string s = chomp(readln()); for(int i=0; i<s.length; ++i){ if(i%2 == 0){ write(s[i]); } } }
D
void main() { problem(); } void problem() { auto N = scan!int; auto X = scan!int; auto T = scan!int; int solve() { auto t = N % X == 0 ? N / X : 1 + N / X; return t * T; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, s...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=new int[](n); foreach(i; 0..n) rd(a[i]); auto dp=new int[](n); dp[0]=1; bool up=true; foreach(i; 1..n){ if(up){ if(a[i-1]<a[i]) dp[i]=dp[i-1]+1; else if(a[i-1]==a[i]) dp[i]=dp[i-1]; else dp[i...
D
// dfmt off T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;} void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(...
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; void main() { auto n = readln.chomp.count('7'); if (n) { writeln("Yes"); } else { write...
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; int n, k; void main() { int n = readln.chomp.to!int; int k = readln.chomp.to!int; in...
D
import std.stdio; import std.string; import std.conv; void main() { string s = readln.chomp; ulong k = readln.chomp.to!ulong; if (s[0] != '1') { s[0].writeln; return; } foreach(i, c; s) { if (c != '1') { if (i < k) { s[i].writeln; ...
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[] lreads(T = long)(long n){return generate(()=>readln.c...
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 n = readln.chomp.to!int; if (!n) break; auto m = new int[][](n); foreach (i; 0..n) { ...
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 main() { string s; readV(s); writeln(s.pr...
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.numeric; void main() { int[3][3] c; foreach (i; 0..3) { c[i] = readln.chomp.split....
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[] lreads(T = long)(long n){return generate(()=>readln.c...
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.algorithm, std.conv, std.array, std.string; void main() { auto a = readln.chomp; auto b = readln.chomp; writeln( a.length > b.length ? "GREATER" : a.length < b.length ? "LESS" : a > b ? "GREATER" : a < b ? "LESS" : "EQUAL" ); }
D
import std.stdio, std.algorithm, std.conv, std.string, std.array; void main() { const N = readln.chomp.to!long; auto ans = long.max; for (long i = 1; i*i <= N; ++i) { if (N%i == 0) ans = ans.min(i+N/i-2); } ans.writeln; }
D
import std.conv, std.stdio, std.string, std.array, std.range, std.algorithm; string s = "CODEFORCES"; void main() { char[] t = readln.strip.dup; int len; foreach (i, e; s) { if (e == t[i]) { ++len; } else { break; } } if (len == 10) { writeln("YES"); return; } len = 0; int j; foreach_...
D
import std.stdio; import std.algorithm; void main() { int w, h, n; scanf("%d\n%d\n%d", &w, &h, &n); write((n + max(w,h) - 1) / max(w, h)); }
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(); ulong MOD =...
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 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; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
import std.stdio, std.string, std.conv; import std.typecons; import std.algorithm, std.array, std.range, std.container; import std.math; void main() { auto data = readln.split; auto N = data[0].to!int, T = data[1].to!int; int cost = 10_000; foreach (i; 0 .. N) { data = readln.split; auto c = data[0].to!int, ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b, h; scan(a); scan(b); scan(h); writeln((a + b) * h / 2); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; 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[] lreads(T = long)(long n){return generate(()=>readln.c...
D
import std.stdio; import std.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto n = to!int(chomp(readln())); long[] t; foreach (i; 0..n) { t ~= to!long(chomp(readln())); } long lcm(long a, long b) { if (a < b) { auto tmp = a; a = b; b = tmp; ...
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 main() { int n; readV(n); writeln(n*800-(...
D
import std.algorithm; import std.array; import std.bigint; import std.bitmanip; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } T[] readToArray(T)() { return readln.split.to!(...
D
import std.algorithm, std.string, std.range, std.stdio, std.conv; void main() { int N = readln.chomp.to!int; string S = readln.chomp; char l = '(', r = ')'; int ls, rs; int als; foreach (c; S) { if (c == l) { ls++; } else { rs++; } if (ls - rs...
D
void main(){ import std.stdio; auto x = readln.dup; x[3] = '8'; writeln(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.to!(char[]); char[] S; for (size_t i; i < s.length; ++i) { if (i < s.length-1 && s[i] == 'B' && s[i+1] == 'C') { S ~= 'X'; ++i; ...
D
void main() { string s = readln.chomp; char[] acgt = ['A', 'C', 'G', 'T']; int cnt, ans; foreach (x; s) { if (acgt.canFind(x)) { ++cnt; ans = max(ans, cnt); } else { ans = max(ans, cnt); cnt = 0; } } ans.writeln; } import s...
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], k = tmp[1]; writeln((n + 1) / 2 >= k ? "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; import std.t...
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, c; long k; scan(a, b, c, k); writeln(k & 1 ? b - a : a - b); } void scan(T......
D
import std.stdio; import std.array; import std.conv; import std.string; import std.algorithm; void main() { string s; while( (s=readln.strip) != "0 0") { auto n = map!(to!int)(s.strip.split); int h = n[0], w = n[1]; foreach(i;0..h) { foreach(j;0..w) { write((i...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { auto n = readln.chomp.to!int; int[][] ab = new int[][](10,10); for(int i=1; i<=n; i++) { int a = i; while(a>=10) a/=10; int b = i%10; ab[a][b]++; } long result = 0; ...
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; void times(alias fun)(int n) { // n.iota...
D