code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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 |
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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!int;
writeln(n*(n+1)/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;
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.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 |
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.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.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.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 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.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() {
int n = readint;
bool[int] m;... | D |
import std.stdio;
import std.conv;
import std.string;
const int DATA = 200;
int main() {
int[] digit = new int[DATA];
int i;
for(i=0; i<DATA; i++) {
string[] data = chomp(readln).split(" ");
if(stdin.eof()) break;
int val = to!(int)(data[0]) + to!(int)(data[1]);
int dig = 1;
while((val/=10) ... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
int N = readln.chomp.to!int;
char[] S = readln.chomp.dup;
foreach(ref c; S) {
c = ((c - 'A' + N) % 26) + 'A';
}
S.writeln;
}
| 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.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 N;
scan(N);
auto a = new in... | D |
// Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_f
// dynamic programming, cumulative sum
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
long n = readln.chomp.to!long;
long[] b = readln.split.map!(to!long).array;
long[] a;
a ~= 0... | D |
import std.stdio;
import std.algorithm;
import core.stdc.stdio;
import core.memory;
void main(){
while(true){
GC.collect;
int[][4][23] nextTown;
int[4] beTown;
beTown[] = -1;
int[10][10] mapData;
int[] dx = [0,-1,0,1];
int[] dy = [-1,0,1,0];
int w,h;
scanf("%d%d",&w,&h);
if(w==0&&h==0)
break;
for(int i=... | D |
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;
bool is_prime(long x) {
if (x <= 1 || x % 2 == 0) return false;
long i = 3;
while ... | D |
void main() {
rs.count!(i => i == '2').writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typ... | 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() {
string s = readln.chomp;
int w;
scan(w);
foreach (i ; 0 .. (s.length.to!int + w - 1) / w ) {
write(s[i*w]);
}
write... | D |
import std.stdio, std.ascii;
void main() {
auto d = readln.dup;
foreach (c; d) {
if (c.isLower) c.toUpper.write;
else c.toLower.write;
}
} | 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;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | D |
void main()
{
long x = rdElem;
long now = 100;
long year;
while (now < x)
{
now += now / 100;
++year;
}
year.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... | 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() {
writeln("ABC", readln.cho... | 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.split.map!(to!int);
auto N = s[0];
auto M = s[1];
int hi = N;
int lo = 1... | 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.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 |
#!/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; )
{
auto nm = S.split().map!(to!int)();
auto n=nm[0], m=nm[1];
auto d = new int[][](n,n);
foreach(i;0..m)
{
a... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
void main(){
auto a=map!(to!int)(readln.chomp.split);
if(a[0]>a[1])
writeln("a > b");
else if(a[0]<a[1])
writeln("a < b");
else
writeln("a == b");
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto a = readln[0];
switch (a) {
case 'A': .. case 'Z':
writeln("A");
return;
default:
writeln("a");
return;
}
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;
void main() {
writeln(readln.chomp.count!"a == 'o'" * 100 + 700);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.prim... | D |
import std.stdio;
import std.string;
void main()
{
bool flg = false;
bool[char] num;
foreach(char a;readln.chomp())
if(a in num) num[a] = !num[a];
else num[a] = true;
foreach(bool a;num)
flg |= a;
writeln(flg? "No" : "Yes");
}
| 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 ps = new int[](10^^6+1);
foreach (i; 2..10^^6+1) if (ps[i] == 0) {
auto x = i;
while (x <= 10^^6) {
ps[x] = i;
x += i;
... | 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp, n = s.length;
writeln((n % 2 == 0) ^ (s[0] == s[$-1]) ? "Second" : "First");
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;
void main()
{
readln;
readln.chomp.split.array.reverse.join(" ").writeln;
} | 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), x = rd[0], a = rd[1], b = rd[2];
if (b-a <= 0)
writeln("delicious");
else if (b-a <= 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.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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
if (n % 2 == 0)
{
writeln((n / 2) - 1);
}
else
{
writeln((n - 1) / 2);
}
}
void scan(L...)(ref... | 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 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(){
int n = _scan();
string[] st = readln().chomp().split();
char[] ans;
foreach(i; 0..n){
ans ~= st[0][i];
ans ~= st[1][i];
}
ans.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行に同... | D |
void main()
{
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], k = tmp[1];
writeln(n - k + 1);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.as... | 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; }
/*
a[i]: i番目を踏むときの最善
漸化式は
a... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto rdx = readln.split.to!(long[]);
auto r = rdx[0];
auto D = rdx[1];
auto x = rdx[2];
foreach (_; 0..10) {
x = r*x-D;
writeln(x);
}
} | D |
import std;
auto input()
{
return readln().chomp();
}
alias sread = () => readln.chomp();
void main()
{
long N;
scan(N);
// writeln(N);
long 今の時間 = 0;
long 今のx座標 = 0;
long 今のy座標 = 0;
long dist = 0;
bool check = true;
long time = 0;
foreach (i; 0 .. N)
{
long T,... | D |
void main() {
problem();
}
void problem() {
const N = scan!int;
const X = scan!int;
const Y = scan!int;
void solve() {
int[int] counts;
foreach(i; 1..N) {
foreach(j; i+1..N+1) {
auto liner = j - i;
auto linerIToX = X - i;
if (linerIToX < 0) linerIToX *= -1;
au... | 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 |
void main() {
auto S = rs;
("A" ~ S[8] ~ "C").writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.t... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n, a, b;
scan(n, a, b);
writeln(min(a*n, b));
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitiv... | D |
void main() {
problem();
}
void problem() {
auto D = scan!int;
auto T = scan!int;
auto S = scan!int;
bool solve() {
return T * S >= D;
}
writeln(solve() ? "Yes" : "No");
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.conta... | 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; readV(a, b);
if (a ==... | 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 |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
for (;;) {
auto rd = readln.split.map!(to!int), n = rd[0], x = rd[1];
if (n == 0 && x == 0) break;
auto r = 0;
foreach (i; 1..n+1)
foreach (j; i+1..n+1) {
auto k = x - i - j;
if (k > j && k <= n) ++... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto x = readln.split[1].to!long;
auto as = readln.split.to!(long[]);
auto last = as[0];
long let = 0;
foreach (a; as[1..$]) {
long d;
if (a+last > x) {
d = (a+last) - x;
let += ... | 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 |
//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;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializ... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;
void main()
{
auto x = readln.chomp.to!long;
if (x < 7) {
writeln(1);
} else if (x < 12) {
writeln(2);
} else {
auto ret = (x / 11) * 2;
writeln(ret + (x%11 == 0 ? 0 : x%11 > 6 ? ... | 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.random;
int ri () {
return readln.stripRight.to!int;
}
string slow (string z, int k) {
auto s = z.dup;
f... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto R = readln.chomp.to!int;
auto G = readln.chomp.to!int;
writeln(2 * G - R);
} | D |
import std.stdio, std.conv, std.string, std.array;
void main(){
int check,cnt=0;
auto n = readln.chomp.to!int;
for(uint i;i<n;++i){
check = 0;
auto s = readln.chomp.to!int;
for(uint x=1;x*x<s;++x){
if((s+x+1)%(x*2+1)==0){
check=1;
break;
}
}
if(check==0) cnt++;
}
cnt.writeln;
} | 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.startsWith("... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
int N = readln.chomp.to!int;
string S = readln.chomp;
int ans = 0;
char prev = '0';
foreach(c; S) {
if(c != prev) ans++;
prev = c;
}
ans.writeln;
}
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.