code
stringlengths
4
1.01M
language
stringclasses
2 values
// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; import std.datetime, std.bigint; void main() { int n; scan(n); int ans = 1; while (ans <= n / 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.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; void main() { int n, m; scan(n, m); auto adj = new int[][](n, 0); foreach (i ; 0 .. m) { int ai, bi; scan(ai, bi); ai--, bi--; adj[ai...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; import std.ascii; void main() { int a, e, k; foreach (i; 0..6) { if (i == 0) a = readln.chomp...
D
import std.stdio, std.string, std.conv; void main(){ auto ip = readln.chomp.to!(dchar[]); ip[3] = '8'; writeln(ip); }
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto s = readln.chomp.to!(char[]); auto t = readln.chomp.to!(char[]); bool[char] ...
D
// dfmt off T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;} T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;} void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(...
D
import std.stdio; import std.conv; import std.string; import std.typecons; import std.algorithm; import std.array; import std.range; import std.math; import std.regex : regex; import std.container; import std.bigint; void main() { auto s = readln.chomp; if (s.length % 2) s.length -= 1; else s.length -= 2; whi...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; enum next = [ "Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny" ]; void main() { writeln(next[readln.chomp]); }
D
import std.conv, std.stdio; import std.algorithm, std.array, std.range, std.string; void main() { switch (readln.chomp[$-1]) { case '0', '1', '6', '8': return "pon".writeln; case '2', '4', '5', '7', '9': return "hon".writeln; default: return "bon".writ...
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, std.bitmanip; class SegmentTree { int[] table; int N, table_size; this(int n) { N = n; ta...
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() { long N = scanElem; auto S = readln.strip; auto T = readln.strip; long res; foreach(i;1..N+1) { ...
D
import std.stdio, std.range, std.conv; import std.math; void main(){ int w, h; while(true){ scanf("%d %d", &h, &w); if(h == 0 && w == 0) break; foreach(i; 0..h){ foreach(j; 0..w){ write(((i+j)%2) ? "." : "#"); } writeln(); } writeln(); } }
D
//dlang template---{{{ import std.stdio; import std.conv; import std.string; import std.array; import std.algorithm; // MIT-License https://github.com/kurokoji/nephele class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; import std.string; import std.traits : isSome...
D
import std.conv, std.stdio, std.string; void main() { auto a = readln.chomp.to!int; auto s = readln.chomp; ((3200 <= a) ? s : "red").writeln; }
D
// import chie template :) {{{ static if (__VERSION__ < 2090) { import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv, std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip, std.numeric; } else { import std; } // }}} // nep.scanner {{{ class Scanner { ...
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[1] % tmp[0] == 0 ? tmp[0] + tmp[1] : tmp[1] - tmp[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() { string x; scan(x); int st, ans; foreach (ch ; x) { if (ch == 'S') { st++; } else { i...
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, d; scan(n, a, b, c, d); a...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = (...
D
import std.stdio; import std.conv; import std.math; void main() { double n; scanf("%lf", &n); auto y = n / 1.08; auto n2 = n.to!int; auto y2 = y.ceil.to!int; if (floor(y2 * 1.08).to!int == n2 || floor((y2+1) * 1.08).to!int == n2) { y2.write; } else { ":(".write; } }
D
import std.stdio, std.string, std.conv, std.array, std.algorithm; void main() { auto a = readln.split.map!(to!int); writeln("a ", a[0] == a[1] ? "==" : (a[0] < a[1] ? "<" : ">"), " b"); }
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 s = sread(); auto tmp = new long[](4); //北西南東 foreach (...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; scan(n); int[string] a; foreach (i ; 0 .. n) { auto s = readln.chomp; if (s in a) { a[s]++; } else { a[s] = 1; } } int m; ...
D
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.functional, std.math, std.numeric, std.range, std.stdio, std.string, std.random, std.typecons, std.container; ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000; alias sread = () => readln.chomp(); alias lread(T = long) = (...
D
import std.algorithm; import std.range; import std.stdio; import std.string; immutable int letters = 26; void main () { string s; while ((s = readln.strip) != "") { auto a = new int [] [letters]; foreach (int i, c; s.map !(x => x - 'a').array) { a[c] ~= i; } int n = cast (int) (s.length); int res = ...
D
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.math; void main() { int n, m; scan(n, m); auto cnt = new int[](n); auto red = new bool[](n); cnt[] = 1; red[0] = 1; foreach (i ; 0 .. m) { int xi, yi; scan(xi, yi); xi--, yi--; ...
D
void main(){ int n = _scan(); int[string] dic; foreach(i; 0..n){ dic[readln().chomp()]++; } dic.length.writeln(); } 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 = int)(){ T[] ln;...
D
import std.stdio,std.string,std.conv; int main() { string s; while((s = readln.chomp).length != 0) { string[] _s = s.split(" "); int a = _s[0].to!int; int b = _s[1].to!int; int n = _s[2].to!int; int ans = 0; a %= b; foreach(i;0..n) { a *= 10; ans += (a/b); a %= b; } ans.writeln; } r...
D
void main(){ string s = readln().chomp(); s.count('1').writeln(); } 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 = int)(){ T[] ln; foreach(string elm; readln().chomp().split()){ ln...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; long n; rd(n); long m=1; while(m<n){ if((n&m)!=m){ writeln(m); return; } m*=2; } writeln(n+1); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; foreach(i, ref e; ...
D
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; import std.ascii; 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 ...
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; alias C = Tuple!(int, int); immutable C[] dirs = [ tuple (1, 0), tuple (-1, 0), tuple (0, 1), tuple (0, -1) ]; enum inf = int.max; void main() { auto s = re...
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() { auto dp = new long[][](11, 1001); dp[0][0] = 1; foreach (i; 0..101) { foreach_reverse ...
D
void main() { import std.stdio, std.string, std.conv, std.algorithm; long a, b, x; rd(a, b, x); long mod = 1_000_000_000 + 7; auto k = (x - a + 1 + (a - b - 1)) / (a - b); if (k < 0) { k = 0; } auto ans = x % mod + (k % mod) * (b % mod); writeln(ans % mod); } void rd(T...)(ref T x) { import s...
D
import std.stdio, std.string, std.conv; import std.array, std.algorithm, std.range; void main() { for(int n; 0!=(n=readln().chomp().to!int()); ) { immutable a = iota(n).map!(_=>readln().chomp().to!int()).array().idup; int m=int.min; auto dp = new int[][](n,n); foreach(i;0..n) ...
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
// Vicfred // https://atcoder.jp/contests/abc134/tasks/abc134_c // greedy import std.algorithm; import std.stdio; import std.conv; import std.string; void main() { const long n = readln.chomp.to!long; long[] as = new long[n]; foreach(i; 0..n) { as[i] = readln.chomp.to!long; } const long m...
D
import std.stdio, std.string, std.conv, std.math; void main() { auto ip = readln.split.to!(int[]); if(0 <= (ip[1] - ip[2])){ writeln("delicious"); } else if(ip[0] >= abs(ip[1] - ip[2])){ writeln("safe"); } else { writeln("dangerous"); } }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string; void main() { auto abc = readln.chomp.split(" ").map!(to!int); writeln( abc[1] - abc[0] == abc[2] - abc[1] ? "YES" : "NO" ); }
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; 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; import std.container; alias sread = () => readln.chomp(); ulong bignu...
D
void main() { long n = readln.chomp.to!long; long[] a = new long[5]; foreach (i; 0 .. 5) { a[i] = readln.chomp.to!long; } long m = a.reduce!min; writeln((n + m - 1) / m + 4); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range...
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[] aryread(T = long)(){return readln.split.to!(T[])();} ...
D
/+ dub.sdl: name "C" dependency "dcomp" version=">=0.3.2" lflags "-stack_size" "100000000" +/ import std.algorithm, std.conv, std.range, std.stdio; // import dcomp.scanner; int[128][1001] dp; int calc(int n, int d) { if (n == 1) return d; if (dp[n][d] != -1) return dp[n][d]; int ans = 0; ...
D
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
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 s = readln.chomp; ...
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() { auto n = readln.chomp.to!int; auto area = new int[][](n+1, n+1); foreach (i; 1..n+1) { auto tmp = re...
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; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]; long ans =...
D
import core.stdc.stdio; import std.algorithm; void main(){ int n; scanf("%d",&n); int[] a = new int[n]; long sum; foreach(ref v;a){ scanf("%d",&v); sum+=v; } bool Solve(long m){ int g=114514; int c,e,f; long cs,es,fs=sum; while(c<g){ bool ok = true; while(cs<m){ cs+=a[e]; es-=a[e]; ...
D
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random; import std.typecons, std.functional, std.traits,std.concurrency; import std.algorithm, std.container; import core.bitop, core.time, core.memory; import std.bitmanip; import std.regex; enum INF = long....
D
void main(){ int a, b; scanf("%d %d", &a, &b); if(a==1)a=100; if(b==1)b=100; if(a>b)writeln("Alice"); else if(a<b)writeln("Bob"); else writeln("Draw"); } 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)(){ r...
D
void main(){ import std.stdio, std.string, std.conv, std.algorithm; int n, k; rd(n, k); auto s=readln.chomp.to!(char[]); int[char] freq; foreach(c; s){ if(c in freq) freq[c]++; else freq[c]=1; } int mn=10^^9; for(char c='A'; c<'A'+k; c++){ if(c in freq) mn=min(mn, freq[c]); else mn=mi...
D
import std.stdio,std.conv,std.algorithm,std.array; int[] raia(){ return readln().split().map!(to!int).array; } //read as int[] string[] rasa(){ return readln().split(); } //read as string[] void main() { auto it = raia(); auto W = it[0]; auto H = it[1]; auto x = it[2]; auto y = it[3]; auto r = it[4]; if(...
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; if(nm[0] == nm[1]){ writeln("Yes"); } else ...
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); long x, y; sc.read(x, y); int c = 1; while (x*2 <= y) { x *= 2; c++; ...
D
import std.stdio, std.array, std.conv, std.string; void main() { string[] input = split(readln()); int a = to!int(input[0]), b = to!int(input[1]), c = to!int(input[2]); int ans = 0; for (int i = a; i <= b; ++i) { if (c % i == 0) 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.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.stdio; import std.algorithm; import std.string; import std.conv; void main() { int n = readln.chomp.to!int; for (int i = 0; i < n; i++) { string X = readln.chomp; string Y = readln.chomp; lcs(X, Y).writeln; } } int lcs(string x, string y) { int[][] dp = new int[][](...
D
void main() { writeln(-readln.chomp.to!int + 2 * readln.chomp.to!int); } import std.stdio; import std.string; import std.array; import std.conv; import std.algorithm; import std.range; import std.math; import std.numeric; import std.container; import std.typecons; import std.ascii; import std.uni;
D
void main() { (rs.startsWith("YAKI") ? "Yes" : "No").writeln; } // =================================== 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; ...
D
void main() { auto N = ri; auto S = rs; if(S[0..N/2] == S[N/2..$]) 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.container; import std.b...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { auto s = readln().split()[0].to!int(); if (s==4 || s==2 || s==1) { writeln("4"); return; } auto i = 1; while(true) { if (s == 1) { writeln(i+1); return; } i++; s = f(s); } } int f(int n) { return n%2 == 0 ? n/2 : 3*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, 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; alias Pair = Tuple!(int, "a", int, "b"); void main() { ...
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 a = readln.splitter.map !(to !(int)).array; writeln (min (a[0], a[1]) < max (a[2], a[3]) && min (a[2], a[3]) < max (a[0], a[1]) ...
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; void main() { for (int i = 1; i <= 9; i++){ for (int j = 1; j <= 9; j++){ writeln(i, "x", j, "=", i * j); } } }
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; void main(){ auto ip = readln.split.to!(int[]); writeln((ip[0] - ...
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; import std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ long n = rea...
D
import std.stdio; import std.conv; import std.string; int maximizeHapiness(int money) { int hapiness500 = money / 500 * 1000; int hapiness5 = (money%500) / 5 * 5; return hapiness500 + hapiness5; } void main(){ string[] input = split(readln()); auto money = to!int(input[0]); writeln(maximizeHapiness(m...
D
void main() { string[] tmp = readln.split; int a = tmp[0].to!int, b = tmp[2].to!int; string op = tmp[1]; writeln(op == "+" ? a + b : 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....
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
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
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(){ import std.stdio, std.string, std.conv, std.algorithm; import std.exception; auto args=readln.split.to!(int[]); auto n=args[0], a=args[1], b=args[2]; int mx=0; for(int ka=1; ka<n; ka++){ auto kb=n-ka; auto xa=a/ka, xb=b/kb; mx=max(mx, min(xa, xb)); } writeln(mx); } void rd(T...
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; enum string vowels = "aeiou"; void main() { int k = readln.strip.to!int; char[] z; z.reserve (k); for (int h = 5;...
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 N = readln.chomp.to!long; if (N % 2 == 0) { writeln(N / 2); return; } lon...
D
import std.stdio; void main() { int n; scanf("%d", &n); printf("%lld\n", 1 + 6L * n * (n + 1) / 2); }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; void main() { auto X = readln.chomp.to!long; foreach (a; 1..X+1) { foreach (b; 1..X+1) { if (...
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!long; long s; foreach (i; 1..N+1) { if (i%3 != 0 && i%5 != 0) s += i; } writeln(s); }
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range, core.bitop; void main() { auto PP = new long[](10^^5*2+1); foreach (i; 1..10^^5*2+1) { PP[i] = PP[i % popcnt(i)] + 1; } auto N = readln.chomp.to!int; auto X = rea...
D
module app; import std.stdio; import std.algorithm; import std.range; import std.array; import std.string; import std.conv; void main(string[] args) { auto five_hund = readln.chop.to!int; auto one_hund = readln.chop.to!int; auto fifty = readln.chop.to!int; immutable auto target_yen = readln.chop.to!in...
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto hw = readln.split.to!(int[]); auto h = hw[0]; auto w = hw[1]; auto ab = readln.split.to!(int[]); auto a = ab[0]; auto b = ab[1]; writeln(h * w - (h / a) * (w / b) * a * ...
D
import std.algorithm; import std.range; import std.ascii; import std.array; import std.container; import std.conv; import std.numeric; 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; } long modPow(long mod...
D
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(...
D
import std.stdio, std.string, std.conv, std.range; import std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, std.random, core.bitop; enum inf = 1_001_001_001; enum infl = 1_001_001_001_001_001_001L; void main() { long N, A, B; scan(N, A, B); auto d = abs(A - B); if...
D
module app; import core.bitop; import std.algorithm; import std.array; import std.bigint; import std.conv; import std.stdio; import std.string; struct Input { long h; } void parseInput(T)(out Input input, T file) { with (file) with (input) { h = readln().strip().to!long; } } struct Output { } auto main2(Inp...
D
import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; void main() { auto data = readln().split(); auto A = data[0].to!int(), B = data[1].to!int(), C = data[2].to!int(); writeln(min(B/A, C)); }
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; void main() { int n = readln.chomp.to!int; long min = 1; long sum = readln.chomp.to!long - 1; foreach ...
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"; static string[] s_rd; T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; re...
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 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, std.format; // }}} // nep.scanner {{{ class Scanner { import std.stdio : File, stdin; import std.conv : to; import std.array : split; impor...
D
import std.stdio; import std.string; import std.algorithm; void main() { int a, b; foreach(c; readln().chomp()) { if (c == '0') ++a; if (c == '1') ++b; } write(min(a, b) * 2); }
D
import std; void main(){ auto S = readln().chomp(); if (S == "ABC") writeln("ARC"); else if (S == "ARC") writeln("ABC"); else writeln("入力も正しくできないんですか!!!"); }
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; bool[int] S; for (int i = 0; i * 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 d=readln.chomp.to!int; write("Christmas"); foreach(i; 0..25-d) { write("...
D
import std.stdio; import std.algorithm; import std.conv; import std.array; import std.string; import std.math; import std.functional; import std.range; void main(string[] args) { readln; readln.solve.writeln; } auto solve(string input) { return input.split.map!(to!int).map!(a => divCount(a, 2)).minElementAlt; ...
D
/* imports all std modules {{{*/ import std.algorithm, std.array, std.ascii, std.base64, std.bigint, std.bitmanip, std.compiler, std.complex, std.concurrency, std.container, std.conv, std.csv, std.datetime, std.demangle, std.encoding, std.exception, std.file, std.format, std.functi...
D