code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto s = readStr;
auto t = readStr;
if(s == t[0 .. $-1]){
wri... | 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()
{
auto x = readln.split.map!(to!int);
auto t = x[1] - 1;
auto tp = readln.split.map!(to!int);
int i;
while (i < tp.length) {
if ... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto tmp = readln.split.to!(long[]);
const H = tmp[0], W = tmp[1];
tmp = readln.split.to!(long[]);
const h = tmp[0], w = tmp[1];
writeln(H * W - (h * W + w * H - h * w));
}
| 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.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 s = readln.chomp;
auto w = ["Sunny", "Cloudy", "Rainy"];
... | 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(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | D |
void main() {
problem();
}
void problem() {
auto X = scan!long;
long solve() {
foreach(t; 1..999_999) {
if (t * X % 360 == 0) return t;
}
return 0;
}
solve().writeln;
}
// ----------------------------------------------
import std.stdio, std.numeric, std.conv, std.array, std.string, std... | D |
import std.stdio;
import std.string;
import std.format;
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.concurrency;
import std.traits;
import std.uni;
import c... | 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 T = readln.chomp;
auto ss = new int[](S.length+1);
foreach (i, c; S) {
ss[i+1] = ss[i];
if (c == 'A') {
ss[i+1] += 1;
} el... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
void main() {
auto N = readln.chomp.to!int;
auto a = ['M': 0, 'A': 1, 'R': 2, 'C': 3, 'H': 4];
auto b = new ulong[](5);
foreach(_; 0..N) {
auto c = readln.chomp[0];
if(c in a) b[a[c]]++;
}
auto A = ... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a,b,c,d;
scan(a, b, c, d);
if (a + b < c + d) {
writeln("Right");
}
else if (a + b > c + d) {
writeln("Left");
}
else {
writeln("Balanced");
}
}
void scan(T... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a,b;
scan(a,b);
writeln(a*b % 2 ? "Odd" : "Even");
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.pri... | 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 o = readln.chomp;
auto e = readln.chomp;
foreach (i; 0..(o.length + e.length... | 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 |
void main() {
int a = readln.chomp.to!int;
int b = readln.chomp.to!int;
int c = readln.chomp.to!int;
int d = readln.chomp.to!int;
writeln(min(a, b) + min(c, d));
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import... | D |
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;
T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
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!(T[]);
}
void main() {
const s = readln;
char prev ... | 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 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.range;
import std.string;
import std.algorithm;
import std.conv;
void main() {
ulong x = readln.chomp.to!ulong;
(x/11*2 + (x%11 <= 6 ? 1 : 2) + (x%11 == 0 ? -1 : 0)).writeln;
} | 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(); } bool DEBUG = 0;
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
voi... | 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;
immutable inf = 10^^9 + 7;
void main() {
int n;
scan(n);
bool[] p = [true, true, false];
foreach (i ; 0 .. n) {
int win;
scan(win);
... | 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 readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFro... | 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;
string s;
void main() {
scan(s);
if (s.canFind('N') == s.canFind('S') && s.canFind('W') == s.canFind('E')) {
... | D |
import std.stdio;
import std.array;
import std.algorithm;
import std.conv;
import std.numeric;
import std.string;
void main() {
auto s = readln.chomp;
auto t = new int[4];
foreach (i, j; s) {
t[i] = j.to!int - '0'.to!int;
}
foreach(i; 0..2) {
foreach(j; 0..2) {
foreach(k; 0..2) {
int a... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ks = readln.split.to!(int[]);
auto K = ks[0];
auto S = ks[1];
int r;
foreach (i; 0..K+1) {
foreach (j; 0..K+1) {
auto k = S - i - j;
if (0 <= k &... | 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() {
long n;
scan(n);
long ans = 100000;
while (n > 0) {
ans = min(ans, abs(753 - n % 1000));
n /= 10;
}
writel... | 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;
scan(N);
int ans;
foreach (i ; 0 .. N) {
int li, ri;
scan(li, ri);
ans += ri - li + 1;
}
writeln(ans);
}
vo... | 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, std.conv, std.range, std.stdio, std.string;
import std.uni; // unicode
void main()
{
auto s = readln.split;
writeln(s.map!"a[0]".array.toUpper);
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
bool check(const char[] arr) {
auto p = arr[0];
foreach (e; arr[1..$]) {
if (p != e) return false;
}
return true;
}
void main()
{
auto s = readln.chomp;
if (check(s)) {
writeln(0);
return;
}
aut... | 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.split.to!(int[]);
auto ab = s[0] * s[1];
auto f = false;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
void main() {
string s = readln.chomp;
int w = readln.chomp.to!(int);
string ans = "";
for (int i = 0; i < s.length; i += w) {
ans ~= s[i];
}
writeln(ans);
}
| D |
import std.conv;
import std.stdio;
import std.array;
import std.range;
import std.string;
import std.algorithm;
void main()
{
int sum = 0;
foreach(_; 0..10) {
sum += readln().chomp().to!int;
}
writeln(sum);
} | 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.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.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto n = readln.chomp.to!int;
writeln("ABC", n);
}
| D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;
void main() {
auto S = readln.chomp.dup;
bool po() {
if (S[0] != 'A') return false;
if (S[2..$-1].count('C') != 1) return false;
foreach (i; 2..S.length-1) {
... | D |
void main(){
char alph = _scan!char();
( ('a'<=alph && alph<='z') ? 'a' : 'A').writeln();
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;
// 1要素のみの入力
T _scan(T= int)(){
return to!(T)( readln().chomp() );
}
// 1行に同一型の複数入力
T[] _scanln(T = int)(){
T[] ln;
foreach(string elm; readln(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto S = readln.chomp.to!(char[]);
int X = 700;
if (S[0] == 'o') X += 100;
if (S[1] == 'o') X += 100;
if (S[2] == 'o') X += 100;
writeln(X);
} | 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.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
void main() {
auto T = readln.chomp.to!int;
auto A = readln.split.map!(to!long).array;
foreach (a; A) {
... | 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;
int p;
bool ok(int s) {
int i = s / 50 % 475;
foreach (_; 0..25) {
i = (i * 96 + 42) % 475;
if (26 + i == p) return... | D |
import std.stdio, std.algorithm, std.conv, std.string;
enum arrow { L,R,U,D };
void main(){
int n = readln.chomp.to!int();
const arrow[dchar] toArrow = [ 'L':arrow.L, 'R':arrow.R, 'U':arrow.U, 'D':arrow.D ];
foreach(i; 0..n){
auto score = readln.chomp.map!(a=>toArrow[a])();
writeln(score.isNatural? "Yes": "No... | 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.stdio, std.conv, std.math, std.string, std.range, std.array,
std.algorithm;
void main(){
auto buf = readln().strip().split().map!(to!int)();
immutable N = buf[0];
auto a = readln().strip().split().map!(to!int)();
long[long] m;
long ans;
long shift;
foreach(ea; a) {
... | 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.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
void main() {
int 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 a, b; readV(a, b);
writeln(a... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto abck = readln.split.to!(long[]);
auto A = abck[0];
auto B = abck[1];
auto C = abck[2];
auto K = abck[3];
long r;
if (K > 0) {
r += min(K, A);
K -= min(K... | D |
void main()
{
long n = rdElem;
long[] a = n.rdCol;
writeln(a.any!"a & 1" ? "first" : "second");
}
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!(dchar[]);
T rdElem(T)(... | 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(){
auto s = readl... | 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;
auto A = readln.chomp.to!long;
auto B = readln.chomp.to!long;
auto C = readln.chomp.to!long;
auto D = readln.chomp.to!long;
auto E = readln.chomp.t... | D |
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_a
import std.algorithm;
import std.math;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
const int n = readln.chomp.to!int;
const int[] h = readln.split.map!(to!int).array;
int[] dp = new int[n];
dp[1] = abs(h... | D |
import std.algorithm;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;
void main() {
auto input = readln.chomp.split.map!(to!long... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
int x = readln().chomp().to!int();
writeln(x * x * x);
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n, k;
scan(n, k);
auto w = new int[][][](2, k, k);
foreach (i ; 0 .. n) {
int xi, yi;
char ci;
scan(xi, yi, ci);
if (ci == 'B') yi += k;
int e = (xi / k % 2 ... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), x = rd[0], t = rd[1];
writeln(max(x-t, 0));
}
| 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 a = aryread!string();
// writeln(a);
writeln(a[0][0], a... | 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.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 core.stdc.stdio;
import std.algorithm;
void main(){
int[] map = new int[100000];
int[] t = new int[10000];
while(1){
int r,c;
scanf("%d%d",&r,&c);
if(r==0&&c==0)
break;
t[] = 0;
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
scanf("%d",&map[i*c+j]);
t[j] += 1-map[i*c+j]... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = (tmp[0] + 13) % 15, b = (tmp[1] + 13) % 15;
if (a > b) {
"Alice".writeln;
} else if (a < b) {
"Bob".writeln;
} else {
"Draw".writeln;
}
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
im... | 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(){
int a, b;
scanf("%d %d", &a, &b);
int ans = (a + b)%24;
ans.writeln();
}
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(T = ... | D |
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
void main(){
int totalTime = 0;
for(int i = 0; i < 4; i++){
totalTime += readln().chomp().to!int();
}
writeln(totalTime / 60);
writeln(totalTime % 60);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
writeln(s[1] == s[2] && (s[0] == s[1] || s[2] == s[3]) ? "Yes" : "No");
}
| 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 y, b, r;
scan(y, b, r);
int ans = 0;
foreach (i ; 1 .. y + 1) {
foreach (j ; 1 .. b + 1) {
foreach (k ; 1 .... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
auto tmp = readln.split.to!(int[]);
writeln(tmp[0] * tmp[1] / 2);
}
| 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()
{
auto N = scanElem;
auto X = scanElem;
auto a = X;
auto b = N-X;
long res = a+b;
if(a>b)... | 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;
writeln(s[0..4], " ", s[4..$]);
}
| 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;
const long MOD = 998244353;
const int INF = 1 << 29;
void main() {
auto N = readln.chomp.to!int;
auto S = N.iota.map!... | 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.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional;
void main(){
(readln().chomp.isHaiku?"YES":"NO").writeln();
}
auto isHaiku(string str){
return ["5 7 5", "7 5 5", "5 5 7"].canFind(str);
}
| D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
const N = readln.chomp.to!long;
const S = readln.chomp;
const K = readln.chomp.to!long;
S.map!(c => c != S[K-1] ? "*" : [c]).join.writeln;
}
| D |
void main(){
int n = _scan();
string s = readln().chomp();
writeln( s[0..n/2] == s[n/2..$]? "Yes": "No" );
}
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(s... | D |
import std.stdio;
import std.conv;
import std.string;
void main(){
// input
int[] input;
for(auto i = 0; i < 3; i++){
input ~= to!int(readln().chomp());
}
immutable int start_money = input[0];
immutable int a_price = input[1];
immutable int b_price = input[2];
immutable int answer = (start_money - a_pric... | D |
import std.stdio: readln, writeln;
import std.string: chomp, split;
import std.conv: to;
void main()
{
auto dataSet = chomp(readln()).split(" ");
int m = to!int(dataSet[0]),
f = to!int(dataSet[1]),
r = to!int(dataSet[2]);
while(1 + m || 1 + f || 1 + r)
{
if(0 == (1 + m) * (1 + f... | 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 data = readln.split;
auto A = data[0].to!long, B = data[1].to!long;
long f(long n) { switch(n%4) {
case 0: return n;
case 1: return 1;
case 2: return 1+... | D |
import std.stdio;
int main(string[] argv)
{
for(int i = 1;i <= 9;i++){
for(int j = 1;j <= 9;j++){
writeln(i,"x",j,"=",i*j);
}
}
return 0;
} | D |
import std.stdio;
void main(string[] args)
{
foreach(int i ; 1..10)
{
foreach(int j; 1..10)
{
writeln(i,"x",j,"=",i*j);
}
}
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.regex;
void main(){
auto z=readln.split.to!(int[]),a=z[0],b=z[1];
writeln(a*b-(a+b-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() {
int x;
scan(x);
auto ans = (x / 500) * 1000 + (x % 500) / ... | 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.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv,
std.format,
std.math;
void main()
{
auto n = readln.chomp.to!int;
... | D |
import std.stdio, std.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.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;... | 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;
import std.numeric;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
... | D |
import std.stdio;
import std.ascii;
import core.stdc.stdio;
int main()
{
int t = readInt!int;
while (t--)
{
long x = readInt!long;
long m111 = 0;
bool can = false;
int maxrep = 20;
int i = 0;
while (m111 <= x && i < maxrep)
{
if ((x - m111... | D |
import std.stdio;
int l,r;
void main()
{
scanf("%d %d", &l, &r);
long low = 1;
int ans = 0;
while(low<=r){
long x=low;
while(x<=r){
if(x>=l){
ans++;
}
x*=2;
}
low*=3;
}
printf("%d",ans);
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto s1 = readln.chomp;
auto s2 = readln.chomp;
writeln(levenshteinDistance(s1, s2));
}
| D |
void main(){
real num = readln().chomp().replace(" ","").to!int();
writeln(num%sqrt(num)==0?"Yes":"No");
}
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(stri... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
const alpha = 26, a = 'a';
void main()
{
auto n = readln.chomp.to!size_t;
auto b = new int[](alpha), bs = new int[](alpha);
b[] = int.max;
foreach (_; 0..n) {
auto s = readln.chomp;
bs[] = 0;
foreach (c; s) ++bs[c-a];
foreach ... | 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.string,std.conv,std.array;
void main(){
int[26] arr;
for(;;){
auto rc = readln().chomp();
if(!rc){ break; }
foreach( c ; rc ){
if( 'a' <= c && c <= 'z' ){
arr[c-'a']++;
} else if ( 'A' <= c && c <= 'Z' ){
arr[c-'A']++;
}
}
}
foreach( key,i ; arr ){
writeln( to!char(ke... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int a,b,c,x;
scan(a);
scan(b);
scan(c);
scan(x);
int ans;
foreach(i;0..a+1){
foreach(j;0..b+1){
foreach(k;0..c+1){
if(500*i+100*j+50*k == x) ans++;
... | D |
import std.functional,
std.algorithm,
std.container,
std.typetuple,
std.typecons,
std.bigint,
std.string,
std.traits,
std.array,
std.range,
std.stdio,
std.conv,
std.format,
std.math;
void main()
{
auto ip = readln.chomp;
if(ip... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int h, w;
rd(h, w);
int a, b;
rd(a, b);
auto p = h / a, q = w / b;
writeln((h - p * a) * w + h * (w - q * b) - ((h - p * a) * (w - q * b)));
}
void rd(T...)(ref T x) {
import std.stdio : readln;
import std.string : split;
import... | D |
import std.algorithm;
import std.range;
import std.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) {
stderr.writeln(arg);
}
int size(T)(in T s) {
return cast(int)s.length;
}
long modPow(long mod... | D |
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;
enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int N, M;
scan(N, M);
auto adj... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.