code
stringlengths
4
1.01M
language
stringclasses
2 values
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() { string s; readV(s); auto n = s.length; auto t = new dchar[]((n+1)/2); foreach (i; 0..(...
D
// Vicfred // https://atcoder.jp/contests/abc163/tasks/abc163_c // map import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { int n = readln.chomp.to!int; int[] a = readln.split.map!(to!int).array; int[] boss = new int[n+1]; foreach(person; a) ...
D
import std.stdio; import std.string; import std.conv; void main() { string[] input = split(readln()); int A = to!int(input[0]); int B = to!int(input[1]); if(A + B >= 10){ writeln("error"); } else { writeln(A + B); } }
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int k; rd(k); struct E{int u, v, w;} E[] edges; int n=2; void f(int x){ if(x==2){ edges~=E(1, 2, 0); edges~=E(1, 2, 1); }else{ if(x&1){ f(x-1); edges~=E(1, n, x-1); }else{ f(x/2); ...
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 calc(string[] g) {...
D
import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv; void main() { auto a = readln.split; ((a[0][$-1] == a[1][0] && a[1][$-1] == a[2][0]) ? "YES" : "NO").writeln; }
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; final class InputReader { private: ubyte[] p, buffer; bool eof; bool rawRead () { if (eof) { return fals...
D
void main() { problem(); } void problem() { auto A = scan!int; auto B = scan!int; auto C = scan!int; auto D = scan!int; bool solve() { while(true) { C -= B; if (C <= 0) return true; A -= D; if (A <= 0) return false; } } writeln(solve() ? "Yes" : "No"); } // ---------...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp.to!int; foreach (_t; 0..T) { auto N = readln.chomp.to!int; writeln(N/2); } }
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; long sum_a, min_a = long.max; int mc; foreach (a; readln.split.to!(long[])) { if (a < 0) ++mc; a = abs(a); sum_a += a; min_a...
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(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto color=new char[](n*2), a=new int[](n*2); auto pos_w=new int[](n*2), pos_b=new int[](n*2); fill(pos_w, -1); fill(pos_b, -1); foreach(i; 0..(n*2)){ rd(color[i], a[i]); a[i]--; if(color[i]=='W') pos_w[a[i]]=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; // 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons; int N; uint[100] FS; int[11][100] PS; int bit_count(uint i) { i = i - ((i >>> 1) & 0x55555555); i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); i = (i + (i >>> 4)) & 0x0f0f0f0f; i = i + (i >>> 8); i = i + (i...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long[10^^5*2+10] F, RF; void init() { F[0] = F[1] = 1; foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P; { RF[$-1] = 1; auto x = F[$-1]; auto k = P-2; ...
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; string d1 = "..##"; string d2 = ".#.#"; string r1 = ""; string r2 = ""; ...
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; import std.concurrency; import core.bitop : popcnt; alias Generator ...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array; void main(){ auto s=readln().chomp().split().map!(to!int); int a=s[0],b=s[1]; if(a<=8&&b<=8) writeln("Yay!"); else writeln(":("); }
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; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import ...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; import std.math; void main(){ while(true){ int n = to!int(chomp(readln())); if(n == 0) break; int ans = 0; int nf=8; while(nf>0){ ans += n / pow(5,nf) ; nf--; } writeln(ans); } }
D
import std.stdio; import std.algorithm; import std.container; import core.stdc.stdio; import std.typecons; int n,k; int[][] sg; int[][] graph; int[2][] queue; bool[] visited; int gSize=0; void buildGraph(int idx,int r){ visited[] = false; int qc=0; visited[idx]=true; foreach(c;sg[idx]){ queue[qc++] = [1,c]; ...
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 cnt = s.count!(a=>a=='o'); auto d = 15 - s.length; ...
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; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();} T[] aryread(T = long)(){return readln.split.to!(T[])();} void scan(TList...)(ref TList Args){auto line = readln.split(); foreach (i, T; TList){T val = line[i]...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii; import std.typecons, std.functional, std.traits; import std.algorithm, std.container; import core.stdc.stdlib, core.bitop; enum MOD=pow(10,9)+7; void main() { auto S = scanString; long[2][] dp; dp.length = S.leng...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop; void main() { auto hwk = readln.split.to!(int[]); auto H = hwk[0]; auto W = hwk[1]; auto K = hwk[2]; char[][] C; foreach (_; 0..H) C ~= readln.chomp.to!(char[]); int r = int.m...
D
import std.stdio; import std.string; import std.conv; void main() { auto line = chomp(readln()).split(" "); int H = to!int(line[0]), W = to!int(line[1]); while(H || W) { writeln(repeat("#", W)); foreach(int i; 2 .. H) { writeln("#" ~ repeat(".", W - 2) ~ "#")...
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; static import std.ascii; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] aryread(T = long)(){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 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 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; import std.string; import std.conv; import std.range; import std.algorithm; void main() { int count = 0; string input; while ((input = readln.chomp).length != 0) { if (hantei(input)) count++; } writeln(count); } bool hantei(string input) { for (int i = 0; i < (input...
D
void main() { auto s = rs; writeln(s[0], s.length-2, s[$-1]); } // =================================== import std.stdio; import std.string; import std.functional; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.numeric;...
D
void main() { int[] abc = readln.split.to!(int[]); writeln(abc.sum - abc.reduce!max); } 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.un...
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 r = readln.chomp.to!int; if (r < 1200) { writeln("ABC");...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp.dup; s.reverse(); writeln(s); }
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() { long n, m; scan(n, m); auto s = readln.chomp; auto t = readln.chomp; auto l = lcm(n, m); auto sg = l / m; auto tg = l /...
D
import std.stdio, std.string, std.conv; void main() { auto x = readln.chomp.to!int; int sum, i; while (x > sum) sum += ++i; writeln(i); }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.string; import std.conv; void main() { auto M = readln.chomp.to!int; auto x = 48-M; writeln(x); }
D
import std.container; import std.range; import std.algorithm; import std.array; import std.string; import std.conv; import std.stdio; import std.container; void main() { auto s = readln.chomp; write(s); if (s[$ - 1] == 's') { writeln("es"); } else { writeln("s"); } }
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { int[string] memo; foreach(str; ["A", "B", "AB", "O"]) { memo[str] = 0; } while(true) { auto line = readln; if(!line)break; auto f = line.chomp.split(","); ++memo[f[1]]; } foreach...
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 readInt() { return readInts()[0]; } auto readInts() { return array(map!(to!int)(rea...
D
import std.stdio, std.string, std.conv, std.regex; void main() { auto n = readln.chomp; if(n[0] == '9' || n[1] == '9'){ writeln("Yes"); } else { writeln("No"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; long P = 10^^9+7; long[10^^5+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(long x)...
D
// Vicfred // https://atcoder.jp/contests/abc159/tasks/abc159_b // string manipulation import std.stdio; import std.string; bool palindrome(string s) { long n = s.length; for(long i = 0; i < n/2; i++) if(s[i] != s[$-i-1]) return false; return true; } void main() { string s = readl...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm, std.math; long q, h, s, d; rd(q, h, s, d); long n; rd(n); s=min(s, 2*h, 4*q); long c=n*s; if(n%2==0){ c=min(c, n/2*d); }else{ c=min(c, s+(n-1)/2*d); } writeln(c); } void rd(T...)(ref T x){ import std.stdio, std.string, s...
D
long solve(long a, long b, long h){ return (a+b)*h/2; } void main(){ int a = inelm(); int b = inelm(); int h = inelm(); solve(a, b, h).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 t...
D
import std.stdio; import std.string; import std.conv; int main() { int line = readln.chomp.to!int; int n = readln.chomp.to!int; int[31] values; foreach(int i;0..line) { values[i] = i+1; } foreach(int i;0..n) { auto input = readln.chomp.split(","); int a = to!int(input[0]); int b = to!int(input[1]); ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=readln.split.to!(long[]); long tot=0; for(auto i=0, j=0, s=0L; i<n; i++){ while(j<n){ if((s+a[j])==(s^a[j])) s+=a[j], j++; else break; } // [i, j) : valid tot+=(j-i).to!(long); s-=a[i]; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; long P = 998244353L; long[10^^5*3+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; } ...
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, W; scan(N, W); auto w = ...
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 (1) { auto s = readln.chomp; if (s == ".") return; writeln(isBalance(s) ? "yes" : "no"); } } bool isBalance(string ...
D
import std.stdio; import std.string; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; void main() { int maxN = 10^^6; int[] f, f_odd; for(int n=1; ;n++) { ...
D
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens....
D
// Cheese-Cracker: cheese-cracker.github.io void theCode(){ ll k = scan; k -= 1; ll rt = to!ll(floor(sqrt(to!double(k)))); if((rt + 1) *(rt + 1) <= k){ rt += 1; } ll lef = k - rt*rt; ll d = min(rt, lef); ll b = max(0, lef - rt); ll x = (rt+1) - b; ll y = d + 1; write...
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; import std.range, std.algorithm, std.array; void main() { int a,b; scan(a,b); a %= 3, b %= 3; writeln(a == b && a != 0 ? "Impossible" : "Possible"); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=readln.split.to!(long[]); auto dp=new int[](n); dp[0]=1; foreach(i; 1..n){ dp[i]=1; if(a[i]<=a[i-1]*2){ dp[i]=max(dp[i], dp[i-1]+1); } } writeln(dp.reduce!(max)); } void rd(T...)(ref T x){ imp...
D
void main() { int n = readln.chomp.to!int; int a = readln.chomp.to!int; writeln(n % 500 <= a ? "Yes" : "No"); } 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; imp...
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 N = readln.chomp.to!int; auto A = readln.chomp; if (A.front == 'W' || A.back == 'W') { ...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); s[3]='8'; writeln(s); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv, std.exception; auto l=readln.split; enforce(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e))...
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, a, b, c; scan(n, a, b, c); int ans = n - (a + b - c); writeln(ans); } void scan(T...)(ref T args) { import std.stdio : 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; } void main() { auto xs = readints; writeln(xs...
D
import std.stdio; import std.string, std.conv, std.array, std.algorithm; import std.uni, std.math, std.container, std.typecons; import core.bitop, std.datetime, std.range; void main(){ auto rd = readln.split.to!(int[]); auto n = rd[0], q = rd[1]; auto ds = new int[][](n, 1); auto n2s = iota(n).array; ...
D
import std.stdio; import std.regex; void main(){ auto io = new IO(); auto N = io.line()[0]; auto A = io.line(N); size_t paired = 0; size_t surplus = 0; foreach( i,a ; A ){ if( surplus == 1 ){ paired += (a+1)/2; surplus = ( (a+1)/2 ) ? (a+1)%2 : 0 ; }else{ paired += a/2; surplus = a%2; } ...
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.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.replace("C", "A").replace("G", "A").replace("T", "A"); int re...
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 AS = readln.split.to!(long[]); auto BS = readln.split.to!(long[]); long r; foreach (i; 0..N) { if (BS[i] <= AS[i]) { r += BS[i...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.algorithm; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() { auto tokens = split(my_readln()); auto S = to!string(tokens[0]); if (S.length == 2) writeln(S); else { foreach_re...
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; import std.container : DList; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads...
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.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 A, B, M; scan(A, B, M); auto a = readln.split.to!(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.string; void main() { auto S = readln.chomp; auto T = readln.chomp; auto N = S.length.to!int; auto M = T.length.t...
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ auto num = readln.chomp.to!int; string[] persons; for(auto i = 0; i < num; i++){ persons ~= readln.chomp; } long[string] groups; groups.divide_march(persons); ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; writeln(s.replace(",", " ")); }
D
import std.stdio; import std.string; import std.conv; import std.range; import std.algorithm; import std.math; import std.regex; void main() { auto ip = readln.split.to!(int[]), a = ip[0], b = ip[1]; ((a*b)&1 ? "Odd" : "Even").writeln; }
D
import std.array : split; import std.conv : to; import std.stdio; import std.string : strip; private { string[] temp; } void main() { read(); int n = get!int(0); int count = 0; foreach (i; 1 .. n + 1) { count += (n - (i - 1)) * i - i + 1; } stdout.write(count); } void read() { temp = split(strip(stdin...
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.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.stdio, std.string, std.conv, std.algorithm; void main() { int n = readln.chomp.to!int; foreach (i; 1 .. n+1) { if (i % 3 == 0 || i.to!string.canFind("3")) write(" ", i); } writeln; }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; immutable long MOD = 10...
D
import std.stdio; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; void main(){ long x = readln.chomp.to!long; long i; for(i = 0; i * (i + 1) / 2 < x; i ++){ } i.writeln; }
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.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.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[]); } long calc(long x, long y) { if (x % y == 0) return -1; for (i...
D
#!/usr/bin/rdmd import std.stdio; import std.conv: to; import std.array: split; import std.ascii: newline; immutable greater = "a > b"; immutable less = "a < b"; immutable equa = "a == b"; void main() { int[2] a; foreach (string line; lines(stdin)) { if(line == newline) break; else { ...
D
import std.stdio; import std.string; import std.conv; import std.array; import std.math; void main() { auto buf = readln.split; int N = buf[0].to!int; int K = buf[1].to!int; int[] h = readln.split.to!(int[]); int[] cost = new int[N]; cost[0] = 0; foreach (i; 1..N){ int min_c = cost...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void main() { auto rs = new int[](10^^4+1); foreach (x; 1..101) foreach (y; 1..101) foreach (z; 1..101) { auto n = x^^2 + y^^2 + z^^2 + x*y + y*z + z*x; if (n > 10^^4...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; auto as = readln.split.to!(long[]); auto cs = new long[](N); foreach (i, a; as) { ...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = () ...
D
//dlang template---{{{ import std.stdio; import std.conv; import std.string; import std.array; import std.algorithm; import std.typecons; import std.math; import std.range; // MIT-License https://github.com/kurokoji/nephele class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : ...
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() { string s; readV(s); auto a = s.map!(c => cast(int)(c-'0')).array; foreach (i; 0..1<<3) ...
D
import std.algorithm; import std.conv; 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; bool [int] b; foreach (i; 0..n) { foreach (j; i ...
D
// Cheese-Cracker: cheese-cracker.github.io const ll PRIME = 10^^9 + 7L; void theCode(){ int n; n = scan!int; auto arr = scanArray; ll summ = 0; foreach(el; arr){ summ += el; summ %= PRIME; } auto freq = new ll[61]; foreach(el; arr){ for(int s = 0; s <= 60; ++s){ ll mas...
D