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
u996749146
p03326
python
s659199830
s853920768
66
26
3,828
3,316
Accepted
Accepted
60.61
# https://abc100.contest.atcoder.jp/tasks/abc100_d # D - Patisserie ABC # D_Patisserie_ABC.py import collections N, M = list(map(int, input().strip().split(" "))) A = [[] for i in range(8)] for n in range(N): # 「綺麗さ」「おいしさ」「人気度」 x, y, z = list(map(int, input().strip().split(" "))) A[0].appen...
# https://abc100.contest.atcoder.jp/tasks/abc100_d # D - Patisserie ABC # D_Patisserie_ABC.py #import collections N, M = list(map(int, input().strip().split(" "))) A = [[] for i in range(8)] for n in range(N): # 「綺麗さ」「おいしさ」「人気度」 x, y, z = list(map(int, input().strip().split(" "))) A[0].appe...
33
33
653
654
# https://abc100.contest.atcoder.jp/tasks/abc100_d # D - Patisserie ABC # D_Patisserie_ABC.py import collections N, M = list(map(int, input().strip().split(" "))) A = [[] for i in range(8)] for n in range(N): # 「綺麗さ」「おいしさ」「人気度」 x, y, z = list(map(int, input().strip().split(" "))) A[0].append(x + y + z) ...
# https://abc100.contest.atcoder.jp/tasks/abc100_d # D - Patisserie ABC # D_Patisserie_ABC.py # import collections N, M = list(map(int, input().strip().split(" "))) A = [[] for i in range(8)] for n in range(N): # 「綺麗さ」「おいしさ」「人気度」 x, y, z = list(map(int, input().strip().split(" "))) A[0].append(x + y + z) ...
false
0
[ "-import collections", "-", "+# import collections" ]
false
0.037888
0.057872
0.654682
[ "s659199830", "s853920768" ]
u529012223
p02989
python
s277246920
s239092060
208
76
23,400
14,396
Accepted
Accepted
63.46
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A_sorted = sorted(A) print((A_sorted[int(N/2)] - A_sorted[int(N/2)-1]))
N = int(eval(input())) d = list(map(int, input().split())) d.sort() if N % 2 == 1: print((0)) else: print((d[N//2] - d[N//2-1]))
9
9
153
136
import numpy as np N = int(eval(input())) A = list(map(int, input().split())) A_sorted = sorted(A) print((A_sorted[int(N / 2)] - A_sorted[int(N / 2) - 1]))
N = int(eval(input())) d = list(map(int, input().split())) d.sort() if N % 2 == 1: print((0)) else: print((d[N // 2] - d[N // 2 - 1]))
false
0
[ "-import numpy as np", "-", "-A = list(map(int, input().split()))", "-A_sorted = sorted(A)", "-print((A_sorted[int(N / 2)] - A_sorted[int(N / 2) - 1]))", "+d = list(map(int, input().split()))", "+d.sort()", "+if N % 2 == 1:", "+ print((0))", "+else:", "+ print((d[N // 2] - d[N // 2 - 1]))"...
false
0.14135
0.076793
1.840651
[ "s277246920", "s239092060" ]
u445624660
p03252
python
s511266190
s291239831
214
87
41,712
12,236
Accepted
Accepted
59.35
# きりみんちゃんの配信からきました # 登場回数が同一ならいけそうなのでそうする s, t = eval(input()), eval(input()) sd, td = {}, {} for sv in s: if sv in sd: sd[sv] += 1 else: sd[sv] = 1 for tv in t: if tv in td: td[tv] += 1 else: td[tv] = 1 sort_sk, sort_tk = sorted(sd.values()), sorted(td.valu...
# chokudaiをredcorderにするのはなんとなくできそうなきがするがなんでできないのだろうか # c->r, r->c = rhokudai # i->r, r->I = ihokudar # たしかに出来なかった # つまり目的の文字にできるのはせいぜい1回まで # (2回目以降はそれより前に変化させた文字に影響が出る) # なので、各文字の登場回数を出し、その数だけで比較する s, t = list(eval(input())), list(eval(input())) sd, td = {}, {} for sv in s: if sv not in sd: sd[sv...
16
24
359
541
# きりみんちゃんの配信からきました # 登場回数が同一ならいけそうなのでそうする s, t = eval(input()), eval(input()) sd, td = {}, {} for sv in s: if sv in sd: sd[sv] += 1 else: sd[sv] = 1 for tv in t: if tv in td: td[tv] += 1 else: td[tv] = 1 sort_sk, sort_tk = sorted(sd.values()), sorted(td.values()) print(("...
# chokudaiをredcorderにするのはなんとなくできそうなきがするがなんでできないのだろうか # c->r, r->c = rhokudai # i->r, r->I = ihokudar # たしかに出来なかった # つまり目的の文字にできるのはせいぜい1回まで # (2回目以降はそれより前に変化させた文字に影響が出る) # なので、各文字の登場回数を出し、その数だけで比較する s, t = list(eval(input())), list(eval(input())) sd, td = {}, {} for sv in s: if sv not in sd: sd[sv] = 1 e...
false
33.333333
[ "-# きりみんちゃんの配信からきました", "-# 登場回数が同一ならいけそうなのでそうする", "-s, t = eval(input()), eval(input())", "+# chokudaiをredcorderにするのはなんとなくできそうなきがするがなんでできないのだろうか", "+# c->r, r->c = rhokudai", "+# i->r, r->I = ihokudar", "+# たしかに出来なかった", "+# つまり目的の文字にできるのはせいぜい1回まで", "+# (2回目以降はそれより前に変化させた文字に影響が出る)", "+# なので、各文字の登場回...
false
0.031811
0.035383
0.899046
[ "s511266190", "s291239831" ]
u535423069
p03166
python
s775844129
s780352668
619
452
78,984
43,696
Accepted
Accepted
26.98
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range...
47
67
1,054
1,466
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdi...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdi...
false
29.850746
[ "+from collections import deque", "+", "+deg = [0] * n", "+ deg[y] += 1", "+def bfs():", "+ q = deque()", "+ for i in range(n):", "+ if deg[i] == 0:", "+ q.append(i)", "+ dp = [0] * n", "+ while len(q):", "+ p = q.popleft()", "+ for v in g[p]:",...
false
0.037471
0.147327
0.254338
[ "s775844129", "s780352668" ]
u197968862
p03161
python
s758608168
s602340312
492
239
55,776
85,888
Accepted
Accepted
51.42
n, k = list(map(int,input().split())) h = list(map(int,input().split())) dp = [float('inf')] * n dp[0] = 0 dp[1] = abs(h[1]-h[0]) for i in range(2,n): for j in range(k+1): if i - j < 0: continue dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]) print((dp[-1]))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float('inf')] * n dp[0]= 0 for i in range(n): for j in range(k+1): if i + j < n: dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i])) print((dp[-1]))
12
12
290
258
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, n): for j in range(k + 1): if i - j < 0: continue dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]) print((dp[-1]))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 for i in range(n): for j in range(k + 1): if i + j < n: dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) print((dp[-1]))
false
0
[ "-dp[1] = abs(h[1] - h[0])", "-for i in range(2, n):", "+for i in range(n):", "- if i - j < 0:", "- continue", "- dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])", "+ if i + j < n:", "+ dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))" ]
false
0.034636
0.075142
0.460941
[ "s758608168", "s602340312" ]
u296518383
p03273
python
s215274052
s953332277
178
22
39,536
3,064
Accepted
Accepted
87.64
H, W = list(map(int, input().split())) A = [eval(input()) for _ in range(H)] h_check = [0] * H w_check = [0] * W for i in range(H): flag = 0 for j in range(W): if A[i][j] != ".": flag = 1 break h_check[i] = flag for j in range(W): flag = 0 for i in range(H): if A[i][j] ...
H, W = list(map(int, input().split())) A = [eval(input()) for _ in range(H)] h_check = [0] * H w_check = [0] * W for i in range(H): for j in range(W): if A[i][j] == ".": h_check[i] += 1 w_check[j] += 1 h_check = list([1 - x // W for x in h_check]) w_check = list([1 - x // H for x in w_...
29
22
505
465
H, W = list(map(int, input().split())) A = [eval(input()) for _ in range(H)] h_check = [0] * H w_check = [0] * W for i in range(H): flag = 0 for j in range(W): if A[i][j] != ".": flag = 1 break h_check[i] = flag for j in range(W): flag = 0 for i in range(H): i...
H, W = list(map(int, input().split())) A = [eval(input()) for _ in range(H)] h_check = [0] * H w_check = [0] * W for i in range(H): for j in range(W): if A[i][j] == ".": h_check[i] += 1 w_check[j] += 1 h_check = list([1 - x // W for x in h_check]) w_check = list([1 - x // H for x in ...
false
24.137931
[ "- flag = 0", "- if A[i][j] != \".\":", "- flag = 1", "- break", "- h_check[i] = flag", "-for j in range(W):", "- flag = 0", "- for i in range(H):", "- if A[i][j] != \".\":", "- flag = 1", "- break", "- w_check[j] = flag"...
false
0.081763
0.037508
2.179887
[ "s215274052", "s953332277" ]
u077291787
p03127
python
s788330837
s331113205
87
78
16,280
16,156
Accepted
Accepted
10.34
# ABC118C - Monsters Battle Royale from fractions import gcd n = int(eval(input())) arr = list(map(int, input().rstrip().split())) ans = arr[0] for i in arr[1:]: ans = gcd(ans, i) print(ans)
# ABC118C - Monsters Battle Royale from functools import reduce from fractions import gcd def main(): N, *A = list(map(int, open(0).read().split())) ans = reduce(gcd, A) print(ans) if __name__ == "__main__": main()
9
13
197
240
# ABC118C - Monsters Battle Royale from fractions import gcd n = int(eval(input())) arr = list(map(int, input().rstrip().split())) ans = arr[0] for i in arr[1:]: ans = gcd(ans, i) print(ans)
# ABC118C - Monsters Battle Royale from functools import reduce from fractions import gcd def main(): N, *A = list(map(int, open(0).read().split())) ans = reduce(gcd, A) print(ans) if __name__ == "__main__": main()
false
30.769231
[ "+from functools import reduce", "-n = int(eval(input()))", "-arr = list(map(int, input().rstrip().split()))", "-ans = arr[0]", "-for i in arr[1:]:", "- ans = gcd(ans, i)", "-print(ans)", "+", "+def main():", "+ N, *A = list(map(int, open(0).read().split()))", "+ ans = reduce(gcd, A)", ...
false
0.052374
0.086288
0.606972
[ "s788330837", "s331113205" ]
u816631826
p02707
python
s910238592
s733559394
180
152
33,288
32,320
Accepted
Accepted
15.56
# In peace, in love, in war, everything is the same import math deg = [0] * 200005 n=int(eval(input())) ar = list(map(int, input().split())) for i in range(n-1): deg[ar[i]] = deg[ar[i]] + 1 for i in range(1, n+1, 1): print((deg[i]))
if __name__ == "__main__": tcase = int(eval(input())) pcase = [ int(i) for i in input().split(' ')] leng = len(pcase) + 1 items = [0]*leng for i in pcase: items[i-1] +=1 for i in items: print(i)
13
9
248
237
# In peace, in love, in war, everything is the same import math deg = [0] * 200005 n = int(eval(input())) ar = list(map(int, input().split())) for i in range(n - 1): deg[ar[i]] = deg[ar[i]] + 1 for i in range(1, n + 1, 1): print((deg[i]))
if __name__ == "__main__": tcase = int(eval(input())) pcase = [int(i) for i in input().split(" ")] leng = len(pcase) + 1 items = [0] * leng for i in pcase: items[i - 1] += 1 for i in items: print(i)
false
30.769231
[ "-# In peace, in love, in war, everything is the same", "-import math", "-", "-deg = [0] * 200005", "-n = int(eval(input()))", "-ar = list(map(int, input().split()))", "-for i in range(n - 1):", "- deg[ar[i]] = deg[ar[i]] + 1", "-for i in range(1, n + 1, 1):", "- print((deg[i]))", "+if __n...
false
0.0593
0.033378
1.77663
[ "s910238592", "s733559394" ]
u466917094
p03291
python
s724806701
s978029319
993
581
21,500
13,280
Accepted
Accepted
41.49
import numpy as np s=eval(input()) n=len(s) MOD=1000000007 wayA=np.array([0,0,0,0]) wayB=np.array([0,0,0,0]) wayC=np.array([0,0,0,0]) hatena=0 for c in s: if c=="A": wayA[0]+=1 if c=="B": wayB+=wayA if c=='C': wayC+=wayB if c=='?': wayC[1]=wayC[1]+wayB[0] wayC[2]=wayC[2]+wayB[1] wayC[3...
import numpy as np s=eval(input()) wayA=np.array([0,0,0,0]) wayB=np.array([0,0,0,0]) wayC=np.array([0,0,0,0]) hatena=0 for c in s: if c=="A": wayA[0]+=1 if c=="B": wayB+=wayA if c=='C': wayC+=wayB if c=='?': wayC[1]+=wayB[0] wayC[2]+=wayB[1] wayC[3]+=wayB[2] wayB[1]+=wayA[0] wayB[2...
27
25
500
437
import numpy as np s = eval(input()) n = len(s) MOD = 1000000007 wayA = np.array([0, 0, 0, 0]) wayB = np.array([0, 0, 0, 0]) wayC = np.array([0, 0, 0, 0]) hatena = 0 for c in s: if c == "A": wayA[0] += 1 if c == "B": wayB += wayA if c == "C": wayC += wayB if c == "?": wa...
import numpy as np s = eval(input()) wayA = np.array([0, 0, 0, 0]) wayB = np.array([0, 0, 0, 0]) wayC = np.array([0, 0, 0, 0]) hatena = 0 for c in s: if c == "A": wayA[0] += 1 if c == "B": wayB += wayA if c == "C": wayC += wayB if c == "?": wayC[1] += wayB[0] way...
false
7.407407
[ "-n = len(s)", "-MOD = 1000000007", "- wayC[1] = wayC[1] + wayB[0]", "- wayC[2] = wayC[2] + wayB[1]", "- wayC[3] = wayC[3] + wayB[2]", "- wayB[1] = wayB[1] + wayA[0]", "- wayB[2] = wayB[2] + wayA[1]", "- wayA[1] = wayA[1] + 1", "+ wayC[1] += wayB[0]",...
false
0.472914
0.495181
0.955032
[ "s724806701", "s978029319" ]
u200887663
p03137
python
s629537811
s296347424
126
114
13,968
13,968
Accepted
Accepted
9.52
#n=int(input()) n,m=list(map(int,input().split())) xl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] cuml=[] if n>=m: print((0)) else: xl.sort() rng=xl[m-1]-xl[0] ans=rng for i in range(1,m): cuml.append(xl[i]-xl[i-1]) cuml.sort() f...
#h=int(input()) n,m=list(map(int,input().split())) xl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] if n>=m: ans=0 else: xl.sort() bet=[] for i in range(1,m): bet.append(xl[i]-xl[i-1]) bet.sort(reverse=True) ans=xl[m-1]-xl[0]-(sum(bet[...
17
16
373
337
# n=int(input()) n, m = list(map(int, input().split())) xl = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] cuml = [] if n >= m: print((0)) else: xl.sort() rng = xl[m - 1] - xl[0] ans = rng for i in range(1, m): cuml.append(xl[i] - xl[i - 1]) cuml....
# h=int(input()) n, m = list(map(int, input().split())) xl = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] if n >= m: ans = 0 else: xl.sort() bet = [] for i in range(1, m): bet.append(xl[i] - xl[i - 1]) bet.sort(reverse=True) ans = xl[m - 1] - xl[...
false
5.882353
[ "-# n=int(input())", "+# h=int(input())", "-cuml = []", "- print((0))", "+ ans = 0", "- rng = xl[m - 1] - xl[0]", "- ans = rng", "+ bet = []", "- cuml.append(xl[i] - xl[i - 1])", "- cuml.sort()", "- for i in range(n - 1):", "- ans -= cuml[m - 2 - i]", "- ...
false
0.043426
0.043475
0.998888
[ "s629537811", "s296347424" ]
u970197315
p03165
python
s092279058
s539304070
525
344
114,396
144,564
Accepted
Accepted
34.48
# F - LCS s=eval(input()) t=eval(input()) ns=len(s) nt=len(t) dp=[[0]*(nt+1) for i in range(ns+1)] for i in range(ns): for j in range(nt): if s[i]==t[j]: dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]) dp[i+1][j+1]=max(dp[i+1][j+1]...
s = eval(input()) t = eval(input()) s_length = len(s) t_length = len(t) dp = [[0]*(t_length + 1) for _ in range(s_length + 1)] for i in range(s_length): for j in range(t_length): if s[i]==t[j]: dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]) dp[i+1][j+1] = max(dp[i+1][j+...
28
27
639
611
# F - LCS s = eval(input()) t = eval(input()) ns = len(s) nt = len(t) dp = [[0] * (nt + 1) for i in range(ns + 1)] for i in range(ns): for j in range(nt): if s[i] == t[j]: dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]) ...
s = eval(input()) t = eval(input()) s_length = len(s) t_length = len(t) dp = [[0] * (t_length + 1) for _ in range(s_length + 1)] for i in range(s_length): for j in range(t_length): if s[i] == t[j]: dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]) dp[i + 1][j + 1] = max(dp[i + 1][j ...
false
3.571429
[ "-# F - LCS", "-ns = len(s)", "-nt = len(t)", "-dp = [[0] * (nt + 1) for i in range(ns + 1)]", "-for i in range(ns):", "- for j in range(nt):", "+s_length = len(s)", "+t_length = len(t)", "+dp = [[0] * (t_length + 1) for _ in range(s_length + 1)]", "+for i in range(s_length):", "+ for j in...
false
0.055267
0.059777
0.924564
[ "s092279058", "s539304070" ]
u264972437
p02266
python
s369069530
s133698127
140
120
9,816
10,204
Accepted
Accepted
14.29
data = eval(input()) #data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\' diff = {'\\':-1, '_':0, '/':1} height = [0] [height.append(height[-1]+diff[i]) for i in data] bottom = min(height) height = [h-bottom for h in height] m = max(height) water = [m for h in height] height00 = [0] + height + ...
data = eval(input()) #data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\' diff = {'\\':-1, '_':0, '/':1} height = [0] [height.append(height[-1]+diff[i]) for i in data] bottom = min(height) height = [h-bottom for h in height] m = max(height) water = [m for h in height] height00 = [0] + height + ...
35
30
859
775
data = eval(input()) # data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\' diff = {"\\": -1, "_": 0, "/": 1} height = [0] [height.append(height[-1] + diff[i]) for i in data] bottom = min(height) height = [h - bottom for h in height] m = max(height) water = [m for h in height] height00 = [0] + height + [0] w...
data = eval(input()) # data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\' diff = {"\\": -1, "_": 0, "/": 1} height = [0] [height.append(height[-1] + diff[i]) for i in data] bottom = min(height) height = [h - bottom for h in height] m = max(height) water = [m for h in height] height00 = [0] + height + [0] w...
false
14.285714
[ "-roop = True", "-forward = 1", "-while roop:", "- temp = water00[:]", "- for i in range(1, len(water00) - 1)[::forward]:", "- water00[i] = max(height00[i], min(water00[i - 1 : i + 2]))", "- roop = temp != water00", "- forward *= -1", "+idx = list(range(1, len(water00) - 1))", "...
false
0.043025
0.04203
1.023668
[ "s369069530", "s133698127" ]
u057668615
p02660
python
s144292800
s046643448
1,268
153
31,724
9,116
Accepted
Accepted
87.93
import math def get_prime(n): if n <= 1: return [] prime = [2] if n > 2: limit = int(math.sqrt(n)) odd = [i for i in range(3, n + 1, 2)] while limit >= odd[0]: prime.append(odd[0]) odd = [j for j in odd if j % odd[0] != 0] prime += o...
def p_facto(n): ret = [] nc = n for i in range(2, nc): if i*i > nc: break if n % i == 0: ex = 0 while n % i == 0: ex += 1 n //= i ret.append([i, ex]) if n != 1: ret.append([n, 1]) re...
47
37
1,018
689
import math def get_prime(n): if n <= 1: return [] prime = [2] if n > 2: limit = int(math.sqrt(n)) odd = [i for i in range(3, n + 1, 2)] while limit >= odd[0]: prime.append(odd[0]) odd = [j for j in odd if j % odd[0] != 0] prime += odd re...
def p_facto(n): ret = [] nc = n for i in range(2, nc): if i * i > nc: break if n % i == 0: ex = 0 while n % i == 0: ex += 1 n //= i ret.append([i, ex]) if n != 1: ret.append([n, 1]) return ret d...
false
21.276596
[ "-import math", "+def p_facto(n):", "+ ret = []", "+ nc = n", "+ for i in range(2, nc):", "+ if i * i > nc:", "+ break", "+ if n % i == 0:", "+ ex = 0", "+ while n % i == 0:", "+ ex += 1", "+ n //= i", "+ ...
false
0.33685
0.056688
5.94218
[ "s144292800", "s046643448" ]
u771917453
p02412
python
s208838399
s341532915
410
370
6,372
6,444
Accepted
Accepted
9.76
while True: n,x= list(map(int,input().split())) if n == x == 0: break count = 0 for i in range(1,n+1): for j in range(i+1,n+1): for k in range(j+1,n+1): if i+j+k == x : count = count + 1 print(count)
while True: n,x= list(map(int,input().split())) if n == x == 0: break count = 0 for i in range(1,n+1): for j in range(i+1,n+1): for k in range(j+1,n+1): if i + j + k == x: count = count + 1 break pri...
13
14
294
326
while True: n, x = list(map(int, input().split())) if n == x == 0: break count = 0 for i in range(1, n + 1): for j in range(i + 1, n + 1): for k in range(j + 1, n + 1): if i + j + k == x: count = count + 1 print(count)
while True: n, x = list(map(int, input().split())) if n == x == 0: break count = 0 for i in range(1, n + 1): for j in range(i + 1, n + 1): for k in range(j + 1, n + 1): if i + j + k == x: count = count + 1 break prin...
false
7.142857
[ "+ break" ]
false
0.089716
0.102871
0.872122
[ "s208838399", "s341532915" ]
u151005508
p03575
python
s119607226
s710542335
203
22
43,612
3,316
Accepted
Accepted
89.16
N, M = list(map(int, input().split())) ab=[] for _ in range(M): ab.append(tuple(map(int, input().split()))) def func(n): seen[n]=True for val in lst[n]: if seen[val] == False: todo.append(val) if todo: func(todo.pop(-1)) else: return None count=...
from collections import deque N, M = list(map(int, input().split())) # 辺集合Eとグラフの構築 G = [[] for _ in range(N)] E = [] for _ in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 E.append((a, b)) G[a].append(b) G[b].append(a) # print(G) cnt = 0 for edge_to_remove ...
35
42
694
802
N, M = list(map(int, input().split())) ab = [] for _ in range(M): ab.append(tuple(map(int, input().split()))) def func(n): seen[n] = True for val in lst[n]: if seen[val] == False: todo.append(val) if todo: func(todo.pop(-1)) else: return None count = 0 for edg...
from collections import deque N, M = list(map(int, input().split())) # 辺集合Eとグラフの構築 G = [[] for _ in range(N)] E = [] for _ in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 E.append((a, b)) G[a].append(b) G[b].append(a) # print(G) cnt = 0 for edge_to_remove in E: i, j = edge...
false
16.666667
[ "+from collections import deque", "+", "-ab = []", "+# 辺集合Eとグラフの構築", "+G = [[] for _ in range(N)]", "+E = []", "- ab.append(tuple(map(int, input().split())))", "-", "-", "-def func(n):", "- seen[n] = True", "- for val in lst[n]:", "- if seen[val] == False:", "- t...
false
0.046487
0.116559
0.398828
[ "s119607226", "s710542335" ]
u912179452
p02995
python
s517078136
s795650688
23
18
3,064
3,064
Accepted
Accepted
21.74
""" import math def lcm(x, y): return (x * y) // math.gcd(x, y) A, B, C, D = map(int, input().split()) # A以上B以下でCで割り切れる数の個数 x1 = (A-1) // C x2 = B // C x = x2 - x1 #print("x:", x) # A以上B以下でDで割り切れる数の個数 y1 = (A-1) // D y2 = B // D y = y2 - y1 #print("y", y) # A以上B以下でC,Dで割り切れる数の個数 z1 = (A-...
import math def lem(A, B): AB = A * B while B != 0: A, B = B, A % B return AB // A a, b, c, d = list(map(int, input().split())) """ # A以上B以下でCで割り切れる数の個数 x1 = (A-1) // C x2 = B // C x = x2 - x1 #print("x:", x) # A以上B以下でDで割り切れる数の個数 y1 = (A-1) // D y2 = B // D y = y2 - y1 #...
50
43
817
727
""" import math def lcm(x, y): return (x * y) // math.gcd(x, y) A, B, C, D = map(int, input().split()) # A以上B以下でCで割り切れる数の個数 x1 = (A-1) // C x2 = B // C x = x2 - x1 #print("x:", x) # A以上B以下でDで割り切れる数の個数 y1 = (A-1) // D y2 = B // D y = y2 - y1 #print("y", y) # A以上B以下でC,Dで割り切れる数の個数 z1 = (A-1) // lcm(C, D) z2 = B // lcm...
import math def lem(A, B): AB = A * B while B != 0: A, B = B, A % B return AB // A a, b, c, d = list(map(int, input().split())) """ # A以上B以下でCで割り切れる数の個数 x1 = (A-1) // C x2 = B // C x = x2 - x1 #print("x:", x) # A以上B以下でDで割り切れる数の個数 y1 = (A-1) // D y2 = B // D y = y2 - y1 #print("y", y) # A以上B以下でC,...
false
14
[ "-\"\"\" import math", "-def lcm(x, y):", "- return (x * y) // math.gcd(x, y)", "-A, B, C, D = map(int, input().split())", "+import math", "+", "+", "+def lem(A, B):", "+ AB = A * B", "+ while B != 0:", "+ A, B = B, A % B", "+ return AB // A", "+", "+", "+a, b, c, d = ...
false
0.039054
0.078506
0.497463
[ "s517078136", "s795650688" ]
u353707427
p03635
python
s990405450
s070143874
19
17
2,940
2,940
Accepted
Accepted
10.53
a,b=list(map(int,input().split())) x = a-1 y = b-1 print((x*y))
a,b=list(map(int,input().split())) print(((a-1)*(b-1)))
4
2
58
48
a, b = list(map(int, input().split())) x = a - 1 y = b - 1 print((x * y))
a, b = list(map(int, input().split())) print(((a - 1) * (b - 1)))
false
50
[ "-x = a - 1", "-y = b - 1", "-print((x * y))", "+print(((a - 1) * (b - 1)))" ]
false
0.084409
0.07759
1.087886
[ "s990405450", "s070143874" ]
u831244171
p02381
python
s407906021
s896797059
40
20
6,584
6,524
Accepted
Accepted
50
import math while True: n = eval(input()) if n == 0: break m = list(map(float,input().split())) print("%5f" %(math.sqrt(sum([(m[i]-(sum(m)/len(m)))**2 for i in range(n)])/n)))
import math while True: n = eval(input()) if n == 0: break m = list(map(float,input().split())) ave= sum(m)/len(m) print("%5f" %(math.sqrt(sum([(m[i]-(ave))**2 for i in range(n)])/n)))
8
10
198
214
import math while True: n = eval(input()) if n == 0: break m = list(map(float, input().split())) print( "%5f" % (math.sqrt(sum([(m[i] - (sum(m) / len(m))) ** 2 for i in range(n)]) / n)) )
import math while True: n = eval(input()) if n == 0: break m = list(map(float, input().split())) ave = sum(m) / len(m) print("%5f" % (math.sqrt(sum([(m[i] - (ave)) ** 2 for i in range(n)]) / n)))
false
20
[ "- print(", "- \"%5f\"", "- % (math.sqrt(sum([(m[i] - (sum(m) / len(m))) ** 2 for i in range(n)]) / n))", "- )", "+ ave = sum(m) / len(m)", "+ print(\"%5f\" % (math.sqrt(sum([(m[i] - (ave)) ** 2 for i in range(n)]) / n)))" ]
false
0.044627
0.045075
0.990059
[ "s407906021", "s896797059" ]
u225388820
p02558
python
s635729763
s552126943
708
291
79,380
75,256
Accepted
Accepted
58.9
from typing import List class DSU: def __init__(self, n: int) -> None: self._n = n self.parent_or_size = [-1] * n def merge(self, a: int, b: int) -> int: assert 0 <= a <= self._n assert 0 <= b <= self._n x, y = self.leader(a), self.leader(b) if x ==...
class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank = [0] * N def __repr__(self): return '\n'...
55
76
1,600
2,020
from typing import List class DSU: def __init__(self, n: int) -> None: self._n = n self.parent_or_size = [-1] * n def merge(self, a: int, b: int) -> int: assert 0 <= a <= self._n assert 0 <= b <= self._n x, y = self.leader(a), self.leader(b) if x == y: ...
class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank = [0] * N def __repr__(self): return "\n".join("{}: {}...
false
27.631579
[ "-from typing import List", "+class UnionFind:", "+ def __init__(self, N):", "+ \"\"\"", "+ N:要素数", "+ root:各要素の親要素の番号を格納するリスト.", "+ ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.", "+ rank:ランク", "+ \"\"\"", "+ self.N = N", "+ self.root ...
false
0.042602
0.035549
1.1984
[ "s635729763", "s552126943" ]
u142415823
p03073
python
s482453632
s358706661
100
76
3,188
3,956
Accepted
Accepted
24
S = eval(input()) ans = [0, 0] for i in range(len(S)): if (i % 2 == int(S[i])): ans[0] += 1 if (i % 2 != int(S[i])): ans[1] += 1 print((min(ans)))
S = list(map(int, eval(input()))) ans = [0, 0] for i in range(len(S)): if (i % 2 == S[i]): ans[0] += 1 if (i % 2 != S[i]): ans[1] += 1 print((min(ans)))
11
10
180
180
S = eval(input()) ans = [0, 0] for i in range(len(S)): if i % 2 == int(S[i]): ans[0] += 1 if i % 2 != int(S[i]): ans[1] += 1 print((min(ans)))
S = list(map(int, eval(input()))) ans = [0, 0] for i in range(len(S)): if i % 2 == S[i]: ans[0] += 1 if i % 2 != S[i]: ans[1] += 1 print((min(ans)))
false
9.090909
[ "-S = eval(input())", "+S = list(map(int, eval(input())))", "- if i % 2 == int(S[i]):", "+ if i % 2 == S[i]:", "- if i % 2 != int(S[i]):", "+ if i % 2 != S[i]:" ]
false
0.034587
0.036416
0.949756
[ "s482453632", "s358706661" ]
u153665391
p02388
python
s038225392
s251101431
30
20
7,576
7,644
Accepted
Accepted
33.33
num = int( eval(input()) ) print(( num * num * num ))
x = int( eval(input()) ) print(( x ** 3 ))
2
2
46
35
num = int(eval(input())) print((num * num * num))
x = int(eval(input())) print((x**3))
false
0
[ "-num = int(eval(input()))", "-print((num * num * num))", "+x = int(eval(input()))", "+print((x**3))" ]
false
0.044283
0.04435
0.998489
[ "s038225392", "s251101431" ]
u931769295
p02622
python
s380726041
s477312913
895
61
9,312
9,448
Accepted
Accepted
93.18
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S == T: count = 0 else: if S[i] != T[i]: count += 1 print(count)
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count)
11
8
172
118
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S == T: count = 0 else: if S[i] != T[i]: count += 1 print(count)
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count)
false
27.272727
[ "- if S == T:", "- count = 0", "- else:", "- if S[i] != T[i]:", "- count += 1", "+ if S[i] != T[i]:", "+ count += 1" ]
false
0.058025
0.038959
1.489409
[ "s380726041", "s477312913" ]
u810787773
p02659
python
s539375409
s816726733
26
24
9,772
9,880
Accepted
Accepted
7.69
from decimal import Decimal a,b = input().split() b = b.replace(".","") c = int(a)*int(b)//100 print(c)
from decimal import Decimal a,b = list(map(float,input().split())) b = round(b*100) c = int(a)*int(b)//100 print(c)
7
7
112
118
from decimal import Decimal a, b = input().split() b = b.replace(".", "") c = int(a) * int(b) // 100 print(c)
from decimal import Decimal a, b = list(map(float, input().split())) b = round(b * 100) c = int(a) * int(b) // 100 print(c)
false
0
[ "-a, b = input().split()", "-b = b.replace(\".\", \"\")", "+a, b = list(map(float, input().split()))", "+b = round(b * 100)" ]
false
0.114368
0.046603
2.454094
[ "s539375409", "s816726733" ]
u875291233
p03715
python
s129556447
s300817296
317
170
3,064
9,144
Accepted
Accepted
46.37
# coding: utf-8 # Your code here! h,w = [int(i) for i in input().split()] def once(h,w): res = 10**9 if h > 1: a,b = h//2*w, (h-h//2)*w res = abs(a-b) if w > 1: c,d = w//2*h, (w-w//2)*h if abs(c-d) < res: a,b = c,d return a,b def hsaki(h...
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline h,w = list(map(int,readline().split())) def f(h,w): ans = h*w for i in range(1,h): v1 = i*w if (h-i)%2==0 or w%2 == 0: v2 = (h-i)*w//2 else: v2 = ma...
30
28
610
517
# coding: utf-8 # Your code here! h, w = [int(i) for i in input().split()] def once(h, w): res = 10**9 if h > 1: a, b = h // 2 * w, (h - h // 2) * w res = abs(a - b) if w > 1: c, d = w // 2 * h, (w - w // 2) * h if abs(c - d) < res: a, b = c, d return a, b ...
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline h, w = list(map(int, readline().split())) def f(h, w): ans = h * w for i in range(1, h): v1 = i * w if (h - i) % 2 == 0 or w % 2 == 0: v2 = (h - i) * w // 2 else: v...
false
6.666667
[ "-h, w = [int(i) for i in input().split()]", "+import sys", "+", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+h, w = list(map(int, readline().split()))", "-def once(h, w):", "- res = 10**9", "- if h > 1:", "- a, b = h // 2 * w, (h - h // 2) * w", "- res = abs...
false
0.087465
0.045671
1.915085
[ "s129556447", "s300817296" ]
u490553751
p03136
python
s280740602
s419179219
21
18
3,316
3,060
Accepted
Accepted
14.29
#template from collections import Counter def inputlist(): return [int(j) for j in input().split()] #template N = int(eval(input())) L = inputlist() L.sort() s = 0 for i in range(N-1): s += L[i] if s > L[-1]: print("Yes") else: print("No")
#template def inputlist(): return [int(k) for k in input().split()] #template N = int(eval(input())) L = inputlist() L.sort() s=sum(L) s -=L[-1] if L[-1] < s: print("Yes") else: print("No")
14
12
258
202
# template from collections import Counter def inputlist(): return [int(j) for j in input().split()] # template N = int(eval(input())) L = inputlist() L.sort() s = 0 for i in range(N - 1): s += L[i] if s > L[-1]: print("Yes") else: print("No")
# template def inputlist(): return [int(k) for k in input().split()] # template N = int(eval(input())) L = inputlist() L.sort() s = sum(L) s -= L[-1] if L[-1] < s: print("Yes") else: print("No")
false
14.285714
[ "-from collections import Counter", "-", "-", "- return [int(j) for j in input().split()]", "+ return [int(k) for k in input().split()]", "-s = 0", "-for i in range(N - 1):", "- s += L[i]", "-if s > L[-1]:", "+s = sum(L)", "+s -= L[-1]", "+if L[-1] < s:" ]
false
0.04887
0.042321
1.154723
[ "s280740602", "s419179219" ]
u624475441
p03687
python
s615246679
s125227752
40
18
3,064
3,060
Accepted
Accepted
55
S = eval(input()) ans = len(S) for tgt in set(S): T = S while len(T) != T.count(tgt): U = '' for ab in zip(T, T[1:]): U += tgt if tgt in ab else ab[0] T = U ans = min(ans, len(S) - len(T)) print(ans)
S = eval(input()) ans = len(S) for c in [chr(i + 97) for i in range(26)]: if c not in S: continue ma = max(list(map(len, S.split(c)))) ans = min(ans, ma) print(ans)
11
8
251
179
S = eval(input()) ans = len(S) for tgt in set(S): T = S while len(T) != T.count(tgt): U = "" for ab in zip(T, T[1:]): U += tgt if tgt in ab else ab[0] T = U ans = min(ans, len(S) - len(T)) print(ans)
S = eval(input()) ans = len(S) for c in [chr(i + 97) for i in range(26)]: if c not in S: continue ma = max(list(map(len, S.split(c)))) ans = min(ans, ma) print(ans)
false
27.272727
[ "-for tgt in set(S):", "- T = S", "- while len(T) != T.count(tgt):", "- U = \"\"", "- for ab in zip(T, T[1:]):", "- U += tgt if tgt in ab else ab[0]", "- T = U", "- ans = min(ans, len(S) - len(T))", "+for c in [chr(i + 97) for i in range(26)]:", "+ if c ...
false
0.033201
0.032097
1.034397
[ "s615246679", "s125227752" ]
u602740328
p02898
python
s913856904
s085850399
70
52
11,912
9,984
Accepted
Accepted
25.71
N, K = list(map(int, input().split(" "))) h = sorted(list(map(int, input().split(" ")))) print((sum([0 if i<K else 1 for i in h])))
N, K = list(map(int, input().split(" "))) print((sum([0 if int(x)<K else 1 for x in input().split(" ")])))
3
2
131
110
N, K = list(map(int, input().split(" "))) h = sorted(list(map(int, input().split(" ")))) print((sum([0 if i < K else 1 for i in h])))
N, K = list(map(int, input().split(" "))) print((sum([0 if int(x) < K else 1 for x in input().split(" ")])))
false
33.333333
[ "-h = sorted(list(map(int, input().split(\" \"))))", "-print((sum([0 if i < K else 1 for i in h])))", "+print((sum([0 if int(x) < K else 1 for x in input().split(\" \")])))" ]
false
0.109921
0.071525
1.536816
[ "s913856904", "s085850399" ]
u670180528
p03634
python
s802788768
s592706363
1,429
718
45,204
63,540
Accepted
Accepted
49.76
from collections import deque n=int(eval(input())) con=[[] for _ in range(n)] dist_f_k=[0]*n for _ in range(n-1): a,b,c=list(map(int,input().split())) con[a-1].append((b-1,c)) con[b-1].append((a-1,c)) q,k=list(map(int,input().split())) que=deque([k-1]) while que: cur=que.popleft() for nxt,dd in con...
from collections import deque n,*t=list(map(int,open(0).read().split())) con=[[] for _ in range(n)] dist_f_k=[0]*n for a,b,c in zip(t[:3*n-3:3],t[1::3],t[2::3]): con[a-1].append((b-1,c)) con[b-1].append((a-1,c)) k=t[3*n-2] que=deque([k-1]) while que: cur=que.popleft() for nxt,dd in con[cur]: if di...
22
20
490
476
from collections import deque n = int(eval(input())) con = [[] for _ in range(n)] dist_f_k = [0] * n for _ in range(n - 1): a, b, c = list(map(int, input().split())) con[a - 1].append((b - 1, c)) con[b - 1].append((a - 1, c)) q, k = list(map(int, input().split())) que = deque([k - 1]) while que: cur = ...
from collections import deque n, *t = list(map(int, open(0).read().split())) con = [[] for _ in range(n)] dist_f_k = [0] * n for a, b, c in zip(t[: 3 * n - 3 : 3], t[1::3], t[2::3]): con[a - 1].append((b - 1, c)) con[b - 1].append((a - 1, c)) k = t[3 * n - 2] que = deque([k - 1]) while que: cur = que.pople...
false
9.090909
[ "-n = int(eval(input()))", "+n, *t = list(map(int, open(0).read().split()))", "-for _ in range(n - 1):", "- a, b, c = list(map(int, input().split()))", "+for a, b, c in zip(t[: 3 * n - 3 : 3], t[1::3], t[2::3]):", "-q, k = list(map(int, input().split()))", "+k = t[3 * n - 2]", "-for _ in range(q):"...
false
0.039284
0.04408
0.891199
[ "s802788768", "s592706363" ]
u813450984
p03612
python
s414307254
s671514859
106
94
14,008
13,880
Accepted
Accepted
11.32
n = int(eval(input())) temp = list(map(int, input().split())) l = [0]*n ans = 0 for i in range(n): if temp[i] == i+1: l[i] = 0 else: l[i] = 1 for i in range(n): if l[i] == 0 and i == n-1: ans += 1 if l[i] == 0 and not i == n-1: l[i] = 1 l[i+1] = 1 ans += 1 print(ans)
n = int(eval(input())) l = list(map(int, input().split())) ans = 0 for i in range(n): if l[i] == i + 1 and i == n-1: ans += 1 if l[i] == i + 1 and not i == n-1: l[i], l[i+1] = l[i+1], l[i] ans += 1 print(ans)
19
10
313
227
n = int(eval(input())) temp = list(map(int, input().split())) l = [0] * n ans = 0 for i in range(n): if temp[i] == i + 1: l[i] = 0 else: l[i] = 1 for i in range(n): if l[i] == 0 and i == n - 1: ans += 1 if l[i] == 0 and not i == n - 1: l[i] = 1 l[i + 1] = 1 ...
n = int(eval(input())) l = list(map(int, input().split())) ans = 0 for i in range(n): if l[i] == i + 1 and i == n - 1: ans += 1 if l[i] == i + 1 and not i == n - 1: l[i], l[i + 1] = l[i + 1], l[i] ans += 1 print(ans)
false
47.368421
[ "-temp = list(map(int, input().split()))", "-l = [0] * n", "+l = list(map(int, input().split()))", "- if temp[i] == i + 1:", "- l[i] = 0", "- else:", "- l[i] = 1", "-for i in range(n):", "- if l[i] == 0 and i == n - 1:", "+ if l[i] == i + 1 and i == n - 1:", "- if l[...
false
0.070256
0.086816
0.809248
[ "s414307254", "s671514859" ]
u337931720
p04012
python
s654644054
s291573291
32
28
2,812
2,808
Accepted
Accepted
12.5
from collections import defaultdict counts = defaultdict(int) for c in input(): counts[c] += 1 allgood = True for k in counts: allgood &= (counts[k] % 2 == 0) print("Yes" if allgood else "No")
from collections import defaultdict counts=defaultdict(int) for c in input():counts[c]+=1 print("Yes"if all(counts[k]%2<1 for k in counts)else"No")
8
4
206
152
from collections import defaultdict counts = defaultdict(int) for c in input(): counts[c] += 1 allgood = True for k in counts: allgood &= counts[k] % 2 == 0 print("Yes" if allgood else "No")
from collections import defaultdict counts = defaultdict(int) for c in input(): counts[c] += 1 print("Yes" if all(counts[k] % 2 < 1 for k in counts) else "No")
false
50
[ "-allgood = True", "-for k in counts:", "- allgood &= counts[k] % 2 == 0", "-print(\"Yes\" if allgood else \"No\")", "+print(\"Yes\" if all(counts[k] % 2 < 1 for k in counts) else \"No\")" ]
false
0.036334
0.036868
0.985508
[ "s654644054", "s291573291" ]
u935184340
p00009
python
s418797352
s664917238
130
120
11,936
11,936
Accepted
Accepted
7.69
import sys import math M = 1000000 B = int(math.sqrt(M)+1) N = M//6 N1 = N+1 if M % 6 == 5 else N N2 = N+1 if M % 6 >= 1 else N l = [1] * N1 m = [1] * N2 for i in range(5,B,6): p = (i-5)//6 ini = (i*5-1)//6 if l[p] == 1: l[p+i::i] = [0] * len(l[p+i::i]) m[ini-1::i] = [0] * len(...
import sys import math M = 1000000 B = int(math.sqrt(M)+1)//6+1 N = M//6 N1 = N+1 if M % 6 == 5 else N N2 = N+1 if M % 6 >= 1 else N l = [1] * N1 m = [1] * N2 i = 5 ini = 4 for p in range(B): if l[p] == 1: l[p+i::i] = [0] * len(l[p+i::i]) m[ini-1::i] = [0] * len(m[ini-1::i]) if m[...
22
25
570
575
import sys import math M = 1000000 B = int(math.sqrt(M) + 1) N = M // 6 N1 = N + 1 if M % 6 == 5 else N N2 = N + 1 if M % 6 >= 1 else N l = [1] * N1 m = [1] * N2 for i in range(5, B, 6): p = (i - 5) // 6 ini = (i * 5 - 1) // 6 if l[p] == 1: l[p + i :: i] = [0] * len(l[p + i :: i]) m[ini - 1...
import sys import math M = 1000000 B = int(math.sqrt(M) + 1) // 6 + 1 N = M // 6 N1 = N + 1 if M % 6 == 5 else N N2 = N + 1 if M % 6 >= 1 else N l = [1] * N1 m = [1] * N2 i = 5 ini = 4 for p in range(B): if l[p] == 1: l[p + i :: i] = [0] * len(l[p + i :: i]) m[ini - 1 :: i] = [0] * len(m[ini - 1 ::...
false
12
[ "-B = int(math.sqrt(M) + 1)", "+B = int(math.sqrt(M) + 1) // 6 + 1", "-for i in range(5, B, 6):", "- p = (i - 5) // 6", "- ini = (i * 5 - 1) // 6", "+i = 5", "+ini = 4", "+for p in range(B):", "+ i += 6", "+ ini += 5" ]
false
0.054847
0.056877
0.964322
[ "s418797352", "s664917238" ]
u923668099
p02234
python
s191241971
s804733327
220
130
7,852
7,768
Accepted
Accepted
40.91
import sys sys.setrecursionlimit(10**7) inf = float('inf') def solve(): n = int(sys.stdin.readline()) r = [0] * n c = [0] * n for i in range(n): ri, ci = list(map(int, sys.stdin.readline().split())) r[i] = ri c[i] = ci memo = [[-1]*(n + 1) for i in rang...
import sys sys.setrecursionlimit(10**7) inf = float('inf') def solve(): n = int(sys.stdin.readline()) r = [0] * n c = [0] * n for i in range(n): ri, ci = list(map(int, sys.stdin.readline().split())) r[i] = ri c[i] = ci dp = [[0]*(n + 1) for i in range(n...
60
31
1,262
655
import sys sys.setrecursionlimit(10**7) inf = float("inf") def solve(): n = int(sys.stdin.readline()) r = [0] * n c = [0] * n for i in range(n): ri, ci = list(map(int, sys.stdin.readline().split())) r[i] = ri c[i] = ci memo = [[-1] * (n + 1) for i in range(n + 1)] ans ...
import sys sys.setrecursionlimit(10**7) inf = float("inf") def solve(): n = int(sys.stdin.readline()) r = [0] * n c = [0] * n for i in range(n): ri, ci = list(map(int, sys.stdin.readline().split())) r[i] = ri c[i] = ci dp = [[0] * (n + 1) for i in range(n + 1)] for ls ...
false
48.333333
[ "- memo = [[-1] * (n + 1) for i in range(n + 1)]", "- ans = mcm(memo, n, r, c, 0, n)", "- # print(memo)", "+ dp = [[0] * (n + 1) for i in range(n + 1)]", "+ for ls in range(2, n + 1):", "+ for i in range(n - ls + 1):", "+ dp[i][i + ls] = inf", "+ for j in ra...
false
0.043339
0.039266
1.103722
[ "s191241971", "s804733327" ]
u785989355
p03045
python
s808503463
s976981648
573
458
27,836
62,128
Accepted
Accepted
20.07
from collections import deque N,M = list(map(int,input().split())) node_list = [[] for i in range(N)] for i in range(M): x,y,z=list(map(int,input().split())) node_list[x-1].append(y-1) node_list[y-1].append(x-1) checked_list = [-1 for i in range(N)] def BFS(start,color,checked_list,nod...
import sys def input(): return sys.stdin.readline()[:-1] N,M = list(map(int,input().split())) e_list = [[] for i in range(N)] for i in range(M): x,y,z = list(map(int,input().split())) x,y = x-1,y-1 e_list[x].append(y) e_list[y].append(x) from collections import deque def BFS(vi,...
31
35
721
715
from collections import deque N, M = list(map(int, input().split())) node_list = [[] for i in range(N)] for i in range(M): x, y, z = list(map(int, input().split())) node_list[x - 1].append(y - 1) node_list[y - 1].append(x - 1) checked_list = [-1 for i in range(N)] def BFS(start, color, checked_list, node...
import sys def input(): return sys.stdin.readline()[:-1] N, M = list(map(int, input().split())) e_list = [[] for i in range(N)] for i in range(M): x, y, z = list(map(int, input().split())) x, y = x - 1, y - 1 e_list[x].append(y) e_list[y].append(x) from collections import deque def BFS(vi, col...
false
11.428571
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", "+", "+N, M = list(map(int, input().split()))", "+e_list = [[] for i in range(N)]", "+for i in range(M):", "+ x, y, z = list(map(int, input().split()))", "+ x, y = x - 1, y - 1", "+ e_list[x].app...
false
0.072362
0.217119
0.333282
[ "s808503463", "s976981648" ]
u723711163
p02862
python
s334267703
s766376733
175
69
38,512
62,788
Accepted
Accepted
60.57
def nCr(n,r): dividend,divisor = 1,1 for i in range(r): dividend *= n-i divisor *= 1+i dividend %= MOD divisor %= MOD return (dividend * pow(divisor, MOD-2, MOD)) % MOD X,Y = list(map(int,input().split())) INF = 10**15 MOD = 10**9+7 if (X+Y)%3!=0: print((0)) exit() n = (-...
def nCr(n,r): dividend = 1 divisor = 1 MOD = 10**9+7 d1 = n for i in range(1,r+1): dividend *= d1 divisor *= i d1 -= 1 dividend %= MOD divisor %= MOD return (dividend * pow(divisor, MOD-2, MOD)) % MOD X,Y = list(map(int,input().split())) if (X+Y) % 3 != 0: print((0)...
26
27
407
421
def nCr(n, r): dividend, divisor = 1, 1 for i in range(r): dividend *= n - i divisor *= 1 + i dividend %= MOD divisor %= MOD return (dividend * pow(divisor, MOD - 2, MOD)) % MOD X, Y = list(map(int, input().split())) INF = 10**15 MOD = 10**9 + 7 if (X + Y) % 3 != 0: pri...
def nCr(n, r): dividend = 1 divisor = 1 MOD = 10**9 + 7 d1 = n for i in range(1, r + 1): dividend *= d1 divisor *= i d1 -= 1 dividend %= MOD divisor %= MOD return (dividend * pow(divisor, MOD - 2, MOD)) % MOD X, Y = list(map(int, input().split())) if (X ...
false
3.703704
[ "- dividend, divisor = 1, 1", "- for i in range(r):", "- dividend *= n - i", "- divisor *= 1 + i", "+ dividend = 1", "+ divisor = 1", "+ MOD = 10**9 + 7", "+ d1 = n", "+ for i in range(1, r + 1):", "+ dividend *= d1", "+ divisor *= i", "+ ...
false
0.311113
0.084821
3.667881
[ "s334267703", "s766376733" ]
u680851063
p03013
python
s358824176
s906106174
155
71
18,336
13,192
Accepted
Accepted
54.19
n, m = list(map(int, input().split())) a = set(map(int, [eval(input()) for _ in range(m)])) dp = [0] * (n+1) # 0段目と1段目は1通り(但し、1段目が壊れていない場合)(0 段目は「なにもしない」という から1 通り) dp[:2] = 1, 1 if 1 not in a else 0 for i in range(2, n+1): if i not in a: dp[i] = ((dp[i-1] + dp[i-2]) % (10**9+7)) print((dp[-1...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) broken = set([int(eval(input())) for _ in range(m)]) # ここが'list'だとPypyでも通らない def ptn_num(x): # 'x'stepまでのパターン数 dp = [0] * (x+1) # DP枠_including step'0' if 1 in broken: # in case, step'1' broken dp[:2] = 1, 0 el...
12
19
310
522
n, m = list(map(int, input().split())) a = set(map(int, [eval(input()) for _ in range(m)])) dp = [0] * (n + 1) # 0段目と1段目は1通り(但し、1段目が壊れていない場合)(0 段目は「なにもしない」という から1 通り) dp[:2] = 1, 1 if 1 not in a else 0 for i in range(2, n + 1): if i not in a: dp[i] = (dp[i - 1] + dp[i - 2]) % (10**9 + 7) print((dp[-1]))
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) broken = set([int(eval(input())) for _ in range(m)]) # ここが'list'だとPypyでも通らない def ptn_num(x): # 'x'stepまでのパターン数 dp = [0] * (x + 1) # DP枠_including step'0' if 1 in broken: # in case, step'1' broken dp[:2] = 1, 0 else: ...
false
36.842105
[ "+import sys", "+", "+input = sys.stdin.readline", "-a = set(map(int, [eval(input()) for _ in range(m)]))", "-dp = [0] * (n + 1)", "-# 0段目と1段目は1通り(但し、1段目が壊れていない場合)(0 段目は「なにもしない」という から1 通り)", "-dp[:2] = 1, 1 if 1 not in a else 0", "-for i in range(2, n + 1):", "- if i not in a:", "- dp[i]...
false
0.037903
0.038823
0.976305
[ "s358824176", "s906106174" ]
u991567869
p03274
python
s513295972
s334696356
92
81
20,332
20,008
Accepted
Accepted
11.96
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = 10**9 for i in range(n - k + 1): if x[i] < 0: if x[i + k - 1] < 0: ref = -x[i] else: ref = min(x[i]*-2 + x[i + k - 1], -x[i] + x[i + k - 1]*2) else: ref = x[i + k - 1] ...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) k -= 1 ans = 10**9 for i in range(n - k): l = x[i] r = x[i + k] if l < 0: if r < 0: ref = -l else: ref = min(l*-2 + r, -l + r*2) else: ref = r ans = min(ans, ref...
16
18
351
329
n, k = list(map(int, input().split())) x = list(map(int, input().split())) ans = 10**9 for i in range(n - k + 1): if x[i] < 0: if x[i + k - 1] < 0: ref = -x[i] else: ref = min(x[i] * -2 + x[i + k - 1], -x[i] + x[i + k - 1] * 2) else: ref = x[i + k - 1] ans = m...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) k -= 1 ans = 10**9 for i in range(n - k): l = x[i] r = x[i + k] if l < 0: if r < 0: ref = -l else: ref = min(l * -2 + r, -l + r * 2) else: ref = r ans = min(ans, ref) print(ans)...
false
11.111111
[ "+k -= 1", "-for i in range(n - k + 1):", "- if x[i] < 0:", "- if x[i + k - 1] < 0:", "- ref = -x[i]", "+for i in range(n - k):", "+ l = x[i]", "+ r = x[i + k]", "+ if l < 0:", "+ if r < 0:", "+ ref = -l", "- ref = min(x[i] * -2 + x[i ...
false
0.037165
0.108373
0.342937
[ "s513295972", "s334696356" ]
u133936772
p02763
python
s413278548
s115549144
1,317
1,042
172,444
30,216
Accepted
Accepted
20.88
f=input n,l,q=int(f()),list(f()),int(f()) B=[[0]*-~n for i in range(26)] def S(o,i): s=0 while i: s+=B[o][i]; i-=i&-i return s def A(o,i,x): while i<=n: B[o][i]+=x; i+=i&-i for i in range(n): A(ord(l[i])-97,i+1,1) for i in range(q): a,b,c=f().split(); b=int(b) if a>'1': print((sum(1 for o in ran...
f=input n,s,q=int(f()),list(f()),int(f()) d={chr(97+i):[] for i in range(26)} for i in range(n): d[s[i]]+=[i] from bisect import * for i in range(q): a,b,c=f().split() b=int(b)-1 if a=='1': if s[b]==c: continue d[s[b]].pop(bisect(d[s[b]],b)-1) s[b]=c insort(d[c],b) else: t=0...
14
20
411
424
f = input n, l, q = int(f()), list(f()), int(f()) B = [[0] * -~n for i in range(26)] def S(o, i): s = 0 while i: s += B[o][i] i -= i & -i return s def A(o, i, x): while i <= n: B[o][i] += x i += i & -i for i in range(n): A(ord(l[i]) - 97, i + 1, 1) for i in rang...
f = input n, s, q = int(f()), list(f()), int(f()) d = {chr(97 + i): [] for i in range(26)} for i in range(n): d[s[i]] += [i] from bisect import * for i in range(q): a, b, c = f().split() b = int(b) - 1 if a == "1": if s[b] == c: continue d[s[b]].pop(bisect(d[s[b]], b) - 1) ...
false
30
[ "-n, l, q = int(f()), list(f()), int(f())", "-B = [[0] * -~n for i in range(26)]", "+n, s, q = int(f()), list(f()), int(f())", "+d = {chr(97 + i): [] for i in range(26)}", "+for i in range(n):", "+ d[s[i]] += [i]", "+from bisect import *", "-", "-def S(o, i):", "- s = 0", "- while i:", ...
false
0.037456
0.03853
0.972132
[ "s413278548", "s115549144" ]
u092387689
p02690
python
s780663801
s082873591
354
51
9,148
9,040
Accepted
Accepted
85.59
x = int(eval(input())) sign = ((1,1),(1,-1),(-1,1),(-1,-1)) isloop=True for a in range(10**3): if(isloop==False): break for b in range(10**3): if(isloop==False): break for s1,s2 in sign: if(isloop==False): break a1 = s1*a ...
n = int(eval(input())) tp = ((1,1),(1,-1)) for i in range(200): for j in range(200): for k in tp: a,b = i*k[0],j*k[1] if((a**5 - b**5)==n): print((a,b)) exit()
20
9
478
227
x = int(eval(input())) sign = ((1, 1), (1, -1), (-1, 1), (-1, -1)) isloop = True for a in range(10**3): if isloop == False: break for b in range(10**3): if isloop == False: break for s1, s2 in sign: if isloop == False: break a1 = s1 * a...
n = int(eval(input())) tp = ((1, 1), (1, -1)) for i in range(200): for j in range(200): for k in tp: a, b = i * k[0], j * k[1] if (a**5 - b**5) == n: print((a, b)) exit()
false
55
[ "-x = int(eval(input()))", "-sign = ((1, 1), (1, -1), (-1, 1), (-1, -1))", "-isloop = True", "-for a in range(10**3):", "- if isloop == False:", "- break", "- for b in range(10**3):", "- if isloop == False:", "- break", "- for s1, s2 in sign:", "- ...
false
0.083514
0.125064
0.667765
[ "s780663801", "s082873591" ]
u607563136
p03112
python
s463413003
s731546608
1,094
883
17,636
23,932
Accepted
Accepted
19.29
import bisect A,B,Q = list(map(int,input().split())) INF = float('inf') S = [-INF]+[int(eval(input())) for i in range(A)]+[INF] T = [-INF]+[int(eval(input())) for i in range(B)]+[INF] for q in range(Q): x = int(eval(input())) i = bisect.bisect_right(S,x) j = bisect.bisect_right(T,x) d = INF ...
import bisect A,B,Q = map(int,input().split()) INF = float('inf') S = [-INF]+[int(input()) for _ in range(A)]+[INF] T = [-INF]+[int(input()) for _ in range(B)]+[INF] ans = [] for q in range(Q): x = int(input()) i = bisect.bisect_right(S,x) j = bisect.bisect_right(T,x) d = INF for s in [...
16
19
470
513
import bisect A, B, Q = list(map(int, input().split())) INF = float("inf") S = [-INF] + [int(eval(input())) for i in range(A)] + [INF] T = [-INF] + [int(eval(input())) for i in range(B)] + [INF] for q in range(Q): x = int(eval(input())) i = bisect.bisect_right(S, x) j = bisect.bisect_right(T, x) d = IN...
import bisect A, B, Q = map(int, input().split()) INF = float("inf") S = [-INF] + [int(input()) for _ in range(A)] + [INF] T = [-INF] + [int(input()) for _ in range(B)] + [INF] ans = [] for q in range(Q): x = int(input()) i = bisect.bisect_right(S, x) j = bisect.bisect_right(T, x) d = INF for s in ...
false
15.789474
[ "-A, B, Q = list(map(int, input().split()))", "+A, B, Q = map(int, input().split())", "-S = [-INF] + [int(eval(input())) for i in range(A)] + [INF]", "-T = [-INF] + [int(eval(input())) for i in range(B)] + [INF]", "+S = [-INF] + [int(input()) for _ in range(A)] + [INF]", "+T = [-INF] + [int(input()) for _...
false
0.046066
0.043569
1.057318
[ "s463413003", "s731546608" ]
u327211044
p02801
python
s773221273
s509039466
175
17
38,256
2,940
Accepted
Accepted
90.29
alpha = eval(input()) print((chr(ord(alpha)+1)))
c = eval(input()) print((chr(ord(c)+1)))
2
2
41
33
alpha = eval(input()) print((chr(ord(alpha) + 1)))
c = eval(input()) print((chr(ord(c) + 1)))
false
0
[ "-alpha = eval(input())", "-print((chr(ord(alpha) + 1)))", "+c = eval(input())", "+print((chr(ord(c) + 1)))" ]
false
0.035231
0.03587
0.98221
[ "s773221273", "s509039466" ]
u375695365
p03681
python
s358686382
s638848569
704
64
5,184
3,064
Accepted
Accepted
90.91
import math mod = 10**9+7 n,m = list(map(int,input().split())) if n!=m and abs(n-m)!=1: print("0") exit() if n==m: n=max(n,m) m=min(n,m) ans = math.factorial(n)*2*math.factorial(m) print((ans%mod)) else: ans = math.factorial(n)*math.factorial(m) print((ans%mod))
n,m=list(map(int,input().split())) if 2<=abs(n-m): print((0)) exit() mod=10**9+7 if abs(n-m)==1: dog=1 cat=1 for i in range(1,n+1): dog*=i dog=dog%mod for i in range(1,m+1): cat*=i cat=cat%mod print((dog*cat%mod)) else: dog=1 cat=1...
16
28
302
469
import math mod = 10**9 + 7 n, m = list(map(int, input().split())) if n != m and abs(n - m) != 1: print("0") exit() if n == m: n = max(n, m) m = min(n, m) ans = math.factorial(n) * 2 * math.factorial(m) print((ans % mod)) else: ans = math.factorial(n) * math.factorial(m) print((ans % mo...
n, m = list(map(int, input().split())) if 2 <= abs(n - m): print((0)) exit() mod = 10**9 + 7 if abs(n - m) == 1: dog = 1 cat = 1 for i in range(1, n + 1): dog *= i dog = dog % mod for i in range(1, m + 1): cat *= i cat = cat % mod print((dog * cat % mod)) else...
false
42.857143
[ "-import math", "-", "+n, m = list(map(int, input().split()))", "+if 2 <= abs(n - m):", "+ print((0))", "+ exit()", "-n, m = list(map(int, input().split()))", "-if n != m and abs(n - m) != 1:", "- print(\"0\")", "- exit()", "-if n == m:", "- n = max(n, m)", "- m = min(n, m)...
false
0.086002
0.083368
1.031594
[ "s358686382", "s638848569" ]
u057109575
p02867
python
s397822045
s386485269
708
545
92,392
101,096
Accepted
Accepted
23.02
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 1 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count X = list(zip(A, B)) X.sort(k...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted(zip(A...
36
22
685
608
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 1 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count X = list(zip(A, B)) X.sort(key=lambda x: ...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) def count_loop(start, idx_map): count = 0 idx = start while True: idx = idx_map[idx] count += 1 if idx == 0: break return count A, B = list(zip(*sorted(zip(A, B), key=la...
false
38.888889
[ "- count = 1", "+ count = 0", "-X = list(zip(A, B))", "-X.sort(key=lambda x: x[1])", "-C = sorted((x[0], i) for i, x in enumerate(X))", "-idx_map = [C[i][1] for i in range(N)]", "+A, B = list(zip(*sorted(zip(A, B), key=lambda x: x[1])))", "+idx_map = sorted(list(range(N)), key=lambda i: A[i])", ...
false
0.047105
0.037351
1.261128
[ "s397822045", "s386485269" ]
u072717685
p02748
python
s640660170
s548308506
278
165
29,640
41,808
Accepted
Accepted
40.65
import sys input = sys.stdin.readline def main(): a, b, m = list(map(int, input().split())) t_a = tuple(map(int, input().split())) t_b = tuple(map(int, input().split())) t_ken = [tuple(map(int, input().split())) for _ in range(m)] r = min(t_a) + min(t_b) for x, y, c in t_ken: ...
import sys read = sys.stdin.read def main(): a, b, m = list(map(int, input().split())) al = tuple(map(int, input().split())) bl = tuple(map(int, input().split())) r = min(al) + min(bl) m = list(map(int, read().split())) xyc = list(zip(m, m, m)) for x, y, c in xyc: r = min(r...
16
15
408
382
import sys input = sys.stdin.readline def main(): a, b, m = list(map(int, input().split())) t_a = tuple(map(int, input().split())) t_b = tuple(map(int, input().split())) t_ken = [tuple(map(int, input().split())) for _ in range(m)] r = min(t_a) + min(t_b) for x, y, c in t_ken: r = min(...
import sys read = sys.stdin.read def main(): a, b, m = list(map(int, input().split())) al = tuple(map(int, input().split())) bl = tuple(map(int, input().split())) r = min(al) + min(bl) m = list(map(int, read().split())) xyc = list(zip(m, m, m)) for x, y, c in xyc: r = min(r, al[x ...
false
6.25
[ "-input = sys.stdin.readline", "+read = sys.stdin.read", "- t_a = tuple(map(int, input().split()))", "- t_b = tuple(map(int, input().split()))", "- t_ken = [tuple(map(int, input().split())) for _ in range(m)]", "- r = min(t_a) + min(t_b)", "- for x, y, c in t_ken:", "- r = min(r,...
false
0.035476
0.042606
0.832646
[ "s640660170", "s548308506" ]
u788703383
p04011
python
s252850932
s326205022
168
17
38,256
2,940
Accepted
Accepted
89.88
a = [int(eval(input())) for i in range(4)] if a[0] <= a[1]: print((a[0] * a[2])) else: print((a[1] * a[2] + (a[0] - a[1]) * a[3]))
n,k,x,y= [int(eval(input())) for i in range(4)] print((n * x + (y-x) * max(n-k,0)))
5
2
128
76
a = [int(eval(input())) for i in range(4)] if a[0] <= a[1]: print((a[0] * a[2])) else: print((a[1] * a[2] + (a[0] - a[1]) * a[3]))
n, k, x, y = [int(eval(input())) for i in range(4)] print((n * x + (y - x) * max(n - k, 0)))
false
60
[ "-a = [int(eval(input())) for i in range(4)]", "-if a[0] <= a[1]:", "- print((a[0] * a[2]))", "-else:", "- print((a[1] * a[2] + (a[0] - a[1]) * a[3]))", "+n, k, x, y = [int(eval(input())) for i in range(4)]", "+print((n * x + (y - x) * max(n - k, 0)))" ]
false
0.042123
0.041286
1.02027
[ "s252850932", "s326205022" ]
u644907318
p02802
python
s536556520
s657531351
575
186
59,236
85,716
Accepted
Accepted
67.65
N,M = list(map(int,input().split())) C = {i:[0,0] for i in range(1,N+1)} for _ in range(M): p,S = input().split() p = int(p) if C[p][0]==0 and S=="WA": C[p][1] += 1 elif C[p][0]==0 and S=="AC": C[p][0] = 1 numA = 0 numB = 0 for i in range(1,N+1): numA += C[i][0] if C...
N,M = list(map(int,input().split())) A = [0 for _ in range(N+1)] B = [0 for _ in range(N+1)] for _ in range(M): p,S = input().split() p = int(p) if S=="AC": if A[p]==0: A[p]=1 else: if A[p]==0: B[p] += 1 for i in range(N+1): if A[i]==0: B...
16
16
367
341
N, M = list(map(int, input().split())) C = {i: [0, 0] for i in range(1, N + 1)} for _ in range(M): p, S = input().split() p = int(p) if C[p][0] == 0 and S == "WA": C[p][1] += 1 elif C[p][0] == 0 and S == "AC": C[p][0] = 1 numA = 0 numB = 0 for i in range(1, N + 1): numA += C[i][0] ...
N, M = list(map(int, input().split())) A = [0 for _ in range(N + 1)] B = [0 for _ in range(N + 1)] for _ in range(M): p, S = input().split() p = int(p) if S == "AC": if A[p] == 0: A[p] = 1 else: if A[p] == 0: B[p] += 1 for i in range(N + 1): if A[i] == 0: ...
false
0
[ "-C = {i: [0, 0] for i in range(1, N + 1)}", "+A = [0 for _ in range(N + 1)]", "+B = [0 for _ in range(N + 1)]", "- if C[p][0] == 0 and S == \"WA\":", "- C[p][1] += 1", "- elif C[p][0] == 0 and S == \"AC\":", "- C[p][0] = 1", "-numA = 0", "-numB = 0", "-for i in range(1, N + 1)...
false
0.064139
0.043003
1.491487
[ "s536556520", "s657531351" ]
u065188401
p03127
python
s470284927
s542213945
103
93
16,284
16,240
Accepted
Accepted
9.71
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) g = [0] * (N + 1) for i in range(N): g[i+1] = gcd(g[i], A[i]) print((g[-1]))
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) g = 0 for i in range(N): g = gcd(g, A[i]) print(g)
10
9
169
144
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) g = [0] * (N + 1) for i in range(N): g[i + 1] = gcd(g[i], A[i]) print((g[-1]))
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) g = 0 for i in range(N): g = gcd(g, A[i]) print(g)
false
10
[ "-g = [0] * (N + 1)", "+g = 0", "- g[i + 1] = gcd(g[i], A[i])", "-print((g[-1]))", "+ g = gcd(g, A[i])", "+print(g)" ]
false
0.04932
0.049333
0.99974
[ "s470284927", "s542213945" ]
u340781749
p03013
python
s782966538
s489711531
66
58
11,884
11,884
Accepted
Accepted
12.12
import sys n, m = list(map(int, input().split())) aaa = set(map(int, sys.stdin)) dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if 1 not in aaa else 0 MOD = 10 ** 9 + 7 for i in range(2, n + 1): if i in aaa: continue dp[i] = (dp[i - 2] + dp[i - 1]) % MOD print((dp[n]))
import sys n, m = list(map(int, input().split())) if m > 0: aaa = set(map(int, sys.stdin)) else: aaa = set() dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if 1 not in aaa else 0 MOD = 10 ** 9 + 7 for i in range(2, n + 1): if i in aaa: continue dp[i] = (dp[i - 2] + dp[i - 1]) % MOD pri...
14
17
291
330
import sys n, m = list(map(int, input().split())) aaa = set(map(int, sys.stdin)) dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if 1 not in aaa else 0 MOD = 10**9 + 7 for i in range(2, n + 1): if i in aaa: continue dp[i] = (dp[i - 2] + dp[i - 1]) % MOD print((dp[n]))
import sys n, m = list(map(int, input().split())) if m > 0: aaa = set(map(int, sys.stdin)) else: aaa = set() dp = [0] * (n + 1) dp[0] = 1 dp[1] = 1 if 1 not in aaa else 0 MOD = 10**9 + 7 for i in range(2, n + 1): if i in aaa: continue dp[i] = (dp[i - 2] + dp[i - 1]) % MOD print((dp[n]))
false
17.647059
[ "-aaa = set(map(int, sys.stdin))", "+if m > 0:", "+ aaa = set(map(int, sys.stdin))", "+else:", "+ aaa = set()" ]
false
0.095176
0.077308
1.231124
[ "s782966538", "s489711531" ]
u924406834
p03611
python
s125676552
s216160348
103
87
14,008
14,004
Accepted
Accepted
15.53
n = int(eval(input())) a = list(map(int,input().split())) check = [0]*((10**5)+1) for i in a:check[i] += 1 ans = check[0] + check[1] for i in range(len(check)-2):ans = max(ans,check[i]+check[i+1]+check[i+2]) print(ans)
n = int(eval(input())) a = list(map(int,input().split())) count = [0]*(10**5+5) for v in a: count[v] += 1 maxX = 0 maxV = 0 for i in range(10**5+1): val = count[i-1] + count[i] + count[i+1] if val > maxV: maxV = val maxX = i print(maxV)
7
15
218
274
n = int(eval(input())) a = list(map(int, input().split())) check = [0] * ((10**5) + 1) for i in a: check[i] += 1 ans = check[0] + check[1] for i in range(len(check) - 2): ans = max(ans, check[i] + check[i + 1] + check[i + 2]) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) count = [0] * (10**5 + 5) for v in a: count[v] += 1 maxX = 0 maxV = 0 for i in range(10**5 + 1): val = count[i - 1] + count[i] + count[i + 1] if val > maxV: maxV = val maxX = i print(maxV)
false
53.333333
[ "-check = [0] * ((10**5) + 1)", "-for i in a:", "- check[i] += 1", "-ans = check[0] + check[1]", "-for i in range(len(check) - 2):", "- ans = max(ans, check[i] + check[i + 1] + check[i + 2])", "-print(ans)", "+count = [0] * (10**5 + 5)", "+for v in a:", "+ count[v] += 1", "+maxX = 0", ...
false
0.245915
0.098487
2.496935
[ "s125676552", "s216160348" ]
u123756661
p03031
python
s404435693
s454697735
229
88
41,584
74,312
Accepted
Accepted
61.57
def sol(): n,m=list(map(int,input().split())) k=[] for i in range(m): l=[int(i) for i in input().split()] k.append([l[j]-1 for j in range(1,l[0]+1)]) p=[int(i) for i in input().split()] ans=0 #for i in range(2**10): for i in range(2**n): s=bin(i)[2:] ...
n,m=list(map(int,input().split())) k=[[int(i) for i in input().split()] for j in range(m)] p=[int(i) for i in input().split()] ans=chk=0 for i in range(2**n): l=[0]*n for j in range(n): if i&1: l[j]=1 i=i>>1 y=0 for j in range(m): x=0 for a in range(k[j][0]): ...
27
17
659
417
def sol(): n, m = list(map(int, input().split())) k = [] for i in range(m): l = [int(i) for i in input().split()] k.append([l[j] - 1 for j in range(1, l[0] + 1)]) p = [int(i) for i in input().split()] ans = 0 # for i in range(2**10): for i in range(2**n): s = bin(i)[2...
n, m = list(map(int, input().split())) k = [[int(i) for i in input().split()] for j in range(m)] p = [int(i) for i in input().split()] ans = chk = 0 for i in range(2**n): l = [0] * n for j in range(n): if i & 1: l[j] = 1 i = i >> 1 y = 0 for j in range(m): x = 0 ...
false
37.037037
[ "-def sol():", "- n, m = list(map(int, input().split()))", "- k = []", "- for i in range(m):", "- l = [int(i) for i in input().split()]", "- k.append([l[j] - 1 for j in range(1, l[0] + 1)])", "- p = [int(i) for i in input().split()]", "- ans = 0", "- # for i in range(...
false
0.035729
0.036706
0.973361
[ "s404435693", "s454697735" ]
u573754721
p03212
python
s828635269
s608355575
232
83
42,348
6,260
Accepted
Accepted
64.22
import itertools n=int(eval(input())) ans=0 for i in range(3,len(str(n))+1): for ptn in itertools.product((3,5,7),repeat=i): if (3 not in ptn) or (5 not in ptn) or (7 not in ptn): continue a=int("".join(list(map(str,ptn)))) if a<=n: ans+=1 print(ans) ...
import itertools n=int(eval(input())) c=0 for i in range(len(str(n))+1): for j in list(itertools.product((3,5,7),repeat=i)): if (3 in j) and (5 in j) and (7 in j): if n >=int((''.join(list(map(str,j))))): c+=1 print(c)
13
10
318
282
import itertools n = int(eval(input())) ans = 0 for i in range(3, len(str(n)) + 1): for ptn in itertools.product((3, 5, 7), repeat=i): if (3 not in ptn) or (5 not in ptn) or (7 not in ptn): continue a = int("".join(list(map(str, ptn)))) if a <= n: ans += 1 print(ans)...
import itertools n = int(eval(input())) c = 0 for i in range(len(str(n)) + 1): for j in list(itertools.product((3, 5, 7), repeat=i)): if (3 in j) and (5 in j) and (7 in j): if n >= int(("".join(list(map(str, j))))): c += 1 print(c)
false
23.076923
[ "-ans = 0", "-for i in range(3, len(str(n)) + 1):", "- for ptn in itertools.product((3, 5, 7), repeat=i):", "- if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):", "- continue", "- a = int(\"\".join(list(map(str, ptn))))", "- if a <= n:", "- ans += 1",...
false
0.068434
0.055424
1.234739
[ "s828635269", "s608355575" ]
u548514780
p03408
python
s733952579
s623678240
29
26
9,052
9,112
Accepted
Accepted
10.34
blue=int(eval(input())) b=[] r=[] for i in range(blue): b.append(eval(input())) red=int(eval(input())) for i in range(red): r.append(eval(input())) count=[] for i in range(len(b)): counter=0 for j in range(len(b)): if b[i]==b[j]: counter+=1 for j in range(len(r)): if b[i]==r[j]: ...
blue=int(eval(input())) b=[] r=[] count=[] for i in range(blue): b.append(eval(input())) red=int(eval(input())) for i in range(red): r.append(eval(input())) for i in b: count.append(b.count(i)-r.count(i)) if max(count)<0: print((0)) else: print((max(count)))
22
15
395
254
blue = int(eval(input())) b = [] r = [] for i in range(blue): b.append(eval(input())) red = int(eval(input())) for i in range(red): r.append(eval(input())) count = [] for i in range(len(b)): counter = 0 for j in range(len(b)): if b[i] == b[j]: counter += 1 for j in range(len(r)):...
blue = int(eval(input())) b = [] r = [] count = [] for i in range(blue): b.append(eval(input())) red = int(eval(input())) for i in range(red): r.append(eval(input())) for i in b: count.append(b.count(i) - r.count(i)) if max(count) < 0: print((0)) else: print((max(count)))
false
31.818182
[ "+count = []", "-count = []", "-for i in range(len(b)):", "- counter = 0", "- for j in range(len(b)):", "- if b[i] == b[j]:", "- counter += 1", "- for j in range(len(r)):", "- if b[i] == r[j]:", "- counter -= 1", "- count.append(counter)", "+for ...
false
0.039506
0.037633
1.049773
[ "s733952579", "s623678240" ]
u604412462
p02708
python
s820578331
s955784199
152
119
19,308
9,204
Accepted
Accepted
21.71
mod = 10**9 + 7 n,k = list(map(int,input().split())) tot = [] cur = 0 for i in range(n+1): cur += i tot.append(cur) cnt = 0 for i in range(k, n+2): if n > i: max_ = tot[n] - tot[n - i] else: max_ = tot[n] min_ = tot[i - 1] cnt += max_ - min_ + 1 cnt %= mod ...
# しゃくとり mod = 10**9 + 7 n,k = list(map(int,input().split())) cnt = 0 sum_ = sum(range(n + 1)) #print("sum", sum_) #print(list(range(n + 1))) max_ = sum(range(n - k + 1, n + 1)) min_ = sum(range(k)) for i in range(k, n+2): #print(max_, min_, cnt) cnt += max_ - min_ + 1 cnt %= mod #prin...
19
24
325
428
mod = 10**9 + 7 n, k = list(map(int, input().split())) tot = [] cur = 0 for i in range(n + 1): cur += i tot.append(cur) cnt = 0 for i in range(k, n + 2): if n > i: max_ = tot[n] - tot[n - i] else: max_ = tot[n] min_ = tot[i - 1] cnt += max_ - min_ + 1 cnt %= mod print(cnt)
# しゃくとり mod = 10**9 + 7 n, k = list(map(int, input().split())) cnt = 0 sum_ = sum(range(n + 1)) # print("sum", sum_) # print(list(range(n + 1))) max_ = sum(range(n - k + 1, n + 1)) min_ = sum(range(k)) for i in range(k, n + 2): # print(max_, min_, cnt) cnt += max_ - min_ + 1 cnt %= mod # print(cnt) ...
false
20.833333
[ "+# しゃくとり", "-tot = []", "-cur = 0", "-for i in range(n + 1):", "- cur += i", "- tot.append(cur)", "+sum_ = sum(range(n + 1))", "+# print(\"sum\", sum_)", "+# print(list(range(n + 1)))", "+max_ = sum(range(n - k + 1, n + 1))", "+min_ = sum(range(k))", "- if n > i:", "- max_ =...
false
0.062844
0.11222
0.560005
[ "s820578331", "s955784199" ]
u405256066
p03049
python
s523324763
s716404415
38
27
3,064
3,064
Accepted
Accepted
28.95
from sys import stdin N=int(stdin.readline().rstrip()) data=[] ans=0 A=0 B=0 ab=0 for i in range(N): S=eval(input()) ans+=S.count("AB") if S[0] == "B": B+=1 if S[-1] == "A": A+=1 if S[-1] == "A" and S[0] == "B": ab+=1 if ab == 0: print((ans+min(A,B))) ...
from sys import stdin N = int(stdin.readline().rstrip()) ans = 0 c1 = 0 c2 = 0 c3 = 0 for _ in range(N): s = (stdin.readline().rstrip()) ans += s.count("AB") if s[0] == "B" and s[-1] == "A": c1 += 1 elif s[0] == "B": c2 += 1 elif s[-1] == "A": c3 += 1 if c1 == ...
25
23
392
454
from sys import stdin N = int(stdin.readline().rstrip()) data = [] ans = 0 A = 0 B = 0 ab = 0 for i in range(N): S = eval(input()) ans += S.count("AB") if S[0] == "B": B += 1 if S[-1] == "A": A += 1 if S[-1] == "A" and S[0] == "B": ab += 1 if ab == 0: print((ans + min(A,...
from sys import stdin N = int(stdin.readline().rstrip()) ans = 0 c1 = 0 c2 = 0 c3 = 0 for _ in range(N): s = stdin.readline().rstrip() ans += s.count("AB") if s[0] == "B" and s[-1] == "A": c1 += 1 elif s[0] == "B": c2 += 1 elif s[-1] == "A": c3 += 1 if c1 == 0: ans += mi...
false
8
[ "-data = []", "-A = 0", "-B = 0", "-ab = 0", "-for i in range(N):", "- S = eval(input())", "- ans += S.count(\"AB\")", "- if S[0] == \"B\":", "- B += 1", "- if S[-1] == \"A\":", "- A += 1", "- if S[-1] == \"A\" and S[0] == \"B\":", "- ab += 1", "-if ab =...
false
0.047368
0.111124
0.426266
[ "s523324763", "s716404415" ]
u905895868
p02694
python
s906618364
s534082254
41
36
10,596
9,920
Accepted
Accepted
12.2
from math import floor from fractions import Fraction from decimal import Decimal def com_interest(n: int) -> int: saving = Decimal(100) interest_per = 0.01 years = 0 while True: years += 1 b = Decimal('1.01') saving = int(saving) * b if saving >= n: ...
from decimal import Decimal def com_interest(n: int) -> int: saving = Decimal('100') interest_per = 0.01 years = 0 while True: years += 1 saving = int(saving * Decimal('1.01')) if saving >= n: break return years print((com_interest(int(eval(in...
20
17
391
323
from math import floor from fractions import Fraction from decimal import Decimal def com_interest(n: int) -> int: saving = Decimal(100) interest_per = 0.01 years = 0 while True: years += 1 b = Decimal("1.01") saving = int(saving) * b if saving >= n: break ...
from decimal import Decimal def com_interest(n: int) -> int: saving = Decimal("100") interest_per = 0.01 years = 0 while True: years += 1 saving = int(saving * Decimal("1.01")) if saving >= n: break return years print((com_interest(int(eval(input())))))
false
15
[ "-from math import floor", "-from fractions import Fraction", "- saving = Decimal(100)", "+ saving = Decimal(\"100\")", "- b = Decimal(\"1.01\")", "- saving = int(saving) * b", "+ saving = int(saving * Decimal(\"1.01\"))" ]
false
0.043008
0.077034
0.558308
[ "s906618364", "s534082254" ]
u334712262
p02863
python
s935960666
s969171772
1,055
340
132,824
45,016
Accepted
Accepted
67.77
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import sys # sys.setrecursionlimit(10**6) # buff_readline = sys.stdin.buffer.readline buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62-1 def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().spli...
92
120
1,807
2,310
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import sys # sys.setrecursionlimit(10**6) # buff_readline = sys.stdin.buffer.readline buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62 - 1 def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) def r...
false
23.333333
[ "-import bisect", "-import heapq", "-import math", "-import random", "-from collections import Counter, defaultdict, deque", "-from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal", "-from functools import lru_cache, reduce", "-from itertools import combinations, combinations_with_replacement, pr...
false
0.087377
0.086363
1.01174
[ "s935960666", "s969171772" ]
u498487134
p02761
python
s080613837
s178229643
168
64
38,384
63,100
Accepted
Accepted
61.9
#!/usr/bin/env pypy3 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,M=MI() ans=[-1]*N f=1 for i in range(M): s,c=MI() s-=1 if ans[s]==-1: ...
#!/usr/bin/env pypy3 def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N,M=MI() st=pow(10,N-1) en=pow(10,N) if N==1: st=0 s=[0]*M c=[0]*M for i in range(M): ...
38
40
801
693
#!/usr/bin/env pypy3 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, M = MI() ans = [-1] * N f = 1 for i in range(M): s, c = MI() s -= 1 if an...
#!/usr/bin/env pypy3 def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): N, M = MI() st = pow(10, N - 1) en = pow(10, N) if N == 1: st = 0 s = [0] * M c = [0] * M for i in r...
false
5
[ "- mod = 10**9 + 7", "- ans = [-1] * N", "- f = 1", "+ st = pow(10, N - 1)", "+ en = pow(10, N)", "+ if N == 1:", "+ st = 0", "+ s = [0] * M", "+ c = [0] * M", "- s, c = MI()", "- s -= 1", "- if ans[s] == -1:", "- ans[s] = c", ...
false
0.037358
0.130598
0.286056
[ "s080613837", "s178229643" ]
u048238198
p02597
python
s576566018
s900324630
34
28
9,476
9,428
Accepted
Accepted
17.65
#https://atcoder.jp/contests/agc008/submissions/15248942 import sys import math sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033...
#https://atcoder.jp/contests/agc008/submissions/15248942 import sys import math sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033...
23
19
517
470
# https://atcoder.jp/contests/agc008/submissions/15248942 import sys import math sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a,...
# https://atcoder.jp/contests/agc008/submissions/15248942 import sys import math sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a,...
false
17.391304
[ "-W = c.count(\"W\")", "-ans = min(R, W)", "-ans = min(ans, left.count(\"W\"))", "+ans = left.count(\"W\")" ]
false
0.03681
0.049021
0.750914
[ "s576566018", "s900324630" ]
u141610915
p02804
python
s198086453
s570196300
277
125
63,144
99,200
Accepted
Accepted
54.87
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) mod = 10 ** 9 + 7 res = 0 a.sort() cs = [0] * (N + 1) for i in range(N): cs[i + 1] = cs[i] + a[i] #print(cs) class Factorial: def __init__(self, n, mod): self.f = [1] for i in range(...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) mod = 10 ** 9 + 7 a.sort() class Factorial: def __init__(self, n, mod): self.mod = mod self.f = [1] for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod) self.i ...
38
36
952
933
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) mod = 10**9 + 7 res = 0 a.sort() cs = [0] * (N + 1) for i in range(N): cs[i + 1] = cs[i] + a[i] # print(cs) class Factorial: def __init__(self, n, mod): self.f = [1] for i in range(1...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) a = list(map(int, input().split())) mod = 10**9 + 7 a.sort() class Factorial: def __init__(self, n, mod): self.mod = mod self.f = [1] for i in range(1, n + 1): self.f.append(self.f[-1] * i % mod) ...
false
5.263158
[ "-res = 0", "-cs = [0] * (N + 1)", "-for i in range(N):", "- cs[i + 1] = cs[i] + a[i]", "-# print(cs)", "+", "+", "+ self.mod = mod", "- return self.f[n] * self.i[n - k] % mod * self.i[k] % mod", "+ return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod", "+",...
false
0.065218
0.075464
0.864226
[ "s198086453", "s570196300" ]
u936985471
p03209
python
s479528891
s110235481
21
18
3,316
3,064
Accepted
Accepted
14.29
N,X=list(map(int,input().split())) # レベル0バーガーの厚さ:1 # レベルLバーガーの厚さ:A(L-1) * 2 + 3 # レベル0バーガーのパティの数:1 # レベルLバーガーのパティの数:P(L-1) * 2 + 1 a=[1] p=[1] for i in range(N): a+=[a[i]*2+3] p+=[p[i]*2+1] def search(n,x): if n==0: return (1,0)[x<=0] elif x<=1+a[n-1]: return search(n-1,x-1) e...
import sys readline = sys.stdin.readline N,X = list(map(int,readline().split())) # レベルNバーガーの厚さ = (レベルN - 1バーガーの厚さ) * 2 + 3 # レベル1〜Nの厚さを先に求めておく T = [1] * (N + 1) for i in range(1, len(T)): T[i] = T[i - 1] * 2 + 3 # レベルNバーガーをX枚目まで食べたとき、パティを何枚食べるか # レベルN - 1バーガーの厚さをtとする # X = 1 : 0枚 # X <= t + 1 : レベル...
23
36
387
852
N, X = list(map(int, input().split())) # レベル0バーガーの厚さ:1 # レベルLバーガーの厚さ:A(L-1) * 2 + 3 # レベル0バーガーのパティの数:1 # レベルLバーガーのパティの数:P(L-1) * 2 + 1 a = [1] p = [1] for i in range(N): a += [a[i] * 2 + 3] p += [p[i] * 2 + 1] def search(n, x): if n == 0: return (1, 0)[x <= 0] elif x <= 1 + a[n - 1]: r...
import sys readline = sys.stdin.readline N, X = list(map(int, readline().split())) # レベルNバーガーの厚さ = (レベルN - 1バーガーの厚さ) * 2 + 3 # レベル1〜Nの厚さを先に求めておく T = [1] * (N + 1) for i in range(1, len(T)): T[i] = T[i - 1] * 2 + 3 # レベルNバーガーをX枚目まで食べたとき、パティを何枚食べるか # レベルN - 1バーガーの厚さをtとする # X = 1 : 0枚 # X <= t + 1 : レベルN - 1バーガーのX - ...
false
36.111111
[ "-N, X = list(map(int, input().split()))", "-# レベル0バーガーの厚さ:1", "-# レベルLバーガーの厚さ:A(L-1) * 2 + 3", "-# レベル0バーガーのパティの数:1", "-# レベルLバーガーのパティの数:P(L-1) * 2 + 1", "-a = [1]", "-p = [1]", "-for i in range(N):", "- a += [a[i] * 2 + 3]", "- p += [p[i] * 2 + 1]", "+import sys", "+", "+readline = s...
false
0.037424
0.041488
0.902043
[ "s479528891", "s110235481" ]
u506858457
p02689
python
s903447326
s409928524
440
391
45,152
29,924
Accepted
Accepted
11.14
N,M=list(map(int,input().split())) H=list(map(int,input().split())) AB=[set() for i in range(N)] #例2を見ると、同じ展望台を結ぶ複数の道がある for i in range(M): A,B=list(map(int,input().split())) A-=1 B-=1 AB[A].add(B) AB[B].add(A) ans=0 for i in range(N): res=True for x in AB[i]: if H[i]<=H[x]:#同じ高さの展望台は条件を...
N,M=list(map(int,input().split())) L=[[] for i in range(N)] #一次配列なら[]*NもOKだが、二次配列だと内包表記 H=list(map(int,input().split())) for i in range(M): A,B=list(map(int,input().split())) A-=1 B-=1 L[A].append(B) L[B].append(A) ans=0 for i in range(N): flag=True #フラグは各展望台毎のチェックに使う for j in L[i]: #fo...
20
22
402
456
N, M = list(map(int, input().split())) H = list(map(int, input().split())) AB = [set() for i in range(N)] # 例2を見ると、同じ展望台を結ぶ複数の道がある for i in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 AB[A].add(B) AB[B].add(A) ans = 0 for i in range(N): res = True for x in AB[i]: i...
N, M = list(map(int, input().split())) L = [[] for i in range(N)] # 一次配列なら[]*NもOKだが、二次配列だと内包表記 H = list(map(int, input().split())) for i in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 L[A].append(B) L[B].append(A) ans = 0 for i in range(N): flag = True # フラグは各展望台毎のチェックに使う ...
false
9.090909
[ "+L = [[] for i in range(N)]", "+# 一次配列なら[]*NもOKだが、二次配列だと内包表記", "-AB = [set() for i in range(N)]", "-# 例2を見ると、同じ展望台を結ぶ複数の道がある", "- AB[A].add(B)", "- AB[B].add(A)", "+ L[A].append(B)", "+ L[B].append(A)", "- res = True", "- for x in AB[i]:", "- if H[i] <= H[x]: # 同じ高さの展望...
false
0.043914
0.042648
1.029681
[ "s903447326", "s409928524" ]
u057964173
p02689
python
s457516619
s967030104
210
121
89,892
85,168
Accepted
Accepted
42.38
import sys def input(): return sys.stdin.readline().strip() def resolve(): N,M=list(map(int, input().split())) H=list(map(int,input().split())) edge = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 edge[x].append(y)...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n,m=list(map(int, input().split())) hl=[0]+list(map(int,input().split())) #どことも繋がっていない展望台もgoodだから、最後にTrueのままになっているのを数える checkl=[True]*n for i in range(m): a,b=list(map(int, input().split())) if hl[a...
22
22
551
568
import sys def input(): return sys.stdin.readline().strip() def resolve(): N, M = list(map(int, input().split())) H = list(map(int, input().split())) edge = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 edge[x].append...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n, m = list(map(int, input().split())) hl = [0] + list(map(int, input().split())) # どことも繋がっていない展望台もgoodだから、最後にTrueのままになっているのを数える checkl = [True] * n for i in range(m): a, b = list(map(int, input().split())) ...
false
0
[ "- N, M = list(map(int, input().split()))", "- H = list(map(int, input().split()))", "- edge = [[] for i in range(N)]", "- for i in range(M):", "- x, y = list(map(int, input().split()))", "- x, y = x - 1, y - 1", "- edge[x].append(y)", "- edge[y].append(x)", "...
false
0.08143
0.079382
1.025811
[ "s457516619", "s967030104" ]
u188827677
p02695
python
s752970193
s796459551
1,228
952
21,640
21,604
Accepted
Accepted
22.48
from itertools import combinations_with_replacement n,m,q = list(map(int, input().split())) abcd = [] for _ in range(q): a,b,c,d = list(map(int, input().split())) abcd.append([a,b,c,d]) nums = list(range(1,m+1)) l = list(combinations_with_replacement(nums, n)) ans = 0 for i in l: p = 0 for j in a...
from itertools import combinations_with_replacement n,m,q = list(map(int, input().split())) abcd = [] for _ in range(q): a,b,c,d = list(map(int, input().split())) abcd.append([a,b,c,d]) nums = list(range(1,m+1)) l = list(combinations_with_replacement(nums, n)) ans = 0 for i in l: p = 0 for j in a...
21
19
427
405
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [] for _ in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a, b, c, d]) nums = list(range(1, m + 1)) l = list(combinations_with_replacement(nums, n)) ans = 0 for i in l: p = 0 for j...
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [] for _ in range(q): a, b, c, d = list(map(int, input().split())) abcd.append([a, b, c, d]) nums = list(range(1, m + 1)) l = list(combinations_with_replacement(nums, n)) ans = 0 for i in l: p = 0 for j...
false
9.52381
[ "- b = i[j[1] - 1]", "- a = i[j[0] - 1]", "- if b - a == j[2]:", "+ if i[j[1] - 1] - i[j[0] - 1] == j[2]:" ]
false
0.064073
0.062913
1.018443
[ "s752970193", "s796459551" ]
u583507988
p03456
python
s673605571
s180421244
30
25
9,092
9,052
Accepted
Accepted
16.67
import math a, b = list(map(str, input().split())) res = a+b #print(math.sqrt(int(res))) x = int(math.sqrt(int(res))) if x**2 == int(res): print('Yes') else: print('No')
from math import sqrt a,b=input().split() c=int(a+b) if sqrt(c)==int(sqrt(c)): print('Yes') else: print('No')
10
7
177
119
import math a, b = list(map(str, input().split())) res = a + b # print(math.sqrt(int(res))) x = int(math.sqrt(int(res))) if x**2 == int(res): print("Yes") else: print("No")
from math import sqrt a, b = input().split() c = int(a + b) if sqrt(c) == int(sqrt(c)): print("Yes") else: print("No")
false
30
[ "-import math", "+from math import sqrt", "-a, b = list(map(str, input().split()))", "-res = a + b", "-# print(math.sqrt(int(res)))", "-x = int(math.sqrt(int(res)))", "-if x**2 == int(res):", "+a, b = input().split()", "+c = int(a + b)", "+if sqrt(c) == int(sqrt(c)):" ]
false
0.076678
0.091484
0.838155
[ "s673605571", "s180421244" ]
u388927326
p03948
python
s168625023
s167631813
105
83
15,060
14,292
Accepted
Accepted
20.95
#!/usr/bin/env python3 def main(): n, t = list(map(int, input().split())) an = list(map(int, input().split())) mi = [an[0]] se_mi = {0} for i in range(1, n): if mi[i - 1] > an[i]: se_mi = {i} elif mi[i - 1] == an[i]: se_mi.add(i) mi.appe...
#!/usr/bin/env python3 def main(): n, t = list(map(int, input().split())) an = list(map(int, input().split())) mi = [an[0]] for i in range(1, n): mi.append(min(mi[i - 1], an[i])) ma = 0 num_ma = 0 for i in range(1, n): be = an[i] - mi[i - 1] if be > m...
27
22
582
440
#!/usr/bin/env python3 def main(): n, t = list(map(int, input().split())) an = list(map(int, input().split())) mi = [an[0]] se_mi = {0} for i in range(1, n): if mi[i - 1] > an[i]: se_mi = {i} elif mi[i - 1] == an[i]: se_mi.add(i) mi.append(min(mi[i - 1...
#!/usr/bin/env python3 def main(): n, t = list(map(int, input().split())) an = list(map(int, input().split())) mi = [an[0]] for i in range(1, n): mi.append(min(mi[i - 1], an[i])) ma = 0 num_ma = 0 for i in range(1, n): be = an[i] - mi[i - 1] if be > ma: ma...
false
18.518519
[ "- se_mi = {0}", "- if mi[i - 1] > an[i]:", "- se_mi = {i}", "- elif mi[i - 1] == an[i]:", "- se_mi.add(i)", "- se_ma = set()", "+ num_ma = 0", "- se_ma = {i}", "+ num_ma = 1", "- se_ma.add(i)", "- print((len(se_ma)...
false
0.035941
0.055399
0.648773
[ "s168625023", "s167631813" ]
u201234972
p03095
python
s998120737
s104924883
936
25
3,188
3,444
Accepted
Accepted
97.33
N = int( eval(input())) S = eval(input()) Q = 10**9+7 A = [1]*26 ANS = [0]*26 for i in range(N): s = ord(S[i]) - ord("a") ans = 1 for j in range(26): if j != s: ans *= A[j] ans %= Q ANS[j] = (ANS[j] + ans)%Q A[s] += 1 print(( sum(ANS)))
from collections import Counter N = int( eval(input())) S = eval(input()) Q = 10**9+7 C = Counter(S) ans = 1 for c in C: ans *= C[c]+1 ans %= Q print(((ans-1)%Q))
15
10
289
166
N = int(eval(input())) S = eval(input()) Q = 10**9 + 7 A = [1] * 26 ANS = [0] * 26 for i in range(N): s = ord(S[i]) - ord("a") ans = 1 for j in range(26): if j != s: ans *= A[j] ans %= Q ANS[j] = (ANS[j] + ans) % Q A[s] += 1 print((sum(ANS)))
from collections import Counter N = int(eval(input())) S = eval(input()) Q = 10**9 + 7 C = Counter(S) ans = 1 for c in C: ans *= C[c] + 1 ans %= Q print(((ans - 1) % Q))
false
33.333333
[ "+from collections import Counter", "+", "-A = [1] * 26", "-ANS = [0] * 26", "-for i in range(N):", "- s = ord(S[i]) - ord(\"a\")", "- ans = 1", "- for j in range(26):", "- if j != s:", "- ans *= A[j]", "- ans %= Q", "- ANS[j] = (ANS[j] + ans) % Q", "...
false
0.130851
0.035876
3.647369
[ "s998120737", "s104924883" ]
u729133443
p03043
python
s747957877
s170594309
182
40
39,408
2,940
Accepted
Accepted
78.02
n,k=list(map(int,input().split())) a=0 for i in range(1,n+1): j=0 while i<k:i*=2;j+=1 a+=1/n*.5**j print(a)
n,k=list(map(int,input().split()));a=0 for i in range(1,n+1): j=1/n while i<k:i*=2;j*=.5 a+=j print(a)
7
6
113
104
n, k = list(map(int, input().split())) a = 0 for i in range(1, n + 1): j = 0 while i < k: i *= 2 j += 1 a += 1 / n * 0.5**j print(a)
n, k = list(map(int, input().split())) a = 0 for i in range(1, n + 1): j = 1 / n while i < k: i *= 2 j *= 0.5 a += j print(a)
false
14.285714
[ "- j = 0", "+ j = 1 / n", "- j += 1", "- a += 1 / n * 0.5**j", "+ j *= 0.5", "+ a += j" ]
false
0.067912
0.137102
0.495338
[ "s747957877", "s170594309" ]
u419877586
p02888
python
s407535354
s418982217
1,721
744
52,980
43,628
Accepted
Accepted
56.77
from bisect import bisect_left N=int(eval(input())) L=list(map(int, input().split())) L.sort() ans=0 for i in range(N): for j in range(i+1, N): ans+=bisect_left(L[j+1:], L[i]+L[j]) print(ans)
import bisect N=int(eval(input())) L=list(map(int, input().split())) L.sort() ans=0 for i in range(N): a=L[i] for j in range(i+1, N): b=L[j] ans+=bisect.bisect_left(L, a+b)-(j+1) print(ans)
10
13
201
222
from bisect import bisect_left N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N): for j in range(i + 1, N): ans += bisect_left(L[j + 1 :], L[i] + L[j]) print(ans)
import bisect N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N): a = L[i] for j in range(i + 1, N): b = L[j] ans += bisect.bisect_left(L, a + b) - (j + 1) print(ans)
false
23.076923
[ "-from bisect import bisect_left", "+import bisect", "+ a = L[i]", "- ans += bisect_left(L[j + 1 :], L[i] + L[j])", "+ b = L[j]", "+ ans += bisect.bisect_left(L, a + b) - (j + 1)" ]
false
0.034801
0.036594
0.95102
[ "s407535354", "s418982217" ]
u075012704
p03039
python
s994755294
s334547347
624
488
27,024
32,836
Accepted
Accepted
21.79
H, W, K = list(map(int, input().split())) MOD = 10 ** 9 + 7 factorial = [1, 1] # 元テーブル inverse = [1, 1] # 逆元テーブル inverse_from = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, H * W + 1): factorial.append((factorial[-1] * i) % MOD) inverse_from.append((-inverse_from[MOD % i] * (MOD // i)) % MOD) inv...
H, W, K = list(map(int, input().split())) MOD = 10 ** 9 + 7 factorial = [1, 1] inverse = [1, 1] invere_base = [0, 1] for i in range(2, H * W + 2): factorial.append((factorial[-1] * i) % MOD) invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD) inverse.append((inverse[-1] * invere_base[-1...
32
27
796
701
H, W, K = list(map(int, input().split())) MOD = 10**9 + 7 factorial = [1, 1] # 元テーブル inverse = [1, 1] # 逆元テーブル inverse_from = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, H * W + 1): factorial.append((factorial[-1] * i) % MOD) inverse_from.append((-inverse_from[MOD % i] * (MOD // i)) % MOD) inverse.append((i...
H, W, K = list(map(int, input().split())) MOD = 10**9 + 7 factorial = [1, 1] inverse = [1, 1] invere_base = [0, 1] for i in range(2, H * W + 2): factorial.append((factorial[-1] * i) % MOD) invere_base.append((-invere_base[MOD % i] * (MOD // i)) % MOD) inverse.append((inverse[-1] * invere_base[-1]) % MOD) ...
false
15.625
[ "-factorial = [1, 1] # 元テーブル", "-inverse = [1, 1] # 逆元テーブル", "-inverse_from = [0, 1] # 逆元テーブル計算用テーブル", "-for i in range(2, H * W + 1):", "+factorial = [1, 1]", "+inverse = [1, 1]", "+invere_base = [0, 1]", "+for i in range(2, H * W + 2):", "- inverse_from.append((-inverse_from[MOD % i] * (MOD ...
false
0.041683
0.151417
0.275286
[ "s994755294", "s334547347" ]
u285891772
p03796
python
s038471431
s445142629
423
302
93,260
22,548
Accepted
Accepted
28.61
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lower...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lower...
29
28
914
888
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
false
3.448276
[ "-", "-", "-def power(N):", "- if N == 1:", "- return 1", "- else:", "- return (N * power(N - 1)) % mod", "-", "-", "-print((power(N)))", "+ans = 1", "+for i in range(1, N + 1):", "+ ans = (ans * i) % mod", "+print(ans)" ]
false
0.094162
0.095943
0.981435
[ "s038471431", "s445142629" ]
u607563136
p02684
python
s807136665
s471451068
361
157
51,044
32,208
Accepted
Accepted
56.51
import numpy as np def main(): N,K = list(map(int,input().split())) A = [0] A += list(map(int,input().split())) A = np.array(A) i = 1 pas = np.zeros(N) pas[0] = i k = 1 pass_set = set(pas) while k <= K: if A[i] in pass_set: rps = np.where(...
def main(): N,K = list(map(int,input().split())) A = [0] + list(map(int,input().split())) i = 1 pas = [i] pas_set = set(pas) k = 1 while k <= K: if A[i] in pas_set: rps = pas.index(A[i]) ans = A[i] break pas.append(A[i]) ...
31
26
611
516
import numpy as np def main(): N, K = list(map(int, input().split())) A = [0] A += list(map(int, input().split())) A = np.array(A) i = 1 pas = np.zeros(N) pas[0] = i k = 1 pass_set = set(pas) while k <= K: if A[i] in pass_set: rps = np.where(pas == (A[i]))[0...
def main(): N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) i = 1 pas = [i] pas_set = set(pas) k = 1 while k <= K: if A[i] in pas_set: rps = pas.index(A[i]) ans = A[i] break pas.append(A[i]) pas_set....
false
16.129032
[ "-import numpy as np", "-", "-", "- A = [0]", "- A += list(map(int, input().split()))", "- A = np.array(A)", "+ A = [0] + list(map(int, input().split()))", "- pas = np.zeros(N)", "- pas[0] = i", "+ pas = [i]", "+ pas_set = set(pas)", "- pass_set = set(pas)", "- ...
false
0.191188
0.135682
1.409089
[ "s807136665", "s471451068" ]
u763534217
p02642
python
s679213048
s222728415
1,249
1,090
104,208
104,204
Accepted
Accepted
12.73
n = int(eval(input())) *A, = list(map(int, input().split())) maxA = max(A) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: t = 2 while a * t <= maxA: D[a * t] = 1 t += 1 ...
n = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: t = 2 while a * t <= maxA: D[a * t] = 1 t += 1 a...
20
20
392
397
n = int(eval(input())) (*A,) = list(map(int, input().split())) maxA = max(A) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: t = 2 while a * t <= maxA: D[a * t] = 1 t += 1 ans = 0 for ...
n = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) # C[a] = A内のaの個数 C = {a: 0 for a in A} for a in A: C[a] += 1 # D[a]=1: Aにaより小さいaの約数が存在する D = {a: 0 for a in A} for a in A: if C[a] > 0: t = 2 while a * t <= maxA: D[a * t] = 1 t += 1 ans = 0 for a in...
false
0
[ "-(*A,) = list(map(int, input().split()))", "+A = list(map(int, input().split()))" ]
false
0.06569
0.038582
1.702613
[ "s679213048", "s222728415" ]
u517682687
p02709
python
s813965400
s025625574
1,968
385
137,192
194,140
Accepted
Accepted
80.44
N = int(eval(input())) A = list(map(int, input().split())) table = [] for i, a in enumerate(A): table.append([a,i]) table.sort() # DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ DP = [[0 for i in range(N+1)] for j in range(N+1)] for i in range(1,N+1): # i 人目 table[i-1] の幼児を移動させる baby, pos = table.po...
N = int(input()) A_list = map(int, input().split()) # [活発度, もとの番号] のリストを降順に並べる A_list = [[A, index] for index, A in enumerate(A_list)] A_list.sort(reverse=True) # print(A_list) dp = [[0 for i in range(N+1)] for j in range(N+1)] # print(dp) for left in range(0, N): for right in range(0, N - left): ...
27
32
696
1,166
N = int(eval(input())) A = list(map(int, input().split())) table = [] for i, a in enumerate(A): table.append([a, i]) table.sort() # DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ DP = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(1, N + 1): # i 人目 table[i-1] の幼児を移動させる baby, pos = table.pop() ...
N = int(input()) A_list = map(int, input().split()) # [活発度, もとの番号] のリストを降順に並べる A_list = [[A, index] for index, A in enumerate(A_list)] A_list.sort(reverse=True) # print(A_list) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] # print(dp) for left in range(0, N): for right in range(0, N - left): # prin...
false
15.625
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-table = []", "-for i, a in enumerate(A):", "- table.append([a, i])", "-table.sort()", "-# DP[i][j] 左端に i 個, 右端に j 個貪欲に詰めたときのうれしさ", "-DP = [[0 for i in range(N + 1)] for j in range(N + 1)]", "-for i in range(1, N + 1):", "- ...
false
0.038148
0.037909
1.006307
[ "s813965400", "s025625574" ]
u202570162
p03617
python
s387867137
s310206047
21
17
3,316
3,060
Accepted
Accepted
19.05
q,h,s,d = list(map(int,input().split())) n = int(eval(input())) twoL = min(q*8,4*h,2*s,d) oneL = min(q*4,2*h,s) p = (n//2)*twoL + (n%2)*oneL print(p)
Q,H,S,D=list(map(int,input().split())) N=int(eval(input())) ans=0 #each 2L ans+=(N//2)*min([8*Q,4*H,2*S,D]) #1L ans+=(N%2)*min([4*Q,2*H,S]) print(ans)
6
8
143
145
q, h, s, d = list(map(int, input().split())) n = int(eval(input())) twoL = min(q * 8, 4 * h, 2 * s, d) oneL = min(q * 4, 2 * h, s) p = (n // 2) * twoL + (n % 2) * oneL print(p)
Q, H, S, D = list(map(int, input().split())) N = int(eval(input())) ans = 0 # each 2L ans += (N // 2) * min([8 * Q, 4 * H, 2 * S, D]) # 1L ans += (N % 2) * min([4 * Q, 2 * H, S]) print(ans)
false
25
[ "-q, h, s, d = list(map(int, input().split()))", "-n = int(eval(input()))", "-twoL = min(q * 8, 4 * h, 2 * s, d)", "-oneL = min(q * 4, 2 * h, s)", "-p = (n // 2) * twoL + (n % 2) * oneL", "-print(p)", "+Q, H, S, D = list(map(int, input().split()))", "+N = int(eval(input()))", "+ans = 0", "+# each ...
false
0.046264
0.039392
1.174457
[ "s387867137", "s310206047" ]
u989345508
p03606
python
s102354864
s833719039
22
20
2,940
2,940
Accepted
Accepted
9.09
n=int(eval(input())) c=0 for i in range(n): l,r=input().split() c+=(int(r)-int(l)+1) print(c)
c=0 n=int(eval(input())) for i in range(n): l,r=list(map(int,input().split())) c+=(r-l+1) print(c)
7
6
103
100
n = int(eval(input())) c = 0 for i in range(n): l, r = input().split() c += int(r) - int(l) + 1 print(c)
c = 0 n = int(eval(input())) for i in range(n): l, r = list(map(int, input().split())) c += r - l + 1 print(c)
false
14.285714
[ "+c = 0", "-c = 0", "- l, r = input().split()", "- c += int(r) - int(l) + 1", "+ l, r = list(map(int, input().split()))", "+ c += r - l + 1" ]
false
0.036522
0.036286
1.006497
[ "s102354864", "s833719039" ]
u136869985
p03206
python
s405288859
s909623492
20
18
3,316
2,940
Accepted
Accepted
10
d = int(eval(input())) if d == 25: print('Christmas') elif d == 24: print('Christmas Eve') elif d == 23: print('Christmas Eve Eve') elif d == 22: print('Christmas Eve Eve Eve')
D = int(eval(input())) ans = 'Christmas' for i in range(25 - D): ans += ' Eve' print(ans)
10
7
197
95
d = int(eval(input())) if d == 25: print("Christmas") elif d == 24: print("Christmas Eve") elif d == 23: print("Christmas Eve Eve") elif d == 22: print("Christmas Eve Eve Eve")
D = int(eval(input())) ans = "Christmas" for i in range(25 - D): ans += " Eve" print(ans)
false
30
[ "-d = int(eval(input()))", "-if d == 25:", "- print(\"Christmas\")", "-elif d == 24:", "- print(\"Christmas Eve\")", "-elif d == 23:", "- print(\"Christmas Eve Eve\")", "-elif d == 22:", "- print(\"Christmas Eve Eve Eve\")", "+D = int(eval(input()))", "+ans = \"Christmas\"", "+for ...
false
0.272227
0.295872
0.920083
[ "s405288859", "s909623492" ]
u593567568
p02781
python
s413073952
s909629464
27
22
3,940
3,064
Accepted
Accepted
18.52
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache N, K = list(map(int,read().split())) @lru_cache(None) def F(N, K): """N以下で0でないものがちょうどK個。0を含める""" assert N >= 0 if N < 10: if K == 0: ...
import sys import math sys.setrecursionlimit(10 ** 7) # 桁DP # 非再帰 S = eval(input()) K = int(eval(input())) N = len(S) # dp[n桁目まで決まってる][Non-Zeroの個数][Nと一致? 0:一致している 1:一致していない] dp = [[[0] * 2 for _ in range(4)] for _ in range(N + 1)] # n=0 桁目の値は、0として、それはKの値には関係なく、Nと一致している dp[0][0][0] = 1 # i,j,kのうち、小...
32
51
647
1,179
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache N, K = list(map(int, read().split())) @lru_cache(None) def F(N, K): """N以下で0でないものがちょうどK個。0を含める""" assert N >= 0 if N < 10: if K == 0: re...
import sys import math sys.setrecursionlimit(10**7) # 桁DP # 非再帰 S = eval(input()) K = int(eval(input())) N = len(S) # dp[n桁目まで決まってる][Non-Zeroの個数][Nと一致? 0:一致している 1:一致していない] dp = [[[0] * 2 for _ in range(4)] for _ in range(N + 1)] # n=0 桁目の値は、0として、それはKの値には関係なく、Nと一致している dp[0][0][0] = 1 # i,j,kのうち、小さい方から埋めていく for i in ran...
false
37.254902
[ "+import math", "-read = sys.stdin.buffer.read", "-readline = sys.stdin.buffer.readline", "-readlines = sys.stdin.buffer.readlines", "-from functools import lru_cache", "-", "-N, K = list(map(int, read().split()))", "-", "-", "-@lru_cache(None)", "-def F(N, K):", "- \"\"\"N以下で0でないものがちょうどK個。...
false
0.046628
0.046639
0.999768
[ "s413073952", "s909629464" ]
u589843455
p04011
python
s654500186
s799900556
183
164
38,384
38,256
Accepted
Accepted
10.38
l = [int(eval(input())) for _ in range(4)] if l[1] >= l[0]: print((l[0]*l[2])) else: print((l[1]*l[2] + (l[0]-l[1])*l[3]))
n,k,x,y = (int(eval(input())) for _ in range(4)) print((min(n,k)*x + y*max(n-k,0)))
5
2
120
76
l = [int(eval(input())) for _ in range(4)] if l[1] >= l[0]: print((l[0] * l[2])) else: print((l[1] * l[2] + (l[0] - l[1]) * l[3]))
n, k, x, y = (int(eval(input())) for _ in range(4)) print((min(n, k) * x + y * max(n - k, 0)))
false
60
[ "-l = [int(eval(input())) for _ in range(4)]", "-if l[1] >= l[0]:", "- print((l[0] * l[2]))", "-else:", "- print((l[1] * l[2] + (l[0] - l[1]) * l[3]))", "+n, k, x, y = (int(eval(input())) for _ in range(4))", "+print((min(n, k) * x + y * max(n - k, 0)))" ]
false
0.045447
0.05524
0.822714
[ "s654500186", "s799900556" ]
u714852797
p02554
python
s280334961
s188017777
389
29
11,032
8,976
Accepted
Accepted
92.54
N = int(eval(input())) print(((10 ** N - 2 * 9 ** N + 8 ** N) % (10 ** 9 + 7)))
N = int(eval(input())) mod = 10 ** 9 + 7 print(((pow(10, N, mod) - 2 * pow(9, N, mod) + pow(8, N, mod)) % mod))
3
5
76
109
N = int(eval(input())) print(((10**N - 2 * 9**N + 8**N) % (10**9 + 7)))
N = int(eval(input())) mod = 10**9 + 7 print(((pow(10, N, mod) - 2 * pow(9, N, mod) + pow(8, N, mod)) % mod))
false
40
[ "-print(((10**N - 2 * 9**N + 8**N) % (10**9 + 7)))", "+mod = 10**9 + 7", "+print(((pow(10, N, mod) - 2 * pow(9, N, mod) + pow(8, N, mod)) % mod))" ]
false
0.129062
0.034812
3.707428
[ "s280334961", "s188017777" ]
u671060652
p03072
python
s023707650
s592662429
297
68
64,492
61,892
Accepted
Accepted
77.1
import itertools import math import fractions import functools import copy n = int(eval(input())) h = list(map(int, input().split())) count = 0 maximum = 0 for i in range(n): maximum = max(maximum,h[i]) if maximum <= h[i]: count += 1 print(count)
import math def main(): n = int(eval(input())) # a, b = map(int, input().split()) h = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] count = 1 maxi = h[0] for i in range(1, n): if h[i] >= h[i-1] and h[i] >= maxi: c...
16
21
273
411
import itertools import math import fractions import functools import copy n = int(eval(input())) h = list(map(int, input().split())) count = 0 maximum = 0 for i in range(n): maximum = max(maximum, h[i]) if maximum <= h[i]: count += 1 print(count)
import math def main(): n = int(eval(input())) # a, b = map(int, input().split()) h = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] count = 1 maxi = h[0] for i in range(1, n): if h[i] >= h[i - 1] and h[i] >= maxi: count += 1 ...
false
23.809524
[ "-import itertools", "-import fractions", "-import functools", "-import copy", "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-count = 0", "-maximum = 0", "-for i in range(n):", "- maximum = max(maximum, h[i])", "- if maximum <= h[i]:", "- count += 1", "-pri...
false
0.039928
0.037502
1.064708
[ "s023707650", "s592662429" ]
u896741788
p02844
python
s868631755
s326739337
547
35
3,444
4,456
Accepted
Accepted
93.6
n=int(eval(input())) s=eval(input()) ans=0 for aim in range(100): sa=str(aim) if aim<=9:sa="0"+sa cnt=0;k=-1 for i in range(n): if sa[cnt]==s[i]:cnt+=1 if cnt==2:k=i;break else:continue ans+=len(set(list(s[k+1:]))) print(ans)
n=int(eval(input())) s=eval(input()) l=[[]for i in range(11)] for i in range(n): d=int(s[i]) l[d].append(i) ans=0 le=[len(f) for f in l] from bisect import bisect_left as bl,bisect_right as br for i in range(0,1000): ss=str(i).zfill(3) now=-1 for x in ss: c=br(l[int(x)],now) ...
13
21
245
405
n = int(eval(input())) s = eval(input()) ans = 0 for aim in range(100): sa = str(aim) if aim <= 9: sa = "0" + sa cnt = 0 k = -1 for i in range(n): if sa[cnt] == s[i]: cnt += 1 if cnt == 2: k = i break else: continue ans += l...
n = int(eval(input())) s = eval(input()) l = [[] for i in range(11)] for i in range(n): d = int(s[i]) l[d].append(i) ans = 0 le = [len(f) for f in l] from bisect import bisect_left as bl, bisect_right as br for i in range(0, 1000): ss = str(i).zfill(3) now = -1 for x in ss: c = br(l[int(x)]...
false
38.095238
[ "+l = [[] for i in range(11)]", "+for i in range(n):", "+ d = int(s[i])", "+ l[d].append(i)", "-for aim in range(100):", "- sa = str(aim)", "- if aim <= 9:", "- sa = \"0\" + sa", "- cnt = 0", "- k = -1", "- for i in range(n):", "- if sa[cnt] == s[i]:", "- ...
false
0.034616
0.036137
0.95791
[ "s868631755", "s326739337" ]
u057109575
p02960
python
s095322735
s878816860
315
187
88,420
95,780
Accepted
Accepted
40.63
S = eval(input()) dp = [[0] * 13 for _ in range(len(S) + 1)] dp[0][0] = 1 mod = 10 ** 9 + 7 for i in range(len(S)): for j in range(13): if S[i] == "?": for k in range(10): x = (j * 10 + k) % 13 dp[i + 1][x] += dp[i][j] dp[i + 1][x] %= m...
S = eval(input()) n = len(S) dp = [[0] * 13 for _ in range(n + 1)] dp[0][0] = 1 MOD = 10 ** 9 + 7 for i in range(n): for j in range(13): if S[i] != "?": dp[i + 1][(j * 10 + int(S[i])) % 13] += dp[i][j] else: for k in range(10): dp[i + 1][(j * 10 +...
18
18
478
412
S = eval(input()) dp = [[0] * 13 for _ in range(len(S) + 1)] dp[0][0] = 1 mod = 10**9 + 7 for i in range(len(S)): for j in range(13): if S[i] == "?": for k in range(10): x = (j * 10 + k) % 13 dp[i + 1][x] += dp[i][j] dp[i + 1][x] %= mod els...
S = eval(input()) n = len(S) dp = [[0] * 13 for _ in range(n + 1)] dp[0][0] = 1 MOD = 10**9 + 7 for i in range(n): for j in range(13): if S[i] != "?": dp[i + 1][(j * 10 + int(S[i])) % 13] += dp[i][j] else: for k in range(10): dp[i + 1][(j * 10 + k) % 13] += dp...
false
0
[ "-dp = [[0] * 13 for _ in range(len(S) + 1)]", "+n = len(S)", "+dp = [[0] * 13 for _ in range(n + 1)]", "-mod = 10**9 + 7", "-for i in range(len(S)):", "+MOD = 10**9 + 7", "+for i in range(n):", "- if S[i] == \"?\":", "+ if S[i] != \"?\":", "+ dp[i + 1][(j * 10 + int(S[i])...
false
0.076227
0.037588
2.027974
[ "s095322735", "s878816860" ]
u057109575
p03112
python
s843446832
s134054138
1,454
474
86,872
94,476
Accepted
Accepted
67.4
from bisect import bisect_right A, B, Q = list(map(int, input().split())) s = [int(eval(input())) for _ in range(A)] t = [int(eval(input())) for _ in range(B)] x = [int(eval(input())) for _ in range(Q)] INF = 10 ** 18 s = [-INF] + s + [INF] t = [-INF] + t + [INF] for i in range(Q): b = bisect_right(s...
from bisect import bisect_right A, B, Q = list(map(int, input().split())) INF = 10 ** 18 S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] X = [int(eval(input())) for _ in range(Q)] for x in X: b = bisect_right(S, x) d = bisect_...
21
20
560
545
from bisect import bisect_right A, B, Q = list(map(int, input().split())) s = [int(eval(input())) for _ in range(A)] t = [int(eval(input())) for _ in range(B)] x = [int(eval(input())) for _ in range(Q)] INF = 10**18 s = [-INF] + s + [INF] t = [-INF] + t + [INF] for i in range(Q): b = bisect_right(s, x[i]) d = ...
from bisect import bisect_right A, B, Q = list(map(int, input().split())) INF = 10**18 S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF] T = [-INF] + [int(eval(input())) for _ in range(B)] + [INF] X = [int(eval(input())) for _ in range(Q)] for x in X: b = bisect_right(S, x) d = bisect_right(T, x) ...
false
4.761905
[ "-s = [int(eval(input())) for _ in range(A)]", "-t = [int(eval(input())) for _ in range(B)]", "-x = [int(eval(input())) for _ in range(Q)]", "-s = [-INF] + s + [INF]", "-t = [-INF] + t + [INF]", "-for i in range(Q):", "- b = bisect_right(s, x[i])", "- d = bisect_right(t, x[i])", "+S = [-INF] +...
false
0.088009
0.05931
1.483871
[ "s843446832", "s134054138" ]
u375193358
p02576
python
s563496651
s222840206
28
23
9,156
9,032
Accepted
Accepted
17.86
N, X, T = list(map(int,input().split())) counter = 0 rem = N while rem > 0: rem -= X counter += 1 print((counter*T))
import math N, X, T = list(map(int,input().split())) if N%X == 0: print((int(N/X*T))) else: print(((math.floor(N/X)+1)*T))
7
6
123
125
N, X, T = list(map(int, input().split())) counter = 0 rem = N while rem > 0: rem -= X counter += 1 print((counter * T))
import math N, X, T = list(map(int, input().split())) if N % X == 0: print((int(N / X * T))) else: print(((math.floor(N / X) + 1) * T))
false
14.285714
[ "+import math", "+", "-counter = 0", "-rem = N", "-while rem > 0:", "- rem -= X", "- counter += 1", "-print((counter * T))", "+if N % X == 0:", "+ print((int(N / X * T)))", "+else:", "+ print(((math.floor(N / X) + 1) * T))" ]
false
0.049597
0.050459
0.982908
[ "s563496651", "s222840206" ]
u706929073
p03160
python
s806882657
s030662352
147
128
13,924
13,924
Accepted
Accepted
12.93
n = int(eval(input())) h = list(map(int, input().split())) dp = [10 ** 18 for _ in range(n)] dp[0] = 0 for i in range(1, n): dp[i] = min([ dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) ]) print((dp[-1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [10 ** 18 for _ in range(n)] dp[0] = 0 for i in range(1, n): dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])) print((dp[-1]))
10
8
242
232
n = int(eval(input())) h = list(map(int, input().split())) dp = [10**18 for _ in range(n)] dp[0] = 0 for i in range(1, n): dp[i] = min([dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])]) print((dp[-1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [10**18 for _ in range(n)] dp[0] = 0 for i in range(1, n): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[-1]))
false
20
[ "- dp[i] = min([dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])])", "+ dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))" ]
false
0.035687
0.040772
0.87529
[ "s806882657", "s030662352" ]
u353797797
p03576
python
s505825412
s595880622
711
82
3,192
3,316
Accepted
Accepted
88.47
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): n, k...
from collections import deque import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_...
53
51
1,506
1,372
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): ...
from collections import deque import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def ...
false
3.773585
[ "+from collections import deque", "+", "+", "+def II():", "+ return int(sys.stdin.readline())", "+def SI():", "+ return sys.stdin.readline()[:-1]", "+", "+", "+ xx = set()", "+ yy = set()", "- xx = []", "- yy = []", "- xy.append([x, y])", "- xx.append(x)",...
false
0.038208
0.044419
0.860172
[ "s505825412", "s595880622" ]
u888337853
p02952
python
s386838117
s731946482
189
83
38,768
5,120
Accepted
Accepted
56.08
import math # inputList=[] # for i in range(6): # inputNum = input() # inputList.append(inputNum) inputa = input().split() # inputb = input().split() # inputa = [int(n) for n in inputa] # inputa.sort() # inputa = list(inputa[0]) a = int(inputa[0]) # b = int(inputa[1]) # c = int(inputa[2]) ...
import math import copy from copy import deepcopy import sys import fractions # import numpy as np from functools import reduce # import statistics import decimal import heapq import collections import itertools from operator import mul sys.setrecursionlimit(100001) # input = sys.stdin.readline # s...
28
66
463
1,199
import math # inputList=[] # for i in range(6): # inputNum = input() # inputList.append(inputNum) inputa = input().split() # inputb = input().split() # inputa = [int(n) for n in inputa] # inputa.sort() # inputa = list(inputa[0]) a = int(inputa[0]) # b = int(inputa[1]) # c = int(inputa[2]) # x = int(inputb[0]) ...
import math import copy from copy import deepcopy import sys import fractions # import numpy as np from functools import reduce # import statistics import decimal import heapq import collections import itertools from operator import mul sys.setrecursionlimit(100001) # input = sys.stdin.readline # sys.setrecursionlim...
false
57.575758
[ "+import copy", "+from copy import deepcopy", "+import sys", "+import fractions", "-# inputList=[]", "-# for i in range(6):", "-# inputNum = input()", "-# inputList.append(inputNum)", "-inputa = input().split()", "-# inputb = input().split()", "-# inputa = [int(n) for n in inputa]", "-...
false
0.076549
0.044463
1.72165
[ "s386838117", "s731946482" ]
u835924161
p02700
python
s235247015
s639851215
21
19
9,172
9,160
Accepted
Accepted
9.52
a,b,c,d=list(map(int,input().split())) taka=int((c+b-1)/b) aoki=int((a+d-1)/d) if taka<=aoki: print("Yes") else: print("No")
a,b,c,d=list(map(int,input().split())) while True: c-=b if c<=0: print("Yes") exit() a-=d if a<=0: print("No") exit()
8
10
134
169
a, b, c, d = list(map(int, input().split())) taka = int((c + b - 1) / b) aoki = int((a + d - 1) / d) if taka <= aoki: print("Yes") else: print("No")
a, b, c, d = list(map(int, input().split())) while True: c -= b if c <= 0: print("Yes") exit() a -= d if a <= 0: print("No") exit()
false
20
[ "-taka = int((c + b - 1) / b)", "-aoki = int((a + d - 1) / d)", "-if taka <= aoki:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+while True:", "+ c -= b", "+ if c <= 0:", "+ print(\"Yes\")", "+ exit()", "+ a -= d", "+ if a <= 0:", "+ print(\"No...
false
0.036864
0.046877
0.786398
[ "s235247015", "s639851215" ]
u519939795
p03331
python
s756327354
s605710792
442
158
3,060
3,060
Accepted
Accepted
64.25
n=int(eval(input())) ans=10**6 for i in range(1,n): a=list(map(int,list(str(i)))) b=list(map(int,list(str(n-i)))) c=sum(a)+sum(b) ans=min(ans,c) print(ans)
n=int(eval(input())) ans=10**6 for i in range(1,n+1): a=i b=n-i if a<=b: asum=sum(map(int,str(a))) bsum=sum(map(int,str(b))) if ans>(asum+bsum): ans=asum+bsum print(ans)
8
11
172
221
n = int(eval(input())) ans = 10**6 for i in range(1, n): a = list(map(int, list(str(i)))) b = list(map(int, list(str(n - i)))) c = sum(a) + sum(b) ans = min(ans, c) print(ans)
n = int(eval(input())) ans = 10**6 for i in range(1, n + 1): a = i b = n - i if a <= b: asum = sum(map(int, str(a))) bsum = sum(map(int, str(b))) if ans > (asum + bsum): ans = asum + bsum print(ans)
false
27.272727
[ "-for i in range(1, n):", "- a = list(map(int, list(str(i))))", "- b = list(map(int, list(str(n - i))))", "- c = sum(a) + sum(b)", "- ans = min(ans, c)", "+for i in range(1, n + 1):", "+ a = i", "+ b = n - i", "+ if a <= b:", "+ asum = sum(map(int, str(a)))", "+ ...
false
0.09887
0.08708
1.135394
[ "s756327354", "s605710792" ]
u761320129
p03739
python
s186361840
s600171101
119
105
14,652
14,332
Accepted
Accepted
11.76
N = int(eval(input())) src = list(map(int, input().split())) sum1 = sum2 = src[0] op1 = op2 = 0 if sum1 < 1: op1 += (1 - sum1) sum1 = 1 if sum2 > -1: op2 += (sum2 + 1) sum2 = -1 for i in range(1,N): if i%2 == 1: if sum1 + src[i] > -1: op1 += (sum1 + src[i] + 1) ...
N = int(eval(input())) src = list(map(int,input().split())) cum1 = cum2 = 0 ans1 = ans2 = 0 for i,a in enumerate(src): cum1 += a cum2 += a if i%2: if cum1 >= 0: ans1 += cum1+1 cum1 = -1 if cum2 <= 0: ans2 += 1-cum2 cum2 = 1 ...
37
24
823
492
N = int(eval(input())) src = list(map(int, input().split())) sum1 = sum2 = src[0] op1 = op2 = 0 if sum1 < 1: op1 += 1 - sum1 sum1 = 1 if sum2 > -1: op2 += sum2 + 1 sum2 = -1 for i in range(1, N): if i % 2 == 1: if sum1 + src[i] > -1: op1 += sum1 + src[i] + 1 sum1 = -1...
N = int(eval(input())) src = list(map(int, input().split())) cum1 = cum2 = 0 ans1 = ans2 = 0 for i, a in enumerate(src): cum1 += a cum2 += a if i % 2: if cum1 >= 0: ans1 += cum1 + 1 cum1 = -1 if cum2 <= 0: ans2 += 1 - cum2 cum2 = 1 else: ...
false
35.135135
[ "-sum1 = sum2 = src[0]", "-op1 = op2 = 0", "-if sum1 < 1:", "- op1 += 1 - sum1", "- sum1 = 1", "-if sum2 > -1:", "- op2 += sum2 + 1", "- sum2 = -1", "-for i in range(1, N):", "- if i % 2 == 1:", "- if sum1 + src[i] > -1:", "- op1 += sum1 + src[i] + 1", "- ...
false
0.036214
0.037641
0.962073
[ "s186361840", "s600171101" ]
u391540332
p02716
python
s931609472
s128712674
1,130
686
155,504
155,556
Accepted
Accepted
39.29
#!/usr/bin/env python3 # coding: utf-8 import collections import math def debug(arg): if __debug__: pass else: import sys print(arg, file=sys.stderr) N, *A = map(int, open(0).read().split()) a = dict(enumerate(A, 1)) # dp = collections.defaultdict(int) dp = collections.def...
#!/usr/bin/env python3 # coding: utf-8 import collections import math def debug(arg): if __debug__: pass else: import sys print(arg, file=sys.stderr) def main(): pass N, *A = map(int, open(0).read().split()) a = dict(enumerate(A, 1)) dp = collections.defau...
31
29
758
715
#!/usr/bin/env python3 # coding: utf-8 import collections import math def debug(arg): if __debug__: pass else: import sys print(arg, file=sys.stderr) N, *A = map(int, open(0).read().split()) a = dict(enumerate(A, 1)) # dp = collections.defaultdict(int) dp = collections.defaultdict(l...
#!/usr/bin/env python3 # coding: utf-8 import collections import math def debug(arg): if __debug__: pass else: import sys print(arg, file=sys.stderr) def main(): pass N, *A = map(int, open(0).read().split()) a = dict(enumerate(A, 1)) dp = collections.defaultdict(lamb...
false
6.451613
[ "-N, *A = map(int, open(0).read().split())", "-a = dict(enumerate(A, 1))", "-# dp = collections.defaultdict(int)", "-dp = collections.defaultdict(lambda: -float(\"inf\"))", "-dp[0, 0] = 0", "-dp[1, 0] = 0", "-dp[1, 1] = a[1]", "-for i in range(2, N + 1):", "- jj = range(max(math.floor(i // 2 - 1)...
false
0.036659
0.096829
0.378594
[ "s931609472", "s128712674" ]
u222668979
p02609
python
s294185769
s843678126
331
205
87,464
92,644
Accepted
Accepted
38.07
def bitcount(N): # 立ってるbitの数 bitcnt = [0] for _ in range(N): bitcnt += [i + 1 for i in bitcnt] return bitcnt n, x = int(eval(input())), eval(input()) num, cnt = int(x, 2), x.count('1') lbit = bitcount(18) for i in range(n): ans = 1 if x[i] == '0': ctmp = cnt + 1 ...
def bitcount(N): # 立ってるbitの数 bitcnt = [0] for _ in range(N): bitcnt += [i + 1 for i in bitcnt] return bitcnt n, x = int(eval(input())), eval(input()) num, cnt = int(x, 2), x.count('1') num0, num1 = num % (cnt + 1), num % max(cnt - 1, 1) lbit = bitcount(18) for i in range(n): ans...
29
30
666
713
def bitcount(N): # 立ってるbitの数 bitcnt = [0] for _ in range(N): bitcnt += [i + 1 for i in bitcnt] return bitcnt n, x = int(eval(input())), eval(input()) num, cnt = int(x, 2), x.count("1") lbit = bitcount(18) for i in range(n): ans = 1 if x[i] == "0": ctmp = cnt + 1 tmp = num ...
def bitcount(N): # 立ってるbitの数 bitcnt = [0] for _ in range(N): bitcnt += [i + 1 for i in bitcnt] return bitcnt n, x = int(eval(input())), eval(input()) num, cnt = int(x, 2), x.count("1") num0, num1 = num % (cnt + 1), num % max(cnt - 1, 1) lbit = bitcount(18) for i in range(n): ans = 1 if x[...
false
3.333333
[ "+num0, num1 = num % (cnt + 1), num % max(cnt - 1, 1)", "- tmp = num % ctmp + pow(2, n - (i + 1), ctmp)", "+ tmp = num0 + pow(2, n - (i + 1), cnt + 1)", "- tmp = num % ctmp - pow(2, n - (i + 1), ctmp)", "+ tmp = num1 - pow(2, n - (i + 1), cnt - 1)" ]
false
0.169343
0.150465
1.125468
[ "s294185769", "s843678126" ]
u262597910
p03546
python
s070352446
s360323894
71
37
3,700
3,444
Accepted
Accepted
47.89
import collections h,w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list(map(int, input().split())) for _ in range(h)] result = [0]*10 def way(n,e,i,p): #現在の数字、現在の必要魔力、始点、暫定最低魔力 for j in range(0,10): if (n == j): continue ...
h,w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list(map(int, input().split())) for _ in range(h)] for k in range(10): for i in range(10): for j in range(10): c[i][j] = min(c[i][j], c[i][k]+c[k][j]) ans = 0 for i in rang...
39
15
831
416
import collections h, w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list(map(int, input().split())) for _ in range(h)] result = [0] * 10 def way(n, e, i, p): # 現在の数字、現在の必要魔力、始点、暫定最低魔力 for j in range(0, 10): if n == j: continue if n ...
h, w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list(map(int, input().split())) for _ in range(h)] for k in range(10): for i in range(10): for j in range(10): c[i][j] = min(c[i][j], c[i][k] + c[k][j]) ans = 0 for i in range(h): for j in ra...
false
61.538462
[ "-import collections", "-", "-result = [0] * 10", "-", "-", "-def way(n, e, i, p): # 現在の数字、現在の必要魔力、始点、暫定最低魔力", "- for j in range(0, 10):", "- if n == j:", "- continue", "- if n == 1:", "- if e < result[i]:", "- result[i] = e", "- ...
false
0.049886
0.040727
1.224894
[ "s070352446", "s360323894" ]
u124498235
p02732
python
s333480959
s689678094
836
658
45,628
45,628
Accepted
Accepted
21.29
import collections MOD = 10**18+9 n = int(eval(input())) a = list(map(int, input().split())) b = [[0 for j in range(2)] for i in range(n)] c = collections.Counter(a) s = 0 def nCr(nn, r, mod): r = min(r, nn-r) numer = denom = 1 for i in range(1, r+1): numer = numer * (nn+1-i) % mod denom = denom * i ...
import collections n = int(eval(input())) a = list(map(int, input().split())) b = [[0 for j in range(2)] for i in range(n)] c = collections.Counter(a) s = 0 for i in c: b[i-1][0] = c[i]*(c[i]-1)//2 s += b[i-1][0] b[i-1][1] = (c[i]-1)*(c[i]-2)//2 for i in a: ans = s-b[i-1][0] + b[i-1][1] print (ans)
27
13
601
310
import collections MOD = 10**18 + 9 n = int(eval(input())) a = list(map(int, input().split())) b = [[0 for j in range(2)] for i in range(n)] c = collections.Counter(a) s = 0 def nCr(nn, r, mod): r = min(r, nn - r) numer = denom = 1 for i in range(1, r + 1): numer = numer * (nn + 1 - i) % mod ...
import collections n = int(eval(input())) a = list(map(int, input().split())) b = [[0 for j in range(2)] for i in range(n)] c = collections.Counter(a) s = 0 for i in c: b[i - 1][0] = c[i] * (c[i] - 1) // 2 s += b[i - 1][0] b[i - 1][1] = (c[i] - 1) * (c[i] - 2) // 2 for i in a: ans = s - b[i - 1][0] + b...
false
51.851852
[ "-MOD = 10**18 + 9", "-", "-", "-def nCr(nn, r, mod):", "- r = min(r, nn - r)", "- numer = denom = 1", "- for i in range(1, r + 1):", "- numer = numer * (nn + 1 - i) % mod", "- denom = denom * i % mod", "- return numer * pow(denom, mod - 2, mod) % mod", "-", "-", "-...
false
0.047686
0.042194
1.13016
[ "s333480959", "s689678094" ]
u116002573
p03805
python
s450299441
s602166328
36
32
9,204
4,596
Accepted
Accepted
11.11
import collections def main(): N, M = list(map(int, input().split())) graph = collections.defaultdict(list) for _ in range(M): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) cur = [[1, set([1])]] for _ in range(N-1): temp = []...
import collections def main(): N, M = list(map(int, input().split())) graph = collections.defaultdict(list) for _ in range(M): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) # print(graph) cur = [[1, 1 << 1]] for _ in range(N-...
22
25
555
592
import collections def main(): N, M = list(map(int, input().split())) graph = collections.defaultdict(list) for _ in range(M): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) cur = [[1, set([1])]] for _ in range(N - 1): temp = [] ...
import collections def main(): N, M = list(map(int, input().split())) graph = collections.defaultdict(list) for _ in range(M): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) # print(graph) cur = [[1, 1 << 1]] for _ in range(N - 1): ...
false
12
[ "- cur = [[1, set([1])]]", "+ # print(graph)", "+ cur = [[1, 1 << 1]]", "- for a, visited in cur:", "+ for a, h in cur:", "- if b not in visited:", "- temp.append([b, visited | {b}])", "+ if (h >> b) % 2 == 0:", "+ ...
false
0.039514
0.039835
0.991944
[ "s450299441", "s602166328" ]
u191874006
p03162
python
s782343352
s408736061
650
345
50,776
46,060
Accepted
Accepted
46.92
#!/usr/bin/env python3 #dp3 #Vacation def c(): n = int(eval(input())) dpa = [0]*n dpb = [0]*n dpc = [0]*n a,b,c = list(map(int,input().split())) dpa[0] = a dpb[0] = b dpc[0] = c for i in range(1,n): a,b,c = list(map(int,input().split())) dpa[i] = max(...
#!/usr/bin/env python3 #dp3 #Vacation import sys def S(): return list(sys.stdin.readline())[:-1] def LI(): return list(map(int,sys.stdin.readline().split())) def c(): n = int(eval(input())) dpa = [0]*n dpb = [0]*n dpc = [0]*n a,b,c = LI() dpa[0] = a dpb[0] = b dpc[0] = c ...
21
23
517
586
#!/usr/bin/env python3 # dp3 #Vacation def c(): n = int(eval(input())) dpa = [0] * n dpb = [0] * n dpc = [0] * n a, b, c = list(map(int, input().split())) dpa[0] = a dpb[0] = b dpc[0] = c for i in range(1, n): a, b, c = list(map(int, input().split())) dpa[i] = max(dpb...
#!/usr/bin/env python3 # dp3 #Vacation import sys def S(): return list(sys.stdin.readline())[:-1] def LI(): return list(map(int, sys.stdin.readline().split())) def c(): n = int(eval(input())) dpa = [0] * n dpb = [0] * n dpc = [0] * n a, b, c = LI() dpa[0] = a dpb[0] = b dpc...
false
8.695652
[ "+import sys", "+", "+", "+def S():", "+ return list(sys.stdin.readline())[:-1]", "+", "+", "+def LI():", "+ return list(map(int, sys.stdin.readline().split()))", "+", "+", "- a, b, c = list(map(int, input().split()))", "+ a, b, c = LI()", "- a, b, c = list(map(int, inpu...
false
0.040927
0.046138
0.887043
[ "s782343352", "s408736061" ]
u018679195
p03107
python
s227509309
s413963999
329
18
3,424
3,188
Accepted
Accepted
94.53
num = eval(input()) predicted_value = 0 finished = False i = 1 while i < len(num): if num[i] != num[i-1]: num = num[:i-1] + num[i+1:] predicted_value += 2 if i > 1: i -= 2 elif i == 1: i = 0 i += 1 print(predicted_value)
Str = eval(input()) minimo = min(Str.count("0"),Str.count("1")) print((2*minimo))
14
3
291
75
num = eval(input()) predicted_value = 0 finished = False i = 1 while i < len(num): if num[i] != num[i - 1]: num = num[: i - 1] + num[i + 1 :] predicted_value += 2 if i > 1: i -= 2 elif i == 1: i = 0 i += 1 print(predicted_value)
Str = eval(input()) minimo = min(Str.count("0"), Str.count("1")) print((2 * minimo))
false
78.571429
[ "-num = eval(input())", "-predicted_value = 0", "-finished = False", "-i = 1", "-while i < len(num):", "- if num[i] != num[i - 1]:", "- num = num[: i - 1] + num[i + 1 :]", "- predicted_value += 2", "- if i > 1:", "- i -= 2", "- elif i == 1:", "- ...
false
0.153031
0.035929
4.259301
[ "s227509309", "s413963999" ]
u150984829
p00003
python
s047532800
s171044858
40
30
5,608
5,716
Accepted
Accepted
25
for _ in[0]*int(eval(input())): a,b,c=sorted(map(int,input().split())) print((['NO','YES'][a*a+b*b==c*c]))
import sys eval(input()) for e in sys.stdin: a,b,c=sorted(map(int,e.split())) print((['NO','YES'][a*a+b*b==c*c]))
3
5
103
112
for _ in [0] * int(eval(input())): a, b, c = sorted(map(int, input().split())) print((["NO", "YES"][a * a + b * b == c * c]))
import sys eval(input()) for e in sys.stdin: a, b, c = sorted(map(int, e.split())) print((["NO", "YES"][a * a + b * b == c * c]))
false
40
[ "-for _ in [0] * int(eval(input())):", "- a, b, c = sorted(map(int, input().split()))", "+import sys", "+", "+eval(input())", "+for e in sys.stdin:", "+ a, b, c = sorted(map(int, e.split()))" ]
false
0.033149
0.090643
0.365713
[ "s047532800", "s171044858" ]
u111365362
p02990
python
s278678800
s223182962
214
29
41,968
3,316
Accepted
Accepted
86.45
n,k = list(map(int,input().split())) m = 10**9+7 b = 1 r = n-k+1 print((b*r%m)) for i in range(2,k+1): b *= k-i+1 b //= i-1 r *= n-k-i+2 r //= i print((b*r%m))
#17:34 n,k = list(map(int,input().split())) mod = 10 ** 9 + 7 def inv(x): y = 1 while x != 1: y *= mod // x + 1 y %= mod x = x - mod % x return y p = 1 q = n-k+1 ans = n-k+1 for i in range(k): print(ans) ans *= k-1-i ans %= mod ans *= inv(i+1) ans %= mod ans *= n-k-i ...
11
23
169
357
n, k = list(map(int, input().split())) m = 10**9 + 7 b = 1 r = n - k + 1 print((b * r % m)) for i in range(2, k + 1): b *= k - i + 1 b //= i - 1 r *= n - k - i + 2 r //= i print((b * r % m))
# 17:34 n, k = list(map(int, input().split())) mod = 10**9 + 7 def inv(x): y = 1 while x != 1: y *= mod // x + 1 y %= mod x = x - mod % x return y p = 1 q = n - k + 1 ans = n - k + 1 for i in range(k): print(ans) ans *= k - 1 - i ans %= mod ans *= inv(i + 1) a...
false
52.173913
[ "+# 17:34", "-m = 10**9 + 7", "-b = 1", "-r = n - k + 1", "-print((b * r % m))", "-for i in range(2, k + 1):", "- b *= k - i + 1", "- b //= i - 1", "- r *= n - k - i + 2", "- r //= i", "- print((b * r % m))", "+mod = 10**9 + 7", "+", "+", "+def inv(x):", "+ y = 1", ...
false
0.059903
0.038344
1.562252
[ "s278678800", "s223182962" ]
u058433718
p02261
python
s698097094
s926702982
110
20
7,876
7,820
Accepted
Accepted
81.82
import sys def is_stable(in_data, out_data): len_data = len(in_data) for i in range(len_data): for j in range(i+1, len_data): for a in range(len_data): for b in range(a+1, len_data): if in_data[i][1] == in_data[j][1] and\ ...
import sys def is_stable(bs_data, ss_data): # in_data : ?????????????????????????????????????????? # ss_data : ??????????????????????????????????????? len_data = len(bs_data) for i in range(len_data): if bs_data[i] != ss_data[i]: return False return True def bubb...
56
50
1,467
1,239
import sys def is_stable(in_data, out_data): len_data = len(in_data) for i in range(len_data): for j in range(i + 1, len_data): for a in range(len_data): for b in range(a + 1, len_data): if ( in_data[i][1] == in_data[j][1] ...
import sys def is_stable(bs_data, ss_data): # in_data : ?????????????????????????????????????????? # ss_data : ??????????????????????????????????????? len_data = len(bs_data) for i in range(len_data): if bs_data[i] != ss_data[i]: return False return True def bubble_sort(data,...
false
10.714286
[ "-def is_stable(in_data, out_data):", "- len_data = len(in_data)", "+def is_stable(bs_data, ss_data):", "+ # in_data : ??????????????????????????????????????????", "+ # ss_data : ???????????????????????????????????????", "+ len_data = len(bs_data)", "- for j in range(i + 1, len_data):...
false
0.064985
0.036146
1.797862
[ "s698097094", "s926702982" ]
u758815106
p03419
python
s040898170
s616633073
30
25
9,164
9,176
Accepted
Accepted
16.67
N, M = list(map(int, input().split())) if N == 2 or M == 2: print((0)) else: print((abs((N - 2) * (M - 2))))
N, M = list(map(int, input().split())) print((abs((N - 2) * (M - 2))))
7
2
114
63
N, M = list(map(int, input().split())) if N == 2 or M == 2: print((0)) else: print((abs((N - 2) * (M - 2))))
N, M = list(map(int, input().split())) print((abs((N - 2) * (M - 2))))
false
71.428571
[ "-if N == 2 or M == 2:", "- print((0))", "-else:", "- print((abs((N - 2) * (M - 2))))", "+print((abs((N - 2) * (M - 2))))" ]
false
0.043621
0.043032
1.013671
[ "s040898170", "s616633073" ]