code
stringlengths
4
1.01M
language
stringclasses
2 values
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.conv, std.algorithm, std.string; alias L = long; L M = 998244353; L[] X, D; L q(L m, L[] U){ foreach(i, u; U) if(i / m & 1 ^ U[i % m] ^ u) return u; return 1; } L t(L[] U){ L f; foreach(u; U) f = (f * 2 + u) % M; return f; } void main(){ L n = readln.chomp.to!L, b = n * 2; foreach(c; readln...
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.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(){ string s = _scan!string(); switch(s){ case "SUN": writeln(7); break; case "MON": writeln(6); break; case "TUE": writeln(5); break; case "WED": writeln(4); break; case "THU": writeln(3); break; case "FRI": writeln(2); break; case "SAT": writeln(1); break; default: break; } } import std.s...
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.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; readV(n); string s; readV...
D
import std.stdio : readln, writeln, writefln; import std.array : array, split; import std.conv : to; import std.range.primitives; import std.range : enumerate, iota, repeat, retro, assumeSorted; import std.algorithm.searching : all, any, canFind, count, countUntil; import std.algorithm.comparison : max, min, clamp; i...
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 N = readln.chomp.to!int; auto A = readln.split.map!(x => x.to!int-1).array; auto B = new int[](N); forea...
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
void main() { string[] tmp = readln.split; string a = tmp[0], b = tmp[1], c = tmp[2]; writeln(a[$-1] == b[0] && b[$-1] == c[0] ? "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.c...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; import std.math; void main() { int n; scan(n); writeln(n/3); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, k; rd(n, k); auto x=new long[](n), y=new long[](n); foreach(i; 0..n) rd(x[i], y[i]); long mn=5_000_000_000_000_000_000; foreach(i1; 0..n)foreach(i2; (i1+1)..n){ foreach(j1; 0..n)foreach(j2; (j1+1)..n){ auto x1=x[i1], x2=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 n = readln.chomp.to!int; int sum; auto tmp = n; while (tmp != 0) { aut...
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; const int BORING = 15; const int MATCH = 90; void main() { int n; int last = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); if ((x - 1) - last >= BORING) { printf("%d\n", last + BORING); return; } last = x; } printf(...
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() { string s; scan(s); int ans; ...
D
import std.stdio,std.string,std.conv,std.algorithm; import std.algorithm:rev=reverse; int main(){ auto input=readln.chomp.split; auto a=input[0].to!int; auto b=input[1].to!int; auto at=(a*13).to!int; auto bt=(b*10).to!int; foreach(y;bt..at+1){ if((y*0.08).to!int==a&&(y*0.1).to!int==b){ ...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.string; void main() { string str = readln.chomp; string[4] ss = ["dream", "erase", "eraser", "dreamer"]; // array.lengthの返り値の型はulongなので // intに代入しようとすると(dmd64 v2.070.1では)CEになる int p = str.length.to!int; while (p > 0) { ...
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; scan(n, a, b); auto mx = min(...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; long[2][10^^5+10] DP; void main() { auto L = readln.chomp.to!(char[]); DP[0][1] = 2; DP[0][0] = 1; foreach (i; 1..L.length) { if (L[i] == '0') { DP[i][1] = DP...
D
void main() { long n = readln.chomp.to!long; string s = readln.chomp; long cnt; foreach (i; 0 .. 1000) { dchar[] a =[ (i / 100 + '0').to!dchar, (i % 100 / 10 + '0').to!dchar, (i % 10 + '0').to!dchar ]; bool ok; long index; ...
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 a = readln.chomp.to!BigInt; auto b = readln.chomp.to!BigInt; if (a > b) { ...
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() { string s; scan(s); string a = "2019/04/30"...
D
import std.stdio, std.string, std.conv; immutable hurui = (int n){ bool[] table = new bool[](n + 1); table[] = true; table[1] = false; for(int i = 2; i * i <= n; ++i) { for(int j = i + i; j <= n; j += i) { table[j] = false; } } return table; }(60000); vo...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint; int count_ds(int i) { int r; while (i) { r += i%10; i /= 10; } return r; } void main() { auto N = readln.chomp.to!int; int r = int.max; foreach (i; 1..N/2+1) ...
D
import std.stdio, std.conv, std.string; void main(){ (n => n * (n + 1) / 2)(r).writeln; } int r() { return readln.chomp.to!int; }
D
import std.stdio, std.string, std.conv, std.math; void main() { writeln(readln.chomp.to!int ^^ 3); }
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.stdio, std.string, std.uni; void main() { string str = readln.chomp; foreach (x; str) { if (x.isUpper) { x.toLower.write; } else if (x.isLower) { x.toUpper.write; } else { x.write; } } writeln; }
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.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
//dlang template---{{{ import std.stdio; import std.conv; import std.string; import std.array; import std.algorithm; import std.typecons; import std.math; import std.range; // MIT-License https://github.com/kurokoji/nephele class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : ...
D
import std.stdio, std.conv, std.array, std.range, std.algorithm, std.string, std.math; void main(){ auto tmp = readln.chomp.split.to!(int[]); auto a = tmp[0], b = tmp[1]; char[100][100] field; foreach(i; 0 .. 50) foreach(j; 0 .. 100) field[i][j] = '.'; foreach(i; 50 .. 100) foreach(j; 0 .. 100) fie...
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() { int[] NK = readln.chomp.split.to!(int[]); int N = NK[0], ...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random; import std.typecons, std.functional, std.traits,std.concurrency; import std.algorithm, std.container; import core.bitop, core.time, core.memory; import std.bitmanip; import std.regex; enum INF = long....
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n, t; rd(n, t); int mn = 10 ^^ 9; foreach (_; 0 .. n) { int c, tm; rd(c, tm); if (tm <= t) { mn = min(mn, c); } } if (mn < 10 ^^ 9) { writeln(mn); } else { writeln("TLE"); } } void rd(T...)(ref T x...
D
import std.stdio,std.conv,std.string; void main() { auto a = readint(); auto b = readint(); auto h = readint(); writeln(((a+b)*h)/2); } int readint() { return to!(int)(chomp(readln())); }
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; import std.uni, std.range, std.math, std.container, std.datetime; import core.bitop, std.typetuple, std.typecons; immutable long MOD = 1_000_000_007; alias tie = TypeTuple; alias triplet = Tuple!(int, int, int); void main(){ long m, n; readVars...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { readln; int[int] as; foreach (a; readln.split.to!(int[])) as[a] += 1; int r; foreach (a, n; as) { if (n >= a) { r += n - a; } else { r += n; } } writeln(...
D
import std.algorithm; import std.conv; import std.stdio; import std.string; void main() { auto abcxy = readln.split.map!( to!int ); writeln( solve( abcxy[ 0 ], abcxy[ 1 ], abcxy[ 2 ], abcxy[ 3 ], abcxy[ 4 ] ) ); } int solve( in int a, in int b, in int c, in int x, in int y ) { auto cc = c * 2; if( a + b < cc )...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.numeric; // gcd, fft void main() { auto n = readln.chomp.to!size_t; auto t = new long[](n); foreach (i; 0..n) t[i] = readln.chomp.to!long; writeln(t.reduce!lcm); } auto lcm(long a, long b) { return a / gcd(a, b) * b; }
D
void main() { int[] a = new int[5]; foreach (i; 0 .. 5) { a[i] = readln.chomp.to!int; } int k = readln.chomp.to!int; writeln(a[$-1] - a[0] > k ? ":(" : "Yay!"); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; 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.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; 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; bool check(string s) { int index = 0; foreach (c; s) { if (c=='(') { ++index; } else { if (index == 0) { ...
D
import std.stdio, std.string, std.conv; void main() { auto S = readln.chomp.to!(dchar[]); S[3] = '8'; writeln(S); }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int a, b, c; rd(a, b, c); int[int] cnt; cnt[a]=1; if(b in cnt) writeln(c); else if(c in cnt) writeln(b); else writeln(a); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; foreach(i, ref e...
D
void main() { string s = readln.chomp[0..$-2]; ulong len = s.length / 2; while (s[0..len] != s[len..$]) { s = s[0..$-2]; --len; } s.length.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; impo...
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, k; scan(n, k); auto s = readln.cho...
D
import std.stdio; void main() { int cnt, max; foreach(c;readln) { if (c == 'A' || c == 'C' || c == 'T' || c == 'G') { ++cnt; if (cnt > max) max = cnt; } else { cnt = 0; } } max.write; }
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; } T[] AR...
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 s = readln.chomp.array; if (s.length == 3) { s.revers...
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.to!(int[]); } void calc(int n, int a, int b) { while (true) { if (a + 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() { int 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
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main(){ auto Z=readln.split.to!(int[]),a=Z[0],b=Z[1]; if((a*b)%2==0)writeln("Even"); else writeln("Odd"); }
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(int[]); auto A = ab[0]; auto B = ab[1]; writeln(B % A == 0 ? A + B : B - A); }
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; immutable long MOD = 10^^9 + 7; void main() { auto K = readln.chomp; auto D = readln.chomp.to!int; auto N = K.len...
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() { int n, w; scan(n, w); auto dp = new int[](w + 1); foreach (i ; 1 .. n + 1) { int val, wei, m; scan(val, wei, m); f...
D
import std.conv, std.stdio; import std.algorithm, std.array, std.range, std.string; void main() { immutable n = readln.chomp.to!size_t, s = readln.chomp; auto count = ['R': long(0), 'G': 0, 'B': 0]; foreach (l; s) count[l] += 1; auto answer = count['R'] * count['G'] * count['B']; 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; enum inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { string s; scan(s); writeln(s[0] == s[1] ||...
D
void main() { string x = readln.chomp; auto g = x.group.array; long slen; long len = x.length; foreach (t; g) { if (t[0] == 'S') { slen += t[1].to!long; } else { long lmin = min(slen, t[1].to!long); len -= 2 * lmin; ...
D
import std.stdio; import std.string; import std.format; 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.concurrency; import std.traits; import std.uni; import c...
D
import core.stdc.stdio; import std.typecons; import std.stdio; import std.algorithm; import std.math; void main(){ int v,e; scanf("%d%d",&v,&e); int[][] graph = new int[][v]; foreach(i;0..e){ int a,b; scanf("%d%d",&a,&b); graph[--a]~=--b; graph[b]~=a; } int[] d=new int[v]; int[] s=new int[v]; int[] t=n...
D
/+ dub.sdl: name "A" 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); string s; sc.read(s); string t = "AKIHABARA"; int cnt = 0; foreach (c; s) { ...
D
import std.stdio;import std.conv;import std.algorithm;import std.array; auto raia(){ return readln().split().map!(to!int); } //read as a int[] static const int mint =60; static const int hour = 60*mint; void main() { auto it = raia(); writeln( it[0] /hour,":",it[0]%hour/mint,":",it[0]%mint); }
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); bool[char] v; v['a']=true; v['i']=true; v['u']=true; v['e']=true; v['o']=true; int n=s.length.to!(int); foreach(i; 0..n){ if((s[i] in v)==null){ if(s[i]=='n'){ // }else{ ...
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.chomp; auto N = S.length.to!int; auto X = new int[](N+1); int[][int] Y; X[0] = 0; Y[0]...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { bool n, w, s, e; foreach (c; readln.chomp) switch (c) { case 'N': n = true; break; case 'W': w = true; break; case 'S': ...
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.array, std.conv, std.string, std.algorithm, std.range; void main() { foreach (string line; lines(stdin)) { auto d = line.chomp.to!int; int ans = 0; for (int i = d; i < 600; i += d) { ans += i * i * d; } ans.writeln; } }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int s = 0; foreach (_; 0 .. n) { int l, r; rd(l, r); s += (r - l + 1); } writeln(s); } void rd(T...)(ref T x) { import std.stdio : readln; import std.string : split; import std.conv : to; auto l = rea...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.regex; import std.range; void main() { char[] a; foreach(i; 0..3) { a ~= readln.chomp[i]; } a.writeln; }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1]; auto a = m * 1900 + (n-m) * 100; writeln(a * 2^^m); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto s = readln.chomp; int i; foreach (c; s) { if (i == 0 && c == 'C') ++i; if (i == 1 && c == 'F') ++i; } writeln(i == 2 ? "Yes" : "No"); }
D
import std.stdio; void main() { int i; for(i=0;i<1000;i++) { writeln("Hello World"); } }
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(i;0..n){t[i]=r.front.to!(ElementType!T);r.popFront;}} void readM(T...)(siz...
D
void main() { rs.count!"a == '1'".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; import std.typecons; import std.uni; import st...
D
void main(){ int n = _scan(); writeln("ABC", n); } 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; foreach(string elm; readln().chomp().split()){ ln ~= elm.to!T(); ...
D
import std.algorithm; import std.range; import std.stdio; void main(){ readln(); readln().split().retro().join(" ").writeln(); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(long[]); auto a = ab[0]; auto b = ab[1]; if (a > b) swap(a, b); long r; while (b) { r *= 10; r += a; --b; } writeln(r);...
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.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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto N = readln.chomp.to!int; auto YS = new long[](N+1); YS[] = 1; YS[0] = 0; foreach (i; 2..N+1) { long k = 1; while (i*k <= N) { YS[i*k] ...
D
import core.stdc.stdio; import std.math; import std.algorithm; import std.typecons; import std.stdio; void main(){ int n; scanf("%d",&n); long[] x=new long[n],y=new long[n]; foreach(i;0..n) scanf("%lld%lld",&x[i],&y[i]); alias Tuple!(long,"x",long,"y",int,"k") p; p[] ps = new p[n-1]; foreach(i;0..n){ int c;...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int q; rd(q); bool enough(long k, long n, long a, long b, long m) { return a * m + b * (n - m) < k; } while (q--) { long k, n, a, b; rd(k, n, a, b); if (b * n >= k) { writeln(-1); continue; } long ok =...
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1], c = tmp[2]; writeln(b - a == c - b ? "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.container; im...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto S = readln.chomp.to!(dchar[]); auto N = S.length; size_t i = 0, j = S.length - 1; auto a = S[0], b = S[0], c = S[$-1], d = S[$-1]; int x, y; foreach (s; S) { ++(s == '1' ? x : y); } if (!x || !...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math, std.functional, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container, std.format; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generate(()=>readln.c...
D
void main() { long n = rdElem; long[] a = 5.rdCol; long amin = a.reduce!min; long m = (n + amin - 1) / amin; writeln(m + 4); } 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 rdD...
D
void main() { long x = rdElem; long limit = 200000; auto sieve = new Prime(limit); foreach (i; x .. limit) { if (sieve.isPrime(i)) { i.writeln; return; } } } struct Prime { bool[] flags; this(long limit) { flags = makeSieve(l...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(int[]); auto A = ab[0]; auto B = ab[1]; if (A >= 13) { writeln(B); } else if (A >= 6) { writeln(B/2); } else { writeln(0); ...
D
module main; import core.stdc.stdio; int main(string[] arv) { int n; scanf("%d", &n); char [] s = new char[n]; for(int i = 0; i < n; i++) scanf(" %c", &s[i]); for(int i = 0; i < n; i++) { if(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && s[i] != 'y') printf("%c", s[i]); else { ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; void main(){ int n = readln.chomp.to!int; int[] a = readln().split().map!(to!int).array; int[] x = [0,0,0]; foreach(i; 0..n-1){ if(a[i] == a[i+1]){ x ~= i+1; } } x ~= n; ...
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.random; void main() { auto a = readln.chomp.split.map!(to!int); auto w = a[0]; auto h = a[1]; auto x = a[2]; auto y = a[3]; ...
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.conv; import std.range, std.algorithm, std.array, std.typecons; import std.math, std.numeric; void main() { int n; scan(n); char[][] ban = new char[][](n, n); iota(n).each!(i => ban[i] = readln.chomp.to!(char[])); long ans; foreach (i ; 0 .. n) { if (isS...
D