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, std.container, std.range; void main() { auto N = readln.chomp.to!int; writeln((N+999)/1000 * 1000 - N); }
D
void main() { long n = readln.chomp.to!long; long[5] cnts; string t = "MARCH"; foreach (i; 0 .. n) { string s = readln.chomp; foreach (j, x; t) { if (x == s[0]) ++cnts[j]; } } long result; foreach (i; 0 .. 3) { foreach (j; i+1 .. ...
D
void main() { int n = readln.chomp.to!int; int h = readln.chomp.to!int; int w = readln.chomp.to!int; writeln((n - h + 1) * (n - w + 1)); } 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.con...
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.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { iota(1, readln.chomp.to!(int)+1).count!(x => x % 2 == 1 && iota(1,x+1).count!(i => x % i == 0) == 8).writeln; }
D
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range; pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); } alias reads = Reads!int; pragma(inline, true) void scan(Args...)(ref Args args) { string[] ss = readln.split; foreach (i, ref arg ; args) ar...
D
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; } /* 桁の数字の和 digit sum ------...
D
import std.algorithm; import std.string; import std.stdio; void main() { readln; string s = readln.chomp; if (s.length < 3) { writeln("0"); return; } auto c = count(s, 'R') * count(s, 'G') * count(s, 'B'); foreach (i;1..(s.length + 1) / 2) { for (size_t j = 0;j + i + i < s.length;++j) { if (cast(int...
D
import std.stdio, std.string; void main() { string s = readln.chomp; bool ok = true; foreach (i; 1 .. 4) { if (s[i] == s[i-1]) ok = false; } writeln(ok ? "Good" : "Bad"); }
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; void times(alias pred)(int n) { foreach(i; 0..n) pred(); } auto ...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() { auto tokens = my_readln().split(); auto N = tokens[0].to!uint; long[] a; foreach (token; my_readln.sp...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto x = readln.chomp.to!long; long r = x / 11L * 2; if (x%11L >= 7) { r += 2; } else if (x%11L >= 1) { r += 1; } writeln(r); }
D
import std.functional, std.algorithm, std.container, std.typetuple, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; void main() { auto ip = readln.split.to!(int[]); if(ip[0] == ip[1]) writeln("a ==...
D
import std.stdio; import std.conv; import std.string; import std.math; import std.array; void main(){ int N = readln().chomp().to!int(); int[] nums; int[] primes; for(int i = 0; i < N; i++){ nums ~= readln().chomp().to!int(); } foreach(int n; nums){ bool isPrime = true; for(int 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[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { auto n = lread(); auto x = new long[](10 ^^ 6 + 10); foreach (i; 1 .. 101) { foreach (j; 1 .. 101) { foreach (k; ...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; import std.array; int n; rd(n); auto a = readln.split.map!((s) => (s == "T" ? 1 : 0)).array; int f(int x, int y) { return (x - y <= 0); } // auto t = f(a[0], a[1]); foreach (i; 2 .. n) { t = f(t, a[i]); } if (t) { ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { writeln(readln.chomp.to!int.among(7,5,3) ? "YES" : "NO"); }
D
import std.stdio, std.conv, std.algorithm, std.string, std.container; void main(){ SList!int list; while(true){ auto line = readln.chomp; if(line.length == 0){ break; } auto input = line.to!int; if(input){ list.insertFront(input); }else{ ...
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 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
void main() { string s = readln.chomp; int diff = 1000; foreach (i; 2 .. s.length) { int x; foreach_reverse (j; 0 .. 3) { x += (s[i-j] - '0') * 10 ^^ j; } diff = min(diff, abs(x-753)); } diff.writeln; } import std.stdio; import std.string; import std.arra...
D
void main() { auto c = readMatrix!char(3, 3); foreach(i; 0..3) c[i][i].write; writeln; } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.bigint; import std.numeric; import std.conv; i...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto abn = readln.split.to!(long[]); auto A = abn[0]; auto B = abn[1]; auto N = abn[2]; auto x = min(N, B-1); writeln((A*x)/B - A*(x/B)); }
D
void main() { int[] ab = readln.split.to!(int[]); writeln(ab.all!"a % 2 == 1" ? "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.container; import std.typecons;
D
import core.bitop; import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.format; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; void main() { bool[char] set; foreach (c; readln.chomp) { set[c] = true; } fo...
D
import std.stdio; import std.conv; import std.algorithm; import std.string; import std.array; void main() { int n = readln.chomp.to!int; int[] c = new int[](n), s = new int[](n), f = new int[](n); for (int i = 0; i < n - 1; ++i) { auto l = readln.chomp.split.map!(to!int).array; c[i] = l[...
D
import std.functional, std.algorithm, std.container, std.typetuple, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv, std.format, std.math; void main() { while(true){ auto ip = readl...
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; void main() { string s = readln.chomp; string t = "CF"; while (!t.empty) { if (s.empty) { w...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.math; int n, k; rd(n, k); auto a=new long[n]; auto b=new long[n]; foreach(i; 0..n) rd(a[i], b[i]); long mx=0; foreach(pos; 0..32){ long vsum=0; if(k&(1<<pos))foreach(i; 0..n){ if(a[i]&(1<<pos)) continue; ...
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
void main(){ ulong x = _scan!ulong(); ulong dep = 100; ulong yy = 0; while( 1 ){ if( dep >= x ){ yy.writeln(); return; } yy++; dep += dep/100; } } 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.conv, std.array,std.string; void main() { auto a=readln; int aa=0; if(a[0]=='1')aa++; if(a[1]=='1')aa++; if(a[2]=='1')aa++; writeln(aa); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.algorithm, std.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.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 nm=readln.split.map!(to!int).array; int[][] abs; foreach(i;0..nm[1])abs~=readln.split.map!(to!int).arra...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; ulong gcd(ulong a, ulong b) { if(b == 0) return a; return gcd(b, a % b); } ulong lcm(ulong a, ulong b) { return (a * b) / gcd(a, b); } void main() { auto input = readln.split.to!(ulong[...
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); auto x = new in...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { int a, b, c; foreach (s; readln.chomp) { switch (s) { case 'a': ++a; break; case 'b': ++b; break; case 'c': ++c; break; default: }...
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; int calc(int a) { return (a + a + 1 + a + 2 + a + 7 + a + 8 + a + 9 + a + 14 + a + 15 + a + 16) % 11; } void main() { ...
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; import std.datetime, std.bigint; int n, m; bool[] a; bool[] b; void main() { scan(n, m); a = new bool[](n + 1); ...
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; auto as = "abcdefghij"; char[] ss; ss.length = N; void solve(int i, int j) { if (i == N) { writeln(ss); return; ...
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.algorithm; import std.conv; 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.strip.map !(q{a - '0'}).array; auto b = readln.strip.map !(q{a - '0'}).array; int mex...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto N = readln.chomp.to!long; long r; foreach (i; 1..N+1) { auto d = N/i; r += d * (d+1) / 2 * i; } writeln(r); }
D
import std.stdio, std.string, std.algorithm, std.array; void main() { int t; scanf("%d", &t); getchar(); foreach(i; 0..t){ auto str = readln.strip(); string result; while (str.length > 0) { result ~= str[0]; str = str.stripLeft(str[0]); } if (result.length > 3) writeln(2); else if (result ...
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() { int[] S; int n; char last; foreach (c; readln.chomp) { if (last && last == c) { ++n; } else { if (n) S ~= n; last = c; n =...
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; immutable inf = 10^^9 + 7; int c, v0, v1, a, l; void main() { scan(c, v0, v1, a, l); int r; int cnt; whil...
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 ans = (a - 1) + (a <= b); writeln(ans); } void scan(T...)(ref T args) { import std.stdio : readln; ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto tmp = readln.split.to!(long[]); auto K = tmp[0], A = tmp[1], B = tmp[2]; if (B - A <= 2) { writeln(1 + K); } else { // A-1回最初に叩く const tataki = max(0, A-1); ...
D
module sigod.codeforces.p298C; import std.algorithm; import std.stdio; import std.string; void main() { string a = stdin.readln().strip(); string b = stdin.readln().strip(); size_t a_count = a.count('1'); if (a_count % 2 == 1) ++a_count; size_t b_count = b.count('1'); stdout.writeln(a_count >= b_count ? "YES...
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.algorithm; import std.concurrency; import std.container; import std.conv; import std.functional; import std.math; import std.meta; import std.random; import std.range; import std.stdio; import std.string; import std.traits; import std.typecons; void main() { auto input = readln.chomp.split.map!(to!long...
D
import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { while (true) { int r0, w0, c, r; scan(r0, w0, c, r); if (!r0) return; int ans; while (r0 < w0*c) { ...
D
import std.stdio; import std.string; import std.conv; void main(){ int x = readln().chomp().to!int(); writeln(x * x * x); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint; void main() { auto N = readln.chomp.to!int; int r, b; foreach (c; readln.chomp.to!(char[])) { if (c == 'R') { ++r; } else if (c == 'B') { ++b; }...
D
module main; import std.stdio; int main(string[] argv) { int n,k; scanf("%d", &n); int [] a = new int[1005]; int [] b = new int[1005]; int [] c = new int[1005]; for(int i = 1; i<=n; i++) scanf("%d:%d", &a[i],&b[i]); for(int i=1;i<=n;i++) { c[i]=a[i]*60+b[i];//printf("%d ",c[i]); } for(int i=1;i<=n;i++)...
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; 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 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; enum MAX = 1_000_100; ulong MOD = 1_000_000_007...
D
void main() { auto S = rs; int i = S[0..2].to!int; int j = S[2..$].to!int; bool YYMM = j <= 12 && 1 <= j; bool MMYY = i <= 12 && 1 <= i; if(YYMM && MMYY) writeln("AMBIGUOUS"); else if(YYMM) writeln("YYMM"); else if(MMYY) writeln("MMYY"); else writeln("NA"); } // =================================== import st...
D
module AOJ_Volume0028; import std.stdio,std.string,std.conv; int main() { int[101] count; int max; string s; while((s = readln.chomp).length != 0) { int value = s.to!int; count[value]++; } max = count[0]; foreach(i;0..100) { if(max < count[i]) max = count[i]; } foreach(i;0..100) { if(max == count...
D
import std.stdio, std.string, std.conv; void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], x = tmp[1]; int[] l = readln.split.to!(int[]); int d, cnt = 1; foreach (i; 0 .. n) { d += l[i]; if (d > x) break; ++cnt; } cnt.writeln; }
D
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], h = tmp[1], w = tmp[2]; int cnt; foreach (i; 0 .. n) { int[] ab = readln.split.to!(int[]); int a = ab[0], b = ab[1]; if (a >= h && b >= w) ++cnt; } cnt.writeln; } import std.stdio; import std.string...
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; int[] dx = [-2,-2,-2,-1,-1,0,0,1,1,2,2,2]; int[] dy = [1,0,-1,2,-2,2,-2,2,-2,1,0,-1]; int[] spx,spy; int tl; bool saiki(int x,in...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.map!(to!int), a = rd[0], b = rd[1], c = rd[2]; auto r = iota(a, b+1).count!(i => c % i == 0); writeln(r); }
D
void main(){ string s = readln().chomp(); if( s[2] == s[3] && s[4] == s[5])writeln("Yes"); else writeln("No"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = int)(){ T[] ln; forea...
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
import std.stdio, std.string, std.conv; import std.algorithm, std.array; auto solve(string S) { immutable N = S.length.to!int(); immutable s = S.map!(c=>(c-'0').to!long()).array(); auto v = new long[][](N,N); v[0][]=s; foreach(i;1..N) foreach(j;0..N-i) v[i][j]=v[i-1][j]*10+s[i+...
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 calc(string s, int...
D
import std.stdio,std.string,std.conv,std.array; void main(){ loop:for(;;){ auto rcs = readln().chomp().split(); auto a = to!int(rcs[0]); auto b = to!int(rcs[2]); final switch(rcs[1]){ case "+":writeln(a+b);break; case "-":writeln(a-b);break; case "*":writeln(a*b);break; case "/":writeln(a/b);break; c...
D
void main() { int s = readln.chomp.to!int; bool[] a = new bool[1000001]; int cnt = 1; while (!a[s]) { a[s] = true; ++cnt; if (s % 2) s = 3 * s + 1; else s /= 2; } cnt.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.al...
D
import std.stdio, std.string, std.algorithm, std.range, std.conv; void main() { // ①入力 auto N = readln.chomp.to!int; auto A = readln.chomp.to!int; // ②処理 int res = N^^2-A; // ③出力 writeln(res); }
D
import std.stdio; import std.string; import std.conv; import std.math; int main() { string s; while((s=readln.chomp).length != 0) { double value = s.to!double; double min_t = value/9.8; double just = 4.9*min_t*min_t; int number = cast(int)((just+10)/5.0); writeln(number); } return 0; }
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() { auto S = readln.strip; long res; foreach(long l;0..S.length) { foreach(long r;l..S.length) { ...
D
import std.stdio; void main(){ for(int i=1;i<=9;i++){ for(int j=1;j<=9;j++){ writeln(i,"x",j,"=",i*j); } } }
D
void main() { long x = rdElem; long result; result += x / 500 * 1000; x %= 500; result += x / 5 * 5; 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; } alias rdStr = rdElem!string; alias rdDchar...
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() { long x, y; scan(x, y); writeln(abs(x - y)...
D
import std.stdio; import std.conv; import std.array; void main() { string[] inputs = split(stdin.readln()); auto a = to!(int)(inputs[0]), op = to!(char)(inputs[1]), b = to!(int)(inputs[2]); writeln((op == '+') ? (a + b) : (a - b)); }
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; } /* まず0の耳がない場合を考える その場合は、端から...
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!int); auto N = s[0]; auto A = s[1]; auto B = s[2]; int ans = 0; int x; ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; int main(string[] argv) { int n, p1, m; scanf("%d %d %d", &n, &p1, &m); long p = p1; long [] d = new long[n + 1]; long [] t = new long[n + 1]; for(int i = 0; i < n; i++) { scanf("%lld %lld", &t[i], &d[i]); } d[n] = 1152921504606846976L; t[n] ...
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; bool solve() { auto N = readln.chomp.to!int; int pa = 0, pb = 0; bool ok = true; while (N--) { a...
D
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.regex; void main() { auto HW = readln.chomp.split.map!(to!int); auto H = HW[0]; foreach (_; 0 .. H) { auto C = readln; C.write; C.write; } }
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 r = lread(); writeln(r ^^ 2); } void scan(L...)(ref L A) { auto l = readln.split; foreach (i, T; L) { A...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp; foreach (i; 0..S.length-1) if (S[i..i+2] == "AC") { writeln("Yes"); return; } writeln("No"); }
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; } bool isPrime(int n) { if (n < 2) return ...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.typecons; import std.numeric, std.math; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; re...
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
void main() { string[] tmp = readln.split; string x = tmp[0], y = tmp[1]; if (x < y) { '<'.writeln; } else if (x > y) { '>'.writeln; } else { '='.writeln; } } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; ...
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 nm = readln.split.map!(to!int); auto co = readln.split.map!(to!int); auto dp = new int[](nm[0] + 1); dp[] = int.max; foreach (c; co) { if (c ...
D
import std.algorithm; import std.range; import std.ascii; import std.array; import std.container; import std.conv; import std.numeric; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } long modPow(long mod)(long x, long n) { if (n == 0) return 1; if (...
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 bignu...
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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
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; bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); } void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.typecons; import std.numeric, std.math; import core.bitop; string FMT_F = "%.10f"; T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.t...
D
import std.stdio; 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
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 d, g; scan(d, g); auto p = new int[](d); auto c = new int[](d); foreach (i ; 0 .. d) { scan(p[i], c[i]); } ...
D