code
stringlengths
4
1.01M
language
stringclasses
2 values
import std; void main() { int N, M, Q; scanf("%d %d %d\n", &N, &M, &Q); auto as = new int[Q]; auto bs = new int[Q]; auto cs = new int[Q]; auto ds = new int[Q]; foreach(q;0..Q) { int a, b, c, d; scanf("%d %d %d %d\n", &a, &b, &c, &d); as[q] = a-1; bs[q] = b-1; cs[q] = c; ds[q] = d; } auto As = new ...
D
import std.stdio,std.conv,std.string; void main(){ auto args = readln().chomp().split(); auto a = to!int(args[0]); auto b = to!int(args[1]); auto c = to!int(args[2]); writeln( a<b&&b<c?"Yes":"No" ); }
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; void main() { int N = readln.chomp.to!int; int[] A = new int[N]; foreach(ref a; A) { a = readln.chomp.to!int; } int[] pal = new int[0]; foreach(a; A) { auto lb = assumeSorted...
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
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.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
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() { auto ip = readln.split.to!(int...
D
import std.stdio; import std.ascii; import std.conv; import std.string; import std.algorithm; import std.range; import std.functional; import std.math; import core.bitop; import std.numeric; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { return readln.split.to!(T[])(); } void m...
D
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons, std.typetuple; import core.bitop, std.datetime; void main(){ int e, rest, ans; while (true) { e = readln.chomp.to!int; if (!e) break; ans = 1<<30; ...
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,m; char[] s, t; scan(n,m); s = readln.chomp.to!(char[]); t = readln.chomp.to!(char[]); s ~= '#'; t ~= '#'; s.reverse();...
D
import core.bitop; import std.algorithm; import std.array; import std.container; import std.conv; import std.exception; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void main () { auto a = readln.strip.to !(int); auto b = read...
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() { import std.stdio, std.string, std.conv, std.algorithm; import std.exception; int t; rd(t); while (t--) { int a; rd(a); bool ok = false; for (int n = 3; n <= 360; n++) { if (360 % n == 0) { auto x = 180 - 360 / n; if (a * (n - 2) % x == 0) { if (a ...
D
import std.stdio, std.string, std.conv, std.math, std.regex; void main() { auto n = readln.chomp; if(n[0] == n[2]){ writeln("Yes"); } else { writeln("No"); } }
D
import std.stdio, std.array, std.conv; void main() { int[] tmp = readln.split.to!(int[]); int k = tmp[0], x = tmp[1]; foreach (i; x-k+1 .. x+k) { i.write; if (i != x + k - 1) " ".write; else writeln; } }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; Node node; foreach (_; n.iota) { auto rd = readln.chomp.splitter(' '), cmd = rd.front; switch (cmd) { case "insert": rd.popFront; node.insert(rd.front.to!int); break; ...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { while(1){ auto n = readln.chomp.to!int; if(n==0) break; int s=1; int max=50000001; for(int i=2;i<n/2;++i){ if(n%i==0){ if(i<max){ s+=(i+n/i); max = n/i; if(i==max) s -= i; }else break; }else if(i>max) ...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio; int[] readints() { return readln.split.to!(int[]); } long calc(long n, long k, long b) { long cnt = max(0, b - k); long p = n / b; long r = n - p * b; long x = max(0, r - k + 1); return p * cnt +...
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; 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() {//try{ auto tokens = split(my_readln()); auto A = to!ulong(tokens[0]); auto B = to!ulong(tokens[1]); a...
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 c; foreach (i; 1..N-1) { auto x = ps[i-1]; auto y = ps[i]; auto z = ps[i+1]; if (x < ...
D
import std.string, std.stdio, std.conv; void main() { int N = readln.chomp.to!int; int[] input = readln.chomp.split.to!(int[]); int max , min = int.max; foreach (e; input) { if (max < e) { max = e; } if (min > e) { min = e; } } writeln(max - min); }
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; void main() { auto K = readln.chomp.to!int; long[] ans = iota(1L, 10L).array; int idx = 0; while (idx < ...
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[] lreads(T = long)(long n){ret...
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.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 = "%.15f"; 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.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.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;}} T[] readArray(T)(size_t n){auto a=new T[](n),r=readln.splitter;foreach(ref v;a){v=r.front.to!T;r.popFront;}return a;} T[] readArrayM(T)(size_t n){au...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nmx = readln.split.to!(int[]); auto N = nmx[0]; auto M = nmx[1]; auto X = nmx[2]; int[][] cas; foreach (_; 0..N) { cas ~= readln.split.to!(int[]); } auto m...
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.array; import std.conv; import std.string; import std.algorithm; void main() { int n = readln.strip.to!int; int[10][3][4] h ; foreach(i;0..4) foreach(j;0..3) foreach(k;0..10) h[i][j][k] = 0; foreach(i;0..n) { auto info = map!(to!...
D
import std.stdio, std.string, std.conv, std.algorithm; void main(){ auto s = readln.chomp.to!int; writeln(s/3600, ":", s%3600/60, ":", s%3600%60); }
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() { string a; scan(a); int[] cnt = new int[](26); foreach (ai ; a) { cnt[ai - 'a']++; } long ans = 1L * a.length * (a.length +...
D
void main(){ long n = _scan(); long[] a; foreach(i; 0..n)a ~= _scan!long(); a.sort!("a>b"); long prev=-1, cnt=1, ans; foreach(i, elm; a){ // 数えている途中 if(prev==elm){ cnt++; } if(prev!=elm && i==a.length-1){ if(cnt&1)ans++; // 最後尾の要素は奇数 ans++; }else if(prev!=elm || i==a.length-1){ if(prev==-...
D
// url: http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_b import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!size_t; auto maxA = 0, maxB = 0; foreach (_; 0..n) { auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1]; if (a > maxA)...
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, m; rd(n, m); auto c=readln.split.to!(int[]); auto a=readln.split.to!(int[]); int cnt=0; for(int i=0, j=0; i<n && j<m; ){ if(c[i]<=a[j]){ cnt++; i++; j++; }else{ i++; } } writeln(cnt); } void rd(T...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric; void main() { const N = readln.chomp.to!long; const as = readln.split.to!(long[]); as.map!(a => a-1).sum.writeln; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto ks = readln.split.to!(int[]); auto k = ks[0]; auto s = ks[1]; long cnt; foreach (x; 0..k+1) { foreach (y; x..k+1) { auto z = s - x - y; if (z < y || z > k) continue; if...
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; immutable inf = 10L^^16; int n; int[] a; void main() { scan(n); a = readln.split.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; 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[string] blue; foreach (_; 0..n) { blue[read...
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() { readln.chomp.count('2').writeln; }
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, m; scan(n, m); auto uf = UnionFind(n); foreach (i ; 0 .. m) { int ai, bi; scan(ai, bi); ai--, bi--; ...
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.algorithm, std.conv, std.range, std.math; void main() { readln.toUpper.write; }
D
import std.stdio; void main(){ foreach(i;0..1000) writeln("Hello World"); }
D
import std.stdio, std.string, std.conv, std.math; void main() { auto ip = readln.split.to!(int[]); if((ip[1] * 10 + ip[2]) % 4 == 0){ writeln("YES"); } else { writeln("NO"); } }
D
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; T readNum(T)(){ return readStr.to!T; } T[] readNums(T)(){ return readStr.split.to!(T[]); } string readStr(){ return readln.chomp; } void main(){ auto n = readNum!int; auto a = readNums!int; auto b = readNums!int...
D
import std.algorithm; import std.array; import std.ascii; import std.bigint; import std.complex; import std.container; import std.conv; import std.functional; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split...
D
void main() { readln.chomp.count('1').writeln; } 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto hw = readln.split.to!(int[]); auto H = hw[0]; auto W = hw[1]; char[][] MAP; MAP.length = H; foreach (i; 0..H) { MAP[i] = readln.chomp.to!(char[]); } int r;...
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; void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primiti...
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; void main() { auto ab = readln.split.map!(to!int); while (1) { bool f; foreach (y; ab[0]..ab[1]+1) { if (isLeapY...
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() { const long MAX = 3501; auto N = readln.chomp.to!long; foreach (b; 1..MAX) { foreach (c; 1..MAX) { ...
D
import std.stdio; import std.string; import std.conv; int main() { string[] str = readln().split(); int a = to!int(str[0]); int b = to!int(str[1]); if (a > b) writeln("a > b"); else if (a < b) writeln("a < b"); else writeln("a == b"); return 0; }
D
import std.stdio; import std.algorithm; import std.string; import std.range; import std.array; import std.conv; import std.complex; import std.math; import std.ascii; import std.bigint; import std.container; import std.typecons; auto readInts() { return array(map!(to!int)(readln().strip().split())); } auto readInt() ...
D
import std.conv, std.stdio; import std.algorithm, std.array, std.range, std.string; void main() { auto a = readln[0]; if ('a' <= a && a <= 'z') return 'a'.writeln; 'A'.writeln; }
D
string solve(int x){ return (x<1200)? "ABC": "ARC"; } void main(){ int x = inelm(); solve(x).writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range; const long mod = 10^^9+7; // 1要素のみの入力 T inelm(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型...
D
import std.stdio; import std.array; import std.conv; import std.range; import std.algorithm; import std.string; import std.numeric; void solve(){ string s = readln().strip(); foreach(a;0..26){ if(gcd(a,26)!=1) continue; foreach(b;0..26){ char[30] m...
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.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; void main() { long N, K; scan(N, K); auto v = abs(N - K) % K; auto a...
D
import std.stdio, std.string, std.conv; void main() { string N = readln.chomp; int a, b; foreach (c; N) { a += c - '0'; } b = N[0] - 1 - '0'; foreach (c; N[1..N.length]) { b += '9' - '0'; } writeln(a > b ? a : b); }
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[]); long[int]cn...
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; int calc(string s) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nkq = readln.split.to!(long[]); auto N = nkq[0]; auto K = nkq[1]; auto Q = nkq[2]; int[] as; as.length = N; foreach (_; 0..Q) { ++as[readln.chomp.to!int - 1]; ...
D
void main() { problem(); } void problem() { auto N = scan!ulong + 1; ulong solve() { ulong[] divisers = new ulong[N]; divisers[] = 1; foreach(i; 2..N) { for(ulong x = i; x < N; x += i) divisers[x]++; } ulong ans; foreach(i; 1..N) ans += i * divisers[i]; return ans; } so...
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; scan(n); auto a = iota(n).map!(i ...
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[int] cnt; foreach (i; 0..n) { auto d = read...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; import std.math; void main(){ auto A=readln.split.to!(int[]),x=A[0],a=A[1],b=A[2]; if(a>=b)writeln("delicious"); else if(a<b&&b-a<=x)writeln("safe"); else if(a<b&&b-a>x)writeln("dangerous"); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 998244353L; long[(10^^5)*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(...
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; // import dcomp.geo.primitive; void solve() { alias P = Point2D!double; P [4] p; foreach (i; 0..4) { double x, y; sc.read(x...
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.algorithm; void main() { int n = readln.chomp.to!int; int[] r = new int[n]; foreach (i; 0 .. n) { r[i] = readln.chomp.to!int; } int maxv = int.min; int minv = r[0]; foreach (i; 1 .. n) { maxv = max(maxv, r[i] - minv); minv ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); auto cnt=new int[](3); foreach(c; s) cnt[c-'a']++; auto mn=reduce!(min)(cnt); auto cnt1=map!(e=>e-mn)(cnt); auto a=new int[](0); foreach(e; cnt1)if(e>0) a~=e; if(a.length==0){writeln("YES"); return...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; import std.array; void main() { while (true) { auto N = readln.chomp; if (N == "0") break; auto k = readln.split.map!(to!int).array; if (reduce!((a,b)=> a > b ? a : b)(k) < 2UL) { writeln("NA"); continue; } auto count = filt...
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.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; string my_readln() { return chomp(readln()); } long mod = pow(10, 9) + 7; long moda(long x, long y) { return (x + y) % mod; } long mods(long x, long y) { return ((x + mod) - (y % mo...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; string Sorting_String(string s) { char[] str; for (int i = 0; i < s.length; i++) str ~= s[i]; for (int i = 0; i < str.length; i++) for (int j = i + 1; j < str.length; j++) { if (str[i] > str[j]) { ...
D
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range; void main() { auto s = readln.chomp; string ret; foreach (c; s) { switch (c) { case 'B': if (!ret.empty) ret = ret[0..$-1]; break; default: ...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; import std.container; alias sread = () => readln.chomp(); alias Point...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { int n; scan(n); auto h = readln.split.to!(int[]); int a = 0, b = abs(h[1] - h[0]); foreach (i ; 2 .. n) { int t = b; ...
D
import std.stdio, std.conv, std.string; import std.array, std.range, std.algorithm, std.container; import std.math, std.random, std.bigint, std.datetime, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } int DEBUG_LEVEL = 0; void pr...
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; void scan(T...)(ref T args) { auto line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFro...
D
void main(){ long n = _scan!long(); long[] stat = [0, 0, 0]; bool legitimate_travel = true; foreach(i; 0..n){ long[] tmp_stat = _scanln!long(); long tdif = tmp_stat[0] - stat[0]; // 所要時間 long xdif = abs( tmp_stat[1] - stat[1] ); // x方向移動距離 long ydif = abs( tmp_stat[2] - stat[2] ); // y方向移動距離 // 移動可能判定 i...
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() { long k; readV(k); auto n = 50, a...
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; const as = readln.split.to!(long[]); long count2(long x) { if (x % 2 == 1) return 0; else return 1 + count2(x/2); } writeln(as.map!(a =...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.math; 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;}} voi...
D
void main() { long n = rdElem; long[] p = rdRow; long[] q = rdRow; long num = 1; foreach (i; 2 .. n) { num *= i; } bool[] used = new bool[n+1]; long a; long anum = num; foreach (i, x; p) { long cnt; foreach (j; 1 .. x) { if (u...
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.string, std.conv; import std.typecons; import std.algorithm, std.array, std.range, std.container; import std.math; void main() { auto data = readln.split; auto X = data[0].to!int, Y = data[1].to!int; writeln(X + Y/2); }
D
import std.stdio, std.string, std.array, std.conv; struct Dice6 { int[string] dice6; int[] _dice6 = new int[](6); this(int[] _dice6) { dice6["top"] = _dice6[0]; dice6["front"] = _dice6[1]; dice6["right"] = _dice6[2]; dice6["left"] = _dice6[3]; dice6["back"] = _dice6...
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 = "%.15f"; 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.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
/+ dub.sdl: name "D" 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); string s; sc.read(s); int n = s.length.to!int; int i = 0; int mid = n/2; whil...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional; void main() { int tol(string n) { auto r = n.to!int; if (r == 1) r = 14; return r; } auto ab = readln.split; auto a = tol(ab[0]); auto b = tol(ab[1]); writeln( a > b ? "A...
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; void main(){ auto ab=readln.split.map!(to!int).array; writeln((ab[0]+ab[1])%24); }
D
import std.stdio; import std.string; import std.conv; void main() { auto input = split( readln() ); long N = to!long(input[0]), M = to!long(input[1]); if (N >= 2 && M >= 2) { writeln( (N-2) * (M-2) ); } else if ( N == 1 && M >= 2 ) { writeln( M-2 ); } else if ( M == 1 && N >= 2 ) { writeln( N-2 ); } else if (...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; bool[101] L; void main() { auto nmx = readln.split.to!(int[]); auto N = nmx[0]; auto M = nmx[1]; auto X = nmx[2]; foreach (a; readln.split.to!(int[])) L[a] = true; int a, b; 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.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