code
stringlengths
4
1.01M
language
stringclasses
2 values
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
void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto n=readln.chomp.to!(int); foreach(b; 0..(1<<3)){ auto tmp=n, sum=0; foreach(i; 0..3){ if((b>>i)&1) sum+=tmp%10; else sum-=tmp%10; tmp/=10; } sum+=tmp; if(sum==7){ char[] s; foreach(i; 0..3...
D
void main(){ string[] val = inln!string(); writeln( (val[0]=="H")^(val[1]=="H")?'D':'H'); } 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 to!(T)( readln().chomp() ); } // 1行に同一型の複数入力 T[] inln(...
D
import std.stdio; import std.algorithm; import std.range; import std.conv; void main() { string[] input = split(readln()); long n = to!long(input[0]); long m = to!long(input[1]); if (n > m) swap(n,m); long ans = 0; if (n == 1) { ans = max(0, m-2); if (m == 1) ans = 1; } else...
D
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n; scan(n); int ans; foreach (i ; 0 .. n) { int li, ri; scan(li, ri); ans += ri - li + 1; } writeln(ans); } void...
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; 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.string; import std.conv; int main() { while (true) { string[] str = readln().chomp().split(); int n = str[0].to!int; int m = str[1].to!int; if (m == n && n == 0) break; int[1001] ans; int c = n - 1; for (int i = 0; i < n; i++) an...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; auto n = readln.chomp.to!(char[]); auto dp = new long[][][][](n.length + 1, 2, 1000, 2); dp[0][0][0][0] = 1; foreach (i; 0 .. (n.length)) { foreach (l; 0 .. 2) { foreach (k; 0 .. 1000) { foreach (ok; 0 .. 2) { a...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.container; import std.bigint; void main() { readln.chomp.toUpper.writeln; }
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio; import std.string; import std.conv; import std.math; void main() { string[] inputs = split(readln()); //int r = to!int(inputs[0]); int g = to!int(inputs[1]); int b = to!int(inputs[2]); if((10*g + b) % 4 == 0) "YES".writeln; else "NO".writeln; }
D
import std.stdio; import std.conv; import std.array; void main() { int N = readln.split[0].to!int; int[] H = readln.split.to!(int[]); int max = 0; int ans = 0; foreach (h; H){ if (h >= max){ ans++; max = h; } } writeln(ans); }
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; alias sread = () => readln.chomp(); alias lread = () => readln.chomp.to!long(); alias aryread(T = long) = () => readln.split.to!(T[]); void main() { auto x = lread(); if (x < 1200) { writeln("ABC"); return; } writeln("ARC"); } void scan(L...)(ref L A) { auto l = 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; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } long calc(int n, int s) { long rec(int p, int s...
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
module c; import std.conv, std.stdio; import std.algorithm, std.array, std.string, std.range; void main() { auto buf = readln.chomp.split.to!(long[]); auto n = buf[0], k = buf[1]; n = n % k; n.min(k-n).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, std.array, std.string, std.conv; void main() { int n = to!int(chomp(readln())); string[] a = split(readln()); for (int i = n - 1; i >= 0; --i) { write(a[i]); write(i ? " ": "\n"); } }
D
import std.stdio;import std.conv;import std.algorithm;import std.array; void main() { auto it = readln().split().map!(to!int); writeln(it[0]*it[1]," ",(it[0]+it[1])*2); }
D
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container, std.typecons; void main() { int[] abc = readln.chomp.split.to!(int[]); if(abc[0]!=abc[1]&&abc[1]==abc[2] || abc[0]!=abc[1]&&abc[0]==abc[2] || abc[0]==abc[1]&&abc[1]!=abc[2]) writeln("Yes"); else writeln("N...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; void main() { int n; scan(n); auto s = readln.chomp.to!string; auto pf = new int[](n + 1); foreach (i ; 1 .. n + 1) { pf[i] = pf[i-1] ...
D
// Your code here! 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>b) writeln(a-1); else writeln(a); }
D
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math; void main() { auto n = readln.chomp.to!int; auto DP = new long[](n+1); DP[0] = 1; DP[1] = 1; foreach (i; 2..n+1) { DP[i] = DP[i-1] + DP[i-2]; } writeln(DP[n]); }
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.functional, std.algorithm, std.typecons, std.bigint, std.string, std.traits, std.array, std.range, std.stdio, std.conv, std.math; T read_num(T)() { return readln.chomp.to!T; } T min(T)(T a, T b) { return a < b ? a : b; } void main() { ...
D
/+ dub.sdl: name "A" dependency "dunkelheit" version="1.0.1" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dkh.foundation, dkh.scanner; int main() { Scanner sc = new Scanner(stdin); scope(exit) assert(!sc.hasNext); int n, k; sc.read(n, k); writeln(n - k + 1); retur...
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() { long a, b, x; readV(a, b, x); wr...
D
void main() { int n = readln.chomp.to!int; int t, x, y; bool ok = true; foreach (i; 0 .. n) { int[] tmp = readln.split.to!(int[]); int ti = tmp[0], xi = tmp[1], yi = tmp[2]; int len = abs(xi - x) + abs(yi - y); if (ti - t < len) { ok = false; ...
D
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto k = readln.chomp.to!long, n = 50; auto kd = k/n, km = k%n; auto a = new long[](n); a[] = n-1+kd; foreach (i; 0..km) { a[] -= 1; a[i] += n+1; } writeln(n); foreach (i, ai; a) write(ai, i < n-1 ? " " : "");...
D
import std.stdio; import std.conv; import std.algorithm; import std.range; import std.string; import std.math; void main() { readln; auto s = readln.chomp.split.map!(to!int); readln; auto t = readln.chomp.split.map!(to!int); int cnt = 0; foreach (e; t) { if (!s.find(e).empty) cnt++; } cnt.writeln...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto X = readln.chomp.to!int; auto ns = new bool[](100004); foreach (i; 2..100004) { if (ns[i]) continue; if (i >= X) { writeln(i); return; }...
D
import std.algorithm; import std.conv; import std.math; 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 balance = abs (s.count ('0').to !(int) - s.count ('1').to !(int)); auto moves = (s.len...
D
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons; void main() { const tmp = readln.split.to!(int[]); writeln(tmp[0] + tmp[1]/2); }
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.stdio; import std.string; import std.range; int readint() { return readln.chomp.to!int; } int[] readints() { return readln.split.map!(to!int).array; } void main() { auto s = readln.chomp; auto t = readln.chomp; ...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; void main() { Input input = void; parseInput(input, stdin); auto result = main2(&input); writeln(result); } auto main2(Input* input) { foreach (i, c; input...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons; import std.math, std.numeric; immutable long mod = 10L^^9 + 7; void main() { int n; scan(n); auto fact = new long[](n + 1); auto rfact = new long[](n + 1); fact[0] = 1; foreach (i ; 1 .. n + 1) { ...
D
// dfmt off T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;} void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(...
D
import std.stdio, std.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; void main() { auto N = readln.chomp.to!int; auto S = N.iota.map!(_ => readln.chom...
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; void main() { auto a = readln.split.map!(to!int); if (a[4] <= a[2] && a[2] <= a[0] - a[4] && a[4] <= a[3] && a[3] <= a[1] - a[4]) writeln("Yes"); else writeln("No"); }
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto n = readln.chomp; if (((n[0] == n[1]) && (n[1] == n[2])) || ((n[1] == n[2]) &&...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum mod = 998244353L; void main() { int n; scan(n); auto f = new long[](n + 1); f[0] = f[1] = 1; foreach (i ; 2 .. n + 1) { f[i] = f[...
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; void main() { auto n = to!int(readln().strip()); while(n > 0){ string[] s; for(int i; i < n; ++i){ s ~= readln().chomp(); } int[][] yoko = new int[][](n+1,n...
D
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.range; void main() { auto N = readln.split[0].to!int; auto s = new string[N]; foreach(i; 0..N) { s[i] = readln.split[0]; } auto bucket = new int[26][N]; foreach(i; 0..N) { foreach(c; s[i]) { bucket[i][c - 'a']++; } }...
D
import std.stdio, std.string, std.conv, std.algorithm, std.numeric; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { while (true) { int n; scan(n); if (n == 0) return; solve(n); } } void solve(int n) { int l=1, r=1; int v; ...
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 main() { string s, t; scan(s); scan(t); auto n = s.length; int ans; foreach (i; 0 .. n) { ans += s[i] != t[i]; ...
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 data = readln.split; auto N = data[0].to!int, M = data[1].to!int; auto D = M / N; if (D == 1) { writeln(1); return; } foreach_reverse (i; 1 .. D+1) { if (M%...
D
void main() { auto S = rs, T = rs; S ~= S; if(S.canFind(T)) writeln("Yes"); else writeln("No"); } // =================================== 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; im...
D
// Vicfred // https://atcoder.jp/contests/abc175/tasks/abc175_a // implementation import std.stdio; import std.string; void main() { string S = readln.strip; if(S.count("RRR") == 1) { 3.writeln; return; } else if(S.count("RR") == 1) { 2.writeln; return; } else if(S.count...
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; void main() { foreach(i; 1 .. 10) { foreach(j; 1 .. 10) { printf("%dx%d=%d\n",i,j,i*j); } } }
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 a, b; readV(a, b); writeln((...
D
/+ dub.sdl: name "C" dependency "dcomp" version=">=0.6.0" +/ import std.stdio, std.algorithm, std.range, std.conv; // import dcomp.foundation, dcomp.scanner, dcomp.algorithm; import std.container.rbtree; int main() { auto sc = new Scanner(stdin); bool ans; scope(exit) { if (ans) writeln("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, std.bitmanip; immutable long MOD = 10^^9+7; void main() { auto S = readln.chomp; if (S.canFind("ABC") || S.canFind("ACB") |...
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.math; import std.algorithm; import std.array; import std.string; import std.conv; import std.range; import std.file; import std.datetime; void main() { int elemanSayısı = stdin.readln.strip.to!int; string harfler = stdin.readln.strip.to!string; int enBüyükIndeksi = 0; char enB...
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; void main() { auto s = readln.stripRight; int[26] c; long[26][26] d; foreach (ch; s) { int i = ch.to!int - 97;...
D
import std.stdio; import std.math; void main() { int n, t; scanf("%d%d", &n, &t); printf("%.10f\n", n * pow(1.000000011, t)); }
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; long a, b, c, d; scan(n, a, b, c, d...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto nmk = readln.split.to!(int[]); auto N = nmk[0]; auto M = nmk[1]; auto K = nmk[2]; foreach (y; 0..N+1) { auto b = 2*y - N; if (b == 0) { if (N*M == 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 main() { auto ...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.traits; import std.math; import std.conv; import std.typecons; void main() { (rs.uniq.array.length - 1).writeln; } // =================================== T readAs(T)() if (isBasicType!T) { return readln.chomp.t...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum mod = 10L^^9 + 7; enum inf = 10^^9; void main() { string s; scan(s); auto n = s.length.to!int; auto dp = new long[][](n + 1, 4); dp[0][0]...
D
import std.stdio; import std.conv; import std.string; import std.algorithm; import std.range; void main() { auto input = readln.split; auto X = input[0]; auto Y = input[1]; (X < Y ? "<" : X > Y ? ">" : "=").writeln; }
D
import std.stdio; import std.conv; import std.string; void main() { auto n = readln.chomp.to!int; string[] words = []; auto ans = "Yes"; foreach (i; 0..n) { auto word = readln.chomp; foreach (w; words) { if (w == word){ "No".writeln; return; ...
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[] lreads(T = long)(long n){ret...
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 as=readln.chomp.array; auto bs=readln.chomp.array; auto cs=readln.chomp.array; auto turn=0; while(true){ ...
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.conv : to; import std.stdio; import std.string : strip; void main() { int n = to!int(strip(stdin.readln())); string sequence = strip(stdin.readln()); char last_symbol = sequence[0]; int length = 1; for (auto i = 1; i < sequence.length; ++i) { if (sequence[i] != last_symbol) { ++length; last_...
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; long m; foreach (e;s) { m += cast(int)(e - '0'); } if (m % 9 == 0) { writeln("Yes"); } else { writeln("No"); } }...
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 a, b; readV(a, b); 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; struct Queue(T) { private { size_t cap, head, tail; T[] data; ...
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.typecons; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.traits; class InputReader { private: ubyte[] p; ubyte[] buffer; size_t cur; public: this () { buffer = uninitializedArray!(ubyte[])(16<<20); p = stdin.rawRead ...
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.algorithm, std.conv, std.range, std.stdio, std.string; void main() { for (;;) { auto s = readln.chomp; if (s == "-") break; auto m = readln.chomp.to!size_t; auto hi = m.iota.map!(_ => readln.chomp.to!int); foreach (h; hi) s = s[h..$] ~ s[0..h]; writeln(s); } }
D
void main(){ _scan(); int[] a = _scanln(); int ans_bit; foreach(elm; a)ans_bit = elm|ans_bit; int cnt; while( (ans_bit&1) == 0){ cnt++; ans_bit = ans_bit >> 1; } cnt.writeln(); } import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math; // 1要素のみの入力 T _scan(T= int)(){ return to!(T)( 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; 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, 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; bool[] seen, finished; int pos = -1; int[] hist; void dfs...
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; 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() { long a, b, c; scan(a, b, c); foreach (i; 1 .. 10 ^^ 6) {...
D
void main(){ auto SW = readLine!size_t(); if( SW[0] <= SW[1] ){ writeln("unsafe"); } else { writeln("safe"); } } import std.stdio, std.string, std.conv; import std.math, std.algorithm, std.array; import std.regex; T[] readLine( T = size_t )( string sp = " " ){ T[] ol; foreach( string elm ; readln().cho...
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
void main() { string s = readln.chomp; int[string] week; week["SAT"] = 1; week["FRI"] = 2; week["THU"] = 3; week["WED"] = 4; week["TUE"] = 5; week["MON"] = 6; week["SUN"] = 7; week[s].writeln; } import std.stdio; import std.string; import std.array; import std.conv; import std...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; int s_n(int n) { int sum = 0; while (n != 0) { sum += n % 10; n /= 10; } return sum; } void main() { int n = readln.chomp.to!(int); writeln((n % s_n(n) == 0) ? "Yes" : "No"); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto S = readln.chomp.to!(char[]); int[char] memo; foreach (c; S) { if (c !in memo) memo[c] = 0; ++memo[c]; } foreach (k, v; memo) { if (v != 2) { ...
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.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
// 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
void main() { int[] tmp = readln.split.to!(int[]); int n = tmp[0], i = tmp[1]; writeln(n - i + 1); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.container; import std.typecons;
D
import std.stdio; void main() { string s = readln; if (s[0] == '7' || s[1] == '7' || s[2] == '7') { writeln("Yes"); } else { writeln("No"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto whn = readln.split.map!(to!int); auto w = whn[0]; auto h = whn[1]; auto n = whn[2]; int t = h, b = 0, l = 0, r = w; foreach (_; 0..n) { auto xya = readln.split.map!(to!int); auto x = xya[0]; ...
D
import std.stdio; import std.string; import std.array; // split import std.conv; // to import std.math; import std.algorithm; void main() { string a = chomp(readln()); string b = chomp(readln()); int N = to!int(a); // 第0要素を整数に変換 int K = to!int(b); // 第1要素を整数に変換 int ans = 1; for(int i=0;i<N;i++){...
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 t = readln.chomp.split.map!(to!int); auto a = r...
D
import std.stdio; import std.algorithm; import std.array; import std.conv; import std.string; import std.math; void main() { int N = readln.chomp.to!int; auto a = readln.chomp.split.map!(to!int).array; int odd; for (int i = 0; i < N; ++i) { if (a[i] % 2 == 1) { odd++; } } if (odd % 2 == 1 ...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { foreach(s;stdin.byLine()) { string t; for(int i=0; i<s.length; ++i) if(s[i]!='@') t~=s[i]; else t~=s[i+2].repeat().take(s[i+1]-'0').array(),i+=2; writeln(t); } }
D
void main() { string s = rdStr; long k = rdElem; long idx; foreach (i, x; s) { if (x != '1') { idx = i; break; } } writeln(idx >= k ? s[0] : s[idx]); } enum long mod = 10L^^9 + 7; enum long inf = 1L << 60; enum double eps = 1.0e-9; T rdElem...
D
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm; void main(){ auto S = readln.chomp.to!(char[]); int count; foreach(i; 0..4){ if(S[i] == '+') count++; else count--; } writeln(count); }
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