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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u469226065 | p02657 | python | s800474646 | s049747438 | 28 | 25 | 9,088 | 8,896 | Accepted | Accepted | 10.71 | # 169A
# A ร B ใๆดๆฐใจใใฆๅบๅใใ
# 1. ๅ
ฅๅใใใญใฐใฉใใณใฐใงๆฑใใใใใซๅใๅใใใจ
a, b = list(map(int, input().split()))
# print(a, b)
# 2. ๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๅฆ็๏ผ่จ็ฎ๏ผใใใใจ
answer = a * b
# 3.่จ็ฎใใ็ตๆใๅบๅใใใใจ
print(answer) | # 169A
# A ร Bใๆฑใใฆใใ ใใใ
A, B = list(map(int, input().split()))
# print(A, B)
answer = A * B
print(answer) | 12 | 8 | 194 | 108 | # 169A
# A ร B ใๆดๆฐใจใใฆๅบๅใใ
# 1. ๅ
ฅๅใใใญใฐใฉใใณใฐใงๆฑใใใใใซๅใๅใใใจ
a, b = list(map(int, input().split()))
# print(a, b)
# 2. ๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๅฆ็๏ผ่จ็ฎ๏ผใใใใจ
answer = a * b
# 3.่จ็ฎใใ็ตๆใๅบๅใใใใจ
print(answer)
| # 169A
# A ร Bใๆฑใใฆใใ ใใใ
A, B = list(map(int, input().split()))
# print(A, B)
answer = A * B
print(answer)
| false | 33.333333 | [
"-# A ร B ใๆดๆฐใจใใฆๅบๅใใ",
"-# 1. ๅ
ฅๅใใใญใฐใฉใใณใฐใงๆฑใใใใใซๅใๅใใใจ",
"-a, b = list(map(int, input().split()))",
"-# print(a, b)",
"-# 2. ๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๅฆ็๏ผ่จ็ฎ๏ผใใใใจ",
"-answer = a * b",
"-# 3.่จ็ฎใใ็ตๆใๅบๅใใใใจ",
"+# A ร Bใๆฑใใฆใใ ใใใ",
"+A, B = list(map(int, input().split()))",
"+# print(A, B)",
"+answer = A * B"
] | false | 0.04195 | 0.007964 | 5.267209 | [
"s800474646",
"s049747438"
] |
u072717685 | p03163 | python | s029656162 | s461780709 | 563 | 405 | 171,400 | 58,632 | Accepted | Accepted | 28.06 | n, w = list(map(int, input().split()))
things = []
things.append([0,0])
things += [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
def do_dp():
for i,thing in enumerate(things):
dp_1 = dp[i-1]
for j in range(1, w + 1):
dp[i][j]... | n, w = list(map(int, input().split()))
dp = [0]*(w+1)
for _ in range(n):
wei, v = list(map(int, input().split()))
dp_1 = dp[:]
for j in range(w + 1):
if j - wei >= 0:
dp[j] = dp_1[j-wei] + v if (dp_1[j-wei] + v) > dp_1[j] else dp[j]
print((dp[w]))
| 16 | 12 | 451 | 266 | n, w = list(map(int, input().split()))
things = []
things.append([0, 0])
things += [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
def do_dp():
for i, thing in enumerate(things):
dp_1 = dp[i - 1]
for j in range(1, w + 1):
dp[i]... | n, w = list(map(int, input().split()))
dp = [0] * (w + 1)
for _ in range(n):
wei, v = list(map(int, input().split()))
dp_1 = dp[:]
for j in range(w + 1):
if j - wei >= 0:
dp[j] = dp_1[j - wei] + v if (dp_1[j - wei] + v) > dp_1[j] else dp[j]
print((dp[w]))
| false | 25 | [
"-things = []",
"-things.append([0, 0])",
"-things += [list(map(int, input().split())) for _ in range(n)]",
"-dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]",
"-",
"-",
"-def do_dp():",
"- for i, thing in enumerate(things):",
"- dp_1 = dp[i - 1]",
"- for j in range(1, w + ... | false | 0.047243 | 0.121362 | 0.389276 | [
"s029656162",
"s461780709"
] |
u057109575 | p02866 | python | s829919388 | s434388656 | 234 | 120 | 62,008 | 98,160 | Accepted | Accepted | 48.72 | from collections import Counter
N, *D = list(map(int, open(0).read().split()))
MOD = 998244353
ctr = Counter(D)
ans = 1
for i in range(1, max(ctr) + 1):
ans = ans * ctr[i - 1] ** ctr[i] % MOD
if ctr[0] == 1 and D[0] == 0:
print(ans)
else:
print((0))
|
from collections import Counter
N = int(eval(input()))
X = list(map(int, input().split()))
MOD = 998244353
ctr = Counter(X)
if X[0] == 0 and ctr[0] == 1:
ans = 1
for i in range(1, max(X) + 1):
ans *= pow(ctr[i - 1], ctr[i], MOD)
ans %= MOD
print(ans)
else:
print((0))
| 13 | 17 | 268 | 312 | from collections import Counter
N, *D = list(map(int, open(0).read().split()))
MOD = 998244353
ctr = Counter(D)
ans = 1
for i in range(1, max(ctr) + 1):
ans = ans * ctr[i - 1] ** ctr[i] % MOD
if ctr[0] == 1 and D[0] == 0:
print(ans)
else:
print((0))
| from collections import Counter
N = int(eval(input()))
X = list(map(int, input().split()))
MOD = 998244353
ctr = Counter(X)
if X[0] == 0 and ctr[0] == 1:
ans = 1
for i in range(1, max(X) + 1):
ans *= pow(ctr[i - 1], ctr[i], MOD)
ans %= MOD
print(ans)
else:
print((0))
| false | 23.529412 | [
"-N, *D = list(map(int, open(0).read().split()))",
"+N = int(eval(input()))",
"+X = list(map(int, input().split()))",
"-ctr = Counter(D)",
"-ans = 1",
"-for i in range(1, max(ctr) + 1):",
"- ans = ans * ctr[i - 1] ** ctr[i] % MOD",
"-if ctr[0] == 1 and D[0] == 0:",
"+ctr = Counter(X)",
"+if X[0... | false | 0.04199 | 0.036581 | 1.147867 | [
"s829919388",
"s434388656"
] |
u764600134 | p03148 | python | s381751646 | s478464328 | 816 | 557 | 85,336 | 36,600 | Accepted | Accepted | 31.74 | # -*- coding: utf-8 -*-
"""
D - Various Sushi
https://atcoder.jp/contests/abc116/tasks/abc116_d
"""
import sys
from collections import Counter
def solve(N, K, sushi):
sushi.sort(key=lambda x: x[1], reverse=True)
pick = sushi[:K] # ใใใใใใคใณใใฎ้ซใๆนใใKๅใฎๅฏฟๅธใ้ธๆ
pick_type = set([t for t, ... | # -*- coding: utf-8 -*-
"""
D - Various Sushi
https://atcoder.jp/contests/abc116/tasks/abc116_d
AC
"""
import sys
from collections import Counter
def solve(N, K, sushi):
sushi.sort(key=lambda x: x[1], reverse=True)
pick = sushi[:K] # ใใใใใใคใณใใฎ้ซใๆนใใKๅใฎๅฏฟๅธใ้ธๆ
pick_type = set([t for t... | 49 | 49 | 1,424 | 1,426 | # -*- coding: utf-8 -*-
"""
D - Various Sushi
https://atcoder.jp/contests/abc116/tasks/abc116_d
"""
import sys
from collections import Counter
def solve(N, K, sushi):
sushi.sort(key=lambda x: x[1], reverse=True)
pick = sushi[:K] # ใใใใใใคใณใใฎ้ซใๆนใใKๅใฎๅฏฟๅธใ้ธๆ
pick_type = set([t for t, d in pick]) # ้ธๆๆธใฎ็จฎ้ก
... | # -*- coding: utf-8 -*-
"""
D - Various Sushi
https://atcoder.jp/contests/abc116/tasks/abc116_d
AC
"""
import sys
from collections import Counter
def solve(N, K, sushi):
sushi.sort(key=lambda x: x[1], reverse=True)
pick = sushi[:K] # ใใใใใใคใณใใฎ้ซใๆนใใKๅใฎๅฏฟๅธใ้ธๆ
pick_type = set([t for t, d in pick]) # ้ธๆๆธใฎ็จฎ้ก... | false | 0 | [
"+AC"
] | false | 0.03954 | 0.039241 | 1.007616 | [
"s381751646",
"s478464328"
] |
u046187684 | p03287 | python | s164098861 | s205219276 | 236 | 73 | 69,272 | 15,524 | Accepted | Accepted | 69.07 | from collections import Counter
from itertools import accumulate
def solve(string):
n, m, *a = list(map(int, string.split()))
a = list(accumulate(a))
d = Counter(_a % m for _a in a)
ans = d[0]
ans += sum(v * (v - 1) // 2 for v in list(d.values()))
return str(ans)
if __name__ =... | from collections import Counter
from itertools import accumulate
def solve(string):
n, m, *a = list(map(int, string.split()))
d = Counter(_a % m for _a in accumulate([0] + a))
return str(sum(v * (v - 1) // 2 for v in list(d.values())))
if __name__ == '__main__':
print((solve('\n'.join([ev... | 16 | 12 | 371 | 326 | from collections import Counter
from itertools import accumulate
def solve(string):
n, m, *a = list(map(int, string.split()))
a = list(accumulate(a))
d = Counter(_a % m for _a in a)
ans = d[0]
ans += sum(v * (v - 1) // 2 for v in list(d.values()))
return str(ans)
if __name__ == "__main__":
... | from collections import Counter
from itertools import accumulate
def solve(string):
n, m, *a = list(map(int, string.split()))
d = Counter(_a % m for _a in accumulate([0] + a))
return str(sum(v * (v - 1) // 2 for v in list(d.values())))
if __name__ == "__main__":
print((solve("\n".join([eval(input())... | false | 25 | [
"- a = list(accumulate(a))",
"- d = Counter(_a % m for _a in a)",
"- ans = d[0]",
"- ans += sum(v * (v - 1) // 2 for v in list(d.values()))",
"- return str(ans)",
"+ d = Counter(_a % m for _a in accumulate([0] + a))",
"+ return str(sum(v * (v - 1) // 2 for v in list(d.values())))"
] | false | 0.070756 | 0.037409 | 1.89144 | [
"s164098861",
"s205219276"
] |
u860002137 | p02803 | python | s952980410 | s774608051 | 511 | 386 | 3,572 | 3,572 | Accepted | Accepted | 24.46 | import copy
from collections import deque
H, W = list(map(int, input().split()))
field_s = []
# ใใฃใผใซใใไฝใ
for h in range(H + 2):
field_s.append(["#"] * (W + 2))
if 1 <= h <= (H):
field_s[h][1:-1] = list(map(str, input().rstrip()))
#ใๅใๆนใฎใปใใใๆบๅ
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
... | import copy
from collections import deque
def bfs(s, f):
f[s[0]][s[1]] = 0
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
q = deque([s])
while q:
c = q.popleft()
for m in moves:
my, mx = c[0] + m[0], c[1] + m[1]
if f[my][mx] == ".":
... | 59 | 49 | 1,189 | 1,075 | import copy
from collections import deque
H, W = list(map(int, input().split()))
field_s = []
# ใใฃใผใซใใไฝใ
for h in range(H + 2):
field_s.append(["#"] * (W + 2))
if 1 <= h <= (H):
field_s[h][1:-1] = list(map(str, input().rstrip()))
# ใๅใๆนใฎใปใใใๆบๅ
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
# ในใฟใผใๅบงๆจใๅๅพ
star... | import copy
from collections import deque
def bfs(s, f):
f[s[0]][s[1]] = 0
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
q = deque([s])
while q:
c = q.popleft()
for m in moves:
my, mx = c[0] + m[0], c[1] + m[1]
if f[my][mx] == ".":
f[my][mx] = f[c[0... | false | 16.949153 | [
"-H, W = list(map(int, input().split()))",
"-field_s = []",
"-# ใใฃใผใซใใไฝใ",
"-for h in range(H + 2):",
"- field_s.append([\"#\"] * (W + 2))",
"- if 1 <= h <= (H):",
"- field_s[h][1:-1] = list(map(str, input().rstrip()))",
"-# ใๅใๆนใฎใปใใใๆบๅ",
"-moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]",
... | false | 0.045859 | 0.045762 | 1.002117 | [
"s952980410",
"s774608051"
] |
u941753895 | p03828 | python | s490860772 | s780264972 | 58 | 48 | 6,484 | 5,840 | Accepted | Accepted | 17.24 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())
# Factoring by tria... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def I(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())
# Factoring by tria... | 43 | 44 | 696 | 712 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI():
return list(map(int, input().split()))
def I():
return int(eval(input()))
def LS():
return input().split()
def S():
return eval... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI():
return list(map(int, input().split()))
def I():
return int(eval(input()))
def LS():
return input().split()
def S():
return eval... | false | 2.272727 | [
"+ n = I()",
"- n = I()",
"- x = getPrimeList(i)",
"- for j in x:",
"- l[j] += 1",
"+ y = getPrimeList(i)",
"+ for x in y:",
"+ l[x] += 1",
"- for i in l:",
"- sm *= i + 1",
"+ for x in l:",
"+ if x != 0:",
"+ ... | false | 0.04773 | 0.089753 | 0.531799 | [
"s490860772",
"s780264972"
] |
u086566114 | p02412 | python | s222732998 | s243903556 | 560 | 450 | 6,416 | 6,416 | Accepted | Accepted | 19.64 | while True:
[n, m] = [int(x) for x in input().split()]
if [n, m] == [0, 0]:
break
hoge = list(range(1, n + 1))
data = []
for x in range(n - 1, 1, -1):
for y in range(x - 1, 0, -1):
for z in range(y - 1, -1, -1):
# print((x, y, z))
... | while True:
[n, m] = [int(x) for x in input().split()]
if [n, m] == [0, 0]:
break
data = []
for x in range(n, 2, -1):
for y in range(x - 1, 1, -1):
for z in range(y - 1, 0, -1):
s = x + y + z
if s < m:
break
... | 19 | 16 | 496 | 407 | while True:
[n, m] = [int(x) for x in input().split()]
if [n, m] == [0, 0]:
break
hoge = list(range(1, n + 1))
data = []
for x in range(n - 1, 1, -1):
for y in range(x - 1, 0, -1):
for z in range(y - 1, -1, -1):
# print((x, y, z))
s = hoge[... | while True:
[n, m] = [int(x) for x in input().split()]
if [n, m] == [0, 0]:
break
data = []
for x in range(n, 2, -1):
for y in range(x - 1, 1, -1):
for z in range(y - 1, 0, -1):
s = x + y + z
if s < m:
break
... | false | 15.789474 | [
"- hoge = list(range(1, n + 1))",
"- for x in range(n - 1, 1, -1):",
"- for y in range(x - 1, 0, -1):",
"- for z in range(y - 1, -1, -1):",
"- # print((x, y, z))",
"- s = hoge[x] + hoge[y] + hoge[z]",
"+ for x in range(n, 2, -1):",
"+ for... | false | 0.046707 | 0.037292 | 1.252478 | [
"s222732998",
"s243903556"
] |
u072717685 | p02861 | python | s028083006 | s208107440 | 405 | 76 | 3,188 | 3,188 | Accepted | Accepted | 81.23 | from math import factorial
from itertools import permutations
def main():
n = int(eval(input()))
town_coor = []
for _ in range(n):
town_coor.append(tuple(map(int, input().split())))
towns = [i for i in range(n)]
roads = permutations(towns, n)
sum_roads = 0
for road in roa... | from math import factorial
from itertools import permutations
def main():
n = int(eval(input()))
town_coor = []
for _ in range(n):
town_coor.append(tuple(map(int, input().split())))
dists = [[0]*n for _ in range(n)]
for j1 in range(n):
for j2 in range(n):
dist... | 20 | 26 | 627 | 751 | from math import factorial
from itertools import permutations
def main():
n = int(eval(input()))
town_coor = []
for _ in range(n):
town_coor.append(tuple(map(int, input().split())))
towns = [i for i in range(n)]
roads = permutations(towns, n)
sum_roads = 0
for road in roads:
... | from math import factorial
from itertools import permutations
def main():
n = int(eval(input()))
town_coor = []
for _ in range(n):
town_coor.append(tuple(map(int, input().split())))
dists = [[0] * n for _ in range(n)]
for j1 in range(n):
for j2 in range(n):
dists[j1][j2... | false | 23.076923 | [
"+ dists = [[0] * n for _ in range(n)]",
"+ for j1 in range(n):",
"+ for j2 in range(n):",
"+ dists[j1][j2] = (",
"+ (town_coor[j1][0] - town_coor[j2][0]) ** 2",
"+ + (town_coor[j1][1] - town_coor[j2][1]) ** 2",
"+ ) ** 0.5",
"- ... | false | 0.039577 | 0.116061 | 0.341003 | [
"s028083006",
"s208107440"
] |
u504836877 | p02953 | python | s101645730 | s993897284 | 130 | 86 | 15,300 | 14,224 | Accepted | Accepted | 33.85 | N = int(eval(input()))
H = [int(h) for h in input().split()]
if N == 1:
ans = "Yes"
else:
c = 0
while c <= N-2:
if H[c] < H[c+1]:
H[c+1] -= 1
c += 1
List = []
for j in range(N):
List.append(H[j])
List.sort()
if List == H:
ans = "Ye... | N = int(eval(input()))
H = [int(h) for h in input().split()]
ans = "Yes"
for i in range(1, N-1):
if H[i] > H[i-1]:
H[i] -= 1
if H[i] > H[i+1]:
ans = "No"
break
print(ans) | 21 | 11 | 361 | 207 | N = int(eval(input()))
H = [int(h) for h in input().split()]
if N == 1:
ans = "Yes"
else:
c = 0
while c <= N - 2:
if H[c] < H[c + 1]:
H[c + 1] -= 1
c += 1
List = []
for j in range(N):
List.append(H[j])
List.sort()
if List == H:
ans = "Yes"
else... | N = int(eval(input()))
H = [int(h) for h in input().split()]
ans = "Yes"
for i in range(1, N - 1):
if H[i] > H[i - 1]:
H[i] -= 1
if H[i] > H[i + 1]:
ans = "No"
break
print(ans)
| false | 47.619048 | [
"-if N == 1:",
"- ans = \"Yes\"",
"-else:",
"- c = 0",
"- while c <= N - 2:",
"- if H[c] < H[c + 1]:",
"- H[c + 1] -= 1",
"- c += 1",
"- List = []",
"- for j in range(N):",
"- List.append(H[j])",
"- List.sort()",
"- if List == H:",
"- ... | false | 0.078171 | 0.034561 | 2.261843 | [
"s101645730",
"s993897284"
] |
u652656291 | p03457 | python | s512755079 | s724991739 | 393 | 344 | 11,636 | 3,060 | Accepted | Accepted | 12.47 | N = int(eval(input()))
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
t[i+1], x[i+1], y[i+1] = list(map(int, input().split()))
f = True
for i in range(N):
dt = t[i+1] - t[i]
dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
if dt < dist:
f = False
if dist%2 != dt%2... | n = int(eval(input()))
for i in range(n):
t,x,y=list(map(int,input().split()))
if (x + y) > t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
| 17 | 7 | 359 | 164 | N = int(eval(input()))
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
t[i + 1], x[i + 1], y[i + 1] = list(map(int, input().split()))
f = True
for i in range(N):
dt = t[i + 1] - t[i]
dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
if dt < dist:
f = False
if dist %... | n = int(eval(input()))
for i in range(n):
t, x, y = list(map(int, input().split()))
if (x + y) > t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
| false | 58.823529 | [
"-N = int(eval(input()))",
"-t = [0] * (N + 1)",
"-x = [0] * (N + 1)",
"-y = [0] * (N + 1)",
"-for i in range(N):",
"- t[i + 1], x[i + 1], y[i + 1] = list(map(int, input().split()))",
"-f = True",
"-for i in range(N):",
"- dt = t[i + 1] - t[i]",
"- dist = abs(x[i + 1] - x[i]) + abs(y[i + ... | false | 0.176458 | 0.042886 | 4.114598 | [
"s512755079",
"s724991739"
] |
u525065967 | p03634 | python | s859796888 | s658008237 | 1,366 | 602 | 52,952 | 53,080 | Accepted | Accepted | 55.93 | ## abc070d: Transit Tree Path
from collections import deque
n = int(eval(input()))
T = [{} for _ in range(n)]
for _ in range(n-1):
v1,v2,d = list(map(int, input().split()))
T[v1-1][v2-1] = d
T[v2-1][v1-1] = d
q,k = list(map(int, input().split()))
visit = [False]*n
depth = [0]*n
que = de... | ## abc070d: Transit Tree Path
import sys
from collections import deque
input = sys.stdin.readline
n = int(eval(input()))
T = [{} for _ in range(n)]
for _ in range(n-1):
v1,v2,d = list(map(int, input().split()))
T[v1-1][v2-1] = d
T[v2-1][v1-1] = d
q,k = list(map(int, input().split()))
visi... | 29 | 30 | 597 | 635 | ## abc070d: Transit Tree Path
from collections import deque
n = int(eval(input()))
T = [{} for _ in range(n)]
for _ in range(n - 1):
v1, v2, d = list(map(int, input().split()))
T[v1 - 1][v2 - 1] = d
T[v2 - 1][v1 - 1] = d
q, k = list(map(int, input().split()))
visit = [False] * n
depth = [0] * n
que = deque... | ## abc070d: Transit Tree Path
import sys
from collections import deque
input = sys.stdin.readline
n = int(eval(input()))
T = [{} for _ in range(n)]
for _ in range(n - 1):
v1, v2, d = list(map(int, input().split()))
T[v1 - 1][v2 - 1] = d
T[v2 - 1][v1 - 1] = d
q, k = list(map(int, input().split()))
visit = [... | false | 3.333333 | [
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.038161 | 0.038665 | 0.986958 | [
"s859796888",
"s658008237"
] |
u767664985 | p02658 | python | s988462624 | s541075525 | 52 | 48 | 21,696 | 21,672 | Accepted | Accepted | 7.69 | N = int(eval(input()))
A = list(map(int, input().split()))
if 0 in A:
print((0))
exit()
ans = A[0]
for i in range(1, N):
ans *= A[i]
if ans > 10**18:
print((-1))
exit()
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
if 0 in A:
print((0))
else:
ans = 1
for i in range(N):
ans *= A[i]
if ans > 10**18:
print((-1))
exit()
print(ans)
| 14 | 13 | 217 | 232 | N = int(eval(input()))
A = list(map(int, input().split()))
if 0 in A:
print((0))
exit()
ans = A[0]
for i in range(1, N):
ans *= A[i]
if ans > 10**18:
print((-1))
exit()
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
if 0 in A:
print((0))
else:
ans = 1
for i in range(N):
ans *= A[i]
if ans > 10**18:
print((-1))
exit()
print(ans)
| false | 7.142857 | [
"- exit()",
"-ans = A[0]",
"-for i in range(1, N):",
"- ans *= A[i]",
"- if ans > 10**18:",
"- print((-1))",
"- exit()",
"-print(ans)",
"+else:",
"+ ans = 1",
"+ for i in range(N):",
"+ ans *= A[i]",
"+ if ans > 10**18:",
"+ print((-1))... | false | 0.036405 | 0.041832 | 0.870249 | [
"s988462624",
"s541075525"
] |
u648315264 | p02713 | python | s336008115 | s631232066 | 1,881 | 1,172 | 9,060 | 74,052 | Accepted | Accepted | 37.69 | k = int(eval(input()))
sum = 0
def gcd(x, y): # ใฆใผใฏใชใใใฎไบ้คๆณ
if y > x:
y,x = x,y
while y > 0:
r = x%y
x = y
y = r
return x
import math
for i in range(1,k+1):
for m in range(1,k+1):
sub = gcd(i,m)
for l in range(1,k+1):
sum ... | k = int(eval(input()))
sum = 0
def gcd(x, y): # ใฆใผใฏใชใใใฎไบ้คๆณ
if y > x:
y,x = x,y
while y > 0:
r = x%y
x = y
y = r
return x
for i in range(1,k+1):
for m in range(1,k+1):
for l in range(1,k+1):
sum += gcd(gcd(i,m),l)
print(sum)
| 21 | 18 | 340 | 306 | k = int(eval(input()))
sum = 0
def gcd(x, y): # ใฆใผใฏใชใใใฎไบ้คๆณ
if y > x:
y, x = x, y
while y > 0:
r = x % y
x = y
y = r
return x
import math
for i in range(1, k + 1):
for m in range(1, k + 1):
sub = gcd(i, m)
for l in range(1, k + 1):
sum += ... | k = int(eval(input()))
sum = 0
def gcd(x, y): # ใฆใผใฏใชใใใฎไบ้คๆณ
if y > x:
y, x = x, y
while y > 0:
r = x % y
x = y
y = r
return x
for i in range(1, k + 1):
for m in range(1, k + 1):
for l in range(1, k + 1):
sum += gcd(gcd(i, m), l)
print(sum)
| false | 14.285714 | [
"-import math",
"-",
"- sub = gcd(i, m)",
"- sum += gcd(sub, l)",
"+ sum += gcd(gcd(i, m), l)"
] | false | 0.166051 | 0.04092 | 4.057984 | [
"s336008115",
"s631232066"
] |
u782098901 | p03013 | python | s563723715 | s745470052 | 214 | 193 | 7,856 | 7,860 | Accepted | Accepted | 9.81 | MOD = 1000000007
N, M = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(M)]
T = [0 for _ in range(N + 5)]
for a in A:
T[a] = -1
T[0] = 1
for i in range(0, N):
if i + 1 <= N and T[i + 1] != -1 and T[i] != -1:
T[i + 1] = (T[i + 1] + T[i]) % MOD
if i + 2 <= N an... | MOD = 1000000007
N, M = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(M)]
T = [0 for _ in range(N + 5)]
for a in A:
T[a] = -1
T[0] = 1
for i in range(0, N):
if T[i + 1] != -1 and T[i] != -1:
T[i + 1] = (T[i + 1] + T[i]) % MOD
if T[i + 2] != -1 and T[i] != -... | 18 | 18 | 400 | 370 | MOD = 1000000007
N, M = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(M)]
T = [0 for _ in range(N + 5)]
for a in A:
T[a] = -1
T[0] = 1
for i in range(0, N):
if i + 1 <= N and T[i + 1] != -1 and T[i] != -1:
T[i + 1] = (T[i + 1] + T[i]) % MOD
if i + 2 <= N and T[i + 2] != -1 a... | MOD = 1000000007
N, M = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(M)]
T = [0 for _ in range(N + 5)]
for a in A:
T[a] = -1
T[0] = 1
for i in range(0, N):
if T[i + 1] != -1 and T[i] != -1:
T[i + 1] = (T[i + 1] + T[i]) % MOD
if T[i + 2] != -1 and T[i] != -1:
T[i + 2... | false | 0 | [
"- if i + 1 <= N and T[i + 1] != -1 and T[i] != -1:",
"+ if T[i + 1] != -1 and T[i] != -1:",
"- if i + 2 <= N and T[i + 2] != -1 and T[i] != -1:",
"+ if T[i + 2] != -1 and T[i] != -1:"
] | false | 0.039371 | 0.062044 | 0.634566 | [
"s563723715",
"s745470052"
] |
u047796752 | p02684 | python | s602848212 | s573951496 | 431 | 116 | 227,904 | 113,708 | Accepted | Accepted | 73.09 | import sys
input = sys.stdin.readline
from collections import *
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
log_size = 100
dp = [[0]*N for _ in range(log_size)]
for i in range(N):
dp[0][i] = A[i]-1
for i in range(1, log_size):
for j in range(N):
dp[i][... | import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
l = [0]
s = {0}
for i in range(K):
nex = A[l[-1]]-1
if nex in s:
for i in range(len(l)):
if l[i]==nex:
mark = i
break
... | 27 | 25 | 464 | 451 | import sys
input = sys.stdin.readline
from collections import *
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
log_size = 100
dp = [[0] * N for _ in range(log_size)]
for i in range(N):
dp[0][i] = A[i] - 1
for i in range(1, log_size):
for j in range(N):
dp[i][j] = dp[i - 1][... | import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
l = [0]
s = {0}
for i in range(K):
nex = A[l[-1]] - 1
if nex in s:
for i in range(len(l)):
if l[i] == nex:
mark = i
break
t = len(l) - mar... | false | 7.407407 | [
"-from collections import *",
"-",
"-log_size = 100",
"-dp = [[0] * N for _ in range(log_size)]",
"-for i in range(N):",
"- dp[0][i] = A[i] - 1",
"-for i in range(1, log_size):",
"- for j in range(N):",
"- dp[i][j] = dp[i - 1][dp[i - 1][j]]",
"-c = 0",
"-cur = 0",
"-while K > 0:",... | false | 0.045556 | 0.040213 | 1.132865 | [
"s602848212",
"s573951496"
] |
u241159583 | p03487 | python | s075517654 | s355006065 | 76 | 70 | 22,480 | 22,368 | Accepted | Accepted | 7.89 | from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for x,y in list(a.items()):
if y<x: ans += y
else:ans += y-x
print(ans) | from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
cnt = 0
for x,y in list(a.items()):
if x==y: continue
if x>y: cnt += y
else: cnt += y-x
print(cnt) | 8 | 9 | 182 | 206 | from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for x, y in list(a.items()):
if y < x:
ans += y
else:
ans += y - x
print(ans)
| from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
cnt = 0
for x, y in list(a.items()):
if x == y:
continue
if x > y:
cnt += y
else:
cnt += y - x
print(cnt)
| false | 11.111111 | [
"-ans = 0",
"+cnt = 0",
"- if y < x:",
"- ans += y",
"+ if x == y:",
"+ continue",
"+ if x > y:",
"+ cnt += y",
"- ans += y - x",
"-print(ans)",
"+ cnt += y - x",
"+print(cnt)"
] | false | 0.048457 | 0.050697 | 0.955817 | [
"s075517654",
"s355006065"
] |
u013629972 | p03212 | python | s022836251 | s670305073 | 222 | 55 | 44,632 | 3,060 | Accepted | Accepted | 75.23 | def main():
global results, S
S = int(eval(input()))
S_str = str(S)
results = []
for i in range(3, len(S_str) + 1):
bfs(i, '')
print((len(results)))
def bfs(i, s):
global results, S
if i == 0:
if int(s) <= S and len(set(s)) == 3:
results.append... | def main():
global result, S
S = int(eval(input()))
result = 0
bfs(0, '')
print(result)
def bfs(i, s):
global result, S
if s != '' and int(s) <= S and len(set(s)) == 3:
result += 1
if i == len(str(S)):
return
i += 1
bfs(i, s + '3')
bfs(i, s +... | 24 | 22 | 451 | 385 | def main():
global results, S
S = int(eval(input()))
S_str = str(S)
results = []
for i in range(3, len(S_str) + 1):
bfs(i, "")
print((len(results)))
def bfs(i, s):
global results, S
if i == 0:
if int(s) <= S and len(set(s)) == 3:
results.append(s)
re... | def main():
global result, S
S = int(eval(input()))
result = 0
bfs(0, "")
print(result)
def bfs(i, s):
global result, S
if s != "" and int(s) <= S and len(set(s)) == 3:
result += 1
if i == len(str(S)):
return
i += 1
bfs(i, s + "3")
bfs(i, s + "5")
bfs(i,... | false | 8.333333 | [
"- global results, S",
"+ global result, S",
"- S_str = str(S)",
"- results = []",
"- for i in range(3, len(S_str) + 1):",
"- bfs(i, \"\")",
"- print((len(results)))",
"+ result = 0",
"+ bfs(0, \"\")",
"+ print(result)",
"- global results, S",
"- if i ==... | false | 0.066247 | 0.041271 | 1.60516 | [
"s022836251",
"s670305073"
] |
u320511454 | p03721 | python | s501574343 | s008594346 | 553 | 493 | 20,504 | 20,496 | Accepted | Accepted | 10.85 | n,k=list(map(int,input().split()))
li=[]
for _ in range(n):
a,b=list(map(int,input().split()))
li.append([a,b])
li.sort()
ans=0
for a,b in li:
ans += b
if k <= ans:
print(a)
break | n,k=list(map(int,input().split()))
li=[]
for _ in range(n):
a,b=list(map(int,input().split()))
li.append([a,b])
li.sort()
for a,b in li:
k -= b
if k <= 0:
print(a)
break | 13 | 12 | 208 | 197 | n, k = list(map(int, input().split()))
li = []
for _ in range(n):
a, b = list(map(int, input().split()))
li.append([a, b])
li.sort()
ans = 0
for a, b in li:
ans += b
if k <= ans:
print(a)
break
| n, k = list(map(int, input().split()))
li = []
for _ in range(n):
a, b = list(map(int, input().split()))
li.append([a, b])
li.sort()
for a, b in li:
k -= b
if k <= 0:
print(a)
break
| false | 7.692308 | [
"-ans = 0",
"- ans += b",
"- if k <= ans:",
"+ k -= b",
"+ if k <= 0:"
] | false | 0.045658 | 0.035277 | 1.294267 | [
"s501574343",
"s008594346"
] |
u540631540 | p02832 | python | s063426982 | s252448090 | 108 | 98 | 26,268 | 17,164 | Accepted | Accepted | 9.26 | n = int(eval(input()))
a = [int(i) for i in input().split()]
if 1 in a:
j = 0
for ai in a:
if ai == j + 1:
j += 1
print((n - j))
else:
print((-1)) | n,a=open(0);j=0
for b in map(int,a.split()):
if b==j+1:j+=1
print(([-1,int(n)-j][j>0])) | 10 | 4 | 181 | 92 | n = int(eval(input()))
a = [int(i) for i in input().split()]
if 1 in a:
j = 0
for ai in a:
if ai == j + 1:
j += 1
print((n - j))
else:
print((-1))
| n, a = open(0)
j = 0
for b in map(int, a.split()):
if b == j + 1:
j += 1
print(([-1, int(n) - j][j > 0]))
| false | 60 | [
"-n = int(eval(input()))",
"-a = [int(i) for i in input().split()]",
"-if 1 in a:",
"- j = 0",
"- for ai in a:",
"- if ai == j + 1:",
"- j += 1",
"- print((n - j))",
"-else:",
"- print((-1))",
"+n, a = open(0)",
"+j = 0",
"+for b in map(int, a.split()):",
"+ ... | false | 0.038765 | 0.036461 | 1.063187 | [
"s063426982",
"s252448090"
] |
u569117803 | p03814 | python | s495176366 | s485354540 | 53 | 27 | 12,804 | 6,376 | Accepted | Accepted | 49.06 | s = list(eval(input()))
a_ind = [i for i, v in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]
ans = z_ind[-1] - a_ind[0] + 1
print(ans) | s = eval(input())
s_r = reversed(s)
s = list(s)
s_r = list(s_r)
a_ind = s.index("A")
z_ind = s_r.index("Z")
z_ind = len(s) - z_ind
ans = z_ind - a_ind
print(ans) | 9 | 12 | 170 | 169 | s = list(eval(input()))
a_ind = [i for i, v in enumerate(s) if v == "A"]
z_ind = [i for i, v in enumerate(s) if v == "Z"]
ans = z_ind[-1] - a_ind[0] + 1
print(ans)
| s = eval(input())
s_r = reversed(s)
s = list(s)
s_r = list(s_r)
a_ind = s.index("A")
z_ind = s_r.index("Z")
z_ind = len(s) - z_ind
ans = z_ind - a_ind
print(ans)
| false | 25 | [
"-s = list(eval(input()))",
"-a_ind = [i for i, v in enumerate(s) if v == \"A\"]",
"-z_ind = [i for i, v in enumerate(s) if v == \"Z\"]",
"-ans = z_ind[-1] - a_ind[0] + 1",
"+s = eval(input())",
"+s_r = reversed(s)",
"+s = list(s)",
"+s_r = list(s_r)",
"+a_ind = s.index(\"A\")",
"+z_ind = s_r.inde... | false | 0.034333 | 0.035285 | 0.973032 | [
"s495176366",
"s485354540"
] |
u144913062 | p03855 | python | s986447599 | s828102942 | 1,768 | 948 | 151,184 | 119,384 | Accepted | Accepted | 46.38 | from collections import defaultdict
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N):
self.parent = list(range(N))
self.rank = [0] * N
self.size = [1] * N
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(s... | from collections import defaultdict
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N):
self.parent = list(range(N))
self.rank = [0] * N
self.size = [1] * N
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(s... | 62 | 49 | 1,624 | 1,325 | from collections import defaultdict
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N):
self.parent = list(range(N))
self.rank = [0] * N
self.size = [1] * N
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent... | from collections import defaultdict
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, N):
self.parent = list(range(N))
self.rank = [0] * N
self.size = [1] * N
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent... | false | 20.967742 | [
"-cnt = [defaultdict(int) for _ in range(N + 1)]",
"-for i in range(1, N + 1):",
"- cnt[i][uf1.find(i)] = 1",
"- if uf2.same(r, s):",
"- continue",
"- a = uf2.find(r)",
"- b = uf2.find(s)",
"- c = uf2.find(r)",
"- if a == c:",
"- for k, v in list(cnt[b].items()):",
... | false | 0.039021 | 0.037457 | 1.041744 | [
"s986447599",
"s828102942"
] |
u067983636 | p03732 | python | s408848253 | s102265029 | 355 | 217 | 76,764 | 40,432 | Accepted | Accepted | 38.87 | import sys
input = sys.stdin.readline
def read_values():
return list(map(int, input().split()))
def read_list():
return list(read_values())
def func(N, mod):
F = [1]
for i in range(1, N + 1):
F.append(F[-1] * i % mod)
return F
INV = {}
def inv(a, mod):
... | import sys
input = sys.stdin.readline
def read_values():
return list(map(int, input().split()))
def read_list():
return list(read_values())
def func(N, mod):
F = [1]
for i in range(1, N + 1):
F.append(F[-1] * i % mod)
return F
INV = {}
def inv(a, mod):
... | 68 | 66 | 1,324 | 1,304 | import sys
input = sys.stdin.readline
def read_values():
return list(map(int, input().split()))
def read_list():
return list(read_values())
def func(N, mod):
F = [1]
for i in range(1, N + 1):
F.append(F[-1] * i % mod)
return F
INV = {}
def inv(a, mod):
if a in INV:
ret... | import sys
input = sys.stdin.readline
def read_values():
return list(map(int, input().split()))
def read_list():
return list(read_values())
def func(N, mod):
F = [1]
for i in range(1, N + 1):
F.append(F[-1] * i % mod)
return F
INV = {}
def inv(a, mod):
if a in INV:
ret... | false | 2.941176 | [
"+ import bisect",
"+",
"- dp = [",
"- [[0 for _ in range(N * 3 + 10)] for __ in range(N + 10)]",
"- for ___ in range(N + 10)",
"- ]",
"- w0 = I[0][0]",
"- if w0 > W:",
"- print((0))",
"- return",
"- for i, (w1, v) in enumerate(I):",
"- w = ... | false | 0.03957 | 0.03893 | 1.016438 | [
"s408848253",
"s102265029"
] |
u455809703 | p02731 | python | s974129239 | s845347184 | 36 | 17 | 5,332 | 2,940 | Accepted | Accepted | 52.78 | from decimal import Decimal
L = eval(input())
l = Decimal(L) / 3
print((l ** 3)) | L = int(eval(input()))
l = L / 3
print((l ** 3))
| 7 | 5 | 81 | 49 | from decimal import Decimal
L = eval(input())
l = Decimal(L) / 3
print((l**3))
| L = int(eval(input()))
l = L / 3
print((l**3))
| false | 28.571429 | [
"-from decimal import Decimal",
"-",
"-L = eval(input())",
"-l = Decimal(L) / 3",
"+L = int(eval(input()))",
"+l = L / 3"
] | false | 0.040107 | 0.03771 | 1.06356 | [
"s974129239",
"s845347184"
] |
u811156202 | p04031 | python | s363089013 | s806001807 | 37 | 18 | 5,148 | 2,940 | Accepted | Accepted | 51.35 | import statistics
am = int(eval(input()))
n_l = list(map(int, input().split(' ')))
m = round(statistics.mean(n_l))
S = 0
for a in range(am):
S += (n_l[a] - m)**2
print((int(S))) | am = int(eval(input()))
n_l = list(map(int, input().split(' ')))
m = round(sum(n_l)/len(n_l))
S = 0
for a in range(am):
S += (n_l[a] - m)**2
print((int(S))) | 12 | 10 | 188 | 164 | import statistics
am = int(eval(input()))
n_l = list(map(int, input().split(" ")))
m = round(statistics.mean(n_l))
S = 0
for a in range(am):
S += (n_l[a] - m) ** 2
print((int(S)))
| am = int(eval(input()))
n_l = list(map(int, input().split(" ")))
m = round(sum(n_l) / len(n_l))
S = 0
for a in range(am):
S += (n_l[a] - m) ** 2
print((int(S)))
| false | 16.666667 | [
"-import statistics",
"-",
"-m = round(statistics.mean(n_l))",
"+m = round(sum(n_l) / len(n_l))"
] | false | 0.061031 | 0.045731 | 1.334568 | [
"s363089013",
"s806001807"
] |
u226108478 | p03309 | python | s095166859 | s100471655 | 242 | 208 | 27,244 | 27,244 | Accepted | Accepted | 14.05 | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
if __name__ == '__main__':
from statistics import median
n = int(eval(input()))
a = list(map(int, input().split()))
total = 0
# See:
# https://www.youtube.com/watch?v=UX4AuiCVtN4
# https://beta.atcoder.jp/contests/abc102/sub... | # -*- coding: utf-8 -*-
def main():
from statistics import median
n = int(eval(input()))
a = list(map(int, input().split()))
mod_a = list()
ans = 0
for index, ai in enumerate(a, 1):
mod_a.append(ai - index)
b = int(median(mod_a))
for mod_ai in mod_a:
... | 21 | 24 | 500 | 401 | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
if __name__ == "__main__":
from statistics import median
n = int(eval(input()))
a = list(map(int, input().split()))
total = 0
# See:
# https://www.youtube.com/watch?v=UX4AuiCVtN4
# https://beta.atcoder.jp/contests/abc102/submissions/2768315... | # -*- coding: utf-8 -*-
def main():
from statistics import median
n = int(eval(input()))
a = list(map(int, input().split()))
mod_a = list()
ans = 0
for index, ai in enumerate(a, 1):
mod_a.append(ai - index)
b = int(median(mod_a))
for mod_ai in mod_a:
ans += abs(mod_ai - ... | false | 12.5 | [
"-# AtCoder Beginner Contest",
"-if __name__ == \"__main__\":",
"+def main():",
"- total = 0",
"- # See:",
"- # https://www.youtube.com/watch?v=UX4AuiCVtN4",
"- # https://beta.atcoder.jp/contests/abc102/submissions/2768315",
"- mod_a = sorted([ai - i for i, ai in enumerate(a, 1)])",
"... | false | 0.048276 | 0.07767 | 0.621549 | [
"s095166859",
"s100471655"
] |
u488401358 | p02635 | python | s814802048 | s154801687 | 1,150 | 245 | 82,008 | 79,796 | Accepted | Accepted | 78.7 | S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
if S[i]=="0":
a.append(val)
val=0
else:
val+=1
if val!=0:
a.append(val)
m=len(a)
K=min(sum(a),K)
dp=[[0 for i in range(K+1)] for j in range(K+1)]
for j in range(K+1):
... | S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
if S[i]=="0":
a.append(val)
val=0
else:
val+=1
if val!=0:
a.append(val)
m=len(a)
K=min(sum(a),K)
b=[a[i] for i in range(m)]
c=[a[i] for i in range(m)]
for i in range(1,m):... | 42 | 71 | 906 | 1,658 | S, K = input().split()
K = int(K)
K = min(K, 300)
mod = 998244353
a = []
val = 0
for i in range(len(S)):
if S[i] == "0":
a.append(val)
val = 0
else:
val += 1
if val != 0:
a.append(val)
m = len(a)
K = min(sum(a), K)
dp = [[0 for i in range(K + 1)] for j in range(K + 1)]
for j in range... | S, K = input().split()
K = int(K)
K = min(K, 300)
mod = 998244353
a = []
val = 0
for i in range(len(S)):
if S[i] == "0":
a.append(val)
val = 0
else:
val += 1
if val != 0:
a.append(val)
m = len(a)
K = min(sum(a), K)
b = [a[i] for i in range(m)]
c = [a[i] for i in range(m)]
for i in ra... | false | 40.84507 | [
"-dp = [[0 for i in range(K + 1)] for j in range(K + 1)]",
"-for j in range(K + 1):",
"- dp[j][j] = 1",
"+dp = [[0 for i in range(K + 1)] for j in range(K + 1)]",
"+plus = [[0 for j in range(K + 1)] for k in range(K + 1)]",
"+minus = [[0 for j in range(K + 1)] for k in range(K + 1)]",
"+for j in rang... | false | 0.169991 | 0.043695 | 3.890377 | [
"s814802048",
"s154801687"
] |
u585482323 | p02727 | python | s108821991 | s701273671 | 1,310 | 348 | 115,308 | 100,076 | Accepted | Accepted | 73.44 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [lis... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [lis... | 59 | 42 | 1,372 | 1,001 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
r... | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
r... | false | 28.813559 | [
"- s = [(i, 0) for i in p] + [(i, 1) for i in q] + [(i, 2) for i in r]",
"+ p.sort(reverse=True)",
"+ q.sort(reverse=True)",
"+ s = p[:x] + q[:y] + r",
"- ans = 0",
"- f = [0, 0]",
"- l = [x, y]",
"- q = deque()",
"- q2 = deque()",
"- for a, i in s:",
"- if i... | false | 0.107852 | 0.036884 | 2.924108 | [
"s108821991",
"s701273671"
] |
u874395007 | p02265 | python | s990665866 | s517536543 | 4,450 | 4,010 | 69,732 | 69,736 | Accepted | Accepted | 9.89 | from collections import deque
n = int(eval(input()))
d = deque()
for _i in range(n):
line = input().split()
order = line[0]
if order == 'deleteFirst':
d.popleft()
elif order == 'deleteLast':
d.pop()
else:
key = line[1]
if order == 'insert':
... | from collections import deque
n = int(eval(input()))
d = deque()
for _i in range(n):
order = eval(input())
if order == 'deleteFirst':
d.popleft()
elif order == 'deleteLast':
d.pop()
else:
order, key = order.split()
if order == 'insert':
d.appendl... | 25 | 24 | 563 | 548 | from collections import deque
n = int(eval(input()))
d = deque()
for _i in range(n):
line = input().split()
order = line[0]
if order == "deleteFirst":
d.popleft()
elif order == "deleteLast":
d.pop()
else:
key = line[1]
if order == "insert":
d.appendleft(k... | from collections import deque
n = int(eval(input()))
d = deque()
for _i in range(n):
order = eval(input())
if order == "deleteFirst":
d.popleft()
elif order == "deleteLast":
d.pop()
else:
order, key = order.split()
if order == "insert":
d.appendleft(key)
... | false | 4 | [
"- line = input().split()",
"- order = line[0]",
"+ order = eval(input())",
"- key = line[1]",
"+ order, key = order.split()"
] | false | 0.046518 | 0.047187 | 0.985823 | [
"s990665866",
"s517536543"
] |
u044220565 | p02733 | python | s916191396 | s658444379 | 1,349 | 272 | 3,444 | 43,356 | Accepted | Accepted | 79.84 | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#imp... | # coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#imp... | 64 | 64 | 1,891 | 1,875 | # coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10**7)
# import math
from itertools import product, accumulate, combinations, product
# import... | # coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10**7)
# import math
from itertools import product, accumulate, combinations, product
# import... | false | 0 | [
"- S.append(",
"- list(accumulate(list(map(int, list(eval(input())))), lambda x, y: x + y))",
"- )",
"+ S.append(list(accumulate(list(map(int, list(eval(input())))))))"
] | false | 0.039121 | 0.06545 | 0.597726 | [
"s916191396",
"s658444379"
] |
u349449706 | p03910 | python | s154392897 | s845570946 | 95 | 80 | 76,828 | 74,600 | Accepted | Accepted | 15.79 | import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if is_ok(mid, n):
ok = mid
else:
ng = mid
return ok
def f(n):
if n>0:
m = megur... | N=int(eval(input()))
m=1
while m*(m+1)<2*N:m+=1
for i in range(1,m+1):
if m*(m+1)//2-i!=N:print(i)
| 19 | 6 | 399 | 103 | import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
return m * (m + 1) // 2 >= n
def meguru_bisect(ng, ok, n):
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if is_ok(mid, n):
ok = mid
else:
ng = mid
return ok
def f(n):
if n > 0:
m = megu... | N = int(eval(input()))
m = 1
while m * (m + 1) < 2 * N:
m += 1
for i in range(1, m + 1):
if m * (m + 1) // 2 - i != N:
print(i)
| false | 68.421053 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def is_ok(m, n):",
"- return m * (m + 1) // 2 >= n",
"-",
"-",
"-def meguru_bisect(ng, ok, n):",
"- while abs(ok - ng) > 1:",
"- mid = (ok + ng) // 2",
"- if is_ok(mid, n):",
"- ok = mid",
"- ... | false | 0.038292 | 0.046854 | 0.817259 | [
"s154392897",
"s845570946"
] |
u861466636 | p03074 | python | s566775006 | s050853479 | 144 | 90 | 7,440 | 5,028 | Accepted | Accepted | 37.5 | N, K = list(map(int, input().split()))
S = eval(input())
l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
if (k[i]==0) & (k[i-1]==0):
v0 += 1
elif (k[i]==1) & (k[i-1]==0):
l[... | import sys
from collections import deque
input = sys.stdin.readline
def main():
n,k = list(map(int,input().split()))
s = list(eval(input()))
#tank: '0...0'ใจ'1...1'ใฎๅกใฎๆฐใชในใ
#ex. 0001011ใชใtank = [3,1,1,2] (0ใ3ใค,1ใ1ใค,0ใ2ใค,1ใ2ใค)
tank = []
cnt = 1
for i in range(1,n):
if s... | 40 | 61 | 837 | 1,365 | N, K = list(map(int, input().split()))
S = eval(input())
l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
if (k[i] == 0) & (k[i - 1] == 0):
v0 += 1
elif (k[i] == 1) & (k[i - 1] == 0):
l[0].a... | import sys
from collections import deque
input = sys.stdin.readline
def main():
n, k = list(map(int, input().split()))
s = list(eval(input()))
# tank: '0...0'ใจ'1...1'ใฎๅกใฎๆฐใชในใ
# ex. 0001011ใชใtank = [3,1,1,2] (0ใ3ใค,1ใ1ใค,0ใ2ใค,1ใ2ใค)
tank = []
cnt = 1
for i in range(1, n):
if s[i] != s[... | false | 34.42623 | [
"-N, K = list(map(int, input().split()))",
"-S = eval(input())",
"-l = [[], []]",
"-ans = []",
"-k = [int(s) for s in S]",
"-if k[0] == 0:",
"- l[1].append(0)",
"-v0 = 1 if k[0] == 0 else 0",
"-v1 = 1 if k[0] == 1 else 0",
"-for i in range(1, N):",
"- if (k[i] == 0) & (k[i - 1] == 0):",
... | false | 0.10565 | 0.044808 | 2.357851 | [
"s566775006",
"s050853479"
] |
u970197315 | p03363 | python | s058233219 | s688949864 | 208 | 144 | 34,452 | 44,344 | Accepted | Accepted | 30.77 | n=int(eval(input()))
a=[0]+list(map(int,input().split()))
from itertools import accumulate
a=accumulate(a)
a=list(a)
a.sort()
from collections import Counter
c=Counter(a)
ans=0
for k,v in list(c.items()):
if v>=2:
ans+=v*(v-1)//2
print(ans)
| N = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
from collections import Counter
from itertools import accumulate
s = list(accumulate(a))
c = Counter(s)
ans = 0
for v in list(c.values()):
ans += v*(v-1)//2
print(ans)
| 13 | 13 | 253 | 253 | n = int(eval(input()))
a = [0] + list(map(int, input().split()))
from itertools import accumulate
a = accumulate(a)
a = list(a)
a.sort()
from collections import Counter
c = Counter(a)
ans = 0
for k, v in list(c.items()):
if v >= 2:
ans += v * (v - 1) // 2
print(ans)
| N = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
from collections import Counter
from itertools import accumulate
s = list(accumulate(a))
c = Counter(s)
ans = 0
for v in list(c.values()):
ans += v * (v - 1) // 2
print(ans)
| false | 0 | [
"-n = int(eval(input()))",
"+N = list(map(int, input().split()))",
"+from collections import Counter",
"-a = accumulate(a)",
"-a = list(a)",
"-a.sort()",
"-from collections import Counter",
"-",
"-c = Counter(a)",
"+s = list(accumulate(a))",
"+c = Counter(s)",
"-for k, v in list(c.items()):",
... | false | 0.034557 | 0.128955 | 0.267979 | [
"s058233219",
"s688949864"
] |
u340781749 | p02925 | python | s052245015 | s376161456 | 1,205 | 1,049 | 35,848 | 35,848 | Accepted | Accepted | 12.95 | import sys
from collections import deque
n = int(eval(input()))
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
q = deque(list(range(n)))
depth = [0] * n
waiting = [-1] * n
while q:
a = q.popleft()
ma = matches[a]
if not ma:
continue
b = ma.pop()
if... | import sys
from collections import deque
n = int(eval(input()))
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
q = deque(list(range(n)))
depth = [0] * n
waiting = [-1] * n
while q:
a = q.popleft()
b = matches[a].pop()
if waiting[b] == a:
depth[a] = depth[b] ... | 26 | 25 | 527 | 536 | import sys
from collections import deque
n = int(eval(input()))
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
q = deque(list(range(n)))
depth = [0] * n
waiting = [-1] * n
while q:
a = q.popleft()
ma = matches[a]
if not ma:
continue
b = ma.pop()
if waiting[b] == a... | import sys
from collections import deque
n = int(eval(input()))
matches = [[a - 1 for a in map(int, line.split())] for line in sys.stdin]
q = deque(list(range(n)))
depth = [0] * n
waiting = [-1] * n
while q:
a = q.popleft()
b = matches[a].pop()
if waiting[b] == a:
depth[a] = depth[b] = max(depth[a]... | false | 3.846154 | [
"- ma = matches[a]",
"- if not ma:",
"- continue",
"- b = ma.pop()",
"+ b = matches[a].pop()",
"- q.append(a)",
"- q.append(b)",
"+ if matches[a]:",
"+ q.append(a)",
"+ if matches[b]:",
"+ q.append(b)"
] | false | 0.040915 | 0.036243 | 1.12889 | [
"s052245015",
"s376161456"
] |
u785989355 | p02936 | python | s977638707 | s225120070 | 1,853 | 817 | 107,540 | 96,532 | Accepted | Accepted | 55.91 | N,Q = list(map(int,input().split()))
e_list = [[] for i in range(N)]
for i in range(N-1):
a,b = list(map(int,input().split()))
a,b = a-1,b-1
e_list[a].append(b)
e_list[b].append(a)
add_list = [0]*N
for i in range(Q):
p,x = list(map(int,input().split()))
... | import sys
def input():
return sys.stdin.readline()[:-1]
N,Q = list(map(int,input().split()))
e_list = [[] for i in range(N)]
for i in range(N-1):
a,b = list(map(int,input().split()))
a,b = a-1,b-1
e_list[a].append(b)
e_list[b].append(a)
add_list = [0]*N
... | 34 | 38 | 752 | 822 | N, Q = list(map(int, input().split()))
e_list = [[] for i in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
e_list[a].append(b)
e_list[b].append(a)
add_list = [0] * N
for i in range(Q):
p, x = list(map(int, input().split()))
p = p - 1
add_list[p] ... | import sys
def input():
return sys.stdin.readline()[:-1]
N, Q = list(map(int, input().split()))
e_list = [[] for i in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
e_list[a].append(b)
e_list[b].append(a)
add_list = [0] * N
for i in range(Q):
p, x... | false | 10.526316 | [
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+"
] | false | 0.108001 | 0.034618 | 3.11975 | [
"s977638707",
"s225120070"
] |
u596536048 | p03447 | python | s975824870 | s207904993 | 31 | 26 | 9,052 | 9,052 | Accepted | Accepted | 16.13 | print(((int(eval(input())) - int(eval(input()))) % int(eval(input())))) | X, A, B = (int(eval(input())) for i in range(3))
print(((X - A) % B)) | 1 | 2 | 51 | 62 | print(((int(eval(input())) - int(eval(input()))) % int(eval(input()))))
| X, A, B = (int(eval(input())) for i in range(3))
print(((X - A) % B))
| false | 50 | [
"-print(((int(eval(input())) - int(eval(input()))) % int(eval(input()))))",
"+X, A, B = (int(eval(input())) for i in range(3))",
"+print(((X - A) % B))"
] | false | 0.046912 | 0.152407 | 0.307804 | [
"s975824870",
"s207904993"
] |
u280552586 | p03693 | python | s159332003 | s751294438 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | a, b, c = list(map(int, input().split()))
A = 100*a + 10*b + c
if A % 4 == 0:
print('YES')
else:
print('NO')
| r, g, b = list(map(int, input().split()))
rgb = 100*r+10*g+b
print(('YES' if rgb % 4 == 0 else 'NO'))
| 7 | 3 | 118 | 96 | a, b, c = list(map(int, input().split()))
A = 100 * a + 10 * b + c
if A % 4 == 0:
print("YES")
else:
print("NO")
| r, g, b = list(map(int, input().split()))
rgb = 100 * r + 10 * g + b
print(("YES" if rgb % 4 == 0 else "NO"))
| false | 57.142857 | [
"-a, b, c = list(map(int, input().split()))",
"-A = 100 * a + 10 * b + c",
"-if A % 4 == 0:",
"- print(\"YES\")",
"-else:",
"- print(\"NO\")",
"+r, g, b = list(map(int, input().split()))",
"+rgb = 100 * r + 10 * g + b",
"+print((\"YES\" if rgb % 4 == 0 else \"NO\"))"
] | false | 0.063758 | 0.070984 | 0.8982 | [
"s159332003",
"s751294438"
] |
u864197622 | p02728 | python | s500144790 | s397021692 | 951 | 859 | 109,972 | 111,420 | Accepted | Accepted | 9.67 | import sys
input = sys.stdin.readline
from collections import deque
mod = 10 ** 9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
x, y = map(int, input().split())
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
i = deque.popleft(Q)... | import sys
input = sys.stdin.readline
from collections import deque
mod = 10 ** 9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
x, y = map(int, input().split())
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
i = deque.popleft(Q)... | 70 | 70 | 1,511 | 1,499 | import sys
input = sys.stdin.readline
from collections import deque
mod = 10**9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N - 1):
x, y = map(int, input().split())
X[x - 1].append(y - 1)
X[y - 1].append(x - 1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
i = deque.popleft(Q)
R.a... | import sys
input = sys.stdin.readline
from collections import deque
mod = 10**9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N - 1):
x, y = map(int, input().split())
X[x - 1].append(y - 1)
X[y - 1].append(x - 1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
i = deque.popleft(Q)
R.a... | false | 0 | [
"-for i in reversed(R[1:]):",
"+for i in R[1:][::-1]:",
"-for i in reversed(R[1:]):",
"+for i in R[1:][::-1]:",
"- for j in reversed(X[i]):",
"+ for j in X[i][::-1]:"
] | false | 0.425907 | 0.258202 | 1.649513 | [
"s500144790",
"s397021692"
] |
u991567869 | p03575 | python | s178481516 | s406484543 | 331 | 29 | 53,388 | 9,220 | Accepted | Accepted | 91.24 | import networkx as nx
n, m = list(map(int, input().split()))
g = nx.Graph()
g.add_nodes_from(list(range(1, n + 1)))
g.add_edges_from([tuple(map(int, input().split())) for i in range(m)])
print((len(tuple(nx.bridges(g))))) | def dfs(f):
if vis[f] == 1:
return
vis[f] = 1 #fใ่จชๅๆธใซใใ
for t in v[f]: #fใจใคใชใใฃใฆใใ้ ็นใ่ชญใฟ่พผใ
if f != a or t != b: #(a,b)ใฎ็ตใฟๅใใใงใชใใใฐ็นฐใ่ฟใ
dfs(t)
n, m = list(map(int, input().split()))
v = [[] for i in range(n)]
e = []
for i in range(m):
a, b = list(map(int, input().s... | 8 | 29 | 216 | 540 | import networkx as nx
n, m = list(map(int, input().split()))
g = nx.Graph()
g.add_nodes_from(list(range(1, n + 1)))
g.add_edges_from([tuple(map(int, input().split())) for i in range(m)])
print((len(tuple(nx.bridges(g)))))
| def dfs(f):
if vis[f] == 1:
return
vis[f] = 1 # fใ่จชๅๆธใซใใ
for t in v[f]: # fใจใคใชใใฃใฆใใ้ ็นใ่ชญใฟ่พผใ
if f != a or t != b: # (a,b)ใฎ็ตใฟๅใใใงใชใใใฐ็นฐใ่ฟใ
dfs(t)
n, m = list(map(int, input().split()))
v = [[] for i in range(n)]
e = []
for i in range(m):
a, b = list(map(int, input().split())... | false | 72.413793 | [
"-import networkx as nx",
"+def dfs(f):",
"+ if vis[f] == 1:",
"+ return",
"+ vis[f] = 1 # fใ่จชๅๆธใซใใ",
"+ for t in v[f]: # fใจใคใชใใฃใฆใใ้ ็นใ่ชญใฟ่พผใ",
"+ if f != a or t != b: # (a,b)ใฎ็ตใฟๅใใใงใชใใใฐ็นฐใ่ฟใ",
"+ dfs(t)",
"+",
"-g = nx.Graph()",
"-g.add_nodes_from(list(range(1, ... | false | 0.037497 | 0.035428 | 1.058396 | [
"s178481516",
"s406484543"
] |
u864197622 | p02728 | python | s227576585 | s656623513 | 1,660 | 1,320 | 128,780 | 129,756 | Accepted | Accepted | 20.48 | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9+7
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i+1) % ... | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9+7
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i+1] * (i+1) % ... | 64 | 64 | 1,464 | 1,530 | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
inv = [1] * (nn + 1)
for i in range(nn):
fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i + 1] * (i + 1... | import sys
input = sys.stdin.readline
from collections import deque
nn = 200200
mod = 10**9 + 7
fa = [1] * (nn + 1)
fainv = [1] * (nn + 1)
inv = [1] * (nn + 1)
for i in range(nn):
fa[i + 1] = fa[i] * (i + 1) % mod
fainv[-1] = pow(fa[-1], mod - 2, mod)
for i in range(nn)[::-1]:
fainv[i] = fainv[i + 1] * (i + 1... | false | 0 | [
"-N = int(eval(input()))",
"+N = int(input())",
"- x, y = list(map(int, input().split()))",
"+ x, y = map(int, input().split())",
"+ AL = [1] * (c + 1)",
"- AL = 1",
"+ for k, j in enumerate(X[i]):",
"+ AL[k + 1] = AL[k] * BU[j] % mod",
"- TD[j] = TD[i] * AL % mod * AR[k... | false | 1.021927 | 0.418489 | 2.441946 | [
"s227576585",
"s656623513"
] |
u470542271 | p03078 | python | s045480007 | s347045276 | 785 | 717 | 196,748 | 248,536 | Accepted | Accepted | 8.66 |
if __name__ == '__main__':
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bc = []
for bb in b:
for cc in c:
bc.append(bb + cc)
bc.sort()
from bi... | x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
bc = []
for bb in b:
for cc in c:
bc.append(bb + cc)
bc.sort()
from bisect import bisect_left, bisect_right
... | 45 | 47 | 942 | 828 | if __name__ == "__main__":
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bc = []
for bb in b:
for cc in c:
bc.append(bb + cc)
bc.sort()
from bisect import bisect... | x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
bc = []
for bb in b:
for cc in c:
bc.append(bb + cc)
bc.sort()
from bisect import bisect_left, bisect_right
def C(x):
# co... | false | 4.255319 | [
"-if __name__ == \"__main__\":",
"- x, y, z, k = list(map(int, input().split()))",
"- a = list(map(int, input().split()))",
"- b = list(map(int, input().split()))",
"- c = list(map(int, input().split()))",
"- bc = []",
"- for bb in b:",
"- for cc in c:",
"- bc.app... | false | 0.035523 | 0.036693 | 0.968119 | [
"s045480007",
"s347045276"
] |
u824144553 | p02804 | python | s425539928 | s371285452 | 298 | 248 | 74,536 | 21,572 | Accepted | Accepted | 16.78 | import math
from functools import lru_cache
from operator import mul
from functools import reduce
def resolve():
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
B = A[::-1]
@lru_... | import math
from functools import lru_cache
from operator import mul
from functools import reduce
def resolve():
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
def combinations_count(n, r, mod=10**9... | 76 | 39 | 2,069 | 951 | import math
from functools import lru_cache
from operator import mul
from functools import reduce
def resolve():
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
B = A[::-1]
@lru_cache(maxsize=No... | import math
from functools import lru_cache
from operator import mul
from functools import reduce
def resolve():
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
def combinations_count(n, r, mod=10**9 + 7):
... | false | 48.684211 | [
"- A.sort()",
"- B = A[::-1]",
"-",
"- @lru_cache(maxsize=None)",
"- def combinations_count__(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"- @lru_cache(maxsize=None)",
"- def combinations_count____(n, r):",
"- r = min(r... | false | 0.065929 | 0.034733 | 1.898164 | [
"s425539928",
"s371285452"
] |
u729133443 | p02813 | python | s640651233 | s141655659 | 188 | 29 | 44,656 | 7,972 | Accepted | Accepted | 84.57 | from itertools import*;(n,),a,b=eval('tuple(map(int,input().split())),'*3);i=list(permutations(list(range(1,n+1)))).index;print((abs(i(a)-i(b)))) | from itertools import*
n,a,b=eval('eval(input().replace(" ",",")),'*3)
i=list(permutations(list(range(1,n+1)))).index
print((abs(i(a)-i(b)))) | 1 | 4 | 137 | 136 | from itertools import *
(n,), a, b = eval("tuple(map(int,input().split()))," * 3)
i = list(permutations(list(range(1, n + 1)))).index
print((abs(i(a) - i(b))))
| from itertools import *
n, a, b = eval('eval(input().replace(" ",",")),' * 3)
i = list(permutations(list(range(1, n + 1)))).index
print((abs(i(a) - i(b))))
| false | 75 | [
"-(n,), a, b = eval(\"tuple(map(int,input().split())),\" * 3)",
"+n, a, b = eval('eval(input().replace(\" \",\",\")),' * 3)"
] | false | 0.082536 | 0.057581 | 1.433374 | [
"s640651233",
"s141655659"
] |
u285891772 | p03804 | python | s934598416 | s654447385 | 56 | 39 | 5,704 | 5,200 | Accepted | Accepted | 30.36 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy... | 36 | 37 | 1,178 | 1,147 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mu... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mu... | false | 2.702703 | [
"- for j in range(N - M + 1): # ๅทฆไธใฎใพใใ(i, j)",
"- tmp_lis = []",
"+ for j in range(N - M + 1):",
"- tmp_lis.append(A[i + k][j : j + M])",
"- if tmp_lis == B:",
"+ if A[i + k][j : j + M] != B[k]:",
"+ break",
"+ else:"
] | false | 0.036622 | 0.05745 | 0.637462 | [
"s934598416",
"s654447385"
] |
u223133214 | p03618 | python | s351983978 | s869557779 | 57 | 34 | 4,840 | 5,224 | Accepted | Accepted | 40.35 | A = list(eval(input()))
n = len(A)
str_cnt = {}
for a in A:
if a in str_cnt:
str_cnt[a] += 1
else:
str_cnt[a] = 1
# print(str_cnt)
zen = n * (n - 1) // 2 + 1
for k in str_cnt:
num = str_cnt[k]
if num > 1:
zen -= num * (num - 1) // 2
print(zen)
| from collections import Counter
A = list(eval(input()))
n = len(A)
b = Counter(A)
z = n * (n - 1) // 2 + 1
for k in b:
m = b[k]
z -= m * (m - 1) // 2
print(z)
| 17 | 10 | 296 | 171 | A = list(eval(input()))
n = len(A)
str_cnt = {}
for a in A:
if a in str_cnt:
str_cnt[a] += 1
else:
str_cnt[a] = 1
# print(str_cnt)
zen = n * (n - 1) // 2 + 1
for k in str_cnt:
num = str_cnt[k]
if num > 1:
zen -= num * (num - 1) // 2
print(zen)
| from collections import Counter
A = list(eval(input()))
n = len(A)
b = Counter(A)
z = n * (n - 1) // 2 + 1
for k in b:
m = b[k]
z -= m * (m - 1) // 2
print(z)
| false | 41.176471 | [
"+from collections import Counter",
"+",
"-str_cnt = {}",
"-for a in A:",
"- if a in str_cnt:",
"- str_cnt[a] += 1",
"- else:",
"- str_cnt[a] = 1",
"-# print(str_cnt)",
"-zen = n * (n - 1) // 2 + 1",
"-for k in str_cnt:",
"- num = str_cnt[k]",
"- if num > 1:",
"- ... | false | 0.112092 | 0.08742 | 1.282226 | [
"s351983978",
"s869557779"
] |
u647999897 | p03163 | python | s923037539 | s854730679 | 686 | 469 | 173,576 | 118,768 | Accepted | Accepted | 31.63 | def solve():
N, W = list(map(int, input().split()))
w = []
v = []
for i in range(N):
tmpw, tmpv = list(map(int, input().split()))
w.append(tmpw)
v.append(tmpv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N+1):
dp[i][0] = 0
... | def solve():
N,W = list(map(int,input().split()))
weight = []
value = []
for i in range(N):
w, v = list(map(int,input().split()))
weight.append(w)
value.append(v)
dp = [[0] * (W+1) for i in range(N+1)]
for i in range(1,N+1):
for w in range(W+1):
... | 28 | 23 | 694 | 623 | def solve():
N, W = list(map(int, input().split()))
w = []
v = []
for i in range(N):
tmpw, tmpv = list(map(int, input().split()))
w.append(tmpw)
v.append(tmpv)
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for i in range(N + 1):
dp[i][0] = 0
for j in ... | def solve():
N, W = list(map(int, input().split()))
weight = []
value = []
for i in range(N):
w, v = list(map(int, input().split()))
weight.append(w)
value.append(v)
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(1, N + 1):
for w in range(W + 1):
... | false | 17.857143 | [
"- w = []",
"- v = []",
"+ weight = []",
"+ value = []",
"- tmpw, tmpv = list(map(int, input().split()))",
"- w.append(tmpw)",
"- v.append(tmpv)",
"- dp = [[0 for i in range(W + 1)] for j in range(N + 1)]",
"- for i in range(N + 1):",
"- dp[i][0] = 0",... | false | 0.045651 | 0.044561 | 1.02447 | [
"s923037539",
"s854730679"
] |
u450983668 | p03043 | python | s308026360 | s844506165 | 65 | 47 | 3,060 | 2,940 | Accepted | Accepted | 27.69 | from math import *
n,k=list(map(int,input().split()))
e=0
for i in range(1,n+1):
t=ceil(log2(k/i))
e+=1*(t<1)or 2**-t
print((e/n)) | n, k = list(map(int, input().split()))
e=0
for i in range(1, n+1):
tmp = i
t = 0
while tmp < k:
tmp *= 2
t += 1
e += 1*(t==0) or 2**-t
print((e/n)) | 7 | 10 | 132 | 164 | from math import *
n, k = list(map(int, input().split()))
e = 0
for i in range(1, n + 1):
t = ceil(log2(k / i))
e += 1 * (t < 1) or 2**-t
print((e / n))
| n, k = list(map(int, input().split()))
e = 0
for i in range(1, n + 1):
tmp = i
t = 0
while tmp < k:
tmp *= 2
t += 1
e += 1 * (t == 0) or 2**-t
print((e / n))
| false | 30 | [
"-from math import *",
"-",
"- t = ceil(log2(k / i))",
"- e += 1 * (t < 1) or 2**-t",
"+ tmp = i",
"+ t = 0",
"+ while tmp < k:",
"+ tmp *= 2",
"+ t += 1",
"+ e += 1 * (t == 0) or 2**-t"
] | false | 0.057054 | 0.052184 | 1.093317 | [
"s308026360",
"s844506165"
] |
u814781830 | p03287 | python | s875125762 | s562181589 | 234 | 103 | 62,576 | 84,732 | Accepted | Accepted | 55.98 | from collections import defaultdict
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
amount = [0] * (N+1)
for i in range(N):
amount[i+1] = amount[i] + A[i]
amount[i+1] %= M
ans = 0
di = defaultdict(int)
for i in range(N):
ans += di[amount[i+1]]
di[amount[i+1]] +=... | from collections import Counter
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp = 0
for i in range(N):
A[i] += tmp
A[i] %= M
tmp = A[i]
c = Counter(A)
ans = 0
for k, v in list(c.items()):
if k == 0:
ans += v
ans += v * (v-1) // 2
print(ans)
| 17 | 17 | 341 | 306 | from collections import defaultdict
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
amount = [0] * (N + 1)
for i in range(N):
amount[i + 1] = amount[i] + A[i]
amount[i + 1] %= M
ans = 0
di = defaultdict(int)
for i in range(N):
ans += di[amount[i + 1]]
di[amount[i + 1]] += 1
p... | from collections import Counter
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp = 0
for i in range(N):
A[i] += tmp
A[i] %= M
tmp = A[i]
c = Counter(A)
ans = 0
for k, v in list(c.items()):
if k == 0:
ans += v
ans += v * (v - 1) // 2
print(ans)
| false | 0 | [
"-from collections import defaultdict",
"+from collections import Counter",
"-amount = [0] * (N + 1)",
"+tmp = 0",
"- amount[i + 1] = amount[i] + A[i]",
"- amount[i + 1] %= M",
"+ A[i] += tmp",
"+ A[i] %= M",
"+ tmp = A[i]",
"+c = Counter(A)",
"-di = defaultdict(int)",
"-for i i... | false | 0.042945 | 0.084084 | 0.510735 | [
"s875125762",
"s562181589"
] |
u440566786 | p03111 | python | s399615195 | s944211460 | 610 | 561 | 69,468 | 68,572 | Accepted | Accepted | 8.03 | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
n,a,b,c=list(map(int,input().split()))
L=[int(eval(input())) for _ in range(n)]
def dfs(v,Idx)->int:
# terminate condition
if(v==n):
s... | import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
n,a,b,c=list(map(int,input().split()))
L=[int(eval(input())) for _ in range(n)]
def dfs(v,Idx)->int:
# terminate condition
if(v==n):
s... | 38 | 38 | 995 | 1,026 | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(n)]
def dfs(v, Idx) -> int:
# terminate condition
if v == n:
... | import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
n, a, b, c = list(map(int, input().split()))
L = [int(eval(input())) for _ in range(n)]
def dfs(v, Idx) -> int:
# terminate condition
if v == n:
... | false | 0 | [
"- res = min(res, dfs(v + 1, Idx + [i]))",
"+ Idx[v] = i",
"+ res = min(res, dfs(v + 1, Idx))",
"- print((dfs(0, [])))",
"+ print((dfs(0, [0] * n)))"
] | false | 0.139547 | 0.160628 | 0.868758 | [
"s399615195",
"s944211460"
] |
u389910364 | p03972 | python | s773558663 | s656818763 | 449 | 292 | 26,300 | 13,080 | Accepted | Accepted | 34.97 | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# ใใใใใใใใใใใใใHใจWใใใใ
W,H = list(map(int, sys.stdin.readline().split()))
P = [int(sys.stdin.readline()) for _ in range(W)]
Q = [int(sy... | import itertools
import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size ใ nodes ใฉใฃใกใๆๅฎใ
n... | 34 | 127 | 641 | 3,045 | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# ใใใใใใใใใใใใใHใจWใใใใ
W, H = list(map(int, sys.stdin.readline().split()))
P = [int(sys.stdin.readline()) for _ in range(W)]
Q = [int(sys.stdin.readline())... | import itertools
import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
class UnionFind:
def __init__(self, size=None, nodes=None):
"""
size ใ nodes ใฉใฃใกใๆๅฎใ
nodes ใฏ setใsize ใฏ list... | false | 73.228346 | [
"+import itertools",
"-# ใใใใใใใใใใใใใHใจWใใใใ ",
"+",
"+",
"+class UnionFind:",
"+ def __init__(self, size=None, nodes=None):",
"+ \"\"\"",
"+ size ใ nodes ใฉใฃใกใๆๅฎใ",
"+ nodes ใฏ setใsize ใฏ list ใไฝฟใใ",
"+ set ใฎๆๆช่จ็ฎ้ใฏ O(N) ใชใฎใง size ๆๅฎใฎใปใใ่ฅๅนฒ้ใ",
"+ :param int siz... | false | 0.058433 | 0.142249 | 0.410781 | [
"s773558663",
"s656818763"
] |
u759412327 | p02771 | python | s210807535 | s195655250 | 22 | 17 | 3,316 | 3,060 | Accepted | Accepted | 22.73 | A,B,C = sorted(list(map(int,input().split())))
if A==B and B==C:
print("No")
elif A==B or B==C:
print("Yes")
else:
print("No") | if len(set(map(int,input().split())))==2:
print("Yes")
else:
print("No") | 8 | 4 | 140 | 79 | A, B, C = sorted(list(map(int, input().split())))
if A == B and B == C:
print("No")
elif A == B or B == C:
print("Yes")
else:
print("No")
| if len(set(map(int, input().split()))) == 2:
print("Yes")
else:
print("No")
| false | 50 | [
"-A, B, C = sorted(list(map(int, input().split())))",
"-if A == B and B == C:",
"- print(\"No\")",
"-elif A == B or B == C:",
"+if len(set(map(int, input().split()))) == 2:"
] | false | 0.078773 | 0.045429 | 1.734 | [
"s210807535",
"s195655250"
] |
u604774382 | p02408 | python | s251594759 | s181818324 | 30 | 20 | 6,752 | 4,248 | Accepted | Accepted | 33.33 | import sys
n = int( sys.stdin.readline() )
s = [ False ] * 13
h = [ False ] * 13
c = [ False ] * 13
d = [ False ] * 13
for i in range( 0, n ):
pattern, num = sys.stdin.readline().split( " " )
if "S" == pattern:
s[ int( num )-1 ] = True
elif "H" == pattern:
h[ int( num )-1 ] = True
elif "C" == patt... | import sys
n = int( sys.stdin.readline() )
cards = { 'S': [ False ] * 13, 'H': [ False ] * 13, 'C': [ False ] * 13, 'D': [ False ] * 13 }
for i in range( n ):
pattern, num = sys.stdin.readline().split( " " )
if "S" == pattern:
cards[ 'S' ][ int( num )-1 ] = True
elif "H" == pattern:
cards[ 'H' ][ int( ... | 30 | 19 | 709 | 607 | import sys
n = int(sys.stdin.readline())
s = [False] * 13
h = [False] * 13
c = [False] * 13
d = [False] * 13
for i in range(0, n):
pattern, num = sys.stdin.readline().split(" ")
if "S" == pattern:
s[int(num) - 1] = True
elif "H" == pattern:
h[int(num) - 1] = True
elif "C" == pattern:
... | import sys
n = int(sys.stdin.readline())
cards = {"S": [False] * 13, "H": [False] * 13, "C": [False] * 13, "D": [False] * 13}
for i in range(n):
pattern, num = sys.stdin.readline().split(" ")
if "S" == pattern:
cards["S"][int(num) - 1] = True
elif "H" == pattern:
cards["H"][int(num) - 1] = ... | false | 36.666667 | [
"-s = [False] * 13",
"-h = [False] * 13",
"-c = [False] * 13",
"-d = [False] * 13",
"-for i in range(0, n):",
"+cards = {\"S\": [False] * 13, \"H\": [False] * 13, \"C\": [False] * 13, \"D\": [False] * 13}",
"+for i in range(n):",
"- s[int(num) - 1] = True",
"+ cards[\"S\"][int(num) - 1... | false | 0.043717 | 0.086302 | 0.506554 | [
"s251594759",
"s181818324"
] |
u886921509 | p03042 | python | s748145626 | s477897014 | 28 | 24 | 9,128 | 9,052 | Accepted | Accepted | 14.29 | S = str(eval(input()))
front = int(S[:2])
back = int(S[2:])
S_list = list(S)
if front > 12 or front == 0:
if 0 < back <= 12 :
print("YYMM")
else:
print("NA")
elif front <= 12 or front == 0:
if 0 < back <= 12:
print("AMBIGUOUS")
else:
print("MMYY") | S = str(eval(input()))
front = int(S[:2])
back = int(S[2:])
if front > 12 or front == 0:
if 0 < back <= 12 :
print("YYMM")
else:
print("NA")
elif front <= 12 or front == 0:
if 0 < back <= 12:
print("AMBIGUOUS")
else:
print("MMYY") | 15 | 14 | 305 | 287 | S = str(eval(input()))
front = int(S[:2])
back = int(S[2:])
S_list = list(S)
if front > 12 or front == 0:
if 0 < back <= 12:
print("YYMM")
else:
print("NA")
elif front <= 12 or front == 0:
if 0 < back <= 12:
print("AMBIGUOUS")
else:
print("MMYY")
| S = str(eval(input()))
front = int(S[:2])
back = int(S[2:])
if front > 12 or front == 0:
if 0 < back <= 12:
print("YYMM")
else:
print("NA")
elif front <= 12 or front == 0:
if 0 < back <= 12:
print("AMBIGUOUS")
else:
print("MMYY")
| false | 6.666667 | [
"-S_list = list(S)"
] | false | 0.08138 | 0.03704 | 2.197069 | [
"s748145626",
"s477897014"
] |
u562935282 | p02936 | python | s074935693 | s508989886 | 1,927 | 1,051 | 295,528 | 81,440 | Accepted | Accepted | 45.46 | def main():
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
Graph = tuple(set() for _ in range(N))
for _ in range(N - 1):
a, b = (int(x) - 1 for x in input().split())
Graph[a].add(b)
Graph[b].add... | def main():
from collections import deque
import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
Graph = tuple(set() for _ in range(N))
for _ in range(N - 1):
a, b = (int(x) - 1 for x in input().split())
Graph[a].add(b)
Graph[b].add(a)
... | 50 | 41 | 931 | 833 | def main():
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
Graph = tuple(set() for _ in range(N))
for _ in range(N - 1):
a, b = (int(x) - 1 for x in input().split())
Graph[a].add(b)
Graph[b].add(a)
ctr = [0] ... | def main():
from collections import deque
import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
Graph = tuple(set() for _ in range(N))
for _ in range(N - 1):
a, b = (int(x) - 1 for x in input().split())
Graph[a].add(b)
Graph[b].add(a)
ctr = [0]... | false | 18 | [
"+ from collections import deque",
"- sys.setrecursionlimit(10**7)",
"-",
"- def dfs(v):",
"+ dq = deque()",
"+ dq.append(root)",
"+ while dq:",
"+ v = dq.pop()",
"- dfs(u)",
"-",
"- dfs(root)",
"+ dq.append(u)",
"-# import sys",
"-#",
"-... | false | 0.036538 | 0.036559 | 0.999426 | [
"s074935693",
"s508989886"
] |
u079022693 | p03147 | python | s805215330 | s387491881 | 41 | 18 | 3,064 | 3,064 | Accepted | Accepted | 56.1 | from sys import stdin
def main():
#ๅ
ฅๅ
readline=stdin.readline
N=int(readline())
h=list(map(int,readline().split()))
count=0
while 1:
first=True
for i in range(N):
if first and h[i]>=1:
first=False
h[i]-=1
elif... | from sys import stdin
def main():
#ๅ
ฅๅ
readline=stdin.readline
n=int(readline())
h=list(map(int,readline().split()))
ans=0
while True:
flag=True
flag2=True
for i in range(n):
if h[i]>0:
h[i]-=1
flag=False
... | 28 | 27 | 634 | 588 | from sys import stdin
def main():
# ๅ
ฅๅ
readline = stdin.readline
N = int(readline())
h = list(map(int, readline().split()))
count = 0
while 1:
first = True
for i in range(N):
if first and h[i] >= 1:
first = False
h[i] -= 1
... | from sys import stdin
def main():
# ๅ
ฅๅ
readline = stdin.readline
n = int(readline())
h = list(map(int, readline().split()))
ans = 0
while True:
flag = True
flag2 = True
for i in range(n):
if h[i] > 0:
h[i] -= 1
flag = False
... | false | 3.571429 | [
"- N = int(readline())",
"+ n = int(readline())",
"- count = 0",
"- while 1:",
"- first = True",
"- for i in range(N):",
"- if first and h[i] >= 1:",
"- first = False",
"+ ans = 0",
"+ while True:",
"+ flag = True",
"+ fla... | false | 0.082846 | 0.036503 | 2.269589 | [
"s805215330",
"s387491881"
] |
u502389123 | p03212 | python | s319835919 | s930235153 | 111 | 67 | 3,064 | 3,064 | Accepted | Accepted | 39.64 | N = int(eval(input()))
def dfs(x):
if x > N:
return 0
san, go, nana = 0, 0, 0
c = x
for i in range(len(str(c))):
if c % 10 == 3:
san += 1
elif c % 10 == 5:
go += 1
elif c % 10 == 7:
nana += 1
c = c // 10
if... | N = int(eval(input()))
cnt = 0
nums = ''
def dfs(nums):
global cnt
if len(nums) >= 10:
return
k = list(nums)
k = set(nums)
if len(nums) >= 1:
if int(nums) <= N and len(k) >= 3:
cnt += 1
dfs(nums + '3')
dfs(nums + '5')
... | 27 | 27 | 485 | 370 | N = int(eval(input()))
def dfs(x):
if x > N:
return 0
san, go, nana = 0, 0, 0
c = x
for i in range(len(str(c))):
if c % 10 == 3:
san += 1
elif c % 10 == 5:
go += 1
elif c % 10 == 7:
nana += 1
c = c // 10
if san > 0 and go ... | N = int(eval(input()))
cnt = 0
nums = ""
def dfs(nums):
global cnt
if len(nums) >= 10:
return
k = list(nums)
k = set(nums)
if len(nums) >= 1:
if int(nums) <= N and len(k) >= 3:
cnt += 1
dfs(nums + "3")
dfs(nums + "5")
dfs(nums + "7")
return
dfs(nums)
p... | false | 0 | [
"+cnt = 0",
"+nums = \"\"",
"-def dfs(x):",
"- if x > N:",
"- return 0",
"- san, go, nana = 0, 0, 0",
"- c = x",
"- for i in range(len(str(c))):",
"- if c % 10 == 3:",
"- san += 1",
"- elif c % 10 == 5:",
"- go += 1",
"- elif c % ... | false | 0.058995 | 0.184223 | 0.320238 | [
"s319835919",
"s930235153"
] |
u002459665 | p02681 | python | s519722046 | s303692831 | 23 | 21 | 9,056 | 9,036 | Accepted | Accepted | 8.7 | S = eval(input())
T = eval(input())
lens = len(S)
lent = len(T)
ans = True
if lens + 1 != lent:
ans = False
for i in range(lens):
if S[i] != T[i]:
ans = False
if ans:
print('Yes')
else:
print('No') | S = eval(input())
T = eval(input())
if S == T[:-1]:
print('Yes')
else:
print('No') | 18 | 7 | 230 | 85 | S = eval(input())
T = eval(input())
lens = len(S)
lent = len(T)
ans = True
if lens + 1 != lent:
ans = False
for i in range(lens):
if S[i] != T[i]:
ans = False
if ans:
print("Yes")
else:
print("No")
| S = eval(input())
T = eval(input())
if S == T[:-1]:
print("Yes")
else:
print("No")
| false | 61.111111 | [
"-lens = len(S)",
"-lent = len(T)",
"-ans = True",
"-if lens + 1 != lent:",
"- ans = False",
"-for i in range(lens):",
"- if S[i] != T[i]:",
"- ans = False",
"-if ans:",
"+if S == T[:-1]:"
] | false | 0.036864 | 0.036361 | 1.013829 | [
"s519722046",
"s303692831"
] |
u604774382 | p02269 | python | s908337499 | s062172837 | 3,560 | 1,670 | 60,344 | 62,724 | Accepted | Accepted | 53.09 | n = int( eval(input( )) )
dic = {}
output = []
for i in range( n ):
cmd, word = input( ).split( " " )
if "insert" == cmd:
dic[ word ] = True
elif "find" == cmd:
if not dic.get( word ):
output.append( "no" )
else:
output.append( "yes" )
print(( "\n".join( output ) )) | n = int( input( ) )
dic = {}
for i in range( n ):
cmd, word = input( ).split( " " )
if "insert" == cmd:
dic[ word ] = True
elif "find" == cmd:
if not dic.get( word ):
print( "no" )
else:
print( "yes" ) | 14 | 11 | 287 | 234 | n = int(eval(input()))
dic = {}
output = []
for i in range(n):
cmd, word = input().split(" ")
if "insert" == cmd:
dic[word] = True
elif "find" == cmd:
if not dic.get(word):
output.append("no")
else:
output.append("yes")
print(("\n".join(output)))
| n = int(input())
dic = {}
for i in range(n):
cmd, word = input().split(" ")
if "insert" == cmd:
dic[word] = True
elif "find" == cmd:
if not dic.get(word):
print("no")
else:
print("yes")
| false | 21.428571 | [
"-n = int(eval(input()))",
"+n = int(input())",
"-output = []",
"- output.append(\"no\")",
"+ print(\"no\")",
"- output.append(\"yes\")",
"-print((\"\\n\".join(output)))",
"+ print(\"yes\")"
] | false | 0.105039 | 0.098973 | 1.061283 | [
"s908337499",
"s062172837"
] |
u600402037 | p03148 | python | s268009743 | s335739757 | 764 | 363 | 76,760 | 31,220 | Accepted | Accepted | 52.49 | from operator import itemgetter
N, K = list(map(int, input().split()))
TD = [list(map(int, input().split())) for _ in range(N)]
TD.sort(key=itemgetter(1), reverse=True)
selected = TD[:K]
dlc = sum(map(itemgetter(1), selected))
variety = set(map(itemgetter(0), selected))
used = set()
overlap = [] # ใใใฃใฆใใใ... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
TD = [lr() for _ in range(N)]
TD.sort(key=lambda x: x[1], reverse=True)
used = set()
overlap = []
for t, d in TD[:K]:
if t in used:
overlap.append(d)
else:
... | 30 | 31 | 684 | 701 | from operator import itemgetter
N, K = list(map(int, input().split()))
TD = [list(map(int, input().split())) for _ in range(N)]
TD.sort(key=itemgetter(1), reverse=True)
selected = TD[:K]
dlc = sum(map(itemgetter(1), selected))
variety = set(map(itemgetter(0), selected))
used = set()
overlap = [] # ใใใฃใฆใใใใฟใฎ็พๅณใใใฎใชในใ
f... | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
TD = [lr() for _ in range(N)]
TD.sort(key=lambda x: x[1], reverse=True)
used = set()
overlap = []
for t, d in TD[:K]:
if t in used:
overlap.append(d)
else:
used.add... | false | 3.225806 | [
"-from operator import itemgetter",
"+import sys",
"-N, K = list(map(int, input().split()))",
"-TD = [list(map(int, input().split())) for _ in range(N)]",
"-TD.sort(key=itemgetter(1), reverse=True)",
"-selected = TD[:K]",
"-dlc = sum(map(itemgetter(1), selected))",
"-variety = set(map(itemgetter(0), s... | false | 0.042552 | 0.042721 | 0.996028 | [
"s268009743",
"s335739757"
] |
u700805562 | p02990 | python | s974054813 | s748429983 | 1,031 | 23 | 3,316 | 3,572 | Accepted | Accepted | 97.77 | def nCr(n, r, mod):
x, y = 1, 1
for r_ in range(1, r+1):
x = x*(n+1-r_)%mod
y = y*r_%mod
return x*pow(y, mod-2, mod)%mod
n, k = list(map(int, input().split()))
mod = 10**9+7
for i in range(1, k+1): print((nCr(n-k+1, i, mod)*nCr(k-1, i-1, mod)%mod)) | def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
num = 2*(10**3) # ๅถ็ดใซๅใใใใ
g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
for i in range(2, num + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod %... | 10 | 18 | 278 | 510 | def nCr(n, r, mod):
x, y = 1, 1
for r_ in range(1, r + 1):
x = x * (n + 1 - r_) % mod
y = y * r_ % mod
return x * pow(y, mod - 2, mod) % mod
n, k = list(map(int, input().split()))
mod = 10**9 + 7
for i in range(1, k + 1):
print((nCr(n - k + 1, i, mod) * nCr(k - 1, i - 1, mod) % mod))
| def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7
num = 2 * (10**3) # ๅถ็ดใซๅใใใใ
g1, g2, inverse = [1, 1], [1, 1], [0, 1]
for i in range(2, num + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod... | false | 44.444444 | [
"-def nCr(n, r, mod):",
"- x, y = 1, 1",
"- for r_ in range(1, r + 1):",
"- x = x * (n + 1 - r_) % mod",
"- y = y * r_ % mod",
"- return x * pow(y, mod - 2, mod) % mod",
"+def cmb(n, r, mod):",
"+ if r < 0 or r > n:",
"+ return 0",
"+ r = min(r, n - r)",
"+ ... | false | 0.130371 | 0.03897 | 3.345421 | [
"s974054813",
"s748429983"
] |
u821588465 | p03854 | python | s083151304 | s982598326 | 78 | 39 | 3,956 | 12,824 | Accepted | Accepted | 50 | S = eval(input())
dp = [0]*(len(S) + 1)
dp[0] = 1
words=['dream', 'dreamer', 'erase', 'eraser']
done = 'NO'
for i in range(len(S)):
if dp[i] == 0:
continue
for w in words:
if S[i:i + len(w)] == w:
dp[i + len(w)] = 1
if dp[len(S)] ==1:
done = ... | from re import *
if match("^(dream|dreamer|erase|eraser)+$", eval(input())):
print('YES')
else:
print('NO')
| 19 | 7 | 357 | 122 | S = eval(input())
dp = [0] * (len(S) + 1)
dp[0] = 1
words = ["dream", "dreamer", "erase", "eraser"]
done = "NO"
for i in range(len(S)):
if dp[i] == 0:
continue
for w in words:
if S[i : i + len(w)] == w:
dp[i + len(w)] = 1
if dp[len(S)] == 1:
done = "YES"
break
pri... | from re import *
if match("^(dream|dreamer|erase|eraser)+$", eval(input())):
print("YES")
else:
print("NO")
| false | 63.157895 | [
"-S = eval(input())",
"-dp = [0] * (len(S) + 1)",
"-dp[0] = 1",
"-words = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]",
"-done = \"NO\"",
"-for i in range(len(S)):",
"- if dp[i] == 0:",
"- continue",
"- for w in words:",
"- if S[i : i + len(w)] == w:",
"- dp[i ... | false | 0.04512 | 0.059956 | 0.752549 | [
"s083151304",
"s982598326"
] |
u349856770 | p02657 | python | s107335291 | s406332856 | 34 | 27 | 9,160 | 9,152 | Accepted | Accepted | 20.59 | # 169A
# A ร B ใๆดๆฐใจใใฆๅบๅใใใ
# ๏ผ๏ผๅ
ฅๅใใใญใฐใฉใ ใงๆฑใใใใใซๅใๅใใใจ
a, b = list(map(int, input().split()))
# print(a, b)
# ๏ผ๏ผๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๆธ้ก๏ผ่จ็ฎ๏ผใใใใจ
answer = a * b
# ๏ผ๏ผ่จ็ฎใใ็ตๆใๅบๅใใใใจ
print(answer) | A, B = list(map(int, input().split()))
answer = A * B
print(answer) | 13 | 4 | 193 | 65 | # 169A
# A ร B ใๆดๆฐใจใใฆๅบๅใใใ
# ๏ผ๏ผๅ
ฅๅใใใญใฐใฉใ ใงๆฑใใใใใซๅใๅใใใจ
a, b = list(map(int, input().split()))
# print(a, b)
# ๏ผ๏ผๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๆธ้ก๏ผ่จ็ฎ๏ผใใใใจ
answer = a * b
# ๏ผ๏ผ่จ็ฎใใ็ตๆใๅบๅใใใใจ
print(answer)
| A, B = list(map(int, input().split()))
answer = A * B
print(answer)
| false | 69.230769 | [
"-# 169A",
"-# A ร B ใๆดๆฐใจใใฆๅบๅใใใ",
"-# ๏ผ๏ผๅ
ฅๅใใใญใฐใฉใ ใงๆฑใใใใใซๅใๅใใใจ",
"-a, b = list(map(int, input().split()))",
"-# print(a, b)",
"-# ๏ผ๏ผๅใๅใฃใๅ
ฅๅๅคใไฝฟใฃใฆใ้ฉๅใซๆธ้ก๏ผ่จ็ฎ๏ผใใใใจ",
"-answer = a * b",
"-# ๏ผ๏ผ่จ็ฎใใ็ตๆใๅบๅใใใใจ",
"+A, B = list(map(int, input().split()))",
"+answer = A * B"
] | false | 0.042346 | 0.007349 | 5.762489 | [
"s107335291",
"s406332856"
] |
u298297089 | p03048 | python | s552397105 | s568665620 | 1,727 | 19 | 2,940 | 3,060 | Accepted | Accepted | 98.9 | *lst,N = list(map(int, input().split()))
lst.sort(reverse=True)
#print(lst)
count = 0
for i in range(N // lst[0] + 1):
for j in range((N - i * lst[0]) // lst[1] + 1):
if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:
count += 1
print(count)
| r,g,b,n = list(map(int,input().split()))
a = [0]*(n+1)
a[0] = 1
for j in range(0,n+1-r,r):
a[j+r]=1
for j in range(n+1-b):
a[j+b]+=a[j]
for j in range(n+1-g):
a[j+g]+=a[j]
#print(a)
print((a[n]))
| 10 | 11 | 267 | 214 | *lst, N = list(map(int, input().split()))
lst.sort(reverse=True)
# print(lst)
count = 0
for i in range(N // lst[0] + 1):
for j in range((N - i * lst[0]) // lst[1] + 1):
if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:
count += 1
print(count)
| r, g, b, n = list(map(int, input().split()))
a = [0] * (n + 1)
a[0] = 1
for j in range(0, n + 1 - r, r):
a[j + r] = 1
for j in range(n + 1 - b):
a[j + b] += a[j]
for j in range(n + 1 - g):
a[j + g] += a[j]
# print(a)
print((a[n]))
| false | 9.090909 | [
"-*lst, N = list(map(int, input().split()))",
"-lst.sort(reverse=True)",
"-# print(lst)",
"-count = 0",
"-for i in range(N // lst[0] + 1):",
"- for j in range((N - i * lst[0]) // lst[1] + 1):",
"- if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:",
"- count += 1",
"-print(count)",... | false | 0.073128 | 0.071796 | 1.018561 | [
"s552397105",
"s568665620"
] |
u762199573 | p02952 | python | s689133013 | s156775466 | 53 | 48 | 6,720 | 3,864 | Accepted | Accepted | 9.43 | n = int(eval(input()))
odd = [i for i in range(1, n+1) if len(str(i)) % 2 != 0]
print((len(odd))) | n = int(eval(input()))
print((sum([1 for i in range(1, n+1) if len(str(i)) % 2 == 1]))) | 3 | 2 | 91 | 80 | n = int(eval(input()))
odd = [i for i in range(1, n + 1) if len(str(i)) % 2 != 0]
print((len(odd)))
| n = int(eval(input()))
print((sum([1 for i in range(1, n + 1) if len(str(i)) % 2 == 1])))
| false | 33.333333 | [
"-odd = [i for i in range(1, n + 1) if len(str(i)) % 2 != 0]",
"-print((len(odd)))",
"+print((sum([1 for i in range(1, n + 1) if len(str(i)) % 2 == 1])))"
] | false | 0.054353 | 0.124819 | 0.435452 | [
"s689133013",
"s156775466"
] |
u761320129 | p02574 | python | s677176129 | s805410299 | 1,320 | 327 | 132,608 | 188,940 | Accepted | Accepted | 75.23 | from math import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
def solve():
g = 0
for a in A:
g = gcd(g,a)
if g > 1:
print('not coprime')
exit()
MAXA = 10**6
B = [0] * (MAXA+1)
for a in A:
if a==1: continue
if B[a]:
... | from math import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
g = 0
for a in A:
g = gcd(g,a)
if g > 1:
print('not coprime')
exit()
MAXA = 10**6
B = [0] * (MAXA+1)
for a in A:
if a==1: continue
if B[a]:
print('setwise coprime')
exit()
B[a] = 1
... | 31 | 29 | 622 | 511 | from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
def solve():
g = 0
for a in A:
g = gcd(g, a)
if g > 1:
print("not coprime")
exit()
MAXA = 10**6
B = [0] * (MAXA + 1)
for a in A:
if a == 1:
continue
if B[a]:
... | from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
g = 0
for a in A:
g = gcd(g, a)
if g > 1:
print("not coprime")
exit()
MAXA = 10**6
B = [0] * (MAXA + 1)
for a in A:
if a == 1:
continue
if B[a]:
print("setwise coprime")
exit()
B[a] = 1
for n... | false | 6.451613 | [
"-",
"-",
"-def solve():",
"- g = 0",
"- for a in A:",
"- g = gcd(g, a)",
"- if g > 1:",
"- print(\"not coprime\")",
"+g = 0",
"+for a in A:",
"+ g = gcd(g, a)",
"+if g > 1:",
"+ print(\"not coprime\")",
"+ exit()",
"+MAXA = 10**6",
"+B = [0] * (MAXA + 1... | false | 1.572338 | 1.508131 | 1.042574 | [
"s677176129",
"s805410299"
] |
u113971909 | p03494 | python | s885734493 | s585094884 | 20 | 18 | 4,212 | 3,060 | Accepted | Accepted | 10 | N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
for i in range(N):
A[i]=list(format(A[i],'320b'))
A=list(map(list,list(zip(*A))))
B=['0']*N
ret=0
A.reverse()
for i in A:
if i==B:
ret+=1
else:
break
print(ret) | def hd2(n):
ans = 0
while n % 2 == 0:
n /= 2
ans += 1
return ans
n = int(eval(input()))
a = list(map(int, input().split()))
ans = min(list(map(hd2, a)))
print(ans) | 15 | 10 | 239 | 161 | N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
for i in range(N):
A[i] = list(format(A[i], "320b"))
A = list(map(list, list(zip(*A))))
B = ["0"] * N
ret = 0
A.reverse()
for i in A:
if i == B:
ret += 1
else:
break
print(ret)
| def hd2(n):
ans = 0
while n % 2 == 0:
n /= 2
ans += 1
return ans
n = int(eval(input()))
a = list(map(int, input().split()))
ans = min(list(map(hd2, a)))
print(ans)
| false | 33.333333 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-A.sort()",
"-for i in range(N):",
"- A[i] = list(format(A[i], \"320b\"))",
"-A = list(map(list, list(zip(*A))))",
"-B = [\"0\"] * N",
"-ret = 0",
"-A.reverse()",
"-for i in A:",
"- if i == B:",
"- ret += 1",
"-... | false | 0.045304 | 0.043862 | 1.032885 | [
"s885734493",
"s585094884"
] |
u073852194 | p02559 | python | s296359139 | s435451703 | 609 | 539 | 166,896 | 143,840 | Accepted | Accepted | 11.49 | class FenwickTree():
def __init__(self, n):
self.n = n
self.data = [0] * n
def build(self, arr):
#assert len(arr) <= n
for i, a in enumerate(arr):
self.data[i] = a
for i in range(1, self.n + 1):
if i + (i & -i) <= self.n:
... | class FenwickTree():
def __init__(self, n):
self.n = n
self.data = [0] * n
def build(self, arr):
#assert len(arr) <= n
for i, a in enumerate(arr):
self.data[i] = a
for i in range(1, self.n + 1):
if i + (i & -i) <= self.n:
... | 49 | 49 | 1,131 | 1,124 | class FenwickTree:
def __init__(self, n):
self.n = n
self.data = [0] * n
def build(self, arr):
# assert len(arr) <= n
for i, a in enumerate(arr):
self.data[i] = a
for i in range(1, self.n + 1):
if i + (i & -i) <= self.n:
self.data[... | class FenwickTree:
def __init__(self, n):
self.n = n
self.data = [0] * n
def build(self, arr):
# assert len(arr) <= n
for i, a in enumerate(arr):
self.data[i] = a
for i in range(1, self.n + 1):
if i + (i & -i) <= self.n:
self.data[... | false | 0 | [
"-A = tuple(map(int, input().split()))",
"+A = list(map(int, input().split()))"
] | false | 0.044689 | 0.045095 | 0.990984 | [
"s296359139",
"s435451703"
] |
u077291787 | p02901 | python | s850388927 | s161100677 | 971 | 312 | 3,188 | 47,448 | Accepted | Accepted | 67.87 | # ABC142E - Get Everything
import sys
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
p = 1 << N
dp = [float("inf")] * p
dp[0] = 0
for _ in range(M):
a, _ = list(map(int, input().split()))
x = sum(1 << (i - 1) for i in map(int, input().split(... | # ABC142E - Get Everything
def main():
N, M = list(map(int, input().split()))
p = 1 << N
dp = [float("inf")] * p
dp[0] = 0
for _ in range(M):
a, _ = list(map(int, input().split()))
x = sum(1 << (i - 1) for i in map(int, input().split()))
for y in range(p):
... | 21 | 18 | 529 | 487 | # ABC142E - Get Everything
import sys
input = sys.stdin.readline
def main():
N, M = list(map(int, input().split()))
p = 1 << N
dp = [float("inf")] * p
dp[0] = 0
for _ in range(M):
a, _ = list(map(int, input().split()))
x = sum(1 << (i - 1) for i in map(int, input().split()))
... | # ABC142E - Get Everything
def main():
N, M = list(map(int, input().split()))
p = 1 << N
dp = [float("inf")] * p
dp[0] = 0
for _ in range(M):
a, _ = list(map(int, input().split()))
x = sum(1 << (i - 1) for i in map(int, input().split()))
for y in range(p):
if dp[x... | false | 14.285714 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-"
] | false | 0.085491 | 0.044335 | 1.928313 | [
"s850388927",
"s161100677"
] |
u691018832 | p02913 | python | s872905934 | s101533346 | 822 | 751 | 52,700 | 50,524 | Accepted | Accepted | 8.64 | def Z_algo(S):
n = len(S)
LCP = [0] * n
c = 0 # ๆใๆซๅฐพๅดใพใงLCPใๆฑใใใคใณใใใฏใน
for i in range(1, n):
# i็ช็ฎใใใฎLCPใไปฅๅ่จ็ฎใใcใใใฎLCPใซๅซใพใใฆใใๅ ดๅ
if i + LCP[i - c] < c + LCP[c]:
LCP[i] = LCP[i - c]
else:
j = max(0, c + LCP[c] - i)
while i + j < n and S[... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
def Z_algo(S):
n = len(S)
LCP = [0] * n
c = 0 # ๆใๆซๅฐพๅดใพใงLCPใๆฑใใใคใณใใใฏใน
for i in range(1, n):
# i็ช็ฎใใใฎLCPใไปฅๅ่จ็ฎใใcใใใฎLCPใซๅซใพใใฆใใๅ ดๅ
... | 27 | 32 | 623 | 765 | def Z_algo(S):
n = len(S)
LCP = [0] * n
c = 0 # ๆใๆซๅฐพๅดใพใงLCPใๆฑใใใคใณใใใฏใน
for i in range(1, n):
# i็ช็ฎใใใฎLCPใไปฅๅ่จ็ฎใใcใใใฎLCPใซๅซใพใใฆใใๅ ดๅ
if i + LCP[i - c] < c + LCP[c]:
LCP[i] = LCP[i - c]
else:
j = max(0, c + LCP[c] - i)
while i + j < n and S[j] == S[i ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
def Z_algo(S):
n = len(S)
LCP = [0] * n
c = 0 # ๆใๆซๅฐพๅดใพใงLCPใๆฑใใใคใณใใใฏใน
for i in range(1, n):
# i็ช็ฎใใใฎLCPใไปฅๅ่จ็ฎใใcใใใฎLCPใซๅซใพใใฆใใๅ ดๅ
if i + LCP[i ... | false | 15.625 | [
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+sys.setrecursionlimit(10**7)",
"+",
"+",
"-n = int(eval(input()))",
"-s = eval(input())",
"+n = int(readline())",
"+s = read().rstrip().decode()",
"- ... | false | 0.048164 | 0.069269 | 0.695319 | [
"s872905934",
"s101533346"
] |
u607155447 | p02755 | python | s609227581 | s958993826 | 88 | 67 | 62,320 | 62,000 | Accepted | Accepted | 23.86 | import math
A, B = list(map(int, input().split()))
for i in range(1,1010):
a, b = i*0.08, i*0.1
if math.floor(a) == A and math.floor(b) == B:
print(i)
break
if i == 1009:
print((-1)) | import math
A, B = list(map(int, input().split()))
b1 = B*10
b2 = b1 + 10
for i in range(b1, b2):
if math.floor(i*0.08) == A:
print(i)
break
if i == b2-1:
print((-1)) | 10 | 12 | 220 | 203 | import math
A, B = list(map(int, input().split()))
for i in range(1, 1010):
a, b = i * 0.08, i * 0.1
if math.floor(a) == A and math.floor(b) == B:
print(i)
break
if i == 1009:
print((-1))
| import math
A, B = list(map(int, input().split()))
b1 = B * 10
b2 = b1 + 10
for i in range(b1, b2):
if math.floor(i * 0.08) == A:
print(i)
break
if i == b2 - 1:
print((-1))
| false | 16.666667 | [
"-for i in range(1, 1010):",
"- a, b = i * 0.08, i * 0.1",
"- if math.floor(a) == A and math.floor(b) == B:",
"+b1 = B * 10",
"+b2 = b1 + 10",
"+for i in range(b1, b2):",
"+ if math.floor(i * 0.08) == A:",
"- if i == 1009:",
"+ if i == b2 - 1:"
] | false | 0.036798 | 0.046489 | 0.791535 | [
"s609227581",
"s958993826"
] |
u263830634 | p03356 | python | s706219609 | s602019046 | 1,098 | 803 | 95,852 | 13,812 | Accepted | Accepted | 26.87 | N, M = list(map(int, input().split()))
P = list(map(int, input().split()))
class UnionFind(object):
def __init__(self, N):
self.parent = [-1] * N #parent[i] ใฏ(i+1)็ช็ฎใฎ่ฆ็ด ใๅซใพใใ่ฆ็ด ๆฐใฎ(-1)ๅ
#่ฆ็ด ใ่ฒ -->ใใฎๆฐใ่ฆชใจใใใฐใซใผใใซๅฑใใ่ฆ็ด ใฎๆฐร(-1)
#่ฆ็ด ใๆญฃ-->่ฆชใฎindex
#Aใใฉใฎใฐใซใผใใซๅฑใใฆใใใใ่ชฟในใ
def root(self, A):
... | N, M = list(map(int, input().split()))
P = list(map(int, input().split()))
class UnionFind(object):
def __init__(self, N):
self.parent = [-1] * N #parent[i] ใฏ(i+1)็ช็ฎใฎ่ฆ็ด ใๅซใพใใ่ฆ็ด ๆฐใฎ(-1)ๅ
#่ฆ็ด ใ่ฒ -->ใใฎๆฐใ่ฆชใจใใใฐใซใผใใซๅฑใใ่ฆ็ด ใฎๆฐร(-1)
#่ฆ็ด ใๆญฃ-->่ฆชใฎindex
#Aใใฉใฎใฐใซใผใใซๅฑใใฆใใใใ่ชฟในใ
def root(self, A):
... | 54 | 55 | 1,498 | 1,506 | N, M = list(map(int, input().split()))
P = list(map(int, input().split()))
class UnionFind(object):
def __init__(self, N):
self.parent = [-1] * N # parent[i] ใฏ(i+1)็ช็ฎใฎ่ฆ็ด ใๅซใพใใ่ฆ็ด ๆฐใฎ(-1)ๅ
# ่ฆ็ด ใ่ฒ -->ใใฎๆฐใ่ฆชใจใใใฐใซใผใใซๅฑใใ่ฆ็ด ใฎๆฐร(-1)
# ่ฆ็ด ใๆญฃ-->่ฆชใฎindex
# Aใใฉใฎใฐใซใผใใซๅฑใใฆใใใใ่ชฟในใ
def root(self, A):
if ... | N, M = list(map(int, input().split()))
P = list(map(int, input().split()))
class UnionFind(object):
def __init__(self, N):
self.parent = [-1] * N # parent[i] ใฏ(i+1)็ช็ฎใฎ่ฆ็ด ใๅซใพใใ่ฆ็ด ๆฐใฎ(-1)ๅ
# ่ฆ็ด ใ่ฒ -->ใใฎๆฐใ่ฆชใจใใใฐใซใผใใซๅฑใใ่ฆ็ด ใฎๆฐร(-1)
# ่ฆ็ด ใๆญฃ-->่ฆชใฎindex
# Aใใฉใฎใฐใซใผใใซๅฑใใฆใใใใ่ชฟในใ
def root(self, A):
if ... | false | 1.818182 | [
"-ans = 0",
"-for i in range(N):",
"- if uni.same(i + 1, P[i]):",
"- ans += 1",
"-print(ans)",
"+count = 0",
"+for index, p in enumerate(P):",
"+ if uni.same(p, index + 1):",
"+ count += 1",
"+print(count)"
] | false | 0.038909 | 0.042787 | 0.909372 | [
"s706219609",
"s602019046"
] |
u828706986 | p03450 | python | s969037620 | s286961113 | 1,138 | 527 | 84,640 | 124,660 | Accepted | Accepted | 53.69 | def main():
n, m = list(map(int, input().split()))
g = [[] for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
g[l - 1].append((r - 1, d))
g[r - 1].append((l - 1, -d))
dis = [0] * n
visited = [False] * n
for i in range(n):
if ... | import sys
def main():
n, m = list(map(int, input().split()))
g = [[] for i in range(n)]
lines = sys.stdin.read().splitlines()
for i in range(m):
l, r, d = list(map(int, lines[i].split()))
g[l - 1].append((r - 1, d))
g[r - 1].append((l - 1, -d))
dis = [0] * n
... | 32 | 36 | 863 | 923 | def main():
n, m = list(map(int, input().split()))
g = [[] for i in range(n)]
for i in range(m):
l, r, d = list(map(int, input().split()))
g[l - 1].append((r - 1, d))
g[r - 1].append((l - 1, -d))
dis = [0] * n
visited = [False] * n
for i in range(n):
if visited[i]... | import sys
def main():
n, m = list(map(int, input().split()))
g = [[] for i in range(n)]
lines = sys.stdin.read().splitlines()
for i in range(m):
l, r, d = list(map(int, lines[i].split()))
g[l - 1].append((r - 1, d))
g[r - 1].append((l - 1, -d))
dis = [0] * n
visited = ... | false | 11.111111 | [
"+import sys",
"+",
"+",
"+ lines = sys.stdin.read().splitlines()",
"- l, r, d = list(map(int, input().split()))",
"+ l, r, d = list(map(int, lines[i].split()))"
] | false | 0.045012 | 0.044718 | 1.006575 | [
"s969037620",
"s286961113"
] |
u941438707 | p02732 | python | s056845549 | s482160971 | 360 | 324 | 25,116 | 25,116 | Accepted | Accepted | 10 | n,*a,=list(map(int,open(0).read().split()))
d={}
for i in a:
d[i]=d.get(i,0)+1
b=0
for i in list(d.values()):
b+=i*(i-1)//2
for i in a:
print((b-d[i]+1)) | n,*a=list(map(int,open(0).read().split()))
d={}
for i in a:
d[i]=d.get(i,0)+1
ans=sum([i*(i-1)//2 for i in list(d.values())])
for i in a:
print((ans+1-d[i])) | 9 | 7 | 159 | 155 | (
n,
*a,
) = list(map(int, open(0).read().split()))
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
b = 0
for i in list(d.values()):
b += i * (i - 1) // 2
for i in a:
print((b - d[i] + 1))
| n, *a = list(map(int, open(0).read().split()))
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
ans = sum([i * (i - 1) // 2 for i in list(d.values())])
for i in a:
print((ans + 1 - d[i]))
| false | 22.222222 | [
"-(",
"- n,",
"- *a,",
"-) = list(map(int, open(0).read().split()))",
"+n, *a = list(map(int, open(0).read().split()))",
"-b = 0",
"-for i in list(d.values()):",
"- b += i * (i - 1) // 2",
"+ans = sum([i * (i - 1) // 2 for i in list(d.values())])",
"- print((b - d[i] + 1))",
"+ pr... | false | 0.044889 | 0.045195 | 0.993235 | [
"s056845549",
"s482160971"
] |
u784022244 | p03107 | python | s774455597 | s550052708 | 176 | 18 | 39,664 | 3,188 | Accepted | Accepted | 89.77 | S=eval(input())
N=len(S)
prezero=0
preone=0
for i in range(N):
s=S[i]
if s=="0":
if preone>0:
preone-=1
else:
prezero+=1
if s=="1":
if prezero>0:
prezero-=1
else:
preone+=1
print((N-prezero-preone))
| S=eval(input())
zeros=S.count("0")
ones=S.count("1")
print((len(S)-abs(zeros-ones)))
| 17 | 4 | 299 | 80 | S = eval(input())
N = len(S)
prezero = 0
preone = 0
for i in range(N):
s = S[i]
if s == "0":
if preone > 0:
preone -= 1
else:
prezero += 1
if s == "1":
if prezero > 0:
prezero -= 1
else:
preone += 1
print((N - prezero - preone))... | S = eval(input())
zeros = S.count("0")
ones = S.count("1")
print((len(S) - abs(zeros - ones)))
| false | 76.470588 | [
"-N = len(S)",
"-prezero = 0",
"-preone = 0",
"-for i in range(N):",
"- s = S[i]",
"- if s == \"0\":",
"- if preone > 0:",
"- preone -= 1",
"- else:",
"- prezero += 1",
"- if s == \"1\":",
"- if prezero > 0:",
"- prezero -= 1",
... | false | 0.075117 | 0.037632 | 1.996102 | [
"s774455597",
"s550052708"
] |
u514118270 | p02609 | python | s101501636 | s981404960 | 458 | 309 | 102,356 | 107,952 | Accepted | Accepted | 32.53 | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return eval(input())
def i(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def L(): return list(in... | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return eval(input())
def i(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def L(): return list(in... | 74 | 71 | 1,548 | 1,445 | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
def s():
return eval(input())
def i():
return int(eval(input()))
def S():
return input().split()
def I():
return list(map(int, input().split()))
def L(... | import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
def s():
return eval(input())
def i():
return int(eval(input()))
def S():
return input().split()
def I():
return list(map(int, input().split()))
def L(... | false | 4.054054 | [
"-cnt = 0",
"-for i in range(N):",
"- if X[i] == \"1\":",
"- cnt += 1",
"+cnt = X.count(\"1\")",
"-nums = []",
"-ans = []",
"-tans = [1] * N",
"+nums1 = []",
"+nums2 = []",
"+ans = [1] * N",
"- nums.append(num1)",
"+ nums1.append(num1)",
"- nums.append(num2)"... | false | 0.038919 | 0.047399 | 0.821095 | [
"s101501636",
"s981404960"
] |
u678167152 | p02954 | python | s843512029 | s887416394 | 1,463 | 483 | 394,700 | 398,688 | Accepted | Accepted | 66.99 | S = eval(input())
N = len(S)
db = [[0]*N for _ in range(400)]
db[0] = [i+1 if S[i]=='R' else i-1 for i in range(N)]
for i in range(1,400):
for j in range(N):
db[i][j] = db[i-1][db[i-1][j]]
ans = [0]*N
for i in range(N):
K = 10**100
p = 0
pos = i
while K:
if K%2:
pos = db[p][pos]
... | S = eval(input())
N = len(S)
db = [[0]*N for _ in range(400)]
db[0] = [i+1 if S[i]=='R' else i-1 for i in range(N)]
for i in range(1,400):
for j in range(N):
db[i][j] = db[i-1][db[i-1][j]]
ans = [0]*N
for i in range(N):
K = 10**5
p = 0
pos = i
while K:
if K%2:
pos = db[p][pos]
... | 19 | 19 | 367 | 365 | S = eval(input())
N = len(S)
db = [[0] * N for _ in range(400)]
db[0] = [i + 1 if S[i] == "R" else i - 1 for i in range(N)]
for i in range(1, 400):
for j in range(N):
db[i][j] = db[i - 1][db[i - 1][j]]
ans = [0] * N
for i in range(N):
K = 10**100
p = 0
pos = i
while K:
if K % 2:
... | S = eval(input())
N = len(S)
db = [[0] * N for _ in range(400)]
db[0] = [i + 1 if S[i] == "R" else i - 1 for i in range(N)]
for i in range(1, 400):
for j in range(N):
db[i][j] = db[i - 1][db[i - 1][j]]
ans = [0] * N
for i in range(N):
K = 10**5
p = 0
pos = i
while K:
if K % 2:
... | false | 0 | [
"- K = 10**100",
"+ K = 10**5"
] | false | 0.039626 | 0.036009 | 1.100449 | [
"s843512029",
"s887416394"
] |
u489959379 | p03644 | python | s024820677 | s262355300 | 177 | 20 | 38,384 | 3,316 | Accepted | Accepted | 88.7 | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
res = 0
ans = 0
for i in range(1, n + 1):
n = int(str(i)[::])
cnt = 0
while n % 2 == 0:
n //= 2
cnt += 1
... | import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
res = defaultdict(int)
for i in range(1, n + 1):
cnt = 0
k = i
while k % 2 == 0:
... | 27 | 32 | 436 | 559 | import sys
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
res = 0
ans = 0
for i in range(1, n + 1):
n = int(str(i)[::])
cnt = 0
while n % 2 == 0:
n //= 2
cnt += 1
if res <= cnt:
... | import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
res = defaultdict(int)
for i in range(1, n + 1):
cnt = 0
k = i
while k % 2 == 0:
k //= 2
... | false | 15.625 | [
"+from collections import defaultdict",
"+input = sys.stdin.readline",
"- res = 0",
"- ans = 0",
"+ res = defaultdict(int)",
"- n = int(str(i)[::])",
"- while n % 2 == 0:",
"- n //= 2",
"+ k = i",
"+ while k % 2 == 0:",
"+ k //= 2",
"-... | false | 0.085843 | 0.036873 | 2.328072 | [
"s024820677",
"s262355300"
] |
u102461423 | p02609 | python | s975869111 | s353741830 | 1,039 | 610 | 138,228 | 127,520 | Accepted | Accepted | 41.29 | import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8, ), cache=True)
def popcount(n):
ret = 0
while n:
ret += n & 1
n >>= 1
retur... | import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8, ), cache=True)
def popcount(n):
ret = 0
while n:
ret += n & 1
n >>= 1
retur... | 64 | 64 | 1,392 | 1,411 | import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8,), cache=True)
def popcount(n):
ret = 0
while n:
ret += n & 1
n >>= 1
return ret
@njit((i... | import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8,), cache=True)
def popcount(n):
ret = 0
while n:
ret += n & 1
n >>= 1
return ret
@njit((i... | false | 0 | [
"-@njit(cache=True)",
"+@njit((i8[:],), cache=True)",
"+ N = len(X)",
"- for n in range(1, len(X)):",
"+ for n in range(1, N):"
] | false | 0.173881 | 0.173866 | 1.000091 | [
"s975869111",
"s353741830"
] |
u344065503 | p02947 | python | s824034415 | s351905915 | 906 | 689 | 128,728 | 65,496 | Accepted | Accepted | 23.95 | N=int(eval(input()))
dictionary={}
count=0
for i in range(N):
s=tuple(sorted(eval(input())))
if s in dictionary:
dictionary[s]+=1
count+=dictionary[s]
else:
dictionary[s]=0
print(count) | N=int(eval(input()))
dictionary={}
count=0
for i in range(N):
s="".join(sorted(eval(input())))
if s in dictionary:
dictionary[s]+=1
count+=dictionary[s]
else:
dictionary[s]=0
print(count) | 11 | 11 | 219 | 221 | N = int(eval(input()))
dictionary = {}
count = 0
for i in range(N):
s = tuple(sorted(eval(input())))
if s in dictionary:
dictionary[s] += 1
count += dictionary[s]
else:
dictionary[s] = 0
print(count)
| N = int(eval(input()))
dictionary = {}
count = 0
for i in range(N):
s = "".join(sorted(eval(input())))
if s in dictionary:
dictionary[s] += 1
count += dictionary[s]
else:
dictionary[s] = 0
print(count)
| false | 0 | [
"- s = tuple(sorted(eval(input())))",
"+ s = \"\".join(sorted(eval(input())))"
] | false | 0.067459 | 0.046644 | 1.446238 | [
"s824034415",
"s351905915"
] |
u070201429 | p03161 | python | s822643523 | s570863541 | 308 | 260 | 84,976 | 84,856 | Accepted | Accepted | 15.58 | def main():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
h = a[i]
dp[i] = min([dp[j] + abs(h - a[j]) for j in range(max(0, i-k), i)])
print((dp[n-1]))
main() | def main():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
h = a[i]
cost = 10**9
for j in range(max(0, i-k), i):
if dp[j] + abs(h - a[j]) < cost:
cost = dp[j] + abs(h - a[j])
... | 12 | 16 | 264 | 364 | def main():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
h = a[i]
dp[i] = min([dp[j] + abs(h - a[j]) for j in range(max(0, i - k), i)])
print((dp[n - 1]))
main()
| def main():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
h = a[i]
cost = 10**9
for j in range(max(0, i - k), i):
if dp[j] + abs(h - a[j]) < cost:
cost = dp[j] + abs(h - a[j])
dp[i... | false | 25 | [
"- dp[i] = min([dp[j] + abs(h - a[j]) for j in range(max(0, i - k), i)])",
"+ cost = 10**9",
"+ for j in range(max(0, i - k), i):",
"+ if dp[j] + abs(h - a[j]) < cost:",
"+ cost = dp[j] + abs(h - a[j])",
"+ dp[i] = cost"
] | false | 0.037218 | 0.036923 | 1.007998 | [
"s822643523",
"s570863541"
] |
u042802884 | p03805 | python | s556454272 | s240734707 | 429 | 180 | 43,868 | 40,048 | Accepted | Accepted | 58.04 | def perm(k,x):
v=[]
for i in range(x):
c=k%x+2
if c not in v:
v.append(c)
k//=x
else:
return []
return v
N,M=list(map(int,input().split()))
e=[[False for i in range(N+1)] for i in range(N+1)]
for i in range(M):
a,b=list(ma... | import itertools as it
N,M=list(map(int,input().split()))
e=[[False for j in range(N+1)] for i in range(N+1)]
for i in range(M):
a,b=list(map(int,input().split()))
e[a][b]=e[b][a]=True
# print(e) #DB
ans=0
l=list(range(2,N+1))
for p in it.permutations(l,N-1):
q=(1,)+p
# print(q) #DB
... | 33 | 24 | 725 | 494 | def perm(k, x):
v = []
for i in range(x):
c = k % x + 2
if c not in v:
v.append(c)
k //= x
else:
return []
return v
N, M = list(map(int, input().split()))
e = [[False for i in range(N + 1)] for i in range(N + 1)]
for i in range(M):
a, b = lis... | import itertools as it
N, M = list(map(int, input().split()))
e = [[False for j in range(N + 1)] for i in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
e[a][b] = e[b][a] = True
# print(e) #DB
ans = 0
l = list(range(2, N + 1))
for p in it.permutations(l, N - 1):
q = (1,) + p
# ... | false | 27.272727 | [
"-def perm(k, x):",
"- v = []",
"- for i in range(x):",
"- c = k % x + 2",
"- if c not in v:",
"- v.append(c)",
"- k //= x",
"- else:",
"- return []",
"- return v",
"-",
"+import itertools as it",
"-e = [[False for i in range(N +... | false | 0.050873 | 0.043046 | 1.181808 | [
"s556454272",
"s240734707"
] |
u852690916 | p03160 | python | s980118757 | s273917536 | 183 | 139 | 13,924 | 13,980 | Accepted | Accepted | 24.04 | N = int(eval(input()))
H = list(map(int, input().split()))
H.append(0)
H.append(0)
#dp[่ถณๅ ดi]=่ถณๅ ดiใซใใฉใ็ใๆๅฐใณในใ
dp = [10**10 for _ in range(N+10)]
dp[0] = 0
for i in range(N):
dp[i+1] = min(dp[i+1], dp[i] + abs(H[i]-H[i+1]))
dp[i+2] = min(dp[i+2], dp[i] + abs(H[i]-H[i+2]))
print((dp[N-1]))
| N = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * (N)
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
dp[i] = dp[i-1] + abs(h[i] - h[i-1])
dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print((dp[N-1]))
| 14 | 10 | 302 | 235 | N = int(eval(input()))
H = list(map(int, input().split()))
H.append(0)
H.append(0)
# dp[่ถณๅ ดi]=่ถณๅ ดiใซใใฉใ็ใๆๅฐใณในใ
dp = [10**10 for _ in range(N + 10)]
dp[0] = 0
for i in range(N):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))
print((dp[N - 1]))
| N = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * (N)
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))
| false | 28.571429 | [
"-H = list(map(int, input().split()))",
"-H.append(0)",
"-H.append(0)",
"-# dp[่ถณๅ ดi]=่ถณๅ ดiใซใใฉใ็ใๆๅฐใณในใ",
"-dp = [10**10 for _ in range(N + 10)]",
"-dp[0] = 0",
"-for i in range(N):",
"- dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))",
"- dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i ... | false | 0.105155 | 0.174128 | 0.603896 | [
"s980118757",
"s273917536"
] |
u302957509 | p02983 | python | s153061100 | s381808358 | 850 | 415 | 3,064 | 2,940 | Accepted | Accepted | 51.18 | L, R = list(map(int, input().split()))
MOD = 2019
if R - L >= MOD - 1:
print((0))
exit()
if L % MOD < R % MOD:
a = [n for n in range(L % MOD, R % MOD + 1)]
elif L % MOD > R % MOD:
a = [n for n in range(L % MOD, MOD)] + [n for n in range(R % MOD + 1)]
else:
a = list(range(MOD))
ans =... | L, R = list(map(int, input().split()))
MOD = 2019
print((min(
(i * j) % MOD
for i in range(L, R + 1)
for j in range(i + 1, R + 1)
) if R - L < MOD - 1 else 0))
| 20 | 8 | 441 | 172 | L, R = list(map(int, input().split()))
MOD = 2019
if R - L >= MOD - 1:
print((0))
exit()
if L % MOD < R % MOD:
a = [n for n in range(L % MOD, R % MOD + 1)]
elif L % MOD > R % MOD:
a = [n for n in range(L % MOD, MOD)] + [n for n in range(R % MOD + 1)]
else:
a = list(range(MOD))
ans = MOD - 1
for i in... | L, R = list(map(int, input().split()))
MOD = 2019
print(
(
min((i * j) % MOD for i in range(L, R + 1) for j in range(i + 1, R + 1))
if R - L < MOD - 1
else 0
)
)
| false | 60 | [
"-if R - L >= MOD - 1:",
"- print((0))",
"- exit()",
"-if L % MOD < R % MOD:",
"- a = [n for n in range(L % MOD, R % MOD + 1)]",
"-elif L % MOD > R % MOD:",
"- a = [n for n in range(L % MOD, MOD)] + [n for n in range(R % MOD + 1)]",
"-else:",
"- a = list(range(MOD))",
"-ans = MOD - ... | false | 0.054598 | 0.037182 | 1.468396 | [
"s153061100",
"s381808358"
] |
u623814058 | p02982 | python | s554609276 | s556212908 | 28 | 25 | 9,396 | 9,460 | Accepted | Accepted | 10.71 | N,D=list(map(int,input().split()))
X=[list(map(int,input().split())) for i in range(N)]
l=len(X)
cnt=0
for i in range(l):
for j in range(i+1,l):
t=sum((X[i][d]-X[j][d])**2for d in range(D))**0.5
if t==int(t):cnt+=1
print(cnt) | N,D=list(map(int,input().split()))
X=[list(map(int,input().split())) for i in range(N)]
l=len(X)
cnt=0
for i in range(l):
for j in range(i+1,l):
t=sum((X[i][d]-X[j][d])**2for d in range(D))**0.5
cnt+=t==int(t)
print(cnt) | 9 | 9 | 232 | 227 | N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
l = len(X)
cnt = 0
for i in range(l):
for j in range(i + 1, l):
t = sum((X[i][d] - X[j][d]) ** 2 for d in range(D)) ** 0.5
if t == int(t):
cnt += 1
print(cnt)
| N, D = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(N)]
l = len(X)
cnt = 0
for i in range(l):
for j in range(i + 1, l):
t = sum((X[i][d] - X[j][d]) ** 2 for d in range(D)) ** 0.5
cnt += t == int(t)
print(cnt)
| false | 0 | [
"- if t == int(t):",
"- cnt += 1",
"+ cnt += t == int(t)"
] | false | 0.047306 | 0.07064 | 0.669682 | [
"s554609276",
"s556212908"
] |
u466335531 | p03061 | python | s576985930 | s559037572 | 230 | 163 | 63,984 | 14,588 | Accepted | Accepted | 29.13 | from math import sqrt
from sys import exit
N=int(eval(input()))
A=list(map(int,input().split()))
if len(A)==2:
print((max(A)))
exit()
def gcd(a,b):
if a<b: a,b=b,a
if a%b==0: return b
return gcd(b,a%b)
g=gcd(A[0],A[-1])
p=[]
for i in range(1,int(sqrt(g)+1)):
if g%i==0... | from math import sqrt
from sys import exit
N=int(eval(input()))
A=list(map(int,input().split()))
if len(A)==2:
print((max(A)))
exit()
def gcd(a,b):
if a<b: a,b=b,a
if a%b==0: return b
return gcd(b,a%b)
g=A[0]
L=[g]
for a in A[1:-1]:
g=gcd(g,a)
L.append(g)
g=A[... | 46 | 30 | 829 | 481 | from math import sqrt
from sys import exit
N = int(eval(input()))
A = list(map(int, input().split()))
if len(A) == 2:
print((max(A)))
exit()
def gcd(a, b):
if a < b:
a, b = b, a
if a % b == 0:
return b
return gcd(b, a % b)
g = gcd(A[0], A[-1])
p = []
for i in range(1, int(sqrt(g... | from math import sqrt
from sys import exit
N = int(eval(input()))
A = list(map(int, input().split()))
if len(A) == 2:
print((max(A)))
exit()
def gcd(a, b):
if a < b:
a, b = b, a
if a % b == 0:
return b
return gcd(b, a % b)
g = A[0]
L = [g]
for a in A[1:-1]:
g = gcd(g, a)
... | false | 34.782609 | [
"-g = gcd(A[0], A[-1])",
"-p = []",
"-for i in range(1, int(sqrt(g) + 1)):",
"- if g % i == 0:",
"- if i * i == g:",
"- p.append(i)",
"- else:",
"- p += [i, g // i]",
"-",
"-",
"-def ok(n):",
"- f = False",
"- for a in A[1:-1]:",
"- if a ... | false | 0.074637 | 0.074314 | 1.004349 | [
"s576985930",
"s559037572"
] |
u796942881 | p03721 | python | s259218261 | s731985935 | 223 | 129 | 29,868 | 13,844 | Accepted | Accepted | 42.15 | from sys import stdin
from operator import itemgetter
def main():
lines = stdin.readlines()
N, K = list(map(int, lines[0].split()))
abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
abn.sort(key=itemgetter(0))
cnt = 0
for ai, bi in abn:
cnt += bi
if K... | from sys import stdin
def main():
lines = stdin.readlines()
N, K = list(map(int, lines[0].split()))
bn = [0] * (int(1e5) + 1)
for line in lines[1:]:
ai, bi = list(map(int, line.split()))
bn[ai] += bi
cnt = 0
for ai, bi in enumerate(bn):
cnt += bi
if... | 19 | 20 | 389 | 385 | from sys import stdin
from operator import itemgetter
def main():
lines = stdin.readlines()
N, K = list(map(int, lines[0].split()))
abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
abn.sort(key=itemgetter(0))
cnt = 0
for ai, bi in abn:
cnt += bi
if K <= cnt:
... | from sys import stdin
def main():
lines = stdin.readlines()
N, K = list(map(int, lines[0].split()))
bn = [0] * (int(1e5) + 1)
for line in lines[1:]:
ai, bi = list(map(int, line.split()))
bn[ai] += bi
cnt = 0
for ai, bi in enumerate(bn):
cnt += bi
if K <= cnt:
... | false | 5 | [
"-from operator import itemgetter",
"- abn = [[int(abi) for abi in line.split()] for line in lines[1:]]",
"- abn.sort(key=itemgetter(0))",
"+ bn = [0] * (int(1e5) + 1)",
"+ for line in lines[1:]:",
"+ ai, bi = list(map(int, line.split()))",
"+ bn[ai] += bi",
"- for ai, bi ... | false | 0.044353 | 0.039284 | 1.129019 | [
"s259218261",
"s731985935"
] |
u467175809 | p01420 | python | s903468425 | s797580721 | 720 | 660 | 5,180 | 5,184 | Accepted | Accepted | 8.33 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
N, M, L = list(map(int, input().split()))
def fact(n):
if n <= 1:
return 1
return fact(n - 1) * n
MC = []
for i in range(M + 1):
MC.append(fact(M) / fact(i) / fact... | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
N, M, L = list(map(int, input().split()))
def fact(n):
if n <= 1:
return 1
return fact(n - 1) * n
MC = []
for i in range(M + 1):
MC.append(fact(M) / fact(i) / fact... | 59 | 58 | 1,392 | 1,367 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
N, M, L = list(map(int, input().split()))
def fact(n):
if n <= 1:
return 1
return fact(n - 1) * n
MC = []
for i in range(M + 1):
MC.append(fact(M) / fact(i) / fact(M - i))
p_lst ... | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
N, M, L = list(map(int, input().split()))
def fact(n):
if n <= 1:
return 1
return fact(n - 1) * n
MC = []
for i in range(M + 1):
MC.append(fact(M) / fact(i) / fact(M - i))
p_lst ... | false | 1.694915 | [
"- flag = True"
] | false | 0.04066 | 0.049205 | 0.826327 | [
"s903468425",
"s797580721"
] |
u094191970 | p02691 | python | s424790652 | s373700255 | 268 | 246 | 63,228 | 63,552 | Accepted | Accepted | 8.21 | from collections import Counter
n=int(eval(input()))
a=list(map(int,input().split()))
i_l=[]
j_l=[]
for i in range(n):
i_l.append(i+a[i])
j_l.append(i-a[i])
ci=Counter(i_l)
cl=Counter(j_l)
ans=0
for k,v in list(ci.items()):
ans+=v*cl[k]
print(ans) | from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter
n=int(eval(input()))
a=lnii()
l1=[i+a[i] for i in range(n)]
l2=[i-a[i] for i in range(n)]
c1=Counter(l1)
c2=Counter(l2)
ans=0
for i in c1:
an... | 19 | 19 | 264 | 336 | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
i_l = []
j_l = []
for i in range(n):
i_l.append(i + a[i])
j_l.append(i - a[i])
ci = Counter(i_l)
cl = Counter(j_l)
ans = 0
for k, v in list(ci.items()):
ans += v * cl[k]
print(ans)
| from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from collections import Counter
n = int(eval(input()))
a = lnii()
l1 = [i + a[i] for i in range(n)]
l2 = [i - a[i] for i in range(n)]
c1 = Counter(l1)
c2 = Counter(l2)
ans = 0
for i in ... | false | 0 | [
"+from sys import stdin",
"+",
"+nii = lambda: list(map(int, stdin.readline().split()))",
"+lnii = lambda: list(map(int, stdin.readline().split()))",
"-a = list(map(int, input().split()))",
"-i_l = []",
"-j_l = []",
"-for i in range(n):",
"- i_l.append(i + a[i])",
"- j_l.append(i - a[i])",
... | false | 0.046876 | 0.155426 | 0.301598 | [
"s424790652",
"s373700255"
] |
u127499732 | p03013 | python | s825781258 | s612020867 | 452 | 210 | 460,020 | 13,192 | Accepted | Accepted | 53.54 | n,m=list(map(int,input().split()))
x=set([int(eval(input())) for _ in range(m)])
f=[0]*(n+1)
f[0]=1
for i in range(1,n+1):
f[i]=f[i-1]+f[i-2]
if i in x:
f[i]=0
print((f[n]%(10**9+7))) | n,m=list(map(int,input().split()))
x=set([int(eval(input())) for _ in range(m)])
f=[0]*(n+1)
f[0]=1
for i in range(1,n+1):
f[i]=(f[i-1]+f[i-2])%(10**9+7)
if i in x:
f[i]=0
print((f[n]%(10**9+7))) | 9 | 9 | 185 | 197 | n, m = list(map(int, input().split()))
x = set([int(eval(input())) for _ in range(m)])
f = [0] * (n + 1)
f[0] = 1
for i in range(1, n + 1):
f[i] = f[i - 1] + f[i - 2]
if i in x:
f[i] = 0
print((f[n] % (10**9 + 7)))
| n, m = list(map(int, input().split()))
x = set([int(eval(input())) for _ in range(m)])
f = [0] * (n + 1)
f[0] = 1
for i in range(1, n + 1):
f[i] = (f[i - 1] + f[i - 2]) % (10**9 + 7)
if i in x:
f[i] = 0
print((f[n] % (10**9 + 7)))
| false | 0 | [
"- f[i] = f[i - 1] + f[i - 2]",
"+ f[i] = (f[i - 1] + f[i - 2]) % (10**9 + 7)"
] | false | 0.132861 | 0.079084 | 1.68 | [
"s825781258",
"s612020867"
] |
u298297089 | p03337 | python | s593643168 | s846237852 | 171 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.06 | A,B = list(map(int, input().split()))
print((max(A+B,A-B,A*B))) | a,b = list(map(int, input().split()))
print((max([a + b, a-b, a*b]))) | 2 | 2 | 56 | 62 | A, B = list(map(int, input().split()))
print((max(A + B, A - B, A * B)))
| a, b = list(map(int, input().split()))
print((max([a + b, a - b, a * b])))
| false | 0 | [
"-A, B = list(map(int, input().split()))",
"-print((max(A + B, A - B, A * B)))",
"+a, b = list(map(int, input().split()))",
"+print((max([a + b, a - b, a * b])))"
] | false | 0.031739 | 0.034916 | 0.908997 | [
"s593643168",
"s846237852"
] |
u972591645 | p02578 | python | s091979093 | s210094489 | 158 | 98 | 32,372 | 32,352 | Accepted | Accepted | 37.97 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
if a[i-1] > a[i]:
ans += a[i-1] - a[i]
a[i] = a[i-1]
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
tmp = a[0]
ans = 0
for i in a:
if i < tmp:
ans += tmp-i
else:
tmp = i
print(ans)
| 9 | 11 | 175 | 169 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
if a[i - 1] > a[i]:
ans += a[i - 1] - a[i]
a[i] = a[i - 1]
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
tmp = a[0]
ans = 0
for i in a:
if i < tmp:
ans += tmp - i
else:
tmp = i
print(ans)
| false | 18.181818 | [
"+tmp = a[0]",
"-for i in range(1, n):",
"- if a[i - 1] > a[i]:",
"- ans += a[i - 1] - a[i]",
"- a[i] = a[i - 1]",
"+for i in a:",
"+ if i < tmp:",
"+ ans += tmp - i",
"+ else:",
"+ tmp = i"
] | false | 0.060097 | 0.059488 | 1.010237 | [
"s091979093",
"s210094489"
] |
u228496478 | p03161 | python | s319868173 | s276413879 | 1,948 | 431 | 13,980 | 52,592 | Accepted | Accepted | 77.87 | def main():
n,k=list(map(int,input().split()))
c=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
dp[i]=min([dp[j]+abs(c[i]-c[j]) for j in range(max(0,i-k),i)])
print((dp[-1]))
if __name__=='__main__':
main() | n,k=list(map(int,input().split()))
c=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
dp[i]=min([dp[j]+abs(c[i]-c[j]) for j in range(max(0,i-k),i)])
print((dp[-1])) | 10 | 7 | 265 | 186 | def main():
n, k = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
for i in range(1, n):
dp[i] = min([dp[j] + abs(c[i] - c[j]) for j in range(max(0, i - k), i)])
print((dp[-1]))
if __name__ == "__main__":
main()
| n, k = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
for i in range(1, n):
dp[i] = min([dp[j] + abs(c[i] - c[j]) for j in range(max(0, i - k), i)])
print((dp[-1]))
| false | 30 | [
"-def main():",
"- n, k = list(map(int, input().split()))",
"- c = list(map(int, input().split()))",
"- dp = [0] * n",
"- dp[0] = 0",
"- for i in range(1, n):",
"- dp[i] = min([dp[j] + abs(c[i] - c[j]) for j in range(max(0, i - k), i)])",
"- print((dp[-1]))",
"-",
"-",
"... | false | 0.076086 | 0.03544 | 2.146866 | [
"s319868173",
"s276413879"
] |
u729133443 | p03088 | python | s609660993 | s216160397 | 168 | 21 | 4,688 | 4,724 | Accepted | Accepted | 87.5 | import re,functools as f;d=f.lru_cache(999)(lambda n,b:n<1or sum(d(n-1,b[1:]+s)for s in'ACGT'if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C',b+s))%(10**9+7));print((d(int(eval(input())),'TTT'))) | a=b=c=d=e=f=0;g=1;exec('a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,(g*4-b-c-d-a*3)%(10**9+7);'*int(eval(input())));print(g) | 1 | 1 | 181 | 104 | import re, functools as f
d = f.lru_cache(999)(
lambda n, b: n < 1
or sum(
d(n - 1, b[1:] + s)
for s in "ACGT"
if not re.match(".AGC|.ACG|.GAC|A.GC|AG.C", b + s)
)
% (10**9 + 7)
)
print((d(int(eval(input())), "TTT")))
| a = b = c = d = e = f = 0
g = 1
exec("a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,(g*4-b-c-d-a*3)%(10**9+7);" * int(eval(input())))
print(g)
| false | 0 | [
"-import re, functools as f",
"-",
"-d = f.lru_cache(999)(",
"- lambda n, b: n < 1",
"- or sum(",
"- d(n - 1, b[1:] + s)",
"- for s in \"ACGT\"",
"- if not re.match(\".AGC|.ACG|.GAC|A.GC|AG.C\", b + s)",
"- )",
"- % (10**9 + 7)",
"-)",
"-print((d(int(eval(input... | false | 0.08781 | 0.03519 | 2.495319 | [
"s609660993",
"s216160397"
] |
u313111801 | p03308 | python | s867336987 | s490783934 | 37 | 27 | 9,124 | 9,156 | Accepted | Accepted | 27.03 | N=int(eval(input()))
A=[int(x) for x in input().split()]
ans=0
for i in range(N):
for j in range(N):
ans=max(ans,abs(A[i]-A[j]))
print(ans) | N=int(eval(input()))
A=[int(x) for x in input().split()]
print((max(A)-min(A))) | 7 | 3 | 151 | 73 | N = int(eval(input()))
A = [int(x) for x in input().split()]
ans = 0
for i in range(N):
for j in range(N):
ans = max(ans, abs(A[i] - A[j]))
print(ans)
| N = int(eval(input()))
A = [int(x) for x in input().split()]
print((max(A) - min(A)))
| false | 57.142857 | [
"-ans = 0",
"-for i in range(N):",
"- for j in range(N):",
"- ans = max(ans, abs(A[i] - A[j]))",
"-print(ans)",
"+print((max(A) - min(A)))"
] | false | 0.050465 | 0.076842 | 0.656731 | [
"s867336987",
"s490783934"
] |
u088552457 | p02660 | python | s238198444 | s610246922 | 117 | 99 | 71,140 | 77,348 | Accepted | Accepted | 15.38 | from functools import reduce
from decimal import *
from operator import mul
def main():
n = int(eval(input()))
p = prime_factorize(n)
sa = list(sorted(p))
pp = []
num = 1
for i, v in enumerate(sa):
if i > 0 and sa[i-1] != v:
num = 1
num *= v
if ... | # import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
# ๆใฃใฆใใใในใฑใใใๅฉใใ1ๆๅขใใ
# ใในใฑใใ Aๆใ 1ๅใซไบคๆใใ
# 1ๅใใในใฑใใ Bๆใซไบคๆใใ
def main():
n = int(eval(input()))
p = prime_factorize(n)
cp = collections.Counter(p)
ans = 0
for c, num in list(cp.... | 40 | 68 | 812 | 1,504 | from functools import reduce
from decimal import *
from operator import mul
def main():
n = int(eval(input()))
p = prime_factorize(n)
sa = list(sorted(p))
pp = []
num = 1
for i, v in enumerate(sa):
if i > 0 and sa[i - 1] != v:
num = 1
num *= v
if num not in ... | # import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
# ๆใฃใฆใใใในใฑใใใๅฉใใ1ๆๅขใใ
# ใในใฑใใ Aๆใ 1ๅใซไบคๆใใ
# 1ๅใใในใฑใใ Bๆใซไบคๆใใ
def main():
n = int(eval(input()))
p = prime_factorize(n)
cp = collections.Counter(p)
ans = 0
for c, num in list(cp.items()):
... | false | 41.176471 | [
"-from functools import reduce",
"-from decimal import *",
"-from operator import mul",
"+# import sys",
"+# input = sys.stdin.readline",
"+import itertools",
"+import collections",
"+from decimal import Decimal",
"-",
"+# ๆใฃใฆใใใในใฑใใใๅฉใใ1ๆๅขใใ",
"+# ใในใฑใใ Aๆใ 1ๅใซไบคๆใใ",
"+# 1ๅใใในใฑใใ Bๆใซไบคๆใใ",
... | false | 0.039548 | 0.10303 | 0.383853 | [
"s238198444",
"s610246922"
] |
u730769327 | p03164 | python | s525117774 | s545493361 | 441 | 123 | 218,120 | 71,664 | Accepted | Accepted | 72.11 | n,W=list(map(int,input().split()))
w=[]
v=[]
for i in range(n):
a,b=list(map(int,input().split()))
w.append(a)
v.append(b)
V=sum(v)
INF=10**18
dp=[[INF for _ in range(V+1)] for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
for j in range(V+1):
if j<v[i]:dp[i+1][j]=dp[i][j]
else:dp[i+1][j]... | INF=10**18
n,m=list(map(int,input().split()))
w=[0]*n
v=[0]*n
for i in range(n):
w[i],v[i]=list(map(int,input().split()))
k=sum(v)
dp=[INF]*(k+1)
dp[0]=0
for i in range(n):
for j in range(k,-1,-1):
if j>=v[i] and dp[j-v[i]]!=INF:dp[j]=min(dp[j],dp[j-v[i]]+w[i])
for i,x in enumerate(dp):
if x<=m:a... | 18 | 15 | 399 | 324 | n, W = list(map(int, input().split()))
w = []
v = []
for i in range(n):
a, b = list(map(int, input().split()))
w.append(a)
v.append(b)
V = sum(v)
INF = 10**18
dp = [[INF for _ in range(V + 1)] for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
for j in range(V + 1):
if j < v[i]:
... | INF = 10**18
n, m = list(map(int, input().split()))
w = [0] * n
v = [0] * n
for i in range(n):
w[i], v[i] = list(map(int, input().split()))
k = sum(v)
dp = [INF] * (k + 1)
dp[0] = 0
for i in range(n):
for j in range(k, -1, -1):
if j >= v[i] and dp[j - v[i]] != INF:
dp[j] = min(dp[j], dp[j - ... | false | 16.666667 | [
"-n, W = list(map(int, input().split()))",
"-w = []",
"-v = []",
"+INF = 10**18",
"+n, m = list(map(int, input().split()))",
"+w = [0] * n",
"+v = [0] * n",
"- a, b = list(map(int, input().split()))",
"- w.append(a)",
"- v.append(b)",
"-V = sum(v)",
"-INF = 10**18",
"-dp = [[INF for... | false | 0.03699 | 0.03623 | 1.020977 | [
"s525117774",
"s545493361"
] |
u638456847 | p02702 | python | s107258444 | s748572049 | 310 | 98 | 16,612 | 10,916 | Accepted | Accepted | 68.39 | from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
S = readline().strip()[::-1]
N = len(S)
a = [0]
s = 0
for i in range(N):
s += int(S[i]) * pow(10, i, 2019)
a.append(s % 2019)
... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
S = [int(i) for i in readline().strip()[::-1]]
a = {}
a[0] = 1
t = 0
x = 1
for s in S:
t += s * x
t %= 2019
if t in a:
a[t] +... | 27 | 33 | 487 | 545 | from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
S = readline().strip()[::-1]
N = len(S)
a = [0]
s = 0
for i in range(N):
s += int(S[i]) * pow(10, i, 2019)
a.append(s % 2019)
t = Counter(... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
S = [int(i) for i in readline().strip()[::-1]]
a = {}
a[0] = 1
t = 0
x = 1
for s in S:
t += s * x
t %= 2019
if t in a:
a[t] += 1
else:
... | false | 18.181818 | [
"-from collections import Counter",
"- S = readline().strip()[::-1]",
"- N = len(S)",
"- a = [0]",
"- s = 0",
"- for i in range(N):",
"- s += int(S[i]) * pow(10, i, 2019)",
"- a.append(s % 2019)",
"- t = Counter(a)",
"+ S = [int(i) for i in readline().strip()[::-... | false | 0.041048 | 0.077376 | 0.530495 | [
"s107258444",
"s748572049"
] |
u057109575 | p02761 | python | s751251247 | s190115737 | 166 | 75 | 38,256 | 61,972 | Accepted | Accepted | 54.82 | from collections import defaultdict
N, M = list(map(int, input().split()))
SC = [list(map(int, input().split())) for _ in range(M)]
d = defaultdict(list)
for s, c in SC:
d[s].append(c)
if any(len(set(v)) > 1 for v in list(d.values())):
print((-1))
elif d[1] == [0] and N > 1:
print((-1))
el... |
N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
cand = [-1] * N
flag = False
for s, c in X:
s -= 1
if cand[s] == -1:
cand[s] = c
elif cand[s] != c:
flag = True
if flag or (N > 1 and cand[0] == 0):
print((-1))
else:
ans... | 24 | 25 | 520 | 539 | from collections import defaultdict
N, M = list(map(int, input().split()))
SC = [list(map(int, input().split())) for _ in range(M)]
d = defaultdict(list)
for s, c in SC:
d[s].append(c)
if any(len(set(v)) > 1 for v in list(d.values())):
print((-1))
elif d[1] == [0] and N > 1:
print((-1))
elif N == 1 and M =... | N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(M)]
cand = [-1] * N
flag = False
for s, c in X:
s -= 1
if cand[s] == -1:
cand[s] = c
elif cand[s] != c:
flag = True
if flag or (N > 1 and cand[0] == 0):
print((-1))
else:
ans = 0
for i in r... | false | 4 | [
"-from collections import defaultdict",
"-",
"-SC = [list(map(int, input().split())) for _ in range(M)]",
"-d = defaultdict(list)",
"-for s, c in SC:",
"- d[s].append(c)",
"-if any(len(set(v)) > 1 for v in list(d.values())):",
"+X = [list(map(int, input().split())) for _ in range(M)]",
"+cand = [... | false | 0.057666 | 0.102006 | 0.56532 | [
"s751251247",
"s190115737"
] |
u392319141 | p03425 | python | s551543023 | s832509452 | 171 | 50 | 3,064 | 3,316 | Accepted | Accepted | 70.76 | N = int(eval(input()))
count = {
'M' : 0,
'A' : 0,
'R' : 0,
'C' : 0,
'H' : 0,
}
for _ in range(N):
s = eval(input())
if s[0] in count:
count[s[0]] += 1
ans = 0
count = list(count.items())
for i in range(len(count)):
for j in range(i + 1, len(count)):
... | from itertools import combinations
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(eval(input()))
cnt = defaultdict(int)
for _ in range(N):
s = eval(input())
cnt[s[0]] += 1
ans = 0
for h in combinations(['M', 'A', 'R', 'C', 'H'], r=3):
prd = 1
for s in h... | 23 | 18 | 417 | 361 | N = int(eval(input()))
count = {
"M": 0,
"A": 0,
"R": 0,
"C": 0,
"H": 0,
}
for _ in range(N):
s = eval(input())
if s[0] in count:
count[s[0]] += 1
ans = 0
count = list(count.items())
for i in range(len(count)):
for j in range(i + 1, len(count)):
for k in range(j + 1, len(... | from itertools import combinations
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(eval(input()))
cnt = defaultdict(int)
for _ in range(N):
s = eval(input())
cnt[s[0]] += 1
ans = 0
for h in combinations(["M", "A", "R", "C", "H"], r=3):
prd = 1
for s in h:
prd *... | false | 21.73913 | [
"+from itertools import combinations",
"+from collections import defaultdict",
"+import sys",
"+",
"+input = sys.stdin.readline",
"-count = {",
"- \"M\": 0,",
"- \"A\": 0,",
"- \"R\": 0,",
"- \"C\": 0,",
"- \"H\": 0,",
"-}",
"+cnt = defaultdict(int)",
"- if s[0] in count:... | false | 0.039439 | 0.037393 | 1.054709 | [
"s551543023",
"s832509452"
] |
u952467214 | p03160 | python | s105517406 | s176654846 | 132 | 122 | 13,708 | 13,928 | Accepted | Accepted | 7.58 | N = int(eval(input()))
h = [int(i) for i in input().split()]
dp = [0]*N
dp[1] = abs(h[1] - h[0])
for i in range(N-2):
dp[i+2]=min(dp[i+1]+ abs(h[i+2]-h[i+1]), dp[i]+ abs(h[i+2]-h[i]))
print((dp[N-1])) | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
print((dp[-1])) | 9 | 10 | 204 | 205 | N = int(eval(input()))
h = [int(i) for i in input().split()]
dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(N - 2):
dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]), dp[i] + abs(h[i + 2] - h[i]))
print((dp[N - 1]))
| n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[-1]))
| false | 10 | [
"-N = int(eval(input()))",
"-h = [int(i) for i in input().split()]",
"-dp = [0] * N",
"-dp[1] = abs(h[1] - h[0])",
"-for i in range(N - 2):",
"- dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]), dp[i] + abs(h[i + 2] - h[i]))",
"-print((dp[N - 1]))",
"+n = int(eval(input()))",
"+h = list(map(i... | false | 0.039278 | 0.048109 | 0.816438 | [
"s105517406",
"s176654846"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.