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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u867826040 | p02844 | python | s360532314 | s121545307 | 159 | 32 | 73,656 | 9,256 | Accepted | Accepted | 79.87 | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
i = str(i).zfill(3)
ind = 0
a = 0
for ij in i:
while(ind < len(s)):
if s[ind] == ij:
a += 1
ind += 1
break
ind += 1
ans += a == 3
prin... | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
i = str(i).zfill(3)
f = True
x = -1
for j in range(3):
x = s.find(i[j],x+1)
f = f and bool(x >= 0)
ans += f
print(ans)
| 16 | 12 | 315 | 225 | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
i = str(i).zfill(3)
ind = 0
a = 0
for ij in i:
while ind < len(s):
if s[ind] == ij:
a += 1
ind += 1
break
ind += 1
ans += a == 3
print(ans)
| n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
i = str(i).zfill(3)
f = True
x = -1
for j in range(3):
x = s.find(i[j], x + 1)
f = f and bool(x >= 0)
ans += f
print(ans)
| false | 25 | [
"- ind = 0",
"- a = 0",
"- for ij in i:",
"- while ind < len(s):",
"- if s[ind] == ij:",
"- a += 1",
"- ind += 1",
"- break",
"- ind += 1",
"- ans += a == 3",
"+ f = True",
"+ x = -1",
"+ for j in ... | false | 0.044009 | 0.037495 | 1.173718 | [
"s360532314",
"s121545307"
] |
u046187684 | p02947 | python | s953546085 | s616005908 | 330 | 303 | 27,856 | 27,468 | Accepted | Accepted | 8.18 | from collections import defaultdict
def solve(string):
n, *s = string.split()
d = defaultdict(int)
for _s in s:
d["".join(sorted(_s))] += 1
return str(sum([v * (v - 1) // 2 for v in list(d.values()) if v > 1]))
if __name__ == '__main__':
n = int(eval(input()))
print((sol... | def solve(string):
n, *ss = string.split()
d = {}
for s in ss:
s = "".join(sorted(s))
d[s] = 1 + d[s] if s in list(d.keys()) else 1
return str(sum([v * (v - 1) // 2 for v in list(d.values())]))
if __name__ == '__main__':
n = int(eval(input()))
print((solve('{}\n'.for... | 14 | 12 | 368 | 351 | from collections import defaultdict
def solve(string):
n, *s = string.split()
d = defaultdict(int)
for _s in s:
d["".join(sorted(_s))] += 1
return str(sum([v * (v - 1) // 2 for v in list(d.values()) if v > 1]))
if __name__ == "__main__":
n = int(eval(input()))
print((solve("{}\n".for... | def solve(string):
n, *ss = string.split()
d = {}
for s in ss:
s = "".join(sorted(s))
d[s] = 1 + d[s] if s in list(d.keys()) else 1
return str(sum([v * (v - 1) // 2 for v in list(d.values())]))
if __name__ == "__main__":
n = int(eval(input()))
print((solve("{}\n".format(n) + "\... | false | 14.285714 | [
"-from collections import defaultdict",
"-",
"-",
"- n, *s = string.split()",
"- d = defaultdict(int)",
"- for _s in s:",
"- d[\"\".join(sorted(_s))] += 1",
"- return str(sum([v * (v - 1) // 2 for v in list(d.values()) if v > 1]))",
"+ n, *ss = string.split()",
"+ d = {}",... | false | 0.042814 | 0.047195 | 0.907173 | [
"s953546085",
"s616005908"
] |
u286955577 | p03151 | python | s010701551 | s500345376 | 430 | 115 | 27,080 | 18,484 | Accepted | Accepted | 73.26 | import numpy as np
def solve(A, B):
diff = np.array(A) - np.array(B)
shortage = list([d for d in diff if d < 0])
remainder = sorted(list([d for d in diff if d > 0]), reverse=True)
short_sum = sum(shortage)
if short_sum == 0: return 0
counter = 0
for r in remainder:
short_sum += r
count... | import operator
def solve(A, B):
diff = list(map(operator.sub, A, B))
shortage = list([d for d in diff if d < 0])
remainder = list([d for d in diff if d > 0])
remainder.sort(reverse=True)
short_sum = sum(shortage)
if short_sum == 0: return 0
counter = len(shortage)
for r in remainder:
s... | 20 | 21 | 517 | 525 | import numpy as np
def solve(A, B):
diff = np.array(A) - np.array(B)
shortage = list([d for d in diff if d < 0])
remainder = sorted(list([d for d in diff if d > 0]), reverse=True)
short_sum = sum(shortage)
if short_sum == 0:
return 0
counter = 0
for r in remainder:
short_su... | import operator
def solve(A, B):
diff = list(map(operator.sub, A, B))
shortage = list([d for d in diff if d < 0])
remainder = list([d for d in diff if d > 0])
remainder.sort(reverse=True)
short_sum = sum(shortage)
if short_sum == 0:
return 0
counter = len(shortage)
for r in rem... | false | 4.761905 | [
"-import numpy as np",
"+import operator",
"- diff = np.array(A) - np.array(B)",
"+ diff = list(map(operator.sub, A, B))",
"- remainder = sorted(list([d for d in diff if d > 0]), reverse=True)",
"+ remainder = list([d for d in diff if d > 0])",
"+ remainder.sort(reverse=True)",
"- co... | false | 0.198546 | 0.042695 | 4.650336 | [
"s010701551",
"s500345376"
] |
u201928947 | p02599 | python | s599214648 | s576998481 | 1,988 | 1,373 | 179,980 | 166,496 | Accepted | Accepted | 30.94 | N,Q = list(map(int,input().split()))
BIT = [0]*(N+1)
def BIT_query(idx):
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx&(-idx)
return res_sum
def BIT_update(idx,x):
while idx <= N:
BIT[idx] += x
idx += idx&(-idx)
return
c = [-1]+list(map(... | N,Q = list(map(int,input().split()))
BIT = [0]*(N+1)
def BIT_query(idx):
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx&(-idx)
return res_sum
def BIT_update(idx,x):
while idx <= N:
BIT[idx] += x
idx += idx&(-idx)
return
c = [-1]+list(map(... | 39 | 43 | 862 | 943 | N, Q = list(map(int, input().split()))
BIT = [0] * (N + 1)
def BIT_query(idx):
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & (-idx)
return res_sum
def BIT_update(idx, x):
while idx <= N:
BIT[idx] += x
idx += idx & (-idx)
return
c = [-1] + list(map(... | N, Q = list(map(int, input().split()))
BIT = [0] * (N + 1)
def BIT_query(idx):
res_sum = 0
while idx > 0:
res_sum += BIT[idx]
idx -= idx & (-idx)
return res_sum
def BIT_update(idx, x):
while idx <= N:
BIT[idx] += x
idx += idx & (-idx)
return
c = [-1] + list(map(... | false | 9.302326 | [
"- queries.append((l, r, q))",
"-queries.sort(key=lambda x: x[1])",
"+ queries.append(r * 10**12 + l * 10**6 + q)",
"+queries.sort()",
"- l, r, q = queries[i]",
"+ query = queries[i]",
"+ r = query // 10**12",
"+ query %= 10**12",
"+ l = query // 10**6",
"+ q = query % 10**... | false | 0.037931 | 0.036762 | 1.031812 | [
"s599214648",
"s576998481"
] |
u057993957 | p03673 | python | s680241764 | s558706481 | 113 | 60 | 34,068 | 25,284 | Accepted | Accepted | 46.9 | n = int(eval(input()))
a = list(map(int, input().split()))
a1 = list(map(str, a[::2]))
a2 = list(map(str, a[1::2]))
if n % 2 == 1:
print((" ".join(a1[::-1] + a2)))
else:
print((" ".join(a2[::-1] + a1))) | n = int(eval(input()))
a = input().split()
a1 = a[::2]
a2 = a[1::2]
if n % 2 == 1:
print((" ".join(a1[::-1] + a2)))
else:
print((" ".join(a2[::-1] + a1))) | 10 | 10 | 207 | 159 | n = int(eval(input()))
a = list(map(int, input().split()))
a1 = list(map(str, a[::2]))
a2 = list(map(str, a[1::2]))
if n % 2 == 1:
print((" ".join(a1[::-1] + a2)))
else:
print((" ".join(a2[::-1] + a1)))
| n = int(eval(input()))
a = input().split()
a1 = a[::2]
a2 = a[1::2]
if n % 2 == 1:
print((" ".join(a1[::-1] + a2)))
else:
print((" ".join(a2[::-1] + a1)))
| false | 0 | [
"-a = list(map(int, input().split()))",
"-a1 = list(map(str, a[::2]))",
"-a2 = list(map(str, a[1::2]))",
"+a = input().split()",
"+a1 = a[::2]",
"+a2 = a[1::2]"
] | false | 0.031999 | 0.029868 | 1.071333 | [
"s680241764",
"s558706481"
] |
u983918956 | p03576 | python | s148680039 | s804865610 | 1,902 | 1,203 | 47,000 | 3,188 | Accepted | Accepted | 36.75 | N,K = list(map(int,input().split()))
X = []; Y = []; info = []
for i in range(N):
x,y = list(map(int,input().split()))
X.append(x); Y.append(y); info.append([x,y])
X.sort(); Y.sort()
ans = float('inf')
for i in range(N):
for j in range(i+1,N):
for k in range(N):
for l in range(... | def acc2(grid):
H = len(grid); W = len(grid[0])
for i in range(H):
for j in range(W-1):
grid[i][j+1] += grid[i][j]
for j in range(W):
for i in range(H-1):
grid[i+1][j] += grid[i][j]
ngrid = [[0]*(W+1)]
for i in range(H):
line = [0] + grid[i]
... | 21 | 42 | 648 | 1,107 | N, K = list(map(int, input().split()))
X = []
Y = []
info = []
for i in range(N):
x, y = list(map(int, input().split()))
X.append(x)
Y.append(y)
info.append([x, y])
X.sort()
Y.sort()
ans = float("inf")
for i in range(N):
for j in range(i + 1, N):
for k in range(N):
for l in range... | def acc2(grid):
H = len(grid)
W = len(grid[0])
for i in range(H):
for j in range(W - 1):
grid[i][j + 1] += grid[i][j]
for j in range(W):
for i in range(H - 1):
grid[i + 1][j] += grid[i][j]
ngrid = [[0] * (W + 1)]
for i in range(H):
line = [0] + gri... | false | 50 | [
"+def acc2(grid):",
"+ H = len(grid)",
"+ W = len(grid[0])",
"+ for i in range(H):",
"+ for j in range(W - 1):",
"+ grid[i][j + 1] += grid[i][j]",
"+ for j in range(W):",
"+ for i in range(H - 1):",
"+ grid[i + 1][j] += grid[i][j]",
"+ ngrid = [[0... | false | 0.042743 | 0.083348 | 0.512822 | [
"s148680039",
"s804865610"
] |
u105210954 | p03163 | python | s556709026 | s817843841 | 500 | 205 | 119,404 | 92,852 | Accepted | Accepted | 59 | def resolve():
n, w = list(map(int, input().split()))
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(w + 1):
tmp = dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1] if j >= goods[i... | import numpy as np
def resolve():
n, w = list(map(int, input().split()))
goods = np.array([list(map(int, input().split())) for _ in range(n)])
dp = np.zeros([n + 1, w + 1], dtype=int)
for i in range(1, n + 1):
tmp = np.zeros(w + 1, dtype=int)
tmp[goods[i - 1][0]:] = dp[i - 1][:-... | 13 | 14 | 416 | 432 | def resolve():
n, w = list(map(int, input().split()))
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(w + 1):
tmp = (
dp[i - 1][j - goods[i - 1][0]] + goods[i - 1][1]
... | import numpy as np
def resolve():
n, w = list(map(int, input().split()))
goods = np.array([list(map(int, input().split())) for _ in range(n)])
dp = np.zeros([n + 1, w + 1], dtype=int)
for i in range(1, n + 1):
tmp = np.zeros(w + 1, dtype=int)
tmp[goods[i - 1][0] :] = dp[i - 1][: -goods... | false | 7.142857 | [
"+import numpy as np",
"+",
"+",
"- goods = [list(map(int, input().split())) for _ in range(n)]",
"- dp = [[0] * (w + 1) for _ in range(n + 1)]",
"+ goods = np.array([list(map(int, input().split())) for _ in range(n)])",
"+ dp = np.zeros([n + 1, w + 1], dtype=int)",
"- for j in rang... | false | 0.037252 | 0.162891 | 0.228695 | [
"s556709026",
"s817843841"
] |
u729133443 | p02930 | python | s679442518 | s090347925 | 262 | 111 | 44,764 | 3,952 | Accepted | Accepted | 57.63 | n=int(eval(input()))
l=[1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1... | n=int(eval(input()))
while n:n-=1;print((*[bin(j+1)[::-1].find('1')+1for j in range(n)])) | 4 | 2 | 1,579 | 82 | n = int(eval(input()))
l = [
1,
2,
1,
3,
1,
2,
1,
4,
1,
2,
1,
3,
1,
2,
1,
5,
1,
2,
1,
3,
1,
2,
1,
4,
1,
2,
1,
3,
1,
2,
1,
6,
1,
2,
1,
3,
1,
2,
1,
4,
1,
... | n = int(eval(input()))
while n:
n -= 1
print((*[bin(j + 1)[::-1].find("1") + 1 for j in range(n)]))
| false | 50 | [
"-l = [",
"- 1,",
"- 2,",
"- 1,",
"- 3,",
"- 1,",
"- 2,",
"- 1,",
"- 4,",
"- 1,",
"- 2,",
"- 1,",
"- 3,",
"- 1,",
"- 2,",
"- 1,",
"- 5,",
"- 1,",
"- 2,",
"- 1,",
"- 3,",
"- 1,",
"- 2,",
"- 1,",
"- ... | false | 0.046804 | 0.052104 | 0.898285 | [
"s679442518",
"s090347925"
] |
u208394180 | p02572 | python | s083648443 | s040936004 | 174 | 132 | 31,364 | 31,552 | Accepted | Accepted | 24.14 | mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
S = sum(A) % mod
ans = 0
for i in range(N):
S -= A[i]
if S < 0: S += mod
ans += S * A[i]
ans %= mod
print(ans) | mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
s = sum(A)
S = s**2
D = sum([a**2 for a in A])
print((int((S - D) // 2) % mod))
| 14 | 9 | 213 | 159 | mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
S = sum(A) % mod
ans = 0
for i in range(N):
S -= A[i]
if S < 0:
S += mod
ans += S * A[i]
ans %= mod
print(ans)
| mod = 10**9 + 7
N = int(eval(input()))
A = [int(x) for x in input().split()]
s = sum(A)
S = s**2
D = sum([a**2 for a in A])
print((int((S - D) // 2) % mod))
| false | 35.714286 | [
"-S = sum(A) % mod",
"-ans = 0",
"-for i in range(N):",
"- S -= A[i]",
"- if S < 0:",
"- S += mod",
"- ans += S * A[i]",
"- ans %= mod",
"-print(ans)",
"+s = sum(A)",
"+S = s**2",
"+D = sum([a**2 for a in A])",
"+print((int((S - D) // 2) % mod))"
] | false | 0.047511 | 0.04457 | 1.065994 | [
"s083648443",
"s040936004"
] |
u241159583 | p03380 | python | s597674990 | s734681819 | 126 | 66 | 14,428 | 14,428 | Accepted | Accepted | 47.62 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
N = float("INF")
ans = 0
for i in range(1,n):
if abs(a[i]-(a[0]-a[i])) < N:
N = abs(a[i]-(a[0]-a[i]))
ans = a[i]
print((a[0], ans)) | n = int(eval(input()))
A = list(map(int, input().split()))
x = max(A)
A.pop(A.index(max(A)))
ans = A[0]
ABS = abs(x//2-A[0])
for a in A[1:]:
if ABS > abs(x//2-a):
ans = a
ABS = abs(x//2-a)
print((x,ans)) | 10 | 11 | 232 | 225 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
N = float("INF")
ans = 0
for i in range(1, n):
if abs(a[i] - (a[0] - a[i])) < N:
N = abs(a[i] - (a[0] - a[i]))
ans = a[i]
print((a[0], ans))
| n = int(eval(input()))
A = list(map(int, input().split()))
x = max(A)
A.pop(A.index(max(A)))
ans = A[0]
ABS = abs(x // 2 - A[0])
for a in A[1:]:
if ABS > abs(x // 2 - a):
ans = a
ABS = abs(x // 2 - a)
print((x, ans))
| false | 9.090909 | [
"-a = list(map(int, input().split()))",
"-a.sort(reverse=True)",
"-N = float(\"INF\")",
"-ans = 0",
"-for i in range(1, n):",
"- if abs(a[i] - (a[0] - a[i])) < N:",
"- N = abs(a[i] - (a[0] - a[i]))",
"- ans = a[i]",
"-print((a[0], ans))",
"+A = list(map(int, input().split()))",
... | false | 0.036304 | 0.037783 | 0.960856 | [
"s597674990",
"s734681819"
] |
u252368621 | p00002 | python | s712255463 | s652455122 | 30 | 20 | 7,584 | 7,608 | Accepted | Accepted | 33.33 | while True:
try:
x,y=[int(i) for i in input().split()]
print((len(str(x+y))))
except:
break; | import sys
while(True):
try:
a,b=[int(i) for i in input().split()]
print((len(str(a+b))))
except:
sys.exit() | 6 | 7 | 127 | 144 | while True:
try:
x, y = [int(i) for i in input().split()]
print((len(str(x + y))))
except:
break
| import sys
while True:
try:
a, b = [int(i) for i in input().split()]
print((len(str(a + b))))
except:
sys.exit()
| false | 14.285714 | [
"+import sys",
"+",
"- x, y = [int(i) for i in input().split()]",
"- print((len(str(x + y))))",
"+ a, b = [int(i) for i in input().split()]",
"+ print((len(str(a + b))))",
"- break",
"+ sys.exit()"
] | false | 0.040728 | 0.150518 | 0.270587 | [
"s712255463",
"s652455122"
] |
u285443936 | p03294 | python | s733457378 | s728042193 | 94 | 18 | 3,316 | 3,316 | Accepted | Accepted | 80.85 | N = int(eval(input()))
a =list(map(int, input().split()))
ans = 0
a_all = 1
for i in range(N):
a_all = a_all*a[i]
for i in range(N):
ans += (a_all -1) % a[i]
print(ans) | N = int(eval(input()))
a = [int(i) for i in input().split()]
ans = sum(a) - N
print(ans) | 10 | 5 | 176 | 87 | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
a_all = 1
for i in range(N):
a_all = a_all * a[i]
for i in range(N):
ans += (a_all - 1) % a[i]
print(ans)
| N = int(eval(input()))
a = [int(i) for i in input().split()]
ans = sum(a) - N
print(ans)
| false | 50 | [
"-a = list(map(int, input().split()))",
"-ans = 0",
"-a_all = 1",
"-for i in range(N):",
"- a_all = a_all * a[i]",
"-for i in range(N):",
"- ans += (a_all - 1) % a[i]",
"+a = [int(i) for i in input().split()]",
"+ans = sum(a) - N"
] | false | 0.051863 | 0.036281 | 1.429458 | [
"s733457378",
"s728042193"
] |
u562935282 | p03946 | python | s339986470 | s789116982 | 77 | 71 | 14,680 | 14,380 | Accepted | Accepted | 7.79 | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
vm = a[n - 1]#数列を右から見た時の最大値
dfm = 0
cnt = 0
for i in range(n - 2, -1, -1):
if a[i] > vm:
vm = a[i]
else:
df = vm - a[i]
if dfm < df:
dfm = df
cnt = 1
elif dfm == df:
... | def main():
from heapq import heappush
inf = 1 << 30
N, T = list(map(int, input().split()))
*A, = list(map(int, input().split()))
h = [inf]
ma = -1
cnt = 0
for x in A:
d = x - h[0]
if ma < d:
ma = d
cnt = 1
elif ma == d:
... | 18 | 25 | 349 | 416 | n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
vm = a[n - 1] # 数列を右から見た時の最大値
dfm = 0
cnt = 0
for i in range(n - 2, -1, -1):
if a[i] > vm:
vm = a[i]
else:
df = vm - a[i]
if dfm < df:
dfm = df
cnt = 1
elif dfm == df:
... | def main():
from heapq import heappush
inf = 1 << 30
N, T = list(map(int, input().split()))
(*A,) = list(map(int, input().split()))
h = [inf]
ma = -1
cnt = 0
for x in A:
d = x - h[0]
if ma < d:
ma = d
cnt = 1
elif ma == d:
cnt ... | false | 28 | [
"-n, t = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-vm = a[n - 1] # 数列を右から見た時の最大値",
"-dfm = 0",
"-cnt = 0",
"-for i in range(n - 2, -1, -1):",
"- if a[i] > vm:",
"- vm = a[i]",
"- else:",
"- df = vm - a[i]",
"- if dfm < df:",
"- ... | false | 0.081682 | 0.04366 | 1.870864 | [
"s339986470",
"s789116982"
] |
u057109575 | p03108 | python | s665326772 | s044683800 | 1,078 | 456 | 110,168 | 107,356 | Accepted | Accepted | 57.7 | N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if rank[x] ... |
class UnionFind:
def __init__(self, n):
self.par = list(range(n))
self.rank = [0] * n
self.size = [1] * n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
... | 44 | 51 | 833 | 1,206 | N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if rank[x] == rank[y]:
r... | class UnionFind:
def __init__(self, n):
self.par = list(range(n))
self.rank = [0] * n
self.size = [1] * n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(sel... | false | 13.72549 | [
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.par = list(range(n))",
"+ self.rank = [0] * n",
"+ self.size = [1] * n",
"+",
"+ def find(self, x):",
"+ if self.par[x] == x:",
"+ return x",
"+ else:",
"+ self.par[x] = self.f... | false | 0.041004 | 0.041518 | 0.987628 | [
"s665326772",
"s044683800"
] |
u332906195 | p02688 | python | s028235305 | s883429964 | 22 | 20 | 9,056 | 9,084 | Accepted | Accepted | 9.09 | N, K = list(map(int, input().split()))
A = [[] for _ in range(N)]
for k in range(K):
d = int(eval(input()))
for a in map(int, input().split()):
A[a - 1].append(k)
print((sum([1 for a in A if len(a) == 0])))
| N, K = list(map(int, input().split()))
F = [1 for _ in range(N)]
for _ in range(K):
d = int(eval(input()))
for a in map(int, input().split()):
F[a - 1] = 0
print((sum(F)))
| 7 | 7 | 215 | 180 | N, K = list(map(int, input().split()))
A = [[] for _ in range(N)]
for k in range(K):
d = int(eval(input()))
for a in map(int, input().split()):
A[a - 1].append(k)
print((sum([1 for a in A if len(a) == 0])))
| N, K = list(map(int, input().split()))
F = [1 for _ in range(N)]
for _ in range(K):
d = int(eval(input()))
for a in map(int, input().split()):
F[a - 1] = 0
print((sum(F)))
| false | 0 | [
"-A = [[] for _ in range(N)]",
"-for k in range(K):",
"+F = [1 for _ in range(N)]",
"+for _ in range(K):",
"- A[a - 1].append(k)",
"-print((sum([1 for a in A if len(a) == 0])))",
"+ F[a - 1] = 0",
"+print((sum(F)))"
] | false | 0.101998 | 0.042371 | 2.407272 | [
"s028235305",
"s883429964"
] |
u057109575 | p02702 | python | s373634518 | s629109364 | 138 | 116 | 86,684 | 68,160 | Accepted | Accepted | 15.94 |
S = list(map(int, list(eval(input()))))
mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
t = (t + int(v) * pow(10, i, mod)) % mod
ctr[t] += 1
ans = ctr[0]
for v in ctr:
ans += v * (v - 1) // 2
print(ans)
|
S = eval(input())
mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
t = (t + int(v) * pow(10, i, mod)) % mod
ctr[t] += 1
ans = ctr[0]
for v in ctr:
ans += v * (v - 1) // 2
print(ans)
| 14 | 14 | 246 | 224 | S = list(map(int, list(eval(input()))))
mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
t = (t + int(v) * pow(10, i, mod)) % mod
ctr[t] += 1
ans = ctr[0]
for v in ctr:
ans += v * (v - 1) // 2
print(ans)
| S = eval(input())
mod = 2019
ctr = [0] * mod
t = 0
for i, v in enumerate(reversed(S)):
t = (t + int(v) * pow(10, i, mod)) % mod
ctr[t] += 1
ans = ctr[0]
for v in ctr:
ans += v * (v - 1) // 2
print(ans)
| false | 0 | [
"-S = list(map(int, list(eval(input()))))",
"+S = eval(input())"
] | false | 0.121054 | 0.173622 | 0.697229 | [
"s373634518",
"s629109364"
] |
u227082700 | p03268 | python | s151835763 | s917532824 | 195 | 167 | 3,060 | 2,940 | Accepted | Accepted | 14.36 | n,k=list(map(int,input().split()))
ans=0
for a in range(1,n+1):
aa=a%k
b=c=(2*k-a-1)%k+1
if (b+c)%k:continue
ans+=((n-b)//k+1)**2
print(ans) | n,k=list(map(int,input().split()))
ans=0
for a in range(1,n+1):
b=c=(k-a-1)%k+1
if (b+c)%k:continue
ans+=((n-b)//k+1)**2
print(ans) | 8 | 7 | 149 | 137 | n, k = list(map(int, input().split()))
ans = 0
for a in range(1, n + 1):
aa = a % k
b = c = (2 * k - a - 1) % k + 1
if (b + c) % k:
continue
ans += ((n - b) // k + 1) ** 2
print(ans)
| n, k = list(map(int, input().split()))
ans = 0
for a in range(1, n + 1):
b = c = (k - a - 1) % k + 1
if (b + c) % k:
continue
ans += ((n - b) // k + 1) ** 2
print(ans)
| false | 12.5 | [
"- aa = a % k",
"- b = c = (2 * k - a - 1) % k + 1",
"+ b = c = (k - a - 1) % k + 1"
] | false | 0.066161 | 0.058186 | 1.13705 | [
"s151835763",
"s917532824"
] |
u762420987 | p03785 | python | s373128278 | s578164013 | 511 | 232 | 51,416 | 8,280 | Accepted | Accepted | 54.6 | N, C, K = list(map(int, input().split()))
Tlist = sorted([int(eval(input())) for _ in range(N)])
ans = 0
count = 0
for i in range(N):
now = Tlist[i]
if count == 0:
rl = now + K
count += 1
continue
else:
if now <= rl <= now + K and count < C:
count +=... | N, C, K = list(map(int, input().split()))
Tlist = sorted([int(eval(input())) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist[1:]:
if now == C:
ans += 1
start = t
now = 1
else:
if t - start <= K:
now += 1
else:
ans ... | 19 | 18 | 413 | 371 | N, C, K = list(map(int, input().split()))
Tlist = sorted([int(eval(input())) for _ in range(N)])
ans = 0
count = 0
for i in range(N):
now = Tlist[i]
if count == 0:
rl = now + K
count += 1
continue
else:
if now <= rl <= now + K and count < C:
count += 1
els... | N, C, K = list(map(int, input().split()))
Tlist = sorted([int(eval(input())) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist[1:]:
if now == C:
ans += 1
start = t
now = 1
else:
if t - start <= K:
now += 1
else:
ans += 1
... | false | 5.263158 | [
"-count = 0",
"-for i in range(N):",
"- now = Tlist[i]",
"- if count == 0:",
"- rl = now + K",
"- count += 1",
"- continue",
"+now = 1",
"+start = Tlist[0]",
"+for t in Tlist[1:]:",
"+ if now == C:",
"+ ans += 1",
"+ start = t",
"+ now = 1... | false | 0.152824 | 0.04796 | 3.186519 | [
"s373128278",
"s578164013"
] |
u318566284 | p02898 | python | s572039446 | s166669028 | 70 | 49 | 11,912 | 11,908 | Accepted | Accepted | 30 | n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
l.sort(reverse=True)
count1=0
for i in l:
if(i<k):
break
count1=count1+1
print(count1)
| n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
count1=0
for i in l:
if(i>=k):
count1+=1
print(count1)
| 10 | 7 | 169 | 129 | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
count1 = 0
for i in l:
if i < k:
break
count1 = count1 + 1
print(count1)
| n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
count1 = 0
for i in l:
if i >= k:
count1 += 1
print(count1)
| false | 30 | [
"-l.sort(reverse=True)",
"- if i < k:",
"- break",
"- count1 = count1 + 1",
"+ if i >= k:",
"+ count1 += 1"
] | false | 0.104826 | 0.04427 | 2.367898 | [
"s572039446",
"s166669028"
] |
u421674761 | p02628 | python | s335777555 | s797014553 | 30 | 26 | 9,212 | 9,176 | Accepted | Accepted | 13.33 | n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
p.sort()
result = 0
for i in range(k):
result += p[i]
print(result)
|
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
p.sort()
print((sum(p[:k])))
| 9 | 7 | 154 | 102 | n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
result = 0
for i in range(k):
result += p[i]
print(result)
| n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print((sum(p[:k])))
| false | 22.222222 | [
"-result = 0",
"-for i in range(k):",
"- result += p[i]",
"-print(result)",
"+print((sum(p[:k])))"
] | false | 0.048317 | 0.134652 | 0.358826 | [
"s335777555",
"s797014553"
] |
u004423772 | p02720 | python | s177174210 | s723970626 | 678 | 217 | 90,968 | 50,012 | Accepted | Accepted | 67.99 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def f(v,i,ans):
if i == 0:return
if str(v)[-1] != "0":
x = int(str(v)+str(int(str(v)[-1])-1))
ans.add(x)
f(x,i-1,ans)
y = int(str(v)+str(v)[-1])
ans.add(y)
f(y,i-1,ans)
if str(v)[-1] != "9... | import sys
input = sys.stdin.readline
from collections import deque
def main():
K = int(eval(input()))
que = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
if K <= 9:
print((que[K-1]))
else:
K -= 9
while K >= 0:
v = que.popleft()
if v[-1]... | 27 | 34 | 630 | 912 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def f(v, i, ans):
if i == 0:
return
if str(v)[-1] != "0":
x = int(str(v) + str(int(str(v)[-1]) - 1))
ans.add(x)
f(x, i - 1, ans)
y = int(str(v) + str(v)[-1])
ans.add(y)
f(y, i - 1, ans)
if ... | import sys
input = sys.stdin.readline
from collections import deque
def main():
K = int(eval(input()))
que = deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
if K <= 9:
print((que[K - 1]))
else:
K -= 9
while K >= 0:
v = que.popleft()
if v[-1] != "0"... | false | 20.588235 | [
"-sys.setrecursionlimit(2147483647)",
"-",
"-",
"-def f(v, i, ans):",
"- if i == 0:",
"- return",
"- if str(v)[-1] != \"0\":",
"- x = int(str(v) + str(int(str(v)[-1]) - 1))",
"- ans.add(x)",
"- f(x, i - 1, ans)",
"- y = int(str(v) + str(v)[-1])",
"- ans.... | false | 0.864193 | 0.05086 | 16.99173 | [
"s177174210",
"s723970626"
] |
u533039576 | p03078 | python | s139149513 | s491672658 | 977 | 36 | 147,904 | 4,976 | Accepted | Accepted | 96.32 | 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()))
d = []
for i in range(x):
for j in range(y):
d.append(a[i] + b[j])
d.sort(reverse=True)
e = []
for i in range(min(len(d), k)):
for j in ... | from heapq import heappush, heappop
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(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
pq = [(-a[0]-b[0]-c[0], 0, 0, 0)]
f = set()
for i in r... | 19 | 25 | 416 | 775 | 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()))
d = []
for i in range(x):
for j in range(y):
d.append(a[i] + b[j])
d.sort(reverse=True)
e = []
for i in range(min(len(d), k)):
for j in range(z):
... | from heapq import heappush, heappop
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(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
pq = [(-a[0] - b[0] - c[0], 0, 0, 0)]
f = set()
for i in range(k):
... | false | 24 | [
"+from heapq import heappush, heappop",
"+",
"-d = []",
"-for i in range(x):",
"- for j in range(y):",
"- d.append(a[i] + b[j])",
"-d.sort(reverse=True)",
"-e = []",
"-for i in range(min(len(d), k)):",
"- for j in range(z):",
"- e.append(d[i] + c[j])",
"-e.sort(reverse=True... | false | 0.037984 | 0.036186 | 1.049682 | [
"s139149513",
"s491672658"
] |
u150984829 | p00009 | python | s409541858 | s930339920 | 450 | 310 | 21,112 | 25,208 | Accepted | Accepted | 31.11 | import sys
m=10**6;a=[0,0]+[1]*m
for i in range(999):
if a[i]:
for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print((sum(a[:int(e)+1])))
| import sys
m=10**6;a=[0,0]+[1]*m
for i in range(999):
if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print((sum(a[:int(e)+1])))
| 6 | 5 | 146 | 144 | import sys
m = 10**6
a = [0, 0] + [1] * m
for i in range(999):
if a[i]:
for j in range(i * 2, m, i):
a[j] = 0
for e in sys.stdin:
print((sum(a[: int(e) + 1])))
| import sys
m = 10**6
a = [0, 0] + [1] * m
for i in range(999):
if a[i]:
a[i * 2 :: i] = [0 for j in a[i * 2 :: i]]
for e in sys.stdin:
print((sum(a[: int(e) + 1])))
| false | 16.666667 | [
"- for j in range(i * 2, m, i):",
"- a[j] = 0",
"+ a[i * 2 :: i] = [0 for j in a[i * 2 :: i]]"
] | false | 1.583968 | 0.617053 | 2.566988 | [
"s409541858",
"s930339920"
] |
u415905784 | p03837 | python | s021684689 | s111157461 | 604 | 403 | 3,444 | 3,444 | Accepted | Accepted | 33.28 | N, M = list(map(int, input().split()))
Adj = [[10 ** 7 for j in range(N)] for i in range(N)]
for i in range(N):
Adj[i][i] = 0
Edge = []
for m in range(M):
a, b, c = list(map(int, input().split()))
Adj[a - 1][b - 1] = c
Adj[b - 1][a - 1] = c
Edge.append([a - 1, b - 1, c])
for i in range(N):
for j ... | N, M = list(map(int, input().split()))
G = [[10000 for j in range(N)] for i in range(N)]
E = [(0, 0, 0)] * M
for i in range(N):
G[i][i] = 0
for i in range(M):
a, b, c = list(map(int, input().split()))
E[i] = (a - 1, b - 1, c)
G[a - 1][b - 1] = c
G[b - 1][a - 1] = c
def warshall_floyd(G):
for k in... | 20 | 25 | 571 | 587 | N, M = list(map(int, input().split()))
Adj = [[10**7 for j in range(N)] for i in range(N)]
for i in range(N):
Adj[i][i] = 0
Edge = []
for m in range(M):
a, b, c = list(map(int, input().split()))
Adj[a - 1][b - 1] = c
Adj[b - 1][a - 1] = c
Edge.append([a - 1, b - 1, c])
for i in range(N):
for j i... | N, M = list(map(int, input().split()))
G = [[10000 for j in range(N)] for i in range(N)]
E = [(0, 0, 0)] * M
for i in range(N):
G[i][i] = 0
for i in range(M):
a, b, c = list(map(int, input().split()))
E[i] = (a - 1, b - 1, c)
G[a - 1][b - 1] = c
G[b - 1][a - 1] = c
def warshall_floyd(G):
for k... | false | 20 | [
"-Adj = [[10**7 for j in range(N)] for i in range(N)]",
"+G = [[10000 for j in range(N)] for i in range(N)]",
"+E = [(0, 0, 0)] * M",
"- Adj[i][i] = 0",
"-Edge = []",
"-for m in range(M):",
"+ G[i][i] = 0",
"+for i in range(M):",
"- Adj[a - 1][b - 1] = c",
"- Adj[b - 1][a - 1] = c",
... | false | 0.007313 | 0.038948 | 0.187762 | [
"s021684689",
"s111157461"
] |
u753803401 | p03948 | python | s586940197 | s357701079 | 605 | 256 | 76,280 | 71,248 | Accepted | Accepted | 57.69 | def slove():
import sys
import collections
input = sys.stdin.readline
n, t = list(map(int, input().rstrip('\n').split()))
a = list(map(int, input().rstrip('\n').split()))
b = collections.defaultdict(list)
m_c = 10 ** 9
for i, v in enumerate(a):
if i != 0 and m_c < v:
... | def slove():
import sys
import collections
input = sys.stdin.readline
n, t = list(map(int, input().rstrip('\n').split()))
a = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(list)
min_b = 10 ** 9
max_p = 0
for v in a:
p = v - min_b
... | 18 | 19 | 507 | 469 | def slove():
import sys
import collections
input = sys.stdin.readline
n, t = list(map(int, input().rstrip("\n").split()))
a = list(map(int, input().rstrip("\n").split()))
b = collections.defaultdict(list)
m_c = 10**9
for i, v in enumerate(a):
if i != 0 and m_c < v:
b... | def slove():
import sys
import collections
input = sys.stdin.readline
n, t = list(map(int, input().rstrip("\n").split()))
a = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(list)
min_b = 10**9
max_p = 0
for v in a:
p = v - min_b
max_p = max(... | false | 5.263158 | [
"- b = collections.defaultdict(list)",
"- m_c = 10**9",
"- for i, v in enumerate(a):",
"- if i != 0 and m_c < v:",
"- b[v - m_c] += [m_c]",
"- m_c = min(m_c, v)",
"- b = sorted(list(b.items()), reverse=True)[0]",
"- print((len(collections.Counter(b[1]))))",
"+... | false | 0.036993 | 0.036554 | 1.011991 | [
"s586940197",
"s357701079"
] |
u905203728 | p03752 | python | s702720142 | s004493717 | 209 | 81 | 41,072 | 68,604 | Accepted | Accepted | 61.24 | n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
ans=float("inf")
for i in range(1,2**n):
num=format(i,"b").zfill(n)
point=0
if num.count("1")!=k:continue
highest=A[0]
for j in range(1,n):
if highest>=A[j] and num[j]=="1":
point +=highest-A[j]+1
... | n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
ans=float("inf")
for i in range(2**n):
num=format(i,"b").zfill(n)
if num.count("1")!=k:continue
height,money=0,0
for j in range(n):
if num[j]=="1":
if A[j]<=height:
money +=height-A[j]+1
... | 17 | 18 | 409 | 461 | n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = float("inf")
for i in range(1, 2**n):
num = format(i, "b").zfill(n)
point = 0
if num.count("1") != k:
continue
highest = A[0]
for j in range(1, n):
if highest >= A[j] and num[j] == "1":
point... | n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = float("inf")
for i in range(2**n):
num = format(i, "b").zfill(n)
if num.count("1") != k:
continue
height, money = 0, 0
for j in range(n):
if num[j] == "1":
if A[j] <= height:
mone... | false | 5.555556 | [
"-for i in range(1, 2**n):",
"+for i in range(2**n):",
"- point = 0",
"- highest = A[0]",
"- for j in range(1, n):",
"- if highest >= A[j] and num[j] == \"1\":",
"- point += highest - A[j] + 1",
"- highest += 1",
"- highest = max(highest, A[j])",
"- ... | false | 0.03832 | 0.033868 | 1.131466 | [
"s702720142",
"s004493717"
] |
u764215612 | p02691 | python | s708184672 | s341828335 | 245 | 162 | 61,828 | 32,376 | Accepted | Accepted | 33.88 | from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
d[i+a[i]] += 1
ans = 0
for i in range(n):
ans += d[i-a[i]]
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
d = [0]*n
for i in range(n):
if i+a[i] < n: d[i+a[i]] += 1
ans = 0
for i in range(n):
if i-a[i] >= 0: ans += d[i-a[i]]
print(ans) | 10 | 9 | 211 | 194 | from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
d[i + a[i]] += 1
ans = 0
for i in range(n):
ans += d[i - a[i]]
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
d = [0] * n
for i in range(n):
if i + a[i] < n:
d[i + a[i]] += 1
ans = 0
for i in range(n):
if i - a[i] >= 0:
ans += d[i - a[i]]
print(ans)
| false | 10 | [
"-from collections import defaultdict",
"-",
"-d = defaultdict(int)",
"+d = [0] * n",
"- d[i + a[i]] += 1",
"+ if i + a[i] < n:",
"+ d[i + a[i]] += 1",
"- ans += d[i - a[i]]",
"+ if i - a[i] >= 0:",
"+ ans += d[i - a[i]]"
] | false | 0.036559 | 0.038191 | 0.957254 | [
"s708184672",
"s341828335"
] |
u086566114 | p02410 | python | s486653275 | s053728645 | 30 | 10 | 6,520 | 6,448 | Accepted | Accepted | 66.67 | [n, m] = [int(x) for x in input().split()]
A = [[0] * m for x in range(n)]
B = [0] * m
counter = 0
while counter < n:
A[counter] = [int(x) for x in input().split()]
counter += 1
counter = 0
while counter < m:
B[counter] = int(input())
counter += 1
counter = 0
while counter < n:
resu... | [n, m] = [int(x) for x in input().split()]
A = []
counter = 0
while counter < n:
A.append([int(x) for x in input().split()])
counter += 1
B = [int(input()) for j in range(m)]
counter = 0
while counter < n:
result = 0
for j in range(m):
result += A[counter][j] * B[j]
print(r... | 20 | 17 | 439 | 356 | [n, m] = [int(x) for x in input().split()]
A = [[0] * m for x in range(n)]
B = [0] * m
counter = 0
while counter < n:
A[counter] = [int(x) for x in input().split()]
counter += 1
counter = 0
while counter < m:
B[counter] = int(input())
counter += 1
counter = 0
while counter < n:
result = 0
for j ... | [n, m] = [int(x) for x in input().split()]
A = []
counter = 0
while counter < n:
A.append([int(x) for x in input().split()])
counter += 1
B = [int(input()) for j in range(m)]
counter = 0
while counter < n:
result = 0
for j in range(m):
result += A[counter][j] * B[j]
print(result)
counter... | false | 15 | [
"-A = [[0] * m for x in range(n)]",
"-B = [0] * m",
"+A = []",
"- A[counter] = [int(x) for x in input().split()]",
"+ A.append([int(x) for x in input().split()])",
"-counter = 0",
"-while counter < m:",
"- B[counter] = int(input())",
"- counter += 1",
"+B = [int(input()) for j in range... | false | 0.038515 | 0.100784 | 0.382152 | [
"s486653275",
"s053728645"
] |
u151625340 | p03557 | python | s946292672 | s417712616 | 901 | 494 | 23,156 | 108,260 | Accepted | Accepted | 45.17 | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def bs_left(l, target):
low, high = 0, len(l)
while low < high:
mid = (low+high)//2
if l[mid] < target:
low ... | N = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき... | 33 | 16 | 728 | 498 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def bs_left(l, target):
low, high = 0, len(l)
while low < high:
mid = (low + high) // 2
if l[mid] < target:
low = mi... | N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/... | false | 51.515152 | [
"-A = list(map(int, input().split()))",
"-B = list(map(int, input().split()))",
"-C = list(map(int, input().split()))",
"-A.sort()",
"-B.sort()",
"-C.sort()",
"+A = sorted(list(map(int, input().split())))",
"+B = sorted(list(map(int, input().split())))",
"+C = sorted(list(map(int, input().split())))... | false | 0.037686 | 0.038342 | 0.982906 | [
"s946292672",
"s417712616"
] |
u513081876 | p04013 | python | s532687060 | s741015838 | 1,074 | 125 | 4,208 | 5,748 | Accepted | Accepted | 88.36 | N, A = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]
dp = [[0] * (sum(x)+1) for j in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
for j in list(range(1, N+1))[::-1]:
for k in list(range(x[i-1], sum(x[:i])+1))[::-1]:
dp[j][k] += dp[j-1][k - x[i-1]]
p... | N, A = [int(_) for _ in input().split()]
x = [int(i)-A for i in input().split()]
dp = [[0 for j in range(100 * N + 1)] for i in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
for j in range(50, 100 * N + 1 - 50):
dp[i + 1][j] = dp[i][j] + dp[i][j - x[i]]
print((dp[N][50 * N] - 1)) | 12 | 11 | 383 | 316 | N, A = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]
dp = [[0] * (sum(x) + 1) for j in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
for j in list(range(1, N + 1))[::-1]:
for k in list(range(x[i - 1], sum(x[:i]) + 1))[::-1]:
dp[j][k] += dp[j - 1][k - x[i - 1]]
pr... | N, A = [int(_) for _ in input().split()]
x = [int(i) - A for i in input().split()]
dp = [[0 for j in range(100 * N + 1)] for i in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
for j in range(50, 100 * N + 1 - 50):
dp[i + 1][j] = dp[i][j] + dp[i][j - x[i]]
print((dp[N][50 * N] - 1))
| false | 8.333333 | [
"-x = [int(_) for _ in input().split()]",
"-dp = [[0] * (sum(x) + 1) for j in range(N + 1)]",
"-dp[0][0] = 1",
"-for i in range(1, N + 1):",
"- for j in list(range(1, N + 1))[::-1]:",
"- for k in list(range(x[i - 1], sum(x[:i]) + 1))[::-1]:",
"- dp[j][k] += dp[j - 1][k - x[i - 1]]",... | false | 0.130587 | 0.048901 | 2.670462 | [
"s532687060",
"s741015838"
] |
u159994501 | p03262 | python | s660124470 | s350069447 | 136 | 116 | 14,224 | 16,316 | Accepted | Accepted | 14.71 | def gcd(a,b):
if b == 0:
return a
return gcd(b, a % b)
n, X = list(map(int,input().split()))
x = list(map(int,input().split()))
x.append(X)
x.sort()
x = [x[i]-x[0] for i in range(n+1)]
del x[0]
g = x[0]
for i in range(1, n):
g = gcd(g,x[i])
print(g)
| import math
from functools import reduce
import fractions
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
dif = [abs(X - x[0])]
if N > 1:
... | 16 | 21 | 281 | 401 | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(X)
x.sort()
x = [x[i] - x[0] for i in range(n + 1)]
del x[0]
g = x[0]
for i in range(1, n):
g = gcd(g, x[i])
print(g)
| import math
from functools import reduce
import fractions
def gcd(*numbers):
return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
return reduce(fractions.gcd, numbers)
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
dif = [abs(X - x[0])]
if N > 1:
for i in range(N - ... | false | 23.809524 | [
"-def gcd(a, b):",
"- if b == 0:",
"- return a",
"- return gcd(b, a % b)",
"+import math",
"+from functools import reduce",
"+import fractions",
"-n, X = list(map(int, input().split()))",
"+def gcd(*numbers):",
"+ return reduce(fractions.gcd, numbers)",
"+",
"+",
"+def gcd_li... | false | 0.079113 | 0.194387 | 0.406989 | [
"s660124470",
"s350069447"
] |
u086056891 | p02972 | python | s232726517 | s162456019 | 651 | 253 | 7,220 | 6,844 | Accepted | Accepted | 61.14 | n = int(eval(input()))
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n, 0, -1):
for j in range(i, n + 1, i):
b[i] ^= b[j]
b[i] ^= a[i]
print((sum(b)))
for i in range(1, n + 1):
if b[i] == 1:
print(i) | n = int(eval(input()))
a = [0] + list(map(int, input().split()))
for i in range(n, 0, -1):
a[i] = sum(a[i::i]) % 2
print((sum(a)))
for i in range(1, n + 1):
if a[i] == 1:
print(i) | 13 | 10 | 262 | 198 | n = int(eval(input()))
a = [0] + list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n, 0, -1):
for j in range(i, n + 1, i):
b[i] ^= b[j]
b[i] ^= a[i]
print((sum(b)))
for i in range(1, n + 1):
if b[i] == 1:
print(i)
| n = int(eval(input()))
a = [0] + list(map(int, input().split()))
for i in range(n, 0, -1):
a[i] = sum(a[i::i]) % 2
print((sum(a)))
for i in range(1, n + 1):
if a[i] == 1:
print(i)
| false | 23.076923 | [
"-b = [0] * (n + 1)",
"- for j in range(i, n + 1, i):",
"- b[i] ^= b[j]",
"- b[i] ^= a[i]",
"-print((sum(b)))",
"+ a[i] = sum(a[i::i]) % 2",
"+print((sum(a)))",
"- if b[i] == 1:",
"+ if a[i] == 1:"
] | false | 0.042978 | 0.054466 | 0.78907 | [
"s232726517",
"s162456019"
] |
u373442126 | p02614 | python | s530977852 | s745430388 | 91 | 84 | 68,836 | 73,964 | Accepted | Accepted | 7.69 | from collections import defaultdict
import itertools
def main():
H,W,K = [int(x) for x in input().split()]
B = 0
BH = [0]*H
BW = [0]*W
BHW = []
pBHW = []
for h in range(H):
BHW.append([0]*W)
for i in range(H):
C = list(eval(input()))
for j in rang... | def main():
H,W,K = [int(x) for x in input().split()]
B = 0
BH = [0]*H
BW = [0]*W
BHW = []
for h in range(H):
BHW.append([0]*W)
for i in range(H):
C = list(eval(input()))
for j in range(W):
if C[j] == '#':
B += 1
... | 81 | 41 | 2,104 | 1,068 | from collections import defaultdict
import itertools
def main():
H, W, K = [int(x) for x in input().split()]
B = 0
BH = [0] * H
BW = [0] * W
BHW = []
pBHW = []
for h in range(H):
BHW.append([0] * W)
for i in range(H):
C = list(eval(input()))
for j in range(W):
... | def main():
H, W, K = [int(x) for x in input().split()]
B = 0
BH = [0] * H
BW = [0] * W
BHW = []
for h in range(H):
BHW.append([0] * W)
for i in range(H):
C = list(eval(input()))
for j in range(W):
if C[j] == "#":
B += 1
BH[... | false | 49.382716 | [
"-from collections import defaultdict",
"-import itertools",
"-",
"-",
"- pBHW = []",
"- pBHW.append((i, j))",
"- # print(b,B,icost,jcost,ijcost,cnt)",
"- # print(B)",
"- # print(BH)",
"- # print(BW)",
"- # print(BHW)",
"- # print(pBHW)",
"- # f... | false | 0.128547 | 0.049278 | 2.608605 | [
"s530977852",
"s745430388"
] |
u408071652 | p02775 | python | s154332700 | s611045705 | 309 | 252 | 11,256 | 19,492 | Accepted | Accepted | 18.45 | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = eval(input())
count = 0
S = len(N)
flag = 0
for i in range(S):
temp = flag + int(N[-1 - i])
if temp > 5:
count += 10 - temp
flag = 1
elif temp ==5 ... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = list(map(int,eval(input())))
count = 0
S = len(N)
flag = 0
for i in range(S):
temp = flag + N[-1 - i]
if temp > 5:
count += 10 - temp
flag = 1
elif ... | 31 | 31 | 531 | 536 | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = eval(input())
count = 0
S = len(N)
flag = 0
for i in range(S):
temp = flag + int(N[-1 - i])
if temp > 5:
count += 10 - temp
flag = 1
elif temp == 5 and i != S - 1 and ... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = list(map(int, eval(input())))
count = 0
S = len(N)
flag = 0
for i in range(S):
temp = flag + N[-1 - i]
if temp > 5:
count += 10 - temp
flag = 1
elif temp == 5 and i !=... | false | 0 | [
"- N = eval(input())",
"+ N = list(map(int, eval(input())))",
"- temp = flag + int(N[-1 - i])",
"+ temp = flag + N[-1 - i]",
"- elif temp == 5 and i != S - 1 and int(N[-1 - i - 1]) >= 5:",
"+ elif temp == 5 and i != S - 1 and N[-1 - i - 1] >= 5:"
] | false | 0.04612 | 0.045078 | 1.023127 | [
"s154332700",
"s611045705"
] |
u933622697 | p03478 | python | s931890347 | s996556414 | 35 | 31 | 3,424 | 3,296 | Accepted | Accepted | 11.43 | n, a, b = list(map(int, input().split()))
canditates = [i for i in range(1, n+1)
if a <= sum(list(map(int, list(str(i))))) <= b]
print((sum(canditates))) | n, a, b = list(map(int, input().split()))
canditates = [i for i in range(1, n+1)
if a <= sum(map(int, list(str(i)))) <= b]
print((sum(canditates))) | 4 | 4 | 163 | 157 | n, a, b = list(map(int, input().split()))
canditates = [i for i in range(1, n + 1) if a <= sum(list(map(int, list(str(i))))) <= b]
print((sum(canditates)))
| n, a, b = list(map(int, input().split()))
canditates = [i for i in range(1, n + 1) if a <= sum(map(int, list(str(i)))) <= b]
print((sum(canditates)))
| false | 0 | [
"-canditates = [i for i in range(1, n + 1) if a <= sum(list(map(int, list(str(i))))) <= b]",
"+canditates = [i for i in range(1, n + 1) if a <= sum(map(int, list(str(i)))) <= b]"
] | false | 0.047038 | 0.007844 | 5.996926 | [
"s931890347",
"s996556414"
] |
u497952650 | p02744 | python | s884192884 | s044551567 | 271 | 166 | 16,224 | 16,224 | Accepted | Accepted | 38.75 | from copy import deepcopy
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t"]
if N == num:
S.sort()
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for ... | from copy import deepcopy
def f(num,N,S):
alphabet = ["a","b","c","d","e","f","g","h","i","j"]
if N == num:
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for i in range(length):
ttmp = sorted(list(S[i]))... | 24 | 19 | 646 | 502 | from copy import deepcopy
def f(num, N, S):
alphabet = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t... | from copy import deepcopy
def f(num, N, S):
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
if N == num:
for i in range(len(S)):
print((S[i]))
return
else:
tmp = []
length = len(S)
for i in range(length):
ttmp = sorted(list(S[i]... | false | 20.833333 | [
"- alphabet = [",
"- \"a\",",
"- \"b\",",
"- \"c\",",
"- \"d\",",
"- \"e\",",
"- \"f\",",
"- \"g\",",
"- \"h\",",
"- \"i\",",
"- \"j\",",
"- \"k\",",
"- \"l\",",
"- \"m\",",
"- \"n\",",
... | false | 0.04297 | 0.048368 | 0.888395 | [
"s884192884",
"s044551567"
] |
u840310460 | p03369 | python | s233207909 | s167921317 | 172 | 21 | 38,256 | 3,316 | Accepted | Accepted | 87.79 | qqq = list(eval(input()))
List_R = []
if qqq[0] == "o":
List_R.append(1)
if qqq[1] == "o":
List_R.append(1)
if qqq[2] == "o":
List_R.append(1)
print((700+len(List_R*100))) | S = eval(input())
from collections import Counter
ans = Counter(S)
print((ans["o"]*100 + 700)) | 9 | 4 | 183 | 89 | qqq = list(eval(input()))
List_R = []
if qqq[0] == "o":
List_R.append(1)
if qqq[1] == "o":
List_R.append(1)
if qqq[2] == "o":
List_R.append(1)
print((700 + len(List_R * 100)))
| S = eval(input())
from collections import Counter
ans = Counter(S)
print((ans["o"] * 100 + 700))
| false | 55.555556 | [
"-qqq = list(eval(input()))",
"-List_R = []",
"-if qqq[0] == \"o\":",
"- List_R.append(1)",
"-if qqq[1] == \"o\":",
"- List_R.append(1)",
"-if qqq[2] == \"o\":",
"- List_R.append(1)",
"-print((700 + len(List_R * 100)))",
"+S = eval(input())",
"+from collections import Counter",
"+",
... | false | 0.059617 | 0.050564 | 1.179053 | [
"s233207909",
"s167921317"
] |
u894258749 | p02889 | python | s703964133 | s783419881 | 1,940 | 1,009 | 88,156 | 26,828 | Accepted | Accepted | 47.99 | import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
def warshall_floyd(N, edges,
nopath=None,
start_distance=0,
plus_func=lambda D,d: D+d):
'''
edges: list of set
edges = [{(y0, distance0... | import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
N, M, L = inpl()
graph = [[0]*N for _ in range(N)]
for i in range(M):
A, B, C = inpl()
if C <=... | 59 | 35 | 1,662 | 866 | import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int, input().split()))
def warshall_floyd(
N, edges, nopath=None, start_distance=0, plus_func=lambda D, d: D + d
):
"""
edges: list of set
edges = [{(y0, distance0), (y1, distance1), ...}, ...]
"""
ret = [[no... | import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int, input().split()))
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
N, M, L = inpl()
graph = [[0] * N for _ in range(N)]
for i in range(M):
A, B, C = inpl()
if C <= L:
... | false | 40.677966 | [
"-",
"-",
"-def warshall_floyd(",
"- N, edges, nopath=None, start_distance=0, plus_func=lambda D, d: D + d",
"-):",
"- \"\"\"",
"- edges: list of set",
"- edges = [{(y0, distance0), (y1, distance1), ...}, ...]",
"- \"\"\"",
"- ret = [[nopath] * N for _ in range(N)]",
"- ... | false | 0.091328 | 0.350817 | 0.260329 | [
"s703964133",
"s783419881"
] |
u202634017 | p02720 | python | s224379251 | s428588390 | 679 | 401 | 83,136 | 21,412 | Accepted | Accepted | 40.94 | k = int(eval(input()))
l = set()
def construct(lunnum: str, depth: int, flag: bool):
global l
if depth == 0:
l.add(int(lunnum))
return
m = int(lunnum[-1])
for i in list(range(0, 10)) if flag else set([max(0, m - 1), m, min(9, m + 1)]):
construct(lunnum + str(i), dept... | k = int(eval(input()))
l = set()
# lunnum : 構築中のルンルン数
# depth : 桁数
# flag : 上位桁が全て0かどうかのフラグ
def construct(lunnum: str, depth: int, flag: bool):
global l
if depth == 0:
l.add(int(lunnum))
return
# m = 末尾桁の値
m = int(lunnum[-1])
if flag:
# 上位桁に0以外の数字が無いなら
... | 17 | 27 | 398 | 737 | k = int(eval(input()))
l = set()
def construct(lunnum: str, depth: int, flag: bool):
global l
if depth == 0:
l.add(int(lunnum))
return
m = int(lunnum[-1])
for i in list(range(0, 10)) if flag else set([max(0, m - 1), m, min(9, m + 1)]):
construct(lunnum + str(i), depth - 1, (i =... | k = int(eval(input()))
l = set()
# lunnum : 構築中のルンルン数
# depth : 桁数
# flag : 上位桁が全て0かどうかのフラグ
def construct(lunnum: str, depth: int, flag: bool):
global l
if depth == 0:
l.add(int(lunnum))
return
# m = 末尾桁の値
m = int(lunnum[-1])
if flag:
# 上位桁に0以外の数字が無いなら
for i in ran... | false | 37.037037 | [
"-",
"-",
"+# lunnum : 構築中のルンルン数",
"+# depth : 桁数",
"+# flag : 上位桁が全て0かどうかのフラグ",
"+ # m = 末尾桁の値",
"- for i in list(range(0, 10)) if flag else set([max(0, m - 1), m, min(9, m + 1)]):",
"- construct(lunnum + str(i), depth - 1, (i == 0) & flag)",
"+ if flag:",
"+ # 上位桁に0以外の数... | false | 0.780727 | 0.399758 | 1.953 | [
"s224379251",
"s428588390"
] |
u077291787 | p02913 | python | s153367639 | s450662131 | 81 | 69 | 11,192 | 10,004 | Accepted | Accepted | 14.81 | from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(sour... | # ABC141E - Who Says a Pun?
def resolve():
N = int(eval(input()))
S = input().rstrip()
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(hash(S[i : i + mid]))
... | 56 | 22 | 1,743 | 622 | from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(source)
def ... | # ABC141E - Who Says a Pun?
def resolve():
N = int(eval(input()))
S = input().rstrip()
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(hash(S[i : i + mid]))
if hash(S... | false | 60.714286 | [
"-from typing import List, Tuple",
"-",
"-",
"-class RollingHash:",
"- \"\"\"Rolling Hash\"\"\"",
"-",
"- __slots__ = [\"_base\", \"_mod\", \"_hash\", \"_power\"]",
"-",
"- def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7):",
"- self._base = base",
"- ... | false | 0.063968 | 0.06831 | 0.936444 | [
"s153367639",
"s450662131"
] |
u418149936 | p02641 | python | s312706595 | s972580157 | 32 | 26 | 9,212 | 9,108 | Accepted | Accepted | 18.75 | X, N = list(map(int, input().split(' ')))
if N == 0:
print(X)
else:
ls = list(map(int, input().split(' ')))
diff = -1
for i in range(101, -1, -1):
if i not in ls:
if diff == -1:
diff = abs(i - X)
result = i
else:
... | X, N = list(map(int, input().split(' ')))
if N == 0:
print(X)
else:
ls = list(map(int, input().split(' ')))
diff, rst = -1, 0
for i in range(101, -1, -1):
if i not in ls:
if diff == -1:
diff = abs(X - i)
rst = i
else:
... | 16 | 16 | 434 | 433 | X, N = list(map(int, input().split(" ")))
if N == 0:
print(X)
else:
ls = list(map(int, input().split(" ")))
diff = -1
for i in range(101, -1, -1):
if i not in ls:
if diff == -1:
diff = abs(i - X)
result = i
else:
diff = min(... | X, N = list(map(int, input().split(" ")))
if N == 0:
print(X)
else:
ls = list(map(int, input().split(" ")))
diff, rst = -1, 0
for i in range(101, -1, -1):
if i not in ls:
if diff == -1:
diff = abs(X - i)
rst = i
else:
diff =... | false | 0 | [
"- diff = -1",
"+ diff, rst = -1, 0",
"- diff = abs(i - X)",
"- result = i",
"+ diff = abs(X - i)",
"+ rst = i",
"- diff = min(diff, abs(i - X))",
"- if diff == abs(i - X):",
"- result ... | false | 0.039052 | 0.006834 | 5.714781 | [
"s312706595",
"s972580157"
] |
u905582793 | p02965 | python | s086311311 | s515654890 | 838 | 572 | 115,556 | 149,968 | Accepted | Accepted | 31.74 | n,m=list(map(int,input().split()))
o,f,i=998244353,[1],1
while i<3*m+n:f+=[f[-1]*i%o];i+=1
c=lambda x,y=n-1:f[x]*pow(f[x-y]*f[y]%o,o-2,o)
a=c(-1)-n*c(n+m-2)
while~-n>m<i-n:m+=2;a-=c(n,m)*c(n-1+i-m>>1)
print((a%o)) | n,m=list(map(int,input().split()))
o,f,i=998244353,[1],1
while i<3*m+n:f+=[f[-1]*i%o];i+=1
c=lambda x,y=n-1:f[x]*pow(f[x-y]*f[y],o-2,o)
a=c(-1)-n*c(n+m-2)
while~-n>m<i-n:m+=2;a-=c(n,m)*c(n-1+i-m>>1)
print((a%o)) | 7 | 7 | 211 | 209 | n, m = list(map(int, input().split()))
o, f, i = 998244353, [1], 1
while i < 3 * m + n:
f += [f[-1] * i % o]
i += 1
c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y] % o, o - 2, o)
a = c(-1) - n * c(n + m - 2)
while ~-n > m < i - n:
m += 2
a -= c(n, m) * c(n - 1 + i - m >> 1)
print((a % o))
| n, m = list(map(int, input().split()))
o, f, i = 998244353, [1], 1
while i < 3 * m + n:
f += [f[-1] * i % o]
i += 1
c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y], o - 2, o)
a = c(-1) - n * c(n + m - 2)
while ~-n > m < i - n:
m += 2
a -= c(n, m) * c(n - 1 + i - m >> 1)
print((a % o))
| false | 0 | [
"-c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y] % o, o - 2, o)",
"+c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y], o - 2, o)"
] | false | 0.23651 | 0.266974 | 0.885894 | [
"s086311311",
"s515654890"
] |
u255317651 | p02271 | python | s314078420 | s521474628 | 12,450 | 740 | 43,060 | 47,160 | Accepted | Accepted | 94.06 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
sum_array = []
for r in range(1,n+1):
for comb in itr.combinati... | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a_r1
@author: maezawa
"""
import itertools as itr
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
sum_array = []
for r in range(1,n+1):
for comb in itr.comb... | 27 | 36 | 528 | 759 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
sum_array = []
for r in range(1, n + 1):
for comb in itr.combinations(a, r):
... | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a_r1
@author: maezawa
"""
import itertools as itr
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
m = list(map(int, input().split()))
sum_array = []
for r in range(1, n + 1):
for comb in itr.combinations(a, r... | false | 25 | [
"-ALDS1_5a",
"+ALDS1_5a_r1",
"+sum_array.sort()",
"+ left = 0",
"+ right = len(sum_array)",
"- for j in sum_array:",
"- # print(i, j)",
"- if i == j:",
"+ while left < right:",
"+ # print(left, right)",
"+ mid = (left + right) // 2",
"+ if sum_arr... | false | 0.042633 | 0.035535 | 1.199761 | [
"s314078420",
"s521474628"
] |
u863442865 | p03273 | python | s474526369 | s790443049 | 24 | 20 | 3,564 | 3,188 | Accepted | Accepted | 16.67 | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
fr... | ### ABC107 B - Grid Compression
h, w = list(map(int, input().split()))
grid = [[x for x in str(eval(input()))] for _ in range(h)]
del_h = [False] * h
del_w = [False] * w
for i in range(h):
if grid[i].count('#') == 0:
del_h[i] = True
for j in range(w):
del_w[j] = True
for i in range(h):
if... | 43 | 22 | 1,160 | 491 | def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from h... | ### ABC107 B - Grid Compression
h, w = list(map(int, input().split()))
grid = [[x for x in str(eval(input()))] for _ in range(h)]
del_h = [False] * h
del_w = [False] * w
for i in range(h):
if grid[i].count("#") == 0:
del_h[i] = True
for j in range(w):
del_w[j] = True
for i in range(h):
if gr... | false | 48.837209 | [
"-def main():",
"- import sys",
"-",
"- input = sys.stdin.readline",
"- sys.setrecursionlimit(10**7)",
"- from collections import Counter, deque",
"-",
"- # from collections import defaultdict",
"- from itertools import combinations, permutations, accumulate, groupby, product",
"... | false | 0.064368 | 0.226389 | 0.284326 | [
"s474526369",
"s790443049"
] |
u511824539 | p02803 | python | s330692029 | s339925529 | 1,385 | 361 | 3,948 | 3,316 | Accepted | Accepted | 73.94 | import queue
def shortestpath(y0, x0):
step_cnt = [[-1] * w for _ in range(h)]
step_cnt[y0][x0] = 0
q.put((y0, x0))
while not q.empty():
y, x = q.get()
for i in range(4):
y_next = y + dy[i]
x_next = x + dx[i]
if 0 <= y_next < h and 0 <= x_n... | from collections import deque
def shortestpath(y0, x0):
step_cnt = [[-1] * w for _ in range(h)]
step_cnt[y0][x0] = 0
q.append((y0, x0))
while q:
y, x = q.popleft()
for i in range(4):
y_next = y + dy[i]
x_next = x + dx[i]
if 0 <= y_next < h ... | 32 | 32 | 905 | 914 | import queue
def shortestpath(y0, x0):
step_cnt = [[-1] * w for _ in range(h)]
step_cnt[y0][x0] = 0
q.put((y0, x0))
while not q.empty():
y, x = q.get()
for i in range(4):
y_next = y + dy[i]
x_next = x + dx[i]
if (
0 <= y_next < h
... | from collections import deque
def shortestpath(y0, x0):
step_cnt = [[-1] * w for _ in range(h)]
step_cnt[y0][x0] = 0
q.append((y0, x0))
while q:
y, x = q.popleft()
for i in range(4):
y_next = y + dy[i]
x_next = x + dx[i]
if (
0 <= y_n... | false | 0 | [
"-import queue",
"+from collections import deque",
"- q.put((y0, x0))",
"- while not q.empty():",
"- y, x = q.get()",
"+ q.append((y0, x0))",
"+ while q:",
"+ y, x = q.popleft()",
"- q.put((y_next, x_next))",
"+ q.append((y_next, x_next))",
... | false | 0.045626 | 0.045701 | 0.998355 | [
"s330692029",
"s339925529"
] |
u212328220 | p03945 | python | s723608538 | s391387119 | 60 | 54 | 3,188 | 3,188 | Accepted | Accepted | 10 | s= eval(input())
now = s[0]
ans = 0
flg = 0
for i in range(1,len(s)):
if flg == 0:
if now == s[i]:
pass
elif now != s[i]:
ans += 1
flg = 1
now = s[i]
else:
if now == s[i]:
pass
elif now != s[i]:
... | s= eval(input())
now = s[0]
ans = 0
for i in range(1,len(s)):
if now == s[i]:
pass
elif now != s[i]:
ans += 1
flg = 1
now = s[i]
print(ans) | 23 | 13 | 400 | 187 | s = eval(input())
now = s[0]
ans = 0
flg = 0
for i in range(1, len(s)):
if flg == 0:
if now == s[i]:
pass
elif now != s[i]:
ans += 1
flg = 1
now = s[i]
else:
if now == s[i]:
pass
elif now != s[i]:
ans += 1
... | s = eval(input())
now = s[0]
ans = 0
for i in range(1, len(s)):
if now == s[i]:
pass
elif now != s[i]:
ans += 1
flg = 1
now = s[i]
print(ans)
| false | 43.478261 | [
"-flg = 0",
"- if flg == 0:",
"- if now == s[i]:",
"- pass",
"- elif now != s[i]:",
"- ans += 1",
"- flg = 1",
"- now = s[i]",
"- else:",
"- if now == s[i]:",
"- pass",
"- elif now != s[i]:",
"- ... | false | 0.054737 | 0.034761 | 1.574669 | [
"s723608538",
"s391387119"
] |
u641722141 | p02688 | python | s088380072 | s952326022 | 22 | 20 | 9,140 | 9,176 | Accepted | Accepted | 9.09 | n, k =list(map(int, input().split()))
l = [0] * n
for i in range(k):
d = int(eval(input()))
lst = list(map(int,input().split()))
for i in range(d):
l[lst[i] - 1] += 1
print((l.count(0))) | n, k = list(map(int, input().split()))
l = [0] * n
for i in range(k):
d = int(eval(input()))
a = list(map(int, input().split()))
for j in range(len(a)):
l[a[j] - 1] = 1
print((l.count(0)))
| 8 | 8 | 189 | 202 | n, k = list(map(int, input().split()))
l = [0] * n
for i in range(k):
d = int(eval(input()))
lst = list(map(int, input().split()))
for i in range(d):
l[lst[i] - 1] += 1
print((l.count(0)))
| n, k = list(map(int, input().split()))
l = [0] * n
for i in range(k):
d = int(eval(input()))
a = list(map(int, input().split()))
for j in range(len(a)):
l[a[j] - 1] = 1
print((l.count(0)))
| false | 0 | [
"- lst = list(map(int, input().split()))",
"- for i in range(d):",
"- l[lst[i] - 1] += 1",
"+ a = list(map(int, input().split()))",
"+ for j in range(len(a)):",
"+ l[a[j] - 1] = 1"
] | false | 0.070501 | 0.071585 | 0.984866 | [
"s088380072",
"s952326022"
] |
u859897687 | p02982 | python | s576904339 | s939153960 | 165 | 18 | 38,384 | 3,188 | Accepted | Accepted | 89.09 | n,d=list(map(int,input().split()))
x=[]
for _ in range(n):
x+=[list(map(int,input().split()))]
ans=0
for i in range(n-1):
for j in range(i+1,n):
dist=0
for k in range(d):
dist+=(x[i][k]-x[j][k])**2
dist=dist**0.5
if dist.is_integer():
ans+=1
print(ans) | n,d=list(map(int,input().split()))
x=[]
for _ in range(n):
x+=[list(map(int,input().split()))]
ans=0
for i in range(n):
for j in range(i+1,n):
l=0
for k in range(d):
l+=(x[i][k]-x[j][k])**2
l=l**0.5
if l.is_integer():
ans+=1
print(ans) | 14 | 14 | 291 | 274 | n, d = list(map(int, input().split()))
x = []
for _ in range(n):
x += [list(map(int, input().split()))]
ans = 0
for i in range(n - 1):
for j in range(i + 1, n):
dist = 0
for k in range(d):
dist += (x[i][k] - x[j][k]) ** 2
dist = dist**0.5
if dist.is_integer():
... | n, d = list(map(int, input().split()))
x = []
for _ in range(n):
x += [list(map(int, input().split()))]
ans = 0
for i in range(n):
for j in range(i + 1, n):
l = 0
for k in range(d):
l += (x[i][k] - x[j][k]) ** 2
l = l**0.5
if l.is_integer():
ans += 1
print... | false | 0 | [
"-for i in range(n - 1):",
"+for i in range(n):",
"- dist = 0",
"+ l = 0",
"- dist += (x[i][k] - x[j][k]) ** 2",
"- dist = dist**0.5",
"- if dist.is_integer():",
"+ l += (x[i][k] - x[j][k]) ** 2",
"+ l = l**0.5",
"+ if l.is_integer():... | false | 0.040824 | 0.034678 | 1.177234 | [
"s576904339",
"s939153960"
] |
u535171899 | p02713 | python | s645196401 | s802180967 | 1,304 | 1,028 | 9,180 | 9,484 | Accepted | Accepted | 21.17 | import math
k = int(eval(input()))
ans = 0
for a in range(1,k+1):
for b in range(1,k+1):
g = math.gcd(a,b)
for c in range(1,k+1):
ans += math.gcd(g,c)
print(ans) | import math
k = int(eval(input()))
map_list = [[0 for i in range(k+1)]for j in range(k+1)]
for i in range(1,k+1):
for j in range(1,k+1):
map_list[i][j]=math.gcd(i,j)
ans=0
for i in range(1,k+1):
for j in range(1,k+1):
gcd1 = map_list[i][j]
for k in range(1,k+1):
... | 10 | 15 | 202 | 350 | import math
k = int(eval(input()))
ans = 0
for a in range(1, k + 1):
for b in range(1, k + 1):
g = math.gcd(a, b)
for c in range(1, k + 1):
ans += math.gcd(g, c)
print(ans)
| import math
k = int(eval(input()))
map_list = [[0 for i in range(k + 1)] for j in range(k + 1)]
for i in range(1, k + 1):
for j in range(1, k + 1):
map_list[i][j] = math.gcd(i, j)
ans = 0
for i in range(1, k + 1):
for j in range(1, k + 1):
gcd1 = map_list[i][j]
for k in range(1, k + 1):... | false | 33.333333 | [
"+map_list = [[0 for i in range(k + 1)] for j in range(k + 1)]",
"+for i in range(1, k + 1):",
"+ for j in range(1, k + 1):",
"+ map_list[i][j] = math.gcd(i, j)",
"-for a in range(1, k + 1):",
"- for b in range(1, k + 1):",
"- g = math.gcd(a, b)",
"- for c in range(1, k + 1)... | false | 0.044331 | 0.042272 | 1.048692 | [
"s645196401",
"s802180967"
] |
u777283665 | p02842 | python | s483101028 | s667331308 | 44 | 34 | 2,940 | 2,940 | Accepted | Accepted | 22.73 | import math
n = int(eval(input()))
for i in range(1, 50001):
if i * 1.08 == n or math.floor(i*1.08) == n:
print(i)
exit()
print(":(") | import math
n = int(eval(input()))
for price in range(1, 50001):
if math.floor(price*1.08) == n:
print(price)
exit()
print(":(") | 10 | 9 | 159 | 152 | import math
n = int(eval(input()))
for i in range(1, 50001):
if i * 1.08 == n or math.floor(i * 1.08) == n:
print(i)
exit()
print(":(")
| import math
n = int(eval(input()))
for price in range(1, 50001):
if math.floor(price * 1.08) == n:
print(price)
exit()
print(":(")
| false | 10 | [
"-for i in range(1, 50001):",
"- if i * 1.08 == n or math.floor(i * 1.08) == n:",
"- print(i)",
"+for price in range(1, 50001):",
"+ if math.floor(price * 1.08) == n:",
"+ print(price)"
] | false | 0.038985 | 0.05957 | 0.654431 | [
"s483101028",
"s667331308"
] |
u912237403 | p00078 | python | s979732025 | s584612434 | 20 | 10 | 4,244 | 4,260 | Accepted | Accepted | 50 | def magic(n):
c=1
x=n/2
y=x+1
while 1:
A[y][x]=c
if c==n*n:break
while 1:
x,y=(x+1)%n,(y+1)%n
if A[y][x]==0:break
x,y=(x-1)%n,(y+1)%n
if A[y][x]==0:break
c+=1
return
while 1:
n=eval(input())
if n=... | def f(x,y):
while 1:
x,y=(x+1)%n,(y+1)%n
if A[y][x]==0:break
x,y=(x-1)%n,(y+1)%n
if A[y][x]==0:break
return x,y
def magic(n):
c=1
x=n/2
y=x+1
while 1:
A[y][x]=c
if c==n*n:break
x,y=f(x,y)
c+=1
return
while 1... | 22 | 27 | 444 | 477 | def magic(n):
c = 1
x = n / 2
y = x + 1
while 1:
A[y][x] = c
if c == n * n:
break
while 1:
x, y = (x + 1) % n, (y + 1) % n
if A[y][x] == 0:
break
x, y = (x - 1) % n, (y + 1) % n
if A[y][x] == 0:
... | def f(x, y):
while 1:
x, y = (x + 1) % n, (y + 1) % n
if A[y][x] == 0:
break
x, y = (x - 1) % n, (y + 1) % n
if A[y][x] == 0:
break
return x, y
def magic(n):
c = 1
x = n / 2
y = x + 1
while 1:
A[y][x] = c
if c == n * n:
... | false | 18.518519 | [
"+def f(x, y):",
"+ while 1:",
"+ x, y = (x + 1) % n, (y + 1) % n",
"+ if A[y][x] == 0:",
"+ break",
"+ x, y = (x - 1) % n, (y + 1) % n",
"+ if A[y][x] == 0:",
"+ break",
"+ return x, y",
"+",
"+",
"- while 1:",
"- x, ... | false | 0.087406 | 0.187846 | 0.465307 | [
"s979732025",
"s584612434"
] |
u376099073 | p03030 | python | s841958624 | s214411685 | 22 | 17 | 3,064 | 3,060 | Accepted | Accepted | 22.73 | N = int(eval(input()))
MAIN = []
for i in range(N):
S,P = list(map(str,input().split()))
MAIN.append([i+1,S,int(P)])
def swap(i,j):
x = MAIN[i]
MAIN[i] = MAIN[j]
MAIN[j] = x
update = True
while update == True:
update = False
for i in range(1,N):
if MAIN[i][1] > MAIN[... | N = int(eval(input()))
MAIN = []
for i in range(N):
S,P = list(map(str,input().split()))
MAIN.append([S,-int(P)])
ans = sorted(MAIN)
for m in ans:
print((MAIN.index(m) + 1)) | 28 | 9 | 587 | 180 | N = int(eval(input()))
MAIN = []
for i in range(N):
S, P = list(map(str, input().split()))
MAIN.append([i + 1, S, int(P)])
def swap(i, j):
x = MAIN[i]
MAIN[i] = MAIN[j]
MAIN[j] = x
update = True
while update == True:
update = False
for i in range(1, N):
if MAIN[i][1] > MAIN[i - 1... | N = int(eval(input()))
MAIN = []
for i in range(N):
S, P = list(map(str, input().split()))
MAIN.append([S, -int(P)])
ans = sorted(MAIN)
for m in ans:
print((MAIN.index(m) + 1))
| false | 67.857143 | [
"- MAIN.append([i + 1, S, int(P)])",
"-",
"-",
"-def swap(i, j):",
"- x = MAIN[i]",
"- MAIN[i] = MAIN[j]",
"- MAIN[j] = x",
"-",
"-",
"-update = True",
"-while update == True:",
"- update = False",
"- for i in range(1, N):",
"- if MAIN[i][1] > MAIN[i - 1][1]:",
"... | false | 0.035171 | 0.035586 | 0.988331 | [
"s841958624",
"s214411685"
] |
u359358631 | p03545 | python | s868098372 | s890043407 | 34 | 31 | 9,072 | 8,924 | Accepted | Accepted | 8.82 | def main():
s = eval(input())
op = ["-", "+"]
for i in range(2 ** 3):
lst = [0] * 3
for j in range(3):
if (i >> j) & 1 == 1:
lst[2 - j] = 1
res = int(s[0])
for j in range(3):
if lst[j] == 0:
res -= int(s[j... | def main():
S = eval(input())
for i in range(2 ** 3):
c = S[0]
for j in range(3):
if (i >> j) & 1:
c += "+"
else:
c += "-"
c += S[j + 1]
if eval(c) == 7:
print((c + "=7"))
exit()
... | 23 | 18 | 559 | 353 | def main():
s = eval(input())
op = ["-", "+"]
for i in range(2**3):
lst = [0] * 3
for j in range(3):
if (i >> j) & 1 == 1:
lst[2 - j] = 1
res = int(s[0])
for j in range(3):
if lst[j] == 0:
res -= int(s[j + 1])
... | def main():
S = eval(input())
for i in range(2**3):
c = S[0]
for j in range(3):
if (i >> j) & 1:
c += "+"
else:
c += "-"
c += S[j + 1]
if eval(c) == 7:
print((c + "=7"))
exit()
if __name__ == "_... | false | 21.73913 | [
"- s = eval(input())",
"- op = [\"-\", \"+\"]",
"+ S = eval(input())",
"- lst = [0] * 3",
"+ c = S[0]",
"- if (i >> j) & 1 == 1:",
"- lst[2 - j] = 1",
"- res = int(s[0])",
"- for j in range(3):",
"- if lst[j] == 0:",
"- ... | false | 0.08325 | 0.151387 | 0.549912 | [
"s868098372",
"s890043407"
] |
u391731808 | p03128 | python | s770025378 | s495858597 | 37 | 21 | 3,440 | 3,188 | Accepted | Accepted | 43.24 | N,M = list(map(int,(input().split())))
A = list(map(int,input().split()))
cost = sorted(list(zip([[2,5,5,4,5,6,3,7,6][a-1] for a in A],A)),key = lambda x: (x[0],-x[1]))
#同じ画数の数字を除く
tmp = len(cost)
i = 1
while i < tmp:
if cost[i][0] == cost[i-1][0]:
cost.pop(i)
tmp = len(cost)
else:... | N,M = list(map(int,input().split()))
*A, = list(map(int,input().split()))
B = sorted((([2,5,5,4,5,6,3,7,6][a-1],a) for a in A),key = lambda x:(x[0],-x[1]))
i = 1
while i<len(B):
if B[i][0]==B[i-1][0]:
B.pop(i)
else:
i+=1
i = [0]*(len(B)-1)
if len(B)==1:
print((str(B[0][1])*(N//B[0... | 31 | 27 | 645 | 742 | N, M = list(map(int, (input().split())))
A = list(map(int, input().split()))
cost = sorted(
list(zip([[2, 5, 5, 4, 5, 6, 3, 7, 6][a - 1] for a in A], A)),
key=lambda x: (x[0], -x[1]),
)
# 同じ画数の数字を除く
tmp = len(cost)
i = 1
while i < tmp:
if cost[i][0] == cost[i - 1][0]:
cost.pop(i)
tmp = len(c... | N, M = list(map(int, input().split()))
(*A,) = list(map(int, input().split()))
B = sorted(
(([2, 5, 5, 4, 5, 6, 3, 7, 6][a - 1], a) for a in A), key=lambda x: (x[0], -x[1])
)
i = 1
while i < len(B):
if B[i][0] == B[i - 1][0]:
B.pop(i)
else:
i += 1
i = [0] * (len(B) - 1)
if len(B) == 1:
p... | false | 12.903226 | [
"-N, M = list(map(int, (input().split())))",
"-A = list(map(int, input().split()))",
"-cost = sorted(",
"- list(zip([[2, 5, 5, 4, 5, 6, 3, 7, 6][a - 1] for a in A], A)),",
"- key=lambda x: (x[0], -x[1]),",
"+N, M = list(map(int, input().split()))",
"+(*A,) = list(map(int, input().split()))",
"+B... | false | 0.041585 | 0.037472 | 1.109771 | [
"s770025378",
"s495858597"
] |
u814986259 | p03372 | python | s187785645 | s077894027 | 707 | 653 | 29,704 | 37,120 | Accepted | Accepted | 7.64 | N,C=list(map(int,input().split()))
xc=[tuple(map(int,input().split())) for i in range(N)]
xc.sort()
ans=0
p=0
#右を取る範囲と左を取る範囲を決めればいい
s=[0]*(N+1)#時計回り
ss=[0]*(N+1)#反時計回り
for i in range(N):
s[i+1]=s[i]+xc[i][1]
for i in range(N):
ss[i+1]=ss[i]+xc[N-1-i][1]
maxs=[0]*(N+1)
maxss=[0]*(N+1)
for i in range(... | N, C = list(map(int, input().split()))
xv = [tuple(map(int, input().split())) for i in range(N)]
xv2 = [(C - x, v)for x, v in xv[::-1]]
L = [0]*N
ans = 0
for i, X in enumerate(xv):
x, v = X
L[i] = L[i-1] + v
R = [0]*N
for i in range(N):
L[i] -= xv[i][0]
for i, X in enumerate(xv2):
x, v... | 28 | 33 | 686 | 701 | N, C = list(map(int, input().split()))
xc = [tuple(map(int, input().split())) for i in range(N)]
xc.sort()
ans = 0
p = 0
# 右を取る範囲と左を取る範囲を決めればいい
s = [0] * (N + 1) # 時計回り
ss = [0] * (N + 1) # 反時計回り
for i in range(N):
s[i + 1] = s[i] + xc[i][1]
for i in range(N):
ss[i + 1] = ss[i] + xc[N - 1 - i][1]
maxs = [0] *... | N, C = list(map(int, input().split()))
xv = [tuple(map(int, input().split())) for i in range(N)]
xv2 = [(C - x, v) for x, v in xv[::-1]]
L = [0] * N
ans = 0
for i, X in enumerate(xv):
x, v = X
L[i] = L[i - 1] + v
R = [0] * N
for i in range(N):
L[i] -= xv[i][0]
for i, X in enumerate(xv2):
x, v = X
R[... | false | 15.151515 | [
"-xc = [tuple(map(int, input().split())) for i in range(N)]",
"-xc.sort()",
"+xv = [tuple(map(int, input().split())) for i in range(N)]",
"+xv2 = [(C - x, v) for x, v in xv[::-1]]",
"+L = [0] * N",
"-p = 0",
"-# 右を取る範囲と左を取る範囲を決めればいい",
"-s = [0] * (N + 1) # 時計回り",
"-ss = [0] * (N + 1) # 反時計回り",
"... | false | 0.089781 | 0.048238 | 1.861201 | [
"s187785645",
"s077894027"
] |
u047796752 | p02913 | python | s775624828 | s032054189 | 1,782 | 303 | 141,192 | 43,356 | Accepted | Accepted | 83 | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
q = deque([])
for i in range(x):
q.append(S[i])
d[''.join(q)] = 0
for i in range(x, N):
q.append(S[i])
q.popleft()
k = ''.join(q)
... | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
for i in range(N-x+1):
k = hash(S[i:i+x])
if k in d:
if i>=d[k]+x:
return True
else:
d[k] = i
return False
... | 42 | 34 | 728 | 574 | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
q = deque([])
for i in range(x):
q.append(S[i])
d["".join(q)] = 0
for i in range(x, N):
q.append(S[i])
q.popleft()
k = "".join(q)
if k in d:
if i ... | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
for i in range(N - x + 1):
k = hash(S[i : i + x])
if k in d:
if i >= d[k] + x:
return True
else:
d[k] = i
return False
def binary_search():
... | false | 19.047619 | [
"- q = deque([])",
"- for i in range(x):",
"- q.append(S[i])",
"- d[\"\".join(q)] = 0",
"- for i in range(x, N):",
"- q.append(S[i])",
"- q.popleft()",
"- k = \"\".join(q)",
"+ for i in range(N - x + 1):",
"+ k = hash(S[i : i + x])",
"- ... | false | 0.03813 | 0.066537 | 0.57306 | [
"s775624828",
"s032054189"
] |
u039355749 | p02627 | python | s857904632 | s589572915 | 73 | 27 | 61,556 | 8,984 | Accepted | Accepted | 63.01 | alpha = eval(input())
if alpha.isupper():
print('A')
else:
print('a') | a = eval(input())
print(('A' if a.isupper() else 'a')) | 6 | 2 | 73 | 47 | alpha = eval(input())
if alpha.isupper():
print("A")
else:
print("a")
| a = eval(input())
print(("A" if a.isupper() else "a"))
| false | 66.666667 | [
"-alpha = eval(input())",
"-if alpha.isupper():",
"- print(\"A\")",
"-else:",
"- print(\"a\")",
"+a = eval(input())",
"+print((\"A\" if a.isupper() else \"a\"))"
] | false | 0.04012 | 0.035896 | 1.117667 | [
"s857904632",
"s589572915"
] |
u867826040 | p02779 | python | s190125429 | s529903464 | 82 | 61 | 26,808 | 30,408 | Accepted | Accepted | 25.61 | n = eval(input())
a = list(map(int,input().split()))
if len(a)== len(set(a)):
print("YES")
else:
print("NO") | n = eval(input())
a = input().split()
if len(a)== len(set(a)):
print("YES")
else:
print("NO") | 6 | 6 | 111 | 96 | n = eval(input())
a = list(map(int, input().split()))
if len(a) == len(set(a)):
print("YES")
else:
print("NO")
| n = eval(input())
a = input().split()
if len(a) == len(set(a)):
print("YES")
else:
print("NO")
| false | 0 | [
"-a = list(map(int, input().split()))",
"+a = input().split()"
] | false | 0.038355 | 0.007307 | 5.249321 | [
"s190125429",
"s529903464"
] |
u225388820 | p02881 | python | s872616136 | s259414153 | 193 | 153 | 40,172 | 2,940 | Accepted | Accepted | 20.73 | n=int(eval(input()))
ans=n
for i in range(1,int(n**0.5)+1):
if n%i==0:
ans=n//i+i-2
print(ans)
| n=int(eval(input()))
ans=0
for i in range(1,int(n**0.5)+1):
if n%i==0:
ans=n//i+i-2
print(ans)
| 6 | 6 | 106 | 106 | n = int(eval(input()))
ans = n
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
ans = n // i + i - 2
print(ans)
| n = int(eval(input()))
ans = 0
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
ans = n // i + i - 2
print(ans)
| false | 0 | [
"-ans = n",
"+ans = 0"
] | false | 0.135611 | 0.047302 | 2.866927 | [
"s872616136",
"s259414153"
] |
u318127926 | p02796 | python | s288347405 | s969013860 | 1,931 | 457 | 18,620 | 18,260 | Accepted | Accepted | 76.33 | import sys
n = int(eval(input()))
xl = []
for _ in range(n):
x, l = list(map(int, input().split()))
xl.append((x, l))
xl.sort(key=lambda x:x[0])
i = 0
if n==1:
print((1))
sys.exit(0)
while i<len(xl)-1:
if xl[i][0]+xl[i][1] <= xl[i+1][0]-xl[i+1][1]:
i += 1
else:
if ... | import sys
n = int(eval(input()))
xl = []
for _ in range(n):
x, l = list(map(int, input().split()))
xl.append((x, l))
xl.sort(key=lambda x:x[0])
if n==1:
print((1))
sys.exit(0)
i=0
j=1
ans=n
while j<len(xl):
if xl[i][0]+xl[i][1] <= xl[j][0]-xl[j][1]:
i = j
j = i+1
... | 20 | 25 | 427 | 470 | import sys
n = int(eval(input()))
xl = []
for _ in range(n):
x, l = list(map(int, input().split()))
xl.append((x, l))
xl.sort(key=lambda x: x[0])
i = 0
if n == 1:
print((1))
sys.exit(0)
while i < len(xl) - 1:
if xl[i][0] + xl[i][1] <= xl[i + 1][0] - xl[i + 1][1]:
i += 1
else:
if... | import sys
n = int(eval(input()))
xl = []
for _ in range(n):
x, l = list(map(int, input().split()))
xl.append((x, l))
xl.sort(key=lambda x: x[0])
if n == 1:
print((1))
sys.exit(0)
i = 0
j = 1
ans = n
while j < len(xl):
if xl[i][0] + xl[i][1] <= xl[j][0] - xl[j][1]:
i = j
j = i + 1
... | false | 20 | [
"-i = 0",
"-while i < len(xl) - 1:",
"- if xl[i][0] + xl[i][1] <= xl[i + 1][0] - xl[i + 1][1]:",
"- i += 1",
"+i = 0",
"+j = 1",
"+ans = n",
"+while j < len(xl):",
"+ if xl[i][0] + xl[i][1] <= xl[j][0] - xl[j][1]:",
"+ i = j",
"+ j = i + 1",
"- if xl[i][0] + x... | false | 0.03645 | 0.127641 | 0.285564 | [
"s288347405",
"s969013860"
] |
u341087021 | p03108 | python | s664984519 | s061282229 | 635 | 566 | 29,536 | 28,848 | Accepted | Accepted | 10.87 | n,m = list(map(int, input().split()))
bridges = []
for i in range(m):
bridges.append([int(x) for x in input().split()])
'''
g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)
for x in reversed(bridges):
a,b = x
... | n,m = list(map(int, input().split()))
bridges = []
for i in range(m):
bridges.append([int(x) for x in input().split()])
def root(par, a):
while par[a] != -1:
a = par[a]
return a
def unite(par, npar, depth, ra, rb):
if depth[ra] >= depth[rb]:
npar[ra] = npar[ra] + npar[rb]... | 75 | 43 | 1,581 | 914 | n, m = list(map(int, input().split()))
bridges = []
for i in range(m):
bridges.append([int(x) for x in input().split()])
"""
g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)
for x in reversed(bridges):
a,b = x
if g[a] != g[b]:
... | n, m = list(map(int, input().split()))
bridges = []
for i in range(m):
bridges.append([int(x) for x in input().split()])
def root(par, a):
while par[a] != -1:
a = par[a]
return a
def unite(par, npar, depth, ra, rb):
if depth[ra] >= depth[rb]:
npar[ra] = npar[ra] + npar[rb]
pa... | false | 42.666667 | [
"-\"\"\"",
"-g = list(range(n+1))",
"-ng = [1 for _ in range(n+1)]",
"-gl = [[i] for i in range(n+1)]",
"-ans = []",
"-unconf = n*(n-1)//2",
"-ans.append(unconf)",
"-for x in reversed(bridges):",
"- a,b = x",
"- if g[a] != g[b]:",
"- tmp = ng[g[a]] * ng[g[b]]",
"- ng[g[a]] ... | false | 0.046713 | 0.047341 | 0.986724 | [
"s664984519",
"s061282229"
] |
u909643606 | p03409 | python | s416571365 | s314638234 | 183 | 108 | 3,572 | 3,572 | Accepted | Accepted | 40.98 | #https://abc010.contest.atcoder.jp/tasks/abc010_4
#http://kmjp.hatenablog.jp/entry/2014/06/08/0900
#よくわからない最大フロー用のdfs---------------------------------
num=201 #今回のnの最大値100*2+1
def dfs(cur):
global vis
global EE
vis[cur] = 1
if cur==num:
return 1
for i in range(num+1):
if vis[i]==0 and EE[c... | #https://abc010.contest.atcoder.jp/tasks/abc010_4
#http://kmjp.hatenablog.jp/entry/2014/06/08/0900
#よくわからない最大フロー用のdfs---------------------------------
num=201 #今回のnの最大値100*2+1
def dfs(cur):
global vis
global EE
vis[cur] = 1
if cur==num:
return 1
for i in range(num+1):
if vis[i]==0 and EE[c... | 81 | 81 | 1,957 | 1,858 | # https://abc010.contest.atcoder.jp/tasks/abc010_4
# http://kmjp.hatenablog.jp/entry/2014/06/08/0900
# よくわからない最大フロー用のdfs---------------------------------
num = 201 # 今回のnの最大値100*2+1
def dfs(cur):
global vis
global EE
vis[cur] = 1
if cur == num:
return 1
for i in range(num + 1):
if... | # https://abc010.contest.atcoder.jp/tasks/abc010_4
# http://kmjp.hatenablog.jp/entry/2014/06/08/0900
# よくわからない最大フロー用のdfs---------------------------------
num = 201 # 今回のnの最大値100*2+1
def dfs(cur):
global vis
global EE
vis[cur] = 1
if cur == num:
return 1
for i in range(num + 1):
if... | false | 0 | [
"-s.sort(key=lambda x: (x[0], x[1]))",
"-ss.sort(key=lambda x: (x[0], x[1]))",
"+# s.sort(key=lambda x:(x[0],x[1]))",
"+# ss.sort(key=lambda x:(x[0],x[1]))",
"-pair.sort(key=lambda x: len(x))",
"+# pair.sort(key=lambda x:len(x))"
] | false | 0.086778 | 0.085609 | 1.013651 | [
"s416571365",
"s314638234"
] |
u153665391 | p02258 | python | s124685544 | s566344467 | 580 | 530 | 5,612 | 13,592 | Accepted | Accepted | 8.62 | N = int(eval(input()))
purchase_price = int(eval(input()))
profit = -2000000000
for _ in range(N-1):
price = int(eval(input()))
profit = max(profit, (price-purchase_price))
purchase_price = min(price, purchase_price)
print(profit)
| N = int(eval(input()))
r1 = int(eval(input()))
r2 = int(eval(input()))
R = [int(eval(input())) for i in range(N-2)]
res = r2 - r1
min_r = min(r1, r2)
for r in R:
res = max(res, r - min_r)
min_r = min(min_r, r)
print(res)
| 10 | 14 | 236 | 218 | N = int(eval(input()))
purchase_price = int(eval(input()))
profit = -2000000000
for _ in range(N - 1):
price = int(eval(input()))
profit = max(profit, (price - purchase_price))
purchase_price = min(price, purchase_price)
print(profit)
| N = int(eval(input()))
r1 = int(eval(input()))
r2 = int(eval(input()))
R = [int(eval(input())) for i in range(N - 2)]
res = r2 - r1
min_r = min(r1, r2)
for r in R:
res = max(res, r - min_r)
min_r = min(min_r, r)
print(res)
| false | 28.571429 | [
"-purchase_price = int(eval(input()))",
"-profit = -2000000000",
"-for _ in range(N - 1):",
"- price = int(eval(input()))",
"- profit = max(profit, (price - purchase_price))",
"- purchase_price = min(price, purchase_price)",
"-print(profit)",
"+r1 = int(eval(input()))",
"+r2 = int(eval(inpu... | false | 0.038609 | 0.037432 | 1.031442 | [
"s124685544",
"s566344467"
] |
u843175622 | p03476 | python | s813903121 | s402142436 | 511 | 180 | 12,584 | 31,704 | Accepted | Accepted | 64.77 | q = int(eval(input()))
p = [True] * 100010
s = [0] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
if p[i]:
j = i * 2
while j <= 100005:
p[j] = False
j += i
i += 1
for i in range(100005):
if i & 1 and p[i] and p[(i + 1) // 2]:
... | from itertools import accumulate
q, *lr = list(map(int, open(0).read().split()))
p = [True] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
if p[i]:
j = i * 2
while j <= 100005:
p[j] = False
j += i
i += 1
s = [0] * 100010
for i in range(3, ... | 25 | 24 | 459 | 470 | q = int(eval(input()))
p = [True] * 100010
s = [0] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
if p[i]:
j = i * 2
while j <= 100005:
p[j] = False
j += i
i += 1
for i in range(100005):
if i & 1 and p[i] and p[(i + 1) // 2]:
s[i] += 1
for i in ra... | from itertools import accumulate
q, *lr = list(map(int, open(0).read().split()))
p = [True] * 100010
p[0] = False
p[1] = False
i = 2
while i <= 100005:
if p[i]:
j = i * 2
while j <= 100005:
p[j] = False
j += i
i += 1
s = [0] * 100010
for i in range(3, 100005, 2):
if ... | false | 4 | [
"-q = int(eval(input()))",
"+from itertools import accumulate",
"+",
"+q, *lr = list(map(int, open(0).read().split()))",
"-s = [0] * 100010",
"-for i in range(100005):",
"- if i & 1 and p[i] and p[(i + 1) // 2]:",
"+s = [0] * 100010",
"+for i in range(3, 100005, 2):",
"+ if p[i] and p[(i + 2... | false | 0.224262 | 0.44607 | 0.50275 | [
"s813903121",
"s402142436"
] |
u585963734 | p02574 | python | s356298202 | s241557239 | 424 | 383 | 204,096 | 199,184 | Accepted | Accepted | 9.67 | from functools import reduce
from math import gcd
N=int(eval(input()))
A=list(map(int, input().split()))
c=max(A)+1
C=[0]*c
f=1
for i in A:
C[i]+=1
for i in range(2,c):
cnt=0
for j in range(i,c,i):
cnt+=C[j]
if cnt>1:
f=0
if f==1:
print('pairwise coprime')
... | from functools import reduce
from math import gcd
N=int(eval(input()))
A=list(map(int, input().split()))
c=max(A)+1
D=[0]*c
div=[0]*c
P=[]
for i in range(2,c):
if D[i]==0:
P.append(i)
D[i]=i
for j in P:
if i*j>=c or j>D[i] :
break
D[i*j]=j
f=0
f... | 27 | 45 | 404 | 771 | from functools import reduce
from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
c = max(A) + 1
C = [0] * c
f = 1
for i in A:
C[i] += 1
for i in range(2, c):
cnt = 0
for j in range(i, c, i):
cnt += C[j]
if cnt > 1:
f = 0
if f == 1:
print("pairwise coprime... | from functools import reduce
from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
c = max(A) + 1
D = [0] * c
div = [0] * c
P = []
for i in range(2, c):
if D[i] == 0:
P.append(i)
D[i] = i
for j in P:
if i * j >= c or j > D[i]:
break
D[i * j]... | false | 40 | [
"-C = [0] * c",
"-f = 1",
"+D = [0] * c",
"+div = [0] * c",
"+P = []",
"+for i in range(2, c):",
"+ if D[i] == 0:",
"+ P.append(i)",
"+ D[i] = i",
"+ for j in P:",
"+ if i * j >= c or j > D[i]:",
"+ break",
"+ D[i * j] = j",
"+f = 0",
"- C[... | false | 0.038072 | 0.038371 | 0.992213 | [
"s356298202",
"s241557239"
] |
u546338822 | p03038 | python | s069802485 | s337844481 | 480 | 297 | 33,316 | 34,336 | Accepted | Accepted | 38.12 | def main():
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
h = {}
for i in range(m):
b,c = list(map(int,input().split()))
if c not in list(h.keys()):
h[c] = b
else:
h[c]+=b
for i in range(n):
if a[i] not in l... | def main():
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
dic = {}
for i in range(n):
if a[i] not in list(dic.keys()):
dic[a[i]] = 1
else:
dic[a[i]] += 1
for i in range(m):
b,c = list(map(int,input().split()))
... | 27 | 28 | 597 | 689 | def main():
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
h = {}
for i in range(m):
b, c = list(map(int, input().split()))
if c not in list(h.keys()):
h[c] = b
else:
h[c] += b
for i in range(n):
if a[i] not in list(... | def main():
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
dic = {}
for i in range(n):
if a[i] not in list(dic.keys()):
dic[a[i]] = 1
else:
dic[a[i]] += 1
for i in range(m):
b, c = list(map(int, input().split()))
if ... | false | 3.571429 | [
"- h = {}",
"+ dic = {}",
"+ for i in range(n):",
"+ if a[i] not in list(dic.keys()):",
"+ dic[a[i]] = 1",
"+ else:",
"+ dic[a[i]] += 1",
"- if c not in list(h.keys()):",
"- h[c] = b",
"+ if c not in list(dic.keys()):",
"+ ... | false | 0.034968 | 0.037247 | 0.938813 | [
"s069802485",
"s337844481"
] |
u989345508 | p02791 | python | s308517864 | s379724450 | 170 | 155 | 25,768 | 25,768 | Accepted | Accepted | 8.82 | n=int(eval(input()))
p=[int(i) for i in input().split()]
for i in range(n):
if i!=0:p[i]=min(p[i-1],p[i])
print((len(set(p))))
| n=int(eval(input()))
p=[int(i) for i in input().split()]
for i in range(1,n):p[i]=min(p[i-1],p[i])
print((len(set(p))))
| 5 | 4 | 127 | 115 | n = int(eval(input()))
p = [int(i) for i in input().split()]
for i in range(n):
if i != 0:
p[i] = min(p[i - 1], p[i])
print((len(set(p))))
| n = int(eval(input()))
p = [int(i) for i in input().split()]
for i in range(1, n):
p[i] = min(p[i - 1], p[i])
print((len(set(p))))
| false | 20 | [
"-for i in range(n):",
"- if i != 0:",
"- p[i] = min(p[i - 1], p[i])",
"+for i in range(1, n):",
"+ p[i] = min(p[i - 1], p[i])"
] | false | 0.067481 | 0.041974 | 1.607672 | [
"s308517864",
"s379724450"
] |
u164727245 | p02685 | python | s565268766 | s549338354 | 1,366 | 842 | 9,240 | 9,192 | Accepted | Accepted | 38.36 | # coding: utf-8
def bpow(x, y, z):
a = 1
for b in format(y, 'b'):
a = (a*a) % z
if b == '1':
a = (a*x) % z
return a
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
mod = 998244353
if m == 1 and n-1 == k:
return str... | # coding: utf-8
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
mod = 998244353
if m == 1 and n-1 == k:
return str(1)
ncr = 1
p = m*pow(m-1, n-1, mod) % mod
ret = p
inv = pow(m-1, mod-2, mod)
for i in range(1, k+1):
ncr = (ncr * ... | 33 | 24 | 666 | 512 | # coding: utf-8
def bpow(x, y, z):
a = 1
for b in format(y, "b"):
a = (a * a) % z
if b == "1":
a = (a * x) % z
return a
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
mod = 998244353
if m == 1 and n - 1 == k:
return str(1)
ncr = ... | # coding: utf-8
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
mod = 998244353
if m == 1 and n - 1 == k:
return str(1)
ncr = 1
p = m * pow(m - 1, n - 1, mod) % mod
ret = p
inv = pow(m - 1, mod - 2, mod)
for i in range(1, k + 1):
ncr = (ncr * (n - ... | false | 27.272727 | [
"-def bpow(x, y, z):",
"- a = 1",
"- for b in format(y, \"b\"):",
"- a = (a * a) % z",
"- if b == \"1\":",
"- a = (a * x) % z",
"- return a",
"-",
"-",
"- p = m * bpow(m - 1, n - 1, mod) % mod",
"+ p = m * pow(m - 1, n - 1, mod) % mod",
"- inv = bpow(... | false | 0.176861 | 0.079155 | 2.23437 | [
"s565268766",
"s549338354"
] |
u225388820 | p02558 | python | s068914305 | s340749852 | 282 | 255 | 74,440 | 74,820 | Accepted | Accepted | 9.57 | class UnionFind:
def __init__(self, N):
"""
N:要素数
root:各要素の親要素の番号を格納するリスト.
ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
rank:ランク
"""
self.N = N
self.root = [-1] * N
self.rank = [0] * N
def __repr__(self):
return '\n'... | class UnionFind:
def __init__(self, N):
"""
N:要素数
root:各要素の親要素の番号を格納するリスト.
ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
rank:ランク
"""
self.N = N
self.root = [-1] * N
self.rank = [0] * N
def __repr__(self):
return '\n'... | 81 | 81 | 2,078 | 2,103 | class UnionFind:
def __init__(self, N):
"""
N:要素数
root:各要素の親要素の番号を格納するリスト.
ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
rank:ランク
"""
self.N = N
self.root = [-1] * N
self.rank = [0] * N
def __repr__(self):
return "\n".join("{}: {}... | class UnionFind:
def __init__(self, N):
"""
N:要素数
root:各要素の親要素の番号を格納するリスト.
ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
rank:ランク
"""
self.N = N
self.root = [-1] * N
self.rank = [0] * N
def __repr__(self):
return "\n".join("{}: {}... | false | 0 | [
"- while self.root[x] >= 0:",
"- x = self.root[x]",
"- return x",
"+ else:",
"+ while self.root[x] >= 0:",
"+ x = self.root[x]",
"+ return x"
] | false | 0.046337 | 0.187992 | 0.246485 | [
"s068914305",
"s340749852"
] |
u606045429 | p03148 | python | s565455231 | s796942086 | 343 | 305 | 31,428 | 32,964 | Accepted | Accepted | 11.08 | from heapq import heappush, heappop, heapreplace
def main():
INF = 10 ** 9 + 7
N, K, *TD = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for t, d in zip(*[iter(TD)] * 2):
E[t - 1].append(d)
for e in E:
if e:
e.sort(reverse=True)
... | from heapq import heappush, heapreplace
def main():
INF = 10 ** 9 + 5
N, K, *TD = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for t, d in zip(*[iter(TD)] * 2):
E[t - 1].append(d)
for e in E:
if e:
e.sort(reverse=True)
else:
... | 44 | 44 | 924 | 889 | from heapq import heappush, heappop, heapreplace
def main():
INF = 10**9 + 7
N, K, *TD = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for t, d in zip(*[iter(TD)] * 2):
E[t - 1].append(d)
for e in E:
if e:
e.sort(reverse=True)
else:
... | from heapq import heappush, heapreplace
def main():
INF = 10**9 + 5
N, K, *TD = list(map(int, open(0).read().split()))
E = [[] for _ in range(N)]
for t, d in zip(*[iter(TD)] * 2):
E[t - 1].append(d)
for e in E:
if e:
e.sort(reverse=True)
else:
e.appe... | false | 0 | [
"-from heapq import heappush, heappop, heapreplace",
"+from heapq import heappush, heapreplace",
"- INF = 10**9 + 7",
"+ INF = 10**9 + 5",
"- for i in range(K):",
"- cur += E[i][0]",
"- for j in range(1, len(E[i])):",
"- heappush(Q, -E[i][j])",
"- for i in range(... | false | 0.142893 | 0.048879 | 2.923436 | [
"s565455231",
"s796942086"
] |
u086503932 | p02996 | python | s818768818 | s889980367 | 1,170 | 925 | 56,644 | 55,264 | Accepted | Accepted | 20.94 | from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
A[i] = list(map(int,input().split()))
s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(s, key=itemgetter(1))
time = 0
for i in range(N):
if t[i][0] + time <= t[i][1]:
time += t[i][0]
else:
prin... | from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
A[i] = list(map(int,input().split()))
#s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(A, key=itemgetter(1))
time = 0
for i in range(N):
if t[i][0] + time <= t[i][1]:
time += t[i][0]
else:
pri... | 17 | 17 | 347 | 348 | from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
A[i] = list(map(int, input().split()))
s = sorted(A, key=itemgetter(0), reverse=True)
t = sorted(s, key=itemgetter(1))
time = 0
for i in range(N):
if t[i][0] + time <= t[i][1]:
time += t[i][0]
else:
pri... | from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
A[i] = list(map(int, input().split()))
# s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(A, key=itemgetter(1))
time = 0
for i in range(N):
if t[i][0] + time <= t[i][1]:
time += t[i][0]
else:
pr... | false | 0 | [
"-s = sorted(A, key=itemgetter(0), reverse=True)",
"-t = sorted(s, key=itemgetter(1))",
"+# s = sorted(A, key=itemgetter(0),reverse=True)",
"+t = sorted(A, key=itemgetter(1))"
] | false | 0.065783 | 0.155971 | 0.421762 | [
"s818768818",
"s889980367"
] |
u761320129 | p03971 | python | s821983660 | s379340695 | 93 | 86 | 6,320 | 6,344 | Accepted | Accepted | 7.53 | N,A,B = map(int,input().split())
S = input()
ans = []
inout = out = 0
for c in S:
if c=='a':
if inout < A+B:
inout += 1
ans.append('Yes')
else:
ans.append('No')
elif c=='b':
if inout < A+B and out < B:
inout += 1
... | N,A,B = map(int,input().split())
S = input()
a = b = 0
ans = []
for c in S:
if c=='a':
if a+b < A+B:
a += 1
ans.append('Yes')
else:
ans.append('No')
elif c=='b':
if a+b < A+B and b < B:
b += 1
ans.append('Yes')
... | 22 | 21 | 465 | 423 | N, A, B = map(int, input().split())
S = input()
ans = []
inout = out = 0
for c in S:
if c == "a":
if inout < A + B:
inout += 1
ans.append("Yes")
else:
ans.append("No")
elif c == "b":
if inout < A + B and out < B:
inout += 1
out ... | N, A, B = map(int, input().split())
S = input()
a = b = 0
ans = []
for c in S:
if c == "a":
if a + b < A + B:
a += 1
ans.append("Yes")
else:
ans.append("No")
elif c == "b":
if a + b < A + B and b < B:
b += 1
ans.append("Yes")
... | false | 4.545455 | [
"+a = b = 0",
"-inout = out = 0",
"- if inout < A + B:",
"- inout += 1",
"+ if a + b < A + B:",
"+ a += 1",
"- if inout < A + B and out < B:",
"- inout += 1",
"- out += 1",
"+ if a + b < A + B and b < B:",
"+ b +=... | false | 0.099814 | 0.042564 | 2.345052 | [
"s821983660",
"s379340695"
] |
u852690916 | p03371 | python | s239568696 | s927315939 | 126 | 73 | 3,064 | 67,584 | Accepted | Accepted | 42.06 | a,b,c,x,y=list(map(int, input().split()))
c*=2
ans=10**9
for cc in range(max(x,y)+1):
tmp = cc * c
tmp += max(0, x-cc)*a
tmp += max(0, y-cc)*b
ans = min(ans, tmp)
print(ans) | A, B, C, X, Y = list(map(int, input().split()))
ans = 10**18
for z in range(0, max(X, Y) * 2 + 1, 2):
x, y = max(0, X - z // 2), max(0, Y - z // 2)
tmp = A * x + B * y + C * z
ans = min(ans, tmp)
print(ans)
| 9 | 7 | 191 | 219 | a, b, c, x, y = list(map(int, input().split()))
c *= 2
ans = 10**9
for cc in range(max(x, y) + 1):
tmp = cc * c
tmp += max(0, x - cc) * a
tmp += max(0, y - cc) * b
ans = min(ans, tmp)
print(ans)
| A, B, C, X, Y = list(map(int, input().split()))
ans = 10**18
for z in range(0, max(X, Y) * 2 + 1, 2):
x, y = max(0, X - z // 2), max(0, Y - z // 2)
tmp = A * x + B * y + C * z
ans = min(ans, tmp)
print(ans)
| false | 22.222222 | [
"-a, b, c, x, y = list(map(int, input().split()))",
"-c *= 2",
"-ans = 10**9",
"-for cc in range(max(x, y) + 1):",
"- tmp = cc * c",
"- tmp += max(0, x - cc) * a",
"- tmp += max(0, y - cc) * b",
"+A, B, C, X, Y = list(map(int, input().split()))",
"+ans = 10**18",
"+for z in range(0, max(X... | false | 0.07096 | 0.071856 | 0.98752 | [
"s239568696",
"s927315939"
] |
u470936782 | p03290 | python | s286560596 | s470275328 | 301 | 27 | 3,064 | 3,064 | Accepted | Accepted | 91.03 | D, G = [int(str) for str in input().strip().split()]
PC = [[int(str) for str in input().strip().split()] for _ in range(D)]
ans = 10 ** 4
for bits in range(2 ** D + 1):
num, score = 0, 0
for i in range(D):
if (0x01 << i) & bits:
score += PC[i][0] * (i + 1) * 100 + PC[i][1]
... | #!/usr/bin/env python3
D, G = [int(str) for str in input().strip().split()]
pc = [[int(str) for str in input().strip().split()] for _ in range(D)]
ans = float('Inf')
sums = [100 * (i + 1) * pc[i][0] + pc[i][1] for i in range(D)]
for bit in range(2 ** D):
score = 0
cnt = 0
for i in range(D):
... | 29 | 26 | 714 | 717 | D, G = [int(str) for str in input().strip().split()]
PC = [[int(str) for str in input().strip().split()] for _ in range(D)]
ans = 10**4
for bits in range(2**D + 1):
num, score = 0, 0
for i in range(D):
if (0x01 << i) & bits:
score += PC[i][0] * (i + 1) * 100 + PC[i][1]
num += PC[... | #!/usr/bin/env python3
D, G = [int(str) for str in input().strip().split()]
pc = [[int(str) for str in input().strip().split()] for _ in range(D)]
ans = float("Inf")
sums = [100 * (i + 1) * pc[i][0] + pc[i][1] for i in range(D)]
for bit in range(2**D):
score = 0
cnt = 0
for i in range(D):
if bit & (... | false | 10.344828 | [
"+#!/usr/bin/env python3",
"-PC = [[int(str) for str in input().strip().split()] for _ in range(D)]",
"-ans = 10**4",
"-for bits in range(2**D + 1):",
"- num, score = 0, 0",
"+pc = [[int(str) for str in input().strip().split()] for _ in range(D)]",
"+ans = float(\"Inf\")",
"+sums = [100 * (i + 1) *... | false | 0.087843 | 0.064594 | 1.359918 | [
"s286560596",
"s470275328"
] |
u058240079 | p03307 | python | s697758714 | s812943705 | 11 | 10 | 2,568 | 2,568 | Accepted | Accepted | 9.09 | n = int(input())
if n % 2 == 0:
print(n)
else:
print(n * 2)
| n = int(input())
if n % 2 == 1:
print(n * 2)
else:
print(n)
| 5 | 5 | 70 | 70 | n = int(input())
if n % 2 == 0:
print(n)
else:
print(n * 2)
| n = int(input())
if n % 2 == 1:
print(n * 2)
else:
print(n)
| false | 0 | [
"-if n % 2 == 0:",
"+if n % 2 == 1:",
"+ print(n * 2)",
"+else:",
"-else:",
"- print(n * 2)"
] | false | 0.045768 | 0.112005 | 0.408628 | [
"s697758714",
"s812943705"
] |
u254871849 | p03032 | python | s668707426 | s954901655 | 24 | 21 | 3,064 | 3,064 | Accepted | Accepted | 12.5 | import sys
n, k, *v = list(map(int, sys.stdin.read().split()))
def main():
m = min(n, k)
res = 0
for i in range(m+1):
for j in range((m-i)+1):
l = v[:i]
r = v[-j:] if j > 0 else []
take = l + r
s = sum(take)
neg = [t for t in... | import sys
n, k, *v = list(map(int, sys.stdin.read().split()))
def main():
m = min(n, k)
ls = [None] * (m + 1)
rs = [None] * (m + 1)
l_neg = [None] * (m + 1)
r_neg = [None] * (m + 1)
ls[0] = 0
rs[0] = 0
l_neg[0] = []
r_neg[0] = []
for i in range(m):
... | 22 | 40 | 507 | 903 | import sys
n, k, *v = list(map(int, sys.stdin.read().split()))
def main():
m = min(n, k)
res = 0
for i in range(m + 1):
for j in range((m - i) + 1):
l = v[:i]
r = v[-j:] if j > 0 else []
take = l + r
s = sum(take)
neg = [t for t in take ... | import sys
n, k, *v = list(map(int, sys.stdin.read().split()))
def main():
m = min(n, k)
ls = [None] * (m + 1)
rs = [None] * (m + 1)
l_neg = [None] * (m + 1)
r_neg = [None] * (m + 1)
ls[0] = 0
rs[0] = 0
l_neg[0] = []
r_neg[0] = []
for i in range(m):
l = v[i]
r ... | false | 45 | [
"+ ls = [None] * (m + 1)",
"+ rs = [None] * (m + 1)",
"+ l_neg = [None] * (m + 1)",
"+ r_neg = [None] * (m + 1)",
"+ ls[0] = 0",
"+ rs[0] = 0",
"+ l_neg[0] = []",
"+ r_neg[0] = []",
"+ for i in range(m):",
"+ l = v[i]",
"+ r = v[-(i + 1)]",
"+ ls... | false | 0.042931 | 0.043343 | 0.990507 | [
"s668707426",
"s954901655"
] |
u279493135 | p03163 | python | s982462766 | s836214038 | 400 | 178 | 63,336 | 15,500 | Accepted | Accepted | 55.5 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, a... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, a... | 29 | 28 | 933 | 944 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_u... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_u... | false | 3.448276 | [
"+import numpy as np",
"-w, v = ZIP(N)",
"-dp = [0] * (W + 1)",
"-for i in range(N):",
"- for j in range(W, -1, -1):",
"- if j - w[i] >= 0:",
"- dp[j] = max(dp[j], dp[j - w[i]] + v[i])",
"+wv = [LIST() for _ in range(N)]",
"+dp = np.zeros(W + 1, dtype=np.int64)",
"+for w, v in... | false | 0.007538 | 0.219632 | 0.034322 | [
"s982462766",
"s836214038"
] |
u569960318 | p02237 | python | s179123056 | s524618686 | 30 | 20 | 7,656 | 7,660 | Accepted | Accepted | 33.33 | n = int(eval(input()))
for _ in range(n):
u = list(map(int,input().split()))
out = [0]*n
for i in range(u[1]): out[u[i+2]-1] = 1
print((*out)) | n = int(eval(input()))
for _ in range(n):
u = list(map(int,input().split()))
out = [0]*n
for i in u[2:]: out[i-1] = 1
print((*out)) | 6 | 6 | 155 | 144 | n = int(eval(input()))
for _ in range(n):
u = list(map(int, input().split()))
out = [0] * n
for i in range(u[1]):
out[u[i + 2] - 1] = 1
print((*out))
| n = int(eval(input()))
for _ in range(n):
u = list(map(int, input().split()))
out = [0] * n
for i in u[2:]:
out[i - 1] = 1
print((*out))
| false | 0 | [
"- for i in range(u[1]):",
"- out[u[i + 2] - 1] = 1",
"+ for i in u[2:]:",
"+ out[i - 1] = 1"
] | false | 0.261175 | 0.046716 | 5.590734 | [
"s179123056",
"s524618686"
] |
u282657760 | p02693 | python | s786314093 | s655994990 | 23 | 21 | 9,172 | 9,164 | Accepted | Accepted | 8.7 | K = int(eval(input()))
a,b=list(map(int,input().split()))
ans = 'NG'
for i in range(a, b+1):
if i%K == 0:
ans = 'OK'
if K == 1:
ans = 'OK'
print(ans) | K = int(eval(input()))
a,b=list(map(int,input().split()))
if b//K-a//K>0:
ans ='OK'
elif K==1:
ans = 'OK'
elif a%K==0:
ans = 'OK'
else:
ans = 'NG'
print(ans)
| 9 | 11 | 153 | 164 | K = int(eval(input()))
a, b = list(map(int, input().split()))
ans = "NG"
for i in range(a, b + 1):
if i % K == 0:
ans = "OK"
if K == 1:
ans = "OK"
print(ans)
| K = int(eval(input()))
a, b = list(map(int, input().split()))
if b // K - a // K > 0:
ans = "OK"
elif K == 1:
ans = "OK"
elif a % K == 0:
ans = "OK"
else:
ans = "NG"
print(ans)
| false | 18.181818 | [
"-ans = \"NG\"",
"-for i in range(a, b + 1):",
"- if i % K == 0:",
"- ans = \"OK\"",
"-if K == 1:",
"+if b // K - a // K > 0:",
"+elif K == 1:",
"+ ans = \"OK\"",
"+elif a % K == 0:",
"+ ans = \"OK\"",
"+else:",
"+ ans = \"NG\""
] | false | 0.041913 | 0.162038 | 0.258659 | [
"s786314093",
"s655994990"
] |
u298297089 | p03212 | python | s944272011 | s687727416 | 578 | 41 | 6,452 | 3,060 | Accepted | Accepted | 92.91 | from collections import deque
N = int(eval(input()))
memo = {i:1 for i in [357, 375, 537, 573, 735, 753]}
ans = 0
queue = deque()
mod = [10**i for i in range(10)]
for key in list(memo.keys()):
if key <= N:
ans += 1
queue.append(key)
while queue:
key = queue.popleft()
len_key = len(str(key)... | # https://atcoder.jp/contests/abc114/submissions/6262572
from itertools import product
N = eval(input())
n = int(N)
ans = 0
for i in range(3, len(N)+1):
for s in product(["3","5","7"],repeat=i):
if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
ans += 1
print(ans)
| 21 | 11 | 591 | 308 | from collections import deque
N = int(eval(input()))
memo = {i: 1 for i in [357, 375, 537, 573, 735, 753]}
ans = 0
queue = deque()
mod = [10**i for i in range(10)]
for key in list(memo.keys()):
if key <= N:
ans += 1
queue.append(key)
while queue:
key = queue.popleft()
len_key = len(str(key)... | # https://atcoder.jp/contests/abc114/submissions/6262572
from itertools import product
N = eval(input())
n = int(N)
ans = 0
for i in range(3, len(N) + 1):
for s in product(["3", "5", "7"], repeat=i):
if int("".join(s)) <= n and "3" in s and "5" in s and "7" in s:
ans += 1
print(ans)
| false | 47.619048 | [
"-from collections import deque",
"+# https://atcoder.jp/contests/abc114/submissions/6262572",
"+from itertools import product",
"-N = int(eval(input()))",
"-memo = {i: 1 for i in [357, 375, 537, 573, 735, 753]}",
"+N = eval(input())",
"+n = int(N)",
"-queue = deque()",
"-mod = [10**i for i in range... | false | 0.363415 | 0.03642 | 9.978473 | [
"s944272011",
"s687727416"
] |
u391875425 | p03107 | python | s574855754 | s246899297 | 34 | 20 | 3,188 | 3,188 | Accepted | Accepted | 41.18 | S = eval(input())
c0 = 0
c1 = 0
for i in range(len(S)):
if S[i] == '0':
c0 += 1
else:
c1 += 1
print((min(c0, c1) * 2)) | S = eval(input())
print((min(S.count('0'), S.count('1')) * 2)) | 9 | 2 | 142 | 55 | S = eval(input())
c0 = 0
c1 = 0
for i in range(len(S)):
if S[i] == "0":
c0 += 1
else:
c1 += 1
print((min(c0, c1) * 2))
| S = eval(input())
print((min(S.count("0"), S.count("1")) * 2))
| false | 77.777778 | [
"-c0 = 0",
"-c1 = 0",
"-for i in range(len(S)):",
"- if S[i] == \"0\":",
"- c0 += 1",
"- else:",
"- c1 += 1",
"-print((min(c0, c1) * 2))",
"+print((min(S.count(\"0\"), S.count(\"1\")) * 2))"
] | false | 0.055895 | 0.036267 | 1.541198 | [
"s574855754",
"s246899297"
] |
u197955752 | p02813 | python | s361325558 | s207993724 | 238 | 36 | 3,316 | 8,052 | Accepted | Accepted | 84.87 | from collections import deque
N = int(eval(input()))
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
st = deque([[i] for i in range(N, 0, -1)])
ord = 0
a = 0
b = 0
while(len(st) > 0):
if a > 0 and b > 0: break
now = st.pop()
if len(now) == N:
ord += 1
... | from itertools import permutations
N = int(eval(input()))
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())
perm = list(permutations(list(range(1, N + 1)), N))
i = 0
a = 0; b = 0;
for i in range(len(perm)):
if a > 0 and b > 0: break
if perm[i] == P: a = i + 1
... | 24 | 15 | 492 | 359 | from collections import deque
N = int(eval(input()))
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
st = deque([[i] for i in range(N, 0, -1)])
ord = 0
a = 0
b = 0
while len(st) > 0:
if a > 0 and b > 0:
break
now = st.pop()
if len(now) == N:
ord += 1
if P == ... | from itertools import permutations
N = int(eval(input()))
P = tuple(int(x) for x in input().split())
Q = tuple(int(x) for x in input().split())
perm = list(permutations(list(range(1, N + 1)), N))
i = 0
a = 0
b = 0
for i in range(len(perm)):
if a > 0 and b > 0:
break
if perm[i] == P:
a = i + 1
... | false | 37.5 | [
"-from collections import deque",
"+from itertools import permutations",
"-P = [int(x) for x in input().split()]",
"-Q = [int(x) for x in input().split()]",
"-st = deque([[i] for i in range(N, 0, -1)])",
"-ord = 0",
"+P = tuple(int(x) for x in input().split())",
"+Q = tuple(int(x) for x in input().spl... | false | 0.092156 | 0.040132 | 2.296332 | [
"s361325558",
"s207993724"
] |
u802963389 | p02928 | python | s808920803 | s365666650 | 1,831 | 1,096 | 3,188 | 3,188 | Accepted | Accepted | 40.14 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for l in range(N - 1):
for r in range(l + 1, N):
if A[l] > A[r]:
x += 1
# print(x)
AA = A + A
y = 0
for l in range(2 * N - 1):
for r in range(l + 1, 2 * N):
if AA[l] > AA[r]:
y += 1
y -= 2 * ... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for l in range(N - 1):
for r in range(l + 1, N):
if A[l] > A[r]:
x += 1
# print(x)
AA = A + A
y = 0
for l in range(N):
for r in range(N):
if AA[l] > AA[r]:
y += 1
# print(y)
print((int((... | 20 | 19 | 392 | 361 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for l in range(N - 1):
for r in range(l + 1, N):
if A[l] > A[r]:
x += 1
# print(x)
AA = A + A
y = 0
for l in range(2 * N - 1):
for r in range(l + 1, 2 * N):
if AA[l] > AA[r]:
y += 1
y -= 2 * ... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
x = 0
for l in range(N - 1):
for r in range(l + 1, N):
if A[l] > A[r]:
x += 1
# print(x)
AA = A + A
y = 0
for l in range(N):
for r in range(N):
if AA[l] > AA[r]:
y += 1
# print(y)
print((int((K * x... | false | 5 | [
"-for l in range(2 * N - 1):",
"- for r in range(l + 1, 2 * N):",
"+for l in range(N):",
"+ for r in range(N):",
"-y -= 2 * x"
] | false | 0.037391 | 0.035132 | 1.064305 | [
"s808920803",
"s365666650"
] |
u017415492 | p02923 | python | s397792020 | s258378562 | 88 | 76 | 14,252 | 15,020 | Accepted | Accepted | 13.64 | n = int (eval(input()))
h = list(map(int,input().split()))
count_list = []
count=0
for i in range(n):
if i == n-1:
break
if h[i] >= h[i+1]:
if count !=0:
count +=1
else:
count = 1
else:
count = 0
count_list.append(count)
if not count_list:
count_l... | n = int(eval(input()))
d= list(map(int,input().split()))
count=0
h=0
for i in range(n-1):
if d[i]>=d[i+1]:
count+=1
else:
count=0
if h<count:
h=count
print(h) | 18 | 14 | 351 | 185 | n = int(eval(input()))
h = list(map(int, input().split()))
count_list = []
count = 0
for i in range(n):
if i == n - 1:
break
if h[i] >= h[i + 1]:
if count != 0:
count += 1
else:
count = 1
else:
count = 0
count_list.append(count)
if not count_list:
... | n = int(eval(input()))
d = list(map(int, input().split()))
count = 0
h = 0
for i in range(n - 1):
if d[i] >= d[i + 1]:
count += 1
else:
count = 0
if h < count:
h = count
print(h)
| false | 22.222222 | [
"-h = list(map(int, input().split()))",
"-count_list = []",
"+d = list(map(int, input().split()))",
"-for i in range(n):",
"- if i == n - 1:",
"- break",
"- if h[i] >= h[i + 1]:",
"- if count != 0:",
"- count += 1",
"- else:",
"- count = 1",
"+h... | false | 0.033233 | 0.042329 | 0.785124 | [
"s397792020",
"s258378562"
] |
u621935300 | p03682 | python | s856030466 | s502644566 | 1,552 | 977 | 185,552 | 163,532 | Accepted | Accepted | 37.05 | # -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop,heapify
N=int(sys.stdin.readline().strip())
V=[] #頂点の集合 (x座標、y座標、頂点番号)
for v in range(N): #v:頂点番号
x,y=tuple(map(int, sys.stdin.readline().split()))
V.append((x,y,v+1))
#頂点をy軸でソート
V.sort(key=lambda x:(x[0]) )
E=[] #辺の集合 (... | # -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop,heapify
N=int(sys.stdin.readline().strip())
V=[] #頂点の集合 (x座標、y座標、頂点番号)
for v in range(N): #v:頂点番号
x,y=tuple(map(int, sys.stdin.readline().split()))
V.append((x,y,v+1))
#頂点をy軸でソート
V.sort(key=lambda x:(x[0]) )
E=[] #辺の集合 (... | 59 | 56 | 1,364 | 1,314 | # -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop, heapify
N = int(sys.stdin.readline().strip())
V = [] # 頂点の集合 (x座標、y座標、頂点番号)
for v in range(N): # v:頂点番号
x, y = tuple(map(int, sys.stdin.readline().split()))
V.append((x, y, v + 1))
# 頂点をy軸でソート
V.sort(key=lambda x: (x[0]))
E = [] # 辺の集合 ... | # -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop, heapify
N = int(sys.stdin.readline().strip())
V = [] # 頂点の集合 (x座標、y座標、頂点番号)
for v in range(N): # v:頂点番号
x, y = tuple(map(int, sys.stdin.readline().split()))
V.append((x, y, v + 1))
# 頂点をy軸でソート
V.sort(key=lambda x: (x[0]))
E = [] # 辺の集合 ... | false | 5.084746 | [
"-# 辺の集合を辺の長さで昇順ソート",
"-E.sort(key=lambda x: (x[0]))"
] | false | 0.050802 | 0.079436 | 0.639534 | [
"s856030466",
"s502644566"
] |
u014333473 | p03853 | python | s035326144 | s923843687 | 28 | 25 | 9,180 | 9,100 | Accepted | Accepted | 10.71 | H,W=list(map(int,input().split()))
cw=[eval(input()) for _ in range(H)]
cw2=cw
for i,j in zip(cw,cw2):
print(i)
print(j) | H,W=map(int,input().split())
cw=[input() for _ in range(H)]
[print(i + '\n' + j) for i,j in zip(cw,cw)]
| 6 | 3 | 117 | 105 | H, W = list(map(int, input().split()))
cw = [eval(input()) for _ in range(H)]
cw2 = cw
for i, j in zip(cw, cw2):
print(i)
print(j)
| H, W = map(int, input().split())
cw = [input() for _ in range(H)]
[print(i + "\n" + j) for i, j in zip(cw, cw)]
| false | 50 | [
"-H, W = list(map(int, input().split()))",
"-cw = [eval(input()) for _ in range(H)]",
"-cw2 = cw",
"-for i, j in zip(cw, cw2):",
"- print(i)",
"- print(j)",
"+H, W = map(int, input().split())",
"+cw = [input() for _ in range(H)]",
"+[print(i + \"\\n\" + j) for i, j in zip(cw, cw)]"
] | false | 0.04465 | 0.035204 | 1.268308 | [
"s035326144",
"s923843687"
] |
u826263061 | p03166 | python | s022338467 | s419455510 | 697 | 628 | 65,200 | 65,200 | Accepted | Accepted | 9.9 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**7)
n, m = list(map(int, input().split()))
v = [-1]*(n+1)
adj = [[] for _ in range(n+1)]
for _ in range(m):
i, j = list(map(int, input().split()))
adj[i].append(j)
... | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 17 11:58:20 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**6)
memo = [-1] * (10**5+100)
def rec(nx):
if memo[nx] > -1:
return memo[nx]
depth = 0
for edge in edges[nx]:
nrec = rec(edge) + 1
if nrec ... | 34 | 35 | 649 | 706 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**7)
n, m = list(map(int, input().split()))
v = [-1] * (n + 1)
adj = [[] for _ in range(n + 1)]
for _ in range(m):
i, j = list(map(int, input().split()))
adj[i].append(j)
def dfs(vi):
... | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 17 11:58:20 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**6)
memo = [-1] * (10**5 + 100)
def rec(nx):
if memo[nx] > -1:
return memo[nx]
depth = 0
for edge in edges[nx]:
nrec = rec(edge) + 1
if nrec > depth:
... | false | 2.857143 | [
"-Created on Sat Jan 19 16:05:26 2019",
"+Created on Sun Mar 17 11:58:20 2019",
"-sys.setrecursionlimit(10**7)",
"-n, m = list(map(int, input().split()))",
"-v = [-1] * (n + 1)",
"-adj = [[] for _ in range(n + 1)]",
"-for _ in range(m):",
"- i, j = list(map(int, input().split()))",
"- adj[i].a... | false | 0.045981 | 0.052776 | 0.871242 | [
"s022338467",
"s419455510"
] |
u203383537 | p02678 | python | s433526711 | s891318731 | 1,382 | 682 | 40,168 | 41,732 | Accepted | Accepted | 50.65 | import queue
n,m=list(map(int,input().split()))
to = [[] for i in range(n+1)]
pre = [-1] * (n+1)
for i in range(m):
a,b=list(map(int,input().split()))
to[a].append(b)
to[b].append(a)
q = queue.Queue()
q.put((1,0))
while not q.empty():
x,p = q.get()
if pre[x] != -1:
continu... | from collections import deque
n,m = list(map(int,input().split()))
adj = [[] for i in range(n+1)]
dist = [-1]*(n+1)
for i in range(m):
a,b = list(map(int,input().split()))
adj[a].append(b)
adj[b].append(a)
d = deque([[1,0]])
while len(d) > 0:
x,y = d.popleft()
if dist[x] != -1:
... | 26 | 29 | 453 | 484 | import queue
n, m = list(map(int, input().split()))
to = [[] for i in range(n + 1)]
pre = [-1] * (n + 1)
for i in range(m):
a, b = list(map(int, input().split()))
to[a].append(b)
to[b].append(a)
q = queue.Queue()
q.put((1, 0))
while not q.empty():
x, p = q.get()
if pre[x] != -1:
continue
... | from collections import deque
n, m = list(map(int, input().split()))
adj = [[] for i in range(n + 1)]
dist = [-1] * (n + 1)
for i in range(m):
a, b = list(map(int, input().split()))
adj[a].append(b)
adj[b].append(a)
d = deque([[1, 0]])
while len(d) > 0:
x, y = d.popleft()
if dist[x] != -1:
... | false | 10.344828 | [
"-import queue",
"+from collections import deque",
"-to = [[] for i in range(n + 1)]",
"-pre = [-1] * (n + 1)",
"+adj = [[] for i in range(n + 1)]",
"+dist = [-1] * (n + 1)",
"- to[a].append(b)",
"- to[b].append(a)",
"-q = queue.Queue()",
"-q.put((1, 0))",
"-while not q.empty():",
"- ... | false | 0.038443 | 0.036593 | 1.050575 | [
"s433526711",
"s891318731"
] |
u771365068 | p03160 | python | s864974525 | s549928571 | 216 | 177 | 93,972 | 13,908 | Accepted | Accepted | 18.06 | import sys
sys.setrecursionlimit(10 ** 7)
def solve(index: int, dp: list, footing: list) -> int:
if dp[index] != -1:
return dp[index]
if index == 0:
return 0
elif index == 1:
return abs(footing[1]-footing[0])
tmp = min(solve(index-1, dp, footing)+abs(footing[index]... |
N = int(eval(input()))
footing = list(map(int, input().split()))
dp = [10 ** 10] * N
dp[0] = 0
# give
for i in range(N-1):
if dp[i+1] > dp[i] + abs(footing[i+1] - footing[i]):
dp[i+1] = dp[i] + abs(footing[i+1] - footing[i])
if i < N-2:
if dp[i+2] > dp[i] + abs(footing[i+2] - fo... | 25 | 17 | 592 | 404 | import sys
sys.setrecursionlimit(10**7)
def solve(index: int, dp: list, footing: list) -> int:
if dp[index] != -1:
return dp[index]
if index == 0:
return 0
elif index == 1:
return abs(footing[1] - footing[0])
tmp = min(
solve(index - 1, dp, footing) + abs(footing[index... | N = int(eval(input()))
footing = list(map(int, input().split()))
dp = [10**10] * N
dp[0] = 0
# give
for i in range(N - 1):
if dp[i + 1] > dp[i] + abs(footing[i + 1] - footing[i]):
dp[i + 1] = dp[i] + abs(footing[i + 1] - footing[i])
if i < N - 2:
if dp[i + 2] > dp[i] + abs(footing[i + 2] - footi... | false | 32 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def solve(index: int, dp: list, footing: list) -> int:",
"- if dp[index] != -1:",
"- return dp[index]",
"- if index == 0:",
"- return 0",
"- elif index == 1:",
"- return abs(footing[1] - footing[0])"... | false | 0.05735 | 0.033049 | 1.7353 | [
"s864974525",
"s549928571"
] |
u254871849 | p03862 | python | s932977490 | s282881239 | 94 | 55 | 14,092 | 14,092 | Accepted | Accepted | 41.49 | import sys
n, x, *a = list(map(int, sys.stdin.read().split()))
a = [0] + a
def main():
tot = 0
for i in range(1, n + 1):
if a[i] + a[i-1] > x:
tot += a[i] + a[i-1] - x
a[i] = x - a[i-1]
print(tot)
if __name__ == '__main__':
main() | import sys
n, x, *a = list(map(int, sys.stdin.read().split()))
def main():
cnt = 0
lim = x
for c in a:
if c > lim:
cnt += c - lim
lim = x - lim
else:
lim = x - c
print(cnt)
if __name__ == '__main__':
main() | 15 | 17 | 266 | 256 | import sys
n, x, *a = list(map(int, sys.stdin.read().split()))
a = [0] + a
def main():
tot = 0
for i in range(1, n + 1):
if a[i] + a[i - 1] > x:
tot += a[i] + a[i - 1] - x
a[i] = x - a[i - 1]
print(tot)
if __name__ == "__main__":
main()
| import sys
n, x, *a = list(map(int, sys.stdin.read().split()))
def main():
cnt = 0
lim = x
for c in a:
if c > lim:
cnt += c - lim
lim = x - lim
else:
lim = x - c
print(cnt)
if __name__ == "__main__":
main()
| false | 11.764706 | [
"-a = [0] + a",
"- tot = 0",
"- for i in range(1, n + 1):",
"- if a[i] + a[i - 1] > x:",
"- tot += a[i] + a[i - 1] - x",
"- a[i] = x - a[i - 1]",
"- print(tot)",
"+ cnt = 0",
"+ lim = x",
"+ for c in a:",
"+ if c > lim:",
"+ cnt ... | false | 0.04521 | 0.040276 | 1.122493 | [
"s932977490",
"s282881239"
] |
u846877959 | p03370 | python | s423871926 | s183779460 | 40 | 17 | 3,060 | 2,940 | Accepted | Accepted | 57.5 | n, x = list(map(int, input().split()))
m = []
sum = 0
for i in range(n):
a = int(eval(input()))
m.append(a)
sum += a
m = sorted(m)
#print(m)
x -= sum
cnt = n
while x >= m[0]:
cnt += 1
x -= m[0]
print(cnt)
| n, x = list(map(int, input().split()))
m = []
sum = 0
for i in range(n):
a = int(eval(input()))
m.append(a)
sum += a
m = sorted(m)
#print(m)
x -= sum
#cnt = n
#while x >= m[0]:
# cnt += 1
# x -= m[0]
cnt = n + x // m[0]
print(cnt)
| 17 | 18 | 231 | 256 | n, x = list(map(int, input().split()))
m = []
sum = 0
for i in range(n):
a = int(eval(input()))
m.append(a)
sum += a
m = sorted(m)
# print(m)
x -= sum
cnt = n
while x >= m[0]:
cnt += 1
x -= m[0]
print(cnt)
| n, x = list(map(int, input().split()))
m = []
sum = 0
for i in range(n):
a = int(eval(input()))
m.append(a)
sum += a
m = sorted(m)
# print(m)
x -= sum
# cnt = n
# while x >= m[0]:
# cnt += 1
# x -= m[0]
cnt = n + x // m[0]
print(cnt)
| false | 5.555556 | [
"-cnt = n",
"-while x >= m[0]:",
"- cnt += 1",
"- x -= m[0]",
"+# cnt = n",
"+# while x >= m[0]:",
"+# cnt += 1",
"+# x -= m[0]",
"+cnt = n + x // m[0]"
] | false | 0.036804 | 0.054202 | 0.679018 | [
"s423871926",
"s183779460"
] |
u352394527 | p00516 | python | s097143011 | s402107971 | 110 | 50 | 5,624 | 5,620 | Accepted | Accepted | 54.55 | n,m = list(map(int,input().split()))
A = [int(eval(input())) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
b = int(eval(input()))
for j in range(n):
if A[j] <= b:
V[j] += 1
break
print((V.index(max(V)) + 1))
| def main():
n,m = list(map(int,input().split()))
A = [int(eval(input())) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
b = int(eval(input()))
for j in range(n):
if A[j] <= b:
V[j] += 1
break
print((V.index(max(V)) + 1))
main()
| 11 | 13 | 237 | 278 | n, m = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
b = int(eval(input()))
for j in range(n):
if A[j] <= b:
V[j] += 1
break
print((V.index(max(V)) + 1))
| def main():
n, m = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(n)]
V = [0 for _ in range(n)]
for i in range(m):
b = int(eval(input()))
for j in range(n):
if A[j] <= b:
V[j] += 1
break
print((V.index(max(V)) + 1))
... | false | 15.384615 | [
"-n, m = list(map(int, input().split()))",
"-A = [int(eval(input())) for _ in range(n)]",
"-V = [0 for _ in range(n)]",
"-for i in range(m):",
"- b = int(eval(input()))",
"- for j in range(n):",
"- if A[j] <= b:",
"- V[j] += 1",
"- break",
"-print((V.index(max(V)... | false | 0.04535 | 0.048004 | 0.944704 | [
"s097143011",
"s402107971"
] |
u969190727 | p02941 | python | s356326019 | s331383785 | 1,962 | 1,075 | 123,036 | 121,208 | Accepted | Accepted | 45.21 | n=int(eval(input()))
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
from heapq import heappop, heappush
push = lambda x,i: heappush(BB,(-x,i))
BB=[]
for i,b in enumerate(B):
push(b,i)
ans=0
while BB:
b,ind=heappop(BB)
b,ai=-b,A[ind]
if b<ai:
ans=-1
break
d... | n=int(eval(input()))
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
key=2**18
from heapq import heappop, heappush
push = lambda x,i: heappush(BB,-(x*key+i))
BB=[]
for i,b in enumerate(B):
push(b,i)
ans=0
while BB:
bb=heappop(BB)
bb=-bb
b,ind=bb//key,bb%key
ai=A[ind]
... | 30 | 32 | 487 | 526 | n = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
from heapq import heappop, heappush
push = lambda x, i: heappush(BB, (-x, i))
BB = []
for i, b in enumerate(B):
push(b, i)
ans = 0
while BB:
b, ind = heappop(BB)
b, ai = -b, A[ind]
if b < ai:
ans ... | n = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
key = 2**18
from heapq import heappop, heappush
push = lambda x, i: heappush(BB, -(x * key + i))
BB = []
for i, b in enumerate(B):
push(b, i)
ans = 0
while BB:
bb = heappop(BB)
bb = -bb
b, ind = bb // key... | false | 6.25 | [
"+key = 2**18",
"-push = lambda x, i: heappush(BB, (-x, i))",
"+push = lambda x, i: heappush(BB, -(x * key + i))",
"- b, ind = heappop(BB)",
"- b, ai = -b, A[ind]",
"+ bb = heappop(BB)",
"+ bb = -bb",
"+ b, ind = bb // key, bb % key",
"+ ai = A[ind]",
"- push(b - d * dd, ind)"... | false | 0.041642 | 0.118534 | 0.351313 | [
"s356326019",
"s331383785"
] |
u525065967 | p02548 | python | s247062835 | s165038371 | 149 | 112 | 9,156 | 16,788 | Accepted | Accepted | 24.83 | n = int(eval(input()))
c = 0
for a in range(1, n): c += (n-1)//a
print(c)
| n = int(eval(input()))
print((sum([(n-1)//a for a in range(1, n)])))
| 4 | 2 | 71 | 62 | n = int(eval(input()))
c = 0
for a in range(1, n):
c += (n - 1) // a
print(c)
| n = int(eval(input()))
print((sum([(n - 1) // a for a in range(1, n)])))
| false | 50 | [
"-c = 0",
"-for a in range(1, n):",
"- c += (n - 1) // a",
"-print(c)",
"+print((sum([(n - 1) // a for a in range(1, n)])))"
] | false | 0.131965 | 0.113254 | 1.165211 | [
"s247062835",
"s165038371"
] |
u139614630 | p03013 | python | s019730297 | s376011552 | 192 | 61 | 8,232 | 6,976 | Accepted | Accepted | 68.23 | #!/usr/bin/env python3
import array
P_NUM = 1000000007
def solv(n, m, a):
comb = array.array('I', [1] * (n+1))
for i in a:
comb[i] = 0
for i in range(2, n+1):
comb[i] *= (comb[i-1] + comb[i-2]) % P_NUM
return comb[-1]
if __name__ == '__main__':
n, m = l... | #!/usr/bin/env python3
import sys
P_NUM = 1000000007
def solv(n, m, a):
comb = [1] * (n+1)
for i in a:
comb[i] = 0
for i in range(2, n+1):
comb[i] *= (comb[i-1] + comb[i-2]) % P_NUM
return comb[-1]
if __name__ == '__main__':
n, m = list(map(int, input().... | 27 | 29 | 432 | 439 | #!/usr/bin/env python3
import array
P_NUM = 1000000007
def solv(n, m, a):
comb = array.array("I", [1] * (n + 1))
for i in a:
comb[i] = 0
for i in range(2, n + 1):
comb[i] *= (comb[i - 1] + comb[i - 2]) % P_NUM
return comb[-1]
if __name__ == "__main__":
n, m = list(map(int, input... | #!/usr/bin/env python3
import sys
P_NUM = 1000000007
def solv(n, m, a):
comb = [1] * (n + 1)
for i in a:
comb[i] = 0
for i in range(2, n + 1):
comb[i] *= (comb[i - 1] + comb[i - 2]) % P_NUM
return comb[-1]
if __name__ == "__main__":
n, m = list(map(int, input().split()))
if ... | false | 6.896552 | [
"-import array",
"+import sys",
"- comb = array.array(\"I\", [1] * (n + 1))",
"+ comb = [1] * (n + 1)",
"- a = [int(eval(input())) for _ in range(m)]",
"+ if m:",
"+ a = list(map(int, sys.stdin))",
"+ else:",
"+ a = []"
] | false | 0.037079 | 0.035957 | 1.031199 | [
"s019730297",
"s376011552"
] |
u210827208 | p03651 | python | s678253435 | s872917714 | 127 | 91 | 16,240 | 16,048 | Accepted | Accepted | 28.35 | from fractions import gcd
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
A.sort()
if k>A[-1]:
print('IMPOSSIBLE')
else:
a=A[0]
for i in range(n):
a=gcd(a,A[i])
if a==1:
print('POSSIBLE')
else:
if k%a==0:
print('POSSIBLE')
... | from fractions import gcd
n,k=list(map(int,input().split()))
A=list(map(int,input().split()))
if k>max(A):
print('IMPOSSIBLE')
else:
a=A[0]
for i in range(n):
a=gcd(a,A[i])
if a==1 or k%a==0:
print('POSSIBLE')
else:
print('IMPOSSIBLE') | 17 | 13 | 354 | 285 | from fractions import gcd
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
if k > A[-1]:
print("IMPOSSIBLE")
else:
a = A[0]
for i in range(n):
a = gcd(a, A[i])
if a == 1:
print("POSSIBLE")
else:
if k % a == 0:
print("POSSIBLE")
... | from fractions import gcd
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
if k > max(A):
print("IMPOSSIBLE")
else:
a = A[0]
for i in range(n):
a = gcd(a, A[i])
if a == 1 or k % a == 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 23.529412 | [
"-A.sort()",
"-if k > A[-1]:",
"+if k > max(A):",
"- if a == 1:",
"+ if a == 1 or k % a == 0:",
"- if k % a == 0:",
"- print(\"POSSIBLE\")",
"- else:",
"- print(\"IMPOSSIBLE\")",
"+ print(\"IMPOSSIBLE\")"
] | false | 0.069112 | 0.097773 | 0.706865 | [
"s678253435",
"s872917714"
] |
u489959379 | p02948 | python | s073426731 | s714029917 | 302 | 179 | 18,472 | 24,376 | Accepted | Accepted | 40.73 | import sys
input = sys.stdin.readline
import heapq
n, m = list(map(int, input().split()))
jobs = [[] for i in range(m)]
for i in range(n):
a, b = list(map(int, input().split()))
if a > m:
pass
else:
jobs[m - a].append(b)
if len(jobs) == 0:
print((0))
exit(0)
q = [... | import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, m = list(map(int, input().split()))
AB = [[] for _ in range(m)]
for _ in range(n):
a, b = list(map(int, input().split()))
... | 27 | 29 | 492 | 598 | import sys
input = sys.stdin.readline
import heapq
n, m = list(map(int, input().split()))
jobs = [[] for i in range(m)]
for i in range(n):
a, b = list(map(int, input().split()))
if a > m:
pass
else:
jobs[m - a].append(b)
if len(jobs) == 0:
print((0))
exit(0)
q = []
heapq.heapify(q)... | import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, m = list(map(int, input().split()))
AB = [[] for _ in range(m)]
for _ in range(n):
a, b = list(map(int, input().split()))
if a <= m... | false | 6.896552 | [
"+from heapq import heappush, heappop",
"+sys.setrecursionlimit(10**7)",
"-import heapq",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"-n, m = list(map(int, input().split()))",
"-jobs = [[] for i in range(m)]",
"-for i in range(n):",
"- a, b = list(map(int, input().split()))",
"- if a > m... | false | 0.040479 | 0.04589 | 0.882089 | [
"s073426731",
"s714029917"
] |
u659302753 | p02691 | python | s304318627 | s416280047 | 266 | 210 | 64,980 | 73,156 | Accepted | Accepted | 21.05 | from sys import stdin
from collections import Counter
def get_result(data):
N = data[0][0]
A = data[1]
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(N):
L[i] = i + A[i] + 1
R[i] = i + 1 - A[i]
L_cnt = Counter(L)
R_cnt = Counter(R)
an... | from sys import stdin
from collections import Counter
def get_result(data):
N = data[0][0]
A = data[1]
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(N):
L[i] = i + A[i] + 1
R[i] = i + 1 - A[i]
L_cnt = Counter(L)
R_cnt = Counter(R)
an... | 27 | 27 | 650 | 668 | from sys import stdin
from collections import Counter
def get_result(data):
N = data[0][0]
A = data[1]
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(N):
L[i] = i + A[i] + 1
R[i] = i + 1 - A[i]
L_cnt = Counter(L)
R_cnt = Counter(R)
ans = 0
max_ke... | from sys import stdin
from collections import Counter
def get_result(data):
N = data[0][0]
A = data[1]
L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(N):
L[i] = i + A[i] + 1
R[i] = i + 1 - A[i]
L_cnt = Counter(L)
R_cnt = Counter(R)
ans = 0
all_ke... | false | 0 | [
"- max_key = max(R_cnt.keys())",
"- for i in range(max_key + 1):",
"- ans += L_cnt[i] * R_cnt[i]",
"+ all_key = list(set(list(R_cnt.keys()) & list(L_cnt.keys())))",
"+ for key in all_key:",
"+ ans += L_cnt[key] * R_cnt[key]"
] | false | 0.039727 | 0.038325 | 1.036576 | [
"s304318627",
"s416280047"
] |
u561992253 | p03326 | python | s353743974 | s853302375 | 350 | 188 | 21,116 | 12,456 | Accepted | Accepted | 46.29 | import numpy as np
import itertools as it
n,m = list(map(int, input().split()))
xyz_l = []
for _ in range(n):
x,y,z = list(map(int, input().split()))
xyz_l.append((x,y,z))
xyz = np.array(xyz_l)
seed = ('+', '-')
pattern = list(it.product(seed, seed, seed))
ans = 0
for p in pattern:
totals ... | import numpy as np
import itertools as it
import functools as ft
n,m = list(map(int, input().split()))
xyz_l = []
for _ in range(n):
x,y,z = list(map(int, input().split()))
xyz_l.append((x,y,z))
xyzs = np.array(xyz_l)
plus = lambda x, y : x + y
minus = lambda x, y : x - y
seed = (plus, minus)... | 38 | 26 | 761 | 632 | import numpy as np
import itertools as it
n, m = list(map(int, input().split()))
xyz_l = []
for _ in range(n):
x, y, z = list(map(int, input().split()))
xyz_l.append((x, y, z))
xyz = np.array(xyz_l)
seed = ("+", "-")
pattern = list(it.product(seed, seed, seed))
ans = 0
for p in pattern:
totals = []
for... | import numpy as np
import itertools as it
import functools as ft
n, m = list(map(int, input().split()))
xyz_l = []
for _ in range(n):
x, y, z = list(map(int, input().split()))
xyz_l.append((x, y, z))
xyzs = np.array(xyz_l)
plus = lambda x, y: x + y
minus = lambda x, y: x - y
seed = (plus, minus)
pattern = np.a... | false | 31.578947 | [
"+import functools as ft",
"-xyz = np.array(xyz_l)",
"-seed = (\"+\", \"-\")",
"-pattern = list(it.product(seed, seed, seed))",
"-ans = 0",
"-for p in pattern:",
"- totals = []",
"- for (x, y, z) in xyz:",
"- t = 0",
"- if p[0] == \"+\":",
"- t += x",
"- e... | false | 0.532876 | 0.412598 | 1.291515 | [
"s353743974",
"s853302375"
] |
u057109575 | p02767 | python | s377744975 | s655270796 | 163 | 64 | 38,256 | 61,956 | Accepted | Accepted | 60.74 | N, *X = list(map(int, open(0).read().split()))
m = sum(X) // N
v1 = sum((v - m) ** 2 for v in X)
v2 = sum((v - m - 1) ** 2 for v in X)
print((min(v1, v2)))
|
N = int(eval(input()))
X = list(map(int, input().split()))
cand = sum(X) // N
ans0 = sum((v - cand) ** 2 for v in X)
ans1 = sum((v - cand - 1) ** 2 for v in X)
print((min(ans0, ans1)))
| 6 | 8 | 154 | 186 | N, *X = list(map(int, open(0).read().split()))
m = sum(X) // N
v1 = sum((v - m) ** 2 for v in X)
v2 = sum((v - m - 1) ** 2 for v in X)
print((min(v1, v2)))
| N = int(eval(input()))
X = list(map(int, input().split()))
cand = sum(X) // N
ans0 = sum((v - cand) ** 2 for v in X)
ans1 = sum((v - cand - 1) ** 2 for v in X)
print((min(ans0, ans1)))
| false | 25 | [
"-N, *X = list(map(int, open(0).read().split()))",
"-m = sum(X) // N",
"-v1 = sum((v - m) ** 2 for v in X)",
"-v2 = sum((v - m - 1) ** 2 for v in X)",
"-print((min(v1, v2)))",
"+N = int(eval(input()))",
"+X = list(map(int, input().split()))",
"+cand = sum(X) // N",
"+ans0 = sum((v - cand) ** 2 for v... | false | 0.038099 | 0.11311 | 0.336827 | [
"s377744975",
"s655270796"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.