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 N = readln.chomp.to!int; auto S = readln.chomp; auto T = readln.chomp; int s, t, c, max_c, d, max_d; foreach (i; 0..N) { auto s1 = S[i] == '1'; auto t1 = T[i] =...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.conv; import std.typecons; void main() { alias Point = Tuple!(int, "x", int, "y"); auto ip = readAs!(int[]), W = ip[0], H = ip[1], N = ip[2]; // 下はダメコード /*auto b = new bool[]...
D
void main() { auto N = ri; auto K = ri; ulong res = 1; foreach(i; 0..N) res = (res * 2 < res + K ? res * 2 : res + K); writeln(res); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; imp...
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, std.regex; void main() { immutable int INF = 1 << 29; auto N = readln.chomp.to!int; auto A = new int[](2*N); ...
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
// 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, std.string, std.conv; import std.typecons; import std.algorithm, std.array, std.range, std.container; import std.math; void main() { auto S = readln.split[0]; auto K = readln.split[0].to!long; foreach (c; S) { if (K == 1 || c != '1') { writeln(c); return; } else K--; } writeln(1); }
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.array,std.conv; void main(){ string[] s=split(readln()); // splitで文字列を文字列の配列に切り分け int x=to!int(s[0]); // 第0要素を整数に変換 int y=to!int(s[1]); int z=to!int(s[2]); int ans=to!int((x-z)/(y+z)); writeln(ans); }
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() { long n, m; scan(n, m); auto g = new long[][](n); // writ...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv; void main() { auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1]; if(A > 8 || B > 8) { writeln(":("); } else { writeln("Yay!"); } }
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = (...
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], a = tmp[1], b = tmp[2]; writeln(min(a, b), " ", max(0, a+b-n)); } 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 std.conv, std.stdio, std.algorithm, std.string, std.range; void main() { const input = readln.split.map!(to!int).array; if (1 <= min(input[0], input[1]) && max(input[0], input[1]) <= 9) { (input[0] * input[1]).writeln; } else { (-1).writeln; } }
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[]); auto K = S.length; int w; foreach (s; S) { if (s == 'o') ++w; } writeln(w+(15-K) >= 8 ? "YES" : "NO"); }
D
import std.stdio, std.string, std.ascii, std.algorithm; void main() { string str, tmp; while ((tmp = readln.chomp.toLower) != "") { str ~= tmp; } foreach (ab; lowercase) { writeln(ab, " : ", str.count(ab)); } }
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; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { bool[3] b;b[0]=true; foreach(s;stdin.byLine()) swap(b[s[0]-'A'],b[s[2]-'A']); foreach(i,v;b) if(v) writeln(cast(char)('A'+i)); }
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 nk = readln.split.to!(long[]); auto N = nk[0]; auto K = nk[1]; long[] AS; long max_a; foreach (a; readln.split.to!(long[])) { max_a = max(m...
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; import core.bitop; int mybsr(long x) { if (x == 0) return -1; return bsr(x); } long f(long a, long b) { if (a == 0 && b == 0) return 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
/+ dub.sdl: name "F" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; // import dcomp.container.deque; int main() { Scanner sc = new Scanner(stdin); int n; sc.read(n); long[] a; sc.read(a); int sm =...
D
void main() { long n, z, w; rdVals(n, z, w); long[] a = rdRow; long result = abs(a[$-1]-w); if (n > 1) result = max(result, abs(a[$-2]-a[$-1])); result.writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; }...
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 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; import std.algorithm; import std.array; import std.string; import std.math; import std.conv; // 昇順に並んだリスト int solve(int[] list) { if ((pow(list[0], 2) + pow(list[1], 2)) == pow(list[2], 2)) return 0; else if (list[0] == list[1]) return 1; return -1; } void main() { string line; int[] tab...
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; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void calc(string[] ss) { int rows = cast(int) ss...
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; void main() { int N; scan(N); auto a = readln.split.to!(int[]); auto...
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 l=readln.chomp; writeln(l[0],l.length-2,l[$-1]); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; long r; int k = K; while (k <= N) { ++r; k += K; } r ^^= 3; if (K % 2 == 0) { long s; k = K ...
D
void main() { int r = readln.chomp.to!int; if (r < 1200) { "ABC".writeln; } else if (r < 2800) { "ARC".writeln; } else { "AGC".writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main(){ string s; while(!(s=readln).length==0){ s=chomp(s); for(int i=cast(int)s.length-1; i>=0; i--) write(s[i]); writeln(); } }
D
void main() { auto X = ri; ulong res; if(X == 1) res = 1; foreach(i; 1..X) { debug iota(1, i+1).sum.writeln; // アホ // if(iota(i).sum < X) res++; if((i-1)*i/2 < X) res++; else break; } if(X == 2) res = 2; res.writeln; } // =================================== import std.stdio; import std.string; import...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math; void main() { string s = readln.chomp; bool can = 1; foreach(c; "abc") can &= (count(s, c) == 1); writeln(can ? "Yes" : "No"); }
D
import std.algorithm; import std.conv; import std.math; 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.splitter.map !(to !(long)).array; writeln (a.front < a.back ? "YES" : "...
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 m...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { long[] CS, xs; CS.length = 16; xs.length = 20000; auto DP = new long[][](20000, 256); for (;;) { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = ...
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.array, std.conv, std.algorithm, std.string, std.numeric, std.range; void main() { int[string] m; m["O"] = 0; m["A"] = 0; m["B"] = 0; m["AB"] = 0; string s; while( (s=readln.strip).length != 0 ){ auto as = s.split(','); m[as[1]] += 1; } writeln(m["A"]); writeln(m["B"]); writeln(m["AB"])...
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.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { readint(); auto ss = assumeSor...
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.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { auto nq = readints(); int n = ...
D
void main() { auto N = readAs!ulong; ulong res = 1; foreach(i; 0..N) { auto b = readAs!ulong; res = res / gcd(res, b) * b; } res.writeln; } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; ...
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) { foreach(i...
D
// Vicfred // https://atcoder.jp/contests/abc129/tasks/abc129_b // brute force import std.algorithm; import std.array; import std.conv; import std.math; import std.stdio; import std.string; void main() { const long n = readln.chomp.to!long; const long[] ws = readln.split.map!(to!long).array; long[] sum = ...
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
void main() { long n, m; rdVals(n, m); Edge[] edge = m.rdCol!Edge; foreach (ref e; edge) --e.from, --e.to; long[] dist = new long[n]; foreach (i; 1 .. n) dist[i] = -inf; void Bellman_Ford() { foreach (i; 0 .. n) { foreach (e; edge) { ...
D
// Cheese-Cracker: cheese-cracker.github.io void theCode(){ ll a = scan; ll b = scan; ll c = scan; ll hf = abs(a - b); ll n = 2 * hf; if(n < max(a, b, c)){ writeln(-1); }else{ ll rem = (c + hf) % n; if(rem == 0){ writeln(n); }else{ writeln...
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, "B", long, "W"); alias PQueue(T, alias less = "a>b") ...
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 a, b; readV(a, b); writeln(a...
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; void main() { int a, b, c, d, e, k; scan(a);scan(b);scan(c);...
D
void main() { import std.stdio, std.string; string s = readln.chomp; writeln("2018", s[4 .. $]); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.container; import std.array; import std.math; import std.range; import std.typecons; import std.ascii; import std.format; void main() { auto a = readln.chomp.split.map!(to!int); writeln = a[0] ^ a[1] ^ a[2]; }
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons; import core.bitop, std.datetime, std.range; void main(){ auto rd = readln.split.to!(int[]); auto n = rd[0], q = rd[1]; auto ds = new int[][](n, 1); auto n2s = iota(n).array; ...
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; void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return r...
D
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens....
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; void main() { auto N = readln.split[0].to!int; auto A = readln.split.to!(int[]); auto B = readln.split.to!(int[]); ulong ans = 0; foreach(i; 0..N) { int b = B[i]; int x; x ...
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; void main() { int n, a, b, c; scan(n, a, b, c); auto x =...
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; 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(){ while(true){ int n = readln().chomp().to!int; if(n==0) break; int ans = 100000000; for(int i=0;i<=25;i++){...
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() { auto S = readln.chomp; if (S.length == 2) { if (S[0] == '0' || S[1] == '1') { writeln(-1); } else { writeln("1 2"); } return; } if...
D
void main() { long n = readln.chomp.to!long; dchar[] s = readln.chomp.to!(dchar[]); dchar[] t = readln.chomp.to!(dchar[]); long len = 2 * n; foreach_reverse (i; 0 .. n) { if (s[i..$] == t[0..$-i]) { len = i + n; } } len.writeln; } import std.stdio; ...
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 main() { readln.chomp.pipe!(a => a...
D
import std.stdio, std.string, std.conv, std.algorithm, std.array; void main(){ while(1){ auto ffffffffff = readln.chomp.to!(int); if(ffffffffff==0) break; int a = 1000 - ffffffffff; int ans; if(a>=500){ ans++; a-=500; } if(a>=100){ ans += a/100; a -= a/100*100; } if(a>=50){ ans ++; a -= 50; ...
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, std.regex; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto D = s[1].to!long; auto A = re...
D
void main() { string[] s = readln.split(','); s.join(" ").writeln; } 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.conv, std.string, std.range, std.array, std.algorithm; import std.bigint; int[32] dp; void main() { while (true){ int n = readln().chomp().to!int; if (n == 0) break; dp[0 .. 32] = -1; int pat = shinobu(n); pat /= 10; if (pat % 10 != 0){ pat++; } writeln(p...
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
void main() { int[] ab = readln.split.to!(int[]); writeln(ab.all!"a & 1" ? "Odd" : "Even"); } 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 ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; void main() { immutable EPS = 1.0e-12; string[] input = new string[](8); while ((input = readln.chomp.split(" ")).length != 0) { auto points = input.map!(to!double); auto innerProduct = fabs((poi...
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); int ans; ...
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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; alias VDC = Tuple!(int, "v", int, "d", int, "c"); int[10^^5] MAX_D, COLS, MEMO; int[][10^^5] G; VDC[10^^5] QS; void main() { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = nm[1]; forea...
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.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.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } int calc(string s) { char[] cs; for (int i =...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.conv; void main() { (min(r, r) + min(r, r)).writeln; } int r() { return readln.chomp.to!int; }
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 x...
D
import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; import std.numeric; import std.bigint; import core.bitop; void main() { auto input = readln.split.map!(to!int); auto N = in...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () ...
D
void main() { bool[int] a; auto N = ri; foreach(_; 0..N) { a[ri] ^= true; } a.values.count!(a => a).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 st...
D
import std.algorithm; import std.array; import std.stdio; import std.conv; import std.string; void main(){ int count; foreach(Unused; 0..readln.chomp.to!int){ if(readln.chomp.to!int.isPrime){ ++count; } } count.writeln; } bool isPrime(int n){ if(n <= 1){ return ...
D
import std.stdio, std.string, std.conv; void main() { string s = readln.chomp; int[] num = new int[s.length]; int cnt; foreach (i, x; s) { if (x == 'R') { ++cnt; } else { num[i-1] += cnt / 2 + cnt % 2; num[i] += cnt / 2; cnt = 0; }...
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, K; scan(N, K); auto h = ...
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 n = lread(); auto ans = new long[](10 ^^ 5); foreach (i; 1 .. 101) { foreach (j; 1 .. 101) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; string m(string a, string b) { if (a == "T" && b == "T") return "T"; if (a == "T" && b == "F") return "F"; if (a == "F" && b == "T") return "T"; return "T"; } void main() { auto N = readln.chomp....
D
import std.stdio,std.conv,std.string; int main(){ int x; x=stdin.readln().chomp.to!int; if(x==3||x==5||x==7){ write("YES"); } else{ write("NO"); } return 0; }
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; import std.typecons; import std.math; import std.numeric; void main(){ int n = readln().chomp().to!int; int[] inputs = readln().chomp().split().map!(to!int).array(); solve(n, inputs).writeln(); }...
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 F = new long[](10^^6*2+10); auto RF = new long[](10^^6*2+10); long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main(){ auto Q=readln.split,a=Q[0],b=Q[1]; if(a==b)writeln("H"); else writeln("D"); }
D
import std.stdio; import std.algorithm; import std.string; import std.range; import std.array; import std.conv; import std.complex; import std.math; import std.ascii; import std.bigint; import std.container; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split())); } auto readInt() ...
D
import std.stdio, std.algorithm, std.string; void main() { readln(); auto s = readln().strip(); int[string] d; foreach (i; 0 .. s.length - 1) { d[s[i .. i+2]]++; } int maxCount = 0; string maxStr = ""; foreach (str, count; d) { if (count > maxCount) {...
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container, std.typecons; 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.c...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int q; scanf("%d", &q); foreach (i; 0..q) { int a, b; scanf("%d%d", &a, &b); if (a > b) swap(a,b); int l = 0, r = b; while (l+1 < r) { int x = (l+r)/2; ...
D
import std; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();} T[] aryread(T = long)(){return readln.split.to!(T[])();} void scan(TList...)(ref TList Args){auto line = readln.split(); foreach (i, T; TList){T val = line[i]...
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[] AS; foreach (_; 0..N) AS ~= readln.chomp.to!int; int[] lis; foreach (a; AS) { if (lis.empty || lis[$-1] < a) { lis ~= 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.regex : regex; import std.container; import std.bigint; void main() { auto n = readln.chomp.to!int; auto s = readln.chomp.split; int[string] cnt; for...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { foreach(s;stdin.byLine()) { auto m = s.split().map!(to!int); auto a=m[0], b=m[1], n=m[2]; int t=0; foreach(_;0..n) a=a%b*10,t+=a/b; writeln(t); } }
D