code
stringlengths
4
1.01M
language
stringclasses
2 values
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; void main(){ int[] ch = [0,6000,4000,3000,2000]; for(int i=0;i<4;i++){ auto s = split(readln()).to!(int[]); writeln(c...
D
import std.stdio; import std.string; import std.conv; import std.range; import std.array; import std.algorithm; import std.typecons; void main(){ auto hw = readln().chomp().split().map!(to!int).array(); string[] grids; foreach(i; 0..(hw[0])){ grids ~= readln().chomp(); } solve(grids).writel...
D
void main() { auto N = ri; int m = int.min; int res; foreach(i; 0..N) { auto p = ri; m = max(m, p); res += p; } res -= m / 2; res.writeln; } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; impo...
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 inf = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int n; scan(n); auto a = readln.split.to!(...
D
import std.stdio; import std.algorithm; import std.math; import std.string; import std.conv; import std.range; void main() { foreach (string line; stdin.lines) { string s = line.chomp; int joi = 0; int ioi = 0; for (int i = 0; i < s.length - 2; i++) { if (s[i..i+3] == "J...
D
import std.functional, std.algorithm, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv; void dfs(bool[][] dp, bool[] visited, int v) { visited[v] = true; foreach (int i, e; dp[v]) { if (e) { if (!visited[i]) { d...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); foreach(i; 0..10){ char[] t; foreach(_; 0..3) t~=i+'0'; if(s[0..($-1)]==t){writeln("Yes"); return;} if(s[1..$]==t){writeln("Yes"); return;} } writeln("No"); } void rd(T...)(ref T x){ impo...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; template bsearch(alias fun) { import std.functional: unaryFun; alias f = unaryFun!fun; int bsearch(T)(T[] arr) { if (arr.empty) return -1; if (!f(arr[0])) return -1; if (f(arr[...
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 a = readln.split[0].to!int; auto b = readln.split[0].to!int; auto c = readln.split[0].to!int; auto d = readln.split[0].to!int; auto e = readln.split[0].to!int...
D
import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math; void main(){ auto s=readln().chomp().split().map!(to!int); int a=s[0],b=s[1],c=s[2],ans=0; if(a>b && a>c) ans=b*c/2; else if(b>a && b>c) ans=c*a/2; else ans=a*b/2; writeln(int(ans)); }
D
import std.stdio,std.regex; void main(){ auto next = readln().chomp().to!size_t; auto list = [111,222,333,444,555,666,777,888,999]; foreach( val; list ){ if( next <= val ){ writeln(val); break; } continue; } return; } import std.string,std.conv;
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons; import std.math, std.numeric; void main() { long n, x; scan(n, x); if (x > n - x) { x = n - x; } if (x == n - x) { writeln(3*x); return; } long ans = n; void dfs(lon...
D
import std.functional, std.algorithm, std.container, std.typetuple, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv, std.format; void main() { auto ip = readln.split.to!(int[]); int count; fo...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional; void main() { auto s = readln.chomp; auto n = s.length; foreach (c; s) { if (c == 'A') break; --n; } foreach_reverse (c; s) { if (c == 'Z') break; --n; } writeln(n); }
D
import std.algorithm; import std.array; import std.bigint; import std.bitmanip; import std.conv; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; // 差の絶対値 @nogc @safe pure T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } // 切り上げ除算 @nogc @safe pur...
D
import std.stdio, std.algorithm, std.conv, std.array, std.range, std.string, std.math, std.typecons; void main() { auto nk = readln.split.to!(int[]); auto N = nk[0]; auto K = nk[1]; long cnt; foreach (long i; 0..N) { if (i < K) continue; else { cnt += N / (i...
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.array, std.algorithm; void main() { auto abc = readln.chomp.split(" ").map!(to!int); writeln( abc.count!"a==5" == 2 && abc.count!"a==7" == 1 ? "YES" : "NO" ); }
D
/+ dub.sdl: name "C" dependency "dunkelheit" version="1.0.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.math; // import dkh.foundation, dkh.scanner; immutable int MD = 3*(10^^5); immutable int S = MD/2; int main() { Scanner sc = new Scanner(stdin); scope(exit) assert(!sc.hasNext); ...
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; enum mod = 1_000_000_007L; void main() { int N; string S; scan(N); s...
D
void main() { auto N = ri, K = ri, X = ri, Y = ri; if(N <= K) { writeln(N*X); return; } else { writeln(K*X + (N-K)*Y); return; } } // =================================== import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import...
D
// Try AtCoder // author: Leonardone @ NEETSDKASU import std.stdio : readln, writeln; import std.array : split; import std.string : chomp; import std.conv : to; auto gets() { return readln.chomp; } auto getVals(T)() { return gets.split.to!(T[]); } void main() { auto xs = getVals!int; auto ...
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; void main() { readln; auto list = scanArray; long r=long.max; foreach(s; [true, false]) { long sum; boo...
D
import std.stdio, std.string, std.conv, std.algorithm, std.range; void main(){ int m, f, r; string rs; while(true){ scanf("%d %d %d", &m, &f, &r); if (m == -1 && f == -1 && r == -1) break; if (m == -1 || f == -1){ rs ~= "F"; } else if (m+f>=80){ rs ~= "A"; } else if (m...
D
import std.stdio, std.math, std.conv, std.array, std.string, std.algorithm; void main() { uint c = to!uint(readln().chomp); for (uint i = 0; i < c; ++i) { double[] dx = map!(to!double)(readln().chomp.split).array; double[] ap = dx[0..2]; double[] bp = dx[3..5]; double ar = dx[2]...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { string[] input = new string[](8); while ((input = readln.chomp.split(" ")).length != 0) { auto points = input.map!(to!double); if (points[0] <= points[6] && points[2] >= points[4] && ...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; import std.typecons; import std.bigint; // import dcomp.foundation, dcomp.scanner; // import dcomp.container.deque; int main() { auto sc = new Scanner(stdin); int n, m, k; sc.read(...
D
import core.bitop; import core.checkedint; import core.simd; import core.stdc.stdio; import core.stdc.stdlib; import core.stdc.string; import std.algorithm; import std.array; import std.ascii; import std.bigint; import std.bitmanip; import std.complex; import std.container; import std.conv; import std.datetime; import ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[10^^5*2+2] LR, DU; void main() { auto hwn = readln.split.to!(int[]); auto H = hwn[0]; auto W = hwn[1]; auto N = hwn[2]; auto rc = readln.split.to!(int[]); auto SR = rc[0]; auto SC = r...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int[] buf = readln.chomp.split.to!(int[]); int a = buf[0], b = buf[1]; if (a + b == 15) { writeln("+"); } else if (a * b == 15) { writeln("*"); } else { writeln("x"); } }
D
void main() { problem(); } void problem() { auto X = scan!long; long solve() { long answer; auto num500 = X / 500; auto num5 = (X - num500 * 500) / 5; return num500 * 1000 + num5 * 5; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std....
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int a, b; char op; scan(a, op, b); if (op == '+') { writeln(a+b); } else { writeln(a-b); } } void scan(T...)(ref T args) { import std.stdio : readln; import std.algo...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto n = readln.chomp.to!int; auto l = new long[](n+1); l[0] = 2; l[1] = 1; foreach (i; 2..n+1) l[i] = l[i-1]+l[i-2]; writeln(l[n]); }
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
// Cheese-Cracker: cheese-cracker.github.io import std.stdio, std.conv, std.functional, std.string, std.algorithm; import std.container, std.range, std.typecons, std.numeric, std.math, std.random; alias ll = long; alias rbt = redBlackTree; alias tup = Tuple!(long, long); static string[] inp; T rd(T = long)(){while(!in...
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.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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int h, w; rd(h, w); auto c=new char[][](h); foreach(i; 0..h) c[i]=readln.chomp.to!(char[]); auto t=readln.chomp.to!(char[]); import std.typecons; alias P=Tuple!(int, "i", int, "j"); P st, gl; foreach(i; 0..h)foreach(j; 0..w){ if...
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, 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 int M = 30; long x, y; int cnt = 0; int ask(long c, long d) { debug { cnt += 1; if ((x^c) >...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio, std.string, std.conv, std.algorithm; void main(){ int n; rd(n); long a, b; rd(a, b); long[] cand; for(int i=2; i*i<=a; i++){ if(a%i==0){ cand~=i; while(a%i==0) a/=i; } } if(a>1) cand~=a; for(int i=2; i*i<=b; i++){ if(b%i==0){ cand~=i; while(b%i==0) 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.string, std.conv, std.array, std.algorithm; void main() { while (true) { auto a = readln.split.map!(to!int); if (a[0] == 0 && a[1] == 0) break; if (a[0] < a[1]) writeln(a[0], " ", a[1]); else writeln(a[1], " ", a[0]); } }
D
import std.stdio; immutable mod = 4294967311L; long[] inv; void main(){ long x; int n, y, op; scanf("%d", &n); inv = new long[1_000_001]; inv[1] = 1; foreach(_; 0..n){ scanf("%d%d", &op, &y); if(op >= 3 && y < 0) x = -x, y = -y; if(op == 1) x += y; else if(op == 2) x -= y; else if(op == 3) x *= y; e...
D
import std.stdio, std.string, std.conv; void main() { foreach (i; 1 .. 10001) { int x = readln.chomp.to!int; if (x == 0) break; writeln("Case ", i, ": ", 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 inf3 = 1_001_001_001; enum inf6 = 1_001_001_001_001_001_001L; enum mod = 1_000_000_007L; void main() { int n, t; scan(n, t); auto a = readln.spli...
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { ret...
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); writeln(n < 100...
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
void main() { long h, w; rdVals(h, w); if (h == 1 || w == 1) 1.writeln; else writeln((h * w + 1) / 2); } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; T rdElem(T = long)() if (!is(T == struct)) { return readln.chomp.to!T; } alias rdStr = rdElem!string; alias rdDchar = rdElem!(dchar[]); T...
D
import std.string; import std.stdio; import std.range; import std.algorithm; import std.array; import std.conv; void bfs(ref int[] table, int curr) { // 上下左右 int[] directions = [1, 14, -1, -14]; int[] que; que ~= curr; while(que != null) { auto point = que.front; que.popFront; foreach(d; dir...
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, R; scan(N, R); auto ans ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nab = readln.split.to!(long[]); auto N = nab[0]; auto A = nab[1]; auto B = nab[2]; if ((B-A)%2 == 0) { writeln((B-A)/2); } else { writeln(min(A + (B-A)/2, N...
D
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range; pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); } alias reads = Reads!int; pragma(inline, true) void scan(Args...)(ref Args args) { string[] ss = readln.split; foreach (i, ref arg ; args) ar...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); int[] a; for(int x=6; x<=n; x*=6) a~=x; for(int x=9; x<=n; x*=9) a~=x; a~=1; auto dp=new int[](n+1); const int inf=1_000_000_000; fill(dp, inf); dp[0]=0; foreach(i; 0..n)foreach(e; a){ if(i+e<=n) dp[i+e]=min...
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"; T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.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.datetime; void main() { auto S = readln.chomp; auto s = readln.split.map!(to!int); auto X = s[0]; auto Y = s[1]; int...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int r, c, si, sj, gi, gj; rd(r, c, si, sj, gi, gj); const int mod = 10 ^^ 9 + 7; const int inf = 10 ^^ 9; auto dist = new int[][](r, c), dp = new int[][](r, c); foreach (i; 0 .. r) foreach (j; 0 .. c) dist[i][j] = inf; struc...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.datetime; import std.numeric; import std.math; import std.string; string my_readln() { return chomp(readln()); } void main() { auto tokens = my_readln().split(); auto N = tokens[0].to!ulong; auto M = tokens[1].to!ulong; ulong[][...
D
void main() { auto N = ri; if(N == 1) { writeln(1); return; } auto arr = generate_prime_list(N); ulong[ulong] m; foreach(i; 1..N+1) { foreach(j; arr) { while(i % j == 0) { m[j]++; i /= j; } } if(arr.canFind(i)) m[i]++; } ulong mod = 1000000007; m.values.map!(i => i + 1).reduce!((i, j) =...
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 vs = readln.split.to!(int[]); auto cs = readln.split.to!(int[]); int r; foreach (i; 0..N) { if (vs[i] - cs[i] > 0) r += vs[i] - cs[i]; ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; int calc(int g, int[][]...
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 d...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto n = readln.chomp.to!int; auto c = new int[][][](n); foreach (i; 0..n-1) ...
D
import std; void main() { int t; scanf("%d", &t); getchar(); foreach(_; 0..t) { int n; scanf("%d", &n); getchar(); long[] a = readln.strip.split(" ").to!(long[]); long[] b = readln.strip.split(" ").to!(long[]); foreach (i; 0..n) { ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math; void main() { auto N = readln.chomp.to!int; auto AS = readln.split.to!(int[]); auto cnt = int.max; foreach (a; AS) { int i; for (; a && a%2 == 0; ++i) a /= 2; cnt = min(cnt, i); } writeln(cnt); ...
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; 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 n = lread(); auto a = aryread(); // writeln(a); lon...
D
import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.conv, std.stdio, std.typecons; void main() { auto x = readln.chomp.to!int; writeln(x ^^ 3); }
D
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; int n; int[] a; int dfs(int depth, bool gu) { if (depth == n) { return gu; } int cnt = 0; for (in...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void main() { auto N = readln.chomp.to!int; auto rs = new int[][N]; int[] as = [0]; foreach (i; 1..N) { auto a = readln.chomp.to!int-1; as ~= a; rs[a]...
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() {//try{ auto tokens = split(my_readln()); auto S = to!string(tokens[0]); ulong ans, cnt_b; foreach (i, e; S) { if (e...
D
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric; void main(){ auto abc=readln.split.map!(to!int).array; auto gcd=gcd(abc[0],abc[1]); writeln(abc[2]%gcd==0?"YES":"NO"); }
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; import std.typecons; alias Edge = Tuple!(int, "from", int, "to", long, "cost"); Edge[] edges = new Edge[](0); int[][] ordg; int[][] revg; bool[] isOk; bool[] i...
D
void main() { long[] tmp = rdRow; long n = tmp[0], a = tmp[1]; long[] x = rdRow; long lim = 50 * 50 + 1; long[][] dp = new long[][](n+1, lim); foreach (i, y; x) { foreach_reverse (j; 1 .. i+1) { foreach (k; 0 .. lim-y) { dp[j+1][k+y] ...
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; while (T--) { auto s = readln.split.map!(to!long); auto...
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; // dfmt off T lread(T = long)(){return readln.chomp.to!T();} T[] lreads(T = long)(long n){return generate(()=>readln.c...
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; auto b = readln.splitter.map !(to !(int)).array; for...
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.split.map!(to!int); auto N = s[0]; auto K = s[1]; auto A = readln.split.map!...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to void main() { string s = chomp(readln()); for(int i=0; i<s.length; ++i){ if(i%2 == 0){ write(s[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
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; bool calc(int x, int y)...
D
void main() { problem(); } void problem() { auto N = scan!int; auto X = scan!int; auto T = scan!int; int solve() { auto t = N % X == 0 ? N / X : 1 + N / X; return t * T; } solve().writeln; } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, s...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a=new int[](n); foreach(i; 0..n) rd(a[i]); auto dp=new int[](n); dp[0]=1; bool up=true; foreach(i; 1..n){ if(up){ if(a[i-1]<a[i]) dp[i]=dp[i-1]+1; else if(a[i-1]==a[i]) dp[i]=dp[i-1]; else dp[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
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 File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(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 n = readln.chomp.count('7'); if (n) { writeln("Yes"); } else { write...
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; int n, k; void main() { int n = readln.chomp.to!int; int k = readln.chomp.to!int; in...
D
void main() { int[] tmp = readln.split.to!(int[]); int h = tmp[0], w = tmp[1], k = tmp[2]; int[][] field = new int[][](h, w); int cnt; int row; foreach (i; 0 .. h) { string s = readln.chomp; if (s.canFind('#')) { int col; foreach (j, x; s) { ...
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 s = readln.strip; auto t = s[4..$]; auto v = t.to !(long); long n = 1989 - 1; int len = 1; while (len <= t.length) { do ...
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; T lread(T = long)() { return readln.chomp.to!T(); } T[] aryread(T = long)() { return readln.split.to!(T[])(); } void sca...
D
import std.stdio; import std.string; import std.conv; void main() { string s = readln.chomp; ulong k = readln.chomp.to!ulong; if (s[0] != '1') { s[0].writeln; return; } foreach(i, c; s) { if (c != '1') { if (i < k) { s[i].writeln; ...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.container.rbtree; import std.conv; import std.stdio; import std.string; import std.traits; struct Input { long n, a, b; } void parseInput(T)(out Input input, T file) { with (file) with (input) { auto ar = readl...
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