code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string s = readln.chomp;
if (s[0] != 'A') {
writeln("WA");
return;
}
if (s[2..$-1].count('C') != 1) {
writeln("WA");
return;
}
string po = s.toLower;
for (int i = 0; i < s.length; i++) {
if (... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;
auto readInts() {
return array(map!(to!int)(readln().strip().split()));
}
auto readInt() ... | 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.algorithm;
import std.range;
import std.conv;
void main() {
string[] input = split(readln());
int n = to!int(input[0]);
int a = to!int(input[1]);
int b = to!int(input[2]);
bool check() {
if (a+b-1 > n) return false;
if (long(a)*b < n) return false;
... | 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 x = readln.chomp.to!int;
writeln(x < 1200 ? "ABC" : "ARC");
... | 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 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 |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.algorithm;
import std.typecons;
int main() {
auto sc = new Scanner(stdin);
int n;
sc.read(n);
alias Edge = Tuple!(int, ... | D |
void main() {
dchar[] s = readln.chomp.to!(dchar[]);
int cnt;
foreach (i; 1 .. s.length) {
if (s[i] == s[i-1]) {
if (s[i] == '1') s[i] = '0';
else s[i] = '1';
++cnt;
}
}
cnt.writeln;
}
import std.stdio;
import std.string;
import std.array;
import ... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;
void main() {
auto input = readln.split.to!(int[]);
auto N = input[0], K = input[1], Q = input[2];
auto A = new int[Q];
foreach(i; 0..Q) {
A[i] = readln.split[0].to!int - 1;
}
auto ps = new int[N];
ps[] = K;... | 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 |
void main()
{
writeln(180 * (readln.chomp.to!int - 2));
}
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 std.uni; | D |
import std.array;
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
void main(){
string[] input;
input.length = 10;
for(int j=0;j<10;++j){
input[j] = chomp(readln());
}
int[] num;
num.length = 10;
for(int i=0;i<10;++i){
num[i] = to!int(input[i]);
}
sort(num);
write... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long n;
scan(n);
auto a = aryread();
long cnt;
foreach (i; 0 .. n)
{
if ((i % 2 == 0) && (a[i] % 2 != 0))
cnt += ... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
writeln(a <= b ? a : a - 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;
impor... | 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;
R delegate(Args) Z(R, Args...)(R delegate(R delegate(Args), Args) f){
return (Args args) => f(Z(f), args);
}
void main() {
(N =>
(Fibonacci =>
Fibonacci(1, 1, N)
)(Z((ulong delegate(ulong, ulong, ulong)solver, ulong n1, ulong n2, ulong N) =>
... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.algorithm, std.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, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;
void main() {
int n, q;
scan(n, q);
auto sd = SqrtDecomp(n);
foreach (_ ; 0 .. q) {
auto line = readln.split.to!(int[]);
if (line[0] == 0) {
sd.add(line[1] - 1, line[2]);
... | 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 h = readln... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
int r, d, x; readV(r, d, x);
fo... | 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 |
void main() {
long s = readln.chomp.to!long;
long x1 = 1L;
long x2 = 10L ^^ 9;
long y1 = (s + x2 - 1) / x2;
long y2 = x2 * y1 - s;
writeln(0, " ", 0, " ", x1, " ", y1, " ", x2, " ", y2);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std... | 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)() { 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; }
long mod = pow... | D |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.math;
import std.stdio;
import std.string;
struct Input
{
int n;
int[] p, q;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
n = readln().strip().to!int;
p = readl... | D |
import std.stdio;
void main(string[] args) {
int done = 0;
string[6] data;
for (int i = 0; i < 6; i++)
{
data[i] = std.stdio.readln();
// data[i] = std.string.stripRight(data[i]);
}
int[][] cost = [
[ 3, 3, 0, 4, 4, 0, 3, 3 ],
[ 3, 3, 0, 4, 4, 0, 3... | D |
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;
void main(){
auto ip = readln.split.to!(int[]), A=ip[0], B=ip[1];
if(A<6) writeln(0);
else if(A<13) writeln(B/2);
else writeln(B);
} | D |
module main;
import core.stdc.stdio ;
int main()
{
int n,l,r,q,k=0,j=0,ans=0,low,mid,i;
scanf("%d", &q);
int [] a = new int[1000005];
for(i=0;i<q;i++)
{
scanf("%d:%d",&l,&r);
k=l*60+r;
a[k]++;
a[k+1440]++;
}
for(i=0;i<2879;i++){
if(a[i]==0) j++;
else {
... | 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!(long[]);
foreach (a; AS) if (a == 0) {
writeln(0);
return;
}
long r = 1;
foreach (a; AS) {
if (r ... | 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 xab = readints();
int x =... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto A = readln.chomp.to!int;
auto B = readln.chomp.to!int;
if (A + B == 5) {
writeln(1);
} else if (A + B == 4) {
writeln(2);
} else if (A + B == 3) {
writel... | 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.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{
auto N = to!ulong(my_readln());
auto tokens = split(my_readln());
auto T = to!long(tokens[0]);
auto A = to!long(tokens[... | D |
import std.stdio, std.string, std.conv;
import std.algorithm;
void main()
{
for(string t; (t=readln().chomp()).length;)
{
immutable N = t.length;
auto a = new int[26][N+1];
int s=-1, e=-1;
void solve()
{
foreach(int i,c;t)
{
immuta... | D |
void main() {
auto arr = [ri,ri,ri,ri,ri];
int res = int.max;
do {
int current = 0;
foreach(v; arr) {
if(current % 10 != 0) current += (10 - current % 10);
current += v;
}
res = min(res, current);
} while(nextPermutation(arr));
res.writeln;
}
// ===================================
import std.stdio;... | D |
void main()
{
long[] tmp = rdRow;
long n = tmp[0], m = tmp[1];
writeln(n == m ? "Yes" : "No");
}
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[] rdDchar()
{
//im... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.array;
struct P { int x, y; }
void main()
{
int[102][102] m;
auto f = readln.split.map!(to!int);
int W = f[0],
H = f[1];
foreach(i; 0 .. H)
{
foreach(j, n; readln.split.map!(to!int).array)
{
m[i + 1][j ... | D |
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
/+
// mod must be a prime number
struct Mod(uint mod) if (mod < int.max) {
import std.conv : to;
uint n;
this(int m) { this(long(m)); }
this(long m) { this.n = m >= 0L ? cast(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto N = readln.chomp.to!int;
wchar[][] MAP;
MAP.length = N;
foreach (ref line; MAP) {
auto cs = readln.chomp.to!(wchar[]);
line = cs ~ cs;
}
int cnt;
foreach (o; 0..N) {
void ... | 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.conv;
import std.stdio;
import std.array;
import std.range;
import std.string;
import std.algorithm;
void main()
{
switch(readln().chomp()) {
case "1 0 0" : writeln("Close"); break;
case "0 1 0" : writeln("Close"); break;
case "1 1 0" : writeln("Open"); break;
case "0 0 1" : writeln("Open"); break;
ca... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
for(;;)
{
string[] ss;
for(string t; (t=readln().chomp())!="" && t!="0 0"; ss~=t){}
if(ss.length==0) break;
int[] c = new int[3];
foreach(s;ss)
{
auto m ... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
bool ask (int x, int y)
{
writeln ("?", " ", x, " ", y);
stdout.flush ();
auto s = readln.strip;
if (s == "e")
{
assert (false);
}
return (s == "x");
}
void main ()
{
string s;
while ((s = readln.strip) != "")
{
... | 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 S = readln.chomp;
int min_l, max_l = N/2+1;
while (min_l+1 < max_l) {
auto l = (min_l + max_l) / 2;
int[string] memo;
bool ok;... | 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 N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
auto st = new SegmentTre... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(char[]);
auto T = readln.chomp.to!(char[]);
auto N = S.length;
auto M = T.length;
foreach_reverse (i; 0..N-M+1) {
foreach (j; 0..M) {
if... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;
void main(){
while(true){
auto temp = readln();
if(stdin.eof()) break;
auto s = split(temp).to!(int[]);
writeln(s[0]-s[... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
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.c... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
readln;
auto S = readln.chomp.to!(char[]);
auto K = readln.chomp.to!int;
auto c = S[K-1];
foreach (ref s; S) if (s != c) s = '*';
writeln(S);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main() {
string str = chomp(readln());
long n = to!long(str);
writeln(factrial(n));
}
long factrial(long n) {
if (n == 0) {
return 1;
} else {
return n * factrial(n-1);
}
} | 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;
void main() {
string[] input = readln.split;
int N = input[0].to!int;
int... | D |
import std.stdio;
import std.string;
import std.range;
import std.conv;
void main()
{
auto X = readln.chomp.to!int;
auto A = readln.chomp.to!int;
auto B = readln.chomp.to!int;
writeln((X-A)%B);
}
| D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;
void main(){
int n = readln().chomp().to!int;
for(int i=0;i<n;i++){
string ans = "";
string inp = readln().chomp();
... | 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 |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
auto min_i = 1, max_i = M;
auto mid_i = (min_i + max_i) / 2;
while (max_i - min_i > 1) {
mid_i = (min_... | D |
void main() {
/*auto S = rs, T = rs;
foreach(i; 0..S.length) {
string tmp = S[1..$];
tmp ~= S[0];
if(S == T) {
writeln("Yes");
return;
}
S = tmp;
}
writeln("No");*/
auto S = rs, T = rs;
S ~= S;
if(S.canFind(T)) writeln("Yes");
else writeln("No");
}
// ===================================
import... | 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(){
writeln(totalSum(readln.chomp));
}
long totalSum(string str){
long total=0;
foreach(i,s;str){
auto num=[s].to!lo... | 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;
// import dcomp.container.deque;
int main() {
auto sc = new Scanner(stdin);
long n, m, k;
sc.read(... | D |
void main()
{
long a, b;
rdVals(a, b);
writeln(calc(b) ^ calc(a-1));
}
long calc(long x)
{
long r = x % 4, y = (r >> 1) & 1;
if (r & 1)
{
return !y;
}
else
{
return x + y;
}
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T ... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | D |
module aizu_online_judge;
import std.stdio;
int main(){
for(int i = 1; i <= 9; i++) {
for(int j = 1; j <= 9; j++) {
writeln(i, "x", j, "=", i * j);
}
}
return 0;
} | D |
void main() {
problem();
}
void problem() {
auto X = scan!long;
auto K = scan!long;
auto D = scan!long;
long solve() {
if (X < 0) X = -X;
auto times = X / D;
if (K < times) {
return X - D*K;
}
auto loopTimes = K - times;
if (loopTimes % 2 == 0) {
return X - D*times;
... | D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
string[] ss = readln.split;
foreach (i, ref arg ; args) ar... | D |
import std.stdio;
import std.string;
void main() {
string s = chomp(readln());
string t = chomp(readln());
int ans = 0;
for (int i=0; i<s.length; i++) {
if (s[i] == t[i]) ans++;
}
writeln(ans);
} | 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 main() {
auto n = readln.strip.to!int;
Tuple!(string, int)[] a;
foreach (i; 0 .. n) {
auto s = readln.splitter;
auto z = s.front;
s.popFront ();
... | D |
import std.stdio;
void main() {
int r,g,b,n;
scanf("%d %d %d %d", &r, &g, &b, &n);
size_t total;
for (int i; i <= n; i += r) {
for (int j = i; j <= n; j += g) {
if ((n - j) % b == 0) ++total;
}
}
total.write;
}
| D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.utf;
bool isGood (R) (R s)
{
int balance = 0;
foreach (c; s)
{
balance += c ? +1 : -1;
if (balance < 0)
{
return false;
}
}
return balance == 0;
}
void main ()
{
auto tests = readln.strip.to !(int... | D |
import std.algorithm;
import std.array;
import std.range;
import std.stdio;
import std.string;
string solve (string s, int i, int j, int n)
{
char [13] [2] res;
int loopLength = (j - i + 1) / 2;
while (i > 0)
{
s = s[1..$] ~ s[0];
i -= 1;
j -= 1;
}
debug {writeln (s, " ", i, " ", j);}
int mid = loopLengt... | 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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, x; rd(n, x);
auto a=readln.split.to!(int[]);
int[int] bef, aft;
foreach(e; a){
if(e in bef) bef[e]++;
else bef[e]=1;
if ((e&x) in aft) aft[e&x]++;
else aft[e&x]=1;
}
int mn=3;
foreach(e; a){
if(bef[e]>1) mn=... | 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
long[1000] XS, IXS, YS, IYS, ZS, IZS;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
foreach (i; 0..N) {
auto xyz = readln.split.to!(long[]);
XS[i] = xyz[0];
... | 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.stdio, std.algorithm, std.range, std.array, std.conv, std.string, std.math, std.container, std.typecons;
void main() {
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto c = readln.chomp.to!int;
auto x = readln.chomp.to!int;
int cnt = 0;
foreach (i; 0..min(x/500,a)+1) {... | D |
void main()
{
long[] tmp = rdRow;
long n = tmp[0], m = tmp[1];
long[] a = rdRow;
long rem;
long[long] lists;
lists[0] = 1;
long result;
foreach (x; a)
{
rem = (rem + x) % m;
result += lists[rem]++;
}
result.writeln;
}
enum long mod = 10^^9 + 7;
enum long in... | 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.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
auto CS = readln.split.to!(int[]);
auto DP = new int[][](M+1, N+1);
foreach (ref dp; DP) dp[] = int.max/3;
... | D |
module app;
import core.bitop;
import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;
import std.traits;
struct Input
{
int n;
int[] x;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
n = readln().strip().to!int;
x = readln... | D |
import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main()
{
auto buf = readln.chomp.split.to!(long[]);
solve(buf[0], buf[1], buf[2]).writeln;
}
long solve(in long n, in long a, in long b)
{
if ((b - a) & 1)
return min(a, n - b + 1) + (b - a) / 2;
return (b - a) / 2... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.algorithm;
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 |
// 10進数から26進数への基数変換と同様に考えれば良い
// 但し, 番号は1から始まるので注意
void main(){
long n = _scan!long();
string ans;
while(n>0){
int rem = (n%26==0)?26:n%26;
ans ~= ( ('a'-1) + rem );
n = (n -1)/26;
}
ans.retro.array.to!string.writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.rang... | 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;
int calc(string s) {
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
int a, b;
foreach (c; readln.chomp) {
if (c == '0') {
++a;
} else {
++b;
}
}
writeln(min(a, b) * 2);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nl = readln.split.to!(int[]);
auto N = nl[0];
auto L = nl[1];
int s, e = int.max;
foreach (i; 0..N) {
s += L+i;
if (abs(L+i) < abs(e)) e = L+i;
}
wr... | D |
import std.stdio, std.conv, std.string, std.algorithm;
void main() {
uint n = readln.chomp.to!uint;
uint[] result;
foreach (i; 0..n) {
uint outNum = 0;
bool[3] fieldPlayer;
uint point = 0;
while (outNum < 3) {
auto str = readln.chomp;
if (str == "HIT") {
if (fieldPlayer[2]) point++;
fieldPla... | D |
import std;
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line =... | 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() {
int d = readln.chomp.to!int;
string s = "Christmas";
string t = " Eve";
while (d < 25) {
s ~= t;
++d;
}
s.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.containe... | 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.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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto a=readln.split.to!(int[]);
foreach(ref e; a) e-=1;
int c=0;
foreach(i; 0..n-1){
if(i==a[i]){
swap(a[i], a[i+1]);
c+=1;
}
}
if(a[n-1]==n-1) c+=1;
writeln(c);
}
void rd(T...)(ref T x){
imp... | 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()
{
auto n = readln.chomp.to!int;
auto as = readln.chomp.split.to!(int[]);
auto res =... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void main()
{
string s; readV(s);
writeln("aei... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.