code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std;
auto input()
{
return readln().chomp();
}
alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long n;
scan(n);
auto T = new long[](n);
foreach (i; 0 .. n)
{
long t;
scan(t);
T[i] = t;
}
// writeln... | 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();
writeln(800 * n - (n / 15) * 200);
}
void scan(L...)(ref L A)
{
auto l = readln.split;
foreach (i, T; L)
{
A[i... | 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;
import std.random;
void main() {
auto x = readln.chomp.split.map!(to!int);
if (x[0] < x[1] && x[1] < x[2]) writeln("Yes");
else writeln("No... | D |
// import chie template :) {{{
static if (__VERSION__ < 2090) {
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
std.range, std.container, std.bigint, std.ascii, std.typecons, std.format,
std.bitmanip, std.numeric;
} else {
import std;
}
// }}}
// nep.scanner {{{
class Scanner {
... | 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;
import std.algorithm;
import std.string;
import std.conv;
import std.array;
void main() {
auto Q = readln.chomp.to!int;
foreach (i; 0..Q) {
auto input = readln.split.map!(to!int).array;
//??????CAN?????°????±??????????CAN?????°??????min(C, A, N)????????????
int can = min(input[0], input[1], i... | D |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln
void main() {
int n;
scanf("%d", &n);
int[] X = new int[n];
int[] Y = new int[n];
long INF = 1L<<40;
int parity = 0;
foreach (i; 0..n) {
scanf("... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main()
{
auto abc = readln.chomp.split.to!(int[]);
if(abc[1] == abc[2])
abc[0].writeln;
else if(abc[0] == abc[2])
abc[1].writeln;
else
abc[2].writeln;
} | 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, q; scan(n, q);
auto uf = UnionFind(n);
foreach (_ ; 0 .. q) {
int com, x, y; scan(com, x, y);
if (com == 0) {
uf.merge(x, y);
... | 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;
import std.datetime;
void main()
{
while (1) {
auto n = readln.chomp.to!int;
if (!n) break;
auto time = new int[](60 * 60 * 24);
foreach (... | 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[] nk = readInts();
string s = readln.chomp;
writeln(s[0 .. nk[1]-1], s[nk[1]-1].toLower, s[nk[... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
writeln((N+1) / 2 >= K ? "YES" : "NO");
} | 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() {
long T1, T2;
long A1, A2;
long ... | D |
import std.stdio, std.string, std.conv;
import std.algorithm;
void main()
{
auto buf = readln.chomp.split;
immutable n = buf[0].to!size_t;
auto target = buf[1..$].to!(int[]);
int[] current;
foreach (i; 0..n)
current ~= readln.chomp.to!int;
solve(n, target, current).writeln;
}
int solve... | 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() {
immutable long MAX = 2*10^^5+1;
immutable long MOD = 10^^9+7;
auto modinv = new long[](MAX);
modinv[0] = mod... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
for (;;) {
auto rd = readln.split.map!(to!int), h = rd[0], w = rd[1];
if (h == 0 && w == 0) break;
foreach (i; 0..h) {
foreach (j; 0..w)
write((i + j) % 2 == 0 ? '#' : '.');
writeln;
}
writeln;
}... | D |
// Vicfred
// https://atcoder.jp/contests/abc152/tasks/abc152_d
// math, combinatorics
import std.conv;
import std.stdio;
import std.string;
void main() {
int n = readln.chomp.to!int;
long[10][10] digits;
// count the numbers starting in i and ending in j
for(int i = 0; i <= n; i++)
digits[i.... | D |
void main() {
auto N = ri;
auto s = rs, t = rs;
if(s==t) writeln(N);
else {
auto tmp = s;
foreach_reverse(i; 0..N+1) {
tmp = s ~ t[i..$];
if(tmp.endsWith(t)) {
writeln(tmp.length);
break;
}
}
}
}
// ===================================
import std.stdio;
import std.string;
import std.functio... | 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) sc.read!true;
int n, a, b;
sc.read(n, a, b);
import std.math;
if (abs... | D |
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DE... | D |
import 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.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() {
int N, p;
scan(N, p);
string s;
scan(s);
auto a =... | D |
import std.stdio;
import std.conv;
import std.array;
import std.string;
void main()
{
while (1) {
string[] input = split(readln());
int h = to!(int)(input[0]);
int w = to!(int)(input[1]);
if (h == 0 && w == 0) break;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if ((... | 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 ()
{
int n;
while (scanf (" %d", &n) > 0)
{
int ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void main() {
long[] ans = new long[31];
ans[0] = 1;
fo... | 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 N = readln.chomp.to!int;
auto as = readln.split.to!(int[]);
auto xs = new int[](5001);
auto ls = new int[](... | 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, q;
scan(n, q);
auto s = readln.chom... | 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;
import std.datetime;
void main()
{
auto n = readln.chomp.to!int;
bool[string] ids;
foreach (i; 0..n) {
auto x = readln.chomp;
ids[x] = 1;
}... | 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() {
auto s = iota(3).map!(i => readln.chomp).array;
auto n = iota(... | 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() {
strin... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
void main() {
auto N = ri;
foreach(k; 1..50001) {
if(floor(k * 1.08) == N) {
writeln(k);
return;
}
}
writeln(":(");
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.... | D |
import std.stdio, std.string, std.conv;
void main() {
int s = readln.chomp.to!int;
int h = s / 3600;
s %= 3600;
int m = s / 60;
s %= 60;
writeln(h, ":", m, ":", s);
}
| D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional, std.container;
import std.typecons;
void main() {
auto S = readln.chomp;
auto N = S.length;
Tuple!(int, int)[] arr;
int i = 0;
while(i < N) {
int r,l;
while(i < N && S[i]=='R') { i++; r++; }
while(i < N &... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import core.bitop;
int n; rd(n);
int k=1;
while(k*2<=n) k*=2;
writeln(max(popcnt(n), popcnt(k-1)));
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i, r... | 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 |
void main()
{
long x = rdElem;
Pair[] list;
foreach (i; 0L .. 3000L)
{
list ~= Pair(i, i ^^ 5);
if (i) list ~= Pair(-i, -i ^^ 5);
}
foreach (a; list)
{
foreach (b; list)
{
if (a.b - b.b == x)
{
writeln(a.a, " ", b.a);
... | 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 |
void main() {
auto t = rs.to!(dchar[]);
t.map!(v => v == '?' ? 'D' : v).array.writeln;
}
// ===================================
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.... | D |
void main(){
int[] ngs = [7, 5, 3];
int x = _scan();
writeln(ngs.count(x)==1? "YES": "NO");
}
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; read... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
string my_readln() { return chomp(readln()); }
long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mo... | D |
import std.stdio, std.conv, std.string, std.array, std.algorithm;
long maximalModulus(long left, long right) {
if (right / 2 + 1 >= left) {
return right % (right / 2 + 1);
}
else {
long max = -1;
long i = 1;
long x = 1;
while (x > max + 1) {
x = ((right -... | 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() {
int N = readln.chomp.to!i... | D |
unittest
{
assert( [ "a" ].parse.expand.solve == 'b' );
assert( [ "y" ].parse.expand.solve == 'z' );
}
import std.conv;
import std.range;
import std.stdio;
import std.typecons;
void main()
{
stdin.byLineCopy.parse.expand.solve.writeln;
}
auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementTy... | D |
void main() {
auto ip = readln.split, a = ip[0], b = ip[1];
if(a == b) "H".writeln;
else "D".writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
imp... | D |
void main() {
problem();
}
void problem() {
const N = scan!int;
const A = scan!long(N);
void solve2() {
auto B = N.iota.map!(i => A[i] + i).array;
int[long] C;
foreach(i; 0..N) {
C[i - A[i]]++;
}
long answer;
foreach(b; B) {
if (b in C) answer += C[b];
}
writ... | D |
import std.stdio;
import std.string;
void main()
{
foreach (i; 0 .. 3)
{
auto tmp = readln.chop();
tmp[i].write();
}
writeln();
}
| D |
import std.stdio;
import std.array;
import std.algorithm;
import std.string;
import std.container;
import std.typecons;
int size(in string s) {
return cast(int)s.length;
}
void main() {
string s = readln.chomp;
immutable X = "ABC";
bool check(in string s) {
foreach (i, c; s) {
if ... | 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 |
void main()
{
int n = readln.chomp.to!int;
int[] c = new int[n-1], s = new int[n-1], f = new int[n-1];
foreach (i; 0 .. n-1)
{
int[] tmp = readln.split.to!(int[]);
c[i] = tmp[0], s[i] = tmp[1], f[i] = tmp[2];
}
int[] time = new int[n];
foreach (i; 0 .. n-1)
{
fo... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
auto a = readln.split.to!(long[]);
long s1 = 0, s2 = 0;
foreach (i; 1 .. n) {
if (i & 1) {
s1 += a[i];
} else {
s2 += a[i];
}
}
int ans = 0;
if (s1 == s2) {
ans++;
}
foreach (i; 1 .. n)... | 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 s = sread();
bool[] tmp = [false, false];
foreach (i; 0... | D |
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
@safe
long solve (const string s) {
enum m = 2019;
auto c = new int[m];
auto d = new int[m];
long res;
foreach (ch; s) {
c[0] += 1;
const int k = ch.to!int - 48;
d[]... | D |
import std.stdio; // readln
import std.array; // split
import std.conv; // to
import std.typecons;
import std.range;
import std.algorithm;
void main(){
string[] s = split(readln());
int n = to!int(s[0]);
s = split(readln());
int[] a = new int[](n);
for(int i = 0; i < n; i++){
a[i] = to!int(s[i]);
a[i]--;
}
... | 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;
void main() {
int n; scan(n);
int ans = 0;
bool[string] d;
foreach (_; 0..n) {
string s = read!string;
d[s] = true;
}
writeln(d.keys.length);
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return... | 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 |
// Cheese-Cracker: cheese-cracker.github.io
void solve(){
long n = scan;
auto a = scanArray!int;
auto b = scanArray!int;
auto freqa = new ll[301];
auto freqb = new ll[301];
auto cache = new ll[301];
for(int i = 0; i < n; ++i){
++freqa[a[i] + 100];
++freqb[b[i] + 100];
}
... | D |
void main() {
string[] tmp = readln.split;
int a = tmp[0].to!int, b = tmp[1].to!int;
string p = tmp[0];
int cnt;
foreach (i; a .. b+1) {
char[] q = p.dup;
reverse(q);
if (p == q) ++cnt;
p = p.succ;
}
cnt.writeln;
}
import std.stdio;
import std.string;
import ... | 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.algorithm;
import std.stdio;
import std.string;
import std.conv;
import std.range;
void main(){
2.iota.map!(a => readln.split.map!(to!int).reduce!q{a + b}).reduce!max.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 = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
void main(){
int n = _scan();
int[] a = _scanln();
bool approve = true;
foreach(elm; a){
if(elm%2 == 0){
if( elm%3==0 || elm%5==0 )continue;
else{
approve = false;
break;
}
}
}
writeln(approve? "APPROVED": "DENIED");
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.m... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
auto c = new int[](26);
foreach (si; s) ++c[si-'a'];
writeln(c.all!"a<2" ? "yes" : "no");
}
| D |
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
... | D |
void main()
{
string[] tmp = rdRow!string;
long n = tmp[0].to!long, m = tmp[1].to!long;
long[] p = new long[m];
string[] s = new string[m];
foreach (i; 0 .. m)
{
tmp = rdRow!string;
p[i] = tmp[0].to!long;
s[i] = tmp[1];
}
bool[] actof = new bool[n+1];
long[] ... | 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_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
auto N = readln.chomp.map!(ch => ch - '0').array;
... | 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.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
int k = readln.chomp.to!int;
int[] done = new int[](k)... | 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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto x = readln.chomp.to!int;
writeln(x < 1200 ? "ABC" : "ARC");
}
| D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int N, K;
scan(N, K);
readln.sp... | D |
import std.stdio, std.algorithm, std.string;
void main()
{
readln();
auto s = readln().strip();
bool ok = true;
ok &= !canFind(s, "000");
ok &= !canFind(s, "11");
ok &= !s.startsWith("00");
ok &= !s.endsWith("00");
ok &= s != "0";
writeln(ok ? "Yes" : "No");
} | 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.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto S = readln.split[0];
int ans1, ans2;
foreach (i; 0 .. S.length) {
if (i % 2 == 0) {
S[i] == '0' ? ans1++ : ans2++;
}
else {
S[i] == '0' ? ans2++ ... | D |
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.math;
import std.format;
void main() {
string[] q;
foreach (string line; stdin.lines) {
if (line == "quit\n") break;
string op, clr;
auto s = line.chomp.split;
if (s.length == 1) {
op = ... | 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 |
void main() {
problem();
}
void problem() {
auto N = scan!ulong;
ulong solve() {
// Sum_{k=1..n} k/2 * floor(n/k) * floor(1 + n/k)
ulong ans;
foreach(k; 1..N+1) {
ulong x = k * cast(ulong)floor(cast(real)N/k) * cast(ulong)floor(1 + cast(real)N/k);
ans += x / 2;
}
return ans;
}
... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;
void main()
{
auto w = readln.chomp.toLower;
string[] ss;
while(1){
auto line = readln.chomp;
if(line == "END_OF_TEXT") break;
ss ~= line.toLower.split;
... | D |
import std.stdio,
std.string,
std.conv,
std.algorithm;
void main() {
int[] buf = readln.chomp.split.to!(int[]);
int a = buf[0] - 1, b = buf[1] - 1;
int K = 50;
char[100][100] m;
for (int i = 0; i < K; i++) {
for (int j = 0; j < K * 2; j++) {
m[i][j] = '#';
}
}
for (in... | D |
void main() {
auto N = ri;
ulong cnt;
foreach(i; 0..N) {
if(rs == "E869120") cnt++;
}
cnt.writeln;
}
// ===================================
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.bi... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main() {
string input;
while ((input = readln.chomp).length != 0) {
while (input.length > 1) {
string output;
for (int i = 0; i < input.length-1; i++) {
... | 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(){
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
writeln(max(a*b, c*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 to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] inl... | D |
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;
void main(){
auto s = readln.chomp;
auto stack = new Stack!(char)(s.length.to!int);
foreach(c;s){
if(c == 'B'){
if(!stack.isEmpty) stack.po... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
struct P {int first; int second;}
int main()
{
while (true) {
string[] str = readln().chomp().split();
int h = str[0].to!int();
int w = str[1].to!int();
if (h == 0 && w == 0) break;
string 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.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 xnm = readln.split.to!(int[]);
auto X = xnm[0];
auto N = xnm[1];
auto M = xnm[2];
while (N > 0 && ... | 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 hs = readln.split.to!(int[]);
int solve(int[] lr) {
if (lr.empty) return 0;
auto m = int.max;
foreach (n; lr) m = min(m, n);
... | D |
import std.stdio;
import std.string;
import std.conv;
void main()
{
int n = readln.chomp.to!(int);
long[] a = readln.chomp.split.to!(long[]);
int ans = 0;
for (int i = 0; i < a.length; i++) {
while (true) {
if (!(a[i] & 1)) {
ans += 1;
a[i] /= 2;
... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.math;
void main()
{
immutable long N = 1000;
foreach(n;stdin.byLine().map!(to!long))
iota(max(0,n-2*N),min(2*N,n)+1).map!(i=>(N-abs(N-i)+1)*(N-abs(N-(n-i))+1)).reduce!"a+b"().writeln();
} | 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 main()
{
int x, t; readV(x, t);
writeln(max(0, x-t));
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] + ip[1... | D |
import std.stdio;
void main() {
long l, r;
scanf("%ld%ld", &l, &r);
auto ans = 0;
for (long a2=1; a2<=r; a2*=2) {
for (long a3=1; a3<=r/a2; a3*=3) {
if (a2 * a3 >= l) ans++;
}
}
writeln(ans);
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
import std.math;
int x, a, b;
scan(x, a, b);
writeln(abs(x-a) < abs(x-b) ? "A" : "B");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std... | 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 x, y;
scan(x, y);
writeln(x + y / 2);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import ... | D |
void main(){
auto K = readLine!()()[0];
auto AB = readLine!()();
foreach( i ; 1..1000 ){
if( AB[0] <= K*i && K*i <= AB[1] ){
writeln("OK");
return;
}
if( K*i > 1001 ){break;}
}
writeln("NG");
return;
}
import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
struct UFTree(T)
{
struct Node
{
T parent;
T rank = 1;
}
this(T n)
{
nodes.length = n;
foreach (i, ref node; nodes) node = Node(i.to!T);
}
void unite(T a, T b)
{
a = roo... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
auto l = readln.chomp;
auto fst = l[0..2].to!int;
auto snd = l[2..4].to!int;
auto fM = fst > 0 && fst <= 12;
auto sM = snd > 0 && snd <= 12;
if (fM && sM)
write("AMBIGUOUS");
else if (sM)
write("YYMM");
else if (fM)
write("MMYY");
else
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.