code
stringlengths
4
1.01M
language
stringclasses
2 values
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.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto S = readln.chomp.map!(c => c.to!(int) - '0'); auto K = readln.chomp.to!long; long pos = 1; foreach(x; S) { if (x == 1 && pos < K) { pos++; } else { ...
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, y, z; readV(x, y, z); writeln((x-z)/(y+z)); }
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.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; import std.string; import std.range; import std.algorithm; void main() { auto s = readln.chomp.retro.array; auto cands = ["dream", "dreamer", "erase", "eraser"].map!(s => s.retro.array).array; int idx = 0; while(true) { bool succ; if (idx >= s.length-1) break; foreach(cand; cands) { if (...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const tmp = readln.split.to!(long[]); auto D = tmp[0], N = tmp[1]; auto res = 100^^D; if (N < 100) res *= N; else res *= N+1; writeln(res); }
D
import std.stdio, std.range, std.conv, std.string, std.array, std.functional; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; import std.container.binaryheap; void main() { char input; scanf("%c", &input); ...
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; void main() { auto c = readMatrix!int(3, 3); (check(c) ? "Yes" : "No").writeln; } bool check(int[][] a) { return a[0][0] == a[0][1] + a[1][0] - a[1][1] && a[1][0] == ...
D
import std.stdio; void main() { long n; scanf("%ld", &n); write((n*(n-1))/2); }
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!long; long r = long.max; for (long i = 1; i^^2 <= N; ++i) { if (N%i != 0) continue; r = min(r, i-1 + N/i-1); } writeln(r); }
D
import std.stdio, std.string, std.conv, std.algorithm; void main(){ while(true){ auto input = readln.split.map!(to!int); int h = input[0], n = input[1]; if(n == 0 && h == 0) break; int[int] cube; foreach(i; 0..n){ auto line = readln.split; int a = lin...
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 h, w, n; //scan(h, w, n); scan(h); scan(w); sc...
D
import std.stdio; // readln import std.array; // split import std.conv; // to int[] dx = [1,1,1,0,-1,-1,-1,0]; int[] dy = [1,0,-1,-1,-1,0,1,1]; void main(){ string[] s = split(readln()); int h = to!int(s[0]); int w = to!int(s[1]); char[][] m = new char[][](h + 2,w + 2); for(int i = 1; i < m.length - 1; i++){ ...
D
import std.stdio,std.string,std.conv; void main(){ auto debt = 10_0000; auto week = to!int( readln().chomp() ) ; for( ; 0<week ; week-- ){ debt *= 1.05; debt += (debt%1000)?1000-debt%1000:0; } writeln(debt); }
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import ...
D
import std.stdio,std.string; void main(){ char[] str2="".dup; auto str = readln().chomp() ; foreach( c ; str ){ str2 = c~str2; } writeln(str2); }
D
import std.stdio; import std.algorithm; import core.stdc.stdio; static immutable maxM = 5000; struct t{ int idx; int len; } class State{ int[] sizes; t[][] data; this(){ sizes = new int[3]; data = new t[][3]; t[] buf = new t[3*(maxM*2+1)]; for(int i=0;i<3;i++){ data[i] = buf[i*(maxM*2+1)..(i+1)*(maxM...
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 x = readln.chomp.split.to!(int[]); if (abs(x[0] - x[2]) <= x[3] || (a...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=readln.split.to!(int[]); auto freq=new int[](n+1); int cnt=0; foreach(e; a){ if(e>n) cnt++; else freq[e]++; } for(int i=1; i<=n; i++){ if(i<freq[i]) cnt+=(freq[i]-i); else if(i>freq[i]) cnt+=freq[i...
D
void main() { string[] tmp = rdRow!string; string s = tmp[0], t = tmp[1]; writeln(t, s); } T rdElem(T = long)() { //import std.stdio : readln; //import std.string : chomp; //import std.conv : to; return readln.chomp.to!T; } alias rdStr = rdElem!string; dchar[] rdDchar() { //import s...
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.algorithm; import std.array; import std.container; import std.conv; import std.exception; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; import core.bitop; void main () { int n; while (scanf (" %d", &n) > 0) { bool...
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]), a[i]--; int cur=0, cnt=0; foreach(_; 0..n+1){ cur=a[cur]; cnt++; if(cur==1){ writeln(cnt); return; } } writeln(-1); } void rd(T...)(ref T x){ ...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to void main() { string s1 = chomp(readln()); string s2 = chomp(readln()); string s3 = chomp(readln()); int a = to!int(s1); // 第0要素を整数に変換 int b = to!int(s2); // 第1要素を整数に変換 int c = to!int(s3); // 第1要素を整数に変換 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 N = readln.chomp.to!int; auto DP = new long[][][][](4, 4, 4, N); DP[0][0][0][0] = 1; DP[0][0][1][0] = 1; DP[0][0][2][0] = 1; DP[0][0][3][0] = 1; fore...
D
void main(){ import std.stdio, std.algorithm; long n, a, b, k; rd(n, a, b, k); const long mod=998244353; const int M=1_000_00*4; long powmod(long a, long x, long mod){ if(x==0) return 1; else if(x==1) return a; else if(x&1) return a*powmod(a, x-1, mod)%mod; else return powmod(a*a%mod, x...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; import std.ascii; void main() { auto n = readln.chomp.to!int; writeln(n*800-(n/15)*200); }
D
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container; import std.math, std.random, std.bigint, std.datetime, std.format; void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE...
D
import std.stdio, std.string, std.conv, std.algorithm, std.array; void main(){ auto A = readln.chomp.to!(int); auto B = readln.chomp.to!(int); auto C = readln.chomp.to!(int); auto D = readln.chomp.to!(int); auto E = readln.chomp.to!(int); int ans; if(A<0){ ans += -A*C; A=0; } if(A==0){ ans += D; }...
D
import std.stdio; import std.string; import std.array; import std.conv; bool isRightTriangle(int a, int b, int c) { int a2 = a * a; int b2 = b * b; int c2 = c * c; return a2 + b2 == c2 || b2 + c2 == a2 || c2 + a2 == b2; } void main() { uint n = to!uint(chomp(readln())); int[][] data; for(uint i = 0; i...
D
import std.stdio, std.string, std.conv; void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], d = tmp[1]; writeln((n + 2 * d) / (2 * d + 1)); }
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons; // }}} // tbh.scanner {{{ class Scanner { import std.stdio; import std.conv ...
D
void main() { string[] tmp = readln.split('/'); string y = "2018", m = tmp[1], d = tmp[2]; writeln(y, '/', m, '/', d); } 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.type...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[10^^5] AS; void main() { auto N = readln.chomp.to!int; long r; foreach (i; 0..N) { auto A = readln.chomp.to!long; if (i != 0 && A > 0 && AS[i-1] > 0) { --A; ++...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto nk = readln.split.to!(long[]); auto N = nk[0]; auto K = nk[1]; writeln(N <= K ? 1 : 0); }
D
/+ dub.sdl: name "A" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); long a, b, c, k; sc.read(a, b, c, k); if (k % 2 == 0) { writeln(a-b); } else ...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void readC(T...)(size_t n,ref T t){foreach(ref v;t)...
D
import std; 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 n = lread(); auto s = sread(); auto t = sread(); //...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); alias route...
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.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; bool calc(int a, int b,...
D
string solve(string s){ return s.replace(',',' '); } void main(){ string s = readln().chomp(); solve(s).writeln(); } 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() ); } ...
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; void main() { auto s = readln.split.map!(to!long); auto N = s[0]; auto Q = s[1]; while (Q--) { s = re...
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(){ import std.stdio, std.string, std.conv, std.algorithm; const mx=1_000_00+5; auto isPrime=new bool[](mx); auto sub=new int[](mx); isPrime[2]=true; for(int i=3; i<=1_000_00; i+=2){ for(int j=3; j*j<=i; j+=2){ if(i%j==0) goto hell; } isPrime[i]=true; if(isPrime[(i+1)/2]) su...
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 n = readln.chomp.to!int; bool include3(int x) { for (; x > 0; x /= 10) if (x % 10 == 3) retu...
D
import std; void main() { readln; auto S = readln.split[0].to!string; auto N = S.length; size_t[][char] rgb; rgb['R'] = [], rgb['G'] = [], rgb['B'] = []; foreach (n, c; S) { rgb[c] ~= n; } size_t ans; ans += rgb['R'].length * rgb['G'].length * rgb['B'].length;...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { int[] a; for (int i = 0; i < 4; i++) { a ~= readln.chomp.to!(int); } writeln(min(a[0], a[1]) + min(a[2], a[3])); }
D
// Vicfred // https://atcoder.jp/contests/abc176/tasks/abc176_c // greedy import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { long n = readln.chomp.to!long; long[] a = readln.split.map!(to!long).array; long last = a[0]; long ans = 0; for(int...
D
import std.algorithm, std.array, std.conv, std.stdio, std.string; void main() { readln; auto l = readln.chomp; l.count("ABC").writeln; }
D
import std.stdio; import std.string; import std.conv; import std.array; void main() { string s; string op = "+"; int res = 0; while(1) { s = readln(); int a = to!int(chomp(s)); if(op[0] == '+') res += a; else if(op[0] == '-') res -= a; else if(op[0] == '*') res *= a; else res /= a; op =...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto hmk = readln.split.to!(int[]); auto h1 = hmk[0]; auto m1 = hmk[1]; auto h2 = hmk[2]; auto m2 = hmk[3]; auto K = hmk[4]; auto s = h1 * 60 + m1; auto e = h2 * 60 + m2...
D
import std.stdio, std.string, std.array, std.conv; void main() { int[] a = readln.chomp.split.to!(int[]); if (a[0] < a[1]) { "a < b".writeln; } else if (a[0] > a[1]) { "a > b".writeln; } else { "a == b".writeln; } }
D
import std.stdio; import std.string; import std.array; import std.conv; uint figure(uint num) { if(num == 0) return 0; else return figure(num / 10) + 1; } void main() { string[][] inputs; while(true) { auto s = readln(); if(stdin.eof()) break; else inputs ~= split(s); } foreach(input; inputs)...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto n = readln.chomp.to!int; auto as = readln.split.to!(int[]); int even_cnt; int quart_cnt; foreach (a; as) { if (!(a&1)) { ++even_cnt; if (!(a&2)) ++quart_cnt; ...
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 chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import ...
D
import std.stdio, std.string, std.conv; void main() { int n = readln.chomp.to!int; int[] a = [1, 5, 10, 25]; int coin = 0; foreach_reverse (x; a) { coin += n / x; n %= x; } coin.writeln; }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { int a, b; scan(a, b); int n = b - a; int ans = n * (n - 1) / 2 - a; writeln(ans); } void...
D
import std.stdio; import std.string; import std.conv; void main() { string[] inputs = split(readln()); bool a = inputs[0] == "H"; bool b = inputs[1] == "H"; if(a == b) 'H'.writeln; else 'D'.writeln; }
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() { for (...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { string s; s = readln.chomp; auto cnt = new int[](26); foreach (ch ; s) { cnt[ch - 'a']++; } int odd; foreach (i ; 0 .. 26) { if (cnt[i] & 1) odd++; } if (odd > 1) ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp; auto DP = new long[](2019); DP[0] = 1; int n, d = 1; foreach_reverse (c; S) { n = ((c - '0').to!int * d + n) % 2019; (d *= 10) %= 2019; ...
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(){ int r, g, b; scanf("%d %d %d", &r, &g, &b); ( (100*r+10*g+b)%4?"NO":"YES").writeln(); } 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行に同一型の複数入力...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.math; void main() { char[] s = readln.chomp.to!(char[]); int k; scan(k); foreach (i ; 0 .. s.length.to!int - 1) { if (s[i] == 'a') continue; int t = 26 - (s[i] - 'a'); if (t <= k) { ...
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 N = readln.split[0].to!int; auto H = readln.split.to!(int[]); int ans; foreach (i, height; H) { bool flag = true; foreach (h; H[0..i]) if (h > height) fl...
D
/+ dub.sdl: name "E" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); scope(exit) assert(!sc.hasNext); int n; sc.read(n); long[] a = new long[n], b = new l...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto nk = readln.split.to!(long[]); auto N = nk[0]; auto K = nk[1]; writeln(N <= K ? 1 : 0); }
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 s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; auto ok = new bool[](N); ...
D
/+ dub.sdl: name "B" dependency "dcomp" version=">=0.7.4" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); int[3] cnt; string s; sc.read(s); int n = s.length.to!int; foreach (c; s) cnt[c - ...
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, k; readV(n, k); writeln(k...
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.co...
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 w = readln.chomp; int[char] cnt; foreach (e; w) { cnt[e]++; } auto f...
D
import std.stdio,std.math,std.string,std.conv,std.typecons,std.format; import std.algorithm,std.range,std.array; T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);} void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;} //END OF TEMPLATE void main(){ ulong n,k; ...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; import std.ascii; void main() { auto n = readln.chomp.map!(a=>a-'0').array; auto res = n.sum; i...
D
import std.stdio, std.string, std.array, std.conv; void main() { int n = readln.chomp.to!int; int[] a = readln.chomp.split.to!(int[]); int q = readln.chomp.to!int; int[] m = readln.chomp.split.to!(int[]); bool[] check = new bool[2001]; foreach (i; 0 .. 1<<n) { int sum = 0; forea...
D
import std.conv,std.string,std.stdio; void main(){ immutable x=readln().chomp().to!int(); writeln(x*x*x); }
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 x = readln.chomp.split.to!(int[]); auto s = readln.chomp; auto ab = x[1] + ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); alias Point...
D
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional; void main() { auto tmp = readln.split.to!(int[]); writeln(abs(tmp[0] - tmp[1]) < abs(tmp[0] - tmp[2]) ? "A" : "B"); }
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, q, com, x, y; void main() { scan(n, q); auto sg = SegTree(n); while (q--) { scan(com, x, y); ...
D
void main() { long k = rdElem; long a, b; rdVals(a, b); foreach (i; a .. b+1) { if (i % k == 0) { "OK".writeln; return; } } "NG".writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; enum double eps = 1.0e-9; T rdElem(T = long)() ...
D
import std.stdio; import std.string; import std.conv; void main(){ string[] input = split(readln()); int x = to!int(input[0]); int y = to!int(input[1]); writeln(x * y, ' ', 2 * (x + y)); }
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; immutable mod = 10^^9 + 7; void main() { int n, m; scan(n, m); auto adj = new bool[][](n, n); foreach (i ; 0 .. m) { int ai, bi; scan(ai, bi); ...
D
import std.stdio; import std.string; import std.conv; void main(){ auto a = readln.chomp.to!int; auto b = a % 10; auto c = a / 10 % 10; auto d = a / 100 % 10; auto e = a /1000 % 10; writeln(b==c&&c==d||c==d&&d==e ? "Yes":"No"); }
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void readC(T...)(size_t n,ref T t){foreach(ref v;t)...
D
import std.stdio, std.conv, std.string; void main() { uint n = readln.strip.to!int; writeln(n & 1 ? n / 2 + 1 : n / 2); }
D
import std.string; import std.stdio; import std.conv; import std.algorithm; import std.typecons; void main() { int n, q; int[][int] map; scanf("%d %d\n", &n, &q); int[] cnts, checks; cnts = new int[n+1]; checks = new int[n+1]; foreach(i;0..n-1) { int a, b; scanf("%d %d\n", &a, &b); map[a] ~= b; } foreac...
D
void main() { dchar[] s = rdDchar; dchar[] t = rdDchar; long pos = t.length - 1; bool ok; foreach_reverse (long i, x; s) { if (x == t[pos] || x == '?') { bool check; if (i - pos >= 0) { check = true; foreach (j;...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; void main() { foreach (i; 0..7) { auto a = readln.split.map!(to!int); writeln(a[0] - a[1]); } }
D
import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; void main() { int[] t = map!(to!int)(split(readln())).array; int[] checker = [0,0]; for(int i=0;i < 3;i ++) { if(t[i] == 5) { checker[0] ++; } else { checker[1] ++; } } if(checker[0] == 2 && checker[...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
import std.stdio, 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, core.stdc.stdlib; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp.map!(c => c.to!int).array; ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.typecons; void main() { auto input = map!(to!int)(readln.split); int N = input[0], T = input[1], H = input[2], L = input[3]; Tuple!(int, int)[] data; foreach (i; 0..N) { input = map!(to!int)(readln.split); auto t = input[0],...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; void main(){ auto a=readln.chomp.to!int; auto b=readln.chomp.to!int; auto c=readln.chomp.to!int; writeln((a-b)%c); }
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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const tmp = readln.split.to!(long[]); const A = tmp[0], B = tmp[1]; // f(A,B) = AからBまでのすべての整数のxor // 各bitでもとめる // 1bit目はAからBまでのうち1のbitが奇数個なら1、偶数個なら0を返す // これは交互に来るから、結局(B-A+1)が奇数個...
D