code
stringlengths
4
1.01M
language
stringclasses
2 values
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
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; calc(n).writeln; } long calc(long x) { long result = inf; for (long i = 1; i * i <= x; ++i) { if (x % i == 0) { result = min(result, i+x/i-2); } } return result; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdE...
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.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.conv; import std.array, std.algorithm, std.range; void main() { writeln(reduce!((a,_)=>(a*105+99999)/100000*1000)(100000L,iota(readln().chomp().to!long()))); }
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; void main() { ulong[] NM = readln.chomp.split.to!(ulong[]); ulong n = NM[0], m = NM[1]; ulong s, c; if (n <= m / 2) { writeln...
D
import std.string; import std.stdio; import std.conv; import std.algorithm; int[] nums = [0,1,2,3,4,5,6,7,8,9]; int n,s; int saiki(int x,int m,int item){ if(m == s && item == n) return 1; if(x == 10) return 0; return saiki(x+1,m+nums[x],item+1) + saiki(x+1,m,item); } void main(){ while(true){ aut...
D
import std.stdio; import std.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto tokens = split(chomp(readln())); auto N = to!ulong(tokens[0]); auto M = to!ulong(tokens[1]); string S = chomp(readln()); string T = chomp(readln()); ulong lcm = (N * M) / gcd(N, M)...
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; void main() { int m = readln.chomp.to!int; writeln(48 - m); }
D
import std.stdio; import std.algorithm; import std.conv; import std.string; void main() { auto k = to!int(chomp(readln())); auto a = k / 2; auto b = k / 2 + k % 2; writeln(a * b); stdout.flush(); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; int abs(int n) { return n < 0 ? -n : n; } void main() { int[] arr = readln.chomp.split.to!(int[]); bool flg = false; writeln( (abs(arr[0] - arr[2]) <= arr[3] || abs(arr[0] - arr[1]) <= arr[3] && abs(arr[1] - arr[2]) <...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.algorithm; import std.string; import std.functional; import std.array; import std.conv; import std.math; import std.typecons; import std.regex; import std.range; char[8][8] s; void bom(int x,int y){ s[y][x] = '0'; for(int dx=-3;dx<=3;dx++){ int nx = x + dx; if(0<=nx&&nx<8) i...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void solve() { auto N = readln.chomp.to!long; long x; foreach (long i; 0..32) { x += x + (2L^^i)^^2; if (N >= x) { N -= x; } 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 main() { int a, b, c, x, y; readV(a, b, c, ...
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; import std.concurrency; void main() { readln.chomp.to!int.rep!r...
D
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } ...
D
import std; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { auto s = readln.strip; auto z = count(s, '0'); auto o = s.length - z; if (z == 0 || o == 0) writeln(0); else if (o == z) if (s.length > 2) ...
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.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, std.bitmanip; int N; string S; char[] ans; bool solve() { foreach (i; 1..N-1) { auto prev = ans[(i-1+N)%N]; ...
D
import std; void main() { string s = read; string t = read; writeln(t.startsWith(s) ? "Yes" : "No"); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T=string)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } ali...
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; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; import std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ int n = read...
D
import std.stdio; import std.string; void main() { int n, k; scanf("%d %d\n", &n, &k); auto l = readln.chomp(); write(l[0..k-1] ~ l[k-1..k].toLower ~ l[k..$]); }
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
// Vicfred // https://atcoder.jp/contests/abc168/tasks/abc168_b // implementation import std.conv; import std.stdio; import std.string; void main() { int K = readln.chomp.to!int; string S = readln.strip; if(S.length > K) { S[0..K].write; "...".writeln; } else { S.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; 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
void main() { dchar[] n = readln.chomp.to!(dchar[]); dchar[] m = n.dup; reverse(m); writeln(n == m ? "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; import std.typ...
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.splitter.map !(to !(int)).array; int [] d; int i = 0; while (i < n * 2) { int ...
D
import std.stdio; import std.conv; import std.string; import core.bitop; void main() { auto N = readln.chomp.to!long; immutable march = "MARCH"; long[march.length] list; foreach (_; 0 .. N) { auto name = readln(); foreach (i, c; march) { if (name[0] == c) ...
D
import std.stdio; import std.string; import std.conv; void main() { string[] inputs = split(readln()); int A = to!int(inputs[0]); int B = to!int(inputs[1]); int C = to!int(inputs[2]); int D = to!int(inputs[3]); if(A + B > C + D) writeln("Left"); else if(A + B == C + D) writeln("Balanced"); else writeln("Righ...
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; // }}} // tbh.scanner {{{ class Scanner { import std.stdio; import std.conv : to; import std.ar...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp.to!int; foreach (_; 0..T) { readln; auto as = readln.split.to!(int[]); auto x = as[0]%2; foreach (a; as) if (x != a%2) goto ng; writ...
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.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, q; readV(n, q); string s;...
D
import std.stdio, std.string, std.conv, std.algorithm; 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; writeln(min(A, B) + min(C, D)); }
D
/+ dub.sdl: name "D" dependency "dcomp" version=">=0.7.3" +/ 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); int n = s.length.to!int; int[] sm = new int[n+1]; foreach ...
D
import std.stdio; import std.string; import std.conv; import std.math; int main() { auto digit = 0; string buf; while ((buf = strip(readln())) != null) { digit = calc_digit(buf); writeln(calc_digit(buf)); } return 0; } int calc_digit(string src) { string[] seed = split(src); ...
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 X = readln.split[0].to!(long); foreach (A; 0 .. 10^^3+1) foreach (B; 0 .. A) { if (A^^5 - B^^5 == X) { writeln (A, " ", B); return; } if (A...
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(){ string[6] ans; for(int i=1;i<=6;i++) ans[i-1] = to!char(i + '0') ~ ":"; int n = readln().chomp().to!in...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto ab = readln.split.to!(int[]); int s, i = 1; while (i <= ab[1] - ab[0]) { s += i; ++i; } writeln(s - ab[1]); }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split, a = rd[0], b = rd[1]; writeln(a == b ? "H" : "D"); }
D
import std.stdio; import std.string; import std.conv; import std.array; import std.range; void main(){ auto a=readln.chomp; auto b=readln.chomp; auto c=readln.chomp; writeln("" ~ a[0] ~ b[1] ~ c[2]); }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, m; rd(n, m); writeln((m*1900+(n-m)*100)*(1<<m)); } 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){ e=l[i].to!(typeof(e)); } }
D
/+ dub.sdl: name "D" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; long isq(long x) { long l = 0, r = 10L^^10; while (r-l > 1) { long md = (l+r)/2; if (md*(md-1) < x) l = md; else r = md...
D
import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; long solve (long [] a) { long a0 = min (a[0], 2); a[0] -= a0; long a3 = min (a[3], 2); a[3] -= a3; long a4 = min (a[4], 2); a[4] -= a4; long res = 0; res += a[1]; a[1] = 0; res += (a[0] / 2) * 2; a[0] %= 2; ...
D
import std.stdio; import std.algorithm; import std.math; import core.stdc.stdio; int[int] compCoord(ref int[] data){ data.sort; int[int] ret; int c=0; foreach(i,d;data){ if((d in ret) is null){ ret[d] = c; data[c++] = d; } } data = data[0..c]; return ret; } void main(){ while(1){ int w,h; scanf("%...
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 S = readln.chomp; auto T = readln.split.array; foreach (t; T) { if (S[0] == t[0] |...
D
import std.stdio; void main(){ for(int i = 0; i < 1000; i++) writeln("Hello World"); }
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() { int n = readln.chomp.to!int; int[] h = readln.split.to!(int[]); int hs = h[0]; int cnt = 1; foreach (i; 1 .. n) { if (h[i] >= hs) { ++cnt; hs = h[i]; } } cnt.writeln; } import std.stdio; import std.string; import std.array; import std.co...
D
import std.stdio; void main() { string input = readln(); int count; foreach(char c; input) { if(c == '1') count++; } writeln(count); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main(){ auto a=readln.chomp; writeln("ABC",a); }
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; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { auto n = lread(); auto d = aryread(); auto m = lread(); auto t = aryread(); long[long] dd; foreach (i; 0 .. n) { dd[d[i]]...
D
void main() { long n = rdElem; if (n == 1) { 0.writeln; return; } long[long] cnt; for (long i = 2; i * i <= n; ++i) { while (!(n % i)) { ++cnt[i]; n /= i; } } if (n > 1) ++cnt[n]; long m = cnt.byValue.reduce!max; ...
D
import std.stdio, std.conv, std.string; void main() { (readln.chomp.to!int < 1200 ? "ABC" : "ARC").writeln; }
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 w = sread(); // writeln(w); long[char] ary; foreach...
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
/+ 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); scope(exit) assert(!sc.hasNext); string s; sc.read(s); int n = s.length.to!int; ...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container; int n; void solve(int max_i, string prefix) { if(prefix.length == n) { writeln(prefix); return; } for(int i=0; i<max_i+1; i++) solve(max(i+1, max_i), prefix~('a'+i).to!char); } void main() { n = readln.chomp.to...
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, std.bitmanip; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; auto B = new long[](N+1); ...
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.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; void main(){ auto cin = new Cin(); auto S = cin.rect!(char[],"")()[0]; //writeln(S); char[] c; foreach( s ; S ){ switch( s ){ case "0": c ~= "0"; break; case "1": c ~= "1"; break; case "B": c.length = 0<c.length ? c.length-1 : 0 ; break; default:break; } ...
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 N = readln.chomp.to!int; auto G = new int[][](N); foreach (i; 0..N-1) { auto s = rea...
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.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional; void main() { readln.split.to!(long[]).pipe!(tmp => max(tmp[0] - tmp[1], 0)).writeln; }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; void main(){ auto A=readln.split.to!(int[]),a=A[0],b=A[1],c=A[2]; if(a+b>=c)writeln("Yes"); else writeln("No"); }
D
void main(){ long x, a, b; scanf("%ld %ld %ld", &x, &a, &b); if(abs(x-a)>abs(x-b))writeln("B"); else writeln("A"); } 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.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
void main() { auto s = rs; auto p = rs; writeln((s ~ s).canFind(p) ? "Yes" : "No"); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.nu...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp.to!(char[]); foreach (i, c; S) { if (i%2 == 0) { if (c == 'L') { writeln("No"); return; } } else { ...
D
void main(){ int k,a,b; k = _scan(); scanf("%d %d", &a, &b); if( a<= b/k*k ) writeln("OK"); else writeln("NG"); } 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; f...
D
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
D
import std.stdio; import std.algorithm; import std.range; import std.array; import std.string; void main(){ auto num_str = readln.chop; auto check_tri = (string target){ return target[0] == target[1] && target[1] == target[2]; }; auto answer = check_tri(num_str[0..3]) || check_tri(num_str[1..4]) ? "Yes" : "No"; ...
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.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
void main() { string s = readln.chomp; writeln(s[0..4], " ", s[4..$]); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.numeric; import std.container; import std.typecons; import std.ascii; import std.uni;
D
import std.stdio; import std.range; import std.string; import std.algorithm; import std.conv; void main() { writeln(readln.find("A").retro.find("Z").source.length); }
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 ps = readln.split.to!(int[]); int d; foreach (i, p; ps) { if (i.to!int+1 != p) ++d; } writeln(d <= 2 ? "YES" : "NO"); }
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(){ string list = "abcdefghijklmnopqrstuvwxyz.?! "; while(true){ string s = readln(); if(stdin.eof()) break;...
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; /* A = 1, B = 2, C = 100, D = 100みたいなケースもある */ void main() { int t; scan(t); while (t--) { long ai, bi, ci, di; scan(ai, bi, ci, di); ...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { foreach(_; 0..readln.chomp.to!int) { readln; int up, down; auto inp=readln.split.map!(to!int); for(int i; i < inp.length-1; ++i) { up=max(inp[i+1]-inp[i],up); down=min(inp[i+1]-...
D
import std.stdio; import std.conv; import std.string; void main() { int R, G; R = readln().chomp().to!(int); G = readln().chomp().to!(int); writeln(R+(G-R)*2); }
D
import std.stdio, std.string, std.conv, std.range, std.algorithm; void main() { auto abc = readln.chomp.split.map!(to!int); if (count(abc, 5) == 2 && count(abc, 7) == 1) { "YES".writeln; } else { "NO".writeln; } }
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.algorithm; void main() { iota(2, readln.chomp.to!long+1).reduce!"a*b".writeln; }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; auto k = readln.chomp.to!int; auto x = readln.chomp.to!int; auto y = readln.chomp.to!int; if (n < k) writeln(x * n); else writeln(x * k + y * (n - k)); }
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 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.stdio; int main(){ for(int i=1;i<10;i++)for(int j=1;j<10;j++)printf("%dx%d=%d\n",i,j,i*j); return 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 inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { string s, t; scan(s); scan(t); iota(3).m...
D
import std.stdio, std.string, std.conv; long [100] L; long foo(int n) { if(L[n]==0) { L[n]= foo(n-1) + foo(n-2); } return L[n]; } void main() { int N = readln().chomp().to!(int); L[0]=2;L[1]=1; writeln(foo(N)); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int n = readln.chomp.to!int; int price = 0; int[][] apList; for (int i = 0; i < n; i++) { auto ap = readln.chomp.split.map!(to!int); int a = ap[0]; int p = ap[1]; apList ~= [a, p]; ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long n, m; rd(n); rd(m); auto k=2L, p=1L; while(k<=m) k*=2, p++; if(p<=n){writeln(m); return;} auto npow2=1L; while(n--) npow2*=2; writeln(m%npow2); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln....
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