code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
/+ dub.sdl:
name "A"
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);
long n, a, b;
sc.read(n, a, b);
if (a > b) {
writeln(0);
return 0;
}
... | 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 N = tmp[0], K = tmp[1];
const a = N/K;
const b = (K&1) ? 0 : (N+K/2)/K;
writeln(a^^3 + b^^3);
}
| 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.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
iota(readln().chomp().to!int()).map!(_=>readln().chomp().replace("Hoshino","Hoshina")).array().join("\n").writeln();
} | D |
void main()
{
int[] abc = readln.split.to!(int[]);
writeln(abc.all!(x => x == abc[0]) ? "Yes" : "No");
}
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 std.stdio, std.conv, std.string, std.algorithm,
std.math, std.array, std.container, std.typecons;
int[] maps = new int[256];
int[] mapt = new int[256];
int sn = 1, tn = 1;
bool check(char sc, char tc) {
if(maps[sc]==0) maps[sc] = sn++;
if(mapt[tc]==0) mapt[tc] = tn++;
return maps[sc]==mapt[tc];
}
... | 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.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; }
void main(){
long n = read.... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n; rd(n);
auto s=readln.chomp.to!(char[]);
auto vo=['a', 'e', 'i', 'o', 'u', 'y'],
used=new bool[](s.length);
while(true){
auto found=false;
foreach(i; 0..(s.length)){
if(used[i]) continue;
if(canFind(vo, s[i]... | D |
void main() {
problem();
}
void problem() {
auto X = scan!long;
const DELTA = 0.000001L;
long solve() {
long theta;
real x = sin(PI*theta/180L);
real y = cos(PI*theta/180L);
while(true) {
theta += X;
x += sin(PI*theta/180L);
y += cos(PI*theta/180L);
[x, y, PI].deb;... | 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 File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() ... | 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.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()
{
string s; readV(s);
writeln(s[0.... | 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 |
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.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
void main(){
auto q=readln.split.to!(int[]),a=q[0],b=q[1];
if(a*b%2==0)writeln("Even");
else writeln("Odd");
} | 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;
struct Katana{
long a, b;
}
void main()
{
long Q = scanElem;
bool[] prime;
prime.length = 10^^5+1;
foreach(n; primes(10^^5))
{... | D |
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
std.functional, std.container, std.typecons;
void main() {
auto input = readln.split.to!(ulong[]);
ulong L = input[0], R = input[1];
int ans = int.max;
ulong end = L + min(R - L, 2019) + 1;
foreach(i; L..(end - 1)) {
foreach(j... | 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;
string s;
scan(N);
scan(s);
auto r = new ... | 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 = readln.chomp.to!int;
auto b = readln.chomp.to!int;
aut... | 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();
long bignum... | D |
import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm, std.typecons;
void main(){
int[4] m;
foreach(immutable int i; 0 .. 3) {
auto buf = readln().strip().split().map!(to!int)();
m[buf[0]-1] ++;
m[buf[1]-1] ++;
}
foreach(immutable i; m) {
... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
string s = readln.chomp;
int scount;
int tcount;
foreach(c; s){
if(c == 'S') scount += 1;
else{
if(scount > 0) scount -= 1;
else tcount += 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;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_00... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.exception;
long x, y; rd(x, y);
if(x==y) writeln(-1);
else if(x<y) writeln(x);
else writeln(x%y==0 ? -1 : x);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.leng... | 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 f = false;
foreach (i; 1..n+1) {
auto d = ... | 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 n; readV(n);
int[int] h;
foreach (_; 0..n) {
int a; readV(a);
h[a]++;
}
... | D |
import std.stdio, std.string, std.conv;
bool isPrime(int x) {
if (x < 2) return false;
if (x == 2) return true;
if (x % 2 == 0) return false;
for (int i = 3; i * i <= x; i += 2) {
if (x % i == 0) return false;
}
return true;
}
void main() {
int n = readln.chomp.to!int;
int cnt ... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
class Process{
private:
string _name;
int _time;
public:
@property{
string name() const { return _name; }
int time() const { return _time; }
}
this(string n, int t){
_name = n;
_time = t;
}
void print(int t) {
w... | 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;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
void main(){
long h = read.to!long;
long w = r... | 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[] aryread(T = long)(){return r... | D |
void main() {
int n = readln.chomp.to!int;
int people;
foreach (i; 0 .. n) {
int[] tmp = readln.split.to!(int[]);
int l = tmp[0], r = tmp[1];
people += r - l + 1;
}
people.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm... | D |
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
void main()
{
readln()[0].write;
readln()[1].write;
readln()[2].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 |
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() {
while (1) {
auto x = readln.chomp.split;
if (x[1] == "?") break;
if (x[1] == "+") writeln(x[0].to!... | 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() {
string s;
scan(s);
int n = s.length.to!int;
auto tp =... | 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;
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();
// writeln(a);
lon... | 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 |
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 s = readln.chomp.map!(to!char).array;
auto k = readln.chomp.to!int;
foreach (... | 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()
{
readln.chomp.count!(x=>x=='1').writeln;
}
| D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.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;
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;
void main() {
readln;
readln.split.reverse.join(" ").writeln;
} | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
void main() {
auto N = readln.chomp.to!int;
auto A = new int[][](N, N);
foreach (i; 0..N) A[i][] = -1;
for... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int c = 0;
while(true){
auto s = split(readln());
int a = to!int(s[0]);
int b = to!int(s[1]);
if(a==0&&b==0) break;
bool ifna = true;
if(c)
writeln("");
c++;
for(int i=a;i<=b;i++){
bool... | 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 n, k;
scan(n, k);
writeln(k * (k - 1) ^^ (n - 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;
import std.conv;
import std.array;
void main()
{
auto reader = readln.split;
int A = reader[0].to!int;
int B = reader[1].to!int;
int T = reader[2].to!int;
writeln(T / A * B);
}
| D |
void main()
{
long k = rdElem - 1;
long[] a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
a[k].writeln;
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
return readln.chomp.to!T;
}
alias rdStr... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
std.typecons, std.container, std.format;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.c... | D |
import 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[] aryread(T = long)(){return r... | D |
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outb... | D |
import std.stdio, std.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.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, 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 |
import std;
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line =... | 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) {
auto line = input.map!(a => a.to!int - '0').array;
while (line.length > 1) {
for (int i = 0; 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.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() {
long[] tmp = readln.split.to!(long[]);
long a = tmp[0], b = tmp[1], x = tmp[2];
writeln(b / x - (a == 0 ? -1 : (a - 1) / x));
}
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.conta... | 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 s = readln.split.map!(to!int);
auto N = s[0];
auto X = s[1] - 1;
auto Y = s[2] - 1;
... | 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 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 |
void main() {
problem();
}
void problem() {
const N = scan!long;
const K = scan!long;
long solve() {
long ans;
long[long] counts;
long minimal = 0;
long maximam = N;
foreach(i; 1..N+2) {
counts[i] = maximam - minimal + 1;
minimal += i;
maximam += (N - i);
}
fore... | D |
import std.stdio, std.string, std.conv, std.math, std.regex;
void main()
{
auto n = readln.split.to!(int[]);
if(abs(n[1] - n[0]) < abs(n[2] - n[0])){
writeln('A');
} else {
writeln('B');
}
} | D |
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;
void main()
{
auto s = readln.... | D |
import std;
bool calc(int k, int a, int b) {
// return a <= b / k * k;
return (a + k - 1) / k * k <= b;
}
void main() {
int k; scan(k);
int a, b; scan(a, b);
writeln(calc(k, a, b) ? "OK" : "NG");
}
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t... | 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()
{
char[] S = readln.strip.to!(char[]);
auto a = S[0..2].to!int;
auto b = S[2..4].to!int;
;
bool... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
void main() {
auto value =[6, 4, 3, 2];
foreach (i; 0..4) {
auto a = readln.split.map!(to!int);
writeln(value[a[0]-1] * a[1] * 1000);
}
} | 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)... | 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.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()
{
auto r = -1;
foreach (i; 1..11) ... | D |
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
string n;
scan(n);
if (n[0 .. 3].to!int % 111 == 0 || n[1 .. 4].to!int % 111 == 0) {
writeln("Yes");
}
else {
writeln("N... | 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() {
int n, m;
scan(n, m);
writeln(n == m ? "Ye... | D |
import std.algorithm, std.stdio, std.range;
int N;
immutable W = 10, M = 12;
immutable dy = [-2,-2,-2,-1,-1,0,0,1,1,2,2,2], dx = [-1,0,1,-2,2,-2,2,-2,2,-1,0,1];
immutable ddy = [-1,-1,-1,0,0,0,1,1,1], ddx = [-1,0,1,-1,0,1,-1,0,1];
int[] ys, xs;
void main(){
for(;init;){
writeln(solve ? "OK" : "NA");
}
}
bool ini... | 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() {
string s;
scan(s);
int n = s.le... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
void main()
{
auto nums = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6];
int n;
scanf("%d", &n);
int len = n / 2;
while (len > 0)
{
foreach_reverse (i; 0..10)
if ((len - 1) ... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
string s = readln.chomp;
long ans;
for(long x = 0; x < 2 ^^ (s.length - 1); x ++){
long a = 0, tmp = ("" ~ s[0]).to!long;
for(int i = 0; i < s.leng... | D |
import core.stdc.stdio;
import std.stdio;
void main(){
int n;
scanf("%d",&n);
char[] buf = new char[n+1];
scanf("%s",buf.ptr);
buf = buf[0..n];
bool[] used = new bool[n];
int[] op = new int[n];
bool Solve(char[] data,int c){
used[] = false;
int ic=n;
int a;
for(int i=n-1;i>=0;i--)
if(a<c&&data[i]=='... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
string s; rd(s);
if(s.length<4){writeln("No"); return;}
auto t="YAKI";
foreach(i; 0..t.length){
if(s[i]!=t[i]){writeln("No"); return;}
}
writeln("Yes");
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=... | 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 N = readln.chomp.to!int / 2;
auto S = readln.chomp;
auto T = S[0..N];
writeln(T ~ T == S ? "Yes" : "No");
}
| 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 s = readln.chomp.to!int;
int an = s;
int[int] cnt;
foreach (i; 2..1_000_0... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
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*K+(N-K)*Y);
}
else writeln(N*X);
} | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
auto N =readln.chomp.to!int;
auto A =readln.chomp.to!int;
writeln(N*N-A);
} | D |
import std.stdio;
import std.array;
import std.conv;
void main()
{
while (1) {
auto input = to!(int[])(split(readln()));
int total = input[0] + input[1];
if (input[0] == -1 && input[1] == -1 && input[2] == -1) break;
if (input[0] == -1 || input[1] == -1) {
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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void main()
{
auto S = readln.chomp;
if (S == "RRR") {
writeln(3);
} else if (S == "SRR" || S == "RRS") {
writeln(2);
} else if (S == "SSS") {
writeln... | D |
#!/usr/bin/rdmd
import std.stdio;
void main()
{
foreach(i ; 1..10)
foreach(j ; 1..10)
writeln(i, "x", j, "=", i*j);
} | D |
void main(){
int a, b;
char op;
scanf("%d %c %d", &a, &op,&b);
writeln(op=='+'?a+b:a-b);
}
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 |
void main() {
int n = readln.chomp.to!int;
string s = readln.chomp;
int x, xmax;
foreach (c; s) {
if (c == 'I') ++x;
else --x;
xmax = max(xmax, x);
}
xmax.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.... | 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!long;
long res;
foreach (i; 1..n+1) {
auto x = (i.to... | D |
import std.stdio, std.string, std.conv, std.ascii, std.array;
void main()
{
foreach(_; 0 .. readln.chomp.to!int)
{
line = readln.chomp;
add.writeln;
}
}
string line;
int add()
{
int lhs = mul;
loop:
while(true)
{
switch(line[0])
{
case '+... | D |
import std.stdio;
void main(string[] args) {
int n;
int[1440] time;
scanf("%d", &n);
for ( int i = 0; i < 1440; i++ ) {
time[ i ] = 0;
}
int h, m;
for ( int i = 0; i < n; i++ ) {
scanf("%d:%d", &h, &m);
time[h*60+m] = 1;
}
int mm=0;
int cur=0;
int cur1=0;
int t ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nmk = readln.split.to!(int[]);
auto N = nmk[0];
auto M = nmk[1];
auto K = nmk[2];
foreach (y; 0..N+1) {
foreach (x; 0..M+1) {
if (x*y + (M-x)*(N-y) == K) {
... | 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 x = readln.chomp.replace(" ", "").to!int;
auto y = sqrt(x.to!double);
if ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto s = readln.chomp;
auto cnt = 0;
char last = s[0];
foreach (c; s[1..$]) {
if (c != last) {
++cnt;
last = c;
}
}
writeln(cnt);
} | 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() {
int i;
while (1) {
auto n = readln.chomp.to!int;
if (!n) break;
writeln("Case ", ++i, ": ", n);... | D |
void main() {
int n = readln.chomp.to!int;
writeln(n / 1000 ? "ABD" : "ABC");
}
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.uni; | D |
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
string[] ss = readln.split;
foreach (i, ref arg ; args) ar... | D |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 17