code
stringlengths
4
1.01M
language
stringclasses
2 values
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.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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ...
D
long[long] solve(long n){ long[long] dic; for(long x=1; x^^2<=n; x++){ for(long y=1; x^^2+y^^2<=n; y++){ for(long z=1; x^^2+y^^2+z^^2<=n; z++){ dic[x^^2+y^^2+z^^2 + x*y+y*z+z*x]++; } } } return dic; } void main(){ long n = _scan!long(); auto ans = solve(n); foreach(i; 1..n+1){ ans.get(i, 0).wri...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(T = long)() ...
D
void main(){ string[] val = inln!string(); bool a = (val[0]=="H")?true:false; bool b = (val[1]=="H")?true:false; bool ans = a^b; writeln(( (a^b)==false)?'H':'D'); } 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=...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { int n = readint; int ans = 0; ...
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
// Try AtCoder /// author: Leonardone @ NEETSDKASU import std.stdio : readln, writeln; import std.string : chomp; import std.array : split; import std.conv : to; auto getVals(T)() { return readln.chomp.split.to!(T[]); } void main() { bool[char] table; foreach (ch; readln.chomp) { table...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.math; void main() { for (;;) { auto rd = readln.split, a = rd[0].to!int, op = rd[1], b = rd[2].to!int; if (op == "?") break; writeln(op.predSwitch("+", a + b, "-", a - b, "*", a * b, "/", a / b)); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto S = readln.chomp.to!(wchar[]); auto w = readln.chomp.to!size_t; size_t i; while (i < S.length) { write(S[i]); i += w; } writeln(""); }
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 T = readln.chomp.to!int; while (T--) { auto s = readln.split.map!(to!long); aut...
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { int n = readln.chomp.to!int; bool[string] map; for(int i=0; i<n; i++) map[readln.chomp] = true; writeln(map.length); }
D
void main() { problem(); } void problem() { auto X = scan!ulong; ulong solve() { ulong years; real money = 100; while(money < X) { years++; money = cast(ulong)(cast(real)money * 1.01); } return years; } writeln(solve()); } // ----------------------------------------------...
D
import std.stdio, std.string, std.conv, std.math, std.regex; void main() { auto t = readln; writeln("ABC" ~ t); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[10^^5+1] MEMO; void main() { auto nm = readln.split.to!(int[]); auto N = nm[0]; auto M = nm[1]; foreach (_; 0..M) { auto lr = readln.split.to!(int[]); auto L = lr[0]-1; au...
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 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 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 D = readln.split.map!(to!int).array; auto M = readln.chomp.to!int; auto T =...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp; auto K = readln.chomp.to!int; auto DP = new long[][][](3, K+1, N.length); DP[2][K-1][0] += 1; foreach (x; 1..N[0]-'0') DP[1][K-1][0] += 1; DP[0][K][0] += ...
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.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, std.math; void main() { auto ip = readln.split.to!(int[]); if(0 <= (ip[1] - ip[2])){ writeln("delicious"); } else if(ip[0] + 1 > abs(ip[1] - ip[2])){ writeln("safe"); } else { writeln("dangerous"); } }
D
import std.stdio, std.conv, std.algorithm, std.range, std.array, std.string, std.uni; void main() { auto inp = readln.split.to!(int[]); if (inp[1] * 2 == inp[0] + inp[2]) { writeln("YES"); } else { writeln("NO"); } }
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[] a = 0~readln.split.map!(to!int).array; int ans = 0; for(int i = 1; i <= a.length; i++) if(i%2 == 1 && a[i]%2 == 1) ans += 1; ans.writeln...
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
void main() { long n = readln.chomp.to!long; string[] tmp = readln.split; string s = tmp[0], t = tmp[1]; foreach (i; 0 .. n) { write(s[i], t[i]); } writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std....
D
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; int readInt(){ return readln.chomp.to!int; } int[] readInts(){ return readln.chomp.split.to!(int[]); } void main(){ int[] nk = readInts(); int ret = nk[0] - nk[1] + 1; writeln(ret); }
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; 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; auto a = readln.chomp.split.to!(int[]); int cnt; ...
D
import std.stdio; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ int[] pasta; int[] juice; for(int i = 0; i < 3; i++){ pasta ~= readln().chomp().to!int(); } for(int i = 0; i < 2; i++){ juice ~= readln().chomp().to!int(); } writeln(pasta....
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { string[] inputs = split(readln()); int X = to!int(inputs[0]); int t = to!int(inputs[1]); max(0, X-t).writeln; }
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 fun)(int n) { foreach(i; 0..n) fun(); } auto re...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto S = readln.chomp; auto res = true; foreach(i, c; S) { auto odd = i % 2; if(!odd && !c.among('R', 'U', 'D')) res = false; if(odd && !c.among('L', 'U', 'D')) res = false; } writeln(res ...
D
// Vicfred // https://atcoder.jp/contests/abc126/tasks/abc126_b // implementation import std.algorithm; import std.conv; import std.stdio; import std.string; void main() { const int a = readln.chomp.to!int; const int yy = a / 100; const int mm = a % 100; if(yy >= 1 && yy <= 12) { if(mm >= 1 &...
D
import std.stdio, std.string, std.conv; void main() { auto AB = readln.split.to!(int[]); auto A = AB[0], B = AB[1]; A = (A + 11) % 13; B = (B + 11) % 13; if (A < B) writeln("Bob"); else if (A > B) writeln("Alice"); else writeln("Draw"); }
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, m; foreach (i; 0..n) { auto p = readln...
D
import std.stdio; void main(){ auto n=readln(); if(n[0]==n[1]&&n[1]==n[2]) writeln("Yes"); else if(n[1]==n[2]&&n[2]==n[3]) writeln("Yes"); else writeln("No"); }
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto s = readln.chomp; auto t = readln.chomp; auto idx = new ulong[][256]; foreach(i, c; s) { idx[c] ~= 1 + i; } long f() { ulong l,j; foreach(c; t) { if(idx[c].length == 0) return...
D
import std.stdio, std.range, std.conv, std.string; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; int calc(int time, int[] n) { if(n.length==0) { return time; } while(time%10!=0) { ...
D
// import chie template :) {{{ static if (__VERSION__ < 2090) { import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip, std.numeric; } else { import std; } // }}} // nep.scanner {{{ class Scanner { ...
D
import std.stdio; import std.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto n = to!int(chomp(readln())); int result; while (true) { auto a1 = n / 100; auto a2 = (n / 10) % 10; auto a3 = n % 10; if (a1 == a2 && a1 == a3) { result = n; break;...
D
import std.stdio,std.conv,std.string; void main(){ auto s=readln.chomp; if(s[2]==s[3]&&s[4]==s[5]) "Yes".writeln; else "No".writeln; }
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() { int r = readln.chomp.to!int; int g = readln.chomp.to!int; writeln = (g ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void get(Args...)(ref Args args) { import std.traits, std.meta, std.typecons; static if (Args.length == 1) { alias Arg = Args[0]; static if (isArray!Arg) { ...
D
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv, std.typecons, std.math, std.container, std.format, std.numeric; void main(string[] args) { string s = readln.strip; string t = readln.strip; long cnt = 0; foreach (i; 0 .. s.length) { if (s[i] != t[i]) ...
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; import std.conv; import std.string; void main() { int[] a;// = to!( int[] )( readln.chomp() ); for(;a.length<4;)a~= to!( int )( readln.chomp() ); writeln(a[0] > a[1] ? a[1] * a[2] + (a[0] - a[1]) * a[3]:a[0] * a[2]); }
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; import core.bitop : popcnt; alias Generator ...
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(string s, st...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.format; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 =...
D
import std.stdio; void main() { foreach(i;1..10) foreach(j;1..10) writeln(i,"x",j,"=",i*j); }
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 ss = new string[](N); auto ts = new int[](N); foreach (i; 0..N) { auto st = readln.split; ss[i] = st[0]; ts[i] = st[1].to!int; ...
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.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(); } bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); } voi...
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.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
//prewritten code: https://github.com/antma/algo import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; int f (int x) { return (x * (x - 1) ) / 2; } void main() { int n = readln.strip.to!int; int[26] c; foreach (i; 0 ...
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
module main; import core.stdc.stdio; int main() { int n; scanf("%d", &n); int [] a = new int[n]; int [] b = new int [n]; int k = 1, id = 0; a[0]=-1; for(int i = 1; i <= n; i ++) { scanf("%d", &a[i]); if(a[i] == a[i - 1]) k ++; else { if(i != 1) { id ++; b[id] = k; k = 1; } } } ...
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; immutable long mod = 10^^9 + 7; void main() { long n, m, k; scan(n, m, k); if (n > m) swap(n, m); long ans = powmod(2, n - 1, mod); ans = powmod(ans...
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 File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(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[] aryread(T = long)(){return readln.split.to!(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; void main() { int[char] aa; string alphabet = "abcdefghijkl...
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.to!int; auto c = ('C' + (x / 1000)).to!char; writeln("AB" ~...
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 chie template :) {{{ static if (__VERSION__ < 2090) { import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip, std.numeric; } else { import std; } // }}} // nep.scanner {{{ class Scanner { ...
D
pragma(inline, true) void chmin(T)(ref T a, T b) { if (a > b) a = b; } int[] init() { enum INF = 1 << 28; int[] dp = new int[100010]; foreach (i; 1..100001) { dp[i] = INF; int p6 = 1, p9 = 1; while (p6 <= i || p9 <= i) { if (i - p6 >= 0) chmin(dp[i], ...
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
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.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
void main() { import std.stdio, std.string, std.conv, std.algorithm; import std.math : abs; int x, y, z; rd(x, y, z); bool plus = false, minus = false, zero = false; if (x + z > y) { plus = true; } if (x < y + z) { minus = true; } if (z >= abs(x - y)) { if ((z - abs(x - y)) % 2 == 0) {...
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.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.conv, std.stdio, std.algorithm, std.string, std.range, std.math; void main() { readln; const tako = readln.split.map!(to!int).array; const N = tako.length; int z; foreach (x; 0..N) foreach (y; x+1..N) { z += tako[x]*tako[y]; } z.writeln; }
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.string; import std.uni; import std.range; import std.algorithm; void main() { while (!stdin.eof) { auto a = readln.strip; if (a == "-") break; auto m = readln.strip.to!int; foreach ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto d=new int[](n); foreach(i; 0..n) rd(d[i]); bool ok=true; void f(){ int r=0; foreach(int i, int e; d){ ok&=i*10<=r; r=max(r, i*10+e); } } f(); reverse(d); f(); if(ok) writeln("yes"); ...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const N = readln.chomp.to!long; writeln(N*(1+(N&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; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } int calc(int[] xs) { int rec(int p, int[] buf) ...
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; void main() { while(true) { string str = readln.chomp; if (str ==...
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 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; enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;} T scan(T=long)(){return readln.chomp.to!T;} void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;} T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);} alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q...
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; ulong MOD = 1_000_000_007; ulong INF = 1_000_00...
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; import core.stdc.stdlib, core.bitop; enum MOD = pow(10,9)+7; void main() { auto S = scanString; if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S...
D
void main() { int[] tmp = readln.split.to!(int[]); int a = tmp[0], b = tmp[1]; int coin; foreach (i; 0 .. 2) { if (a > b) { coin += a; --a; } else { coin += b; --b; } } coin.writeln; } import std.stdio; import std.string; i...
D
import std.stdio, std.string, std.array; void main() { readln.replace("apple", "##").replace("peach", "apple").replace("##", "peach").write; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto a = readln.chomp.to!int; writeln(a + a^^2 + a^^3); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm: canFind; void main() { string[] inputs = split(readln()); int x = to!int(inputs[0]); int y = to!int(inputs[1]); int res_x = group(x); int res_y = group(y); if(res_x == res_y) "Yes".writeln; else "No".writeln; } ubyte group(int a) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; long[(10^^6)*2+50] F, RF; long pow(long x, long n) { long y = 1; while (n) { if (n%2 == 1) y = (y * x) % P; x = x^^2 % P; n /= 2; } return y; } long inv(lo...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array; void main(){ auto sn=readln().split(); int n,ans; n=to!int(sn[0]); ans=n/3; writeln(ans); }
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.typecons; import std.stdio; T gcd(T)(T a, T b) { if (a % b == 0) return b; return gcd(b, a % b); } struct Rat(T) { import std.math : abs; T n, d; this(T n_, T d_) { if (d_ == 0) { n = 1; d = 0; } else if (n_ == 0) { d = 1; n = 0; } else { auto c = gcd(abs(n_), abs(d_)); bool neg ...
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() { int a, b; scan(a, b); int t = 1; int a...
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; import std.typecons; void main() { (rs.uniq.array.length - 1).writeln; } // =================================== T readAs(T)() if (isBasicType!T) { return readln.chomp.t...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional; import std.algorithm, std.container; void main() { auto N = scanElem; auto M = scanElem; auto Q = scanElem; long[501][501] table; foreach(i; 0..M) { long l...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto c1 = readln.chomp; auto c2 = readln.chomp; writeln(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0] ? "YES" : "NO"); }
D
// Your code here! import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math; void main(){ auto s=readln().chomp().split().map!(to!int); int a=s[0],b=s[1],x=s[2]; if(a<=x && x<=a+b) writeln("YES"); else writeln("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 main() { int a, b, c; readV(a, b, c); wri...
D
import std.stdio; import std.algorithm; import std.conv; import std.numeric; import std.math; import std.string; void main() { auto n = to!int(chomp(readln())); auto a1 = n / 100; auto a2 = (n / 10) % 10; auto a3 = n % 10; if (a1 == 1) a1 = 9; else a1 = 1; if (a2 == 1) a2 = 9; else a2 = 1; if (a3 == 1) a3 =...
D