user_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 1
value | submission_id_v0 stringlengths 10 10 | submission_id_v1 stringlengths 10 10 | cpu_time_v0 int64 10 38.3k | cpu_time_v1 int64 0 24.7k | memory_v0 int64 2.57k 1.02M | memory_v1 int64 2.57k 869k | status_v0 stringclasses 1
value | status_v1 stringclasses 1
value | improvement_frac float64 7.51 100 | input stringlengths 20 4.55k | target stringlengths 17 3.34k | code_v0_loc int64 1 148 | code_v1_loc int64 1 184 | code_v0_num_chars int64 13 4.55k | code_v1_num_chars int64 14 3.34k | code_v0_no_empty_lines stringlengths 21 6.88k | code_v1_no_empty_lines stringlengths 20 4.93k | code_same bool 1
class | relative_loc_diff_percent float64 0 79.8 | diff list | diff_only_import_comment bool 1
class | measured_runtime_v0 float64 0.01 4.45 | measured_runtime_v1 float64 0.01 4.31 | runtime_lift float64 0 359 | key list |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u562935282 | p03108 | python | s066744349 | s350716867 | 665 | 560 | 24,048 | 24,088 | Accepted | Accepted | 15.79 | class UnionFind:
def __init__(self, n):
self.v = [-1] * n
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
... | class UnionFind:
def __init__(self, n):
self.v = [-1] * n
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
... | 75 | 59 | 1,606 | 1,239 | class UnionFind:
def __init__(self, n):
self.v = [-1] * n
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x ... | class UnionFind:
def __init__(self, n):
self.v = [-1] * n
def find(self, x):
if self.v[x] < 0:
return x
else:
self.v[x] = self.find(self.v[x])
return self.v[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x ... | false | 21.333333 | [
"- collapse_schedule = []",
"+ es = []",
"- A, B = (int(x) - 1 for x in input().split())",
"- collapse_schedule.append((A, B))",
"- collapse_schedule.reverse()",
"+ a, b = (int(x) - 1 for x in input().split())",
"+ es.append((a, b))",
"+ es.reverse()",
"+ e... | false | 0.036181 | 0.102288 | 0.353722 | [
"s066744349",
"s350716867"
] |
u711539583 | p02763 | python | s612225503 | s802235707 | 1,917 | 1,760 | 435,324 | 397,240 | Accepted | Accepted | 8.19 | import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = input().rstrip('\n')
l = [c for c in s]
q = int(input().rstrip('\n'))
Q = [input().rstrip('\n').split() for _ in range(q)]
class SegTree():
def __init__(self, n_):
self.n = 1
while self.n < n_:
self.n ... | import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = input().rstrip('\n')
q = int(input().rstrip('\n'))
Q = []
for _ in range(q):
Q.append(input().rstrip().split())
class SegTree():
def __init__(self, n_):
self.n = 1
while self.n < n_:
self.n *= 2... | 58 | 63 | 1,500 | 1,561 | import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = input().rstrip("\n")
l = [c for c in s]
q = int(input().rstrip("\n"))
Q = [input().rstrip("\n").split() for _ in range(q)]
class SegTree:
def __init__(self, n_):
self.n = 1
while self.n < n_:
self.n *= 2
s... | import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = input().rstrip("\n")
q = int(input().rstrip("\n"))
Q = []
for _ in range(q):
Q.append(input().rstrip().split())
class SegTree:
def __init__(self, n_):
self.n = 1
while self.n < n_:
self.n *= 2
self.tre... | false | 7.936508 | [
"-l = [c for c in s]",
"-Q = [input().rstrip(\"\\n\").split() for _ in range(q)]",
"+Q = []",
"+for _ in range(q):",
"+ Q.append(input().rstrip().split())",
"- self.tree = [2 for _ in range(2 * self.n - 1)]",
"+ self.tree = []",
"+ for _ in range(2 * self.n - 1):",
"+ ... | false | 0.039774 | 0.037822 | 1.051617 | [
"s612225503",
"s802235707"
] |
u098012509 | p03274 | python | s175712892 | s553256875 | 97 | 80 | 14,940 | 14,172 | Accepted | Accepted | 17.53 | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
plus = [0]
j = 0
for i in range(N):
if x[i] >= 0:
plus.append(x[i])
j += 1
j = 0
minus = [0]
for i in rang... | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
ans = float("inf")
for i in range(N + 1 - K):
l = x[i]
r = x[i + K - 1]
if l < 0 < r:
ans = min(ans, abs(l) + abs(r) + min(... | 47 | 25 | 849 | 473 | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
plus = [0]
j = 0
for i in range(N):
if x[i] >= 0:
plus.append(x[i])
j += 1
j = 0
minus = [0]
for i in range(N - 1, -1, -1):
... | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
ans = float("inf")
for i in range(N + 1 - K):
l = x[i]
r = x[i + K - 1]
if l < 0 < r:
ans = min(ans, abs(l) + abs(r) + min(abs(l), abs(r... | false | 46.808511 | [
"- plus = [0]",
"- j = 0",
"- for i in range(N):",
"- if x[i] >= 0:",
"- plus.append(x[i])",
"- j += 1",
"- j = 0",
"- minus = [0]",
"- for i in range(N - 1, -1, -1):",
"- if x[i] < 0:",
"- minus.append(x[i])",
"- j +=... | false | 0.049524 | 0.048432 | 1.022541 | [
"s175712892",
"s553256875"
] |
u703528810 | p02683 | python | s302432377 | s615784183 | 365 | 82 | 85,432 | 9,756 | Accepted | Accepted | 77.53 | N,M,X=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
S=[[0 for _ in range(M)] for _ in range(2**N)]
cost=[]
for i in range(2**N):
b=bin(i)[2:].zfill(N)
t_cost=0
for j in range(N):
t_cost+=A[j][0]*int(b[j])
for m in range(M):
S[i][m... | def dfs(bit):
if len(bit)==N:
c=0
s=[0 for _ in range(M)]
for i in range(N):
c+=A[i][0]*bit[i]
if bit[i]==1:
for j in range(M):
s[j]+=A[i][j+1]
cond=True
for k in range(M):
... | 20 | 35 | 457 | 766 | N, M, X = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
S = [[0 for _ in range(M)] for _ in range(2**N)]
cost = []
for i in range(2**N):
b = bin(i)[2:].zfill(N)
t_cost = 0
for j in range(N):
t_cost += A[j][0] * int(b[j])
for m in range(M):
... | def dfs(bit):
if len(bit) == N:
c = 0
s = [0 for _ in range(M)]
for i in range(N):
c += A[i][0] * bit[i]
if bit[i] == 1:
for j in range(M):
s[j] += A[i][j + 1]
cond = True
for k in range(M):
... | false | 42.857143 | [
"+def dfs(bit):",
"+ if len(bit) == N:",
"+ c = 0",
"+ s = [0 for _ in range(M)]",
"+ for i in range(N):",
"+ c += A[i][0] * bit[i]",
"+ if bit[i] == 1:",
"+ for j in range(M):",
"+ s[j] += A[i][j + 1]",
"+ ... | false | 0.040346 | 0.038025 | 1.061029 | [
"s302432377",
"s615784183"
] |
u883048396 | p03242 | python | s117047080 | s910314638 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | print((input().rstrip().replace("1","a").replace("9","1").replace("a","9")))
| print((1110-int(eval(input())))) | 1 | 1 | 75 | 24 | print((input().rstrip().replace("1", "a").replace("9", "1").replace("a", "9")))
| print((1110 - int(eval(input()))))
| false | 0 | [
"-print((input().rstrip().replace(\"1\", \"a\").replace(\"9\", \"1\").replace(\"a\", \"9\")))",
"+print((1110 - int(eval(input()))))"
] | false | 0.037389 | 0.037446 | 0.998472 | [
"s117047080",
"s910314638"
] |
u733814820 | p03029 | python | s484120041 | s781185811 | 22 | 17 | 3,316 | 2,940 | Accepted | Accepted | 22.73 | A, P = list(map(int, input().split()))
P += A * 3
pie = P // 2
print(pie)
| def resolve():
a, p = list(map(int, input().split()))
print(((a*3+p) // 2))
return
if __name__ == "__main__":
resolve()
| 7 | 7 | 77 | 127 | A, P = list(map(int, input().split()))
P += A * 3
pie = P // 2
print(pie)
| def resolve():
a, p = list(map(int, input().split()))
print(((a * 3 + p) // 2))
return
if __name__ == "__main__":
resolve()
| false | 0 | [
"-A, P = list(map(int, input().split()))",
"-P += A * 3",
"-pie = P // 2",
"-print(pie)",
"+def resolve():",
"+ a, p = list(map(int, input().split()))",
"+ print(((a * 3 + p) // 2))",
"+ return",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ resolve()"
] | false | 0.03246 | 0.03123 | 1.039371 | [
"s484120041",
"s781185811"
] |
u099566485 | p03361 | python | s494558024 | s918374775 | 204 | 186 | 40,176 | 40,176 | Accepted | Accepted | 8.82 | #ABC096-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(eval(input()))
def S(): return list(eval(input()))
h,w=IL()
S=[S() for i in range(h)]
ret=True
#grid周り探索
for i in range(h):
for j in range(w):
if S[i][j]==".":
continue
... | #ABC096-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(eval(input()))
def S(): return list(eval(input()))
h,w=IL()
G=[["."]*(w+2)]
for i in range(h):
G.append(["."]+S()+["."])
G.append(["."]*(w+2))
ret=True
#grid周り探索
for i in range(1,h):
for j... | 28 | 26 | 660 | 597 | # ABC096-C
def IL():
return list(map(int, input().split()))
def SL():
return input().split()
def I():
return int(eval(input()))
def S():
return list(eval(input()))
h, w = IL()
S = [S() for i in range(h)]
ret = True
# grid周り探索
for i in range(h):
for j in range(w):
if S[i][j] == ".":
... | # ABC096-C
def IL():
return list(map(int, input().split()))
def SL():
return input().split()
def I():
return int(eval(input()))
def S():
return list(eval(input()))
h, w = IL()
G = [["."] * (w + 2)]
for i in range(h):
G.append(["."] + S() + ["."])
G.append(["."] * (w + 2))
ret = True
# grid周り... | false | 7.142857 | [
"-S = [S() for i in range(h)]",
"+G = [[\".\"] * (w + 2)]",
"+for i in range(h):",
"+ G.append([\".\"] + S() + [\".\"])",
"+G.append([\".\"] * (w + 2))",
"-for i in range(h):",
"- for j in range(w):",
"- if S[i][j] == \".\":",
"+for i in range(1, h):",
"+ for j in range(1, w):",
... | false | 0.047773 | 0.04744 | 1.007009 | [
"s494558024",
"s918374775"
] |
u327466606 | p02720 | python | s243662791 | s151819970 | 143 | 109 | 3,064 | 11,980 | Accepted | Accepted | 23.78 | K = int(input())
N = [0]
for _ in range(K):
i = 0
while i < len(N) and N[i] == 9:
i += 1
while i+1 < len(N) and N[i] == N[i+1]+1:
i += 1
if i == len(N):
N = [0]*len(N) + [1]
else:
N[i] += 1
i -= 1
while i >= 0:
N[i] = max(... | from collections import deque
K = int(eval(input()))
q = deque(list(range(1,10)))
for _ in range(K):
x = q.popleft()
r = x%10
if r == 0:
q.append(x*10)
q.append(x*10+1)
elif r == 9:
q.append(x*10+8)
q.append(x*10+9)
else:
q.append(x*10+r-1... | 20 | 21 | 382 | 373 | K = int(input())
N = [0]
for _ in range(K):
i = 0
while i < len(N) and N[i] == 9:
i += 1
while i + 1 < len(N) and N[i] == N[i + 1] + 1:
i += 1
if i == len(N):
N = [0] * len(N) + [1]
else:
N[i] += 1
i -= 1
while i >= 0:
N[i] = max(N[i + 1] -... | from collections import deque
K = int(eval(input()))
q = deque(list(range(1, 10)))
for _ in range(K):
x = q.popleft()
r = x % 10
if r == 0:
q.append(x * 10)
q.append(x * 10 + 1)
elif r == 9:
q.append(x * 10 + 8)
q.append(x * 10 + 9)
else:
q.append(x * 10 + r ... | false | 4.761905 | [
"-K = int(input())",
"-N = [0]",
"+from collections import deque",
"+",
"+K = int(eval(input()))",
"+q = deque(list(range(1, 10)))",
"- i = 0",
"- while i < len(N) and N[i] == 9:",
"- i += 1",
"- while i + 1 < len(N) and N[i] == N[i + 1] + 1:",
"- i += 1",
"- if i == ... | false | 0.252729 | 0.05637 | 4.483405 | [
"s243662791",
"s151819970"
] |
u562935282 | p03674 | python | s397000173 | s155251071 | 513 | 299 | 28,268 | 28,292 | Accepted | Accepted | 41.72 | class Calc:
def __init__(self, max_value, mod):
"""combination(max_value, all)"""
fact = [-1] * (max_value + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, max_value + 1):
fact[x] = x * fact[x - 1] % mod
invs = [1] * (max_value + 1)
invs[m... | class Calc:
def __init__(self, max_value, mod):
"""combination(max_value, all)"""
fact = [-1] * (max_value + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, max_value + 1):
fact[x] = x * fact[x - 1] % mod
invs = [1] * (max_value + 1)
invs[m... | 79 | 72 | 2,160 | 1,957 | class Calc:
def __init__(self, max_value, mod):
"""combination(max_value, all)"""
fact = [-1] * (max_value + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, max_value + 1):
fact[x] = x * fact[x - 1] % mod
invs = [1] * (max_value + 1)
invs[max_value] =... | class Calc:
def __init__(self, max_value, mod):
"""combination(max_value, all)"""
fact = [-1] * (max_value + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, max_value + 1):
fact[x] = x * fact[x - 1] % mod
invs = [1] * (max_value + 1)
invs[max_value] =... | false | 8.860759 | [
"+ # <editorial>",
"+ # LRから1個,XZからK-1個取るchoose(XZ,K-1)=choose(N+1-2-Y,K-1)でよい",
"- div2 = pow(2, MOD - 2, MOD)",
"- t = (",
"- calc.nCr(N + 1, k)",
"- - (",
"- calc.nCr(N + 1 - Y, k)",
"- - calc.nCr(N + 1 - 2 - Y, k)",
"- ... | false | 0.081318 | 0.078393 | 1.037306 | [
"s397000173",
"s155251071"
] |
u622045059 | p03162 | python | s842033620 | s480034301 | 769 | 477 | 100,180 | 95,960 | Accepted | Accepted | 37.97 | import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def... | # python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大... | 43 | 55 | 1,545 | 2,077 | import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
def gcd(a, b):
return fractions.gcd(a, b) # 最大公約数
def lcm(a, b):
return (a * b) // fractions.gcd(a, b)... | # python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf") # 無限大
def gcd(a, b):
return fractions.gcd(a, b) # 最... | false | 21.818182 | [
"+# python3.4.2用",
"+from decimal import *",
"+INF = float(\"inf\") # 無限大",
"- return int(eval(input())) # 整数読み込み",
"+ return int(sys.stdin.readline()) # 整数読み込み",
"- return float(eval(input())) # 浮動小数点読み込み",
"+ return float(sys.stdin.readline()) # 浮動小数点読み込み",
"- return input().spli... | false | 0.156634 | 0.106677 | 1.468295 | [
"s842033620",
"s480034301"
] |
u073097598 | p03161 | python | s082089579 | s737830695 | 380 | 312 | 52,448 | 53,216 | Accepted | Accepted | 17.89 | import sys
n,k = list(map(int,input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
for j in range(i+1,i+k+1):
if(j<n):
dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print((dp[n-1])) | import sys
def frog():
for i in range(n):
for j in range(i+1,i+k+1):
if(j<n):
dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
return dp[n-1]
if __name__ == "__main__":
n,k=list(map(int,input().split()))
dp = [sys.maxsize] * n
dp[0] = 0
l = lis... | 10 | 13 | 250 | 381 | import sys
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize] * n
dp[0] = 0
for i in range(n):
for j in range(i + 1, i + k + 1):
if j < n:
dp[j] = min(dp[j], dp[i] + abs(l[i] - l[j]))
print((dp[n - 1]))
| import sys
def frog():
for i in range(n):
for j in range(i + 1, i + k + 1):
if j < n:
dp[j] = min(dp[j], dp[i] + abs(l[i] - l[j]))
return dp[n - 1]
if __name__ == "__main__":
n, k = list(map(int, input().split()))
dp = [sys.maxsize] * n
dp[0] = 0
l = list(... | false | 23.076923 | [
"-n, k = list(map(int, input().split()))",
"-l = list(map(int, input().split()))",
"-dp = [sys.maxsize] * n",
"-dp[0] = 0",
"-for i in range(n):",
"- for j in range(i + 1, i + k + 1):",
"- if j < n:",
"- dp[j] = min(dp[j], dp[i] + abs(l[i] - l[j]))",
"-print((dp[n - 1]))",
"+"... | false | 0.060885 | 0.041391 | 1.470984 | [
"s082089579",
"s737830695"
] |
u142415823 | p03495 | python | s510126676 | s927464753 | 176 | 138 | 32,556 | 20,184 | Accepted | Accepted | 21.59 | import collections
def calc(A, K):
dist = {}
tmp = collections.Counter(A)
type_ = len(tmp)
if type_ <= K:
return 0
for a, count in list(tmp.items()):
if count not in list(dist.keys()):
dist[count] = [a]
else:
dist[count].append(a)
... | N, K = list(map(int, input().split()))
cnt = [0 for _ in range(N)]
for i in map(int, input().split()):
cnt[i-1] += 1
ans = 0
for i in sorted(cnt)[:N - K]:
ans += i
print(ans) | 36 | 11 | 686 | 189 | import collections
def calc(A, K):
dist = {}
tmp = collections.Counter(A)
type_ = len(tmp)
if type_ <= K:
return 0
for a, count in list(tmp.items()):
if count not in list(dist.keys()):
dist[count] = [a]
else:
dist[count].append(a)
rewrite = 0
... | N, K = list(map(int, input().split()))
cnt = [0 for _ in range(N)]
for i in map(int, input().split()):
cnt[i - 1] += 1
ans = 0
for i in sorted(cnt)[: N - K]:
ans += i
print(ans)
| false | 69.444444 | [
"-import collections",
"-",
"-",
"-def calc(A, K):",
"- dist = {}",
"- tmp = collections.Counter(A)",
"- type_ = len(tmp)",
"- if type_ <= K:",
"- return 0",
"- for a, count in list(tmp.items()):",
"- if count not in list(dist.keys()):",
"- dist[count] =... | false | 0.034024 | 0.119938 | 0.283678 | [
"s510126676",
"s927464753"
] |
u857293613 | p02887 | python | s317585852 | s247869703 | 53 | 42 | 15,860 | 3,316 | Accepted | Accepted | 20.75 | import itertools
n = int(eval(input()))
s = eval(input())
gr = itertools.groupby(s)
print((len(list(gr)))) | n = int(eval(input()))
s = eval(input())
ans = 1
for i in range(n-1):
if s[i] != s[i+1]:
ans += 1
print(ans) | 5 | 7 | 96 | 114 | import itertools
n = int(eval(input()))
s = eval(input())
gr = itertools.groupby(s)
print((len(list(gr))))
| n = int(eval(input()))
s = eval(input())
ans = 1
for i in range(n - 1):
if s[i] != s[i + 1]:
ans += 1
print(ans)
| false | 28.571429 | [
"-import itertools",
"-",
"-gr = itertools.groupby(s)",
"-print((len(list(gr))))",
"+ans = 1",
"+for i in range(n - 1):",
"+ if s[i] != s[i + 1]:",
"+ ans += 1",
"+print(ans)"
] | false | 0.100687 | 0.118373 | 0.850591 | [
"s317585852",
"s247869703"
] |
u445624660 | p03910 | python | s726264095 | s439960031 | 299 | 22 | 43,740 | 3,444 | Accepted | Accepted | 92.64 | # 最大値の最小値、ちょうどn/2臭い
# あとは帳尻合わせが効きそう
# 14とかだと7+4+2+1 (7+5+2でも7+4+3でもいい
# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった
# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定
# あとはそれでnを引いて0になるまで -> これだと間に合わない
n = int(eval(input()))
ans = []
cur = 0
while cur != n:
tmp = 0
for i in range(1, n + 1 - cur):
if i + ... | # 解説を観たのでそれをやってみるバージョン
# (最初に解いたやつは愚直に毎回最大値を求めていた(なんかしらんけど通った))
n = int(eval(input()))
cur = 0
target = 0
for i in range(1, n + 1):
if i + cur >= n:
target = i
break
cur += i
remove_num = sum([i for i in range(1, target + 1)]) - n
for i in range(1, target + 1):
if i != remove_n... | 24 | 16 | 520 | 338 | # 最大値の最小値、ちょうどn/2臭い
# あとは帳尻合わせが効きそう
# 14とかだと7+4+2+1 (7+5+2でも7+4+3でもいい
# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった
# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定
# あとはそれでnを引いて0になるまで -> これだと間に合わない
n = int(eval(input()))
ans = []
cur = 0
while cur != n:
tmp = 0
for i in range(1, n + 1 - cur):
if i + tmp >= n - cur:
... | # 解説を観たのでそれをやってみるバージョン
# (最初に解いたやつは愚直に毎回最大値を求めていた(なんかしらんけど通った))
n = int(eval(input()))
cur = 0
target = 0
for i in range(1, n + 1):
if i + cur >= n:
target = i
break
cur += i
remove_num = sum([i for i in range(1, target + 1)]) - n
for i in range(1, target + 1):
if i != remove_num:
pr... | false | 33.333333 | [
"-# 最大値の最小値、ちょうどn/2臭い",
"-# あとは帳尻合わせが効きそう",
"-# 14とかだと7+4+2+1 (7+5+2でも7+4+3でもいい",
"-# かと思いきや 1+2+3+4+5で15いくので, 5+4+3+2でよかった",
"-# 10^7なので毎回足してもどうせ間に合う。これで答えの集合のうち最大値は確定",
"-# あとはそれでnを引いて0になるまで -> これだと間に合わない",
"+# 解説を観たのでそれをやってみるバージョン",
"+# (最初に解いたやつは愚直に毎回最大値を求めていた(なんかしらんけど通った))",
"-ans = []",
"-wh... | false | 0.039651 | 0.035427 | 1.119233 | [
"s726264095",
"s439960031"
] |
u600402037 | p04012 | python | s433776851 | s819474951 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | import collections
W = eval(input())
c = collections.Counter(W)
answer = 'Yes'
for w in c:
if c[w] % 2 == 1:
answer = 'No'
print(answer) | W = eval(input())
print(('Yes' if all([W.count(x)%2==0 for x in set(W)]) else 'No')) | 8 | 2 | 149 | 82 | import collections
W = eval(input())
c = collections.Counter(W)
answer = "Yes"
for w in c:
if c[w] % 2 == 1:
answer = "No"
print(answer)
| W = eval(input())
print(("Yes" if all([W.count(x) % 2 == 0 for x in set(W)]) else "No"))
| false | 75 | [
"-import collections",
"-",
"-c = collections.Counter(W)",
"-answer = \"Yes\"",
"-for w in c:",
"- if c[w] % 2 == 1:",
"- answer = \"No\"",
"-print(answer)",
"+print((\"Yes\" if all([W.count(x) % 2 == 0 for x in set(W)]) else \"No\"))"
] | false | 0.04174 | 0.041487 | 1.006093 | [
"s433776851",
"s819474951"
] |
u451017206 | p03078 | python | s901400575 | s469103340 | 971 | 687 | 138,864 | 9,528 | Accepted | Accepted | 29.25 | X, Y, Z, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
AB = sorted([a + b for a in A for b in B], reverse=True)[:K]
ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K]
for a in ABC:
print(a)... | X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
a = []
for x in range(X):
for y in range(Y):
for z in range(Z):
... | 9 | 16 | 315 | 499 | X, Y, Z, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
AB = sorted([a + b for a in A for b in B], reverse=True)[:K]
ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K]
for a in ABC:
print(a)
| X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
a = []
for x in range(X):
for y in range(Y):
for z in range(Z):
if (x +... | false | 43.75 | [
"-A = [int(i) for i in input().split()]",
"-B = [int(i) for i in input().split()]",
"-C = [int(i) for i in input().split()]",
"-AB = sorted([a + b for a in A for b in B], reverse=True)[:K]",
"-ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K]",
"-for a in ABC:",
"- print(a)",
"+A = s... | false | 0.037671 | 0.036138 | 1.042409 | [
"s901400575",
"s469103340"
] |
u807864121 | p02990 | python | s237363614 | s454741022 | 468 | 20 | 3,820 | 3,316 | Accepted | Accepted | 95.73 | def comb(n, r):
if n < 0 or r < 0:
raise ValueError
r = min(r, n - r)
if n == 0 or r == 0:
return 1
return (n - r + 1) * comb(n, r - 1) // r
N, K = list(map(int, input().split()))
for i in range(K):
if N - K + 1 < i + 1:
print('0')
continue
print((comb(N - K + 1, i + 1) * comb(... | N, K = list(map(int, input().split()))
a = N - K + 1
print(a)
for i in range(1, K):
a = a * (N - K + 1 - i) * (K - i) // ((i + 1) * i)
print((a % (10 ** 9 + 7))) | 14 | 6 | 345 | 168 | def comb(n, r):
if n < 0 or r < 0:
raise ValueError
r = min(r, n - r)
if n == 0 or r == 0:
return 1
return (n - r + 1) * comb(n, r - 1) // r
N, K = list(map(int, input().split()))
for i in range(K):
if N - K + 1 < i + 1:
print("0")
continue
print((comb(N - K + 1... | N, K = list(map(int, input().split()))
a = N - K + 1
print(a)
for i in range(1, K):
a = a * (N - K + 1 - i) * (K - i) // ((i + 1) * i)
print((a % (10**9 + 7)))
| false | 57.142857 | [
"-def comb(n, r):",
"- if n < 0 or r < 0:",
"- raise ValueError",
"- r = min(r, n - r)",
"- if n == 0 or r == 0:",
"- return 1",
"- return (n - r + 1) * comb(n, r - 1) // r",
"-",
"-",
"-for i in range(K):",
"- if N - K + 1 < i + 1:",
"- print(\"0\")",
"- ... | false | 0.071805 | 0.034889 | 2.058107 | [
"s237363614",
"s454741022"
] |
u724687935 | p02547 | python | s134884368 | s231187405 | 30 | 23 | 9,172 | 9,200 | Accepted | Accepted | 23.33 | N = int(eval(input()))
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
if all(d[0] == d[1] for d in D[i: i + 3]):
print('Yes')
exit()
else:
print('No')
| def input_array():
return list(map(int,input().split()))
n=int(eval(input()))
D=[input_array() for i in range(n)]
count=0
for d in D:
if d[0]==d[1]:
count+=1
else:
count=0
if count==3:
break
if count==3:
print("Yes")
else:
print("No") | 8 | 19 | 209 | 263 | N = int(eval(input()))
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
if all(d[0] == d[1] for d in D[i : i + 3]):
print("Yes")
exit()
else:
print("No")
| def input_array():
return list(map(int, input().split()))
n = int(eval(input()))
D = [input_array() for i in range(n)]
count = 0
for d in D:
if d[0] == d[1]:
count += 1
else:
count = 0
if count == 3:
break
if count == 3:
print("Yes")
else:
print("No")
| false | 57.894737 | [
"-N = int(eval(input()))",
"-D = [tuple(map(int, input().split())) for _ in range(N)]",
"-for i in range(N - 2):",
"- if all(d[0] == d[1] for d in D[i : i + 3]):",
"- print(\"Yes\")",
"- exit()",
"+def input_array():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+n... | false | 0.033861 | 0.034875 | 0.970923 | [
"s134884368",
"s231187405"
] |
u936985471 | p02818 | python | s028897911 | s401721507 | 20 | 17 | 3,316 | 2,940 | Accepted | Accepted | 15 | A,B,K=list(map(int,input().split()))
if A>=K:
print((A-K,B))
elif A<K and A+B>K:
print((0,B-(K-A)))
else:
print((0,0)) | A,B,K=list(map(int,input().split()))
print((max(0,A-K),max(0,B-(max(K-A,0))))) | 7 | 2 | 118 | 71 | A, B, K = list(map(int, input().split()))
if A >= K:
print((A - K, B))
elif A < K and A + B > K:
print((0, B - (K - A)))
else:
print((0, 0))
| A, B, K = list(map(int, input().split()))
print((max(0, A - K), max(0, B - (max(K - A, 0)))))
| false | 71.428571 | [
"-if A >= K:",
"- print((A - K, B))",
"-elif A < K and A + B > K:",
"- print((0, B - (K - A)))",
"-else:",
"- print((0, 0))",
"+print((max(0, A - K), max(0, B - (max(K - A, 0)))))"
] | false | 0.092357 | 0.036758 | 2.512591 | [
"s028897911",
"s401721507"
] |
u644907318 | p03157 | python | s791164876 | s143434857 | 524 | 237 | 44,784 | 94,420 | Accepted | Accepted | 54.77 | from collections import deque
H,W = list(map(int,input().split()))
S = [input().strip() for _ in range(H)]
D = {0:".",1:"#"}
G = {}
C = {}
hist = [[-1 for _ in range(W)] for _ in range(H)]
col = -1
for i in range(H):
for j in range(W):
if S[i][j]=="#" and hist[i][j]==-1:
col += 1
... | from collections import deque
H,W = list(map(int,input().split()))
S = [input().strip() for _ in range(H)]
hist = [[0 for _ in range(W)] for _ in range(H)]
col = 1
for i in range(H):
for j in range(W):
if hist[i][j]==0:
hist[i][j]=col
que = deque([(i,j,S[i][j])])
... | 59 | 41 | 2,256 | 1,337 | from collections import deque
H, W = list(map(int, input().split()))
S = [input().strip() for _ in range(H)]
D = {0: ".", 1: "#"}
G = {}
C = {}
hist = [[-1 for _ in range(W)] for _ in range(H)]
col = -1
for i in range(H):
for j in range(W):
if S[i][j] == "#" and hist[i][j] == -1:
col += 1
... | from collections import deque
H, W = list(map(int, input().split()))
S = [input().strip() for _ in range(H)]
hist = [[0 for _ in range(W)] for _ in range(H)]
col = 1
for i in range(H):
for j in range(W):
if hist[i][j] == 0:
hist[i][j] = col
que = deque([(i, j, S[i][j])])
... | false | 30.508475 | [
"-D = {0: \".\", 1: \"#\"}",
"-G = {}",
"-C = {}",
"-hist = [[-1 for _ in range(W)] for _ in range(H)]",
"-col = -1",
"+hist = [[0 for _ in range(W)] for _ in range(H)]",
"+col = 1",
"- if S[i][j] == \"#\" and hist[i][j] == -1:",
"+ if hist[i][j] == 0:",
"+ hist[i][j] = co... | false | 0.038737 | 0.041798 | 0.926752 | [
"s791164876",
"s143434857"
] |
u672475305 | p02780 | python | s949314271 | s251675567 | 415 | 351 | 33,892 | 34,148 | Accepted | Accepted | 15.42 | import numpy as np
n,k = list(map(int,input().split()))
lst = list(map(int,input().split()))
exp_val = [(l+1)/2 for l in lst]
cumsum = np.cumsum(exp_val)
for i in range(k-1, n):
if i==k-1:
val = cumsum[i]
else:
val = max(val, cumsum[i] - cumsum[i-k])
print(val) | import numpy as np
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
cs = []
for x in p:
cs.append(((x+1)*x//2)/x)
cs = [0]+np.cumsum(cs).tolist()
ans = 0
for i in range(k, n+1):
ans = max(ans, cs[i]-cs[i-k])
print(ans) | 14 | 11 | 295 | 253 | import numpy as np
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
exp_val = [(l + 1) / 2 for l in lst]
cumsum = np.cumsum(exp_val)
for i in range(k - 1, n):
if i == k - 1:
val = cumsum[i]
else:
val = max(val, cumsum[i] - cumsum[i - k])
print(val)
| import numpy as np
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
cs = []
for x in p:
cs.append(((x + 1) * x // 2) / x)
cs = [0] + np.cumsum(cs).tolist()
ans = 0
for i in range(k, n + 1):
ans = max(ans, cs[i] - cs[i - k])
print(ans)
| false | 21.428571 | [
"-lst = list(map(int, input().split()))",
"-exp_val = [(l + 1) / 2 for l in lst]",
"-cumsum = np.cumsum(exp_val)",
"-for i in range(k - 1, n):",
"- if i == k - 1:",
"- val = cumsum[i]",
"- else:",
"- val = max(val, cumsum[i] - cumsum[i - k])",
"-print(val)",
"+p = list(map(int,... | false | 0.551002 | 0.177436 | 3.10535 | [
"s949314271",
"s251675567"
] |
u020373088 | p03495 | python | s518605228 | s494194025 | 112 | 98 | 32,564 | 32,564 | Accepted | Accepted | 12.5 | from collections import Counter
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnts = list(Counter(a).values())
print((sum(sorted(cnts)[:-k]))) | from collections import Counter
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnts = list(Counter(a).values())
print((sum(sorted(cnts, reverse=True)[k:]))) | 5 | 5 | 161 | 174 | from collections import Counter
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnts = list(Counter(a).values())
print((sum(sorted(cnts)[:-k])))
| from collections import Counter
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
cnts = list(Counter(a).values())
print((sum(sorted(cnts, reverse=True)[k:])))
| false | 0 | [
"-print((sum(sorted(cnts)[:-k])))",
"+print((sum(sorted(cnts, reverse=True)[k:])))"
] | false | 0.052856 | 0.05752 | 0.918914 | [
"s518605228",
"s494194025"
] |
u133936772 | p02598 | python | s624291667 | s719956788 | 914 | 764 | 31,240 | 31,076 | Accepted | Accepted | 16.41 | from math import *
f=lambda:[*list(map(int,input().split()))]
n,k=f()
a=f()
def ok(x):
c=0
for i in a:
c+=ceil(i/x)
return c<=n+k
l,r=0,10**9+1
while r-l>0.1:
m=(l+r)/2
if ok(m): r=m
else: l=m
t=ceil(r)
print((t-ok(t-1) if t>1 else t)) | from math import *
f=lambda:[*list(map(int,input().split()))]
n,k=f()
a=f()
def ok(x):
c=0
for i in a:
c+=ceil(i/x)
return c<=n+k
l,r=0,10**9
while r-l>1:
m=(l+r)/2
if ok(m): r=m
else: l=m
t=ceil(r)
print((t-ok(t-1) if t>1 else t)) | 16 | 16 | 258 | 254 | from math import *
f = lambda: [*list(map(int, input().split()))]
n, k = f()
a = f()
def ok(x):
c = 0
for i in a:
c += ceil(i / x)
return c <= n + k
l, r = 0, 10**9 + 1
while r - l > 0.1:
m = (l + r) / 2
if ok(m):
r = m
else:
l = m
t = ceil(r)
print((t - ok(t - 1) if... | from math import *
f = lambda: [*list(map(int, input().split()))]
n, k = f()
a = f()
def ok(x):
c = 0
for i in a:
c += ceil(i / x)
return c <= n + k
l, r = 0, 10**9
while r - l > 1:
m = (l + r) / 2
if ok(m):
r = m
else:
l = m
t = ceil(r)
print((t - ok(t - 1) if t > 1... | false | 0 | [
"-l, r = 0, 10**9 + 1",
"-while r - l > 0.1:",
"+l, r = 0, 10**9",
"+while r - l > 1:"
] | false | 0.069953 | 0.043216 | 1.61866 | [
"s624291667",
"s719956788"
] |
u150984829 | p02412 | python | s361445566 | s460408795 | 30 | 20 | 5,608 | 5,600 | Accepted | Accepted | 33.33 | while 1:
n,x=list(map(int,input().split()))
if n+x==0:break
print((len([1 for i in range(1,x//3)for j in range(i+1,n)if j<x-i-j<=n]))) | while 1:
n,x=list(map(int,input().split()))
if n+x==0:break
print((sum([max(0,(x-a-1)//2-max(a,x-a-1-n))for a in range(1,x//3)]))) | 4 | 4 | 132 | 128 | while 1:
n, x = list(map(int, input().split()))
if n + x == 0:
break
print(
(
len(
[
1
for i in range(1, x // 3)
for j in range(i + 1, n)
if j < x - i - j <= n
]
... | while 1:
n, x = list(map(int, input().split()))
if n + x == 0:
break
print(
(
sum(
[
max(0, (x - a - 1) // 2 - max(a, x - a - 1 - n))
for a in range(1, x // 3)
]
)
)
)
| false | 0 | [
"- len(",
"+ sum(",
"- 1",
"- for i in range(1, x // 3)",
"- for j in range(i + 1, n)",
"- if j < x - i - j <= n",
"+ max(0, (x - a - 1) // 2 - max(a, x - a - 1 - n))",
"+ ... | false | 0.046316 | 0.091525 | 0.506053 | [
"s361445566",
"s460408795"
] |
u261103969 | p02695 | python | s759660721 | s078270440 | 672 | 316 | 23,164 | 9,120 | Accepted | Accepted | 52.98 | from collections import deque
# 数列の点数を計算する関数
def calc(seq):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
return score
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que =... | def dfs(seq):
# 返り値は、すべての数列の得点の最大値 ans です。
ans = 0
if len(seq) == n:
# 数列が完成したので、得点を計算します
score_ret = 0
for a, b, c, d in req:
if seq[b-1] - seq[a-1] == c:
score_ret += d
return score_ret # この数列の得点を返します
else:
# まだ数列が完成していません... | 39 | 32 | 771 | 938 | from collections import deque
# 数列の点数を計算する関数
def calc(seq):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
return score
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que = deque()
# 数列の1番目、[1]~... | def dfs(seq):
# 返り値は、すべての数列の得点の最大値 ans です。
ans = 0
if len(seq) == n:
# 数列が完成したので、得点を計算します
score_ret = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score_ret += d
return score_ret # この数列の得点を返します
else:
# まだ数列が完成していません
... | false | 17.948718 | [
"-from collections import deque",
"-",
"-# 数列の点数を計算する関数",
"-def calc(seq):",
"- score = 0",
"- for a, b, c, d in req:",
"- if seq[b - 1] - seq[a - 1] == c:",
"- score += d",
"- return score",
"+def dfs(seq):",
"+ # 返り値は、すべての数列の得点の最大値 ans です。",
"+ ans = 0",
"+... | false | 0.006977 | 0.054168 | 0.12881 | [
"s759660721",
"s078270440"
] |
u467479913 | p02615 | python | s251379096 | s908036005 | 170 | 126 | 31,672 | 31,316 | Accepted | Accepted | 25.88 | eval(input())
l = sorted(map(int, input().split(' ')))
answer = 0
spots = [l.pop()]
x = len(l)
for i in range(x):
n = l.pop()
answer += spots[i]
spots.append(n)
spots.append(n)
print(answer)
| n = int(eval(input()))
l = list(map(int, input().split(' ')))
l.sort()
s = l.pop()
while n > 3:
s += l.pop() * 2
n -= 2
if n == 3:
s += l.pop()
print(s) | 14 | 10 | 205 | 158 | eval(input())
l = sorted(map(int, input().split(" ")))
answer = 0
spots = [l.pop()]
x = len(l)
for i in range(x):
n = l.pop()
answer += spots[i]
spots.append(n)
spots.append(n)
print(answer)
| n = int(eval(input()))
l = list(map(int, input().split(" ")))
l.sort()
s = l.pop()
while n > 3:
s += l.pop() * 2
n -= 2
if n == 3:
s += l.pop()
print(s)
| false | 28.571429 | [
"-eval(input())",
"-l = sorted(map(int, input().split(\" \")))",
"-answer = 0",
"-spots = [l.pop()]",
"-x = len(l)",
"-for i in range(x):",
"- n = l.pop()",
"- answer += spots[i]",
"- spots.append(n)",
"- spots.append(n)",
"-print(answer)",
"+n = int(eval(input()))",
"+l = list(m... | false | 0.039215 | 0.039044 | 1.004363 | [
"s251379096",
"s908036005"
] |
u260036763 | p03416 | python | s821841002 | s836759784 | 211 | 35 | 39,408 | 2,940 | Accepted | Accepted | 83.41 | a, b = list(map(int, input().split()))
count = 0
for i in range(a,b+1):
b1 = i%10
s = i//10
b2 = s%10
t = s//10
u = t//10
a2 = u%10
v = u//10
a1 = v%10
if a1 == b1 and a2 == b2:
count += 1
print(count) | A, B = list(map(int, input().split()))
count = 0
for n in range(A, B+1):
if n//10000 == n%10 and (n//1000)%10 == (n//10)%10:
count += 1
print(count) | 14 | 6 | 230 | 153 | a, b = list(map(int, input().split()))
count = 0
for i in range(a, b + 1):
b1 = i % 10
s = i // 10
b2 = s % 10
t = s // 10
u = t // 10
a2 = u % 10
v = u // 10
a1 = v % 10
if a1 == b1 and a2 == b2:
count += 1
print(count)
| A, B = list(map(int, input().split()))
count = 0
for n in range(A, B + 1):
if n // 10000 == n % 10 and (n // 1000) % 10 == (n // 10) % 10:
count += 1
print(count)
| false | 57.142857 | [
"-a, b = list(map(int, input().split()))",
"+A, B = list(map(int, input().split()))",
"-for i in range(a, b + 1):",
"- b1 = i % 10",
"- s = i // 10",
"- b2 = s % 10",
"- t = s // 10",
"- u = t // 10",
"- a2 = u % 10",
"- v = u // 10",
"- a1 = v % 10",
"- if a1 == b1 ... | false | 0.103035 | 0.040498 | 2.544168 | [
"s821841002",
"s836759784"
] |
u018679195 | p03072 | python | s472209866 | s018676588 | 21 | 18 | 3,316 | 3,060 | Accepted | Accepted | 14.29 | n = int(eval(input()))
xs = [int(x) for x in input().split()]
mx = xs[0]
count = 0
for x in xs:
if x >= mx:
count += 1
mx = x
print(count)
| line = eval(input())
line = eval(input())
numbers = [int(n) for n in line.split()]
predicted_value = 0
for i in range(len(numbers)):
is_smaller = False
for k in range(i):
if numbers[i] < numbers[k]:
is_smaller = True
break
if not is_smaller:
predicted_value... | 12 | 13 | 167 | 337 | n = int(eval(input()))
xs = [int(x) for x in input().split()]
mx = xs[0]
count = 0
for x in xs:
if x >= mx:
count += 1
mx = x
print(count)
| line = eval(input())
line = eval(input())
numbers = [int(n) for n in line.split()]
predicted_value = 0
for i in range(len(numbers)):
is_smaller = False
for k in range(i):
if numbers[i] < numbers[k]:
is_smaller = True
break
if not is_smaller:
predicted_value += 1
print... | false | 7.692308 | [
"-n = int(eval(input()))",
"-xs = [int(x) for x in input().split()]",
"-mx = xs[0]",
"-count = 0",
"-for x in xs:",
"- if x >= mx:",
"- count += 1",
"- mx = x",
"-print(count)",
"+line = eval(input())",
"+line = eval(input())",
"+numbers = [int(n) for n in line.split()]",
"+... | false | 0.036647 | 0.038018 | 0.963936 | [
"s472209866",
"s018676588"
] |
u525065967 | p03288 | python | s350335220 | s435203330 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | r = int(eval(input()))
ans = 'ARC'
if r < 1200: ans = 'ABC'
elif 2800 <= r: ans = 'AGC'
print(ans)
| r = int(eval(input()))
if r < 1200: print('ABC')
elif 2800 <= r: print('AGC')
else: print('ARC')
| 5 | 4 | 97 | 94 | r = int(eval(input()))
ans = "ARC"
if r < 1200:
ans = "ABC"
elif 2800 <= r:
ans = "AGC"
print(ans)
| r = int(eval(input()))
if r < 1200:
print("ABC")
elif 2800 <= r:
print("AGC")
else:
print("ARC")
| false | 20 | [
"-ans = \"ARC\"",
"- ans = \"ABC\"",
"+ print(\"ABC\")",
"- ans = \"AGC\"",
"-print(ans)",
"+ print(\"AGC\")",
"+else:",
"+ print(\"ARC\")"
] | false | 0.066437 | 0.066549 | 0.998322 | [
"s350335220",
"s435203330"
] |
u256256172 | p02407 | python | s066430616 | s670621601 | 30 | 20 | 7,448 | 7,448 | Accepted | Accepted | 33.33 | eval(input())
a = list(input().split())
a.reverse()
print((" ".join(a))) | eval(input())
print((" ".join(reversed(input().split())))) | 4 | 2 | 67 | 51 | eval(input())
a = list(input().split())
a.reverse()
print((" ".join(a)))
| eval(input())
print((" ".join(reversed(input().split()))))
| false | 50 | [
"-a = list(input().split())",
"-a.reverse()",
"-print((\" \".join(a)))",
"+print((\" \".join(reversed(input().split()))))"
] | false | 0.195506 | 0.035395 | 5.523508 | [
"s066430616",
"s670621601"
] |
u504800764 | p02658 | python | s846300653 | s670570785 | 91 | 54 | 84,632 | 21,488 | Accepted | Accepted | 40.66 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 1
for i in range(n):
ans *= a[i]
if(ans > 1000000000000000000):
break
if(ans > 1000000000000000000):
print((-1))
else:
print(ans)
| n = int(eval(input()))
a = list(map(int,input().split()))
if 0 in a:
print((0))
exit()
ans = 1
for i in a:
ans *= i
if(ans > 10**18):
print((-1))
exit()
print(ans) | 15 | 15 | 245 | 202 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 1
for i in range(n):
ans *= a[i]
if ans > 1000000000000000000:
break
if ans > 1000000000000000000:
print((-1))
else:
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
if 0 in a:
print((0))
exit()
ans = 1
for i in a:
ans *= i
if ans > 10**18:
print((-1))
exit()
print(ans)
| false | 0 | [
"-a.sort()",
"+if 0 in a:",
"+ print((0))",
"+ exit()",
"-for i in range(n):",
"- ans *= a[i]",
"- if ans > 1000000000000000000:",
"- break",
"-if ans > 1000000000000000000:",
"- print((-1))",
"-else:",
"- print(ans)",
"+for i in a:",
"+ ans *= i",
"+ if an... | false | 0.043952 | 0.137107 | 0.32057 | [
"s846300653",
"s670570785"
] |
u006883624 | p02768 | python | s178762665 | s471482584 | 154 | 114 | 3,572 | 3,572 | Accepted | Accepted | 25.97 | # from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]
def main():
def modcmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
... | # from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]
def main():
mod = 1000000007
n, a, b = list(map(int, input().split()))
def combi(n, r):
if ... | 40 | 50 | 993 | 970 | # from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]
def main():
def modcmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
if r ==... | # from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]
def main():
mod = 1000000007
n, a, b = list(map(int, input().split()))
def combi(n, r):
if r < 0 or r > n:
... | false | 20 | [
"- def modcmb(n, r, mod):",
"+ mod = 1000000007",
"+ n, a, b = list(map(int, input().split()))",
"+",
"+ def combi(n, r):",
"- r = min(r, n - r)",
"+ r = min(n - r, r)",
"+ over = 1",
"+ under = 1",
"+ for i in range(n - r + 1, n + 1):",
"+ ... | false | 0.475435 | 0.12683 | 3.74859 | [
"s178762665",
"s471482584"
] |
u562935282 | p02629 | python | s167084265 | s248100867 | 45 | 38 | 9,968 | 9,888 | Accepted | Accepted | 15.56 | def main():
from string import ascii_lowercase
N = int(eval(input()))
ans = ''
while N > 0:
N -= 1
N, r = divmod(N, 26)
ans = ascii_lowercase[r] + ans
print(ans)
if __name__ == '__main__':
main()
# import sys
# input = sys.stdin.readline
#
# sys... | def main():
from string import ascii_lowercase
N = int(eval(input()))
def rec(n):
if n == 0: return ''
n -= 1
n, r = divmod(n, 26)
return rec(n) + ascii_lowercase[r]
print((rec(N)))
if __name__ == '__main__':
main()
| 33 | 16 | 609 | 280 | def main():
from string import ascii_lowercase
N = int(eval(input()))
ans = ""
while N > 0:
N -= 1
N, r = divmod(N, 26)
ans = ascii_lowercase[r] + ans
print(ans)
if __name__ == "__main__":
main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 **... | def main():
from string import ascii_lowercase
N = int(eval(input()))
def rec(n):
if n == 0:
return ""
n -= 1
n, r = divmod(n, 26)
return rec(n) + ascii_lowercase[r]
print((rec(N)))
if __name__ == "__main__":
main()
| false | 51.515152 | [
"- ans = \"\"",
"- while N > 0:",
"- N -= 1",
"- N, r = divmod(N, 26)",
"- ans = ascii_lowercase[r] + ans",
"- print(ans)",
"+",
"+ def rec(n):",
"+ if n == 0:",
"+ return \"\"",
"+ n -= 1",
"+ n, r = divmod(n, 26)",
"+ ... | false | 0.043337 | 0.102798 | 0.421571 | [
"s167084265",
"s248100867"
] |
u745514010 | p03565 | python | s141912502 | s670432736 | 30 | 26 | 9,100 | 9,108 | Accepted | Accepted | 13.33 | s = input()[::-1]
t = input()[::-1]
if len(s) < len(t):
print("UNRESTORABLE")
exit()
for i in range(len(s) - len(t) + 1):
for j in range(len(t)):
if s[i + j] == "?":
continue
elif s[i + j] == t[j]:
continue
break
else:
ans = ""
... | s = input()[::-1]
t = input()[::-1]
if len(s) < len(t):
print("UNRESTORABLE")
exit()
tmp = s.replace("?", "a")
if t in tmp:
print((tmp[::-1]))
exit()
for i in range(len(s) - len(t) + 1):
for j in range(len(t)):
if s[i + j] == "?":
continue
elif s[... | 30 | 35 | 711 | 792 | s = input()[::-1]
t = input()[::-1]
if len(s) < len(t):
print("UNRESTORABLE")
exit()
for i in range(len(s) - len(t) + 1):
for j in range(len(t)):
if s[i + j] == "?":
continue
elif s[i + j] == t[j]:
continue
break
else:
ans = ""
for k in ran... | s = input()[::-1]
t = input()[::-1]
if len(s) < len(t):
print("UNRESTORABLE")
exit()
tmp = s.replace("?", "a")
if t in tmp:
print((tmp[::-1]))
exit()
for i in range(len(s) - len(t) + 1):
for j in range(len(t)):
if s[i + j] == "?":
continue
elif s[i + j] == t[j]:
... | false | 14.285714 | [
"+ exit()",
"+tmp = s.replace(\"?\", \"a\")",
"+if t in tmp:",
"+ print((tmp[::-1]))"
] | false | 0.043936 | 0.045515 | 0.965299 | [
"s141912502",
"s670432736"
] |
u923279197 | p03107 | python | s880049597 | s714192326 | 171 | 31 | 39,792 | 3,188 | Accepted | Accepted | 81.87 | s = eval(input())
a = 0
b = 0
for i in s:
if i == "1":
a += 1
else:
b += 1
print((len(s)-abs(a-b))) | s = eval(input())
r = 0
b = 0
for i in s:
if i == "1":r += 1
else: b += 1
now = max(b,r) - min(b,r)
ans = len(s)-now
print(ans) | 9 | 10 | 123 | 139 | s = eval(input())
a = 0
b = 0
for i in s:
if i == "1":
a += 1
else:
b += 1
print((len(s) - abs(a - b)))
| s = eval(input())
r = 0
b = 0
for i in s:
if i == "1":
r += 1
else:
b += 1
now = max(b, r) - min(b, r)
ans = len(s) - now
print(ans)
| false | 10 | [
"-a = 0",
"+r = 0",
"- a += 1",
"+ r += 1",
"-print((len(s) - abs(a - b)))",
"+now = max(b, r) - min(b, r)",
"+ans = len(s) - now",
"+print(ans)"
] | false | 0.046649 | 0.08882 | 0.525206 | [
"s880049597",
"s714192326"
] |
u994988729 | p03659 | python | s973287428 | s585271008 | 258 | 176 | 76,880 | 24,168 | Accepted | Accepted | 31.78 | N = int(eval(input()))
A = list(map(int, input().split()))
x = sum(A)
y = 0
res = 10 ** 18
for i in range(N - 1):
x -= A[i]
y += A[i]
res = min(res, abs(x - y))
print(res)
| from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
Acum = list(accumulate(A))
ans = 10 ** 20
for a in Acum[:-1]:
snuke = a
arai = Acum[-1] - a
ans = min(ans, abs(snuke - arai))
print(ans) | 13 | 12 | 193 | 247 | N = int(eval(input()))
A = list(map(int, input().split()))
x = sum(A)
y = 0
res = 10**18
for i in range(N - 1):
x -= A[i]
y += A[i]
res = min(res, abs(x - y))
print(res)
| from itertools import accumulate
N = int(eval(input()))
A = list(map(int, input().split()))
Acum = list(accumulate(A))
ans = 10**20
for a in Acum[:-1]:
snuke = a
arai = Acum[-1] - a
ans = min(ans, abs(snuke - arai))
print(ans)
| false | 7.692308 | [
"+from itertools import accumulate",
"+",
"-x = sum(A)",
"-y = 0",
"-res = 10**18",
"-for i in range(N - 1):",
"- x -= A[i]",
"- y += A[i]",
"- res = min(res, abs(x - y))",
"-print(res)",
"+Acum = list(accumulate(A))",
"+ans = 10**20",
"+for a in Acum[:-1]:",
"+ snuke = a",
"... | false | 0.034087 | 0.036062 | 0.945227 | [
"s973287428",
"s585271008"
] |
u690419532 | p02621 | python | s783723848 | s231481735 | 26 | 24 | 9,140 | 9,148 | Accepted | Accepted | 7.69 | a = int(eval(input()))
x = a + a**2 + a**3
print(x) | a = int(eval(input()))
print((a + a**2 + a**3)) | 3 | 2 | 47 | 40 | a = int(eval(input()))
x = a + a**2 + a**3
print(x)
| a = int(eval(input()))
print((a + a**2 + a**3))
| false | 33.333333 | [
"-x = a + a**2 + a**3",
"-print(x)",
"+print((a + a**2 + a**3))"
] | false | 0.03602 | 0.036483 | 0.987302 | [
"s783723848",
"s231481735"
] |
u252805217 | p02912 | python | s680185625 | s282338963 | 223 | 149 | 14,380 | 14,380 | Accepted | Accepted | 33.18 | from math import ceil
from heapq import *
n, m = list(map(int, input().split()))
a_s = [-int(a) for a in input().split()]
heapify(a_s)
for _ in range(m):
amax = heappop(a_s)
heappush(a_s, ceil(amax / 2))
res = sum([-heappop(a_s) for _ in range(n)])
print(res) | from math import ceil
from heapq import *
n, m = list(map(int, input().split()))
a_s = [-int(a) for a in input().split()]
heapify(a_s)
for _ in range(m):
amax = -heappop(a_s)
heappush(a_s, -(amax // 2))
res = -sum(a_s)
print(res)
| 13 | 13 | 270 | 241 | from math import ceil
from heapq import *
n, m = list(map(int, input().split()))
a_s = [-int(a) for a in input().split()]
heapify(a_s)
for _ in range(m):
amax = heappop(a_s)
heappush(a_s, ceil(amax / 2))
res = sum([-heappop(a_s) for _ in range(n)])
print(res)
| from math import ceil
from heapq import *
n, m = list(map(int, input().split()))
a_s = [-int(a) for a in input().split()]
heapify(a_s)
for _ in range(m):
amax = -heappop(a_s)
heappush(a_s, -(amax // 2))
res = -sum(a_s)
print(res)
| false | 0 | [
"- amax = heappop(a_s)",
"- heappush(a_s, ceil(amax / 2))",
"-res = sum([-heappop(a_s) for _ in range(n)])",
"+ amax = -heappop(a_s)",
"+ heappush(a_s, -(amax // 2))",
"+res = -sum(a_s)"
] | false | 0.048235 | 0.047413 | 1.017349 | [
"s680185625",
"s282338963"
] |
u172035535 | p03835 | python | s149112727 | s771467396 | 1,514 | 17 | 3,060 | 3,064 | Accepted | Accepted | 98.88 | K,S = list(map(int,input().split()))
ans = 0
for x in range(K+1):
for y in range(K+1):
z = S-x-y
if 0<=z<=K:
ans += 1
print(ans) | k,s = list(map(int,input().split()))
a = ((s+1)*(s+2))//2
b = ((s-k)*(s-k+1))//2
c = (((abs(s-k*3))+1)*((abs(s-k*3))+2))//2
if s <= k:
print(a)
elif s <= k*2:
print((a-b*3))
elif s <= k*3:
print(c) | 8 | 11 | 161 | 212 | K, S = list(map(int, input().split()))
ans = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if 0 <= z <= K:
ans += 1
print(ans)
| k, s = list(map(int, input().split()))
a = ((s + 1) * (s + 2)) // 2
b = ((s - k) * (s - k + 1)) // 2
c = (((abs(s - k * 3)) + 1) * ((abs(s - k * 3)) + 2)) // 2
if s <= k:
print(a)
elif s <= k * 2:
print((a - b * 3))
elif s <= k * 3:
print(c)
| false | 27.272727 | [
"-K, S = list(map(int, input().split()))",
"-ans = 0",
"-for x in range(K + 1):",
"- for y in range(K + 1):",
"- z = S - x - y",
"- if 0 <= z <= K:",
"- ans += 1",
"-print(ans)",
"+k, s = list(map(int, input().split()))",
"+a = ((s + 1) * (s + 2)) // 2",
"+b = ((s - k... | false | 0.046524 | 0.046829 | 0.993501 | [
"s149112727",
"s771467396"
] |
u492910842 | p02623 | python | s673307974 | s887489213 | 190 | 156 | 127,072 | 132,668 | Accepted | Accepted | 17.89 | import bisect
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
A,B=[0],[0]
for i in range(n):
A.append(a[i]+A[i])
for i in range(m):
B.append(b[i]+B[i])
for j in range(n+1):
K=k-A[j]
if K<0:
break
else:
ans=max(ans,bisect.b... | n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans,right=0,0
A,B=[0],[0]
for i in range(n):
A.append(a[i]+A[i])
for i in range(m):
B.append(b[i]+B[i])
for i in range(m+1):
if k<B[i] or i==m:
right=i-1
if i==m:
right=i
ans=ri... | 20 | 26 | 353 | 461 | import bisect
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
A, B = [0], [0]
for i in range(n):
A.append(a[i] + A[i])
for i in range(m):
B.append(b[i] + B[i])
for j in range(n + 1):
K = k - A[j]
if K < 0:
break
else:... | n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans, right = 0, 0
A, B = [0], [0]
for i in range(n):
A.append(a[i] + A[i])
for i in range(m):
B.append(b[i] + B[i])
for i in range(m + 1):
if k < B[i] or i == m:
right = i - 1
if... | false | 23.076923 | [
"-import bisect",
"-",
"-ans = 0",
"+ans, right = 0, 0",
"-for j in range(n + 1):",
"- K = k - A[j]",
"- if K < 0:",
"+for i in range(m + 1):",
"+ if k < B[i] or i == m:",
"+ right = i - 1",
"+ if i == m:",
"+ right = i",
"+ ans = right",
"- else... | false | 0.039825 | 0.039431 | 1.010014 | [
"s673307974",
"s887489213"
] |
u709079466 | p02881 | python | s534612586 | s671713136 | 374 | 223 | 9,124 | 9,056 | Accepted | Accepted | 40.37 | import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
n = int(eval(input()))
a = 1
b = 1
tmp_ans = 0
ans = 10**12
if is_prime(n) == True:
print((n - 1))
elif is_prime(n) == False:
... | import math
n = int(eval(input()))
a = 1
b = 1
tmp_ans = 0
ans = 10**12
for i in range(1, int(math.sqrt(n))+1):
j = n // i
if n == i*j:
tmp_ans = (i-a) + (j-b)
if tmp_ans < ans:
ans = tmp_ans
print(ans)
| 25 | 15 | 511 | 249 | import math
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
n = int(eval(input()))
a = 1
b = 1
tmp_ans = 0
ans = 10**12
if is_prime(n) == True:
print((n - 1))
elif is_prime(n) == False:
for i i... | import math
n = int(eval(input()))
a = 1
b = 1
tmp_ans = 0
ans = 10**12
for i in range(1, int(math.sqrt(n)) + 1):
j = n // i
if n == i * j:
tmp_ans = (i - a) + (j - b)
if tmp_ans < ans:
ans = tmp_ans
print(ans)
| false | 40 | [
"-",
"-",
"-def is_prime(n):",
"- if n == 1:",
"- return False",
"- for k in range(2, int(math.sqrt(n)) + 1):",
"- if n % k == 0:",
"- return False",
"- return True",
"-",
"-if is_prime(n) == True:",
"- print((n - 1))",
"-elif is_prime(n) == False:",
"-... | false | 0.042438 | 0.040518 | 1.047374 | [
"s534612586",
"s671713136"
] |
u971091945 | p02726 | python | s828236433 | s288967582 | 1,699 | 1,296 | 3,444 | 3,444 | Accepted | Accepted | 23.72 | n, x, y = list(map(int, input().split()))
li = [0]*(n-1)
num = 0
for i in range(1,n+1):
for j in range(i+1,n+1):
if j<=x or y<i:
num = j-i
elif i<=x and x<j<=y:
num = (x-i)+min(j-x, y-j+1)
elif i<=x and y<j:
num = (x-i)+(j-y)+1
elif x<... | n, x, y = list(map(int, input().split()))
li = [0] * (n - 1)
num = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
num = min(j-i, abs(i-x)+abs(j-y)+1)
li[num - 1] += 1
for i in li:
print(i) | 20 | 11 | 492 | 229 | n, x, y = list(map(int, input().split()))
li = [0] * (n - 1)
num = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
if j <= x or y < i:
num = j - i
elif i <= x and x < j <= y:
num = (x - i) + min(j - x, y - j + 1)
elif i <= x and y < j:
num = (x -... | n, x, y = list(map(int, input().split()))
li = [0] * (n - 1)
num = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
num = min(j - i, abs(i - x) + abs(j - y) + 1)
li[num - 1] += 1
for i in li:
print(i)
| false | 45 | [
"- if j <= x or y < i:",
"- num = j - i",
"- elif i <= x and x < j <= y:",
"- num = (x - i) + min(j - x, y - j + 1)",
"- elif i <= x and y < j:",
"- num = (x - i) + (j - y) + 1",
"- elif x < i and j <= y:",
"- num = min(j - i, (i ... | false | 0.100017 | 0.036221 | 2.761335 | [
"s828236433",
"s288967582"
] |
u279955105 | p02397 | python | s086514122 | s541607869 | 80 | 60 | 7,540 | 5,608 | Accepted | Accepted | 25 | while True:
a,b = list(map(int, input().split()))
if a == 0 and b ==0:
break
elif a < b:
print((a,b))
else:
print((b,a)) | i = 0
while True:
a,b = list(map(int, input().split()))
if (a == 0) and (b == 0):
break
elif a < b:
print((str(a)+' '+str(b)))
i = i + 1
else:
print((str(b)+' '+str(a)))
i = i + 1
| 8 | 11 | 163 | 236 | while True:
a, b = list(map(int, input().split()))
if a == 0 and b == 0:
break
elif a < b:
print((a, b))
else:
print((b, a))
| i = 0
while True:
a, b = list(map(int, input().split()))
if (a == 0) and (b == 0):
break
elif a < b:
print((str(a) + " " + str(b)))
i = i + 1
else:
print((str(b) + " " + str(a)))
i = i + 1
| false | 27.272727 | [
"+i = 0",
"- if a == 0 and b == 0:",
"+ if (a == 0) and (b == 0):",
"- print((a, b))",
"+ print((str(a) + \" \" + str(b)))",
"+ i = i + 1",
"- print((b, a))",
"+ print((str(b) + \" \" + str(a)))",
"+ i = i + 1"
] | false | 0.043616 | 0.037382 | 1.166768 | [
"s086514122",
"s541607869"
] |
u554954744 | p02982 | python | s197193511 | s364579369 | 181 | 166 | 38,384 | 38,256 | Accepted | Accepted | 8.29 | import math
N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
for j in range(i, N):
tmp = 0
if i == j:
continue
for k in range(D):
tmp += (X[i][k] - X[j][k]) ** 2
if math.sq... | import math
N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
for j in range(i+1, N):
tmp = 0
for k in range(D):
tmp += (X[i][k] - X[j][k]) ** 2
if math.sqrt(tmp).is_integer():
cnt +... | 17 | 15 | 379 | 339 | import math
N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
for j in range(i, N):
tmp = 0
if i == j:
continue
for k in range(D):
tmp += (X[i][k] - X[j][k]) ** 2
if math.sqrt(tmp).is_int... | import math
N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
for j in range(i + 1, N):
tmp = 0
for k in range(D):
tmp += (X[i][k] - X[j][k]) ** 2
if math.sqrt(tmp).is_integer():
cnt += 1
print(c... | false | 11.764706 | [
"- for j in range(i, N):",
"+ for j in range(i + 1, N):",
"- if i == j:",
"- continue"
] | false | 0.074596 | 0.049457 | 1.508291 | [
"s197193511",
"s364579369"
] |
u055875839 | p02813 | python | s152134182 | s964705284 | 151 | 27 | 12,480 | 8,052 | Accepted | Accepted | 82.12 | from numpy import prod
n = int(eval(input()))
def solve(l:list):
now = [i + 1 for i in range(n)]
res = 0
for i in range(n):
res += now.index(l[i]) * prod([j+1 for j in range(len(now)-1)])
now.remove(l[i])
return res
l_p = list(map(int, input().split()))
l_q = list(map(int, input().split(... | from itertools import permutations
n = int(eval(input()))
all_ = list(permutations([i+1 for i in range(n)], n))
l_p = tuple(map(int, input().split()))
l_q = tuple(map(int, input().split()))
res = abs(all_.index(l_p) - all_.index(l_q))
print(res) | 16 | 9 | 362 | 249 | from numpy import prod
n = int(eval(input()))
def solve(l: list):
now = [i + 1 for i in range(n)]
res = 0
for i in range(n):
res += now.index(l[i]) * prod([j + 1 for j in range(len(now) - 1)])
now.remove(l[i])
return res
l_p = list(map(int, input().split()))
l_q = list(map(int, inpu... | from itertools import permutations
n = int(eval(input()))
all_ = list(permutations([i + 1 for i in range(n)], n))
l_p = tuple(map(int, input().split()))
l_q = tuple(map(int, input().split()))
res = abs(all_.index(l_p) - all_.index(l_q))
print(res)
| false | 43.75 | [
"-from numpy import prod",
"+from itertools import permutations",
"-",
"-",
"-def solve(l: list):",
"- now = [i + 1 for i in range(n)]",
"- res = 0",
"- for i in range(n):",
"- res += now.index(l[i]) * prod([j + 1 for j in range(len(now) - 1)])",
"- now.remove(l[i])",
"- ... | false | 0.24296 | 0.046979 | 5.171686 | [
"s152134182",
"s964705284"
] |
u600402037 | p03464 | python | s348296417 | s249506844 | 146 | 98 | 14,428 | 14,100 | Accepted | Accepted | 32.88 | import sys
sys.setrecursionlimit(10 ** 7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
A = lr()[::-1]
domain = [2, 2] #現在の最小と最大
for i in range(K):
x = A[i]
left = domain[0]; right = domain[1]
if x > right * 2 - 1:
... | import sys
sys.setrecursionlimit(10 ** 7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
A = lr()[::-1]
left = 2
right = 2
for x in A:
left += (-left) % x
right -= right % x
right += x - 1
if left > right:
print((-... | 26 | 21 | 525 | 359 | import sys
sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
A = lr()[::-1]
domain = [2, 2] # 現在の最小と最大
for i in range(K):
x = A[i]
left = domain[0]
right = domain[1]
if x > right * 2 - 1:
print((-1)... | import sys
sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
K = ir()
A = lr()[::-1]
left = 2
right = 2
for x in A:
left += (-left) % x
right -= right % x
right += x - 1
if left > right:
print((-1))
else:
print((... | false | 19.230769 | [
"-domain = [2, 2] # 現在の最小と最大",
"-for i in range(K):",
"- x = A[i]",
"- left = domain[0]",
"- right = domain[1]",
"- if x > right * 2 - 1:",
"- print((-1))",
"- exit()",
"+left = 2",
"+right = 2",
"+for x in A:",
"- if left > right:",
"- print((-1))",
"-... | false | 0.041498 | 0.0419 | 0.990409 | [
"s348296417",
"s249506844"
] |
u476435125 | p03244 | python | s872351563 | s392205690 | 147 | 104 | 17,644 | 17,632 | Accepted | Accepted | 29.25 | N=int(eval(input()))
lv=list(map(int,input().split()))
dev={}
dod={}
#cev=0#devの種類数
#cod=0#dodの種類数
max1_ev=[0,0]#数字,個数
max2_ev=[0,0]
max1_od=[0,0]#数字,個数
max2_od=[0,0]
for i in range(N):
if i%2==0:#even
#max1_ev=[0,0]#数字,個数
#max2_ev=[0,0]
#毎回初期化していた!!
if lv[i] in de... | N=int(eval(input()))
lv=list(map(int,input().split()))
dev={}
dod={}
for i in range(N):
if i%2==0:#even
if lv[i] in dev:
dev[lv[i]]+=1
else:
dev[lv[i]]=1
else:#odd
if lv[i] in dod:
dod[lv[i]]+=1
else:
dod[lv[i]]=1
m... | 80 | 39 | 2,089 | 883 | N = int(eval(input()))
lv = list(map(int, input().split()))
dev = {}
dod = {}
# cev=0#devの種類数
# cod=0#dodの種類数
max1_ev = [0, 0] # 数字,個数
max2_ev = [0, 0]
max1_od = [0, 0] # 数字,個数
max2_od = [0, 0]
for i in range(N):
if i % 2 == 0: # even
# max1_ev=[0,0]#数字,個数
# max2_ev=[0,0]
# 毎回初期化していた!!
... | N = int(eval(input()))
lv = list(map(int, input().split()))
dev = {}
dod = {}
for i in range(N):
if i % 2 == 0: # even
if lv[i] in dev:
dev[lv[i]] += 1
else:
dev[lv[i]] = 1
else: # odd
if lv[i] in dod:
dod[lv[i]] += 1
else:
dod[lv... | false | 51.25 | [
"-# cev=0#devの種類数",
"-# cod=0#dodの種類数",
"-max1_ev = [0, 0] # 数字,個数",
"-max2_ev = [0, 0]",
"-max1_od = [0, 0] # 数字,個数",
"-max2_od = [0, 0]",
"- # max1_ev=[0,0]#数字,個数",
"- # max2_ev=[0,0]",
"- # 毎回初期化していた!!",
"- if lv[i] in dev: # 辞書の更新",
"+ if lv[i] in dev:",... | false | 0.038965 | 0.06831 | 0.570422 | [
"s872351563",
"s392205690"
] |
u328510800 | p03013 | python | s095323946 | s802833731 | 562 | 388 | 466,584 | 469,664 | Accepted | Accepted | 30.96 | n, m = list(map(int, input().split()))
stairs = [i for i in range(1, n+1)]
a = [0 for _ in range(m)]
for i in range(m):
a[i] = int(eval(input()))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n+1):
if i in a:
continue
dp[i] = dp[i] + dp[i-1]
if i > 1:
dp[i] = dp[i] + dp[i-... | n, m = list(map(int, input().split()))
stairs = [i for i in range(1, n+1)]
a = [0 for _ in range(m)]
for i in range(m):
a[i] = int(eval(input()))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n+1):
if i in a:
continue
dp[i] = dp[i-1]
if i > 1:
dp[i] += dp[i-2]
print((dp... | 18 | 18 | 339 | 324 | n, m = list(map(int, input().split()))
stairs = [i for i in range(1, n + 1)]
a = [0 for _ in range(m)]
for i in range(m):
a[i] = int(eval(input()))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i in a:
continue
dp[i] = dp[i] + dp[i - 1]
if i > 1:
dp[i] = dp[i] + dp... | n, m = list(map(int, input().split()))
stairs = [i for i in range(1, n + 1)]
a = [0 for _ in range(m)]
for i in range(m):
a[i] = int(eval(input()))
a = set(a)
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i in a:
continue
dp[i] = dp[i - 1]
if i > 1:
dp[i] += dp[i - 2]
print((... | false | 0 | [
"- dp[i] = dp[i] + dp[i - 1]",
"+ dp[i] = dp[i - 1]",
"- dp[i] = dp[i] + dp[i - 2]",
"+ dp[i] += dp[i - 2]"
] | false | 0.074191 | 0.062551 | 1.186092 | [
"s095323946",
"s802833731"
] |
u255555420 | p03711 | python | s630455826 | s829086291 | 22 | 17 | 3,060 | 3,060 | Accepted | Accepted | 22.73 | x, y =list(map( int,input().split()))
listA = [1, 3, 5, 7 , 8 , 10 , 12]
listB = [4 , 6, 9, 11]
listC=[2]
if x in listA and y in listA:
print("Yes")
elif x in listB and y in listB:
print("Yes")
elif x in listC and y in listC:
print("Yes")
else:
print("No") | x,y =list(map(int,input().split()))
L1=[1,3,5,7,8,10,12]
L2=[4,6,9,11]
L3=[2]
if x in L1 and y in L1:
print("Yes")
elif x in L2 and y in L2:
print("Yes")
elif x in L3 and y in L3:
print("Yes")
else:
print("No")
| 17 | 17 | 299 | 250 | x, y = list(map(int, input().split()))
listA = [1, 3, 5, 7, 8, 10, 12]
listB = [4, 6, 9, 11]
listC = [2]
if x in listA and y in listA:
print("Yes")
elif x in listB and y in listB:
print("Yes")
elif x in listC and y in listC:
print("Yes")
else:
print("No")
| x, y = list(map(int, input().split()))
L1 = [1, 3, 5, 7, 8, 10, 12]
L2 = [4, 6, 9, 11]
L3 = [2]
if x in L1 and y in L1:
print("Yes")
elif x in L2 and y in L2:
print("Yes")
elif x in L3 and y in L3:
print("Yes")
else:
print("No")
| false | 0 | [
"-listA = [1, 3, 5, 7, 8, 10, 12]",
"-listB = [4, 6, 9, 11]",
"-listC = [2]",
"-if x in listA and y in listA:",
"+L1 = [1, 3, 5, 7, 8, 10, 12]",
"+L2 = [4, 6, 9, 11]",
"+L3 = [2]",
"+if x in L1 and y in L1:",
"-elif x in listB and y in listB:",
"+elif x in L2 and y in L2:",
"-elif x in listC and... | false | 0.033818 | 0.046244 | 0.731284 | [
"s630455826",
"s829086291"
] |
u472065247 | p03221 | python | s060740332 | s746633205 | 812 | 653 | 42,020 | 49,484 | Accepted | Accepted | 19.58 | from collections import defaultdict
N, M = list(map(int, input().split()))
l = []
for i in range(M):
p, y = list(map(int, input().split()))
l.append((y, p, i))
l.sort()
d = defaultdict(int)
c = []
for y, p, i in l:
d[p] += 1
c.append((i, str(p).zfill(6) + str(d[p]).zfill(6)))
c.sort()
for i... | from collections import defaultdict
N, M = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
d = defaultdict(int)
c = {}
for p, y in sorted(l, key=lambda x: x[1]):
d[p] += 1
c[y] = str(p).zfill(6) + str(d[p]).zfill(6)
for p, y in l:
print((c[y])) | 18 | 12 | 329 | 295 | from collections import defaultdict
N, M = list(map(int, input().split()))
l = []
for i in range(M):
p, y = list(map(int, input().split()))
l.append((y, p, i))
l.sort()
d = defaultdict(int)
c = []
for y, p, i in l:
d[p] += 1
c.append((i, str(p).zfill(6) + str(d[p]).zfill(6)))
c.sort()
for i, x in c:
... | from collections import defaultdict
N, M = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
d = defaultdict(int)
c = {}
for p, y in sorted(l, key=lambda x: x[1]):
d[p] += 1
c[y] = str(p).zfill(6) + str(d[p]).zfill(6)
for p, y in l:
print((c[y]))
| false | 33.333333 | [
"-l = []",
"-for i in range(M):",
"- p, y = list(map(int, input().split()))",
"- l.append((y, p, i))",
"-l.sort()",
"+l = [list(map(int, input().split())) for _ in range(M)]",
"-c = []",
"-for y, p, i in l:",
"+c = {}",
"+for p, y in sorted(l, key=lambda x: x[1]):",
"- c.append((i, str(... | false | 0.087561 | 0.039408 | 2.221923 | [
"s060740332",
"s746633205"
] |
u397496203 | p02888 | python | s281457689 | s219520559 | 945 | 324 | 3,188 | 74,260 | Accepted | Accepted | 65.71 | import bisect
def main():
N = int(eval(input()))
edges = [int(i) for i in input().split()]
edges.sort()
ans = 0
for a in range(N - 2):
for b in range(a + 1, N - 1):
ans += bisect.bisect_left(edges, edges[a] + edges[b])-b-1
print(ans)
if __name__ == "__main... | import sys
# sys.setrecursionlimit(100000)
import bisect
def input():
return sys.stdin.readline().strip()
def input_int():
return int(eval(input()))
def input_int_list():
return [int(i) for i in input().split()]
def main():
n = input_int()
L = sorted(input_int_list())
... | 17 | 31 | 330 | 548 | import bisect
def main():
N = int(eval(input()))
edges = [int(i) for i in input().split()]
edges.sort()
ans = 0
for a in range(N - 2):
for b in range(a + 1, N - 1):
ans += bisect.bisect_left(edges, edges[a] + edges[b]) - b - 1
print(ans)
if __name__ == "__main__":
mai... | import sys
# sys.setrecursionlimit(100000)
import bisect
def input():
return sys.stdin.readline().strip()
def input_int():
return int(eval(input()))
def input_int_list():
return [int(i) for i in input().split()]
def main():
n = input_int()
L = sorted(input_int_list())
ans = 0
for i ... | false | 45.16129 | [
"+import sys",
"+",
"+# sys.setrecursionlimit(100000)",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def input_int():",
"+ return int(eval(input()))",
"+",
"+",
"+def input_int_list():",
"+ return [int(i) for i in input().split()]",
"+",
"+",
"- N =... | false | 0.038263 | 0.082512 | 0.463719 | [
"s281457689",
"s219520559"
] |
u875291233 | p02914 | python | s112557186 | s201286715 | 645 | 347 | 69,536 | 71,456 | Accepted | Accepted | 46.2 | # Python program to find
# maximum XOR subset
# Number of bits to
# represent int
INT_BITS=61
# Function to return
# maximum XOR subset
# in set[]
def maxSubarrayXOR(set,n):
# Initialize index of
# chosen elements
index = 0
# Traverse through all
# bits of... | # coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
n = int(eval(input()))
a = [int(i) for i in readline().split()]
from functools import reduce
from operator import xor
NMAX = 62
omask = reduce(xor,a)
emask = (1<<NMAX)-1
emask ^= omas... | 130 | 41 | 2,745 | 678 | # Python program to find
# maximum XOR subset
# Number of bits to
# represent int
INT_BITS = 61
# Function to return
# maximum XOR subset
# in set[]
def maxSubarrayXOR(set, n):
# Initialize index of
# chosen elements
index = 0
# Traverse through all
# bits of integer
# starting from the most
... | # coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline # 文字列入力のときは注意
n = int(eval(input()))
a = [int(i) for i in readline().split()]
from functools import reduce
from operator import xor
NMAX = 62
omask = reduce(xor, a)
emask = (1 << NMAX) - 1
emask ^= omask
for i in ... | false | 68.461538 | [
"-# Python program to find",
"-# maximum XOR subset",
"-# Number of bits to",
"-# represent int",
"-INT_BITS = 61",
"-# Function to return",
"-# maximum XOR subset",
"-# in set[]",
"-def maxSubarrayXOR(set, n):",
"- # Initialize index of",
"- # chosen elements",
"- index = 0",
"- ... | false | 0.076841 | 0.066546 | 1.154705 | [
"s112557186",
"s201286715"
] |
u094191970 | p03645 | python | s292323024 | s915908025 | 1,256 | 1,074 | 81,584 | 79,544 | Accepted | Accepted | 14.49 | from collections import deque
n,m=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
sx=0
gx=n-1
tree=[[] for i in range(n)]
for i in l:
tree[i[0]-1].append(i[1]-1)
tree[i[1]-1].append(i[0]-1)
dist=[-1 for i in range(n)]
dist[sx]=0
que=deque()
que.append(sx... | n,m=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
tree=[[] for i in range(n)]
for i in l:
tree[i[0]-1].append(i[1]-1)
tree[i[1]-1].append(i[0]-1)
for i in tree:
if 0 in i and n-1 in i:
print('POSSIBLE')
exit()
print('IMPOSSIBLE') | 35 | 13 | 635 | 303 | from collections import deque
n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(m)]
sx = 0
gx = n - 1
tree = [[] for i in range(n)]
for i in l:
tree[i[0] - 1].append(i[1] - 1)
tree[i[1] - 1].append(i[0] - 1)
dist = [-1 for i in range(n)]
dist[sx] = 0
que = deque()
que.a... | n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]
for i in l:
tree[i[0] - 1].append(i[1] - 1)
tree[i[1] - 1].append(i[0] - 1)
for i in tree:
if 0 in i and n - 1 in i:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| false | 62.857143 | [
"-from collections import deque",
"-",
"-sx = 0",
"-gx = n - 1",
"-dist = [-1 for i in range(n)]",
"-dist[sx] = 0",
"-que = deque()",
"-que.append(sx)",
"-while que:",
"- x = que.popleft()",
"- if x == gx and dist[gx] == 2:",
"+for i in tree:",
"+ if 0 in i and n - 1 in i:",
"- ... | false | 0.04165 | 0.036422 | 1.143547 | [
"s292323024",
"s915908025"
] |
u814781830 | p02937 | python | s486889794 | s933587227 | 359 | 274 | 63,012 | 54,312 | Accepted | Accepted | 23.68 | import bisect
S = list(eval(input()))
T = list(eval(input()))
s_dict = {}
# 二週分の文字とインデックス番号の組み合わせを保持
for s in S:
s_dict[s] = []
for i, s in enumerate(S+S):
bisect.insort_right(s_dict[s], i)
N = len(S)
try:
ret = 0
cnt = 0
pre_t_idx = -1
for t in T:
t_idx = s_dict[t][bise... | from bisect import bisect_right
def main():
S = eval(input())
T = eval(input())
lens = len(S)
s = set(S)
t = set(T)
for i in t:
if not i in s:
return -2
S = S + S
alpha = [[] for i in range(26)]
for i, v in enumerate(S):
alpha[ord(v)-ord('a'... | 26 | 28 | 531 | 613 | import bisect
S = list(eval(input()))
T = list(eval(input()))
s_dict = {}
# 二週分の文字とインデックス番号の組み合わせを保持
for s in S:
s_dict[s] = []
for i, s in enumerate(S + S):
bisect.insort_right(s_dict[s], i)
N = len(S)
try:
ret = 0
cnt = 0
pre_t_idx = -1
for t in T:
t_idx = s_dict[t][bisect.bisect_righ... | from bisect import bisect_right
def main():
S = eval(input())
T = eval(input())
lens = len(S)
s = set(S)
t = set(T)
for i in t:
if not i in s:
return -2
S = S + S
alpha = [[] for i in range(26)]
for i, v in enumerate(S):
alpha[ord(v) - ord("a")].append(i... | false | 7.142857 | [
"-import bisect",
"+from bisect import bisect_right",
"-S = list(eval(input()))",
"-T = list(eval(input()))",
"-s_dict = {}",
"-# 二週分の文字とインデックス番号の組み合わせを保持",
"-for s in S:",
"- s_dict[s] = []",
"-for i, s in enumerate(S + S):",
"- bisect.insort_right(s_dict[s], i)",
"-N = len(S)",
"-try:"... | false | 0.044033 | 0.074123 | 0.594059 | [
"s486889794",
"s933587227"
] |
u736788838 | p03109 | python | s842843935 | s620555187 | 20 | 17 | 3,188 | 2,940 | Accepted | Accepted | 15 | date = eval(input())
import re
date_num = int(re.sub("\D", "", date))
if date_num <= 20190430:
print("Heisei")
else:
print("TBD") | date = int(input().replace("/", ""))
if date <= 20190430:
print("Heisei")
else:
print("TBD") | 9 | 5 | 141 | 104 | date = eval(input())
import re
date_num = int(re.sub("\D", "", date))
if date_num <= 20190430:
print("Heisei")
else:
print("TBD")
| date = int(input().replace("/", ""))
if date <= 20190430:
print("Heisei")
else:
print("TBD")
| false | 44.444444 | [
"-date = eval(input())",
"-import re",
"-",
"-date_num = int(re.sub(\"\\D\", \"\", date))",
"-if date_num <= 20190430:",
"+date = int(input().replace(\"/\", \"\"))",
"+if date <= 20190430:"
] | false | 0.040025 | 0.038911 | 1.028624 | [
"s842843935",
"s620555187"
] |
u037430802 | p03221 | python | s652021089 | s605738416 | 719 | 633 | 36,668 | 35,568 | Accepted | Accepted | 11.96 | import bisect
n, m = list(map(int, input().split()))
prefs_list = []
prefs_dict = {}
for i in range(m):
p, y = list(map(int, input().split()))
prefs_list.append([p,y])
if p in prefs_dict:
prefs_dict[p].append(y)
else:
prefs_dict[p] = [y]
for key in prefs_dict:
prefs_dict[key].sort()
... | from collections import defaultdict
import bisect
N,M = list(map(int, input().split()))
PY = [tuple(map(int, input().split())) for _ in range(M)]
prefs = defaultdict(list)
for p, y in PY:
# ここで実際の誕生年をつめてから、あとで県ごとにソートして単なる順番に座標圧縮
prefs[p].append(y)
for k in list(prefs.keys()):
# 順に並び替えたので、... | 20 | 20 | 436 | 469 | import bisect
n, m = list(map(int, input().split()))
prefs_list = []
prefs_dict = {}
for i in range(m):
p, y = list(map(int, input().split()))
prefs_list.append([p, y])
if p in prefs_dict:
prefs_dict[p].append(y)
else:
prefs_dict[p] = [y]
for key in prefs_dict:
prefs_dict[key].sort(... | from collections import defaultdict
import bisect
N, M = list(map(int, input().split()))
PY = [tuple(map(int, input().split())) for _ in range(M)]
prefs = defaultdict(list)
for p, y in PY:
# ここで実際の誕生年をつめてから、あとで県ごとにソートして単なる順番に座標圧縮
prefs[p].append(y)
for k in list(prefs.keys()):
# 順に並び替えたので、後にbisectで位置を探せば誕生... | false | 0 | [
"+from collections import defaultdict",
"-n, m = list(map(int, input().split()))",
"-prefs_list = []",
"-prefs_dict = {}",
"-for i in range(m):",
"- p, y = list(map(int, input().split()))",
"- prefs_list.append([p, y])",
"- if p in prefs_dict:",
"- prefs_dict[p].append(y)",
"- e... | false | 0.046782 | 0.045233 | 1.034244 | [
"s652021089",
"s605738416"
] |
u815763296 | p02608 | python | s510832474 | s215055768 | 834 | 111 | 9,184 | 9,348 | Accepted | Accepted | 86.69 | import math
N = int(eval(input()))
ans = [0]*(N+1)
Nruto = math.sqrt(N)
Nruto = math.floor(Nruto)+1
for x in range(1, Nruto):
for y in range(1, Nruto):
for z in range(1, Nruto):
n = x**2+y**2+z**2+x*y+y*z+z*x
if n <= N:
ans[n] += 1
for i in range(1, N+1):
... | import math
N = int(eval(input()))
ans = [0]*(N+1)
owari = math.sqrt(N)
owari = math.ceil(owari)
for x in range(1, owari):
a = x*x
for y in range(1, owari):
b = y*y
c = x*y
for z in range(1, owari):
hantei = z*(z+x+y)+a+b+c
if hantei > N:
... | 13 | 18 | 332 | 400 | import math
N = int(eval(input()))
ans = [0] * (N + 1)
Nruto = math.sqrt(N)
Nruto = math.floor(Nruto) + 1
for x in range(1, Nruto):
for y in range(1, Nruto):
for z in range(1, Nruto):
n = x**2 + y**2 + z**2 + x * y + y * z + z * x
if n <= N:
ans[n] += 1
for i in rang... | import math
N = int(eval(input()))
ans = [0] * (N + 1)
owari = math.sqrt(N)
owari = math.ceil(owari)
for x in range(1, owari):
a = x * x
for y in range(1, owari):
b = y * y
c = x * y
for z in range(1, owari):
hantei = z * (z + x + y) + a + b + c
if hantei > N:
... | false | 27.777778 | [
"-Nruto = math.sqrt(N)",
"-Nruto = math.floor(Nruto) + 1",
"-for x in range(1, Nruto):",
"- for y in range(1, Nruto):",
"- for z in range(1, Nruto):",
"- n = x**2 + y**2 + z**2 + x * y + y * z + z * x",
"- if n <= N:",
"- ans[n] += 1",
"+owari = math.sq... | false | 0.126452 | 0.042926 | 2.945799 | [
"s510832474",
"s215055768"
] |
u506858457 | p02803 | python | s993380973 | s827243953 | 701 | 358 | 14,484 | 3,316 | Accepted | Accepted | 48.93 | from collections import deque
import numpy as np
H,W = list(map(int,input().split()))
maze = [eval(input()) for _ in range(H)]#迷路の入力
ans = 0
for x in range(H):#すべてのマスからスタート
for y in range(W):
#壁からはスタートできない:スルー
if maze[x][y] == "#":
continue
#初期化:0埋め、HとWの順番に注意
... | '''ika tako
スタートが決められたとき、そこから最も遠いマスは、
幅優先探索で最後に訪れたマスとなる。
よって、道である各マスをスタート地点として全て試し、
最長移動距離の最大値が答え。
H,W の上限が小さいので、スタート地点候補が最大400、
1回の探索で探索するマスが最大400、あわせて160000回に
比例する計算量で間に合う。
'''
from collections import deque
def bfs(field, s):
MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
q = deque([(0, s)])
d... | 33 | 42 | 1,046 | 1,080 | from collections import deque
import numpy as np
H, W = list(map(int, input().split()))
maze = [eval(input()) for _ in range(H)] # 迷路の入力
ans = 0
for x in range(H): # すべてのマスからスタート
for y in range(W):
# 壁からはスタートできない:スルー
if maze[x][y] == "#":
continue
# 初期化:0埋め、HとWの順番に注意
d... | """ika tako
スタートが決められたとき、そこから最も遠いマスは、
幅優先探索で最後に訪れたマスとなる。
よって、道である各マスをスタート地点として全て試し、
最長移動距離の最大値が答え。
H,W の上限が小さいので、スタート地点候補が最大400、
1回の探索で探索するマスが最大400、あわせて160000回に
比例する計算量で間に合う。
"""
from collections import deque
def bfs(field, s):
MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
q = deque([(0, s)])
dist = [[-1] * ... | false | 21.428571 | [
"+\"\"\"ika tako",
"+スタートが決められたとき、そこから最も遠いマスは、",
"+幅優先探索で最後に訪れたマスとなる。",
"+よって、道である各マスをスタート地点として全て試し、",
"+最長移動距離の最大値が答え。",
"+H,W の上限が小さいので、スタート地点候補が最大400、",
"+1回の探索で探索するマスが最大400、あわせて160000回に",
"+比例する計算量で間に合う。",
"+\"\"\"",
"-import numpy as np",
"-H, W = list(map(int, input().split()))",
"-maze... | false | 0.472936 | 0.067305 | 7.02678 | [
"s993380973",
"s827243953"
] |
u687574784 | p03599 | python | s979575878 | s765323918 | 41 | 32 | 9,952 | 9,220 | Accepted | Accepted | 21.95 | from decimal import Decimal
a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
for bt in range(0,31-at):
water = (at * a + bt * b) * 100
if water > f:
continue
# 溶け残らないように砂糖を選ぶ
maxsugar = water * e // 100
for ct in... | a,b,c,d,e,f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0,31):
for bt in range(0,31-at):
water = (at * a + bt * b) * 100
if water > f:
continue
# 溶け残らないように砂糖を選ぶ
maxsugar = water * e // 100
for ct in range(0, (maxsugar+1)//c + 1... | 26 | 25 | 886 | 839 | from decimal import Decimal
a, b, c, d, e, f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0, 31):
for bt in range(0, 31 - at):
water = (at * a + bt * b) * 100
if water > f:
continue
# 溶け残らないように砂糖を選ぶ
maxsugar = water * e // 100
for ct in ra... | a, b, c, d, e, f = list(map(int, input().split()))
maxn = -1
ans = ()
for at in range(0, 31):
for bt in range(0, 31 - at):
water = (at * a + bt * b) * 100
if water > f:
continue
# 溶け残らないように砂糖を選ぶ
maxsugar = water * e // 100
for ct in range(0, (maxsugar + 1) // c + ... | false | 3.846154 | [
"-from decimal import Decimal",
"-",
"- n = Decimal(100 * sugar / water)",
"- if n == Decimal(e):",
"+ n = 100 * sugar / water",
"+ if n == e:"
] | false | 0.041072 | 0.091852 | 0.447154 | [
"s979575878",
"s765323918"
] |
u241159583 | p02627 | python | s153337900 | s134762226 | 34 | 27 | 9,028 | 9,020 | Accepted | Accepted | 20.59 | a = eval(input())
print(("A" if a.upper()==a else "a")) | a = eval(input())
print(("A" if a == a.upper() else "a")) | 2 | 2 | 48 | 50 | a = eval(input())
print(("A" if a.upper() == a else "a"))
| a = eval(input())
print(("A" if a == a.upper() else "a"))
| false | 0 | [
"-print((\"A\" if a.upper() == a else \"a\"))",
"+print((\"A\" if a == a.upper() else \"a\"))"
] | false | 0.116492 | 0.040227 | 2.895837 | [
"s153337900",
"s134762226"
] |
u201928947 | p02558 | python | s952132745 | s186035498 | 388 | 355 | 81,308 | 76,848 | Accepted | Accepted | 8.51 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
li = []
while self.parents[x] >= 0:
li.append(x)
x = self.parent... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
li = []
while self.parents[x] >= 0:
if self.parents[self.parents[x]] >= 0:
... | 65 | 64 | 1,604 | 1,636 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
li = []
while self.parents[x] >= 0:
li.append(x)
x = self.parents[x]
... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
li = []
while self.parents[x] >= 0:
if self.parents[self.parents[x]] >= 0:
... | false | 1.538462 | [
"- li.append(x)",
"+ if self.parents[self.parents[x]] >= 0:",
"+ self.parents[x] = self.parents[self.parents[x]]",
"- for y in li:",
"- self.parents[y] = x"
] | false | 0.035789 | 0.035044 | 1.021256 | [
"s952132745",
"s186035498"
] |
u952708174 | p02706 | python | s647580057 | s018463498 | 24 | 21 | 9,888 | 10,052 | Accepted | Accepted | 12.5 | N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = N - sum(A)
print((ans if ans >= 0 else -1)) | N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print((ans if (ans := N - sum(A)) >= 0 else -1)) | 5 | 3 | 131 | 127 | N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = N - sum(A)
print((ans if ans >= 0 else -1))
| N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print((ans if (ans := N - sum(A)) >= 0 else -1))
| false | 40 | [
"-ans = N - sum(A)",
"-print((ans if ans >= 0 else -1))",
"+print((ans if (ans := N - sum(A)) >= 0 else -1))"
] | false | 0.045612 | 0.041432 | 1.100888 | [
"s647580057",
"s018463498"
] |
u353895424 | p02989 | python | s818285665 | s394778427 | 150 | 75 | 14,812 | 14,428 | Accepted | Accepted | 50 | from collections import Counter
n = int(eval(input()))
d = list(map(int, input().split()))
minD = min(d)
maxD = max(d)
c = Counter(d)
abc = 0
arc = n
ans = 0
for i in range(minD, maxD+1):
abc += c[i-1]
arc -= c[i-1]
if abc == arc:
ans += 1
print(ans) | n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((max(0, d[n//2] - d[n//2 - 1]))) | 21 | 6 | 294 | 105 | from collections import Counter
n = int(eval(input()))
d = list(map(int, input().split()))
minD = min(d)
maxD = max(d)
c = Counter(d)
abc = 0
arc = n
ans = 0
for i in range(minD, maxD + 1):
abc += c[i - 1]
arc -= c[i - 1]
if abc == arc:
ans += 1
print(ans)
| n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((max(0, d[n // 2] - d[n // 2 - 1])))
| false | 71.428571 | [
"-from collections import Counter",
"-",
"-minD = min(d)",
"-maxD = max(d)",
"-c = Counter(d)",
"-abc = 0",
"-arc = n",
"-ans = 0",
"-for i in range(minD, maxD + 1):",
"- abc += c[i - 1]",
"- arc -= c[i - 1]",
"- if abc == arc:",
"- ans += 1",
"-print(ans)",
"+d.sort()",
... | false | 0.103796 | 0.049141 | 2.112193 | [
"s818285665",
"s394778427"
] |
u564902833 | p03017 | python | s925144599 | s850148479 | 192 | 19 | 41,328 | 3,572 | Accepted | Accepted | 90.1 | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
S = '.' + S
if C < D:
ans = (
'Yes' if '##' not in S[A:(D + 1)] else
'No'
)
else:
i = A
j = B
while i < C:
if i + 1 == C or i + 2 == C:
ans = 'Yes'
break
elif i + ... | # 入力
N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
'Yes' if ('##' not in S[(A - 1):max(C, D)]) and (
C < D or
'...' in S[(B - 2):(D + 1)]
) else
'No'
)
# 出力
print(ans)
| 29 | 16 | 697 | 297 | N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
S = "." + S
if C < D:
ans = "Yes" if "##" not in S[A : (D + 1)] else "No"
else:
i = A
j = B
while i < C:
if i + 1 == C or i + 2 == C:
ans = "Yes"
break
elif i + 1 <= C and S[i + 1] == "." and i + 1 ... | # 入力
N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
"Yes"
if ("##" not in S[(A - 1) : max(C, D)]) and (C < D or "..." in S[(B - 2) : (D + 1)])
else "No"
)
# 出力
print(ans)
| false | 44.827586 | [
"+# 入力",
"-S = \".\" + S",
"-if C < D:",
"- ans = \"Yes\" if \"##\" not in S[A : (D + 1)] else \"No\"",
"-else:",
"- i = A",
"- j = B",
"- while i < C:",
"- if i + 1 == C or i + 2 == C:",
"- ans = \"Yes\"",
"- break",
"- elif i + 1 <= C and S[i +... | false | 0.047909 | 0.042384 | 1.130379 | [
"s925144599",
"s850148479"
] |
u294922877 | p02394 | python | s151782323 | s820723639 | 60 | 30 | 7,708 | 5,600 | Accepted | Accepted | 50 | W,H,x,y,r = list(map(int,input().split()))
print(('Yes' if (0<=x-r and x+r<=W and 0<=y-r and y+r<=H) else 'No')) | def judge(w, h, x, y, r):
within_range = (0 <= x - r and x + r <= w) and (0 <= y - r and y + r <= h)
return 'Yes' if within_range else 'No'
if __name__ == '__main__':
w, h, x, y, r = list(map(int, input().split(' ')))
print((judge(w, h, x, y, r)))
| 2 | 8 | 105 | 265 | W, H, x, y, r = list(map(int, input().split()))
print(("Yes" if (0 <= x - r and x + r <= W and 0 <= y - r and y + r <= H) else "No"))
| def judge(w, h, x, y, r):
within_range = (0 <= x - r and x + r <= w) and (0 <= y - r and y + r <= h)
return "Yes" if within_range else "No"
if __name__ == "__main__":
w, h, x, y, r = list(map(int, input().split(" ")))
print((judge(w, h, x, y, r)))
| false | 75 | [
"-W, H, x, y, r = list(map(int, input().split()))",
"-print((\"Yes\" if (0 <= x - r and x + r <= W and 0 <= y - r and y + r <= H) else \"No\"))",
"+def judge(w, h, x, y, r):",
"+ within_range = (0 <= x - r and x + r <= w) and (0 <= y - r and y + r <= h)",
"+ return \"Yes\" if within_range else \"No\""... | false | 0.116855 | 0.077512 | 1.50757 | [
"s151782323",
"s820723639"
] |
u497952650 | p03700 | python | s672078989 | s685444344 | 1,927 | 928 | 10,300 | 18,340 | Accepted | Accepted | 51.84 | import sys
from math import ceil
"""
def input():
return sys.stdin.readline().strip()
"""
def check(k):
tmp = list(h)
for i in range(N):
tmp[i] -= B*k
flag = False
for i in tmp:
if i > 0:
flag = True
break
if not flag:
return ... | from math import ceil
def is_ok(m):
tmp = h[:]
for i in range(N):
tmp[i] -= m*B
flag = True
for i in tmp:
if i > 0:
flag = False
break
if flag:##全部0以下
return True
else:
rem = 0
for i in tmp:
... | 44 | 47 | 739 | 676 | import sys
from math import ceil
"""
def input():
return sys.stdin.readline().strip()
"""
def check(k):
tmp = list(h)
for i in range(N):
tmp[i] -= B * k
flag = False
for i in tmp:
if i > 0:
flag = True
break
if not flag:
return True
lf = 0
... | from math import ceil
def is_ok(m):
tmp = h[:]
for i in range(N):
tmp[i] -= m * B
flag = True
for i in tmp:
if i > 0:
flag = False
break
if flag: ##全部0以下
return True
else:
rem = 0
for i in tmp:
if i > 0:
... | false | 6.382979 | [
"-import sys",
"-\"\"\"",
"-def input():",
"- return sys.stdin.readline().strip()",
"-\"\"\"",
"-",
"-def check(k):",
"- tmp = list(h)",
"+def is_ok(m):",
"+ tmp = h[:]",
"- tmp[i] -= B * k",
"- flag = False",
"+ tmp[i] -= m * B",
"+ flag = True",
"- ... | false | 0.036601 | 0.034266 | 1.068155 | [
"s672078989",
"s685444344"
] |
u077898957 | p02880 | python | s443829921 | s422736071 | 24 | 19 | 3,060 | 3,060 | Accepted | Accepted | 20.83 | import sys
n = int(eval(input()))
for i in range(9):
if n/(i+1) in (1,2,3,4,5,6,7,8,9):
print('Yes')
sys.exit()
print('No') | n=int(eval(input()))
ans='No'
for i in range(1,10):
for j in range(1,10):
if i*j==n:
ans='Yes'
break
print(ans) | 7 | 8 | 143 | 148 | import sys
n = int(eval(input()))
for i in range(9):
if n / (i + 1) in (1, 2, 3, 4, 5, 6, 7, 8, 9):
print("Yes")
sys.exit()
print("No")
| n = int(eval(input()))
ans = "No"
for i in range(1, 10):
for j in range(1, 10):
if i * j == n:
ans = "Yes"
break
print(ans)
| false | 12.5 | [
"-import sys",
"-",
"-for i in range(9):",
"- if n / (i + 1) in (1, 2, 3, 4, 5, 6, 7, 8, 9):",
"- print(\"Yes\")",
"- sys.exit()",
"-print(\"No\")",
"+ans = \"No\"",
"+for i in range(1, 10):",
"+ for j in range(1, 10):",
"+ if i * j == n:",
"+ ans = \"Yes\... | false | 0.040774 | 0.07431 | 0.548702 | [
"s443829921",
"s422736071"
] |
u761320129 | p03127 | python | s798301867 | s933280354 | 86 | 63 | 16,280 | 20,476 | Accepted | Accepted | 26.74 | from fractions import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
g = A[0]
for a in A:
g = gcd(g,a)
print(g) | from math import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
g = 0
for a in A:
g = gcd(a,g)
print(g) | 7 | 7 | 130 | 122 | from fractions import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
g = A[0]
for a in A:
g = gcd(g, a)
print(g)
| from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
g = 0
for a in A:
g = gcd(a, g)
print(g)
| false | 0 | [
"-from fractions import gcd",
"+from math import gcd",
"-g = A[0]",
"+g = 0",
"- g = gcd(g, a)",
"+ g = gcd(a, g)"
] | false | 0.046315 | 0.077395 | 0.59842 | [
"s798301867",
"s933280354"
] |
u672475305 | p03353 | python | s898331418 | s625049104 | 1,777 | 33 | 4,084 | 3,188 | Accepted | Accepted | 98.14 | s = eval(input())
k = int(eval(input()))
dct = []
for i in range(len(s)):
for j in range(k+1):
word = s[i:i+j]
if word not in dct:
dct.append(word)
dct.sort()
print((dct[k])) | s = eval(input())
k = int(eval(input()))
lst = sorted(list(set(s)))
tank = []
for tg in lst:
for i in range(len(s)):
if s[i]==tg:
for j in range(k):
if i+j<=len(s) and (s[i:i+j+1] not in tank):
tank.append(s[i:i+j+1])
if len(tank) >= k:
... | 12 | 14 | 205 | 344 | s = eval(input())
k = int(eval(input()))
dct = []
for i in range(len(s)):
for j in range(k + 1):
word = s[i : i + j]
if word not in dct:
dct.append(word)
dct.sort()
print((dct[k]))
| s = eval(input())
k = int(eval(input()))
lst = sorted(list(set(s)))
tank = []
for tg in lst:
for i in range(len(s)):
if s[i] == tg:
for j in range(k):
if i + j <= len(s) and (s[i : i + j + 1] not in tank):
tank.append(s[i : i + j + 1])
if len(tank) >= k:
... | false | 14.285714 | [
"-dct = []",
"-for i in range(len(s)):",
"- for j in range(k + 1):",
"- word = s[i : i + j]",
"- if word not in dct:",
"- dct.append(word)",
"-dct.sort()",
"-print((dct[k]))",
"+lst = sorted(list(set(s)))",
"+tank = []",
"+for tg in lst:",
"+ for i in range(len(s... | false | 0.039116 | 0.038659 | 1.011823 | [
"s898331418",
"s625049104"
] |
u968166680 | p03557 | python | s536658852 | s192669527 | 378 | 303 | 22,720 | 22,720 | Accepted | Accepted | 19.84 | from sys import stdin
from bisect import bisect_right, bisect_left
def input():
return stdin.readline().strip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()... | from sys import stdin
from bisect import bisect_right, bisect_left
def input():
return stdin.readline().strip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()... | 30 | 24 | 543 | 463 | from sys import stdin
from bisect import bisect_right, bisect_left
def input():
return stdin.readline().strip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
... | from sys import stdin
from bisect import bisect_right, bisect_left
def input():
return stdin.readline().strip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
... | false | 20 | [
"- ans = 0",
"- i, j = 0, 0",
"- for b in B:",
"- i = bisect_left(A, b, lo=i)",
"- j = bisect_right(C, b, lo=j)",
"- ans += i * (N - j)",
"+ ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)"
] | false | 0.046179 | 0.046057 | 1.002658 | [
"s536658852",
"s192669527"
] |
u987170100 | p03371 | python | s629385880 | s905960283 | 193 | 99 | 9,188 | 8,888 | Accepted | Accepted | 48.7 | A, B, C, X, Y = list(map(int, input().split()))
ret = A * X + B * Y
x = 0
y = 0
c = 0
while (X + Y) * 2 > c :
c += 2
x += 1
y += 1
ret = min(ret, A * max(0, X - x) + B * max(0, Y - y) + c * C)
print(ret)
| A, B, C, X, Y = list(map(int, input().split()))
ret = float('inf')
for i in range(10 ** 5 + 1):
ret = min(ret, A * max(0, X - i) + B * max(0, Y - i) + 2 * i * C)
print(ret) | 11 | 5 | 224 | 174 | A, B, C, X, Y = list(map(int, input().split()))
ret = A * X + B * Y
x = 0
y = 0
c = 0
while (X + Y) * 2 > c:
c += 2
x += 1
y += 1
ret = min(ret, A * max(0, X - x) + B * max(0, Y - y) + c * C)
print(ret)
| A, B, C, X, Y = list(map(int, input().split()))
ret = float("inf")
for i in range(10**5 + 1):
ret = min(ret, A * max(0, X - i) + B * max(0, Y - i) + 2 * i * C)
print(ret)
| false | 54.545455 | [
"-ret = A * X + B * Y",
"-x = 0",
"-y = 0",
"-c = 0",
"-while (X + Y) * 2 > c:",
"- c += 2",
"- x += 1",
"- y += 1",
"- ret = min(ret, A * max(0, X - x) + B * max(0, Y - y) + c * C)",
"+ret = float(\"inf\")",
"+for i in range(10**5 + 1):",
"+ ret = min(ret, A * max(0, X - i) + B... | false | 0.177843 | 0.339758 | 0.523441 | [
"s629385880",
"s905960283"
] |
u072053884 | p02271 | python | s973853010 | s145200991 | 4,250 | 20 | 7,768 | 8,076 | Accepted | Accepted | 99.53 | def solve(A, i, m, n):
"""Return if it is possible to make value m with some elements in A.
n is length of A.
i is index.
Using Divide-and-Conquer method.
"""
if m == 0:
return True
if i >= n or m < 0:
return False
return solve(A, i + 1, m, n) or solve(A, i ... | def solve(A, i, m, n):
"""Return if it is possible to make value m with some elements in A.
n is length of A.
i is index.
R is the record of answer i, m.
Using Divide-and-Conquer method.
"""
if R[i][m] != None:
return R[i][m]
if m == 0:
R[i][m] = True
... | 35 | 44 | 708 | 941 | def solve(A, i, m, n):
"""Return if it is possible to make value m with some elements in A.
n is length of A.
i is index.
Using Divide-and-Conquer method.
"""
if m == 0:
return True
if i >= n or m < 0:
return False
return solve(A, i + 1, m, n) or solve(A, i + 1, m - A[i],... | def solve(A, i, m, n):
"""Return if it is possible to make value m with some elements in A.
n is length of A.
i is index.
R is the record of answer i, m.
Using Divide-and-Conquer method.
"""
if R[i][m] != None:
return R[i][m]
if m == 0:
R[i][m] = True
return True
... | false | 20.454545 | [
"+ R is the record of answer i, m.",
"+ if R[i][m] != None:",
"+ return R[i][m]",
"+ R[i][m] = True",
"- if i >= n or m < 0:",
"+ elif i >= n:",
"+ R[i][m] = False",
"- return solve(A, i + 1, m, n) or solve(A, i + 1, m - A[i], n)",
"+ else:",
"+ ans = ... | false | 0.051841 | 0.051474 | 1.007121 | [
"s973853010",
"s145200991"
] |
u784022244 | p02996 | python | s643430675 | s676501957 | 955 | 873 | 39,700 | 33,396 | Accepted | Accepted | 8.59 | N=int(eval(input()))
AB=[]
for i in range(N):
a,b=list(map(int, input().split()))
AB.append([a,b])
AB=sorted(AB, key=lambda x: x[1])
addtime=0
nowtime=0
for i in range(N):
a=AB[i][0]
b=AB[i][1]
nowtime+=a
if nowtime>b:
print("No")
exit()
print("Yes") | N=int(eval(input()))
now=0
L=[]
for i in range(N):
a,b=list(map(int, input().split()))
L.append((a,b))
L=sorted(L, key=lambda x: x[1])
for i in range(N):
t=L[i]
a,b=t
if now+a<=b:
now+=a
else:
print("No")
exit()
print("Yes") | 17 | 20 | 275 | 283 | N = int(eval(input()))
AB = []
for i in range(N):
a, b = list(map(int, input().split()))
AB.append([a, b])
AB = sorted(AB, key=lambda x: x[1])
addtime = 0
nowtime = 0
for i in range(N):
a = AB[i][0]
b = AB[i][1]
nowtime += a
if nowtime > b:
print("No")
exit()
print("Yes")
| N = int(eval(input()))
now = 0
L = []
for i in range(N):
a, b = list(map(int, input().split()))
L.append((a, b))
L = sorted(L, key=lambda x: x[1])
for i in range(N):
t = L[i]
a, b = t
if now + a <= b:
now += a
else:
print("No")
exit()
print("Yes")
| false | 15 | [
"-AB = []",
"+now = 0",
"+L = []",
"- AB.append([a, b])",
"-AB = sorted(AB, key=lambda x: x[1])",
"-addtime = 0",
"-nowtime = 0",
"+ L.append((a, b))",
"+L = sorted(L, key=lambda x: x[1])",
"- a = AB[i][0]",
"- b = AB[i][1]",
"- nowtime += a",
"- if nowtime > b:",
"+ t... | false | 0.035126 | 0.035627 | 0.985941 | [
"s643430675",
"s676501957"
] |
u761320129 | p02973 | python | s775724597 | s303091464 | 864 | 237 | 73,556 | 7,836 | Accepted | Accepted | 72.57 | from collections import defaultdict
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
d = defaultdict(lambda: [])
for i,a in enumerate(A):
d[a].append(i)
B = [None for i in range(N)]
for i,k in enumerate(sorted(d.keys())):
for j in d[k]:
B[j] = i
bit = [0] * (N+2)
def bit_... | from bisect import bisect
N = int(eval(input()))
A = [-int(eval(input())) for i in range(N)]
mem = []
for a in A:
i = bisect(mem, a)
if i==len(mem):
mem.append(a)
else:
mem[i] = a
print((len(mem))) | 48 | 12 | 938 | 223 | from collections import defaultdict
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
d = defaultdict(lambda: [])
for i, a in enumerate(A):
d[a].append(i)
B = [None for i in range(N)]
for i, k in enumerate(sorted(d.keys())):
for j in d[k]:
B[j] = i
bit = [0] * (N + 2)
def bit_add(a, w... | from bisect import bisect
N = int(eval(input()))
A = [-int(eval(input())) for i in range(N)]
mem = []
for a in A:
i = bisect(mem, a)
if i == len(mem):
mem.append(a)
else:
mem[i] = a
print((len(mem)))
| false | 75 | [
"-from collections import defaultdict",
"+from bisect import bisect",
"-A = [int(eval(input())) for i in range(N)]",
"-d = defaultdict(lambda: [])",
"-for i, a in enumerate(A):",
"- d[a].append(i)",
"-B = [None for i in range(N)]",
"-for i, k in enumerate(sorted(d.keys())):",
"- for j in d[k]:... | false | 0.00719 | 0.040148 | 0.179091 | [
"s775724597",
"s303091464"
] |
u785578220 | p03472 | python | s414485005 | s348925053 | 491 | 397 | 25,936 | 12,236 | Accepted | Accepted | 19.14 | from heapq import heappush, heappop
from operator import itemgetter
N, K = list(map(int, input().split()))
a = []
aa = []
for i in range(N):
ta,tb = list(map(int, input().split()))
a.append([i,ta,tb])
aa.append(tb)
a = sorted(a, key=itemgetter(2), reverse=True)
aa.append(0)
aa.sort()
b = max(a, ... | from heapq import heappush, heappop
from operator import itemgetter
N, K = list(map(int, input().split()))
a = []
aa = []
for i in range(N):
ta,tb = list(map(int, input().split()))
a.append(ta)
aa.append(tb)
a = sorted(a)
aa.append(0)
aa.sort()
b = max(a)
n = K//b+1
res = 0
while K>0:
... | 26 | 26 | 506 | 444 | from heapq import heappush, heappop
from operator import itemgetter
N, K = list(map(int, input().split()))
a = []
aa = []
for i in range(N):
ta, tb = list(map(int, input().split()))
a.append([i, ta, tb])
aa.append(tb)
a = sorted(a, key=itemgetter(2), reverse=True)
aa.append(0)
aa.sort()
b = max(a, key=item... | from heapq import heappush, heappop
from operator import itemgetter
N, K = list(map(int, input().split()))
a = []
aa = []
for i in range(N):
ta, tb = list(map(int, input().split()))
a.append(ta)
aa.append(tb)
a = sorted(a)
aa.append(0)
aa.sort()
b = max(a)
n = K // b + 1
res = 0
while K > 0:
t = aa.pop... | false | 0 | [
"- a.append([i, ta, tb])",
"+ a.append(ta)",
"-a = sorted(a, key=itemgetter(2), reverse=True)",
"+a = sorted(a)",
"-b = max(a, key=itemgetter(1))[1]",
"+b = max(a)"
] | false | 0.045308 | 0.046073 | 0.983396 | [
"s414485005",
"s348925053"
] |
u278356323 | p03627 | python | s884011529 | s255952555 | 153 | 93 | 14,748 | 14,628 | Accepted | Accepted | 39.22 | # ARC081c
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import Counter
import heapq
n = int(eval(input()))
def fun(i):
return -int(i)
a = list(map(fun, input().split()))
heapq.heapify(a)
b = []
hea... | # ARC081c
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import Counter
import heapq
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
heapq.heapify(b)
ln = 0
cou = 0
... | 39 | 33 | 732 | 623 | # ARC081c
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import Counter
import heapq
n = int(eval(input()))
def fun(i):
return -int(i)
a = list(map(fun, input().split()))
heapq.heapify(a)
b = []
heapq.heapify(b)
... | # ARC081c
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import Counter
import heapq
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
heapq.heapify(b)
ln = 0
cou = 0
for i in a:
... | false | 15.384615 | [
"-",
"- def fun(i):",
"- return -int(i)",
"-",
"- a = list(map(fun, input().split()))",
"- heapq.heapify(a)",
"+ a = list(map(int, input().split()))",
"+ a.sort(reverse=True)",
"- mn = 0",
"- while len(a) > 0:",
"- i = -heapq.heappop(a)",
"- # print(i)... | false | 0.169342 | 0.037867 | 4.471993 | [
"s884011529",
"s255952555"
] |
u521271655 | p03775 | python | s739995302 | s549328987 | 68 | 42 | 3,060 | 9,412 | Accepted | Accepted | 38.24 | N = int(eval(input()))
for i in range(0,int(N**0.5)):
if N % (int(N**0.5) - i) == 0:
A = (int(N**0.5) - i)
B = N//(int(N**0.5) - i)
break
print((len(str(B)))) | n = int(eval(input()))
ans = 10**100
for a in range(1,int(n**(0.5))+2):
if n%a == 0:
b = n//a
f = len(str(b))
ans = min(ans,f)
print(ans) | 7 | 8 | 184 | 166 | N = int(eval(input()))
for i in range(0, int(N**0.5)):
if N % (int(N**0.5) - i) == 0:
A = int(N**0.5) - i
B = N // (int(N**0.5) - i)
break
print((len(str(B))))
| n = int(eval(input()))
ans = 10**100
for a in range(1, int(n ** (0.5)) + 2):
if n % a == 0:
b = n // a
f = len(str(b))
ans = min(ans, f)
print(ans)
| false | 12.5 | [
"-N = int(eval(input()))",
"-for i in range(0, int(N**0.5)):",
"- if N % (int(N**0.5) - i) == 0:",
"- A = int(N**0.5) - i",
"- B = N // (int(N**0.5) - i)",
"- break",
"-print((len(str(B))))",
"+n = int(eval(input()))",
"+ans = 10**100",
"+for a in range(1, int(n ** (0.5)) +... | false | 0.059575 | 0.053204 | 1.119732 | [
"s739995302",
"s549328987"
] |
u421674761 | p02576 | python | s376150229 | s893189984 | 35 | 27 | 9,088 | 9,112 | Accepted | Accepted | 22.86 |
n,x,t = list(map(int,input().split()))
cnt = 0
while n > 0:
n -= x
cnt += 1
print((cnt*t))
| n,x,t = list(map(int,input().split()))
cnt = 0
while n > 0:
n = n - x
cnt += 1
print((cnt*t))
| 8 | 8 | 100 | 103 | n, x, t = list(map(int, input().split()))
cnt = 0
while n > 0:
n -= x
cnt += 1
print((cnt * t))
| n, x, t = list(map(int, input().split()))
cnt = 0
while n > 0:
n = n - x
cnt += 1
print((cnt * t))
| false | 0 | [
"- n -= x",
"+ n = n - x"
] | false | 0.087505 | 0.036188 | 2.418099 | [
"s376150229",
"s893189984"
] |
u800058906 | p03037 | python | s562386709 | s995350734 | 245 | 204 | 28,552 | 16,964 | Accepted | Accepted | 16.73 | n,m=list(map(int,input().split()))
c=list()
for i in range(m):
c.append(list(map(int,input().split())))
s=(list([x[0] for x in c]))
b=(list([x[1] for x in c]))
maxs=max(s)
minb=min(b)
if minb<maxs:
print('0')
else:
ans=minb-maxs+1
print(ans) | n,m=list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
l,r=list(map(int,input().split()))
a.append(l)
b.append(r)
x=max(a)
y=min(b)
if y-x<0:
print('0')
else:
print((y-x+1)) | 17 | 14 | 277 | 202 | n, m = list(map(int, input().split()))
c = list()
for i in range(m):
c.append(list(map(int, input().split())))
s = list([x[0] for x in c])
b = list([x[1] for x in c])
maxs = max(s)
minb = min(b)
if minb < maxs:
print("0")
else:
ans = minb - maxs + 1
print(ans)
| n, m = list(map(int, input().split()))
a = []
b = []
for i in range(m):
l, r = list(map(int, input().split()))
a.append(l)
b.append(r)
x = max(a)
y = min(b)
if y - x < 0:
print("0")
else:
print((y - x + 1))
| false | 17.647059 | [
"-c = list()",
"+a = []",
"+b = []",
"- c.append(list(map(int, input().split())))",
"-s = list([x[0] for x in c])",
"-b = list([x[1] for x in c])",
"-maxs = max(s)",
"-minb = min(b)",
"-if minb < maxs:",
"+ l, r = list(map(int, input().split()))",
"+ a.append(l)",
"+ b.append(r)",
... | false | 0.038184 | 0.046536 | 0.820518 | [
"s562386709",
"s995350734"
] |
u203239974 | p02657 | python | s299245958 | s982665826 | 30 | 27 | 9,076 | 9,028 | Accepted | Accepted | 10 | A,B = list(map(int,input().split(" ")))
print((A*B)) | if __name__ == "__main__":
A,B = list(map(float,input().split(" ")))
print((int((int(A)*(int((B)*100)))/100)))
| 2 | 3 | 51 | 119 | A, B = list(map(int, input().split(" ")))
print((A * B))
| if __name__ == "__main__":
A, B = list(map(float, input().split(" ")))
print((int((int(A) * (int((B) * 100))) / 100)))
| false | 33.333333 | [
"-A, B = list(map(int, input().split(\" \")))",
"-print((A * B))",
"+if __name__ == \"__main__\":",
"+ A, B = list(map(float, input().split(\" \")))",
"+ print((int((int(A) * (int((B) * 100))) / 100)))"
] | false | 0.036101 | 0.038746 | 0.931745 | [
"s299245958",
"s982665826"
] |
u764956288 | p02683 | python | s704228099 | s859760836 | 146 | 56 | 27,308 | 9,220 | Accepted | Accepted | 61.64 | import numpy as np
from itertools import product
def main():
N, M, X = list(map(int, input().split()))
books = np.array([list(map(int, input().split())) for _ in range(N)])
min_total_cost = 10**9
for read_flags in product((True, False), repeat=N):
to_read_books = books[read_flag... | def main():
N, M, X = list(map(int, input().split()))
books = [list(map(int, input().split())) for _ in range(N)]
min_total_cost = 10**9
for i in range(2**N):
total_cost = 0
learned = [0] * M
for j in range(N):
if (i >> j) & 1:
cost, *... | 27 | 29 | 675 | 675 | import numpy as np
from itertools import product
def main():
N, M, X = list(map(int, input().split()))
books = np.array([list(map(int, input().split())) for _ in range(N)])
min_total_cost = 10**9
for read_flags in product((True, False), repeat=N):
to_read_books = books[read_flags, :]
t... | def main():
N, M, X = list(map(int, input().split()))
books = [list(map(int, input().split())) for _ in range(N)]
min_total_cost = 10**9
for i in range(2**N):
total_cost = 0
learned = [0] * M
for j in range(N):
if (i >> j) & 1:
cost, *points = books[j]... | false | 6.896552 | [
"-import numpy as np",
"-from itertools import product",
"-",
"-",
"- books = np.array([list(map(int, input().split())) for _ in range(N)])",
"+ books = [list(map(int, input().split())) for _ in range(N)]",
"- for read_flags in product((True, False), repeat=N):",
"- to_read_books = boo... | false | 0.272168 | 0.04566 | 5.960807 | [
"s704228099",
"s859760836"
] |
u279605379 | p02297 | python | s571163927 | s528688055 | 30 | 20 | 7,732 | 7,668 | Accepted | Accepted | 33.33 | x=list(range(int(eval(input()))))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print((_*0.5)) | x=list(range(int(eval(input()))))
P=[]
Q=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:Q+=[P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]]
print((sum(Q)*0.5)) | 7 | 7 | 159 | 167 | x = list(range(int(eval(input()))))
P = []
for _ in x:
P += [[int(i) for i in input().split()]]
_ = 0
P += [P[0]]
for j in x:
_ += P[j][0] * P[j + 1][1] - P[j][1] * P[j + 1][0]
print((_ * 0.5))
| x = list(range(int(eval(input()))))
P = []
Q = []
for _ in x:
P += [[int(i) for i in input().split()]]
P += [P[0]]
for j in x:
Q += [P[j][0] * P[j + 1][1] - P[j][1] * P[j + 1][0]]
print((sum(Q) * 0.5))
| false | 0 | [
"+Q = []",
"-_ = 0",
"- _ += P[j][0] * P[j + 1][1] - P[j][1] * P[j + 1][0]",
"-print((_ * 0.5))",
"+ Q += [P[j][0] * P[j + 1][1] - P[j][1] * P[j + 1][0]]",
"+print((sum(Q) * 0.5))"
] | false | 0.037044 | 0.037635 | 0.984288 | [
"s571163927",
"s528688055"
] |
u340781749 | p02930 | python | s860484128 | s744701582 | 182 | 93 | 3,952 | 3,952 | Accepted | Accepted | 48.9 | n = int(input())
for i in range(n):
for j in range(i + 1, n):
print((i ^ j & -(i ^ j)).bit_length(), end=' ')
print()
| n = int(eval(input()))
for i in range(n):
print((*((i ^ j & -(i ^ j)).bit_length() for j in range(i + 1, n))))
| 5 | 3 | 138 | 109 | n = int(input())
for i in range(n):
for j in range(i + 1, n):
print((i ^ j & -(i ^ j)).bit_length(), end=" ")
print()
| n = int(eval(input()))
for i in range(n):
print((*((i ^ j & -(i ^ j)).bit_length() for j in range(i + 1, n))))
| false | 40 | [
"-n = int(input())",
"+n = int(eval(input()))",
"- for j in range(i + 1, n):",
"- print((i ^ j & -(i ^ j)).bit_length(), end=\" \")",
"- print()",
"+ print((*((i ^ j & -(i ^ j)).bit_length() for j in range(i + 1, n))))"
] | false | 0.043961 | 0.037044 | 1.186741 | [
"s860484128",
"s744701582"
] |
u350049649 | p03081 | python | s166200857 | s681346518 | 1,977 | 1,522 | 25,660 | 25,588 | Accepted | Accepted | 23.01 | N,Q=list(map(int,input().split()))
S='.'+eval(input())+'.'
TD=[]
for i in range(Q):
t, d = input().split()
if d=='L':
TD.append([t,-1])
else:
TD.append([t,1])
def check(place):
for i in range(Q):
td=TD[i]
if td[0]!=S[place]:
continue
... | N,Q=list(map(int,input().split()))
S=eval(input())
TD=[]
for i in range(Q):
t, d = input().split()
if d=='L':
TD.append([t,-1])
else:
TD.append([t,1])
def check(place):
for td in TD:
if td[0]==S[place]:
place+=td[1]
if place<0:
... | 47 | 43 | 705 | 647 | N, Q = list(map(int, input().split()))
S = "." + eval(input()) + "."
TD = []
for i in range(Q):
t, d = input().split()
if d == "L":
TD.append([t, -1])
else:
TD.append([t, 1])
def check(place):
for i in range(Q):
td = TD[i]
if td[0] != S[place]:
continue
... | N, Q = list(map(int, input().split()))
S = eval(input())
TD = []
for i in range(Q):
t, d = input().split()
if d == "L":
TD.append([t, -1])
else:
TD.append([t, 1])
def check(place):
for td in TD:
if td[0] == S[place]:
place += td[1]
if place < 0:
... | false | 8.510638 | [
"-S = \".\" + eval(input()) + \".\"",
"+S = eval(input())",
"- for i in range(Q):",
"- td = TD[i]",
"- if td[0] != S[place]:",
"- continue",
"- else:",
"+ for td in TD:",
"+ if td[0] == S[place]:",
"- if place <= 0:",
"- return -1",
... | false | 0.073867 | 0.11822 | 0.624831 | [
"s166200857",
"s681346518"
] |
u741397536 | p02936 | python | s437948968 | s673836763 | 1,801 | 1,663 | 227,804 | 265,280 | Accepted | Accepted | 7.66 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, Q = map(int, input().split())
T = [[]for i in range(N)]
for i in range(N-1):
a, b = map(int, input().split())
T[a-1].append(b-1)
T[b-1].append(a-1)
X = [0 for i in range(N)]
for i in range(Q):
p, x = map(int, i... | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, Q = map(int, input().split())
T = [[]for i in range(N)]
for i in range(N-1):
a, b = map(int, input().split())
T[a-1].append(b-1)
T[b-1].append(a-1)
... | 30 | 32 | 537 | 676 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, Q = map(int, input().split())
T = [[] for i in range(N)]
for i in range(N - 1):
a, b = map(int, input().split())
T[a - 1].append(b - 1)
T[b - 1].append(a - 1)
X = [0 for i in range(N)]
for i in range(Q):
p, x = map(int, input().split... | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, Q = map(int, input().split())
T = [[] for i in range(N)]
for i in range(N - 1):
a, b = map(int, input().split())
T[a - 1].append(b - 1)
T[b - 1].append(a - 1)
X = [0 for i in range(N)]
... | false | 6.25 | [
"-import sys",
"+def main():",
"+ import sys",
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**7)",
"-N, Q = map(int, input().split())",
"-T = [[] for i in range(N)]",
"-for i in range(N - 1):",
"- a, b = map(int, input().split())",
"- T[a - 1].append(b - 1)",
"- T[b - 1].... | false | 0.040912 | 0.125502 | 0.325989 | [
"s437948968",
"s673836763"
] |
u345621867 | p02642 | python | s028065641 | s686560995 | 1,570 | 1,114 | 50,844 | 50,780 | Accepted | Accepted | 29.04 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
for i in range(a, MAX_A + 1, a):
X[i] += 1
ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans) | from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
C = Counter(A)
A = set(A)
B = [True] * (10 ** 6 + 1)
for a in A:
for i in range(2 * a,10**6 + 1 ,a):
B[i] = False
cnt = 0
for a in A:
if (B[a] == True) and (C[a] == 1):
cnt += 1
print(cnt) | 14 | 14 | 298 | 309 | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
A = set(A)
MAX_A = 10**6
X = [0] * (MAX_A + 1)
for a in A:
for i in range(a, MAX_A + 1, a):
X[i] += 1
ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)
| from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
A = set(A)
B = [True] * (10**6 + 1)
for a in A:
for i in range(2 * a, 10**6 + 1, a):
B[i] = False
cnt = 0
for a in A:
if (B[a] == True) and (C[a] == 1):
cnt += 1
print(cnt)
| false | 0 | [
"-MAX_A = 10**6",
"-X = [0] * (MAX_A + 1)",
"+B = [True] * (10**6 + 1)",
"- for i in range(a, MAX_A + 1, a):",
"- X[i] += 1",
"-ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])",
"-print(ans)",
"+ for i in range(2 * a, 10**6 + 1, a):",
"+ B[i] = False",
"+cnt = 0",
"+... | false | 0.372999 | 0.245301 | 1.520574 | [
"s028065641",
"s686560995"
] |
u994988729 | p03162 | python | s182682929 | s275636068 | 859 | 483 | 14,960 | 3,064 | Accepted | Accepted | 43.77 | N=int(eval(input()))
dp=[[0 for i in range(N+1)] for i in range(3)]
for j in range(N):
abc=list(map(int,input().split()))
for i in range(3):
if j==0:
dp[i][j]=abc[i]
else:
dp[i][j]=max([dp[k][j-1]+abc[i] for k in range(3) if k!=i])
print((max([dp[i][N-1] for i ... | N = int(eval(input()))
dp = list(map(int, input().split()))
for i in range(1, N):
a, b, c = list(map(int, input().split()))
newDP = [0] * 3
newDP[0] = max(dp[1], dp[2]) + a
newDP[1] = max(dp[0], dp[2]) + b
newDP[2] = max(dp[0], dp[1]) + c
dp = newDP[::]
ans = max(dp)
print(ans)
| 11 | 14 | 327 | 307 | N = int(eval(input()))
dp = [[0 for i in range(N + 1)] for i in range(3)]
for j in range(N):
abc = list(map(int, input().split()))
for i in range(3):
if j == 0:
dp[i][j] = abc[i]
else:
dp[i][j] = max([dp[k][j - 1] + abc[i] for k in range(3) if k != i])
print((max([dp[i][N... | N = int(eval(input()))
dp = list(map(int, input().split()))
for i in range(1, N):
a, b, c = list(map(int, input().split()))
newDP = [0] * 3
newDP[0] = max(dp[1], dp[2]) + a
newDP[1] = max(dp[0], dp[2]) + b
newDP[2] = max(dp[0], dp[1]) + c
dp = newDP[::]
ans = max(dp)
print(ans)
| false | 21.428571 | [
"-dp = [[0 for i in range(N + 1)] for i in range(3)]",
"-for j in range(N):",
"- abc = list(map(int, input().split()))",
"- for i in range(3):",
"- if j == 0:",
"- dp[i][j] = abc[i]",
"- else:",
"- dp[i][j] = max([dp[k][j - 1] + abc[i] for k in range(3) if k !... | false | 0.035603 | 0.040699 | 0.874798 | [
"s182682929",
"s275636068"
] |
u664373116 | p03038 | python | s948960404 | s976154860 | 667 | 591 | 32,448 | 32,448 | Accepted | Accepted | 11.39 | from collections import Counter
N,M=list(map(int,input().split()))
cards=list(map(int,input().split()))
all_c=Counter(cards)
for i in range(M):
time,val=list(map(int,input().split()))
try:
all_c[val]+=time
except:
all_c[val]=time
tmp=list(all_c.keys())
tmp.sort(reverse=True)
... | from collections import Counter
N,M=list(map(int,input().split()))
cards=list(map(int,input().split()))
all_c=Counter(cards)
for i in range(M):
time,val=list(map(int,input().split()))
if val in list(all_c.keys()):
all_c[val]+=time
else:
all_c[val]=time
"""
try:
... | 25 | 31 | 527 | 636 | from collections import Counter
N, M = list(map(int, input().split()))
cards = list(map(int, input().split()))
all_c = Counter(cards)
for i in range(M):
time, val = list(map(int, input().split()))
try:
all_c[val] += time
except:
all_c[val] = time
tmp = list(all_c.keys())
tmp.sort(reverse=Tr... | from collections import Counter
N, M = list(map(int, input().split()))
cards = list(map(int, input().split()))
all_c = Counter(cards)
for i in range(M):
time, val = list(map(int, input().split()))
if val in list(all_c.keys()):
all_c[val] += time
else:
all_c[val] = time
"""
try:
... | false | 19.354839 | [
"+ if val in list(all_c.keys()):",
"+ all_c[val] += time",
"+ else:",
"+ all_c[val] = time",
"+ \"\"\"",
"- all_c[val] += time",
"+ all_c[val]+=time",
"- all_c[val] = time",
"+ all_c[val]=time",
"+ \"\"\""
] | false | 0.04102 | 0.079827 | 0.513859 | [
"s948960404",
"s976154860"
] |
u989345508 | p03986 | python | s584866420 | s730209848 | 57 | 44 | 3,500 | 3,500 | Accepted | Accepted | 22.81 | x=eval(input())
l=len(x)
f=0
c=0
for i in range(l):
if x[i]=="S":
f+=1
else:
if f==0:
c+=1
else:
f-=1
print((2*c))
| x=eval(input())
f=0
c=0
#なかなか良い解法、flag立てる
for i in x:
if i=="S":
f+=1
else:
if f==0:
c+=1
else:
f-=1
print((2*c))
| 13 | 13 | 175 | 174 | x = eval(input())
l = len(x)
f = 0
c = 0
for i in range(l):
if x[i] == "S":
f += 1
else:
if f == 0:
c += 1
else:
f -= 1
print((2 * c))
| x = eval(input())
f = 0
c = 0
# なかなか良い解法、flag立てる
for i in x:
if i == "S":
f += 1
else:
if f == 0:
c += 1
else:
f -= 1
print((2 * c))
| false | 0 | [
"-l = len(x)",
"-for i in range(l):",
"- if x[i] == \"S\":",
"+# なかなか良い解法、flag立てる",
"+for i in x:",
"+ if i == \"S\":"
] | false | 0.085205 | 0.089774 | 0.949099 | [
"s584866420",
"s730209848"
] |
u591503175 | p03163 | python | s104718937 | s446710120 | 688 | 195 | 171,656 | 91,548 | Accepted | Accepted | 71.66 | N, W = [int(item) for item in input().split()]
item = [[int(item) for item in input().split()] for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
for w in range(W+1):
if 0 <= w - item[i][0]:
dp[i+1][w] = max(dp[i][w], dp[i][w - item[i][0]] + item[i... | import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.zeros((N+1, W+1), dtype='int64')
for i in range(N):
dp[i+1] = dp[i]
w, v... | 12 | 19 | 393 | 483 | N, W = [int(item) for item in input().split()]
item = [[int(item) for item in input().split()] for _ in range(N)]
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(N):
for w in range(W + 1):
if 0 <= w - item[i][0]:
dp[i + 1][w] = max(dp[i][w], dp[i][w - item[i][0]] + item[i][... | import sys
input = sys.stdin.readline
import numpy as np
def main():
N, W = [int(item) for item in input().split()]
item = np.array([[int(item) for item in input().split()] for _ in range(N)])
dp = np.zeros((N + 1, W + 1), dtype="int64")
for i in range(N):
dp[i + 1] = dp[i]
w, v = ite... | false | 36.842105 | [
"-N, W = [int(item) for item in input().split()]",
"-item = [[int(item) for item in input().split()] for _ in range(N)]",
"-dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]",
"-for i in range(N):",
"- for w in range(W + 1):",
"- if 0 <= w - item[i][0]:",
"- dp[i + 1][w] = max(... | false | 0.039335 | 0.176368 | 0.22303 | [
"s104718937",
"s446710120"
] |
u075012704 | p03971 | python | s716044248 | s053751081 | 102 | 78 | 4,016 | 9,272 | Accepted | Accepted | 23.53 | N, A, B = list(map(int, input().split()))
S = eval(input())
passed = 0
oversea = 0
for s in S:
if s == "a" and passed < A + B:
passed += 1
print("Yes")
continue
if s == "b" and passed < A + B and oversea < B:
passed += 1
oversea += 1
print("Yes")
... | N, A, B = list(map(int, input().split()))
S = eval(input())
X, Y = 0, 0
for s in S:
if s == 'c':
print('No')
if s == 'a':
if X + Y < A + B:
print('Yes')
X += 1
else:
print('No')
if s == 'b':
if X + Y < A + B and Y < B:
... | 18 | 21 | 344 | 392 | N, A, B = list(map(int, input().split()))
S = eval(input())
passed = 0
oversea = 0
for s in S:
if s == "a" and passed < A + B:
passed += 1
print("Yes")
continue
if s == "b" and passed < A + B and oversea < B:
passed += 1
oversea += 1
print("Yes")
continue
... | N, A, B = list(map(int, input().split()))
S = eval(input())
X, Y = 0, 0
for s in S:
if s == "c":
print("No")
if s == "a":
if X + Y < A + B:
print("Yes")
X += 1
else:
print("No")
if s == "b":
if X + Y < A + B and Y < B:
print("Ye... | false | 14.285714 | [
"-passed = 0",
"-oversea = 0",
"+X, Y = 0, 0",
"- if s == \"a\" and passed < A + B:",
"- passed += 1",
"- print(\"Yes\")",
"- continue",
"- if s == \"b\" and passed < A + B and oversea < B:",
"- passed += 1",
"- oversea += 1",
"- print(\"Yes\")",
... | false | 0.083181 | 0.069345 | 1.199517 | [
"s716044248",
"s053751081"
] |
u186838327 | p03696 | python | s707013046 | s918428180 | 184 | 71 | 38,384 | 64,720 | Accepted | Accepted | 61.41 | n = int(eval(input()))
s = str(eval(input()))
ans = s
ans = list(ans)
cum = 0
for i in range(n):
if s[i] == '(':
cum += 1
else:
cum -= 1
if cum < 0:
ans = ['('] + ans
cum = 0
else:
ans = ans + [')']*cum
print((''.join(ans)))
| n = int(eval(input()))
s = str(eval(input()))
c = 0
from collections import deque
res = deque([])
for i in range(n):
if s[i] =='(':
c += 1
else:
c -= 1
if c < 0:
res.appendleft('(')
c = 0
res.append(s[i])
if c > 0:
res.append(')'*c)
print((''.join(list... | 19 | 17 | 280 | 315 | n = int(eval(input()))
s = str(eval(input()))
ans = s
ans = list(ans)
cum = 0
for i in range(n):
if s[i] == "(":
cum += 1
else:
cum -= 1
if cum < 0:
ans = ["("] + ans
cum = 0
else:
ans = ans + [")"] * cum
print(("".join(ans)))
| n = int(eval(input()))
s = str(eval(input()))
c = 0
from collections import deque
res = deque([])
for i in range(n):
if s[i] == "(":
c += 1
else:
c -= 1
if c < 0:
res.appendleft("(")
c = 0
res.append(s[i])
if c > 0:
res.append(")" * c)
print(("".join(list(res))))
| false | 10.526316 | [
"-ans = s",
"-ans = list(ans)",
"-cum = 0",
"+c = 0",
"+from collections import deque",
"+",
"+res = deque([])",
"- cum += 1",
"+ c += 1",
"- cum -= 1",
"- if cum < 0:",
"- ans = [\"(\"] + ans",
"- cum = 0",
"-else:",
"- ans = ans + [\")\"] * cum"... | false | 0.040328 | 0.043596 | 0.925027 | [
"s707013046",
"s918428180"
] |
u280552586 | p03862 | python | s953195237 | s024838319 | 123 | 111 | 14,252 | 14,252 | Accepted | Accepted | 9.76 | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
for i in range(1, n):
if A[i-1]+A[i] <= x:
continue
eat = A[i-1]+A[i] - x
ans += eat
A[i] = max(0, A[i]-eat)
print(ans) | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
for i in range(n):
if i == 0:
if A[i] <= x:
continue
eat = A[i] - x
ans += eat
A[i] = A[i] - eat
continue
if A[i-1]+A[i] <= x:
continue
eat = A[i-1] + A... | 11 | 18 | 231 | 374 | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
for i in range(1, n):
if A[i - 1] + A[i] <= x:
continue
eat = A[i - 1] + A[i] - x
ans += eat
A[i] = max(0, A[i] - eat)
print(ans)
| n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
for i in range(n):
if i == 0:
if A[i] <= x:
continue
eat = A[i] - x
ans += eat
A[i] = A[i] - eat
continue
if A[i - 1] + A[i] <= x:
continue
eat = A[i - 1] + A[i] - x... | false | 38.888889 | [
"-for i in range(1, n):",
"+for i in range(n):",
"+ if i == 0:",
"+ if A[i] <= x:",
"+ continue",
"+ eat = A[i] - x",
"+ ans += eat",
"+ A[i] = A[i] - eat",
"+ continue",
"- A[i] = max(0, A[i] - eat)",
"+ A[i] = A[i] - eat"
] | false | 0.056353 | 0.052165 | 1.080286 | [
"s953195237",
"s024838319"
] |
u276192130 | p03420 | python | s344592921 | s545814037 | 195 | 121 | 3,060 | 2,940 | Accepted | Accepted | 37.95 | n, k = list(map(int, input().split()))
ans = 0
if k == 0:
ans = n*n
else:
for i in range(1, n+1):
ans += n//i * max(i-k, 0)
a = n//i * max(i-k, 0)
b = 0
if i >= k and n % i != 0:
ans += max(0, (n%i+1)-k)
b = max(0, (n%i+1)-k)
print(ans)
| n, k = list(map(int, input().split()))
ans = 0
if k == 0:
ans = n * n
else:
for i in range(1, n + 1):
ans += n // i * max(i - k, 0)
if i >= k and n % i != 0:
ans += max(0, (n % i + 1) - k)
print(ans)
| 13 | 10 | 307 | 239 | n, k = list(map(int, input().split()))
ans = 0
if k == 0:
ans = n * n
else:
for i in range(1, n + 1):
ans += n // i * max(i - k, 0)
a = n // i * max(i - k, 0)
b = 0
if i >= k and n % i != 0:
ans += max(0, (n % i + 1) - k)
b = max(0, (n % i + 1) - k)
print(... | n, k = list(map(int, input().split()))
ans = 0
if k == 0:
ans = n * n
else:
for i in range(1, n + 1):
ans += n // i * max(i - k, 0)
if i >= k and n % i != 0:
ans += max(0, (n % i + 1) - k)
print(ans)
| false | 23.076923 | [
"- a = n // i * max(i - k, 0)",
"- b = 0",
"- b = max(0, (n % i + 1) - k)"
] | false | 0.043479 | 0.046292 | 0.939245 | [
"s344592921",
"s545814037"
] |
u729133443 | p02777 | python | s458140374 | s728267259 | 161 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.44 | s,a,u=open(0)
i=s.find(u)<1
print((int(a[:2])-i,int(a[2:])-1+i)) | s,a,u=open(0);i=u in s;print((int(a[:2])-1+i,int(a[2:])-i)) | 3 | 1 | 64 | 57 | s, a, u = open(0)
i = s.find(u) < 1
print((int(a[:2]) - i, int(a[2:]) - 1 + i))
| s, a, u = open(0)
i = u in s
print((int(a[:2]) - 1 + i, int(a[2:]) - i))
| false | 66.666667 | [
"-i = s.find(u) < 1",
"-print((int(a[:2]) - i, int(a[2:]) - 1 + i))",
"+i = u in s",
"+print((int(a[:2]) - 1 + i, int(a[2:]) - i))"
] | false | 0.036007 | 0.035049 | 1.027317 | [
"s458140374",
"s728267259"
] |
u835482198 | p04044 | python | s160336765 | s940522809 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | # https://atcoder.jp/contests/abc042/tasks/abc042_b
N, L = list(map(int, input().split()))
s = [eval(input()) for _ in range(N)]
s = sorted(s)
print(("".join(s)))
| n, l = list(map(int, input().split()))
print(("".join(sorted([eval(input()) for _ in range(n)]))))
| 6 | 2 | 155 | 86 | # https://atcoder.jp/contests/abc042/tasks/abc042_b
N, L = list(map(int, input().split()))
s = [eval(input()) for _ in range(N)]
s = sorted(s)
print(("".join(s)))
| n, l = list(map(int, input().split()))
print(("".join(sorted([eval(input()) for _ in range(n)]))))
| false | 66.666667 | [
"-# https://atcoder.jp/contests/abc042/tasks/abc042_b",
"-N, L = list(map(int, input().split()))",
"-s = [eval(input()) for _ in range(N)]",
"-s = sorted(s)",
"-print((\"\".join(s)))",
"+n, l = list(map(int, input().split()))",
"+print((\"\".join(sorted([eval(input()) for _ in range(n)]))))"
] | false | 0.044515 | 0.044956 | 0.990201 | [
"s160336765",
"s940522809"
] |
u294385082 | p02881 | python | s885261601 | s670456567 | 408 | 368 | 2,940 | 3,060 | Accepted | Accepted | 9.8 | n = int(eval(input()))
tmp = 1
for i in range(1,10**6+1):
if n%i == 0:
if i <= n//i:
tmp = i
else:
break
elif tmp == 1 and i >= n/i:
break
print((tmp + (n//tmp) -2)) | n = int(eval(input()))
tmp = 1
for i in range(1,10**6+1): #10**12とかにしてしまうとTLE
#たとえばn=2*大きい素数である時を考えると,この時は全回ししてまう
if n%i == 0:
if i <= n//i:
tmp = i
else:
break
elif tmp == 1 and i >= n/i:
break
print((tmp + (n//tmp) -2)) | 13 | 14 | 207 | 267 | n = int(eval(input()))
tmp = 1
for i in range(1, 10**6 + 1):
if n % i == 0:
if i <= n // i:
tmp = i
else:
break
elif tmp == 1 and i >= n / i:
break
print((tmp + (n // tmp) - 2))
| n = int(eval(input()))
tmp = 1
for i in range(1, 10**6 + 1): # 10**12とかにしてしまうとTLE
# たとえばn=2*大きい素数である時を考えると,この時は全回ししてまう
if n % i == 0:
if i <= n // i:
tmp = i
else:
break
elif tmp == 1 and i >= n / i:
break
print((tmp + (n // tmp) - 2))
| false | 7.142857 | [
"-for i in range(1, 10**6 + 1):",
"+for i in range(1, 10**6 + 1): # 10**12とかにしてしまうとTLE",
"+ # たとえばn=2*大きい素数である時を考えると,この時は全回ししてまう"
] | false | 0.170913 | 0.186988 | 0.91403 | [
"s885261601",
"s670456567"
] |
u901122076 | p03087 | python | s402245229 | s295311390 | 1,000 | 359 | 50,776 | 52,824 | Accepted | Accepted | 64.1 | N, Q = list(map(int, input().split()))
S = eval(input())
hit = [0] * N
for i in range(0, N - 1):
hit[i + 1] = hit[i]
if S[i:i+2] == 'AC':
hit[i + 1] += 1
for _ in range(0, Q):
l, r = list(map(int, input().split()))
result = hit[r - 1] - hit[l - 1]
print(result)
| import sys
def input():
return sys.stdin.readline()[:-1]
N, Q = list(map(int, input().split()))
S = eval(input())
hit = [0] * N
for i in range(0, N - 1):
hit[i + 1] = hit[i]
if S[i:i+2] == 'AC':
hit[i + 1] += 1
for _ in range(0, Q):
l, r = list(map(int, input().split()... | 16 | 22 | 292 | 362 | N, Q = list(map(int, input().split()))
S = eval(input())
hit = [0] * N
for i in range(0, N - 1):
hit[i + 1] = hit[i]
if S[i : i + 2] == "AC":
hit[i + 1] += 1
for _ in range(0, Q):
l, r = list(map(int, input().split()))
result = hit[r - 1] - hit[l - 1]
print(result)
| import sys
def input():
return sys.stdin.readline()[:-1]
N, Q = list(map(int, input().split()))
S = eval(input())
hit = [0] * N
for i in range(0, N - 1):
hit[i + 1] = hit[i]
if S[i : i + 2] == "AC":
hit[i + 1] += 1
for _ in range(0, Q):
l, r = list(map(int, input().split()))
result = hit... | false | 27.272727 | [
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+"
] | false | 0.036062 | 0.035724 | 1.009436 | [
"s402245229",
"s295311390"
] |
u815763296 | p02724 | python | s412821922 | s400295407 | 30 | 25 | 8,992 | 9,096 | Accepted | Accepted | 16.67 | X = int(eval(input()))
ans = X//500*1000
X = X % 500
ans += X//5*5
print(ans)
| def LI():
return list(map(int, input().split()))
X = int(eval(input()))
ans = X//500*1000
X = X % 500
ans += X//5*5
print(ans)
| 5 | 9 | 76 | 135 | X = int(eval(input()))
ans = X // 500 * 1000
X = X % 500
ans += X // 5 * 5
print(ans)
| def LI():
return list(map(int, input().split()))
X = int(eval(input()))
ans = X // 500 * 1000
X = X % 500
ans += X // 5 * 5
print(ans)
| false | 44.444444 | [
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+"
] | false | 0.036381 | 0.039012 | 0.932574 | [
"s412821922",
"s400295407"
] |
u891635666 | p03000 | python | s450873396 | s694326417 | 167 | 17 | 38,384 | 3,064 | Accepted | Accepted | 89.82 | n, x = list(map(int, input().split()))
nums = list(map(int, input().split()))
count = 1
s = 0
for num in nums:
s += num
if s <= x:
count += 1
else:
break
print(count) | import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)... | 12 | 24 | 200 | 511 | n, x = list(map(int, input().split()))
nums = list(map(int, input().split()))
count = 1
s = 0
for num in nums:
s += num
if s <= x:
count += 1
else:
break
print(count)
| import sys
input = sys.stdin.readline
ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = la... | false | 50 | [
"-n, x = list(map(int, input().split()))",
"-nums = list(map(int, input().split()))",
"-count = 1",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+ri = lambda: int(eval(input()))",
"+rs = lambda: input().rstrip()",
"+ril = lambda: list(map(int, input().split()))",
"+rsl = lambda: input().rst... | false | 0.038255 | 0.037641 | 1.016312 | [
"s450873396",
"s694326417"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.