id stringlengths 6 117 | description stringlengths 29 13k | code stringlengths 9 465k | language class label 4
classes | test_samples dict | source class label 5
classes |
|---|---|---|---|---|---|
p02741 Panasonic Programming Contest 2020 - Kth Term_800 | Print the K-th element of the following sequence of length 32:
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
Constraints
* 1 \leq K \leq 32
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
K
Output
Print ... | n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(n[K-1]) | 3Python3 | {
"input": [
"27",
"6",
"16",
"19",
"8",
"24",
"32",
"28",
"-22",
"1",
"15",
"5",
"-9",
"-27",
"-13",
"29",
"-20",
"001",
"8",
"1",
"32",
"5",
"15",
"24",
"-9",
"-13",
"19",
"29",
"16",
"28",
"-... | 5ATCODER |
p02741 Panasonic Programming Contest 2020 - Kth Term_801 | Print the K-th element of the following sequence of length 32:
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
Constraints
* 1 \leq K \leq 32
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
K
Output
Print ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = sc.nextInt();
int[] number = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
System.out.println(n... | 4JAVA | {
"input": [
"27",
"6",
"16",
"19",
"8",
"24",
"32",
"28",
"-22",
"1",
"15",
"5",
"-9",
"-27",
"-13",
"29",
"-20",
"001",
"8",
"1",
"32",
"5",
"15",
"24",
"-9",
"-13",
"19",
"29",
"16",
"28",
"-... | 5ATCODER |
p02876 AtCoder Grand Contest 040 - Balance Beam_802 | We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
* First, Snuke connects the N beams in any order of his choice and m... | #ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while... | 2C++ | {
"input": [
"3\n4 1\n5 2\n6 3",
"4\n1 5\n4 7\n2 1\n8 4",
"2\n3 2\n1 2",
"10\n866111664 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178",
"3\n1 1\n5 ... | 5ATCODER |
p02876 AtCoder Grand Contest 040 - Balance Beam_803 | We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
* First, Snuke connects the N beams in any order of his choice and m... | import sys
input = sys.stdin.readline
def gcd(a, b):
while b: a, b = b, a % b
return a
N = int(input())
S = 0
Y = []
for i in range(N):
a, b = map(int, input().split())
if b > a:
S += b-a
Y.append((b, b))
else:
Y.append((a, b))
Y = sorted(Y)
YY = [0] * (N+1)
for i in range(... | 3Python3 | {
"input": [
"3\n4 1\n5 2\n6 3",
"4\n1 5\n4 7\n2 1\n8 4",
"2\n3 2\n1 2",
"10\n866111664 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178",
"3\n1 1\n5 ... | 5ATCODER |
p02876 AtCoder Grand Contest 040 - Balance Beam_804 | We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
* First, Snuke connects the N beams in any order of his choice and m... | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;
import static java.util.Arrays.binarySearch;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
... | 4JAVA | {
"input": [
"3\n4 1\n5 2\n6 3",
"4\n1 5\n4 7\n2 1\n8 4",
"2\n3 2\n1 2",
"10\n866111664 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178",
"3\n1 1\n5 ... | 5ATCODER |
p03010 diverta 2019 Programming Contest 2 - Diverta City_805 | Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once... | #include<bits/stdc++.h>
using namespace std;
long long a1[13]={1,2,4,7,12,20,29,38,52,101},a2[13]={1,2,4,7,12,20,30,39,67,101},n,an[15][15],no=1;
int main(){
cin>>n;
for (int i=1;i<=n;i++)an[i][i]=0;
for (int i=1;i<=n;i++){
for (int j=i+1;j<=n;j++)an[i][j]=an[j][i]=no*a1[j-i-1];
no*=a2[n-i];
}
for (int i=1;i<=... | 2C++ | {
"input": [
"4",
"3",
"2",
"6",
"7",
"8",
"10",
"1",
"5",
"9",
"001",
"010",
"5",
"6",
"1",
"9",
"7",
"2",
"10",
"8",
"001",
"010"
],
"output": [
"0 111 157 193\n111 0 224 239\n157 224 0 258\n193 239 258 0",
"0 6 15\n... | 5ATCODER |
p03010 diverta 2019 Programming Contest 2 - Diverta City_806 | Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once... | from itertools import combinations, permutations
N = int(input())
# 整数列の生成
# s = [1]
# while len(s) < 10 :
# i = s[-1] + 1
# while True :
# path = s.copy() + [i]
# flag = True
# for comb in combinations(s + [i], 2) :
# if not sum(comb) in path :
# path.... | 3Python3 | {
"input": [
"4",
"3",
"2",
"6",
"7",
"8",
"10",
"1",
"5",
"9",
"001",
"010",
"5",
"6",
"1",
"9",
"7",
"2",
"10",
"8",
"001",
"010"
],
"output": [
"0 111 157 193\n111 0 224 239\n157 224 0 258\n193 239 258 0",
"0 6 15\n... | 5ATCODER |
p03010 diverta 2019 Programming Contest 2 - Diverta City_807 | Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once... | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
public class Main {
static InputStream is;
static PrintWriter out;
static String ... | 4JAVA | {
"input": [
"4",
"3",
"2",
"6",
"7",
"8",
"10",
"1",
"5",
"9",
"001",
"010",
"5",
"6",
"1",
"9",
"7",
"2",
"10",
"8",
"001",
"010"
],
"output": [
"0 111 157 193\n111 0 224 239\n157 224 0 258\n193 239 258 0",
"0 6 15\n... | 5ATCODER |
p03150 KEYENCE Programming Contest 2019 - KEYENCE String_808 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.
Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
Constraints
* The length of S is between 7 and 100 (inclusive).
* S consists of lowerc... | l = raw_input()
flag = False
if len(l) >= 6:
for i in range(7):
tmp = l[0:i] + l[-7+i:]
if tmp == "keyence":
flag = True
if flag == True:
print "YES"
else:
print "NO"
| 1Python2 | {
"input": [
"keyence",
"ashlfyha",
"keyofscience",
"mpyszsbznf",
"ecneyek",
"ashkfyha",
"eeyofscienck",
"mnyszsbzpf",
"ecneyel",
"arhkfyha",
"eeyofsciencj",
"mnyszsb{pf",
"ecleyen",
"arhkyfha",
"eeyofscienci",
"mnzszsb{pf",
"neyelce",
"ahfykhra"... | 5ATCODER |
p03150 KEYENCE Programming Contest 2019 - KEYENCE String_809 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.
Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
Constraints
* The length of S is between 7 and 100 (inclusive).
* S consists of lowerc... | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
string s, t = "keyence";
cin >> s;
for (int i = 0; i < s.length(); i++) {
for (int j = i - 1; j < s.length(); j++) {
if (s.substr(0, i) + s.substr(j + 1, s.length() - j + 1) == t) {
cout << "YES" << endl;
ret... | 2C++ | {
"input": [
"keyence",
"ashlfyha",
"keyofscience",
"mpyszsbznf",
"ecneyek",
"ashkfyha",
"eeyofscienck",
"mnyszsbzpf",
"ecneyel",
"arhkfyha",
"eeyofsciencj",
"mnyszsb{pf",
"ecleyen",
"arhkyfha",
"eeyofscienci",
"mnzszsb{pf",
"neyelce",
"ahfykhra"... | 5ATCODER |
p03150 KEYENCE Programming Contest 2019 - KEYENCE String_810 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.
Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
Constraints
* The length of S is between 7 and 100 (inclusive).
* S consists of lowerc... | S = input()
k = "keyence"
n = len(S)-7
for i in range(len(S)-n+1):
if S[:i]+S[i+n:] == k:
print("YES")
break
else:
print("NO")
| 3Python3 | {
"input": [
"keyence",
"ashlfyha",
"keyofscience",
"mpyszsbznf",
"ecneyek",
"ashkfyha",
"eeyofscienck",
"mnyszsbzpf",
"ecneyel",
"arhkfyha",
"eeyofsciencj",
"mnyszsb{pf",
"ecleyen",
"arhkyfha",
"eeyofscienci",
"mnzszsb{pf",
"neyelce",
"ahfykhra"... | 5ATCODER |
p03150 KEYENCE Programming Contest 2019 - KEYENCE String_811 | A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.
Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
Constraints
* The length of S is between 7 and 100 (inclusive).
* S consists of lowerc... |
public class Main {
private static void solve() {
char[] s = ns();
int n = s.length;
for (int i = 1; i <= n; i ++) {
for (int j = i; j < n; j ++) {
String a = new String(s, 0, i);
String b = new String(s, j, n - j);
if ((a + b).equals("keyence")) {
System.out.pri... | 4JAVA | {
"input": [
"keyence",
"ashlfyha",
"keyofscience",
"mpyszsbznf",
"ecneyek",
"ashkfyha",
"eeyofscienck",
"mnyszsbzpf",
"ecneyel",
"arhkfyha",
"eeyofsciencj",
"mnyszsb{pf",
"ecleyen",
"arhkyfha",
"eeyofscienci",
"mnzszsb{pf",
"neyelce",
"ahfykhra"... | 5ATCODER |
p03294 AtCoder Beginner Contest 103 - Modulo Summation_812 | You are given N positive integers a_1, a_2, ..., a_N.
For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).
Here, X\ mod\ Y denotes the remainder of the division of X by Y.
Find the maximum value of f.
Constraints
* All values in input are integers.
* 2 \leq N \leq 3000
* 2 ... | def gcd(x, y):
m = x
n = y
while n != 0L:
tmp = n
n = m % n
m = tmp
return m
n = int(raw_input())
a = map(long, raw_input().split())
lcm = 1L
for i in range(0, n):
lcm = lcm * a[i] / gcd(lcm, a[i])
sum = 0L
for i in range(0, n):
sum = sum + (lcm-1L) % a[i]
print sum | 1Python2 | {
"input": [
"5\n7 46 11 20 11",
"7\n994 518 941 851 647 2 581",
"3\n3 4 6",
"5\n7 46 11 17 11",
"7\n994 518 941 851 647 2 568",
"3\n3 1 6",
"5\n7 46 11 17 13",
"7\n994 518 941 523 647 2 568",
"3\n3 2 6",
"5\n7 13 11 17 13",
"7\n994 518 941 523 647 1 568",
"3\n3 3 6",
... | 5ATCODER |
p03294 AtCoder Beginner Contest 103 - Modulo Summation_813 | You are given N positive integers a_1, a_2, ..., a_N.
For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).
Here, X\ mod\ Y denotes the remainder of the division of X by Y.
Find the maximum value of f.
Constraints
* All values in input are integers.
* 2 \leq N \leq 3000
* 2 ... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0;
cin>>n;
for(int i=0,a;i<n;i++){
cin>>a;ans+=a-1;
}
cout<<ans<<endl;
} | 2C++ | {
"input": [
"5\n7 46 11 20 11",
"7\n994 518 941 851 647 2 581",
"3\n3 4 6",
"5\n7 46 11 17 11",
"7\n994 518 941 851 647 2 568",
"3\n3 1 6",
"5\n7 46 11 17 13",
"7\n994 518 941 523 647 2 568",
"3\n3 2 6",
"5\n7 13 11 17 13",
"7\n994 518 941 523 647 1 568",
"3\n3 3 6",
... | 5ATCODER |
p03294 AtCoder Beginner Contest 103 - Modulo Summation_814 | You are given N positive integers a_1, a_2, ..., a_N.
For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).
Here, X\ mod\ Y denotes the remainder of the division of X by Y.
Find the maximum value of f.
Constraints
* All values in input are integers.
* 2 \leq N \leq 3000
* 2 ... | N=int(input())
S=sum(list(map(int,input().split(' '))))
print(S-N) | 3Python3 | {
"input": [
"5\n7 46 11 20 11",
"7\n994 518 941 851 647 2 581",
"3\n3 4 6",
"5\n7 46 11 17 11",
"7\n994 518 941 851 647 2 568",
"3\n3 1 6",
"5\n7 46 11 17 13",
"7\n994 518 941 523 647 2 568",
"3\n3 2 6",
"5\n7 13 11 17 13",
"7\n994 518 941 523 647 1 568",
"3\n3 3 6",
... | 5ATCODER |
p03294 AtCoder Beginner Contest 103 - Modulo Summation_815 | You are given N positive integers a_1, a_2, ..., a_N.
For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).
Here, X\ mod\ Y denotes the remainder of the division of X by Y.
Find the maximum value of f.
Constraints
* All values in input are integers.
* 2 \leq N \leq 3000
* 2 ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int gokei = 0;
for(int i=0;i<N;i++) {
gokei+=sc.nextInt();
}
System.out.println(gokei-N);
}
} | 4JAVA | {
"input": [
"5\n7 46 11 20 11",
"7\n994 518 941 851 647 2 581",
"3\n3 4 6",
"5\n7 46 11 17 11",
"7\n994 518 941 851 647 2 568",
"3\n3 1 6",
"5\n7 46 11 17 13",
"7\n994 518 941 523 647 2 568",
"3\n3 2 6",
"5\n7 13 11 17 13",
"7\n994 518 941 523 647 1 568",
"3\n3 3 6",
... | 5ATCODER |
p03452 AtCoder Regular Contest 090 - People on a Line_816 | There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.
You will given M pieces of information regarding the positions of these people. The i-th piece of... | n,m = map(int,raw_input().split(" "))
pos = []
for a in range(100001):
pos.append([a,0])
def check(i):
k,x = pos[i]
if k != i:
k2,x2 = check(k)
pos[i] = [k2,x+x2]
return pos[i]
for a in range(m):
l,r,d = map(int,raw_input().split(" "))
lk,lx = check(l)
rk,rx = check(r)
if lk != rk:
t = ... | 1Python2 | {
"input": [
"3 3\n1 2 1\n2 3 1\n1 3 5",
"100 0",
"10 3\n8 7 100\n7 9 100\n9 8 100",
"3 3\n1 2 1\n2 3 1\n1 3 2",
"4 3\n2 1 1\n2 3 5\n3 4 2",
"000 0",
"10 3\n8 7 000\n7 9 100\n9 8 100",
"4 3\n2 1 1\n2 3 3\n3 4 2",
"10 3\n8 7 000\n7 9 110\n9 8 100",
"4 3\n1 1 1\n2 3 3\n3 4 2",
... | 5ATCODER |
p03452 AtCoder Regular Contest 090 - People on a Line_817 | There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.
You will given M pieces of information regarding the positions of these people. The i-th piece of... | #include <bits/stdc++.h>
using namespace std;
const int maxn=112345;
typedef pair<int,int> pii;
int n,m,l,r,x,d[maxn],vis[maxn];
vector<pii> G[maxn];
bool dfs(int u,int dep) {
vis[u]=1;
d[u]=dep;
for (int i=0;i<(int)G[u].size();++i) {
int v=G[u][i].first,w=G[u][i].second;
if (vis[v]&&d[u]+w!... | 2C++ | {
"input": [
"3 3\n1 2 1\n2 3 1\n1 3 5",
"100 0",
"10 3\n8 7 100\n7 9 100\n9 8 100",
"3 3\n1 2 1\n2 3 1\n1 3 2",
"4 3\n2 1 1\n2 3 5\n3 4 2",
"000 0",
"10 3\n8 7 000\n7 9 100\n9 8 100",
"4 3\n2 1 1\n2 3 3\n3 4 2",
"10 3\n8 7 000\n7 9 110\n9 8 100",
"4 3\n1 1 1\n2 3 3\n3 4 2",
... | 5ATCODER |
p03452 AtCoder Regular Contest 090 - People on a Line_818 | There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.
You will given M pieces of information regarding the positions of these people. The i-th piece of... | def inpl(): return [int(i) for i in input().split()]
def find(x):
if par[x] == x:
return x
else:
par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]
for _ in range(M):
l, r, d = inpl()
fl = find(l)
... | 3Python3 | {
"input": [
"3 3\n1 2 1\n2 3 1\n1 3 5",
"100 0",
"10 3\n8 7 100\n7 9 100\n9 8 100",
"3 3\n1 2 1\n2 3 1\n1 3 2",
"4 3\n2 1 1\n2 3 5\n3 4 2",
"000 0",
"10 3\n8 7 000\n7 9 100\n9 8 100",
"4 3\n2 1 1\n2 3 3\n3 4 2",
"10 3\n8 7 000\n7 9 110\n9 8 100",
"4 3\n1 1 1\n2 3 3\n3 4 2",
... | 5ATCODER |
p03452 AtCoder Regular Contest 090 - People on a Line_819 | There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.
You will given M pieces of information regarding the positions of these people. The i-th piece of... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class Main {
public stat... | 4JAVA | {
"input": [
"3 3\n1 2 1\n2 3 1\n1 3 5",
"100 0",
"10 3\n8 7 100\n7 9 100\n9 8 100",
"3 3\n1 2 1\n2 3 1\n1 3 2",
"4 3\n2 1 1\n2 3 5\n3 4 2",
"000 0",
"10 3\n8 7 000\n7 9 100\n9 8 100",
"4 3\n2 1 1\n2 3 3\n3 4 2",
"10 3\n8 7 000\n7 9 110\n9 8 100",
"4 3\n1 1 1\n2 3 3\n3 4 2",
... | 5ATCODER |
p03612 AtCoder Beginner Contest 072 - Derangement_820 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero):
Operation: Swap two adjacent elements in the permutation.
You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
Constraint... | from sys import stdin
di = {}
n = int(stdin.readline())
a = [0] + map(int,stdin.readline().split())
ans = 0
for i in xrange(1,n):
if a[i]==i:
x = a[i]
a[i] = a[i+1]
a[i+1] = x
ans+=1
if a[n]==n:
ans+=1
print ans | 1Python2 | {
"input": [
"5\n1 4 3 5 2",
"9\n1 2 4 9 5 8 7 3 6",
"2\n1 2",
"2\n2 1",
"5\n1 4 4 5 2",
"9\n1 2 4 9 5 8 7 6 6",
"9\n1 2 4 9 5 8 4 6 6",
"5\n0 4 4 5 1",
"2\n1 0",
"2\n1 1",
"5\n1 4 4 5 1",
"2\n1 -1",
"2\n0 2",
"9\n2 2 4 9 5 8 4 6 6",
"2\n2 2",
"2\n0 1",
... | 5ATCODER |
p03612 AtCoder Beginner Contest 072 - Derangement_821 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero):
Operation: Swap two adjacent elements in the permutation.
You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
Constraint... | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
int S = 0;
int seq = 0;
int p;
for(int i = 1; i <= N; i++) {
cin >> p;
if(i != p) {
S += seq / 2 + seq % 2;
seq = 0;
}
if(i == p) seq++;
}
S += seq / 2 + seq % 2;
cout << S << endl;
return 0;
} | 2C++ | {
"input": [
"5\n1 4 3 5 2",
"9\n1 2 4 9 5 8 7 3 6",
"2\n1 2",
"2\n2 1",
"5\n1 4 4 5 2",
"9\n1 2 4 9 5 8 7 6 6",
"9\n1 2 4 9 5 8 4 6 6",
"5\n0 4 4 5 1",
"2\n1 0",
"2\n1 1",
"5\n1 4 4 5 1",
"2\n1 -1",
"2\n0 2",
"9\n2 2 4 9 5 8 4 6 6",
"2\n2 2",
"2\n0 1",
... | 5ATCODER |
p03612 AtCoder Beginner Contest 072 - Derangement_822 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero):
Operation: Swap two adjacent elements in the permutation.
You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
Constraint... | N = int(input())
p = list(map(int, input().split()))
p.append(0)
cnt = 0
for i in range(N):
if p[i] == i + 1:
p[i], p[i+1] = p[i+1], p[i]
cnt += 1
print (cnt)
| 3Python3 | {
"input": [
"5\n1 4 3 5 2",
"9\n1 2 4 9 5 8 7 3 6",
"2\n1 2",
"2\n2 1",
"5\n1 4 4 5 2",
"9\n1 2 4 9 5 8 7 6 6",
"9\n1 2 4 9 5 8 4 6 6",
"5\n0 4 4 5 1",
"2\n1 0",
"2\n1 1",
"5\n1 4 4 5 1",
"2\n1 -1",
"2\n0 2",
"9\n2 2 4 9 5 8 4 6 6",
"2\n2 2",
"2\n0 1",
... | 5ATCODER |
p03612 AtCoder Beginner Contest 072 - Derangement_823 | You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero):
Operation: Swap two adjacent elements in the permutation.
You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
Constraint... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n+1];
for(int i=1;i<=n;i++){
a[i] = sc.nextInt();
}
int ans = 0;
for(int i=1;i<=n;i++){
if(a[i] == i){
ans++;
i++;
}
... | 4JAVA | {
"input": [
"5\n1 4 3 5 2",
"9\n1 2 4 9 5 8 7 3 6",
"2\n1 2",
"2\n2 1",
"5\n1 4 4 5 2",
"9\n1 2 4 9 5 8 7 6 6",
"9\n1 2 4 9 5 8 4 6 6",
"5\n0 4 4 5 1",
"2\n1 0",
"2\n1 1",
"5\n1 4 4 5 1",
"2\n1 -1",
"2\n0 2",
"9\n2 2 4 9 5 8 4 6 6",
"2\n2 2",
"2\n0 1",
... | 5ATCODER |
p03771 AtCoder Grand Contest 012 - Camel and Oases_824 | There are N oases on a number line. The coordinate of the i-th oases from the left is x_i.
Camel hopes to visit all these oases. Initially, the volume of the hump on his back is V. When the volume of the hump is v, water of volume at most v can be stored. Water is only supplied at oases. He can get as much water as he... | #include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define repd(i,n) for ((i)=(n);(i)>=1;(i)--)
using namespace std;
int n,m;
int i,j;
int a[200005],d[200005],lim[25];
int tor[200005][25],tol[200005][25];
int dppre[1<<19],dpsuf[1<<19];
void calc(int x){
int i;
rep(i,n){
tor[i][x]=tor[i-1][x];
... | 2C++ | {
"input": [
"7 2\n-10 -4 -2 0 2 4 10",
"16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 52 80 81 82 84",
"3 2\n1 3 6",
"7 4\n-10 -4 -2 0 2 4 10",
"16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 55 80 81 82 84",
"3 2\n1 3 2",
"16 19\n-49 -48 -24 -30 -21 -14 0 15 19 23 44 55 80 81 82 84",
"5... | 5ATCODER |
p03771 AtCoder Grand Contest 012 - Camel and Oases_825 | There are N oases on a number line. The coordinate of the i-th oases from the left is x_i.
Camel hopes to visit all these oases. Initially, the volume of the hump on his back is V. When the volume of the hump is v, water of volume at most v can be stored. Water is only supplied at oases. He can get as much water as he... | import java.io.*;
import java.util.*;
public class Main {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
void solve() throws IOException {
int n = nextInt();
int v = nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
int[] b = new int[n - 1];... | 4JAVA | {
"input": [
"7 2\n-10 -4 -2 0 2 4 10",
"16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 52 80 81 82 84",
"3 2\n1 3 6",
"7 4\n-10 -4 -2 0 2 4 10",
"16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 55 80 81 82 84",
"3 2\n1 3 2",
"16 19\n-49 -48 -24 -30 -21 -14 0 15 19 23 44 55 80 81 82 84",
"5... | 5ATCODER |
p03940 AtCoder Grand Contest 007 - Shik and Game_826 | Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all.
When the player gives a c... | from sys import stdin
from itertools import repeat
def main():
n, e, t = map(int, stdin.readline().split())
x = [0] + map(int, stdin.readline().split(), repeat(10, n)) + [e]
dp = [0] * (n + 1)
f = [0] * (n + 1)
f[0] = -x[1] * 2
j = 0
for i in xrange(1, n + 1):
while j < i - 1 and (x[... | 1Python2 | {
"input": [
"3 9 1\n1 3 8",
"2 1000000000 1000000000\n1 999999999",
"3 9 3\n1 3 8",
"3 9 1\n2 3 8",
"2 1000000000 1000000000\n1 199586132",
"3 9 3\n1 3 7",
"3 9 3\n1 0 7",
"2 1000001000 1000000000\n2 199586132",
"3 9 5\n1 0 7",
"2 1010001000 1000000000\n2 199586132",
"2 10... | 5ATCODER |
p03940 AtCoder Grand Contest 007 - Shik and Game_827 | Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all.
When the player gives a c... | //Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define inf 20021225
#define N 100100
using namespace std;
int read()
{
int s=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getch... | 2C++ | {
"input": [
"3 9 1\n1 3 8",
"2 1000000000 1000000000\n1 999999999",
"3 9 3\n1 3 8",
"3 9 1\n2 3 8",
"2 1000000000 1000000000\n1 199586132",
"3 9 3\n1 3 7",
"3 9 3\n1 0 7",
"2 1000001000 1000000000\n2 199586132",
"3 9 5\n1 0 7",
"2 1010001000 1000000000\n2 199586132",
"2 10... | 5ATCODER |
p03940 AtCoder Grand Contest 007 - Shik and Game_828 | Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all.
When the player gives a c... | import sys
readline = sys.stdin.readline
class Segtree:
def __init__(self, A, intv, initialize = True, segf = max):
self.N = len(A)
self.N0 = 2**(self.N-1).bit_length()
self.intv = intv
self.segf = segf
if initialize:
self.data = [intv]*self.N0 + A + [intv]*(self... | 3Python3 | {
"input": [
"3 9 1\n1 3 8",
"2 1000000000 1000000000\n1 999999999",
"3 9 3\n1 3 8",
"3 9 1\n2 3 8",
"2 1000000000 1000000000\n1 199586132",
"3 9 3\n1 3 7",
"3 9 3\n1 0 7",
"2 1000001000 1000000000\n2 199586132",
"3 9 5\n1 0 7",
"2 1010001000 1000000000\n2 199586132",
"2 10... | 5ATCODER |
p03940 AtCoder Grand Contest 007 - Shik and Game_829 | Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all.
When the player gives a c... | // -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream;
if (args.length > 0 && args[0].equals("devTesting")) {
try {
inputStream = new FileIn... | 4JAVA | {
"input": [
"3 9 1\n1 3 8",
"2 1000000000 1000000000\n1 999999999",
"3 9 3\n1 3 8",
"3 9 1\n2 3 8",
"2 1000000000 1000000000\n1 199586132",
"3 9 3\n1 3 7",
"3 9 3\n1 0 7",
"2 1000001000 1000000000\n2 199586132",
"3 9 5\n1 0 7",
"2 1010001000 1000000000\n2 199586132",
"2 10... | 5ATCODER |
p00032 Plastic Board_830 | There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t... | #!/usr/bin/env python
# coding: utf-8
import sys
def is_rectangle(side_a, side_b, diagonal):
if side_a == side_b:
return False
return (side_a ** 2 + side_b ** 2) == diagonal ** 2
def is_rhombus(side_a, side_b, diagonal):
if side_a != side_b:
return False
elif (side_a ** 2 + side_b *... | 1Python2 | {
"input": [
"3,4,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n5,4,3",
"3,3,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n3,4,5",
"3,4,5\n8,5,5\n4,5,4\n3,4,5",
"3,5,5\n6,5,8\n4,4,5\n5,4,3",
"3,3,5\n5,5,8\n3,4,4\n5,4,3",
"3,4,5\n8,5,5\n4,5,4\n5,4,3",
"4,4,5\n5,5,8\n4,5,4\n3,4,5",... | 6AIZU |
p00032 Plastic Board_831 | There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t... | #include <iostream>
using namespace std;
int main(void){
int rectangle=0, lozenge=0;
while (true){
int a,b,c;
char e;
cin>>a>>e>>b>>e>>c;
if (cin.eof()) break;
if (a==b) lozenge++;
if (a*a+b*b==c*c) rectangle++;
}
cout<<rectangle<<endl;
cout<<lozenge<<endl;
return 0;
} | 2C++ | {
"input": [
"3,4,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n5,4,3",
"3,3,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n3,4,5",
"3,4,5\n8,5,5\n4,5,4\n3,4,5",
"3,5,5\n6,5,8\n4,4,5\n5,4,3",
"3,3,5\n5,5,8\n3,4,4\n5,4,3",
"3,4,5\n8,5,5\n4,5,4\n5,4,3",
"4,4,5\n5,5,8\n4,5,4\n3,4,5",... | 6AIZU |
p00032 Plastic Board_832 | There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t... | rect = 0
loze = 0
while True:
try:
n, m, o = map(int, input().split(','))
if n ** 2 + m ** 2 == o ** 2:
rect += 1
if n == m:
loze += 1
except:
print(rect)
print(loze)
break | 3Python3 | {
"input": [
"3,4,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n5,4,3",
"3,3,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n3,4,5",
"3,4,5\n8,5,5\n4,5,4\n3,4,5",
"3,5,5\n6,5,8\n4,4,5\n5,4,3",
"3,3,5\n5,5,8\n3,4,4\n5,4,3",
"3,4,5\n8,5,5\n4,5,4\n5,4,3",
"4,4,5\n5,5,8\n4,5,4\n3,4,5",... | 6AIZU |
p00032 Plastic Board_833 | There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t... | import java.io.IOException;
import java.util.Scanner;
public class Main{
public static void main(String args[]) throws IOException{
Scanner stdin = new Scanner(System.in);
int tyo = 0;
int hishi = 0;
while(stdin.hasNext()){
String tmp = stdin.nextLine();
String[] str = tmp.split(",");
int a = Int... | 4JAVA | {
"input": [
"3,4,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n5,4,3",
"3,3,5\n5,5,8\n4,4,4\n5,4,3",
"3,4,5\n5,5,8\n4,5,4\n3,4,5",
"3,4,5\n8,5,5\n4,5,4\n3,4,5",
"3,5,5\n6,5,8\n4,4,5\n5,4,3",
"3,3,5\n5,5,8\n3,4,4\n5,4,3",
"3,4,5\n8,5,5\n4,5,4\n5,4,3",
"4,4,5\n5,5,8\n4,5,4\n3,4,5",... | 6AIZU |
p00163 Highway Toll_834 | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... | data = {(1,2):(6,300), (1,3):(13,500), (1,4):(18,600),
(1,5):(23,700), (1,6):(43,1350), (1,7):(58,1650),
(2,3):(7,350), (2,4):(12,450), (2,5):(17,600),
(2,6):(37,1150),(2,7):(52,1500), (3,4):(5,250),
(3,5):(10,400), (3,6):(30,1000), (3,7):(45,1350),
(4,5):(5,250), (4,6):(25,... | 1Python2 | {
"input": [
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0",
"2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0",
"2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0",
"2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0",
"2\n13 25\n3\... | 6AIZU |
p00163 Highway Toll_835 | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... |
#include<iostream>
using namespace std;
int main()
{
int list[7][7]={
{0,300,500,600,700,1350,1650},
{6,0,350,450,600,1150,1500},
{13,7,0,250,400,1000,1350},
{18,12,5,0,250,850,1300},
{23,17,10,5,0,600,1150},
{43,37,30,25,20,0,500},
{58,52,45,40,35,15,0}
};
int in,out,h,m,start,end,f... | 2C++ | {
"input": [
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0",
"2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0",
"2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0",
"2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0",
"2\n13 25\n3\... | 6AIZU |
p00163 Highway Toll_836 | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... | # Aizu Problem 00163: Highway Tooll
#
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
M = [[0, 300, 500, 600, 700,1350,1650],
[6, 0, 350, 450, 600,1150,1500],
[13, 7, 0, 250, 400,1000,1350],
[18, 12, 5,... | 3Python3 | {
"input": [
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0",
"2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0",
"2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0",
"2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0",
"2\n13 25\n3\... | 6AIZU |
p00163 Highway Toll_837 | In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a... | import java.util.Scanner;
//Highway Toll
public class Main{
public static void main(String[] args) {
int[][] p = {
{0,300,500,600,700,1350,1650},
{300,0,350,450,600,1150,1500},
{500,350,0,250,400,1000,1350},
{600,450,250,0,250,850,1300},
{700,600,400,250,0,600,1150},
{1350,1150,1000,850,600... | 4JAVA | {
"input": [
"2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0",
"2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0",
"2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0",
"2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0",
"2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0",
"2\n13 25\n3\... | 6AIZU |
p00320 Cuboid_838 | The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or ... | #include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _rep1(n) _rep2(i,n)
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(... | 2C++ | {
"input": [
"2 2\n2 3\n2 3\n2 3\n2 2\n3 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 2\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2 3\n2 2\n2 2\n10 2",
"2 2\n2 3\n4 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2... | 6AIZU |
p00320 Cuboid_839 | The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or ... | lst = [set(map(int, input().split())) for _ in range(6)]
rec = []
while lst:
x = lst[0]
count = lst.count(x)
if count % 2 == 1:
print("no")
break
rec.append((count, x))
for _ in range(count):
lst.pop(lst.index(x))
else:
if len(rec) == 1:
if len(rec[0][1]) == 1:
print("yes")
else:
... | 3Python3 | {
"input": [
"2 2\n2 3\n2 3\n2 3\n2 2\n3 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 2\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2 3\n2 2\n2 2\n10 2",
"2 2\n2 3\n4 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2... | 6AIZU |
p00320 Cuboid_840 | The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or ... | import java.util.*;
class Main{
boolean check(){
Scanner sc = new Scanner(System.in);
Pair[] D = new Pair[6];
for ( int i = 0; i < 6; i++ ) {
D[i] = new Pair(0, 0);
D[i].first = sc.nextInt();
D[i].second = sc.nextInt();
if ( D[i].first > D[i... | 4JAVA | {
"input": [
"2 2\n2 3\n2 3\n2 3\n2 2\n3 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 3\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 2",
"2 2\n2 3\n2 3\n2 2\n2 2\n5 2",
"2 2\n2 3\n2 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2 3\n2 2\n2 2\n10 2",
"2 2\n2 3\n4 2\n2 3\n2 2\n2 3",
"2 2\n2 3\n2... | 6AIZU |
p00490 Best Pizza_841 | problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi... | N = input()
A,B = map(int, raw_input().split())
C = input()
D = [input() for _ in range(N)]
D = sorted(D)[::-1]
price = A
cal = C
ans = cal/price
for d in D:
cal += d
price += B
ans = max(ans, cal/price)
print ans | 1Python2 | {
"input": [
"3\n12 2\n200\n50\n300\n100",
"3\n12 2\n200\n50\n300\n110",
"3\n17 2\n200\n73\n300\n110",
"3\n12 2\n200\n50\n599\n100",
"3\n12 2\n200\n73\n575\n110",
"3\n17 2\n200\n50\n300\n010",
"3\n17 2\n63\n50\n300\n010",
"3\n12 2\n200\n54\n506\n110",
"3\n17 2\n38\n50\n300\n010",
... | 6AIZU |
p00490 Best Pizza_842 | problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi... | #include<algorithm>
#include<functional>
#include<iostream>
int N;
int A, B, C;
int D[100];
int main()
{
std::cin >> N >> A >> B >> C;
for( int i = 0; i != N; ++i )
std::cin >> D[i];
std::sort( D, D + N, std::greater<int>() );
int sum = 0, ans = 0;
for( int i = 0; i != N; ++i )
{
sum += D[i];
ans = std:... | 2C++ | {
"input": [
"3\n12 2\n200\n50\n300\n100",
"3\n12 2\n200\n50\n300\n110",
"3\n17 2\n200\n73\n300\n110",
"3\n12 2\n200\n50\n599\n100",
"3\n12 2\n200\n73\n575\n110",
"3\n17 2\n200\n50\n300\n010",
"3\n17 2\n63\n50\n300\n010",
"3\n12 2\n200\n54\n506\n110",
"3\n17 2\n38\n50\n300\n010",
... | 6AIZU |
p00490 Best Pizza_843 | problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi... | #C
N = int(input())
A,B = map(int,input().split())
C = int(input())
T = [int(input()) for i in range(N)]
T.sort(reverse=True)
cal = C
cost = A
for t in T:
if cal/cost < (cal+t)/(cost+B):
cal+=t
cost+=B
else:
break
print(cal//cost)
| 3Python3 | {
"input": [
"3\n12 2\n200\n50\n300\n100",
"3\n12 2\n200\n50\n300\n110",
"3\n17 2\n200\n73\n300\n110",
"3\n12 2\n200\n50\n599\n100",
"3\n12 2\n200\n73\n575\n110",
"3\n17 2\n200\n50\n300\n010",
"3\n17 2\n63\n50\n300\n010",
"3\n12 2\n200\n54\n506\n110",
"3\n17 2\n38\n50\n300\n010",
... | 6AIZU |
p00490 Best Pizza_844 | problem
Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi... | import java.util.Scanner;
import java.util.Arrays;
public class Main{
public static void main(String[] args){
new Main().run();
}
public void run(){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int a = scan.nextInt();
int b = scan.nextInt();
int cal = scan.nextInt();
int max = cal / a... | 4JAVA | {
"input": [
"3\n12 2\n200\n50\n300\n100",
"3\n12 2\n200\n50\n300\n110",
"3\n17 2\n200\n73\n300\n110",
"3\n12 2\n200\n50\n599\n100",
"3\n12 2\n200\n73\n575\n110",
"3\n17 2\n200\n50\n300\n010",
"3\n17 2\n63\n50\n300\n010",
"3\n12 2\n200\n54\n506\n110",
"3\n17 2\n38\n50\n300\n010",
... | 6AIZU |
p00676 KND is So Sexy_845 | Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l... | import math
while True:
try:
a,l,x=map(int,raw_input().split())
except EOFError:
break
ANS=math.sqrt(pow(l,2)-pow(a/2.0,2))*a/2+math.sqrt(pow((l+x)/2.0,2)-pow(l/2.0,2))*l/2*2
print ANS
| 1Python2 | {
"input": [
"2 2 1\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n3 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 5",
"2 2 1\n2 3 1\n3 2 5\n1 3 5",
"2 2 0\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n1 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 0",
"2 2 1\n2 3 1\n1 2 5\n1 3 5",
"2 2 0\n2 3 0\n3 2 3\n2 3 5",... | 6AIZU |
p00676 KND is So Sexy_846 | Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l... | #include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep... | 2C++ | {
"input": [
"2 2 1\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n3 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 5",
"2 2 1\n2 3 1\n3 2 5\n1 3 5",
"2 2 0\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n1 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 0",
"2 2 1\n2 3 1\n1 2 5\n1 3 5",
"2 2 0\n2 3 0\n3 2 3\n2 3 5",... | 6AIZU |
p00676 KND is So Sexy_847 | Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l... | import math
while True:
try:
a,l,x=map(int, input().split())
temp=(l+x)/2
except EOFError:
break
def heron(i,j,k):
d = (i+j+k)/2
return math.sqrt(d*(d-i)*(d-j)*(d-k))
print((str(heron(a,l,l)+heron(l,temp,temp)*2)))
| 3Python3 | {
"input": [
"2 2 1\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n3 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 5",
"2 2 1\n2 3 1\n3 2 5\n1 3 5",
"2 2 0\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n1 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 0",
"2 2 1\n2 3 1\n1 2 5\n1 3 5",
"2 2 0\n2 3 0\n3 2 3\n2 3 5",... | 6AIZU |
p00676 KND is So Sexy_848 | Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l... | import java.util.*;
public class Main {
public static void main(String args[]) {
solve1091();
}
public static void solve1091() {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a = sc.nextInt();
int l = sc.nextInt();
int x = sc.ne... | 4JAVA | {
"input": [
"2 2 1\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n3 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 5",
"2 2 1\n2 3 1\n3 2 5\n1 3 5",
"2 2 0\n2 3 1\n3 2 3\n2 3 5",
"2 2 1\n2 3 1\n1 2 3\n1 3 5",
"4 2 1\n2 3 1\n3 2 3\n1 3 0",
"2 2 1\n2 3 1\n1 2 5\n1 3 5",
"2 2 0\n2 3 0\n3 2 3\n2 3 5",... | 6AIZU |
p00819 Unreliable Message_849 | The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A... | def correct(m, s):
if m == "J":
return s[-1] + s[:len(s)-1]
elif m == "C":
return s[1:] + s[0]
elif m == "E":
length = len(s)
if length % 2 == 0:
return s[length / 2:] + s[:length / 2]
else :
return s[(length+1) / 2:] + s[(length-1) / 2] + s[:(length-1) / 2]
elif m == "A":
return s[::-1]
elif m =... | 1Python2 | {
"input": [
"5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM... | 6AIZU |
p00819 Unreliable Message_850 | The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A... | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 1e8
using namespace std;
bool is_digit(char x){
for(int i=48; i<=57; i++){
if(x == i) return true;
}
return false;
}
int main(){
int n;
cin >> n;
rep(k,n){
string s,t;
cin >> s >> t;
for... | 2C++ | {
"input": [
"5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM... | 6AIZU |
p00819 Unreliable Message_851 | The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... | 3Python3 | {
"input": [
"5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM... | 6AIZU |
p00819 Unreliable Message_852 | The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A... | import java.util.Scanner;
public class Main{
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int N = sc.nextInt();
while(N-->0){
String s = sc.next();
String t = sc.next();
for (int i = 0;... | 4JAVA | {
"input": [
"5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf",
"5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM... | 6AIZU |
p00950 Infallibly Crack Perplexing Cryptarithm_853 | Example
Input
ACM
Output
0 | #include <bits/stdc++.h>
using namespace std;
typedef pair<string,string> P;
int bnf();
set<P> used;
map<char,int> M;
string S;
int idx,valid;
char ch[8]={'0','1','+','-','*','(',')','='};
int ord[8];
bool check(string a){//??????????????????°???¨???????????????????????¢????
int par=0;
for(char s:a){
par += (... | 2C++ | {
"input": [
"ACM",
"ABM",
"BIB",
"1MI",
"MCA",
"MAC",
"M@C",
"C@M",
"@MC",
"?MC",
"M?C",
"C?M",
"CM?",
"DM?",
"?MD",
"@MD",
"@ME",
"@EM",
"@DM",
"MD@",
"@CM",
"@CN",
"NC@",
"CN@",
"@NC",
"@OC",
"@CO",
"C@O... | 6AIZU |
p00950 Infallibly Crack Perplexing Cryptarithm_854 | Example
Input
ACM
Output
0 | from itertools import permutations
base = "=+-*()01"
s = input()
l = len(s)
mapping = {}
counter = {}
cnt = 0
for c in s:
if c in base:
continue
if c not in mapping:
mapping[c] = cnt
cnt += 1
v = mapping[c]
counter[v] = counter.get(v, 0) + 1
if cnt > 8:
print(0)
exit(0)
... | 3Python3 | {
"input": [
"ACM",
"ABM",
"BIB",
"1MI",
"MCA",
"MAC",
"M@C",
"C@M",
"@MC",
"?MC",
"M?C",
"C?M",
"CM?",
"DM?",
"?MD",
"@MD",
"@ME",
"@EM",
"@DM",
"MD@",
"@CM",
"@CN",
"NC@",
"CN@",
"@NC",
"@OC",
"@CO",
"C@O... | 6AIZU |
p01083 RedBlue_855 | Story
At UZIA High School in the sky city AIZU, the club activities of competitive programming are very active. N Red Coders and n Blue Coders belong to this club.
One day, during club activities, Red Coder and Blue Coder formed a pair, and from this club activity, n groups participated in a contest called KCP. At th... | #include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-5;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
typedef complex<do... | 2C++ | {
"input": [
"2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n8 7",
"2\n3 3 2\n8 3 2\n0 3\n3 7\n8 0\n8 7",
"1\n10 10 10\n31 10 10\n15 19\n26 1",
"2\n3 3 2\n8 3 2\n0 0\n0 5\n11 0\n11 5",
"2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n5 7",
"2\n3 3 2\n8 3 2\n1 3\n3 7\n8 0\n8 7",
"1\n10 10 17\n31 10 10\n15 19\n26 1",
... | 6AIZU |
p01219 Private Teacher_856 | You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard.
You know days of the week convenient for each pupil, and also know how many lessons you have to give to him or her. You can give just ... | #include<cstdio>
#include<numeric>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int V_MAX=109;
const int E_MAX=1000;
template<class T>
struct graph{
int n,m,head[V_MAX],next[2*E_MAX],to[2*E_MAX];
T capa[2*E_MAX],flow[2*E_MAX];
void init(int N){
... | 2C++ | {
"input": [
"2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nThursday Friday Saturday Sunday\n0 0",
"2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nTsurhday Friday Saturday S... | 6AIZU |
p01219 Private Teacher_857 | You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard.
You know days of the week convenient for each pupil, and also know how many lessons you have to give to him or her. You can give just ... | import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
//Private Teacher
public class Main{
long augumentPath(int v, int t, long f, long[][] cap, boolean[] used){
if(v==t)return f;
used[v] = true;
for(int i=0;i<cap[v].length;i++){
if(cap[v][i]>0 && !used[i]){
... | 4JAVA | {
"input": [
"2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nThursday Friday Saturday Sunday\n0 0",
"2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nTsurhday Friday Saturday S... | 6AIZU |
p01353 Rabbit Plays Games!_858 | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ... | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(10000000)
n = input()
H, A, D, S = map(int, raw_input().split())
ans = 0
flag = False
ls = []
for i in range(n):
h, a, d, s = map(int, raw_input().split())
a -= D
if s < S:
ans ... | 1Python2 | {
"input": [
"1\n1 1 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n2 2 1 1",
"1\n1 0 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n1 2 1 1",
"2\n10 3 1 2\n2 4 1 3\n1 3 1 1",
"2\n10 3 1 2\n3 4 1 3\n1 3 1 1",
"2\n10 3 2 2\n3 4 1 3\n1 3 1 1",
"1\n1 0 1 1\n10000 10010 10000... | 6AIZU |
p01353 Rabbit Plays Games!_859 | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ... | #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
struct Data {
ll h, a, d, s;
Data() {}
Data(ll h, ll a, ll d, ll s) :
h{h}, a{a}, d{d}, s{s} {}
bool operator < (const Data& d) const {
return s < d.s;
}
};... | 2C++ | {
"input": [
"1\n1 1 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n2 2 1 1",
"1\n1 0 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n1 2 1 1",
"2\n10 3 1 2\n2 4 1 3\n1 3 1 1",
"2\n10 3 1 2\n3 4 1 3\n1 3 1 1",
"2\n10 3 2 2\n3 4 1 3\n1 3 1 1",
"1\n1 0 1 1\n10000 10010 10000... | 6AIZU |
p01353 Rabbit Plays Games!_860 | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N = int(readline())
ha, aa, da, sa = map(int, readline().split())
ans = 0
S = []
for i in range(N):
hi, ai, di, si = map(int, readline().split())
m0 = max(ai - da, 0)
if si > sa:
ans +... | 3Python3 | {
"input": [
"1\n1 1 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n2 2 1 1",
"1\n1 0 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n1 2 1 1",
"2\n10 3 1 2\n2 4 1 3\n1 3 1 1",
"2\n10 3 1 2\n3 4 1 3\n1 3 1 1",
"2\n10 3 2 2\n3 4 1 3\n1 3 1 1",
"1\n1 0 1 1\n10000 10010 10000... | 6AIZU |
p01353 Rabbit Plays Games!_861 | A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int[][] e = new int[n][5];
long sum = 0;
long dmg = 0;
boolean... | 4JAVA | {
"input": [
"1\n1 1 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n2 2 1 1",
"1\n1 0 1 1\n10000 10000 10000 10000",
"2\n10 3 1 2\n2 4 1 3\n1 2 1 1",
"2\n10 3 1 2\n2 4 1 3\n1 3 1 1",
"2\n10 3 1 2\n3 4 1 3\n1 3 1 1",
"2\n10 3 2 2\n3 4 1 3\n1 3 1 1",
"1\n1 0 1 1\n10000 10010 10000... | 6AIZU |
p01535 Markup language has Declined_862 | E: Markup language has declined
It's been centuries since we humans have been declining slowly. The earth may already belong to "Progurama". Programa-sans with an average height of 170 cm, 7 heads, high intelligence, and loves Kodingu. I have returned to my hometown of Nibunki, becoming an important international civi... | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
struct Node;
struct Fun;
int h, w, cr, cc;
char scr[512][512];
Node *lnk[512][512];
Fun *evt[512][512];
map<string, vector<pair<stri... | 2C++ | {
"input": [
"1\nindex.dml\n<dml><title>Markup language has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index",
"1\nindex.dml\n<dml><title>Markup aangulge has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index",
"1\nindex.dml\n<dml><title>Markup aangulge sah Declined</title><br>Progra... | 6AIZU |
p01691 Disappear Drive_863 | E --Disappear Drive
Story
The person in D likes basketball, but he likes shooting, so other techniques are crazy. I'm not particularly good at dribbling, and when I enter the opponent's defensive range, I always get the ball stolen. So I decided to come up with a deadly dribble that would surely pull out any opponent... | #include <bits/stdc++.h>
using namespace std;
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<endl)
struct DUMP : stringstream {
template<class T>
DUMP &operator,(const T &t) {
if(this->tellp()) *this << ", ";
*this << t;
return *this;
}
};
constexpr double EPS = 1e-8;
struct point... | 2C++ | {
"input": [
"1 0\n25 47 10",
"1 0\n25 47 15",
"1 0\n16 47 15",
"1 0\n31 47 15",
"2 0\n31 47 13",
"2 0\n31 47 20",
"2 0\n31 47 33",
"1 0\n25 38 10",
"1 0\n25 61 15",
"1 0\n16 57 15",
"1 0\n31 18 15",
"2 0\n31 47 11",
"2 0\n1 47 20",
"1 0\n25 58 10",
"2 0\n31... | 6AIZU |
p01835 Donut Decoration_864 | Example
Input
3 2
3
1 2 1
2 3 2
3 3 1
Output
1 | #include <bits/stdc++.h>
using namespace std;
struct SegmentTree
{
vector< pair< int, int > > seg;
int sz;
SegmentTree(int n)
{
sz = 1;
while(sz < n) sz <<= 1;
seg.assign(2 * sz - 1, make_pair(0, 0));
}
void push(int k)
{
if(k >= sz - 1 || seg[k] == make_pair(0, 0)) return;
if(seg[... | 2C++ | {
"input": [
"3 2\n3\n1 2 1\n2 3 2\n3 3 1",
"2 2\n3\n1 2 1\n2 3 2\n3 3 1",
"3 2\n1\n1 2 1\n2 3 2\n3 3 1",
"2 2\n3\n2 2 1\n2 3 2\n3 3 1",
"3 2\n1\n1 1 1\n2 3 2\n3 3 1",
"0 2\n3\n1 2 1\n2 3 2\n3 3 1",
"0 2\n3\n1 2 1\n2 3 0\n3 3 1",
"2 2\n3\n2 2 1\n2 3 4\n3 3 1",
"3 2\n1\n1 2 1\n2 3 2... | 6AIZU |
p01835 Donut Decoration_865 | Example
Input
3 2
3
1 2 1
2 3 2
3 3 1
Output
1 | import sys
class Set:
__slots__ = ["data", "one", "N", "N0", "size"]
def __init__(self, N):
self.data = [0]*(N+1)
self.one = [0]*(N+1)
self.N = N
self.N0 = 2**(N.bit_length()-1)
self.size = 0
def __get(self, k):
s = 0
data = self.data
while ... | 3Python3 | {
"input": [
"3 2\n3\n1 2 1\n2 3 2\n3 3 1",
"2 2\n3\n1 2 1\n2 3 2\n3 3 1",
"3 2\n1\n1 2 1\n2 3 2\n3 3 1",
"2 2\n3\n2 2 1\n2 3 2\n3 3 1",
"3 2\n1\n1 1 1\n2 3 2\n3 3 1",
"0 2\n3\n1 2 1\n2 3 2\n3 3 1",
"0 2\n3\n1 2 1\n2 3 0\n3 3 1",
"2 2\n3\n2 2 1\n2 3 4\n3 3 1",
"3 2\n1\n1 2 1\n2 3 2... | 6AIZU |
p01970 The Diversity of Prime Factorization_866 | D: The Diversity of Prime Factorization
Problem
Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces.
In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ... | #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> sieve_of_eratosthenes(int n) {
vector<int> primes(n);
for (int... | 2C++ | {
"input": [
"3\n2 3 3",
"3\n2 3 6",
"3\n2 3 11",
"3\n3 2 3",
"3\n2 5 3",
"3\n2 2 3",
"3\n2 2 11",
"3\n3 2 6",
"3\n2 2 13",
"3\n4 2 6",
"3\n2 2 0",
"3\n4 2 2",
"3\n3 2 0",
"3\n2 2 2",
"3\n2 3 2",
"3\n2 1 2",
"3\n2 1 0",
"3\n2 2 1",
"3\n4 2 1"... | 6AIZU |
p01970 The Diversity of Prime Factorization_867 | D: The Diversity of Prime Factorization
Problem
Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces.
In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ... | from collections import defaultdict
MAX = 1000000
ROOT = 1000
MOD = 1000000007
is_prime = [True] * (MAX + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, ROOT + 1):
if is_prime[i]:
for j in range(i * i, MAX + 1, i):
is_prime[j] = False
n = int(input())
qlst = list(map(int, input().split()))
total1 =... | 3Python3 | {
"input": [
"3\n2 3 3",
"3\n2 3 6",
"3\n2 3 11",
"3\n3 2 3",
"3\n2 5 3",
"3\n2 2 3",
"3\n2 2 11",
"3\n3 2 6",
"3\n2 2 13",
"3\n4 2 6",
"3\n2 2 0",
"3\n4 2 2",
"3\n3 2 0",
"3\n2 2 2",
"3\n2 3 2",
"3\n2 1 2",
"3\n2 1 0",
"3\n2 2 1",
"3\n4 2 1"... | 6AIZU |
p01970 The Diversity of Prime Factorization_868 | D: The Diversity of Prime Factorization
Problem
Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces.
In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ... | import java.util.*;
public class Main {
static final int MOD = 1000000007;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean[] isNotPrimes = new boolean[1000001];
isNotPrimes[0] = true;
isNotPrimes[1] = true;
for (int i = 2; i < isNotP... | 4JAVA | {
"input": [
"3\n2 3 3",
"3\n2 3 6",
"3\n2 3 11",
"3\n3 2 3",
"3\n2 5 3",
"3\n2 2 3",
"3\n2 2 11",
"3\n3 2 6",
"3\n2 2 13",
"3\n4 2 6",
"3\n2 2 0",
"3\n4 2 2",
"3\n3 2 0",
"3\n2 2 2",
"3\n2 3 2",
"3\n2 1 2",
"3\n2 1 0",
"3\n2 2 1",
"3\n4 2 1"... | 6AIZU |
p02117 Picnic_869 | Problem
Tomorrow is finally the day of the excursion to Maizu Elementary School. Gatcho, who attends Maizu Elementary School, noticed that he had forgotten to buy tomorrow's sweets because he was so excited. Gaccho wants to stick to sweets so that he can enjoy the excursion to the fullest.
Gaccho gets a $ X $ yen al... | #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> PP;
const int N=14;
int dp1[N][1001],c[N][N],dp2[1<<N][N],dp3[2][1<<(N/2+1)][1001],dp[1<<N][1001],ans;
vector<PP> a[N+1];
int main() {
int A,B,n;
cin >> n >> A >> B;
for(int k=0; k<n; k++) {... | 2C++ | {
"input": [
"3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0",
"4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0",
"1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0",
"2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0",
... | 6AIZU |
p02257 Prime Numbers_870 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbers in the list.
Constraints
1 ≤ N ≤ 10000
2 ≤ an element of the ... | n = int(raw_input())
a = []
for i in range(n):
a.append(int(raw_input()))
nprimes = 0
a = sorted(a)
while True:
for d in range(2,10001):
if d**2>a[0]:
nprimes+=1
del a[0]
break
elif a[0]%d==0:
del a[0]
break
if len(a) <= 0:
... | 1Python2 | {
"input": [
"5\n2\n3\n4\n5\n6",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17",
"11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17",
"5\n2\n4\n7\n5\n6",
"11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11... | 6AIZU |
p02257 Prime Numbers_871 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbers in the list.
Constraints
1 ≤ N ≤ 10000
2 ≤ an element of the ... | #include<iostream>
using namespace std;
bool prime(int p){
for(int i=2;i*i<=p;i++)
if(!(p%i))return false;
return true;
}
int main(){
int n,p,ans=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> p;
if(prime(p))ans++;
}
cout << ans << endl;
} | 2C++ | {
"input": [
"5\n2\n3\n4\n5\n6",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17",
"11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17",
"5\n2\n4\n7\n5\n6",
"11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11... | 6AIZU |
p02257 Prime Numbers_872 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbers in the list.
Constraints
1 ≤ N ≤ 10000
2 ≤ an element of the ... | import math
n = int(input())
count = 0
for i in range(n):
t = int(input())
a = int(t ** (1 / 2))
end = 0
for j in range(2, a + 1):
if t % j == 0:
end = 1
break
if end == 0:
count += 1
print(count)
| 3Python3 | {
"input": [
"5\n2\n3\n4\n5\n6",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17",
"11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17",
"5\n2\n4\n7\n5\n6",
"11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11... | 6AIZU |
p02257 Prime Numbers_873 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbers in the list.
Constraints
1 ≤ N ≤ 10000
2 ≤ an element of the ... | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int ans = 0;
for(int i = 0; i< n ; i++){
int now = Integer.parseInt(br.r... | 4JAVA | {
"input": [
"5\n2\n3\n4\n5\n6",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17",
"11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17",
"11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17",
"5\n2\n4\n7\n5\n6",
"11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27",
"11... | 6AIZU |
p02405 Print a Chessboard_874 | Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Constraints
* 1 ≤ H ≤ 300
* 1... |
import sys
write = sys.stdout.write
while True:
entry = map(int, raw_input().split())
H = entry[0]
W = entry[1]
if H == 0 and W == 0:
break
for j in range(H):
for k in range(W):
if (j + k) % 2 == 0:
write("#")
else:
write... | 1Python2 | {
"input": [
"3 4\n5 6\n3 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 11\n5 6\n3 0\n2 2\n1 0\n0 0",
"3 4\n5 6\n2 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 4\n1 0\n0 0",
"3 7\n5 6\n4... | 6AIZU |
p02405 Print a Chessboard_875 | Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Constraints
* 1 ≤ H ≤ 300
* 1... | #include<bits/stdc++.h>
using namespace std;
int main(){
int h,w;
while(cin>>h>>w,h+w!=0){
for(int i=0;i<h;++i){
for(int j=0;j<w;++j){
cout<<(((i+j)%2==0)?"#":".");
}
cout<<endl;
}
cout<<endl;
}
}
| 2C++ | {
"input": [
"3 4\n5 6\n3 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 11\n5 6\n3 0\n2 2\n1 0\n0 0",
"3 4\n5 6\n2 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 4\n1 0\n0 0",
"3 7\n5 6\n4... | 6AIZU |
p02405 Print a Chessboard_876 | Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Constraints
* 1 ≤ H ≤ 300
* 1... | while True:
a,b = map(int, input().split())
if a==b == 0:
break
for i in range(a):
s = ""
for j in range(b):
s += "#" if (i+j) % 2 == 0 else "."
print(s)
print("")
| 3Python3 | {
"input": [
"3 4\n5 6\n3 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 11\n5 6\n3 0\n2 2\n1 0\n0 0",
"3 4\n5 6\n2 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 4\n1 0\n0 0",
"3 7\n5 6\n4... | 6AIZU |
p02405 Print a Chessboard_877 | Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Constraints
* 1 ≤ H ≤ 300
* 1... | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
int g,r;
Scanner scan = new Scanner(System.in);
while(true)
{
boolean bool=false;
g = scan.nextInt();
r = scan.nextInt();
if( (g|r) == 0) break;
for(int i=0; i<g; i++)
{
for(int j=0; j<r; j++)
... | 4JAVA | {
"input": [
"3 4\n5 6\n3 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 3\n2 2\n1 0\n0 0",
"3 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 7\n5 6\n3 0\n2 2\n1 0\n0 0",
"6 11\n5 6\n3 0\n2 2\n1 0\n0 0",
"3 4\n5 6\n2 3\n2 2\n1 1\n0 0",
"3 4\n5 6\n3 3\n2 4\n1 0\n0 0",
"3 7\n5 6\n4... | 6AIZU |
anuwta_878 | There are N+1 lights. Lights are placed at (0, 0), (1, 0), (2, 0) ... (N, 0). Initially all the lights are on. You want to turn off all of them one after one. You want to follow a special pattern in turning off the lights.
You will start at (0, 0). First, you walk to the right most light that is on, turn it off. Th... | # cook your code here
T = int(raw_input())
while T:
n = int(raw_input())
print (n*(n+1)/2)+n
T = T - 1 | 1Python2 | {
"input": [
"2\n1\n2",
"2\n1\n4",
"2\n2\n4",
"2\n2\n1",
"2\n0\n1",
"2\n0\n2",
"2\n2\n2",
"2\n4\n2",
"2\n2\n3",
"2\n3\n2",
"2\n0\n0",
"2\n-1\n0",
"2\n-1\n-1",
"2\n-3\n-1",
"2\n-3\n-6",
"2\n-4\n0",
"2\n-1\n2",
"2\n-1\n1",
"2\n1\n1",
"2\n2\... | 1CODECHEF |
chsparr_879 | Chef has a an array A consisting of N elements. He wants to add some elements into the array as per the below mentioned process.
After each minute, Chef iterates over the array in order from left to right, and takes every two neighbouring pair of elements, say x and y, he adds a new element x + y in the middle of eleme... | p=10**9+7;
def modpow(x,n):
if(n==0):
return 1;
elif(n%2==0):
m=modpow(x,n/2);
return (m*m)%p;
else:
m=modpow(x,n/2);
return (m*m*x)%p;
def modinv(x):
return modpow(x,p-2);
inv2=modinv(2);
mods=[1]*31;
mod2s=[1]*31;
for i in range(1,31):
mods[i]=(mods[i-1]*3)%p;
mod2s[i]=(mod2s[i-1]*2);
#A:0 in... | 1Python2 | {
"input": [
"2\n3 1 1 5\n1 6 9\n3 2 6 7\n1 6 9"
],
"output": [
"38\n36"
]
} | 1CODECHEF |
etmx05_880 | Middle Strings
Miss Roma has got a new job in a computer agency. To test her skills the manager has appointed her with a small project.
She will get a string of any length but of ODD length and what she has to do
is finding a center string of length 3 in the original string.
For Example: She gets a string 'CANDY' the... | x=raw_input()
l=len(x)
if l>=3:
l=l/2
print x[l-1:l+2]
else:
print "0" | 1Python2 | {
"input": [
"CANDY",
"SOLVING"
],
"output": [
"AND",
"LVI"
]
} | 1CODECHEF |
laddu_881 | You might have heard about our new goodie distribution program aka the "Laddu Accrual System". This problem is designed to give you a glimpse of its rules. You can read the page once before attempting the problem if you wish, nonetheless we will be providing all the information needed here itself.
Laddu Accrual Syste... | # @author Kilari Teja
# LADDU
for Inx in xrange(0, int(raw_input().strip())):
initParams = raw_input().strip().split(" ")
TotalActions = int(initParams[0])
Indian = True if initParams[1] == "INDIAN" else False
Points = 0
for ActionIndx in xrange(0, TotalActions):
Actions = raw_input().strip().split(" ")
Got... | 1Python2 | {
"input": [
"2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n4 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED",
"2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n1 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONT... | 1CODECHEF |
pcsc1_882 | George is getting tired of the decimal number system. He intends to switch and use the septenary (base 7) number system for his future needs. Write a program to help George start his transformation into the septenary number system by taking in a list of decimal numbers and print out the corresponding septenary number... | import sys
def numberToBase(n, b):
temp=''
while n:
temp+=str(n % b)
n /= b
return temp
a=map(int,sys.stdin.readline().split())
i=0
while a[i]!=-1:
s=numberToBase(a[i],7)
s=s[::-1]
sys.stdout.write(s+" ")
i+=1 | 1Python2 | {
"input": [
"1 2 88 42 99 -1",
"1 2 101 42 99 -1",
"1 2 101 42 33 -1",
"1 2 101 36 33 -1",
"1 2 101 36 50 -1",
"0 2 101 36 50 -1",
"1 2 132 42 99 -1",
"1 4 101 42 33 -1",
"1 2 111 36 33 -1",
"1 2 100 36 50 -1",
"0 2 101 43 50 -1",
"0 2 132 42 99 -1",
"1 2 110 36 33... | 1CODECHEF |
stadium_883 | The bustling town of Siruseri has just one sports stadium. There
are a number of schools, colleges, sports associations, etc. that
use this stadium as the venue for their sports events.
Anyone interested in using the stadium has to apply to the Manager
of the stadium indicating both the starting date (a positive inte... | #Manage maximum events given start date and duration for a case
def main():
#f = open('C:\\Users\\GLCR3257\\Desktop\\pyLogics\\test.txt','r')
N=int(raw_input())
#print N
E=[]
for i in range(N):
start,duration=map(int,raw_input().split())
E.append([start+duration,start])
E.sort()
#print E
x=E[0][0]
#print... | 1Python2 | {
"input": [
"4\n2 5\n9 7\n15 6\n9 3"
],
"output": [
"3"
]
} | 1CODECHEF |
1007_E. Mini Metro_884 | In a simplified version of a "Mini Metro" game, there is only one subway line, and all the trains go in the same direction. There are n stations on the line, a_i people are waiting for the train at the i-th station at the beginning of the game. The game starts at the beginning of the 0-th hour. At the end of each hour ... | #include <bits/stdc++.h>
using namespace std;
const int N = 201;
const int T = 201;
int n, t;
long long z;
long long a[N], b[N], c[N];
long long pa[N], pb[N];
bool cl1[N][T], cl2[N][T];
long long mr1[N][T], mr2[N][T];
long long dp1[N][T], dp2[N][T];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >... | 2C++ | {
"input": [
"3 3 10\n2 4 10\n3 3 9\n4 2 8\n",
"4 10 5\n1 1 1\n1 0 1\n0 5 8\n2 7 100\n",
"2 5 1\n0 5 6\n0 2 7\n",
"1 1 1000000000\n0 0 0\n",
"2 200 5\n1 1 1\n12 3 15\n",
"2 10 5\n1 1 1\n12 3 15\n",
"5 200 10\n1 1 1\n1000000000 200 1000000000\n1000000000 300 1000000000\n1000000000 400 10000... | 2CODEFORCES |
1030_E. Vasya and Good Sequences_885 | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | #include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long... | 2C++ | {
"input": [
"4\n1 2 1 16\n",
"3\n6 7 14\n",
"5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n",
"1\n15\n",
"1\n4\n",
"1\n17\n",
"3\n10 7 14\n",
"3\n10 7 16\n",
"1\n7\n",
"1\n24\n",
"1\n9\n",
"1\n2\n",
"1\n10\n",
... | 2CODEFORCES |
1030_E. Vasya and Good Sequences_886 | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | #Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threadi... | 3Python3 | {
"input": [
"4\n1 2 1 16\n",
"3\n6 7 14\n",
"5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n",
"1\n15\n",
"1\n4\n",
"1\n17\n",
"3\n10 7 14\n",
"3\n10 7 16\n",
"1\n7\n",
"1\n24\n",
"1\n9\n",
"1\n2\n",
"1\n10\n",
... | 2CODEFORCES |
1030_E. Vasya and Good Sequences_887 | Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 10... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
// editorial: cnt even sum bitcnt segs & brute force rem segs where max > sum / 2 (max len of bad seg is 61)
public class cf1030e {
public static void main(String[] args) throws IOException {
int n = ... | 4JAVA | {
"input": [
"4\n1 2 1 16\n",
"3\n6 7 14\n",
"5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n",
"1\n15\n",
"1\n4\n",
"1\n17\n",
"3\n10 7 14\n",
"3\n10 7 16\n",
"1\n7\n",
"1\n24\n",
"1\n9\n",
"1\n2\n",
"1\n10\n",
... | 2CODEFORCES |
1053_C. Putting Boxes Together_888 | There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a_i holds for all valid i.
You would like to put together some boxes. Putting together boxes with indices in the segment [l, r... | #include <bits/stdc++.h>
using namespace std;
int n, q;
int nn;
int *arra, *arrw;
long long int *suml, *sumr, *sum;
long long int mod = 1E9 + 7;
int mx;
long sm;
bool TEST = 0;
void read() {
cin >> n >> q;
nn = ceil(log2(n)) * n - 1;
if (nn < 5) nn = 5;
arra = new int[n];
arrw = new int[n];
suml = new long ... | 2C++ | {
"input": [
"5 8\n1 2 6 7 10\n1 1 1 1 2\n1 1\n1 5\n1 3\n3 5\n-3 5\n-1 10\n1 4\n2 5\n",
"4 10\n1 333333333 666666666 1000000000\n1000000000 1000000000 1000000000 1000000000\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n",
"10 10\n4 5 6 7 8 11 14 15 17 19\n1 4 12 10 13 20 14 20 13 16\n-7 16\n1 1\n7 9\... | 2CODEFORCES |
1053_C. Putting Boxes Together_889 | There is an infinite line consisting of cells. There are n boxes in some cells of this line. The i-th box stands in the cell a_i and has weight w_i. All a_i are distinct, moreover, a_{i - 1} < a_i holds for all valid i.
You would like to put together some boxes. Putting together boxes with indices in the segment [l, r... | import java.io.*;
import java.math.*;
import java.util.*;
public class A {
public static void main (String[] args) { new A(); }
long MOD = (long)1e9+7;
A() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
System.err.println("");
// BIT tmp = new BIT(10);
// tmp.upda... | 4JAVA | {
"input": [
"5 8\n1 2 6 7 10\n1 1 1 1 2\n1 1\n1 5\n1 3\n3 5\n-3 5\n-1 10\n1 4\n2 5\n",
"4 10\n1 333333333 666666666 1000000000\n1000000000 1000000000 1000000000 1000000000\n1 1\n1 2\n1 3\n1 4\n2 2\n2 3\n2 4\n3 3\n3 4\n4 4\n",
"10 10\n4 5 6 7 8 11 14 15 17 19\n1 4 12 10 13 20 14 20 13 16\n-7 16\n1 1\n7 9\... | 2CODEFORCES |
1075_D. Intersecting Subtrees_890 | You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's labelling of the tree.
You and Li Chen each chose a subtree (i.e., a connected su... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
void enumerateSubmasks(long long m) {
for (long long s = m;; s = (s - 1) & m) {
if (s == 0) {
break;
}
}
}
long long mpow(long long a, long long b, long long m) {
if (b == 0) return 1;
long long x = mpow(a, b / 2, m);
x = (x * x)... | 2C++ | {
"input": [
"1\n3\n1 2\n2 3\n1\n1\n1\n2\n2\n1\n",
"2\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n3\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n3\n1 2 3\n3\n4 1 6\n5\n",
"1\n1\n1\n1\n1\n1\n1\n",
"1\n3\n2 3 1\n1 2\n2 3\n1\n1\n1\n2\n",
"2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 ... | 2CODEFORCES |
1075_D. Intersecting Subtrees_891 | You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's labelling of the tree.
You and Li Chen each chose a subtree (i.e., a connected su... | from collections import deque
import sys
t = int(input())
for i in range(t):
n = int(input())
edge = {}
for j in range(1,n+1):
a = set()
edge[j] = a
for k in range(n-1):
a,b = map(int,input().split())
edge[a].add(b)
edge[b].add(a)
k1 = int(input())
x = inp... | 3Python3 | {
"input": [
"1\n3\n1 2\n2 3\n1\n1\n1\n2\n2\n1\n",
"2\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n3\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n3\n1 2 3\n3\n4 1 6\n5\n",
"1\n1\n1\n1\n1\n1\n1\n",
"1\n3\n2 3 1\n1 2\n2 3\n1\n1\n1\n2\n",
"2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 ... | 2CODEFORCES |
1075_D. Intersecting Subtrees_892 | You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's labelling of the tree.
You and Li Chen each chose a subtree (i.e., a connected su... | import java.io.*;
import java.math.*;
import java.util.*;
public class IntersectingSubtrees {
public static void solve(FastIO io) {
int T = io.nextInt();
while (T-- > 0) {
int N = io.nextInt();
Node[] nodes = new Node[N + 1];
for (int i = 1; i <= N; ++i) {
... | 4JAVA | {
"input": [
"1\n3\n1 2\n2 3\n1\n1\n1\n2\n2\n1\n",
"2\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n3\n6\n1 2\n1 3\n1 4\n4 5\n4 6\n3\n1 2 3\n3\n4 1 6\n5\n",
"1\n1\n1\n1\n1\n1\n1\n",
"1\n3\n2 3 1\n1 2\n2 3\n1\n1\n1\n2\n",
"2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 ... | 2CODEFORCES |
1096_E. The Top Scorer_893 | Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.
They have just finished the... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, M = 998244353, N = 1e5 + 7;
int f[N], inv[N], fi[N];
int INV(int i) {
if (i == 1) return 1;
return M - (long long)M / i * INV(M % i) % M;
}
int C(int n, int k) { return (long long)f[n] * fi[k] % M * fi[n - k] % M; }
int H(int n, int k) {
if (n... | 2C++ | {
"input": [
"10 30 10\n",
"2 6 3\n",
"5 20 11\n",
"1 5000 4999\n",
"2 1 0\n",
"83 2813 123\n",
"93 2364 2364\n",
"100 1 0\n",
"21 862 387\n",
"1 1 0\n",
"93 2364 1182\n",
"1 0 0\n",
"100 5000 30\n",
"100 0 0\n",
"45 2315 2018\n",
"45 886 245\n",
"69... | 2CODEFORCES |
1096_E. The Top Scorer_894 | Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.
They have just finished the... | base=998244353;
def power(x, y):
if(y==0):
return 1
t=power(x, y//2)
t=(t*t)%base
if(y%2):
t=(t*x)%base
return t;
def inverse(x):
return power(x, base-2)
f=[1]
iv=[1]
for i in range(1, 5555):
f.append((f[i-1]*i)%base)
iv.append(inverse(f[i]))
def C(n, k):
return (f[n]... | 3Python3 | {
"input": [
"10 30 10\n",
"2 6 3\n",
"5 20 11\n",
"1 5000 4999\n",
"2 1 0\n",
"83 2813 123\n",
"93 2364 2364\n",
"100 1 0\n",
"21 862 387\n",
"1 1 0\n",
"93 2364 1182\n",
"1 0 0\n",
"100 5000 30\n",
"100 0 0\n",
"45 2315 2018\n",
"45 886 245\n",
"69... | 2CODEFORCES |
1096_E. The Top Scorer_895 | Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.
They have just finished the... | import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
void solve() {
int p=ni(),s=ni(),r=ni();
precompute(100000);
long ans=0;
for(int i=r;i<=s;i++){
for(int j=1;j<=p && i*1L*j<=s;j++){
long d=mul(C[p-1][j-1],m... | 4JAVA | {
"input": [
"10 30 10\n",
"2 6 3\n",
"5 20 11\n",
"1 5000 4999\n",
"2 1 0\n",
"83 2813 123\n",
"93 2364 2364\n",
"100 1 0\n",
"21 862 387\n",
"1 1 0\n",
"93 2364 1182\n",
"1 0 0\n",
"100 5000 30\n",
"100 0 0\n",
"45 2315 2018\n",
"45 886 245\n",
"69... | 2CODEFORCES |
1117_F. Crisp String_896 | You are given a string of length n. Each character is one of the first p lowercase Latin letters.
You are also given a matrix A with binary values of size p × p. This matrix is symmetric (A_{ij} = A_{ji}). A_{ij} = 1 means that the string can have the i-th and j-th letters of Latin alphabet adjacent.
Let's call the s... | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const int maxmsk = (1 << 17) + 7;
int n, p, num[maxn], ok[27][27];
int bad[maxmsk], met[27], sum[27];
bool hve[27];
string s;
void init() {
scanf("%d%d", &n, &p);
cin >> s;
for (int i = 0; i <... | 2C++ | {
"input": [
"7 3\nabacaba\n1 1 1\n1 0 0\n1 0 0\n",
"7 3\nabacaba\n0 1 1\n1 0 0\n1 0 0\n",
"7 4\nbacadab\n0 1 1 1\n1 0 0 0\n1 0 0 0\n1 0 0 0\n",
"3 3\ncbc\n0 0 0\n0 0 1\n0 1 0\n",
"10 4\nbcaaddaacc\n1 0 1 1\n0 0 1 0\n1 1 1 0\n1 0 0 1\n",
"100 10\nigffabeaiaajhjaghjgfjcchheeigjhibadbbhdhcjiibhj... | 2CODEFORCES |
1117_F. Crisp String_897 | You are given a string of length n. Each character is one of the first p lowercase Latin letters.
You are also given a matrix A with binary values of size p × p. This matrix is symmetric (A_{ij} = A_{ji}). A_{ij} = 1 means that the string can have the i-th and j-th letters of Latin alphabet adjacent.
Let's call the s... | import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.TreeSet;
@SuppressWarnings("unchecked")
public class F {
int ... | 4JAVA | {
"input": [
"7 3\nabacaba\n1 1 1\n1 0 0\n1 0 0\n",
"7 3\nabacaba\n0 1 1\n1 0 0\n1 0 0\n",
"7 4\nbacadab\n0 1 1 1\n1 0 0 0\n1 0 0 0\n1 0 0 0\n",
"3 3\ncbc\n0 0 0\n0 0 1\n0 1 0\n",
"10 4\nbcaaddaacc\n1 0 1 1\n0 0 1 0\n1 1 1 0\n1 0 0 1\n",
"100 10\nigffabeaiaajhjaghjgfjcchheeigjhibadbbhdhcjiibhj... | 2CODEFORCES |
1144_B. Parity Alternated Deletions_898 | Polycarp has an array a consisting of n integers.
He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its... | # -*- coding: utf-8 -*-
import sys
from fractions import gcd
from fractions import gcd
def fi():
return int(sys.stdin.readline())
def fi2():
return map(int, sys.stdin.readline().split())
def fi3():
return sys.stdin.readline()
def fo(*args):
for s in args:
sys.stdout.write(str(s)+' ')
sys.... | 1Python2 | {
"input": [
"2\n1000000 1000000\n",
"6\n5 1 2 4 6 3\n",
"5\n1 5 7 8 2\n",
"5\n1 1 1 1 1\n",
"5\n2 1 1 1 1\n",
"5\n2 1 1 1 2\n",
"6\n5 1 3 4 8 3\n",
"5\n1 5 7 1 2\n",
"6\n5 1 3 4 5 3\n",
"2\n1000010 1001000\n",
"2\n1000110 1001000\n",
"2\n1000110 1000000\n",
"2\n000... | 2CODEFORCES |
1144_B. Parity Alternated Deletions_899 | Polycarp has an array a consisting of n integers.
He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains n-1 elements). For each of the next moves he chooses any element with the only restriction: its... | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> myodd, myeven;
bool cmp(int a, int b) { return a > b; }
int main() {
scanf("%d", &n);
int tmp;
int sum = 0;
for (int i = 0; i < n; ++i) {
scanf("%d", &tmp);
sum += tmp;
if (tmp % 2 == 0) {
myeven.push_back(tmp);
} else {
... | 2C++ | {
"input": [
"2\n1000000 1000000\n",
"6\n5 1 2 4 6 3\n",
"5\n1 5 7 8 2\n",
"5\n1 1 1 1 1\n",
"5\n2 1 1 1 1\n",
"5\n2 1 1 1 2\n",
"6\n5 1 3 4 8 3\n",
"5\n1 5 7 1 2\n",
"6\n5 1 3 4 5 3\n",
"2\n1000010 1001000\n",
"2\n1000110 1001000\n",
"2\n1000110 1000000\n",
"2\n000... | 2CODEFORCES |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.