code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; void main() { auto s = readln.strip; auto cl = s.count!"a == 'x'"; writeln (cl <= 7 ? "YES" : "NO"); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a = readln.split.to!(int[]); int s = 0; foreach (i; 0 .. n) { a[i] *= n; s += a[i]; } auto ave = s / n; int best_idx = 0; import std.math : abs; foreach (int i; 1 .. n) { if (abs(ave - a[best_idx...
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 M = readln.chomp.to!int; if (M==0...
D
void main() { int[] arr; arr ~= 1; foreach(i; 2..1001) { auto a = i; auto b = a; auto k = 2; a *= a; while(a <= 1000) { arr ~= a; k++; a = b^^k; } } auto X = ri; while(true) { if(arr.canFind(X)) { X.writeln; return; } X--; } } // =================================== import std....
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; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; alias Pair = Tuple!(int, "a", int, "b"); void main() { ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long l, r; rd(l, r); writeln("YES"); for(auto i=l; i+1<=r; i+=2){ writeln(i, " ", i+1); } } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x) e...
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.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.algorithm; import std.conv; import std.stdio; import std.string; void main() { auto ns = readln.strip; writeln( solve( ns ) ); } int solve( in string ns ) { auto ds = ns.map!( a => a - '0' ); auto r = ds.sum; if( 1 < r ) return r; else return solve( ( ns.to!int / 2 ).to!string ) * 2; } uni...
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.to!int; int sum; foreach (i; 1..n+1) { sum += i; } ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long[10^^5] AS, BS; void main() { auto N = readln.chomp.to!int; foreach (i; 0..N) { auto ab = readln.split.to!(long[]); AS[i] = ab[0]; BS[i] = ab[1]; } long r; foreach_re...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], c = rd[2], d = rd[3]; writeln(max(0, min(b, d) - max(a, 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.regex : regex; import std.container; import std.bigint; import std.ascii; void main() { writeln(readln.chomp.to!int^^3); }
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.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 r; readV(r); if (r < 1200) ...
D
import std.stdio; import std.conv; void main() { char[] buf; readln(buf); for (int i = to!(int)(buf.length); i > 1; i--) { write(buf[i-2]); } write("\n"); }
D
/* AOJ 0501 'Data Conversion' http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0501 */ import std.stdio; import std.array; import std.range; import std.conv; import std.string; import std.algorithm; void main() { while(true) { int N = readln().chomp().to!int; if(N == 0) break; int[char] table; ...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array; void main() { writeln(readln.chomp.map!(to!int).array.sort().map!(to!char).array == "abc" ? "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; immutable long MOD = 998244353; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]...
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
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.conv; import std.stdio; import std.string; void main() { auto nk = readln.split.to!( int[] ); auto as = readln.split.to!( int[] ); writeln( solve( nk[ 1 ], as ) ); } auto solve( in int k, in int[] as ) { auto as_r = as.length - k; auto k_r = k - 1; auto c = 1 + as_r / k_r; auto re = ( as_r % k_r ==...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n, k; int[] a; scan(n, k); a = readln.split.to!(int[]); auto dp1 = new bool[][](n + 1, k); dp1[0][0] = 1; foreach (i ; 1 .. n + 1) { foreach (j ; 0 .. k) { dp1[i][j] ...
D
import std.stdio; import std.string; import std.conv; void main() { string input = readln(); char a = input[0]; char b = input[1]; if(a == '9' || b == '9') { "Yes".writeln; } else { "No".writeln; } }
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.stdio; void main() { int n, k, s; scanf("%d %d %d\n", &n, &k, &s); if (s == 10^^9) { foreach(_;0..n-k) { write(1, " "); } foreach(_;0..k) { write(10^^9, " "); } } else { foreach(_;0..n-k) { write(s+1, " "); } foreach(_;0..k) { write(s, " "); } } }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int a = to!int(chomp(readln())); int b = to!int(chomp(readln())); int h = to!int(chomp(readln())); int surface = (a + b) * h / 2; surface.writeln; }
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
void main(){ import std.stdio, std.conv, std.string, std.algorithm; long n, a, b, k; rd(n, a, b, k); const long mod=998244353; const int M=1_000_00*4; auto fact=new long[](M); fact[0]=fact[1]=1; foreach(i; 2..M) fact[i]=i*fact[i-1]%mod; auto inv_fact=new long[](M); long powmod(long a, long x){ 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
void main() { int n = readln.chomp.to!int; writeln(800 * n - n / 15 * 200); } 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.typecons; import std.ascii; import std.uni;
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.stdlib; void main() { auto N = readln.chomp.to!long; long[] F; for (long i = 1; i * i <= (N - 1); ++i) { if (...
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
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 core.stdc.stdio; long gcd(long a,long b){ return b?gcd(b,a%b):a; } long lcd(long a,long b){ return a/gcd(a,b)*b; } void main(){ while(1){ int n; scanf("%d",&n); if(!n) break; auto p=new long[n],q=new long[n]; auto r=new int[n],b=new int[n],ic=new int[n]; foreach(i;0..n){ scanf("%lld%lld%d%d",&p...
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, H = data[0].to!uint, W = data[1].to!uint; uint[501][501] coin; foreach (i; 0 .. H) foreach (j, a; readln.split.to!(uint[])) { coin[i][j] ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long[10^^6+50] F, RF; long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * x) % P; x = x^^2 % P; n /= 2; } return y; } long inv(long x)...
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.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; long[][] factor(long n) { if (n == 1) return [[1, 1]]; long[][] res; if (n % 2 == 0) { int k = 0; w...
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.stdio, std.algorithm, std.conv, std.array, std.string; void main() { readln; auto s = readln.chomp; string k; string kk; string l; int p; foreach (c; s) { switch (c) { case '(': if (!p++) { kk ~= k; k = ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto s = readln.chomp.to!(dchar[]); s[3] = '8'; writeln(s); }
D
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math; struct UFTree(T) { struct Node { T parent; T rank = 1; } /// this(T n) { nodes.length = n; sizes.length = n; foreach (i, ref node; nodes) { ...
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 lim = 24 * 3600 + 1; void main() { while (true) { int n; s...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); //aryread!string(); void main() { auto s = sread(); // writeln(s); // writeln(s[0 .. (s.length) / 2]); // writeln(s[(s.length) / 2 .. $]); foreach (i; 2...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.functional; void main() { int n = readln.chomp.to!int; int[] a = readln.split.to!(int[]); int k = a.reduce!min, m = a.reduce!max; if (m - k > 1) { writeln("No"); return; ...
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 tt = readln.split.to!(long[]); auto T1 = tt[0]; auto T2 = tt[1]; auto aa = readln.split.to!(long[]); auto A1 = aa[0]; auto A2 = aa[1]; auto bb = readln.split.to!(long[])...
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
void main(){ int[] n = _scanln(); foreach(i; 0..n[0]+1 ){ if(n[1] == 2*i + 4*(n[0]-i)){ writeln("Yes"); return; } } writeln("No"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = in...
D
import std.stdio; import std.string; import std.conv; import std.array; void main() { int num; num = chomp(readln()).to!int; string[][4] card; for(int i = 0; i < num; ++i){ string[] tmp = split(chomp(readln())); if(tmp[0] == "S") card[0] ~= tmp[1]; else if(tmp[0...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long[10^^5+50] F, RF; void init() { F[0] = F[1] = 1; foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P; { RF[$-1] = 1; auto x = F[$-1]; auto k = P-2; ...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { string s; s = readln().chomp; int n = s.length.to!int; if (s[n-1] == '1') { writeln(-1); return; } if (s[0] == '0') { writeln(-...
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; import std.random; import std.datetime.systime : Clock; class InputReader { private: ubyte[] p; ubyte[] buffer; si...
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!(int[]); auto A = nab[1]; auto B = nab[2]; writeln(A%2 == B%2 ? "Alice" : "Borys"); }
D
import std.algorithm, std.string, std.array, std.range, std.stdio, std.conv; void main() { string[] n = readln.chomp.split(""); if (n[0] == n[2]) { writeln("Yes"); } else { writeln("No"); } }
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.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional, std.traits; import std.algorithm, std.container; void main() { long A = scanElem; long B = scanElem; long C = scanElem; if(A>B)swap(A,B); if(A<C&&C<B){ writeln(...
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; } void main(){ long a = read....
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; 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; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); //aryread!string(); //auto PS = new Tuple!(long,string)[](M); //x[]=1;でlong[]全要素1に初期化 void main() { auto o = sread(); auto e = sread(); auto s = (o.length) + (e...
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; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum inf3 = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; enum lim = 2 * 10^^5; void main() { auto s = eratos(lim); au...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.container; import std.bigint; import std.math; void main() { auto n = readln.chomp.to!int; foreach (i; 1..n+1) { auto x = i; if (x % 3 == 0) { write(" ", i); continue; } while (x) { ...
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.string,std.conv,std.array; void main(){ int[4][] data; for(int i=0;;i++){ auto rd = readln().chomp(); if(rd){ data.length = i+1; auto abcd = split(rd); data[i][0] = to!int(abcd[0]); data[i][1] = to!int(abcd[1]); data[i][2] = to!int(abcd[2]); data[i][3] = to!int(abcd[3]); }...
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; int[] xs, ys; foreach (_; 0..N) { auto rc = readln.split.to!(int[]); xs ~= rc[1]; ys ~= rc[0]; } xs.length = 8; ys.length = ...
D
void main(){ string s = readln().chomp(); char tmpc; foreach(ch; s){ if(tmpc == ch){ writeln("Bad"); return; } tmpc = ch; } writeln("Good"); } 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.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 N = readln.chomp.to!long; long a = 0; long b = 0; foreach (i; 0..10^^6) { b += 1...
D
void main() { long[] tmp = rdRow; long n = tmp[0]; long a = tmp[1], b = tmp[2], c = tmp[3], d = tmp[4]; string s = rdStr; bool ok = !s[a..max(c, d)].canFind("##"); if (c > d) ok &= s[b-2..d+1].canFind("..."); writeln(ok ? "Yes" : "No"); } T rdElem(T = long)() { //import std.stdio : re...
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.algorithm, core.bitop; void main(){ int A, B, K, ans; scanf("%d%d%d", &A, &B, &K); foreach(bit; 0..1<<10)if(popcnt(bit) <= K){ ans = max(ans, test(A, B, bit)); } writeln(ans); } int test(int A, int B, int bit){ int carry = 0, ten = 1, C = 0; for(;A;A/=10, B/=10, ten*=10, bit>>=1){ int...
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, M = data[1].to!int, C = data[2].to!int; auto B = readln.split.to!(int[]); int ans = 0; foreach (i; 0 .. N) { ...
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.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; long calc(int h, int w)...
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.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 k, s; readV(k, s); auto ans...
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; int[] ss, ls, ps; foreach (_; 0..N) { auto slp = readln.split.to!(int[]); ss ~= slp[0]; ls ~= slp[1]; ps ~= slp[2]; } au...
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 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; import core.bitop; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () => readln.chomp.to!(T); alias aryread(T = long) = () => readln.split.to!(T[]); alias Pair = Tuple!(long, "x", long, "c"); alias PQueue(T, alias less = "a>b") ...
D
void main() { string s1 = readln.chomp; string s2 = readln.chomp; string s3 = readln.chomp; writeln(s1[0], s2[1], s3[2]); } 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 s...
D
import std.algorithm; import std.array; import std.range; import std.conv; import std.stdio; import std.string; import std.typecons; alias FairyPos = Tuple!(int,int); void main(){ auto blue_num = readln.chomp.to!int; string[] blues; foreach(i; iota(0, blue_num)) { blues ~= readln.chomp; } ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; void main() { auto N = readln.chomp.to!long; auto AS = readln.split.to!(ulong[]); long[61][] CS; CS.length = N; foreach_reverse (i; 0..N) { foreach (j; 0..61) { ...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, core.bitop; int r, c; int[] sb; void main() { string s = readln.chomp; int n = s.length.to!int; bool[] e = new bool[](26); foreach (ch ; s) { e[ch - 'a'] = 1; } if (e.count(1)...
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(D...
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.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() { string s; readV(s); auto b = new bool[](26); foreach (c; s) b[c-'a'] = true; foreach...
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; enum inf3 = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; enum L = 2001; void main() { int n, k; scan(n, k); aut...
D
void main() { string s = readln.chomp; long n = s.countUntil('C'); long m = -1; if (n != -1) { m = s[n+1..$].countUntil('F'); } writeln(m != -1 ? "Yes" : "No"); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import...
D
void main() { problem(); } void problem() { const S = scan; auto N = S.length; long solve() { if (N < 4) return 0; const P = 2019; long ans; auto cs = new long[](P); cs[0] = 1; long x, t = 1; foreach_reverse (c; S) { x = ((c-'0').to!long * t + x) % P; t = (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 n; scan(n); auto a = iota(n).map!(i => readln.chomp.to!int).array; foreach (s ; 0 .. 1<<n) { int deg; foreach ...
D
/+ dub.sdl: name "D" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); int n; long k; sc.read(n, k); long[] a = new long[n]; long[] b = new long[n]; fore...
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() { auto n = readln.chomp.to!int; bool[string] cnt; foreach (_; 0...
D
import std.stdio; import std.string; import std.conv; int main() { int[string] hash; int n = to!int(readln.chomp); string[] s = readln.chomp.split; foreach (ref c; s) { hash[c]++; } writeln(hash.length == 3 ? "Three" : "Four"); return (0); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; import core.bitop; alias H = Tuple!(int, "r", string, "s"); void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; long[H] ls, rs; foreach (b; 0..(1<<N)) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { writeln(readln.to!(wchar[]).count!(c => c == '1')); }
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable ip = readln.split.to!(ulong[]); immutable n = ip[0], m = ip[1]; auto ls = new ulong[m]; auto rs = new ulong[m]; for(ulong i = 0; i...
D