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
u721316601
p02786
python
s900882596
s814423363
19
17
3,060
3,060
Accepted
Accepted
10.53
def solve(n): if n == 1: return 1 return 2 * solve(n//2) + 1 print((solve(int(eval(input())))))
def solve(n): if n in memo: return memo[n] memo[n] = 2*solve(n//2)+1 return memo[n] memo = {1:1} print((solve(int(eval(input())))))
5
9
101
146
def solve(n): if n == 1: return 1 return 2 * solve(n // 2) + 1 print((solve(int(eval(input())))))
def solve(n): if n in memo: return memo[n] memo[n] = 2 * solve(n // 2) + 1 return memo[n] memo = {1: 1} print((solve(int(eval(input())))))
false
44.444444
[ "- if n == 1:", "- return 1", "- return 2 * solve(n // 2) + 1", "+ if n in memo:", "+ return memo[n]", "+ memo[n] = 2 * solve(n // 2) + 1", "+ return memo[n]", "+memo = {1: 1}" ]
false
0.042605
0.042238
1.008688
[ "s900882596", "s814423363" ]
u814265211
p02743
python
s165505202
s902287658
303
172
59,844
38,384
Accepted
Accepted
43.23
from decimal import * getcontext().prec = 128 a, b, c = [int(i) for i in input().split()] print(("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No"))
a, b, c = [int(i) for i in input().split()] d = c - a - b print(('Yes' if d > 0 and d**2 > 4*a*b else 'No'))
6
3
181
108
from decimal import * getcontext().prec = 128 a, b, c = [int(i) for i in input().split()] print(("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No"))
a, b, c = [int(i) for i in input().split()] d = c - a - b print(("Yes" if d > 0 and d**2 > 4 * a * b else "No"))
false
50
[ "-from decimal import *", "-", "-getcontext().prec = 128", "-print((\"Yes\" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else \"No\"))", "+d = c - a - b", "+print((\"Yes\" if d > 0 and d**2 > 4 * a * b else \"No\"))" ]
false
0.039573
0.037752
1.048238
[ "s165505202", "s902287658" ]
u134019875
p03043
python
s777860028
s405451219
64
38
3,828
2,940
Accepted
Accepted
40.62
n, k = list(map(int, input().split())) L = [''] * n for i in range(1, n + 1): j = 0 while i * (2 ** j) < k: j += 1 L[i - 1] = j S = 0 for k in L: S += 1 / (2 ** k) print((S / n))
n, k = list(map(int, input().split())) ans = 0 for i in range(1, n+1): cnt = 0 while i < k: i *= 2 cnt += 1 ans += (0.5) ** cnt print((ans / n))
11
9
204
173
n, k = list(map(int, input().split())) L = [""] * n for i in range(1, n + 1): j = 0 while i * (2**j) < k: j += 1 L[i - 1] = j S = 0 for k in L: S += 1 / (2**k) print((S / n))
n, k = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): cnt = 0 while i < k: i *= 2 cnt += 1 ans += (0.5) ** cnt print((ans / n))
false
18.181818
[ "-L = [\"\"] * n", "+ans = 0", "- j = 0", "- while i * (2**j) < k:", "- j += 1", "- L[i - 1] = j", "-S = 0", "-for k in L:", "- S += 1 / (2**k)", "-print((S / n))", "+ cnt = 0", "+ while i < k:", "+ i *= 2", "+ cnt += 1", "+ ans += (0.5) ** cnt",...
false
0.19108
0.204929
0.93242
[ "s777860028", "s405451219" ]
u102461423
p03283
python
s394327794
s682651050
2,507
1,679
18,280
26,252
Accepted
Accepted
33.03
# count p<=x<=q and p<=y <=q # 長方形に含まれる格子点の数 import numpy as np N,M,Q = list(map(int,input().split())) cnt = [[0]*(N+1) for _ in range(N+1)] for _ in range(M): x,y = list(map(int,input().split())) cnt[x][y] += 1 cnt = np.cumsum(cnt,axis=0).cumsum(axis=1) for _ in range(Q): p,q = list(map(int,input...
# count p<=x<=q and p<=y <=q # 長方形に含まれる格子点の数 import numpy as np N,M,Q = list(map(int,input().split())) cnt = [[0]*(N+1) for _ in range(N+1)] for _ in range(M): x,y = list(map(int,input().split())) cnt[x][y] += 1 # cumsumだけnumpyを使って、添字アクセスするときはlistの方が速い cnt = np.cumsum(cnt,axis=0).cumsum(axis=1).tolist(...
20
21
403
458
# count p<=x<=q and p<=y <=q # 長方形に含まれる格子点の数 import numpy as np N, M, Q = list(map(int, input().split())) cnt = [[0] * (N + 1) for _ in range(N + 1)] for _ in range(M): x, y = list(map(int, input().split())) cnt[x][y] += 1 cnt = np.cumsum(cnt, axis=0).cumsum(axis=1) for _ in range(Q): p, q = list(map(int, ...
# count p<=x<=q and p<=y <=q # 長方形に含まれる格子点の数 import numpy as np N, M, Q = list(map(int, input().split())) cnt = [[0] * (N + 1) for _ in range(N + 1)] for _ in range(M): x, y = list(map(int, input().split())) cnt[x][y] += 1 # cumsumだけnumpyを使って、添字アクセスするときはlistの方が速い cnt = np.cumsum(cnt, axis=0).cumsum(axis=1).tol...
false
4.761905
[ "-cnt = np.cumsum(cnt, axis=0).cumsum(axis=1)", "+# cumsumだけnumpyを使って、添字アクセスするときはlistの方が速い", "+cnt = np.cumsum(cnt, axis=0).cumsum(axis=1).tolist()", "- x = cnt[q, q]", "- x -= cnt[q, p]", "- x -= cnt[p, q]", "- x += cnt[p, p]", "+ x = cnt[q][q]", "+ x -= cnt[q][p]", "+ x -= c...
false
0.769247
0.450368
1.708041
[ "s394327794", "s682651050" ]
u174394352
p03493
python
s487010849
s463287775
178
17
38,384
2,940
Accepted
Accepted
90.45
s=eval(input()) print((s.count('1')))
a=list(map(int,list(eval(input())))) b=0 for i in a: if i==1: b+=1 else: pass print(b)
2
8
30
93
s = eval(input()) print((s.count("1")))
a = list(map(int, list(eval(input())))) b = 0 for i in a: if i == 1: b += 1 else: pass print(b)
false
75
[ "-s = eval(input())", "-print((s.count(\"1\")))", "+a = list(map(int, list(eval(input()))))", "+b = 0", "+for i in a:", "+ if i == 1:", "+ b += 1", "+ else:", "+ pass", "+print(b)" ]
false
0.056334
0.03932
1.43271
[ "s487010849", "s463287775" ]
u399721252
p03044
python
s205733169
s191346560
1,841
475
67,760
68,716
Accepted
Accepted
74.2
import sys input = sys.stdin.readline n = int(eval(input())) connect_list = [ [] for i in range(n) ] distance_list = [ -1 for i in range(n) ] color_list = [ "Gray" for i in range(n) ] distance_list[0] = 0 for i in range(n-1): u, v, w = [ int(v) for v in input().split() ] w %= 2 connect_list[u-1].appe...
import sys input = sys.stdin.readline n = int(eval(input())) connect_list = [ [] for i in range(n) ] distance_list = [ -1 for i in range(n) ] color_list = [ "Gray" for i in range(n) ] distance_list[0] = 0 for i in range(n-1): u, v, w = [ int(v) for v in input().split() ] w %= 2 connect_list[u-1].ap...
30
34
641
662
import sys input = sys.stdin.readline n = int(eval(input())) connect_list = [[] for i in range(n)] distance_list = [-1 for i in range(n)] color_list = ["Gray" for i in range(n)] distance_list[0] = 0 for i in range(n - 1): u, v, w = [int(v) for v in input().split()] w %= 2 connect_list[u - 1].append((v - 1,...
import sys input = sys.stdin.readline n = int(eval(input())) connect_list = [[] for i in range(n)] distance_list = [-1 for i in range(n)] color_list = ["Gray" for i in range(n)] distance_list[0] = 0 for i in range(n - 1): u, v, w = [int(v) for v in input().split()] w %= 2 connect_list[u - 1].append((v - 1,...
false
11.764706
[ "-while search_list != []:", "- s = search_list[0]", "+t = 0", "+stop = 0", "+while t < len(search_list):", "+ s = search_list[t]", "+ stop = 0", "- del search_list[0]", "+ t += 1" ]
false
0.036163
0.035669
1.013852
[ "s205733169", "s191346560" ]
u777923818
p03425
python
s518125106
s258539301
203
165
3,064
3,316
Accepted
Accepted
18.72
# -*- coding: utf-8 -*- from itertools import combinations N = int(eval(input())) C = [0, 0, 0, 0, 0] march = set(list("MARCH")) for _ in range(N): S = input()[0] if S in march: C["MARCH".index(S)] += 1 ans = 0 for a, b, c in combinations(list(range(5)), r=3): ans += C[a]*C[b]*C[c] pri...
# -*- coding: utf-8 -*- from collections import defaultdict from itertools import combinations N = int(eval(input())) C = [0, 0, 0, 0, 0, 0] D = defaultdict(int) for i, m in enumerate("MARCH", start=1): D[m] = i for _ in range(N): C[D[input()[0]]] += 1 ans = 0 for a, b, c in combinations(list(ran...
14
16
316
363
# -*- coding: utf-8 -*- from itertools import combinations N = int(eval(input())) C = [0, 0, 0, 0, 0] march = set(list("MARCH")) for _ in range(N): S = input()[0] if S in march: C["MARCH".index(S)] += 1 ans = 0 for a, b, c in combinations(list(range(5)), r=3): ans += C[a] * C[b] * C[c] print(ans)
# -*- coding: utf-8 -*- from collections import defaultdict from itertools import combinations N = int(eval(input())) C = [0, 0, 0, 0, 0, 0] D = defaultdict(int) for i, m in enumerate("MARCH", start=1): D[m] = i for _ in range(N): C[D[input()[0]]] += 1 ans = 0 for a, b, c in combinations(list(range(1, 6)), r=3...
false
12.5
[ "+from collections import defaultdict", "-C = [0, 0, 0, 0, 0]", "-march = set(list(\"MARCH\"))", "+C = [0, 0, 0, 0, 0, 0]", "+D = defaultdict(int)", "+for i, m in enumerate(\"MARCH\", start=1):", "+ D[m] = i", "- S = input()[0]", "- if S in march:", "- C[\"MARCH\".index(S)] += 1", ...
false
0.036708
0.035637
1.030047
[ "s518125106", "s258539301" ]
u411203878
p03380
python
s562365063
s342082632
241
106
62,704
85,732
Accepted
Accepted
56.02
n=int(eval(input())) t = list(map(int,input().split())) t.sort() a1 = max(t) ans = 100000000000000 memo = 0 for i in t: if ans > abs(a1/2-i): ans = abs(a1/2-i) memo = i print((a1, memo))
n=int(eval(input())) t = list(map(int,input().split())) t.sort() max_value = t[-1] mid_value = 0 for a in t: if abs(max_value/2-a) < abs(max_value/2-mid_value): mid_value = a print((max_value, mid_value))
15
15
220
228
n = int(eval(input())) t = list(map(int, input().split())) t.sort() a1 = max(t) ans = 100000000000000 memo = 0 for i in t: if ans > abs(a1 / 2 - i): ans = abs(a1 / 2 - i) memo = i print((a1, memo))
n = int(eval(input())) t = list(map(int, input().split())) t.sort() max_value = t[-1] mid_value = 0 for a in t: if abs(max_value / 2 - a) < abs(max_value / 2 - mid_value): mid_value = a print((max_value, mid_value))
false
0
[ "-a1 = max(t)", "-ans = 100000000000000", "-memo = 0", "-for i in t:", "- if ans > abs(a1 / 2 - i):", "- ans = abs(a1 / 2 - i)", "- memo = i", "-print((a1, memo))", "+max_value = t[-1]", "+mid_value = 0", "+for a in t:", "+ if abs(max_value / 2 - a) < abs(max_value / 2 - mi...
false
0.070449
0.007673
9.180911
[ "s562365063", "s342082632" ]
u027685417
p02861
python
s928023876
s864393391
433
17
8,180
3,188
Accepted
Accepted
96.07
N = int(eval(input())) coordinates = [] for i in range(N): x, y = list(map(int, input().split())) coordinates.append((x, y)) import itertools paths = list(itertools.permutations(list(range(N)))) total_length = 0 for i in paths: for j in range(N - 1): x1, y1 = coordinates[i[j]] ...
n = int(eval(input())) C = [] for _ in range(n): x, y = list(map(int, input().split())) C.append((x, y)) l = 0 for i in range(n - 1): for j in range(i + 1, n): xi, yi = C[i][0], C[i][1] xj, yj = C[j][0], C[j][1] l += ((xi - xj)**2 + (yi - yj)**2)**0.5 print(((2 * l) ...
19
15
465
312
N = int(eval(input())) coordinates = [] for i in range(N): x, y = list(map(int, input().split())) coordinates.append((x, y)) import itertools paths = list(itertools.permutations(list(range(N)))) total_length = 0 for i in paths: for j in range(N - 1): x1, y1 = coordinates[i[j]] x2, y2 = coor...
n = int(eval(input())) C = [] for _ in range(n): x, y = list(map(int, input().split())) C.append((x, y)) l = 0 for i in range(n - 1): for j in range(i + 1, n): xi, yi = C[i][0], C[i][1] xj, yj = C[j][0], C[j][1] l += ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5 print(((2 * l) / n))
false
21.052632
[ "-N = int(eval(input()))", "-coordinates = []", "-for i in range(N):", "+n = int(eval(input()))", "+C = []", "+for _ in range(n):", "- coordinates.append((x, y))", "-import itertools", "-", "-paths = list(itertools.permutations(list(range(N))))", "-total_length = 0", "-for i in paths:", "...
false
0.112584
0.039812
2.827894
[ "s928023876", "s864393391" ]
u707124227
p02787
python
s192576033
s573512961
606
357
45,532
91,532
Accepted
Accepted
41.09
h,n=list(map(int,input().split())) ab=[list(map(int,input().split()))for _ in range(n)] maxa=max([a for a,b in ab]) maxmp=pow(10,8) dp=[maxmp]*(h+maxa) # dp[i]:ダメージをぴったりi与えるのに必要な最小魔力 dp[0]=0 for i in range(h+maxa): b=[dp[i-a]+b for a,b in ab if i-a>=0] dp[i]=min(dp[i],min(b)) if b else dp[i] print((min(dp[...
h,n=list(map(int,input().split())) ab=[list(map(int,input().split())) for _ in range(n)] inf=float('inf') dp=[inf]*(h+1) # dp[i]:ダメージiを与えるための最小魔力 dp[0]=0 for a,b in ab: # a:ダメージ,b:魔力 ndp=[inf]*(h+1) ndp[0]=0 for i in range(1,h+1): ndp[i]=min(dp[i],ndp[max(0,i-a)]+b) dp=ndp print((dp[h]))
10
14
319
307
h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] maxa = max([a for a, b in ab]) maxmp = pow(10, 8) dp = [maxmp] * (h + maxa) # dp[i]:ダメージをぴったりi与えるのに必要な最小魔力 dp[0] = 0 for i in range(h + maxa): b = [dp[i - a] + b for a, b in ab if i - a >= 0] dp[i] = min(dp[i], min(...
h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] inf = float("inf") dp = [inf] * (h + 1) # dp[i]:ダメージiを与えるための最小魔力 dp[0] = 0 for a, b in ab: # a:ダメージ,b:魔力 ndp = [inf] * (h + 1) ndp[0] = 0 for i in range(1, h + 1): ndp[i] = min(dp[i], ndp[max(0, i - a...
false
28.571429
[ "-maxa = max([a for a, b in ab])", "-maxmp = pow(10, 8)", "-dp = [maxmp] * (h + maxa) # dp[i]:ダメージをぴったりi与えるのに必要な最小魔力", "+inf = float(\"inf\")", "+dp = [inf] * (h + 1)", "+# dp[i]:ダメージiを与えるための最小魔力", "-for i in range(h + maxa):", "- b = [dp[i - a] + b for a, b in ab if i - a >= 0]", "- dp[i] = ...
false
0.163141
0.1377
1.184752
[ "s192576033", "s573512961" ]
u651663683
p02936
python
s524214567
s337001434
1,262
763
65,288
161,812
Accepted
Accepted
39.54
n,q=list(map(int,input().split())) e=[[] for i in range(n)] for i in range(n-1): a,b=[int(x)-1 for x in input().split()] e[a].append(b) e[b].append(a) ps=[0 for i in range(n)] for i in range(q): p,x=list(map(int,input().split())) ps[p-1]+=x s=[-1 for i in range(n)] sc=[0] s[0]=0 while sc: ns...
n,q=list(map(int,input().split())) e=[[] for i in range(n)] for i in range(n-1): a,b=[int(x)-1 for x in input().split()] e[a].append(b) e[b].append(a) ps=[0 for i in range(n)] for i in range(q): p,x=list(map(int,input().split())) ps[p-1]+=x s=[-1 for i in range(n)] sc=[0] s[0]=0 while sc: ns...
28
26
503
473
n, q = list(map(int, input().split())) e = [[] for i in range(n)] for i in range(n - 1): a, b = [int(x) - 1 for x in input().split()] e[a].append(b) e[b].append(a) ps = [0 for i in range(n)] for i in range(q): p, x = list(map(int, input().split())) ps[p - 1] += x s = [-1 for i in range(n)] sc = [0] ...
n, q = list(map(int, input().split())) e = [[] for i in range(n)] for i in range(n - 1): a, b = [int(x) - 1 for x in input().split()] e[a].append(b) e[b].append(a) ps = [0 for i in range(n)] for i in range(q): p, x = list(map(int, input().split())) ps[p - 1] += x s = [-1 for i in range(n)] sc = [0] ...
false
7.142857
[ "-r = \"\"", "-for i in range(n):", "- r += str(s[i]) + \" \"", "-print((r[:-1]))", "+print((\" \".join(map(str, s))))" ]
false
0.089768
0.069644
1.288949
[ "s524214567", "s337001434" ]
u806403461
p02641
python
s879823148
s145957579
24
21
9,132
9,188
Accepted
Accepted
12.5
x, n = list(map(int, input().split())) p = list(map(int, input().split())) p = set(p) diff = 101 indx = 0 if n != 0: for now in range(0, 102): if now not in p: now_diff = abs(now - x) if diff > now_diff: diff = now_diff indx = now ...
x, n = list(map(int, input().split())) p = list(map(int, input().split())) p = set(p) diff = 101 indx = 0 ans = (101, 0) if n != 0: for now in range(0, 102): if now not in p: now_diff = abs(now - x) ans = min(ans, (now_diff, now)) print((ans[1])) else: print(...
19
16
388
315
x, n = list(map(int, input().split())) p = list(map(int, input().split())) p = set(p) diff = 101 indx = 0 if n != 0: for now in range(0, 102): if now not in p: now_diff = abs(now - x) if diff > now_diff: diff = now_diff indx = now else: ...
x, n = list(map(int, input().split())) p = list(map(int, input().split())) p = set(p) diff = 101 indx = 0 ans = (101, 0) if n != 0: for now in range(0, 102): if now not in p: now_diff = abs(now - x) ans = min(ans, (now_diff, now)) print((ans[1])) else: print(x)
false
15.789474
[ "+ans = (101, 0)", "- if diff > now_diff:", "- diff = now_diff", "- indx = now", "- else:", "- break", "- print(indx)", "+ ans = min(ans, (now_diff, now))", "+ print((ans[1]))" ]
false
0.05381
0.082868
0.649348
[ "s879823148", "s145957579" ]
u753803401
p03289
python
s313526381
s197278191
19
17
3,060
2,940
Accepted
Accepted
10.53
s = eval(input()) cnt = 0 for i in range(len(s)): if i == 0: if s[i] != "A": print("WA") exit() else: if s[i] == "C" and 2 <= i <= len(s) - 2: cnt += 1 else: if s[i] != s[i].lower(): print("WA") ...
s = eval(input()) if s[0] == "A" and s[2:-1].count("C") == 1: for i in range(len(s)): if s[i] != "A" and s[i] != "C": if s[i] != s[i].lower(): print("WA") exit() print("AC") else: print("WA")
18
10
376
259
s = eval(input()) cnt = 0 for i in range(len(s)): if i == 0: if s[i] != "A": print("WA") exit() else: if s[i] == "C" and 2 <= i <= len(s) - 2: cnt += 1 else: if s[i] != s[i].lower(): print("WA") exit() if cnt...
s = eval(input()) if s[0] == "A" and s[2:-1].count("C") == 1: for i in range(len(s)): if s[i] != "A" and s[i] != "C": if s[i] != s[i].lower(): print("WA") exit() print("AC") else: print("WA")
false
44.444444
[ "-cnt = 0", "-for i in range(len(s)):", "- if i == 0:", "- if s[i] != \"A\":", "- print(\"WA\")", "- exit()", "- else:", "- if s[i] == \"C\" and 2 <= i <= len(s) - 2:", "- cnt += 1", "- else:", "+if s[0] == \"A\" and s[2:-1].count(\"C\"...
false
0.04713
0.04699
1.002994
[ "s313526381", "s197278191" ]
u223646582
p03096
python
s871071359
s732779219
523
254
29,796
91,232
Accepted
Accepted
51.43
from collections import defaultdict N=int(eval(input())) C=[int(eval(input())) for _ in range(N)] d = defaultdict(int) ans=1 for i,c in enumerate(C): if i>=1 and C[i-1]==C[i]: continue else: ans+=d[c] d[c]=ans ans%=10**9+7 d[c]%=10**9+7 print(...
MOD = 10**9 + 7 N = int(eval(input())) C = [int(eval(input())) for _ in range(N)] L = [-1]*(2*10**5+10) dp = [-1]*(2*10**5+10) dp[0] = 1 for i in range(N): if L[C[i]] == -1: dp[i+1] = dp[i] elif C[i] == C[i-1]: dp[i+1] = dp[i] else: dp[i+1] = dp[i]+dp[L[C[i]]] dp...
18
18
312
354
from collections import defaultdict N = int(eval(input())) C = [int(eval(input())) for _ in range(N)] d = defaultdict(int) ans = 1 for i, c in enumerate(C): if i >= 1 and C[i - 1] == C[i]: continue else: ans += d[c] d[c] = ans ans %= 10**9 + 7 d[c] %= 10**9 + 7 print(ans...
MOD = 10**9 + 7 N = int(eval(input())) C = [int(eval(input())) for _ in range(N)] L = [-1] * (2 * 10**5 + 10) dp = [-1] * (2 * 10**5 + 10) dp[0] = 1 for i in range(N): if L[C[i]] == -1: dp[i + 1] = dp[i] elif C[i] == C[i - 1]: dp[i + 1] = dp[i] else: dp[i + 1] = dp[i] + dp[L[C[i]]] ...
false
0
[ "-from collections import defaultdict", "-", "+MOD = 10**9 + 7", "-d = defaultdict(int)", "-ans = 1", "-for i, c in enumerate(C):", "- if i >= 1 and C[i - 1] == C[i]:", "- continue", "+L = [-1] * (2 * 10**5 + 10)", "+dp = [-1] * (2 * 10**5 + 10)", "+dp[0] = 1", "+for i in range(N):",...
false
0.038176
0.038487
0.991913
[ "s871071359", "s732779219" ]
u386819480
p02779
python
s127169270
s148516235
158
128
46,256
40,384
Accepted
Accepted
18.99
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1<<32 YES = "YES" # type: str NO = "NO" # type: str def solve(N: int, A: "List[int]"): from collections import Counter c = Counter(A) if len([k for k,v in list(c.items()) if v != 1]) == 0: print(YES) else: ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1<<32 YES = "YES" # type: str NO = "NO" # type: str def solve(N: int, A: "List[int]"): if len(list(set(A))) == N: print(YES) else: print(NO) return def main(): def iterate_tokens(): ...
31
29
687
608
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1 << 32 YES = "YES" # type: str NO = "NO" # type: str def solve(N: int, A: "List[int]"): from collections import Counter c = Counter(A) if len([k for k, v in list(c.items()) if v != 1]) == 0: print(YES) else: p...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1 << 32 YES = "YES" # type: str NO = "NO" # type: str def solve(N: int, A: "List[int]"): if len(list(set(A))) == N: print(YES) else: print(NO) return def main(): def iterate_tokens(): for line in sys.s...
false
6.451613
[ "- from collections import Counter", "-", "- c = Counter(A)", "- if len([k for k, v in list(c.items()) if v != 1]) == 0:", "+ if len(list(set(A))) == N:" ]
false
0.044358
0.152077
0.29168
[ "s127169270", "s148516235" ]
u467736898
p02574
python
s344687115
s480190618
1,756
1,236
335,700
308,624
Accepted
Accepted
29.61
from itertools import groupby class Osa_k: def __init__(self, n_max): self.min_factor = min_factor = list(range(n_max+1)) for i in range(2, int(n_max**0.5)+1): if min_factor[i] == i: for j in range(i*i, n_max+1, i): if min_factor[j] == j: ...
def numba_compile(numba_config): import os, sys if sys.argv[-1] == "ONLINE_JUDGE": from numba import njit from numba.pycc import CC cc = CC("my_module") for func, signature in numba_config: globals()[func.__name__] = njit(signature)(func) cc.export...
48
78
1,339
2,309
from itertools import groupby class Osa_k: def __init__(self, n_max): self.min_factor = min_factor = list(range(n_max + 1)) for i in range(2, int(n_max**0.5) + 1): if min_factor[i] == i: for j in range(i * i, n_max + 1, i): if min_factor[j] == j: ...
def numba_compile(numba_config): import os, sys if sys.argv[-1] == "ONLINE_JUDGE": from numba import njit from numba.pycc import CC cc = CC("my_module") for func, signature in numba_config: globals()[func.__name__] = njit(signature)(func) cc.export(func....
false
38.461538
[ "-from itertools import groupby", "+def numba_compile(numba_config):", "+ import os, sys", "+", "+ if sys.argv[-1] == \"ONLINE_JUDGE\":", "+ from numba import njit", "+ from numba.pycc import CC", "+", "+ cc = CC(\"my_module\")", "+ for func, signature in numba_co...
false
0.811668
0.19955
4.067496
[ "s344687115", "s480190618" ]
u102461423
p02931
python
s192435408
s701337667
573
480
100,776
101,608
Accepted
Accepted
16.23
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import operator N,H,W = list(map(int,readline().split())) RCA = [tuple(int(x) for x in line.split()) for line in readlines()] RCA.sort(key = operator.itemgetter(2), reverse=True) root = li...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) import operator N,H,W = list(map(int,readline().split())) m = list(map(int,read().split())) RCA = sorted(zip(m,m,m),key=operator.itemgetter(2),reverse=True) roo...
48
48
1,048
1,045
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) import operator N, H, W = list(map(int, readline().split())) RCA = [tuple(int(x) for x in line.split()) for line in readlines()] RCA.sort(key=operator.itemgetter(2), reverse=True) root = list(range(H + ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) import operator N, H, W = list(map(int, readline().split())) m = list(map(int, read().split())) RCA = sorted(zip(m, m, m), key=operator.itemgetter(2), reverse=True) root = l...
false
0
[ "+read = sys.stdin.buffer.read", "-RCA = [tuple(int(x) for x in line.split()) for line in readlines()]", "-RCA.sort(key=operator.itemgetter(2), reverse=True)", "+m = list(map(int, read().split()))", "+RCA = sorted(zip(m, m, m), key=operator.itemgetter(2), reverse=True)" ]
false
0.038063
0.037929
1.003515
[ "s192435408", "s701337667" ]
u703196441
p02416
python
s432178973
s419924572
20
10
4,292
4,196
Accepted
Accepted
50
from functools import reduce while 1: n = input() if n == '0': break; print(reduce(lambda x,y: x+int(y), n, 0))
while 1: x = input() if x == '0': break; print(sum([int(d) for d in x]))
4
4
100
90
from functools import reduce while 1: n = input() if n == "0": break print(reduce(lambda x, y: x + int(y), n, 0))
while 1: x = input() if x == "0": break print(sum([int(d) for d in x]))
false
0
[ "-from functools import reduce", "-", "- n = input()", "- if n == \"0\":", "+ x = input()", "+ if x == \"0\":", "- print(reduce(lambda x, y: x + int(y), n, 0))", "+ print(sum([int(d) for d in x]))" ]
false
0.036946
0.03306
1.117542
[ "s432178973", "s419924572" ]
u802963389
p02744
python
s576198675
s210997818
426
109
42,092
16,312
Accepted
Accepted
74.41
import sys sys.setrecursionlimit(10 ** 6) def create_li(li): if len(li) >= n: lis.append(li) return p = max(li) for i in range(1, p + 2): cp = li[:] cp.append(i) # print(cp) create_li(cp) lis = [] n = int(eval(input())) pre = [1] create_li(pre) lis.sort() al = ["a",...
from collections import deque n = int(eval(input())) def dfs(n): stack = deque() stack.append("a") while stack: q = stack.popleft() if len(q) == n: ans.append(q) if len(q) < n: for i in range(ord("a"), ord(max(q)) + 2): stack.append(q + chr(i)) ans = [] dfs(...
26
19
465
341
import sys sys.setrecursionlimit(10**6) def create_li(li): if len(li) >= n: lis.append(li) return p = max(li) for i in range(1, p + 2): cp = li[:] cp.append(i) # print(cp) create_li(cp) lis = [] n = int(eval(input())) pre = [1] create_li(pre) lis.sort()...
from collections import deque n = int(eval(input())) def dfs(n): stack = deque() stack.append("a") while stack: q = stack.popleft() if len(q) == n: ans.append(q) if len(q) < n: for i in range(ord("a"), ord(max(q)) + 2): stack.append(q + chr(...
false
26.923077
[ "-import sys", "+from collections import deque", "-sys.setrecursionlimit(10**6)", "+n = int(eval(input()))", "-def create_li(li):", "- if len(li) >= n:", "- lis.append(li)", "- return", "- p = max(li)", "- for i in range(1, p + 2):", "- cp = li[:]", "- cp.a...
false
0.040717
0.053177
0.765698
[ "s576198675", "s210997818" ]
u353797797
p03162
python
s969843916
s784718685
385
228
3,060
3,060
Accepted
Accepted
40.78
n=int(eval(input())) a,b,c=list(map(int,input().split())) for i in range(n-1): a1, b1, c1 = list(map(int, input().split())) a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b) print((max(a,b,c)))
import sys input=sys.stdin.readline n=int(eval(input())) a,b,c=list(map(int,input().split())) for i in range(n-1): a1, b1, c1 = list(map(int, input().split())) a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b) print((max(a,b,c)))
6
9
178
218
n = int(eval(input())) a, b, c = list(map(int, input().split())) for i in range(n - 1): a1, b1, c1 = list(map(int, input().split())) a, b, c = a1 + max(b, c), b1 + max(a, c), c1 + max(a, b) print((max(a, b, c)))
import sys input = sys.stdin.readline n = int(eval(input())) a, b, c = list(map(int, input().split())) for i in range(n - 1): a1, b1, c1 = list(map(int, input().split())) a, b, c = a1 + max(b, c), b1 + max(a, c), c1 + max(a, b) print((max(a, b, c)))
false
33.333333
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.161718
0.087227
1.853995
[ "s969843916", "s784718685" ]
u145950990
p03073
python
s713437792
s404671595
81
48
5,160
3,188
Accepted
Accepted
40.74
import copy s = list(eval(input())) c = copy.copy(s) n = len(s) cnt1 = cnt2 = 0 for i in range(n-1): if c[i+1]==c[i]: cnt1 += 1 c[i+1] = '0' if c[i+1]=='1' else '1' s[0] = '0' if s[0]=='1' else '1' cnt2+=1 for i in range(1,n): if s[i-1]==s[i]: cnt2 += 1 s[i] = '0' i...
s = eval(input()) a1 = a2 = 0 for i in range(len(s)): if i%2==0: if s[i]=='1':a1+=1 else:a2+=1 else: if s[i]=='0':a1+=1 else:a2+=1 print((min(a1,a2)))
16
10
357
191
import copy s = list(eval(input())) c = copy.copy(s) n = len(s) cnt1 = cnt2 = 0 for i in range(n - 1): if c[i + 1] == c[i]: cnt1 += 1 c[i + 1] = "0" if c[i + 1] == "1" else "1" s[0] = "0" if s[0] == "1" else "1" cnt2 += 1 for i in range(1, n): if s[i - 1] == s[i]: cnt2 += 1 s[i]...
s = eval(input()) a1 = a2 = 0 for i in range(len(s)): if i % 2 == 0: if s[i] == "1": a1 += 1 else: a2 += 1 else: if s[i] == "0": a1 += 1 else: a2 += 1 print((min(a1, a2)))
false
37.5
[ "-import copy", "-", "-s = list(eval(input()))", "-c = copy.copy(s)", "-n = len(s)", "-cnt1 = cnt2 = 0", "-for i in range(n - 1):", "- if c[i + 1] == c[i]:", "- cnt1 += 1", "- c[i + 1] = \"0\" if c[i + 1] == \"1\" else \"1\"", "-s[0] = \"0\" if s[0] == \"1\" else \"1\"", "-cnt...
false
0.007701
0.054214
0.142046
[ "s713437792", "s404671595" ]
u608088992
p02953
python
s932967772
s463013487
77
64
14,396
14,252
Accepted
Accepted
16.88
N = int(eval(input())) H = [int(h) for h in input().split()] for i in reversed(list(range(1, N))): if H[i] >= H[i-1]: continue elif H[i] == H[i-1] - 1: H[i-1] -= 1 else: print("No") break else: print("Yes")
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) H = [int(h) for h in input().split()] for i in reversed(list(range(N-1))): if H[i] > H[i + 1]: H[i] -= 1 if H[i] > H[i + 1]: print("No") break else: print("Yes") retu...
10
17
233
355
N = int(eval(input())) H = [int(h) for h in input().split()] for i in reversed(list(range(1, N))): if H[i] >= H[i - 1]: continue elif H[i] == H[i - 1] - 1: H[i - 1] -= 1 else: print("No") break else: print("Yes")
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) H = [int(h) for h in input().split()] for i in reversed(list(range(N - 1))): if H[i] > H[i + 1]: H[i] -= 1 if H[i] > H[i + 1]: print("No") break else: print("Yes") ...
false
41.176471
[ "-N = int(eval(input()))", "-H = [int(h) for h in input().split()]", "-for i in reversed(list(range(1, N))):", "- if H[i] >= H[i - 1]:", "- continue", "- elif H[i] == H[i - 1] - 1:", "- H[i - 1] -= 1", "+import sys", "+", "+", "+def solve():", "+ input = sys.stdin.readli...
false
0.068911
0.036153
1.906077
[ "s932967772", "s463013487" ]
u498487134
p03032
python
s886154006
s235281885
195
137
40,304
69,804
Accepted
Accepted
29.74
#import heapq import copy N,K=list(map(int,input().split())) V=list(map(int,input().split())) V.append(0)#右から取る時用 S=[0]*(N+1)#累積和 for i in range(N): S[i+1]=S[i]+V[i] #左からi番目まで見たときに,持っている負の宝石 left=[[] for _ in range(N+1)] for i in range(N): left[i+1]=copy.deepcopy(left[i]) if V[i]<0: ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,K=MI() V=LI() ans=0 import heapq #左からa個,右からb個とって,あまり分で負数を捨てる for a ...
44
46
928
1,070
# import heapq import copy N, K = list(map(int, input().split())) V = list(map(int, input().split())) V.append(0) # 右から取る時用 S = [0] * (N + 1) # 累積和 for i in range(N): S[i + 1] = S[i] + V[i] # 左からi番目まで見たときに,持っている負の宝石 left = [[] for _ in range(N + 1)] for i in range(N): left[i + 1] = copy.deepcopy(left[i]) ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N, K = MI() V = LI() ans = 0 import heapq # 左からa個,右からb個とって,あまり分で負数を捨てる ...
false
4.347826
[ "-# import heapq", "-import copy", "+import sys", "-N, K = list(map(int, input().split()))", "-V = list(map(int, input().split()))", "-V.append(0) # 右から取る時用", "-S = [0] * (N + 1) # 累積和", "-for i in range(N):", "- S[i + 1] = S[i] + V[i]", "-# 左からi番目まで見たときに,持っている負の宝石", "-left = [[] for _ in r...
false
0.047109
0.043917
1.072683
[ "s886154006", "s235281885" ]
u130900604
p02785
python
s595909870
s897248557
309
186
90,572
110,324
Accepted
Accepted
39.81
n,k=list(map(int,input().split())) h=sorted(list(map(int,input().split()))) # print(h) new_h=h[0:max(n-k,0)] # print(new_h) print((sum(new_h)))
n,k,*h=list(map(int,open(0).read().split())) if k>=n: print((0)) exit() h.sort(reverse=True) for i in range(k): h[i]=0 print((sum(h)))
11
8
151
137
n, k = list(map(int, input().split())) h = sorted(list(map(int, input().split()))) # print(h) new_h = h[0 : max(n - k, 0)] # print(new_h) print((sum(new_h)))
n, k, *h = list(map(int, open(0).read().split())) if k >= n: print((0)) exit() h.sort(reverse=True) for i in range(k): h[i] = 0 print((sum(h)))
false
27.272727
[ "-n, k = list(map(int, input().split()))", "-h = sorted(list(map(int, input().split())))", "-# print(h)", "-new_h = h[0 : max(n - k, 0)]", "-# print(new_h)", "-print((sum(new_h)))", "+n, k, *h = list(map(int, open(0).read().split()))", "+if k >= n:", "+ print((0))", "+ exit()", "+h.sort(re...
false
0.044776
0.063552
0.704555
[ "s595909870", "s897248557" ]
u560867850
p03200
python
s271220482
s016160027
67
33
3,500
3,500
Accepted
Accepted
50.75
import sys # input = sys.stdin.readline def main(): s = eval(input()) total = 0 for i in range(len(s)-1): if s[i] == "B": total += 1 if s[i] == "B" and s[i+1] == "W": yield total else: if s[i] == "W" and s[i+1] == "W": ...
import sys # input = sys.stdin.readline def main(): s = eval(input()) b = 0 for c in s: if c == "B": b += 1 else: yield b print((sum(main())))
17
14
358
202
import sys # input = sys.stdin.readline def main(): s = eval(input()) total = 0 for i in range(len(s) - 1): if s[i] == "B": total += 1 if s[i] == "B" and s[i + 1] == "W": yield total else: if s[i] == "W" and s[i + 1] == "W": ...
import sys # input = sys.stdin.readline def main(): s = eval(input()) b = 0 for c in s: if c == "B": b += 1 else: yield b print((sum(main())))
false
17.647059
[ "- total = 0", "- for i in range(len(s) - 1):", "- if s[i] == \"B\":", "- total += 1", "- if s[i] == \"B\" and s[i + 1] == \"W\":", "- yield total", "+ b = 0", "+ for c in s:", "+ if c == \"B\":", "+ b += 1", "- ...
false
0.03832
0.045717
0.838217
[ "s271220482", "s016160027" ]
u237991875
p02396
python
s457992481
s163642826
60
50
6,248
6,692
Accepted
Accepted
16.67
i = 1 n = 1 while n != 0: n = int(input()) if n == 0: continue print("Case %d: %d" %(i, n)) i += 1
cases = [] n = 1 while n != 0: n = int(input()) if n == 0: continue cases.append(n) for i in range(len(cases)): print("Case %d: %d" %(i + 1, cases[i]))
8
11
114
172
i = 1 n = 1 while n != 0: n = int(input()) if n == 0: continue print("Case %d: %d" % (i, n)) i += 1
cases = [] n = 1 while n != 0: n = int(input()) if n == 0: continue cases.append(n) for i in range(len(cases)): print("Case %d: %d" % (i + 1, cases[i]))
false
27.272727
[ "-i = 1", "+cases = []", "- print(\"Case %d: %d\" % (i, n))", "- i += 1", "+ cases.append(n)", "+for i in range(len(cases)):", "+ print(\"Case %d: %d\" % (i + 1, cases[i]))" ]
false
0.035975
0.035332
1.018206
[ "s457992481", "s163642826" ]
u268318377
p02678
python
s342587961
s786364082
1,122
1,032
57,640
42,008
Accepted
Accepted
8.02
import sys readline = sys.stdin.buffer.readline read = sys.stdin.buffer.read N, M = list(map(int, readline().split())) m = list(map(int, read().split())) AB = list(zip(m, m)) graph = [[] for _ in range(N+1)] for a, b in AB: graph[a].append(b) graph[b].append(a) root = 1 q = [root] checked = [0] ...
import sys readline = sys.stdin.buffer.readline N, M = list(map(int, readline().split())) ans = [0] * (N+1) graph = [[] for _ in range(N+1)] for _ in range(M): a, b = list(map(int, readline().split())) graph[a].append(b) graph[b].append(a) root = 1 q = [root] checked = [0] * (N + 1) checke...
39
28
773
537
import sys readline = sys.stdin.buffer.readline read = sys.stdin.buffer.read N, M = list(map(int, readline().split())) m = list(map(int, read().split())) AB = list(zip(m, m)) graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) root = 1 q = [root] checked = [0] * (N + 1) che...
import sys readline = sys.stdin.buffer.readline N, M = list(map(int, readline().split())) ans = [0] * (N + 1) graph = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, readline().split())) graph[a].append(b) graph[b].append(a) root = 1 q = [root] checked = [0] * (N + 1) checked[root] = 1 w...
false
28.205128
[ "-read = sys.stdin.buffer.read", "-m = list(map(int, read().split()))", "-AB = list(zip(m, m))", "+ans = [0] * (N + 1)", "-for a, b in AB:", "+for _ in range(M):", "+ a, b = list(map(int, readline().split()))", "-order = []", "-D = [0 for _ in range(N + 1)]", "-d = 0", "- d = D[x]", "- ...
false
0.037476
0.066386
0.564507
[ "s342587961", "s786364082" ]
u762420987
p03127
python
s066895205
s363546380
368
79
83,992
14,184
Accepted
Accepted
78.53
from heapq import heapify, heappush, heappop N = int(eval(input())) Alist = list(map(int, input().split())) heapify(Alist) while len(Alist)>1: Alist = [a for a in Alist if a > 0] min_num = heappop(Alist) for i in range(len(Alist)): Alist[i] %= min_num heappush(Alist, min_num) print((Al...
from heapq import heapify, heappop, heappush N = int(eval(input())) Alist = list(map(int, input().split())) heapify(Alist) while len(Alist) > 1: atk = heappop(Alist) Alist = [A % atk for A in Alist if (A % atk != 0)] heapify(Alist) heappush(Alist, atk) print((Alist[0]))
11
10
320
288
from heapq import heapify, heappush, heappop N = int(eval(input())) Alist = list(map(int, input().split())) heapify(Alist) while len(Alist) > 1: Alist = [a for a in Alist if a > 0] min_num = heappop(Alist) for i in range(len(Alist)): Alist[i] %= min_num heappush(Alist, min_num) print((Alist[0])...
from heapq import heapify, heappop, heappush N = int(eval(input())) Alist = list(map(int, input().split())) heapify(Alist) while len(Alist) > 1: atk = heappop(Alist) Alist = [A % atk for A in Alist if (A % atk != 0)] heapify(Alist) heappush(Alist, atk) print((Alist[0]))
false
9.090909
[ "-from heapq import heapify, heappush, heappop", "+from heapq import heapify, heappop, heappush", "- Alist = [a for a in Alist if a > 0]", "- min_num = heappop(Alist)", "- for i in range(len(Alist)):", "- Alist[i] %= min_num", "- heappush(Alist, min_num)", "+ atk = heappop(Alist)...
false
0.042246
0.039096
1.080548
[ "s066895205", "s363546380" ]
u566428756
p03681
python
s954657282
s024682348
67
58
9,192
9,204
Accepted
Accepted
13.43
N,M=list(map(int,input().split())) abs_NM=abs(N-M) if abs_NM>1: print((0)) exit() p=10**9+7 ans=1 for i in range(1,N+1): ans=(ans*i)%p for i in range(1,M+1): ans=(ans*i)%p if abs_NM==0: ans=(ans*2)%p print(ans)
N,M=list(map(int,input().split())) abs_NM=abs(N-M) if abs_NM>1: print((0)) exit() p=10**9+7 min_=min(N,M) max_=max(N,M) ans=1 for i in range(1,min_+1): ans=(ans*i)%p ans=(ans*i)%p if abs_NM==1: ans=(ans*max_)%p else: ans=(ans*2)%p print(ans)
16
20
239
279
N, M = list(map(int, input().split())) abs_NM = abs(N - M) if abs_NM > 1: print((0)) exit() p = 10**9 + 7 ans = 1 for i in range(1, N + 1): ans = (ans * i) % p for i in range(1, M + 1): ans = (ans * i) % p if abs_NM == 0: ans = (ans * 2) % p print(ans)
N, M = list(map(int, input().split())) abs_NM = abs(N - M) if abs_NM > 1: print((0)) exit() p = 10**9 + 7 min_ = min(N, M) max_ = max(N, M) ans = 1 for i in range(1, min_ + 1): ans = (ans * i) % p ans = (ans * i) % p if abs_NM == 1: ans = (ans * max_) % p else: ans = (ans * 2) % p print(ans)
false
20
[ "+min_ = min(N, M)", "+max_ = max(N, M)", "-for i in range(1, N + 1):", "+for i in range(1, min_ + 1):", "-for i in range(1, M + 1):", "-if abs_NM == 0:", "+if abs_NM == 1:", "+ ans = (ans * max_) % p", "+else:" ]
false
0.041672
0.109429
0.380812
[ "s954657282", "s024682348" ]
u703950586
p02684
python
s034841365
s642967466
124
114
101,292
96,812
Accepted
Accepted
8.06
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): sys.setrecursionlimit(10**7) LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N,K = LI() A = [0] + LI() his = [0] * (N+1) s = 1 cnt = 1 his[1]...
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): sys.setrecursionlimit(10**7) LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N,K = LI() A = [0] + LI() his = [0] * (N+1) s = 1 cnt = K whil...
36
24
657
508
import sys, queue, math, copy, itertools, bisect, collections, heapq def main(): sys.setrecursionlimit(10**7) LI = lambda: [int(x) for x in sys.stdin.readline().split()] NI = lambda: int(sys.stdin.readline()) N, K = LI() A = [0] + LI() his = [0] * (N + 1) s = 1 cnt = 1 his[1] = 1 ...
import sys, queue, math, copy, itertools, bisect, collections, heapq def main(): sys.setrecursionlimit(10**7) LI = lambda: [int(x) for x in sys.stdin.readline().split()] NI = lambda: int(sys.stdin.readline()) N, K = LI() A = [0] + LI() his = [0] * (N + 1) s = 1 cnt = K while cnt > ...
false
33.333333
[ "- cnt = 1", "- his[1] = 1", "- while his[A[s]] == 0:", "+ cnt = K", "+ while cnt > 0:", "+ his[s] = cnt", "- cnt += 1", "- his[s] = cnt", "- if K >= cnt:", "- s = A[s]", "- cnt -= his[s] - 1", "- k = (K - his[s] + 1) % cnt", "- ...
false
0.03732
0.042802
0.871908
[ "s034841365", "s642967466" ]
u694810977
p03087
python
s846616790
s451346567
639
438
59,208
10,208
Accepted
Accepted
31.46
N, Q = list(map(int, input().split())) ruisekiwa = [0] lists = [] cnt = 0 S = str(eval(input())) for t in range(1, N): if S[t - 1] == "A" and S[t] == "C": cnt += 1 ruisekiwa.append(cnt) ruisekiwa.append(cnt) for i in range(Q): l, r = list(map(int, input().split())) ans = ruisekiwa[r ...
N, Q = list(map(int, input().split())) S = str(eval(input())) count = [0]*(N+1) lists = [] for i in range(1, N): if S[i-1] == "A" and S[i] == "C": count[i] = count[i-1] + 1 else: count[i] = count[i-1] for i in range(Q): l, r = list(map(int, input().split())) ans = count[r-1] -...
16
15
399
387
N, Q = list(map(int, input().split())) ruisekiwa = [0] lists = [] cnt = 0 S = str(eval(input())) for t in range(1, N): if S[t - 1] == "A" and S[t] == "C": cnt += 1 ruisekiwa.append(cnt) ruisekiwa.append(cnt) for i in range(Q): l, r = list(map(int, input().split())) ans = ruisekiwa[r - 1] - ruise...
N, Q = list(map(int, input().split())) S = str(eval(input())) count = [0] * (N + 1) lists = [] for i in range(1, N): if S[i - 1] == "A" and S[i] == "C": count[i] = count[i - 1] + 1 else: count[i] = count[i - 1] for i in range(Q): l, r = list(map(int, input().split())) ans = count[r - 1] ...
false
6.25
[ "-ruisekiwa = [0]", "+S = str(eval(input()))", "+count = [0] * (N + 1)", "-cnt = 0", "-S = str(eval(input()))", "-for t in range(1, N):", "- if S[t - 1] == \"A\" and S[t] == \"C\":", "- cnt += 1", "- ruisekiwa.append(cnt)", "-ruisekiwa.append(cnt)", "+for i in range(1, N):", "+ ...
false
0.079438
0.107676
0.737748
[ "s846616790", "s451346567" ]
u852690916
p03705
python
s361098830
s743481028
193
160
38,384
38,384
Accepted
Accepted
17.1
N,A,B = list(map(int, input().split())) if N == 1 and A != B: print((0)) exit() if A > B: print((0)) exit() if N == 2: print((1)) exit() m = N - 2 print((B*m - A*m + 1))
N,A,B=list(map(int, input().split())) if A>B: print((0)) exit() elif N==1 and A!=B: print((0)) exit() mn=A*(N-1) + B mx=A + B*(N-1) print((mx-mn+1))
14
12
194
166
N, A, B = list(map(int, input().split())) if N == 1 and A != B: print((0)) exit() if A > B: print((0)) exit() if N == 2: print((1)) exit() m = N - 2 print((B * m - A * m + 1))
N, A, B = list(map(int, input().split())) if A > B: print((0)) exit() elif N == 1 and A != B: print((0)) exit() mn = A * (N - 1) + B mx = A + B * (N - 1) print((mx - mn + 1))
false
14.285714
[ "-if N == 1 and A != B:", "- print((0))", "- exit()", "-if N == 2:", "- print((1))", "+elif N == 1 and A != B:", "+ print((0))", "-m = N - 2", "-print((B * m - A * m + 1))", "+mn = A * (N - 1) + B", "+mx = A + B * (N - 1)", "+print((mx - mn + 1))" ]
false
0.101284
0.039024
2.595391
[ "s361098830", "s743481028" ]
u504836877
p03077
python
s646334654
s869852592
19
17
3,188
2,940
Accepted
Accepted
10.53
N = int(eval(input())) L = [0 for i in range(5)] for i in range(5): L[i] = int(eval(input())) time = [0 for i in range(5)] time[0] = (N-1)//L[0] + 1 for i in range(4): if L[i] <= L[i+1]: time[i+1] = time[i] else: time[i+1] = (N-1)//L[i+1] + 1 ans = max(time) + 4 ...
N = int(eval(input())) L = [int(eval(input())) for _ in range(5)] n = min(L) ans = (N+n-1) // n + 4 print(ans)
16
6
327
104
N = int(eval(input())) L = [0 for i in range(5)] for i in range(5): L[i] = int(eval(input())) time = [0 for i in range(5)] time[0] = (N - 1) // L[0] + 1 for i in range(4): if L[i] <= L[i + 1]: time[i + 1] = time[i] else: time[i + 1] = (N - 1) // L[i + 1] + 1 ans = max(time) + 4 print(ans)
N = int(eval(input())) L = [int(eval(input())) for _ in range(5)] n = min(L) ans = (N + n - 1) // n + 4 print(ans)
false
62.5
[ "-L = [0 for i in range(5)]", "-for i in range(5):", "- L[i] = int(eval(input()))", "-time = [0 for i in range(5)]", "-time[0] = (N - 1) // L[0] + 1", "-for i in range(4):", "- if L[i] <= L[i + 1]:", "- time[i + 1] = time[i]", "- else:", "- time[i + 1] = (N - 1) // L[i + 1] ...
false
0.051625
0.050092
1.030614
[ "s646334654", "s869852592" ]
u581603131
p03835
python
s071765851
s981870799
1,415
800
2,940
41,112
Accepted
Accepted
43.46
K, S = list(map(int, input().split())) count = 0 for X in range(K+1): for Y in range(K+1): if 0<=S-X-Y<=K: #X+Y+Z=S Z=S-X-Y,0<=Z<=K count += 1 print(count)
k,s=list(map(int,input().split())) print((len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k])))
7
2
179
100
K, S = list(map(int, input().split())) count = 0 for X in range(K + 1): for Y in range(K + 1): if 0 <= S - X - Y <= K: # X+Y+Z=S Z=S-X-Y,0<=Z<=K count += 1 print(count)
k, s = list(map(int, input().split())) print((len([1 for z in range(k + 1) for y in range(k + 1) if 0 <= s - y - z <= k])))
false
71.428571
[ "-K, S = list(map(int, input().split()))", "-count = 0", "-for X in range(K + 1):", "- for Y in range(K + 1):", "- if 0 <= S - X - Y <= K: # X+Y+Z=S Z=S-X-Y,0<=Z<=K", "- count += 1", "-print(count)", "+k, s = list(map(int, input().split()))", "+print((len([1 for z in range(k + ...
false
0.035081
0.042251
0.830305
[ "s071765851", "s981870799" ]
u089142196
p02727
python
s860024643
s906452857
1,821
224
23,584
29,592
Accepted
Accepted
87.7
import heapq X,Y,A,B,C = list(map(int,input().split())) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) a=p[0:X]+q[0:Y] heapq.heapify(a) #print(a) #print(a[0]) flag=True while flag: ...
import heapq X,Y,A,B,C=list(map(int,input().split())) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort() s = p[:X]+q[:Y] ans=sum(s) heapq.heapify(s) while r and s: if s[0]<r[-1]: ans += r[-1...
27
22
466
403
import heapq X, Y, A, B, C = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) a = p[0:X] + q[0:Y] heapq.heapify(a) # print(a) # print(a[0]) flag = True while flag: ...
import heapq X, Y, A, B, C = list(map(int, input().split())) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort() s = p[:X] + q[:Y] ans = sum(s) heapq.heapify(s) while r and s: if s[0] < r[-1]: ans += ...
false
18.518519
[ "-r.sort(reverse=True)", "-a = p[0:X] + q[0:Y]", "-heapq.heapify(a)", "-# print(a)", "-# print(a[0])", "-flag = True", "-while flag:", "- if len(r) == 0:", "- flag = False", "- elif a[0] < r[0]:", "- heapq.heappop(a)", "- heapq.heappush(a, r[0])", "- r.pop(0...
false
0.118277
0.068838
1.718202
[ "s860024643", "s906452857" ]
u729133443
p02709
python
s482036186
s820929619
937
858
9,676
9,676
Accepted
Accepted
8.43
e=enumerate n,*a=list(map(int,open(0).read().split())) d=[0] for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):d=[d[0]+a*(~i-j+n)]+[max(d[k]+a*(~i-j+n+k),d[k-1]+a*abs(i-k+1))for k in range(1,j+1)]+[d[j]+a*abs(i-j)] print((max(d)))
e=enumerate n,*a=list(map(int,open(0).read().split())) d=[0] for j,(a,i)in e(sorted((a,i)for i,a in e(a))[::-1]):d=[d[0]+a*(~i-j+n)]+[max(d[k+1]+a*(n+k-i-j),d[k]+a*abs(i-k))for k in range(j)]+[d[j]+a*abs(i-j)] print((max(d)))
5
5
228
221
e = enumerate n, *a = list(map(int, open(0).read().split())) d = [0] for j, (a, i) in e(sorted((a, i) for i, a in e(a))[::-1]): d = ( [d[0] + a * (~i - j + n)] + [ max(d[k] + a * (~i - j + n + k), d[k - 1] + a * abs(i - k + 1)) for k in range(1, j + 1) ] + [d[...
e = enumerate n, *a = list(map(int, open(0).read().split())) d = [0] for j, (a, i) in e(sorted((a, i) for i, a in e(a))[::-1]): d = ( [d[0] + a * (~i - j + n)] + [max(d[k + 1] + a * (n + k - i - j), d[k] + a * abs(i - k)) for k in range(j)] + [d[j] + a * abs(i - j)] ) print((max(d)))
false
0
[ "- + [", "- max(d[k] + a * (~i - j + n + k), d[k - 1] + a * abs(i - k + 1))", "- for k in range(1, j + 1)", "- ]", "+ + [max(d[k + 1] + a * (n + k - i - j), d[k] + a * abs(i - k)) for k in range(j)]" ]
false
0.108108
0.071441
1.513251
[ "s482036186", "s820929619" ]
u780342333
p02389
python
s376463199
s944133112
30
20
7,728
5,580
Accepted
Accepted
33.33
width, length = [int(x) for x in input().split(" ")] print(("{} {}".format(width * length, 2 * (width+length))))
a, b = list(map(int, input().split())) print(("{} {}".format(a*b, (a+b)* 2)))
2
2
111
71
width, length = [int(x) for x in input().split(" ")] print(("{} {}".format(width * length, 2 * (width + length))))
a, b = list(map(int, input().split())) print(("{} {}".format(a * b, (a + b) * 2)))
false
0
[ "-width, length = [int(x) for x in input().split(\" \")]", "-print((\"{} {}\".format(width * length, 2 * (width + length))))", "+a, b = list(map(int, input().split()))", "+print((\"{} {}\".format(a * b, (a + b) * 2)))" ]
false
0.043198
0.042982
1.005033
[ "s376463199", "s944133112" ]
u263830634
p03660
python
s835778793
s111665603
321
296
22,232
22,232
Accepted
Accepted
7.79
import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) graph = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) check = [0] * (N + 1) que1 = deque() #fennecのキュー que2 = deque()...
def main(): import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) graph = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) check = [0] ...
59
63
1,164
1,411
import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) graph = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) check = [0] * (N + 1) que1 = deque() # fennecのキュー que2 = deque() # sunukeのキュー q...
def main(): import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) graph = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) check = [0] * (N + 1) que...
false
6.349206
[ "-import sys", "-from collections import deque", "+def main():", "+ import sys", "+ from collections import deque", "-input = sys.stdin.readline", "-N = int(eval(input()))", "-graph = [[] for _ in range(N + 1)]", "-for _ in range(N - 1):", "- a, b = list(map(int, input().split()))", "- ...
false
0.04085
0.054886
0.744259
[ "s835778793", "s111665603" ]
u729133443
p03425
python
s751092813
s437144013
58
53
17,688
17,832
Accepted
Accepted
8.62
from itertools import*;s,*_=list(zip(*open(0).readlines()));print((sum(p*q*r for p,q,r in combinations(list(map(s.count,'MARCH')),3))))
from itertools import*;s,*_=list(zip(*open(0)));print((sum(p*q*r for p,q,r in combinations(list(map(s.count,'MARCH')),3))))
1
1
121
109
from itertools import * s, *_ = list(zip(*open(0).readlines())) print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))
from itertools import * s, *_ = list(zip(*open(0))) print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))
false
0
[ "-s, *_ = list(zip(*open(0).readlines()))", "+s, *_ = list(zip(*open(0)))" ]
false
0.059567
0.046368
1.284649
[ "s751092813", "s437144013" ]
u942982705
p02659
python
s841917569
s011334399
24
21
10,076
9,148
Accepted
Accepted
12.5
from sys import stdin from decimal import Decimal import math A, B = [Decimal(x) for x in stdin.readline().rstrip().split()] print((int(math.floor(A * B))))
from sys import stdin A,B=stdin.readline().rstrip().split() print((int(A)*int(B.replace(".", ""))//100))
5
3
158
104
from sys import stdin from decimal import Decimal import math A, B = [Decimal(x) for x in stdin.readline().rstrip().split()] print((int(math.floor(A * B))))
from sys import stdin A, B = stdin.readline().rstrip().split() print((int(A) * int(B.replace(".", "")) // 100))
false
40
[ "-from decimal import Decimal", "-import math", "-A, B = [Decimal(x) for x in stdin.readline().rstrip().split()]", "-print((int(math.floor(A * B))))", "+A, B = stdin.readline().rstrip().split()", "+print((int(A) * int(B.replace(\".\", \"\")) // 100))" ]
false
0.103771
0.082363
1.259929
[ "s841917569", "s011334399" ]
u150821332
p02715
python
s931917045
s192248325
741
553
27,416
27,312
Accepted
Accepted
25.37
import numpy as np n,k = list(map(int,input().split())) m = 10**9 + 7 gcds = np.zeros(k+1, int) for i in range(k,0,-1): tmp = k // i gcds[i] = pow(tmp,n, m) for j in range(tmp,1,-1): gcds[i] -= gcds[j*i] ans = 0 for i in range(k,0,-1): ans = (ans + gcds[i]*i)%m print(ans)
import numpy as np n,k = list(map(int,input().split())) m = 10**9 + 7 gcds = np.zeros(k+1, int) ans = 0 for i in range(k,0,-1): tmp = pow(k//i,n, m) for j in range(i*2,k+1,i): tmp -= gcds[j] ans = (ans + tmp*i)%m gcds[i] = tmp print(ans)
14
13
292
256
import numpy as np n, k = list(map(int, input().split())) m = 10**9 + 7 gcds = np.zeros(k + 1, int) for i in range(k, 0, -1): tmp = k // i gcds[i] = pow(tmp, n, m) for j in range(tmp, 1, -1): gcds[i] -= gcds[j * i] ans = 0 for i in range(k, 0, -1): ans = (ans + gcds[i] * i) % m print(ans)
import numpy as np n, k = list(map(int, input().split())) m = 10**9 + 7 gcds = np.zeros(k + 1, int) ans = 0 for i in range(k, 0, -1): tmp = pow(k // i, n, m) for j in range(i * 2, k + 1, i): tmp -= gcds[j] ans = (ans + tmp * i) % m gcds[i] = tmp print(ans)
false
7.142857
[ "-for i in range(k, 0, -1):", "- tmp = k // i", "- gcds[i] = pow(tmp, n, m)", "- for j in range(tmp, 1, -1):", "- gcds[i] -= gcds[j * i]", "- ans = (ans + gcds[i] * i) % m", "+ tmp = pow(k // i, n, m)", "+ for j in range(i * 2, k + 1, i):", "+ tmp -= gcds[j]", "+ ...
false
0.623361
0.288925
2.15752
[ "s931917045", "s192248325" ]
u970197315
p03680
python
s072454049
s527473843
286
206
16,500
7,852
Accepted
Accepted
27.97
# ABC065 B - Trained? N = int(eval(input())) A = [[int(eval(input())),False] for i in range(N)] idx = 0 A[0][1] == True cnt = 1 while cnt != N+1: if A[idx][1]: print((-1)) exit() if A[idx][0] == 2: print(cnt) exit() A[idx][1] = True idx = A[idx][0]-1 ...
n=int(eval(input())) a=[int(eval(input())) for i in range(n)] btn=[0]*n ans=1 i=0 while True: if btn[i]==1: print((-1)) exit() if a[i]==2: print(ans) exit() btn[i]=1 i=a[i]-1 ans+=1
17
15
315
208
# ABC065 B - Trained? N = int(eval(input())) A = [[int(eval(input())), False] for i in range(N)] idx = 0 A[0][1] == True cnt = 1 while cnt != N + 1: if A[idx][1]: print((-1)) exit() if A[idx][0] == 2: print(cnt) exit() A[idx][1] = True idx = A[idx][0] - 1 cnt += 1
n = int(eval(input())) a = [int(eval(input())) for i in range(n)] btn = [0] * n ans = 1 i = 0 while True: if btn[i] == 1: print((-1)) exit() if a[i] == 2: print(ans) exit() btn[i] = 1 i = a[i] - 1 ans += 1
false
11.764706
[ "-# ABC065 B - Trained?", "-N = int(eval(input()))", "-A = [[int(eval(input())), False] for i in range(N)]", "-idx = 0", "-A[0][1] == True", "-cnt = 1", "-while cnt != N + 1:", "- if A[idx][1]:", "+n = int(eval(input()))", "+a = [int(eval(input())) for i in range(n)]", "+btn = [0] * n", "+a...
false
0.036839
0.040911
0.900474
[ "s072454049", "s527473843" ]
u280978334
p03309
python
s818180320
s891429191
205
185
25,196
27,412
Accepted
Accepted
9.76
N = int(eval(input())) A = [int(x)-i for x,i in zip(input().split(),list(range(1,N+1)))] from math import ceil,floor A.sort() if N%2 == 0: b = round((A[floor(N/2)]+A[ceil(N/2)])/2) else: b = A[floor(N/2)] ans = 0 for a in A: ans += abs(a-b) print(ans)
def main(): N = int(eval(input())) A = list(map(int,input().split())) B = [A[i-1] - i for i in range(1,N+1)] B.sort() b = B[N // 2] if N%2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2) print((sum([abs(bb -b) for bb in B]))) return if __name__ == "__main__": main()
15
11
272
302
N = int(eval(input())) A = [int(x) - i for x, i in zip(input().split(), list(range(1, N + 1)))] from math import ceil, floor A.sort() if N % 2 == 0: b = round((A[floor(N / 2)] + A[ceil(N / 2)]) / 2) else: b = A[floor(N / 2)] ans = 0 for a in A: ans += abs(a - b) print(ans)
def main(): N = int(eval(input())) A = list(map(int, input().split())) B = [A[i - 1] - i for i in range(1, N + 1)] B.sort() b = B[N // 2] if N % 2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2) print((sum([abs(bb - b) for bb in B]))) return if __name__ == "__main__": main()
false
26.666667
[ "-N = int(eval(input()))", "-A = [int(x) - i for x, i in zip(input().split(), list(range(1, N + 1)))]", "-from math import ceil, floor", "+def main():", "+ N = int(eval(input()))", "+ A = list(map(int, input().split()))", "+ B = [A[i - 1] - i for i in range(1, N + 1)]", "+ B.sort()", "+ ...
false
0.049055
0.088264
0.555769
[ "s818180320", "s891429191" ]
u886747123
p03354
python
s167451187
s123649924
1,068
618
110,060
34,472
Accepted
Accepted
42.13
# D - Equals from collections import deque N, M = list(map(int, input().split())) p = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(M)] neighbor = [[] for _ in range(N)] for idx in range(M): neighbor[xy[idx][0]-1].append(xy[idx][1]-1) neighbor[xy[idx][1]-1].a...
# D - Equals Union Find N, M = list(map(int, input().split())) p = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(M)] # 負ならそのノードが根かつ絶対値が木の要素数を示す、正なら値のノードが根であることを示す root = [-1] * N # 木の高さを示す rank = [1] * N # インデックスxを与えると、xの根を返す関数 def find_root(x): if root[x] <...
35
46
976
1,107
# D - Equals from collections import deque N, M = list(map(int, input().split())) p = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(M)] neighbor = [[] for _ in range(N)] for idx in range(M): neighbor[xy[idx][0] - 1].append(xy[idx][1] - 1) neighbor[xy[idx][1] - 1].append(x...
# D - Equals Union Find N, M = list(map(int, input().split())) p = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(M)] # 負ならそのノードが根かつ絶対値が木の要素数を示す、正なら値のノードが根であることを示す root = [-1] * N # 木の高さを示す rank = [1] * N # インデックスxを与えると、xの根を返す関数 def find_root(x): if root[x] < 0: return ...
false
23.913043
[ "-# D - Equals", "-from collections import deque", "-", "+# D - Equals Union Find", "-neighbor = [[] for _ in range(N)]", "+# 負ならそのノードが根かつ絶対値が木の要素数を示す、正なら値のノードが根であることを示す", "+root = [-1] * N", "+# 木の高さを示す", "+rank = [1] * N", "+# インデックスxを与えると、xの根を返す関数", "+def find_root(x):", "+ if root[x] < ...
false
0.00747
0.042712
0.174898
[ "s167451187", "s123649924" ]
u729133443
p03607
python
s988983448
s980877666
504
57
62,296
16,400
Accepted
Accepted
88.69
d={} for _ in[0]*int(eval(input())): i=eval(input()) d[i]=d.get(i,0)^1 print((sum(d.values())))
_,a,*s=open(0) a={a} for i in s:a^={i} print((len(a)))
5
4
87
55
d = {} for _ in [0] * int(eval(input())): i = eval(input()) d[i] = d.get(i, 0) ^ 1 print((sum(d.values())))
_, a, *s = open(0) a = {a} for i in s: a ^= {i} print((len(a)))
false
20
[ "-d = {}", "-for _ in [0] * int(eval(input())):", "- i = eval(input())", "- d[i] = d.get(i, 0) ^ 1", "-print((sum(d.values())))", "+_, a, *s = open(0)", "+a = {a}", "+for i in s:", "+ a ^= {i}", "+print((len(a)))" ]
false
0.035623
0.035651
0.999205
[ "s988983448", "s980877666" ]
u150984829
p00424
python
s926065671
s311164634
850
300
6,472
6,484
Accepted
Accepted
64.71
while 1: n=int(input()) if n==0:break d={} for _ in[0]*n: k,v=input().strip().split() d[k]=v for _ in[0]*int(input()): e=input().strip() print(d[e]if e in d else e,end='') print()
while 1: n=int(eval(input())) if n==0:break d={} for _ in[0]*n: k,v=input().strip().split() d[k]=v a='' for _ in[0]*int(eval(input())): e=input().strip() a+=d[e]if e in d else e print(a)
11
12
204
201
while 1: n = int(input()) if n == 0: break d = {} for _ in [0] * n: k, v = input().strip().split() d[k] = v for _ in [0] * int(input()): e = input().strip() print(d[e] if e in d else e, end="") print()
while 1: n = int(eval(input())) if n == 0: break d = {} for _ in [0] * n: k, v = input().strip().split() d[k] = v a = "" for _ in [0] * int(eval(input())): e = input().strip() a += d[e] if e in d else e print(a)
false
8.333333
[ "- n = int(input())", "+ n = int(eval(input()))", "- for _ in [0] * int(input()):", "+ a = \"\"", "+ for _ in [0] * int(eval(input())):", "- print(d[e] if e in d else e, end=\"\")", "- print()", "+ a += d[e] if e in d else e", "+ print(a)" ]
false
0.032808
0.036884
0.889497
[ "s926065671", "s311164634" ]
u497952650
p03599
python
s305348285
s135512807
355
23
7,256
3,188
Accepted
Accepted
93.52
A,B,C,D,E,F = list(map(int,input().split())) MAX_SUGER = E*F/(E+100) water = [min(A,B)*100,max(A,B)*100] for i in range(1,300): for j in range(1,300): water.append(100*A*i+100*B*j) water = sorted(list(set(water))) suger = [] for i in range(1000): for j in range(1000): if C*i + ...
A,B,C,D,E,F = list(map(int,input().split())) MAX_SUGER = E*F/(E+100) water = [min(A,B)*100,max(A,B)*100] for i in range(1,31): for j in range(1,31): water.append(100*A*i+100*B*j) water = sorted(list(set(water))) suger = [] for i in range(101): for j in range(101): if C*i + D*j ...
30
31
657
656
A, B, C, D, E, F = list(map(int, input().split())) MAX_SUGER = E * F / (E + 100) water = [min(A, B) * 100, max(A, B) * 100] for i in range(1, 300): for j in range(1, 300): water.append(100 * A * i + 100 * B * j) water = sorted(list(set(water))) suger = [] for i in range(1000): for j in range(1000): ...
A, B, C, D, E, F = list(map(int, input().split())) MAX_SUGER = E * F / (E + 100) water = [min(A, B) * 100, max(A, B) * 100] for i in range(1, 31): for j in range(1, 31): water.append(100 * A * i + 100 * B * j) water = sorted(list(set(water))) suger = [] for i in range(101): for j in range(101): ...
false
3.225806
[ "-for i in range(1, 300):", "- for j in range(1, 300):", "+for i in range(1, 31):", "+ for j in range(1, 31):", "-for i in range(1000):", "- for j in range(1000):", "+for i in range(101):", "+ for j in range(101):" ]
false
1.234327
0.039457
31.282666
[ "s305348285", "s135512807" ]
u340781749
p02975
python
s314164212
s595298163
65
53
15,516
14,460
Accepted
Accepted
18.46
from collections import Counter def solve(n, aaa): if all(a == 0 for a in aaa): return True if n % 3 != 0: return False cnt = list(Counter(aaa).items()) if len(cnt) == 2: (a1, c1), (a2, c2) = cnt if c1 > c2: c1, c2 = c2, c1 if c1 != ...
from collections import Counter def solve(n, aaa): if all(a == 0 for a in aaa): return True if n % 3 != 0: return False cnt = Counter(aaa) if len(cnt) == 2: (a1, c1), (a2, c2) = cnt.most_common() if c1 != n * 2 // 3 or c2 != n // 3: return Fa...
31
29
689
636
from collections import Counter def solve(n, aaa): if all(a == 0 for a in aaa): return True if n % 3 != 0: return False cnt = list(Counter(aaa).items()) if len(cnt) == 2: (a1, c1), (a2, c2) = cnt if c1 > c2: c1, c2 = c2, c1 if c1 != n // 3 or c2 != n...
from collections import Counter def solve(n, aaa): if all(a == 0 for a in aaa): return True if n % 3 != 0: return False cnt = Counter(aaa) if len(cnt) == 2: (a1, c1), (a2, c2) = cnt.most_common() if c1 != n * 2 // 3 or c2 != n // 3: return False retu...
false
6.451613
[ "- cnt = list(Counter(aaa).items())", "+ cnt = Counter(aaa)", "- (a1, c1), (a2, c2) = cnt", "- if c1 > c2:", "- c1, c2 = c2, c1", "- if c1 != n // 3 or c2 != n * 2 // 3:", "+ (a1, c1), (a2, c2) = cnt.most_common()", "+ if c1 != n * 2 // 3 or c2 != n ...
false
0.118036
0.154801
0.7625
[ "s314164212", "s595298163" ]
u723583932
p02712
python
s736203423
s094574870
197
104
9,100
9,064
Accepted
Accepted
47.21
n=int(eval(input())) ans=0 def fb(num): if num%3==0 or num%5==0: return False else: return True for i in range(1,n+1): if fb(i): ans+=i print(ans)
n=int(eval(input())) def func(): s=0 for i in range(1,n+1): if not(i%3==0 or i%5==0): s+=i else: continue return s print((func()))
12
10
190
185
n = int(eval(input())) ans = 0 def fb(num): if num % 3 == 0 or num % 5 == 0: return False else: return True for i in range(1, n + 1): if fb(i): ans += i print(ans)
n = int(eval(input())) def func(): s = 0 for i in range(1, n + 1): if not (i % 3 == 0 or i % 5 == 0): s += i else: continue return s print((func()))
false
16.666667
[ "-ans = 0", "-def fb(num):", "- if num % 3 == 0 or num % 5 == 0:", "- return False", "- else:", "- return True", "+def func():", "+ s = 0", "+ for i in range(1, n + 1):", "+ if not (i % 3 == 0 or i % 5 == 0):", "+ s += i", "+ else:", "+ ...
false
0.368778
0.096137
3.835977
[ "s736203423", "s094574870" ]
u287132915
p02781
python
s330923833
s209164017
40
22
3,440
3,064
Accepted
Accepted
45
n = eval(input()) k = int(eval(input())) keta = len(n) # dp0 = ヨユーなやつ, dp1 = ギリなやつ dp0 = [[0 for j in range(keta+1)] for i in range(keta+1)] dp1 = [[0 for j in range(keta+1)] for i in range(keta+1)] dp1[0][0] = 1 for i in range(keta): for j in range(keta+1): # ギリギリのやつ(dp1)の処理 if n[...
n = eval(input()) km = int(eval(input())) dp1 = [[0] * (4) for _ in range(len(n) + 1)] dp2 = [[0] * (4) for _ in range(len(n) + 1)] dp1[0][0] = 1 for i in range(len(n)): for j in range(4): # i+1桁目に0が入る場合 if n[i] == '0': dp1[i + 1][j] += dp1[i][j] dp2[i + 1][j] += dp...
42
22
1,362
734
n = eval(input()) k = int(eval(input())) keta = len(n) # dp0 = ヨユーなやつ, dp1 = ギリなやつ dp0 = [[0 for j in range(keta + 1)] for i in range(keta + 1)] dp1 = [[0 for j in range(keta + 1)] for i in range(keta + 1)] dp1[0][0] = 1 for i in range(keta): for j in range(keta + 1): # ギリギリのやつ(dp1)の処理 if n[i] == "0...
n = eval(input()) km = int(eval(input())) dp1 = [[0] * (4) for _ in range(len(n) + 1)] dp2 = [[0] * (4) for _ in range(len(n) + 1)] dp1[0][0] = 1 for i in range(len(n)): for j in range(4): # i+1桁目に0が入る場合 if n[i] == "0": dp1[i + 1][j] += dp1[i][j] dp2[i + 1][j] += dp2[i][j] ...
false
47.619048
[ "-k = int(eval(input()))", "-keta = len(n)", "-# dp0 = ヨユーなやつ, dp1 = ギリなやつ", "-dp0 = [[0 for j in range(keta + 1)] for i in range(keta + 1)]", "-dp1 = [[0 for j in range(keta + 1)] for i in range(keta + 1)]", "+km = int(eval(input()))", "+dp1 = [[0] * (4) for _ in range(len(n) + 1)]", "+dp2 = [[0] * (...
false
0.036889
0.037272
0.989716
[ "s330923833", "s209164017" ]
u899975427
p03231
python
s960302419
s145267837
35
17
5,432
3,316
Accepted
Accepted
51.43
import fractions n,m = list(map(int,input().split())) gcd = int(fractions.gcd(n,m)) lcm = n * m // gcd s = eval(input()) t = eval(input()) if gcd == 1: if s[0] == t[0]: print(lcm) else: print((-1)) else: if s[::n//gcd] == t[::m//gcd]: print(lcm) else: print((-1))
n,m = list(map(int,input().split())) def gcd(a, b): a, b = (a, b) if a >= b else (b, a) while b > 0: a, b = b, a % b return a gc = gcd(n,m) lcm = n * m // gc s = eval(input()) t = eval(input()) if s[::n//gc] == t[::m//gc]: print(lcm) else: print((-1))
17
17
287
264
import fractions n, m = list(map(int, input().split())) gcd = int(fractions.gcd(n, m)) lcm = n * m // gcd s = eval(input()) t = eval(input()) if gcd == 1: if s[0] == t[0]: print(lcm) else: print((-1)) else: if s[:: n // gcd] == t[:: m // gcd]: print(lcm) else: print((-1)...
n, m = list(map(int, input().split())) def gcd(a, b): a, b = (a, b) if a >= b else (b, a) while b > 0: a, b = b, a % b return a gc = gcd(n, m) lcm = n * m // gc s = eval(input()) t = eval(input()) if s[:: n // gc] == t[:: m // gc]: print(lcm) else: print((-1))
false
0
[ "-import fractions", "+n, m = list(map(int, input().split()))", "-n, m = list(map(int, input().split()))", "-gcd = int(fractions.gcd(n, m))", "-lcm = n * m // gcd", "+", "+def gcd(a, b):", "+ a, b = (a, b) if a >= b else (b, a)", "+ while b > 0:", "+ a, b = b, a % b", "+ return a...
false
0.062153
0.059874
1.03806
[ "s960302419", "s145267837" ]
u254871849
p02888
python
s266362423
s516513459
1,374
869
3,316
3,188
Accepted
Accepted
36.75
import bisect n = int(eval(input())) ls = list(map(int, input().split())) ls.sort() count = 0 for i in range(n - 2): a = ls[i] for j in range(i + 1, n - 1): b = ls[j] index = bisect.bisect_left(ls, a + b) count += index - j - 1 print(count)
# 2019-11-18 23:58:23(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # import re # import heapq # import arr...
15
30
268
718
import bisect n = int(eval(input())) ls = list(map(int, input().split())) ls.sort() count = 0 for i in range(n - 2): a = ls[i] for j in range(i + 1, n - 1): b = ls[j] index = bisect.bisect_left(ls, a + b) count += index - j - 1 print(count)
# 2019-11-18 23:58:23(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # import re # import heapq # import array # from...
false
50
[ "-import bisect", "+# 2019-11-18 23:58:23(JST)", "+import sys", "-n = int(eval(input()))", "-ls = list(map(int, input().split()))", "-ls.sort()", "-count = 0", "-for i in range(n - 2):", "- a = ls[i]", "- for j in range(i + 1, n - 1):", "- b = ls[j]", "- index = bisect.bise...
false
0.078507
0.037362
2.101232
[ "s266362423", "s516513459" ]
u645250356
p03062
python
s583101296
s435572520
333
120
85,976
16,384
Accepted
Accepted
63.96
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,copy sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
22
20
513
486
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.read...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, copy sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readli...
false
9.090909
[ "-import sys, bisect, math, itertools, fractions, pprint", "+import sys, bisect, math, itertools, fractions, copy", "-mic = 0", "+cnt = 0", "- mic += 1", "- a[i] *= -1", "-if mic % 2:", "- a.sort()", "- print((sum(a[1:]) - a[0]))", "-else:", "- print((sum(a)))", "+ ...
false
0.091222
0.03607
2.528996
[ "s583101296", "s435572520" ]
u562935282
p03674
python
s435017206
s275980407
345
273
20,432
19,428
Accepted
Accepted
20.87
# 解説を見た class Calc: def __init__(self, max_value, mod): """combination(max_value, all)""" fact = [-1] * (max_value + 1) fact[0] = 1 fact[1] = 1 for x in range(2, max_value + 1): fact[x] = x * fact[x - 1] % mod invs = [-1] * (max_value + 1) ...
def build_combination(n, mod): def cmb(n, r): if r < 0 or n < r: return 0 return (((invs[r] * invs[n - r]) % mod) * fact[n]) % mod fact = [1] * (n + 1) for x in range(2, n + 1): fact[x] = x * fact[x - 1] % mod invs = [1] * (n + 1) invs[n] = pow(fact[n...
75
51
1,673
1,212
# 解説を見た class Calc: def __init__(self, max_value, mod): """combination(max_value, all)""" fact = [-1] * (max_value + 1) fact[0] = 1 fact[1] = 1 for x in range(2, max_value + 1): fact[x] = x * fact[x - 1] % mod invs = [-1] * (max_value + 1) invs[max...
def build_combination(n, mod): def cmb(n, r): if r < 0 or n < r: return 0 return (((invs[r] * invs[n - r]) % mod) * fact[n]) % mod fact = [1] * (n + 1) for x in range(2, n + 1): fact[x] = x * fact[x - 1] % mod invs = [1] * (n + 1) invs[n] = pow(fact[n], mod - 2, ...
false
32
[ "-# 解説を見た", "-class Calc:", "- def __init__(self, max_value, mod):", "- \"\"\"combination(max_value, all)\"\"\"", "- fact = [-1] * (max_value + 1)", "- fact[0] = 1", "- fact[1] = 1", "- for x in range(2, max_value + 1):", "- fact[x] = x * fact[x - 1] ...
false
0.055005
0.06916
0.795337
[ "s435017206", "s275980407" ]
u268554510
p02798
python
s625936314
s154337988
1,924
922
419,904
165,660
Accepted
Accepted
52.08
def main(): N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) # M:カードの数字の最大値+1 M = max(max(A),max(B))+1 INF=float('inf') # dp[mask][a]:maskのカードが操作済で、そのうち右端のカードの数字がaであるときの操作回数の最小値 dp = [[INF for _ in range(M)] for _ in range(1<<N)] dp[0][0] = 0 ...
N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) INF = N**3 max_ab = max(max(A),max(B))+1 dp = [[INF] * max_ab for _ in range(2**N)] dp[0][0]=0 for i in range(2**N): done = 0 for j in range(N): if (i>>j)&1: done += 1 for right_end in range(max_...
53
40
1,363
976
def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) # M:カードの数字の最大値+1 M = max(max(A), max(B)) + 1 INF = float("inf") # dp[mask][a]:maskのカードが操作済で、そのうち右端のカードの数字がaであるときの操作回数の最小値 dp = [[INF for _ in range(M)] for _ in range(1 << N)] d...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) INF = N**3 max_ab = max(max(A), max(B)) + 1 dp = [[INF] * max_ab for _ in range(2**N)] dp[0][0] = 0 for i in range(2**N): done = 0 for j in range(N): if (i >> j) & 1: done += 1 for right_end in...
false
24.528302
[ "-def main():", "- N = int(eval(input()))", "- A = list(map(int, input().split()))", "- B = list(map(int, input().split()))", "- # M:カードの数字の最大値+1", "- M = max(max(A), max(B)) + 1", "- INF = float(\"inf\")", "- # dp[mask][a]:maskのカードが操作済で、そのうち右端のカードの数字がaであるときの操作回数の最小値", "- dp ...
false
0.0462
0.03719
1.242276
[ "s625936314", "s154337988" ]
u736729525
p03634
python
s038287829
s243650234
1,590
621
56,696
44,412
Accepted
Accepted
60.94
from collections import deque N = int(eval(input())) E = [[] for i in range(N)] C = {} D = [0] * N parent = [0]*N for i in range(N-1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].append(b) E[b].append(a) C[(a,b)] = c C[(b,a)] = c M, K = list(map(int, input().split())) ...
from collections import deque def main(): def p(a,b): if a < b: return (a,b) else: return (b,a) input = open(0).readline N = int(eval(input())) E = [[] for i in range(N)] C = {} D = [0] * N parent = [0]*N for i in range(N-1): a, b, c = list(map(int, input().split(...
41
47
621
795
from collections import deque N = int(eval(input())) E = [[] for i in range(N)] C = {} D = [0] * N parent = [0] * N for i in range(N - 1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].append(b) E[b].append(a) C[(a, b)] = c C[(b, a)] = c M, K = list(map(int, input().split()))...
from collections import deque def main(): def p(a, b): if a < b: return (a, b) else: return (b, a) input = open(0).readline N = int(eval(input())) E = [[] for i in range(N)] C = {} D = [0] * N parent = [0] * N for i in range(N - 1): a, b...
false
12.765957
[ "-N = int(eval(input()))", "-E = [[] for i in range(N)]", "-C = {}", "-D = [0] * N", "-parent = [0] * N", "-for i in range(N - 1):", "- a, b, c = list(map(int, input().split()))", "- a -= 1", "- b -= 1", "- E[a].append(b)", "- E[b].append(a)", "- C[(a, b)] = c", "- C[(b,...
false
0.042738
0.036675
1.165301
[ "s038287829", "s243650234" ]
u710921979
p03478
python
s554350711
s043158750
205
34
42,092
3,188
Accepted
Accepted
83.41
n,a,b=list(map(int,input().split())) ans=0 for i in range(n+1): if a<=sum(list(map(int,list(str(i)))))<=b: ans+=i print(ans)
n,a,b=list(map(int,input().split())) ans=0 for i in range(1,n+1): if a<=sum(list(map(int,str(i))))<=b: ans+=i print(ans)
6
6
135
131
n, a, b = list(map(int, input().split())) ans = 0 for i in range(n + 1): if a <= sum(list(map(int, list(str(i))))) <= b: ans += i print(ans)
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): if a <= sum(list(map(int, str(i)))) <= b: ans += i print(ans)
false
0
[ "-for i in range(n + 1):", "- if a <= sum(list(map(int, list(str(i))))) <= b:", "+for i in range(1, n + 1):", "+ if a <= sum(list(map(int, str(i)))) <= b:" ]
false
0.053629
0.054505
0.983938
[ "s554350711", "s043158750" ]
u284854859
p03061
python
s040742222
s462423400
822
675
104,664
88,288
Accepted
Accepted
17.88
def main(): import sys input = sys.stdin.readline def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) #[p,q)のgcd def query(p,q): if p>n-1 or q<1: return 0 if abs(q-p)<=1: return a[p] p += num-...
def main(): import sys from fractions import gcd input = sys.stdin.readline def init(): #set_val for i in range(n): seg[i+num-1]=a[i] #built for i in range(num-2,-1,-1) : seg[i]=gcd(seg[2*i+1],seg[2*i+2]) def upd...
45
57
1,051
1,228
def main(): import sys input = sys.stdin.readline def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) # [p,q)のgcd def query(p, q): if p > n - 1 or q < 1: return 0 if abs(q - p) <= 1: return a[p] p +=...
def main(): import sys from fractions import gcd input = sys.stdin.readline def init(): # set_val for i in range(n): seg[i + num - 1] = a[i] # built for i in range(num - 2, -1, -1): seg[i] = gcd(seg[2 * i + 1], seg[2 * i + 2]) def update(k, ...
false
21.052632
[ "+ from fractions import gcd", "- def gcd(a, b):", "- if b == 0:", "- return a", "- else:", "- return gcd(b, a % b)", "+ def init():", "+ # set_val", "+ for i in range(n):", "+ seg[i + num - 1] = a[i]", "+ # built", "...
false
0.050961
0.062562
0.814575
[ "s040742222", "s462423400" ]
u044220565
p02757
python
s539289151
s279672612
1,216
229
14,320
12,564
Accepted
Accepted
81.17
# coding: utf-8 import numpy as np N,P = list(map(int, input().split())) S = '0'+eval(input()) #N=200000 #P=9893 #S= '0'+'1234567890' * 20000 if (P==2)|(P==5): sum=0 for i in range(N, 0, -1): if int(S[i]) % P == 0: sum+= i print(sum) else: dp1 = np.zeros(N + 1) ...
# coding: utf-8 N,P = list(map(int, input().split())) S = '0'+eval(input()) #N=200000 #P=9893 #S= '0'+'1234567890' * 20000 if (P==2)|(P==5): sum=0 for i in range(N, 0, -1): if int(S[i]) % P == 0: sum+= i print(sum) else: dp1 = [0] * (N+1) dp2 = [0] * (N+1)...
38
38
821
791
# coding: utf-8 import numpy as np N, P = list(map(int, input().split())) S = "0" + eval(input()) # N=200000 # P=9893 # S= '0'+'1234567890' * 20000 if (P == 2) | (P == 5): sum = 0 for i in range(N, 0, -1): if int(S[i]) % P == 0: sum += i print(sum) else: dp1 = np.zeros(N + 1) dp...
# coding: utf-8 N, P = list(map(int, input().split())) S = "0" + eval(input()) # N=200000 # P=9893 # S= '0'+'1234567890' * 20000 if (P == 2) | (P == 5): sum = 0 for i in range(N, 0, -1): if int(S[i]) % P == 0: sum += i print(sum) else: dp1 = [0] * (N + 1) dp2 = [0] * (N + 1) ...
false
0
[ "-import numpy as np", "-", "- dp1 = np.zeros(N + 1)", "- dp2 = np.zeros(N + 1)", "- dp3 = np.zeros(P)", "+ dp1 = [0] * (N + 1)", "+ dp2 = [0] * (N + 1)", "+ dp3 = [0] * P" ]
false
0.513854
0.063848
8.048085
[ "s539289151", "s279672612" ]
u977389981
p03937
python
s423432647
s735084780
20
17
3,188
3,060
Accepted
Accepted
15
h, w = list(map(int, input().split())) A = [eval(input()) for i in range(h)] flag = 0 for a in A: X = a.split('.') cnt = 0 for x in X: if '#' in x: cnt += 1 if cnt > 1: flag = 1 if flag: ans = 'Impossible' else: ans = 'Possible' posi = 0...
h, w = list(map(int, input().split())) A = [eval(input()) for i in range(h)] cnt = 0 for i in range(h): for j in range(w): if A[i][j] == '#': cnt += 1 if cnt == w + h - 1: print('Possible') else: print('Impossible')
30
11
583
245
h, w = list(map(int, input().split())) A = [eval(input()) for i in range(h)] flag = 0 for a in A: X = a.split(".") cnt = 0 for x in X: if "#" in x: cnt += 1 if cnt > 1: flag = 1 if flag: ans = "Impossible" else: ans = "Possible" posi = 0 for i in range(h): ...
h, w = list(map(int, input().split())) A = [eval(input()) for i in range(h)] cnt = 0 for i in range(h): for j in range(w): if A[i][j] == "#": cnt += 1 if cnt == w + h - 1: print("Possible") else: print("Impossible")
false
63.333333
[ "-flag = 0", "-for a in A:", "- X = a.split(\".\")", "- cnt = 0", "- for x in X:", "- if \"#\" in x:", "+cnt = 0", "+for i in range(h):", "+ for j in range(w):", "+ if A[i][j] == \"#\":", "- if cnt > 1:", "- flag = 1", "-if flag:", "- ans = \"Impossib...
false
0.048423
0.047365
1.022328
[ "s423432647", "s735084780" ]
u773265208
p02954
python
s254393924
s777000085
402
207
4,968
51,120
Accepted
Accepted
48.51
import sys s = eval(input()) n = len(s) l = [0] * n reverse_s = ''.join(list(reversed(s))) for i in range(n): state = i count = 0 while True: if s[state] == 'R' and s[state+1] == 'L': if count % 2 == 0: l[state] += 1 else: l[state+1] += 1 break elif s[state] == 'L' and s[state...
import sys readline = sys.stdin.readline def main(): s = eval(input()) n = len(s) ans = [0 for _ in range(n)] field = [0 for _ in range(n)] for i in range(n): if s[i] == 'L' and s[i-1] == 'L': field[i] = field[i-1] + 1 for i in reversed(list(range(n))): if s[i] == 'R' and s[i+1] == 'R': ...
39
34
792
672
import sys s = eval(input()) n = len(s) l = [0] * n reverse_s = "".join(list(reversed(s))) for i in range(n): state = i count = 0 while True: if s[state] == "R" and s[state + 1] == "L": if count % 2 == 0: l[state] += 1 else: l[state + 1] += 1 ...
import sys readline = sys.stdin.readline def main(): s = eval(input()) n = len(s) ans = [0 for _ in range(n)] field = [0 for _ in range(n)] for i in range(n): if s[i] == "L" and s[i - 1] == "L": field[i] = field[i - 1] + 1 for i in reversed(list(range(n))): if s[i]...
false
12.820513
[ "-s = eval(input())", "-n = len(s)", "-l = [0] * n", "-reverse_s = \"\".join(list(reversed(s)))", "-for i in range(n):", "- state = i", "- count = 0", "- while True:", "- if s[state] == \"R\" and s[state + 1] == \"L\":", "- if count % 2 == 0:", "- l[stat...
false
0.045901
0.064398
0.712775
[ "s254393924", "s777000085" ]
u393253137
p02983
python
s640947439
s075493042
638
53
75,436
6,788
Accepted
Accepted
91.69
mod = 2019 l, r = list(map(int, input().split())) m = min(r, l + mod) MN=[] for i in range(l, m): for j in range(i+1, m+1): MN.append(i*j%mod) print((min(MN)))
mod = 2019 l, r = list(map(int, input().split())) m = min(r, l + mod) MN=[] for i in range(l, m): for j in range(i+1, m+1): cand = i * j % mod if cand: MN.append(cand) else: print((0)) exit() print((min(MN)))
8
13
170
274
mod = 2019 l, r = list(map(int, input().split())) m = min(r, l + mod) MN = [] for i in range(l, m): for j in range(i + 1, m + 1): MN.append(i * j % mod) print((min(MN)))
mod = 2019 l, r = list(map(int, input().split())) m = min(r, l + mod) MN = [] for i in range(l, m): for j in range(i + 1, m + 1): cand = i * j % mod if cand: MN.append(cand) else: print((0)) exit() print((min(MN)))
false
38.461538
[ "- MN.append(i * j % mod)", "+ cand = i * j % mod", "+ if cand:", "+ MN.append(cand)", "+ else:", "+ print((0))", "+ exit()" ]
false
0.062272
0.037147
1.676367
[ "s640947439", "s075493042" ]
u815754241
p02771
python
s823042199
s561930014
19
17
3,060
2,940
Accepted
Accepted
10.53
ary = input().split(" ") a = ary[0] b = ary[1] c = ary[2] if ( a == b and ( a != c or b != c) ) or ( a == c and ( a != b or c != b ) ) or ( b == c and ( b != a or c != a ) ) : print("Yes") else : print("No")
ary = input().split(" ") if len(set(ary)) == 2 : print("Yes") else : print("No")
9
5
221
88
ary = input().split(" ") a = ary[0] b = ary[1] c = ary[2] if ( (a == b and (a != c or b != c)) or (a == c and (a != b or c != b)) or (b == c and (b != a or c != a)) ): print("Yes") else: print("No")
ary = input().split(" ") if len(set(ary)) == 2: print("Yes") else: print("No")
false
44.444444
[ "-a = ary[0]", "-b = ary[1]", "-c = ary[2]", "-if (", "- (a == b and (a != c or b != c))", "- or (a == c and (a != b or c != b))", "- or (b == c and (b != a or c != a))", "-):", "+if len(set(ary)) == 2:" ]
false
0.169321
0.042587
3.975834
[ "s823042199", "s561930014" ]
u227082700
p03274
python
s351744032
s855596277
83
75
14,252
14,252
Accepted
Accepted
9.64
n,k=list(map(int,input().split())) k-=1 x=list(map(int,input().split())) print((min(min(abs(x[i])+abs(x[i+k]-x[i]),abs(x[i+k])+abs(x[i+k]-x[i])) for i in range(n-k))))
n,k=list(map(int,input().split())) k-=1 x=list(map(int,input().split())) print((min(min(abs(x[i]),abs(x[i+k]))+abs(x[i]-x[i+k])for i in range(n-k))))
4
4
162
144
n, k = list(map(int, input().split())) k -= 1 x = list(map(int, input().split())) print( ( min( min(abs(x[i]) + abs(x[i + k] - x[i]), abs(x[i + k]) + abs(x[i + k] - x[i])) for i in range(n - k) ) ) )
n, k = list(map(int, input().split())) k -= 1 x = list(map(int, input().split())) print((min(min(abs(x[i]), abs(x[i + k])) + abs(x[i] - x[i + k]) for i in range(n - k))))
false
0
[ "-print(", "- (", "- min(", "- min(abs(x[i]) + abs(x[i + k] - x[i]), abs(x[i + k]) + abs(x[i + k] - x[i]))", "- for i in range(n - k)", "- )", "- )", "-)", "+print((min(min(abs(x[i]), abs(x[i + k])) + abs(x[i] - x[i + k]) for i in range(n - k))))" ]
false
0.033722
0.094773
0.355818
[ "s351744032", "s855596277" ]
u013629972
p03252
python
s749645051
s714296204
148
42
3,632
3,888
Accepted
Accepted
71.62
S = eval(input()) T = eval(input()) s_dict, t_dict = {}, {} for i in range(len(S)): if S[i] in list(s_dict.keys()): if s_dict[S[i]] != T[i]: print("No") exit() else: s_dict[S[i]] = T[i] if T[i] in list(t_dict.keys()): if t_dict[T[i]] != S[i]: ...
from collections import Counter S = eval(input()) T = eval(input()) s = Counter(S) t = Counter(T) if sorted(s.values()) == sorted(t.values()): print("Yes") else: print("No")
21
12
397
187
S = eval(input()) T = eval(input()) s_dict, t_dict = {}, {} for i in range(len(S)): if S[i] in list(s_dict.keys()): if s_dict[S[i]] != T[i]: print("No") exit() else: s_dict[S[i]] = T[i] if T[i] in list(t_dict.keys()): if t_dict[T[i]] != S[i]: print...
from collections import Counter S = eval(input()) T = eval(input()) s = Counter(S) t = Counter(T) if sorted(s.values()) == sorted(t.values()): print("Yes") else: print("No")
false
42.857143
[ "+from collections import Counter", "+", "-s_dict, t_dict = {}, {}", "-for i in range(len(S)):", "- if S[i] in list(s_dict.keys()):", "- if s_dict[S[i]] != T[i]:", "- print(\"No\")", "- exit()", "- else:", "- s_dict[S[i]] = T[i]", "- if T[i] in list(t...
false
0.167117
0.03552
4.704893
[ "s749645051", "s714296204" ]
u346812984
p03221
python
s190384782
s678012379
733
476
38,604
30,692
Accepted
Accepted
35.06
N, M = list(map(int, input().split())) pref = [1] * (N + 1) iPY = [] for i in range(M): p, y = list(map(int, input().split())) iPY.append([i, p, y]) iPY.sort(key=lambda x: x[2]) ans = [] for i, p, y in iPY: name = str(p).zfill(6) + str(pref[p]).zfill(6) ans.append((i, name)) pref[p] += ...
import bisect import sys sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, M = list(map(int, input().split())) d = [[] for _ in range(N + 1)] PY = [] for _ in range(M): p, y = list(map(i...
17
34
380
659
N, M = list(map(int, input().split())) pref = [1] * (N + 1) iPY = [] for i in range(M): p, y = list(map(int, input().split())) iPY.append([i, p, y]) iPY.sort(key=lambda x: x[2]) ans = [] for i, p, y in iPY: name = str(p).zfill(6) + str(pref[p]).zfill(6) ans.append((i, name)) pref[p] += 1 ans.sort(ke...
import bisect import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): N, M = list(map(int, input().split())) d = [[] for _ in range(N + 1)] PY = [] for _ in range(M): p, y = list(map(int, input().split())) ...
false
50
[ "-N, M = list(map(int, input().split()))", "-pref = [1] * (N + 1)", "-iPY = []", "-for i in range(M):", "- p, y = list(map(int, input().split()))", "- iPY.append([i, p, y])", "-iPY.sort(key=lambda x: x[2])", "-ans = []", "-for i, p, y in iPY:", "- name = str(p).zfill(6) + str(pref[p]).zfi...
false
0.044059
0.037515
1.174446
[ "s190384782", "s678012379" ]
u548545174
p03574
python
s254273061
s519242827
38
29
3,700
3,188
Accepted
Accepted
23.68
import copy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] ans = copy.deepcopy(S) dx = [1, 1, 0, -1, -1, -1, 0, 1] dy = [0, 1, 1, 1, 0, -1, -1, -1] for i in range(H): for j in range(W): if S[i][j] == ".": cnt = 0 for dir in range(8)...
H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] def bomb_count(hi, wi): cnt = 0 for i in range(-1, 2): for j in range(-1, 2): if (0 <= (hi + i) <= (H-1)) and (0 <= (wi + j) <= (W-1)): if S[hi+i][wi+j] == "#": cn...
20
22
542
545
import copy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] ans = copy.deepcopy(S) dx = [1, 1, 0, -1, -1, -1, 0, 1] dy = [0, 1, 1, 1, 0, -1, -1, -1] for i in range(H): for j in range(W): if S[i][j] == ".": cnt = 0 for dir in range(8): ...
H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] def bomb_count(hi, wi): cnt = 0 for i in range(-1, 2): for j in range(-1, 2): if (0 <= (hi + i) <= (H - 1)) and (0 <= (wi + j) <= (W - 1)): if S[hi + i][wi + j] == "#": cn...
false
9.090909
[ "-import copy", "-", "-ans = copy.deepcopy(S)", "-dx = [1, 1, 0, -1, -1, -1, 0, 1]", "-dy = [0, 1, 1, 1, 0, -1, -1, -1]", "-for i in range(H):", "- for j in range(W):", "- if S[i][j] == \".\":", "- cnt = 0", "- for dir in range(8):", "- if 0 <= i + ...
false
0.143972
0.036132
3.984606
[ "s254273061", "s519242827" ]
u185297444
p02597
python
s090739735
s189184607
54
47
10,600
10,752
Accepted
Accepted
12.96
n = int(eval(input())) c = list(eval(input())) r = c.count('R') w = c.count('W') ans = 0 for i in range(r): if c[i] == 'R': pass elif c[i] == 'W': ans += 1 print(ans)
n = int(eval(input())) c = list(eval(input())) r = c.count('R') ans = 0 for i in range(r): if c[i] == 'W': ans += 1 print(ans)
12
9
190
135
n = int(eval(input())) c = list(eval(input())) r = c.count("R") w = c.count("W") ans = 0 for i in range(r): if c[i] == "R": pass elif c[i] == "W": ans += 1 print(ans)
n = int(eval(input())) c = list(eval(input())) r = c.count("R") ans = 0 for i in range(r): if c[i] == "W": ans += 1 print(ans)
false
25
[ "-w = c.count(\"W\")", "- if c[i] == \"R\":", "- pass", "- elif c[i] == \"W\":", "+ if c[i] == \"W\":" ]
false
0.043715
0.084783
0.515612
[ "s090739735", "s189184607" ]
u296518383
p02996
python
s054843915
s665659868
1,047
918
55,260
53,728
Accepted
Accepted
12.32
N=int(eval(input())) AB=[list(map(int,input().split())) for _ in range(N)] #print(AB) AB=sorted(AB,key= lambda x: x[1]) #print(AB) res=0 for i in range(N): res+=AB[i][0] if res>AB[i][1]: print("No") break if i==N-1: print("Yes")
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort(key = lambda x: x[1]) sum_a = 0 for a, b in AB: sum_a += a if sum_a > b: print("No") exit() print("Yes")
15
12
256
211
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] # print(AB) AB = sorted(AB, key=lambda x: x[1]) # print(AB) res = 0 for i in range(N): res += AB[i][0] if res > AB[i][1]: print("No") break if i == N - 1: print("Yes")
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort(key=lambda x: x[1]) sum_a = 0 for a, b in AB: sum_a += a if sum_a > b: print("No") exit() print("Yes")
false
20
[ "-# print(AB)", "-AB = sorted(AB, key=lambda x: x[1])", "-# print(AB)", "-res = 0", "-for i in range(N):", "- res += AB[i][0]", "- if res > AB[i][1]:", "+AB.sort(key=lambda x: x[1])", "+sum_a = 0", "+for a, b in AB:", "+ sum_a += a", "+ if sum_a > b:", "- break", "- i...
false
0.133278
0.094655
1.408044
[ "s054843915", "s665659868" ]
u017810624
p03055
python
s478738479
s061788647
1,370
1,249
137,204
137,128
Accepted
Accepted
8.83
def bfs(v): distance=[-1]*n distance[v]=0 next=connection[v] next2=set() visited=[-1]*n visited[v]=1 visitct=1 ct=0 while visitct!=n: ct+=1 for i in range(len(next)): if visited[next[i]]==-1: distance[next[i]]=ct visited[next[i]]=1 visitct+=1 ...
def bfs(v): distance=[-1]*n distance[v]=0 next=connection[v] next2=set() visited=[-1]*n visited[v]=1 visitct=1 ct=0 while visitct!=n: ct+=1 for i in range(len(next)): distance[next[i]]=ct visited[next[i]]=1 visitct+=1 for j in range(len(connection[next[i]...
35
34
837
792
def bfs(v): distance = [-1] * n distance[v] = 0 next = connection[v] next2 = set() visited = [-1] * n visited[v] = 1 visitct = 1 ct = 0 while visitct != n: ct += 1 for i in range(len(next)): if visited[next[i]] == -1: distance[next[i]] = ct...
def bfs(v): distance = [-1] * n distance[v] = 0 next = connection[v] next2 = set() visited = [-1] * n visited[v] = 1 visitct = 1 ct = 0 while visitct != n: ct += 1 for i in range(len(next)): distance[next[i]] = ct visited[next[i]] = 1 ...
false
2.857143
[ "- if visited[next[i]] == -1:", "- distance[next[i]] = ct", "- visited[next[i]] = 1", "- visitct += 1", "- for j in range(len(connection[next[i]])):", "- if visited[connection[next[i]][j]] == -1:", "- ...
false
0.106455
0.039622
2.686729
[ "s478738479", "s061788647" ]
u054514819
p02866
python
s212953662
s098169023
131
119
98,712
98,444
Accepted
Accepted
9.16
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) if Ds[0]!=0: print((0)) exit(0) Ds.sort() mod = 998244353 from collections import Counter c = Counter(Ds) dmax...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) mod = 998244353 from collections import Counter c = Counter(Ds) if Ds[0]!=0: print((0)) elif c[0]>1: print((0))...
26
21
472
426
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) if Ds[0] != 0: print((0)) exit(0) Ds.sort() mod = 998244353 from collections import Counter c = Counter(Ds) dmax...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) mod = 998244353 from collections import Counter c = Counter(Ds) if Ds[0] != 0: print((0)) elif c[0] > 1: print((...
false
19.230769
[ "-if Ds[0] != 0:", "- print((0))", "- exit(0)", "-Ds.sort()", "-dmax = Ds[-1]", "-if c[0] > 1:", "+if Ds[0] != 0:", "+ print((0))", "+elif c[0] > 1:", "- for i in range(1, dmax + 1):", "+ for i in range(1, N):" ]
false
0.170007
0.044254
3.841633
[ "s212953662", "s098169023" ]
u816631826
p02790
python
s140965698
s542381483
68
27
61,868
9,032
Accepted
Accepted
60.29
x, y = map(int, input().split()) if(x < y): for i in range(0, y): print(x, end = '') else: for i in range(0, x): print(y, end = '')
a = [int(i) for i in input().split()] if (a[0] <= a[1]): print((str(a[0])*a[1])) elif (a[1] < a[0]): print((str(a[1])*a[0]))
11
5
170
129
x, y = map(int, input().split()) if x < y: for i in range(0, y): print(x, end="") else: for i in range(0, x): print(y, end="")
a = [int(i) for i in input().split()] if a[0] <= a[1]: print((str(a[0]) * a[1])) elif a[1] < a[0]: print((str(a[1]) * a[0]))
false
54.545455
[ "-x, y = map(int, input().split())", "-if x < y:", "- for i in range(0, y):", "- print(x, end=\"\")", "-else:", "- for i in range(0, x):", "- print(y, end=\"\")", "+a = [int(i) for i in input().split()]", "+if a[0] <= a[1]:", "+ print((str(a[0]) * a[1]))", "+elif a[1] < a[...
false
0.076298
0.037618
2.028194
[ "s140965698", "s542381483" ]
u119148115
p03078
python
s659933398
s129664495
662
351
186,608
184,008
Accepted
Accepted
46.98
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def S(): r...
import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり X,Y,Z,K = MI() A,B,C = LI(),LI(),LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ANS = [] for i in range(X): if i >= K: ...
35
28
941
608
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().rstrip(...
import sys def MI(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり X, Y, Z, K = MI() A, B, C = LI(), LI(), LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ANS = [] for i in range(X): if i >= K: ...
false
20
[ "-", "-sys.setrecursionlimit(10**7)", "-", "-", "-def I():", "- return int(sys.stdin.readline().rstrip())", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし", "-", "-", "-def S():", "- return sys.stdin.readline().rstrip()", "-", "-", "...
false
0.036547
0.061644
0.592873
[ "s659933398", "s129664495" ]
u225388820
p03033
python
s242084712
s979525438
1,264
1,145
248,632
231,364
Accepted
Accepted
9.41
import sys input = sys.stdin.readline # Segment Tree class Segment: def __init__(self, N, init_val): self.N0 = 2 ** (N - 1).bit_length() # 0-indexedで管理 self.dat = [identity_element] * (2 * self.N0) # 値を代入 for i in range(N): self.dat[i + self.N0 - 1] ...
import sys input = sys.stdin.readline # Segment Tree # segfunc : min, +, *, xor, gcd など # identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0) class Segment: def __init__(self, N, init_val): """[セグメント木] Args: N ([int]): [要素数] init_val ([list]): [初期化する値] ...
97
99
2,248
2,419
import sys input = sys.stdin.readline # Segment Tree class Segment: def __init__(self, N, init_val): self.N0 = 2 ** (N - 1).bit_length() # 0-indexedで管理 self.dat = [identity_element] * (2 * self.N0) # 値を代入 for i in range(N): self.dat[i + self.N0 - 1] = init_val[i]...
import sys input = sys.stdin.readline # Segment Tree # segfunc : min, +, *, xor, gcd など # identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0) class Segment: def __init__(self, N, init_val): """[セグメント木] Args: N ([int]): [要素数] init_val ([list]): [初期化する値] """ ...
false
2.020202
[ "+# segfunc : min, +, *, xor, gcd など", "+# identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0)", "- self.N0 = 2 ** (N - 1).bit_length()", "+ \"\"\"[セグメント木]", "+ Args:", "+ N ([int]): [要素数]", "+ init_val ([list]): [初期化する値]", "+ \"\"\"", "+ ...
false
0.00813
0.079954
0.101688
[ "s242084712", "s979525438" ]
u794173881
p03832
python
s982034753
s223084499
1,958
1,454
102,732
102,092
Accepted
Accepted
25.74
class Combination: """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う""" def __init__(self, n, MOD): self.fact = [1] for i in range(1, n + 1): self.fact.append(self.fact[-1] * i % MOD) self.inv_fact = [0] * (n + 1) self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD) ...
class Combination: """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う""" def __init__(self, n, MOD): self.fact = [1] for i in range(1, n + 1): self.fact.append(self.fact[-1] * i % MOD) self.inv_fact = [0] * (n + 1) self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD) ...
62
66
1,978
2,078
class Combination: """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う""" def __init__(self, n, MOD): self.fact = [1] for i in range(1, n + 1): self.fact.append(self.fact[-1] * i % MOD) self.inv_fact = [0] * (n + 1) self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD) ...
class Combination: """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う""" def __init__(self, n, MOD): self.fact = [1] for i in range(1, n + 1): self.fact.append(self.fact[-1] * i % MOD) self.inv_fact = [0] * (n + 1) self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD) ...
false
6.060606
[ "+ pow_ = pow(comb.inverse_factorial(per_g), c - 1, MOD)", "+ p = pow_", "+ p *= comb.inverse_factorial(per_g)", "+ p %= MOD", "- * (pow(comb.inverse_factorial(per_g), cnt_g, MOD))", "+ * p" ]
false
0.032327
0.037702
0.85743
[ "s982034753", "s223084499" ]
u579699847
p03253
python
s400037086
s622501339
167
25
38,640
3,436
Accepted
Accepted
85.03
import collections,sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,M = LI() ans = 1 def prime_factor(num): prime_factor = collections.defaultdict(int) for i in range(2,int(num**0.5)+1): while num%i==0: prime_factor[i] += 1 num //= i if nu...
import collections,sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,M = LI() ans = 1 def prime_factor(num): prime_factor = collections.defaultdict(int) for i in range(2,int(num**0.5)+1): while num%i==0: prime_factor[i] += 1 num //= i if nu...
26
26
715
715
import collections, sys def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N, M = LI() ans = 1 def prime_factor(num): prime_factor = collections.defaultdict(int) for i in range(2, int(num**0.5) + 1): while num % i == 0: prime_factor[i] += 1 num //= i...
import collections, sys def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N, M = LI() ans = 1 def prime_factor(num): prime_factor = collections.defaultdict(int) for i in range(2, int(num**0.5) + 1): while num % i == 0: prime_factor[i] += 1 num //= i...
false
0
[ "- for j in range(1, r + 1):", "- comb_count *= pow(j, mod - 2, mod)", "+ for i in range(1, r + 1):", "+ comb_count *= pow(i, mod - 2, mod)" ]
false
0.154523
0.047561
3.248943
[ "s400037086", "s622501339" ]
u515740713
p02616
python
s253185704
s243862356
256
236
31,716
27,832
Accepted
Accepted
7.81
MOD = (10 ** 9) + 7 n, k = list(map(int, input().split())) a = list(map(int, input().split())) negs = [-x for x in a if x < 0] non_negs = [x for x in a if x >= 0] if len(non_negs) == 0 and k % 2 == 1: negs.sort() ans = 1 for i in range(k): ans = ans * -negs[i] % MOD print(ans) ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K = list(map(int, readline().split())) A = list(map(int,readline().split())) MOD = 10**9 +7 B = [] C = [] for a in A: if a >= 0: B.append(a) else: C.append(-a) ...
80
81
1,750
1,916
MOD = (10**9) + 7 n, k = list(map(int, input().split())) a = list(map(int, input().split())) negs = [-x for x in a if x < 0] non_negs = [x for x in a if x >= 0] if len(non_negs) == 0 and k % 2 == 1: negs.sort() ans = 1 for i in range(k): ans = ans * -negs[i] % MOD print(ans) exit() negs_p, n...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K = list(map(int, readline().split())) A = list(map(int, readline().split())) MOD = 10**9 + 7 B = [] C = [] for a in A: if a >= 0: B.append(a) else: C.append(-a) ans = 1 if len...
false
1.234568
[ "-MOD = (10**9) + 7", "-n, k = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-negs = [-x for x in a if x < 0]", "-non_negs = [x for x in a if x >= 0]", "-if len(non_negs) == 0 and k % 2 == 1:", "- negs.sort()", "- ans = 1", "- for i in range(k):", "- an...
false
0.112474
0.112725
0.99778
[ "s253185704", "s243862356" ]
u761989513
p03048
python
s460895814
s359720417
298
19
41,452
3,060
Accepted
Accepted
93.62
R, G, B, n = list(map(int, input().split())) ans = 0 for r in range(n // R + 1): for g in range((n - r) // G + 1): if (n - r * R - g * G) % B == 0: b = (n - r * R - g * G) / B if b >= 0: ans += 1 print(ans)
r, g, b, n = list(map(int, input().split())) a = [0] * (n + 1) a[0] = 1 for i in [r, g, b]: for j in range(n + 1 - i): a[i + j] += a[j] print((a[n]))
9
7
260
159
R, G, B, n = list(map(int, input().split())) ans = 0 for r in range(n // R + 1): for g in range((n - r) // G + 1): if (n - r * R - g * G) % B == 0: b = (n - r * R - g * G) / B if b >= 0: ans += 1 print(ans)
r, g, b, n = list(map(int, input().split())) a = [0] * (n + 1) a[0] = 1 for i in [r, g, b]: for j in range(n + 1 - i): a[i + j] += a[j] print((a[n]))
false
22.222222
[ "-R, G, B, n = list(map(int, input().split()))", "-ans = 0", "-for r in range(n // R + 1):", "- for g in range((n - r) // G + 1):", "- if (n - r * R - g * G) % B == 0:", "- b = (n - r * R - g * G) / B", "- if b >= 0:", "- ans += 1", "-print(ans)", "+r...
false
0.141425
0.037512
3.770112
[ "s460895814", "s359720417" ]
u652057333
p02632
python
s591872987
s189815195
1,654
367
166,584
166,576
Accepted
Accepted
77.81
k = int(eval(input())) s = eval(input()) MOD = 10**9+7 class Facts(): # O(max_num) def __init__(self, max_num=10**5, p=10**9 + 7): self.p = p self.max_num = max_num self.fact = [1] * (self.max_num + 1) for i in range(1, self.max_num + 1): self.fact[i] = se...
k = int(eval(input())) s = eval(input()) MOD = 10**9+7 class Facts(): # O(max_num) def __init__(self, max_num=10**5, p=10**9+7): self.p = p self.max_num = max_num self.fact = [1] * (self.max_num + 1) self.rev = [1] * (self.max_num + 1) for i in range(1, self.max_num + 1):...
53
52
1,381
1,415
k = int(eval(input())) s = eval(input()) MOD = 10**9 + 7 class Facts: # O(max_num) def __init__(self, max_num=10**5, p=10**9 + 7): self.p = p self.max_num = max_num self.fact = [1] * (self.max_num + 1) for i in range(1, self.max_num + 1): self.fact[i] = self.fact[i ...
k = int(eval(input())) s = eval(input()) MOD = 10**9 + 7 class Facts: # O(max_num) def __init__(self, max_num=10**5, p=10**9 + 7): self.p = p self.max_num = max_num self.fact = [1] * (self.max_num + 1) self.rev = [1] * (self.max_num + 1) for i in range(1, self.max_num +...
false
1.886792
[ "+ self.rev = [1] * (self.max_num + 1)", "- self.fact[i] = self.fact[i - 1] * i", "- self.fact[i] %= self.p", "+ self.fact[i] = (self.fact[i - 1] * i) % self.p", "+ self.rev[self.max_num] = self.power_func(self.fact[self.max_num], self.p - 2)", "+ for ...
false
0.038056
0.038076
0.999458
[ "s591872987", "s189815195" ]
u179169725
p03311
python
s993412088
s719119096
274
122
31,356
33,104
Accepted
Accepted
55.47
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ...
import sys sys.setrecursionlimit(1 << 25) readline = sys.stdin.buffer.readline read = sys.stdin.readline # 文字列読み込む時はこっち import numpy as np from functools import partial array = partial(np.array, dtype=np.int64) zeros = partial(np.zeros, dtype=np.int64) full = partial(np.full, dtype=np.int64) ra = range e...
70
80
1,525
1,896
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tupl...
import sys sys.setrecursionlimit(1 << 25) readline = sys.stdin.buffer.readline read = sys.stdin.readline # 文字列読み込む時はこっち import numpy as np from functools import partial array = partial(np.array, dtype=np.int64) zeros = partial(np.zeros, dtype=np.int64) full = partial(np.full, dtype=np.int64) ra = range enu = enumera...
false
12.5
[ "-read = sys.stdin.readline", "+readline = sys.stdin.buffer.readline", "+read = sys.stdin.readline # 文字列読み込む時はこっち", "+import numpy as np", "+from functools import partial", "+", "+array = partial(np.array, dtype=np.int64)", "+zeros = partial(np.zeros, dtype=np.int64)", "+full = partial(np.full, dty...
false
0.649579
0.216962
2.993978
[ "s993412088", "s719119096" ]
u432551953
p03805
python
s093906163
s453493180
230
203
44,600
42,972
Accepted
Accepted
11.74
import sys input = sys.stdin.readline from operator import itemgetter lis = [] n = 0 m = 0 ans = 0 def dfs(i, d, fr, used): global lis, ans if i in used: return if d == n - 1: ans += 1 return for j in lis[i]: if j != fr: used.append(i) ...
import sys input = sys.stdin.readline from operator import itemgetter lis = [] n = 0 m = 0 ans = 0 visited = [] def dfs(i, d, fr): global lis, ans, visited if visited[i] == 1: return if d == n - 1: ans += 1 return for j in lis[i]: if j != fr: ...
38
40
782
833
import sys input = sys.stdin.readline from operator import itemgetter lis = [] n = 0 m = 0 ans = 0 def dfs(i, d, fr, used): global lis, ans if i in used: return if d == n - 1: ans += 1 return for j in lis[i]: if j != fr: used.append(i) # print(...
import sys input = sys.stdin.readline from operator import itemgetter lis = [] n = 0 m = 0 ans = 0 visited = [] def dfs(i, d, fr): global lis, ans, visited if visited[i] == 1: return if d == n - 1: ans += 1 return for j in lis[i]: if j != fr: visited[i] = ...
false
5
[ "+visited = []", "-def dfs(i, d, fr, used):", "- global lis, ans", "- if i in used:", "+def dfs(i, d, fr):", "+ global lis, ans, visited", "+ if visited[i] == 1:", "- used.append(i)", "+ visited[i] = 1", "- dfs(j, d + 1, i, used)", "- used....
false
0.119782
0.036349
3.295284
[ "s093906163", "s453493180" ]
u896741788
p03329
python
s399871091
s638726880
517
351
6,900
3,064
Accepted
Accepted
32.11
n=int(eval(input())) dp=[float("INF")]*(n+1) dp[0]=0 temp=6 cnt=0 while temp<=n: cnt+=1 dp[temp]=1 temp*=6 l=[0,0] l[0]=cnt temp=9 cnt=0 while temp<=n: cnt+=1 dp[temp]=1 temp*=9 l[1]=cnt for j,v in zip(l,[6,9]): for i in range(j+1): h=pow(v,i) for d in range(h,n+1): dp[...
n=int(eval(input())) ans=float("INF") for i in range(n+1): d=0 temp=i while (temp>0): d+=temp%6 temp//=6 temp=n-i while(temp>0): d+=temp%9 temp//=9 ans=min(d,ans) print(ans)
24
14
352
208
n = int(eval(input())) dp = [float("INF")] * (n + 1) dp[0] = 0 temp = 6 cnt = 0 while temp <= n: cnt += 1 dp[temp] = 1 temp *= 6 l = [0, 0] l[0] = cnt temp = 9 cnt = 0 while temp <= n: cnt += 1 dp[temp] = 1 temp *= 9 l[1] = cnt for j, v in zip(l, [6, 9]): for i in range(j + 1): h = p...
n = int(eval(input())) ans = float("INF") for i in range(n + 1): d = 0 temp = i while temp > 0: d += temp % 6 temp //= 6 temp = n - i while temp > 0: d += temp % 9 temp //= 9 ans = min(d, ans) print(ans)
false
41.666667
[ "-dp = [float(\"INF\")] * (n + 1)", "-dp[0] = 0", "-temp = 6", "-cnt = 0", "-while temp <= n:", "- cnt += 1", "- dp[temp] = 1", "- temp *= 6", "-l = [0, 0]", "-l[0] = cnt", "-temp = 9", "-cnt = 0", "-while temp <= n:", "- cnt += 1", "- dp[temp] = 1", "- temp *= 9", ...
false
0.328783
0.06506
5.053552
[ "s399871091", "s638726880" ]
u072717685
p03166
python
s884740888
s341657246
856
495
134,800
79,456
Accepted
Accepted
42.17
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) longs = [] edges = {} def graph_DP(node_to, long): global longs if longs[node_to] != -1: return longs[node_to] else: nodes_next = edges[node_to] if not nodes_next: longs[node_to] = 0 ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) longs = [] edges = {} def graph_DP(node_to): global longs if longs[node_to] != -1: return longs[node_to] else: nodes_next = edges[node_to] if not nodes_next: longs[node_to] = 0 r...
41
41
1,110
1,097
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) longs = [] edges = {} def graph_DP(node_to, long): global longs if longs[node_to] != -1: return longs[node_to] else: nodes_next = edges[node_to] if not nodes_next: longs[node_to] = 0 return ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) longs = [] edges = {} def graph_DP(node_to): global longs if longs[node_to] != -1: return longs[node_to] else: nodes_next = edges[node_to] if not nodes_next: longs[node_to] = 0 return 0 ...
false
0
[ "-def graph_DP(node_to, long):", "+def graph_DP(node_to):", "- long_max_t = max(long_max_t, graph_DP(node_next, 0) + 1)", "+ long_max_t = max(long_max_t, graph_DP(node_next) + 1)", "- graph_DP(i1, 0)", "+ graph_DP(i1)" ]
false
0.07062
0.081058
0.871237
[ "s884740888", "s341657246" ]
u977193988
p03838
python
s294969358
s876143882
154
18
12,496
3,064
Accepted
Accepted
88.31
import sys import numpy as np def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): x, y = list(map(int, input().split())) if x > 0: if y > 0: if x > y: answer = x - y + 2 else: answ...
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) def main(): x, y = list(map(int, input().split())) if x == y: print((0)) return if x == 0: if y < 0: print((abs(y) + 1)) return els...
49
62
1,045
1,262
import sys import numpy as np def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) def main(): x, y = list(map(int, input().split())) if x > 0: if y > 0: if x > y: answer = x - y + 2 else: answer = y - x e...
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) def main(): x, y = list(map(int, input().split())) if x == y: print((0)) return if x == 0: if y < 0: print((abs(y) + 1)) return else: prin...
false
20.967742
[ "-import numpy as np", "-sys.setrecursionlimit(10**9)", "+sys.setrecursionlimit(20000000)", "- if x > 0:", "+ if x == y:", "+ print((0))", "+ return", "+ if x == 0:", "+ if y < 0:", "+ print((abs(y) + 1))", "+ return", "+ else:", "+ ...
false
0.036037
0.035613
1.011923
[ "s294969358", "s876143882" ]
u201928947
p02889
python
s418982320
s574414353
1,707
870
58,524
52,572
Accepted
Accepted
49.03
def warshall_floid(d): for k in range(1,n+1): for i in range(1,n+1): for j in range(1,n+1): d[i][j] = min(d[i][j],d[i][k]+d[k][j]) return d n,m,l = list(map(int,input().split())) d = [[10**13]*(n+1) for i in range(n+1)] for i in range(m): a,b,c = list(map(int,i...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def warshall_floid(d): for k in range(1,n+1): for i in range(1,n+1): for j in range(1,n+1): d[i][j] = min(d[i][j],d[i][k]+d[k][j]) return d n,m,l = ...
30
34
751
882
def warshall_floid(d): for k in range(1, n + 1): for i in range(1, n + 1): for j in range(1, n + 1): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d n, m, l = list(map(int, input().split())) d = [[10**13] * (n + 1) for i in range(n + 1)] for i in range(m): a, b, c = ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def warshall_floid(d): for k in range(1, n + 1): for i in range(1, n + 1): for j in range(1, n + 1): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d n, ...
false
11.764706
[ "+import sys", "+", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+", "+", "-n, m, l = list(map(int, input().split()))", "-d = [[10**13] * (n + 1) for i in range(n + 1)]", "+n, m, l = list(map(int, readline().split()))", "+d...
false
0.05997
0.034898
1.718442
[ "s418982320", "s574414353" ]
u603921794
p02923
python
s313751137
s988816942
135
98
11,136
14,252
Accepted
Accepted
27.41
n=int(eval(input())) ans=0 now=input().split() a=0 for i in range(len(now)-1): if int(now[i])>=int(now[i+1]): a+=1 else : a=0 # print(a) ans=max(ans,a) print(ans)
from sys import stdin n=int(stdin.readline()) ans=0 now=list(map(int,stdin.readline().split())) a=0 for i in range(len(now)-1): if now[i]>=now[i+1]: a+=1 else : a=0 # print(a) ans=max(ans,a) print(ans)
12
13
199
245
n = int(eval(input())) ans = 0 now = input().split() a = 0 for i in range(len(now) - 1): if int(now[i]) >= int(now[i + 1]): a += 1 else: a = 0 # print(a) ans = max(ans, a) print(ans)
from sys import stdin n = int(stdin.readline()) ans = 0 now = list(map(int, stdin.readline().split())) a = 0 for i in range(len(now) - 1): if now[i] >= now[i + 1]: a += 1 else: a = 0 # print(a) ans = max(ans, a) print(ans)
false
7.692308
[ "-n = int(eval(input()))", "+from sys import stdin", "+", "+n = int(stdin.readline())", "-now = input().split()", "+now = list(map(int, stdin.readline().split()))", "- if int(now[i]) >= int(now[i + 1]):", "+ if now[i] >= now[i + 1]:" ]
false
0.041957
0.037331
1.12393
[ "s313751137", "s988816942" ]
u066413086
p02902
python
s397029722
s369267971
592
42
3,692
9,616
Accepted
Accepted
92.91
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque def find_shortest_cycle(G, s): dq = deque() N = len(G) INF = float('inf') dist = [INF] * N dist[s] = 0 parent = [-1] * N ans_las...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque def shorten_cycle(G, route): # ループだとすでに分かってるルートに対して、 # ショートカットが存在する場合はショートカットを行い、 # ルートを短くする _next = {k: v for k, v in zip(route, route[1:]+route...
92
123
2,464
3,342
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque def find_shortest_cycle(G, s): dq = deque() N = len(G) INF = float("inf") dist = [INF] * N dist[s] = 0 parent = [-1] * N ans_last = None # sから...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque def shorten_cycle(G, route): # ループだとすでに分かってるルートに対して、 # ショートカットが存在する場合はショートカットを行い、 # ルートを短くする _next = {k: v for k, v in zip(route, route[1:] + route[:1])} ...
false
25.203252
[ "-def find_shortest_cycle(G, s):", "+def shorten_cycle(G, route):", "+ # ループだとすでに分かってるルートに対して、", "+ # ショートカットが存在する場合はショートカットを行い、", "+ # ルートを短くする", "+ _next = {k: v for k, v in zip(route, route[1:] + route[:1])}", "+ v = route[0]", "+ while True:", "+ # もしvからroute内の、次の点ではない点n...
false
0.060356
0.036892
1.635989
[ "s397029722", "s369267971" ]
u910632349
p03434
python
s906013230
s845781643
31
28
8,984
9,140
Accepted
Accepted
9.68
n=int(eval(input())) a=sorted(list(map(int,input().split())),reverse=True) alice=sum(a[::2]) bob=sum(a[1::2]) print((alice-bob))
n=int(eval(input())) a=sorted(list(map(int,input().split())),reverse=True) print((sum(a[::2])-sum(a[1::2])))
5
3
124
102
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) alice = sum(a[::2]) bob = sum(a[1::2]) print((alice - bob))
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) print((sum(a[::2]) - sum(a[1::2])))
false
40
[ "-alice = sum(a[::2])", "-bob = sum(a[1::2])", "-print((alice - bob))", "+print((sum(a[::2]) - sum(a[1::2])))" ]
false
0.049637
0.045577
1.089077
[ "s906013230", "s845781643" ]
u054514819
p02701
python
s682569226
s637923753
260
133
35,580
104,048
Accepted
Accepted
48.85
N = int(eval(input())) lis = [eval(input()) for _ in range(N)] print((len(set(lis))))
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ss = [eval(input()) for _ in range(N)] print((len(set(Ss[:N]))))
4
8
75
217
N = int(eval(input())) lis = [eval(input()) for _ in range(N)] print((len(set(lis))))
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ss = [eval(input()) for _ in range(N)] print((len(set(Ss[:N]))))
false
50
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "+def mapint():", "+ return list(map(int, input().split()))", "+", "+", "+sys.setrecursionlimit(10**9)", "-lis = [eval(input()) for _ in range(N)]", "-print((len(set(lis))))", "+Ss = [eval(...
false
0.033878
0.040946
0.827387
[ "s682569226", "s637923753" ]
u936735179
p02859
python
s990391291
s168053484
149
17
12,420
2,940
Accepted
Accepted
88.59
import numpy print((int(eval(input()))**2))
print((int(eval(input()))**2))
2
1
36
22
import numpy print((int(eval(input())) ** 2))
print((int(eval(input())) ** 2))
false
50
[ "-import numpy", "-" ]
false
0.038798
0.040114
0.967201
[ "s990391291", "s168053484" ]
u678167152
p02815
python
s521678397
s428686101
152
129
31,748
105,100
Accepted
Accepted
15.13
def solve(): ans = 0 N = int(eval(input())) C = list(map(int, input().split())) C.sort() mod = 10**9+7 for i in range(N): ans += C[i]*(N+1-i) ans %= mod ans = ans*pow(2,2*N-2,mod)%mod return ans print((solve()))
def solve(): ans = 0 N = int(eval(input())) C = list(map(int, input().split())) C.sort() mod = 10**9+7 for i in range(N): ans += C[i]*(N+1-i) ans = ans*pow(2,2*N-2)%mod return ans print((solve()))
12
11
238
218
def solve(): ans = 0 N = int(eval(input())) C = list(map(int, input().split())) C.sort() mod = 10**9 + 7 for i in range(N): ans += C[i] * (N + 1 - i) ans %= mod ans = ans * pow(2, 2 * N - 2, mod) % mod return ans print((solve()))
def solve(): ans = 0 N = int(eval(input())) C = list(map(int, input().split())) C.sort() mod = 10**9 + 7 for i in range(N): ans += C[i] * (N + 1 - i) ans = ans * pow(2, 2 * N - 2) % mod return ans print((solve()))
false
8.333333
[ "- ans %= mod", "- ans = ans * pow(2, 2 * N - 2, mod) % mod", "+ ans = ans * pow(2, 2 * N - 2) % mod" ]
false
0.09634
0.035335
2.726493
[ "s521678397", "s428686101" ]
u575431498
p02803
python
s193069935
s741726366
665
560
3,436
3,444
Accepted
Accepted
15.79
from collections import deque from copy import deepcopy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] dxs = [0, 0, 1, -1] dys = [1, -1, 0, 0] cand = [] field_org = [[-1] * W for _ in range(H)] for j in range(H): for i in range(W): if S[j][i] == '#': ...
from collections import deque from copy import copy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] dxs = [0, 0, 1, -1] dys = [1, -1, 0, 0] cand = [] field_org = [-1] * (W * H) for j in range(H): for i in range(W): if S[j][i] == '#': continue ...
28
29
850
851
from collections import deque from copy import deepcopy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] dxs = [0, 0, 1, -1] dys = [1, -1, 0, 0] cand = [] field_org = [[-1] * W for _ in range(H)] for j in range(H): for i in range(W): if S[j][i] == "#": continue...
from collections import deque from copy import copy H, W = list(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] dxs = [0, 0, 1, -1] dys = [1, -1, 0, 0] cand = [] field_org = [-1] * (W * H) for j in range(H): for i in range(W): if S[j][i] == "#": continue q = deque...
false
3.448276
[ "-from copy import deepcopy", "+from copy import copy", "-field_org = [[-1] * W for _ in range(H)]", "+field_org = [-1] * (W * H)", "- field = deepcopy(field_org)", "- field[j][i] = 0", "+ field = copy(field_org)", "+ field[j * W + i] = 0", "+ f_idx = y * W...
false
0.133491
0.069481
1.921245
[ "s193069935", "s741726366" ]
u836939578
p02571
python
s228679458
s256002506
118
68
73,420
73,036
Accepted
Accepted
42.37
S = eval(input()) T = eval(input()) ans = 0 for i in range(len(S)-len(T)+1): tmp = 0 pos = i for j in range(len(T)): if pos < len(S): if S[pos] == T[j]: tmp += 1 pos += 1 ans = max(tmp, ans) print((len(T)-ans))
S = eval(input()) T = eval(input()) ans = len(S) for i in range(len(S)-len(T)+1): tmp = 0 for j in range(len(T)): if S[i+j] != T[j]: tmp += 1 ans = min(ans, tmp) print(ans)
15
13
272
207
S = eval(input()) T = eval(input()) ans = 0 for i in range(len(S) - len(T) + 1): tmp = 0 pos = i for j in range(len(T)): if pos < len(S): if S[pos] == T[j]: tmp += 1 pos += 1 ans = max(tmp, ans) print((len(T) - ans))
S = eval(input()) T = eval(input()) ans = len(S) for i in range(len(S) - len(T) + 1): tmp = 0 for j in range(len(T)): if S[i + j] != T[j]: tmp += 1 ans = min(ans, tmp) print(ans)
false
13.333333
[ "-ans = 0", "+ans = len(S)", "- pos = i", "- if pos < len(S):", "- if S[pos] == T[j]:", "- tmp += 1", "- pos += 1", "- ans = max(tmp, ans)", "-print((len(T) - ans))", "+ if S[i + j] != T[j]:", "+ tmp += 1", "+ ans = min(ans, tm...
false
0.045528
0.036662
1.241829
[ "s228679458", "s256002506" ]
u539969758
p02726
python
s771719766
s781997359
1,792
1,399
3,444
3,444
Accepted
Accepted
21.93
N, X, Y = list(map(int,input().split())) k_list = [0]*N for p in range(1, N): for q in range(p, N+1): p2X = abs(p - X) p2Y = abs(p - Y) q2X = abs(q - X) q2Y = abs(q - Y) distance = min(q-p, p2X+1+q2Y) k_list[distance] += 1 for k in range(1, N): pr...
N, X, Y = list(map(int,input().split())) k_list = [0]*N for p in range(1, N): for q in range(p, N+1): p2X = abs(p - X) q2Y = abs(q - Y) distance = min(q-p, p2X+1+q2Y) k_list[distance] += 1 for k in range(1, N): print((k_list[k]))
15
13
328
276
N, X, Y = list(map(int, input().split())) k_list = [0] * N for p in range(1, N): for q in range(p, N + 1): p2X = abs(p - X) p2Y = abs(p - Y) q2X = abs(q - X) q2Y = abs(q - Y) distance = min(q - p, p2X + 1 + q2Y) k_list[distance] += 1 for k in range(1, N): print((k...
N, X, Y = list(map(int, input().split())) k_list = [0] * N for p in range(1, N): for q in range(p, N + 1): p2X = abs(p - X) q2Y = abs(q - Y) distance = min(q - p, p2X + 1 + q2Y) k_list[distance] += 1 for k in range(1, N): print((k_list[k]))
false
13.333333
[ "- p2Y = abs(p - Y)", "- q2X = abs(q - X)" ]
false
0.046621
0.038044
1.225468
[ "s771719766", "s781997359" ]
u026155812
p03476
python
s354605246
s982338049
854
328
14,440
27,236
Accepted
Accepted
61.59
from itertools import accumulate Q = int(eval(input())) def prime(n): # 素数列挙 # nまでの素数をリストで返す(nを含む) primes = set(range(2, n+1)) for i in range(2, int(n**0.5+1)): primes.difference_update(list(range(i*2, n+1, i))) primes=list(primes) return primes prime_set = set(prime(10**5)...
from itertools import accumulate Q = int(eval(input())) m = 0 ls = [] for i in range(Q): l, r = list(map(int, input().split())) m = max(m, max(l, r)) ls.append((l, r)) def sieve_eratosthenes(n): primes = [0, 1] * (n // 2 + 1) if n % 2 == 0: primes.pop() primes[1] = 0 p...
28
29
641
700
from itertools import accumulate Q = int(eval(input())) def prime(n): # 素数列挙 # nまでの素数をリストで返す(nを含む) primes = set(range(2, n + 1)) for i in range(2, int(n**0.5 + 1)): primes.difference_update(list(range(i * 2, n + 1, i))) primes = list(primes) return primes prime_set = set(prime(10**5...
from itertools import accumulate Q = int(eval(input())) m = 0 ls = [] for i in range(Q): l, r = list(map(int, input().split())) m = max(m, max(l, r)) ls.append((l, r)) def sieve_eratosthenes(n): primes = [0, 1] * (n // 2 + 1) if n % 2 == 0: primes.pop() primes[1] = 0 primes[2] = 1...
false
3.448276
[ "+m = 0", "+ls = []", "+for i in range(Q):", "+ l, r = list(map(int, input().split()))", "+ m = max(m, max(l, r))", "+ ls.append((l, r))", "-def prime(n):", "- # 素数列挙", "- # nまでの素数をリストで返す(nを含む)", "- primes = set(range(2, n + 1))", "- for i in range(2, int(n**0.5 + 1)):", "...
false
0.147991
0.046694
3.169345
[ "s354605246", "s982338049" ]
u815763296
p02596
python
s439739877
s676912381
236
208
9,016
9,068
Accepted
Accepted
11.86
K = int(eval(input())) like = 7 ans = -1 for i in range(K): if like % K == 0: ans = i+1 break like = (like*10+7) % K print(ans)
K = int(eval(input())) ans = -1 N = 7 for i in range(K): if N % K == 0: ans = i+1 break N = (N*10+7) % K print(ans)
9
9
154
142
K = int(eval(input())) like = 7 ans = -1 for i in range(K): if like % K == 0: ans = i + 1 break like = (like * 10 + 7) % K print(ans)
K = int(eval(input())) ans = -1 N = 7 for i in range(K): if N % K == 0: ans = i + 1 break N = (N * 10 + 7) % K print(ans)
false
0
[ "-like = 7", "+N = 7", "- if like % K == 0:", "+ if N % K == 0:", "- like = (like * 10 + 7) % K", "+ N = (N * 10 + 7) % K" ]
false
0.120169
0.071754
1.674733
[ "s439739877", "s676912381" ]
u482982507
p03965
python
s318760890
s701586785
45
32
3,316
3,316
Accepted
Accepted
28.89
s = eval(input()) score = 0 for i in range(len(s)): if i % 2 == 0: if s[i] == 'p': score -= 1 else: if s[i] == 'g': score += 1 print(score)
s = eval(input()) p = 0 for i in range(len(s)): if s[i] == 'p': p += 1 print((-p + len(s) // 2))
8
5
164
96
s = eval(input()) score = 0 for i in range(len(s)): if i % 2 == 0: if s[i] == "p": score -= 1 else: if s[i] == "g": score += 1 print(score)
s = eval(input()) p = 0 for i in range(len(s)): if s[i] == "p": p += 1 print((-p + len(s) // 2))
false
37.5
[ "-score = 0", "+p = 0", "- if i % 2 == 0:", "- if s[i] == \"p\":", "- score -= 1", "- else:", "- if s[i] == \"g\":", "- score += 1", "-print(score)", "+ if s[i] == \"p\":", "+ p += 1", "+print((-p + len(s) // 2))" ]
false
0.041612
0.034939
1.190966
[ "s318760890", "s701586785" ]
u914797917
p03555
python
s001839009
s136879509
20
17
3,060
2,940
Accepted
Accepted
15
c = [eval(input()) for i in range(2)] c0=[] for i in range(3): c0.append(c[0][i]) c1=[] for i in range(3): c1.append(c[1][i]) if c0[0]==c1[2] and c0[1]==c1[1] and c0[2]==c1[0]: print('YES') else: print('NO')
c1=eval(input()) c2=eval(input()) print(('YES' if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] else 'NO'))
13
3
225
96
c = [eval(input()) for i in range(2)] c0 = [] for i in range(3): c0.append(c[0][i]) c1 = [] for i in range(3): c1.append(c[1][i]) if c0[0] == c1[2] and c0[1] == c1[1] and c0[2] == c1[0]: print("YES") else: print("NO")
c1 = eval(input()) c2 = eval(input()) print(("YES" if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0] else "NO"))
false
76.923077
[ "-c = [eval(input()) for i in range(2)]", "-c0 = []", "-for i in range(3):", "- c0.append(c[0][i])", "-c1 = []", "-for i in range(3):", "- c1.append(c[1][i])", "-if c0[0] == c1[2] and c0[1] == c1[1] and c0[2] == c1[0]:", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+c1 = eval(...
false
0.047432
0.049393
0.960289
[ "s001839009", "s136879509" ]
u445624660
p03355
python
s194663185
s399815975
75
48
74,036
11,192
Accepted
Accepted
36
# kが極端に少ないので、下位K個を管理してよさそうな気がする # -> なんかダメ # じゃ決め打ちして全探索することにしてみる どうせ長さは最大でKなので # 時間的に間に合うか微妙な気がする # -> はい s = list(eval(input())) k = int(eval(input())) d = {} for i in range(len(s)): for j in range(i, min(i + k, len(s))): t = "".join(s[i:j + 1]) if t not in d: d[t] = True...
s = eval(input()) k = int(eval(input())) lis = [] for i in range(len(s)): for j in range(k): lis.append("".join(s[i:i + j + 1])) lis = sorted(list(set(lis))) print((lis[k - 1]))
16
10
350
187
# kが極端に少ないので、下位K個を管理してよさそうな気がする # -> なんかダメ # じゃ決め打ちして全探索することにしてみる どうせ長さは最大でKなので # 時間的に間に合うか微妙な気がする # -> はい s = list(eval(input())) k = int(eval(input())) d = {} for i in range(len(s)): for j in range(i, min(i + k, len(s))): t = "".join(s[i : j + 1]) if t not in d: d[t] = True dk = sorted...
s = eval(input()) k = int(eval(input())) lis = [] for i in range(len(s)): for j in range(k): lis.append("".join(s[i : i + j + 1])) lis = sorted(list(set(lis))) print((lis[k - 1]))
false
37.5
[ "-# kが極端に少ないので、下位K個を管理してよさそうな気がする", "-# -> なんかダメ", "-# じゃ決め打ちして全探索することにしてみる どうせ長さは最大でKなので", "-# 時間的に間に合うか微妙な気がする", "-# -> はい", "-s = list(eval(input()))", "+s = eval(input())", "-d = {}", "+lis = []", "- for j in range(i, min(i + k, len(s))):", "- t = \"\".join(s[i : j + 1])", "- ...
false
0.046002
0.144252
0.3189
[ "s194663185", "s399815975" ]
u312025627
p02994
python
s247565576
s108080491
184
17
38,384
3,060
Accepted
Accepted
90.76
def main(): N, L = (int(i) for i in input().split()) s = 0 li = [] for i in range(1, N+1): s += L + i - 1 li.append((abs(L + i - 1), i)) li.sort() print((s - (L + li[0][1] - 1))) if __name__ == '__main__': main()
def main(): N, L = (int(i) for i in input().split()) s = sum(L+i-1 for i in range(1, N+1)) mi = 10**5 ans = -1 for i in range(1, N+1): cur = L + i - 1 eat = s - cur if abs(s - eat) < mi: mi = abs(s - eat) ans = eat print(ans) if __n...
14
16
271
353
def main(): N, L = (int(i) for i in input().split()) s = 0 li = [] for i in range(1, N + 1): s += L + i - 1 li.append((abs(L + i - 1), i)) li.sort() print((s - (L + li[0][1] - 1))) if __name__ == "__main__": main()
def main(): N, L = (int(i) for i in input().split()) s = sum(L + i - 1 for i in range(1, N + 1)) mi = 10**5 ans = -1 for i in range(1, N + 1): cur = L + i - 1 eat = s - cur if abs(s - eat) < mi: mi = abs(s - eat) ans = eat print(ans) if __name__ ...
false
12.5
[ "- s = 0", "- li = []", "+ s = sum(L + i - 1 for i in range(1, N + 1))", "+ mi = 10**5", "+ ans = -1", "- s += L + i - 1", "- li.append((abs(L + i - 1), i))", "- li.sort()", "- print((s - (L + li[0][1] - 1)))", "+ cur = L + i - 1", "+ eat = s - cu...
false
0.036551
0.03509
1.041636
[ "s247565576", "s108080491" ]