code
stringlengths
4
1.01M
language
stringclasses
2 values
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum mod = 10L^^9 + 7; enum inf = 10^^9; void main() { int n, k; scan(n, k); auto a = readln.split.to!(long[]); auto ac = new long[](n + 1); f...
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() { while (1) { auto n = readln.chomp.to!int; if (n == -1) break; n.to!string(4).writeln; } }
D
import std.stdio,std.algorithm,std.range,std.conv,std.string; void main() { foreach(i;0..readln.chomp.to!int) { auto input=readln.split; real x1=input[0].to!real,y1=input[1].to!real, x2=input[2].to!real,y2=input[3].to!real, x3=input[4].to!real,y3=input[5].to!real, ...
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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container; void main() { auto N = readln.chomp.to!int; auto as = readln.split.to!(long[]); foreach (a; as) if (a >= N) goto solve; writeln(0); return; solve: long l, r = (10L^^16+100...
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 lrd = readln.split.to!(int[]); auto L = lrd[0]; auto R = lrd[1]; auto d = lrd[2]; int c; foreach (i; L..R+1) if (i%d == 0) ++c; writeln(c); }
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; int n; rd(n); auto a = readln.split.to!(long[]); foreach (i; 1 .. n) a[i] = a[i] + a[i - 1]; long mn = 10L ^^ 18; import std.math; foreach (i; 0 .. (n - 1)) { // [0, i], (i, n) mn = min(mn, abs(a[i] - (a[n - 1] - a[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; void main() { auto ...
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; scan(n); auto a = iota(n).map!(i =>...
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable i = readln.split.to!(long[]); writeln(i[0]+1-i[1]); }
D
import std.algorithm; import std.array; import std.stdio; import std.conv; import std.string; import std.range; void main(){ size_t w, h, sx, sy; char[][] data = new char[][](20, 20); while(true){ auto input = readln.split; w = input[0].to!int; h = input[1].to!int; if(!(w | ...
D
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; import std.array; int readInt(){ return readln.chomp.to!int; } int[] readInts(){ return readln.chomp.split.to!(int[]); } void main(){ int n = readInt(), i; int[] h = readInts(); for(i = 0; h.count(0) != h.length...
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; int cx, cy, ct; auto f = false; foreach (_; 0..n)...
D
void main() { auto N = ri; auto s = rs; if(s.count!"a == 'R'" > s.count!"a == 'B'") writeln("Yes"); else writeln("No"); } // =================================== import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.contai...
D
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.to!(int[]); } void main() { int a,b,c; scanf("%d%d%d", &a,&b,&c); writeln(a+b >= c ? "Yes" : "No"); auto _ = read...
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.bitmanip; void main() { auto s = readln.split.map!(to!int); auto n = s[0]; auto q = s[1]; auto st = new SegmentTree!(int...
D
void main() { problem(); } void problem() { auto K = scan!int; auto A = scan!int; auto B = scan!int; bool solve() { foreach(i; A..B+1) { if (i % K == 0) return true; } return false; } writeln(solve() ? "OK" : "NG"); } // ---------------------------------------------- import std.std...
D
class UnionFind{ int n; int[] root; this(int n){ root.length=n; foreach(i; 0..n) root[i]=i; } int find(int i){ if(root[i]==i) return root[i]; else return root[i]=find(root[i]); } void unite(int x, int y){ x=find(x); y=find(y); if(x==y) return; root[x]=y; } bool same(int x, ...
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.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.split.map!(to!int); auto N = s[0]; auto K = s[1]; ...
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 std.string...
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 a = readln.chomp.split.to!(int[]); int dup; ...
D
import std.stdio; import std.string; import std.functional; import std.algorithm; import std.range; import std.traits; import std.math; import std.container; import std.bigint; import std.numeric; import std.conv; import std.typecons; import std.uni; import std.ascii; import std.bitmanip; import core.bitop; // void ma...
D
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv, std.typecons, std.math; import std.functional; // import dcomp.foundation, dcomp.scanner; // import dcomp.graph.maxflow; long f(int le, int p, long d) { int q = le-1-p; long up = 0; ...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; import std.numeric; void main() { int n; int[] a; scan(n); a = readln.split.to!(int[]); a = [0] ~ a ~ [0]; auto lb = new int[](n + 2), rb = new int[](n + 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; const RED_OVER_INDEX = ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { size_t n; scanf("%ld\n", &n); size_t[ubyte[]] map; foreach(i; 0..n) { auto l = readln.chomp.representation.dup; l.sort!"a<b"; immutable key = l.dup; if (key in map) { ++map[key]; } else { map[key] = 1; } ...
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; void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primiti...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; void main() { auto s = readln.strip; int t; for (size_t i = 0, j = s.length - 1; i < j; i++,j--) { if (s[i] != s[j]) ++t; } writeln (t); }
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; void main() { while(true) { int n=readln.chomp.to!int; if(!n)break; int num; for(int i=1; i<n; ++i) { int sum; for(int j=i; j<n; ++j) { sum+=j; if(sum == n) ++num...
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
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); string t; readV(t); auto ns = s.length.to!int, nt = t.length.to!int...
D
// import std.stdio,std.array,std.conv; void main(){ auto sr=readln.split; int r=to!int(sr[0]); auto sg=readln.split; int g=to!int(sg[0]); writeln(g*2-r); }
D
import std.algorithm; import std.bigint; import std.concurrency; import std.container; import std.conv; import std.functional; import std.format; import std.math; import std.meta; import std.numeric; import std.random; import std.range; import std.stdio; import std.string; import std.traits; import std.typecons; auto...
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.array, std.string; import std.algorithm; import std.container; import std.range; import core.stdc.stdlib; import std.math; void main() { auto N = readln.chomp.to!int; auto S = readln; int total = 0; foreach(i; 0..N) { if (i == 0) { total++; continue; } ...
D
void main() { int x = readln.chomp.to!int; int a = readln.chomp.to!int; int b = readln.chomp.to!int; writeln((x - a) % b); } 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 ...
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
void main() { import std.stdio, std.string, std.conv, std.algorithm; string a, b; int m; rd(a); rd(b); rd(m); const int MOD = 10 ^^ 4; int solve(string n) { auto memo = new short[][][][][][](n.length + 1, 2, 4, 10, 3, m); afill(memo, (-1).to!(short)); int f(size_t i, bool less, int foo, in...
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; void main() { auto s = readln.chomp; auto t = readln.chomp; foreach (i; 0 .. s.length) { bool flag = true; foreach...
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; int c; foreach (i; 1..N+1) { if (i < 10 || (100 <= i && i < 1000) || (10000 <= i && i < 100000)) ++c; } writeln(c); }
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(n...
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(int[] a) { ...
D
import std.stdio; void main() { for(int i = 1; i < 10; i++) for(int j = 1; j < 10; j++) writeln(i,"x",j,"=",i*j); }
D
import std.stdio; void main(){ foreach(e1; 1..10){ foreach(e2; 1..10){ writeln(e1, "x", e2, "=", e1*e2); } } }
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; void main() { auto n = readln().chomp().to!int; int cnt4, cnt2, cnt1; foreach(e; readln().chomp().splitter(' ').map!(to!int)){ if(e % 4 == 0){ ++cnt4; }else if(e % 2 != 0){ ...
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.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.string, std.regex, std.math, std.array, std.algorithm; void main(){ auto ip = readln.split; int A = ip[0].to!int; int B = ip[2].to!int; char op = ip[1].to!char; if(op == '+'){ writeln(A + B); } else if(op == '-'){ writeln(A - B); } }
D
import std.stdio,std.array,std.conv,std.algorithm,std.range,std.string,std.math; void main(string[] args) { real a; a = readln.chomp.to!real; a.sqrt.floor.to!int.pow(2).writeln; }
D
import std.stdio,std.conv,std.string; /*int lyca(int n){ if(n==0) return 2; else if(n==1) return 1; else return lyca(n-1)+lyca(n-2); }*/ void main(){ int n=readln().chomp().to!int; ulong k=2UL,l=1UL,ans=1UL; for(int i=1;i<n;i++){ ans=k+l; //ansはl(i+1)に対応 k=l; l=ans; } writeln(ans)...
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, std.bitmanip; immutable long MOD = 10^^9+7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto p = s[1]; ...
D
/+ dub.sdl: name "C" dependency "dunkelheit" version=">=0.9.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); scope(exit) sc.read!true; int n; long l; long[] c; sc.read(n, l, c); foreach_revers...
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 : write, writeln; import std.array; import std.range; import std.typecons; import std.bigint; import std.algorithm; void main(){ int n = next!int; int m = next!int; int cnt; for( int i = 1; i <= min(n, m); ++i ){ for( int j = i; j <= max(n, m); ++j ){ if( i!=1 && j>i ) continue; ++cnt; ...
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.traits; import core.bitop; import std.typecons; class LazyPropagationSegmentTree(T = int, D = int, D init = D.init) { immutable size_t n; immutab...
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, 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 s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1] + 2; string[] A; bool ok = false; fo...
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 x = rd[0], y = rd[1]; if (x == 0 && y == ...
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(i; 2..50) inv_[i]=mul(inv_[mod%i], mod-mod/i)%mod; foreach(_; 0..n){ scanf("%d%d", &op, &y); if(op >= 3 && y < 0) x = -x, y = -y; if(op == 1) x ...
D
import std.stdio; import std.algorithm; import std.math; import std.conv; import std.string; T readNum(T)(){ return readStr.to!T; } T[] readNums(T)(){ return readStr.split.to!(T[]); } string readStr(){ return readln.chomp; } void main(){ auto nm = readNums!int; int n = nm[0], m = nm[1]; bool[] broken =...
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; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto X = s[1].to!long; auto A = readln.split.map!(to!long)....
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.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.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 = 998244353; long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2...
D
import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; import std.numeric; import std.bigint; class UnionFind { int N; int[] table; this(int n) { N = n; table = new in...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto sa = readln.chomp; auto sb = readln.chomp; auto sc = readln.chomp; char t = 'a'; for (;;) { switch (t) { case 'a': if (sa.empty) { writeln("A"); ...
D
import std.stdio, std.array, std.conv, std.typecons, std.algorithm; T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; } void main() { immutable ip = readln.split.to!(ulong[]); immutable a = ip[0], p = ip[1]; writeln((a*3+p)/2); }
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.stdio, std.string, std.conv; import std.algorithm, std.array; auto solve(string s_) { immutable P = "Possible"; immutable I = "Impossible"; immutable N = s_.to!int(); immutable a = readln.split.map!(to!int).array(); auto c = new int[N]; foreach(v;a) { if(v<1 || N<=v) return I;...
D
import std.stdio, std.conv, std.string, std.random, std.range, std.typecons, std.math; import std.algorithm.comparison, std.algorithm.iteration; import std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting; void main() { auto input = readln().strip.split.to!(int[]); auto A = input[0]; auto...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto h = readln.chomp.to!size_t; auto hi = readln.split.to!(int[]); hi = 0 ~ hi; buildMaxHeap(hi, h); foreach (i; 1..h+1) write(" ", hi[i]); writeln; } void maxHeapify(ref int[] ai, size_t h, size_t i) { auto l = i * 2...
D
unittest { assert( [ "123456789" ].solve == "Yes" ); assert( [ "0" ].solve == "Yes" ); assert( [ "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280" ].solve == "No" ); } import std.algorithm; import std.conv; import std.range; import std.stdio; void main() { stdin.byLineCopy...
D
import std.stdio, std.string, std.conv, std.algorithm; void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], a = tmp[1], b = tmp[2]; writeln(min(n*a, b)); }
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 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.array, std.conv, std.algorithm, std.typecons, std.range; void main(){ auto hwd=readln.split.map!(to!int).array; auto H=hwd[0],W=hwd[1],d=hwd[2]; foreach(w;0..H){ foreach(h;0..W){ auto k=w+h; auto j=w-h; auto x=k.div(d); ...
D
import std.stdio, std.conv, std.string; void main() { auto D = readln().strip.to!int; switch(D) { case 25: writeln("Christmas"); break; case 24: writeln("Christmas Eve"); break; case 23: writeln("Christmas Eve Eve"); break;...
D
import std.stdio, std.string, std.array, std.conv; void main() { while (true) { int[] tmp = readln.chomp.split.to!(int[]); int h = tmp[0], w = tmp[1]; if (h == 0 && w == 0) break; foreach (i; 0 .. h) { foreach (j; 0 .. w) { write(i == 0 || i == h - 1 || j...
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; //C // void main() // { // auto N = scanElem; // auto K = scanElem; // auto k = K; // long count=1; // real r...
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[] as = [0]; foreach (i, a; readln.split.to!(long[])) as ~= a + as[i]; auto pq_max = new long[](N+1); auto pq_min = new long[](N+1); auto rs_ma...
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
// Vicfred // https://atcoder.jp/contests/abc158/tasks/abc158_d import std.algorithm; import std.array; import std.stdio; import std.conv; import std.string; import std.container; void main() { string s = readln.chomp; int q = readln.chomp.to!int; int[] t = new int[q]; int[] f = new int[q]; char[]...
D
import std.conv; import std.stdio; import std.string; void main() { int n = readln.chomp.to!int; writeln(n % 2 == 0 ? n : 2 * n); }
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto x = readln.chomp.to!int; writeln(x ^^ 3); }
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 calc(int[] xs) { int rec(int p, int[] buf) ...
D
import std.stdio, std.conv, std.string, std.algorithm; void main() { int H, W; int [][10] c; auto t = readln().chomp().split().to!(int[])(); H = t[0]; W = t[1]; foreach(int i; 0..10) { c[i] = readln().chomp().split().to!(int[])(); } foreach(int i; 0..10) { foreach(int j; 0..10) { foreach(int k; 0..10) { ...
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, m; readV(n, m); auto t = 1900*m + 100*(n-m); writeln(t*2^^m); }
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container, std.typecons; void main() { string S = readln.chomp; switch(S) { case "SUN": 7.writeln; break; case "MON": 6.writeln; break; case "TUE": 5.writeln; break; case "WED": 4.writeln; break; ...
D
void main() { auto N = ri; auto S = rs; ulong res = ulong.max; auto A = new int[](N); A[0] = S[0] == 'W'; foreach(i; 1..N) A[i] = S[i] == 'W' ? A[i-1]+1 : A[i-1]; /*auto B = new int[](N); [0] = S[0] == 'E'; foreach(i; 1..N) B[i] = S[i] == 'E' ? B[i-1]+1 : B[i-1]; */ debug A.writeln; //B.writeln; auto C = i...
D
void main(){ string s = readln().chomp(); foreach(ch; s){ if( s.count(ch) != 2){ writeln("No"); return; } } writeln("Yes"); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] _scanln(T =...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; int[][] MAX, MEMO; void main() { auto s = readln.chomp.to!(wchar[]); auto t = readln.chomp.to!(wchar[]); MEMO.length = s.length; MAX.length = s.length; foreach (i; 0..s.length) { MEMO[i]...
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 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; void main() { while(true) { int N = readln.chomp.to!int; if (N ==...
D