code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.range, std.array, std.conv, std.string, std.math, std.container, std.typecons;
void main() {
writeln((readln.chomp.to!int - readln.chomp.to!int) % readln.chomp.to!int);
}
| 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;
auto K=readln.chomp.to!int;
auto X=readln.chomp.to!int;
auto Y=readln.chomp.to!int;
if(N<=K)writeln(X*N);
else writeln(X*K+Y*(N-K));
} | 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,
std.format,
std.math;
void main()
{
auto n = readln.chomp.to!int;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(dchar[]);
auto T = readln.chomp.to!(dchar[]);
foreach (i; 0..S.length) {
S = S[1..$] ~ S[0];
if (S == T) {
writeln("Yes");
r... | D |
import std.stdio, std.string;
void main() {
string n = readln.chomp;
string s = "0";
int cnt;
while (s != n) {
s = succ(s);
if (s.length % 2) ++cnt;
}
cnt.writeln;
} | 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 n;
long x;
scan(n, x);
auto a = new long[](n + 1); // 長さ
auto b = new long[](n + 1); // Pの枚数
a[0] = b[0] = 1;
fore... | D |
import std.stdio;
void main()
{
foreach (former; 1 .. 10)
{
foreach (latter; 1 .. 10)
{
writeln(former,"x",latter,"=",former*latter);
}
}
} | D |
import std.stdio,std.string,std.conv;
int main()
{
string s;
while((s = readln.chomp).length != 0)
{
bool flag = true;
for(int i=0;i<7;i += 3)
{
if(s[i] != 's' && s[i] == s[i+1] && s[i+1] == s[i+2])
{
s[i].writeln;
flag = false;
break;
}
}
if(flag)
{
foreach(i;0..3)
{
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 |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto a=new long[](100);
a[0]=2; a[1]=1;
for(int i=2; i<=n; i++){
a[i]=a[i-1]+a[i-2];
}
writeln(a[n]);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.le... | D |
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.algorithm;
import std.range;
void main() {
long n = readln.chomp.to!long;
long[] answer;
for (long i = 2; i <= sqrt(cast(float)n); i++) {
if (n % i == 0) {
answer ~= i;
}
while (n % i == 0... | 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;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializ... | 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;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializ... | 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.stdio;
void main() {
auto T = readln.chomp.to!int;
while (T--) {
auto N = readln.chomp.to!int;
if (N % 2)... | D |
import core.bitop;
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;
bool solve (string s, string [] t)
{
if (t.canFind (s))
{
r... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nd = readln.split.to!(long[]);
auto N = nd[0];
auto A = nd[1];
auto B = nd[2];
auto C = nd[3];
auto D = nd[4];
foreach (m; 0..N-1) {
if (C * (N-1-m) - D*m <= B... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.functional;
void main() {
writeln(readln.replace(" ", "").chomp.to!uint.pipe!(x => (cast(uint)sqrt(cast(real)x)) ^^ 2 == x) ? "Yes" : "No");
}
| 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() {
immutable int INF = 1 << 29;
auto N = readln.chomp.to!int + 2;
auto S = '0' ~ readln.ch... | 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.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;
void main()
{
auto N = readln.strip.to!int;
(N>=1000?"ABD":"ABC").writeln;
} | D |
import std.stdio,std.string;
int main(){
auto input=readln.chomp;
char[] s=input.dup;
foreach(ss;s[1..3]){
if(ss!=s[0]){
writeln("Yes");
return 0;
}
}
"No".writeln;
return 0;
}
| D |
import std.stdio;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
import std.math;
char[12][12] map;
int[] dx = [1,0,-1,0];
int[] dy = [0,1,0,-1];
void saiki(int x, int y){
if(map[y][x] == '1'){
map[y][x] = '0';
for(int i=0;i<4;i++){
if(x+dx[i]>=12||y+dy[i]>=12||x+dx[i]<0||y+dy[... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
void main() {
string[char] d;
d['a'] = rs;
d['b'] = rs;
d['c'] = rs;
import std.uni;
solve(d).toUpper.writeln;
}
char solve(string[char] d) {
if(d['a'].length == 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.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;
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 h = readln.chomp.to!long;
long c = 1;
long num;
while (h != 0) {
num +... | 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[]);
const A = tmp[0], B = tmp[1], C = tmp[2];
writeln(min(C, B/A));
}
| D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
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 =... | 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 std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(wchar[]);
int r, b;
foreach (c; S) {
switch (c) {
case '0':
++r;
break;
case '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, 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.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.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
void main() {
auto D = readln.split[0].to!int;
auto c =
D == 25 ? "Christmas" :
D == 24 ? "Christmas Eve" :
D == 23 ? "Christmas Eve Eve" :
D == 22 ? "Christmas Eve Eve Eve" : "";
c.write... | 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 ans = 0;
for (int i... | D |
import std.stdio, std.string, std.conv;
void main() {
foreach (i; 0 .. 10) {
string cards = readln.chomp.to!(string);
if (cards == "-") break;
int m = readln.chomp.to!int;
foreach (j; 0 .. m) {
int h = readln.chomp.to!int;
cards = cards[h..$] ~ cards[0..h];
... | D |
import std.stdio, std.string, std.conv, std.array, std.regex, std.algorithm;
void main(){
auto ip = readln.chomp;
switch(ip){
case "a", "i", "u", "e", "o":
writeln("vowel");
break;
default:
writeln("consonant");
break;
}
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n;
scan(n);
auto a = new int[](n), b = new int[](n);
auto c = new int[](n), d = new int[](n);
foreach (i ; 0 .. n) {
scan(a[i], b[i]);
}
foreach (i ; 0 .. n) {
scan(c[i]... | D |
import std.stdio,
std.string,
std.conv,
std.algorithm;
void main() {
string S = readln.chomp;
int[char] arr;
foreach (c; 'a'..'z') {
arr[c] = 0;
}
foreach (c; S) {
arr[c]++;
}
char add_char = 'z' + 1;
foreach (c; arr.byKey) {
if (arr[c] != 0) continue;
add_char =... | 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.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
void main(){
auto mn=readln.split.map!(to!int).array;
auto m=mn[0];
auto n=mn[1];
string[] as;
string[] bs;
foreach(i;0..m... | 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() {
auto week = ["MON", "TUE", "WED", "THU"... | D |
void main()
{
dchar[] s = rdDchar;
dchar[] t = rdDchar;
LCS!dchar(s, t).writeln;
}
T[] LCS(T)(T[] x, T[] y)
{
T[] result;
long xlen = x.length, ylen = y.length;
long[][] dp = new long[][](xlen+1, ylen+1);
foreach (i, u; x)
{
foreach (j, v; y)
{
if (u == v) d... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
import std.stdio, 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.datetime;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto Y = s[1];
for (int i = 0; i * 10000 <= ... | D |
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
void main() {
readln.enumerate.filter!(a => a.index % 2 == 0).map!(a => a.value).array.writeln;
} | D |
void main(){
int a = _scan();
(a+a^^2+a^^3).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[] _scanln(T = int)(){
T[] ln;
foreach(string elm; readln().chomp().split()){
ln ~= elm.to!... | 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.array, std.conv;
void main() {
string row;
foreach (i; 0 .. 300) row ~= "#";
while (true) {
int[] tmp = readln.chomp.split.to!(int[]);
int h = tmp[0], w = tmp[1];
if (h == 0 && w == 0) break;
foreach (i; 0 .. h) row[0..w].writeln;
wr... | 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;
bool calc(int a, int b, int c, int d) {
int x = (c + b - 1) / b;
int y = (a + d - 1) / d;
return x <= y;
}
void main() {
int a, b, c, d; scan(a, b, c, d);
writeln(calc(a, b, c, d) ? "Yes" : "No");
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] ... | 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 S = readln.chomp;
auto T = readln.chomp;
int s, t, c, max_c, d, max_d;
foreach (i; 0..N) {
auto s1 = S[i] == '1';
auto t1 = T[i] =... | D |
void main() {
auto N = ri;
auto K = ri;
ulong res = 1;
foreach(i; 0..N) res = (res * 2 < res + K ? res * 2 : res + K);
writeln(res);
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
imp... | 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.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;
void main() {
auto S = readln.split[0];
auto K = readln.split[0].to!long;
foreach (c; S) {
if (K == 1 || c != '1') { writeln(c); return; }
else K--;
}
writeln(1);
} | D |
import std.stdio,std.array,std.conv;
void main(){
string[] s=split(readln()); // splitで文字列を文字列の配列に切り分け
int x=to!int(s[0]); // 第0要素を整数に変換
int y=to!int(s[1]);
int z=to!int(s[2]);
int ans=to!int((x-z)/(y+z));
writeln(ans);
} | D |
import std.stdio, std.string, std.algorithm, std.range, std.conv;
void main()
{
auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1];
if(A > 8 || B > 8) {
writeln(":(");
} else {
writeln("Yay!");
}
} | 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.conv, std.stdio, std.algorithm, std.string, std.range;
void main() {
const input = readln.split.map!(to!int).array;
if (1 <= min(input[0], input[1]) && max(input[0], input[1]) <= 9) {
(input[0] * input[1]).writeln;
} else {
(-1).writeln;
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(char[]);
auto K = S.length;
int w;
foreach (s; S) {
if (s == 'o') ++w;
}
writeln(w+(15-K) >= 8 ? "YES" : "NO");
} | D |
import std.stdio, std.string, std.ascii, std.algorithm;
void main() {
string str, tmp;
while ((tmp = readln.chomp.toLower) != "") {
str ~= tmp;
}
foreach (ab; lowercase) {
writeln(ab, " : ", str.count(ab));
}
}
| 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.stdlib;
immutable long MOD = 10^^9 + 7;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto K = s[1... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
bool[3] b;b[0]=true;
foreach(s;stdin.byLine())
swap(b[s[0]-'A'],b[s[2]-'A']);
foreach(i,v;b) if(v) writeln(cast(char)('A'+i));
} | 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 nk = readln.split.to!(long[]);
auto N = nk[0];
auto K = nk[1];
long[] AS;
long max_a;
foreach (a; readln.split.to!(long[])) {
max_a = max(m... | D |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
import core.bitop;
int mybsr(long x) {
if (x == 0) return -1;
return bsr(x);
}
long f(long a, long b) {
if (a == 0 && b == 0) return 1;
... | 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.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;
void main(){
auto l=readln.chomp;
writeln(l[0],l.length-2,l[$-1]);
}
| D |
void main() {
int r = readln.chomp.to!int;
if (r < 1200) {
"ABC".writeln;
} else if (r < 2800) {
"ARC".writeln;
} else {
"AGC".writeln;
}
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main(){
string s;
while(!(s=readln).length==0){
s=chomp(s);
for(int i=cast(int)s.length-1; i>=0; i--) write(s[i]);
writeln();
}
} | D |
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
void main() {
string s = readln.chomp;
bool can = 1;
foreach(c; "abc") can &= (count(s, c) == 1);
writeln(can ? "Yes" : "No");
} | D |
import std.algorithm;
import std.conv;
import std.math;
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);
auto a = readln.splitter.map !(to !(long)).array;
writeln (a.front < a.back ? "YES" : "... | 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 m... | 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;
}
void main() {
auto nq = readints();
int n = ... | 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 times(alias fun)(int n) {
foreach(i... | D |
// Vicfred
// https://atcoder.jp/contests/abc129/tasks/abc129_b
// brute force
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
void main() {
const long n = readln.chomp.to!long;
const long[] ws = readln.split.map!(to!long).array;
long[] sum = ... | 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 a, b; readV(a, b);
writeln(a... | 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 a, b, c, d, e, k;
scan(a);scan(b);scan(c);... | D |
void main() {
import std.stdio, std.string;
string s = readln.chomp;
writeln("2018", s[4 .. $]);
} | 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 a = readln.chomp.split.map!(to!int);
writeln = a[0] ^ a[1] ^ a[2];
}
| 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 A = readln.split.to!(int[]);
auto B = readln.split.to!(int[]);
ulong ans = 0;
foreach(i; 0..N) {
int b = B[i];
int x;
x ... | 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.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;
void main(){
while(true){
int n = readln().chomp().to!int;
if(n==0) break;
int ans = 100000000;
for(int i=0;i<=25;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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
if (S.length == 2) {
if (S[0] == '0' || S[1] == '1') {
writeln(-1);
} else {
writeln("1 2");
}
return;
}
if... | D |
void main()
{
long n = readln.chomp.to!long;
dchar[] s = readln.chomp.to!(dchar[]);
dchar[] t = readln.chomp.to!(dchar[]);
long len = 2 * n;
foreach_reverse (i; 0 .. n)
{
if (s[i..$] == t[0..$-i])
{
len = i + n;
}
}
len.writeln;
}
import std.stdio;
... | 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.chomp.pipe!(a => a... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.array;
void main(){
while(1){
auto ffffffffff = readln.chomp.to!(int);
if(ffffffffff==0) break;
int a = 1000 - ffffffffff;
int ans;
if(a>=500){
ans++;
a-=500;
}
if(a>=100){
ans += a/100;
a -= a/100*100;
}
if(a>=50){
ans ++;
a -= 50;
... | D |
void main() {
string[] s = readln.split(',');
s.join(" ").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.ascii;
import std.uni; | D |
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;
int[32] dp;
void main()
{
while (true){
int n = readln().chomp().to!int;
if (n == 0) break;
dp[0 .. 32] = -1;
int pat = shinobu(n);
pat /= 10;
if (pat % 10 != 0){
pat++;
}
writeln(p... | D |
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }
T[] readToArray(T)() {
return readln.split.to!(... | D |
void main() {
int[] ab = readln.split.to!(int[]);
writeln(ab.all!"a & 1" ? "Odd" : "Even");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import ... | 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);
int ans;
... | 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.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 std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.conv;
void main() {
(min(r, r) + min(r, r)).writeln;
}
int r() {
return readln.chomp.to!int;
} | 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 x... | 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.stdio;
import std.conv;
import std.string;
void main(){
int count;
foreach(Unused; 0..readln.chomp.to!int){
if(readln.chomp.to!int.isPrime){
++count;
}
}
count.writeln;
}
bool isPrime(int n){
if(n <= 1){
return ... | D |
import std.stdio, std.string, std.conv;
void main() {
string s = readln.chomp;
int[] num = new int[s.length];
int cnt;
foreach (i, x; s) {
if (x == 'R') {
++cnt;
} else {
num[i-1] += cnt / 2 + cnt % 2;
num[i] += cnt / 2;
cnt = 0;
}... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.