code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
import std.stdio, 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.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 T = readln.chomp.to!int;
while (T--) {
auto X = readln.chomp.to!long;
auto Y = ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp;
switch (N[$-1]) {
case '3': writeln("bon"); return;
case '0':
case '1':
case '6':
case '8': writeln("pon"); return;
default... | 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];
auto as = readln.split.to!(int[]);
... | 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[] ts, as;
foreach(i; 0 .. n){
int[] tmp = readln.chomp.split.map!(to!int).array;
ts ~= tmp[0], as ~= tmp[1];
}
lo... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const tmp = readln.split.to!(long[]);
writeln(tmp[0] < tmp[2] && tmp[2] < tmp[1] || tmp[0] > tmp[2] && tmp[2] > tmp[1] ? "Yes" : "No");
}
| D |
import std.stdio, std.conv, std.string;
void main() {
int N = readln().chomp().to!(int);
long [256] cnt;
foreach(i; 0..256) cnt[i] = 0;
foreach(i; 0..N) {
string S;
S = readln();
cnt[S[0]]++;
}
long res = 0;
string m = "MARCH";
foreach(i; 0..5) {
foreach(j; (i+1)..5) {
foreach(k; (j+1)..5) {
re... | 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.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(int n) {
i... | 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 (_; 0..T) {
auto S = readln.chomp;
int max_l, l;
foreach (c; S) {
if (c == 'L') {
l += 1;
... | 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
{
ulong n;
int a, b;
}
void parseInput(T)(out Input input, T file)
{
with (file) with (input)
{
auto ar = readln().strip().split().... | 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.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.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;
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;
char[][] field = new char[][](4, n + 2);
f... | D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto N = readln.chomp.to!int;
long s, last;
foreach (a; readln.split.to!(long[])) {
if (a >= last) {
last = a;
} else {
s +=... | 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 bs = readln.split.to!(int[]);
int[] solve(int[] as) {
if (as.empty) {
return [];
} else {
foreach_reverse (i, a; a... | 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 nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
auto xs = new long[int][](M);
foreach (x; readln.split.to!(int[])) {
auto p = x ... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;
void main()
{
auto s = readln.chomp.to!int;
writeln(s/3600, ":", s%3600/60, ":", s%60);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
bool[string] di;
foreach (_; n.iota) {
auto rd = readln.chomp.splitter(' ');
auto cmd = rd.front; rd.popFront;
auto str = rd.front;
switch (cmd) {
case "insert":
di[str] = t... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | D |
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.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;
int k = readln.chomp.to!int;
int sum = 0;
foreach (x; readl... | 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;
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;
int color (int[] c1, int[] c2) {
return (c1[0] - c2[0])^^2 + (c1[1] - c2[1])^^2 + (c1[2] - c2[2])^^2;
}
void main()
{
... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
string s = readln.chomp;
bool[char] flag;
foreach(c; s) flag[c] = 1;
string ans = "Yes";
if('N' in flag && !('S' in flag)) ans = "No";
if('S' in flag ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
void main()
{
int N = readln.chomp.to!int;
int[3][] price = new int[3][](N);
foreach (i; 0..N) price[i] = readln.split.to!(int[]);
int[3][] max_sum = new int[3][](N);
max_sum[0] = price[0];
foreach (i; 1..N){
fore... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
void main() {
auto S = readln;
int[char] count;
foreach (c; S) {
if (c != '\n')
count[c]++;
}
int[] data;
int oddCount = 0;
foreach(int co; count) {
if (co % 2 == 1) oddCount++;
else data ~= co / 2;
}
if (... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int k = tmp[0], s = tmp[1];
int cnt;
foreach (x; 0 .. k+1) {
foreach (y; 0 .. k+1) {
int z = s - x - y;
if (0 <= z && z <= k) ++cnt;
}
}
cnt.writeln;
}
import std.stdio;
import std.string;
import std.arra... | D |
/+ dub.sdl:
name "B"
dependency "dcomp" version=">=0.4.0"
+/
import std.stdio, std.algorithm, std.conv, std.range;
import std.container;
// import dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
int n;
long a, b;
long[] x;
sc.read(n, a, b, x);
long ans = 0;
writeln(iota... | D |
void main(){
string[] val = inln!string();
bool a = (val[0]=="H")?true:false;
bool b = (val[1]=="H")?true:false;
writeln(( (a^b)==false)?'H':'D');
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力
T inelm(T= int)(){
return ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main()
{
auto N = readln.chomp.to!int;
int ans = 0;
foreach(_; 0..N){
auto l = readln.chomp.split.map!(to!int);
ans += l[1] - l[0] + 1;
}
writeln(ans);
} | D |
void main() {
auto N = ri;
int[string] count;
foreach(_; 0..N) {
count[rs]++;
}
auto M = ri;
foreach(_; 0..M) {
count[rs]--;
}
count.values.reduce!max.max(0).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
impo... | 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;
const long mod = 1_000_000_007;
void main(){
int n = readln.chomp.to!int;
long[] as = readln.chomp.split.to!(long[]);
long m = 1;
long ans;
A: while(1){
... | 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;
char c='a';
long res=long.max;
while(isASCII(c))
{
res = min(res, S.split(... | 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;
const int INF = 100000000;
int[21][21] map;
int n;
int ans;
bool check(int x,int u){
int count;
for(int i=1;i<=n;i++)
... | D |
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons;
void main()
{
const ... | 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, a;
{
int[] cs = readln.chomp.split.map!(to!int).array;
n = cs[0], a = cs[1];
}
int[] xs = readln.chomp.split.map!(to!int).array;
int[] ys =... | D |
import std.stdio, std.algorithm, std.string, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
void main() {
auto hwd = readints();
int h = hwd[0], w = hwd[1], d = hwd[2];
int[] px = new int[h*w+5];
i... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.... | D |
import std;
int calc(string s) {
int[2019] a;
a[0] = 1;
int ans = 0;
int p = 1;
int now = 0;
foreach_reverse (c; s) {
now = (now + p * (c - '0')) % 2019;
p = p * 10 % 2019;
ans += a[now];
a[now]++;
}
return ans;
}
void main() {
string s = read!strin... | D |
void main()
{
long[] tmp = readln.split.to!(long[]);
long n = tmp[0], m = tmp[1];
bool[] boxes = new bool[n];
boxes[0] = true;
long[] balls = new long[n];
balls[] = 1;
foreach (i; 0 .. m)
{
tmp = readln.split.to!(long[]);
long x = tmp[0] - 1, y = tmp[1] - 1;
--ba... | 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 N = readln.split[0].to!int;
bool[string] S;
foreach (i; 0 .. N) {
S[readln.split[0]] = true;
}
writeln(S.keys.length);
}
| D |
import std.stdio,std.algorithm;void main(){readln;writeln(readln.canFind("Y")?"Four":"Three");} | D |
import std.stdio;
import std.math;
import std.conv;
import std.string;
import std.algorithm;
import std.array;
void main() {
while(true) {
string line = readln.chomp;
if (stdin.eof) break;
uint[] data = line.split(" ").map!(to!(uint)).array;
uint a = data[0];
uint b = data[1];
uint n = data[... | 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;
void main()
{
foreach (line; stdin.byLine) {
auto x = line.chomp.split.map!(to!int);
foreach_reverse (i; 1..max(x[0], x[1])+1) {
if (x[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, std.bitmanip;
immutable long MOD = 10^^9 + 7;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
... | 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 w, a, b; readV(w, a, b);
if... | 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;
void main()
{
auto n = readln.chomp.to!int;
long sum;
foreach (i; 0..n) {
sum += readln.chomp.to!long;
}
writeln(sum / n);
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
alias T=long;
const inf=1e9.to!(T);
struct Edge{int to; T cost;}
int n; rd(n);
auto g=new Edge[][](n);
foreach(i; 0..n){
auto args=readln.split.to!(int[]);
foreach(j; 0..args[1]){
g[i]~=Edge(args[j*2+2], args[j*2+3]);
}... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto x=readln.chomp.to!int;
if(x<1200)writeln("ABC");
else writeln("ARC");
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];
auto c = new int[](n);
foreach (_; 0..m) {
auto rd2 = readln.splitter;
auto a = rd2.front.to!size_t-1; rd2.popFront();
auto b = rd2.front.to!size_t-1;
if ... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
void main() {
int[] tmp = readln.chomp.split.to!(int[]);
int[] h = readln.chomp.split.to!(int[]);
h.count!("a >= b")(tmp[1]).writeln;
} | D |
void main()
{
long n, k;
rdVals(n, k);
long a = n % k;
min(a, k-a).writeln;
}
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... | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math, core.stdc.stdio;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
int f(string n) {
int k = n.length.to!int;
int r = (n[0] - '0') + (k - 1) * 9;
if (count(n[1..$], '9') !... | D |
// Vicfred
// https://atcoder.jp/contests/abc043/tasks/arc059_a
// brute force
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
int n = readln.chomp.to!int;
int[] a = readln.split.map!(to!int).array;
long minima = long.max;
for(int i = -100; i... | D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main ()
{
string s;
while ((s = readln.strip) != "")
{
int res1 = 0;
int res2 = 0;
foreach (i, c; s)
{
res1 += (c != ('0' ^ (i & 1)));
res2 += (c != ('1' ^ (i & 1)));
}
writeln (... | 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 |
/+ dub.sdl:
name "A"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int[long] mp;
int n;
sc.read(n);
long[] a;
s... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return r... | D |
import std.stdio, 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, std.string, std.conv, std.algorithm;
void main() {
int[] d;
foreach (string l; lines(stdin)) d ~= l.chomp.to!int;
d.sort!"a > b"[0..3].each!writeln;
} | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main() {
auto a = readln.split.map!(to!int).array;
writeln(a[0]*a[1], " ",(a[0]+a[1])*2);
} | 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.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, std.container, std.range;
void main()
{
auto N = readln.chomp.to!int;
int c;
foreach (i, a; readln.split.to!(int[])) if (i%2 == 0 && a%2 == 1) ++c;
writeln(c);
} | 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.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 |
void main() {
auto N = ri;
writeln((N-1)/2);
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typec... | 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 |
import std.stdio, std.string, std.conv;
void main() {
int n = readln.chomp.to!int;
int[] fib = new int[n+1];
fib[0] = fib[1] = 1;
foreach (i; 2 .. n+1) {
fib[i] = fib[i-1] + fib[i-2];
}
fib[n].writeln;
}
| 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.array;
void main()
{
long N = readln.split[0].to!long;
long[] T = new long[5];
foreach (i; 0..5){
T[i] = readln.split[0].to!long;
}
long minT = T[0];
foreach (t; T){
if (t < minT) minT = t;
}
long ans = N / minT;
if (N ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
struct Matrix(size_t height, size_t width)
{
long M;
long[width][height] arr;
this(long[width][height] arr, long M = 0) {
this.arr = arr;
this.M = M;
}
pure nothrow @nogc
Mat... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
auto readNum(T)(){
return readln.chomp.to!T;
}
auto readNums(T)(){
return readln.chomp.split.to!(T[]);
}
void main(){
auto r = readNums!long;
foreach(i; 0 .. 10){
r[2] = r[0] * r[2] - r[1];
writeln(r[2]);
... | 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.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv;
void main() {
ulong N = readln.chomp.to!ulong;
ulong[] A = readln.chomp.split... | D |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.7.4"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int n;
int[] a;
int[] hist;
void query(int k) {
hist ~= k;
foreach (i; k..n) {
swap(a[i], a[i-k]);
}
}
int main() {
Scanner sc... | 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 primes = e... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
auto readNum(T)(){
return readln.chomp.to!T;
}
auto readNums(T)(){
return readln.chomp.split.to!(T[]);
}
void main(){
auto ab = readNums!int;
if(ab[0] <= 5){
writeln(0);
} else if(ab[0] <= 12){
writeln(ab[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 |
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 = int.max;
void main() {
int n, q;
scan(n, q);
auto st = SegmentTree!(int, min, inf)(n);
foreach (_ ; 0 .. q) {
int com, x, y;
... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
(6 - readln.chomp.to!int - readln.chomp.to!int).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, std.bitmanip, std.regex;
void main() {
int[] dr = [1, -1, 0, 0];
int[] dc = [0, 0, 1, -1];
auto s = readln.split.map!(to!int);
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
void main(){
string[] sqlen = readln().chomp().split();
int a = sqlen[0].to!int(); int b = sqlen[1].to!int();
writeln(a*b, " ", (a+b)*2);
} | 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!(long[]);
auto N = nm[0];
auto M = nm[1];
writeln(N == 1 && M == 1 ? 1 : N == 1 ? max(0, M-2) : M == 1 ? max(0, N-2) : (N-2) * (M-2));
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
auto a = readln.chomp.split.map!(to!int);
int w = a[0], h = a[1], x = a[2], y = a[3], r = a[4];
if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
writeln("Yes");
} else {
writeln("No");
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nx = readln.split.to!(long[]);
auto N = nx[0];
auto X = nx[1];
auto xs = readln.split.to!(long[]);
auto r = abs(xs[0] - X);
foreach (x; xs[1..$]) {
r = gcd(r, abs(x ... | 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;
import core.stdc.stdio;
import std.algorithm;
struct state{
int x;
int y;
int z;
int r;
}
void main(){
while(1){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==0&&b==0&&c==0)
break;
int m = a+b+c;
int n;
scanf("%d",&n);
int[] dec = new int[m];
dec[] = 2;
state[] sts = new state[n];
for... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
int[30] CNT;
void main()
{
auto nm = readln.split.to!(int[]);
auto N = nm[0];
auto M = nm[1];
foreach (_; 0..N) {
auto as = readln.split.to!(int[]);
foreach (n; as[1..$]) {
... | 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 = sread();
// writeln(n);
if ((n[0] == n[1]) && (n[0] == n[2]))
{
writeln("Yes");
return;
}
if ((n[1] == n[2])... | D |
import std.stdio, std.string, std.array, std.conv;
void main() {
while (true) {
int[] tmp = readln.chomp.split.to!(int[]);
int n = tmp[0], x = tmp[1];
int cnt = 0;
if (n == 0 && x == 0) break;
foreach (i; 1 .. n+1) {
foreach (j; 1 .. i) {
foreach ... | D |
void main() {
auto arr = 5.iota.map!(i => ri).array;
ulong res = ulong.max;
do {
ulong tmp;
foreach(i, v; arr) {
if(i == 4) {
tmp += v;
} else {
tmp = ceil((tmp + v) / 10.).to!ulong * 10;
}
}
res = min(res, tmp);
} while(nextPermutation(arr));
res.writeln;
}
// =========================... | D |
import std;
void main() {
int a, b; scan(a, b);
writeln(a * b);
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;
| D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.