code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;
void main() {
int n, m;
scan(n, m);
auto cnt = new int[](n);
auto red = new bool[](n);
cnt[] = 1;
red[0] = 1;
foreach (i ; 0 .. m) {
int xi, yi;
scan(xi, yi);
xi--, yi--;
... | D |
import std.algorithm;
import std.range;
import std.stdio;
import std.string;
immutable string vowels = "aeiou";
void main ()
{
string s;
while ((s = readln.strip) != "")
{
string [] res;
main_loop:
while (!s.empty)
{
foreach (i; 2..s.length)
{
if (!vowels.canFind (s[i - 2]) &&
!vowels.canFi... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import std.string;
import std.traits : isSome... | 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();
alias Point... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | D |
void main() {
problem();
}
void problem() {
auto X = scan!char;
string solve() {
return 'A' <= X && X <= 'Z' ? "A" : "a";
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib... | 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 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.stdio, std.string, std.conv, std.algorithm;
void main() {
int[] tmp = readln.split.to!(int[]);
int p = tmp[0], q = tmp[1], r = tmp[2];
writeln(min(p+q, q+r, r+p));
} | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
int solve (string s)
{
s = s.strip ('1');
if (s.empty)
{
return 0;
}
if (s.all !(q{a == '0'}))
{
return 1;
}
return 2;
}
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
readln.... | 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.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.algorithm;
void main(){
auto a = readln.split.map!(to!int);
writeln(a[0]*a[1], " ", (a[0]+a[1])*2);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1],C=Q[2],D=Q[3];
if(A*B>C*D)writeln(A*B);
else writeln(C*D);
} | D |
import std.stdio;
import std.math;
import std.conv;
import std.string;
int solve(int x) {
return pow(x,3);
}
void main() {
writeln(solve(to!int(chomp(readln))));
} | D |
import std.stdio,
std.string,
std.range,
std.algorithm,
std.conv;
void main(){
readln;
auto S = readln.chomp.split.map!(to!int).array;
readln;
auto T = readln.chomp.split.map!(to!int).array;
int c = 0;
foreach(i; T){
if(!S.find(i).empty)
c++;
}
c.writeln();
// filter!("a")(c... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
void main() {
immutable i = readln.split.to!(ulong[]);
immutable a = i[0], b = i[1];
auto ans = a >= 13 ? b : (a >= 6 ? b/2 : 0);
writeln(ans);
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
void main()
{
auto nk = readln.split.to!(long[]);
auto N = nk[0];
auto K = nk[1];
auto cs = new long[](N+1);
foreach (long i; 0..N+1) {
cs[i] = i;
if (i) cs[i] ... | D |
void main()
{
long a = readln.chomp.to!long - 1;
long b = readln.chomp.to!long - 1;
bool[3] ok;
ok[] = true;
ok[a] = ok[b] = false;
foreach (i, x; ok)
{
if (x) writeln(i + 1);
}
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
im... | D |
import core.stdc.stdio;
import std.algorithm;
void main(){
int n;
scanf("%d",&n);
int[] a = new int[n];
foreach(ref v;a)
scanf("%d",&v);
long[][] dp = new long[][](n,n);
int l = n%2;
if(l)
foreach(i;0..n)
dp[0][i]=a[i];
foreach(s;1..n){
l^=1;
foreach(i;0..n)
if(l)
dp[s][i]=max(dp[s-1][i]+a[(i... | D |
class UF{
int[] par;
this(int n){
par.length=n;
foreach(i; 0..n) par[i]=i;
}
int find(int x){
if(x==par[x]) return par[x];
else return par[x]=find(par[x]);
}
void unite(int x, int y){
if((x=find(x))!=(y=find(y))) par[x]=y;
}
bool same(int x, int y){
return find(x)==find(y);
}
}... | 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^^9 + 7;
void main() {
int n, w;
scan(n, w);
auto dp = new long[](w + 1);
foreach (i ; 0 .. n) {
int wi, vi;
scan(wi... | 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 h, w, k;
scan(h, w, k);
auto c = new ... | D |
import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math;
void main(){
auto x = readln.chomp.to!ulong;
auto n = x / 11 * 2;
auto m = x % 11;
if (1 <= m && m <= 6) {
n++;
} else if (7 <= m) {
n += 2;
}
writeln(n);
} | 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 = "%.15f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional, std.typecons;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
void main()
{
int Q = readln().strip.to!int;
foreach(i;0..Q)
{
auto aList = rea... | 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 core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
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 ... | D |
import std.stdio, std.array, std.conv, std.string, std.algorithm, std.math;
void main() {
while (true) {
auto input = readln.chomp.split;
int a = input[0].to!int;
int b = input[2].to!int;
char op = input[1].to!char;
if (op == '?') { break; }
switch (op) {
case '+':
writeln(a + b);
... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int x,a,b;
scan(x);
scan(a);
scan(b);
auto ans = a + (x - a) / b * b;
ans = x - ans;
writeln(ans);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm :... | D |
void main() {
int n = readln.chomp.to!int;
int k = readln.chomp.to!int;
int x = readln.chomp.to!int;
int y = readln.chomp.to!int;
writeln(n > k ? x * k + (n - k) * y : x * n);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import st... | D |
void solve(){
}
void main(){
int n = inelm();
int a = inelm();
(n*n-a).writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)... | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | D |
import std.stdio,std.string,std.conv,std.array,std.algorithm;
void main(){
for(;;){
auto rcs = readln().chomp().split();
auto scorelist = [to!int(rcs[0]),to!int(rcs[1]),to!int(rcs[2])];
if( scorelist[0]==-1 && scorelist[1]==-1 && scorelist[2]==-1 ){
break;
}
if( scorelist[0]==-1 || scorelist[1]==-1 ){
... | D |
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
void main() {
auto data = readln.split;
auto N = data[0].to!long, X = data[1].to!long;
long height(long level) { return 2^^(level+2) - 3; }
long p_num(long level) { return 2^^(level+1) - 1; }
... | D |
import std.stdio;
import std.ascii;
import std.algorithm;
import core.stdc.stdio;
int main()
{
int t = readInt!int;
foreach(ti; 0 .. t)
{
string str = readString;
auto a = new int[](str.length);
foreach(i, ref ai; a)
switch(str[i])
{
case '0': ai ... | 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.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto data = readln.split;
auto A = data[0].to!long, B = data[1].to!long;
long ans;
foreach (i; 1 .. 41) {
immutable power = 2L^^i;
if (B < power) break;
... | 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;
import std.typecons;
void main() {
auto a = read.to!int;
auto b = read.to!int;
if (a + b == 15) writeln("+");
else if (a * b == 15) writeln("*")... | 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 |
// Vicfred
// https://atcoder.jp/contests/abc160/tasks/abc160_b
import std.conv;
import std.stdio;
import std.string;
void main() {
int n = readln.chomp.to!int;
long ans = (n/500)*1000;
n -= (n/500)*500;
ans += (n/5)*5;
ans.writeln;
}
| 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 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, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!double;
writeln(sqrt(N).to!int^^2);
} | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.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.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n, m;
char[] s;
scan(n, m);
scan(s);
foreach (i ; 0 .. m) {
int l, r;
char c1, c2;
scan(l, r, c1, c2);
... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto x = readln.strip.to !(int);
int step = 0;
int pos = 0;
while (pos < x)
{
step += 1;
pos += step;
}
writeln (step + (po... | D |
void main() {
problem();
}
void problem() {
const N = scan!long;
long solve() {
long ans;
foreach(i; 1..N+1) {
if (i % 3 != 0 && i % 5 != 0) ans += i;
}
return ans;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.str... | D |
/+ dub.sdl:
name "B"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n, m, x;
sc.read(n, m, x);
foreach (i; 0..n+1) {
foreach (j; 0..m+1) {
... | D |
import std.stdio,
std.conv,
std.algorithm,
std.range,
std.string,
std.numeric;
void main() {
size_t a,b;
auto n = readln.chomp.to!size_t - 1;
auto ary = readln.chomp.split.to!(size_t[]);
a = ary[0];
b = ary[1];
foreach(cnt;0..n){
auto tmp = readln.chomp.split.to!(size_t[]);
auto inp_x = tmp[0];
auto i... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
string s = readln.chomp;
int ans;
char x = 'a';
foreach(c; s){
if(x != 'a') if(x != c) ans += 1;
x = c;
}
ans.writeln;
} | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main() {
int count;
while (true) {
auto x = readln.chomp;
if (x == "0") break;
writeln("Case " ~ to!string(++count) ~ ": " ~ x);
}
} | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
auto s = readln.chomp.to!(char[]);
auto n = s.length;
auto a = new long[](n + 1), c = new long[](n + 1), q = new long[](n + 1);
foreach (i; 0 .. n) {
a[i + 1] += a[i];
c[i + 1] += c[i];
q[i + 1] += q[i];
if (s[i] == 'A')
... | D |
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
T[] readToArray(T)() {
return readln.split.to!(... | 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.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | D |
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.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 readC(T...)(size_t n,ref T t){foreach(ref v;t)... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
void main() {
readln.chomp.count!"a == '1'".writeln;
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;... | 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 inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int a, p;
scan(a, p);
auto ans = (3*a + p)... | 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.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
int d;
scan(d);
write("Christmas ");
foreach (i ; 0 .. 25 - d) {
write("Eve ");
}
writeln;
}
void... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
void main() {
string s = readln.strip;
foreach (i; 0 .. 26) {
auto c = (i + 97).to!(char);
if (s.find (c).empty) {
writeln (s, c);
return;
}
}
int l = s.le... | 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;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
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 =... | D |
void main()
{
long n = readln.chomp.to!long;
string digits = "0357";
long cnt;
foreach (i; 0 .. 1000000)
{
long x = i;
long len;
string nums;
while (x)
{
++len;
nums ~= digits[x%4];
x /= 4;
}
long num;
... | D |
void main(){
string s = readln().chomp();
string outs;
foreach(i; 0..s.length){
outs ~= "x";
}
outs.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;
f... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.functional;
void main()
{
auto n = readln.chomp.to!int;
long answer;
foreach (a; 1..n+1)
foreach (b; 1..n+1)
{
immutable g = gcd(a, b);
foreach (c; 1..n+1)
a... | 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 |
//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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | D |
// import chie template :) {{{
static if (__VERSION__ < 2090) {
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, std.numeric;
} else {
import std;
}
// }}}
// nep.scanner {{{
class Scanner {
... | D |
import std.stdio, std.conv, std.string, std.math;
void main(){
auto ip = readln.split.to!(string[]);
auto A = ip[0];
auto B = ip[1];
auto C = ip[2];
if(A[$-1] == B[0] && B[$-1] == C[0]) "YES".writeln;
else "NO".writeln;
} | D |
void main()
{
long a, b, c, d;
rdVals(a, b, c, d);
foreach (i; 0 .. 1000)
{
if (i & 1)
{
a -= d;
if (a <= 0)
{
"No".writeln;
return;
}
}
else
{
c -= b;
if (c <... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto N = readln.chomp.to!int;
auto K = readln.chomp.to!int;
auto ret = 1;
foreach (_; 0..N)
ret = min(ret * 2, ret + K);
writeln(ret);
} | D |
/+ dub.sdl:
name "E"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n;
sc.read(n);
int[] wpos = new int[n], bpos = ... | 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);
long k; read... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
long ask (int lo, int hi)
{
writeln ("? ", lo, " ", hi);
stdout.flush ();
return readln.strip.to !(long);
}
void solve (int n)
{
auto total = ask (1, n);
int lo = 1;
int hi = n;
while (lo < hi)
{
int me = (lo + hi... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }
void solve() {
auto a = reads();
writeln(abs(a[0] - a[1]) > 1 ? ":(" : "Yay!");
}
void main() {
solve();
readln;
} | 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 scan(T...)(ref T args) {
auto line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFro... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return r... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;
void main(string[] args) {
auto input = readln().chomp.split.map!(to!int).array;
if(input[1] == 100){input[1]++;}
auto ans = input[1] * pow(100,input[0]);
ans.writeln;
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
alias Pair = Tuple!(int, "a", int, "b");
void main() {
... | D |
module Main;
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.math;
import std.algorithm;
void main() {
string input;
immutable limitList = 50022;
bool[] listPrimeNumber = new bool[](limitList);
int number, primeNumberSmaller, primeNumberBigger;
listPrimeNumber... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
void main() {
int ans;
foreach (dchar[] line; stdin.lines) {
line = line.chomp;
if (line == line.retro.array) ans++;
}
ans.writeln;
} | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto input1=readln.chomp;
writeln(input1[0],input1.length-2,input1[input1.length-1]);
} | D |
import std.stdio,std.algorithm;
long n,no,ne,mino,so,se,temp;
void main()
{
scanf(" %d",&n);
mino=long.max;
for(int i=0;i<n;++i)
{
scanf(" %d",&temp);
if(temp%2)
{
mino=min(mino,temp);
so+=temp;
++no;
}else{
se+=temp;
++ne;
}
}
writeln(se+so-(no%2?mino:0));
}
| 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() {
long x;
scan(x);
long t;
while (t * (t + 1) / 2 < x) ... | D |
void main(){
int m = _scan();
writeln(48-m);
}
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();
}
r... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int[] primes = [2,3,5];
for(int i=7;primes.length <= 10000;i++){
bool flg = true;
for(int j=0;primes[j]*primes[j]<=i;j++){
if(i%primes[j]==0){
flg = false;
break;
}
}
if(flg) primes ~= i... | D |
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
string str = readln.chomp;
writeln = str.indexOf("9") == -1 ? "No" : "Yes... | D |
void main() {
problem();
}
void problem() {
auto S = scan;
auto N = S.length;
bool solve() {
auto head = S[0..(N-1)/2];
auto tail = S[(N+3)/2-1..$];
S.deb;
head.deb;
tail.deb;
auto s = S;
for(long i = 0; i < s.length/2; i++) {
if (s[i] != s[$-i-1]) return false;
}
... | 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; readV(a);
int b; readV(b)... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int n = readln.chomp.to!int - 1;
int[] a = readln.split.to!(int[]);
int ans = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == a[i + 1])
{
ans++;
i++;
}
}
writeln(ans);
}
| D |
immutable long mod=998244353;
immutable int M=1_000_00*4;
void main(){
import std.stdio, std.algorithm;
long n, a, b, k; rd(n, a, b, k);
auto fact=genFact(M, mod);
auto invFact=genInv(fact, mod);
long comb(long nn, long rr){
if(nn<rr) return 0;
long ret=fact[nn]%mod;
(ret*=invFact[rr])%=mod;... | D |
import std.stdio;
enum conv = [
'I':1,
'V':5,
'X':10,
'L':50,
'C':100,
'D':500,
'M':1000
];
void main()
{
foreach(input; stdin.byLine())
{
int arabia = 0;
if(input.length == 1) arabia = conv[input[0]];
else
{
foreach(i; 1 .. input.length)... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.