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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u707124227 | p02586 | python | s165499680 | s292150125 | 1,121 | 992 | 195,148 | 177,880 | Accepted | Accepted | 11.51 | import sys
input = sys.stdin.readline
def main(R,C,K,rcv):
inf=float('inf')
dp0=[[-inf,-inf,-inf,0] for _ in range(C)]
item=[[0]*C for _ in range(R)]
for r,c,v in rcv:
item[r-1][c-1]=v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
# 初期化
for j in range(C):
... | import sys
input = sys.stdin.readline
def main(R,C,K,rcv):
inf=float('inf')
dp0=[[-inf,-inf,-inf,0] for _ in range(C)]
item=[[0]*C for _ in range(R)]
for r,c,v in rcv:
item[r-1][c-1]=v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
# 遷移
for j in range(C):
... | 32 | 33 | 905 | 918 | import sys
input = sys.stdin.readline
def main(R, C, K, rcv):
inf = float("inf")
dp0 = [[-inf, -inf, -inf, 0] for _ in range(C)]
item = [[0] * C for _ in range(R)]
for r, c, v in rcv:
item[r - 1][c - 1] = v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
... | import sys
input = sys.stdin.readline
def main(R, C, K, rcv):
inf = float("inf")
dp0 = [[-inf, -inf, -inf, 0] for _ in range(C)]
item = [[0] * C for _ in range(R)]
for r, c, v in rcv:
item[r - 1][c - 1] = v
# dp0[c][j]:c列目の時点で残りちょうどj個取れる時の最大値
for i in range(R):
# i+1行目に対する操作
... | false | 3.030303 | [
"- # 初期化",
"- for j in range(C):",
"- dp0[j][3] = max(dp0[j])",
"- dp0[j][2] = -inf",
"- dp0[j][1] = -inf",
"- dp0[j][0] = -inf",
"+ # 遷移",
"- dp0[j][0] = max(dp0[j][0], dp0[j - 1][0])",
"+ dp0[j][3] = max... | false | 0.040852 | 0.174085 | 0.23467 | [
"s165499680",
"s292150125"
] |
u301624971 | p04033 | python | s156593046 | s293834458 | 19 | 17 | 3,064 | 3,060 | Accepted | Accepted | 10.53 | def myAnswer(a:int,b:int) -> str:
if(a <= 0 and b >= 0): return "Zero"
if(a < 0):
if(b < 0):
return "Negative" if((abs(a-b) + 1)%2==1) else "Positive"
else:
return "Negative" if(abs(a)%2==1) else "Positive"
else:
return "Positive"
def modelAnswer():
tmp=1
d... | def myAnswer(a:int,b:int) -> str:
# ゼロがまたがっている場合はzero ex)-1 2
if(a <= 0 and b >= 0): return "Zero"
if(a < 0):# aが負の数で
if(b < 0): # bも負の数だった場合は,負の数の個数をカウントし、奇数ならNegative,偶数ならポジティブ
return "Negative" if((abs(a-b) + 1)%2==1) else "Positive"
else:
return "Positive"
def model... | 19 | 19 | 431 | 453 | def myAnswer(a: int, b: int) -> str:
if a <= 0 and b >= 0:
return "Zero"
if a < 0:
if b < 0:
return "Negative" if ((abs(a - b) + 1) % 2 == 1) else "Positive"
else:
return "Negative" if (abs(a) % 2 == 1) else "Positive"
else:
return "Positive"
def mod... | def myAnswer(a: int, b: int) -> str:
# ゼロがまたがっている場合はzero ex)-1 2
if a <= 0 and b >= 0:
return "Zero"
if a < 0: # aが負の数で
if b < 0: # bも負の数だった場合は,負の数の個数をカウントし、奇数ならNegative,偶数ならポジティブ
return "Negative" if ((abs(a - b) + 1) % 2 == 1) else "Positive"
else:
return "Positiv... | false | 0 | [
"+ # ゼロがまたがっている場合はzero ex)-1 2",
"- if a < 0:",
"- if b < 0:",
"+ if a < 0: # aが負の数で",
"+ if b < 0: # bも負の数だった場合は,負の数の個数をカウントし、奇数ならNegative,偶数ならポジティブ",
"- else:",
"- return \"Negative\" if (abs(a) % 2 == 1) else \"Positive\""
] | false | 0.081321 | 0.086025 | 0.945321 | [
"s156593046",
"s293834458"
] |
u629780968 | p02361 | python | s028206213 | s015736785 | 4,870 | 2,890 | 102,480 | 96,968 | Accepted | Accepted | 40.66 | v,e,r = list(map(int,input().split()))
d = [float('INF')]*v
d[r] = 0
edges=[]
for i in range(e):
s,t,c = list(map(int,input().split()))
edges.append([s,t,c])
for i in range(v):
count = 0
for s,v,c in edges:
if d[v] > d[s]+c:
count += 1
d[v] = d[s]+c
if count == 0:
break
... | from heapq import heappush, heappop
v,e,r = list(map(int,input().split()))
edges=[[] for i in range(v)]
d = [float('INF')]*v
for i in range(e):
s,t,c = list(map(int,input().split()))
edges[s].append([t,c])
que = []
heappush(que,(0,r))
d[r] = 0
while que:
c, u = heappop(que)
for v, s in edges[u... | 23 | 24 | 388 | 462 | v, e, r = list(map(int, input().split()))
d = [float("INF")] * v
d[r] = 0
edges = []
for i in range(e):
s, t, c = list(map(int, input().split()))
edges.append([s, t, c])
for i in range(v):
count = 0
for s, v, c in edges:
if d[v] > d[s] + c:
count += 1
d[v] = d[s] + c
... | from heapq import heappush, heappop
v, e, r = list(map(int, input().split()))
edges = [[] for i in range(v)]
d = [float("INF")] * v
for i in range(e):
s, t, c = list(map(int, input().split()))
edges[s].append([t, c])
que = []
heappush(que, (0, r))
d[r] = 0
while que:
c, u = heappop(que)
for v, s in edg... | false | 4.166667 | [
"+from heapq import heappush, heappop",
"+",
"+edges = [[] for i in range(v)]",
"-d[r] = 0",
"-edges = []",
"- edges.append([s, t, c])",
"-for i in range(v):",
"- count = 0",
"- for s, v, c in edges:",
"- if d[v] > d[s] + c:",
"- count += 1",
"- d[v] = d[s... | false | 0.071389 | 0.083345 | 0.856551 | [
"s028206213",
"s015736785"
] |
u780475861 | p03276 | python | s416802774 | s485437576 | 78 | 64 | 14,052 | 14,052 | Accepted | Accepted | 17.95 | import bisect
n, k, *lst = list(map(int, open(0).read().split()))
z = bisect.bisect_left(lst, 0)
if not z:
print((lst[k - 1]))
quit()
if z >= n - 1:
print((-lst[-k]))
quit()
res = float('inf')
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), l... | import bisect
def main():
n, k, *lst = list(map(int, open(0).read().split()))
z = bisect.bisect_left(lst, 0)
if not z:
print((lst[k - 1]))
elif z >= n - 1:
print((-lst[-k]))
else:
res = float('inf')
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
tmp = lst[i + k - 1] -... | 16 | 19 | 369 | 448 | import bisect
n, k, *lst = list(map(int, open(0).read().split()))
z = bisect.bisect_left(lst, 0)
if not z:
print((lst[k - 1]))
quit()
if z >= n - 1:
print((-lst[-k]))
quit()
res = float("inf")
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst... | import bisect
def main():
n, k, *lst = list(map(int, open(0).read().split()))
z = bisect.bisect_left(lst, 0)
if not z:
print((lst[k - 1]))
elif z >= n - 1:
print((-lst[-k]))
else:
res = float("inf")
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
t... | false | 15.789474 | [
"-n, k, *lst = list(map(int, open(0).read().split()))",
"-z = bisect.bisect_left(lst, 0)",
"-if not z:",
"- print((lst[k - 1]))",
"- quit()",
"-if z >= n - 1:",
"- print((-lst[-k]))",
"- quit()",
"-res = float(\"inf\")",
"-for i in range(max(z - k + 1, 0), min(z, n - k) + 1):",
"- ... | false | 0.04048 | 0.040522 | 0.998967 | [
"s416802774",
"s485437576"
] |
u072717685 | p03680 | python | s324433900 | s171981764 | 194 | 62 | 7,980 | 20,452 | Accepted | Accepted | 68.04 | n = int(eval(input()))
a = [0]
tmp = [int(eval(input())) for _ in range(n)]
a = a + tmp
r = -1
cnt = 1
next = a[1]
while cnt < n:
if next == 2:
r = cnt
break
else:
next = a[next]
cnt += 1
print(r) | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n, *a = list(map(int, read().split()))
r = 0
x = 1
while x != 2:
r += 1
x = a[x - 1]
if x == 1 or r >= n:
r = -1
break
print(r)
if __name__ == '__main__':
... | 16 | 17 | 220 | 321 | n = int(eval(input()))
a = [0]
tmp = [int(eval(input())) for _ in range(n)]
a = a + tmp
r = -1
cnt = 1
next = a[1]
while cnt < n:
if next == 2:
r = cnt
break
else:
next = a[next]
cnt += 1
print(r)
| import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
n, *a = list(map(int, read().split()))
r = 0
x = 1
while x != 2:
r += 1
x = a[x - 1]
if x == 1 or r >= n:
r = -1
break
print(r)
if __name__ == "__main__":
main()
| false | 5.882353 | [
"-n = int(eval(input()))",
"-a = [0]",
"-tmp = [int(eval(input())) for _ in range(n)]",
"-a = a + tmp",
"-r = -1",
"-cnt = 1",
"-next = a[1]",
"-while cnt < n:",
"- if next == 2:",
"- r = cnt",
"- break",
"- else:",
"- next = a[next]",
"- cnt += 1",
"-pr... | false | 0.08032 | 0.066069 | 1.215688 | [
"s324433900",
"s171981764"
] |
u179169725 | p04013 | python | s301616688 | s100369461 | 360 | 188 | 92,124 | 41,584 | Accepted | Accepted | 47.78 | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
'''
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
dp(j+1,k,s)... | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
'''
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
更新則
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
すなわち... | 59 | 98 | 1,253 | 2,256 | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
"""
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
dp(j+1,k,s) = dp(j,k-1,s... | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
"""
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
更新則
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
すなわち
dp(j+1,k,s) = d... | false | 39.795918 | [
"+更新則",
"+すなわち",
"-伝播条件 s-X[j]<0に関しては dp(j-1,k-1,s-X[j])が必ず0通りとなる(ありえないので)",
"+伝播条件 s-X[j]<0に関しては dp(j,k-1,s-X[j])が必ず0通りとなる(ありえないので)",
"-S = sum(X)",
"-# 満点解法1",
"-dp = [[[0] * (S + 1) for _ in range(N + 1)] for _ in range(N + 1)]",
"-for j in range(N + 1): # 初期条件",
"- dp[j][0][0] = 1 # 1枚も選ばずに... | false | 0.052788 | 0.05521 | 0.956136 | [
"s301616688",
"s100369461"
] |
u753803401 | p03095 | python | s026321295 | s068749512 | 212 | 181 | 39,408 | 39,536 | Accepted | Accepted | 14.62 | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = collections.Counter(str(input().rstrip('\n')))
cnt = 1
for k, v in list(s.items()):
cnt *= (v + 1)
cnt %= (10 ** 9 + 7)
print((cnt - 1))
if __name__ == '... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
s = str(input().rstrip('\n'))
s = collections.Counter(s).most_common()
t = 1
for k, v in s:
t = (t * (v + 1)) % (10 ** 9 + 7)
print((t - 1))
if __name__ == '__ma... | 15 | 15 | 336 | 338 | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = collections.Counter(str(input().rstrip("\n")))
cnt = 1
for k, v in list(s.items()):
cnt *= v + 1
cnt %= 10**9 + 7
print((cnt - 1))
if __name__ == "__main__":
slo... | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip("\n"))
s = str(input().rstrip("\n"))
s = collections.Counter(s).most_common()
t = 1
for k, v in s:
t = (t * (v + 1)) % (10**9 + 7)
print((t - 1))
if __name__ == "__main__":
slo... | false | 0 | [
"- s = collections.Counter(str(input().rstrip(\"\\n\")))",
"- cnt = 1",
"- for k, v in list(s.items()):",
"- cnt *= v + 1",
"- cnt %= 10**9 + 7",
"- print((cnt - 1))",
"+ s = str(input().rstrip(\"\\n\"))",
"+ s = collections.Counter(s).most_common()",
"+ t = 1",
... | false | 0.038478 | 0.038339 | 1.003643 | [
"s026321295",
"s068749512"
] |
u790710233 | p02720 | python | s556501497 | s369143093 | 222 | 147 | 17,012 | 16,848 | Accepted | Accepted | 33.78 | from collections import deque
k = int(eval(input()))
def generate_lunlun(x):
d = int(x) % 10
if d != 0:
yield x+str(d-1)
yield x+str(d)
if d != 9:
yield x+str(d+1)
d = deque([str(i) for i in range(1, 10)])
for _ in range(k):
x = d.popleft()
for y in generate_l... | lunlun = []
def dfs(x):
lunlun.append(x)
if x > 3234566667:
return 0
d = x % 10
if d != 0:
dfs(10*x+d-1)
dfs(10*x+d)
if d != 9:
dfs(10*x+d+1)
for i in range(1, 10):
dfs(i)
lunlun.sort()
k = int(eval(input()))
print((lunlun[k-1])) | 19 | 21 | 355 | 298 | from collections import deque
k = int(eval(input()))
def generate_lunlun(x):
d = int(x) % 10
if d != 0:
yield x + str(d - 1)
yield x + str(d)
if d != 9:
yield x + str(d + 1)
d = deque([str(i) for i in range(1, 10)])
for _ in range(k):
x = d.popleft()
for y in generate_lunlun... | lunlun = []
def dfs(x):
lunlun.append(x)
if x > 3234566667:
return 0
d = x % 10
if d != 0:
dfs(10 * x + d - 1)
dfs(10 * x + d)
if d != 9:
dfs(10 * x + d + 1)
for i in range(1, 10):
dfs(i)
lunlun.sort()
k = int(eval(input()))
print((lunlun[k - 1]))
| false | 9.52381 | [
"-from collections import deque",
"-",
"-k = int(eval(input()))",
"+lunlun = []",
"-def generate_lunlun(x):",
"- d = int(x) % 10",
"+def dfs(x):",
"+ lunlun.append(x)",
"+ if x > 3234566667:",
"+ return 0",
"+ d = x % 10",
"- yield x + str(d - 1)",
"- yield x + s... | false | 0.145982 | 0.666028 | 0.219183 | [
"s556501497",
"s369143093"
] |
u422291726 | p03250 | python | s880027073 | s280169815 | 30 | 17 | 3,316 | 2,940 | Accepted | Accepted | 43.33 | S = list(input().split())
S.sort(reverse=True)
print((int(S[0] + S[1]) + int(S[2])))
| S = sorted(input().split(), reverse=True)
print((int(S[0] + S[1]) + int(S[2])))
| 3 | 2 | 85 | 79 | S = list(input().split())
S.sort(reverse=True)
print((int(S[0] + S[1]) + int(S[2])))
| S = sorted(input().split(), reverse=True)
print((int(S[0] + S[1]) + int(S[2])))
| false | 33.333333 | [
"-S = list(input().split())",
"-S.sort(reverse=True)",
"+S = sorted(input().split(), reverse=True)"
] | false | 0.082686 | 0.115079 | 0.718517 | [
"s880027073",
"s280169815"
] |
u254871849 | p02881 | python | s522452489 | s290995440 | 116 | 103 | 3,060 | 3,264 | Accepted | Accepted | 11.21 | # 2019-11-19 19:43:48(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import arr... | import sys
def divisors(n):
res = []
for i in range(1, int(n ** 0.5) + 1):
if n % i: continue
res.append(i)
res.append(n // i)
return res
n = int(sys.stdin.readline().rstrip())
def main():
res = divisors(n)
print((res[-1] + res[-2] - 2))
if __name__ == '__main__':
mai... | 28 | 18 | 681 | 321 | # 2019-11-19 19:43:48(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from... | import sys
def divisors(n):
res = []
for i in range(1, int(n**0.5) + 1):
if n % i:
continue
res.append(i)
res.append(n // i)
return res
n = int(sys.stdin.readline().rstrip())
def main():
res = divisors(n)
print((res[-1] + res[-2] - 2))
if __name__ == "__ma... | false | 35.714286 | [
"-# 2019-11-19 19:43:48(JST)",
"-# import collections",
"-import math",
"-# from string import ascii_lowercase, ascii_uppercase, digits",
"-# from bisect import bisect_left as bi_l, bisect_right as bi_r",
"-# import itertools",
"-# from functools import reduce",
"-# import operator as op",
"-# impor... | false | 0.049742 | 0.040216 | 1.236884 | [
"s522452489",
"s290995440"
] |
u727148417 | p02924 | python | s911275091 | s865925962 | 1,468 | 17 | 38,384 | 2,940 | Accepted | Accepted | 98.84 | N = int(eval(input()))
print((sum(range(1, N)))) | n=int(eval(input()))
print(((n-1)*n//2)) | 2 | 2 | 41 | 33 | N = int(eval(input()))
print((sum(range(1, N))))
| n = int(eval(input()))
print(((n - 1) * n // 2))
| false | 0 | [
"-N = int(eval(input()))",
"-print((sum(range(1, N))))",
"+n = int(eval(input()))",
"+print(((n - 1) * n // 2))"
] | false | 0.054323 | 0.047505 | 1.143509 | [
"s911275091",
"s865925962"
] |
u281610856 | p02850 | python | s453403015 | s221367619 | 474 | 320 | 85,624 | 28,076 | Accepted | Accepted | 32.49 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
a, b = map(int, input().split())
a, b = a - 1, b - 1
g[a].append((b, i))
g[b].append((a, i))
ans = [0] * (n-1)
def dfs(u, c=-1, p=-1):
k = 1
... | from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
def main():
N = int(eval(input()))
g = [[] for _ in range(N)]
edge_order = []
for i in range(N-1):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
g[a].app... | 28 | 32 | 509 | 772 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n = int(input())
g = [[] for _ in range(n)]
for i in range(n - 1):
a, b = map(int, input().split())
a, b = a - 1, b - 1
g[a].append((b, i))
g[b].append((a, i))
ans = [0] * (n - 1)
def dfs(u, c=-1, p=-1):
k = 1
for v, i in g[u]... | from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
def main():
N = int(eval(input()))
g = [[] for _ in range(N)]
edge_order = []
for i in range(N - 1):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
g[a].append((i, b))
... | false | 12.5 | [
"+from collections import deque",
"-n = int(input())",
"-g = [[] for _ in range(n)]",
"-for i in range(n - 1):",
"- a, b = map(int, input().split())",
"- a, b = a - 1, b - 1",
"- g[a].append((b, i))",
"- g[b].append((a, i))",
"-ans = [0] * (n - 1)",
"-def dfs(u, c=-1, p=-1):",
"- ... | false | 0.038998 | 0.038723 | 1.007103 | [
"s453403015",
"s221367619"
] |
u198440493 | p03200 | python | s562010018 | s174739131 | 59 | 46 | 3,500 | 3,500 | Accepted | Accepted | 22.03 | c=eval(input())
n=0
ans=0
for i in range(len(c)-1,-1,-1):
if c[i]=='W':
n+=1
else:
ans+=n
print(ans) | c=eval(input())
n=0
ans=0
for x in c:
if x=='B':
n+=1
else:
ans+=n
print(ans) | 9 | 9 | 114 | 91 | c = eval(input())
n = 0
ans = 0
for i in range(len(c) - 1, -1, -1):
if c[i] == "W":
n += 1
else:
ans += n
print(ans)
| c = eval(input())
n = 0
ans = 0
for x in c:
if x == "B":
n += 1
else:
ans += n
print(ans)
| false | 0 | [
"-for i in range(len(c) - 1, -1, -1):",
"- if c[i] == \"W\":",
"+for x in c:",
"+ if x == \"B\":"
] | false | 0.090346 | 0.036257 | 2.491805 | [
"s562010018",
"s174739131"
] |
u937642029 | p02720 | python | s138681341 | s893192668 | 1,332 | 664 | 110,896 | 114,140 | Accepted | Accepted | 50.15 | import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
... | import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
... | 53 | 41 | 1,345 | 1,175 | import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod ... | import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod ... | false | 22.641509 | [
"- last = int(x[-1]) + i",
"- if int(\"\".join(x)) <= 3234566667 and last != -1 and last != 10:",
"- y = copy.copy(x)",
"- y.append(str(last))",
"- f(y)",
"- return",
"+ last = (x % 10) + i",
"+ if x <= 3234566667 and last != -1 and last ... | false | 1.215267 | 0.468957 | 2.591423 | [
"s138681341",
"s893192668"
] |
u340781749 | p02564 | python | s814557376 | s290565836 | 2,505 | 2,076 | 245,624 | 241,996 | Accepted | Accepted | 17.13 | import os
import sys
import numpy as np
def solve(inp):
def dfs(links, s, checked, postorder):
stack = [0, s]
while stack:
i, v = stack[-2:]
if i == 0 and checked[v]:
stack.pop()
stack.pop()
continue
... | import os
import sys
import numpy as np
def solve(inp):
def scc_dfs1(links, s, stack, checked, postorder, pi):
stack[0] = 0
stack[1] = s
si = 2
while si > 0:
i = stack[si - 2]
v = stack[si - 1]
if i == 0 and checked[v]:
... | 100 | 112 | 2,346 | 2,770 | import os
import sys
import numpy as np
def solve(inp):
def dfs(links, s, checked, postorder):
stack = [0, s]
while stack:
i, v = stack[-2:]
if i == 0 and checked[v]:
stack.pop()
stack.pop()
continue
checked[v] = 1... | import os
import sys
import numpy as np
def solve(inp):
def scc_dfs1(links, s, stack, checked, postorder, pi):
stack[0] = 0
stack[1] = s
si = 2
while si > 0:
i = stack[si - 2]
v = stack[si - 1]
if i == 0 and checked[v]:
si -= 2
... | false | 10.714286 | [
"- def dfs(links, s, checked, postorder):",
"- stack = [0, s]",
"- while stack:",
"- i, v = stack[-2:]",
"+ def scc_dfs1(links, s, stack, checked, postorder, pi):",
"+ stack[0] = 0",
"+ stack[1] = s",
"+ si = 2",
"+ while si > 0:",
"+ ... | false | 0.252166 | 0.222767 | 1.131972 | [
"s814557376",
"s290565836"
] |
u777283665 | p03986 | python | s472483797 | s586058594 | 340 | 67 | 3,752 | 4,328 | Accepted | Accepted | 80.29 | x = eval(input())
ans = ""
for i in x:
ans += i
if len(ans) >= 2 and (ans[-2] == "S" and ans[-1] == "T"):
ans = ans[:-2]
print((len(ans))) | x = eval(input())
s = list()
cnt = 0
for c in x:
if c == "S":
s.append(c)
elif c == "T" and len(s) != 0:
s.pop()
cnt += 1
print((len(x)-cnt*2)) | 9 | 12 | 148 | 180 | x = eval(input())
ans = ""
for i in x:
ans += i
if len(ans) >= 2 and (ans[-2] == "S" and ans[-1] == "T"):
ans = ans[:-2]
print((len(ans)))
| x = eval(input())
s = list()
cnt = 0
for c in x:
if c == "S":
s.append(c)
elif c == "T" and len(s) != 0:
s.pop()
cnt += 1
print((len(x) - cnt * 2))
| false | 25 | [
"-ans = \"\"",
"-for i in x:",
"- ans += i",
"- if len(ans) >= 2 and (ans[-2] == \"S\" and ans[-1] == \"T\"):",
"- ans = ans[:-2]",
"-print((len(ans)))",
"+s = list()",
"+cnt = 0",
"+for c in x:",
"+ if c == \"S\":",
"+ s.append(c)",
"+ elif c == \"T\" and len(s) != 0... | false | 0.042242 | 0.034734 | 1.216163 | [
"s472483797",
"s586058594"
] |
u130900604 | p03476 | python | s899046872 | s137633499 | 1,421 | 1,076 | 73,432 | 54,492 | Accepted | Accepted | 24.28 | from functools import lru_cache
@lru_cache(maxsize=None)
def is_prime(x):
if x==1:
return False
for i in range(2,int(x**0.5)+1):
if x%i==0:
return False
return True
# @lru_cache(maxsize=None)
def like2017(x):
return is_prime(i) and is_prime((i+1)//2)
table... | #from functools import lru_cache
#@lru_cache(maxsize=None)
def is_prime(x):
if x==1:
return False
for i in range(2,int(x**0.5)+1):
if x%i==0:
return False
return True
# @lru_cache(maxsize=None)
def like2017(x):
return is_prime(i) and is_prime((i+1)//2)
tab... | 23 | 23 | 517 | 519 | from functools import lru_cache
@lru_cache(maxsize=None)
def is_prime(x):
if x == 1:
return False
for i in range(2, int(x**0.5) + 1):
if x % i == 0:
return False
return True
# @lru_cache(maxsize=None)
def like2017(x):
return is_prime(i) and is_prime((i + 1) // 2)
table ... | # from functools import lru_cache
# @lru_cache(maxsize=None)
def is_prime(x):
if x == 1:
return False
for i in range(2, int(x**0.5) + 1):
if x % i == 0:
return False
return True
# @lru_cache(maxsize=None)
def like2017(x):
return is_prime(i) and is_prime((i + 1) // 2)
tabl... | false | 0 | [
"-from functools import lru_cache",
"-",
"-",
"-@lru_cache(maxsize=None)",
"+# from functools import lru_cache",
"+# @lru_cache(maxsize=None)"
] | false | 0.370554 | 1.088137 | 0.34054 | [
"s899046872",
"s137633499"
] |
u759412327 | p02837 | python | s115778245 | s287885753 | 241 | 83 | 3,064 | 9,196 | Accepted | Accepted | 65.56 | n,ans=int(eval(input())),0
xy=[[list(map(int,input().split())) for _ in range(int(eval(input())))] for _ in range(n)]
for i in range(2**n):
f=True
for j in range(n):
if (i>>j)&1:
for x,y in xy[j]:
if (i>>(x-1))&1!=y:
f=False
break
if f:
ans=max(an... | from itertools import *
N = int(eval(input()))
H = []
A = []
for i in range(N):
for j in range(int(eval(input()))):
x,y = list(map(int, input().split()))
H+=[[i,x-1,y]]
for P in product([0,1],repeat=N):
for h in H:
if P[h[0]]==1 and P[h[1]]!=h[2]:
break
else:
A+=[sum(P)]
... | 13 | 18 | 349 | 315 | n, ans = int(eval(input())), 0
xy = [
[list(map(int, input().split())) for _ in range(int(eval(input())))]
for _ in range(n)
]
for i in range(2**n):
f = True
for j in range(n):
if (i >> j) & 1:
for x, y in xy[j]:
if (i >> (x - 1)) & 1 != y:
f = Fal... | from itertools import *
N = int(eval(input()))
H = []
A = []
for i in range(N):
for j in range(int(eval(input()))):
x, y = list(map(int, input().split()))
H += [[i, x - 1, y]]
for P in product([0, 1], repeat=N):
for h in H:
if P[h[0]] == 1 and P[h[1]] != h[2]:
break
else... | false | 27.777778 | [
"-n, ans = int(eval(input())), 0",
"-xy = [",
"- [list(map(int, input().split())) for _ in range(int(eval(input())))]",
"- for _ in range(n)",
"-]",
"-for i in range(2**n):",
"- f = True",
"- for j in range(n):",
"- if (i >> j) & 1:",
"- for x, y in xy[j]:",
"- ... | false | 0.077287 | 0.040967 | 1.886549 | [
"s115778245",
"s287885753"
] |
u868600519 | p03086 | python | s815577289 | s571133658 | 21 | 19 | 3,188 | 3,188 | Accepted | Accepted | 9.52 | import re
S = eval(input())
l = re.findall(r'[ACGT]+', S)
if l:
print((max(list(map(len, l)))))
else:
print((0)) | import re
S = eval(input())
l = re.findall(r'[ACGT]+', S)
print((max(list(map(len, l))) if l else 0))
| 8 | 5 | 108 | 93 | import re
S = eval(input())
l = re.findall(r"[ACGT]+", S)
if l:
print((max(list(map(len, l)))))
else:
print((0))
| import re
S = eval(input())
l = re.findall(r"[ACGT]+", S)
print((max(list(map(len, l))) if l else 0))
| false | 37.5 | [
"-if l:",
"- print((max(list(map(len, l)))))",
"-else:",
"- print((0))",
"+print((max(list(map(len, l))) if l else 0))"
] | false | 0.104271 | 0.051545 | 2.022926 | [
"s815577289",
"s571133658"
] |
u537962130 | p03828 | python | s563057851 | s612176101 | 200 | 82 | 38,512 | 74,824 | Accepted | Accepted | 59 | def kaijo(n):
k=1
for i in range(n):
k*=i+1
return k
def yaku(n):
b=2
l=[]
while n>1:
while n%b==0:
l.append(b)
n//=b
b+=1
ls=set(l)
ans=[(i,l.count(i)) for i in ls]
return ans
def resolve():
n=int(e... | def soin(n):
ans=[]
l=int(n**0.5)+1
for i in range(2,l+1):
if n%i==0:
a=[i,0]
while n%i==0:
n//=i
a[1]+=1
ans+=[a]
if n>1:
ans+=[[n,1]]
return ans
d={}
n=int(eval(input()))
for i in range(2,n+1):
a=soin(i)
for j in a:
if j[0] in d:
d[j[0]]+=j[1]
else:
d[j[0]]=j... | 27 | 26 | 431 | 375 | def kaijo(n):
k = 1
for i in range(n):
k *= i + 1
return k
def yaku(n):
b = 2
l = []
while n > 1:
while n % b == 0:
l.append(b)
n //= b
b += 1
ls = set(l)
ans = [(i, l.count(i)) for i in ls]
return ans
def resolve():
n = int(eva... | def soin(n):
ans = []
l = int(n**0.5) + 1
for i in range(2, l + 1):
if n % i == 0:
a = [i, 0]
while n % i == 0:
n //= i
a[1] += 1
ans += [a]
if n > 1:
ans += [[n, 1]]
return ans
d = {}
n = int(eval(input()))
for i ... | false | 3.703704 | [
"-def kaijo(n):",
"- k = 1",
"- for i in range(n):",
"- k *= i + 1",
"- return k",
"-",
"-",
"-def yaku(n):",
"- b = 2",
"- l = []",
"- while n > 1:",
"- while n % b == 0:",
"- l.append(b)",
"- n //= b",
"- b += 1",
"- ls ... | false | 0.038258 | 0.036067 | 1.060768 | [
"s563057851",
"s612176101"
] |
u906501980 | p03329 | python | s891040270 | s162228828 | 306 | 182 | 3,060 | 40,944 | Accepted | Accepted | 40.52 | n = int(eval(input()))
ans = n
for i in range(n+1):
count = 0
num = i
while num > 0:
count += num % 6
num //= 6
num = n - i
while num > 0:
count += num % 9
num //= 9
ans = min(ans, count)
print(ans) | def main():
n = int(eval(input()))
dp = [None]*(n+1)
dp[0] = 0
dp[1] = 1
nl = list(sorted([6**i for i in range(10) if (6**i)<=n]+[9**i for i in range(1, 10) if (9**i)<=n]))
for i in range(2, n+1):
d = 10**15
for j in nl:
if j > i:
break
... | 14 | 17 | 261 | 422 | n = int(eval(input()))
ans = n
for i in range(n + 1):
count = 0
num = i
while num > 0:
count += num % 6
num //= 6
num = n - i
while num > 0:
count += num % 9
num //= 9
ans = min(ans, count)
print(ans)
| def main():
n = int(eval(input()))
dp = [None] * (n + 1)
dp[0] = 0
dp[1] = 1
nl = list(
sorted(
[6**i for i in range(10) if (6**i) <= n]
+ [9**i for i in range(1, 10) if (9**i) <= n]
)
)
for i in range(2, n + 1):
d = 10**15
for j in nl:... | false | 17.647059 | [
"-n = int(eval(input()))",
"-ans = n",
"-for i in range(n + 1):",
"- count = 0",
"- num = i",
"- while num > 0:",
"- count += num % 6",
"- num //= 6",
"- num = n - i",
"- while num > 0:",
"- count += num % 9",
"- num //= 9",
"- ans = min(ans, cou... | false | 0.069637 | 0.072654 | 0.958478 | [
"s891040270",
"s162228828"
] |
u280938208 | p03317 | python | s394147431 | s701595906 | 40 | 17 | 13,812 | 2,940 | Accepted | Accepted | 57.5 | import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))
print((math.ceil((N-1)/(K-1))))
| N, K = list(map(int, input().split()))
print(((N-1)//(K-1)+bool((N-1)%(K-1))))
| 6 | 2 | 129 | 78 | import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))
print((math.ceil((N - 1) / (K - 1))))
| N, K = list(map(int, input().split()))
print(((N - 1) // (K - 1) + bool((N - 1) % (K - 1))))
| false | 66.666667 | [
"-import math",
"-",
"-a_list = list(map(int, input().split()))",
"-print((math.ceil((N - 1) / (K - 1))))",
"+print(((N - 1) // (K - 1) + bool((N - 1) % (K - 1))))"
] | false | 0.079495 | 0.076975 | 1.032733 | [
"s394147431",
"s701595906"
] |
u002539468 | p02843 | python | s584393741 | s470002010 | 1,513 | 17 | 3,064 | 3,064 | Accepted | Accepted | 98.88 | x = int(eval(input()))
max_a = (x // 100) + 1
max_b = (x // 101) + 1
max_c = (x // 102) + 1
max_d = (x // 103) + 1
max_e = (x // 104) + 1
for a in range(max_a):
for b in range(max_b):
for c in range(max_c):
for d in range(max_d):
for e in range(max_e):
for_f = x - (a * 100 +... | x = int(eval(input()))
c = int(x / 100)
# print(c)
for i in range(c * 100, c * 105 + 1):
if i == x:
print((1))
exit(0)
print((0))
| 19 | 9 | 508 | 139 | x = int(eval(input()))
max_a = (x // 100) + 1
max_b = (x // 101) + 1
max_c = (x // 102) + 1
max_d = (x // 103) + 1
max_e = (x // 104) + 1
for a in range(max_a):
for b in range(max_b):
for c in range(max_c):
for d in range(max_d):
for e in range(max_e):
for_f =... | x = int(eval(input()))
c = int(x / 100)
# print(c)
for i in range(c * 100, c * 105 + 1):
if i == x:
print((1))
exit(0)
print((0))
| false | 52.631579 | [
"-max_a = (x // 100) + 1",
"-max_b = (x // 101) + 1",
"-max_c = (x // 102) + 1",
"-max_d = (x // 103) + 1",
"-max_e = (x // 104) + 1",
"-for a in range(max_a):",
"- for b in range(max_b):",
"- for c in range(max_c):",
"- for d in range(max_d):",
"- for e in rang... | false | 0.093933 | 0.069028 | 1.360797 | [
"s584393741",
"s470002010"
] |
u774160580 | p02995 | python | s005438990 | s996915937 | 170 | 35 | 38,384 | 5,048 | Accepted | Accepted | 79.41 | def main():
A, B, C, D = list(map(int, input().split()))
candiv_C = num_can_div(A, B, C)
candiv_D = num_can_div(A, B, D)
candiv_lcm = num_can_div(A, B, lcm(C, D))
print((B-A+1 - candiv_C - candiv_D + candiv_lcm))
def num_can_div(A, B, x):
return B//x - (A-1)//x
def gcd(a, b):
... | import fractions as f
A, B, C, D = list(map(int, input().split()))
A = A - 1
lcmCD = C * D // f.gcd(C, D)
underB = B - B // C - B // D + B // lcmCD
underA = A - A // C - A // D + A // lcmCD
print((underB - underA))
| 20 | 8 | 425 | 221 | def main():
A, B, C, D = list(map(int, input().split()))
candiv_C = num_can_div(A, B, C)
candiv_D = num_can_div(A, B, D)
candiv_lcm = num_can_div(A, B, lcm(C, D))
print((B - A + 1 - candiv_C - candiv_D + candiv_lcm))
def num_can_div(A, B, x):
return B // x - (A - 1) // x
def gcd(a, b):
w... | import fractions as f
A, B, C, D = list(map(int, input().split()))
A = A - 1
lcmCD = C * D // f.gcd(C, D)
underB = B - B // C - B // D + B // lcmCD
underA = A - A // C - A // D + A // lcmCD
print((underB - underA))
| false | 60 | [
"-def main():",
"- A, B, C, D = list(map(int, input().split()))",
"- candiv_C = num_can_div(A, B, C)",
"- candiv_D = num_can_div(A, B, D)",
"- candiv_lcm = num_can_div(A, B, lcm(C, D))",
"- print((B - A + 1 - candiv_C - candiv_D + candiv_lcm))",
"+import fractions as f",
"-",
"-def nu... | false | 0.035407 | 0.043718 | 0.809889 | [
"s005438990",
"s996915937"
] |
u940780117 | p03331 | python | s796832493 | s944140510 | 143 | 122 | 3,060 | 9,104 | Accepted | Accepted | 14.69 | def sum_of_digits(n):
mod=0
num=[]
while n !=0:
mod=n%10
n=n//10
num.append(mod)
return (sum(num))
N=int(eval(input()))
sum_of_all =0
for i in range(1,N//2+2):
sum1=sum_of_digits(i)
sum2=sum_of_digits(N-i)
sum_of_all=sum1+sum2
if i ==1:
ans=sum_of_all
elif ans>sum_of_all:
ans=sum_o... | def dig_sum(N):
ans=0
while N>0:
ans+=N%10
N=N//10
return ans
N=int(eval(input()))
ans=100
for i in range(1,N):
tmp=dig_sum(i)+dig_sum(N-i)
if tmp<ans:
ans=tmp
print(ans)
| 22 | 14 | 338 | 223 | def sum_of_digits(n):
mod = 0
num = []
while n != 0:
mod = n % 10
n = n // 10
num.append(mod)
return sum(num)
N = int(eval(input()))
sum_of_all = 0
for i in range(1, N // 2 + 2):
sum1 = sum_of_digits(i)
sum2 = sum_of_digits(N - i)
sum_of_all = sum1 + sum2
if i =... | def dig_sum(N):
ans = 0
while N > 0:
ans += N % 10
N = N // 10
return ans
N = int(eval(input()))
ans = 100
for i in range(1, N):
tmp = dig_sum(i) + dig_sum(N - i)
if tmp < ans:
ans = tmp
print(ans)
| false | 36.363636 | [
"-def sum_of_digits(n):",
"- mod = 0",
"- num = []",
"- while n != 0:",
"- mod = n % 10",
"- n = n // 10",
"- num.append(mod)",
"- return sum(num)",
"+def dig_sum(N):",
"+ ans = 0",
"+ while N > 0:",
"+ ans += N % 10",
"+ N = N // 10",
"... | false | 0.083342 | 0.435523 | 0.19136 | [
"s796832493",
"s944140510"
] |
u605879293 | p02388 | python | s169019541 | s458131482 | 30 | 20 | 7,660 | 7,580 | Accepted | Accepted | 33.33 | x = int(eval(input()))
print((x*x*x)) | x = int(eval(input()))
print((x ** 3)) | 2 | 2 | 30 | 31 | x = int(eval(input()))
print((x * x * x))
| x = int(eval(input()))
print((x**3))
| false | 0 | [
"-print((x * x * x))",
"+print((x**3))"
] | false | 0.035952 | 0.037704 | 0.953545 | [
"s169019541",
"s458131482"
] |
u759412327 | p03102 | python | s102558425 | s806637565 | 304 | 30 | 20,728 | 9,160 | Accepted | Accepted | 90.13 | import numpy as np
N,M,C = list(map(int,input().split()))
B = np.array(input().split(),dtype=np.int)
A = np.array([input().split() for _ in range(N)],dtype=np.int)
answer = (((A*B).sum(axis=1)+C)>0).sum()
print(answer)
| N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
a = 0
for n in range(N):
A = list(map(int,input().split()))
if 0<sum([a*b for a,b in zip(A,B)])+C:
a+=1
print(a) | 6 | 10 | 218 | 199 | import numpy as np
N, M, C = list(map(int, input().split()))
B = np.array(input().split(), dtype=np.int)
A = np.array([input().split() for _ in range(N)], dtype=np.int)
answer = (((A * B).sum(axis=1) + C) > 0).sum()
print(answer)
| N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
for n in range(N):
A = list(map(int, input().split()))
if 0 < sum([a * b for a, b in zip(A, B)]) + C:
a += 1
print(a)
| false | 40 | [
"-import numpy as np",
"-",
"-B = np.array(input().split(), dtype=np.int)",
"-A = np.array([input().split() for _ in range(N)], dtype=np.int)",
"-answer = (((A * B).sum(axis=1) + C) > 0).sum()",
"-print(answer)",
"+B = list(map(int, input().split()))",
"+a = 0",
"+for n in range(N):",
"+ A = li... | false | 0.355345 | 0.041722 | 8.516958 | [
"s102558425",
"s806637565"
] |
u509621775 | p02936 | python | s499821057 | s901944863 | 1,061 | 950 | 58,996 | 58,512 | Accepted | Accepted | 10.46 | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tre... | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tre... | 38 | 38 | 896 | 892 | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tree[a].append(b)
... | from sys import stdin, setrecursionlimit
from collections import deque
def main():
setrecursionlimit(2000001)
n, q = [int(x) for x in stdin.readline().split()]
tree = [[] for _ in range(n + 1)]
for _ in range(n - 1):
a, b = [int(x) for x in stdin.readline().split()]
tree[a].append(b)
... | false | 0 | [
"- parent, current = queue.popleft()",
"+ parent, current = queue.pop()"
] | false | 0.064738 | 0.065506 | 0.988283 | [
"s499821057",
"s901944863"
] |
u130900604 | p02935 | python | s654940454 | s974330697 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | from heapq import *
n=int(eval(input()))
inputs=lambda:list(map(int,input().split()))
v=inputs()
u=[]
for i in v:
heappush(u,i)
for j in range(n-1):
a1=heappop(u)
a2=heappop(u)
ave=(a1+a2)/2
heappush(u,ave)
print((u[0]))
| n=int(eval(input()))
v=sorted(list(map(int,input().split())),reverse=False)
#print(v)
ave=v.pop(0)
while True:
tmp=v.pop(0)
ave=(ave+tmp)*0.5
if len(v)==0:
print(ave)
exit()
| 15 | 11 | 236 | 194 | from heapq import *
n = int(eval(input()))
inputs = lambda: list(map(int, input().split()))
v = inputs()
u = []
for i in v:
heappush(u, i)
for j in range(n - 1):
a1 = heappop(u)
a2 = heappop(u)
ave = (a1 + a2) / 2
heappush(u, ave)
print((u[0]))
| n = int(eval(input()))
v = sorted(list(map(int, input().split())), reverse=False)
# print(v)
ave = v.pop(0)
while True:
tmp = v.pop(0)
ave = (ave + tmp) * 0.5
if len(v) == 0:
print(ave)
exit()
| false | 26.666667 | [
"-from heapq import *",
"-",
"-inputs = lambda: list(map(int, input().split()))",
"-v = inputs()",
"-u = []",
"-for i in v:",
"- heappush(u, i)",
"-for j in range(n - 1):",
"- a1 = heappop(u)",
"- a2 = heappop(u)",
"- ave = (a1 + a2) / 2",
"- heappush(u, ave)",
"-print((u[0]))... | false | 0.049498 | 0.050575 | 0.978702 | [
"s654940454",
"s974330697"
] |
u279493135 | p03450 | python | s014163963 | s924667115 | 1,131 | 994 | 76,484 | 112,852 | Accepted | Accepted | 12.11 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upp... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upp... | 46 | 94 | 1,214 | 2,579 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase... | false | 51.06383 | [
"+",
"+",
"+class WeightedUnionFind:",
"+ def __init__(self, n_nodes):",
"+ self.n_nodes = n_nodes",
"+ self.parents = [-1] * n_nodes",
"+ # 親への重みを管理",
"+ self.weights = [0] * n_nodes",
"+",
"+ def find(self, x):",
"+ if self.parents[x] < 0:",
"+ ... | false | 0.04438 | 0.045811 | 0.968753 | [
"s014163963",
"s924667115"
] |
u550146922 | p02731 | python | s943411396 | s577853112 | 34 | 28 | 9,732 | 8,972 | Accepted | Accepted | 17.65 | from math import floor
from decimal import Decimal
L = Decimal(eval(input()))
print((L**3/27))
| l=int(eval(input()))
print((l**3/27))
| 6 | 2 | 94 | 31 | from math import floor
from decimal import Decimal
L = Decimal(eval(input()))
print((L**3 / 27))
| l = int(eval(input()))
print((l**3 / 27))
| false | 66.666667 | [
"-from math import floor",
"-from decimal import Decimal",
"-",
"-L = Decimal(eval(input()))",
"-print((L**3 / 27))",
"+l = int(eval(input()))",
"+print((l**3 / 27))"
] | false | 0.071217 | 0.036004 | 1.978004 | [
"s943411396",
"s577853112"
] |
u273010357 | p03645 | python | s881613945 | s967619344 | 824 | 750 | 55,208 | 48,144 | Accepted | Accepted | 8.98 | from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
a,b = list(map(int, input().split()))
d[a].append(b)
for i,j in list(d.items()):
if i!=1:
continue
for k in j:
if N in d[k]:
print('POSSIBLE')
... | from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
a,b = list(map(int, input().split()))
d[a].append(b)
for j in d[1]:
if N in d[j]:
print('POSSIBLE')
exit()
print('IMPOSSIBLE') | 15 | 12 | 344 | 270 | from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
a, b = list(map(int, input().split()))
d[a].append(b)
for i, j in list(d.items()):
if i != 1:
continue
for k in j:
if N in d[k]:
print("POSSIBLE")
... | from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
a, b = list(map(int, input().split()))
d[a].append(b)
for j in d[1]:
if N in d[j]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
| false | 20 | [
"-for i, j in list(d.items()):",
"- if i != 1:",
"- continue",
"- for k in j:",
"- if N in d[k]:",
"- print(\"POSSIBLE\")",
"- exit()",
"+for j in d[1]:",
"+ if N in d[j]:",
"+ print(\"POSSIBLE\")",
"+ exit()"
] | false | 0.039649 | 0.036939 | 1.073371 | [
"s881613945",
"s967619344"
] |
u761320129 | p02802 | python | s000310248 | s305599365 | 322 | 261 | 48,920 | 38,292 | Accepted | Accepted | 18.94 | N,M = list(map(int,input().split()))
ps = [input().split() for i in range(M)]
from collections import defaultdict
acs = set()
penas = defaultdict(lambda: 0)
for p,s in ps:
if p in acs: continue
if s=='AC':
acs.add(p)
else:
penas[p] += 1
pena = 0
for p in acs:
pena += penas... | N,M = list(map(int,input().split()))
PS = [input().split() for i in range(M)]
penas = {}
acs = set()
pena = 0
for p,s in PS:
if s=='AC':
if p in acs: continue
acs.add(p)
if p in penas:
pena += penas[p]
else:
if p in penas:
penas[p] += 1
... | 16 | 17 | 340 | 371 | N, M = list(map(int, input().split()))
ps = [input().split() for i in range(M)]
from collections import defaultdict
acs = set()
penas = defaultdict(lambda: 0)
for p, s in ps:
if p in acs:
continue
if s == "AC":
acs.add(p)
else:
penas[p] += 1
pena = 0
for p in acs:
pena += penas[... | N, M = list(map(int, input().split()))
PS = [input().split() for i in range(M)]
penas = {}
acs = set()
pena = 0
for p, s in PS:
if s == "AC":
if p in acs:
continue
acs.add(p)
if p in penas:
pena += penas[p]
else:
if p in penas:
penas[p] += 1
... | false | 5.882353 | [
"-ps = [input().split() for i in range(M)]",
"-from collections import defaultdict",
"-",
"+PS = [input().split() for i in range(M)]",
"+penas = {}",
"-penas = defaultdict(lambda: 0)",
"-for p, s in ps:",
"- if p in acs:",
"- continue",
"+pena = 0",
"+for p, s in PS:",
"+ if p... | false | 0.048163 | 0.047282 | 1.018619 | [
"s000310248",
"s305599365"
] |
u403301154 | p03721 | python | s072448051 | s843920704 | 409 | 369 | 14,948 | 5,912 | Accepted | Accepted | 9.78 | n, k = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
a, b = list(map(int, input().split()))
d[a] += b
for ele in sorted(d.items()):
k -= ele[1]
if k<=0:
print((ele[0]))
break | n, k = list(map(int, input().split()))
d = [0 for i in range(100010)]
for i in range(n):
a, b = list(map(int, input().split()))
d[a] += b
for j, e in enumerate(d):
k -= e
if k<=0:
print(j)
break | 11 | 12 | 260 | 223 | n, k = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
a, b = list(map(int, input().split()))
d[a] += b
for ele in sorted(d.items()):
k -= ele[1]
if k <= 0:
print((ele[0]))
break
| n, k = list(map(int, input().split()))
d = [0 for i in range(100010)]
for i in range(n):
a, b = list(map(int, input().split()))
d[a] += b
for j, e in enumerate(d):
k -= e
if k <= 0:
print(j)
break
| false | 8.333333 | [
"-from collections import defaultdict",
"-",
"-d = defaultdict(int)",
"+d = [0 for i in range(100010)]",
"-for ele in sorted(d.items()):",
"- k -= ele[1]",
"+for j, e in enumerate(d):",
"+ k -= e",
"- print((ele[0]))",
"+ print(j)"
] | false | 0.090155 | 0.113136 | 0.796868 | [
"s072448051",
"s843920704"
] |
u263830634 | p03724 | python | s474774021 | s403454553 | 313 | 161 | 3,828 | 3,828 | Accepted | Accepted | 48.56 | N, M = list(map(int, input().split()))
lst = [0] * (N + 1)
for _ in range(M):
a, b = list(map(int, input().split()))
lst[a] += 1
lst[b] += 1
for i in lst:
if i % 2 == 1:
print ('NO')
exit()
print ('YES') | import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
lst = [0] * (N + 1)
for _ in range(M):
a, b = list(map(int, input().split()))
lst[a] += 1
lst[b] += 1
for i in lst:
if i % 2 == 1:
print ('NO')
exit()
print ('YES') | 15 | 17 | 241 | 281 | N, M = list(map(int, input().split()))
lst = [0] * (N + 1)
for _ in range(M):
a, b = list(map(int, input().split()))
lst[a] += 1
lst[b] += 1
for i in lst:
if i % 2 == 1:
print("NO")
exit()
print("YES")
| import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
lst = [0] * (N + 1)
for _ in range(M):
a, b = list(map(int, input().split()))
lst[a] += 1
lst[b] += 1
for i in lst:
if i % 2 == 1:
print("NO")
exit()
print("YES")
| false | 11.764706 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.034812 | 0.036597 | 0.951238 | [
"s474774021",
"s403454553"
] |
u363610900 | p03610 | python | s418936264 | s988058718 | 21 | 17 | 4,268 | 3,188 | Accepted | Accepted | 19.05 | s = list(eval(input()))
print((''.join(s[::2]))) | s = eval(input())
print((s[0::2])) | 2 | 2 | 41 | 27 | s = list(eval(input()))
print(("".join(s[::2])))
| s = eval(input())
print((s[0::2]))
| false | 0 | [
"-s = list(eval(input()))",
"-print((\"\".join(s[::2])))",
"+s = eval(input())",
"+print((s[0::2]))"
] | false | 0.039199 | 0.049317 | 0.794826 | [
"s418936264",
"s988058718"
] |
u031722966 | p02754 | python | s145303177 | s387598684 | 155 | 17 | 12,496 | 2,940 | Accepted | Accepted | 89.03 | def main():
import numpy as numpy
import sys
n,a,b=list(map(int,sys.stdin.readline().split()))
print((a*(n//(a+b))+min(a,n%(a+b))))
main() | def main():
n,a,b = list(map(int,input().split()))
x = (n // (a + b) ) * a
y = n % (a + b)
ans = x + min(y,a)
print(ans)
main() | 10 | 7 | 169 | 148 | def main():
import numpy as numpy
import sys
n, a, b = list(map(int, sys.stdin.readline().split()))
print((a * (n // (a + b)) + min(a, n % (a + b))))
main()
| def main():
n, a, b = list(map(int, input().split()))
x = (n // (a + b)) * a
y = n % (a + b)
ans = x + min(y, a)
print(ans)
main()
| false | 30 | [
"- import numpy as numpy",
"- import sys",
"-",
"- n, a, b = list(map(int, sys.stdin.readline().split()))",
"- print((a * (n // (a + b)) + min(a, n % (a + b))))",
"+ n, a, b = list(map(int, input().split()))",
"+ x = (n // (a + b)) * a",
"+ y = n % (a + b)",
"+ ans = x + min(... | false | 0.073671 | 0.037176 | 1.981652 | [
"s145303177",
"s387598684"
] |
u796942881 | p03013 | python | s361600170 | s699831894 | 119 | 50 | 11,028 | 11,028 | Accepted | Accepted | 57.98 | from sys import stdin
INF = int(1e9+7)
def modadd(a, b):
# aとbを足した値をmodする(a + b mod p)
return (a + b) % INF
def main():
lines = stdin.readlines()
N = int(lines[0].split()[0])
M = [True] * (N + 1)
for i in map(int, lines[1:]):
M[i] = False
dp = [0] * (N + 1)
dp... | from sys import stdin
INF = int(1e9+7)
def modadd(a, b):
# aとbを足した値をmodする(a + b mod p)
return (a + b) % INF
def main():
lines = stdin.readlines()
N = int(lines[0].split()[0])
M = [True] * (N + 1)
for i in map(int, lines[1:]):
M[i] = False
dp = [0] * (N + 1)
dp... | 26 | 25 | 525 | 488 | from sys import stdin
INF = int(1e9 + 7)
def modadd(a, b):
# aとbを足した値をmodする(a + b mod p)
return (a + b) % INF
def main():
lines = stdin.readlines()
N = int(lines[0].split()[0])
M = [True] * (N + 1)
for i in map(int, lines[1:]):
M[i] = False
dp = [0] * (N + 1)
dp[0] = 1
f... | from sys import stdin
INF = int(1e9 + 7)
def modadd(a, b):
# aとbを足した値をmodする(a + b mod p)
return (a + b) % INF
def main():
lines = stdin.readlines()
N = int(lines[0].split()[0])
M = [True] * (N + 1)
for i in map(int, lines[1:]):
M[i] = False
dp = [0] * (N + 1)
dp[:2] = 1, 1 i... | false | 3.846154 | [
"- dp[0] = 1",
"- for cur in range(N + 1):",
"- for i in range(cur + 1, min(cur + 2, N) + 1):",
"- if M[i]:",
"- dp[i] = modadd(dp[cur], dp[i])",
"+ dp[:2] = 1, 1 if M[1] else 0",
"+ for i in range(2, N + 1):",
"+ if M[i]:",
"+ dp[i] = m... | false | 0.128831 | 0.071705 | 1.796688 | [
"s361600170",
"s699831894"
] |
u143051858 | p02891 | python | s143763688 | s707659494 | 31 | 27 | 9,236 | 9,232 | Accepted | Accepted | 12.9 | s = list(eval(input()))
k = int(eval(input()))
n = len(s)
res = 0
i = 1
if s.count(s[0]) == n: # 全て同じ
print((n*k//2))
exit()
while i < n:
if s[i-1] == s[i]:
res += 1
i +=1
i+=1
res *= k
if s[0] != s[n-1]:
print(res)
else:
a=0
b=0
v=s[0]
i=0
... | s = eval(input())
k = int(eval(input()))
n = len(s)
res = 0
i = 0
if s.count(s[0]) == n:#全て同じ文字
print((n*k//2))
exit()
while i < n-1:
if s[i] == s[i+1]:
res += 1
i += 1
i += 1
res *= k
if s[0] != s[n-1]: #先頭と末尾の文字が異なる
print(res)
else:
a = 0
b = 0
... | 31 | 31 | 467 | 488 | s = list(eval(input()))
k = int(eval(input()))
n = len(s)
res = 0
i = 1
if s.count(s[0]) == n: # 全て同じ
print((n * k // 2))
exit()
while i < n:
if s[i - 1] == s[i]:
res += 1
i += 1
i += 1
res *= k
if s[0] != s[n - 1]:
print(res)
else:
a = 0
b = 0
v = s[0]
i = 0
whi... | s = eval(input())
k = int(eval(input()))
n = len(s)
res = 0
i = 0
if s.count(s[0]) == n: # 全て同じ文字
print((n * k // 2))
exit()
while i < n - 1:
if s[i] == s[i + 1]:
res += 1
i += 1
i += 1
res *= k
if s[0] != s[n - 1]: # 先頭と末尾の文字が異なる
print(res)
else:
a = 0
b = 0
i = 0
... | false | 0 | [
"-s = list(eval(input()))",
"+s = eval(input())",
"-i = 1",
"-if s.count(s[0]) == n: # 全て同じ",
"+i = 0",
"+if s.count(s[0]) == n: # 全て同じ文字",
"-while i < n:",
"- if s[i - 1] == s[i]:",
"+while i < n - 1:",
"+ if s[i] == s[i + 1]:",
"-if s[0] != s[n - 1]:",
"+if s[0] != s[n - 1]: # 先頭と末尾... | false | 0.036351 | 0.036439 | 0.997591 | [
"s143763688",
"s707659494"
] |
u844005364 | p03162 | python | s255709112 | s127753074 | 520 | 252 | 44,148 | 24,308 | Accepted | Accepted | 51.54 |
n = int(eval(input()))
a = [[int(i) for i in input().split()] for j in range(n)]
def happy(n, a):
d = [[0] * 3 for j in range(n)]
for i in range(3):
d[0][i] = a[0][i]
for i in range(1, n):
d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0]
d[i][1] = max(d[i - 1][0], d[... | import sys
input = sys.stdin.readline
n = int(eval(input()))
abc = [[int(i) for i in input().split()] for j in range(n)]
def happy(n, abc):
da, db, dc = 0, 0, 0
for a, b, c in abc:
na = max(db, dc) + a
nb = max(dc, da) + b
nc = max(da, db) + c
da, db, dc = na, nb,... | 18 | 18 | 444 | 372 | n = int(eval(input()))
a = [[int(i) for i in input().split()] for j in range(n)]
def happy(n, a):
d = [[0] * 3 for j in range(n)]
for i in range(3):
d[0][i] = a[0][i]
for i in range(1, n):
d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i][0]
d[i][1] = max(d[i - 1][0], d[i - 1][2]) + a... | import sys
input = sys.stdin.readline
n = int(eval(input()))
abc = [[int(i) for i in input().split()] for j in range(n)]
def happy(n, abc):
da, db, dc = 0, 0, 0
for a, b, c in abc:
na = max(db, dc) + a
nb = max(dc, da) + b
nc = max(da, db) + c
da, db, dc = na, nb, nc
retur... | false | 0 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"-a = [[int(i) for i in input().split()] for j in range(n)]",
"+abc = [[int(i) for i in input().split()] for j in range(n)]",
"-def happy(n, a):",
"- d = [[0] * 3 for j in range(n)]",
"- for i in range(3):",
"- d[0][i] = a[0][i]",
"- ... | false | 0.036218 | 0.080535 | 0.449714 | [
"s255709112",
"s127753074"
] |
u374146618 | p02958 | python | s717659733 | s210996084 | 148 | 17 | 12,444 | 2,940 | Accepted | Accepted | 88.51 | import numpy as np
n = int(eval(input()))
p = np.array([int(_) for _ in input().split()])
pp = sorted(p)
dif = pp - p
non_zero = len(p)-np.count_nonzero(dif==0)
if (non_zero == 2) or (non_zero == 0):
print("YES")
else:
print("NO") | n = int(eval(input()))
p = [int(_) for _ in input().split()]
dif = 0
for idx, pp in enumerate(p, 1): # 1からidx
dif += (idx != pp)
if dif <= 2:
print("YES")
else:
print("NO") | 11 | 10 | 243 | 189 | import numpy as np
n = int(eval(input()))
p = np.array([int(_) for _ in input().split()])
pp = sorted(p)
dif = pp - p
non_zero = len(p) - np.count_nonzero(dif == 0)
if (non_zero == 2) or (non_zero == 0):
print("YES")
else:
print("NO")
| n = int(eval(input()))
p = [int(_) for _ in input().split()]
dif = 0
for idx, pp in enumerate(p, 1): # 1からidx
dif += idx != pp
if dif <= 2:
print("YES")
else:
print("NO")
| false | 9.090909 | [
"-import numpy as np",
"-",
"-p = np.array([int(_) for _ in input().split()])",
"-pp = sorted(p)",
"-dif = pp - p",
"-non_zero = len(p) - np.count_nonzero(dif == 0)",
"-if (non_zero == 2) or (non_zero == 0):",
"+p = [int(_) for _ in input().split()]",
"+dif = 0",
"+for idx, pp in enumerate(p, 1): ... | false | 0.181127 | 0.037641 | 4.812017 | [
"s717659733",
"s210996084"
] |
u700805562 | p02781 | python | s829727460 | s239263053 | 22 | 18 | 3,064 | 3,064 | Accepted | Accepted | 18.18 | n = int(eval(input()))
N = len(str(n))
k = int(eval(input()))
s = [int(i) for i in str(n)]
dpi = [[0]*(k+1) for _ in range(N+1)]
dpj = [[0]*(k+1) for _ in range(N+1)]
dpi[0][0] = 1
for i in range(N):
for j in range(k+1):
dpi[i+1][j] += dpi[i][j]*(s[i]==0)
dpj[i+1][j] += dpj[i][j]+dpi[i][j]... | n = eval(input())
k = int(eval(input()))
dp0 = [[0]*(k+1) for _ in range(len(n)+1)]
dp1 = [[0]*(k+1) for _ in range(len(n)+1)]
dp0[0][0] = 1
for i in range(len(n)):
for j in range(k+1):
if int(n[i]) == 0:
dp0[i+1][j] += dp0[i][j]
if int(n[i]) > 0:
dp1[i+1][j] += dp0... | 15 | 18 | 475 | 572 | n = int(eval(input()))
N = len(str(n))
k = int(eval(input()))
s = [int(i) for i in str(n)]
dpi = [[0] * (k + 1) for _ in range(N + 1)]
dpj = [[0] * (k + 1) for _ in range(N + 1)]
dpi[0][0] = 1
for i in range(N):
for j in range(k + 1):
dpi[i + 1][j] += dpi[i][j] * (s[i] == 0)
dpj[i + 1][j] += dpj[i][... | n = eval(input())
k = int(eval(input()))
dp0 = [[0] * (k + 1) for _ in range(len(n) + 1)]
dp1 = [[0] * (k + 1) for _ in range(len(n) + 1)]
dp0[0][0] = 1
for i in range(len(n)):
for j in range(k + 1):
if int(n[i]) == 0:
dp0[i + 1][j] += dp0[i][j]
if int(n[i]) > 0:
dp1[i + 1][j... | false | 16.666667 | [
"-n = int(eval(input()))",
"-N = len(str(n))",
"+n = eval(input())",
"-s = [int(i) for i in str(n)]",
"-dpi = [[0] * (k + 1) for _ in range(N + 1)]",
"-dpj = [[0] * (k + 1) for _ in range(N + 1)]",
"-dpi[0][0] = 1",
"-for i in range(N):",
"+dp0 = [[0] * (k + 1) for _ in range(len(n) + 1)]",
"+dp1 ... | false | 0.040392 | 0.096258 | 0.419622 | [
"s829727460",
"s239263053"
] |
u597374218 | p03469 | python | s417716313 | s611472259 | 28 | 24 | 8,956 | 9,088 | Accepted | Accepted | 14.29 | S = eval(input())
print(("2018"+S[4:])) | s=eval(input())
print((s.replace("2017","2018"))) | 2 | 2 | 32 | 42 | S = eval(input())
print(("2018" + S[4:]))
| s = eval(input())
print((s.replace("2017", "2018")))
| false | 0 | [
"-S = eval(input())",
"-print((\"2018\" + S[4:]))",
"+s = eval(input())",
"+print((s.replace(\"2017\", \"2018\")))"
] | false | 0.00765 | 0.039211 | 0.195104 | [
"s417716313",
"s611472259"
] |
u477977638 | p03569 | python | s681424531 | s678369855 | 48 | 44 | 9,276 | 9,244 | Accepted | Accepted | 8.33 | def main():
s = eval(input())
l = 0
r = len(s)-1
ans = 0
while l < r:
if s[l] == s[r]:
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
ans += 1
else:
... | """
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,in... | 23 | 55 | 421 | 834 | def main():
s = eval(input())
l = 0
r = len(s) - 1
ans = 0
while l < r:
if s[l] == s[r]:
l += 1
r -= 1
elif s[l] == "x":
l += 1
ans += 1
elif s[r] == "x":
r -= 1
ans += 1
else:
print((... | """
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
d... | false | 58.181818 | [
"+\"\"\"",
"+import sys",
"+read = sys.stdin.buffer.read",
"+input = sys.stdin.readline",
"+#input = sys.stdin.buffer.readline",
"+#sys.setrecursionlimit(10**9)",
"+#from functools import lru_cache",
"+def RD(): return sys.stdin.read()",
"+def II(): return int(input())",
"+def MI(): return map(int... | false | 0.035124 | 0.035894 | 0.978551 | [
"s681424531",
"s678369855"
] |
u075303794 | p03481 | python | s535299045 | s027272347 | 28 | 25 | 9,152 | 9,084 | Accepted | Accepted | 10.71 | X,Y=list(map(int,input().split()))
ans=0
for i in range(10000):
if X*2**i > Y:
print(i)
break | X,Y=list(map(int,input().split()))
ans=0
for i in range(100):
if X*(2**i) > Y:
print(i)
break | 6 | 6 | 102 | 102 | X, Y = list(map(int, input().split()))
ans = 0
for i in range(10000):
if X * 2**i > Y:
print(i)
break
| X, Y = list(map(int, input().split()))
ans = 0
for i in range(100):
if X * (2**i) > Y:
print(i)
break
| false | 0 | [
"-for i in range(10000):",
"- if X * 2**i > Y:",
"+for i in range(100):",
"+ if X * (2**i) > Y:"
] | false | 0.038891 | 0.043304 | 0.898092 | [
"s535299045",
"s027272347"
] |
u179169725 | p03241 | python | s728774553 | s550984715 | 495 | 20 | 40,044 | 3,188 | Accepted | Accepted | 95.96 | # https://atcoder.jp/contests/abc112/tasks/abc112_d
# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である
# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLE思想
N, M = list(map(int, input().split()))
ans = M // N
for a in range(ans, 0, -1):
if M % a == 0:
print(a)
exit()
| # https://atcoder.jp/contests/abc112/tasks/abc112_d
# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である
# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう→しなかった(コーナーケースに助けられた?)
# 2 999999937でTLEしてしまうのでこれは嘘解答
N, M = list(map(int, input().split()))
# 以下嘘解答
# ans = M // N
# for a in range(ans... | 17 | 60 | 316 | 1,206 | # https://atcoder.jp/contests/abc112/tasks/abc112_d
# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である
# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLE思想
N, M = list(map(int, input().split()))
ans = M // N
for a in range(ans, 0, -1):
if M % a == 0:
print(a)
exit()
| # https://atcoder.jp/contests/abc112/tasks/abc112_d
# 答えansの満たす条件
# ans<=M//Nである
# M%ans==0である
# 仮説:M//Nからansを--して、M%ans==0となるansが答え
# でももしN=2, M=10*9+7とかだったらTLEしそう→しなかった(コーナーケースに助けられた?)
# 2 999999937でTLEしてしまうのでこれは嘘解答
N, M = list(map(int, input().split()))
# 以下嘘解答
# ans = M // N
# for a in range(ans, 0, -1):
# if M... | false | 71.666667 | [
"-# でももしN=2, M=10*9+7とかだったらTLE思想",
"+# でももしN=2, M=10*9+7とかだったらTLEしそう→しなかった(コーナーケースに助けられた?)",
"+# 2 999999937でTLEしてしまうのでこれは嘘解答",
"-ans = M // N",
"-for a in range(ans, 0, -1):",
"- if M % a == 0:",
"- print(a)",
"- exit()",
"+# 以下嘘解答",
"+# ans = M // N",
"+# for a in range(ans, 0... | false | 0.081533 | 0.035311 | 2.308999 | [
"s728774553",
"s550984715"
] |
u332385682 | p03735 | python | s372844933 | s767157390 | 794 | 657 | 33,904 | 33,904 | Accepted | Accepted | 17.25 | import sys
from operator import itemgetter
inf = 1 << 30
def solve():
n = int(sys.stdin.readline())
# r_max = MAX, b_min = MIN にしたとき
r_max = b_max = 0
r_min = b_min = inf
p = []
for i in range(n):
xi, yi = list(map(int, sys.stdin.readline().split()))
... | import sys
from operator import itemgetter
inf = 1 << 30
def solve():
n = int(sys.stdin.readline())
# r_max = MAX, b_min = MIN にしたとき
r_max = b_max = 0
r_min = b_min = inf
p = []
for i in range(n):
xi, yi = list(map(int, sys.stdin.readline().split()))
... | 65 | 73 | 1,177 | 1,437 | import sys
from operator import itemgetter
inf = 1 << 30
def solve():
n = int(sys.stdin.readline())
# r_max = MAX, b_min = MIN にしたとき
r_max = b_max = 0
r_min = b_min = inf
p = []
for i in range(n):
xi, yi = list(map(int, sys.stdin.readline().split()))
if xi > yi:
xi... | import sys
from operator import itemgetter
inf = 1 << 30
def solve():
n = int(sys.stdin.readline())
# r_max = MAX, b_min = MIN にしたとき
r_max = b_max = 0
r_min = b_min = inf
p = []
for i in range(n):
xi, yi = list(map(int, sys.stdin.readline().split()))
if xi > yi:
xi... | false | 10.958904 | [
"+ # print('r_max = MAX, b_min = MIN -> ', ans1, file=sys.stderr)",
"+ # print(*p, sep='\\n', file=sys.stderr)",
"+ # print(b_min, b_max, b_max - b_min, file=sys.stderr)",
"- if p[i][1] < p[i + 1][0]:",
"+ if y_min < p[i + 1][0]:",
"+ # print('r_max = MAX, r_min = MIN ->', an... | false | 0.042505 | 0.042968 | 0.989234 | [
"s372844933",
"s767157390"
] |
u310335994 | p03853 | python | s782160519 | s854420475 | 40 | 18 | 4,600 | 3,060 | Accepted | Accepted | 55 | def main():
h, w = map(int, input().split())
c = list(list(input()) for i in range(h))
for i in range(2*h):
for j in range(w):
print(c[int(i/2)][j], end='')
print()
main()
| def main():
h, w = list(map(int, input().split()))
for i in range(h):
s = eval(input())
print((s + '\n' + s + '\n'))
main()
| 10 | 8 | 223 | 143 | def main():
h, w = map(int, input().split())
c = list(list(input()) for i in range(h))
for i in range(2 * h):
for j in range(w):
print(c[int(i / 2)][j], end="")
print()
main()
| def main():
h, w = list(map(int, input().split()))
for i in range(h):
s = eval(input())
print((s + "\n" + s + "\n"))
main()
| false | 20 | [
"- h, w = map(int, input().split())",
"- c = list(list(input()) for i in range(h))",
"- for i in range(2 * h):",
"- for j in range(w):",
"- print(c[int(i / 2)][j], end=\"\")",
"- print()",
"+ h, w = list(map(int, input().split()))",
"+ for i in range(h):",
"+ ... | false | 0.117269 | 0.046585 | 2.517305 | [
"s782160519",
"s854420475"
] |
u472065247 | p03798 | python | s693176433 | s367083766 | 110 | 69 | 5,620 | 5,636 | Accepted | Accepted | 37.27 | N = int(eval(input()))
s = eval(input())
s += s[0]
# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
l = [a0, a1]
for c in s[1:]:
if c == 'o':
a0, a1 = a1, not (a0 ^ a1)
else:
a0, a1 = a1, (a0 ^ a1)
l.append(a1)
if (l[0] == l[-2]) and (l[1] == l[-1]):
prin... | def main():
N = int(eval(input()))
s = eval(input())
s += s[0]
# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
l = [a0, a1]
for c in s[1:]:
if c == 'o':
a0, a1 = a1, not (a0 ^ a1)
else:
a0, a1 = a1, (a0 ^ a1)
l.append(a1)
if (l[0] =... | 20 | 24 | 383 | 468 | N = int(eval(input()))
s = eval(input())
s += s[0]
# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
l = [a0, a1]
for c in s[1:]:
if c == "o":
a0, a1 = a1, not (a0 ^ a1)
else:
a0, a1 = a1, (a0 ^ a1)
l.append(a1)
if (l[0] == l[-2]) and (l[1] == l[-1]... | def main():
N = int(eval(input()))
s = eval(input())
s += s[0]
# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
l = [a0, a1]
for c in s[1:]:
if c == "o":
a0, a1 = a1, not (a0 ^ a1)
else:
a0, a1 = a1, (a0 ^ a1)
... | false | 16.666667 | [
"-N = int(eval(input()))",
"-s = eval(input())",
"-s += s[0]",
"-# S: 1, W: 0",
"-for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):",
"- l = [a0, a1]",
"- for c in s[1:]:",
"- if c == \"o\":",
"- a0, a1 = a1, not (a0 ^ a1)",
"- else:",
"- a0, a1 = a1, (a0 ... | false | 0.089613 | 0.045842 | 1.954805 | [
"s693176433",
"s367083766"
] |
u519968172 | p03077 | python | s594642587 | s206488192 | 30 | 27 | 9,052 | 9,076 | Accepted | Accepted | 10 | n=int(eval(input()))
m=10**15+1
mi=0
for i in range(5):
a=int(eval(input()))
if a<m:
m=a
mi=i
print(((n-1)//m+1+5-1)) | n=int(eval(input()))
m=10**15+1
a=[int(eval(input())) for _ in range(5)]
print(((n-1)//min(a)+5)) | 9 | 4 | 123 | 86 | n = int(eval(input()))
m = 10**15 + 1
mi = 0
for i in range(5):
a = int(eval(input()))
if a < m:
m = a
mi = i
print(((n - 1) // m + 1 + 5 - 1))
| n = int(eval(input()))
m = 10**15 + 1
a = [int(eval(input())) for _ in range(5)]
print(((n - 1) // min(a) + 5))
| false | 55.555556 | [
"-mi = 0",
"-for i in range(5):",
"- a = int(eval(input()))",
"- if a < m:",
"- m = a",
"- mi = i",
"-print(((n - 1) // m + 1 + 5 - 1))",
"+a = [int(eval(input())) for _ in range(5)]",
"+print(((n - 1) // min(a) + 5))"
] | false | 0.037413 | 0.03595 | 1.040694 | [
"s594642587",
"s206488192"
] |
u392319141 | p03731 | python | s527806238 | s811873496 | 150 | 122 | 25,200 | 25,528 | Accepted | Accepted | 18.67 | N, T = list(map(int, input().split()))
time = list(map(int, input().split()))
time.append(float('inf'))
ans = 0
for i in range(N):
ans += min(T, time[i + 1] - time[i])
print(ans) | import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')
def sol():
N, T = list(map(int, input().split()))
pus... | 9 | 22 | 186 | 471 | N, T = list(map(int, input().split()))
time = list(map(int, input().split()))
time.append(float("inf"))
ans = 0
for i in range(N):
ans += min(T, time[i + 1] - time[i])
print(ans)
| import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")
def sol():
N, T = list(map(int, input().split()))
push = list(map... | false | 59.090909 | [
"-N, T = list(map(int, input().split()))",
"-time = list(map(int, input().split()))",
"-time.append(float(\"inf\"))",
"-ans = 0",
"-for i in range(N):",
"- ans += min(T, time[i + 1] - time[i])",
"-print(ans)",
"+import sys",
"+import heapq",
"+from operator import itemgetter",
"+from collecti... | false | 0.046338 | 0.046204 | 1.002898 | [
"s527806238",
"s811873496"
] |
u761320129 | p03551 | python | s180994365 | s878039554 | 601 | 17 | 2,940 | 2,940 | Accepted | Accepted | 97.17 | N,M = list(map(int,input().split()))
t = M * 1900 + (N-M) * 100
ac_rate = 1 / (2**M)
rate = 1.0
ans = 0.0
for n in range(1,1000000):
ans += rate * ac_rate * t * n
rate *= (1 - ac_rate)
print((round(ans)))
| N,M = list(map(int,input().split()))
p = 2**M
ans = p * (1900*M + 100*(N-M))
print(ans) | 9 | 5 | 213 | 86 | N, M = list(map(int, input().split()))
t = M * 1900 + (N - M) * 100
ac_rate = 1 / (2**M)
rate = 1.0
ans = 0.0
for n in range(1, 1000000):
ans += rate * ac_rate * t * n
rate *= 1 - ac_rate
print((round(ans)))
| N, M = list(map(int, input().split()))
p = 2**M
ans = p * (1900 * M + 100 * (N - M))
print(ans)
| false | 44.444444 | [
"-t = M * 1900 + (N - M) * 100",
"-ac_rate = 1 / (2**M)",
"-rate = 1.0",
"-ans = 0.0",
"-for n in range(1, 1000000):",
"- ans += rate * ac_rate * t * n",
"- rate *= 1 - ac_rate",
"-print((round(ans)))",
"+p = 2**M",
"+ans = p * (1900 * M + 100 * (N - M))",
"+print(ans)"
] | false | 1.686261 | 0.03884 | 43.41542 | [
"s180994365",
"s878039554"
] |
u440566786 | p02720 | python | s207411854 | s658493579 | 224 | 184 | 43,376 | 40,688 | Accepted | Accepted | 17.86 | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def bisection(l,r,f,left=True,discrete=True):
eps=1 if(discrete) else 10**-8
if((not left)^f(r)): return r if(left) else r+1
elif(left^f(l))... | from collections import deque
k = int(eval(input()))
Q = deque()
for i in range(1, 10):
Q.append(i)
for _ in range(k-1):
a = Q.popleft()
d = a % 10
if d != 0:
Q.append(10 * a + d - 1)
Q.append(10 * a + d)
if d != 9:
Q.append(10 * a + d + 1)
print((Q.popleft())) | 47 | 16 | 1,457 | 290 | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda: sys.stdin.readline().rstrip()
from itertools import product
def bisection(l, r, f, left=True, discrete=True):
eps = 1 if (discrete) else 10**-8
if (not left) ^ f(r):
return r if (left) else r ... | from collections import deque
k = int(eval(input()))
Q = deque()
for i in range(1, 10):
Q.append(i)
for _ in range(k - 1):
a = Q.popleft()
d = a % 10
if d != 0:
Q.append(10 * a + d - 1)
Q.append(10 * a + d)
if d != 9:
Q.append(10 * a + d + 1)
print((Q.popleft()))
| false | 65.957447 | [
"-import sys",
"+from collections import deque",
"-sys.setrecursionlimit(2147483647)",
"-INF = float(\"inf\")",
"-MOD = 10**9 + 7 # 998244353",
"-input = lambda: sys.stdin.readline().rstrip()",
"-from itertools import product",
"-",
"-",
"-def bisection(l, r, f, left=True, discrete=True):",
"- ... | false | 0.05455 | 0.07516 | 0.725794 | [
"s207411854",
"s658493579"
] |
u141786930 | p02848 | python | s388631974 | s751538072 | 27 | 21 | 3,444 | 3,188 | Accepted | Accepted | 22.22 | from collections import deque
def main():
N = int(eval(input()))
S = deque(eval(input()))
A = ['A','B','C','D','E','F','G','H','I','J','K',
'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = deque()
while len(S)>0:
s = S.popleft()
i = A.index(s... | def main():
N = int(eval(input()))
S = list(ord(x) - ord('A') for x in eval(input()))
ans = list(chr((N+x)%26 + ord('A')) for x in S)
print((''.join(ans)))
if __name__ == '__main__':
main() | 19 | 9 | 409 | 205 | from collections import deque
def main():
N = int(eval(input()))
S = deque(eval(input()))
A = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
... | def main():
N = int(eval(input()))
S = list(ord(x) - ord("A") for x in eval(input()))
ans = list(chr((N + x) % 26 + ord("A")) for x in S)
print(("".join(ans)))
if __name__ == "__main__":
main()
| false | 52.631579 | [
"-from collections import deque",
"-",
"-",
"- S = deque(eval(input()))",
"- A = [",
"- \"A\",",
"- \"B\",",
"- \"C\",",
"- \"D\",",
"- \"E\",",
"- \"F\",",
"- \"G\",",
"- \"H\",",
"- \"I\",",
"- \"J\",",
"- ... | false | 0.048706 | 0.045519 | 1.07001 | [
"s388631974",
"s751538072"
] |
u315703650 | p04011 | python | s436725826 | s523538927 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | N,K,X,Y = [int(eval(input())) for _ in range(4)]
cnt = 0
for i in range(N):
if i<K:
cnt += X
else:
cnt += Y
print(cnt) | n,k,x,y = [int(eval(input())) for _ in range(4)]
if n>k:
print((k*x+(n-k)*y))
else:
print((n*x))
| 8 | 5 | 143 | 99 | N, K, X, Y = [int(eval(input())) for _ in range(4)]
cnt = 0
for i in range(N):
if i < K:
cnt += X
else:
cnt += Y
print(cnt)
| n, k, x, y = [int(eval(input())) for _ in range(4)]
if n > k:
print((k * x + (n - k) * y))
else:
print((n * x))
| false | 37.5 | [
"-N, K, X, Y = [int(eval(input())) for _ in range(4)]",
"-cnt = 0",
"-for i in range(N):",
"- if i < K:",
"- cnt += X",
"- else:",
"- cnt += Y",
"-print(cnt)",
"+n, k, x, y = [int(eval(input())) for _ in range(4)]",
"+if n > k:",
"+ print((k * x + (n - k) * y))",
"+else:... | false | 0.043233 | 0.056257 | 0.76848 | [
"s436725826",
"s523538927"
] |
u198440493 | p03108 | python | s900196991 | s640761529 | 557 | 455 | 40,184 | 40,268 | Accepted | Accepted | 18.31 | n,m=list(map(int,input().split()))
l=[-1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[n*(n-1)//2]
def r(s):
t=l[s]
if t<0:
return s
else:
l[s]=r(t)
return l[s]
def f(s):
return r(int(s)-1)
for i in range(m-1,-1,-1):
x,y=list(map(f,b[i]))
s,t=0,0
if x!=y:
s,t=l[x],l[y]... | import sys
n,m=list(map(int,input().split()))
l=[-1]*n
b=[sys.stdin.readline().split() for _ in range(m)]
c=[0]*m+[n*(n-1)//2]
def r(s):
t=l[s]
if t<0:
return s
else:
l[s]=r(t)
return l[s]
def f(s):
return r(int(s)-1)
for i in range(m-1,-1,-1):
x,y=list(map(f,b[i]))
s,t=0,0
if... | 27 | 28 | 438 | 463 | n, m = list(map(int, input().split()))
l = [-1] * n
b = [input().split() for _ in range(m)]
c = [0] * m + [n * (n - 1) // 2]
def r(s):
t = l[s]
if t < 0:
return s
else:
l[s] = r(t)
return l[s]
def f(s):
return r(int(s) - 1)
for i in range(m - 1, -1, -1):
x, y = list(map... | import sys
n, m = list(map(int, input().split()))
l = [-1] * n
b = [sys.stdin.readline().split() for _ in range(m)]
c = [0] * m + [n * (n - 1) // 2]
def r(s):
t = l[s]
if t < 0:
return s
else:
l[s] = r(t)
return l[s]
def f(s):
return r(int(s) - 1)
for i in range(m - 1, -1,... | false | 3.571429 | [
"+import sys",
"+",
"-b = [input().split() for _ in range(m)]",
"+b = [sys.stdin.readline().split() for _ in range(m)]"
] | false | 0.037755 | 0.007847 | 4.81119 | [
"s900196991",
"s640761529"
] |
u674052742 | p02682 | python | s968463050 | s599117308 | 23 | 21 | 9,116 | 9,176 | Accepted | Accepted | 8.7 | # -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:54:25 2020
@author: Kanaru Sato
"""
a,b,c,k = list(map(int,input().split()))
if a>=k:
print(k)
else:
k = k-a
if b>= k:
print(a)
else:
k = k-b
print((a-k)) | # -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:35:24 2020
@author: Kanaru Sato
"""
a,b,c,k = list(map(int,input().split()))
if k <= a:
print(k)
elif a<k and k<=a+b:
print(a)
else:
print((a-k+(a+b)))
| 18 | 15 | 265 | 232 | # -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:54:25 2020
@author: Kanaru Sato
"""
a, b, c, k = list(map(int, input().split()))
if a >= k:
print(k)
else:
k = k - a
if b >= k:
print(a)
else:
k = k - b
print((a - k))
| # -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:35:24 2020
@author: Kanaru Sato
"""
a, b, c, k = list(map(int, input().split()))
if k <= a:
print(k)
elif a < k and k <= a + b:
print(a)
else:
print((a - k + (a + b)))
| false | 16.666667 | [
"-Created on Sun May 10 20:54:25 2020",
"+Created on Fri May 15 00:35:24 2020",
"-if a >= k:",
"+if k <= a:",
"+elif a < k and k <= a + b:",
"+ print(a)",
"- k = k - a",
"- if b >= k:",
"- print(a)",
"- else:",
"- k = k - b",
"- print((a - k))",
"+ print((... | false | 0.098012 | 0.040753 | 2.405046 | [
"s968463050",
"s599117308"
] |
u054514819 | p02603 | python | s942224244 | s549772992 | 262 | 63 | 96,704 | 61,204 | Accepted | Accepted | 75.95 | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
As = list(mapint())
memo = {}
s = set()
ans = 0
def dfs(idx, money, stocks):
global ans
if idx==N:
ans = max(ans, money)
... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
As = list(mapint())
money = 1000
for i in range(1, N):
if As[i]>As[i-1]:
money += (money//As[i-1])*(As[i]-As[i-1])
print(money) | 30 | 12 | 645 | 304 | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
As = list(mapint())
memo = {}
s = set()
ans = 0
def dfs(idx, money, stocks):
global ans
if idx == N:
ans = max(ans, money)
... | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N = int(eval(input()))
As = list(mapint())
money = 1000
for i in range(1, N):
if As[i] > As[i - 1]:
money += (money // As[i - 1]) * (As[i] - As[i - 1])
... | false | 60 | [
"-memo = {}",
"-s = set()",
"-ans = 0",
"-",
"-",
"-def dfs(idx, money, stocks):",
"- global ans",
"- if idx == N:",
"- ans = max(ans, money)",
"- return",
"- a = As[idx]",
"- if (idx, stocks) in s:",
"- if money <= memo[(idx, stocks)]:",
"- retu... | false | 0.066468 | 0.037138 | 1.789769 | [
"s942224244",
"s549772992"
] |
u200887663 | p02971 | python | s568657480 | s523878121 | 681 | 556 | 20,828 | 14,112 | Accepted | Accepted | 18.36 | n=int(eval(input()))
#l=[int(input()) for i in range(n)]
l=[]
mydic={}
for i in range(n) :
s=int(eval(input()))
l.append(s)
if not s in list(mydic.keys()) :
mydic[s]=1
else :
mydic[s]=mydic[s]+1
l2=sorted(l,reverse=True)
#print(l)
#print(mydic)
mx=l2[0]
for i in range(n) :
if l[i]==mx ... | n=int(eval(input()))
dic={}
mx=0
al=[]
for i in range(n):
a=int(eval(input()))
al.append(a)
order=sorted(al,reverse=True)
mx1=order[0]
mx2=order[1]
for a in al:
if a==mx1:
print(mx2)
else:
print(mx1)
| 23 | 17 | 399 | 238 | n = int(eval(input()))
# l=[int(input()) for i in range(n)]
l = []
mydic = {}
for i in range(n):
s = int(eval(input()))
l.append(s)
if not s in list(mydic.keys()):
mydic[s] = 1
else:
mydic[s] = mydic[s] + 1
l2 = sorted(l, reverse=True)
# print(l)
# print(mydic)
mx = l2[0]
for i in range(... | n = int(eval(input()))
dic = {}
mx = 0
al = []
for i in range(n):
a = int(eval(input()))
al.append(a)
order = sorted(al, reverse=True)
mx1 = order[0]
mx2 = order[1]
for a in al:
if a == mx1:
print(mx2)
else:
print(mx1)
| false | 26.086957 | [
"-# l=[int(input()) for i in range(n)]",
"-l = []",
"-mydic = {}",
"+dic = {}",
"+mx = 0",
"+al = []",
"- s = int(eval(input()))",
"- l.append(s)",
"- if not s in list(mydic.keys()):",
"- mydic[s] = 1",
"+ a = int(eval(input()))",
"+ al.append(a)",
"+order = sorted(al, ... | false | 0.040306 | 0.035502 | 1.135317 | [
"s568657480",
"s523878121"
] |
u378157957 | p03545 | python | s690950727 | s789108225 | 31 | 26 | 9,160 | 9,060 | Accepted | Accepted | 16.13 | import operator
vals = eval(input())
nums = list(map(int, tuple(vals)))
def dump(a,b,c):
if a == operator.add:
a = '+'
else:
a = '-'
if b == operator.add:
b = '+'
else:
b = '-'
if c == operator.add:
c = '+'
else:
c = '-'
pri... | nums = eval(input())
N = 3
for i in range(2**N):
equation = ''
for j in range(N):
equation += nums[j]
if ((i >> j) & 1):
equation += '+'
else:
equation += '-'
equation += nums[-1]
if eval(equation) == 7:
print((equation + '=7'))
... | 26 | 15 | 630 | 322 | import operator
vals = eval(input())
nums = list(map(int, tuple(vals)))
def dump(a, b, c):
if a == operator.add:
a = "+"
else:
a = "-"
if b == operator.add:
b = "+"
else:
b = "-"
if c == operator.add:
c = "+"
else:
c = "-"
print((vals[0] + a... | nums = eval(input())
N = 3
for i in range(2**N):
equation = ""
for j in range(N):
equation += nums[j]
if (i >> j) & 1:
equation += "+"
else:
equation += "-"
equation += nums[-1]
if eval(equation) == 7:
print((equation + "=7"))
exit()
| false | 42.307692 | [
"-import operator",
"-",
"-vals = eval(input())",
"-nums = list(map(int, tuple(vals)))",
"-",
"-",
"-def dump(a, b, c):",
"- if a == operator.add:",
"- a = \"+\"",
"- else:",
"- a = \"-\"",
"- if b == operator.add:",
"- b = \"+\"",
"- else:",
"- b ... | false | 0.104057 | 0.047842 | 2.175018 | [
"s690950727",
"s789108225"
] |
u332906195 | p03088 | python | s537886207 | s224685358 | 166 | 96 | 3,188 | 3,064 | Accepted | Accepted | 42.17 | # -*- coding: utf-8 -*-
import itertools
comb = list(map(''.join, itertools.product("ACGT", repeat=4)))
N = int(eval(input()))
dp = {c: [0, 0] for c in comb}
dp["TTTT"] = [1, 0]
for _ in range(N):
dp_new = {c: [0, 0] for c in comb}
for k in dp:
for b in "ACGT":
if k[2:4] + ... | # -*- coding: utf-8 -*-
N = int(eval(input()))
dp = {b: 1 for b in "ACGT"}
for _ in range(N - 1):
dp_new = {}
for k in dp:
for b in "ACGT":
n = k[-3:] + b
if n[-3:] in ("AGC", "ACG", "GAC") or n in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):
con... | 23 | 20 | 683 | 534 | # -*- coding: utf-8 -*-
import itertools
comb = list(map("".join, itertools.product("ACGT", repeat=4)))
N = int(eval(input()))
dp = {c: [0, 0] for c in comb}
dp["TTTT"] = [1, 0]
for _ in range(N):
dp_new = {c: [0, 0] for c in comb}
for k in dp:
for b in "ACGT":
if k[2:4] + b in ("AGC", "ACG... | # -*- coding: utf-8 -*-
N = int(eval(input()))
dp = {b: 1 for b in "ACGT"}
for _ in range(N - 1):
dp_new = {}
for k in dp:
for b in "ACGT":
n = k[-3:] + b
if n[-3:] in ("AGC", "ACG", "GAC") or n in (
"ACGC",
"AGGC",
"ATGC",
... | false | 13.043478 | [
"-import itertools",
"-",
"-comb = list(map(\"\".join, itertools.product(\"ACGT\", repeat=4)))",
"-dp = {c: [0, 0] for c in comb}",
"-dp[\"TTTT\"] = [1, 0]",
"-for _ in range(N):",
"- dp_new = {c: [0, 0] for c in comb}",
"+dp = {b: 1 for b in \"ACGT\"}",
"+for _ in range(N - 1):",
"+ dp_new ... | false | 0.149719 | 0.072718 | 2.058894 | [
"s537886207",
"s224685358"
] |
u957872856 | p03814 | python | s062360890 | s853901562 | 69 | 18 | 4,840 | 3,500 | Accepted | Accepted | 73.91 | s = list(eval(input()))
a = 200000
z = 0
for i in range(len(s)):
if s[i] == 'A' and a > i:
a = i
if s[i] == 'Z' and z < i:
z = i
print((z - a + 1)) | s = eval(input())
print((len(s)-s[::-1].index("Z")-s.index("A"))) | 9 | 2 | 171 | 58 | s = list(eval(input()))
a = 200000
z = 0
for i in range(len(s)):
if s[i] == "A" and a > i:
a = i
if s[i] == "Z" and z < i:
z = i
print((z - a + 1))
| s = eval(input())
print((len(s) - s[::-1].index("Z") - s.index("A")))
| false | 77.777778 | [
"-s = list(eval(input()))",
"-a = 200000",
"-z = 0",
"-for i in range(len(s)):",
"- if s[i] == \"A\" and a > i:",
"- a = i",
"- if s[i] == \"Z\" and z < i:",
"- z = i",
"-print((z - a + 1))",
"+s = eval(input())",
"+print((len(s) - s[::-1].index(\"Z\") - s.index(\"A\")))"
] | false | 0.039289 | 0.039725 | 0.989027 | [
"s062360890",
"s853901562"
] |
u670180528 | p03044 | python | s648494691 | s891514363 | 397 | 326 | 49,396 | 49,396 | Accepted | Accepted | 17.88 | def solve():
from collections import deque
n,*l=map(int,open(0).read().split())
con=[[] for _ in range(n)]
dist=[None]*n
dist[0]=0
for a,b,c in zip(*[iter(l)]*3):
con[a-1].append((b-1,c%2))
con[b-1].append((a-1,c%2))
que=deque([0])
while que:
cur=que.popleft()
for nxt,d in con[cur]:
i... | def solve():
from collections import deque
n,*l=map(int,open(0).read().split())
con=[[] for _ in range(n)]
dist=[None]*n
dist[0]=0
for a,b,c in zip(*[iter(l)]*3):
con[a-1].append((b-1,c%2))
con[b-1].append((a-1,c%2))
stk=deque([0])
while stk:
cur=stk.pop()
for nxt,d in con[cur]:
if di... | 22 | 22 | 454 | 450 | def solve():
from collections import deque
n, *l = map(int, open(0).read().split())
con = [[] for _ in range(n)]
dist = [None] * n
dist[0] = 0
for a, b, c in zip(*[iter(l)] * 3):
con[a - 1].append((b - 1, c % 2))
con[b - 1].append((a - 1, c % 2))
que = deque([0])
while q... | def solve():
from collections import deque
n, *l = map(int, open(0).read().split())
con = [[] for _ in range(n)]
dist = [None] * n
dist[0] = 0
for a, b, c in zip(*[iter(l)] * 3):
con[a - 1].append((b - 1, c % 2))
con[b - 1].append((a - 1, c % 2))
stk = deque([0])
while s... | false | 0 | [
"- que = deque([0])",
"- while que:",
"- cur = que.popleft()",
"+ stk = deque([0])",
"+ while stk:",
"+ cur = stk.pop()",
"- que.append(nxt)",
"+ stk.append(nxt)"
] | false | 0.165328 | 0.115451 | 1.432021 | [
"s648494691",
"s891514363"
] |
u983918956 | p03194 | python | s137945350 | s241832365 | 323 | 124 | 3,060 | 3,064 | Accepted | Accepted | 61.61 | import math
N,P = list(map(int,input().split()))
b = math.floor(round(pow(P,1/N),10))
for i in range(b,0,-1):
if P % pow(i,N) == 0:
ans = i
break
print(ans) | import math
N,P = list(map(int,input().split()))
if N == 1:
print(P)
exit()
ans = 1
for i in range(2,math.floor(pow(P,1/2)) + 1):
if P % i == 0:
count = 1
P = P // i
while P % i == 0:
count += 1
P = P // i
ans *= pow(i,count // N)
print(a... | 8 | 15 | 177 | 317 | import math
N, P = list(map(int, input().split()))
b = math.floor(round(pow(P, 1 / N), 10))
for i in range(b, 0, -1):
if P % pow(i, N) == 0:
ans = i
break
print(ans)
| import math
N, P = list(map(int, input().split()))
if N == 1:
print(P)
exit()
ans = 1
for i in range(2, math.floor(pow(P, 1 / 2)) + 1):
if P % i == 0:
count = 1
P = P // i
while P % i == 0:
count += 1
P = P // i
ans *= pow(i, count // N)
print(ans)
| false | 46.666667 | [
"-b = math.floor(round(pow(P, 1 / N), 10))",
"-for i in range(b, 0, -1):",
"- if P % pow(i, N) == 0:",
"- ans = i",
"- break",
"+if N == 1:",
"+ print(P)",
"+ exit()",
"+ans = 1",
"+for i in range(2, math.floor(pow(P, 1 / 2)) + 1):",
"+ if P % i == 0:",
"+ coun... | false | 0.040812 | 0.082093 | 0.497149 | [
"s137945350",
"s241832365"
] |
u708618797 | p02919 | python | s538729721 | s696951745 | 1,282 | 777 | 115,368 | 83,432 | Accepted | Accepted | 39.39 | class WeightBalancedTree:
def __init__(self, q):
self.left = [0] * (q + 1)
self.right = [0] * (q + 1)
self.weight = [1] * (q + 1)
self.key = [None] * (q + 1)
self.last_index = 0
self.root = 0
# key 未満の最大値
def search_lower(self, key):
if key == ... | import time
import random
class TreapNode:
def __init__(self, key, pri):
self.left = None
self.right = None
self.key = key
self.pri = pri
class Treap:
def __init__(self):
self.nil = TreapNode(None, 0)
self.root = self.nil
def search_lower... | 143 | 122 | 4,157 | 3,166 | class WeightBalancedTree:
def __init__(self, q):
self.left = [0] * (q + 1)
self.right = [0] * (q + 1)
self.weight = [1] * (q + 1)
self.key = [None] * (q + 1)
self.last_index = 0
self.root = 0
# key 未満の最大値
def search_lower(self, key):
if key == None:
... | import time
import random
class TreapNode:
def __init__(self, key, pri):
self.left = None
self.right = None
self.key = key
self.pri = pri
class Treap:
def __init__(self):
self.nil = TreapNode(None, 0)
self.root = self.nil
def search_lower(self, key):
... | false | 14.685315 | [
"-class WeightBalancedTree:",
"- def __init__(self, q):",
"- self.left = [0] * (q + 1)",
"- self.right = [0] * (q + 1)",
"- self.weight = [1] * (q + 1)",
"- self.key = [None] * (q + 1)",
"- self.last_index = 0",
"- self.root = 0",
"+import time",
"+impo... | false | 0.03792 | 0.042199 | 0.8986 | [
"s538729721",
"s696951745"
] |
u503263570 | p00002 | python | s108834878 | s227320755 | 30 | 20 | 7,680 | 7,516 | Accepted | Accepted | 33.33 | import sys
a=[map(int,i.split()) for i in sys.stdin]
[print(len(str(b+c))) for b,c in a]
| import sys
for a in sys.stdin:
b,c=list(map(int,a.split()))
d=len(str(b+c))
print(d) | 3 | 5 | 90 | 94 | import sys
a = [map(int, i.split()) for i in sys.stdin]
[print(len(str(b + c))) for b, c in a]
| import sys
for a in sys.stdin:
b, c = list(map(int, a.split()))
d = len(str(b + c))
print(d)
| false | 40 | [
"-a = [map(int, i.split()) for i in sys.stdin]",
"-[print(len(str(b + c))) for b, c in a]",
"+for a in sys.stdin:",
"+ b, c = list(map(int, a.split()))",
"+ d = len(str(b + c))",
"+ print(d)"
] | false | 0.045747 | 0.036529 | 1.252336 | [
"s108834878",
"s227320755"
] |
u352394527 | p00450 | python | s593878714 | s226764933 | 350 | 300 | 5,616 | 5,624 | Accepted | Accepted | 14.29 | while True:
n = int(eval(input()))
if not n: break
count = 0
flag = -1
lst = [0]
for i in range(n):
a = int(eval(input()))
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.append(1)
flag = a
else:
if len(lst) == 1:
lst[-1] +=... | def main():
while True:
n = int(eval(input()))
if not n: break
flag = -1
lst = []
for i in range(n):
a = int(eval(input()))
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.append(1)
flag = a
else:
if len(lst... | 30 | 33 | 630 | 713 | while True:
n = int(eval(input()))
if not n:
break
count = 0
flag = -1
lst = [0]
for i in range(n):
a = int(eval(input()))
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.append(1)
flag = a
el... | def main():
while True:
n = int(eval(input()))
if not n:
break
flag = -1
lst = []
for i in range(n):
a = int(eval(input()))
if flag == a:
lst[-1] += 1
else:
if i % 2 == 0:
lst.... | false | 9.090909 | [
"-while True:",
"- n = int(eval(input()))",
"- if not n:",
"- break",
"- count = 0",
"- flag = -1",
"- lst = [0]",
"- for i in range(n):",
"- a = int(eval(input()))",
"- if flag == a:",
"- lst[-1] += 1",
"- else:",
"- if i %... | false | 0.039636 | 0.039273 | 1.009248 | [
"s593878714",
"s226764933"
] |
u813098295 | p03290 | python | s948448025 | s761467007 | 266 | 158 | 3,064 | 3,064 | Accepted | Accepted | 40.6 | D, G = list(map(int, input().split()))
P, C = [], []
for _ in range(D):
p, c = list(map(int, input().split()))
P.append(p); C.append(c)
ans = float('inf')
for bit in range(2**D):
is_solve = [ 0 for _ in range(D) ]
score, solve_num = 0, 0
# i 番目の bit が立っている => 100(i+1)点をつけられた p_i 問を全完す... | D, G = list(map(int, input().split()))
P, C = [], []
for _ in range(D):
p, c = list(map(int, input().split()))
P.append(p); C.append(c)
ans = float('inf')
for bit in range(2**D):
score, solve_num = 0, 0
for i in range(D):
if (bit >> i) & 1:
score += (100 * (i+1) * P... | 34 | 34 | 782 | 675 | D, G = list(map(int, input().split()))
P, C = [], []
for _ in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = float("inf")
for bit in range(2**D):
is_solve = [0 for _ in range(D)]
score, solve_num = 0, 0
# i 番目の bit が立っている => 100(i+1)点をつけられた p_i 問を全完する
for i in... | D, G = list(map(int, input().split()))
P, C = [], []
for _ in range(D):
p, c = list(map(int, input().split()))
P.append(p)
C.append(c)
ans = float("inf")
for bit in range(2**D):
score, solve_num = 0, 0
for i in range(D):
if (bit >> i) & 1:
score += 100 * (i + 1) * P[i] + C[i]
... | false | 0 | [
"- is_solve = [0 for _ in range(D)]",
"- # i 番目の bit が立っている => 100(i+1)点をつけられた p_i 問を全完する",
"- is_solve[i] += P[i]",
"- while is_solve[i] < P[i]:",
"+ if (bit >> i) & 1:",
"+ continue",
"+ for j in range(P[i]):",
"- is_solve[i] += 1"
] | false | 0.037097 | 0.04236 | 0.875751 | [
"s948448025",
"s761467007"
] |
u463655976 | p03053 | python | s067151352 | s859449826 | 820 | 679 | 153,308 | 133,084 | Accepted | Accepted | 17.2 | from collections import deque
H,W = list(map(int, input().split()))
A = 0
dp = [None] * H
mat = deque(maxlen=W*H)
for h in range(H):
s = list(eval(input()))
for w, x in zip(list(range(W)), s):
if x == "#":
mat.append((h, w, 0))
dp[h] = s
while len(mat):
h, w, cnt = mat.... | from collections import deque
H,W = list(map(int, input().split()))
A = 0
dp = [None] * H
mat = deque()
for h in range(H):
s = list(eval(input()))
for w, x in zip(list(range(W)), s):
if x == "#":
mat.append((h, w, 0))
s[w] = 1
else:
s[w] = 0
d... | 21 | 24 | 556 | 601 | from collections import deque
H, W = list(map(int, input().split()))
A = 0
dp = [None] * H
mat = deque(maxlen=W * H)
for h in range(H):
s = list(eval(input()))
for w, x in zip(list(range(W)), s):
if x == "#":
mat.append((h, w, 0))
dp[h] = s
while len(mat):
h, w, cnt = mat.popleft()
... | from collections import deque
H, W = list(map(int, input().split()))
A = 0
dp = [None] * H
mat = deque()
for h in range(H):
s = list(eval(input()))
for w, x in zip(list(range(W)), s):
if x == "#":
mat.append((h, w, 0))
s[w] = 1
else:
s[w] = 0
dp[h] = s
wh... | false | 12.5 | [
"-mat = deque(maxlen=W * H)",
"+mat = deque()",
"+ s[w] = 1",
"+ else:",
"+ s[w] = 0",
"- if t and dp[h][w] == \".\":",
"+ if t and dp[h][w] == 0:",
"- dp[h][w] = \"#\"",
"+ dp[h][w] = 1"
] | false | 0.041418 | 0.042611 | 0.972016 | [
"s067151352",
"s859449826"
] |
u644907318 | p03209 | python | s353601073 | s442196252 | 196 | 65 | 44,784 | 62,012 | Accepted | Accepted | 66.84 | def f(n):
if n==0:
return 1
return 2*f(n-1)+3
def g(n):
if n==0:
return 1
return 2*g(n-1)+1
def F(n,x):
if n==0:return 1
if x<=n:return 0
if x<=f(n-1)+1:
return F(n-1,x-1)
elif x==f(n-1)+2:
return g(n-1)+1
else:
return g(n-1)+1+... | memo1 = {}
def cho(n):
if n==0:
return 1
if n in memo1:
return memo1[n]
memo1[n] = 2*cho(n-1)+3
return memo1[n]
memo2 = {}
def pat(n):
if n==0:
return 1
if n in memo2:
return memo2[n]
memo2[n] = 2*pat(n-1)+1
return memo2[n]
N,X = list(map(i... | 19 | 38 | 384 | 705 | def f(n):
if n == 0:
return 1
return 2 * f(n - 1) + 3
def g(n):
if n == 0:
return 1
return 2 * g(n - 1) + 1
def F(n, x):
if n == 0:
return 1
if x <= n:
return 0
if x <= f(n - 1) + 1:
return F(n - 1, x - 1)
elif x == f(n - 1) + 2:
return... | memo1 = {}
def cho(n):
if n == 0:
return 1
if n in memo1:
return memo1[n]
memo1[n] = 2 * cho(n - 1) + 3
return memo1[n]
memo2 = {}
def pat(n):
if n == 0:
return 1
if n in memo2:
return memo2[n]
memo2[n] = 2 * pat(n - 1) + 1
return memo2[n]
N, X = l... | false | 50 | [
"-def f(n):",
"+memo1 = {}",
"+",
"+",
"+def cho(n):",
"- return 2 * f(n - 1) + 3",
"+ if n in memo1:",
"+ return memo1[n]",
"+ memo1[n] = 2 * cho(n - 1) + 3",
"+ return memo1[n]",
"-def g(n):",
"+memo2 = {}",
"+",
"+",
"+def pat(n):",
"- return 2 * g(n - 1) + 1",... | false | 0.063597 | 0.045045 | 1.41186 | [
"s353601073",
"s442196252"
] |
u891635666 | p03281 | python | s995239186 | s621511139 | 22 | 18 | 3,316 | 2,940 | Accepted | Accepted | 18.18 | import collections
n = int(eval(input()))
def eratosthenes(n):
sieve = [True for _ in range(n + 1)]
sieve[0] = False
sieve[1] = False
def _update(p):
if sieve[p]:
for i in range(p * 2, n + 1, p):
sieve[i] = False
_update(2)
p = 3
whil... | n = int(eval(input()))
res = 0
for k in range(1, n + 1, 2):
count = 0
for i in range(1, k + 1):
if k % i == 0:
count += 1
if count == 8:
res += 1
print(res) | 40 | 12 | 737 | 203 | import collections
n = int(eval(input()))
def eratosthenes(n):
sieve = [True for _ in range(n + 1)]
sieve[0] = False
sieve[1] = False
def _update(p):
if sieve[p]:
for i in range(p * 2, n + 1, p):
sieve[i] = False
_update(2)
p = 3
while p * p <= n:
... | n = int(eval(input()))
res = 0
for k in range(1, n + 1, 2):
count = 0
for i in range(1, k + 1):
if k % i == 0:
count += 1
if count == 8:
res += 1
print(res)
| false | 70 | [
"-import collections",
"-",
"-",
"-",
"-def eratosthenes(n):",
"- sieve = [True for _ in range(n + 1)]",
"- sieve[0] = False",
"- sieve[1] = False",
"-",
"- def _update(p):",
"- if sieve[p]:",
"- for i in range(p * 2, n + 1, p):",
"- sieve[i] = Fa... | false | 0.036769 | 0.036716 | 1.001459 | [
"s995239186",
"s621511139"
] |
u279266699 | p02832 | python | s106706015 | s782033995 | 242 | 111 | 77,516 | 32,260 | Accepted | Accepted | 54.13 | from collections import deque
n = int(eval(input()))
a = list(map(int, input().split()))
if 1 in a:
count = 0
num = 1
for i in a:
if num == i:
num += 1
else:
count += 1
print(count)
else:
print((-1))
| n = int(eval(input()))
A = list(map(int, input().split()))
i = 1
ans = 0
red = []
for a in A:
if a == i:
red += [i]
i += 1
else:
ans += 1
if not ans == len(A):
print(ans)
else:
print((-1)) | 16 | 16 | 269 | 236 | from collections import deque
n = int(eval(input()))
a = list(map(int, input().split()))
if 1 in a:
count = 0
num = 1
for i in a:
if num == i:
num += 1
else:
count += 1
print(count)
else:
print((-1))
| n = int(eval(input()))
A = list(map(int, input().split()))
i = 1
ans = 0
red = []
for a in A:
if a == i:
red += [i]
i += 1
else:
ans += 1
if not ans == len(A):
print(ans)
else:
print((-1))
| false | 0 | [
"-from collections import deque",
"-",
"-a = list(map(int, input().split()))",
"-if 1 in a:",
"- count = 0",
"- num = 1",
"- for i in a:",
"- if num == i:",
"- num += 1",
"- else:",
"- count += 1",
"- print(count)",
"+A = list(map(int, input().... | false | 0.06611 | 0.041623 | 1.588309 | [
"s106706015",
"s782033995"
] |
u393253137 | p02848 | python | s020991486 | s669148811 | 107 | 24 | 4,468 | 3,060 | Accepted | Accepted | 77.57 | L="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n=int(input())
s=input()
i=0
for j in s:
print(s.replace(j,L[(L.index(j)+n)%26])[i],end="")
i += 1
| n=int(eval(input()))
s=eval(input())
ans=""
for c in s:
ind = (ord(c)-ord("A")+n)%26
ans += chr(ord("A")+ind)
print(ans) | 7 | 7 | 143 | 122 | L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
s = input()
i = 0
for j in s:
print(s.replace(j, L[(L.index(j) + n) % 26])[i], end="")
i += 1
| n = int(eval(input()))
s = eval(input())
ans = ""
for c in s:
ind = (ord(c) - ord("A") + n) % 26
ans += chr(ord("A") + ind)
print(ans)
| false | 0 | [
"-L = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"-n = int(input())",
"-s = input()",
"-i = 0",
"-for j in s:",
"- print(s.replace(j, L[(L.index(j) + n) % 26])[i], end=\"\")",
"- i += 1",
"+n = int(eval(input()))",
"+s = eval(input())",
"+ans = \"\"",
"+for c in s:",
"+ ind = (ord(c) - ord(\"A\... | false | 0.041142 | 0.0438 | 0.939308 | [
"s020991486",
"s669148811"
] |
u181195295 | p03160 | python | s531799290 | s051391775 | 145 | 134 | 14,592 | 13,928 | Accepted | Accepted | 7.59 | N = int(eval(input()))
h = list(map(int,input().split()))
dp = [[] for i in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(1,N-1):
dp[i+1] = min( dp[i] + abs(h[i+1] - h[i]), dp[i-1] + abs(h[i+1] - h[i-1]))
print((dp[-1])) | n = int(eval(input()))
cost = [int(i) for i in input().split()]
dp = [0]*n
dp[1] = abs(cost[1] - cost[0])
for i in range(2, n):
be1 = abs(cost[i]-cost[i-1])
be2 = abs(cost[i]-cost[i-2])
dp[i] = min(dp[i-1]+be1, dp[i-2]+be2)
print((dp[-1])) | 11 | 12 | 241 | 253 | N = int(eval(input()))
h = list(map(int, input().split()))
dp = [[] for i in range(N)]
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(1, N - 1):
dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]))
print((dp[-1]))
| n = int(eval(input()))
cost = [int(i) for i in input().split()]
dp = [0] * n
dp[1] = abs(cost[1] - cost[0])
for i in range(2, n):
be1 = abs(cost[i] - cost[i - 1])
be2 = abs(cost[i] - cost[i - 2])
dp[i] = min(dp[i - 1] + be1, dp[i - 2] + be2)
print((dp[-1]))
| false | 8.333333 | [
"-N = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-dp = [[] for i in range(N)]",
"-dp[0] = 0",
"-dp[1] = abs(h[0] - h[1])",
"-for i in range(1, N - 1):",
"- dp[i + 1] = min(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]))",
"+n = int(eval(input()))",
"+cost = ... | false | 0.125923 | 0.091771 | 1.372145 | [
"s531799290",
"s051391775"
] |
u761320129 | p03645 | python | s553735572 | s243278444 | 658 | 432 | 37,192 | 42,872 | Accepted | Accepted | 34.35 | N,M = list(map(int,input().split()))
AB = [tuple(map(int,input().split())) for i in range(M)]
sa = set()
sb = set()
for a,b in AB:
if a==1:
sa.add(b)
if b==N:
sb.add(a)
s = sa & sb
print(('POSSIBLE' if len(s) else 'IMPOSSIBLE')) | N,M = list(map(int,input().split()))
AB = [tuple(map(int,input().split())) for i in range(M)]
s1 = set()
sn = set()
for a,b in AB:
if a==1:
s1.add(b)
if b==N:
sn.add(a)
print(('POSSIBLE' if s1&sn else 'IMPOSSIBLE')) | 11 | 12 | 254 | 244 | N, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(M)]
sa = set()
sb = set()
for a, b in AB:
if a == 1:
sa.add(b)
if b == N:
sb.add(a)
s = sa & sb
print(("POSSIBLE" if len(s) else "IMPOSSIBLE"))
| N, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(M)]
s1 = set()
sn = set()
for a, b in AB:
if a == 1:
s1.add(b)
if b == N:
sn.add(a)
print(("POSSIBLE" if s1 & sn else "IMPOSSIBLE"))
| false | 8.333333 | [
"-sa = set()",
"-sb = set()",
"+s1 = set()",
"+sn = set()",
"- sa.add(b)",
"+ s1.add(b)",
"- sb.add(a)",
"-s = sa & sb",
"-print((\"POSSIBLE\" if len(s) else \"IMPOSSIBLE\"))",
"+ sn.add(a)",
"+print((\"POSSIBLE\" if s1 & sn else \"IMPOSSIBLE\"))"
] | false | 0.042191 | 0.040641 | 1.038145 | [
"s553735572",
"s243278444"
] |
u599114793 | p02996 | python | s471007177 | s029287569 | 931 | 797 | 38,044 | 31,860 | Accepted | Accepted | 14.39 | n = int(eval(input()))
w = []
for i in range(n):
a,b = list(map(int,input().split()))
w.append([a,b])
w.sort(key=lambda x:x[1])
time = 0
for i in range(n):
time += w[i][0]
if time > w[i][1]:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
task = []
for i in range(n):
a,b = list(map(int,input().split()))
task.append((a,b))
task.sort(key=lambda x:x[1])
time = 0
deadline = 0
for i in range(n):
time += task[i][0]
deadline = task[i][1]
if time > deadline:
print("No")
exit()
print("Yes")... | 13 | 15 | 255 | 309 | n = int(eval(input()))
w = []
for i in range(n):
a, b = list(map(int, input().split()))
w.append([a, b])
w.sort(key=lambda x: x[1])
time = 0
for i in range(n):
time += w[i][0]
if time > w[i][1]:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
task = []
for i in range(n):
a, b = list(map(int, input().split()))
task.append((a, b))
task.sort(key=lambda x: x[1])
time = 0
deadline = 0
for i in range(n):
time += task[i][0]
deadline = task[i][1]
if time > deadline:
print("No")
exit()
print("Yes")
| false | 13.333333 | [
"-w = []",
"+task = []",
"- w.append([a, b])",
"-w.sort(key=lambda x: x[1])",
"+ task.append((a, b))",
"+task.sort(key=lambda x: x[1])",
"+deadline = 0",
"- time += w[i][0]",
"- if time > w[i][1]:",
"+ time += task[i][0]",
"+ deadline = task[i][1]",
"+ if time > deadline:"... | false | 0.108918 | 0.112542 | 0.967798 | [
"s471007177",
"s029287569"
] |
u075012704 | p03240 | python | s703235276 | s783644184 | 433 | 130 | 3,064 | 3,064 | Accepted | Accepted | 69.98 | N = int(eval(input()))
Info = [list(map(int, input().split())) for i in range(N)]
Info_nonzero = []
highest = 0
for x, y, h in Info:
if h != 0:
Info_nonzero.append([x, y, h])
for x, y, h in Info:
if h == 0:
highest = max(highest, x + y)
for Cx in range(101):
for Cy in range(10... | N = int(eval(input()))
Info = [list(map(int, input().split())) for i in range(N)]
for Cx in range(101):
for Cy in range(101):
H = None
for x, y, h in Info:
if h == 0:
continue
# hが0以外の情報からHを一意に定める
tmp_H = abs(Cx - x) + abs(Cy - y) + h
... | 33 | 29 | 988 | 775 | N = int(eval(input()))
Info = [list(map(int, input().split())) for i in range(N)]
Info_nonzero = []
highest = 0
for x, y, h in Info:
if h != 0:
Info_nonzero.append([x, y, h])
for x, y, h in Info:
if h == 0:
highest = max(highest, x + y)
for Cx in range(101):
for Cy in range(101):
can... | N = int(eval(input()))
Info = [list(map(int, input().split())) for i in range(N)]
for Cx in range(101):
for Cy in range(101):
H = None
for x, y, h in Info:
if h == 0:
continue
# hが0以外の情報からHを一意に定める
tmp_H = abs(Cx - x) + abs(Cy - y) + h
i... | false | 12.121212 | [
"-Info_nonzero = []",
"-highest = 0",
"-for x, y, h in Info:",
"- if h != 0:",
"- Info_nonzero.append([x, y, h])",
"-for x, y, h in Info:",
"- if h == 0:",
"- highest = max(highest, x + y)",
"- candidate_set = set()",
"- for x, y, h in Info_nonzero:",
"- ... | false | 0.042406 | 0.040687 | 1.042263 | [
"s703235276",
"s783644184"
] |
u729133443 | p03088 | python | s696854897 | s780016492 | 49 | 42 | 3,316 | 3,444 | Accepted | Accepted | 14.29 | n=int(eval(input()))
M,R=10**9+7,list(range(4))
dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]
dp[0][3][3][3]=1
for i in range(1,n+1):
for j in R:
for k in R:
for l in R:
for m in R:
if(2,0,1)!=(k,l,m)!=(0,1,2)!=(k,l,m)!=(0,2,1)!=(j,l,m)!=(0,2,1)!=(j,k,m):dp[i][k][l][m]=(dp... | n=int(eval(input()))
R=list(range(4))
dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]
dp[0][3][3][3]=1
for i in range(1,n+1):
for j in R:
for k in R:
for l in R:
for m in R:
if(2,0,1)!=(k,l,m)!=(0,1,2)!=(k,l,m)!=(0,2,1)!=(j,l,m)!=(0,2,1)!=(j,k,m):dp[i][k][l][m]+=dp[i-1][j][k... | 11 | 11 | 393 | 373 | n = int(eval(input()))
M, R = 10**9 + 7, list(range(4))
dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(1, n + 1):
for j in R:
for k in R:
for l in R:
for m in R:
if (
(2, 0, 1)
... | n = int(eval(input()))
R = list(range(4))
dp = [[[[0] * 4 for k in R] for j in R] for i in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(1, n + 1):
for j in R:
for k in R:
for l in R:
for m in R:
if (
(2, 0, 1)
... | false | 0 | [
"-M, R = 10**9 + 7, list(range(4))",
"+R = list(range(4))",
"- dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % M",
"-print((sum(c for a in dp[n] for b in a for c in b) % M))",
"+ dp[i][k][l][m] += dp[i - 1][j][k][l]",
"+print((sum(c for a in dp[n] for... | false | 0.052625 | 0.057369 | 0.917305 | [
"s696854897",
"s780016492"
] |
u285443936 | p03607 | python | s407051275 | s893496259 | 257 | 231 | 7,388 | 15,072 | Accepted | Accepted | 10.12 | N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
array = []
ans = 0
A.sort()
count = 0
for i in range(N):
count += 1
if i == N-1:
if count%2 == 1:
ans += 1
# print(A[i], count, ans)
# elif A[i] == A[i+1]:
# print(A[i], count, ans)
elif A[i] != A[i+1]:
... | N = int(eval(input()))
paper = {}
ans = 0
for i in range(N):
A = int(eval(input()))
if A in list(paper.keys()):
paper[A] += 1
else:
paper[A] = 1
for i in list(paper.values()):
if i%2 == 1:
ans += 1
print(ans) | 24 | 13 | 406 | 216 | N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
array = []
ans = 0
A.sort()
count = 0
for i in range(N):
count += 1
if i == N - 1:
if count % 2 == 1:
ans += 1
# print(A[i], count, ans)
# elif A[i] == A[i+1]:
# print(A[i], count, ans)
elif A[i] != A[i ... | N = int(eval(input()))
paper = {}
ans = 0
for i in range(N):
A = int(eval(input()))
if A in list(paper.keys()):
paper[A] += 1
else:
paper[A] = 1
for i in list(paper.values()):
if i % 2 == 1:
ans += 1
print(ans)
| false | 45.833333 | [
"-A = [int(eval(input())) for i in range(N)]",
"-array = []",
"+paper = {}",
"-A.sort()",
"-count = 0",
"- count += 1",
"- if i == N - 1:",
"- if count % 2 == 1:",
"- ans += 1",
"- # print(A[i], count, ans)",
"- # elif A[i] == A[i+1]:",
"- # print(A[i], ... | false | 0.041924 | 0.041478 | 1.010756 | [
"s407051275",
"s893496259"
] |
u729939940 | p02760 | python | s335198388 | s785787666 | 30 | 25 | 9,192 | 9,236 | Accepted | Accepted | 16.67 | A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
A3=list(map(int, input().split()))
A=A1+A2+A3
N=int(eval(input()))
s=set()
for _ in range(N):
b=int(eval(input()))
if b in A:
s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}]
print((["No","Yes... | A1=list(map(int, input().split()))
A2=list(map(int, input().split()))
A3=list(map(int, input().split()))
A=A1+A2+A3
N=int(eval(input()))
s=set()
for _ in range(N):
b=int(eval(input()))
if b in A:
s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,5,8},{2,4,6},{3,4,5},{6,7,8}]
print((['No','Yes... | 13 | 12 | 339 | 336 | A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3
N = int(eval(input()))
s = set()
for _ in range(N):
b = int(eval(input()))
if b in A:
s |= {A.index(b)}
bingo = [
{0, 1, 2},
{0, 3, 6},
{0, 4, 8},
{1, 4, 7},
... | A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = A1 + A2 + A3
N = int(eval(input()))
s = set()
for _ in range(N):
b = int(eval(input()))
if b in A:
s |= {A.index(b)}
bingo = [
{0, 1, 2},
{0, 3, 6},
{0, 4, 8},
{1, 4, 7},
... | false | 7.692308 | [
"+ {2, 5, 8},",
"- {2, 5, 8},"
] | false | 0.04833 | 0.035886 | 1.346758 | [
"s335198388",
"s785787666"
] |
u633068244 | p01359 | python | s602085558 | s334497726 | 4,680 | 3,690 | 4,732 | 4,732 | Accepted | Accepted | 21.15 | while 1:
n,m = list(map(int,input().split()))
if n == 0: break
EBY = [input().split() for i in range(n)]
EBY = [[e,int(b),int(y)] for e,b,y in EBY]
for i in range(m):
year = int(input())
for j in range(n):
if EBY[j][2]-EBY[j][1] < year <= EBY[j][2]:
print(EBY[j][0], year-EBY[j][2]+EBY[j][1])
... | while 1:
n,m = list(map(int,input().split()))
if n == 0: break
EBY = [input().split() for i in range(n)]
EBY = [[e,int(y)-int(b),int(y)] for e,b,y in EBY]
for i in range(m):
year = int(input())
for j in range(n):
if EBY[j][1] < year <= EBY[j][2]:
print(EBY[j][0], year-EBY[j][1])
break
e... | 13 | 13 | 362 | 349 | while 1:
n, m = list(map(int, input().split()))
if n == 0:
break
EBY = [input().split() for i in range(n)]
EBY = [[e, int(b), int(y)] for e, b, y in EBY]
for i in range(m):
year = int(input())
for j in range(n):
if EBY[j][2] - EBY[j][1] < year <= EBY[j][2]:
... | while 1:
n, m = list(map(int, input().split()))
if n == 0:
break
EBY = [input().split() for i in range(n)]
EBY = [[e, int(y) - int(b), int(y)] for e, b, y in EBY]
for i in range(m):
year = int(input())
for j in range(n):
if EBY[j][1] < year <= EBY[j][2]:
... | false | 0 | [
"- EBY = [[e, int(b), int(y)] for e, b, y in EBY]",
"+ EBY = [[e, int(y) - int(b), int(y)] for e, b, y in EBY]",
"- if EBY[j][2] - EBY[j][1] < year <= EBY[j][2]:",
"- print(EBY[j][0], year - EBY[j][2] + EBY[j][1])",
"+ if EBY[j][1] < year <= EBY[j][2]:",
"+ ... | false | 0.115056 | 0.040869 | 2.815248 | [
"s602085558",
"s334497726"
] |
u500376440 | p03252 | python | s437972961 | s532963807 | 113 | 96 | 73,420 | 68,660 | Accepted | Accepted | 15.04 | S=eval(input())
T=eval(input())
ok=True
a,b={},{}
for i in range(len(S)):
s=S[i]
t=T[i]
if s in a:
if a[s]!=t:
ok=False
if t in b:
if b[t]!=s:
ok=False
a[s]=t
b[t]=s
print(("Yes" if ok else "No"))
| import sys
def input():
return sys.stdin.readline().rstrip()
S=eval(input())
T=eval(input())
ok=True
a,b={},{}
for i in range(len(S)):
s=S[i]
t=T[i]
if s in a:
if a[s]!=t:
ok=False
if t in b:
if b[t]!=s:
ok=False
a[s]=t
b[t]=s
print(("Yes" if ok else "No"))
| 18 | 22 | 234 | 302 | S = eval(input())
T = eval(input())
ok = True
a, b = {}, {}
for i in range(len(S)):
s = S[i]
t = T[i]
if s in a:
if a[s] != t:
ok = False
if t in b:
if b[t] != s:
ok = False
a[s] = t
b[t] = s
print(("Yes" if ok else "No"))
| import sys
def input():
return sys.stdin.readline().rstrip()
S = eval(input())
T = eval(input())
ok = True
a, b = {}, {}
for i in range(len(S)):
s = S[i]
t = T[i]
if s in a:
if a[s] != t:
ok = False
if t in b:
if b[t] != s:
ok = False
a[s] = t
b[t]... | false | 18.181818 | [
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+"
] | false | 0.038757 | 0.100543 | 0.385472 | [
"s437972961",
"s532963807"
] |
u519939795 | p03352 | python | s261777361 | s689191919 | 1,044 | 18 | 2,940 | 3,064 | Accepted | Accepted | 98.28 | x=int(eval(input()))
ans=1
for i in range(1,x+1):
for j in range(2,50):
for k in range(2,50):
if i==j**k:
ans=j**k
print(ans) | x=int(eval(input()))
if x==1:
print((1))
exit()
i=2
ans=0
while i*i<x:
j=2
while i**j<=x:
ans=max(ans,i**j)
j +=1
i += 1
print(ans) | 8 | 14 | 166 | 173 | x = int(eval(input()))
ans = 1
for i in range(1, x + 1):
for j in range(2, 50):
for k in range(2, 50):
if i == j**k:
ans = j**k
print(ans)
| x = int(eval(input()))
if x == 1:
print((1))
exit()
i = 2
ans = 0
while i * i < x:
j = 2
while i**j <= x:
ans = max(ans, i**j)
j += 1
i += 1
print(ans)
| false | 42.857143 | [
"-ans = 1",
"-for i in range(1, x + 1):",
"- for j in range(2, 50):",
"- for k in range(2, 50):",
"- if i == j**k:",
"- ans = j**k",
"+if x == 1:",
"+ print((1))",
"+ exit()",
"+i = 2",
"+ans = 0",
"+while i * i < x:",
"+ j = 2",
"+ while i**... | false | 0.49232 | 0.039789 | 12.373316 | [
"s261777361",
"s689191919"
] |
u075012704 | p03965 | python | s384235832 | s720930738 | 50 | 18 | 3,956 | 3,188 | Accepted | Accepted | 64 | S = eval(input())
X = [('g' if i % 2 == 0 else 'p') for i in range(len(S))]
ans = 0
for s, x in zip(S, X):
if s == 'g' and x == 'p':
ans += 1
if s == 'p' and x == 'g':
ans -= 1
print(ans)
| S = eval(input())
N = len(S)
P = S.count('p')
print((N // 2 - P))
| 12 | 5 | 220 | 63 | S = eval(input())
X = [("g" if i % 2 == 0 else "p") for i in range(len(S))]
ans = 0
for s, x in zip(S, X):
if s == "g" and x == "p":
ans += 1
if s == "p" and x == "g":
ans -= 1
print(ans)
| S = eval(input())
N = len(S)
P = S.count("p")
print((N // 2 - P))
| false | 58.333333 | [
"-X = [(\"g\" if i % 2 == 0 else \"p\") for i in range(len(S))]",
"-ans = 0",
"-for s, x in zip(S, X):",
"- if s == \"g\" and x == \"p\":",
"- ans += 1",
"- if s == \"p\" and x == \"g\":",
"- ans -= 1",
"-print(ans)",
"+N = len(S)",
"+P = S.count(\"p\")",
"+print((N // 2 - P)... | false | 0.035273 | 0.040748 | 0.865644 | [
"s384235832",
"s720930738"
] |
u945181840 | p03160 | python | s854040432 | s595742179 | 144 | 101 | 14,052 | 14,052 | Accepted | Accepted | 29.86 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N = int(readline())
A = tuple(map(int, read().split()))
if N == 2:
print((A[1] - A[0]))
exit()
dp = [10 ** 10] * N
dp[1] = abs(A[1] - A[0])
dp[2] = abs(A[2] - A[0])
for i in range(3, N):
dp[i]... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = tuple(map(int, read().split()))
if N == 2:
print((A[1] - A[0]))
exit()
dp = [10 ** 10] * N
dp[1] = abs(A[1] - A[0])
dp[2] = abs(A... | 20 | 26 | 409 | 512 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N = int(readline())
A = tuple(map(int, read().split()))
if N == 2:
print((A[1] - A[0]))
exit()
dp = [10**10] * N
dp[1] = abs(A[1] - A[0])
dp[2] = abs(A[2] - A[0])
for i in range(3, N):
dp[i] = min(dp[i - 1] + abs... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = tuple(map(int, read().split()))
if N == 2:
print((A[1] - A[0]))
exit()
dp = [10**10] * N
dp[1] = abs(A[1] - A[0])
dp[2] = abs(A[2] - A[0])
for... | false | 23.076923 | [
"-N = int(readline())",
"-A = tuple(map(int, read().split()))",
"-if N == 2:",
"- print((A[1] - A[0]))",
"- exit()",
"-dp = [10**10] * N",
"-dp[1] = abs(A[1] - A[0])",
"-dp[2] = abs(A[2] - A[0])",
"-for i in range(3, N):",
"- dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A... | false | 0.045119 | 0.106136 | 0.425105 | [
"s854040432",
"s595742179"
] |
u006880673 | p03241 | python | s419618847 | s034943326 | 106 | 87 | 63,008 | 63,952 | Accepted | Accepted | 17.92 | N, M = list(map(int, input().split()))
from math import sqrt
def divisor(num):
max_num = int(sqrt(num))
divisor_list = []
for i in range(1, max_num + 1):
if num % i == 0:
divisor_list.append(i)
divisor_list.append(num//i)
return divisor_list
g_list = divisor... | ### ABC112D Partition Diff:
N, M = list(map(int, input().split()))
from math import sqrt
def divisor(num):
max_num = int(sqrt(num))
divisor_list = []
for i in range(1, max_num + 1):
if num % i == 0:
divisor_list.append(i)
divisor_list.append(num//i)
return d... | 20 | 23 | 434 | 468 | N, M = list(map(int, input().split()))
from math import sqrt
def divisor(num):
max_num = int(sqrt(num))
divisor_list = []
for i in range(1, max_num + 1):
if num % i == 0:
divisor_list.append(i)
divisor_list.append(num // i)
return divisor_list
g_list = divisor(M)
g_li... | ### ABC112D Partition Diff:
N, M = list(map(int, input().split()))
from math import sqrt
def divisor(num):
max_num = int(sqrt(num))
divisor_list = []
for i in range(1, max_num + 1):
if num % i == 0:
divisor_list.append(i)
divisor_list.append(num // i)
return divisor_lis... | false | 13.043478 | [
"+### ABC112D Partition Diff:",
"-g_list = divisor(M)",
"-g_list.sort(reverse=True)",
"-ans = 0",
"-for g in g_list:",
"- if M // g >= N:",
"- ans = g",
"- break",
"+div = divisor(M)",
"+div.sort(reverse=True)",
"+ans = None",
"+for g in div:",
"+ if N > M // g:",
"+ ... | false | 0.038481 | 0.038748 | 0.99312 | [
"s419618847",
"s034943326"
] |
u254871849 | p03607 | python | s662241840 | s911355112 | 120 | 68 | 18,784 | 18,784 | Accepted | Accepted | 43.33 | from sys import stdin
from collections import Counter
n, *a = (int(x) for x in stdin.read().split())
count = 0
for v in list(Counter(a).values()):
if v % 2 == 1: count += 1
print(count) | import sys
from collections import Counter
n, *a = list(map(int, sys.stdin.read().split()))
def main():
res = 0
for c in list(Counter(a).values()):
res += c & 1
return res
if __name__ == '__main__':
ans = main()
print(ans) | 10 | 15 | 195 | 256 | from sys import stdin
from collections import Counter
n, *a = (int(x) for x in stdin.read().split())
count = 0
for v in list(Counter(a).values()):
if v % 2 == 1:
count += 1
print(count)
| import sys
from collections import Counter
n, *a = list(map(int, sys.stdin.read().split()))
def main():
res = 0
for c in list(Counter(a).values()):
res += c & 1
return res
if __name__ == "__main__":
ans = main()
print(ans)
| false | 33.333333 | [
"-from sys import stdin",
"+import sys",
"-n, *a = (int(x) for x in stdin.read().split())",
"-count = 0",
"-for v in list(Counter(a).values()):",
"- if v % 2 == 1:",
"- count += 1",
"-print(count)",
"+n, *a = list(map(int, sys.stdin.read().split()))",
"+",
"+",
"+def main():",
"+ ... | false | 0.035394 | 0.062978 | 0.562005 | [
"s662241840",
"s911355112"
] |
u564589929 | p02706 | python | s348461862 | s015988961 | 25 | 22 | 10,056 | 9,884 | Accepted | Accepted | 12 | # import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(... | import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): retur... | 25 | 25 | 503 | 561 | # import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def LLI(rows_number):
return [L... | import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline ####
int1 = lambda x: int(x) - 1
def II():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def MI1():
return list(map(int1, input().split()))
def LI():
return list(map(int, input().split()))
def... | false | 0 | [
"-# import sys",
"-# sys.setrecursionlimit(10 ** 6)",
"+import sys",
"+",
"+sys.setrecursionlimit(10**6)",
"+# input = sys.stdin.readline ####",
"+def LI1():",
"+ return list(map(int1, input().split()))",
"+",
"+",
"+",
"+",
"+INF = float(\"inf\")",
"- sm = sum(A)",
"- if n -... | false | 0.049755 | 0.049057 | 1.014223 | [
"s348461862",
"s015988961"
] |
u454022848 | p02396 | python | s685688446 | s401871892 | 110 | 40 | 6,720 | 6,272 | Accepted | Accepted | 63.64 | c=1
while True:
i=eval(input())
if(i=="0"):
break
print(("Case "+str(c)+": "+i))
c+=1 | # encoding:utf-8
count = 1
while True:
input = input()
if input == "0":
break
text = "Case " + ": ".join(map(str, (count, input)))
print(text)
count += 1 | 7 | 9 | 89 | 172 | c = 1
while True:
i = eval(input())
if i == "0":
break
print(("Case " + str(c) + ": " + i))
c += 1
| # encoding:utf-8
count = 1
while True:
input = input()
if input == "0":
break
text = "Case " + ": ".join(map(str, (count, input)))
print(text)
count += 1
| false | 22.222222 | [
"-c = 1",
"+# encoding:utf-8",
"+count = 1",
"- i = eval(input())",
"- if i == \"0\":",
"+ input = input()",
"+ if input == \"0\":",
"- print((\"Case \" + str(c) + \": \" + i))",
"- c += 1",
"+ text = \"Case \" + \": \".join(map(str, (count, input)))",
"+ print(text)",
... | false | 0.041242 | 0.034768 | 1.186206 | [
"s685688446",
"s401871892"
] |
u388927326 | p03295 | python | s777532341 | s601188143 | 610 | 432 | 57,220 | 57,184 | Accepted | Accepted | 29.18 | #!/usr/bin/env python3
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
a = []
b = []
atoi = defaultdict(list)
btoi = defaultdict(list)
for i in range(m):
aa, bb = list(map(int, input().split()))
a.append(aa - 1)
b.appe... | #!/usr/bin/env python3
import sys
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
a = []
b = []
atoi = defaultdict(list)
btoi = defaultdict(list)
for i in range(m):
aa, bb = list(map(int, sys.stdin.readline().split()))
a.appen... | 35 | 36 | 859 | 884 | #!/usr/bin/env python3
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
a = []
b = []
atoi = defaultdict(list)
btoi = defaultdict(list)
for i in range(m):
aa, bb = list(map(int, input().split()))
a.append(aa - 1)
b.append(bb - 1)
... | #!/usr/bin/env python3
import sys
from collections import defaultdict
def main():
n, m = list(map(int, input().split()))
a = []
b = []
atoi = defaultdict(list)
btoi = defaultdict(list)
for i in range(m):
aa, bb = list(map(int, sys.stdin.readline().split()))
a.append(aa - 1)
... | false | 2.777778 | [
"+import sys",
"- aa, bb = list(map(int, input().split()))",
"+ aa, bb = list(map(int, sys.stdin.readline().split()))"
] | false | 0.03621 | 0.041593 | 0.870561 | [
"s777532341",
"s601188143"
] |
u297574184 | p02920 | python | s060088238 | s861129600 | 733 | 406 | 34,376 | 106,316 | Accepted | Accepted | 44.61 | from heapq import heapify, heappush, heappop
def solve():
N = int(eval(input()))
Ss = list(map(int, input().split()))
Ss.sort(reverse=True)
pow2s = [2**i for i in range(N)]
PQs = [[-Ss[0]] for _ in range(N)]
nums = [0] * N
tm0 = 0
for S in Ss[1:]:
for tm in range(... | from collections import deque
def solve():
N = int(eval(input()))
Ss = list(map(int, input().split()))
Ss.sort(reverse=True)
Qs = [deque() for _ in range(N+1)]
Qs[0].append(10**10)
for S in Ss:
for day in range(N+1):
if not Qs[day]: continue
if Q... | 32 | 29 | 753 | 588 | from heapq import heapify, heappush, heappop
def solve():
N = int(eval(input()))
Ss = list(map(int, input().split()))
Ss.sort(reverse=True)
pow2s = [2**i for i in range(N)]
PQs = [[-Ss[0]] for _ in range(N)]
nums = [0] * N
tm0 = 0
for S in Ss[1:]:
for tm in range(tm0, N):
... | from collections import deque
def solve():
N = int(eval(input()))
Ss = list(map(int, input().split()))
Ss.sort(reverse=True)
Qs = [deque() for _ in range(N + 1)]
Qs[0].append(10**10)
for S in Ss:
for day in range(N + 1):
if not Qs[day]:
continue
... | false | 9.375 | [
"-from heapq import heapify, heappush, heappop",
"+from collections import deque",
"- pow2s = [2**i for i in range(N)]",
"- PQs = [[-Ss[0]] for _ in range(N)]",
"- nums = [0] * N",
"- tm0 = 0",
"- for S in Ss[1:]:",
"- for tm in range(tm0, N):",
"- if nums[tm] >= pow... | false | 0.037263 | 0.040035 | 0.930769 | [
"s060088238",
"s861129600"
] |
u761320129 | p02936 | python | s386755530 | s912892075 | 1,988 | 915 | 124,548 | 125,608 | Accepted | Accepted | 53.97 | N,Q = list(map(int,input().split()))
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a,b in AB:
a,b = a-1,b-1
es[a].append(b)
es[b].append(a)
xs = [0] * N
for p,x in PX:
xs[p-1] += x
ans ... | import sys
input = sys.stdin.readline
N,Q = list(map(int,input().split()))
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a,b in AB:
a,b = a-1,b-1
es[a].append(b)
es[b].append(a)
xs = [0] * N
... | 27 | 29 | 558 | 598 | N, Q = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N - 1)]
PX = [tuple(map(int, input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a, b in AB:
a, b = a - 1, b - 1
es[a].append(b)
es[b].append(a)
xs = [0] * N
for p, x in PX:
xs[p - 1] += x
ans =... | import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N - 1)]
PX = [tuple(map(int, input().split())) for i in range(Q)]
es = [[] for i in range(N)]
for a, b in AB:
a, b = a - 1, b - 1
es[a].append(b)
es[b].append(a)
xs = [0] * N
f... | false | 6.896552 | [
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.033243 | 0.037711 | 0.881509 | [
"s386755530",
"s912892075"
] |
u057109575 | p02768 | python | s524375686 | s043067802 | 487 | 79 | 38,768 | 71,668 | Accepted | Accepted | 83.78 | N, A, B = list(map(int, open(0).read().split()))
MOD = 10 ** 9 + 7
def comb(n, k):
ret = 1
for i in range(1, k + 1):
ret = ret * (n - i + 1) % MOD
ret = ret * pow(i, MOD - 2, MOD) % MOD
return ret
print(((pow(2, N, MOD) - 1 - comb(N, A) - comb(N, B)) % MOD))
|
N, A, B = list(map(int, input().split()))
MAX = 2 * 10 ** 5 + 1
MOD = 10 ** 9 + 7
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1
# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[... | 13 | 38 | 303 | 707 | N, A, B = list(map(int, open(0).read().split()))
MOD = 10**9 + 7
def comb(n, k):
ret = 1
for i in range(1, k + 1):
ret = ret * (n - i + 1) % MOD
ret = ret * pow(i, MOD - 2, MOD) % MOD
return ret
print(((pow(2, N, MOD) - 1 - comb(N, A) - comb(N, B)) % MOD))
| N, A, B = list(map(int, input().split()))
MAX = 2 * 10**5 + 1
MOD = 10**9 + 7
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1
# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] = M... | false | 65.789474 | [
"-N, A, B = list(map(int, open(0).read().split()))",
"+N, A, B = list(map(int, input().split()))",
"+MAX = 2 * 10**5 + 1",
"-",
"-",
"-def comb(n, k):",
"- ret = 1",
"- for i in range(1, k + 1):",
"- ret = ret * (n - i + 1) % MOD",
"- ret = ret * pow(i, MOD - 2, MOD) % MOD",
... | false | 0.905397 | 0.874221 | 1.035661 | [
"s524375686",
"s043067802"
] |
u296150111 | p02559 | python | s607642642 | s075221472 | 3,836 | 607 | 69,112 | 127,600 | Accepted | Accepted | 84.18 | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
BIT=[0]*n
def ADD(x,y):#A[x]+=y,1-origin
while x<=n:
BIT[x-1]+=y
x+=x&(-x)
def SUM(l):#1からlまでの和
if l==0:
return 0
ret=0
while l>=1:
ret+=BIT[l-1]
l-=l&(-l)
return ret
IN=list(map(int,input().split()))
for i in ran... | import sys
input=sys.stdin.readline
n,q=list(map(int,input().split()))
BIT=[0]*n
def ADD(x,y):#A[x]+=y,1-origin
while x<=n:
BIT[x-1]+=y
x+=x&(-x)
def SUM(l):#1からlまでの和
ret=0
while l>=1:
ret+=BIT[l-1]
l-=l&(-l)
return ret
IN=list(map(int,input().split()))
for i in range(n):
ADD(i+1,IN[i])... | 28 | 26 | 449 | 426 | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
BIT = [0] * n
def ADD(x, y): # A[x]+=y,1-origin
while x <= n:
BIT[x - 1] += y
x += x & (-x)
def SUM(l): # 1からlまでの和
if l == 0:
return 0
ret = 0
while l >= 1:
ret += BIT[l - 1]
l -= ... | import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
BIT = [0] * n
def ADD(x, y): # A[x]+=y,1-origin
while x <= n:
BIT[x - 1] += y
x += x & (-x)
def SUM(l): # 1からlまでの和
ret = 0
while l >= 1:
ret += BIT[l - 1]
l -= l & (-l)
return ret
IN = l... | false | 7.142857 | [
"- if l == 0:",
"- return 0"
] | false | 0.038662 | 0.046289 | 0.835239 | [
"s607642642",
"s075221472"
] |
u150984829 | p02315 | python | s855908522 | s172038383 | 340 | 160 | 5,916 | 5,924 | Accepted | Accepted | 52.94 | N,W=list(map(int,input().split()))
C=[0]*-~W
for _ in[0]*N:
v,w=list(map(int,input().split()))
for i in range(W,w-1,-1):
t=v+C[i-w]
if t>C[i]:C[i]=t
print((C[W]))
| import sys
def s():
W=int(input().split()[1])
C=[0]*-~W
for e in sys.stdin:
v,w=list(map(int,e.split()))
for i in range(W,w-1,-1):
t=v+C[i-w]
if t>C[i]:C[i]=t
print((C[W]))
if'__main__'==__name__:s()
| 8 | 11 | 162 | 216 | N, W = list(map(int, input().split()))
C = [0] * -~W
for _ in [0] * N:
v, w = list(map(int, input().split()))
for i in range(W, w - 1, -1):
t = v + C[i - w]
if t > C[i]:
C[i] = t
print((C[W]))
| import sys
def s():
W = int(input().split()[1])
C = [0] * -~W
for e in sys.stdin:
v, w = list(map(int, e.split()))
for i in range(W, w - 1, -1):
t = v + C[i - w]
if t > C[i]:
C[i] = t
print((C[W]))
if "__main__" == __name__:
s()
| false | 27.272727 | [
"-N, W = list(map(int, input().split()))",
"-C = [0] * -~W",
"-for _ in [0] * N:",
"- v, w = list(map(int, input().split()))",
"- for i in range(W, w - 1, -1):",
"- t = v + C[i - w]",
"- if t > C[i]:",
"- C[i] = t",
"-print((C[W]))",
"+import sys",
"+",
"+",
"+... | false | 0.042563 | 0.042296 | 1.006318 | [
"s855908522",
"s172038383"
] |
u263830634 | p03096 | python | s118576857 | s519061053 | 734 | 252 | 762,280 | 20,500 | Accepted | Accepted | 65.67 | import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 **9 + 7
N = int(eval(input()))
C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10 ** 5 + 10) #各番号がどこにあるかを管理するリスト
ans = [1] * N
lst[C[-1]] = N - 1
for i in range(N - 2, -1, -1):
c = C[i]
if lst[c] == INF or lst[c] ==... | import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 **9 + 7
N = int(eval(input()))
C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10 ** 5 + 10) #各番号がどこにあるかを管理するリスト
ans = [1] * N
lst[C[-1]] = N - 1
for i in range(N - 2, -1, -1):
c = C[i]
if lst[c] == INF or lst[c] ==... | 24 | 25 | 453 | 472 | import sys
input = sys.stdin.readline
INF = 10**9
MOD = 10**9 + 7
N = int(eval(input()))
C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10**5 + 10) # 各番号がどこにあるかを管理するリスト
ans = [1] * N
lst[C[-1]] = N - 1
for i in range(N - 2, -1, -1):
c = C[i]
if lst[c] == INF or lst[c] == i + 1:
ans[i] =... | import sys
input = sys.stdin.readline
INF = 10**9
MOD = 10**9 + 7
N = int(eval(input()))
C = [int(eval(input())) for _ in range(N)]
lst = [INF] * (2 * 10**5 + 10) # 各番号がどこにあるかを管理するリスト
ans = [1] * N
lst[C[-1]] = N - 1
for i in range(N - 2, -1, -1):
c = C[i]
if lst[c] == INF or lst[c] == i + 1:
ans[i] =... | false | 4 | [
"+ ans[i] %= MOD"
] | false | 0.039062 | 0.044647 | 0.874916 | [
"s118576857",
"s519061053"
] |
u934442292 | p03112 | python | s271032322 | s491530214 | 1,090 | 484 | 17,508 | 34,496 | Accepted | Accepted | 55.6 | # https://img.atcoder.jp/abc119/editorial.pdf
# bisect_right ---> bisect_left
import bisect
A, B, Q = list(map(int, input().split()))
INF = 10 ** 18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
x = int(eval(input()... | import sys
from bisect import bisect_left
input = sys.stdin.readline
def solve(Q, S, T, X):
ans = [0] * Q
INF = 10 ** 11
for q, x in enumerate(X):
min_dist = INF
i_s = bisect_left(S, x)
i_t = bisect_left(T, x)
for s in (S[i_s - 1], S[i_s]):
for t ... | 16 | 43 | 568 | 1,021 | # https://img.atcoder.jp/abc119/editorial.pdf
# bisect_right ---> bisect_left
import bisect
A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(B)] + [INF]
for q in range(Q):
x = int(eval(input()))
b,... | import sys
from bisect import bisect_left
input = sys.stdin.readline
def solve(Q, S, T, X):
ans = [0] * Q
INF = 10**11
for q, x in enumerate(X):
min_dist = INF
i_s = bisect_left(S, x)
i_t = bisect_left(T, x)
for s in (S[i_s - 1], S[i_s]):
for t in (T[i_t - 1], ... | false | 62.790698 | [
"-# https://img.atcoder.jp/abc119/editorial.pdf",
"-import bisect",
"+import sys",
"+from bisect import bisect_left",
"-A, B, Q = list(map(int, input().split()))",
"-INF = 10**18",
"-s = [-INF] + [int(eval(input())) for i in range(A)] + [INF]",
"-t = [-INF] + [int(eval(input())) for i in range(B)] + [... | false | 0.120727 | 0.059995 | 2.012273 | [
"s271032322",
"s491530214"
] |
u185249212 | p02954 | python | s255351415 | s899098198 | 498 | 347 | 83,612 | 76,464 | Accepted | Accepted | 30.32 |
from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heap... |
from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heap... | 125 | 95 | 2,750 | 1,909 | from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heapp... | from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heapp... | false | 24 | [
"+def add_temp_to_T(p, temp, T):",
"+ if p % 2 == 0:",
"+ T[p - 1] += temp[1]",
"+ T[p] += temp[0]",
"+ else:",
"+ T[p - 1] += temp[0]",
"+ T[p] += temp[1]",
"+ return 0",
"+",
"+",
"- #",
"- #",
"- temp = 0",
"- cnt = 0",
"- for i in r... | false | 0.044469 | 0.034989 | 1.270961 | [
"s255351415",
"s899098198"
] |
u935558307 | p03039 | python | s380182377 | s456085348 | 292 | 265 | 213,388 | 213,040 | Accepted | Accepted | 9.25 | from itertools import combinations
import math
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) ... | """
基本の方針は「各マンハッタン距離が何回足されるか」という考え方で距離の値を積み上げて行けばよい
まず、XとYは独立に考えることにする。
X軸の距離の方から積み上げる。
X1とX2の距離が足される回数は、
A.X1の列とX2の列の座標の組み合わせの数 × B.その組み合わせが含まれるような座標の組み合わせの数
である。
A = 行数**2
B = CMB(N*M-2 , K-2)である
同様の計算をY軸に関しても行えばよい。
"""
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n -... | 42 | 49 | 970 | 1,007 | from itertools import combinations
import math
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n - r] % p
p = 10**9 + 7
N = 10**6 # N は必要分だけ用意する
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv... | """
基本の方針は「各マンハッタン距離が何回足されるか」という考え方で距離の値を積み上げて行けばよい
まず、XとYは独立に考えることにする。
X軸の距離の方から積み上げる。
X1とX2の距離が足される回数は、
A.X1の列とX2の列の座標の組み合わせの数 × B.その組み合わせが含まれるような座標の組み合わせの数
である。
A = 行数**2
B = CMB(N*M-2 , K-2)である
同様の計算をY軸に関しても行えばよい。
"""
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return f... | false | 14.285714 | [
"-from itertools import combinations",
"-import math",
"+\"\"\"",
"+基本の方針は「各マンハッタン距離が何回足されるか」という考え方で距離の値を積み上げて行けばよい",
"+まず、XとYは独立に考えることにする。",
"+X軸の距離の方から積み上げる。",
"+X1とX2の距離が足される回数は、",
"+A.X1の列とX2の列の座標の組み合わせの数 × B.その組み合わせが含まれるような座標の組み合わせの数",
"+である。",
"+A = 行数**2",
"+B = CMB(N*M-2 , K-2)である",
"+... | false | 1.386053 | 1.369248 | 1.012274 | [
"s380182377",
"s456085348"
] |
u139112865 | p03044 | python | s456111116 | s392680009 | 839 | 670 | 80,272 | 80,260 | Accepted | Accepted | 20.14 | #126_D
import sys
sys.setrecursionlimit(500000)
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
u,v,w=map(int,input().split())
edges[u-1].append((v-1,w))
edges[v-1].append((u-1,w))
visit=[False for _ in range(n)]
d=[0 for i in range(n)]
def dfs(i):
visit[i]=True
if ... | #126_D
import sys
sys.setrecursionlimit(500000)
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
u,v,w=map(int,input().split())
edges[u-1].append((v-1,w))
edges[v-1].append((u-1,w))
visit=[False for _ in range(n)]
d=[0 for i in range(n)]
def dfs(i):
visit[i]=True
for... | 24 | 22 | 522 | 457 | # 126_D
import sys
sys.setrecursionlimit(500000)
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = map(int, input().split())
edges[u - 1].append((v - 1, w))
edges[v - 1].append((u - 1, w))
visit = [False for _ in range(n)]
d = [0 for i in range(n)]
def dfs(i):
visit[i] ... | # 126_D
import sys
sys.setrecursionlimit(500000)
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = map(int, input().split())
edges[u - 1].append((v - 1, w))
edges[v - 1].append((u - 1, w))
visit = [False for _ in range(n)]
d = [0 for i in range(n)]
def dfs(i):
visit[i] ... | false | 8.333333 | [
"- if all(visit[i] for i in range(n)):",
"- print(*d, sep=\"\\n\")",
"- exit()",
"+print(*d, sep=\"\\n\")"
] | false | 0.113584 | 0.0859 | 1.322284 | [
"s456111116",
"s392680009"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.