code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1];
writeln((a-1)*(b-1));
}
| 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[] stk;
foreach (_; 0..N) {
auto a = readln.chomp.to!int;
if (stk.empty || stk[$-1] >= a) {
stk ~=a;
continue;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto kn = readln.split.to!(int[]);
auto K = kn[0];
auto N = kn[1];
auto as = readln.split.to!(int[]);
int max_a = K - as[$-1] + as[0];
foreach (i; 0..N-1) max_a = max(max_a, as[i... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto a = readln.chomp.to!int;
auto b = readln.chomp.to!int;
auto c = readln.chomp.to!int;
auto d = readln.chomp.to!int;
auto e = readln.chomp.to!int;
auto k = readln.chomp.to!int... | D |
import std.stdio;
import std.conv;
import std.array;
void main()
{
auto reader = readln.split;
int N = reader[0].to!int;
int D = reader[1].to!int;
int range = D * 2 + 1;
int ans = N / range;
if (N % range > 0){
ans++;
}
writeln(ans);
}
| 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;
// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TL... | 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() {
auto ... | D |
import std.stdio, std.algorithm;
void main() {
int A, B, C, D, P;
scanf("%d\n", &A);
scanf("%d\n", &B);
scanf("%d\n", &C);
scanf("%d\n", &D);
scanf("%d\n", &P);
writeln( min(A * P, B + D * max(0, P - C)) );
} | 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) {
// n.iota... | D |
import std.stdio;
import std.string, std.conv;
import std.array, std.algorithm;
import std.math;
void main() {
int[] weight = [200, 300, 500, 200 * 5, 300 * 4, 500 * 3];
int[] price = [380, 550, 850, 1520, 1870, 2244];
int[5000+1] dp = cast(int)1e9;
dp[0] = 0;
foreach(i; 0 .. 6) {
for(int j = weight[i]; ... | 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;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;
void main()
{
auto l = readln.chomp;
if (l.equal(l.retro)) {
writeln = "Yes";
} else {
writeln =... | D |
import std.algorithm;
import std.array;
import std.bitmanip;
import std.conv;
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; }
void main() {
immutable ip = readln.split.to!(ulong[]);
immutable n = ip[0], k = ip[1];
ulong r... | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
int f(int n, int m, int k) {
if (n < m) return max(0, n-k+1);
return f(n%m, m, k) + (n/m)*(m-k);
}
void main() {
string[] input = split(readln());
int n = to!int(input[0]);
int k = to!int(input[1]);
long ans = 0;
fo... | 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 abc = readln.split.to!(int[]);
if (abc[0] > abc[1]) {
auto tmp = abc[0];
abc[0] = abc[1];
abc[1] = tmp;
}
writeln(abc[0] <... | D |
import std.stdio;
void main() {
while(true) {
uint[][][char] mapping;
char[3][3] field;
foreach (c; ['b', 'w', '+'])
mapping[c] = new uint[][](3, 3);
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++) {
scanf(j == 2 ? "%c\n" : "%c", &field[i][j]);
if (field[i][j] == '0... | 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.chomp.to!int;
while (T--) solve;
}
void solve() {
auto N = readln.chomp.to!int;
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.random;
import std.range;
import std.algorithm;
import std.functional;
import core.bitop;
import std.bigint;
import std.typecons;
import std.container;
void main()
{
auto input = readln.split.to!(int[]);
auto A = input[0], B = i... | D |
void main() {
int n = readln.chomp.to!int;
int cnt;
for (int i = 1; i <= n; i += 2) {
int divisor;
for (int j = 1; j * j <= i; j += 2) {
if (i % j == 0) {
++divisor;
if (j * j != i) ++divisor;
}
}
if (divisor == 8) ++cnt... | D |
void main(){
int a = _scan();
string s = readln().chomp();
if(a>=3200)s.writeln();
else writeln("red");
}
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(str... | 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);
long r, g, b;... | 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;
void main()
{
auto s = readln.chomp.to!int;
writeln((s/3600).to!string ~ ":" ~ (s... | D |
import std.stdio, std.algorithm;
void main(){
foreach(char[] line; lines(stdin)){
foreach(i; 0..26){
foreach(ref c; line){
if('a' <= c && c <= 'z') c = c == 'z' ? 'a' : cast(char)(c + 1);
}
if(line.countUntil("the") + 1 || line.countUntil("this") + 1 || line.countUntil("th... | D |
import std.stdio,
std.array,
std.conv,
std.algorithm;
void main() {
string s;
while((s=readln()).length != 0) {
string[] input = split(s);
int pos = 1;
int carry = 0;
int lena = to!int(input[0].length);
int lenb = to!int(input[1].length);
while(true) {
int a = len... | 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 x; readV(x);
writeln(x == 3 ... | 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.map!(x=>(x-'0').to!int).array;
auto op = ['-', ' ', '+'];
... | D |
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
void main()
{
string input;
int num;
int[] train;
while ((input = readln().chomp()).length != 0) {
num = input.to!int();
if (num == 0) {
writeln(train[$ - 1]);
train.length--;... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.container;
import std.typecons;
void log(A...)(A arg) {
stderr.writeln(arg);
}
void main() {
long N, K; scanf("%d %d\n", &N, &K);
long f(long n) {
return n + 1 + (n / (K - 1));
}
long x = 0;
for (long n = 1; n < N; 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() {
char c;
scan(c);
writeln((c + 1).to!char);... | 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.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 |
void main() {
problem();
}
void problem() {
const A = scan!long;
const B = scan!long;
const N = scan!long;
long calc(long x) {
return (A*x / B) - A*(x/B);
}
long solve() {
if (B > N) {
return calc(N);
}
const k = N / B;
return calc(B * k - 1);
}
solve().writeln;
}
// --... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;
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 ... | 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 X = readln.split[0].to!long;
long money = 100;
foreach (i; 1 .. 4000) {
money = cast(long) floor(money * 1.01);
if (money >= X) { writeln(i); break; }... | 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;
}
int gcd(int a, int b) {
if (b == 0)
retu... | 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 s;
scan(s);
writeln(s.count!"a == '1'");
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args)... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
writeln("ABC" ~ readln.chomp);
}
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primitives;
auto line = readln... | 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.algorithm;
import std.math;
import std.string;
import std.conv;
import std.range;
void main() {
while (true) {
int sum = readln.chomp.to!int;
if (sum == 0) break;
foreach (i; 0..9) {
sum -= readln.chomp.to!int;
}
sum.writeln;
}
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];
auto r = new int[](n);
foreach (_; 0..m) {
auto rd2 = readln.split.to!(size_t[]), a = rd2[0]-1, b = rd2[1]-1;
++r[a];
++r[b];
}
foreach (ri; r) writeln(r... | D |
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.conv;
void main(){
readln.split.map!(to!int).unaryFun!(a => a[0] < a[1] ? "a < b" : a[0] > a[1] ? "a > b" : "a == b").writeln;
} | 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.algorithm, std.ascii;
void main()
{
foreach(_; 0 .. readln.chomp.to!int)
{
auto line = readln;
auto keys = line.split.filter!(str => str.length == 4);
loop:foreach(a; [0, 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25])
{
foreac... | D |
import std.stdio;
import std.conv;
import std.string;
void main()
{
int[] input = readln.split.to!(int[]);
int sx = input[0];
int sy = input[1];
int tx = input[2];
int ty = input[3];
char[] ans;
foreach (i; 0..(ty - sy))
ans ~= 'U';
foreach (i; 0..(tx - sx))
ans ~= 'R';... | 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.range;
import std.conv;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
void main()
{
readln();
writeln(readln().strip.split(" ").reverse.join(" "));
}
| D |
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;
void main() {
int n = readln.chomp.to!int;
int[] arr = readln.chomp.split.map!(to!int).array;
long ans = 1000000000000007;
for (int i = 0; i < 2; ++i) {
auto a = arr.dup;
long tmp;
long[]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
auto S = readln.chomp.to!(char[]);
int r;
foreach (i; 1..N-1) {
int[char] CNT;
foreach (c; S[0..i]) {
CNT[c] = 1;
}
... | 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, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;
T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] AR... | D |
import std.stdio, 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;
foreach... | 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;
long n = long.max;
foreach (_; 0..5) n = min(n, readln.chomp.to!long);
writeln((N + n - 1) / n + 4);
} | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], c = rd[2], d = rd[3];
writeln(max(a*b, c*d));
}
| 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.algorithm;
import std.array;
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 = my_readln().split();
auto N = tokens[0].to!uint;
uint[] h;
foreach (token; my_readln().... | D |
import std.stdio;
import std.string;
import std.conv;
void main(){
(readln.chomp.to!int ^^ 3).writeln;
} | D |
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nab = readln.split.to!(int[]);
auto N = nab[0];
auto A = nab[1];
auto B = nab[2];
auto S = readln.chomp;
int b, n;
foreach (c; S) {
switch (c) {
case... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;
void main(){
auto a=readln.chomp;
writeln("A",a[8],"C");
} | D |
void main(){
int x, y;
scanf("%d %d", &x, &y);
(x + y/2).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().chomp().split()){
... | 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.string;
immutable int INF = 1 << 29;
void main() {
auto T = readln.chomp.to!int;
while (T--) {
auto s = readln.sp... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : ... | 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;
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() {
string s;
scan(s);
auto n = s.length.to!in... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1];
if(A==B)writeln("Draw");
else if(A==1&&A<B)writeln("Alice");
else if(B==1&&A>B)writeln("Bob");
else if(A<B)writeln("Bob");
else if(A>B)writeln... | D |
void main() {
int[] tmp = readln.split.to!(int[]);
int a = tmp[0], b = tmp[1];
writeln((a + b) % 24);
}
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.... | 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;
alias Edge = Tuple!(int, "to", int, "idx");
void main() {... | D |
void main(){
int[int] dic;
int ans;
int[] colors = inln();
foreach(elm; colors){
dic[elm]++;
if(dic.get(elm,0)==1)ans++;
}
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!(... | 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.regex : regex;
import std.container;
import std.bigint;
void main()
{
auto n = readln.chomp.to!int;
writeln(((n-1)/111+1)*111);
}
| 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 p = readln.chomp.split.to!(int[]);
int 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.datetime;
void main()
{
auto pat = ['z', '.', '?', '!', ' '];
foreach (line; stdin.byLine) {
auto str = line.chomp;
if (str.... | D |
import std.algorithm;
import std.array;
import std.stdio;
import std.conv;
import std.string;
import std.range;
void main(){
int[] ary;
int[] temp1, temp2;
while(true){
auto input = readln.split;
int n = input[0].to!int;
int r = input[1].to!int;
if(n == 0 && r == 0){
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto Q = readln.chomp.to!int;
foreach (_; 0..Q) {
auto X = readln.chomp;
auto Y = readln.chomp;
auto DP = new int[][](X.length, Y.length);
foreach_reverse (i; 0.... | D |
import std.stdio, std.conv, std.array,std.string,std.algorithm;
void main()
{
auto input1=readln.chomp,input2=readln.chomp;
writeln((2*input2.to!int)-input1.to!int);
} | D |
void main() {
problem();
}
void problem() {
auto N = scan!int;
auto STONES = scan!string.to!(char[]);
long solve() {
long left = 0;
long right = N-1;
long ans;
while(true) {
if (STONES[right] != 'R') right--;
if (STONES[left] != 'W') left++;
if (right <= left) break;
... | D |
import std.stdio;
long fact(int N) {
if (N == 0) return 1L;
return N * fact(N - 1);
}
void main() {
int N; scanf("%d\n", &N);
writeln(fact(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;
import std.conv;
import std.string;
import std.range;
import std.algorithm;
void main(){
while(true){
int n = readln().chomp().to!int();
if(n == 0){
break;
}
string str = readln().chomp();
foreach(i; 0..n){
string res;
in... | 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 x... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;
import std.typecons : Tuple;
ulong safeMod(long x, long m) @safe pure nothrow @nogc
{
x %= m;
if (x < 0)
x += m;
return x;
}
long ctPowMod(long x, long n, int m) @safe p... | 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 Point... | 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);
string t; re... | 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<<30;
enum full = (1<<26) - 1;
void main() {
string s;
scan(s);
int n = s.length.to!int;
long ans;
void dfs(int i, long val, lon... | D |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
import std.typecons;
import std.bigint;
// import dcomp.foundation, dcomp.scanner;
// import dcomp.container.deque;
int main() {
auto sc = new Scanner(stdin);
int n, m, k;
sc.read(n... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long solve(long N)
{
if (N == -1) return 0;
if (N%2 == 0) {
return N ^ ((N/2)%2 == 0 ? 0 : 1);
} else {
return (N/2)%2 == 1 ? 0 : 1;
}
}
void main()
{
auto ab = readln.split.to!(l... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
writeln(A * B - A - B + 1);
} | D |
import std.stdio;
import std.uni;
import std.conv;
import std.container;
import std.functional;
import std.algorithm;
import std.array;
import std.typecons;
import std.range;
import std.numeric;
import std.traits;
import std.math;
void main(string[] args)
{
long[100][100] mat;
auto t = next!int;
foreach(tc; 0 ..... | 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;
final class InputReader {
private:
ubyte[] p, buffer;
bool eof;
bool rawRead () {
if (eof) {
return fals... | D |
/+ dub.sdl:
name "A"
dependency "dunkelheit" version=">=0.9.0"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner;
int main() {
Scanner sc = new Scanner(stdin);
scope(exit) sc.read!true;
string s;
sc.read(s);
string err = "aeiou13579";
int an... | D |
void solve(string[] s){
foreach(elm; s){
writeln(elm);
writeln(elm);
}
}
void main(){
int[] hw = inln();
string[] s;
foreach(_; 0..hw[0])s ~= readln().chomp();
solve(s);
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
// 1要素のみの入力... | D |
import std.stdio,std.conv,std.string,std.algorithm;
void main(){
for( int i;;++i ){
auto arg = readln().chomp().split;
auto a = arg[0].to!int , b = arg[1].to!int;
if( !a && !b ) break;
if( a<b ){
writeln( a," ",b );
}else{
writeln( b," ",a );
}
}
} | D |
void main(){
int r = _scan();
( r^^2 ).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().chomp().split()){
ln ~= elm.to!T();
... | D |
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
void main() {
int[3] coins;
int x, ans;
for (int i = 0; i < 3; i++) {
coins[i] = readln.chomp.to!int + 1;
}
x = readln.chomp.to!int;
foreach (i; 0..coins[0]) {
foreach (j; 0..coins[1]) {
foreach (k; 0..coins[2]) {
... | 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(Vec2 p0, Vec2 p1, Vec2 p2) {
auto p0... | D |
// Vicfred
// https://atcoder.jp/contests/abc156/tasks/abc156_c
// brute force
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;
void main() {
int n = readln.chomp.to!int;
int[] x = readln.split.map!(to!int).array;
long minima = 1<<30;
foreach(p; 1..101) {
... | 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() {
long H;
scan(H);
long[long] memo;
lon... | 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 N = readln.chomp.to!int;
long[] as;
foreach (_; 0..N) as ~= readln.chomp.to!long;
long min_p = 1;
long r;
foreach (a; as) {
if (min_p == a) {
min_p += 1... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.