code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio, std.algorithm, std.array, std.math, std.typecons, std.bigint, std.conv; void main() { int k; scanf("%d", &k); long res1 = 2UL^^k - 2; BigInt n = 4; BigInt res2 = powmod(n, to!BigInt(res1), to!BigInt(10^^9 + 7)); writeln((res2 * to!BigInt(6)) % (10^^9 + 7)); }
D
/+ dub.sdl: name "B" 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) sc.read!true; int n; sc.read(n); int[][] g = new int[][](n); foreach...
D
module sigod.codeforces.p287A; import std.stdio; import std.string; void main() { bool[4][4] square = read(); bool answer = solve(square); stdout.writeln(answer ? "YES" : "NO"); } private bool[4][4] read() { bool[4][4] square; foreach (ref line; square) { auto tmp = stdin.readln().strip(); foreach (i; 0...
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; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { buffer = uninitializ...
D
import std.stdio; import std.ascii; import core.stdc.stdio; import std.algorithm; int main() { int n = readInt!int; auto a = new long[](n); foreach(ref ai; a) ai = readInt!long; int pos = cast(int) a.count!(ai => ai >= 0); long[][] maxSum = new long[][](n + 1, n + 1); maxSum[0][0] = (a[0] < 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
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; import std.conv; import std.array; import std.stdio; import std.string; void main() { string[][int] blocks; readln; // to skip n loop: for (;;) { auto command = readln.strip.split; auto operation = command[0]; final switch (operation) { case "push": auto dst = command[1].to!int -...
D
import std.algorithm; import std.conv; import std.math; import std.range; import std.stdio; import std.string; long solve (int [] a, int pos) { auto n = a.length.to !(int); auto half = (n + 1 - pos) / 2; auto total = a.sum; if (total != half) { return long.max; } long res = 0; foreach (int i, ref c; a) { ...
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 r; scan(r); auto ans = 3 * r * 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.stdio; import std.string; import std.conv; import std.array; import std.algorithm; void main() { auto a = readln.chomp.split(" ").map!(to!int).array; foreach (size_t i, e;a) { if (e == 0) { writeln(i + 1); break; } } }
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.array; int n, m; rd(n, m); auto a=readln.split.to!(long[]).map!((e)=>(e%m)).array; auto cul=new long[](n+1); foreach(i; 0..n) cul[i+1]=(cul[i]+a[i])%m; long[long] freq; freq[0]=0; long tot=0; foreach(x; cul[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; void main() { char x, y; scan(x, y); char ans; if (x < y) { ans = '<'; } else if (x > y) { ans = '>'; } else { a...
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; 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 - y) % mod; } long modm(long x, long...
D
void main() { string[dchar] s; s['a'] = readln.chomp; s['b'] = readln.chomp; s['c'] = readln.chomp; dchar now = 'a'; dchar ans; while (true) { dchar tmp = s[now][0]; s[now] = s[now][1..$]; now = tmp; if (s[now].length == 0) { ans = tmp; ...
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 N = readln.chomp.to!long; long ans = 0; foreach (i; 2..N) ans += i * (i + 1); ans.wri...
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 r = long.max; foreach (x; 0..N+1) { long rr; auto a = x; while (a) rr += a%6, a /= 6; auto b = N-x; while (b) rr...
D
import std.stdio, std.algorithm, std.conv; void main() { foreach(n; stdin.byLine().map!(to!int)) { bool flag; foreach(i; 0..10) { if(n & 1) { if(flag) " ".write; else flag = true; (2 ^^ i).write; } ...
D
/+ dub.sdl: name "F" dependency "dcomp" version=">=0.7.3" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner; import std.typecons; alias E = Tuple!(int, "to", int, "dist"); alias D = int; int main() { Scanner sc = new Scanner(stdin); static struct ...
D
import std.stdio; import std.string; import std.conv; void main() { string input; while ((input = readln.chomp).length != 0) { auto n = input.to!int; auto sum = 0; auto a = 2; sum += a; if (n >= 2) { sum += (n+2)*(n-1)/2; } writeln(sum); ...
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 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.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; enum MOD = 998244353L; struct Sum{ long k; long s; } void main() { long N = scanElem; string S = readln.strip; auto lis...
D
import std.algorithm; import std.array; import std.container; import std.conv; import std.math; 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 readln.chomp.to!T; } T[]...
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 = N.iota.map!(_ => readln.chomp.to!int - 1).array; auto B = new...
D
import std.algorithm; import std.stdio; void main () { auto s = readln; auto x = (s[0] == 'a' || s[0] == 'h'); auto y = (s[1] == '1' || s[1] == '8'); writeln (8 - 3 * (x + y) + (x * y)); }
D
void main() { long x, y, z; rdVals(x, y, z); writeln(z, " ", x, " ", y); } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; enum double eps = 1.0e-9; T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]); T rdElem(...
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; enum L = 2001; void main() { int M, D; scan(M, D); int...
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 s = readln.split.map!(to!int); auto N = s[0]; auto P = s[1]; auto A = readln.split.map!(...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; void main() { auto first = new char[0]; auto last = readln.chomp.dup; uint queryMax = readln.chomp.to!uint; foreach (i;0..queryMax) { auto query = readln.chomp.split(' '); if (query[0] == "1") { swap(first, last...
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; alias Point = Tuple!(in...
D
void main() { long n, q; rdVals(n, q); foreach (i; 0 .. q) { long v, w; rdVals(v, w); if (n == 1) { min(v, w).writeln; continue; } while (v != w) { if (v < w) w = (w + n - 2) / n; else v = (v + n -...
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.stdio,std.math,std.string,std.conv,std.typecons,std.format; import std.algorithm,std.range,std.array; T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);} void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;} //END OF TEMPLATE void main(){ ulong m,n; ...
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, 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() { int N, M; scan(N, M); auto a = new int[](N); a[] = -1;...
D
import std.stdio; import std.string; void main() { string s = readln.chomp; if (s == "SUN") writeln(7); if (s == "MON") writeln(6); if (s == "TUE") writeln(5); if (s == "WED") writeln(4); if (s == "THU") writeln(3); if (s == "FRI") writeln(2); if (s == "SAT") writeln(1); }
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); writeln(n % s(n) == 0 ? "Yes" : "No"); } int s(int n) { return n > 0 ? s(n / 10) + n % 10 : 0; } ...
D
void main() { auto N = ri; auto S = rs; ulong res = ulong.max; auto A = new int[](N); // i番目含め左から今までのWの個数 A[0] = S[0] == 'W'; foreach(i; 1..N) A[i] = S[i] == 'W' ? A[i-1]+1 : A[i-1]; // i番目含め左から今までのEの個数 // C[i] = (i+1) - A[i]; // 下二行はどちらも同じ結果をもつ auto C = iota(1, N+1).map!(a => a - A[a-1]).array; // auto ...
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.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; struct Qes{ char t; char d; } long N; string S; Qes[] qs; long calc(long s, long g) { long pos = (s+g)/2; foreach(q; qs) { ...
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; void main() { const K = readln().chomp().to!ulong(); ulong sum = 0; foreach (i; 1 .. K + 1) foreach (j; 1 .. K + 1) foreach (k; 1 .. K + 1) { sum += gcd(gcd(i, j), k); } writeln(sum); }
D
void main() { auto N = ri; ulong a = 0, b = 0; while(4*a <= 100) { ulong tmp = 4*a + 7*b; while(tmp <= 100) { if(tmp == N) { writeln("Yes"); return; } b++; tmp = 4*a + 7*b; } a++; b = 0; } writeln("No"); } // =================================== import std.stdio; import std.string; i...
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[]); if (s[0] == s[$-1] && s.length%2 == 0 || s[0] != s[$-1] && s.length%2 == 1) { writeln("First"); } else { writeln("Second"); } }
D
import std.stdio, std.string, std.conv; void main() { int n = readln.chomp.to!int; bool ok; foreach (i; 1 .. 10) { foreach (j; 1 .. 10) { if (i * j == n) ok = true; } } writeln(ok ? "Yes" : "No"); }
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; void main() { auto ...
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons; // }}} // tbh.scanner {{{ class Scanner { import std.stdio; import std.conv ...
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 input = readln.split.to!(int[]); auto A = input[0], B = input[1], C = input[2], D = input[3]; writeln( (C%B == 0 ? C/B : C/B+1) <= (A%D == 0 ? A/D : A/D+1) ? ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum P = 10L^^9+7; void main() { auto N = readln.chomp.to!int; auto ts = readln.split.to!(int[]); auto as = readln.split.to!(int[]); auto xs = new long[](N); foreach (i; 0..N) { if (i ==...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { readln; int c; foreach (i; readln.split.to!(int[])) if (i%2 == 1) ++c; writeln(c%2 == 0 ? "YES" : "NO"); }
D
import std.stdio; import std.string; import std.array; import std.algorithm; import std.conv; void main() { auto buf = readln.chomp.split.map!(x => x.to!int); int N = buf[0]; int x = buf[1]; ulong[] a = readln.chomp.split.map!(x => x.to!ulong).array; ulong count = 0; foreach(i; 0 .. N) { ...
D
/+ dub.sdl: name "C" 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); long a, b, c, x, y; sc.read(a, b, c, x, y); a = min(...
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; scan(n); int ds = digsum(n); writeln(n % ds == 0 ? "Yes" : "No"); } int digsum(int n) { return n > 0 ? digsum(n / 10) + (n % 10...
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.algorithm, std.container, std.conv, std.math, std.range, std.typecons, 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!T;r.popFro...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; void main() { auto ...
D
import std.stdio; import std.string; import std.conv; import std.bigint; import std.typecons; import std.algorithm; import std.array; void main() { auto a = readln.chomp.dup; auto b = readln.chomp.dup; reverse(b); writeln(a == b ? "YES" : "NO"); }
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const tmp = readln.split.to!(long[]); writeln(tmp[0] <= 8 && tmp[1] <= 8 ? "Yay!" : ":("); }
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; import std.conv; import std.array; void main() { while (1) { int cnt = 0; string[] input = split(readln()); int n = to!(int)(input[0]); int x = to!(int)(input[1]); if (n == 0 && x == 0) break; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { ...
D
import std.stdio, std.conv, std.array, std.range, std.algorithm, std.string, std.typecons; void main() { auto s = readln.strip; if (15 - s.length + s.count('o') >= 8) { writeln("YES"); } else { writeln("NO"); } }
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; foreach (e; s) { if (e == '1') { ...
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
void main() { long[] tmp = readln.split.to!(long[]); long n = tmp[0], a = tmp[1], b = tmp[2]; long[] x = readln.split.to!(long[]); long result; foreach (i; 1 .. n) { long diff = x[i] - x[i-1]; result += min(a*diff, b); } result.writeln; } import std.stdio; import std.string;...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; import std.math; void main(){ bool[3] a; a[0] = true; a[1] = false; a[2] = false; while(true){ auto s = readln(); if(stdin.eof()) break; s = chomp(s); swap(a[to!int(s[0]-'A')],a[to!int(s[2]-'A')]); } for(int 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.algorithm; import std.array; import std.conv; import std.math; 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 readln.chomp.to!T; } T[] reads(T)() { return 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 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, std.datetime; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generat...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { auto S = split(readln())[0]; auto year = to!int(S[0 .. 4]), month = to!int(S[5 .. 7]), day = to!int(S[8 .. 10]); string result = (year < 2019 || year == 2019 && month < 4 || year == 2019 && month == 4 && day <= 30) ? "Heisei" ...
D
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.math; void main() { foreach (string line; lines(stdin)) { if (line == "0\n") break; int n = line.chomp.to!int; auto points = readln.chomp.split.map!(to!double); auto avr = points.reduce!"a+b" / n; double var = 0; for...
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; 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 digits(int n) { ...
D
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range; void main() { 0.iota(readln.chomp.to!int+1).reduce!"a+b".writeln; }
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.numeric; void main() { auto x = readln.chomp.to!int; while (x > 0) { auto m = x %...
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[]); } alias Info = Tuple!(int, "l", int, "r", int, "d"); bool calc(int n, ...
D
/+ dub.sdl: name "B" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner, dcomp.algorithm; int main() { auto sc = new Scanner(stdin); int[] buf = new int[1000]; int a, b; sc.read(a, b); foreach (i; a..b) {...
D
import std.stdio, std.string, std.algorithm; void main(){ readln.split.sort.join(" ").writeln; }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(long[]), n = rd[0], m = rd[1]; auto c = min(n, m/2); m -= c*2; c += m/4; writeln(c); }
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 r...
D
import std.stdio, std.ascii; void main() { auto d = readln.dup; foreach (c; d) c.isLower ? c.toUpper.write : c.toLower.write; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { readln; auto as = readln.split.to!(long[]); auto x = as[0]; foreach (a; as[1..$]) x = gcd(a, x); writeln(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() { (48-readln.chomp.to!int).writeln; }
D
import std.stdio; import std.string; import std.conv; void main() { uint[string] table; while(true) { string line = readln.chomp; if (stdin.eof) break; auto data = line.split(","); table[data[1]] += 1; } foreach(type; ["A", "B", "AB", "O"]) { if (type in table) writeln(table[type]); ...
D
import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { while (true) { int n,q; scan(n,q); if (!n && !q) return; auto a = iota(n).map!(i => readln.split.to!(int[])).array; ...
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.bigint; void main() { auto str1 = readln.chomp; auto str2 = readln.chomp; int s1, s2; for (int i; i < str1.length; ...
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
// 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; import std.algorithm; import std.string; void main() { while (true) { int H, N; scanf("%d %d\n", &H, &N); if (H == 0 && N == 0) break; const int X = 20; auto F = new string[2][X]; foreach (i; 0 .. H) { F[i][0] = readln.chomp; ...
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 n = readln.chomp.to!int; auto a = readln.chomp.split.to!(int...
D
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math; void main() { auto nw = readln.split.to!(int[]); auto N = nw[0]; auto W = nw[1]; int[] vs, ws; foreach (_; 0..N) { auto vw = readln.split.to!(int[]); vs ~= vw[0]; ws ~= vw[...
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() { string s = readln.chomp; s[0..$-8].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.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.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 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.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