code stringlengths 4 1.01M | language stringclasses 2
values |
|---|---|
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
void main()
{
auto nw = readln.split.to!(int[]);
auto N = nw[0];
long W = nw[1];
int[] vs;
long[] ws;
foreach (_; 0..N) {
auto vw = readln.split.to!(int[]);
vs ~... | 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); }
v... | D |
void main() {
writeln(canFind(rs, "AC") ? "Yes" : "No");
}
// ===================================
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 std.bigint;
import std.numeric;
import std.conv;
impor... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
enum PS = [3, 13, 23, 43, 53, 73, 83, 103, 113, 163, 173, 193, 223, 233, 263, 283, 293, 313, 353, 373, 383, 433, 443, 463, 503, 523, 563, 593, 613, 643, 653, 673, 683, 733, 743, 773, 823, 853, 863, 883, 953, 983, 101... | 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 readC(T...)(size_t n,ref T t){foreach(ref v;t)... | 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;
void scan(T...)(ref T args) {
import std.stdio : readln;
import std.algorithm : splitter;
import std.conv : to;
import std.range.primiti... | D |
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
auto NT = s_.split.map!(to!int)();
immutable N=NT[0], T=NT[1];
auto A = readln.split.map!(to!int).array();
int m=0,d=0,nl=0, nr=0, n=0, nm=0;
foreach_reverse(v;A) {
if(v>m) m=v,++n,nm=1;
... | 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 n;
scan(n);
if (n <= 999) {
writeln("ABC");
}
else {
writeln("ABD");
}
}
... | 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);
auto ok = iota(3).all!(i => s[i] == s[... | D |
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
void main()
{
string s;
do{
char[][] m;
while((s=readln()).chomp().length) m~=s.chomp().to!(char[]);
void update(int x, int y)
{
if(x<0 || m.length<=x || y<0 || m[x].length<=y)
... | 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() {
readi... | D |
/+ dub.sdl:
name "C"
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) assert(!sc.hasNext);
int n, m;
sc.read(n, m);
int a, b; //a : <>, b : ^v... | 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;
void main()
{
auto s = new string[](3);
foreach (i; 0..3) {
s[i] = readln.chomp;
}
auto i... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto ap = readln.split.to!(int[]);
auto A = ap[0];
auto P = ap[1];
writeln((P + A*3)/2);
} | D |
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
int[100001] dp;
int solve(int n) {
if (n == 0)
return 0;
if (dp[n] != -1)
return dp[n];
int ret = solve(n - 1) + 1;
for (int d = ... | D |
void main() {
auto H = readAs!long;
ulong cnt;
long[] queue = [H];
long[long] m;
m[1] = 1;
long dfs(long n) {
if(n in m) return m[n];
return m[n] = 2*dfs(n/2) + 1;
}
dfs(H).writeln;
}
// ===================================
import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto abc = readln.split.to!(int[]);
auto A = abc[0];
auto B = abc[1];
auto C = abc[2];
writeln(min(B / A, C));
} | D |
import std.stdio : writeln;
import std.array;
import std.range;
import std.typecons;
import std.algorithm : max, min;
immutable INF = 1 << 27;
immutable N = 100;
int n, m;
int[ N + 1 ][ N + 1 ] adj;
int[ N + 1 ][ N + 1 ] two_link;
void init(){
init_d_cost();
init_two_link();
}
void init_two_link(){
for( int i = 1... | 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;
class InputReader {
private:
ubyte[] p;
ubyte[] buffer;
size_t cur;
public:
this () {
buffer = uninitializ... | D |
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=(... | D |
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
int n = readln.chomp.to!int;
string s = readln.chomp;
ulong mod = 1_000_000_007;
ulong[][] dp; // dp[j][i] := # of ways to make (any) string of length i... | 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.math;
import std.conv;
import std.string;
import std.range;
T readNum(T)(){
return readStr.to!T;
}
T[] readNums(T)(){
return readStr.split.to!(T[]);
}
string readStr(){
return readln.chomp;
}
void main(){
auto nl = readNums!int;
auto n = nl[0], l = nl[1];... | 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 n = read.to!int;
in... | D |
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.... | 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;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_00... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto md = readln.split.to!(int[]);
auto M = md[0];
auto D = md[1];
int r;
foreach (m; 0..M) {
++m;
foreach (d; 21..D) {
++d;
if (d%10 >= 2 &&... | D |
import std;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
auto n = lread();
auto a = aryread();
long cnt;
while (func(a))
{
foreach (i; 0 .. n)
{
a[... | 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!(dchar[]);
auto Q = readln.chomp.to!int;
dchar[] as, bs;
int f;
foreach (_; 0..Q) {
auto q = readln;
if (q[0] == '1') {
++f;
... | D |
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main(){
auto c=readln.chomp.to!char;
if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')writeln("vowel");
else writeln("consonant");
} | 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;
long[Tuple!(long, long)] mem;
immutable long MOD = 10^^9 + 7;
long dp(long s, long x) {
Tuple!(long, long) t = tuple(s... | D |
void main()
{
int n = readln.chomp.to!int;
int[] a = readln.split.to!(int[]);
int[] odd = new int[n];
foreach (i, x; a)
{
if (x & 1)
{
odd[i] = 1;
}
else
{
odd[i] = 2;
}
}
writeln(3 ^^ n - odd.reduce!((x, y) => x * y))... | 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],C=Q[2];
if(C>=A&&C<=B)writeln("Yes");
else writeln("No");
} | 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, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int h, w;
scan(h, w);
auto c = new int[][](10, 10);
auto d = new int[][](10, 10);
foreach (i ; 0 .. 10) {
c[i] = readln.split.t... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln((readln.chomp.to!int+1)/2);
} | D |
import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
void main() {
auto tmp = readln.split.to!(int[]);
auto N = tmp[0];
auto M = tmp[1];
writeln((M * 1900 + (N-M) * 100) * 2^^M);
}
| D |
void main() {
problem();
}
void problem() {
const N = scan!int;
const M = scan!int;
const A = scan!int(N);
string solve() {
const votesCount = A.sum();
int items;
foreach(a; A) if (a*4*M >= votesCount) items++;
return items >= M ? "Yes" : "No";
}
solve().writeln;
}
// -----------... | D |
import std.stdio, std.string, std.conv;
void main(){
string str;
string[] s;
int q1, b, c1, c2, q2, a1, a2, t;
while ((str = readln()) != "0\n") {
s = split(str);
q1 = s[0].to!int;
b = s[1].to!int;
c1 = s[2].to!int;
c2 = s[3].to!int;
q2 = s[4].to!int;
foreach (i; 0..q2+1) {
a1 = q2 - i;
t = b -... | 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, k; readV(n, k);
writeln(n... | 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.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }
int s(string n) {
int z;
foreach (c; n) z += c - '0';
return z;
}
void solve() {
string n = readln.chomp;
debug {
... | 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 s = readln.chomp;
int m;
foreach (i; 1..n) {... | 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[]);
foreach (ref c; S) c = 'x';
writeln(S);
} | D |
unittest
{
assert( [ "axyb", "abyxb" ].parse.expand.solve == "axb" );
assert( [ "aa", "xayaz" ].parse.expand.solve == "aa" );
assert( [ "a", "z" ].parse.expand.solve == "" );
assert( [ "abracadabra", "avadakedavra" ].parse.expand.solve == "aaadara" );
}
import std.algorithm;
import std.conv;
import std.range;
im... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
import core.bitop;
void main()
{
auto nk = readln.split.to!(int[]);
auto N = nk[0];
auto K = nk[1];
auto as = readln.split.to!(long[]);
auto c = long.max;
foreach (x; 0..(1<<N)) {
if ... | 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.stdlib;
void main() {
auto N = readln.chomp.to!int;
long ans = 0;
foreach (i; 1..N+1) foreach (j; 1..N+1) foreach(k; 1... | 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.numeric;
void main()
{
auto n = readln.chomp.to!int;
auto res = new int[](n);
auto a... | D |
void main() {
auto a = ri;
writeln(a + a*a + a*a*a);
}
// ===================================
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 std.bigint;
import std.numeric;
import std.conv;
import s... | D |
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int k; rd(k);
int n=1;
while((1<<n)<=k) n++;
struct E{int u, v, w;}
E[] edges;
int w=0;
for(int i=1; i<n; i++){
edges~=E(i, i+1, 0);
edges~=E(i, i+1, 1<<(n-i-1));
w+=(1<<(n-i-1));
}
if(w<(k-1)){
w=0;
for(int i... | D |
import std.stdio,
std.string,
std.conv,
std.algorithm,
std.range,
std.math;
void main()
{
while(true){
auto ip = readln.split.to!(int[]), h = ip[0], w = ip[1];
if(h == 0 && w == 0) break;
else{
string W;
foreach(j; 0..w){
W ~= "#";
}
foreach(i; 0..h){
W.writeln;
}
... | D |
import std.algorithm,
std.string,
std.range,
std.stdio,
std.conv;
void chmax(T)(ref T a, ref T b) {
if (a < b) {
a = b;
}
}
void main() {
int N = readln.chomp.to!int;
int[] s = N.iota.map!(_ => readln.chomp.to!int).array;
bool[10010][110] dp;
dp[0][0] = true;
dp[0][s[0]... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 10^^9+7;
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 x)
{
return pow(x, P... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
writeln(reduce!"a + b"(0, readln.split.to!(int[])) >= 22 ? "bust" : "win");
} | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln((readln.split.to!(int[]).sum+1)/2);
}
| 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, 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 s1, s2;
s1 = readln().chomp().dup().reverse();
s2 = readln().chomp();
if(s1 == s2)writeln("YES");
else writeln("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[] _scanl... | D |
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;
string FMT_F = "%.10f";
static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
long P = 10^^9+7;
long[10^^5+50] F, RF;
void init()
{
F[0] = F[1] = 1;
foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;
{
RF[$-1] = 1;
auto x = F[$-1];
auto k = P-2;
... | D |
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto s = readln.chomp;
auto a = ["dream", "dreamer", "erase", "eraser"];
loop: while (!s.empty) {
foreach (ai; a) {
if (s.length >= ai.length && s[$-ai.length..$] == ai) {
s = s[0..$-ai.length];
continue loo... | 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 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()
{
long n, t;
rdVals(n, t);
long[] a = rdRow;
long[] amax = new long[n+1];
foreach_reverse (i, x; a)
{
amax[i] = max(amax[i+1], x);
}
long key, cnt;
foreach (i, x; a)
{
long diff = max(0, amax[i]-x);
if (key < diff)
{
key =... | D |
/+ dub.sdl:
name "C"
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);
int n;
sc.read(n);
int[][] g = new int[][n];
foreach (i; 0..n-1) {
int a, b;
... | 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.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.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;
void main(){
auto NAB=readln.split.map!(to!int).array;
auto Xs=readln.split.map!(to!long).array;
auto res=0L;... | 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.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;
void main() {
int N; readlnTo(N);
if (N == 1) "Hello World".writeln;
else {
int A, B;
readlnTo(A);
readlnTo(B);
(A + B).writeln... | 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[] uniq(int[] a) {
... | 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 digits(int n) {
... | D |
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
void main()
{
int n = to!int(chomp(readln()));
writeln(to!string((1+n)*n/2));
}
int[] stringText2IntArray(string text)
{
return map!(to!int)(split(readln())).array;
} | D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
void main() {
int n, m;
scan(n, m);
auto uf = WeightedUnionFind!(int)(n + 1);
bool ok = 1;
foreach (i ; 0 .. m) {
int l, r, d;
scan(l, r, d);
if (uf.same(l, r)) {
if (uf.diff(l... | 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;
alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
long h, w;
scan(h, w);
auto s = new string[](h);
foreach (i; 0 .. h)
{
s[i] = sread();
}
// writeln(s);
auto ans = new long[][](h, w);
// writeln(ans);
... | D |
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;
int readint() {
return readln.chomp.to!int;
}
int[] readints() {
return readln.split.map!(to!int).array;
}
void main() {
auto xs = readints();
int a = xs[0], b = xs[1], c =... | D |
import std.stdio, std.conv, std.string, std.algorithm, std.range;
void main() {
auto N = readln.split[0].to!int;
(N ^^ 3).writeln;
} | 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.string;
import std.conv;
import std.algorithm;
void main() {
string[] inputs = split(readln());
int a = to!int(inputs[0]);
int b = to!int(inputs[1]);
int c = to!int(inputs[2]);
min(a + b, b + c, c + a).writeln;
}
| D |
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;
void main()
{
auto R = readln.chomp.to!int;
if (R < 1200) {
writeln("ABC");
} else if (R < 2800) {
writeln("ARC");
} else {
writeln("AGC");
}
} | D |
void main()
{
long[] tmp = rdRow;
long n = tmp[0], m = tmp[1];
string s = rdStr;
string t = rdStr;
long g = gcd(n, m);
long l = n * m / g;
long sl = n / g, tl = m / g;
foreach (i; 0 .. g)
{
if (s[sl*i] != t[tl*i])
{
writeln(-1);
return;
... | D |
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
std.random, std.typecons, std.container;
ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = (... | D |
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;
void main() {
writeln(48 - readln.chomp.to!int);
}
| D |
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, 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 k;
scan(k);
auto ans = (k /... | D |
import std.stdio,std.string;
import std.conv,std.math;
void main(){
int [] n = readln.chomp.split.to!(int[]);
if((abs(n[0]-n[1])<=n[3] &&abs(n[1]-n[2])<=n[3])
||abs(n[0]-n[2])<=n[3]){
writeln("Yes");
}
else{
writeln("No");
}
} | 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;
alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
void main()
{
auto n = lread();
auto a = aryread();
// writeln(a);
long cost;
auto new_a = new long[](n + 2);
foreach (i; 0 .. n)
{
new... | D |
import std.stdio, std.algorithm, std.conv, std.array, std.string;
int[10^^5] BS;
bool[10^^5] HS;
void main()
{
auto n = readln.chomp.to!int;
foreach (i; 0..n) {
BS[i] = readln.chomp.to!int - 1;
}
int p, cnt;
for (;;) {
++cnt;
HS[p] = true;
p = BS[p];
if (p ... | D |
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;
immutable long mod = 10^^9 + 7;
immutable long inf = mod;
void main(){
long m, n;
readVars(m, n);
long ans = modpow(m, n, 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 a, b, c, x, y;
scan(a, b, c, x,... | D |
import std.stdio;
import std.string;
import std.conv;
void main() {
int N = to!int(chomp(readln()));
int x = N * 800;
int y = (N / 15) * 200;
(x - y).writeln;
}
| D |
void main() {
int n = readln.chomp.to!int;
int[] a = readln.split.to!(int[]);
int cnt, tmp;
foreach (i; 0 .. n) {
if (i == n - 1 && a[i] == n) {
tmp = a[i];
a[i] = a[i-1];
a[i-1] = tmp;
++cnt;
} else if (a[i] == i + 1) {
tmp = ... | D |
void main() {
"square1001".writeln;
}
// ===================================
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 std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
impor... | 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 MAX = 10^^5 * 2;
immutable long MOD = 10^^9 + 7;
long[] F;
long[] G;
void main() {
F = new long[](MAX);
... | 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 |
/+ dub.sdl:
name "E"
dependency "dcomp" version=">=0.6.0"
+/
import std.stdio, std.range, std.algorithm, std.conv;
// import dcomp.scanner;
// import dcomp.algorithm;
int n;
long[] d, v;
bool check(long fi) {
v[] = d[];
foreach_reverse(i; 1..n) {
long x = v[i];
if (fi < x) return fals... | 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;
double[] cross(double[] a, double[] b) {
return [a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]];... | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.