code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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.array, std.conv;
void main() {
int[] tmp = readln.chomp.split.to!(int[]);
int w = tmp[0], h = tmp[1], x = tmp[2], y = tmp[3], r = tmp[4];
writeln(0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h ? "Yes" : "No");
}
| D |
void main()
{
string s = readln.chomp;
string t = readln.chomp;
long[][] alpha = new long[][](26);
foreach (i, x; s)
{
alpha[x-'a'] ~= i + 1;
}
long n = s.length.to!long;
long cnt;
long index;
foreach (x; t)
{
auto a = alpha[x-'a'].assumeSorted;
if ... | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
void main()
{
auto n=map!(to!int)(readln.strip.split);
int cnt = 0;
for(int i = n[0];i<=n[1];i++)
if(n[2] % i == 0)
cnt++;
writeln(cnt);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm.searching;
void main(){
auto str = readln.chomp;
if(str[2] == str[3] && str[4] == str[5])
{
"Yes".writeln;
}
else
{
"No".writeln;
}
}
| 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;
long powmod(long a, long x, long m) {
long ret = 1;
while (x) {
if (x % 2... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
int t=0;
foreach(s;stdin.byLine())
{
int n=0;
foreach(c;s)
if('0'<=c && c<='9') n=n*10+c-'0';
else t+=n,n=0;
t+=n;
}
writeln(t);
} | D |
void main()
{
string s = readln.chomp;
writeln(s.countUntil("YAKI") == 0 ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import s... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;
void main() {
auto X = readln.chomp.to!int, A = readln.chomp.to!int, B = readln.chomp.to!int;
auto tmp = X - A;
(tmp % B).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() {
int 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 |
import std.conv;
import std.stdio;
import std.string;
void scan(TList...)(ref TList Args)
{
auto line = readln.split();
foreach (i, T; TList)
{
T val = line[i].to!(T);
Args[i] = val;
}
}
void main()
{
ulong A, B;
scan(A, B);
writeln(f(A - 1) ^ f(B));
}
ulong f(ulong x)
{
... | D |
import std.algorithm;
import std.range;
import std.stdio;
import std.string;
immutable string str = "Bulbasaur";
void main ()
{
string s;
while ((s = readln.strip) != "")
{
int [256] num;
foreach (char c; s)
{
num[c] += 1;
}
int res = int.max;
foreach (char c; str)
{
int d = cast (int) (str.cou... | D |
/+ dub.sdl:
name "A"
dependency "dunkelheit" version="1.0.1"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.algorithm;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n, m;
int[] v;
sc.read(n, m, v);
... | 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 nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
int[] as;
bool has;
foreach ... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int t;
rd(t);
while (t--) {
long s, a, b, c;
rd(s, a, b, c);
auto n = s / c;
writeln(n + n / a * b);
}
}
void rd(T...)(ref T x) {
import std.stdio : readln;
import std.string : split;
import std.conv : to;
auto l =... | D |
import std.stdio;
import std.algorithm;
import std.array;
int main()
{
int n;
scanf("%d", &n);
int x = 0, y = 0;
for (int z, i = 0; i < n; i++) {
scanf("%d", &z);
if (z % 2 == 1) x = x + 1;
else y = y + 1;
}
int ans;
if (x < y) ans = x;
else {
ans = y;
x = x - y;
ans = ans + x / 3;
}
write... | D |
import std.stdio;
import std.string;
void main ()
{
while (readln.strip != "")
{
writeln (25);
}
}
| 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 main()
{
auto rd = readln.split.to!(size_t[]), h = rd[0], w = rd[1];
foreach (_; 0..h) {
auto c = readln.chomp;
writeln(c);
writeln(c);
}
}
| D |
void main() {
string[] ab = readln.split;
int n = (ab[0] ~ ab[1]).to!int;
int m = n.to!double.sqrt.to!int;
writeln(n == m * m ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import st... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.math;
int n; rd(n);
int cur=0, x=0, y=0;
while(n--){
int t, nx, ny; rd(t, nx, ny);
auto d=(nx-x).abs+(ny-y).abs;
if(d>(t-cur)){writeln("No"); return;}
auto r=(t-cur)-d;
if(r&1){writeln("No"); return;}
cur=t... | 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 S = readln.chomp;
auto N = S.length;
auto DP = new long[][](N+1, 4);
DP[0][0] = 1;
foreach (i, c; S) {
foreach (j; 0..4) DP[i+1][j] = DP[i][j] * (c ... | D |
import std.stdio;
import std.conv;
import std.array;
void main()
{
auto reader = readln.split;
int r = reader[0].to!int;
writeln(3 * r * r);
}
| D |
import std.stdio, std.string, std.array, std.conv;
int[] factors(int n) {
int[] result;
while (n % 2 == 0) {
result ~= 2;
n /= 2;
}
for (int i = 3; i * i <= n; i += 2) {
while (n % i == 0) {
result ~= i;
n /= i;
}
}
if (n != 1) result ~= n... | D |
import std.stdio;
import std.string;
import std.format;
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.concurrency;
import std.traits;
import std.uni;
import s... | D |
void main(){
string s = readln().chomp();
writeln(s.count("A")%3==0? "No": "Yes");
}
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... | D |
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
void main() {
auto s = readln.chomp.split.map!(to!char).array;
if (s[0] < s[1]) "<".writeln;
else if (s[0] > s[1]) ">".writeln;
else "=".writeln;
} | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nmxy = readln.split.to!(int[]);
auto X = nmxy[2];
auto Y = nmxy[3];
auto xs = readln.split.to!(int[]);
auto ys = readln.split.to!(int[]);
int xmax = int.min, ymin = int.max... | 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() {
foreach(i; 1..1000000) {
int n = readln.chomp.to!int;
... | 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;
void main()
{
int n;
long k;
readVars(n, k);
auto bkt = new long[](10^^5 + 1);
int ai, bi;
foreach(i ; 0 .. n){... | 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 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;
import std.container;
void main()
{
auto n = readln.chomp.to!int;
int cnt;
while (cnt < n) {
int outCnt, score;
int base;
while (outCnt < ... | D |
void main()
{
string s = rdStr;
writeln(s == "ABC" ? "ARC" : "ABC");
}
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;
}
alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);
T rdElem(T)()
if ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto kx = readln.split.to!(int[]);
auto K = kx[0];
auto X = kx[1];
writeln(500*K >= X ? "Yes" : "No");
} | 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(){
int n = readln.chomp.to!int;
int[] as = readln.chomp.split.map!(to!int).array;
int minsum = int.max;
for(int i = -100; i <= 100; i ++){
int sum = 0;
f... | D |
void main(){
int n = _scan();
int[] d = _scanln();
int ans;
foreach(i; 0..n){
foreach(j; i+1..n){
ans += d[i]*d[j];
}
}
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行に同一型の複数入力
T[]... | 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 n = readln.strip.to !(int);
writeln ((n + 1) / 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.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
int a, b, c; scan(a, b, c);
int k; scan(k);
int ans = max(a, b, c) * 2^^k + a + b + c - max(a, b, c);
writeln(ans);
}
void scan(T... | 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;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
void main() {
string s;
scan(s);
int cnt_w;
long ans;
foreach_reverse (ch ; s) {
if (ch == 'W') {
cnt_w++;
}
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.numeric; // gcd, fft
void main()
{
auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], c = rd[2];
writeln(c % gcd(a, b) == 0 ? "YES" : "NO");
}
| 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.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;
immutable long MOD = 10^^9 + 7;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1].to... | 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.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
immutable char [] digits = "0123456789";
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto s = readln.strip;
int res = 0;
foreach (char c; digits)
{
res = max (res, s.count (c)... | D |
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T[]readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.string;
import std.array;
import core.stdc.stdlib;
import core.stdc.stdio;
import core.stdc.string;
void main() @nogc {
// int tt = 1000;
int tt;
scanf("%d", &tt);
foreach (t; 0 .. tt) {
// int n = 8000;
int n;
scanf("%d", ... | 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;
bool f;
foreach (i; 0..n/4 + 1) {
foreach (j; 0... | 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();
foreach (i; 0 .. 10)
{
foreach (j; 0 .. 10)
{
if (i * j == n)
{
writeln... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
writeln(readln.chomp.to!int/3);
} | 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;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf = 1<<30;
enum mod = 10L^^9 + 7;
void main() {
int h, w, a, b;
scan(h, w, a, b);
auto mc = ModComb(h + w);
long ans;
foreach (i ; 0 ... | 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.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, 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, a, b;
scan(n, a, b);
auto ans = n / (a + b) * a + ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string s = readln.chomp;
int ans = 0;
foreach (e; s) {
if (e == '+') {
ans += 1;
}
else if (e == '-') {
ans -= 1;
}
}
writeln(ans);
} | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;
void main() {
auto tmp = readln.split.map!(to!int).array;
auto X = tmp[0];
auto Y = tmp[1];
auto Z = tmp[2];
//X >= n * Y + (n+1)*Z
//X >= n * (Y+Z) + Z
writeln((X-Z) / (Y+Z));
} | 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, 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;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
void main() {
string str = readln.chomp;
// array.lengthの返り値の型はulongなので
// intに代入しようとすると(dmd64 v2.070.1では)CEになる
int p = str.length.to!int;
while (p > 0) {
if (str[(p - 7)..p] == "dreamer") {
p -= 7;
... | 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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto ... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(int[]);
if (tmp[0] >= tmp[1] && tmp[0] >= tmp[2])
writeln(tmp[0] * 10 + tmp[1] + tmp[2]);
else if (tmp[1] >= tmp[0] && tmp[1] >= tmp[2])
writeln(tm... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
readln.chomp.map!(a => a - '0').map!(a => a == 1 ? 9 : a == 9 ? 1 : a).each!write;
writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto cs = new int[][](3, 3);
foreach (i; 0..3) foreach (j, c; readln.split.to!(int[])) cs[i][j] = c;
writeln(
cs[1][0] - cs[0][0] == cs[1][1] - cs[0][1] &&
cs[1][1] - cs[0][1... | 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!long;
auto a = n * (n + 1) / 2 - n;
a.writeln;
}
| D |
void main()
{
long n = rdElem;
if (n == 0) 0.writeln;
else
{
string s;
long b = 1;
while (n)
{
long d = abs(n%(-2*b)/b);
s ~= (d + '0').to!dchar;
n -= d * b;
b *= -2;
}
foreach_reverse (x; s)
{
... | 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.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
void main() {
int N; readlnTo(N);
if (N == 1) "Hello World".writeln;
else {
in... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int c(int a, int b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
int main() {
auto sc = new Scanner(stdin);
int n;
... | 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 dp = new b... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
writeln(N^^3);
} | 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.array, std.conv, std.algorithm;
void main() {
string str = readln.chomp;
int n = readln.chomp.to!int;
int a, b;
foreach (i; 0 .. n) {
string[] tmp = readln.chomp.split;
a = tmp[1].to!int, b = tmp[2].to!int + 1;
if (tmp[0] == "print") {
... | D |
import std.algorithm.iteration;
import std.conv;
import std.math;
import std.stdio;
import std.string;
void main()
{
auto abcd = readln.split.map!( to!int );
auto ac = ( abcd[ 0 ] - abcd[ 2 ] ).abs;
auto ab = ( abcd[ 0 ] - abcd[ 1 ] ).abs;
auto bc = ( abcd[ 1 ] - abcd[ 2 ] ).abs;
if( ac <= abcd[ 3 ] || ( ab <=... | 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 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; }
int calc(int[] xs) {
int[int] d;
foreach (x; xs) d[x]... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
auto n = lread();
long ans = 1;
long mod = (10 ^^ 9) + 7;
... | 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 T = readln.chomp.to!int;
foreach (_; 0..T) {
auto N = readln.chomp.to!int;
auto D = readln.chomp;
if (N%2 == 1) {
for (int i = ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto N=readln.chomp.to!int;
writeln(800*N-200*(N/15));
} | D |
/+ dub.sdl:
name "C"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n, m;
sc.read(n, m);
int[][] g = new int[][](n);
foreach (i; 0..m) {
int a... | 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;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
int n... | D |
import std.stdio;
void main() {
enum Head = "2018";
auto s = readln();
write(Head, s[Head.length..$]);
} | D |
void main()
{
string s = rdStr;
long g, p;
long score;
foreach (x; s)
{
if (p < g)
{
++p;
if (x == 'g') ++score;
}
else
{
++g;
if (x == 'p') --score;
}
}
score.writeln;
}
T rdElem(T = long)()
{... | D |
void main()
{
string s = rdStr;
string t = rdStr;
writeln(s == t[0..$-1] ? "Yes" : "No");
}
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;
}
alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dch... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
string s = readln.chomp;
while (!s.empty) {
s.popBack();
s.popBack();
if (s[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.algorithm;
int n, m;
int[] xs, memo;
void main(){
for(;scanf("%d%d\n", &m, &n) && n;){
xs.length = n;
foreach(ref x; xs){
x = 0;
auto s = readln;
foreach(i; 0..m) x |= (s[i]=='1')<<i;
}
memo.length = 3^^m;
memo[] = -1;
writeln(solve(0));
}
}
int solve(int state){
if(memo... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a, b, k;
scan(a, b, k);
foreach (i ; a .. b + 1) {
if (i < a + k || i > b - k) {
writeln(i);
}
}
}
void scan(T...)(ref T args) {
import std.stdio : readln;
imp... | D |
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
//END OF TEMPLATE
void main(){
auto n=scan!siz... | 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 = '0' ~ readln.chomp;
auto N = S.length.to!int - 1;
if (S.back == '1') {
writeln(-1)... | 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 "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv, std.numeric;
// import dcomp.foundation, dcomp.scanner, dcomp.algorithm;
import std.typecons, std.ascii;
Scanner sc;
static this() {sc = new Scanner(stdin);}
int main() {
string s;
sc.re... | 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() {
long a, b, c;
scan(a, b, c);
long ans = 0;
if (b >= c) {
ans = b + c;
}
else { // b < c
ans = 2L*b;
... | D |
import std.stdio;
import std.string;
import std.format;
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.concurrency;
import std.traits;
import std.uni;
import c... | 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;
int res;
foreach (i; iota(1, n+1, 2)) {
int ... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.