code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | D |
import std.stdio, std.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, std.bitmanip;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto S = readln.chomp;
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 |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
long n = rea... | 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 |
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;
import std.string;
import std.conv;
import std.algorithm;
bool[100000] prime;
void initPrime() {
prime[0] = false;
prime[1] = false;
for (int i = 3; i < 100000; i++) {
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
prime[i] = false;
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
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_rd[0]; s_rd.popFront; re... | 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()
{
int x;
for (auto i = 1; ; ++i) {
x = readln.chomp.to!int;
if (x == 0) break;
writeln("Case ", i,... | D |
import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
void main()
{
auto s = readln.chomp;
auto abc = "ABC";
auto mod = 10 ^^ 9 + 7;
long[][4] dp;
foreach (ref row; dp)
row ... | D |
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
struct gom{
int x = -1;
int depth=-1;
this(int a,int b){
x = a;
depth = b;
}
}
gom[][5000] kugi;
void main(){
string[] fi = readln().split();
int n = to!int(fi[0]);
int m = to!int(fi[1]);
for(int i = 0;i < m;++i){
string[] inpu... | 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!int;
if(N <= 999) writeln("ABC");
else writeln("ABD");
} | D |
import std.stdio;
void main() {
auto s = readln;
auto r = (s[0] == s[1] && s[0] == s[2]) ? "No" : "Yes";
writeln(r);
}
| D |
// Vicfred
// https://atcoder.jp/contests/abc045/tasks/abc045_b
import std.array;
import std.stdio;
import std.string;
import std.range.primitives;
void main() {
string a = readln.strip;
string b = readln.strip;
string c = readln.strip;
char[] A;
foreach(ch; a)
A ~= ch;
char[] B;
... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
int[] buf = readln.chomp.split.to!(int[]);
int a = buf[0], p = buf[1];
writeln((a * 3 + p) / 2);
}
| D |
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.math;
void main() {
string s;
while( (s=readln()).length != 0 ){
string[] input = split(s);
int a = to!int(input[0]);
int x= 0;
for(int i=0;i<10;i++){
if(a%2==1){
if(x!=0) write(" ");
write(pow(2,i));
x++;
... | D |
import std.stdio;
import std.string;
void main()
{
string input;
int count = 0;
for (int i = 1; ; i++) {
input = chomp(readln());
if (input == "0") break;
writeln("Case ", i, ": ", input);
}
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
void main()
{
ulong N = readln.split[0].to!ulong;
string S = readln.chomp;
S = "." ~ S ~ "#";
int switch_i = 0;
while (S[switch_i] == '.') switch_i++;
int cnt = 0;
foreach (i; switch_i..(N + 2)) if (S[i] == '.') cnt++... | 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 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 MOD = 10^^9 + 7;
void main() {
auto N = readln.chomp;
auto K = readln.chomp.to!int;
auto dp = new int[](1001);
dp[1] =... | 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;
// 差の絶対値
@nogc @safe pure T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
// 切り上げ除算
@nogc @safe pur... | D |
module main;
import std.stdio : readln, writeln, write, writefln, writef;
import std.conv : to;
import std.array : split, replace;
import std.string : strip;
import std.algorithm : max, min, map, reduce, sort, reverse;
import std.functional : memoize;
version = B;
version (A)
{
void main()
{
auto seq... | 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;
import std.typecons;
import std.datetime.systime : Clock;
class InputReader {
private:
ubyte[] 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 |
void main() {
int[] tmp = readln.split.to!(int[]);
int n = tmp[0], k = tmp[1];
writeln(n % k != 0 ? 1 : 0);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons; | D |
import std.stdio;
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.ascii;
void main()
{
auto s = readln.chomp;
int res;
switch (s) {
case "SUN":
... | 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;
import std.string;
void main()
{
auto n = readln;
auto s = readln.strip;
writeln( solve( s ) );
}
int solve( in string s )
{
auto lc = new int[ s.length ];
lc[ 0 ] = 0;
foreach( i; 1 .. s.length )
{
lc[ i ] = lc[ i - 1 ] + ( s[ i - 1 ] == 'E' ? 0 : 1 );
}
auto rc = new int[ s.length ... | 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.array, std.conv, std.string;
void main() {
while (true) {
string[] input = split(readln());
int h = to!int(input[0]);
int w = to!int(input[1]);
if (h == 0 && w == 0) return;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
write("#");
}
... | 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 nxt = readln.split.to!(int[]);
auto N = nxt[0];
auto X = nxt[1];
auto T = nxt[2];
writeln((N + X - 1) / X * T);
} | D |
import std.stdio, std.conv, std.string;
void main() {
int N = to!(int)(readln().chomp());
writeln(N/3);
}
| D |
import std.stdio;
import std.algorithm;
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]);
ulong[] A;
foreach (i; 0..N)
{
auto tokens2 ... | 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 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.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp, a = s.map!(c => cast(int)(c-'0')).sum, n = s.to!int;
writeln(n%a == 0 ? "Yes" : "No");
}
| D |
void main()
{
string s = readln.chomp;
auto g = s.group.array;
writeln(g.length - 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.ascii;
import ... | 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 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 bignu... | 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 x = lread();
long ans;
foreach (p; 2 .. 11)
{
... | 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 b = readln.split[0];
if (b == "A") "T".writeln;
if (b == "T") "A".writeln;
if (b == "G") "C".writeln;
if (b == "C") "G".writeln;
}
| 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 n, k;
scan(n, k);
auto a = aryread();
// writeln(a)... | 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.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 N;
scan(N);
auto ans = N * (N - 1) / 2;
writeln(... | D |
import std.stdio, std.string, std.conv, std.math;
void main(){
real x = 0, y = 0, rad = 90;
while(true){
auto line = readln.chomp.split(",");
auto speed = line[0].to!int;
if(speed == 0) break;
x += cos(rad / 180 * PI) * speed;
y += sin(rad / 180 * PI) * speed;
ra... | 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) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primiti... | D |
import std.stdio;
import std.string;
import std.conv;
import std.math;
void main ()
{
double a = 100000;
int n = to!int(chomp(readln()));
foreach (i; 0 .. n)
{
a = a * 1.05;
if(a % 1000)
a = a - (a % 1000) + 1000;
}
writeln(to!int(a));
} | 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.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 k; readV(k);
writeln((k/2) *... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
void main(){
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
auto h=readln.chomp.to!int;
writeln((a+b)*h/2);
}
| 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 long inf = mod;
void main(){
long n, m;
readVars(n, m);
auto ans = modpow(n, m, mod... | 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, K;
scan(N, K);
auto ans ... | 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[] lreads(T = long)(long n){return generate(()=>readln.c... | 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 a = readln.split[0].to!int;
auto b = readln.split[0].to!int;
auto c = readln.split[0].to!int;
auto d = readln.split[0].to!int;
auto e = readln.split[0].to!int... | D |
import std.stdio; // readln
import std.array; // split
import std.conv; // to
void main(){
string[] s = split(readln());
int a = to!int(s[0]);
int b = to!int(s[1]);
int c = to!int(s[2]);
if(a == b) writeln(c);
else if(a == c) writeln(b);
else writeln(a);
}
| D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto nq = readints();
int n = ... | D |
import std.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 std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm, std.typecons;
void main(){
auto buf = readln().strip().split().map!(to!int)();
immutable N = buf[0];
immutable K = buf[1];
if((N-1)/2 + 1 >= K) {
writeln("YES");
} else {
writeln("NO");
}
}
| 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.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;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string[] inputs = split(readln());
int a = to!int(inputs[0]);
int b = to!int(inputs[1]);
int c = to!int(inputs[2]);
if(a + b == c || b + c == a || c + a == b) "Yes".writeln;
else "No".writeln;
}
| 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; }
void main(){
auto n = read.... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_... | 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;
void main()
{
readln;
auto a = readln.chomp.split.map!(to!int);
writeln = a.reduce!max - a.reduce!min;
}
| D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto a = lread();
auto s = sread();
if (a >= 3200)
writeln(s);
else if (a < 3200)
writeln("red");
}
//https://rclone.org/
v... | 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() {
auto s = new bool[](10^^5 + 1);
s[] = 1;
s[0] = s[1] = 0;
for (int p = 2; p*p <= 10^^5; p++) {
if (s[p]) {
for (int q =... | 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.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) {
stderr.writeln(arg);
}
int size(T)(in T s) {
return cast(int)s.length;
}
lon... | D |
import std;
void main()
{
const N = readln().chomp().to!uint();
const S = readln().chomp();
size_t ans = count(S, 'R') * count(S, 'G') * count(S, 'B');
foreach (uint i; 0 .. N)
foreach (uint j; i + 1 .. N)
{
if (S[i] == S[j]) continue;
const k = 2 * j - i;
if (k >= 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 = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_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.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()
{
auto rd = readln.split.map!(to!int);
auto a = rd[0], b = rd[1];
writeln(a == b ? "a == b" : (a < b ? "a < ... | 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()
{
int n = readln.chomp.to!int;
bool[int] set;
foreach (i; 0..n) {
int... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n, k;
scanf("%d%d", &n, &k);
int[] x = new int[n];
foreach (i; 0..n) scanf("%d", &x[i]);
int c = x.assumeSorted.lowerBound(0).leng... | 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;
import std.typecons;
void main() {
auto N = readln.chomp.to!int;
char[] S = cast(char[])readln.chomp;
foreach(i; 0..S.length) {
S[i] = 'A' + (S[i] - 'A... | 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;
int a, b, ab, r;
foreach (_; 0..N) {
auto s = readln.chomp;
if (s[0] == 'B' && s[$-1] == 'A') {
++ab;
} else if (s[0] == 'B'... | 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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
auto a = aryread();
long ans;
foreach (i; 0 .. n)
{
ans += a[i] - 1;
}
writeln(ans);
}
void scan(L..... | D |
import std.stdio;
import std.string;
import std.ascii;
void main() {
string s = readln.chomp;
writeln( (s.length >= 6 && s.count!(isDigit) >= 1 && s.count!(isUpper) >= 1 && s.count!(isLower) >= 1) ? "VALID" : "INVALID" );
} | D |
void main()
{
long n = readln.chomp.to!long;
if (n & 1)
{
0.writeln;
}
else
{
long cnt;
long d = 10;
while (d <= n)
{
cnt += n / d;
d *= 5;
}
cnt.writeln;
}
}
import std.stdio;
import std.string;
import std.ar... | 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 route... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto DP = new long[][](2, 2019);
long r;
foreach (i, c; S) {
auto n = c - '0';
foreach (x; 0..2019) DP[i%2][x] = 0;
DP[i%2][n] = 1;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
int main()
{
int i = 0;
while (++i <= 1000)
writeln("Hello World");
return 0;
} | 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;
void main()
{
writeln = readln.chomp.split.join.to!int % 4 ? "NO" : "YES";
}
| 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 |
void main() {
auto S = rs;
bool flag = true;
if(S[0] != 'A') flag = false;
ulong tmp;
foreach(i; 2..S.length-1) {
tmp += S[i] == 'C';
}
if(flag) {
ulong tmp2;
foreach(i; S) {
if(i.isUpper) tmp2++;
}
if(tmp2!=2) flag = false;
}
if(tmp != 1) flag = false;
writeln(flag ? "AC" : "WA");
}
// ========... | 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;
import std.string;
import std.conv;
void main(){
string str;
string[] input = split(readln());
int a = to!int(input[0]), b = to!int(input[1]);
if(a > b)
str = " > ";
else if(a < b)
str = " < ";
else
str = " == ";
writeln('a',str,'b');
} | D |
import std.stdio, std.algorithm, std.array, std.string, std.conv;
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(_; 0..t)
{
auto str = readln.strip;
int zero_cnt, five_cnt;
bool zero_f = false, five_f = false;
for(int i = cast (int) str.length - 1; i > 0; ... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
bool check(string s){
for(int i=0;i<s.length-3;i++){
string str = s[i..i+4];
if(str == "this" || str == "that"){
writeln(s);
return true;
}
}
return false;
}
void main(){
int n = to!int(chomp(rea... | 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() {
problem();
}
void problem() {
auto N = scan!long;
const K = scan!long;
long solve() {
while(true) {
real ratio = cast(real)N / cast(real)K;
if (ratio <= 0.5) return N;
if (ratio < 1.0) return K - N;
N = N - (N/K)*K;
}
}
solve().writeln;
}
// ---------------... | D |
import std.stdio,std.string,std.algorithm,std.conv;
void main(){
readln;
auto a=readln.chomp.split.to!(ulong[]);
ulong[ulong] l;
foreach(x;a)
l[x]++;
ulong sum;
foreach(x;l.values)
sum+=x*(x-1)>>1;
foreach(x;a)
(sum-(l[x]-1)).writeln;
} | 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;
void main()
{
auto S = readln.strip;
if(S[0]==S[$-1]){
writeln(S.length%2==0?"First":"Second");
}else{
writeln(... | D |
module aoj;
import std.array;
import std.stdio;
import std.string;
void main() {
string line;
while ((line = chomp(readln())) != "END OF INPUT") {
foreach (word; split(line, " ")) {
write(word.length);
}
writeln();
}
} | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;
void main()
{
foreach (line; stdin.byLine) {
auto x = line.chomp;
if (x.length == 0) continue;
auto f = new string[](10... | 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.uni;
void main() {
string w = readln.chomp;
int cnt = 0;
while (true) {
string t = readln.chomp;
if (t == "END_OF_TEXT") break;
string[] s = t.toLower.split;
foreach (x; s) {
if (x == w) ++cnt;
}
}
cnt.writeln;
}
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.