code
stringlengths
4
1.01M
language
stringclasses
2 values
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() { string input = readln.chomp; switch(input) { case "1 0 ...
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[]); } int calc(int[][] xs) { int n = cast(int) xs[0].length; ...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto AS = new int[][](3, 3); foreach (i; 0..3) foreach (j, a; readln.split.to!(int[])) AS[i][j] = a; auto N = readln.chomp.to!int; foreach (_; 0..N) { auto b = readln.chomp.to!in...
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; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; import std.numeric; void main() { auto x = readln.chomp.to!long; auto t = x % 11; auto res = (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, 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; string S; scan(N); s...
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
void main() { long[] tmp = readln.split.to!(long[]); long n = tmp[0], m = tmp[1]; long[] dp = new long[](1<<n); dp[1..$] = 1L << 60; foreach (i; 0 .. m) { tmp = readln.split.to!(long[]); long a = tmp[0], b = tmp[1]; long[] c = readln.split.to!(long[]); long pos;...
D
void main() { auto S = rs; auto T = rs; ulong res; foreach(i; 0..S.length) { if(S[i] != T[i]) res++; } res.writeln; } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.conta...
D
import std.conv, std.stdio, std.algorithm, std.string, std.range, std.math; void main() { readln; const S = readln.chomp; S.uniq.count.writeln; }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; bool[1000001] MEMO; void main() { auto s = readln.chomp.to!int; int i; for (;;) { ++i; if (MEMO[s]) { writeln(i); return; } MEMO[s] = true; ...
D
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range; void main() { auto N = readln.chomp.to!int; auto A = readln.chomp.to!int; writeln(N^^2 - A); }
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; long[] m = [31,28,31,30,31,30,31,31,30,31,30,31]; void main(){ while(true){ auto s = readln().split().to!(long[]); if(s[...
D
void main() { dchar[] s = rdDchar; dchar[] t = rdDchar; long len = s.length; foreach (i; 0 .. len) { if (s == t) { "Yes".writeln; return; } s = s[$-1] ~ s[0..$-1]; } "No".writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60;...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a = readln.split.to!(int[]); long ans = 0; for (int i = 0, j = 0, s = 0; i < n; s ^= a[i++]) { while (j < n && ((s & a[j]) == 0)) { s ^= a[j++]; ans += (j - i); } } writeln(ans); } void rd(T......
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
/+ 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 std.stdio; void main(){ for(int x=1;x<10;x++){for(int y=1;y<10;y++){ writeln(x,"x",y,"=",x*y); }} }
D
import std.stdio; import std.string; import std.algorithm; void main() { foreach (input; stdin.byLine) { // 勝敗を判定 string result = judge(input.chomp); // 結果を出力 result.writeln; } } string judge(char[] banmen) { // 勝ち筋 auto combs = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; import std.math; void main(){ while(true){ auto s1 = readln(); if(stdin.eof()) break; auto s = split(s1); int a = to!int(s[0]); int b = to!int(s[1]); int oth = to!int(s[2]); int[11] cards; cards = 0; cards[a]--; cards[b]--; car...
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.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); string s; readV...
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); writeln(n.nsqrt^^2); } pure T nsqrt(T)(T n) { import std.algorithm, st...
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!long; long r; foreach (a; 1..N) { auto b = N/a; r += b - (N%a == 0 ? 1 : 0); } writeln(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; 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.string, std.conv, std.algorithm; import std.math; void main(){ writeln("Odd"); }
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(){ import std.stdio, std.string, std.conv, std.algorithm; int n=14; auto a=readln.split.to!(long[]); long ret=0; foreach(i; 0..n)if(a[i]>0){ auto b=a.dup; long k=b[i]; b[i]=0; foreach(j; 0..n) b[j]+=k/n; for(int j=1; j<=(k%n).to!(int); j++) b[(i+j)%n]+=1; long score=0; f...
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; import std.exception; T gcd(T) (T a, T b) pure nothrow @nogc { if (a < b) { swap (a, b); } while (b) { T 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.bigint, std.string; void main() { int n; scanf("%d", &n); int[] a = new int[n]; for(int i = 0; i<n; i++) { scanf("%d", &a[i]); } int [] b= new int[n]; for (int i =0; i < n; ++i) { b[i] = -1; } b[0] = a[0]; int c = 1; int i = 1; while (i < n) { c +=1; b[c-1] = a[...
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, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n; scan(n); int ans; int set = (1<<26) - 1; bool safe; foreach (i ; 0 .. n-1) { char e; string s; scan(...
D
import std.algorithm; import std.conv; import std.range; import std.stdio; import std.string; void main () { auto tests = readln.strip.to !(int); multitest_loop: foreach (test; 0..tests) { auto n = readln.strip.to !(int); auto s = readln.strip; auto t = readln.strip; if (n.iota.any !(i => s[i] > t[i])) { ...
D
import std.stdio, std.conv, std.string; void main() { int n,m,k; scanf("%d %d %d", &n, &m, &k); foreach (i;0..(m+1)) { foreach (j;0..(n+1)) { auto a = n*i + (m-2*i)*j; if (a == k) { writeln("Yes"); return; } } } writeln("No"); }
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; T gcd(T)(T a, T b) { ...
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; void main(){ auto n=readln().chomp.to!int; long[] Ts; long[] As; foreach(i;0..n){ auto ln=readln.split.map!(to!long).array...
D
import std.stdio; // ??\???????????????????????? import std.string; // chomp????????????????????????(?????????????????????) import std.conv; // to???????????????????????? import std.array; // split????????????????????? import std.algorithm; // map????????????????????? void main() { uint i = 1; while (true) {...
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 S = readln.chomp; auto N = S.length.to!int; auto dp = new long...
D
void main(){ int[] atox; int cnt; foreach(i; 0..4)atox ~= _scan(); for(int an; an<=atox[0]; an++){ for(int bn; bn<=atox[1]; bn++){ for(int cn; cn<=atox[2]; cn++){ if(500*an+100*bn+50*cn==atox[3])cnt++; } } } cnt.writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.ma...
D
import core.bitop; import std.algorithm; import std.ascii; import std.bigint; import std.conv; import std.functional; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.random; import std.typecons; alias sread = () => readln.chomp(); alias Point2 = Tuple!(long, "y", ...
D
import std.stdio, std.conv, std.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.stdc.stdio; import std.algorithm; char[][] mapdata; bool[] visited; int[3][] queue; int w,h,n; int len(int[2] p1,int[2] p2){ visited[] = false; queue[0]=[p1[0],p1[1],0]; visited[p1[0]*w+p1[1]] = true; int[] dx = [0,-1,0,1]; int[] dy = [-1,0,1,0]; int qc=1; for(int i=0;i<w*h;i++){ int y=queu...
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.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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum cs = [6,36,216,1296,7776,46656,279936,9,81,729,6561,59049,531441]; void main() { auto N = readln.chomp.to!int; auto DP = new int[][](cs.length, N+1); foreach (ref dp; DP) dp[] = -1; int solve(i...
D
import std.stdio; import std.conv; import std.algorithm; import std.range; import std.string; import std.math; import std.format; import std.datetime; import std.typecons; void main() { foreach (string line; stdin.lines) { int n = line.chomp.to!int; int i = 0; int[] ans; while (n != 0) { if (n...
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 M = s[1]; auto G = new UndirectedGra...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n, m; rd(n, m); auto a = new int[][](n, m); foreach (i; 0 .. n) { a[i] = readln.split.to!(int[]); } auto b = new int[][](n, m); foreach (i; 0 .. n) { b[i] = readln.split.to!(int[]); } if (n < 2 || m < 2) { bool al...
D
import std.stdio; import std.string; import std.array; import std.range; import std.algorithm; import std.conv; void main(string[] args) { auto input = readln().chomp.split.map!(to!int); max(input[0]+input[1],input[0]-input[1],input[0]*input[1]).writeln; }
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, T; scan(N, T); auto a =...
D
import std.stdio,std.string,std.array,std.algorithm,std.range,std.conv; import std.algorithm:rev=reverse; void main(){ auto input=readln.chomp.split.to!(int[]); auto n=input[0]; auto m=input[1]; auto result=n*(n-1)/2; result+=m*(m-1)/2; result.writeln; }
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; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { // 1*2*3*4*5*6 == 2^^4 * 3^^2 * 5 // 1* // 2* // 3* // 2*2* // 5* // 2*3 auto n = lread(); long[long] aa; foreach (i...
D
void main() { int n = readln.chomp.to!int; int[] v = readln.split.to!(int[]); int[] c = readln.split.to!(int[]); int ans; foreach (i; 0 .. n) { int diff = v[i] - c[i]; if (diff > 0) ans += diff; } ans.writeln; } import std.stdio; import std.string; import std.array; import s...
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.format; void main() { auto D = readln.chomp.to!int; sw...
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() { while (true) { auto rd = readln.split.map!(to!int); auto h = rd[0], w = rd[1]; if (h == 0 && w ==...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; alias E = Tuple!(int, "...
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; auto A = readln.split.to!(uint[]); uint count; loop: while(true) { foreach(ref A_i; A) { if(A_i % 2 != 0) break loop; else A_i /= 2; } count++; } ...
D
// Vicfred // https://atcoder.jp/contests/abc136/tasks/abc136_c import std.algorithm; import std.array; import std.conv; import std.stdio; import std.string; void main() { const long n = readln.chomp.to!long; long[] h = readln.split.map!(to!long).array; long maxima = h[0] - 1; foreach(square; h) { ...
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; writeln(N%2 == 0 ? N : N*2); }
D
import std.stdio; import std.conv; import std.string; void main() { int x = readln.chomp.to!int; writeln(x * x * x); }
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto hw = readln.chomp.split.to!(int[]); auto c = new int[][](10, 10); foreach...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; import std.traits; struct Input { int n; } void parseInput(T)(out Input input, T file) { with (file) with (input) { n = readln().strip().to!int; } } auto main2(Input...
D
import std.algorithm; import std.array; import std.conv; import std.stdio; void main() { int[] n_and_m; int n; int m; int[] a_tachi; int total_vote_count; n_and_m = readln.split.to!(int[]); n = n_and_m[0]; m = n_and_m[1]; a_tachi = readln.split.to!(int[]); total_vote_count = a_tachi.sum; ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; int cnt; void InsertionSort(int[] arr, int n, int g){ for(int i = g; i < n; ++i){ int v = arr[i]; int j = i - g; while (j >= 0 && arr[j] > v){ arr[j+g] = arr[j]; j -= g; ++cnt; } arr[j+g] = v; } } void ShellSort(int[] ar...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; import std.traits; struct Input { int n, m; int[] s, c; } void parseInput(T)(out Input input, T file) { with (file) with (input) { auto ar = readln().strip().split()....
D
import std.stdio; import std.range; import std.array; import std.algorithm; import std.string; import std.conv; void main(){ auto n = readln(); auto s = readln().chomp(); solve(s).writeln(); } int solve(string s){ int allE = s.filter!((ch) => ch == 'E').array().length.to!int; int allW = s.filter!(...
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[] s; for...
D
import std.stdio; import std.algorithm; import std.string; import std.conv; import std.math; void main(){ auto s = chomp(readln()); char[] ss; for(int i=0;i<s.length;i++){ ss ~= s[i]; } for(int i=0;i<s.length-4;i++){ if(ss[i]=='a'&&ss[i+1]=='p'&&ss[i+2]=='p'&&ss[i+3]=='l'&&ss[i+4]=='e'){ ss...
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, A, B, C; scan(N, A, B, C); long a...
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.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); foreach (i ; 0 .. 100) { foreach (j ; 0 .. 100) { if (4*i + 7*j == n) { writeln("Yes...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { int n = readln.chomp.to!int; string s = readln.chomp; int leftW = 0; int rightE = 0; foreach (c; s) { if (c == 'E') { ++rightE; } } int ans = int.max; foreach (c; s) { if (c == 'E') { --rig...
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
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.algorithm, 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() { string a, b, c; readV(a, b, c); ...
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.ascii; import std.concurrency; import std.traits; import...
D
void main(){ auto ABCD = readLine!long(); foreach( i ; 0..102 ){ ABCD[2] -= ABCD[1]; if( ABCD[2] <= 0 ){ writeln("Yes");return; } ABCD[0] -= ABCD[3]; if ( ABCD[0] <= 0 ){ writeln("No");return; } } } import std.stdio, std.string, std.conv; import std.math, std.algorithm, std.array; import std.rege...
D
// Vicfred // https://atcoder.jp/contests/abc162/tasks/abc162_a // implementation import std.stdio; void main() { string n = readln; foreach(ch; n) { if(ch == '7') { "Yes".writeln; return; } } "No".writeln; }
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; } void main() ...
D
void main() { int[] tmp = readln.split.to!(int[]); int w = tmp[0], h = tmp[1], n = tmp[2]; int[] x = new int[n], y = new int[n], a = new int[n]; foreach (i; 0 .. n) { tmp = readln.split.to!(int[]); x[i] = tmp[0], y[i] = tmp[1], a[i] = tmp[2]; } int xmin, xmax = w, ymin, ymax = h;...
D
void main() { int n = readln.chomp.to!int; int k = readln.chomp.to!int; int m = k.log2.ceil.to!int; int ans = n - m > 0 ? 2 ^^ m + (n - m) * k : 2 ^^ n; ans.writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; im...
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.algorithm; import std.range; import std.conv; import std.string; int f(int a, int k) { if (a < k) return 0; if (a%k == 0) return a/k; int c = a/k+1; int l = a/k*k; a -= ((a-l-1)/c+1)*c; return f(a, k); } void main() { int n = to!int(chomp(readln())); //int ...
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(){ int n, x; { int[] tmp = readln.chomp.split.map!(to!int).array; n = tmp[0], x = tmp[1]; } ulong[] as = readln.chomp.split.map!(to!ulong).array; ulo...
D
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math; import core.stdc.stdio; // foreach, foreach_reverse, writeln void main() { int a, b, c, x, y; scanf("%d%d%d%d%d", &a, &b, &c, &x, &y); a = min(a,c*2); b = min(b,c*2); int ans = a*x + b*y; ans -= max(0, a+b-c*2) * min(x,y); writeln(ans);...
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; } int[] digits(int n) { if (n == 0) return [0]; int[] ...
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[]); auto A = ab[0]; auto B = ab[1]; int t = 1, r; while (t < B) { ++r; t = t - 1 + A; } writeln(r); }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; void main() { string S = readln.chomp; long n; char prev = '#'; foreach(c;S) { if(c != prev) { prev = c; n++; } } writeln(n-1); }
D
import std.stdio, std.conv, std.string; import std.algorithm, std.array, std.container; import std.numeric, std.math; import core.bitop; T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; } string RDR()() { return readln.chomp; } long ...
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; scan(a, b); foreach (x ; 0 .. 100000) { ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; void main() { auto ...
D
import std.stdio; import std.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 x = readln.chomp.split.to!(int[]); if (x[0]+x[1]<x[2] || x[0] > x[2]) { wr...
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
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.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional; alias FactorizeResult = ulong[101]; void main() { const N = readln.chomp.to!int; FactorizeResult table; foreach (i; 1..N+1) { table[] += primeFactorize(i)[]; } ulong func(...
D
void main() { long n, a, b; rdVals(n, a, b); long cnt; foreach (i; 0 .. n) { long t = rdElem; if (t < a || b <= t) ++cnt; } cnt.writeln; } enum long mod = 10^^9 + 7; enum long inf = 1L << 60; enum double eps = 1.0e-9; T rdElem(T = long)() if (!is(T == struct)) { retur...
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; auto C = new int[](N); auto D = new long[](N); foreach (i; 0..N) { auto ...
D