code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;
void main() {
string[] inputs = split(readln());
int x = to!int(inputs[0]);
int y = to!int(inputs[1]);
int res_x = group(x);
int res_y = group(y);
if(res_x == res_y) "Yes".writeln;
else "No".writeln;
}
ubyte group(int a) {
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
long[(10^^6)*2+50] F, RF;
long pow(long x, long n) {
long y = 1;
while (n) {
if (n%2 == 1) y = (y * x) % P;
x = x^^2 % P;
n /= 2;
}
return y;
}
long inv(lo... | D |
import std.stdio,std.conv,std.string,std.algorithm,std.array;
void main(){
auto sn=readln().split();
int n,ans;
n=to!int(sn[0]);
ans=n/3;
writeln(ans);
} | 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.typecons;
import std.stdio;
T gcd(T)(T a, T b) {
if (a % b == 0) return b;
return gcd(b, a % b);
}
struct Rat(T) {
import std.math : abs;
T n, d;
this(T n_, T d_) {
if (d_ == 0) {
n = 1;
d = 0;
} else if (n_ == 0) {
d = 1;
n = 0;
} else {
auto c = gcd(abs(n_), abs(d_));
bool neg ... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;
import std.conv;
void main(){
auto n = readln.chomp.to!long;
if(is_harshad(n)){
writeln("Yes");
}else{
writeln("No");
}
}
bool is_harshad(long n){
auto fx = n.to!string.map!((c) => [c].to!long).reduce!("a+b");
ret... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int a, b;
scan(a, b);
int t = 1;
int a... | 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.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;
void main()
{
auto N = scanElem;
auto M = scanElem;
auto Q = scanElem;
long[501][501] table;
foreach(i; 0..M)
{
long l... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto c1 = readln.chomp;
auto c2 = readln.chomp;
writeln(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0] ? "YES" : "NO");
} | 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;
auto a = new long[][](n);
foreach (i; 0 .. n)
{
a[i] = ... | D |
// Your code here!
import std.stdio,std.conv,std.string,std.algorithm,std.array,std.math;
void main(){
auto s=readln().chomp().split().map!(to!int);
int a=s[0],b=s[1],x=s[2];
if(a<=x && x<=a+b)
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, c; readV(a, b, c);
wri... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;
void main()
{
auto n = to!int(chomp(readln()));
auto a1 = n / 100;
auto a2 = (n / 10) % 10;
auto a3 = n % 10;
if (a1 == 1) a1 = 9;
else a1 = 1;
if (a2 == 1) a2 = 9;
else a2 = 1;
if (a3 == 1) a3 =... | D |
import std.stdio, std.conv, std.string, std.range, std.typecons, std.format;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.mutation;
void main()
{
readln();
int[] input = readln().split.to!(int[]);
auto max = input.reduce!"a<b?b:a";
auto sum = input.sum()... | 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 core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
void main()
{
long n = rdElem;
calc(n).writeln;
}
long calc(long x)
{
long result = inf;
for (long i = 1; i * i <= x; ++i)
{
if (x % i == 0)
{
result = min(result, i+x/i-2);
}
}
return result;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdE... | D |
void main() {
auto N = ri;
if(N == 1) {
writeln("Hello World");
} else {
auto A = ri, B = ri;
writeln(A + B);
}
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.containe... | 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 |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int H, W;
scan(H, W);
auto ng =... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto as = readln.split.to!(long[]);
auto cs = new long[](N);
auto ds = new long[](N);
cs[0] = as[0];
foreach (i; 1..N) cs[i] = gcd(cs[i-1], as[i]);
... | 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.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
writeln(reduce!((a,_)=>(a*105+99999)/100000*1000)(100000L,iota(readln().chomp().to!long())));
} | D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
ulong[] NM = readln.chomp.split.to!(ulong[]);
ulong n = NM[0],
m = NM[1];
ulong s, c;
if (n <= m / 2) {
writeln... | D |
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
int[] nums = [0,1,2,3,4,5,6,7,8,9];
int n,s;
int saiki(int x,int m,int item){
if(m == s && item == n) return 1;
if(x == 10) return 0;
return saiki(x+1,m+nums[x],item+1) + saiki(x+1,m,item);
}
void main(){
while(true){
aut... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;
void main()
{
auto tokens = split(chomp(readln()));
auto N = to!ulong(tokens[0]);
auto M = to!ulong(tokens[1]);
string S = chomp(readln());
string T = chomp(readln());
ulong lcm = (N * M) / gcd(N, M)... | 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.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
int m = readln.chomp.to!int;
writeln(48 - m);
}
| D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
void main()
{
auto k = to!int(chomp(readln()));
auto a = k / 2;
auto b = k / 2 + k % 2;
writeln(a * b);
stdout.flush();
} | 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 A = Tuple!(int, "... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
int abs(int n) {
return n < 0 ? -n : n;
}
void main() {
int[] arr = readln.chomp.split.to!(int[]);
bool flg = false;
writeln(
(abs(arr[0] - arr[2]) <= arr[3] || abs(arr[0] - arr[1]) <= arr[3] && abs(arr[1] - arr[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.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
void main() {
int n = readint();
int[] a = 0 ~ readints() ~ 0;
auto d = new int[n + 1];
foreach (i; 0..n+1) {
... | 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;
char[8][8] s;
void bom(int x,int y){
s[y][x] = '0';
for(int dx=-3;dx<=3;dx++){
int nx = x + dx;
if(0<=nx&&nx<8)
i... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void solve()
{
auto N = readln.chomp.to!long;
long x;
foreach (long i; 0..32) {
x += x + (2L^^i)^^2;
if (N >= x) {
N -= x;
} else {
... | 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, c, x, y; readV(a, b, c, ... | 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.concurrency;
void main() {
readln.chomp.to!int.rep!r... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | 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 n = readNum!int;
auto w = readNums!int;
int ans = 10001;
f... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto n = readln.chomp.to!int;
auto ps = readln.split.to!(int[]);
int cnt;
if (ps[0] == 1) {
swap(ps[0], ps[1]);
cnt++;
}
foreach (i; 1..n) if (ps[i] == i+1) {
swap(ps[i], ps[i... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;
void main() {
auto N = readln.chomp.to!int;
auto A1 = readln.split.to!(int[]);
auto A2 = readln.split.to!(int[]);
int res;
int tmp;
foreach(i; 0..N) {
tmp += A1[i];
res = max(res... | 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;
long calc(string[] g) {... | D |
import std;
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(_; 0..t)
{
auto s = readln.strip;
auto z = count(s, '0');
auto o = s.length - z;
if (z == 0 || o == 0)
writeln(0);
else if (o == z)
if (s.length > 2)
... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
long[63] ns, cs;
foreach (i; 0..63) ns[i] = (1L<<(i+1))-1;
foreach (_; 0..T) {
auto N = readln.chomp.to!int;
auto as = readln.split.to!(long... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.... | D |
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;
int N;
string S;
char[] ans;
bool solve() {
foreach (i; 1..N-1) {
auto prev = ans[(i-1+N)%N];
... | D |
import std;
void main() {
string s = read;
string t = read;
writeln(t.startsWith(s) ? "Yes" : "No");
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
ali... | 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 |
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(){
int n = read... | D |
import std.stdio;
import std.string;
void main() {
int n, k;
scanf("%d %d\n", &n, &k);
auto l = readln.chomp();
write(l[0..k-1] ~ l[k-1..k].toLower ~ l[k..$]);
}
| D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
int calc(string s) {
... | 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.algorithm;
import std.array;
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 scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
// Vicfred
// https://atcoder.jp/contests/abc168/tasks/abc168_b
// implementation
import std.conv;
import std.stdio;
import std.string;
void main() {
int K = readln.chomp.to!int;
string S = readln.strip;
if(S.length > K) {
S[0..K].write;
"...".writeln;
} else {
S.writeln;
}... | 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() {
dchar[] n = readln.chomp.to!(dchar[]);
dchar[] m = n.dup;
reverse(m);
writeln(n == m ? "Yes" : "No");
}
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.typ... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(int);
auto a = readln.splitter.map !(to !(int)).array;
int [] d;
int i = 0;
while (i < n * 2)
{
int ... | D |
import std.stdio;
import std.conv;
import std.string;
import core.bitop;
void main()
{
auto N = readln.chomp.to!long;
immutable march = "MARCH";
long[march.length] list;
foreach (_; 0 .. N)
{
auto name = readln();
foreach (i, c; march)
{
if (name[0] == c)
... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
string[] inputs = split(readln());
int A = to!int(inputs[0]);
int B = to!int(inputs[1]);
int C = to!int(inputs[2]);
int D = to!int(inputs[3]);
if(A + B > C + D) writeln("Left");
else if(A + B == C + D) writeln("Balanced");
else writeln("Righ... | 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;
// }}}
// tbh.scanner {{{
class Scanner {
import std.stdio;
import std.conv : to;
import std.ar... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
foreach (_; 0..T) {
readln;
auto as = readln.split.to!(int[]);
auto x = as[0]%2;
foreach (a; as) if (x != a%2) goto ng;
writ... | 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.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, q; readV(n, q);
string s;... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main() {
auto A = readln.chomp.to!int;
auto B = readln.chomp.to!int;
auto C = readln.chomp.to!int;
auto D = readln.chomp.to!int;
writeln(min(A, B) + min(C, D));
}
| 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;
auto AS = readln.split.to!(long[]);
auto BS = readln.split.to!(long[]);
long solve(long N, long[] XS, long[] YS) {
int[]... | D |
import std;
alias Book = Tuple!(int, "cost", int[], "ss");
int calc(int x, Book[] books) {
int p = cast(int)books.length;
int n = cast(int)books[0].ss.length;
int ans = int.max;
for (int i = 0; i < (1 << p); i++) {
int cost = 0;
auto ss = new int[n];
for (int j = 0; j < p; j++... | 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.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
immutable inf = 10^^9 + 7;
void main() {
int n, m;
scan(n, m);
auto c = readln.split.to!(int[]);
auto uf = UnionFind(n);
foreach (i ; 0 .. m) {
... | D |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
string s;
sc.read(s);
int n = s.length.to!int;
int[] sm = new int[n+1];
foreach ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
int main() {
auto digit = 0;
string buf;
while ((buf = strip(readln())) != null) {
digit = calc_digit(buf);
writeln(calc_digit(buf));
}
return 0;
}
int calc_digit(string src) {
string[] seed = split(src);
... | 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 X = readln.split[0].to!(long);
foreach (A; 0 .. 10^^3+1) foreach (B; 0 .. A) {
if (A^^5 - B^^5 == X) { writeln (A, " ", B); return; }
if (A... | 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, K;
scan(N);
scan(K);
auto x = new int[](N);
x = readln.split.to!(int[]);
int ans;
foreach (i ; 0 .. N) {
ans += min(2 * x[i... | 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 int INF = 1 << 29;
bool solve() {
auto N = readln.chomp.to!int;
auto P = readln.split.map!(to!int).array;
auto X = re... | 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;
void main(){
string[6] ans;
for(int i=1;i<=6;i++) ans[i-1] = to!char(i + '0') ~ ":";
int n = readln().chomp().to!in... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
int[10^^5] NS;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
foreach (_; 0..M) {
auto ab = readln.split.to!(int[]);
auto a = ab[0] - 1;
auto b = ab[1] -... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto ab = readln.split.to!(int[]);
int s, i = 1;
while (i <= ab[1] - ab[0]) {
s += i;
++i;
}
writeln(s - ab[1]);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split, a = rd[0], b = rd[1];
writeln(a == b ? "H" : "D");
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.range;
void main(){
auto a=readln.chomp;
auto b=readln.chomp;
auto c=readln.chomp;
writeln("" ~ a[0] ~ b[1] ~ c[2]);
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, m; rd(n, m);
writeln((m*1900+(n-m)*100)*(1<<m));
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i, ref e; x){
e=l[i].to!(typeof(e));
}
} | D |
// 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;
int n, a;
int[] x;
void main() {
scan(n, a);
x = readln.split.to!(int[]);
auto... | D |
/+ dub.sdl:
name "D"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
long isq(long x) {
long l = 0, r = 10L^^10;
while (r-l > 1) {
long md = (l+r)/2;
if (md*(md-1) < x) l = md;
else r = md... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
long solve (long [] a)
{
long a0 = min (a[0], 2);
a[0] -= a0;
long a3 = min (a[3], 2);
a[3] -= a3;
long a4 = min (a[4], 2);
a[4] -= a4;
long res = 0;
res += a[1];
a[1] = 0;
res += (a[0] / 2) * 2;
a[0] %= 2;
... | D |
import std.stdio;
import std.algorithm;
import std.math;
import core.stdc.stdio;
int[int] compCoord(ref int[] data){
data.sort;
int[int] ret;
int c=0;
foreach(i,d;data){
if((d in ret) is null){
ret[d] = c;
data[c++] = d;
}
}
data = data[0..c];
return ret;
}
void main(){
while(1){
int w,h;
scanf("%... | 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.chomp;
auto T = readln.split.array;
foreach (t; T) {
if (S[0] == t[0] |... | D |
void main()
{
long n, m;
rdVals(n, m);
long[] a = rdRow;
max(n-a.sum, -1).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))
{
return readln.chomp.to!T;
}
alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 1000000007L;
long pow(long x, long n) {
long y = 1;
while (n) {
if (n%2 == 1) y = (y * x) % P;
x = x^^2 % P;
n /= 2;
}
return y;
}
alias Iw = Tuple!(long, "a", long,... | D |
import std.stdio;
void main(){
for(int i = 0; i < 1000; i++)
writeln("Hello World");
} | 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 n = readln.chomp.to!int;
int[] h = readln.split.to!(int[]);
int hs = h[0];
int cnt = 1;
foreach (i; 1 .. n) {
if (h[i] >= hs) {
++cnt;
hs = h[i];
}
}
cnt.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.co... | D |
import std.stdio;
void main() {
string input = readln();
int count;
foreach(char c; input) {
if(c == '1') count++;
}
writeln(count);
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto a=readln.chomp;
writeln("ABC",a);
} | 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;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return 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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ... | 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.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.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
auto d = aryread();
auto m = lread();
auto t = aryread();
long[long] dd;
foreach (i; 0 .. n)
{
dd[d[i]]... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.