code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.string;
void main() {
auto ar = readln.chomp.split(" ");
auto a = ar[0];
auto b = ar[1];
auto c = ar[2];
if (a == b && b == c) {
writeln("No");
return;
}
if (a != b && a != c && b != c) {
writeln("No");
return;
}
writeln("Yes");
}
| D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
foreach(s;stdin.byLine())
{
int[] a;
foreach(c;s) a~=c-'0';
foreach_reverse(i;1..a.length)
foreach(j;0..i) a[j]=(a[j]+a[j+1])%10;
writeln(a[0]);
}
} | D |
import std.stdio, std.string, std.conv, std.range, std.algorithm;
void main() {
auto s = readln.chomp;
char[] line;
foreach (c; s) {
if (c == 'B' && line.length > 0) {
line = line.dropBackOne;
} else if (c == '0' || c == '1') {
line ~= c;
}
}
line.writeln;
}
| D |
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
immutable int mod = 998_244_353;
void main ()
{
string s;
while ((s = readln.strip ()) != "")
{
auto t = readln.strip;
auto n = s.length.to !(int);
auto m = t.length.to !(int);
auto f = new in... | 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 core.stdc.stdio;
int main(string[] argv)
{
int n,l,tmp;
scanf("%d", &n);
int [] a = new int[n+5];
for(int i = 0; i<n; i++)
scanf("%d", &a[i]);
for(int i=0;i<n;i++)
{
if (i==0||a[i]==a[i-1])
l = i + 1;
else break;
}
tmp = l;
for(int i=0; i<n; i++)
{
if (i==0||a[i]!=a[... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1], c = tmp[2];
writeln(a + b >= c ? "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 ... | 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 |
module main;
import core.stdc.stdio;
import std.algorithm;
int main(string[] argv)
{
int n, ans = 0;
scanf("%d", &n);
int[] t = new int[n];
for (int i = 0; i < n; ++i) {
int h, m;
scanf("%d:%d", &h, &m);
t[i] = 60*h+m;
}
if (n == 1) {
puts("23:59");
retur... | D |
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void main()
{
int n = readln.chomp.to!int;
int[int] cnt;
foreach (a; readln.chomp.spl... | D |
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.ascii, std.regex, std.conv, std.stdio, std.typecons;
void main()
{
auto s = readln.chomp;
auto p = readln.chomp;
foreach (i; 0..s.length)
if ((s[i... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main() {
string s = readln.chomp;
string odd, even;
foreach (i, x; s) {
if (i % 2) even ~= x;
else odd ~= x;
}
writeln(odd.count('L') || even.count('R') ? "No" : "Yes");
} | D |
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.functional;
void main() {
readln.split.to!(int[]).pipe!(input => writeln(min(input[0] * input[1], input[2])));
}
| D |
import std.stdio;
import std.array;
import std.conv;
void main() {
string[] input=split(readln());
int N=to!int(input[0]);
int A=to!int(input[1]);
int B=to!int(input[2]);
int ans=0;
for(int i=1;i<=N;i++) {
int sum=0;
int j=i;
while(j>0) sum+=j%10,j/=10;
if(A<=sum&&sum<=B) ans+=i;
}
write... | 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 ab=readln.split.map!(to!int).map!"a==1?999:a".array;
if(ab[0]==ab[1]) writeln("Draw");
else if(ab[0]<ab[1]) writeln(... | D |
void main() {
int n = readln.chomp.to!int;
int[] p = new int[n];
foreach (i; 0 .. n) {
p[i] = readln.chomp.to!int;
}
writeln(p.sum - p.reduce!max / 2);
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import s... | D |
import std.stdio, std.conv, std.string, std.math, std.algorithm;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] + ip[1] < 24) (ip[0] + ip[1]).writeln;
else (ip[0] + ip[1] - 24).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 File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() ... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
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.c... | 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.conv;
import std.algorithm;
import std.range;
import std.string;
void main() {
foreach (char[] line; stdin.lines) {
if (line == "-\n") break;
char[] s = line.chomp;
int i = readln.chomp.to!int;
for (int x = 0; x < i; x++) {
int n = readln.chomp.to!int;
s = s... | D |
import std.stdio, std.string, std.conv;
void main() {
auto x = readln.chomp.to!ulong;
auto ans = x / 11;
x -= ans * 11;
ans *= 2;
if (0 < x && x <= 6) ans += 1;
else if (x > 6) ans += 2;
writeln(ans);
} | 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;
}
string calc(string s, string t) {
bool match(in... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
int n;
scanf("%d\n", &n);
auto s = readln.chomp;
auto cache = '\n';
size_t cnt;
foreach(c; s) {
if (c != cache) {
cache = c;
++cnt;
}
}
cnt.write;
}
| D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto X=readln.chomp.to!int;
auto A=readln.chomp.to!int;
auto B=readln.chomp.to!int;
writeln((X-A)%B);
} | 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, 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 t;
scan(t);
while (t--) {
int a, b, c;
... | 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 |
void main() {
problem();
}
void problem() {
auto a = scan;
long solve() {
long ans;
long count;
foreach(c; a) {
if (c == 'R') {
count++;
if (ans < count) ans = count;
} else {
count = 0;
}
}
return ans;
}
solve().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.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 |
import std.stdio, std.algorithm, std.range, std.conv;
void main(){
iota(1, 10).map!(a => iota(1, 10).map!(b => text(a, "x", b, "=", a*b)).join("\n")).join("\n").writeln;
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
auto ab = readln.split.to!(int[]);
writeln(ab[0] + ab[1] == 15 ? "+" : ab[0] * ab[1] == 15 ? "*" : "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, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto X = readln.chomp.to!long;
long r;
r += X/500 * 1000;
X -= X/500 * 500;
r += X/5 * 5;
writeln(r);
} | D |
//aoj10018
import std.stdio;
import std.ascii;
void main()
{
char c;
dchar c1;
while(1)
{
scanf("%c", &c);
if(c == '\n') break;
if(isLower(c) != 0) c1 = toUpper(c);
else if(isUpper(c) != 0) c1 = toLower(c);
else c1 = c;
write(c1);
}
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;
long powmod(long a, long x, long m) {
long ret = 1;
while (x) {
if (x % 2) ret = ret * a % m;
a = a * a % m;
... | 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.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 std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.container, std.math;
immutable int mod = 10^^9 + 7;
int x1, y1, x2, y2;
int x, y;
void main() {
readVariables(x1, y1, x2, y2);
readVariables(x, y);
if ((x2 - x1) % x || (y2 - y1) % y) {
writeln("NO");
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln(readln.chomp.to!int^^2);
} | 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;
import core.bitop : popcnt;
alias Generator ... | 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;
scan(N);
auto a = readln.split.to!(int[]);
auto... | 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 |
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array;
void main() {
string s = readln.chomp;
if(s[0]==s[1] && s[1]==s[2]) writeln("No");
else writeln("Yes");
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
string[100] WS;
bool[string] MEMO;
void main()
{
auto N = readln.chomp.to!int;
foreach (i; 0..N) {
WS[i] = readln.chomp;
}
char c = WS[0][0];
foreach (w; WS[0..N]) {
if (c != w[0] || w in MEMO... | 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 = readln();
int cnt = 0;
foreach (elem; s) {
if(elem == '1') cnt++;
}
writeln(cnt);
}
| 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.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
void main()
{
while (1) {
auto x = readln.chomp.to!int;
if (!x) break;
int cnt;
while (x != 1) {
if (x % 2) x = x * 3 + 1;
else x /=... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
int i = 1;
while(1){
int a = readln().chomp().to!int();
if(a == 0)
break;
writeln("Case ", i, ": ", a);
i++;
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(int[]);
writeln(max(ab[0] + ab[1], ab[0] - ab[1], ab[0] * ab[1]));
} | D |
import std.stdio, std.math;
void main(){
int n, m;
immutable mod = cast(long)(1e9 + 7);
scanf("%d%d", &n, &m);
auto Cs = new int[][](m,2), idxToC = new int[][](n+1, 2);
auto appear = new int[](n+1);
foreach(i; 0..m){
scanf("%d%d", &Cs[i][0], &Cs[i][1]);
foreach(j; 0..2){
int x = abs(Cs[i][j]);
idxToC[... | 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;
import std.typecons;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
... | 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 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 |
import std.array, std.conv, std.stdio, std.string;
void main()
{
auto buf = readln.chomp.split.to!(int[]);
((buf[0] * 500 >= buf[1]) ? "Yes" : "No").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;
void main() {
auto S = readln.chomp;
auto N = S.length.to!int;
auto next = new int[][](26, N);
foreach (i; 0..26) fill(next... | D |
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);
if (n % 2 == 0)
{
writeln(n / 2);
}
else
{
writeln(n / 2 + 1);
}
}
void scan(L...)(ref ... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
void main() {
int N = readln.chomp.to!int;
auto cards = readln.chomp.split;
auto cards2 = cards.dup;
string b = cards.bubbleSort.join(" ");
b.writeln;
"Stable".writeln;
string s = cards2.selectionSort.join(" ");
... | D |
void main() {
string s = readln.chomp;
int n = s.to!int;
int m;
foreach (x; s) {
m += x -'0';
}
writeln(n % m == 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;
impo... | D |
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
string RD() { 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 % mod)) % m... | D |
void main()
{
string s = rdStr;
long len = s.length;
foreach (i; 0 .. len)
{
'x'.write;
}
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 = rdElem!string;
alias rdDchar = rdElem!(... | D |
import std.string;
import std.stdio;
import std.algorithm;
void main() {
auto s = readln.chomp.dup;
auto t = readln.chomp.dup;
if (t.length < s.length) {
swap(s, t);
}
auto dp0 = new char[][s.length + 1];
auto dp1 = new char[][s.length + 1];
foreach (ref e;dp0) {
e = new char[0];
}
dp1[0] = new char[0];... | D |
void main() {
auto S = rs;
string s;
foreach(i; 1..6) {
s ~= "hi";
if(S == s) {
writeln("Yes");
return;
}
}
writeln("No");
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
i... | D |
import std.stdio, std.string, std.conv, std.algorithm;
void main(string[] args) {
auto x = readln().chomp;
foreach(int i, char c; x){
if(i%2==0){c.write;}
}
writeln;
} | 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;
const days = [0,31,28,31,30,31,30,31,31,30,31,30,31];
void main()
{
auto rd = readln.split.to!(int[]), x = rd[0], y = rd[1];
writeln(days[x] == days[y] ? "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.container;
import std.datetime;
void main()
{
while (1) {
auto x = readln.chomp.split.map!(to!int);
if (x[0] == 0 && x[1] == 0) break;
foreac... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
void main() {
(readln.chomp.to!int / 3).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() {
immutable long MAX = 2*10^^6+1;
immutable long MOD = 10^^9+7;
auto modinv = new long[](MAX);
... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n, k; rd(n, k);
auto x=new long[](n), y=new long[](n);
foreach(i; 0..n) rd(x[i], y[i]);
long mn=5_000_000_000_000_000_000;
foreach(i1; 0..n)foreach(i2; (i1+1)..n){
foreach(j1; 0..n)foreach(j2; (j1+1)..n){
auto x1=x[i1], x2=x... | 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.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 t = readln.split;
auto N = t[0].to!int;
auto L = t[1].to!long;
auto S = N.iota.map!(_ => re... | D |
import std.stdio,std.array,std.conv,std.string;
void main(){
int n=readln().chomp().to!int;
string k=to!string(n);
int m=0;
for(int i=0;i<k.length;i++){
m+=to!int(k[i])-48;
}
if(n%m==0) writeln("Yes");
else writeln("No");
} | D |
import std.stdio;
import std.string;
import std.conv;
void main()
{
int[] a = readln.chomp.split.to!(int[]);
if (a[0] <= 8 && a[1] <= 8) {
writeln("Yay!");
}
else {
writeln(":(");
}
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
enum DREAM = "dream";
enum DREAM_CNT = DREAM.length;
enum DREAMER = "dreamer";
enum DREAMER_CNT = DREAMER.length;
enum ERASE = "erase";
enum ERASE_CNT = ERASE.length;
enum ERASER = "eraser";
enum ERASER_CNT = ERASER.length;
void main()
{
auto 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto abc = readln.split.to!(int[]);
auto d = abc[0] + abc[1] + abc[2];
writeln(d + max(abc[0], abc[1], abc[2]) * 9);
} | D |
import std.stdio;
import std.conv;
import std.string;
void main() {
auto n = readln.chomp.to!(int);
auto ans = 0;
if (n / 100 == 9)
ans += 100;
else
ans += 900;
if (n % 100 >= 90)
ans += 10;
else
ans += 90;
if (n % 10 == 9)
ans += 1;
else
... | D |
void main() {
string b = readln.chomp;
b == "A" && "T".writeln;
b == "T" && "A".writeln;
b == "C" && "G".writeln;
b == "G" && "C".writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import ... | 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.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 S = readln.chomp;
auto dp = new bool[][][][](N+1, 11, 11, 11)... | 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.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 |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto a = readln.chomp;
auto b = readln.chomp;
auto s = max(a.length, b.length);
auto a2 = a.rightJustify(s, '0');
auto b2 = b.rightJustify(s, '0');
if (a2 == b2)
writeln("EQUAL");
else if (a2 < b2)
writeln("LESS");
... | 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();
long ans = long.max;
// foreach (i; 1 .. (... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto xs = readints();
int a = xs[0], b = xs[1], c =... | 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 |
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio, core.bitop;
// foreach, foreach_reverse, writeln
void main() {
int n, MOD;
scanf("%d%d", &n, &MOD);
long[][] c = new long[][](n+1,n+2);
c[0][0] = 1;
foreach (i; 0..n) {
foreach (j; 0..i+1) {
(c[i+1][j] += c[... | D |
void main() {
int k = readln.chomp.to!int;
writeln(k / 2 * ((k + 1) / 2));
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons; | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.math;
int n, d; rd(n, d);
auto t=new long[](n);
auto f=new long[](n);
foreach(i; 0..n) rd(t[i], f[i]);
long sm=0, pos=1, tm=0, m=0;
foreach(i; 0..n){
if(tm+(pos-1)+(f[i]-1)<=t[i]){
sm+=m*(pos-1);
m=1;
}e... | D |
import std.stdio;
import std.conv;
import std.array;
import std.string;
import std.algorithm;
void main() {
string S;
S = chomp(readln());
string res = "";
if(S[0] == '9' || S[1] == '9') {
res = "Yes";
}
else{
res = "No";
}
writeln(res);
}
| D |
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
bool isPalindrome(string s) {
int n = cast(int)s.length;
for (int i = 0; i < n/2; i++) {
if (s[i] != s[$-i-1]) ... | D |
void main() {
int n = readln.chomp.to!int;
int[] a = new int[n];
foreach (i; 0 .. n) {
a[i] = readln.chomp.to!int;
}
bool[] light = new bool[n];
light[0] = true;
int now = a[0];
int cnt;
while (!light[1]) {
if (light[now-1]) {
cnt = -1;
break;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto a=readln.chomp.to!int;
auto b=readln.chomp.to!int;
auto h=readln.chomp.to!int;
writeln((a+b)*h/2);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
auto P = 10L^^9+7;
long[100][5][5][5] MEMO;
void main()
{
auto N = readln.chomp.to!int;
foreach (ref xx; MEMO) foreach (ref yy; xx) foreach (ref zz; yy) foreach (ref memo; zz) memo = -1;
long solve(in... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
void get(Args...)(ref Args args)
{
import std.traits, std.meta, std.typecons;
static if (Args.length == 1) {
alias Arg = Args[0];
static if (isArray!Arg) {
... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
import std.numeric;
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... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.