code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
string str = readln.chomp;
string[2] ss = ["eraser", "dreamer"];
// array.lengthの返り値の型はulongなので
// intに代入しようとすると(dmd64 v2.070.1では)CEになる
int p = str.length.to!int;
while (p > 0) {
bool flag = fa... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
string my_readln() { return chomp(readln()); }
long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mo... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main(){
auto a = readln.split.map!(to!int);
int n = a[0];
int m = a[1];
int c;
int cnt,gomi;
for(uint i;i<m;++i){
auto b = readln.split.map!(to!int);
c = b[0];
if(c<n){
cnt += n-c;
if(n-c>gomi) gomi = n-c;
}
}
writeln(cnt-gom... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.range, std.typecons;
void main() {
auto S = readln.split.to!(ulong[]);
auto N = S[0], A = S[1], B = S[2];
auto X = readln.split.to!(ulong[]);
ulong res = 0;
foreach (i; 0..N-1) {
res += min((X[i+1] - X[i]) * A, B);
}
writeln... | 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.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()
{
string a; readV(a);
string b; re... | D |
void main()
{
dchar[] s = rdDchar;
dchar[] t;
foreach_reverse (x; s)
{
if (x == 'b') t ~= 'd';
if (x == 'd') t ~= 'b';
if (x == 'p') t ~= 'q';
if (x == 'q') t ~= 'p';
}
writeln(s == t ? "Yes" : "No");
}
enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum... | 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() {
int x;
scan(x);
x -= 400;
auto ans = 8 - (x / 200);
writeln(ans);
}
void scan(T...)(ref T args) {
auto line = rea... | D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
void main() {
const MAX = 1000000;
auto budget = readln.chomp.to!int;
auto hasuu = budget % 100;
int purchasedCount;
while(hasuu > 0) {
if (hasuu < 5) {
purchasedCo... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.numeric;
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... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
const dx = [-1, 0, 1, -1, 1, -1, 0, 1];
const dy = [-1, -1, -1, 0, 0, 1, 1, 1];
void main() {
auto ip = readln.split.to!(int[]), H = ip[0], W = ip[1];
char[][] S;
foreach(_; 0..H) S ~= readln.chomp.dup;
... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons;
immutable int inf = 10^^9 + 7;
int n;
void main() {
scan(n);
long ans = 10L^^5;
foreach (i ; 0 .. n) {
ans = (ans * 105) / 100;
ans = ((ans + 999) / 1000) * 1000;
}
write... | 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 a = readNum!int;
writeln(a^^3);
}
| 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.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto hw = readln.split.to!(int[]);
auto h = hw[0];
auto w = hw[1];
auto ret = "";
foreach (_; 0..(w+1)) ret ~= "#";
ret ~= "#\n";
foreach (_; 0..h) {
ret ~= "#";
ret ~= readln.chomp;
r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nt = readln.split.to!(long[]);
auto N = nt[0];
auto T = nt[1];
auto ts = readln.split.to!(long[]);
ts ~= long.max;
long st;
foreach (i; 0..N) st += min(T, ts[i+1] - ts[i... | 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, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto a = new int[](n), b = new bool[](n);
foreach (i; 0..n) a[i] = readln.chomp.to!int-1;
auto c = 0, d = 0;
for (;;) {
++d;
b[c] = true;
c = a[c];
if (c == 1) {
writeln(d);... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;
void main() {
int n;
scan(n);
long ans = 1;
foreach (i ; 0 .. n) {
long t;
scan(t);
ans = lcm(ans, t);
}
writ... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, m;
rd(n, m);
int[] a;
for (int i = 2; i * i <= m; i++) {
if (m % i == 0) {
int cnt = 0;
while (m % i == 0) {
cnt++;
m /= i;
}
a ~= cnt;
}
}
if (m > 1) {
a ~= 1;
}
const lo... | 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.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
int M = 1000000007;
int[] tbl = [ 1, 10, 9, 12, 3, 4 ];
void main() {
string S = readln.chomp;
auto N = S.length;
ulong[] items = new ulong[0];
int baseMod13 = 0;
foreach(i; 0..N) {
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main(){
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
if(a%500<=b)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, 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()
{
string s; readV(s);
auto n = s.l... | D |
import std.stdio;
void main() {
int m1, m2, d1, d2;
scanf("%d %d\n%d %d\n", &m1, &d1, &m2, &d2);
if (m1 == m2) {
0.write;
}
else {
1.write;
}
}
| 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 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;
T lread(T = long)()
{
return readln.chomp.to!T();
}
T[] aryread(T = long)()
{
return readln.split.to... | D |
void main() {
auto k = ri;
auto s = rs;
if (s.length <= k) writeln(s);
else writeln(s[0..k] ~ "...");
}
// ===================================
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 st... | D |
void main()
{
string s = rdStr;
if (s[0] == '>') s = '<' ~ s;
if (s[$-1] == '<') s ~= '>';
auto g = s.group.array;
long result;
for (long i = 0; i < g.length; i += 2)
{
long x = g[i][1], y = g[i+1][1];
if (x < y)
{
result += x * (x - 1) / 2;
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.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto F=readln.split.to!(int[]),a=F[0],b=F[1],c=F[2];
if(a+b==c||a+c==b||b+c==a)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;
import std.numeric;
void main()
{
auto n = readln.chomp.to!int;
long[char] cnt;
foreach (_; 0..... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{//try{
//auto tokens = split(my_readln());
//auto N = to!ulong(tokens[0]);
//auto W = to!ulong(tokens[1... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto F=readln.split.to!(int[]),A=F[0],B=F[1],C=F[2],D=F[3];
if(A+B<C+D)writeln("Right");
else if(A+B>C+D)writeln("Left");
else writeln("Balanced");
} | D |
import std.stdio;
import std.array;
import std.conv;
void main() {
string[] input = split(readln());
int a=to!int(input[0]);
int b=to!int(input[1]);
if((a*b)%2==0) {
writeln("Even");
}else {
writeln("Odd");
}
}
| 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 times(alias fun)(int n) {
foreach(i... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
const mx=1_000_00+5;
auto isPrime=new bool[](mx);
auto sub=new int[](mx);
isPrime[2]=true;
for(int i=3; i<=1_000_00; i+=2){
for(int j=3; j*j<=i; j+=2){
if(i%j==0) goto hell;
}
isPrime[i]=true;
if(isPrime[(i+1)/2]) su... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
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;
int[2][6] pt;
void main()
{
foreach (i; 0..3) {
auto ab = readln.split.to!(int[]);
pt[i] = [ab[0], ab[1]];
pt[3+i] = [ab[1], ab[0]];
}
foreach (i, a; pt) {
foreach (j, b;... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
void main() {
readln;
string s = readln.chomp;
int count=0;
for(int i=0; i<s.length-2; i++) {
if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') count++;
}
writeln(count);
}
| 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 |
void main()
{
long n = readln.chomp.to!long;
long result;
foreach (i; 1 .. 500001)
{
int x = 108 * i / 100;
if (x == n)
{
result = i;
break;
}
}
if (result > 0)
{
result.writeln;
}
else
{
":(".writeln;
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() ... | D |
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;
struct E{
long[] parentes;
long h=-1;
}
E[] list;
long calc(long i)
{
if(list[i].parentes.empty){
list[i].parentes = [... | 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.string, std.range, std.algorithm;
import std.conv;
void main() {
int n = readln.strip.to!int;if (n == 3 || n == 5 || n == 7) writeln("YES"); else writeln("NO");
} | D |
import std.stdio,
std.string,
std.conv;
string selectOp(int f) {
return (f ? "+" : "-");
}
void main() {
string s = readln.chomp;
int[] a;
for (int i = 0; i < s.length; i++) {
a ~= cast(char)s[i] - '0';
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
for (int k... | 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.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.math;
import std.format;
void main() {
int[] q;
foreach (string line; stdin.lines) {
int n = line.chomp.to!int;
if (n == 0) {
q.back.writeln;
q.popBack;
} else {
q ~= n;
}
... | 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 S = readln.split[0];
int result = 10000;
foreach (i; 0 .. S.length-2) { result = min( (S[i .. i+3].to!int - 753).abs, result); }
result.writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
foreach (i; 0..3) write(readln.chomp.to!(wchar[])[i]);
writeln("");
} | 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;
scan(n);
auto c = new int[](n);
auto s = new int[](n);
auto f = new int[](n);
foreach (i ; 0 .. n-1) {
int ci, si, fi... | 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 ts = readln.split.to!(long[]);
auto I = ts[0];
auto O = ts[1];
auto J = ts[3];
auto L = ts[4];
auto K = O + I/2*2 + J/2*2 + L/2*2;
auto r = I%... | D |
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;
immutable long mod = 10^^9 + 7;
immutable int inf = mod;
void main(){
int n = readln.chomp.to!int;
auto a = new int[](n + 1);
... | D |
import std.stdio, std.string, std.algorithm, std.array, std.conv;
void main() {
for (int i = 0; i < 1000; i++) {
"Hello World".writeln;
}
} | 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 r, g, b; readV(r, g, b);
wri... | 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;
void main() {
string n;
scan(n);
writeln("ABC" ~ n);
}
void scan(T...)(ref ... | D |
import std.stdio, std.conv,std.string;
void main()
{
while(true)
{
int sum=readln.chomp.to!int;
if(sum==0)break;
foreach(unused;0..9)
{
sum-=readln.chomp.to!int;
}
sum.writeln;
}
} | D |
void main()
{
long N = rdElem;
foreach (h; 1 .. 3501)
{
foreach (n; 1 .. 3501)
{
long numer = h * n * N;
long dinom = 4 * h * n - (h + n) * N;
if (dinom <= 0) continue;
long w = numer / dinom, rem = numer % dinom;
if (w > 0 && rem... | 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 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.stdio;
import std.string;
void main()
{
auto s = readln.strip;
writeln( solve( s ) );
}
int solve( in string s )
{
return 700 + s.map!( a => ( a == 'o' ) ? 100 : 0 ).sum;
}
unittest
{
assert( solve( "oxo" ) == 900 );
assert( solve( "ooo" ) == 1000 );
assert( solve( "xxx" ) == ... | 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;
void main()
{
auto A = scanElem;
auto B = scanElem;
auto T = scanElem;
writeln((T/A)*B);
}
class... | D |
import std.stdio, std.string, std.algorithm, std.array, std.conv;
int mex(int[] arr)
{
if (arr.maxElement == 2)
return 2;
else if (arr.minElement == arr.maxElement)
return 1 - arr.minElement;
else
return 2;
}
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(j; 0..t){
int str_l;
scan... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
auto N = readln.chomp.to!int;
bool[int] d;
foreach(_; 0..N) {
d[readln.chomp.to!int] = true;
}
writeln(d.length);
}
| D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int x, a, b;
scan(x, a, b);
if (b - a <= 0) {
writeln("delicious");
}
else if (b - a <= x) {
writeln("safe");
}
else {
writeln("dangerous");
}
}
void scan(T...)(... | D |
import std;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i]... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.algorithm;
void main() {
int n = readln.chomp.to!int;
int minv = readln.chomp.to!int;
int maxv = -1_000_000_000;
foreach (i; iota(1, n, 1)) {
int l = readln.chomp.to!int;
maxv = max(maxv, l - minv);
... | D |
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import c... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long l, r, d;
scan(l, r, d);
long cnt;
foreach (i; l .. r + 1)
{
if (i % d == 0)
{
cnt += 1;
}
}
... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
max(a*b, c*d).writeln;
}
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 s... | D |
import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.container, std.datetime;
void main() {
auto S = readln.chomp;
string result;
foreach (s; S) {
final switch (s) {
case '0':
case '1':
result ~= s;
break;
case 'B':
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
import core.bitop;
void main() {
int n; scan(n);
auto a = iota(n).map!(i => readln.chomp.to!int).array;
auto on = new bool[](32);
int xs;
foreach (i ; 0 .. n) {
o... | D |
module main;
import core.stdc.stdio;
import std.algorithm.sorting;
int gcd (int a, int b) {
if (b == 0)
return a;
else
return gcd (b, a % b);
}
int main(string[] argv)
{
int n;
scanf("%d", &n);
int [] a = new int[n];
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
a.sort();
int small = a[1] - a[0];
for(... | 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;
int calc2(int n) {
if(n <= 1000) {
return n+1;
} else {
return 2000-n+1;
}
}
void main() {
while(!stdin.eof()){
auto s = readln().strip();
if(s.empty())
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a, b, c;
scan(a, b, c);
writeln(a + b >= c ? "Yes" : "No");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.r... | D |
import std;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i]... | 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;
int balance = 0;
int lo = 0;
long res = s.length;
foreach (i, char c; s)
{
balance += (c... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
void main(){
int[] xs = readln.chomp.split.map!(to!int).array;
int x = xs[0], y = xs[1];
writeln(x + y / 2);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main() {
auto s = readln.chomp.split.map!(to!int).array;
if (s[0] * s[1] < s[2]) writeln(s[0] * s[1]);
else s[2].writeln;
} | 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;
immutable long mod = 10L^^9 + 7L;
long n, m;
void main() {
scan(n, m);
if (n < m) swap(n, m);
if (n == m) {
... | 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;
import std.typecons;
import std.format;
void main(string[] args) {
readln.solve.writeln;
}
auto solve(string line1) {
auto _ = line1.chomp.split.map!(to!int).arra... | 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;
bool calc(int h, int w, string[] ss) {
foreach (r; 0..h) {
foreach (c; 0..w) {
if (ss[r][c] == '#') {
... | 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;
long N, cnt;
bool ask(long n) {
writeln("? ", n);
stdout.flush;
cnt += 1;
debug {
string sn = n.to!string;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nx = readln.split.to!(long[]);
auto N = nx[0];
auto x = nx[1];
auto as = readln.split.to!(long[]);
long r;
if (as[0] > x) {
r += as[0] - x;
as[0] = x;
}
... | D |
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
/*
ナップサック問題
xs[i][w]: i個目よ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto abc = readln.split.to!(int[]);
auto AB = abc[0];
auto BC = abc[1];
writeln(AB * BC / 2);
} | D |
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import c... | D |
import 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() {
string s;
scan(s);
yes(check(s));
}
bool check(string s) ... | 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() {
int r = readint;
int g = readi... | D |
import std.conv;
import std.string;
import std.algorithm;
import std.array;
import std.stdio;
void main() {
auto s = readln.chomp;
auto t = readln.chomp;
uint a;
foreach (i;0..s.length) {
if (s[i] != t[i]) {
++a;
}
}
a.writeln;
}
| 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, A;
scan(N);
scan(A);
writeln(N^^2 - A);
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args) {
... | D |
import std.stdio;
void main(){
for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++){
printf("%dx%d=%d\n",i,j,i*j);
}
}
} | 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 |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split, a = rd[0].to!int, op = rd[1], b = rd[2].to!int;
writeln(op == "+" ? a+b : a-b);
}
| D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
long r, g, b, n;
scan(r, g, b, n);
// writeln(r, g, b, n);
long cnt;
foreach (i; 0 .. 3001)
{
foreach (j; ... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
foreach (_; 0..T) {
auto S = readln.chomp;
auto len = S.length;
auto l1 = new size_t[](len);
auto r1 = new size_t[](len);
au... | 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;
import std.random;
void main() {
int nt = readln.strip.to!int;
foreach (tid; 0 .. nt) {
int n = readln.strip.to!int;
auto s = readln.take (n).array;
auto r... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.