code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto ip = readln.split.to!(int[]); auto A = ip[0]; auto B = ip[1]; auto C = ip[2]; auto X = ip[3]; auto Y = ip[4]; writeln(min( X * A + Y * B, X * 2 * C + max(Y - X, 0) * B, ma...
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 n; readV(n); writeln(n%calc(n) == 0 ? "Yes" : "No"); } auto calc(int n) { int r = 0...
D
import std.stdio, std.string, std.conv; void main(){ auto AB = ri!size_t(); solve( AB[0] , AB[1] ).writeln(); return; } auto solve( size_t A , size_t B ){ if ( (B-1)%(A-1)==0 ){ return (B-1)/(A-1); } else { return (B-1)/(A-1)+1; } } T[] ri( T = size_t )(){ T[] ol; foreach( string elm ; readln().chomp...
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; void scan(T...)(ref T args) { auto line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFro...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.container.rbtree; import std.conv; import std.math; import std.stdio; import std.string; import std.traits; struct Input { int a, b; } void parseInput(T)(out Input input, T file) { with (file) with (input) { au...
D
void main() { dchar[] c1 = readln.chomp.to!(dchar[]); dchar[] c2 = readln.chomp.to!(dchar[]); reverse(c2); writeln(c1 == c2 ? "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....
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 a,b; for(int i=0;i<n;i++){ auto s =...
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 s, string t) { ulong start = 0;...
D
void main() { long n = rdElem; long[] factor = new long[n+1]; foreach (i; 2 .. n+1) { long num = i; for (long j = 2; j * j <= n; ++j) { while (num % j == 0) { num /= j; ++factor[j]; } } if (num >...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int a, b, c; rd(a, b, c); writeln(max(a * 10 + b + c, b * 10 + c + a, c * 10 + a + b)); } 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) ...
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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto M = readln.chomp.to!int; long r, n = -1; foreach (_; 0..M) { auto dc = readln.split.to!(long[]); auto d = dc[0]; auto c = dc[1]; if (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.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; 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() { strin...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto N = readln.split[0].to!ulong; ((N*(N-1))/2).writeln; }
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; bool check(long a, long b, long c) { return (c - b - a) >= 0 && 4*a*b < (c - b - ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.numeric; void main() { auto rd = readln.split.map!(to!int), x = rd[0], y = rd[1]; writeln(gcd(x, y)); }
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.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; void solve() { auto N = readln.chomp.to!int; auto S = readln.chomp; if (N == 1) { writeln("NO"); ...
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 X = readln.chomp.to!int; writeln(8 - (X-400)/200); }
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; } /* グリッド 経路数 剰余 x[i][j] = x...
D
import std.functional, std.algorithm, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv, std.math; N gcd(N)(N a, N b) if (isNumeric!N || is (N == Biglong)) { return a ? gcd(b % a, a) : b; } T read_num(T)() {...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto r = 100_000; foreach (_; n.iota) r = next(r); writeln(r); } int next(int r) { r = r + r / 20; if (r % 1000 > 0) return (r / 1000 + 1) * 1000; else return r / 1000 * 1000; }
D
import std.stdio, std.string, std.conv; import std.typecons; import std.algorithm; import std.math; void main(){ int n = readln.chomp.to!int; auto ls = readln.chomp.split.map!(to!long); long s = 0; foreach(l; ls){ s += l; } long m = 0; foreach(l; ls){ m = max(m, l); } long res = abs(2*m-s)...
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, 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; void main() { auto Q = readln.chomp.to!int; while (Q--) { int N = readln.chomp.to!int; int L = 2;...
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, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nk = readln.split.to!(int[]); readln; auto N = nk[0]; auto K = nk[1]; int c; while (N > 1) { ++c; N -= K-1; } writeln(c); }
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*2+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...
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 n; scanf("%d", &n); int[] a = new int[n+2]; foreach (i; 0..n) { scanf("%d", &a[i+1]); } int ans = 0; foreach (i; 0..n+1) { ans += abs(a[i+1]-a[i]); } f...
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, 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.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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, q; rd(n, q); auto tree=new SquareRootDecomposition(n); while(q--){ auto args=readln.split.to!(int[]); if(args[0]==0){ tree.add(args[1]-1, args[2], args[3]); }else{ writeln(tree.sum(args[1]-1, args[2])); } }...
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.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; T RD(T)() { 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 mod = pow(1...
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_003; ModComb mc; void main() { int Q; scan(Q); mc = ModComb(mod -...
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.string, std.conv, std.algorithm, std.math; void main() { int n = readln.chomp.to!int; int[] w = readln.split.to!(int[]); int l, r = w.sum; int diff = r; foreach (i; 0 .. n) { l += w[i]; r -= w[i]; if (abs(l-r) > diff) break; diff = abs(l-r); ...
D
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency; const dx = [1,0,-1,0], dy = [0,1,0,-1]; const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(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 n, m; scan(n, m); int[] d; for (...
D
void main() { auto arr = 5.iota.map!(i => ri).array; auto k = ri; if(arr.back - arr.front > k) { writeln(":("); } else writeln("Yay!"); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math;...
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
unittest { assert( [ "3", "())" ].parse.expand.solve == "(())" ); assert( [ "6", ")))())" ].parse.expand.solve == "(((()))())" ); assert( [ "8", "))))((((" ].parse.expand.solve == "(((())))(((())))" ); } import std.conv; import std.range; import std.stdio; import std.typecons; void main() { stdin.byLineCopy.par...
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { auto S = readln.chomp.to!(char[]); S[3] = '8'; S.writeln; //if(S[4] == '7'); //writeln(S[0],S[1],S[2],8,S[4],S[5],S[6],S[7],S[8],S[9],S[10]); }
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; void main(){ auto str=readln().chomp; writeln(str.length/2-str.count!(s=>s=='p')); }
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; 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.stdio, std.string, std.conv, std.algorithm, std.math; struct P { int x,y; } void main() { int n = readln.chomp.to!int; foreach(_; 0 .. n) { P[] rooms; P cur; while(true) { auto inp = readln.split.map!(to!int); if(!inp[0] && !inp[1]) break; ...
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() { auto path = new bool[][]('I'+1, 'I'+1); foreach (i; 'A'..'I'+1) { if ((i - 'A') % 3) path[i][i-1] = 1; if ...
D
void main() { long[] tmp = readln.split.to!(long[]); long a = tmp[0], b = tmp[1], c = tmp[2], k = tmp[3]; writeln(k & 1 ? b - a : a - b); } 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.contain...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; int main() { while (true) { int n = readln().chomp().to!int(); if (n == 0) break; //writeln(dfs(0,0,0,n)); int p = 9999999; for (int i = 0; i <= 25 && i * 200 <= n; i++) { for (int j = 0;...
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.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() { long n = rdElem; long[][] list = new long[][](10, 10); foreach (i; 1 .. n+1) { long f = i.to!string[0] - '0'; long b = i % 10; ++list[f][b]; } long result; foreach (i; 0 .. 10) { foreach (j; 0 .. 10) { result += list[i][...
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; int n; string s, t; void main() { scan(n); scan(s); scan(t); int ans = n; while (!s.empty) { i...
D
import std.stdio; int n; short[] a; ulong sumW() { ulong sum; for (size_t i = 0; i < 2 * n; i += 2) sum += a[i]; return sum; } size_t j, k, t; short maxH() { short max; for (size_t i = 1; i < 2 * n; i += 2) if ((a[i] > max) && (i != j)) { max = a[i]; k = i; } if (t < 1) j = k; ++t; re...
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, c; readV(a, b, c); wri...
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.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFE...
D
void main() { int[] tmp = readln.split.to!(int[]); int l = tmp[0] + tmp[1], r = tmp[2] + tmp[3]; if (l > r) { "Left".writeln; } else if (l == r) { "Balanced".writeln; } else { "Right".writeln; } } import std.stdio; import std.string; import std.array; import std.conv; im...
D
import std.stdio; import std.string; import std.range; import std.conv; void main() { auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1]; if(a*b%2 == 1){ writeln("Odd"); }else{ writeln("Even"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto N = readln.chomp.to!int; int cnt; foreach (n; 1..N+1) { if (n % 2 == 0) continue; int y; foreach (x; 1..n+1) { if (n % x == 0) ++y; } if (y == 8) ...
D
import std.stdio, std.conv, std.array, std.string; import std.algorithm; import std.container; void main() { auto a = readln.chomp.to!int; auto s = readln.chomp; writeln(a >= 3200 ? s : "red"); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ps = new bool[](10^^5+1); ps[] = true; ps[0] = ps[1] = false; foreach (i; 3..10^^5+1) if (ps[i]) { if (i%2 == 0) { ps[i] = false; continue; }...
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() { long n = readln.chomp.to!long; long f = long.max; for (long i = 1; i * i <= n; ++i) { if (n % i == 0) { long a = i.log10.to!long + 1; long b = log10(n/i).to!long + 1; f = min(f, max(a, b)); } } f.writeln; } import std.s...
D
import std.algorithm; import std.array; import std.bigint; import std.bitmanip; import std.conv; import std.math; 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 ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.math; auto s=readln.chomp.to!(char[]); char[] t; foreach(c; s)if(c!='x') t~=c; bool ok=true; foreach(i; 0..(t.length/2)) ok&=(t[i]==t[$-i-1]); if(!ok){writeln(-1); return;} int cnt=0; int[] y; foreach(c; s){ if...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, 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_rd[0]; s_rd....
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b, c, d; scanf("%d %d %d %d ", &a, &b, &c, &d); writeln(min(a,b) + min(c,d)); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv :...
D
void main() { long n = rdElem; string[] s = 2.rdCol!string; dchar[] vh = new dchar[n]; long result = 1L; long pos; while (pos < n) { if (s[0][pos] == s[1][pos]) { vh[pos] = 'v'; if (pos > 0) { if (vh[pos-1] == 'v') result *...
D
import std.stdio; import core.stdc.stdio; import std.algorithm; int n,m; int[][] map; int ans=0; void DFS(int y,int x,int count){ map[y][x] = 0; int[] dx=[0,-1,0,1]; int[] dy=[-1,0,1,0]; for(int k=0;k<4;k++){ int ny = y+dy[k]; int nx = x+dx[k]; if(0<=ny&&ny<n&&0<=nx&&nx<m&&map[ny][nx] == 1) DFS(ny,nx,cou...
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() { _lazy[] = NIL; _maxi[] = int.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.string, std.array, std.conv; struct Dice6 { int[string] dice6; int[] _dice6 = new int[6]; this(int[] _dice6) { dice6["top"] = _dice6[0]; dice6["front"] = _dice6[1]; dice6["right"] = _dice6[2]; dice6["left"] = _dice6[3]; dice6["back"] = _dice6[4...
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]); int[int] cnt; foreach(e; a){ if(e in cnt) cnt.remove(e); else cnt[e]=1; } writeln(cnt.length); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv...
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 k, int[] ...
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; void main() { auto s = readln.split.map!(to!long); auto H = s[0]; auto W = s[1]; if (H % 3 == 0 || W % 3 == 0) { w...
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
// 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, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; void main(){ int n, m, q; readVars(n, m, q); auto s = new int[][](n, m); foreach(i ; 0 .. n){ auto line = readln.c...
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; void main() { auto N = readln.chomp.to!int; auto A = N.iota.map!(_ => readln.spli...
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; void main() { int n; scan(n); auto ans = read...
D
/+ dub.sdl: name "C" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.math; // import dcomp.foundation, dcomp.scanner; int main() { auto sc = new Scanner(stdin); int n; long[] a; sc.read(n, a); auto s = a.sum; long ans = 10L^^18; long u ...
D
import std.stdio;void main(){writeln(cast(char)(readln[0]+1));}
D
unittest { assert( [ "H H" ].parse.expand.solve == "H" ); assert( [ "D H" ].parse.expand.solve == "D" ); assert( [ "D D" ].parse.expand.solve == "H" ); } import std.conv; import std.range; import std.stdio; import std.typecons; void main() { stdin.byLineCopy.parse.expand.solve.writeln; } auto parse( Range )( R...
D
import core.stdc.stdio; import std.traits; import std.algorithm; import std.typecons; import std.stdio; int[][] wall; bool[][][] pass; int[][][][] dist; int[][][] buf; int[] dx=[0,-1,0,1]; int[] dy=[-1,0,1,0]; static immutable int inf=114514; int w,h; void Clear(T,U)(ref T t,U u){ static if(isArray!T) foreach(re...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.to!(int[]); } void main() { int[string] a, b; { int n = readint(); foreach (i; 0..n) { a[read...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.range; auto str=readln.chomp.to!(char[]); int[char] cnt; foreach(c; str){ if(!(c in cnt)) cnt[c]=1; } bool g(char[] s){ char tg=s[0]; bool ok=true; foreach(c; s) ok&=(c==tg); return ok; } int f(char ...
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; void main() { while (1) { auto x = readln.chomp.split.map!(to!int); if (x[0] == 0) break; int res; foreach (i; 1...
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 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 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, std.datetime; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generat...
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 nk = readln.split.to!(long[]); auto N = nk[0]; ulong K = nk[1]; long[31] rs; foreach (_; 0..N) { auto ab = readln.split.to!(long[]); ulong A = ab[0]; aut...
D
void main(){ auto N = readLine!long()[0]; long[string] dict; foreach( i ; 0..N ){ dict[ readln().chomp() ] = 1; } writeln(dict.length); } import std.stdio, std.string, std.conv; import std.math, std.algorithm, std.array; import std.regex; T[] readLine( T = size_t )( string sp = " " ){ T[] ol; ...
D