code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
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.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
auto readInts() {
return array(map!(to!int)(readln().strip().split... | 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.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 D = S.map!(c => c == 'D').sum;
auto... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
long a, b, c, x, y; rd(a, b, c, x, y);
if(a+b<c*2){
writeln(x*a+y*b);
}else{
auto z=min(x, y),
ret=z*c*2;
x-=z; y-=z;
// writeln(ret);
if(x>0){
ret+=x*min(a, c*2);
}else if(y>0){
ret+=y*min(b, c*2)... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!int;
auto f = new int[](n);
foreach (i; 0..n) f[i] = readln.split.to!(int[]).toBit;
auto p = new int[][](n, 11);
foreach (i; 0..n) p[i] = readln.split.to!(int[]);
auto ans = long.min;
foreach (i; 1..... | D |
void main()
{
long a, b;
rdVals(a, b);
foreach (i; 1 .. 10001)
{
long x = i * 8 / 100;
long y = i * 10 / 100;
if (x == a && y == b)
{
i.writeln;
return;
}
}
writeln(-1);
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T ... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void main()
{
string[] c; re... | D |
/+ dub.sdl:
name "D"
dependency "dcomp" version=">=0.6.0"
+/
//ICPC Bangkok Regional 2016 F
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
auto sc = new Scanner(stdin);
int n;
sc.read(n);
int[][] g = new int[][](n);
foreach (i... | D |
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void main(){
auto ip = readln.split.to!(int[]);
if(ip[0] > ip[2])... | 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, d;
scan(n, d);
long cnt;
foreach (_; 0 .. n)
... | 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 n; readV(n);
auto f = new i... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
void main()
{
auto len = readln.chomp.to!long;
auto as = readln.split;
string[] ret;
ret.length = len;
size_t p = len / 2;
auto v = len & 1 ? 1 : -1;
foreach (i, a; as) {
v = -v;
p += i * v;
ret[p] =... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto M = readln.chomp.to!int;
long b = 0, res;
foreach (_; 0..M) {
auto dc = readln.split.to!(long[]);
int d = dc[0].to!int;
auto c = dc[1];
int[] at;
... | D |
import std.stdio;
import std.string;
import std.array;
import std.range;
import std.algorithm;
import std.conv;
import std.typecons;
long solve(long d, long n){
if(n != 100){
return 100 ^^ d * n;
}else{
return 100 ^^ (d+1) + 100 ^^ d;
}
}
void main(){
auto dn = readln().chomp().split()... | D |
void main() {
auto b = rs;
switch(b) {
case "A": writeln("T"); break;
case "T": writeln("A"); break;
case "G": writeln("C"); break;
case "C": writeln("G"); break;
default: break;
}
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
i... | 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.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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!long;
writeln(N * (N-1) / 2);
} | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
void main()
{
int X, Y, r;
auto input = readln.split.to!(int[]);
X = input[0];
Y = input[1];
while(X%Y)
{
r = X%Y;
X = Y;
Y = r;
}
writeln(Y);
}
| D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int n = readln.chomp.to!int;
if (n == 1){
"Hello World".writeln;
return;
}
int a = readln.chomp.to!int;
int b = readln.chomp.to!int;
(a + b).writeln;
}
| 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(){
long[] ds = readln.chomp.split.map!(to!long).array;
long a = ds[0], b = ds[1], c = ds[2];
long ans;
if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) ans = 0;
... | D |
void main() {
int n = readln.chomp.to!int;
writeln(n * (n + 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.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni; | D |
void main()
{
int n = readln.chomp.to!int;
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
int[] p = readln.split.to!(int[]);
int p1, p2, p3;
foreach (x; p)
{
if (x <= a) ++p1;
if (a + 1 <= x && x <= b) ++p2;
if (x >= b + 1) ++p3;
}
min(p1, ... | 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 a, b, c, d;
scan(a, b, c, d);
auto tmp = new long[](100... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;
void main(){
int ans=0;
while(true){
auto s = readln();
if(stdin.eof()) break;
s = chomp(s);
int len = to!int(s.length);
int l,r;
if(len%2==1){
l = len/2 - 1;
r = len/2 + 1;
}else{
l = len/2 - 1;... | 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 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;
void scan(T...)(ref T a) {
string[] ss = readln.split;
foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return read... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.7.3"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
int n;
sc.read(n);
int[] g = new int[n];
foreach (i; 0..n-1) {
int a, b, z;
... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
auto s = readln().chomp().to!(char[]);
reverse(s);
writeln(s);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto S = readln.chomp.to!(dchar[]);
sort(S);
writeln(S == "abc" ? "Yes" : "No");
} | D |
// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio : readln, writeln;
import std.string : chomp;
import std.array : split;
import std.conv : to;
import std.bigint : BigInt;
auto gets() { return readln.chomp; }
auto getV(T)() { return gets.to!T; }
auto getVals(T)() { return ge... | D |
import std.stdio, std.string, std.algorithm, std.conv, std.range, std.math;
void main() {
auto p = readln.chomp.split.map!(to!double);
auto ans = sqrt(pow(p[2] - p[0], 2) + pow(p[3] - p[1], 2));
printf("%.8lf\n", ans);
} | 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() {
long n, a, b;
scan(n, a, b);
if (n == 1)... | D |
void main(){
string n = readln().chomp();
writeln(n.count('9')==0? "No": "Yes");
}
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()... | 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 a, b, c, d;
scan(a, b, c, d);
max(a * c, b * c, a * d, ... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
immutable N = 8;
immutable n = readln().chomp().to!int();
foreach(i;0..n)
{
readln();
auto m = iota(N).map!(_=>readln.chomp().to!(char[])()).array();
immutable x = readln().chomp().... | 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[] lreads(T = long)(long n){ret... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 998244353L;
long[(10^^5)*3+50] 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 inv(... | 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;
import std.bigint;
import std.container;
bool isConnected(int[26][] c) {
bool[26] appear;
foreach(i; 0..26) {
foreach(j; 0..26) {
if(c[i][j]) {
... | 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);
aut... | D |
void main() {
auto N = ri;
pow(2, log2(N).to!int).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import s... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln(readln.chomp[0..$-8]);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
readln;
auto ws = readln.split.to!(int[]);
int ret, l, r;
foreach (w; ws) r += w;
ret = abs(l-r);
foreach (w; ws) {
r -= w;
l += w;
ret = min(ret, abs(l-r... | D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
void main() {
auto a = readln.split.map!(to!int);
if (a[0] >= a[1]) {
writeln("No"); return;
}
if (a[1] >= a[2]) {
writeln("No"); return;
}
writeln("Yes");
} | D |
import std.stdio, std.conv, std.array,std.string;
void main()
{
string[] input=readln.split;
int a=input[0].to!int,b=input[1].to!int;
writeln((a-1)*(b-1));
} | D |
import std.stdio, std.string, std.conv, std.math, std.algorithm, std.range;
// indexから始めるstringのstartIndexを返す
ulong calculateIndex( ulong index ) {
index--;
ulong sum = 0;
ulong sumNumDiv3 = 0;
ulong sumNumDiv5 = 0;
ulong sumNumDiv15 = 0;
ulong digit = 1;
while ( 10 ^^ digit < index ) {
immutable ulong ... | D |
import std.stdio;
import std.string;
char[8][8] ch;
void main(){
foreach (i; 0..8) ch[i] = chomp(readln());
for (int i = 1; i <= 3; i++) {
rotate();
writeln(i*90);
print();
}
}
void rotate(){
char[8][8] tmp;
foreach (i; 0..8)
foreach (j; 0..8)
tmp[i][j] = ch[7-j][i];
foreach (i; 0..8)
foreach (j; ... | D |
import std.algorithm,
std.string,
std.array,
std.stdio,
std.range,
std.conv;
void main() {
int[] AB = readln.chomp.split.to!(int[]);
int A = AB[0],
B = AB[1];
writeln([(A % 3), (B % 3), ((A + B) % 3)].any!(x => x == 0) ? "Possible" : "Impossible");
}
| 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 hw = readln.split.to!(int[]);
auto H = hw[0];
auto W = hw[1];
auto M = new int[][](H, W);
foreach (i; 0..H) foreach (j, a; readln.split.to!(int[])) M[... | 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 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 |
void main()
{
long n = readln.chomp.to!long;
bool[] cards = new bool[n];
long pair;
foreach (i; 0 .. n)
{
long a = readln.chomp.to!long;
if (i > 0 && cards[i-1] && a > 0)
{
++pair;
--a;
}
pair += a / 2;
cards[i] = a % 2 == 1;
... | D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
import std.stdio, 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.array;
import std.string;
import std.algorithm;
string[char] next;
static this() {
next = [
'A': "BD",
'B': "ACE",
'C': "BF",
'D': "AEG",
'E': "BDFH",
'F': "CEI",
'G': "DH",
'H': "EGI",
'I': "FH"
];
}
bool movable(cha... | 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 |
void main() {
problem();
}
void problem() {
auto N = scan!int;
string solve() {
int hon, pon, bon;
int n = N % 10;
if (n == 3) {
return "bon";
}
if (n == 0 || n == 1 || n == 6 || n == 8) {
return "pon";
}
return "hon";
}
solve().writeln;
}
// ---------------------... | D |
void main() {
auto K = ri;
auto S = rs;
if(S.length <= K) writeln(S);
else {
writeln(S[0..K] ~ "...");
}
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import... | 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.string;
import std.array; // split
import std.conv; // to
void main()
{
string n = chomp(readln());
int a = to!int(n);
if(a%10 == a/100){
writeln("Yes");
} else {
writeln("No");
}
} | D |
/+ dub.sdl:
name "F"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.datastructure.lazyseg;
int main() {
auto sc = new Scanner(stdin);
int n, m;
sc.read(n, m);
int[] l = new int[n], r = ne... | 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; }
class X{
}
void main(){
// A=1、B=2として、区間の合... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
void main()
{
auto input = split(readln());
auto N = to!int(input[0]);
long aM, aA, aR, aC, aH; // the number of the names that starts with ...
foreach(i; 0..N) {
auto S = split(readln())[0];
aM += (S[0] == 'M'? 1 ... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
void main() {
long a, b, c;
scan(a, b, c);
auto ans = b;
if (a + b... | D |
/* imports all std modules {{{*/
import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.encoding,
std.exception,
std.file,
std.format,
std.functi... | D |
import std.stdio;
import std.numeric;
import std.math;
import std.algorithm;
import std.string;
import std.container;
import std.typecons;
void log(A...)(A arg) {
stderr.writeln(arg);
}
void main() {
int p, q; scanf("%d %d\n", &p, &q);
q /= gcd(p, q);
int ans = 1;
for (int n = 2; n * n <= q; n++) ... | 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() {
int a = readln.chomp.to!int;
string s = readln.chomp;
writeln(a >= 3200 ? s : "red");
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto kab = readln.split.to!(long[]);
auto K = kab[0];
auto A = kab[1];
auto B = kab[2];
if (K <= A) {
writeln(1);
} else if (A - B <= 0) {
writeln(-1);
} else... | 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[] VS = [0], WS = [0];
foreach (_; 0..N) {
auto vw = readln.split.to!(int[]);
VS ~= vw[0];
WS ~= vw[1];
}
auto Q = readln.cho... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
import std.math;
auto s=readln.chomp.to!(char[]);
char[] t;
foreach(c; s)if(c!='x') t~=c;
bool ok=true;
foreach(i; 0..(t.length/2)) ok&=(t[i]==t[$-i-1]);
if(!ok){writeln(-1); return;}
int cnt=0;
int[] y;
foreach(c; s){
if... | D |
import std.stdio;
void main() {
int n, q;
scanf("%d %d\n", &n, &q);
auto c1 = 'X';
int cnt = 0;
int[] cache = [];
auto s = readln;
foreach (c; s) {
if (c1 == 'A' && c == 'C') {
++cnt;
}
c1 = c;
cache ~= cnt;
}
foreach(_;0..q) {
int l, r;
scanf("%d %d", &l, &r);
writeln(cache[r-1] - cache[l-1]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
enum P = 998244353L;
void main()
{
auto nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
int[] LS, RS;
foreach (_; 0..K) {
auto lr = readln.split.to... | D |
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;
void chmax(T)(ref T a, in T b) {
if (a < b) {
a = b;
}
}
void main() {
auto n = readln.chomp.to!int;
auto a = readln.chomp.split(' ').map!(to!int).array;
l... | 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;
void main(){
auto args = readln().chomp().split();
auto a = to!int(args[0]);
auto b = to!int(args[1]);
writeln( a<b?"a < b":a==b?"a == b":"a > b" );
} | 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 = 10^^9 + 7;
void main() {
int n, k;
scan(n, k);
auto h = readln.split.to!(int[]);
auto dp = new int[](n);
foreach (i ; 1 .. n) {
... | D |
import std.stdio,
std.array,
std.conv;
void main(){
string s;
int i = 0,j = 0;
int[] result;
for(;;){
s=readln();
if(stdin.eof()) break;
result.length += 1;
string[] input = split(s);
int a = to!int(input[0]);
int b = to!int(input[1]);
int k = 0;
int keta = 1;
wh... | 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.split.map!(to!int);
auto N = S[0];
auto K = S[1];
auto A = readln.split.map!(to!long).array;
... | 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 k = readln.chomp.to!int;
auto x = readln.chomp... | D |
void main()
{
string s = readln.chomp;
writeln(
s.canFind('N') == s.canFind('S')
&& s.canFind('W') == s.canFind('E')
? "Yes"
: "No"
);
}
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.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; }
/*
x: i日目にAをするときの最大
y: i日目にB... | D |
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;
string my_readln() { return chomp(readln()); }
void main()
{
auto tokens = split(my_readln());
auto A = to!uint(tokens[0]);
auto B = to!uint(tokens[1]);
auto K = to!uint(tokens[2])... | 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;
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;
enum MAX = 1_000_100;
ulong MOD = 1_000_000_007... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto N = readln.chomp.to!int;
int ret;
foreach (_; 0..N) {
auto lr = readln.split.to!(int[]);
ret += lr[1] - lr[0] + 1;
}
writeln(ret);
} | 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() {
string[] s = readln.split;
foreach (i; 0 .. 3) {
s[i][0].toUpper.write;
}
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;
impo... | 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;
import std.algorithm;
import std.conv;
import std.string;
import std.range;
import std.math;
void main() {
while (true) {
int n = readln.chomp.to!int;
if (n == 0) break;
int[] s;
foreach (i; 0..n) {
s ~= readln.chomp.to!int;
}
writeln(... | D |
import std.stdio;
import std.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;
void main() {
while (true) {
int l = readln.chomp.to!int;
if (l == 0) break;
int[][] ary;
for (int i = 0; i < 12; i++) {
ary ~= readln.chomp.split.map!(to!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()
{
long n, m;
scan(n, m);
auto 色 = new bool[](n);
色[0] = tr... | 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 a = readln.chomp.split.map!(to!int);
auto b = n... | 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;
int[] di = [1,0,-1,0,1,1,-1,-1], dj = [0,1,0,-1,1,-1,1,-1];
int ans;
void main() {
while (1) {
int w, h;
scan(w, h);
if (!w) return;
... | 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.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.algorithm, std.string, std.array;
long seq(int a, int m) {
int cnt = 1;
int x = 1;
while(true) {
x = (a * x) % m;
if (x == 1) break;
else
cnt++;
}
return cnt.to!long;
}
long gcd(long a, long b) {
if (a > b) swap(a, b);
while(true) {
b %= a;
if (b... | 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;
const W = 0;
const B = ... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.