code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio,std.conv,std.string,std.algorithm,std.array;
void main(){
auto s=readln().chomp().split().map!(to!int);
int a=s[0],b=s[1];
writeln(max(a+b,a-b,a*b));
} | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n;
scanf("%d\n", &n);
int[][] g = new int[][n];
int[] degree = new int[n];
foreach (i; 0..n-1) {
int x, y;
scanf("%d %d\n", &x, &y);
--x; --y;
g[x] ~= ... | D |
void main()
{
long n, m;
rdVals(n, m);
long result = n * (n - 1) / 2 + m * (m - 1) / 2;
result.writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
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.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.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 |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, g;
rd(n, g);
struct P {
int p, c;
}
auto ps = new P[](n);
foreach (i; 0 .. n)
rd(ps[i].p, ps[i].c);
int mn = 1000000000;
foreach (bit; 0 .. (1 << n)) {
int s = 0, cnt = 0;
foreach (i; 0 .. n) {
if (bit ... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm;
void main() {
int d = readln.chomp.to!int;
("Christmas " ~ repeat("Eve", 25 - d).join(" ")).writeln;
} | D |
import std.algorithm;
import std.array;
import std.ascii;
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;
bool ... | 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 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.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
void main() {
int n = read();
writeln(n&1 ? 2*n : n);
}
| D |
import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;
// Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eo... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
void main() {
int n = readln.chomp.to!int;
auto L = readln.chomp.split.map!(to!int).array;
int[] is_alive = new int[n];
for (int i = n - 1; i > 0; i--) {
if (L[i] == 0) continue;
int idx = max(0, i - L[i]);
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio;
import std.string;
import std.conv;
import std.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 times(alias fun)(int n) {
foreach(i; 0..n) fun();
}
auto 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, core.stdc.string;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
long ans = 0;
long w = 0;
foreach_rev... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], c = tmp[2];
writeln(c % gcd(a, b) == 0 ? "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;... | 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;
import core.bitop;
const int segSize = 1 << 20;
int[segSize * 2] seg;
// a_i を v に上書き
void update(int ind, int v) {
ind +=... | 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 s = readStr;
int[char] dic;
foreach(c; s){
dic[c]++;
}... | D |
void main()
{
string s = readln.chomp;
string t = "CODEFESTIVAL2016";
int cnt;
foreach (i; 0 .. 16)
{
if (s[i] != t[i]) ++cnt;
}
cnt.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import s... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] AR... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
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 % mod)) % mod; }
long m... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;
void main()
{
foreach(line; stdin.byLine)
{
auto s = line.chomp;
if(s == "0") return;
writeln(reduce!"a+b"(0, s.map!"a-'0'"));
}
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
void main() {
string[] inputs = split(readln());
int A = to!int(inputs[0]);
int B = to!int(inputs[1]);
int result = A + B;
if(result < 10) result.writeln;
else "error".writeln;
}
| D |
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;
void main()
{
while (true) {
auto rd = readln.split.map!(to!int);
auto h = rd[0], w = rd[1];
if (h == 0 && w ==... | 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 |
#!/usr/bin/env rdmd
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
void main()
{
for(string S; (S=readln().chomp()).length; )
{
long[3] h;
foreach(c;S)
if(c=='B') ++h[0];
else if(c=='S') ++h[1];
else ++h[2];
auto n = array(re... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 10^^9+7;
long[10^^5*2+50] F, RF;
void init()
{
F[0] = F[1] = 1;
foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;
{
RF[$-1] = 1;
auto x = F[$-1];
auto k = P-2;
... | 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 long mod = 10^^9 + 7;
void main() {
int n;
scan(n);
auto s = iota(n + 1).array;
long ans = 1;
foreach (p ; 2 .. n + 1) {
if (s[p] ... | 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;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
readint();
auto ss = readints(... | 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 us = new int[][](H, W);
auto ds = new int[][](H, W);
auto ls = new int[][](H, W);
auto rs = new int[][... | D |
import std.stdio : writeln;
void main() {
int a,b;
scan(a,b);
writeln((a+b+1)/2);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.array : split;
import std.conv : to;
import std.range.primitives;
string[] line = readln.split;
foreach (ref arg; args) {
... | 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 x, y, z;
scan(x, y, z);
int ans = (x - z) / (y + z);
writeln(ans);
}
void scan(T...)(ref T args) {
string[] line = readln.split;
... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
import std.typecons;
import std.bigint;
// import dcomp.foundation, dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
long n, m;
sc.read(n, m);
long[][] a = new 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;
writeln(0);
stdout.flush();
auto f = readln.chomp;
if (f == "Vacant") return;
int l = 0, r = N;
for (;;) {
auto m = (l+r)/2;
wri... | 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;
bool calc(int a, int b)... | D |
void main()
{
dchar[] s = readln.chomp.to!(dchar[]);
reverse(s);
string[] words = ["dream", "dreamer", "erase", "eraser"];
dchar[][] rev = new dchar[][](4);
foreach (i, x; words)
{
rev[i] = x.to!(dchar[]);
reverse(rev[i]);
}
long index;
bool ok = true;
while (in... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
auto input = readln.split.to!(int[]);
if(input.all!"1 <= a && a <= 9"()) {
writeln(input[0] * input[1]);
} else {
writeln(-1);
}
}
| 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() {
strin... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
auto N = split(readln())[0].to!int();
auto L = split(readln()).map!(x => to!int(x));
auto sum = reduce!("a + b")(L);
foreach (i; 0 .. N) {
if (sum-L[i] <= L[i] ) { writeln("No"); return; }
}
writeln("Yes");
} | D |
unittest
{
assert( [ "36", "24" ].parse.expand.solve == "GREATER" );
assert( [ "850", "3777" ].parse.expand.solve == "LESS" );
assert( [ "9720246", "22516266" ].parse.expand.solve == "LESS" );
assert( [ "123456789012345678901234567890", "234567890123456789012345678901" ].parse.expand.solve == "LESS" );
assert( [ ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main(){
if(readln.chomp.to!int == 1){
writeln("Hello World");}
else{
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
writeln(a+b);}
} | 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[]);
int cnt, last, d;
foreach (a; AS) {
if (last) {
if (d == 0) {
if (last > a) {
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!int;
writeln(n*(n+1)/2);
}
| 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 ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
auto PS = readln.split.to!(int[]);
int a, b, c;
foreach (p; PS) {
if... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.range;
void main() {
auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1], C = ip[2], D = ip[3];
if(B <= C || D <= A) 0.writeln;
else if(A <= C) (B < D ? B - C : D - C).writeln;
else (B < D ? B - A : D - A).w... | D |
void main(){
int n = _scan();
(n^^3).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 ~= elm.to!T();
}... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main(){
auto z=readln.split.to!(int[]),a=z[0],b=z[1],c=z[2];
if(a+b<=a+c&&a+b<=b+c)writeln(a+b);
else if(a+c<=a+b&&a+c<=b+c)writeln(a+c);
else if(b+c<=a+b&&b+c<=a+c)writeln(b+c);
} | 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 = 10^^6;
void main() {
int r;
scan(r);
writeln(r < 1200 ? "ABC" : r < 2800 ? "ARC" : "AGC");
}
void scan(T...)(ref T args)... | D |
import std.stdio,std.conv;
long[2001] a,b;
long n,x,y,ans;
void main()
{
scanf(" %d",&n);
for(int i=0;i<n;++i)
{
scanf(" %d %d",&x,&y);
++a[to!uint(x+y)];
++b[to!uint(1000+x-y)];
}
for(int i=0;i<=2000;++i)
{
if(a[i]>1) ans+=a[i]*(a[i]-1)/2;
if(b[i]>1) ans+=b[i]*(b[i]-1)/2;
}
writeln(ans);
}
| D |
void main()
{
long x = rdElem;
long result = ceil(0.5 * (-1 + sqrt(1.0 + 8.0 * x))).to!long;
result.writeln;
}
T rdElem(T = long)()
{
//import std.stdio : readln;
//import std.string : chomp;
//import std.conv : to;
return readln.chomp.to!T;
}
alias rdStr = rdElem!string;
dchar[] rdDch... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int q;
rd(q);
int l = 0, r = 0; // [l, r)
auto pos = new int[](2 * 10 ^^ 5 + 1);
while (q--) {
char t;
int x;
rd(t, x);
if (t == 'L') {
pos[x] = --l;
} else if (t == 'R') {
pos[x] = r++;
} else {
... | D |
import std.stdio;
void main(){
auto cin = new Cin();
auto ab = cin.line!long();
if( ab[0] <= 0 && 0 <= ab[1] ){
writeln("Zero");
} else if( ab[1]<0 && (ab[1]-ab[0])%2==0 ){
writeln("Negative");
} else {
writeln("Positive");
}
//sum.writeln();
}
auto solve(){
}
unittest{
}
import std.stdio,std.co... | 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() {
while (true) {
int N, M;
... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
static import std.ascii;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){ret... | D |
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
{
ulong a, b;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto array = readln().strip().split();
a = array[0].to!ulong;
... | 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 N = readln.chomp.to!int;
auto S = readln.chomp;
auto dp =... | 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], d=N[3];
if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)) writeln("Yes");
else writeln("No");
} | 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 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 MOD =... | D |
void main() {
problem();
}
void problem() {
auto a = scan!long;
auto b = scan!long;
auto c = scan!long;
auto d = scan!long;
long solve() {
if ((b <= 0 && c >= 0) || (a >= 0 && d <= 0)) {
return -1 * min(abs(a), abs(b)) * min(abs(c), abs(d));
}
return max(a*c, b*d);
}
solve().write... | 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()
{
immutable mod = 1_000_000_000 + 7;
auto n = readln.chomp.to!int;
long res = 1;
... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
long q, h, s, d;
scan(q, h, s, d);
// writeln(q, ' ', h, ' '... | D |
import std.stdio;
import std.conv;
import std.array;
import std.math;
void main()
{
auto reader = readln.split;
int A = reader[0].to!int;
int B = reader[1].to!int;
int diff = abs(A - B);
if (diff % 2 == 0){
writeln((A + B) / 2);
} else {
writeln("IMPOSSIBLE");
}
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;
void main()
{
int n = readln.chomp.to!int;
long[] t = new long[](n);
foreach (ref v; t) {
v = readln... | D |
module AOJ_Volume0101;
import std.stdio,std.string,std.conv,std.array;
int main()
{
int n = readln.chomp.to!int;
while(n--)
{
string s = readln.chomp;
replace(s,"Hoshino","Hoshina").writeln;
}
return 0;
} | 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.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto N = readln.chomp.to!long;
auto W = readln.split.to!(long[]);
long count = W.sum;
foreach(i; 0..N){
long x = abs(W.sum - 2*((W[0..i]).sum));
if(x < count) count=x;
}
writeln(count);
} | D |
import std;
alias S = Tuple!(int, "a", int, "b", int, "c", int, "d");
int calc(int n, int m, S[] s) {
int ans = 0;
void rec(int last, int p, int[] buf) {
if (p == buf.length) {
int t = 0;
foreach (e; s) {
int x = buf[e.b - 1] - buf[e.a - 1];
if ... | 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];
int[][] cs;
foreach (_; 0..H) cs ~= readln.split.to!(int[]);
int[] xs1, ys1, xs2, ys2;
foreach (i; 0..H) {... | 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, 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, d;
scan(n, d);
auto c = 2*d + 1;
... | 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);
writeln(s.le... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
auto s = readln.chomp.to!(char[]);
auto t = readln.chomp.to!(char[]);
char[char] map;
foreach (i; 0 .. s.length) {
if (s[i] in map) {
if (t[i] != map[s[i]]) {
writeln("No");
return;
}
} else {
map[... | 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.algorithm, std.conv, std.array, std.string;
void main()
{
auto ss = readln.chomp;
while (ss) {
ss = ss[0..$-2];
auto l = ss.length;
if (ss[0..l/2] == ss[l/2..$]) {
writeln(l);
return;
}
}
} | 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;
void main() {
auto S = readln.chomp;
auto T = readln.chomp;
auto N = S.length.to!int;
auto M... | D |
void main()
{
int[] tmp = readln.split.to!(int[]);
int m1 = tmp[0], d1 = tmp[1];
tmp = readln.split.to!(int[]);
int m2 = tmp[0], d2 = tmp[1];
writeln(m1 != m2 && d1 > d2 ? 1 : 0);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
imp... | D |
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
void main() {
auto S = readln.chomp;
writeln(S == "Sunny" ? "Cloudy" : S == "Cloudy" ? "Rainy" : "Sunny");
}
| D |
import std;
void main() {
int n; scan(n);
int m = n % 10;
if (m == 3) writeln("bon");
else if ([0, 1, 6, 8].canFind(m)) writeln("pon");
else writeln("hon");
}
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.ch... | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto T = readln.chomp.to!int;
foreach (_t; 0..T) {
auto nn = readln.split.to!(int[]);
auto N = nn[0];
auto A = nn[1];
auto B = nn[2];
auto C = nn[3];
... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
while(1){
auto n = readln.chomp.to!int;
if(n==0) break;
int s=1;
int max=50000001;
for(int i=2;i*i<n;++i){
if(n%i==0){
if(i<max){
s+=(i+n/i);
max = n/i;
if(i==max)
s -= i;
}else break;
... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto N = readln.chomp.to!int;
int[] as;
int[3] ns;
foreach (c; readln.chomp) {
auto a = c - '1';
++ns[a];
as ~= a;
}
foreach (r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto ab = readln.split.to!(int[]);
writeln((ab[0]&1) == 1 && (ab[1]&1) == 1 ? "Odd" : "Even");
} | 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.algorithm, std.array, std.range;
auto solve(string s_){
immutable K = s_.chomp.to!int();
if(K<13) return K.to!string();
string a;
void add(int i){ a~=(i+'0').to!char(); }
immutable M=18;
auto dp = new int[10][M];
dp[1][]=1;
auto t=9;
... | D |
import std.stdio, std.string, std.conv, std.algorithm;
immutable int n = 2019;
void divmod(int x, ref int a, ref int b) {
a = x / n;
b = x % n;
}
void main() {
int[] tmp = readln.split.to!(int[]);
int ld, lm, rd, rm;
divmod(tmp[0], ld, lm);
divmod(tmp[1], rd, rm);
if (ld != rd) {
... | 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.stdlib;
void main() {
auto N = readln.chomp.to!int;
auto S = readln.chomp;
auto R = new int[](N+1);
auto G = new ... | 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 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, std.algorithm, std.range, std.array, std.typecons;
void main() {
auto s = readln.strip;
if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
writeln("Bad");
} else {
writeln("Good");
}
}
| 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!(int[]);
auto N = nx[0];
auto x = nx[1];
if (x == 1 || x == N*2-1) {
writeln("No");
return;
}
writeln("Yes");
int[] line;
bool... | 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 n = lread();
auto a = aryread();
// writeln(a);
aut... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.