code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.string;
import std.ascii;
void main() {
string s = readln.chomp;
writeln( (s.length >= 6 && s.count!(isDigit) >= 1 && s.count!(isUpper) >= 1 && s.count!(isLower) >= 1) ? "VALID" : "INVALID" );
} | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int N;
int[] a;
scan(N);
a = readln.split.to!(int[]);
long x = 0, y = a.sum(0L);
long ans = long.max;
foreach (i ; 0 .. N - 1) {
x... | D |
void main()
{
long n = readln.chomp.to!long;
if (n & 1)
{
0.writeln;
}
else
{
long cnt;
long d = 10;
while (d <= n)
{
cnt += n / d;
d *= 5;
}
cnt.writeln;
}
}
import std.stdio;
import std.string;
import std.ar... | D |
void main() {
auto S = rs;
ulong res = ulong.max;
foreach(i; 0..S.length - 2) {
auto a = S[i..i + 3];
res = min(res, abs(753 - a.to!int));
}
res.writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.tra... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
long P = 10^^9+7;
long[2001] F, RF;
long pow(long x, long n) {
long y = 1;
while (n) {
if (n%2 == 1) y = (y * x) % P;
x = x^^2 % P;
n /= 2;
}
return y;
}
long ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto s = readln.chomp.to!(dchar[]);
sort(s);
s = s.uniq.array;
if (s[0] != 'a') {
writeln("a");
return;
}
foreach (i, c; s[0..$-1]) {
if (s[i+1] - c != 1) {
writeln((c +... | D |
void main()
{
long n = rdElem;
Train[] train = rdCol!Train(n-1);
long[] list = new long[n];
foreach (i; 0 .. n-1)
{
foreach (t; train[i..$])
{
list[i] = t.c + t.s + max(0, (list[i]-t.s+t.f-1)/t.f) * t.f;
}
}
foreach (l; list)
{
l.writeln;
... | 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();
alias route... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp;
auto DP = new long[][](2, 2019);
long r;
foreach (i, c; S) {
auto n = c - '0';
foreach (x; 0..2019) DP[i%2][x] = 0;
DP[i%2][n] = 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;
import std.container;
alias sread = () => readln.chomp();
ulong MOD =... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm;
void main() {
int n;
int[] a;
scan(n);
a = iota(n).map!(i => readln.chomp.to!int).array;
auto dp = repeat(10^^9 + 7, n + 2).array.assumeSorted;
dp[0] = -1;
int ans = 1;
foreach (i ; 0 .. n) {
auto j = d... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
int main()
{
int i = 0;
while (++i <= 1000)
writeln("Hello World");
return 0;
} | 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;
void main()
{
writeln = readln.chomp.split.join.to!int % 4 ? "NO" : "YES";
}
| 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 AS = readln.split.to!(int[]);
auto BS = readln.split.to!(int[]);
auto CS = readln.split.to!(int[]);
int r;
foreach (i; 0..N) {
auto x ... | 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 |
void main() {
auto S = rs;
bool flag = true;
if(S[0] != 'A') flag = false;
ulong tmp;
foreach(i; 2..S.length-1) {
tmp += S[i] == 'C';
}
if(flag) {
ulong tmp2;
foreach(i; S) {
if(i.isUpper) tmp2++;
}
if(tmp2!=2) flag = false;
}
if(tmp != 1) flag = false;
writeln(flag ? "AC" : "WA");
}
// ========... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
int[][][] MEMO;
MEMO.length = N;
foreach (i; 0..N) {
auto A = readln.chomp.to!int;
MEMO[i].length = A;
foreach (j; 0..A) {
... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.range;
int n, m, t; rd(n, m, t);
auto r=readln.split.to!(int[]);
auto d=new long[][](n, n);
const long inf=1_000_000_000_000_000_000;
foreach(i; 0..n) fill(d[i], inf);
foreach(i; 0..n) d[i][i]=0;
foreach(_; 0..m){
int ... | 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.string;
import std.conv;
void main(){
string str;
string[] input = split(readln());
int a = to!int(input[0]), b = to!int(input[1]);
if(a > b)
str = " > ";
else if(a < b)
str = " < ";
else
str = " == ";
writeln('a',str,'b');
} | D |
import std.stdio, std.algorithm, std.array, std.string, std.conv;
void main()
{
int t;
scanf("%d", &t);
getchar();
foreach(_; 0..t)
{
auto str = readln.strip;
int zero_cnt, five_cnt;
bool zero_f = false, five_f = false;
for(int i = cast (int) str.length - 1; i > 0; ... | 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() {
auto ip = readAs!(int[]), N = ip[0], K = ip[1];
(K * ((K - 1) ^^ (N - 1))).writeln;
}
// ===================================
T readAs(T)() if (isBasicType... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
bool check(string s){
for(int i=0;i<s.length-3;i++){
string str = s[i..i+4];
if(str == "this" || str == "that"){
writeln(s);
return true;
}
}
return false;
}
void main(){
int n = to!int(chomp(rea... | 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() {
problem();
}
void problem() {
auto N = scan!long;
const K = scan!long;
long solve() {
while(true) {
real ratio = cast(real)N / cast(real)K;
if (ratio <= 0.5) return N;
if (ratio < 1.0) return K - N;
N = N - (N/K)*K;
}
}
solve().writeln;
}
// ---------------... | D |
import std.stdio,std.string,std.algorithm,std.conv;
void main(){
readln;
auto a=readln.chomp.split.to!(ulong[]);
ulong[ulong] l;
foreach(x;a)
l[x]++;
ulong sum;
foreach(x;l.values)
sum+=x*(x-1)>>1;
foreach(x;a)
(sum-(l[x]-1)).writeln;
} | 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;
if(S[0]==S[$-1]){
writeln(S.length%2==0?"First":"Second");
}else{
writeln(... | D |
module aoj;
import std.array;
import std.stdio;
import std.string;
void main() {
string line;
while ((line = chomp(readln())) != "END OF INPUT") {
foreach (word; split(line, " ")) {
write(word.length);
}
writeln();
}
} | D |
import std;
void main() {
auto t = readln.strip.to!int;
Attempt: foreach(tt; 0 .. t) {
uint cm = 1;
readln;
auto ai = readln.split.to!(int[]);
if(ai[0] == 1) {
cm++;
}
if(ai.length >= 2) {
foreach(i, a; ai[1 .. $]) {
if(a == 0 && ai[i] == 0) {
writeln("-1");
continue Attempt;
} els... | D |
/+ dub.sdl:
name "F"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
import core.bitop;
immutable int L = 20;
int main() {
Scanner sc = new Scanner(stdin);
int[][] dp = new int[][](L+1, 1<<(L+1));
int[] ans ... | 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()
{
foreach (line; stdin.byLine) {
auto x = line.chomp;
if (x.length == 0) continue;
auto f = new string[](10... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
for (;;) {
auto N = readln.chomp.to!int;
if (N == 0) return;
auto ws = readln.split.to!(int[]);
auto DP = new int[][](N, N);
int max_l;
foreach (i; 0... | 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.uni;
void main() {
string w = readln.chomp;
int cnt = 0;
while (true) {
string t = readln.chomp;
if (t == "END_OF_TEXT") break;
string[] s = t.toLower.split;
foreach (x; s) {
if (x == w) ++cnt;
}
}
cnt.writeln;
}
| D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] AR... | D |
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main(){
auto ab = readln().chomp().split().map!(to!int).array();
ab.solve().writeln();
}
int solve(int[] input){
auto a = input[0];
auto b = input[1];
if (b >= a){
return a;... | 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;
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()
{
foreach (line; stdin.byLine) {
auto p = line.map!(a=>a.to!int-'0').array;
foreach (i; 0..10) {
fore... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
auto n = lread();
auto a = aryread();
long sum_a = a.sum();
... | D |
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
/*
------------------------... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
auto t = "";
foreach (c; s)
switch (c) {
case '0':
case '1':
t ~= c;
break;
case 'B':
t = t.empty ? t : t[0..$-1];
break;
default:
assert(0);
}
writeln(... | 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.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.string, std.algorithm, std.math, std.functional;
void main() {
auto N = readln.chomp.to!int;
int cx = 0, cy = 0;
int ct = 0;
bool ok = true;
foreach (i; 0..N) {
auto tmp = readln.split.to!(int[]);
if (!ok) continue;
auto t = tmp[0];
au... | D |
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
long n = read.to!long;
lo... | 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()
{
immutable N = readln.chomp.to!long;
long res;
foreach (i; 1..N.to!real.sqrt.to!l... | 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, A, B;
scan(N, A, B);
string s = readln.chomp;
... | D |
import std.stdio;
void main(string[]args){
long l,r;scanf("%d %d",&l,&r);
long a=1;int ans=0;
for(int i=0;i<32;++i){
long b=a;
for(int j=0;j<30;++j){
if(l<=b&&b<=r)++ans;
b*=3;if(b>r)break;
}
a*=2;if(a>r)break;
}
printf("%d",ans);
}
| D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!int).array;
auto C = new int[](13);
foreach (a; A... | D |
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.range;
import std.typecons;
import std.algorithm;
struct RMQSegmentTree(Type = int,string gstr = "a>b"){
Type[] data;
size_t height;
Type initvalue;
bool greater(Type a,Type b){
bool ret;
mixin("ret = "~gstr~";");
return ret;... | 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()
{
long x, a, b;
scan(x, a, b);
long A = abs(x - a);
long B... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main(){
auto a=readln.split.to!(int[]),x=a[0],y=a[1];
writeln(x+y/2);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto di = readln.split.map!(to!int).array;
auto si = readln.chomp;
auto dice = new Dice(di);
foreach (c; si)
dice.roll(c);
writeln(dice.top);
}
class Dice
{
int[] di;
this(int[] di)
{
this.di = di;
}
int t... | D |
import std;
void main() {
auto K = readln.split[0].to!int;
auto AB = readln.split.to!(int[]);
auto A = AB[0], B = AB[1];
foreach (i; A .. B+1) {
if (i % K == 0) { writeln("OK"); return; }
}
writeln("NG");
}
| D |
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;
void main() {
auto s = map!(x => x.to!int)(readln.chomp.split);
int n = s[0], a = s[1], b = s[2];
int res = 0;
foreach (i; 1 .. n + 1) {
auto t = i.to!(dchar[]);
int sum = 0;
foreach (j; 0 .. t.length) {
sum += t[j] ... | D |
void main() {
string s = readln.chomp;
string s1 = s[0..2], s2 = s[2..$];
bool yymm, mmyy;
if ("01" <= s1 && s1 <= "12") mmyy = true;
if ("01" <= s2 && s2 <= "12") yymm = true;
if (yymm && mmyy) {
writeln("AMBIGUOUS");
} else if (yymm && !mmyy) {
writeln("YYMM");
} else i... | D |
import std.string;
import std.stdio;
import std.functional;
import std.conv;
import std.algorithm;
void main(){
readln.split.map!(to!int).unaryFun!(a => text(a[0] * a[1], " ", 2 * (a[0] + a[1]))).writeln;
} | D |
import std;
const AB = 1;
const AC = 2;
const BA = 3;
const BC = 4;
const CA = 5;
const CB = 6;
void calc(int a, int b, int c, string[] ss) {
string move(int mv) {
switch (mv) {
case AB:
if (a == 0 && b == 0) return "X";
if (a == 0) { a++; b--; return "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.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, m;
scan(n, m);
auto cnt = new int[... | D |
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to
void main()
{
string n = chomp(readln());
int a = to!int(n);
if(a/100%10 == a/10%10 && (a/100%10 == a/1000 || a/100%10 == a%10)){
writeln("Yes");
} else {
writeln("No");
}
} | D |
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.typecons;
import std.math;
import std.numeric;
void main() {
int[] input;
foreach (i; 0 .. 5) {
input ~= readln().chomp().to!int;
}
solve(input).writeln();
}
int solve(in... | 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 N = readln.chomp.to!int;
auto S = N.iota.map!(_ => readln.chomp).array;
long ans = 0;
fore... | D |
void main(){
string s = inelm!string();
writeln( s.lastIndexOf('Z') - s.indexOf('A')+1 );
}
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[] inln(... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
... | D |
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
int n;
void main() {
while (true) {
scan(n);
if (n == 0) break;
writeln(solve(n));
}
}
in... | 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()
{
long x; readV(x);
auto ans = x/... | D |
import std;
void main() {
int n, k; scan(n, k);
auto s = new int[n + 1];
foreach (_; 0..k) {
readint;
foreach (e; readints) s[e]++;
}
auto ans = n - s[1..$].count!(e => e > 0);
writeln(ans);
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) 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.regex : regex;
import std.container;
import std.bigint;
import std.ascii;
void main()
{
auto r = readln.chomp.to!int;
auto g = readln.chomp.to!int;
wr... | 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;
const long INF = 1L << 59;
const long MOD = 10 ^^ 9 + 7;
void main() {
auto N = readln.chomp.to!int;
auto edges = new Tuple!(int, ... | 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;
auto S = readln.split[0].to!(dchar[]);
auto K = readln.split[0].to!int;
string ans = "";
auto c = S[K-1];
foreach (d; S) {
if... | D |
import std.stdio;
import std.string;
import std.conv;
int main()
{
string[] str;
while (true) {
str = readln().split();
int num1 = str[0].to!int();
char op = str[1].to!char();
int num2 = str[2].to!int();
switch (op) {
case '+': writeln(num1 + num2); break;
... | 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.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto s = readln.chomp.to!ulong;
bool[1000000] memo;
foreach (i; 0..1000000) {
memo[s] = true;
auto a = s & 1 ? (3*s+1) : (s/2);
if (memo[a]) {
writeln(i+2);... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split, n = rd[0].to!int, k = rd[1].to!size_t;
auto d = readln.split.to!(int[]);
auto db = new bool[](10);
foreach (di; d) db[di] = true;
while (toDigits(n).any!(i => db[i])) ++n;
writeln(n);
}
auto toDigits(i... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
double[] weight = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91];
string[] names =
["light fly", "fly", "bantam", "feather",
"light", "light welter", "welter",
"light middle", "middle", "light heavy", "heavy"];
while(true) {
string ... | D |
import std.stdio;
import std.regex;
void main(){
auto io = new IO();
auto N = io.line()[0];
auto K = io.line()[0];
auto X = io.line()[0];
auto Y = io.line()[0];
size_t fee = 0;
if( N>K ){
fee += K*X;
fee += (N-K)*Y;
}else{
fee += N*X;
}
writeln(fee);
return;
}
import std.stdio,std.conv,std.stri... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!int;
auto a = readln.chomp.to!int;
writeln(n * n - a);
}
| D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv, std.math;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) assert(!sc.hasNext);
int n, k1, k2;
sc.read(n, k1, k2);
long[]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto S = readln.chomp.to!(wchar[]);
auto T = readln.chomp.to!(wchar[]);
foreach (_; 0..101) {
if (S == T) {
writeln("Yes");
return;
}
S = [S[$-1]] ~ S[0..... | 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 |
// 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;
import std.ascii;
import std.algorithm;
import core.stdc.stdio;
int main()
{
auto t = readInt!int;
foreach(ti; 0 .. t)
{
int[4] s;
s[0] = readInt!int;
s[1] = readInt!int;
s[2] = readInt!int;
s[3] = readInt!int;
if (min(s[2], s[3]) > max(s[0]... | D |
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
struct Strut{
long A;
long B;
}
void main()
{
long[] input = readln().split.to!(long[]);
long A = i... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
readln.split.to!(int[]).map!(x => x-1).reduce!((a,b) => a * b).writeln;
}
| 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()
{
foreach (line; stdin.byLine) {
auto x = line.split;
long cost, sum;
cost += x[1].to!long * 200 + x[2... | D |
// Vicfred
// https://atcoder.jp/contests/abc052/tasks/abc052_b
// simulation
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;
void main() {
int n = readln.chomp.to!int;
string s = readln.chomp;
int maxima = 0;
int x = 0;
foreach(ch; s) {
if(ch == 'I')
... | D |
void main(){
long n = _scan!long();
for(int i;; i++){
if(i*i>n){
( (i-1)*(i-1) ).writeln();
break;
}
}
}
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;
for... | D |
/+ dub.sdl:
name "B"
dependency "dunkelheit" version="1.0.1"
+/
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 a, b, c, d;
sc.read(a, b, c, d);
int ans = 0;
... | 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;
string[] operators = ["=","(", ")", "+", "-", "*", "/"];
bool isOperator(string s) {
return operators.canFind(s);
}
int priority(string op) {
int i =... | 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;
import std.algorithm;
int[] readArray(int n) {
int[] a = new int[n - 1];
int start = -1;
for (int i = 0, j = 0; i < n; i++) {
int x;
scanf("%d", &x);
if (x == 1) {
start = j;
}
if (x != 0) {
a[j++] = x;
}
}
int[] res = new int[n - 1];
for (int i = 0, j = star... | D |
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
bool isSquare (int n)
{
auto p = cast (int) (sqrt (n * 1.0) + 0.5);
return p * p == n;
}
void main ()
{
auto tests = readln.strip.to !(int);
foreach (test; 0..tests)
{
auto n = readln.strip.to !(int);... | D |
import std.stdio, std.algorithm, std.array, std.string, std.conv;
void main()
{
int t;
scanf("%d", &t);
foreach(_; 0..t)
{
long n;
scanf("%lld", &n);
getchar();
writeln(-1 * (n - 1), ' ', n);
}
} | 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;
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 |
//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.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 |
module main;
import std.stdio;
import std.string;
int main(string[] argv)
{
int n, j = 0;
scanf("%d", &n);
int [] a = new int[n];
for(int i = 0; i < n; i++)
{
scanf("%d", &a[j]);
while(j > 0 && a[j] == a[j - 1])
{
a[j - 1]++;
a[j] = 0;
j--;
}
... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.