code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
int parse(string s)
{
int r;
if (s[0] == '0') {
r += s[1] - '0';
} else {
r += s[0..2].to!int;
}
r *= 60;
if (s[3] == '0') {
r += s[4] - '0';
} else {
r +... | D |
void main()
{
string s = rdStr;
s = s[0..$-2];
long len = s.length >> 1;
while (s[0..len] != s[len..$])
{
s = s[0..$-2];
--len;
}
s.length.writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
return readln.chomp.... | 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 |
//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.stdio, std.range, std.random, std.conv, std.string, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;
void main()
{
int[] input = readln().strip.split().to!(int[]);
int N = input[0];
int K = input[1];
... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | 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;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
//END OF TEMPLATE
void main(){
auto k=scan!siz... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math; // math functions
void main()
{
auto rd = readln.split.to!(long[]), x = rd[0], y = rd[1];
writeln((x-y).abs <= 1 ? "Brown" : "Alice");
}
| D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
void main()
{
string n = chomp(readln());
int a = to!int(n);
if(a%10 == a/100){
writeln("Yes");
} else {
writeln("No");
}
} | 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;
long calc(long n, long ... | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto N = readln.split.to!(int[]), A=N[0], B=N[1], C=N[2];
if((A<C&&C<B)||(B<C&&C<A)){
writeln("Yes");
}else{
writeln("No");
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
T[][] comb(T)(in T[] arr, in int k) pure nothrow {
if (k == 0) return [[]];
typeof(return) result;
foreach (immutable i, immutable x; arr)
foreach (suffix; arr[i + 1 .. $].comb(k - 1))
result ~= x ... | 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(int a, int b,... | D |
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;
void main() {
auto a = map!(x => x.to!int)(readln.chomp.split);
if (a[0] + a[1] == a[2] + a[3]) {
writeln("Balanced");
} else if (a[0] + a[1] < a[2] + a[3]) {
writeln("Right");
} else {
writeln("Left");
}
}
| D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto n=readln.chomp.to!int,a=readln.split;
int ma=a[0].to!int,mi=a[0].to!int;
for(int i;i<n;i++){
ma=max(ma,a[i].to!int);
mi=min(mi,a[i].to!int);
}
writeln(ma-mi);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto o = readln.chomp, no = o.length;
auto e = readln.chomp, ne = e.length;
auto r = new char[](no+ne);
foreach (i, c; o) r[i*2] = c;
foreach (i, c; e) r[i*2+1] = c;
writeln(r);
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nhlr = readln.split.to!(int[]);
auto N = nhlr[0];
auto H = nhlr[1];
auto L = nhlr[2];
auto R = nhlr[3];
auto as = readln.split.to!(int[]);
auto DP = new int[][](N, H);
... | D |
import std.functional,
std.algorithm,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
bool[int] isPrime;
void init_isPrime() {
foreach (i; 1..10^^5+1) {
isPrime[i] = true;
}
foreach (i; 2..100001) {
if (isPrime[i]) {... | 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, std.bitmanip;
// }}}
// nep.scanner {{{
class Scanner {
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long k = tmp[0], t = tmp[1];
long[] a = readln.split.to!(long[]);
long day = 2 * a.reduce!max - a.sum - 1;
writeln(day > 0 ? day : 0);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.ran... | 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, core.bitop;
void main()
{
auto S = scanString;
foreach(i;0..3)
{
if(S[i]==S[i+1]){
... | D |
void main() {
auto X = rs;
string res = X[0..1];
foreach(i; X[1..$]) {
if(res.length == 0) { res ~= i; continue; }
auto p = res.back;
if(p == 'S' && i == 'T') res.popBack;
else res ~= i;
}
res.length.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functio... | 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 |
// 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;
void main() {
int s = readln.chomp.to!int;
writeln(s / 3600, ":", s / 60 % 60, ":", s % 60);
} | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof... | 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;
scan(n);
long ans = 1;
foreach (k ; 1 .. 30) {
long bn = 1L * (2L^^k - 1) * (2L^^(k - 1));
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
void main()
{
foreach (line; stdin.byLine) {
string str = line.to!string.chomp;
foreach (i; 0..26) {
if (str.caesar(i).split.count!(s => s == "the" || s == "this" || s == "that") > 0) {
... | 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 = 10^^9 + 7;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
bool read(ref string str){
str=readln.chomp();
if(str==null)return false;
return true;
}
void main(){
string str;
while(read(str)){
string[] s=str.split(" ");
auto n1=s[0].to!int();
auto n2=s[1].to!int();
writeln... | 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;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_00... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(wchar[]);
int r = int.max;
foreach (i; 0..S.length-2) {
r = min(r, abs(753 - S[i..i+3].to!int));
}
writeln(r);
} | 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, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n, m;
scan(n, m);
long t = 100 * (n - m) + 1900 * m;
long ans = 2L^^m * t;
writeln(ans);
}
void scan(T...)(ref T args) {
str... | 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.functional;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (e... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias A = Tuple!(long, "i", long, "j");
void main()
{
auto hwd = readln.split.to!(int[]);
auto H = hwd[0];
auto W = hwd[1];
auto D = hwd[2];
auto AS = new A[](H*W+1);
foreach (long i; 0..H) {... | 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.container;
void main()
{
auto hw = readln.chomp.split.map!(to!int);
auto field = new string[](hw[0]);
foreach (i; 0..hw[0]) {
field[i] = readln.chomp;
}... | 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;
import core.bitop : popcnt;
alias Generator ... | 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;
void main() {
auto N = readln.chomp.to!int;
auto A = N.iota.map!(_ => readln.chomp.to!int).array;
auto S = new ... | D |
import std.stdio;
int main(string[] argv)
{
for (int i = 0; i < 1000; ++i)
writeln("Hello World");
return 0;
} | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
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() {
int 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 main() {
auto ... | D |
// Cheese-Cracker: cheese-cracker.github.io
void solve(){
long u = scan;
long v = scan;
long y = v * v;
long x = - (u * u);
writeln(x, " ", y);
}
void main(){
long tests = scan; // Toggle!
while(tests--) solve;
}
/************** ***** That's All Folks! ***** ***********... | D |
void main() {
auto X = readAs!long;
ulong cnt;
long tmp = 100;
while(X > tmp) {
tmp *= 1.01;
cnt++;
}
cnt.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conta... | D |
import std.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.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 i = readln.chomp;
if (i[0] != 'A')
{
"WA".writeln;
return;
}
if (i[1].isUpper || i[$ - 1].isU... | D |
import std.algorithm;
import std.array;
import std.container;
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[]... | 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 Rect = Tuple!(int... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main()
{
int b=0;
while(1){
auto a = readln.split.map!(to!int);
if(a[0]==0) break;
if(b) writeln();
int flag=0;
for(uint i=a[0];i<=a[1];++i){
if(i%4==0){
if(i%100==0){
if(i%400==0){
flag=1;
i.writeln();
... | D |
import std.stdio, std.algorithm, std.array, std.string, std.conv;
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(_; 0..t)
{
long a,b,c;
scanf("%lld %lld %lld\n", &a, &b, &c);
writeln(max(0, max(b,c) - a + 1), ' ', max(0, max(a,c) - b + 1), ' ', max(0, max(a,b) - c... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.array;
void main(){
auto a=readln.chomp;
if(a=="oxx"||a=="xox"||a=="xxo")writeln(700+100);
else if(a=="oox"||a=="oxo"||a=="xoo")writeln(700+200);
else if(a=="ooo")writeln(700+300);
else writeln(700);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto w = readln.chomp;
auto a = new int[](26);
foreach (c; w) ++a[cast(int)(c - 'a')];
writeln(a.all!(ai => ai % 2 == 0) ? "Yes" : "No");
}
| 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 a, b, t;
scan(a, b, t);
writeln(t / a *... | D |
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
int DEBUG_LEVEL = 0;
void pr... | D |
import std.stdio, std.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.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array;
T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
//END OF TEMPLATE
void main(){
long n,k;
... | 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.string;
import std.algorithm;
import std.functional;
import std.conv;
enum long INF = long.max/5;
void main() {
while(solve()){}
}
bool solve() {
int n = readln.chomp.to!int;
if (n == 0) return false;
long[] as = new long[n];
foreach(i; 0..n) {
as[i] = readln.chomp.to!long... | 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!(int[]);
auto ss = new bool[](2000*n+1);
void solve(int i, int s) {
if (i == n) return;
solve(i+1, s);
... | 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 |
void main()
{
long n = rdElem;
long[] a = rdRow;
long[] b = new long[n+1];
long[long] cnt;
++cnt[0];
foreach (i, x; a)
{
b[i+1] = b[i] + a[i];
++cnt[b[i+1]];
}
long result;
foreach (x; cnt.byValue)
{
result += x * (x - 1) / 2;
}
result.write... | 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;
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 b = new long[][](64, 0);
... | 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;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | 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;
int n;
long k;
rd(n, k);
auto s = readln.chomp.to!(char[]);
auto dp = new long[][](n + 1, n + 1);
dp[0][0] = 1;
auto last_pos = new int[](26);
fill(last_pos, -1);
for (int i = 1; i <= n; i++) {
foreach (j; 0 .. i) {
dp[... | D |
import std.string,
std.stdio,
std.conv;
void main() {
int[] xab = readln.chomp.split.to!(int[]);
int x = xab[0],
a = xab[1],
b = xab[2];
int z = b - a;
if (z <= 0) {
writeln("delicious");
} else if (0 < z && z <= x) {
writeln("safe");
} else {
writeln("dangerous");
... | 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.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nd = readln.split.to!(int[]);
auto N = nd[0];
auto D = nd[1];
int[][] xs;
xs.length = N;
foreach (i; 0..N) {
xs[i] = readln.split.to!(int[]);
}
int c;
f... | D |
void main() {
int n = readln.chomp.to!int;
writeln((n - 1) / 2);
}
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, 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.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFE... | 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(long n, long[... | D |
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;
void main() {
long x, y;
auto s = map!(x => x.to!long)(readln.chomp.split);
x = s[0];
y = s[1];
long res = 0;
while (x <= y) {
x *= 2;
++res;
}
writeln(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;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto nq = readints();
int n = ... | D |
import std.array;
import std.range;
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;
void main(string[] args) {
string s = readln.chomp;
string[] words = ["dream", "dreamer", "erase", "eraser"];
bool ans = false;
loop: while (true) {
if (s.length <= 0) {
... | 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 s = readln.chomp;
int r, b;
foreach (i; 0..n... | D |
// unihernandez22
// https://atcoder.jp/contests/abc150/tasks/abc150_c
// implementation
import std.stdio;
import std.array;
import std.conv: to;
import std.string: chomp;
import std.algorithm;
import std.range: iota;
import std.math: abs;
void main() {
int n = readln.chomp.to!int;
int[] p = readln.split.map!(to!in... | D |
import std.algorithm;
import std.array;
import std.range;
import std.conv;
import std.stdio;
import std.string;
import std.typecons;
alias FairyPos = Tuple!(int,int);
void main(){
auto inputs = readln.chomp.split.map!(to!int);
auto a = inputs[0];
auto b = inputs[1];
auto c = inputs[2];
string ans... | 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 adj = new int[][](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 |
import std;
const MOD = 10^^9 + 7;
long calc(int n, int k) {
long ans = 0;
for (long i = k; i <= n + 1; i++) {
long lo = (0 + i - 1) * i / 2;
long hi = (n - i + 1 + n) * i / 2;
ans = (ans + hi - lo + 1) % MOD;
}
return ans;
}
void main() {
int n, k; scan(n, k);
writeln... | D |
// Try AtCoder
/// author: Leonardone @ NEETSDKASU
import std.stdio : readln, writeln;
import std.string : chomp;
import std.array : split;
import std.conv : to;
import std.typecons : Tuple;
import std.math : abs;
auto getVals(T)() { return readln.chomp.split.to!(T[]); }
void main() {
Tuple!(int,"... | 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, m;
scan(n, m);
auto p = readln.split.to!(int[]);
p[] -= 1;
auto uf = UnionFind(n);
foreach (i ; 0 .. m) {
i... | 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;
int n, m;
int[] a;
void main() {
scan(n, m);
a = readln.split.to!(int[]);
auto imos0 = new long[](m + 2);
a... | 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;
alias Edge = Tuple!(int, "to", int, "idx");
void main() {... | 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.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;
int[] di = [1, 1, -1, -1];
int[] dj = [1, -1, 1, -1];
void main() {
... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.numeric, std.math, std.array;
int n, x; rd(n, x);
auto a=readln.split.to!(int[]);
auto d=a.map!(e=>abs(e-x)).array;
if(n==1){
writeln(d[0]);
return;
}
auto g=gcd(d[0], d[1]);
foreach(i; 2..n) g=gcd(g, d[i]);
wri... | D |
import std.stdio,
std.string,
std.conv,
std.range,
std.algorithm;
void main() {
int[] buf = readln.chomp.split.to!(int[]);
int n = buf[0], m = buf[1], x = buf[2];
int[] A = readln.chomp.split.to!(int[]);
int count_left,
count_right;
for (int i = x - 1; i >= 1; i--) {
if... | 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()
{
bool[string] c;
auto a = readln.chomp.split;
foreach (e; a) {
c[e] = true;
... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
writeln(readln.chomp.group.canFind!"a[1] >= 3" ? "Yes" : "No");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.pr... | 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.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto xs = 5.iota.map!(_ => readln.chomp.to!int).array;
auto cs = xs.map!(x => x % 10).filter!(m => m > 0).array;
auto m = cs.empty ? 0 : (10 - cs.reduce!min);
writeln(xs.map!(x => cast(int... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.