code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
void main()
{
long[] tmp = readln.split.to!(long[]);
long n = tmp[0], m = tmp[1];
long mod = 10 ^^ 9 + 7;
long factorial(long x)
{
long result = 1;
foreach (i; 2 .. x+1)
{
result = result * i % mod;
}
return result;
}
long cnt;
if ... | 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;
int calc(int n) {
/... | D |
void main()
{
long n, k;
rdVals(n, k);
long[] list = new long[k+1];
long result;
foreach_reverse (i; 1 .. k+1)
{
list[i] = (list[i] + modPow(k/i, n)) % mod;
result = (result + list[i] * i % mod) % mod;
foreach (d; divisors(i))
{
if (d == i) continue;
... | 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(){
int d = read.to!int;
int ... | D |
void main(){
string s = readln().chomp();
string t = readln().chomp();
sort!("a<b")( cast(ubyte[]) s);
sort!("a>b")( cast(ubyte[]) t);
writeln(s<t?"Yes":"No");
}
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= in... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum P = 10L^^9+7;
long[2][10^^5+10] DP;
void main()
{
auto L = readln.chomp.to!(char[]);
DP[0][1] = 2;
DP[0][0] = 1;
foreach (i; 1..L.length) {
if (L[i] == '0') {
DP[i][1] = DP... | D |
void main() {
long n = readln.chomp.to!long;
string s = readln.chomp;
long cnt;
foreach (i; 0 .. 1000)
{
dchar[] a =[
(i / 100 + '0').to!dchar,
(i % 100 / 10 + '0').to!dchar,
(i % 10 + '0').to!dchar
];
bool ok;
long index;
... | 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 a = readln.chomp.to!BigInt;
auto b = readln.chomp.to!BigInt;
if (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 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);
string a = "2019/04/30"... | D |
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
import std.stdio : File, stdin;
import std.conv : to;
import std.array : split;
import std.string;
import std.traits : isSome... | D |
import std.stdio, std.string, std.conv;
immutable hurui = (int n){
bool[] table = new bool[](n + 1);
table[] = true;
table[1] = false;
for(int i = 2; i * i <= n; ++i)
{
for(int j = i + i; j <= n; j += i)
{
table[j] = false;
}
}
return table;
}(60000);
vo... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;
int count_ds(int i)
{
int r;
while (i) {
r += i%10;
i /= 10;
}
return r;
}
void main()
{
auto N = readln.chomp.to!int;
int r = int.max;
foreach (i; 1..N/2+1) ... | D |
import std.stdio, std.conv, std.string;
void main(){
(n => n * (n + 1) / 2)(r).writeln;
}
int r() { return readln.chomp.to!int; } | D |
import std.stdio, std.string, std.conv, std.math;
void main() {
writeln(readln.chomp.to!int ^^ 3);
} | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
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_rd[0]; s_rd.popFront; re... | D |
import std.stdio, std.string, std.uni;
void main() {
string str = readln.chomp;
foreach (x; str) {
if (x.isUpper) {
x.toLower.write;
} else if (x.isLower) {
x.toUpper.write;
} else {
x.write;
}
}
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;
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 |
//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.array, std.range, std.algorithm,
std.string, std.math;
void main(){
auto tmp = readln.chomp.split.to!(int[]);
auto a = tmp[0], b = tmp[1];
char[100][100] field;
foreach(i; 0 .. 50) foreach(j; 0 .. 100) field[i][j] = '.';
foreach(i; 50 .. 100) foreach(j; 0 .. 100) fie... | 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() {
int[] NK = readln.chomp.split.to!(int[]);
int N = NK[0],
... | 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 |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n, t;
rd(n, t);
int mn = 10 ^^ 9;
foreach (_; 0 .. n) {
int c, tm;
rd(c, tm);
if (tm <= t) {
mn = min(mn, c);
}
}
if (mn < 10 ^^ 9) {
writeln(mn);
} else {
writeln("TLE");
}
}
void rd(T...)(ref T x... | D |
import std.stdio,std.conv,std.string;
void main()
{
auto a = readint();
auto b = readint();
auto h = readint();
writeln(((a+b)*h)/2);
}
int readint() {
return to!(int)(chomp(readln()));
}
| D |
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop, std.typetuple, std.typecons;
immutable long MOD = 1_000_000_007;
alias tie = TypeTuple;
alias triplet = Tuple!(int, int, int);
void main(){
long m, n;
readVars... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;
void main()
{
readln;
int[int] as;
foreach (a; readln.split.to!(int[])) as[a] += 1;
int r;
foreach (a, n; as) {
if (n >= a) {
r += n - a;
} else {
r += n;
}
}
writeln(... | D |
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;
void main()
{
auto abcxy = readln.split.map!( to!int );
writeln( solve( abcxy[ 0 ], abcxy[ 1 ], abcxy[ 2 ], abcxy[ 3 ], abcxy[ 4 ] ) );
}
int solve( in int a, in int b, in int c, in int x, in int y )
{
auto cc = c * 2;
if( a + b < cc )... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.numeric; // gcd, fft
void main()
{
auto n = readln.chomp.to!size_t;
auto t = new long[](n);
foreach (i; 0..n) t[i] = readln.chomp.to!long;
writeln(t.reduce!lcm);
}
auto lcm(long a, long b) { return a / gcd(a, b) * b; }
| D |
void main()
{
long n, k;
rdVals(n, k);
foreach (i; 1 .. 100)
{
if (k ^^ (i - 1) <= n && n < k ^^ i)
{
i.writeln;
return;
}
}
}
enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
T rdElem(T = long)()
if (!is(T == struct))
{
return readln.chomp.... | 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.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nmq = readln.split.to!(int[]);
auto N = nmq[0];
auto M = nmq[1];
auto Q = nmq[2];
int[] as, bs, cs;
long[] ds;
foreach (_; 0..Q) {
auto abcd = readln.split.to!(... | D |
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;
/// 数列の読み込み
auto readNums(T = int)() {
return readln().chomp.split.map!(to!T).array;
}
/// 数の読み込み
auto readNum(T = int)() {
return readNums!T.front;
}
/// 指定行数読み込み
auto readRows(size_t r... | D |
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.container, std.math, std.typecons;
import std.ascii, std.getopt;
void main() {
int Q, N;
Q = readln.chomp.to!int;
foreach (qi ; 0 .. Q) {
N = readln.chomp.to!int;
solve(N).writeln;
}
}
int solve(i... | 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 |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 10^^9+7;
long[10^^5*2+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(long ... | D |
void main() {
int[] a = new int[5];
foreach (i; 0 .. 5) {
a[i] = readln.chomp.to!int;
}
int k = readln.chomp.to!int;
writeln(a[$-1] - a[0] > k ? ":(" : "Yay!");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
bool check(string s)
{
int index = 0;
foreach (c; s) {
if (c=='(') {
++index;
} else {
if (index == 0) {
... | D |
import std.stdio, std.string, std.conv;
void main()
{
auto S = readln.chomp.to!(dchar[]);
S[3] = '8';
writeln(S);
} | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int a, b, c; rd(a, b, c);
int[int] cnt;
cnt[a]=1;
if(b in cnt) writeln(c);
else if(c in cnt) writeln(b);
else writeln(a);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
foreach(i, ref e... | D |
void main()
{
long n, q;
rdVals(n, q);
auto uf = UnionFind(n);
foreach (i; 0 .. q)
{
long com, x, y;
rdVals(com, x, y);
if (com)
{
writeln(uf.same(x, y) ? 1 : 0);
}
else
{
uf.unite(x, y);
}
}
}
struct Unio... | D |
void main() {
string s = readln.chomp[0..$-2];
ulong len = s.length / 2;
while (s[0..len] != s[len..$]) {
s = s[0..$-2];
--len;
}
s.length.writeln;
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
impo... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n, k;
scan(n, k);
auto s = readln.cho... | D |
import std.stdio;
void main() {
int cnt, max;
foreach(c;readln) {
if (c == 'A' || c == 'C' || c == 'T' || c == 'G') {
++cnt;
if (cnt > max) max = cnt;
}
else {
cnt = 0;
}
}
max.write;
}
| 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.array, std.algorithm, std.range, std.typecons, std.numeric, std.math;
void main() {
ulong n = readln.strip.to!ulong;
auto as = readln.strip.split.to!(ulong[]).array;
auto bs = readln.strip.split.to!(ulong[]).array;
ulong ans = 0;
foreach (i; 0..n) {
... | 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.regex, std.conv, std.stdio, std.typecons;
void main()
{
auto n = readln.chomp.to!size_t;
auto cards = new bool[](52);
foreach (_; 0..n) {
auto c =... | 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.array;
if (s.length == 3) {
s.revers... | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;
enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;
void main() {
int n;
scan(n);
auto cnt = new int[][](11... | 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.to!(int[]); }
void calc(int n, int a, int b) {
while (true) {
if (a + 1... | D |
void main()
{
long n, m;
rdVals(n, m);
string s = rdStr;
long[] lists;
while (n > 0)
{
long ok;
foreach_reverse (i; 1 .. m+1)
{
if (n - i < 0) continue;
if (s[n-i] == '0')
{
lists ~= i;
n -= i;
... | D |
void main() {
int[] abc = readln.split.to!(int[]);
writeln(abc.sum - 2 * abc.reduce!max == 0 ? "Yes" : "No");
}
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import ... | D |
void main()
{
long n, p;
rdVals(n, p);
string s = rdStr;
long result;
if (p == 2 || p == 5)
{
foreach (i, x; s)
{
if ((x - '0') % p) continue;
result += i + 1;
}
result.writeln;
return;
}
long[] exp = new long[n];
exp... | D |
void main() {
auto s = rs.to!(dchar[]);
s[5] = s[13] = ' ';
s.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.c... | 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.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_r... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
void main(){
auto Z=readln.split.to!(int[]),a=Z[0],b=Z[1];
if((a*b)%2==0)writeln("Even");
else writeln("Odd");
} | 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 std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ab = readln.split.to!(int[]);
auto A = ab[0];
auto B = ab[1];
writeln(B % A == 0 ? A + B : B - 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, std.bitmanip;
immutable long MOD = 10^^9 + 7;
void main() {
auto K = readln.chomp;
auto D = readln.chomp.to!int;
auto N = K.len... | 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() {
int n, w;
scan(n, w);
auto dp = new int[](w + 1);
foreach (i ; 1 .. n + 1) {
int val, wei, m;
scan(val, wei, m);
f... | D |
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
immutable n = readln.chomp.to!size_t, s = readln.chomp;
auto count = ['R': long(0), 'G': 0, 'B': 0];
foreach (l; s)
count[l] += 1;
auto answer = count['R'] * count['G'] * count['B'];
foreach (i;... | D |
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
stri... | 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() {
string s;
scan(s);
writeln(s[0] == s[1] ||... | D |
void main()
{
string x = readln.chomp;
auto g = x.group.array;
long slen;
long len = x.length;
foreach (t; g)
{
if (t[0] == 'S')
{
slen += t[1].to!long;
}
else
{
long lmin = min(slen, t[1].to!long);
len -= 2 * lmin;
... | 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 core.stdc.stdio;
import std.typecons;
import std.stdio;
import std.algorithm;
import std.math;
void main(){
int v,e;
scanf("%d%d",&v,&e);
int[][] graph = new int[][v];
foreach(i;0..e){
int a,b;
scanf("%d%d",&a,&b);
graph[--a]~=--b;
graph[b]~=a;
}
int[] d=new int[v];
int[] s=new int[v];
int[] t=n... | 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 |
/+ dub.sdl:
name "A"
dependency "dcomp" version=">=0.7.4"
+/
import std.stdio, std.algorithm, std.range, std.conv;
// import dcomp.foundation, dcomp.scanner;
int main() {
Scanner sc = new Scanner(stdin);
string s;
sc.read(s);
string t = "AKIHABARA";
int cnt = 0;
foreach (c; s) {
... | D |
import std.stdio;import std.conv;import std.algorithm;import std.array;
auto raia(){ return readln().split().map!(to!int); } //read as a int[]
static const int mint =60;
static const int hour = 60*mint;
void main()
{
auto it = raia();
writeln( it[0] /hour,":",it[0]%hour/mint,":",it[0]%mint);
} | 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; }
long ... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
auto s=readln.chomp.to!(char[]);
bool[char] v;
v['a']=true;
v['i']=true;
v['u']=true;
v['e']=true;
v['o']=true;
int n=s.length.to!(int);
foreach(i; 0..n){
if((s[i] in v)==null){
if(s[i]=='n'){
//
}else{
... | 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 X = new int[](N+1);
int[][int] Y;
X[0] = 0;
Y[0]... | D |
import std;
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line =... | D |
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;
void main() {
auto s = readln.split.map!(to!int);
auto H = s[0];
auto N = s[1];
auto A = iota(N).map!(_ => ... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
bool n, w, s, e;
foreach (c; readln.chomp) switch (c) {
case 'N':
n = true;
break;
case 'W':
w = true;
break;
case 'S':
... | D |
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto ... | D |
import std;
long calcEven(int[] a) {
assert(a.length % 2 == 0);
long sum1 = 0;
long sum2 = 0;
for (int i = 0; i < a.length; i += 2) {
sum1 += a[i];
sum2 += a[i+1];
}
return max(sum1, sum2);
}
long calc(int[] a) {
// if (a.length % 2 == 0) return calcEven(a);
alias Key ... | D |
import std.stdio, std.array, std.conv, std.string, std.algorithm, std.range;
void main() {
foreach (string line; lines(stdin)) {
auto d = line.chomp.to!int;
int ans = 0;
for (int i = d; i < 600; i += d) {
ans += i * i * d;
}
ans.writeln;
}
} | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.range;
enum long PRIM = 10^^9+7;
void main()
{
auto nm = readln.chomp.split(" ").map!(to!long);
auto n = nm[0];
auto m = nm[1];
auto xs = readln.chomp.split(" ").map!(to!long);
auto ys = readln.chomp.split(" ").map!(to!long);
... | D |
void main() {
import std.stdio, std.string, std.conv, std.algorithm;
int n;
rd(n);
int s = 0;
foreach (_; 0 .. n) {
int l, r;
rd(l, r);
s += (r - l + 1);
}
writeln(s);
}
void rd(T...)(ref T x) {
import std.stdio : readln;
import std.string : split;
import std.conv : to;
auto l = rea... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;
import std.range;
void main() {
char[] a;
foreach(i; 0..3) {
a ~= readln.chomp[i];
}
a.writeln;
}
| D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1];
auto a = m * 1900 + (n-m) * 100;
writeln(a * 2^^m);
}
| D |
auto solve(long target, in int[] cards)
{
import std.algorithm, std.range;
immutable
n = cards.length,
m = cards.sum;
auto dp = new long[][](n+1, m+1);
dp[0][0] = 1;
foreach (card; cards)
foreach_reverse (usedCards; 0..n)
foreach (currentSum; 0..m+1-card)
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
alias A = Tuple!(int, "i", int, "j");
A[300*300+1] AS;
long[300*300+1] DS;
void main()
{
auto hwd = readln.split.to!(int[]);
auto H = hwd[0];
auto W = hwd[1];
auto D = hwd[2];
foreach (j; 0..H)
for... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto s = readln.chomp;
int i;
foreach (c; s) {
if (i == 0 && c == 'C') ++i;
if (i == 1 && c == 'F') ++i;
}
writeln(i == 2 ? "Yes" : "No");
} | D |
import std.stdio;
void main()
{
int i;
for(i=0;i<1000;i++)
{
writeln("Hello World");
}
} | 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(i;0..n){t[i]=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(siz... | D |
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
void main() {
auto N = readln.chomp.to!ulong;
auto An = readln.split.to!(int[]);
auto Bn = readln.split.to!(int[]);
auto Cn = 0 ~ readln.split.to!(int[]);
... | D |
void main() {
rs.count!"a == '1'".writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import st... | D |
void main(){
int n = _scan();
writeln("ABC", n);
}
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.algorithm;
import std.range;
import std.stdio;
void main(){
readln();
readln().split().retro().join(" ").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 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;
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 Cell{
char c;
int i, j;
int _value;
bo... | 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 ab = readln.split.to!(long[]);
auto a = ab[0];
auto b = ab[1];
if (a > b) swap(a, b);
long r;
while (b) {
r *= 10;
r += a;
--b;
}
writeln(r);... | 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.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto N = readln.chomp.to!int;
long[] as;
auto MEMO = new long[](N+1);
foreach (a; readln.split.to!(long[])) {
++MEMO[a];
as ~= a;
}
long r;
foreach (n; MEMO) ... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.