code
stringlengths
4
1.01M
language
stringclasses
2 values
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = (...
D
import 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 s = readln.chomp; auto res = int.max; foreach (i; 0..s.length-2) { res =...
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.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 x, y, s; scan(x, y, s); if (!x && !y && !s) return; solve(x, y, s); } } void solve(int x, int y...
D
// import chie template :) {{{ import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint; // }}} void main() { int n = readln.chomp.to!int; int[] c, s, f; foreach (i; 0 .. n - 1) { int[] t = readln....
D
import std.stdio, std.string, std.array, std.conv; void main() { while (true) { string[] tmp = readln.chomp.split; int a = tmp[0].to!int, b = tmp[2].to!int; string op = tmp[1]; if (op == "+") { writeln(a + b); } else if (op == "-") { writeln(a - b); ...
D
import std.stdio, std.ascii, std.string; void main() { readln.chomp.toUpper.writeln; }
D
import std.stdio; import std.algorithm; void main(){ string str = "Hello World"; for(int i=0;i<1000;i++){ writeln(str); } }
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; bool[string] s; foreach (_; 0..N) { auto t = readln.chomp; s[t] = t...
D
import std.stdio, std.conv, std.string; void main() { int N = to!(int)(readln().chomp()); string [] S = readln().chomp().split(); bool flg = false; foreach(i; S) { if(i=="Y") flg = true; } if(flg) writeln("Four"); else writeln("Three"); }
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.algorithm, std.string, std.array, std.range, std.stdio, std.conv; void main() { string n = readln.chomp; writeln("ABC", n); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; auto s = readln.chomp.to!(char[]); if (s[0] != 'A') { writeln("WA"); return; } if (s.count('A') != 1 || s.count('C') != 1) { writeln("WA"); return; } foreach (c; s) { if (c != 'A' && c != 'C') { if ('A' <= c &&...
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; auto Q = readln.chomp.to!int; auto K = read...
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.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.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[][][](2, K+1, N.length); DP[1][K-1][0] += 1; foreach (x; 1..N[0]-'0') DP[0][K-1][0] += 1; foreach (i; 1.....
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; Tuple!(N, N)[] prime_division(N)(N n) { Tuple!(N, N)[] res; foreach (N i; 2..10^^6+1) { if (n%i == 0) { N cnt; while (n%i == 0) { ++cnt; n /= i;...
D
void main() { string s = readln.chomp; int price = 700; foreach (x; s) { if (x == 'o') price += 100; } price.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; ...
D
// This file is a "Hello, world!" in D language by DMD for wandbox. import std.algorithm, std.conv, std.stdio, std.array; int main() { const I = readln.split.map!(to!long).array; ((I[2]/I[0])*I[1]).writeln; return 0; } // DMD reference: // https://dlang.org/dmd-linux.html // D language references: // ...
D
void main() { problem(); } void problem() { const X = scan!int; const N = scan!int; const P = scan!int(N); int solve() { int absolute = 101; int answer = 101; auto NP = iota(0, 102, 1).filter!(a => !P.canFind(a)); foreach(p; NP) { const a = X > p ? X - p : p - X; if (a == absol...
D
import std.stdio, std.string, std.algorithm, std.conv; const long INF = long.max/3; void main() { while(solve()){} } bool solve() { int N = readln.chomp.to!int; if (N == 0) return false; long[] as = new long[N]; foreach(i; 0..N) { as[i] = readln.chomp.to!long; } long res = -INF; ...
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 MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; auto as = readln.split.to!(long[]); long[] ss; foreach (i; 0..N) { long s; foreach (j; i..N) ...
D
import std.stdio, std.string, std.conv, std.algorithm, std.range; void main() { int n = readln.chomp.to!int; int[] a = new int[n]; foreach (i; 0 .. n) { a[i] = readln.chomp.to!int; } int[] b = a.dup.sort!("a > b").array; foreach (x; a) { if (x != b[0]) b[0].writeln; else...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { auto a = readln.split.to!(int[]); if (a[2] > a[0] + a[1]) { writeln("dangerous"); } else if (a[2] > a[0]) { writeln("safe"); } else { writeln("delicious"); } } ...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { foreach(_;0..readln().chomp().to!int()) { auto m = readln().split().map!(to!real); immutable x1=m[0], y1=m[1], x2=m[2], y2=m[3], x3=m[4], y3=m[5], x4=m[6], y4=m[7]; writeln((x1-x2)*(y3-y4)=...
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, d; scan(n, d); auto x = new int[]...
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 = 2L * 10L^^16; int n; long[] a; void main() { scan(n); a = readln.s...
D
import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container, std.format; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } /* (B - A) < 2 の場合は、換金しないでひた...
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 s = readln.chomp; auto d = s.length - 7; auto f = false; foreach (i; 0....
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; scan(N); auto a = iota(5).map!(i => readln.chomp.t...
D
void main() { long n, c; rdVals(n, c); long lim = 2 * 10L^^5 + 1; long[][] list = new long[][](c, lim); foreach (i; 0 .. n) { long s, t, d; rdVals(s, t, d); --d; ++list[d][(s<<1)-1], --list[d][t<<1]; } long[] cnt = new long[lim]; foreach (i; 0 .. c) ...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional; void main() { auto abcd = readln.split.to!(long[]); auto ab = abcd[0] * abcd[1]; auto cd = abcd[2] * abcd[3]; writeln( ab > cd ? ab : cd ); }
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; void main() { auto nk = readln.split.to!(long[]); long n = nk[0]; long k = nk[1]; long[] X = readln.split.to!(lo...
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() { readln(); const auto targets = readln().strip.split.to!(long[]); long[] list; list.len...
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(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}} void ...
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 a = readln.split.to!(int[]); int ans; foreach (ai ; a) { while (ai % 2 == 0) { ans++; ...
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() { readln; auto S = readln.split[0]; writeln( S.count('R') > S.count('B') ? "Yes" : "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; void main() { auto ans = new int[](4001); auto tmp = new int[](2001); foreach (i; 0..1001) { foreach (j; 0..1001) {...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int x, t; scan(x, t); writeln(max(x - t, 0)); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg =...
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
void main(){ long n = _scan!long(); long[] a = _scanln!long(); // 要素に0がある場合 if( a.count(0) != 0 ){ writeln(0); return; } // 桁あふれが起きないかチェックしならが積をとる long mula = 1; foreach(elm; a){ if( mula <= mula*elm && mula <= 10L^^18/elm ) mula *= elm; else { writeln(-1); return; } } mula.writeln(); } impo...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto xab = readln.split.to!(int[]); writeln(abs(xab[0] - xab[1]) > abs(xab[0] - xab[2]) ? "B" : "A"); }
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; 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 a = readln.chomp.to!int; auto b = readln.chomp.to!int; if ...
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 s = readln.chomp.to!int; auto u2 = s / 100; auto d2 = s % 100; bool uf, df...
D
import std.stdio; import std.array; import std.conv; void main() { string[] input = split(readln()); int a = to!(int)(input[0]); int b = to!(int)(input[1]); writeln(a*b, ' ', a * 2 + b * 2); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nm = readln.split.to!(long[]); auto N = nm[0]; auto M = nm[1]; writeln(N == 1 && M == 1 ? 1 : N == 1 ? M-2 : M == 1 ? N-2 : (N-2) * (M-2)); }
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; void main() { auto ip = readln.split.to!(int[]), w=ip[0], h=ip[1], x=ip[2], y=ip[...
D
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; import std.numeric; 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...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio, std.string, std.conv, std.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() { while (true) { int n, x; ...
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 long mod = 10^^9 + 7; void main() { int h, w, k; scan(h, w, k); k--; if (w == 1) { writeln(1); return; } auto m = ne...
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.random; void main() { auto x = readln.chomp.split.map!(to!int); int cnt; foreach (i; x[0]..x[1]+1) if (x[2] % i == 0) cnt++; ...
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 solve() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1].to!long; auto A = readln.sp...
D
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container; import std.math, std.random, std.bigint, std.datetime, std.format; void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE...
D
void main() { problem(); } void problem() { auto S = scan; string solve() { return S[2] == S[3] && S[4] == S[5] ? "Yes" : "No"; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc....
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.conv, std.string, std.range, std.algorithm, std.array, std.functional; void main() { auto N = readln.split[0].to!int; auto S = readln.chomp; auto dp = new int[][N]; foreach(ref d; dp) { d = new int[N]; } for(int i = N - 2; i >= 0; i--) { for(int j = N - 1; j > i; j--) { ...
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.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 pred)(int n) { foreach(i; 0..n) pred(); } auto ...
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 Node{ long index; long[] to; long[] cost; } void main() { auto N = scanElem; Node[] nodes; nodes.length = N+1; forea...
D
void main() { int n = readln.chomp.to!int; string s = readln.chomp; int k = readln.chomp.to!int - 1; foreach (x; s) { if (x == s[k]) x.write; else '*'.write; } writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import st...
D
import std.stdio; import std.conv; import std.string; void main(){ long n=to!int(readln.chomp),a=1; while(n--)a*=n+1; writeln(a); }
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.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void main() { int n; readV(n); int k; readV(k)...
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 mod = 10L^^9 + 7; void main() { int n, a, b, c, d; scan(n, a, b, c, d); auto fact = new long[](n + 1); auto rfact = new long[](n + 1); fa...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; long check(long op, long sum, long[] as) { foreach (a; as) { if (sum < 0) { if ((sum + a) <= 0) { op += (1 - (sum + a)); sum = 1; } else { sum += a; ...
D
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math; import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting; import std.container.binaryheap; import std.typecons; struct S{ long all; ...
D
import std; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); //aryread!string(); //auto PS = new Tuple!(long,string)[](M); //x[]=1;でlong[]全要素1に初期化 void main() { auto s = sread(); if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')...
D
import std.algorithm; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; void main () { auto tests = readln.strip.to !(int); foreach (test; 0..tests) { auto n = readln.strip.to !(int); auto a = readln.splitter.map !(to !(int)).array; auto lo = a.filter !(x => (x & 1) =...
D
import std.stdio; import std.string; import std.format; 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.concurrency; import std.traits; import std.uni; import c...
D
import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ long a = read.to!long; lo...
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); writeln((a-1)*(b-1)); } void scan(T...)(ref T args) { import std.stdio : readln; ...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
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.string; import std.conv; import std.algorithm; void main() { string[] inputs = split(readln()); int A = to!int(inputs[0]); char op = inputs[1][0]; int B = to!int(inputs[2]); if(op == '+') (A + B).writeln; else (A - B).writeln; }
D
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.uni; void main(){ string i = readln.chomp; string s; foreach(c;i){ if (isLower(c)) s ~= toUpper(c); else s ~= toLower(c); } writeln(s); }
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
// 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; void main() { readln(); auto s = readln.split(); int ans = 0; int vol(stri...
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
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.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.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.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; void main(string[ ] args) { int n; scanf("%d", &n); int n_0 = 0; int n_1 = 0; for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); if (a % 2 == 0) { ++n_0; } else { ++n_1; } } //writeln(n_0); //writeln(n_1); int ans;...
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; void main() { auto N = readln.chomp.to!int; auto A = readln.chomp; auto B = readln.chomp; long ans = 0; f...
D
import std.algorithm; import std.ascii; import std.stdio; import std.string; void main () { string s; while ((s = readln.strip) != "") { int res = 0; foreach (c; s) { if (c.isLower) { res -= c - 'a' + 1; } else if (c.isUpper) { res += c - 'A' + 1; } } writeln (res); } }
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; bool solve (int n, int [] a) { auto m = 1 << n; for (int s = 0; s < m; s++) { int r = m - 1 - s; int t = r; do { int cur = 0; foreach (i; 0..n) { if (s & (1 << i)) { cur += a[i]; } if...
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.string; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1...
D
import std.stdio, std.conv, std.array, std.string; import std.algorithm; import std.container; import std.range; import core.stdc.stdlib; import std.math; void main() { auto r = readln.chomp.to!int; writeln(r*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; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } bool calc(string s) { for (int i = 0; i < s.leng...
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() { long N = scanElem; primes(55555).filter!"a%5==1".take(N).each!writeln; } class UnionFind{ UnionFind parent = null; voi...
D
import std.stdio, std.conv, std.array; import std.algorithm; void main() { auto input = readln.split.to!(int[]); auto a = input[0]; auto b = input[1]; auto max = max(a+b, a-b, a*b); writeln(max); }
D
import std.stdio, std.conv, std.string; void main() { auto r = readln.chomp.to!int; writeln(3 * r * r); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto A = readln.chomp.to!int; auto B = readln.chomp.to!int; auto C = readln.chomp.to!int; auto X = readln.chomp.to!int; int result; foreach (a; 0..A+1) { foreach (b; 0..B+1) { auto res...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; void main() { auto M = readln.split[1].to!long; long[long] HS = [0: 0]; long c; foreach (a; readln.split.to!(long[])) { c = (c + a) % M; if (c in HS) { ++HS[c]; } else { ...
D