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
u744920373
p03221
python
s514789053
s622500921
741
544
44,696
81,372
Accepted
Accepted
26.59
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
44
57
1,277
1,604
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
false
22.807018
[ "-# import bisect #bisect.bisect_left(B, a)", "+import bisect # bisect.bisect_left(B, a)", "+", "+ \"\"\"", "- cnt = [0] * (N + 1)", "+ cnt = [0]*(N+1)", "- l[i][0], l[i][1], l[i][2] = p - 1, y, i", "+ l[i][0], l[i][1], l[i][2] = p-1, y, i", "- cnt[i + 1] += cnt[i]", ...
false
0.042647
0.044646
0.955224
[ "s514789053", "s622500921" ]
u954858867
p02396
python
s063190204
s647202387
130
120
6,460
6,472
Accepted
Accepted
7.69
ret = [] while True: n = eval(input()) if n == 0: break ret += [n] for i, x in enumerate(ret): print('Case %d: %d' % (i+1, x))
ret = [] while True: n = eval(input()) if n == 0: break ret += [n] for i, x in enumerate(ret): print(('Case %d: %d' % (i+1, x)))
9
9
152
154
ret = [] while True: n = eval(input()) if n == 0: break ret += [n] for i, x in enumerate(ret): print("Case %d: %d" % (i + 1, x))
ret = [] while True: n = eval(input()) if n == 0: break ret += [n] for i, x in enumerate(ret): print(("Case %d: %d" % (i + 1, x)))
false
0
[ "- print(\"Case %d: %d\" % (i + 1, x))", "+ print((\"Case %d: %d\" % (i + 1, x)))" ]
false
0.037763
0.038666
0.97663
[ "s063190204", "s647202387" ]
u590825760
p03160
python
s855127390
s570182311
264
128
52,552
13,928
Accepted
Accepted
51.52
n = int(eval(input())) h = [int(x) for x in input().split()] dp = [float("inf")]*(n+10) dp[0] = 0 for i in range(n): if i<n-1: dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i])) if i<n-2: dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i])) print((dp[n-1]))
n = int(eval(input())) h = [int(x) for x in input().split()] dp = [float("inf")]*n dp[0] = 0 dp[1] = abs(h[0]-h[1]) for i in range(2,n): dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])) print((dp[-1]))
10
8
276
219
n = int(eval(input())) h = [int(x) for x in input().split()] dp = [float("inf")] * (n + 10) dp[0] = 0 for i in range(n): if i < n - 1: dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) if i < n - 2: dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) print((dp[n - 1]))
n = int(eval(input())) h = [int(x) for x in input().split()] dp = [float("inf")] * n dp[0] = 0 dp[1] = abs(h[0] - h[1]) for i in range(2, n): dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) print((dp[-1]))
false
20
[ "-dp = [float(\"inf\")] * (n + 10)", "+dp = [float(\"inf\")] * n", "-for i in range(n):", "- if i < n - 1:", "- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))", "- if i < n - 2:", "- dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))", "-print((dp[n - 1]))", "+dp[...
false
0.04652
0.036183
1.285678
[ "s855127390", "s570182311" ]
u623819879
p02735
python
s337740073
s354585108
237
214
42,732
41,324
Accepted
Accepted
9.7
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby import sys,bisect,string,math,time,functools,random def Golf():*a,=map(int,open(0)) def I():return int(input()) def S_():return input() def IS():return input().spli...
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby import sys,bisect,string,math,time,functools,random def Golf():*a,=map(int,open(0)) def I():return int(input()) def S_():return input() def IS():return input().spli...
71
71
2,404
2,379
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter from itertools import permutations, combinations, groupby import sys, bisect, string, math, time, functools, random def Golf(): (*a,) = map(int, open(0)) def I(): return int(input()) def S_(): return input...
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter from itertools import permutations, combinations, groupby import sys, bisect, string, math, time, functools, random def Golf(): (*a,) = map(int, open(0)) def I(): return int(input()) def S_(): return input...
false
0
[ "- dp[j + d] = min(dp[j] + 1 if (g[j], g[j + d]) == (0, 1) else dp[j], dp[j + d])", "-print(dp[(h - 2) * w + w - 2])", "+ dp[j + d] = min(dp[j] + (g[j] * 2 + g[j + d] == 1), dp[j + d])", "+print(dp[-w - 2])" ]
false
0.047216
0.13603
0.347096
[ "s337740073", "s354585108" ]
u698064859
p03240
python
s039123013
s736049090
1,117
733
3,188
3,188
Accepted
Accepted
34.38
N = int(eval(input())) points = [None] * N for i in range(0, N): points[i] = list(map(int, input().split())) h_max = max([h for x, y, h in points]) for H in range(h_max + 100, h_max - 1, -1): for Cx in range(101): for Cy in range(101): ok = True for X, Y, h1 in poi...
N = int(eval(input())) points = [[int(s) for s in input().split()] for i in range(N)] h_max = max(h for x, y, h in points) for H in range(h_max, h_max + 1000): for Cx in range(101): for Cy in range(101): ok = True for x, y, h in points: h_calc = max(H - abs(...
20
16
565
529
N = int(eval(input())) points = [None] * N for i in range(0, N): points[i] = list(map(int, input().split())) h_max = max([h for x, y, h in points]) for H in range(h_max + 100, h_max - 1, -1): for Cx in range(101): for Cy in range(101): ok = True for X, Y, h1 in points: ...
N = int(eval(input())) points = [[int(s) for s in input().split()] for i in range(N)] h_max = max(h for x, y, h in points) for H in range(h_max, h_max + 1000): for Cx in range(101): for Cy in range(101): ok = True for x, y, h in points: h_calc = max(H - abs(x - Cx) - ...
false
20
[ "-points = [None] * N", "-for i in range(0, N):", "- points[i] = list(map(int, input().split()))", "-h_max = max([h for x, y, h in points])", "-for H in range(h_max + 100, h_max - 1, -1):", "+points = [[int(s) for s in input().split()] for i in range(N)]", "+h_max = max(h for x, y, h in points)", "...
false
0.826252
0.412043
2.005257
[ "s039123013", "s736049090" ]
u644907318
p03734
python
s262635316
s464737129
335
218
67,932
77,284
Accepted
Accepted
34.93
INFTY = 10**10 N,W = list(map(int,input().split())) X = [list(map(int,input().split())) for _ in range(N)] dp = [[[-INFTY for _ in range(3*(N-1)+1)] for _ in range(N+1)] for _ in range(N+1)] for i in range(N+1): dp[i][0][0] = 0 for i in range(1,N+1): for j in range(1,i+1): for k in range(3*(N-1)...
N,W = list(map(int,input().split())) A = [list(map(int,input().split())) for _ in range(N)] w1 = A[0][0] C = {0:[],1:[],2:[],3:[]} for i in range(N): w,v = A[i] C[w-w1].append(v) C[0] = sorted(C[0],reverse=True) C[1] = sorted(C[1],reverse=True) C[2] = sorted(C[2],reverse=True) C[3] = sorted(C[3],rever...
18
24
638
714
INFTY = 10**10 N, W = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(N)] dp = [ [[-INFTY for _ in range(3 * (N - 1) + 1)] for _ in range(N + 1)] for _ in range(N + 1) ] for i in range(N + 1): dp[i][0][0] = 0 for i in range(1, N + 1): for j in range(1, i + 1): ...
N, W = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(N)] w1 = A[0][0] C = {0: [], 1: [], 2: [], 3: []} for i in range(N): w, v = A[i] C[w - w1].append(v) C[0] = sorted(C[0], reverse=True) C[1] = sorted(C[1], reverse=True) C[2] = sorted(C[2], reverse=True) C[3] = sorted(C[3]...
false
25
[ "-INFTY = 10**10", "-X = [list(map(int, input().split())) for _ in range(N)]", "-dp = [", "- [[-INFTY for _ in range(3 * (N - 1) + 1)] for _ in range(N + 1)]", "- for _ in range(N + 1)", "-]", "-for i in range(N + 1):", "- dp[i][0][0] = 0", "-for i in range(1, N + 1):", "- for j in ran...
false
0.035129
0.037942
0.925863
[ "s262635316", "s464737129" ]
u347640436
p02850
python
s000918573
s126967913
761
476
53,784
86,564
Accepted
Accepted
37.45
# 深さ優先探索 from sys import setrecursionlimit def genid(a, b): if b < a: a, b = b, a return a * 100000 + b N = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(N - 1)] edges = [[] for _ in range(N)] for a, b in ab: edges[a - 1].append(b - 1) edges[b - 1]....
# 深さ優先探索 from sys import setrecursionlimit def genid(a, b): if b < a: a, b = b, a return a * 100000 + b def paint(currentNode, usedColor, parentNode, edges, colors): color = 1 for childNode in edges[currentNode]: if childNode == parentNode: continue ...
35
38
814
875
# 深さ優先探索 from sys import setrecursionlimit def genid(a, b): if b < a: a, b = b, a return a * 100000 + b N = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(N - 1)] edges = [[] for _ in range(N)] for a, b in ab: edges[a - 1].append(b - 1) edges[b - 1].append(a - 1) col...
# 深さ優先探索 from sys import setrecursionlimit def genid(a, b): if b < a: a, b = b, a return a * 100000 + b def paint(currentNode, usedColor, parentNode, edges, colors): color = 1 for childNode in edges[currentNode]: if childNode == parentNode: continue if color == us...
false
7.894737
[ "+def paint(currentNode, usedColor, parentNode, edges, colors):", "+ color = 1", "+ for childNode in edges[currentNode]:", "+ if childNode == parentNode:", "+ continue", "+ if color == usedColor:", "+ color += 1", "+ colors[genid(currentNode, childNode)...
false
0.041786
0.060088
0.695408
[ "s000918573", "s126967913" ]
u608088992
p03329
python
s430534225
s472733423
334
202
7,064
41,072
Accepted
Accepted
39.52
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) DP = [int(i) for i in range(N + 1)] ni = 9 for i in range(N): if ni > N: break for j in range(N - ni + 1): DP[j + ni] = min(DP[j + ni], DP[j] + 1) ni *= 9 six = 6 for...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) M = [1] for i in range(1, 12): if pow(6, i) > N: break M.append(pow(6, i)) for i in range(1, 10): if pow(9, i) > N: break M.append(pow(9, i)) M.sort() DP = [100000] * (N ...
25
26
548
567
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) DP = [int(i) for i in range(N + 1)] ni = 9 for i in range(N): if ni > N: break for j in range(N - ni + 1): DP[j + ni] = min(DP[j + ni], DP[j] + 1) ni *= 9 six = 6 for i...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) M = [1] for i in range(1, 12): if pow(6, i) > N: break M.append(pow(6, i)) for i in range(1, 10): if pow(9, i) > N: break M.append(pow(9, i)) M.sort() DP = [100...
false
3.846154
[ "- DP = [int(i) for i in range(N + 1)]", "- ni = 9", "- for i in range(N):", "- if ni > N:", "+ M = [1]", "+ for i in range(1, 12):", "+ if pow(6, i) > N:", "- for j in range(N - ni + 1):", "- DP[j + ni] = min(DP[j + ni], DP[j] + 1)", "- ni *= ...
false
0.070413
0.083504
0.843231
[ "s430534225", "s472733423" ]
u888092736
p02845
python
s918133958
s564332100
163
148
20,624
20,160
Accepted
Accepted
9.2
N = int(eval(input())) A = list(map(int, input().split())) MOD = 1_000_000_007 cnt = [0, 0, 0] ans = 1 for i in range(N): ans *= sum(c == A[i] for c in cnt) ans %= MOD for j in range(3): if cnt[j] == A[i]: cnt[j] += 1 break print(ans)
N, *A = list(map(int, open(0).read().split())) MOD = 1_000_000_007 cnt = [0, 0, 0] ans = 1 for a in A: possible = sum(c == a for c in cnt) ans *= possible ans %= MOD for i in range(3): if cnt[i] == a: cnt[i] += 1 break print(ans)
14
13
287
284
N = int(eval(input())) A = list(map(int, input().split())) MOD = 1_000_000_007 cnt = [0, 0, 0] ans = 1 for i in range(N): ans *= sum(c == A[i] for c in cnt) ans %= MOD for j in range(3): if cnt[j] == A[i]: cnt[j] += 1 break print(ans)
N, *A = list(map(int, open(0).read().split())) MOD = 1_000_000_007 cnt = [0, 0, 0] ans = 1 for a in A: possible = sum(c == a for c in cnt) ans *= possible ans %= MOD for i in range(3): if cnt[i] == a: cnt[i] += 1 break print(ans)
false
7.142857
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "+N, *A = list(map(int, open(0).read().split()))", "-for i in range(N):", "- ans *= sum(c == A[i] for c in cnt)", "+for a in A:", "+ possible = sum(c == a for c in cnt)", "+ ans *= possible", "- for j in range(3):", "- ...
false
0.043948
0.043704
1.005595
[ "s918133958", "s564332100" ]
u326609687
p02889
python
s817229378
s274106859
413
303
22,440
39,344
Accepted
Accepted
26.63
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall i8 = np.int64 i4 = np.int32 def main(): stdin = open('/dev/stdin') pin = np.fromstring(stdin.read(), i8, sep=' ') N = pin[0] M = pin[1] L = pin[2] ABC = pin[3: M * 3 + 3].reshape...
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall i8 = np.int64 i4 = np.int32 def main(): stdin = open('/dev/stdin') pin = np.fromstring(stdin.read(), i8, sep=' ') N = pin[0] M = pin[1] L = pin[2] ABC = pin[3: M * 3 + 3].reshape...
32
36
872
928
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall i8 = np.int64 i4 = np.int32 def main(): stdin = open("/dev/stdin") pin = np.fromstring(stdin.read(), i8, sep=" ") N = pin[0] M = pin[1] L = pin[2] ABC = pin[3 : M * 3 + 3].reshape((-1, 3)) ...
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import floyd_warshall i8 = np.int64 i4 = np.int32 def main(): stdin = open("/dev/stdin") pin = np.fromstring(stdin.read(), i8, sep=" ") N = pin[0] M = pin[1] L = pin[2] ABC = pin[3 : M * 3 + 3].reshape((-1, 3)) ...
false
11.111111
[ "+ s = st[:, 0]", "+ t = st[:, 1]", "- for i in range(st.shape[0]):", "- print((int(min_dist[st[i, 0], st[i, 1]] - 1.0)))", "+ min_dist = (min_dist + 0.5).astype(int)", "+ x = min_dist[s, t] - 1", "+ print((\"\\n\".join(x.astype(str))))" ]
false
0.331359
0.273739
1.210495
[ "s817229378", "s274106859" ]
u414980766
p02579
python
s702596020
s727803676
1,703
1,351
29,048
29,044
Accepted
Accepted
20.67
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # ---------標準入力時-------------- h,w=list(map(int,readline().split())) ch, cw=list(map(int,readline().split())) dh, dw=list(map(int,readline().split())) m=list([list(x.decode()) for x in readlines...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # ---------標準入力時-------------- h,w=list(map(int,readline().split())) ch, cw=list(map(int,readline().split())) dh, dw=list(map(int,readline().split())) m=list([list(x.decode()) for x in readlines...
79
70
2,153
1,873
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # ---------標準入力時-------------- h, w = list(map(int, readline().split())) ch, cw = list(map(int, readline().split())) dh, dw = list(map(int, readline().split())) m = list([list(x.decode()) for x in readli...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # ---------標準入力時-------------- h, w = list(map(int, readline().split())) ch, cw = list(map(int, readline().split())) dh, dw = list(map(int, readline().split())) m = list([list(x.decode()) for x in readli...
false
11.392405
[ "-ud = [(-1, 0), (1, 0)] # 上下", "-lr = [(0, -1), (0, 1)] # 左右", "+ad = [(-1, 0), (0, -1), (1, 0), (0, 1)]", "-def bfs5():", "+def bfs6():", "- bfs4から少し変更", "+ bfs5から少し変更", "+ これをwarpを考えるときに処理する", "- cnt_ud = 0", "- # 隣接した上下のマスへの移動", "- for si, sj in ud...
false
0.038871
0.042126
0.922729
[ "s702596020", "s727803676" ]
u670180528
p02940
python
s277326005
s707412230
371
279
47,704
43,224
Accepted
Accepted
24.8
import math n=int(eval(input())) a=1;c={"R":0,"G":0,"B":0} m=998244353 for i in eval(input()): s=sorted(c.values()) c[i]+=1 if c[i]>s[2]:pass elif c[i]>s[1]:a*=s[2]-s[1] else:a*=s[1]-s[0] a%=m print((math.factorial(n)*a%m))
n=int(eval(input())) a=1;c={"R":0,"G":0,"B":0} m=998244353 for i in eval(input()): s=sorted(c.values()) c[i]+=1 if c[i]>s[2]:pass elif c[i]>s[1]:a*=s[2]-s[1] else:a*=s[1]-s[0] a%=m for j in range(1,n+1): a*=j a%=m print(a)
12
14
226
231
import math n = int(eval(input())) a = 1 c = {"R": 0, "G": 0, "B": 0} m = 998244353 for i in eval(input()): s = sorted(c.values()) c[i] += 1 if c[i] > s[2]: pass elif c[i] > s[1]: a *= s[2] - s[1] else: a *= s[1] - s[0] a %= m print((math.factorial(n) * a % m))
n = int(eval(input())) a = 1 c = {"R": 0, "G": 0, "B": 0} m = 998244353 for i in eval(input()): s = sorted(c.values()) c[i] += 1 if c[i] > s[2]: pass elif c[i] > s[1]: a *= s[2] - s[1] else: a *= s[1] - s[0] a %= m for j in range(1, n + 1): a *= j a %= m print(a)
false
14.285714
[ "-import math", "-", "-print((math.factorial(n) * a % m))", "+for j in range(1, n + 1):", "+ a *= j", "+ a %= m", "+print(a)" ]
false
0.042177
0.042436
0.993897
[ "s277326005", "s707412230" ]
u941407962
p02852
python
s595387793
s017147942
263
224
56,284
52,896
Accepted
Accepted
14.83
from collections import deque INF = 10**18 def append_dq(i, x, dq, dp1): while True: if not len(dq): dq.append(i) break lxi = dq[-1] if x > dp1[lxi]: dq.append(i) break dq.pop() return dq dq = deque() N,M = list(map(...
N,M=map(int,input().split()) S,r,s=input(),[],N for _ in range(2*N): if S[s]=='1': s += 1 else: r.append(str(N-s)) N,s=s,max(0,s-M) if N == 0: break print(*[-1] if s else r[1:][::-1])
43
11
927
237
from collections import deque INF = 10**18 def append_dq(i, x, dq, dp1): while True: if not len(dq): dq.append(i) break lxi = dq[-1] if x > dp1[lxi]: dq.append(i) break dq.pop() return dq dq = deque() N, M = list(map(int, input...
N, M = map(int, input().split()) S, r, s = input(), [], N for _ in range(2 * N): if S[s] == "1": s += 1 else: r.append(str(N - s)) N, s = s, max(0, s - M) if N == 0: break print(*[-1] if s else r[1:][::-1])
false
74.418605
[ "-from collections import deque", "-", "-INF = 10**18", "-", "-", "-def append_dq(i, x, dq, dp1):", "- while True:", "- if not len(dq):", "- dq.append(i)", "- break", "- lxi = dq[-1]", "- if x > dp1[lxi]:", "- dq.append(i)", "- ...
false
0.04052
0.04343
0.932987
[ "s595387793", "s017147942" ]
u894258749
p03006
python
s205780976
s272564758
252
186
48,240
39,024
Accepted
Accepted
26.19
from collections import defaultdict inpl = lambda: list(map(int,input().split())) N = int(eval(input())) xy = [] field = defaultdict(int) for _ in range(N): x, y = inpl() xy.append((x,y)) field[(x,y)] = 1 xy.sort() pq = set() for i in range(N): for j in range(i+1,N): x1, y1 = xy...
from collections import defaultdict inpl = lambda: list(map(int,input().split())) N = int(eval(input())) xy = [] for _ in range(N): x, y = inpl() xy.append((x,y)) xy.sort() edges = defaultdict(int) edges[(0,0)] = 0 for i in range(N): for j in range(i+1,N): x1, y1 = xy[i] x2...
41
20
859
417
from collections import defaultdict inpl = lambda: list(map(int, input().split())) N = int(eval(input())) xy = [] field = defaultdict(int) for _ in range(N): x, y = inpl() xy.append((x, y)) field[(x, y)] = 1 xy.sort() pq = set() for i in range(N): for j in range(i + 1, N): x1, y1 = xy[i] ...
from collections import defaultdict inpl = lambda: list(map(int, input().split())) N = int(eval(input())) xy = [] for _ in range(N): x, y = inpl() xy.append((x, y)) xy.sort() edges = defaultdict(int) edges[(0, 0)] = 0 for i in range(N): for j in range(i + 1, N): x1, y1 = xy[i] x2, y2 = xy[j...
false
51.219512
[ "-field = defaultdict(int)", "- field[(x, y)] = 1", "-pq = set()", "+edges = defaultdict(int)", "+edges[(0, 0)] = 0", "- pq.add((p, q))", "-ans = N", "-for p, q in pq:", "- removed = defaultdict(int)", "- cost = 0", "- for x, y in xy:", "- if removed[(x, y)]:", "- ...
false
0.038069
0.038512
0.98848
[ "s205780976", "s272564758" ]
u088552457
p02597
python
s532938722
s465731248
81
55
68,708
12,568
Accepted
Accepted
32.1
# import sys # input = sys.stdin.readline # import re import collections def main(): n = int(eval(input())) s = eval(input()) sc = collections.Counter(s) # 半分ずつの場合 if sc['W'] == sc['R']: # 右側のRをカウント print((s[n//2:].count('R'))) exit() print((s[:sc['R']].cou...
# import sys # input = sys.stdin.readline import collections def main(): n = int(eval(input())) s = eval(input()) a_list = [] for i in range(n): if s[i] == "W": a_list.append(0) else: a_list.append(1) r_count = sum(a_list) print((r_count - s...
28
27
498
512
# import sys # input = sys.stdin.readline # import re import collections def main(): n = int(eval(input())) s = eval(input()) sc = collections.Counter(s) # 半分ずつの場合 if sc["W"] == sc["R"]: # 右側のRをカウント print((s[n // 2 :].count("R"))) exit() print((s[: sc["R"]].count("W")))...
# import sys # input = sys.stdin.readline import collections def main(): n = int(eval(input())) s = eval(input()) a_list = [] for i in range(n): if s[i] == "W": a_list.append(0) else: a_list.append(1) r_count = sum(a_list) print((r_count - sum(a_list[0:r...
false
3.571429
[ "-# import re", "- sc = collections.Counter(s)", "- # 半分ずつの場合", "- if sc[\"W\"] == sc[\"R\"]:", "- # 右側のRをカウント", "- print((s[n // 2 :].count(\"R\")))", "- exit()", "- print((s[: sc[\"R\"]].count(\"W\")))", "+ a_list = []", "+ for i in range(n):", "+ ...
false
0.036911
0.052517
0.702837
[ "s532938722", "s465731248" ]
u153499445
p02689
python
s079690298
s149690181
417
372
32,972
29,940
Accepted
Accepted
10.79
n,m=[int(x) for x in input().split()] h=[int(x) for x in input().split()] road=[[]*1 for i in range(n)] for i in range(m): a=[int(x) for x in input().split()] road[a[0]-1].append(a[1]-1) road[a[1]-1].append(a[0]-1) good=[] for i in range(n): if road[i]==[]: good.append(i) else: check=[] ...
n,m=[int(x) for x in input().split()] h=[int(x) for x in input().split()] t=[[]for i in range(n)] ans=0 for i in range(m): a,b=[int(x) for x in input().split()] t[a-1].append(b-1) t[b-1].append(a-1) for i in range(n): if t[i]==[]: ans+=1 else: c=[] for j in t[i]:...
19
19
450
432
n, m = [int(x) for x in input().split()] h = [int(x) for x in input().split()] road = [[] * 1 for i in range(n)] for i in range(m): a = [int(x) for x in input().split()] road[a[0] - 1].append(a[1] - 1) road[a[1] - 1].append(a[0] - 1) good = [] for i in range(n): if road[i] == []: good.append(i) ...
n, m = [int(x) for x in input().split()] h = [int(x) for x in input().split()] t = [[] for i in range(n)] ans = 0 for i in range(m): a, b = [int(x) for x in input().split()] t[a - 1].append(b - 1) t[b - 1].append(a - 1) for i in range(n): if t[i] == []: ans += 1 else: c = [] ...
false
0
[ "-road = [[] * 1 for i in range(n)]", "+t = [[] for i in range(n)]", "+ans = 0", "- a = [int(x) for x in input().split()]", "- road[a[0] - 1].append(a[1] - 1)", "- road[a[1] - 1].append(a[0] - 1)", "-good = []", "+ a, b = [int(x) for x in input().split()]", "+ t[a - 1].append(b - 1)",...
false
0.035201
0.035737
0.985006
[ "s079690298", "s149690181" ]
u546285759
p00478
python
s938123939
s602167198
30
20
7,640
7,640
Accepted
Accepted
33.33
s=eval(input()) print((sum(1 for _ in range(int(eval(input())))if s in 2*eval(input()))))
s=eval(input()) print((sum(s in 2*eval(input())for _ in range(int(eval(input()))))))
2
2
70
65
s = eval(input()) print((sum(1 for _ in range(int(eval(input()))) if s in 2 * eval(input()))))
s = eval(input()) print((sum(s in 2 * eval(input()) for _ in range(int(eval(input()))))))
false
0
[ "-print((sum(1 for _ in range(int(eval(input()))) if s in 2 * eval(input()))))", "+print((sum(s in 2 * eval(input()) for _ in range(int(eval(input()))))))" ]
false
0.040484
0.040683
0.995112
[ "s938123939", "s602167198" ]
u282228874
p03014
python
s509760027
s605921657
1,467
915
244,872
123,096
Accepted
Accepted
37.63
H,W = list(map(int,input().split())) S = [list(eval(input())) for i in range(H)] dpyoko = [[1]*(W) for i in range(H)] for j in range(W): for i in range(H): if S[i][j] == '#': dpyoko[i][j] = 0 else: if j != 0: dpyoko[i][j] += dpyoko[i][j-1] for j in r...
h,w = list(map(int,input().split())) S = [eval(input()) for i in range(h)] yoko = [[1]*w for _ in range(h)] tate = [[1]*w for _ in range(h)] for i in range(h): for j in range(w): if S[i][j] == '#': yoko[i][j] = 0 else: if j != 0: yoko[i][j] += yoko[i...
37
37
1,060
1,016
H, W = list(map(int, input().split())) S = [list(eval(input())) for i in range(H)] dpyoko = [[1] * (W) for i in range(H)] for j in range(W): for i in range(H): if S[i][j] == "#": dpyoko[i][j] = 0 else: if j != 0: dpyoko[i][j] += dpyoko[i][j - 1] for j in range...
h, w = list(map(int, input().split())) S = [eval(input()) for i in range(h)] yoko = [[1] * w for _ in range(h)] tate = [[1] * w for _ in range(h)] for i in range(h): for j in range(w): if S[i][j] == "#": yoko[i][j] = 0 else: if j != 0: yoko[i][j] += yoko[i][j ...
false
0
[ "-H, W = list(map(int, input().split()))", "-S = [list(eval(input())) for i in range(H)]", "-dpyoko = [[1] * (W) for i in range(H)]", "-for j in range(W):", "- for i in range(H):", "+h, w = list(map(int, input().split()))", "+S = [eval(input()) for i in range(h)]", "+yoko = [[1] * w for _ in range(...
false
0.035652
0.05197
0.686018
[ "s509760027", "s605921657" ]
u411353821
p02712
python
s382061220
s790727679
157
68
9,180
72,704
Accepted
Accepted
56.69
def main(): n = int(eval(input())) s = 0 for i in range(1, n+1): if i % 3 == 0 and i % 5 == 0: pass elif i%3 == 0: pass elif i%5 == 0: pass else: s += i print(s) if __name__ == "__main__": main()
def main(): n = int(eval(input())) s = 0 for i in range(1, n+1): if not (i % 3 == 0 or i % 5 == 0): s += i print(s) if __name__ == "__main__": main()
16
11
306
196
def main(): n = int(eval(input())) s = 0 for i in range(1, n + 1): if i % 3 == 0 and i % 5 == 0: pass elif i % 3 == 0: pass elif i % 5 == 0: pass else: s += i print(s) if __name__ == "__main__": main()
def main(): n = int(eval(input())) s = 0 for i in range(1, n + 1): if not (i % 3 == 0 or i % 5 == 0): s += i print(s) if __name__ == "__main__": main()
false
31.25
[ "- if i % 3 == 0 and i % 5 == 0:", "- pass", "- elif i % 3 == 0:", "- pass", "- elif i % 5 == 0:", "- pass", "- else:", "+ if not (i % 3 == 0 or i % 5 == 0):" ]
false
0.101917
0.083609
1.218975
[ "s382061220", "s790727679" ]
u204800924
p03448
python
s322590124
s705747558
50
30
2,940
9,188
Accepted
Accepted
40
A, B, C, X = [int(eval(input())) for _ in range(4)] count = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): if 500*a + 100*b + 50*c == X: count += 1 print(count)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) a = min(x//500, a)+1 b = min(x//100, b)+1 c = min(x//50, c) cnt = 0 for i in range(a): for j in range(b): now = x-500*i-100*j if now>=0 and now//50 <= c: cnt +=1 print(cnt)
10
18
224
277
A, B, C, X = [int(eval(input())) for _ in range(4)] count = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): if 500 * a + 100 * b + 50 * c == X: count += 1 print(count)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) a = min(x // 500, a) + 1 b = min(x // 100, b) + 1 c = min(x // 50, c) cnt = 0 for i in range(a): for j in range(b): now = x - 500 * i - 100 * j if now >= 0 and now // 50 <= c: cnt += 1 print(cnt)
false
44.444444
[ "-A, B, C, X = [int(eval(input())) for _ in range(4)]", "-count = 0", "-for a in range(A + 1):", "- for b in range(B + 1):", "- for c in range(C + 1):", "- if 500 * a + 100 * b + 50 * c == X:", "- count += 1", "-print(count)", "+a = int(eval(input()))", "+b = in...
false
0.082743
0.037665
2.196787
[ "s322590124", "s705747558" ]
u285891772
p03077
python
s912359164
s348217532
51
39
5,712
5,200
Accepted
Accepted
23.53
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter...
29
24
1,001
978
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, ) # , log2 from itertools import ( accumulate, permutations, combinations, combi...
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, ) # , log2 from itertools import ( accumulate, permutations, combinations, combi...
false
17.241379
[ "-N = INT()", "-L = [INT() for _ in range(5)]", "-C = min(L)", "-l = L.index(C)", "-r = 4 - l", "-print((-(-N // C) + l + r))", "+N, A, B, C, D, E = [INT() for _ in range(6)]", "+print((-(-N // min(A, B, C, D, E)) + 4))" ]
false
0.063324
0.103491
0.611878
[ "s912359164", "s348217532" ]
u814986259
p03457
python
s351008808
s594753935
397
172
3,064
3,060
Accepted
Accepted
56.68
N=int(eval(input())) pos=[0,0] now=0 flag=True for i in range(N): t,x,y=list(map(int,input().split())) d = abs(x-pos[0])+abs(y-pos[1]) if d>t-now: flag=False break else: if d%2==(t-now)%2: now=t pos[0],pos[1]=x,y else: flag=False break if flag: print("...
def main(): import sys input = sys.stdin.readline N = int(eval(input())) prev = 0 x = 0 y = 0 for i in range(N): a, b, c = list(map(int, input().split())) dis = abs(b - x) + abs(c - y) diff = a - prev if diff >= dis and diff % 2 == dis % 2: ...
21
26
335
459
N = int(eval(input())) pos = [0, 0] now = 0 flag = True for i in range(N): t, x, y = list(map(int, input().split())) d = abs(x - pos[0]) + abs(y - pos[1]) if d > t - now: flag = False break else: if d % 2 == (t - now) % 2: now = t pos[0], pos[1] = x, y ...
def main(): import sys input = sys.stdin.readline N = int(eval(input())) prev = 0 x = 0 y = 0 for i in range(N): a, b, c = list(map(int, input().split())) dis = abs(b - x) + abs(c - y) diff = a - prev if diff >= dis and diff % 2 == dis % 2: prev =...
false
19.230769
[ "-N = int(eval(input()))", "-pos = [0, 0]", "-now = 0", "-flag = True", "-for i in range(N):", "- t, x, y = list(map(int, input().split()))", "- d = abs(x - pos[0]) + abs(y - pos[1])", "- if d > t - now:", "- flag = False", "- break", "- else:", "- if d % 2 == ...
false
0.03227
0.036532
0.88335
[ "s351008808", "s594753935" ]
u562935282
p03240
python
s595592091
s723146934
590
102
3,064
3,064
Accepted
Accepted
82.71
N = int(eval(input())) XYHs = [list(map(int, input().split())) for _ in range(N)] for Cx in range(100 + 1): for Cy in range(100 + 1): flg = True H = -1 max_H = float('inf') for x, y, h in XYHs: CF = abs(x - Cx) + abs(y - Cy) if h == 0: ...
N = int(eval(input())) x = [] y = [] h = [] for _ in range(N): xx, yy, hh = list(map(int, input().split())) x.append(xx) y.append(yy) h.append(hh) V_MAX = 100 for cx in range(V_MAX + 1): for cy in range(V_MAX + 1): # 頂上がどのくらいの高さであって欲しいか # -1: 未定, 0以上は確定しているとき ...
22
46
615
1,119
N = int(eval(input())) XYHs = [list(map(int, input().split())) for _ in range(N)] for Cx in range(100 + 1): for Cy in range(100 + 1): flg = True H = -1 max_H = float("inf") for x, y, h in XYHs: CF = abs(x - Cx) + abs(y - Cy) if h == 0: max_H = ...
N = int(eval(input())) x = [] y = [] h = [] for _ in range(N): xx, yy, hh = list(map(int, input().split())) x.append(xx) y.append(yy) h.append(hh) V_MAX = 100 for cx in range(V_MAX + 1): for cy in range(V_MAX + 1): # 頂上がどのくらいの高さであって欲しいか # -1: 未定, 0以上は確定しているとき # -2: 不可能だと分かったと...
false
52.173913
[ "-XYHs = [list(map(int, input().split())) for _ in range(N)]", "-for Cx in range(100 + 1):", "- for Cy in range(100 + 1):", "- flg = True", "- H = -1", "- max_H = float(\"inf\")", "- for x, y, h in XYHs:", "- CF = abs(x - Cx) + abs(y - Cy)", "- if...
false
0.038311
0.11814
0.324284
[ "s595592091", "s723146934" ]
u545368057
p03329
python
s727963758
s935829182
621
199
54,436
44,912
Accepted
Accepted
67.95
N = int(eval(input())) n6 = 1 n9 = 1 li = [] while 9**n9 <= N: li.append(9**n9) n9 += 1 while 6**n6 <= N: li.append(6**n6) n6 += 1 li.sort() INF = 10**10 # 1円の場合はね dp = [[i for i in range(N+1)] for i in range(len(li) + 1)] dp = [i for i in range(N+1)] for i,l in enumerate(li): ...
N = int(eval(input())) array = [] cnt6 = 0 while 6**cnt6 <= N: array.append(6**cnt6) cnt6 += 1 cnt9 = 0 while 9**cnt9 <= N: array.append(9**cnt9) cnt9 += 1 a = sorted(list(set(array))) # 最小 dp = [i for i in range(N+1)] # print(a) n = 6 for n in a: for i in range(N+1): ...
23
23
421
390
N = int(eval(input())) n6 = 1 n9 = 1 li = [] while 9**n9 <= N: li.append(9**n9) n9 += 1 while 6**n6 <= N: li.append(6**n6) n6 += 1 li.sort() INF = 10**10 # 1円の場合はね dp = [[i for i in range(N + 1)] for i in range(len(li) + 1)] dp = [i for i in range(N + 1)] for i, l in enumerate(li): for j in range(N ...
N = int(eval(input())) array = [] cnt6 = 0 while 6**cnt6 <= N: array.append(6**cnt6) cnt6 += 1 cnt9 = 0 while 9**cnt9 <= N: array.append(9**cnt9) cnt9 += 1 a = sorted(list(set(array))) # 最小 dp = [i for i in range(N + 1)] # print(a) n = 6 for n in a: for i in range(N + 1): if i + n <= N: ...
false
0
[ "-n6 = 1", "-n9 = 1", "-li = []", "-while 9**n9 <= N:", "- li.append(9**n9)", "- n9 += 1", "-while 6**n6 <= N:", "- li.append(6**n6)", "- n6 += 1", "-li.sort()", "-INF = 10**10", "-# 1円の場合はね", "-dp = [[i for i in range(N + 1)] for i in range(len(li) + 1)]", "+array = []", "+c...
false
0.182874
0.179943
1.016289
[ "s727963758", "s935829182" ]
u608088992
p03201
python
s898179877
s584709635
1,537
746
33,200
33,908
Accepted
Accepted
51.46
import sys F = sys.stdin N = int(F.readline().strip("\n")) A = list(map(int, F.readline().strip("\n").split())) A.sort() pair_sum = 0 A_dict = dict() for a in A: if a not in A_dict: A_dict[a] = 1 else: A_dict[a] += 1 for i in reversed(list(range(1, N))): if A_dict[A[i]] > 0: nowA = A...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) A = [int(a) for a in input().split()] A.sort() nDict = dict() for i, a in enumerate(A): if a in nDict: nDict[a] += 1 else: nDict[a] = 1 count = 0 for i in reversed(list(range(N))): ...
31
32
808
791
import sys F = sys.stdin N = int(F.readline().strip("\n")) A = list(map(int, F.readline().strip("\n").split())) A.sort() pair_sum = 0 A_dict = dict() for a in A: if a not in A_dict: A_dict[a] = 1 else: A_dict[a] += 1 for i in reversed(list(range(1, N))): if A_dict[A[i]] > 0: nowA = ...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) A = [int(a) for a in input().split()] A.sort() nDict = dict() for i, a in enumerate(A): if a in nDict: nDict[a] += 1 else: nDict[a] = 1 count = 0 for i in reversed(list(ran...
false
3.125
[ "-F = sys.stdin", "-N = int(F.readline().strip(\"\\n\"))", "-A = list(map(int, F.readline().strip(\"\\n\").split()))", "-A.sort()", "-pair_sum = 0", "-A_dict = dict()", "-for a in A:", "- if a not in A_dict:", "- A_dict[a] = 1", "- else:", "- A_dict[a] += 1", "-for i in rev...
false
0.040465
0.041432
0.976665
[ "s898179877", "s584709635" ]
u371763408
p03805
python
s749063191
s768296519
31
27
3,064
3,316
Accepted
Accepted
12.9
n,m=list(map(int,input().split())) edges=[[] for i in range(n)] for i in range(m): s,t = list(map(int,input().split())) edges[s-1].append(t-1) edges[t-1].append(s-1) cnt =[0] def dfs(V,s): V[s]=1 if sum(V)==n: cnt[0]+=1 else: for adj in edges[s]: if V[adj] == 0: ...
n,m=list(map(int,input().split())) edges=[[] for i in range(n)] for i in range(m): s,t = list(map(int,input().split())) edges[s-1].append(t-1) edges[t-1].append(s-1) cnt =0 V=[0]*n def dfs(V,s): global cnt V=V[:] V[s]=1 if sum(V)==n: cnt+=1 else: for v in edges[s]: ...
22
26
379
375
n, m = list(map(int, input().split())) edges = [[] for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) edges[s - 1].append(t - 1) edges[t - 1].append(s - 1) cnt = [0] def dfs(V, s): V[s] = 1 if sum(V) == n: cnt[0] += 1 else: for adj in edges[s]: ...
n, m = list(map(int, input().split())) edges = [[] for i in range(n)] for i in range(m): s, t = list(map(int, input().split())) edges[s - 1].append(t - 1) edges[t - 1].append(s - 1) cnt = 0 V = [0] * n def dfs(V, s): global cnt V = V[:] V[s] = 1 if sum(V) == n: cnt += 1 else: ...
false
15.384615
[ "-cnt = [0]", "+cnt = 0", "+V = [0] * n", "+ global cnt", "+ V = V[:]", "- cnt[0] += 1", "+ cnt += 1", "- for adj in edges[s]:", "- if V[adj] == 0:", "- dfs(V[:adj] + [1] + V[adj + 1 :], adj)", "+ for v in edges[s]:", "+ if...
false
0.164283
0.048238
3.405682
[ "s749063191", "s768296519" ]
u017810624
p02863
python
s167825019
s950523644
1,615
515
268,552
121,304
Accepted
Accepted
68.11
import sys input=sys.stdin.readline def knapsack(N,W,weight,value): dp=[[float('inf') for i in range(W+1)] for j in range(N+1)] for i in range(W+1): dp[0][i]=0 for i in range(N): for w in range(W+1): if weight[i]<=w: if dp[i][w-weight[i]]+value[i]>dp[i][w]: dp[i+1][w]=...
import sys input=sys.stdin.readline def knapsack(N,W,weight,value): dp=[[999999999999 for i in range(W+1)] for j in range(N+1)] for i in range(W+1): dp[0][i]=0 for i in range(N): for w in range(W+1): if weight[i]<=w: if dp[i][w-weight[i]]+value[i]>dp[i][w]: dp[i+1][w]=...
33
33
767
767
import sys input = sys.stdin.readline def knapsack(N, W, weight, value): dp = [[float("inf") for i in range(W + 1)] for j in range(N + 1)] for i in range(W + 1): dp[0][i] = 0 for i in range(N): for w in range(W + 1): if weight[i] <= w: if dp[i][w - weight[i]] +...
import sys input = sys.stdin.readline def knapsack(N, W, weight, value): dp = [[999999999999 for i in range(W + 1)] for j in range(N + 1)] for i in range(W + 1): dp[0][i] = 0 for i in range(N): for w in range(W + 1): if weight[i] <= w: if dp[i][w - weight[i]] +...
false
0
[ "- dp = [[float(\"inf\") for i in range(W + 1)] for j in range(N + 1)]", "+ dp = [[999999999999 for i in range(W + 1)] for j in range(N + 1)]" ]
false
0.038746
0.047645
0.813222
[ "s167825019", "s950523644" ]
u201928947
p02573
python
s200687321
s779875690
270
193
87,084
84,564
Accepted
Accepted
28.52
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): ...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: li = [] while self.parents[x] >= 0: li.append(x) x = self.parent...
58
63
1,444
1,564
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: li = [] while self.parents[x] >= 0: li.append(x) x = self.parents[x] ...
false
7.936508
[ "- self.parents[x] = self.find(self.parents[x])", "- return self.parents[x]", "+ li = []", "+ while self.parents[x] >= 0:", "+ li.append(x)", "+ x = self.parents[x]", "+ for y in li:", "+ self.parents[y...
false
0.04019
0.046297
0.868093
[ "s200687321", "s779875690" ]
u863370423
p04039
python
s325880124
s385762802
67
49
2,940
3,060
Accepted
Accepted
26.87
n,m = input().split() k=int(n) li = list(input().split()) for i in range(k,100000): for e in li: if e in str(i): break else: print(i) break
n, k = list(map(int, input().split())) digits = [0]*10 digits_disliked = list(map(int, input().split())) for i in digits_disliked: digits[i] = 1 for i in range(n, 10**7+1): temp = i flag = True while(temp): rem = temp%10 temp = temp//10 if(digits[rem] != 0): ...
11
23
194
426
n, m = input().split() k = int(n) li = list(input().split()) for i in range(k, 100000): for e in li: if e in str(i): break else: print(i) break
n, k = list(map(int, input().split())) digits = [0] * 10 digits_disliked = list(map(int, input().split())) for i in digits_disliked: digits[i] = 1 for i in range(n, 10**7 + 1): temp = i flag = True while temp: rem = temp % 10 temp = temp // 10 if digits[rem] != 0: fla...
false
52.173913
[ "-n, m = input().split()", "-k = int(n)", "-li = list(input().split())", "-for i in range(k, 100000):", "- for e in li:", "- if e in str(i):", "+n, k = list(map(int, input().split()))", "+digits = [0] * 10", "+digits_disliked = list(map(int, input().split()))", "+for i in digits_disliked...
false
0.036364
0.096898
0.375277
[ "s325880124", "s385762802" ]
u227082700
p03986
python
s719343219
s429403748
81
55
3,500
9,172
Accepted
Accepted
32.1
x=eval(input());a,l=0,len(x) for i in range(l): if x[l-i-1]=="T":a+=1 else:a=max(0,a-1) print((a*2))
x=eval(input()) s=t=0 for i in x: if i=="S":s+=1 else: if s: s-=1 else: t+=1 print((s+t))
5
10
100
114
x = eval(input()) a, l = 0, len(x) for i in range(l): if x[l - i - 1] == "T": a += 1 else: a = max(0, a - 1) print((a * 2))
x = eval(input()) s = t = 0 for i in x: if i == "S": s += 1 else: if s: s -= 1 else: t += 1 print((s + t))
false
50
[ "-a, l = 0, len(x)", "-for i in range(l):", "- if x[l - i - 1] == \"T\":", "- a += 1", "+s = t = 0", "+for i in x:", "+ if i == \"S\":", "+ s += 1", "- a = max(0, a - 1)", "-print((a * 2))", "+ if s:", "+ s -= 1", "+ else:", "+ ...
false
0.036654
0.035603
1.029526
[ "s719343219", "s429403748" ]
u809006576
p03160
python
s519221338
s085145913
98
88
13,928
13,980
Accepted
Accepted
10.2
def helper(h, n): res = [0]*n res[0] = 0 res[1] = abs(h[1]-h[0]) for i in range(2, n): res[i] = min(res[i-1]+abs(h[i]-h[i-1]), res[i-2]+abs(h[i]-h[i-2])) return res[-1] def main(): n = int(eval(input())) h = list(map(int, input().split(" "))) print((helper(h, n))) ...
def helper(h, n): prev = 0 curr = abs(h[1]-h[0]) for i in range(2, n): next = min(curr+abs(h[i]-h[i-1]), prev+abs(h[i]-h[i-2])) prev = curr curr = next return curr def main(): n = int(eval(input())) h = list(map(int, input().split(" "))) print((helper(h, ...
15
16
350
358
def helper(h, n): res = [0] * n res[0] = 0 res[1] = abs(h[1] - h[0]) for i in range(2, n): res[i] = min( res[i - 1] + abs(h[i] - h[i - 1]), res[i - 2] + abs(h[i] - h[i - 2]) ) return res[-1] def main(): n = int(eval(input())) h = list(map(int, input().split(" ")...
def helper(h, n): prev = 0 curr = abs(h[1] - h[0]) for i in range(2, n): next = min(curr + abs(h[i] - h[i - 1]), prev + abs(h[i] - h[i - 2])) prev = curr curr = next return curr def main(): n = int(eval(input())) h = list(map(int, input().split(" "))) print((helper(...
false
6.25
[ "- res = [0] * n", "- res[0] = 0", "- res[1] = abs(h[1] - h[0])", "+ prev = 0", "+ curr = abs(h[1] - h[0])", "- res[i] = min(", "- res[i - 1] + abs(h[i] - h[i - 1]), res[i - 2] + abs(h[i] - h[i - 2])", "- )", "- return res[-1]", "+ next = min(curr ...
false
0.205325
0.138386
1.483711
[ "s519221338", "s085145913" ]
u632360669
p02819
python
s884947873
s730128786
25
23
2,940
2,940
Accepted
Accepted
8
X = int(eval(input())) result = False while result == False: result = True for i in range(2,-(-X//2)+1): if X % i == 0: result = False break else: result = True if not result: X += 1 print(X)
X = int(eval(input()))-1 result = False while not result: result = True X += 1 for i in range(2,X//2+1): if X % i == 0: result = False break print(X)
14
11
236
176
X = int(eval(input())) result = False while result == False: result = True for i in range(2, -(-X // 2) + 1): if X % i == 0: result = False break else: result = True if not result: X += 1 print(X)
X = int(eval(input())) - 1 result = False while not result: result = True X += 1 for i in range(2, X // 2 + 1): if X % i == 0: result = False break print(X)
false
21.428571
[ "-X = int(eval(input()))", "+X = int(eval(input())) - 1", "-while result == False:", "+while not result:", "- for i in range(2, -(-X // 2) + 1):", "+ X += 1", "+ for i in range(2, X // 2 + 1):", "- else:", "- result = True", "- if not result:", "- X += 1" ]
false
0.047145
0.045977
1.025409
[ "s884947873", "s730128786" ]
u349449706
p03380
python
s910514477
s763547321
306
110
85,744
84,232
Accepted
Accepted
64.05
n,*a=list(map(int,open(0).read().split())) m=max(a) b=m//2 o=min(a) for A in a: if abs(A-b)<abs(o-b):o=A print((m,o))
n,a=open(0) *a,=list(map(int,a.split())) m=max(a) print((m,min((abs(m-2*i),i)for i in a)[1]))
7
4
117
89
n, *a = list(map(int, open(0).read().split())) m = max(a) b = m // 2 o = min(a) for A in a: if abs(A - b) < abs(o - b): o = A print((m, o))
n, a = open(0) (*a,) = list(map(int, a.split())) m = max(a) print((m, min((abs(m - 2 * i), i) for i in a)[1]))
false
42.857143
[ "-n, *a = list(map(int, open(0).read().split()))", "+n, a = open(0)", "+(*a,) = list(map(int, a.split()))", "-b = m // 2", "-o = min(a)", "-for A in a:", "- if abs(A - b) < abs(o - b):", "- o = A", "-print((m, o))", "+print((m, min((abs(m - 2 * i), i) for i in a)[1]))" ]
false
0.036214
0.037013
0.978404
[ "s910514477", "s763547321" ]
u678167152
p03610
python
s130738712
s275771326
38
17
3,188
3,188
Accepted
Accepted
55.26
S = eval(input()) ans = '' for i,s in enumerate(S): if i%2==0: ans += s print(ans)
def solve(): S = eval(input()) ans = S[0::2] return ans print((solve()))
6
6
87
86
S = eval(input()) ans = "" for i, s in enumerate(S): if i % 2 == 0: ans += s print(ans)
def solve(): S = eval(input()) ans = S[0::2] return ans print((solve()))
false
0
[ "-S = eval(input())", "-ans = \"\"", "-for i, s in enumerate(S):", "- if i % 2 == 0:", "- ans += s", "-print(ans)", "+def solve():", "+ S = eval(input())", "+ ans = S[0::2]", "+ return ans", "+", "+", "+print((solve()))" ]
false
0.046697
0.046611
1.001843
[ "s130738712", "s275771326" ]
u861141787
p03035
python
s275316697
s930833863
161
17
38,256
2,940
Accepted
Accepted
89.44
A, B = list(map(int, input().split())) if A >= 13: print(B) elif A <= 12 and A >= 6: print((B//2)) else: print((0))
a, b = list(map(int, input().split())) if a >= 13: print(b) elif a <= 5: print((0)) else: print((b//2))
7
8
123
104
A, B = list(map(int, input().split())) if A >= 13: print(B) elif A <= 12 and A >= 6: print((B // 2)) else: print((0))
a, b = list(map(int, input().split())) if a >= 13: print(b) elif a <= 5: print((0)) else: print((b // 2))
false
12.5
[ "-A, B = list(map(int, input().split()))", "-if A >= 13:", "- print(B)", "-elif A <= 12 and A >= 6:", "- print((B // 2))", "+a, b = list(map(int, input().split()))", "+if a >= 13:", "+ print(b)", "+elif a <= 5:", "+ print((0))", "- print((0))", "+ print((b // 2))" ]
false
0.082844
0.042243
1.96112
[ "s275316697", "s930833863" ]
u790012205
p03290
python
s480012487
s004515244
146
46
3,064
3,064
Accepted
Accepted
68.49
D, G = list(map(int, input().split())) pc = [list(map(int, input().split())) for i in range(D)] G /= 100 C = 2e3 N = len(pc) for i in range(2 ** N): p = 0 c = 0 for j in range(N): if i >> j & 1: p += pc[j][0] * (j + 1) + pc[j][1] / 100 c += pc[j][0] if p >= G:...
D, G = list(map(int, input().split())) G = int(G / 100) pc = [list(map(int, input().split())) for _ in range(D)] N = 10 ** 9 for bit in range(2 ** D): S = 0 c = 0 A = True a = -1 for i in range(D - 1, -1, -1): if bit & (1 << i): S += (i + 1) * pc[i][0] + int(pc[i][1]...
29
27
675
604
D, G = list(map(int, input().split())) pc = [list(map(int, input().split())) for i in range(D)] G /= 100 C = 2e3 N = len(pc) for i in range(2**N): p = 0 c = 0 for j in range(N): if i >> j & 1: p += pc[j][0] * (j + 1) + pc[j][1] / 100 c += pc[j][0] if p >= G: C = m...
D, G = list(map(int, input().split())) G = int(G / 100) pc = [list(map(int, input().split())) for _ in range(D)] N = 10**9 for bit in range(2**D): S = 0 c = 0 A = True a = -1 for i in range(D - 1, -1, -1): if bit & (1 << i): S += (i + 1) * pc[i][0] + int(pc[i][1] / 100) ...
false
6.896552
[ "-pc = [list(map(int, input().split())) for i in range(D)]", "-G /= 100", "-C = 2e3", "-N = len(pc)", "-for i in range(2**N):", "- p = 0", "+G = int(G / 100)", "+pc = [list(map(int, input().split())) for _ in range(D)]", "+N = 10**9", "+for bit in range(2**D):", "+ S = 0", "- for j in...
false
0.156058
0.04569
3.415631
[ "s480012487", "s004515244" ]
u227082700
p02859
python
s630200984
s519468518
20
17
3,316
2,940
Accepted
Accepted
15
r=int(eval(input())) print((r*r))
print((int(eval(input()))**2))
2
1
26
22
r = int(eval(input())) print((r * r))
print((int(eval(input())) ** 2))
false
50
[ "-r = int(eval(input()))", "-print((r * r))", "+print((int(eval(input())) ** 2))" ]
false
0.042397
0.040741
1.040646
[ "s630200984", "s519468518" ]
u621935300
p03732
python
s159466854
s550123536
350
129
2,940
5,364
Accepted
Accepted
63.14
from collections import defaultdict N,W=list(map(int,input().split())) a=defaultdict(lambda:[]) for i in range(N): w,v=list(map(int,input().split())) a[w]=a[w]+[v] for i,j in list(a.items()): a[i]=sorted(j,reverse=True) lst=[] for i,j in list(a.items()): lst.append( (i,len(j)) ) max_val=0 if...
from collections import defaultdict N,W=list(map(int,input().split())) wv=[] for i in range(N): w,v=list(map(int,input().split())) wv.append((w,v)) dp=defaultdict(lambda: 0) # Weight:Value dp[0]=0 for w1,v1 in wv: d=dp.copy() for w,v in list(dp.items()): dp[w+w1]=max( dp[w+w1], d[w]+v1 ) l...
54
20
1,296
407
from collections import defaultdict N, W = list(map(int, input().split())) a = defaultdict(lambda: []) for i in range(N): w, v = list(map(int, input().split())) a[w] = a[w] + [v] for i, j in list(a.items()): a[i] = sorted(j, reverse=True) lst = [] for i, j in list(a.items()): lst.append((i, len(j))) ma...
from collections import defaultdict N, W = list(map(int, input().split())) wv = [] for i in range(N): w, v = list(map(int, input().split())) wv.append((w, v)) dp = defaultdict(lambda: 0) # Weight:Value dp[0] = 0 for w1, v1 in wv: d = dp.copy() for w, v in list(dp.items()): dp[w + w1] = max(dp[...
false
62.962963
[ "-a = defaultdict(lambda: [])", "+wv = []", "- a[w] = a[w] + [v]", "-for i, j in list(a.items()):", "- a[i] = sorted(j, reverse=True)", "-lst = []", "-for i, j in list(a.items()):", "- lst.append((i, len(j)))", "-max_val = 0", "-if len(lst) == 1:", "- w1 = lst[0][0]", "- c1 = ls...
false
0.038078
0.039236
0.970493
[ "s159466854", "s550123536" ]
u679439110
p03062
python
s298432978
s981459344
173
97
16,716
14,252
Accepted
Accepted
43.93
n = int(eval(input())) la = list(map(int, input().split())) lb = [0]*(n+1) lb_flip = [-100000000000000]*(n+1) for i in range(n): lb[i+1] = max(lb[i]+la[i], lb_flip[i]-la[i]) lb_flip[i+1] = max(lb[i]-la[i], lb_flip[i]+la[i]) #print(lb) #print(lb_flip) print((lb[n]))
n = int(eval(input())) la = list(map(int, input().split())) ct0 = 0 ctm = 0 minm = 100000000000000000 ans = 0 for i in range(n): if la[i] == 0: ct0 += 1 elif la[i] < 0: ctm += 1 m = abs(la[i]) if m < minm: minm = m ans += m if ct0 > 0 or ctm % 2 == 0: print(ans) else: ans -= 2 * ...
14
24
276
331
n = int(eval(input())) la = list(map(int, input().split())) lb = [0] * (n + 1) lb_flip = [-100000000000000] * (n + 1) for i in range(n): lb[i + 1] = max(lb[i] + la[i], lb_flip[i] - la[i]) lb_flip[i + 1] = max(lb[i] - la[i], lb_flip[i] + la[i]) # print(lb) # print(lb_flip) print((lb[n]))
n = int(eval(input())) la = list(map(int, input().split())) ct0 = 0 ctm = 0 minm = 100000000000000000 ans = 0 for i in range(n): if la[i] == 0: ct0 += 1 elif la[i] < 0: ctm += 1 m = abs(la[i]) if m < minm: minm = m ans += m if ct0 > 0 or ctm % 2 == 0: print(ans) else: ...
false
41.666667
[ "-lb = [0] * (n + 1)", "-lb_flip = [-100000000000000] * (n + 1)", "+ct0 = 0", "+ctm = 0", "+minm = 100000000000000000", "+ans = 0", "- lb[i + 1] = max(lb[i] + la[i], lb_flip[i] - la[i])", "- lb_flip[i + 1] = max(lb[i] - la[i], lb_flip[i] + la[i])", "-# print(lb)", "-# print(lb_flip)", "-pr...
false
0.119633
0.039539
3.025656
[ "s298432978", "s981459344" ]
u191874006
p03325
python
s280566361
s758072473
241
153
4,148
4,148
Accepted
Accepted
36.51
#!/usr/bin/env python3 import re n = int(eval(input())) a = eval(input()) a = re.split(" ",a) count = 0 for i in range(len(a)): if(int(a[i]) % 2 == 0): while(int(a[i]) > 1): a[i] = int(a[i])/2 count += 1 if(int(a[i]) % 2 != 0): break; ...
#!/usr/bin/env python3 #ABC100 C N = int(eval(input())) a = list(map(int,input().split())) ans = 0 for i in range(N): if a[i] % 2 == 0: while a[i] % 2 == 0: a[i] = a[i] / 2 ans += 1 print(ans)
21
13
347
238
#!/usr/bin/env python3 import re n = int(eval(input())) a = eval(input()) a = re.split(" ", a) count = 0 for i in range(len(a)): if int(a[i]) % 2 == 0: while int(a[i]) > 1: a[i] = int(a[i]) / 2 count += 1 if int(a[i]) % 2 != 0: break else: pas...
#!/usr/bin/env python3 # ABC100 C N = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in range(N): if a[i] % 2 == 0: while a[i] % 2 == 0: a[i] = a[i] / 2 ans += 1 print(ans)
false
38.095238
[ "-import re", "-", "-n = int(eval(input()))", "-a = eval(input())", "-a = re.split(\" \", a)", "-count = 0", "-for i in range(len(a)):", "- if int(a[i]) % 2 == 0:", "- while int(a[i]) > 1:", "- a[i] = int(a[i]) / 2", "- count += 1", "- if int(a[i]) % ...
false
0.050851
0.062629
0.811943
[ "s280566361", "s758072473" ]
u600402037
p03112
python
s251995360
s068566223
1,115
850
17,640
12,944
Accepted
Accepted
23.77
import bisect import itertools A,B,Q = list(map(int,input().split())) # 簡略化のため常に左右に存在するようにしておく INF = 10 ** 15 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)] def solve(x): # xの位置 i = bi...
# coding: utf-8 import sys from bisect import bisect_left sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 番兵を左右に置いて、4通り試す A, B, Q = lr() INF = 10 ** 12 S = [-INF] + [ir() for _ in range(A)] + [INF] T = [-INF] + [ir() for _ in range(B)] + [INF] ...
25
30
581
747
import bisect import itertools A, B, Q = list(map(int, input().split())) # 簡略化のため常に左右に存在するようにしておく INF = 10**15 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)] def solve(x): # xの位置 i = bisect.bis...
# coding: utf-8 import sys from bisect import bisect_left sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 番兵を左右に置いて、4通り試す A, B, Q = lr() INF = 10**12 S = [-INF] + [ir() for _ in range(A)] + [INF] T = [-INF] + [ir() for _ in range(B)] + [INF] S.sort() T.sort...
false
16.666667
[ "-import bisect", "-import itertools", "+# coding: utf-8", "+import sys", "+from bisect import bisect_left", "-A, B, Q = list(map(int, input().split()))", "-# 簡略化のため常に左右に存在するようにしておく", "-INF = 10**15", "-S = [-INF] + [int(eval(input())) for _ in range(A)] + [INF]", "-T = [-INF] + [int(eval(input())...
false
0.045408
0.037289
1.217726
[ "s251995360", "s068566223" ]
u417365712
p02803
python
s330346400
s744620339
1,114
1,028
12,544
12,532
Accepted
Accepted
7.72
from copy import deepcopy from collections import deque from itertools import product import numpy as np inputs = open(0).readlines() class Grid(): def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtyp...
from copy import deepcopy from collections import deque from itertools import product import numpy as np inputs = open(0).readlines() class Grid(): def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtyp...
51
52
1,694
1,700
from copy import deepcopy from collections import deque from itertools import product import numpy as np inputs = open(0).readlines() class Grid: def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type...
from copy import deepcopy from collections import deque from itertools import product import numpy as np inputs = open(0).readlines() class Grid: def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type...
false
1.923077
[ "- for i, rows in zip(list(range(h)), grid):", "- for j, val in zip(list(range(w)), rows):", "+ for i, row in zip(list(range(h)), grid):", "+ for j, val in zip(list(range(w)), row):", "- return \"\\n\".join([\" \".join(map(str, rows)) for rows in self.grid])", "+...
false
0.303001
0.284177
1.066238
[ "s330346400", "s744620339" ]
u644907318
p02820
python
s568544671
s642762809
217
106
45,648
92,020
Accepted
Accepted
51.15
N,K = list(map(int,input().split())) R,S,P = list(map(int,input().split())) D = {"r":P,"s":R,"p":S} T = input().strip() hist = [0 for _ in range(N)] ans = 0 for i in range(N): a = T[i] if hist[i]==0: hist[i] = 1 cnt = 1 j = i while j+K<N and T[j+K]==a: hi...
N,K = list(map(int,input().split())) R,S,P = list(map(int,input().split())) D={"r":P,"s":R,"p":S} T = input().strip() A = {i:[] for i in range(K)} for i in range(N): A[i%K].append(T[i]) cnt = 0 for k in range(K): if len(A[k])>0: cnt += D[A[k][0]] for i in range(1,len(A[k])): ...
18
17
405
448
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) D = {"r": P, "s": R, "p": S} T = input().strip() hist = [0 for _ in range(N)] ans = 0 for i in range(N): a = T[i] if hist[i] == 0: hist[i] = 1 cnt = 1 j = i while j + K < N and T[j + K] == a: ...
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) D = {"r": P, "s": R, "p": S} T = input().strip() A = {i: [] for i in range(K)} for i in range(N): A[i % K].append(T[i]) cnt = 0 for k in range(K): if len(A[k]) > 0: cnt += D[A[k][0]] for i in range(1, len(A[k])): ...
false
5.555556
[ "-hist = [0 for _ in range(N)]", "-ans = 0", "+A = {i: [] for i in range(K)}", "- a = T[i]", "- if hist[i] == 0:", "- hist[i] = 1", "- cnt = 1", "- j = i", "- while j + K < N and T[j + K] == a:", "- hist[j + K] = 1", "- cnt += 1", "- ...
false
0.090512
0.047407
1.909239
[ "s568544671", "s642762809" ]
u729133443
p03993
python
s795786054
s433950641
208
66
52,912
13,940
Accepted
Accepted
68.27
n=int(eval(input()));a=list(map(int,input().split()));print((sum([0,1][a[a[i]-1]-1==i]for i in range(n))//2))
n,*a=list(map(int,open(0).read().split()));print((sum(a[a[i]-1]==i+1for i in range(n))>>1))
1
1
101
83
n = int(eval(input())) a = list(map(int, input().split())) print((sum([0, 1][a[a[i] - 1] - 1 == i] for i in range(n)) // 2))
n, *a = list(map(int, open(0).read().split())) print((sum(a[a[i] - 1] == i + 1 for i in range(n)) >> 1))
false
0
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-print((sum([0, 1][a[a[i] - 1] - 1 == i] for i in range(n)) // 2))", "+n, *a = list(map(int, open(0).read().split()))", "+print((sum(a[a[i] - 1] == i + 1 for i in range(n)) >> 1))" ]
false
0.04498
0.046298
0.971526
[ "s795786054", "s433950641" ]
u983181637
p02802
python
s870921636
s201397606
312
169
22,888
19,620
Accepted
Accepted
45.83
from collections import defaultdict n, m = list(map(int, input().split())) ac = 0 wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない already = set() for line in range(m): p, s = input().split() # forでその都度入力を受け取る p = int(p) if p in already: # acを見つけたときのみalreadyにpをいれすので、ac後のw...
from collections import defaultdict import sys input = sys.stdin.readline n, m = list(map(int, input().split())) ac = 0 wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない already = set() sum_wa = 0 for line in range(m): p, s = input().split() # forでその都度入力を受け取る p = int(p) ...
18
23
633
690
from collections import defaultdict n, m = list(map(int, input().split())) ac = 0 wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない already = set() for line in range(m): p, s = input().split() # forでその都度入力を受け取る p = int(p) if p in already: # acを見つけたときのみalreadyにpをいれすので、ac後のwaのカウントを...
from collections import defaultdict import sys input = sys.stdin.readline n, m = list(map(int, input().split())) ac = 0 wa = defaultdict(lambda: 0) # wa = {} だと 存在しないkeyにおいて wa[key] = ○ で代入できない already = set() sum_wa = 0 for line in range(m): p, s = input().split() # forでその都度入力を受け取る p = int(p) if p in al...
false
21.73913
[ "+import sys", "+input = sys.stdin.readline", "+sum_wa = 0", "- if p in already: # acを見つけたときのみalreadyにpをいれすので、ac後のwaのカウントを避けている。", "+ if p in already: # acを見つけたときのみalreadyにpをいれるので、ac後のwaのカウントを避けている。", "+ sum_wa += wa[p]", "-print((ac, sum(wa[i] for i in already)))", "+print((ac, sum_wa)...
false
0.03786
0.079547
0.475949
[ "s870921636", "s201397606" ]
u216928054
p03161
python
s176884768
s157575575
540
385
344,800
83,496
Accepted
Accepted
28.7
#!/usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = 10 ** 9 + 1 # sys.maxsize # float("inf") def debug(*x): print((*x)) def solve1(N, K, heights): heights += [INF] * ...
#!/usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = 10 ** 9 + 1 # sys.maxsize # float("inf") def debug(*x): print((*x)) def solve1(N, K, heights): heights += [INF] * ...
113
113
2,695
2,695
#!/usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = 10**9 + 1 # sys.maxsize # float("inf") def debug(*x): print((*x)) def solve1(N, K, heights): heights += [INF] * K costs = [INF]...
#!/usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = 10**9 + 1 # sys.maxsize # float("inf") def debug(*x): print((*x)) def solve1(N, K, heights): heights += [INF] * K costs = [INF]...
false
0
[ "-def solve2(N, K, heights):", "+def solve(N, K, heights):", "-def solve(N, K, heights):", "+def solve3(N, K, heights):" ]
false
0.03748
0.037687
0.994494
[ "s176884768", "s157575575" ]
u505420467
p03805
python
s580041776
s247237317
31
26
4,212
3,064
Accepted
Accepted
16.13
v=[] n,m=list(map(int,input().split())) ans=[[] for i in range(n)] for i in range(m): a,b=list(map(int,input().split())) ans[a-1].append((b-1)) ans[b-1].append((a-1)) def dfs(now,visited=[]): if len(visited)==n: v.append([visited]) return for j in ans[now]: if j n...
def DFS(now, visited): if len(visited) == n: ans.append(1) return for i in graph[now]: if not i in visited: DFS(i, visited + [i]) n, m = list(map(int, input().split())) graph = [[] for i in range(n)] ans = [] for i in range(m): a, b = list(map(int, in...
16
23
382
413
v = [] n, m = list(map(int, input().split())) ans = [[] for i in range(n)] for i in range(m): a, b = list(map(int, input().split())) ans[a - 1].append((b - 1)) ans[b - 1].append((a - 1)) def dfs(now, visited=[]): if len(visited) == n: v.append([visited]) return for j in ans[now]: ...
def DFS(now, visited): if len(visited) == n: ans.append(1) return for i in graph[now]: if not i in visited: DFS(i, visited + [i]) n, m = list(map(int, input().split())) graph = [[] for i in range(n)] ans = [] for i in range(m): a, b = list(map(int, input().split())) ...
false
30.434783
[ "-v = []", "+def DFS(now, visited):", "+ if len(visited) == n:", "+ ans.append(1)", "+ return", "+ for i in graph[now]:", "+ if not i in visited:", "+ DFS(i, visited + [i])", "+", "+", "-ans = [[] for i in range(n)]", "+graph = [[] for i in range(n)]", "...
false
0.037556
0.053297
0.704654
[ "s580041776", "s247237317" ]
u411537765
p03488
python
s822485564
s051029051
1,322
219
3,444
3,444
Accepted
Accepted
83.43
import sys from collections import deque s = deque(eval(input()) + 'T') X, Y = list(map(int, input().split())) while True: if s[0] == 'T': break s.popleft() X -= 1 dirx = True x_list = [] y_list = [] count = 0 for c in s: if c == 'F': count += 1 else: i...
import sys from collections import deque s = deque(eval(input()) + 'T') X, Y = list(map(int, input().split())) while True: if s[0] == 'T': break s.popleft() X -= 1 dirx = True x_list = [] y_list = [] count = 0 for c in s: if c == 'F': count += 1 else: i...
53
56
1,133
1,165
import sys from collections import deque s = deque(eval(input()) + "T") X, Y = list(map(int, input().split())) while True: if s[0] == "T": break s.popleft() X -= 1 dirx = True x_list = [] y_list = [] count = 0 for c in s: if c == "F": count += 1 else: if count > 0: ...
import sys from collections import deque s = deque(eval(input()) + "T") X, Y = list(map(int, input().split())) while True: if s[0] == "T": break s.popleft() X -= 1 dirx = True x_list = [] y_list = [] count = 0 for c in s: if c == "F": count += 1 else: if count > 0: ...
false
5.357143
[ "-dx = (sum(x_list) + abs(X)) // 2", "-dy = (sum(y_list) + abs(Y)) // 2", "+dx = (sum(x_list) - abs(X)) // 2", "- if dp_x[i] and i + x <= dx:", "+ if dp_x[i]:", "+ if dp_x[dx]:", "+ break", "+dy = (sum(y_list) - abs(Y)) // 2", "- if dp_y[i] and i + y <= dy:", "+ ...
false
0.047449
0.047692
0.994902
[ "s822485564", "s051029051" ]
u064505481
p03164
python
s682945283
s125595348
369
234
71,584
83,080
Accepted
Accepted
36.59
from sys import stdin, stdout from collections import deque, defaultdict import math as m rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float('inf'), float('-inf') def main(): n, W = rli() items = [] maxval = 0 ...
from sys import stdin, stdout, setrecursionlimit from collections import deque, defaultdict, Counter from heapq import heappush, heappop import math rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) rlf = lambda: list(map(float, stdin.re...
34
39
712
899
from sys import stdin, stdout from collections import deque, defaultdict import math as m rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float("inf"), float("-inf") def main(): n, W = rli() items = [] maxval = 0 ...
from sys import stdin, stdout, setrecursionlimit from collections import deque, defaultdict, Counter from heapq import heappush, heappop import math rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) rlf = lambda: list(map(float, stdin.readline()...
false
12.820513
[ "-from sys import stdin, stdout", "-from collections import deque, defaultdict", "-import math as m", "+from sys import stdin, stdout, setrecursionlimit", "+from collections import deque, defaultdict, Counter", "+from heapq import heappush, heappop", "+import math", "+rlf = lambda: list(map(float, std...
false
0.098669
0.39088
0.252429
[ "s682945283", "s125595348" ]
u360515075
p03329
python
s282758368
s852660663
36
18
3,064
3,060
Accepted
Accepted
50
import bisect as bi li6 = [6 ** i for i in range(7)] li9 = [9 ** i for i in range(6)] def s69(n): if n < 6: return n else: s6 = li6[bi.bisect(li6, n)-1] s9 = li9[bi.bisect(li9, n)-1] return min(n // s6 + s69(n % s6), 1 + s69(n-s9), n // s9 + s69(n % s9)) print((s69(int(eval(input()...
import bisect as bi li6 = [6 ** i for i in range(7)] li9 = [9 ** i for i in range(6)] def s69(n): if n < 6: return n else: s6 = li6[bi.bisect(li6, n)-1] s9 = li9[bi.bisect(li9, n)-1] return min(n // s6 + s69(n % s6), 1 + s69(n-s9)) print((s69(int(eval(input())))))
14
14
318
295
import bisect as bi li6 = [6**i for i in range(7)] li9 = [9**i for i in range(6)] def s69(n): if n < 6: return n else: s6 = li6[bi.bisect(li6, n) - 1] s9 = li9[bi.bisect(li9, n) - 1] return min(n // s6 + s69(n % s6), 1 + s69(n - s9), n // s9 + s69(n % s9)) print((s69(int(eva...
import bisect as bi li6 = [6**i for i in range(7)] li9 = [9**i for i in range(6)] def s69(n): if n < 6: return n else: s6 = li6[bi.bisect(li6, n) - 1] s9 = li9[bi.bisect(li9, n) - 1] return min(n // s6 + s69(n % s6), 1 + s69(n - s9)) print((s69(int(eval(input())))))
false
0
[ "- return min(n // s6 + s69(n % s6), 1 + s69(n - s9), n // s9 + s69(n % s9))", "+ return min(n // s6 + s69(n % s6), 1 + s69(n - s9))" ]
false
0.052054
0.046396
1.121948
[ "s282758368", "s852660663" ]
u513081876
p03862
python
s209134601
s857451142
119
109
14,588
14,548
Accepted
Accepted
8.4
N, X = list(map(int, input().split())) a = list(map(int, input().split())) ans = 0 for i in range(N-1): if a[i] + a[i+1] > X: if X - a[i] >= 0: ans += a[i+1] - (X - a[i]) a[i+1] = (X - a[i]) else: ans += a[i+1] a[i+1] = 0 ...
N, x = list(map(int, input().split())) a = [int(i) for i in input().split()] ans = 0 if a[0] > x: ans += a[0] - x a[0] = x for i in range(1, N): if a[i] + a[i - 1] > x: ans += a[i] - (x - a[i - 1]) a[i] = x - a[i - 1] print(ans)
18
14
384
266
N, X = list(map(int, input().split())) a = list(map(int, input().split())) ans = 0 for i in range(N - 1): if a[i] + a[i + 1] > X: if X - a[i] >= 0: ans += a[i + 1] - (X - a[i]) a[i + 1] = X - a[i] else: ans += a[i + 1] a[i + 1] = 0 ans += a...
N, x = list(map(int, input().split())) a = [int(i) for i in input().split()] ans = 0 if a[0] > x: ans += a[0] - x a[0] = x for i in range(1, N): if a[i] + a[i - 1] > x: ans += a[i] - (x - a[i - 1]) a[i] = x - a[i - 1] print(ans)
false
22.222222
[ "-N, X = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "+N, x = list(map(int, input().split()))", "+a = [int(i) for i in input().split()]", "-for i in range(N - 1):", "- if a[i] + a[i + 1] > X:", "- if X - a[i] >= 0:", "- ans += a[i + 1] - (X - a[i])", ...
false
0.043927
0.006322
6.947963
[ "s209134601", "s857451142" ]
u879870653
p03325
python
s130104970
s161112493
121
97
4,148
4,212
Accepted
Accepted
19.83
N = int(eval(input())) L = list(map(int,input().split())) ans = 0 for i in range(N) : flag = 0 while flag == 0 : if (L[i] % 2) == 0 : ans += 1 L[i] = L[i]//2 else : flag = 1 print(ans)
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 for i in range(len(A)) : while True : if A[i] % 2 != 0 : break ans += 1 A[i] //= 2 print(ans)
13
11
252
205
N = int(eval(input())) L = list(map(int, input().split())) ans = 0 for i in range(N): flag = 0 while flag == 0: if (L[i] % 2) == 0: ans += 1 L[i] = L[i] // 2 else: flag = 1 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(len(A)): while True: if A[i] % 2 != 0: break ans += 1 A[i] //= 2 print(ans)
false
15.384615
[ "-L = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "-for i in range(N):", "- flag = 0", "- while flag == 0:", "- if (L[i] % 2) == 0:", "- ans += 1", "- L[i] = L[i] // 2", "- else:", "- flag = 1", "+for i in range(l...
false
0.037119
0.038402
0.966583
[ "s130104970", "s161112493" ]
u489959379
p03141
python
s018007764
s323875234
583
301
30,272
30,580
Accepted
Accepted
48.37
n = int(eval(input())) A, B, C = [], [], [] for i in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) C.append([a + b, i]) C = sorted(C, reverse=True) suma, sumb = 0, 0 for i in range(n): if i % 2: sumb += B[C[i][1]] else: suma += A[C[i][1]]...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] for i in range(n): a, b = AB[i] AB[i] = [a + b, a, b] AB.sort(key=la...
16
28
328
581
n = int(eval(input())) A, B, C = [], [], [] for i in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) C.append([a + b, i]) C = sorted(C, reverse=True) suma, sumb = 0, 0 for i in range(n): if i % 2: sumb += B[C[i][1]] else: suma += A[C[i][1]] print((suma - ...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] for i in range(n): a, b = AB[i] AB[i] = [a + b, a, b] AB.sort(key=lambda x: x[0], reve...
false
42.857143
[ "-n = int(eval(input()))", "-A, B, C = [], [], []", "-for i in range(n):", "- a, b = list(map(int, input().split()))", "- A.append(a)", "- B.append(b)", "- C.append([a + b, i])", "-C = sorted(C, reverse=True)", "-suma, sumb = 0, 0", "-for i in range(n):", "- if i % 2:", "- ...
false
0.036945
0.037788
0.977696
[ "s018007764", "s323875234" ]
u729133443
p03246
python
s848635196
s730415280
216
86
36,356
20,520
Accepted
Accepted
60.19
n=int(eval(input())) v=list(map(int,input().split())) w=sorted(a for a in v[0::2]) x=sorted(a for a in v[1::2]) a=[[0,i]for i in range(10**5+1)] b=[[0,i]for i in range(10**5+1)] for t in w: a[t][0]+=1 for t in x: b[t][0]+=1 c=sorted(a) d=sorted(b) e=c[len(c)-1][0] i=c[len(c)-1][1] f=d[len(d)-1][0]...
from collections import* n,*v=list(map(int,open(0).read().split())) a=Counter(v[::2]).most_common() b=Counter(v[1::2]).most_common() if a[0][0]==b[0][0]: if len(a)>1and len(b)>1: print((min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1]))) elif len(a)>1: print((n-a[1][1]-b[0][1])) elif len(b)>...
27
15
603
415
n = int(eval(input())) v = list(map(int, input().split())) w = sorted(a for a in v[0::2]) x = sorted(a for a in v[1::2]) a = [[0, i] for i in range(10**5 + 1)] b = [[0, i] for i in range(10**5 + 1)] for t in w: a[t][0] += 1 for t in x: b[t][0] += 1 c = sorted(a) d = sorted(b) e = c[len(c) - 1][0] i = c[len(c) -...
from collections import * n, *v = list(map(int, open(0).read().split())) a = Counter(v[::2]).most_common() b = Counter(v[1::2]).most_common() if a[0][0] == b[0][0]: if len(a) > 1 and len(b) > 1: print((min(n - a[0][1] - b[1][1], n - a[1][1] - b[0][1]))) elif len(a) > 1: print((n - a[1][1] - b[0...
false
44.444444
[ "-n = int(eval(input()))", "-v = list(map(int, input().split()))", "-w = sorted(a for a in v[0::2])", "-x = sorted(a for a in v[1::2])", "-a = [[0, i] for i in range(10**5 + 1)]", "-b = [[0, i] for i in range(10**5 + 1)]", "-for t in w:", "- a[t][0] += 1", "-for t in x:", "- b[t][0] += 1", ...
false
0.352121
0.096324
3.655597
[ "s848635196", "s730415280" ]
u465699806
p03665
python
s489752601
s225526853
227
127
76,724
76,712
Accepted
Accepted
44.05
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) input = sys.stdin.readline def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBU...
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) input = sys.stdin.readline def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBU...
54
53
1,079
991
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) input = sys.stdin.readline def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBUG" in sys.argv el...
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) input = sys.stdin.readline def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBUG" in sys.argv el...
false
1.851852
[ "-if __name__ == \"__main__\":", "- N, P = map(int, input().split())", "- A = [int(n) % 2 for n in input().split()]", "- cnt0 = len([a for a in A if a == 0])", "- cnt1 = len([a for a in A if a == 1])", "- ans = 0", "- if odd(P):", "- for i in range(cnt1 + 1):", "- ...
false
0.047363
0.046517
1.018181
[ "s489752601", "s225526853" ]
u780475861
p02773
python
s360130757
s396566181
682
283
61,044
38,476
Accepted
Accepted
58.5
from collections import Counter import sys n = int(sys.stdin.readline()) sn = sys.stdin.read().split() c = Counter(sn) c = sorted(list(c.items()), key=lambda x: (-x[1], x[0])) num = c[0][1] for i, j in c: if j == num: print(i) else: quit()
from collections import Counter import sys n = int(sys.stdin.readline()) sn = sys.stdin.read().split() c = Counter(sn) num = max(c.values()) ans = [i for i, j in list(c.items()) if j == num] ans.sort() print(('\n'.join(ans)))
12
9
256
225
from collections import Counter import sys n = int(sys.stdin.readline()) sn = sys.stdin.read().split() c = Counter(sn) c = sorted(list(c.items()), key=lambda x: (-x[1], x[0])) num = c[0][1] for i, j in c: if j == num: print(i) else: quit()
from collections import Counter import sys n = int(sys.stdin.readline()) sn = sys.stdin.read().split() c = Counter(sn) num = max(c.values()) ans = [i for i, j in list(c.items()) if j == num] ans.sort() print(("\n".join(ans)))
false
25
[ "-c = sorted(list(c.items()), key=lambda x: (-x[1], x[0]))", "-num = c[0][1]", "-for i, j in c:", "- if j == num:", "- print(i)", "- else:", "- quit()", "+num = max(c.values())", "+ans = [i for i, j in list(c.items()) if j == num]", "+ans.sort()", "+print((\"\\n\".join(ans)))...
false
0.104945
0.080311
1.306729
[ "s360130757", "s396566181" ]
u631277801
p03095
python
s426662583
s450530534
102
26
3,956
3,572
Accepted
Accepted
74.51
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.re...
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.re...
33
33
675
668
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
false
0
[ "-MOD = 10**9 + 7", "-for key, val in list(cnt.items()):", "- ans *= val + 1", "- ans %= MOD", "+mod = 10**9 + 7", "+for k, v in list(cnt.items()):", "+ ans *= v + 1", "+ ans %= mod", "- ans += MOD", "+ ans += mod" ]
false
0.076989
0.007323
10.513407
[ "s426662583", "s450530534" ]
u705617253
p03448
python
s562212782
s029028589
54
49
3,060
3,060
Accepted
Accepted
9.26
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) count = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: count += 1 print(count)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) result = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: result += 1 print(result)
13
13
261
264
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) count = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: count += 1 print(count)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) result = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: result += 1 print(result)
false
0
[ "-count = 0", "+result = 0", "- count += 1", "-print(count)", "+ result += 1", "+print(result)" ]
false
0.073618
0.3016
0.244091
[ "s562212782", "s029028589" ]
u904945034
p03671
python
s097816269
s466596825
29
24
9,120
9,104
Accepted
Accepted
17.24
ring = list(map(int,input().split())) print((sum(ring) - max(ring)))
a,b,c = sorted(map(int,input().split())) print((a+b))
2
2
67
52
ring = list(map(int, input().split())) print((sum(ring) - max(ring)))
a, b, c = sorted(map(int, input().split())) print((a + b))
false
0
[ "-ring = list(map(int, input().split()))", "-print((sum(ring) - max(ring)))", "+a, b, c = sorted(map(int, input().split()))", "+print((a + b))" ]
false
0.035202
0.039699
0.886718
[ "s097816269", "s466596825" ]
u397384480
p02996
python
s645200705
s805922113
1,625
1,021
72,172
68,460
Accepted
Accepted
37.17
N = int(eval(input())) A = [[None]*2 for i in range(N)] for i in range(N): A[i][1],A[i][0] = list(map(int,input().split())) A.sort() zum = 0 now = 0 for i in range(N): zum += A[i][1] now = A[i][0] if zum > now: print("No") break else: print("Yes")
import sys input = sys.stdin.readline N = int(eval(input())) A = [[None]*2 for i in range(N)] for i in range(N): A[i][1],A[i][0] = list(map(int,input().split())) A.sort() zum = 0 now = 0 for i in range(N): zum += A[i][1] now = A[i][0] if zum > now: print("No") break ...
17
20
289
331
N = int(eval(input())) A = [[None] * 2 for i in range(N)] for i in range(N): A[i][1], A[i][0] = list(map(int, input().split())) A.sort() zum = 0 now = 0 for i in range(N): zum += A[i][1] now = A[i][0] if zum > now: print("No") break else: print("Yes")
import sys input = sys.stdin.readline N = int(eval(input())) A = [[None] * 2 for i in range(N)] for i in range(N): A[i][1], A[i][0] = list(map(int, input().split())) A.sort() zum = 0 now = 0 for i in range(N): zum += A[i][1] now = A[i][0] if zum > now: print("No") break else: print(...
false
15
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.040493
0.096798
0.418329
[ "s645200705", "s805922113" ]
u964998676
p03814
python
s923299000
s487242424
60
17
3,512
3,500
Accepted
Accepted
71.67
str = eval(input('')) start = -1 end = -1 for x in range(len(str)): if str[x] == 'A' and start == -1: start = x elif str[x] == 'Z': end = x print((end - start + 1))
str = eval(input('')) start = str.find('A') end = str.rfind('Z') print((end - start + 1))
9
4
176
84
str = eval(input("")) start = -1 end = -1 for x in range(len(str)): if str[x] == "A" and start == -1: start = x elif str[x] == "Z": end = x print((end - start + 1))
str = eval(input("")) start = str.find("A") end = str.rfind("Z") print((end - start + 1))
false
55.555556
[ "-start = -1", "-end = -1", "-for x in range(len(str)):", "- if str[x] == \"A\" and start == -1:", "- start = x", "- elif str[x] == \"Z\":", "- end = x", "+start = str.find(\"A\")", "+end = str.rfind(\"Z\")" ]
false
0.035695
0.037109
0.961909
[ "s923299000", "s487242424" ]
u380524497
p03682
python
s480574387
s902732303
1,211
1,052
89,796
86,420
Accepted
Accepted
13.13
import sys import heapq input = sys.stdin.readline n = int(eval(input())) Xs = [] Ys = [] for i in range(n): x, y = list(map(int, input().split())) Xs.append((x-1, i)) Ys.append((y-1, i)) Xs.sort() Ys.sort() edges = [[] for _ in range(n)] for i in range(n-1): x, node = Xs[i] n...
import sys from heapq import heappush, heappop buf = sys.stdin.buffer def main(): n = int(buf.readline()) XY = list(map(int, buf.read().split())) Xs = [] Ys = [] for i, (x, y) in enumerate(zip(XY, XY)): Xs.append((x-1, i)) Ys.append((y-1, i)) Xs.sort() Ys.so...
47
49
932
1,181
import sys import heapq input = sys.stdin.readline n = int(eval(input())) Xs = [] Ys = [] for i in range(n): x, y = list(map(int, input().split())) Xs.append((x - 1, i)) Ys.append((y - 1, i)) Xs.sort() Ys.sort() edges = [[] for _ in range(n)] for i in range(n - 1): x, node = Xs[i] nx, new_node = Xs...
import sys from heapq import heappush, heappop buf = sys.stdin.buffer def main(): n = int(buf.readline()) XY = list(map(int, buf.read().split())) Xs = [] Ys = [] for i, (x, y) in enumerate(zip(XY, XY)): Xs.append((x - 1, i)) Ys.append((y - 1, i)) Xs.sort() Ys.sort() ed...
false
4.081633
[ "-import heapq", "+from heapq import heappush, heappop", "-input = sys.stdin.readline", "-n = int(eval(input()))", "-Xs = []", "-Ys = []", "-for i in range(n):", "- x, y = list(map(int, input().split()))", "- Xs.append((x - 1, i))", "- Ys.append((y - 1, i))", "-Xs.sort()", "-Ys.sort()...
false
0.037684
0.036535
1.031441
[ "s480574387", "s902732303" ]
u190405389
p02767
python
s971017313
s687612398
184
168
38,512
38,384
Accepted
Accepted
8.7
n = int(eval(input())) x = list(map(int, input().split())) ans = 10**9 for p in range(1,101): a = 0 for k in x: a+=(k-p)**2 ans = min(ans,a) print(ans)
n = int(eval(input())) x = list(map(int, input().split())) s = round(sum(x)/n) ans = [(a-s)**2 for a in x] print((sum(ans)))
12
7
179
124
n = int(eval(input())) x = list(map(int, input().split())) ans = 10**9 for p in range(1, 101): a = 0 for k in x: a += (k - p) ** 2 ans = min(ans, a) print(ans)
n = int(eval(input())) x = list(map(int, input().split())) s = round(sum(x) / n) ans = [(a - s) ** 2 for a in x] print((sum(ans)))
false
41.666667
[ "-ans = 10**9", "-for p in range(1, 101):", "- a = 0", "- for k in x:", "- a += (k - p) ** 2", "- ans = min(ans, a)", "-print(ans)", "+s = round(sum(x) / n)", "+ans = [(a - s) ** 2 for a in x]", "+print((sum(ans)))" ]
false
0.036443
0.036434
1.00025
[ "s971017313", "s687612398" ]
u066337396
p02990
python
s395990410
s707689472
71
62
32,876
33,004
Accepted
Accepted
12.68
MOD = 10 ** 9 + 7 def main(): n, k = list(map(int, input().split())) a = aa = n + 1 - k b = 1 bb = k for i in range(1, k + 1): print(a * b % MOD) aa -= 1 a = a * aa / (i + 1) bb -= 1 b = b * bb / i if __name__ == '__main__': main()
MOD = 10 ** 9 + 7 def main(): n, k = list(map(int, input().split())) a = aa = n + 1 - k b = 1 bb = k for i in range(1, k + 1): print(a * b % MOD) aa -= 1 a = a * aa // (i + 1) bb -= 1 b = b * bb // i if __name__ == '__main__': main()...
19
19
317
319
MOD = 10**9 + 7 def main(): n, k = list(map(int, input().split())) a = aa = n + 1 - k b = 1 bb = k for i in range(1, k + 1): print(a * b % MOD) aa -= 1 a = a * aa / (i + 1) bb -= 1 b = b * bb / i if __name__ == "__main__": main()
MOD = 10**9 + 7 def main(): n, k = list(map(int, input().split())) a = aa = n + 1 - k b = 1 bb = k for i in range(1, k + 1): print(a * b % MOD) aa -= 1 a = a * aa // (i + 1) bb -= 1 b = b * bb // i if __name__ == "__main__": main()
false
0
[ "- a = a * aa / (i + 1)", "+ a = a * aa // (i + 1)", "- b = b * bb / i", "+ b = b * bb // i" ]
false
0.036595
0.036498
1.002665
[ "s395990410", "s707689472" ]
u002459665
p03293
python
s362337975
s399353149
20
18
2,940
3,064
Accepted
Accepted
10
x = eval(input()) y = eval(input()) l = [] for i in range(len(x)): s = x[-i - 1:] + x[:-i - 1] l.append(s) if y in l: print("Yes") else: print("No")
def main(): x = eval(input()) y = eval(input()) l = [] for i in range(len(x)): s = x[-i - 1:] + x[:-i - 1] l.append(s) if y in l: print("Yes") else: print("No") def main2(): x = eval(input()) y = eval(input()) ans = False s...
12
35
165
535
x = eval(input()) y = eval(input()) l = [] for i in range(len(x)): s = x[-i - 1 :] + x[: -i - 1] l.append(s) if y in l: print("Yes") else: print("No")
def main(): x = eval(input()) y = eval(input()) l = [] for i in range(len(x)): s = x[-i - 1 :] + x[: -i - 1] l.append(s) if y in l: print("Yes") else: print("No") def main2(): x = eval(input()) y = eval(input()) ans = False s = x for i in ran...
false
65.714286
[ "-x = eval(input())", "-y = eval(input())", "-l = []", "-for i in range(len(x)):", "- s = x[-i - 1 :] + x[: -i - 1]", "- l.append(s)", "-if y in l:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+def main():", "+ x = eval(input())", "+ y = eval(input())", "+ l = [...
false
0.035083
0.036063
0.972814
[ "s362337975", "s399353149" ]
u930705402
p02613
python
s056097290
s994223014
154
139
16,608
16,172
Accepted
Accepted
9.74
from collections import Counter N=int(eval(input())) S=[eval(input()) for i in range(N)] a=[0]*4 for i in range(N): if S[i]=='AC': a[0]+=1 elif S[i]=='WA': a[1]+=1 elif S[i]=='TLE': a[2]+=1 else: a[3]+=1 print(('AC','x',a[0])) print(('WA','x',a[1])) print((...
N=int(eval(input())) S=[eval(input()) for i in range(N)] print(('AC','x',S.count('AC'))) print(('WA','x',S.count('WA'))) print(('TLE','x',S.count('TLE'))) print(('RE','x',S.count('RE')))
17
6
340
171
from collections import Counter N = int(eval(input())) S = [eval(input()) for i in range(N)] a = [0] * 4 for i in range(N): if S[i] == "AC": a[0] += 1 elif S[i] == "WA": a[1] += 1 elif S[i] == "TLE": a[2] += 1 else: a[3] += 1 print(("AC", "x", a[0])) print(("WA", "x", a[...
N = int(eval(input())) S = [eval(input()) for i in range(N)] print(("AC", "x", S.count("AC"))) print(("WA", "x", S.count("WA"))) print(("TLE", "x", S.count("TLE"))) print(("RE", "x", S.count("RE")))
false
64.705882
[ "-from collections import Counter", "-", "-a = [0] * 4", "-for i in range(N):", "- if S[i] == \"AC\":", "- a[0] += 1", "- elif S[i] == \"WA\":", "- a[1] += 1", "- elif S[i] == \"TLE\":", "- a[2] += 1", "- else:", "- a[3] += 1", "-print((\"AC\", \"x\", ...
false
0.048377
0.12243
0.395137
[ "s056097290", "s994223014" ]
u225388820
p02558
python
s031359525
s036272030
297
264
79,888
75,156
Accepted
Accepted
11.11
def main(): class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank =...
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'...
83
79
2,411
2,099
def main(): 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 ...
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
4.819277
[ "-def main():", "- class UnionFind:", "- def __init__(self, N):", "- \"\"\"", "- N:要素数", "- root:各要素の親要素の番号を格納するリスト.", "- ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.", "- rank:ランク", "- \"\"\"", "- self.N = N",...
false
0.041333
0.072474
0.570314
[ "s031359525", "s036272030" ]
u635540732
p02713
python
s649373912
s903744651
1,194
1,042
9,204
76,908
Accepted
Accepted
12.73
def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) k=int(eval(input())) count=0 count+=k*(k+1)//2 for i in range(1,k+1): for j in range(1,k+1): if i!=j: count+=3*gcd(i,j) for a in range(1,k+1): for b in range(a+1,k+1): for c in range(b+1,k+1): coun...
def gcd(a, b): if b == 0: return a else: return gcd(b, a%b) k=int(eval(input())) count=0 for a in range(1,k+1): for b in range(1,k+1): for c in range(1,k+1): count+=gcd(gcd(a,b),c) print(count)
17
12
348
235
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) k = int(eval(input())) count = 0 count += k * (k + 1) // 2 for i in range(1, k + 1): for j in range(1, k + 1): if i != j: count += 3 * gcd(i, j) for a in range(1, k + 1): for b in range(a + 1, k + 1): ...
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) k = int(eval(input())) count = 0 for a in range(1, k + 1): for b in range(1, k + 1): for c in range(1, k + 1): count += gcd(gcd(a, b), c) print(count)
false
29.411765
[ "-count += k * (k + 1) // 2", "-for i in range(1, k + 1):", "- for j in range(1, k + 1):", "- if i != j:", "- count += 3 * gcd(i, j)", "- for b in range(a + 1, k + 1):", "- for c in range(b + 1, k + 1):", "- count += 6 * gcd(gcd(a, b), c)", "+ for b in ra...
false
0.144518
0.073208
1.974085
[ "s649373912", "s903744651" ]
u564589929
p02861
python
s363949304
s926449248
384
326
3,064
3,064
Accepted
Accepted
15.1
import math from itertools import permutations def solve(): n = int(eval(input())) cord = [list(map(int, input().split())) for _ in range(n)] # print(cord) # dist = {} # for i in range(n): # for j in range(n): # if i == j: continue # d = math.sqrt(pow(cord...
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): retur...
30
47
882
1,102
import math from itertools import permutations def solve(): n = int(eval(input())) cord = [list(map(int, input().split())) for _ in range(n)] # print(cord) # dist = {} # for i in range(n): # for j in range(n): # if i == j: continue # d = math.sqrt(pow(cord[i][0] - c...
import sys sys.setrecursionlimit(10**6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def...
false
36.170213
[ "-import math", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+# input = sys.stdin.readline ####", "+int1 = lambda x: int(x) - 1", "+", "+", "+def II():", "+ return int(eval(input()))", "+", "+", "+def MI():", "+ return list(map(int, input().split()))", "+", "+", "+d...
false
0.035686
0.046799
0.76253
[ "s363949304", "s926449248" ]
u880480312
p02813
python
s755972746
s587524513
46
37
3,060
13,816
Accepted
Accepted
19.57
#<C> import math import itertools n = int(eval(input())) p = list(map(int,input().split())) q = list(map(int,input().split())) ans1=n ans2=n x = [i for i in range(1, n+1)] for i in itertools.permutations(x,n): if p < list(i): ans1 -= 1 if q < list(i): ans2 -= 1 print((abs(ans1-an...
#<順列全探索> #n!通りの順列の組み合わせを全探索する方法。 #pythonにはitertoolsが存在するからそれを利用 #<ex.1(ABC150-C)> import itertools n = int(eval(input())) p = tuple(map(int,input().split())) q = tuple(map(int,input().split())) ls = list(itertools.permutations(list(range(1, n + 1)))) #順列作成 print((abs(ls.index(p) - ls.index(q))))
17
12
323
297
# <C> import math import itertools n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) ans1 = n ans2 = n x = [i for i in range(1, n + 1)] for i in itertools.permutations(x, n): if p < list(i): ans1 -= 1 if q < list(i): ans2 -= 1 print((abs(ans1 - ans2)...
# <順列全探索> # n!通りの順列の組み合わせを全探索する方法。 # pythonにはitertoolsが存在するからそれを利用 # <ex.1(ABC150-C)> import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) ls = list(itertools.permutations(list(range(1, n + 1)))) # 順列作成 print((abs(ls.index(p) - ls.index(q))))
false
29.411765
[ "-# <C>", "-import math", "+# <順列全探索>", "+# n!通りの順列の組み合わせを全探索する方法。", "+# pythonにはitertoolsが存在するからそれを利用", "+# <ex.1(ABC150-C)>", "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "-ans1 = n", "-ans2 = n", "-x = [i for i in range(1, n + 1)]", "-for i in itertools.pe...
false
0.04293
0.045409
0.945395
[ "s755972746", "s587524513" ]
u729133443
p02838
python
s196810779
s570876017
1,913
1,240
38,884
156,172
Accepted
Accepted
35.18
n,*a=list(map(int,open(0).read().split())) c=0 for i in range(61): i=2**i t=sum(i&b and 1for b in a) c=(c+t*(n-t)*i)%(10**9+7) print(c)
n,*a=list(map(int,open(0).read().split())) c=0 for i in range(61):t=sum(2**i&b>0for b in a);c=(c+t*(n-t)*2**i)%(10**9+7) print(c)
7
4
141
126
n, *a = list(map(int, open(0).read().split())) c = 0 for i in range(61): i = 2**i t = sum(i & b and 1 for b in a) c = (c + t * (n - t) * i) % (10**9 + 7) print(c)
n, *a = list(map(int, open(0).read().split())) c = 0 for i in range(61): t = sum(2**i & b > 0 for b in a) c = (c + t * (n - t) * 2**i) % (10**9 + 7) print(c)
false
42.857143
[ "- i = 2**i", "- t = sum(i & b and 1 for b in a)", "- c = (c + t * (n - t) * i) % (10**9 + 7)", "+ t = sum(2**i & b > 0 for b in a)", "+ c = (c + t * (n - t) * 2**i) % (10**9 + 7)" ]
false
0.043745
0.076628
0.570878
[ "s196810779", "s570876017" ]
u974935538
p03556
python
s875286243
s279086727
504
25
42,776
2,940
Accepted
Accepted
95.04
li =[] for i in range(1000000): li.append(i**2) N = int(eval(input())) ans = [] for i in range(1000000): if li[i]<=N: ans.append(li[i]) print((max(ans)))
n = int(eval(input())) a = 0 for i in range(n+1): if i*i <= n: a = i*i else: break print(a)
9
8
169
117
li = [] for i in range(1000000): li.append(i**2) N = int(eval(input())) ans = [] for i in range(1000000): if li[i] <= N: ans.append(li[i]) print((max(ans)))
n = int(eval(input())) a = 0 for i in range(n + 1): if i * i <= n: a = i * i else: break print(a)
false
11.111111
[ "-li = []", "-for i in range(1000000):", "- li.append(i**2)", "-N = int(eval(input()))", "-ans = []", "-for i in range(1000000):", "- if li[i] <= N:", "- ans.append(li[i])", "-print((max(ans)))", "+n = int(eval(input()))", "+a = 0", "+for i in range(n + 1):", "+ if i * i <= n...
false
1.738141
0.038033
45.701267
[ "s875286243", "s279086727" ]
u836939578
p02585
python
s791535516
s982328972
517
477
80,876
81,136
Accepted
Accepted
7.74
N, K = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) for i in range(len(p)): p[i] -= 1 ans = float("-inf") for i in range(N): #iはスタートポジション pos = i #移動先のマスにかかれたポイント point = [] total = 0 while True: pos = p[...
N, K = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) for i in range(len(p)): p[i] -= 1 ans = float("-inf") for i in range(N): #iはスタートポジション pos = i #移動先のマスにかかれたポイント point = [] total = 0 while True: pos = p[...
43
44
1,052
1,074
N, K = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) for i in range(len(p)): p[i] -= 1 ans = float("-inf") for i in range(N): # iはスタートポジション pos = i # 移動先のマスにかかれたポイント point = [] total = 0 while True: pos = p[pos] point....
N, K = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) for i in range(len(p)): p[i] -= 1 ans = float("-inf") for i in range(N): # iはスタートポジション pos = i # 移動先のマスにかかれたポイント point = [] total = 0 while True: pos = p[pos] point....
false
2.272727
[ "- now += total * ((K - i - 1) // l)", "+ cnt = (K - i - 1) // l", "+ now += total * cnt" ]
false
0.03561
0.036397
0.978391
[ "s791535516", "s982328972" ]
u631277801
p03283
python
s901853708
s439515272
811
739
46,652
46,800
Accepted
Accepted
8.88
from itertools import accumulate import sys sdin = sys.stdin.readline n,m,q = list(map(int, sdin().split())) lr = [] for i in range(m): l,r = list(map(int, sdin().split())) lr.append(tuple([l-1, r-1])) pq = [] for _ in range(q): p,q = list(map(int, sdin().split())) pq.append(tup...
from itertools import accumulate import sys sdin = sys.stdin.readline n,m,q = list(map(int, sdin().split())) lr = [] for i in range(m): l,r = list(map(int, sdin().split())) lr.append(tuple([l, r])) pq = [] for _ in range(q): p,q = list(map(int, sdin().split())) pq.append(tuple([...
37
33
862
801
from itertools import accumulate import sys sdin = sys.stdin.readline n, m, q = list(map(int, sdin().split())) lr = [] for i in range(m): l, r = list(map(int, sdin().split())) lr.append(tuple([l - 1, r - 1])) pq = [] for _ in range(q): p, q = list(map(int, sdin().split())) pq.append(tuple([p - 1, q - 1...
from itertools import accumulate import sys sdin = sys.stdin.readline n, m, q = list(map(int, sdin().split())) lr = [] for i in range(m): l, r = list(map(int, sdin().split())) lr.append(tuple([l, r])) pq = [] for _ in range(q): p, q = list(map(int, sdin().split())) pq.append(tuple([p, q])) # n×nフィールドを用...
false
10.810811
[ "- lr.append(tuple([l - 1, r - 1]))", "+ lr.append(tuple([l, r]))", "- pq.append(tuple([p - 1, q - 1]))", "+ pq.append(tuple([p, q]))", "-field = [[0 for _ in range(n)] for _ in range(n)]", "+field = [[0 for _ in range(n + 1)] for _ in range(n + 1)]", "-field_cum = [list(accumulate(field[i])...
false
0.042323
0.045135
0.937692
[ "s901853708", "s439515272" ]
u761320129
p03061
python
s009716060
s555975183
1,971
183
16,140
16,144
Accepted
Accepted
90.72
from fractions import gcd N = int(eval(input())) A = list(map(int,input().split())) class SegTree: def __init__(self,arr,func,unit): self.func = func self.unit = unit n = 1 while n < len(arr): n *= 2 self.n = n nodes = [unit]*(2*n-1) ...
from fractions import gcd N = int(eval(input())) A = list(map(int,input().split())) lc = [0] for a in A: lc.append(gcd(lc[-1], a)) rc = [0] for a in A[::-1]: rc.append(gcd(rc[-1], a)) rc.reverse() ans = 0 for l,r in zip(lc,rc[1:]): g = gcd(l,r) ans = max(ans, g) print(ans)
48
17
1,226
301
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) class SegTree: def __init__(self, arr, func, unit): self.func = func self.unit = unit n = 1 while n < len(arr): n *= 2 self.n = n nodes = [unit] * (2 * n - 1) n...
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) lc = [0] for a in A: lc.append(gcd(lc[-1], a)) rc = [0] for a in A[::-1]: rc.append(gcd(rc[-1], a)) rc.reverse() ans = 0 for l, r in zip(lc, rc[1:]): g = gcd(l, r) ans = max(ans, g) print(ans)
false
64.583333
[ "-", "-", "-class SegTree:", "- def __init__(self, arr, func, unit):", "- self.func = func", "- self.unit = unit", "- n = 1", "- while n < len(arr):", "- n *= 2", "- self.n = n", "- nodes = [unit] * (2 * n - 1)", "- nodes[n - 1 : n...
false
0.062173
0.060981
1.019547
[ "s009716060", "s555975183" ]
u936985471
p04034
python
s652248360
s501014277
365
225
4,596
12,652
Accepted
Accepted
38.36
n,m=list(map(int,input().split())) b=[1]*n red=[False]*n red[0]=True for i in range(m): x,y=list(map(int,input().split())) x,y=x-1,y-1 if not b[x]: continue b[y]+=1 if red[x]: red[y]=True b[x]-=1 if b[x]==0: red[x]=False print((red.count(True)))
import sys readline = sys.stdin.readline N,M = list(map(int,readline().split())) B = [1] * N possible = {0} for i in range(M): x,y = list(map(int,readline().split())) x,y = x - 1,y - 1 B[x] -= 1 B[y] += 1 if x in possible: possible.add(y) if x in possible and B[x] == 0: possible.remov...
18
17
283
336
n, m = list(map(int, input().split())) b = [1] * n red = [False] * n red[0] = True for i in range(m): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 if not b[x]: continue b[y] += 1 if red[x]: red[y] = True b[x] -= 1 if b[x] == 0: red[x] = False print((red....
import sys readline = sys.stdin.readline N, M = list(map(int, readline().split())) B = [1] * N possible = {0} for i in range(M): x, y = list(map(int, readline().split())) x, y = x - 1, y - 1 B[x] -= 1 B[y] += 1 if x in possible: possible.add(y) if x in possible and B[x] == 0: po...
false
5.555556
[ "-n, m = list(map(int, input().split()))", "-b = [1] * n", "-red = [False] * n", "-red[0] = True", "-for i in range(m):", "- x, y = list(map(int, input().split()))", "+import sys", "+", "+readline = sys.stdin.readline", "+N, M = list(map(int, readline().split()))", "+B = [1] * N", "+possibl...
false
0.037567
0.044298
0.848043
[ "s652248360", "s501014277" ]
u624475441
p03448
python
s355077649
s611501200
58
18
3,060
3,060
Accepted
Accepted
68.97
A,B,C,X=[int(eval(input()))for _ in[0]*4] ans=sum(a*500+b*100+c*50==X for a in range(A+1)for b in range(B+1)for c in range(C+1)) print(ans)
A, B, C, X = [int(eval(input())) for _ in range(4)] ans = 0 for a in range(A + 1): if X < 500 * a: break for b in range(B + 1): remainder = X - 500 * a - 100 * b if remainder < 0: break if remainder // 50 > C: continue ans += 1 print(an...
3
13
135
316
A, B, C, X = [int(eval(input())) for _ in [0] * 4] ans = sum( a * 500 + b * 100 + c * 50 == X for a in range(A + 1) for b in range(B + 1) for c in range(C + 1) ) print(ans)
A, B, C, X = [int(eval(input())) for _ in range(4)] ans = 0 for a in range(A + 1): if X < 500 * a: break for b in range(B + 1): remainder = X - 500 * a - 100 * b if remainder < 0: break if remainder // 50 > C: continue ans += 1 print(ans)
false
76.923077
[ "-A, B, C, X = [int(eval(input())) for _ in [0] * 4]", "-ans = sum(", "- a * 500 + b * 100 + c * 50 == X", "- for a in range(A + 1)", "- for b in range(B + 1)", "- for c in range(C + 1)", "-)", "+A, B, C, X = [int(eval(input())) for _ in range(4)]", "+ans = 0", "+for a in range(A + 1):...
false
0.066161
0.037318
1.7729
[ "s355077649", "s611501200" ]
u923668099
p02258
python
s296857004
s617881879
310
260
7,676
15,696
Accepted
Accepted
16.13
import sys n = int(eval(input())) dif_max = -float("inf") min_v = float("inf") for i in range(n): r = int(sys.stdin.readline()) dif_max = max(dif_max, r - min_v) min_v = min(min_v, r) print(dif_max)
from sys import stdin inf = 10**9 + 1 def solve(): n = int(stdin.readline()) R = [int(stdin.readline()) for i in range(n)] ans = max_profit(n, R) print(ans) def max_profit(n, R): max_dif = -inf min_v = R[0] for i in range(1, n): max_dif = max(max_dif, R[i] - min_v)...
13
22
220
419
import sys n = int(eval(input())) dif_max = -float("inf") min_v = float("inf") for i in range(n): r = int(sys.stdin.readline()) dif_max = max(dif_max, r - min_v) min_v = min(min_v, r) print(dif_max)
from sys import stdin inf = 10**9 + 1 def solve(): n = int(stdin.readline()) R = [int(stdin.readline()) for i in range(n)] ans = max_profit(n, R) print(ans) def max_profit(n, R): max_dif = -inf min_v = R[0] for i in range(1, n): max_dif = max(max_dif, R[i] - min_v) min_v...
false
40.909091
[ "-import sys", "+from sys import stdin", "-n = int(eval(input()))", "-dif_max = -float(\"inf\")", "-min_v = float(\"inf\")", "-for i in range(n):", "- r = int(sys.stdin.readline())", "- dif_max = max(dif_max, r - min_v)", "- min_v = min(min_v, r)", "-print(dif_max)", "+inf = 10**9 + 1",...
false
0.036189
0.039489
0.916445
[ "s296857004", "s617881879" ]
u709079466
p02628
python
s538341323
s549412124
39
28
9,260
9,192
Accepted
Accepted
28.21
n, k = list(map(int, input().split())) price_list = list(map(int, input().split())) sum = 0 min_index = 0 for i in range(k): min_index = price_list.index(min(price_list)) sum += price_list.pop(min_index) print(sum)
n, k = list(map(int, input().split())) price_list = list(map(int, input().split())) price_list.sort() sum = 0 for i in range(k): sum += price_list[i] print(sum)
11
10
229
170
n, k = list(map(int, input().split())) price_list = list(map(int, input().split())) sum = 0 min_index = 0 for i in range(k): min_index = price_list.index(min(price_list)) sum += price_list.pop(min_index) print(sum)
n, k = list(map(int, input().split())) price_list = list(map(int, input().split())) price_list.sort() sum = 0 for i in range(k): sum += price_list[i] print(sum)
false
9.090909
[ "+price_list.sort()", "-min_index = 0", "- min_index = price_list.index(min(price_list))", "- sum += price_list.pop(min_index)", "+ sum += price_list[i]" ]
false
0.10456
0.08621
1.212853
[ "s538341323", "s549412124" ]
u802963389
p02947
python
s599283807
s391417732
506
360
43,528
19,764
Accepted
Accepted
28.85
import collections N = int(eval(input())) s = [list(eval(input())) for _ in range(N)] mydict = {} ans = 0 for i in s: a = str(sorted(i)) if a in mydict: ans += mydict[a] mydict[a] += 1 else: mydict.setdefault(a,1) print(ans)
# C - Green Bin # https://atcoder.jp/contests/abc137/tasks/abc137_c from collections import Counter n = int(eval(input())) S = [] for _ in range(n): s = "".join(sorted(eval(input()))) S.append(s) C = Counter(S) ans = 0 for i in list(C.values()): ans += (i * (i - 1)) // 2 print(ans)
13
18
242
293
import collections N = int(eval(input())) s = [list(eval(input())) for _ in range(N)] mydict = {} ans = 0 for i in s: a = str(sorted(i)) if a in mydict: ans += mydict[a] mydict[a] += 1 else: mydict.setdefault(a, 1) print(ans)
# C - Green Bin # https://atcoder.jp/contests/abc137/tasks/abc137_c from collections import Counter n = int(eval(input())) S = [] for _ in range(n): s = "".join(sorted(eval(input()))) S.append(s) C = Counter(S) ans = 0 for i in list(C.values()): ans += (i * (i - 1)) // 2 print(ans)
false
27.777778
[ "-import collections", "+# C - Green Bin", "+# https://atcoder.jp/contests/abc137/tasks/abc137_c", "+from collections import Counter", "-N = int(eval(input()))", "-s = [list(eval(input())) for _ in range(N)]", "-mydict = {}", "+n = int(eval(input()))", "+S = []", "+for _ in range(n):", "+ s =...
false
0.039409
0.039162
1.006305
[ "s599283807", "s391417732" ]
u672475305
p03472
python
s932671240
s547145584
1,328
373
17,880
12,156
Accepted
Accepted
71.91
import numpy as np n,h = list(map(int,input().split())) amax = 0 lst = [] for i in range(n): a,b = list(map(int,input().split())) amax = max(amax,a) lst.append(b) lst.sort(reverse = True) rui = np.cumsum(lst) cnt = 10**10 for k in range(n): if rui[k] > h: cnt = min(cnt,k+1) ...
import math n,h = list(map(int,input().split())) A = [] B = [] for i in range(n): a,b = list(map(int,input().split())) A.append(a) B.append(b) x = max(A) B = sorted(B, reverse=True) B_lst = [] for i in range(n): if B[i] > x: B_lst.append(B[i]) cnt = 0 damage = 0 ans...
23
30
469
519
import numpy as np n, h = list(map(int, input().split())) amax = 0 lst = [] for i in range(n): a, b = list(map(int, input().split())) amax = max(amax, a) lst.append(b) lst.sort(reverse=True) rui = np.cumsum(lst) cnt = 10**10 for k in range(n): if rui[k] > h: cnt = min(cnt, k + 1) break ...
import math n, h = list(map(int, input().split())) A = [] B = [] for i in range(n): a, b = list(map(int, input().split())) A.append(a) B.append(b) x = max(A) B = sorted(B, reverse=True) B_lst = [] for i in range(n): if B[i] > x: B_lst.append(B[i]) cnt = 0 damage = 0 ans = None for i in range(le...
false
23.333333
[ "-import numpy as np", "+import math", "-amax = 0", "-lst = []", "+A = []", "+B = []", "- amax = max(amax, a)", "- lst.append(b)", "-lst.sort(reverse=True)", "-rui = np.cumsum(lst)", "-cnt = 10**10", "-for k in range(n):", "- if rui[k] > h:", "- cnt = min(cnt, k + 1)", "+...
false
0.61333
0.037974
16.151271
[ "s932671240", "s547145584" ]
u227082700
p02939
python
s547877930
s106945379
100
72
3,624
9,220
Accepted
Accepted
28
s=eval(input()) l=len(s) a=0 b="" i=0 while i<l: if s[i]!=b:a+=1;b=s[i] else:b="";i+=1;a+=1 i+=1 if i==l+1:a-=1 print(a)
s=eval(input())+"--" n=len(s)-1 ans=0 i=0 a="" while i<n: if s[i]==a: i+=1 a="" else: a=s[i] i+=1 ans+=1 print((ans-1))
11
14
132
144
s = eval(input()) l = len(s) a = 0 b = "" i = 0 while i < l: if s[i] != b: a += 1 b = s[i] else: b = "" i += 1 a += 1 i += 1 if i == l + 1: a -= 1 print(a)
s = eval(input()) + "--" n = len(s) - 1 ans = 0 i = 0 a = "" while i < n: if s[i] == a: i += 1 a = "" else: a = s[i] i += 1 ans += 1 print((ans - 1))
false
21.428571
[ "-s = eval(input())", "-l = len(s)", "-a = 0", "-b = \"\"", "+s = eval(input()) + \"--\"", "+n = len(s) - 1", "+ans = 0", "-while i < l:", "- if s[i] != b:", "- a += 1", "- b = s[i]", "+a = \"\"", "+while i < n:", "+ if s[i] == a:", "+ i += 1", "+ a = ...
false
0.04721
0.067483
0.699585
[ "s547877930", "s106945379" ]
u021548497
p02560
python
s294395433
s546169217
976
657
9,376
106,300
Accepted
Accepted
32.68
import sys input = sys.stdin.readline def floor_sum(n, m, a, b): ans = 0 if a >= m: ans += (n-1) * n * (a // m) // 2 a %= m if b >= m: ans += b * (b // m) b %= m y_max = (a * n + b) // m x_max = y_max * m - b if y_max == 0: return ans ...
import sys import numba from numba import njit, i8 input = sys.stdin.readline @njit(i8(i8, i8, i8, i8), cache=True) def floor_sum(n, m, a, b): ans = 0 if a >= m: ans += (n-1) * n * (a // m) // 2 a %= m if b >= m: ans += b * (b // m) b %= m y_max = (a ...
31
33
654
733
import sys input = sys.stdin.readline def floor_sum(n, m, a, b): ans = 0 if a >= m: ans += (n - 1) * n * (a // m) // 2 a %= m if b >= m: ans += b * (b // m) b %= m y_max = (a * n + b) // m x_max = y_max * m - b if y_max == 0: return ans ans += (n - ...
import sys import numba from numba import njit, i8 input = sys.stdin.readline @njit(i8(i8, i8, i8, i8), cache=True) def floor_sum(n, m, a, b): ans = 0 if a >= m: ans += (n - 1) * n * (a // m) // 2 a %= m if b >= m: ans += b * (b // m) b %= m y_max = (a * n + b) // m ...
false
6.060606
[ "+import numba", "+from numba import njit, i8", "+@njit(i8(i8, i8, i8, i8), cache=True)" ]
false
0.036674
0.044152
0.830626
[ "s294395433", "s546169217" ]
u623819879
p03579
python
s549309049
s576228900
481
425
75,624
75,496
Accepted
Accepted
11.64
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from itertools import permutations,combinations import sys import bisect import string import math import time import random def I(): return int(input()) def MI(): return map(int,input().sp...
from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from itertools import permutations,combinations import sys import bisect import string import math import time import random def I(): return int(input()) def MI(): return map(int,input().sp...
98
88
2,104
1,978
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations import sys import bisect import string import math import time import random def I(): return int(input()) def MI(): return map(int, input().split...
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations import sys import bisect import string import math import time import random def I(): return int(input()) def MI(): return map(int, input().split...
false
10.204082
[ "-def bfs(x):", "- q = [x]", "- v[x] = 0", "+def IsBipartite():", "+ q = [0]", "+ v[0] = 0", "+ elif v[n] == v[c]:", "+ return False", "+ return True", "-bfs(0)", "-flg = True", "-for i in range(n):", "- MM = max([v[nb] for nb in g[i]])", "- m...
false
0.056098
0.127775
0.439035
[ "s549309049", "s576228900" ]
u062484507
p03835
python
s678675090
s432326569
1,905
18
2,940
3,060
Accepted
Accepted
99.06
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - (x + y) if 0 <= z <= K: if x <= S or y <= S: count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): yz = S - x if yz < 0: break elif yz <= K: count += yz + 1 elif yz <= 2*K: count += K - (yz-K) + 1 print(count)
9
11
221
226
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - (x + y) if 0 <= z <= K: if x <= S or y <= S: count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): yz = S - x if yz < 0: break elif yz <= K: count += yz + 1 elif yz <= 2 * K: count += K - (yz - K) + 1 print(count)
false
18.181818
[ "- for y in range(K + 1):", "- z = S - (x + y)", "- if 0 <= z <= K:", "- if x <= S or y <= S:", "- count += 1", "+ yz = S - x", "+ if yz < 0:", "+ break", "+ elif yz <= K:", "+ count += yz + 1", "+ elif yz <= 2 * K:", "+ ...
false
0.047849
0.046968
1.018765
[ "s678675090", "s432326569" ]
u926412290
p02707
python
s425780020
s787241795
229
155
40,824
94,384
Accepted
Accepted
32.31
N = int(eval(input())) boss = {i+1: 0 for i in range(N)} A = list(map(int, input().split())) for i in A: boss[i] += 1 for i in range(N): print((boss[i+1]))
N = int(input()) boss = [0] * N A = map(lambda x:int(x) - 1, input().split()) for i in A: boss[i] += 1 print(*boss, sep='\n')
9
8
159
138
N = int(eval(input())) boss = {i + 1: 0 for i in range(N)} A = list(map(int, input().split())) for i in A: boss[i] += 1 for i in range(N): print((boss[i + 1]))
N = int(input()) boss = [0] * N A = map(lambda x: int(x) - 1, input().split()) for i in A: boss[i] += 1 print(*boss, sep="\n")
false
11.111111
[ "-N = int(eval(input()))", "-boss = {i + 1: 0 for i in range(N)}", "-A = list(map(int, input().split()))", "+N = int(input())", "+boss = [0] * N", "+A = map(lambda x: int(x) - 1, input().split())", "-for i in range(N):", "- print((boss[i + 1]))", "+print(*boss, sep=\"\\n\")" ]
false
0.036796
0.036025
1.021393
[ "s425780020", "s787241795" ]
u327466606
p03716
python
s534198400
s254528422
722
297
59,052
38,748
Accepted
Accepted
58.86
from heapq import * N = int(eval(input())) A = list(map(int, input().split())) A_indexed = [(a, i) for i, a in enumerate(A)] def scores(): # initial N:2N selected_left = A[:N] # min heap heapify(selected_left) l_score = sum(selected_left) temp = sorted(A_indexed[N:]) selected_right_set = s...
from heapq import * N = int(eval(input())) A = list(map(int, input().split())) B = list([-x for x in reversed(A)]) def left_scores(L): s = sum(L[:N]) scores = [s] q = L[:N] heapify(q) for e in L[N:2*N]: s -= heappushpop(q, e) s += e scores.append(s) return scores print((ma...
42
19
1,049
393
from heapq import * N = int(eval(input())) A = list(map(int, input().split())) A_indexed = [(a, i) for i, a in enumerate(A)] def scores(): # initial N:2N selected_left = A[:N] # min heap heapify(selected_left) l_score = sum(selected_left) temp = sorted(A_indexed[N:]) selected_right_set = set...
from heapq import * N = int(eval(input())) A = list(map(int, input().split())) B = list([-x for x in reversed(A)]) def left_scores(L): s = sum(L[:N]) scores = [s] q = L[:N] heapify(q) for e in L[N : 2 * N]: s -= heappushpop(q, e) s += e scores.append(s) return scores ...
false
54.761905
[ "-A_indexed = [(a, i) for i, a in enumerate(A)]", "+B = list([-x for x in reversed(A)])", "-def scores():", "- # initial N:2N", "- selected_left = A[:N] # min heap", "- heapify(selected_left)", "- l_score = sum(selected_left)", "- temp = sorted(A_indexed[N:])", "- selected_right_s...
false
0.163717
0.166723
0.981966
[ "s534198400", "s254528422" ]
u077291787
p03732
python
s054185848
s483849901
33
30
3,064
3,064
Accepted
Accepted
9.09
# ABC060D - Simple Knapsack (ARC073D) # exhaustive search from itertools import accumulate def main(): N, W, *A = list(map(int, open(0).read().split())) V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 ≤ wi ≤ w1 + 3) for i in range(0, 2 * N, 2): # group by weight w, v = A[i : i + 2] ...
# ABC060D - Simple Knapsack (ARC073D) from itertools import accumulate as acc def main(): N, W, *A = list(map(int, open(0).read().split())) V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 ≤ wi ≤ w1 + 3) for w, v in zip(*[iter(A)] * 2): # group by weight V[w - x].append(v) for i in r...
29
27
935
892
# ABC060D - Simple Knapsack (ARC073D) # exhaustive search from itertools import accumulate def main(): N, W, *A = list(map(int, open(0).read().split())) V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 ≤ wi ≤ w1 + 3) for i in range(0, 2 * N, 2): # group by weight w, v = A[i : i + 2] V[w -...
# ABC060D - Simple Knapsack (ARC073D) from itertools import accumulate as acc def main(): N, W, *A = list(map(int, open(0).read().split())) V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 ≤ wi ≤ w1 + 3) for w, v in zip(*[iter(A)] * 2): # group by weight V[w - x].append(v) for i in range(4): ...
false
6.896552
[ "-# exhaustive search", "-from itertools import accumulate", "+from itertools import accumulate as acc", "- for i in range(0, 2 * N, 2): # group by weight", "- w, v = A[i : i + 2]", "- V[w - x] += [v]", "+ for w, v in zip(*[iter(A)] * 2): # group by weight", "+ V[w - x].ap...
false
0.092258
0.046244
1.995027
[ "s054185848", "s483849901" ]
u352394527
p00315
python
s754186393
s169097657
5,270
4,590
68,828
68,824
Accepted
Accepted
12.9
C, n = list(map(int, input().split())) mp = [eval(input()) for _ in range(n)] diff_dic = {} def change(x, y): global diff_dic if (x, y) in diff_dic: diff_dic.pop((x, y)) else: diff_dic[(x, y)] = True for y in range(n // 2): for x in range(n // 2): base = mp[y][x] if mp[y][n - 1 - x] ...
def main(): C, n = list(map(int, input().split())) mp = [eval(input()) for _ in range(n)] diff_dic = {} def change(x, y): if (x, y) in diff_dic: diff_dic.pop((x, y)) else: diff_dic[(x, y)] = True for y in range(n // 2): for x in range(n // 2): base = mp[y][x] ...
50
53
1,261
1,365
C, n = list(map(int, input().split())) mp = [eval(input()) for _ in range(n)] diff_dic = {} def change(x, y): global diff_dic if (x, y) in diff_dic: diff_dic.pop((x, y)) else: diff_dic[(x, y)] = True for y in range(n // 2): for x in range(n // 2): base = mp[y][x] if m...
def main(): C, n = list(map(int, input().split())) mp = [eval(input()) for _ in range(n)] diff_dic = {} def change(x, y): if (x, y) in diff_dic: diff_dic.pop((x, y)) else: diff_dic[(x, y)] = True for y in range(n // 2): for x in range(n // 2): ...
false
5.660377
[ "-C, n = list(map(int, input().split()))", "-mp = [eval(input()) for _ in range(n)]", "-diff_dic = {}", "+def main():", "+ C, n = list(map(int, input().split()))", "+ mp = [eval(input()) for _ in range(n)]", "+ diff_dic = {}", "+", "+ def change(x, y):", "+ if (x, y) in diff_dic...
false
0.039092
0.037971
1.029524
[ "s754186393", "s169097657" ]
u125545880
p03611
python
s885444903
s718653203
75
67
14,292
14,068
Accepted
Accepted
10.67
import sys import collections #import numpy as np readline = sys.stdin.readline def main(): N = int(eval(input())) #A1 = np.array(list(map(int, readline().split()))) A = list(map(int, readline().split())) count = [0] * (max(A) + 3) for a in A: count[a+1] += 1 count...
import sys readline = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, readline().split())) count = [0] * (pow(10, 5)+3) for a in A: count[a] += 1 count[a+1] += 1 count[a+2] += 1 ans = max(count) print(ans) if __name__ == "...
23
18
417
337
import sys import collections # import numpy as np readline = sys.stdin.readline def main(): N = int(eval(input())) # A1 = np.array(list(map(int, readline().split()))) A = list(map(int, readline().split())) count = [0] * (max(A) + 3) for a in A: count[a + 1] += 1 count[a] += 1 ...
import sys readline = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, readline().split())) count = [0] * (pow(10, 5) + 3) for a in A: count[a] += 1 count[a + 1] += 1 count[a + 2] += 1 ans = max(count) print(ans) if __name__ == "__main__": ...
false
21.73913
[ "-import collections", "-# import numpy as np", "- # A1 = np.array(list(map(int, readline().split())))", "- count = [0] * (max(A) + 3)", "+ count = [0] * (pow(10, 5) + 3)", "+ count[a] += 1", "- count[a] += 1", "- print((max(count)))", "+ ans = max(count)", "+ print...
false
0.046238
0.051248
0.90225
[ "s885444903", "s718653203" ]
u832039789
p03073
python
s036498888
s837619777
67
53
3,188
3,188
Accepted
Accepted
20.9
s = eval(input()) res1, res2 = 0, 0 for i, j in enumerate(s): if i % 2 == 0: if j == '0': res1 += 1 else: if j == '1': res1 += 1 for i, j in enumerate(s): if i % 2 == 1: if j == '0': res2 += 1 else: if j == '1': ...
s=eval(input()) n=len(s) a=sum(i%2^int(s[i])for i in range(n)) print((min(a,n-a)))
17
4
351
77
s = eval(input()) res1, res2 = 0, 0 for i, j in enumerate(s): if i % 2 == 0: if j == "0": res1 += 1 else: if j == "1": res1 += 1 for i, j in enumerate(s): if i % 2 == 1: if j == "0": res2 += 1 else: if j == "1": res2 += 1 pr...
s = eval(input()) n = len(s) a = sum(i % 2 ^ int(s[i]) for i in range(n)) print((min(a, n - a)))
false
76.470588
[ "-res1, res2 = 0, 0", "-for i, j in enumerate(s):", "- if i % 2 == 0:", "- if j == \"0\":", "- res1 += 1", "- else:", "- if j == \"1\":", "- res1 += 1", "-for i, j in enumerate(s):", "- if i % 2 == 1:", "- if j == \"0\":", "- res2 ...
false
0.042258
0.106152
0.398089
[ "s036498888", "s837619777" ]
u864197622
p02734
python
s654307247
s078045053
116
100
3,316
3,316
Accepted
Accepted
13.79
K = 32 P = 998244353 pa = (1 << 30) - ((1 << 30) % P) M = [] N, S = list(map(int, input().split())) m = int(("1" * 2 + "0" * 30) * (S + 1), 2) mm = (1 << K * (S + 1)) - 1 A = [int(a) for a in input().split()] s = 0 ans = 0 for a in A: s += 1 s += s << a * K s &= mm s -= ((s & m) >> 30) * p...
K = 32 P = 998244353 pa = (1 << 30) - ((1 << 30) % P) M = [] N, S = list(map(int, input().split())) m = int(("1" * 2 + "0" * 30) * (S + 1), 2) mm = 1 << K * S mmm = (1 << K) - 1 A = [int(a) for a in input().split()] s = 0 ans = 0 for a in A: s += mm s += s >> a * K s -= ((s & m) >> 30) * pa ...
18
18
356
349
K = 32 P = 998244353 pa = (1 << 30) - ((1 << 30) % P) M = [] N, S = list(map(int, input().split())) m = int(("1" * 2 + "0" * 30) * (S + 1), 2) mm = (1 << K * (S + 1)) - 1 A = [int(a) for a in input().split()] s = 0 ans = 0 for a in A: s += 1 s += s << a * K s &= mm s -= ((s & m) >> 30) * pa ans += s...
K = 32 P = 998244353 pa = (1 << 30) - ((1 << 30) % P) M = [] N, S = list(map(int, input().split())) m = int(("1" * 2 + "0" * 30) * (S + 1), 2) mm = 1 << K * S mmm = (1 << K) - 1 A = [int(a) for a in input().split()] s = 0 ans = 0 for a in A: s += mm s += s >> a * K s -= ((s & m) >> 30) * pa ans += s & m...
false
0
[ "-mm = (1 << K * (S + 1)) - 1", "+mm = 1 << K * S", "+mmm = (1 << K) - 1", "- s += 1", "- s += s << a * K", "- s &= mm", "+ s += mm", "+ s += s >> a * K", "- ans += s >> S * K", "+ ans += s & mmm" ]
false
0.070487
0.036772
1.916875
[ "s654307247", "s078045053" ]
u928254435
p02730
python
s810834063
s174967898
19
17
3,064
3,064
Accepted
Accepted
10.53
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(S: str): N = len(S) a = S[0:int((N-1)/2)] b = S[int((N+3)/2)-1:N] if a == b[::-1]: Na = len(a) if Na % 2 == 0: aa = a[0:int(Na/2)] ab = a[int(Na/2):Na] ...
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(S: str): N = len(S) a = S[0:int((N-1)/2)] b = S[int((N+3)/2)-1:N] print(YES) if S == S[::-1] and a == a[::-1] and b == b[::-1] else print(NO) return # Generated by 1.1.6 https://github.com...
48
28
1,218
710
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(S: str): N = len(S) a = S[0 : int((N - 1) / 2)] b = S[int((N + 3) / 2) - 1 : N] if a == b[::-1]: Na = len(a) if Na % 2 == 0: aa = a[0 : int(Na / 2)] ab = a[int(Na / 2) :...
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(S: str): N = len(S) a = S[0 : int((N - 1) / 2)] b = S[int((N + 3) / 2) - 1 : N] print(YES) if S == S[::-1] and a == a[::-1] and b == b[::-1] else print(NO) return # Generated by 1.1.6 https://github.com/...
false
41.666667
[ "- if a == b[::-1]:", "- Na = len(a)", "- if Na % 2 == 0:", "- aa = a[0 : int(Na / 2)]", "- ab = a[int(Na / 2) : Na]", "- else:", "- aa = a[0 : int((Na - 1) / 2)]", "- ab = a[int((Na + 3) / 2) - 1 : Na]", "- Nb = len(b)", "...
false
0.036257
0.034611
1.047565
[ "s810834063", "s174967898" ]
u513081876
p03361
python
s649960901
s097012317
24
18
3,064
3,064
Accepted
Accepted
25
H, W = list(map(int, input().split())) s = [[] for i in range(H)] num = 0 judge = 0 start = [] for i in range(H): s[i] = eval(input()) if '#' in s[i]: num += s[i].count('#') if num == 0: print('Yes') else: for y in range(H): for x in range(W): flag = False ...
import sys H, W = list(map(int, input().split())) col = [] col.append('.' * (W + 2)) for i in range(H): col.append('.' + eval(input()) + '.') col.append('.' * (W + 2)) dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]] for y in range(1, H + 1): for x in range(1, W + 1): if col[y][x] == '#': ...
30
23
796
504
H, W = list(map(int, input().split())) s = [[] for i in range(H)] num = 0 judge = 0 start = [] for i in range(H): s[i] = eval(input()) if "#" in s[i]: num += s[i].count("#") if num == 0: print("Yes") else: for y in range(H): for x in range(W): flag = False if s[y]...
import sys H, W = list(map(int, input().split())) col = [] col.append("." * (W + 2)) for i in range(H): col.append("." + eval(input()) + ".") col.append("." * (W + 2)) dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]] for y in range(1, H + 1): for x in range(1, W + 1): if col[y][x] == "#": for dx, ...
false
23.333333
[ "+import sys", "+", "-s = [[] for i in range(H)]", "-num = 0", "-judge = 0", "-start = []", "+col = []", "+col.append(\".\" * (W + 2))", "- s[i] = eval(input())", "- if \"#\" in s[i]:", "- num += s[i].count(\"#\")", "-if num == 0:", "- print(\"Yes\")", "-else:", "- for...
false
0.039099
0.04927
0.793579
[ "s649960901", "s097012317" ]
u439063038
p03160
python
s913125345
s906165774
122
97
20,592
85,108
Accepted
Accepted
20.49
N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1]-h[0]) for i in range(2, N): dp[i] = min([dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1])]) print((dp[N-1]))
N = int(eval(input())) h = list(map(int, input().split())) dp = [10**9] * N dp[0] = 0 dp[1] = abs(h[1]-h[0]) for i in range(2, N): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print((dp[N-1]))
8
9
203
216
N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) for i in range(2, N): dp[i] = min([dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])]) print((dp[N - 1]))
N = int(eval(input())) h = list(map(int, input().split())) dp = [10**9] * N dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[N - 1]))
false
11.111111
[ "-dp = [0] * N", "+dp = [10**9] * N", "+dp[0] = 0", "- dp[i] = min([dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])])", "+ dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))" ]
false
0.039273
0.148204
0.26499
[ "s913125345", "s906165774" ]
u600402037
p03999
python
s116838889
s097570940
31
18
3,568
3,060
Accepted
Accepted
41.94
import itertools import copy S = list(eval(input())) answer = 0 length = len(S) for pattern in itertools.product((True, False), repeat=length-1): S2 = S[:] for i in range(length-1): if pattern[i]: S2.insert(length-i-1, '+') answer += eval(''.join(S2)) print(answer)
S = eval(input()) N = len(S) def f(i, a): if i == N-1: return sum(list(map(int, a.split('+')))) return f(i+1, a + S[i+1]) + f(i+1, a + '+' + S[i+1]) print((f(0, S[0])))
15
10
308
192
import itertools import copy S = list(eval(input())) answer = 0 length = len(S) for pattern in itertools.product((True, False), repeat=length - 1): S2 = S[:] for i in range(length - 1): if pattern[i]: S2.insert(length - i - 1, "+") answer += eval("".join(S2)) print(answer)
S = eval(input()) N = len(S) def f(i, a): if i == N - 1: return sum(list(map(int, a.split("+")))) return f(i + 1, a + S[i + 1]) + f(i + 1, a + "+" + S[i + 1]) print((f(0, S[0])))
false
33.333333
[ "-import itertools", "-import copy", "+S = eval(input())", "+N = len(S)", "-S = list(eval(input()))", "-answer = 0", "-length = len(S)", "-for pattern in itertools.product((True, False), repeat=length - 1):", "- S2 = S[:]", "- for i in range(length - 1):", "- if pattern[i]:", "- ...
false
0.037614
0.09089
0.413834
[ "s116838889", "s097570940" ]
u624617831
p02946
python
s459212813
s725135706
302
17
20,656
3,060
Accepted
Accepted
94.37
K = list(map(int, input().split())) import numpy as np tmp = [] for i in range(K[1]-K[0]+1, K[1]+K[0]): if abs(i) <= 1000000: print(i)
k, x = list(map(int, input().split())) under = x-(k-1) top = x+(k-1) ans = '' for i in range(under,top+1): if i == top: ans += str(i) else: ans += str(i)+' ' print(ans)
8
14
156
203
K = list(map(int, input().split())) import numpy as np tmp = [] for i in range(K[1] - K[0] + 1, K[1] + K[0]): if abs(i) <= 1000000: print(i)
k, x = list(map(int, input().split())) under = x - (k - 1) top = x + (k - 1) ans = "" for i in range(under, top + 1): if i == top: ans += str(i) else: ans += str(i) + " " print(ans)
false
42.857143
[ "-K = list(map(int, input().split()))", "-import numpy as np", "-", "-tmp = []", "-for i in range(K[1] - K[0] + 1, K[1] + K[0]):", "- if abs(i) <= 1000000:", "- print(i)", "+k, x = list(map(int, input().split()))", "+under = x - (k - 1)", "+top = x + (k - 1)", "+ans = \"\"", "+for i ...
false
0.041269
0.036172
1.140909
[ "s459212813", "s725135706" ]
u345389118
p02630
python
s799999777
s561738246
443
378
40,336
40,256
Accepted
Accepted
14.67
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) Q = int(eval(input())) B = [list(map(int, input().split())) for _ in range(Q)] res = sum(A) A_counter = Counter(A) for i, j in B: if i not in A_counter: A_counter[i] = 0 if j not in A_counter: ...
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) Q = int(eval(input())) B = [list(map(int, input().split())) for _ in range(Q)] res = sum(A) A_counter = Counter(A) for i, j in B: # if i not in A_counter: # A_counter[i] = 0 # if j not in A_counter: ...
19
19
441
445
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) Q = int(eval(input())) B = [list(map(int, input().split())) for _ in range(Q)] res = sum(A) A_counter = Counter(A) for i, j in B: if i not in A_counter: A_counter[i] = 0 if j not in A_counter: A_counter[j...
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) Q = int(eval(input())) B = [list(map(int, input().split())) for _ in range(Q)] res = sum(A) A_counter = Counter(A) for i, j in B: # if i not in A_counter: # A_counter[i] = 0 # if j not in A_counter: # A_c...
false
0
[ "- if i not in A_counter:", "- A_counter[i] = 0", "- if j not in A_counter:", "- A_counter[j] = 0", "+ # if i not in A_counter:", "+ # A_counter[i] = 0", "+ # if j not in A_counter:", "+ # A_counter[j] = 0" ]
false
0.03792
0.038607
0.982197
[ "s799999777", "s561738246" ]
u188827677
p02982
python
s486882881
s964243781
31
26
9,136
9,384
Accepted
Accepted
16.13
n,d = list(map(int, input().split())) x = [list(map(int, input().split())) for _ in range(n)] ans = 0 for i in range(n-1): for j in range(i+1,n): s = 0 for k in range(d): s += abs(x[i][k] - x[j][k])**2 s = s**0.5 if s.is_integer(): ans += 1 print(ans)
n,d = list(map(int, input().split())) x = [list(map(int, input().split())) for _ in range(n)] ans = 0 for i in range(n-1): for j in range(i+1, n): t = 0 for k in range(d): t += abs(x[i][k] - x[j][k])**2 t **= 0.5 if t.is_integer(): ans += 1 print(ans)
12
11
281
274
n, d = list(map(int, input().split())) x = [list(map(int, input().split())) for _ in range(n)] ans = 0 for i in range(n - 1): for j in range(i + 1, n): s = 0 for k in range(d): s += abs(x[i][k] - x[j][k]) ** 2 s = s**0.5 if s.is_integer(): ans += 1 print(ans)
n, d = list(map(int, input().split())) x = [list(map(int, input().split())) for _ in range(n)] ans = 0 for i in range(n - 1): for j in range(i + 1, n): t = 0 for k in range(d): t += abs(x[i][k] - x[j][k]) ** 2 t **= 0.5 if t.is_integer(): ans += 1 print(ans)
false
8.333333
[ "- s = 0", "+ t = 0", "- s += abs(x[i][k] - x[j][k]) ** 2", "- s = s**0.5", "- if s.is_integer():", "+ t += abs(x[i][k] - x[j][k]) ** 2", "+ t **= 0.5", "+ if t.is_integer():" ]
false
0.063914
0.063675
1.003757
[ "s486882881", "s964243781" ]
u265118937
p02627
python
s600241794
s570034894
33
26
8,952
9,080
Accepted
Accepted
21.21
a = eval(input()) if ord(a) < 0x61: print('A') else: print("a")
s = eval(input()) if ord(s) <= 0x5a: print("A") else: print("a")
5
5
69
70
a = eval(input()) if ord(a) < 0x61: print("A") else: print("a")
s = eval(input()) if ord(s) <= 0x5A: print("A") else: print("a")
false
0
[ "-a = eval(input())", "-if ord(a) < 0x61:", "+s = eval(input())", "+if ord(s) <= 0x5A:" ]
false
0.038168
0.035425
1.077419
[ "s600241794", "s570034894" ]