code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
while(true){
auto a = readln();
if(stdin.eof()) break;
auto s1 = split(a);
real n = to!real(s1[0]) / to!real(s1[1]);
long sum = 0;
int s = to!int(s1[2]);
n = n - to!int(n);
for(int i=0;i<s;i++){
... | 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.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
readln.chomp.count('1').writeln;
}
| D |
unittest
{
assert( [ "100" ].parse.expand.solve == "ABC100" );
assert( [ "425" ].parse.expand.solve == "ABC425" );
assert( [ "999" ].parse.expand.solve == "ABC999" );
}
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
stdin.byLineCopy.parse.expand.solve.... | 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.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;... | D |
import std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
bool solve() {
readln;
int[] a = readln.chomp.split.to!(int[]);
for(int i=0; i<a.length; i++) {
if(a[i]%2==0) {
if(a[i]%3==0 || a[i]%5==0) continue;
else return false;
}
}
retur... | D |
void main()
{
long a, b, c, d;
rdVals(a, b, c, d);
--a;
long l = c / gcd(c, d) * d;
long x = b - b / c - b / d + b / l;
long y = a - a / c - a / d + a / l;
writeln(x - y);
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
return readl... | 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;
bool[long] kset;
void main(){
int n, m;
{
int[] tmp = readln.chomp.split.map!(to!int).array;
n = tmp[0], m = tmp[1];
}
for(int j = 0; j < m; j ++){
int[] tmp =... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio, std.array, std.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 s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1];
auto S = readln.chomp;
... | D |
import std.stdio, std.string, std.array, std.conv;
struct Stack {
int[] x;
void push(int y) {
x ~= y;
}
int pop() {
int result = x[$-1];
--x.length;
return result;
}
}
void main() {
Stack s;
string[] c = readln.chomp.split.to!(string[]);
int a, b;
... | D |
/+ dub.sdl:
name "C"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
long n;
sc.read(n);
foreach (i; 1..3501) {
foreach (j; 1..3501) {
long... | D |
import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;
void main() {
auto z = map!(to!int)(split(chomp(readln)));
string exp = "==";
if (z[0]<z[1]) exp = "<";
else if (z[0]>z[1]) exp = ">";
writeln("a ",exp," b");
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto hwk = readln.split.to!(int[]);
auto H = hwk[0];
auto W = hwk[1];
auto K = hwk[2];
char[][] MAP;
MAP.length = H;
size_t sx, sy;
foreach (i; 0..H) {
MAP[i] = ... | 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 x; readV(x);
writeln(x < 120... | 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, W;
scan(N, W);
auto w = ... | 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 a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1,... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!size_t;
auto ai = readln.split.to!(short[]);
auto k = ai.reduce!(max);
auto bi = countingSort(ai, k);
foreach (i, b; bi) {
write(b);
if (i < n - 1) write(" ");
}
writeln;
}
short[] counting... | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;
void main()
{
string S = readln.strip;
long res= long.max;
foreach(n; [0, 1])
{
long count;
foreach(i, c; S)
... | D |
void main()
{
long n, w;
rdVals(n, w);
Pair[] pair = n.rdCol!Pair;
long limit = 10L ^^ 3 * n + 1;
long[][] dp = new long[][](n+1, limit);
dp[0][] = inf;
dp[0][0] = 0;
foreach (i, p; pair)
{
foreach (j; 0 .. limit)
{
dp[i+1][j] = dp[i][j];
if (... | 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;
scan(n);
auto ans = 180 * (n - 2);... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;
alias sread = () => readln.chomp();
ulong bignu... | D |
import std.stdio,
std.string,
std.conv,
std.algorithm;
void main(){
int[] lists;
foreach(i; 0..10){
lists.length++;
lists[i] = readln.chomp.to!int;
}
sort!("a > b")(lists);
foreach(e; lists[0..3])
writeln(e);
} | D |
import std.stdio;
import std.array;
import std.conv;
import std.string;
void main() {
string[] input = split(readln());
int a = to!int(input[0]);
int b = to!int(input[1]);
writeln(to!string(a * b) ~ " " ~ to!string(2 * (a + b)));
} | 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 |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto w = readln.chomp;
auto r = 0;
for (;;) {
auto t = readln.chomp;
if (t == "END_OF_TEXT") break;
auto ti = t.split;
r += ti.count!(a => icmp(a, w) == 0);
}
writeln(r);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
auto C = new char[][](100, 100);
foreach (i; 0..50) C[i][] = '#';
foreach (i; 50..100) C[i][] = '.';
fore... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto ab = readln.split.to!(int[]);
writeln(ab[0] - 1 + (ab[1] >= ab[0] ? 1 : 0));
} | 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 |
void main()
{
long n = readln.chomp.to!long;
long[] a = readln.split.to!(long[]);
long snuke = a[0], raccoon = a[1..$].sum;
long diff = abs(snuke-raccoon);
foreach (i; 1 .. n-1)
{
snuke += a[i], raccoon -= a[i];
diff = min(diff, abs(snuke - raccoon));
}
diff.writeln;
}
... | D |
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;
enum INF = long.... | D |
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;
void main()
{
while (1) {
auto a = readln.split.map!(to!int);
auto h = a[0];
auto w = a[1];
if (!h) break;
aut... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(readln.chomp.split.to!(int[]).reduce!"a-b"+1);
}
| 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.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 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, 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;
import core.stdc.stdlib;
void main()
{
auto N = scanElem;
long res;
foreach(div; 1L..N)
{
auto m = (N-div)/div;
... | D |
void main()
{
long n, x, y;
rdVals(n, x, y);
--x, --y;
long[][] g = new long[][](n, n);
foreach (i; 0 .. n-1)
{
foreach (j; i+1 .. n)
{
g[i][j] = g[j][i] = abs(i-j);
}
}
g[x][y] = g[y][x] = 1;
foreach (i; 0 .. n-1)
{
foreach (j; i+1 .... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int x = tmp[0], t = tmp[1];
max(0, x-t).writeln;
}
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.as... | 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.algorithm, std.container, std.conv, std.math, std.range, std.typecons, 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!T;r.popFro... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
void main() {
int n = readln.chomp.to!int;
int[] h = readln.chomp.split.to!(int[]);
int cnt, ans;
foreach (i; 1 .. n) {
if (h[i] <= h[i-1]) {
++cnt;
} else {
ans = max(ans, cnt);
cnt = ... | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;
void main()
{
auto a = readln.strip.repeat(2).join("");
if (a.indexOf(readln.strip) != -1)
writeln("Yes");
else
writeln("No");
}
| D |
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
void main() {
auto S = readln.chomp;
auto easy = true;
for(int i=0; i<S.length; i++) {
if (i%2 == 0 && S[i] == 'L') easy = false;
if (i%2 == 1 && S[i... | D |
import std.stdio, std.conv, std.string;
void main()
{
string[] inputs = split(readln());
int N = to!int(inputs[0]);
int A = to!int(inputs[1]);
int B = to!int(inputs[2]);
int time_charge = A * N;
writeln(time_charge < B ? time_charge : B);
}
| D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;
void main() {
auto s = readln.split.map!(to!int);
auto H = s[0];
auto W = s[1];
auto A = iota(H).map!(_ => rea... | 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 |
void solve(){
}
void main(){
string s = instr();
int head = s[0..2].to!int();
int tail = s[2..4].to!int();
int stat;
if(1<=head && head<=12){
stat = stat|1;
}
if(1<=tail && tail<=12 ){
stat = stat|2;
}
switch(stat){
case 1:
writeln("MMYY"); break;
case 2:
writeln("YYMM"); break;
case 3:
writ... | 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;
immutable long INF = 1L << 59;
void main() {
auto N = readln.chomp.to!int;
auto A = r... | D |
import std.stdio;
import std.array;
import std.algorithm;
import std.conv;
void main()
{
auto inp = readln().split.map!(to!uint);
writeln(inp[0] * inp[1], ' ', 2 * inp.reduce!((a, b) => a + b));
} | 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.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(int);
auto a = readln.strip.map !(q{a - '0'}).array;
a[] -= 1;
int [int] f;
f[0] = 1;... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;
void main() {
int N, L; scan(N, L);
auto a = readln.split.to!(int[]);
int r = -1;
foreach (i ; 1 .. N) {
if (a[i] + a[i-1] >= L) {
r = i;
brea... | D |
import std.stdio : writeln, stdin;
import std.conv : to;
import std.range : dropOne;
import core.stdc.stdio;
int main(string[] argv)
{
int cnt = 1;
char last = 'Z';
int n;
scanf("%d",&n);
foreach(words; stdin.byLine)
{
foreach(word;words){
if(word != last){
... | 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 std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;
void main()
{
auto input = readln.chomp.split.map!(to!int);
auto n = input[0];
auto m = input[1];
int[... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto s = readNums!int;
auto n = s[0], x = s[1];
auto l = readNums... | 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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nm = readln.split.to!(int[]);
writeln(nm[0] == nm[1] ? "Yes" : "No");
} | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{//try{
auto tokens = split(my_readln());
auto N = to!ulong(tokens[0]);
auto W = to!ulong(tokens[1]);
... | D |
import std.stdio, std.string, std.array, std.conv, std.algorithm;
void main() {
int[] tmp = readln.chomp.split.to!(int[]);
int r = tmp[0], c = tmp[1];
int[][] mat = new int[][](r, c);
foreach (i; 0 .. r) {
int[] row = readln.chomp.split.to!(int[]);
foreach(j; 0 .. c) {
mat[i... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
auto N = readln.split[0].to!int;
auto p = readln.split.to!(int[]);
auto ctr = 0;
foreach(i, pi; p) {
if(pi != i+1) ctr++;
}
if(ctr == 0 || ctr == 2) {
writeln("... | D |
void main() {
problem();
}
void problem() {
const A = scan!ulong;
const B = scan.split(".").to!(ulong[]);
ulong solve() {
const b100 = B[0] * 100 + (B.length == 1 ? 0 : B[1]);
deb(A, b100);
return A * b100 / 100;
}
solve().writeln;
}
// ----------------------------------------------
impor... | D |
import std.stdio;
import std.string;
import std.conv;
void main()
{
auto input = split( readln() );
long N = to!long(input[0]), K = to!long(input[1]);
long cnt = 0;
long b = K+1;
while ( b <= N ) {
cnt += (b-K) * (N/b);
long s = N%b - K + 1;
if (s > 0) { cnt += s; }
if (K == 0) { cnt -= 1; }
b += 1;... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
void main()
{
auto s1 = split(readln);
//auto a = map(to!int)(s1);
auto s2 = split(readln);
long count;
long sum;
foreach (val; s2)
{
if (to!long(val) <= to!long(s1[1]))
sum += to!long(val);
... | 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 INF = 1L << 59;
void main() {
auto T = readln.chomp.to!int;
while (T--) {
auto s = readln.spl... | D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.string;
void main()
{
int r, g;
r = readln.chomp.to!int;
g = readln.chomp.to!int;
writeln(g - r + g);
}
| 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.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;
void main()
{
auto S = readln.chomp;
auto T = readln.chomp;
int r;
foreach (i, s; S) {
if (s != T[i]) ++r;
}
writeln(r);
} | 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.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 "B"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
int n, s, x;
sc.read(n, s, x); s--;
int[] v = new int[n];
int[] nx = new int[n];
void... | D |
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;
void main()
{
auto rd = readln.split.map!(to!size_t);
auto n = rd[0], m = rd[1];
auto aij = iota(n).map!(_ =>... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
long n, m;
rd(n, m);
import std.math : sqrt;
if (n == 1) {
writeln(m);
return;
}
for (long k = 6 * 10L ^^ 8; k >= 1; k--) {
if (m >= k * n && (m - k * n) % k == 0) {
writeln(k);
return;
}
}
import std.e... | D |
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons;
// }}}
// nep.scanner {{{
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
long[long][101] TABLE;
auto nw = readln.chomp.split(" ");
auto N = nw[0].to!int;
auto W = nw[1].to!long;
long[101] ws;
long[101] vs;
foreach (i; 0..N) {
auto wv = readln.chomp.split(" ").map!(to!long);... | 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;
import std.bitmanip; // BitArray
void main()
{
auto s = readln.chomp, n = s.length;
auto ans = 0L;
foreach (i; 0..1<<(n-1)) {
auto j = [size_t(0)] ~ i.bitsSet.map!"a+1".array ~ [n];
auto r = 0L;
foreach (k; 0..j.length-1)
r += ... | 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);
int n, m, k;
sc.read(n... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(long[]);
auto A = ab[0]-1;
auto B = ab[1];
long[60] bs;
foreach (long i; 0..60) {
bs[i] += B/(1L<<(i+1))*(1L<<i) + max(0, B%(1L<<(i+1)) - ((1L<<i)-... | D |
import std.stdio;
void main() {
foreach (i; 1 .. 10)
foreach (j; 1 .. 10)
writeln(i, "x", j, "=", i*j);
} | 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 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;
int[] a = readln.chomp.split.map!(to!int).ar... | 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()
{
long a, b;
char op;
scan(a, op, b);
// writeln(a);
// writeln(op);
// writeln(b);
if (op == '+')
{
writeln(a + b);
... | 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 s = readln.chomp;
int res, c;
foreach (e; s)... | 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.math;
import std.conv;
import std.string;
int readInt(){
return readln.chomp.to!int;
}
int[] readInts(){
return readln.chomp.split.to!(int[]);
}
void main(){
int[] balls = readInts();
int ret;
for(int i; i <= balls[3] / balls[0]; i++){
for(int j; j <=... | D |
void main() {
problem();
}
void problem() {
const N = scan!ulong;
ulong solve() {
ulong ans;
foreach(i; 1..N) {
ans += (N - 1) / i;
}
return ans;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.conv, std.array, std.string, std.algorithm, ... | 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 |
// Cheese-Cracker: cheese-cracker.github.io
void solve(){
long l = scan; long r = scan; long k = scan;
long len = r - l + 1;
if(len == 1){
writeln( (l == 1) ? "NO" : "YES");
return;
}
long tim = len / 2;
if(r % 2 == 1 && l % 2 == 1){ tim += 1; }
writeln( (k >= tim) ? "YES" ... | D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import core.bitop;
void main ()
{
string s;
while ((s = readln.strip) != ... | 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.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 INF = 1L << 59;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto X = s[1]... | 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.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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.