code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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!(int[]);
int max_a = int.min;
foreach (i; 0..N-1) {
foreach (j; i+1..N) {
max_a = max(max_a, abs(AS[i] - AS[j]... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import std.bitmanip;
struct BitMatrix
{
int H, W;
BitArray[] val;
this(int n, int m) {
H = n;
W = m;
val.length = H;
foreach (ref row; val) {
row = BitArray(ne... | 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;
alias Point = Tuple!(in... | 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 std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto na = readln.split.to!(int[]);
auto N = na[0];
auto A = na[1];
auto xs = readln.split.to!(int[]);
auto DP = new long[][][](N+1, N+1, N*50+1);
foreach (c; 1..N+1) {
f... | 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 |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
void main()
{
auto nmk = readln.split.to!(int[]);
auto N = nmk[0];
auto M = nmk[1];
long K = nmk[2];
auto AS = readln.split.to!(long[]);
foreach (i, ref a; AS) if (i) a += AS[i... | 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.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;
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;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
import core.bitop : popcnt;
alias Generator ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, m;
scan(n, m);
auto uf = UnionFind(... | 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;
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "number", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHea... | 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 |
module _template;
import std.stdio;
import std.string;
import std.algorithm;
import std.container;
import std.range;
import std.math;
import std.numeric;
import std.conv;
import std.typecons;
import std.format;
struct IO {
string read_string() {
while (tokens.empty) {
tokens = 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 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.array, std.conv, std.algorithm;
void main() {
int n = readln.chomp.to!int;
int[] a = readln.chomp.split.to!(int[]);
int q = readln.chomp.to!int;
foreach (i; 0 .. q) {
int[] tmp = readln.chomp.split.to!(int[]);
a[tmp[0]..tmp[1]].reverse;
}
foreac... | 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 |
void main() {
auto N = readAs!long;
if(N.to!real.sqrt.to!ulong ^^ 2 == N) {
writeln(N.to!real.sqrt.to!ulong * 2 - 2);
return;
}
auto div = getDivisors(N);
debug div.writeln;
writeln(div[$ / 2 - 1] + div[$ / 2] - 2);
}
ulong[] getDivisors(ulong N) {
if(N == 0) return [];
if(N == 1) return [1];
ulong[] lowe... | 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 |
void main()
{
long h, w;
rdVals(h, w);
string[] a = h.rdCol!string;
long[][] dp = new long[][](h, w);
dp[0][0] = 1;
foreach (i, y; a)
{
foreach (j, x; y)
{
if (x == '#') continue;
if (i) dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
if (j) dp[... | 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.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.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.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.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.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;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!long).array;
A = 0L ~ A ~ 0L;
long S = (N+1).iota... | 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.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.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.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 |
void main()
{
long a, b, c, x, y;
rdVals(a, b, c, x, y);
if (a + b < 2 * c)
{
writeln(a * x + b * y);
return;
}
long z = min(x, y);
long u = a * (x - z) + b * (y - z) + 2 * c * z;
long v = 2 * c * max(x, y);
min(u, v).writeln;
}
enum long mod = 10L^^9 + 7;
enum lo... | 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 |
import std.algorithm;
import std.array;
import std.container;
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[]... | 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[] lreads(T = long)(long n){ret... | 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 std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void main() {
readln.split.to!(int[]).m... | D |
import std.algorithm;
import std.array;
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 scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | 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.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T[][] factor(T)(T n) {
if (n == 1) return [[1, 1]];
long[][] res;
for (T i = 2; i * i <= n; i++) {
if (n % ... | 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 |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
auto
buf0 = readln.chomp.split.to!(int[]),
buf1 = readln.chomp.split.to!(int[]);
((buf0[0] - buf1[0]) * (buf0[1] - buf1[1])).writeln;
}
| 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.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;
void main() {
auto s = readln.split.map!(to!int);
auto H = s[0];
auto W = s[1];
auto A = H.iota.map!(_ => readln.chomp).arr... | 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 |
void main()
{
long[] tmp = readln.split.to!(long[]);
long n = tmp[0], a = tmp[1], b = tmp[2], c = tmp[3];
long[] l = new long[n];
foreach (i; 0 .. n)
{
l[i] = readln.chomp.to!long;
}
long dfs(long d, long x, long y, long z)
{
if (d == n)
{
if (min(x, ... | 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 N = readln.chomp.to!int;
int[][] T;
T.length = N;
foreach (_; 0..N-1) {
auto xy = readln.split.to!(int[]);
auto x = xy[0]-1;
auto y = xy[... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
alias To = Tuple!(int, int);
void main()
{
auto N = readln.chomp.to!int;
bool[To][][] G;
G.length = N;
foreach (i; 0..N) {
G[i].length = N;
auto AS = readln.split.to!(int[]);
... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
long calc(int p, string s) {
if (p == 2 || p == 5) {
long ans = 0;
for (int i = cast(int)s.length-1; i >= 0... | 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.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto s = readln();
if(stdin.eof()) break;
auto t = split(s);
real[] x,y;
for(int i=0;i<4;i++){
x ~= to!real(t[2*i]);
y ~= to!real(t[2*i+1]);
}
real ax = to!real(t[0]) - to!real(t... | 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.