code
stringlengths
4
1.01M
language
stringclasses
2 values
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 = 10^^9 + 7; void main() { int n; scan(n); auto a = new int[](n); auto b = new int[](n); auto c = new int[](n); iota(n).each!(i =>...
D
import std.stdio; import std.functional; alias memoize!(c) cm; ulong c(ulong n, ulong k){ if(k==0 || n==k) return 1; return cm(n-1, k) + cm(n-1, k-1); } int main(){ auto s = readln; ulong[char] maji; foreach(i; 0..s.length-1){ maji[s[i]]++; } bool shinu = false; foreach(i; maji){ if(i%2){ if(shinu){ ...
D
// Cheese-Cracker: cheese-cracker.github.io void theCode(){ int n = scan!int; auto w = scan!(dchar[]); int l1, l2, r1, r2; for(int i = n/2; i < n; ++i){ if(w[i] == '0'){ l1 = 0; r1 = i; l2 = 0; r2 = i-1; writeln(l1+1, " ", r1+1, " ", l...
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; enum MAX = 1_000_100; ulong MOD = 1_000_000_007...
D
import std.conv, std.stdio; import std.algorithm, std.array, std.range, std.string; import std.numeric; void main() { auto n = readln.chomp.to!ulong; if (n & 1) return 0.writeln; n /= 2; ulong ret; while (n) { n /= 5; ret += n; } ret.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; import std.container; alias sread = () => readln.chomp(); long bignum...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.math; import std.regex; void main() { auto N = readln.chomp.to!int; int count; foreach(_; 0..N) { auto ip = readln.split.to!(int[]); count += ip[1] - ip[0] + 1; } writeln(count); }
D
void main() { string s = rdStr; string f(string x, dchar y) { string t; long len = x.length.to!long - 1; foreach (i; 0 .. len) { if (x[i] == y || x[i+1] == y) t ~= y; else t ~= s[i]; } return t; } long result = inf; forea...
D
import std.stdio, std.conv, std.string; void main(){ auto ip = readln.split.to!(int[]); if(ip[0] == 2 || ip[1] == 2){ writeln("No"); } else { writeln("Yes"); } }
D
import std.stdio, std.algorithm, std.array, std.string, std.conv; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { int n; scanf("%d", &n); getchar(); auto str1 = readln.strip(); auto str2 = readln.strip(); bool flag = true; ...
D
import std.algorithm; import std.array; import std.ascii; 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 log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } voi...
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 std.stdio: writeln; void main() { foreach(int i; 0 .. 1000) { writeln("Hello World"); } }
D
import std; int calc(long x) { long s = 100; int k = 0; while (s < x) { s += s / 100; k++; } return k; } void main() { long x; scan(x); writeln(calc(x)); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { r...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.numeric; 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() { string s; ...
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; import std.string; import std.array; // split import std.conv; // to void main() { string s = chomp(readln()); write("ABC"); writeln(s); }
D
import std.stdio; void main() { int n, m; scanf("%d %d\n", &n, &m); auto add = new int[n]; auto sub = new int[n]; foreach (i; 0..m) { int l, r; scanf("%d %d\n", &l, &r); ++add[l-1]; ++sub[r-1]; } int y, cnt; foreach(i; 0..n) { y += add[i]; if (y == m) ++cnt; y -= sub[i]; } cnt.write; }
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, 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 N, M; scan(N, M); auto deg...
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; const long MOD = 998244353; const long INF = 1L << 59; void main() { auto N = readln.chomp.to!int; auto G = new int[]...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.array; int n, m; rd(n, m); auto g=new int[][](n, n); foreach(_; 0..m){ int a, b; rd(a, b); g[a-1][b-1]=g[b-1][a-1]=1; } auto v=new int[](0); v~=0; auto usd=new bool[](n); usd[0]=true; int f(int k){ if(k==n)...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int N; scan(N); auto row = new ...
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; auto input() { return readln().chomp(); } alias sread = () => readln.chomp(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long n, m; scan(n, m); auto ACしたか = new bool[](n + 1); // ACしたか[n] = false; // writeln(ACしたか); auto 何回WAしたか = new long[](n + 1); ...
D
import std.stdio; import std.conv; import std.string; void main(){ auto A =readln.chomp.to!int; if(A<1200){ "ABC".writeln; }else{ "ARC".writeln; } }
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.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; auto cnt = new int[](10); while (T--) { cnt[] = 0; ...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional; int happiness(string s) { int r = 0; foreach(i; 0..s.length) { if (s[i] == 'L' && i != 0 && s[i-1] == 'L') r++; if (s[i] == 'R' && i != s.length - 1 && s[i+1] == 'R') r++; } return r; } string inverse(string s...
D
import std.stdio; import std.conv; import std.algorithm; import std.range; import std.string; import std.typecons; import std.math; import std.range; void main() { readln; auto a = readln().strip.split(" ").map!(to!int); auto b = new typeof(a[0])[10000]; foreach (i; a) { b[i]++; } bo...
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() { auto S = rs; string A = S; char[] arr = ['0', '1']; ulong k = 0; ulong res = ulong.max, cnt; foreach(i, v; A) { if(v != arr[i % 2]) { cnt++; } } res = cnt; cnt = 0; foreach(i, v; A) { if(v != arr[(i+1) % 2]) { cnt++; } } res = min(res, cnt); res.writeln; } // ============...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long[100] WS, VS; void main() { auto nw = readln.split.to!(int[]); auto N = nw[0]; auto W = nw[1]; long[][] MEMO; MEMO.length = N; foreach (i; 0..N) { auto wv = readln.split.to!(lon...
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 n = readln.chomp.to!int; auto a = new int[](n); foreach ...
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; const MOD = 998244353; const N = 2 * 10^^5; long calc(int n, int m, int k) { auto binom = new Binom(N); long ans = 0; foreach (i; 0..k+1) { ans += (m * modpow(m-1, n-i-1) % MOD) * binom(n-1, i) % MOD; ans %= MOD; } return ans; } void main() { int n, m, k; scan(n, ...
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.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() { long k, a, b; scan(k, a, b); if (b - a <=...
D
void main() { string s = readln.chomp; string t = "keyence"; bool ok; foreach (i; 0 .. 8) { if (s[0..i] == t[0..i] && s[$-7+i..$] == t[i..$]) { ok = true; } } writeln(ok ? "YES" : "NO"); } import std.stdio; import std.string; import std.array; import st...
D
void main() { auto N = readAs!ulong; auto arr = 5.iota.map!(i => readAs!ulong); writeln((ceil(N /arr.reduce!min.to!real) + 4).to!ulong); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math;...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; struct Matrix(size_t height, size_t width) { long M; long[width][height] arr; this(long[width][height] arr, long M = 10L^^9+7) { this.arr = arr; this.M = M; } pure Matrix!(he...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long[10^^5] HS, MEMO; void main() { auto N = readln.chomp.to!int; foreach (i, h; readln.split.to!(long[])) HS[i] = h; MEMO[0..N] = -1; long solve(int i) { if (MEMO[i] != -1) return MEMO[i];...
D
// dfmt off T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;} void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(...
D
void main() { int n = readln.chomp.to!int; int[] a = readln.split.to!(int[]); int cnt; foreach (x; a) { while (x % 2 == 0) { x /= 2; ++cnt; } } cnt.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto N = readln.chomp.to!int; auto HS = readln.split.to!(int[]); int c, max_c; foreach_reverse (i; 0..N) { if (i+1 == N) continue; if (HS[i] >= HS[i+1]) { ++...
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.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), n = rd[0], a = rd[1], b = rd[2]; writeln(min(a*n, b)); }
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.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; void main() { string[] inputs = split(readln()); int A = to!int(inputs[0]); int B = to!int(inputs[1]); if(A == B) "Draw".writeln; else if(A == 1 && B > 1) "Alice".writeln; else if(B == 1 && A > 1) "Bob".writeln; else if(A > B) "Alice".writeln; else "Bob".wr...
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; immutable long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!long; if (N <= 2) { writeln("No"); ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { readln.split.to!(int[]).reduce!"(a + b) % 24".writeln; } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives;...
D
import std.stdio, std.algorithm, std.conv, std.array, std.range, std.string, std.math, std.typecons; void main() { auto nm = readln.split.to!(long[]); auto N = nm[0]; auto M = nm[1]; long ret; if (N == 1 && M == 1) { ret = 1; } else if (N == 1) { ret = M - 2; } else if (M =...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric; void main() { auto tmp = readln.split.to!(long[]); auto N = tmp[0], X = tmp[1]; auto xs = readln.split.to!(long[]); xs.map!(x => abs(x - X)).reduce!((a,b) => gcd(a,b)).writeln; }
D
import std.stdio; import std.conv; import std.string; import std.algorithm; import std.range; import std.functional; import std.math; import core.bitop; void main() { auto input = readln.chomp.split.to!(long[]); long n = input[0]; long m = input[1]; long x = input[2]; auto as = readln.chomp.split...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { long a, b, c; scan(a, b, c); long max_x = max(a, b, c); long sum_x = a + b + c; long x, y; if (((max_x % 2 == 0) && (sum_x % 2 == 0))...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; void main() { int n, m; scanf("%d %d\n", &n, &m); auto r = new int[m]; foreach(i;0..n) { auto input = readln.chomp.split(" ").to!(int[]); foreach(a;input[1..$]) ++r[a-1]; } size_t c; foreach(a; r) if (a == n) ...
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; import core.bitop; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () => readln.chomp.to!(T); alias aryread(T = long) = () => readln.split.to!(T[]); alias Pair = Tuple!(long, "x", long, "c"); alias PQueue(T, alias less = "a>b") ...
D
import std.stdio; import std.conv; import std.array; void main() { int[] T = new int[5]; foreach (i; 0..5){ T[i] = readln.split[0].to!int; } int ans = 0; int minMod = 0; foreach (t; T){ if (t % 10 == 0){ ans += t; } else { if (minMod == 0 || t % ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto ab = readln.split.to!(int[]); writeln(ab[0] * ab[1]); }
D
void main(){ int[] hen = _scanln(); (hen[0]*hen[1]/2).writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = int)(){ T[] ln; foreach(string elm; readln().chomp().split()){ ln ...
D
import std.stdio; import std.string; import std.conv; void main() { // input int n = to!int(readln.chomp); int k = to!int(readln.chomp); int[] x, y; x.length = y.length = k; for(int i=0; i<k; ++i) { auto temp = readln.split; x[i] = to!int(temp[0]); y[i] = ...
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 N = readln.split[0].to!int; foreach (n; 1 .. 10) { if (N <= n*111) { writeln(n*111); return; } } }
D
import std.stdio; import std.conv; import std.string; import std.format; void main() { string s = chomp(readln()); int min = to!int(s.split(" ")[0]); int max = to!int(s.split(" ")[1]); int val = to!int(s.split(" ")[2]); int result = 0; for (int i = min; i <= max; i++ ) { if (val % i == 0) { res...
D
import std.conv, std.stdio; import std.algorithm, std.range, std.string; void main() { immutable n = readln.chomp.to!size_t; size_t[immutable(ubyte)[]] d; foreach (i; 0..n) { auto s = cast(ubyte[])(readln.chomp); auto k = s.sort().array.idup; if (auto p = k in d) (*p...
D
import std.stdio: writeln, writefln, readln; import std.array: array, split; import std.algorithm: map; import std.string: chomp; import std.conv: to; void main() { int[3][3] bingo; foreach(byte i; 0..3) { int[] input = readln.split.map!(to!int).array; foreach(int j; 0..3) bingo[i][j] = input[j]; } int n = ...
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.string, std.range, std.conv, std.algorithm; void main(){ int s; foreach (i; 0..5) { s += max(readln.chomp.to!int, 40); } writeln(s / 5); }
D
void main() { problem(); } void problem() { auto N = scan!int; auto K = scan!int; void solve() { bool[int] snk; foreach(i; 1..N+1) { snk[i] = true; } foreach(_; 0..K) { auto d = scan!int; foreach(i; scan!int(d)) { snk[i] = false; } } int answer; fo...
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() { string s = readln.chomp; string t = readln.chomp; string ans = '~'.repe...
D
import std.stdio; import std.string; import std.conv; void main() { int R = to!int(chomp(readln())); int G = to!int(chomp(readln())); // (R + P)/2 = G // R + P = 2G // P = 2G - R writeln(2*G - R); }
D
void main(){ int[] abc = _scanln(); writeln(abc.count(5)==2 && abc.count(7)==1? "YES": "NO"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T = int)(){ T[] ln; foreach(string elm; re...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.string; // import dcomp.foundation, dcomp.scanner; int main() { Scanner sc = new Scanner(stdin); string s; sc.read(s); if (s.startsWith("YAKI")) { writeln("Yes"); ...
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; void main() { long s = readln().strip.to!(long); long[] list; list ~= s; while(1) { auto...
D
import std.stdio, std.string, std.conv, std.range, std.algorithm; 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(N * X); } else { writeln(K * X + (N - K) * Y); } }
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; Tuple!(int,string)[] insort(Tuple!(int,string)[] arr){ for(int i=1;i<arr.length;i++){ int j = i; while(arr[j][0] > arr[j-1...
D
void main() { string s = readln.chomp; string t = readln.chomp; bool ok; foreach (i; 0 .. s.length) { if (s == t) ok = true; s = s[$-1] ~ s[0..$-1]; } writeln(ok ? "Yes" : "No"); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; impo...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math; int read() { return readln.chomp.to!int; } int[] reads() { return readln.split.to!(int[]); } void solve() { int n = read(); int[] a = reads(); int r, m; long ans; foreach (l; 0..n) { while (r < n && !(m ...
D
import std.stdio; import std.string; import std.math; import std.conv; import std.algorithm; import std.bigint; void main(){ auto n = to!int(chomp(readln())); for(int i=0;i<n;i++){ auto s = split(readln()); real[] a; foreach(j;s) a ~= to!real(j); real R2 = (a[0] - a[3])*(a[0] - a[3]) + (a[1] - a[4])*(a[1]...
D
// Vicfred // https://atcoder.jp/contests/abc045/tasks/arc061_a // brute force, bitmask import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { string s = readln.strip; const long n = s.length; long ans = 0; for(int bit = 0; bit < (1 << n - 1); bit+...
D
import std.stdio; import std.conv; import std.algorithm; import std.array; import std.string; import std.uni; import std.math; import std.container.rbtree; import std.range; import std.numeric; void main() { auto t = to!long(readln().chomp); OUTER: foreach(_; 0..t) { auto arr = readln().chomp.split...
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(...
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 a, b; scan(a, b); if (a + b == 15) { writeln("+"); } else if (a * b == 15) { writeln("*"); } else {...
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 x; scan(x); auto ans = (x / 500) * 1000 + ((x % 500)...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto line = readln.split; auto a = line[0].to!long; auto b = line[2].to!long; writeln(line[1] == "+" ? a + b : a - b); }
D
import std.stdio; import std.string; string toSwapCase(string s) { if (s == s.toLower) { return s.toUpper; } if (s == s.toUpper) { return s.toLower; } return s; } void main() { auto str = readln; foreach (ch; str.split("")) { write(toSwapCase(ch)); } }
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 main() { int n; readV(n); auto l = new long[](n+1); l[0] = 2; l[1] = 1; foreach (i; 2..n+1) l[i...
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.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.uni; import std.conv; import std.container; import std.functional; import std.algorithm; import std.array; import std.typecons; import std.range; import std.numeric; import std.traits; long pmod(long a, long m) { if (a < 0) return (a % m) + m; return a % m; } void main(string[] args) ...
D
import std.stdio; import std.uni; import std.conv; import std.container; import std.functional; import std.algorithm; import std.array; import std.typecons; import std.range; import std.numeric; void main(string[] args) { inputFile = stdin; debug inputFile = File(args[1]); auto t = next!int; foreach(tc; 0 .. ...
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; immutable long INF = 1L << 59; void main() { auto N = readln.chomp.to!int; auto P = readln.split.map!(to!int).arr...
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
/+ 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); int h, w; sc.read(h, w); bool[][] g = new bool[][]...
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.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; stri...
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