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
u896847891
p02659
python
s194791598
s215492066
25
22
9,164
9,168
Accepted
Accepted
12
from math import floor a, b = input().split() a = int(a) b = int(float(b)*100+0.0001) print((a*b//100))
a, b = input().split() a = int(a) b = round(float(b)*100) print((a*b//100))
7
5
109
78
from math import floor a, b = input().split() a = int(a) b = int(float(b) * 100 + 0.0001) print((a * b // 100))
a, b = input().split() a = int(a) b = round(float(b) * 100) print((a * b // 100))
false
28.571429
[ "-from math import floor", "-", "-b = int(float(b) * 100 + 0.0001)", "+b = round(float(b) * 100)" ]
false
0.047348
0.048631
0.973607
[ "s194791598", "s215492066" ]
u811841526
p02417
python
s442168678
s001715255
70
40
7,684
6,688
Accepted
Accepted
42.86
from collections import Counter counter = Counter() while True: try: s = eval(input()) for c in s: counter[c.lower()] += 1 except: break for c in range(ord('a'), ord('z')+1): print(('{} : {}'.format(chr(c), counter[chr(c)])))
from collections import Counter import string counter = Counter() while True: try: s = input().lower() counter += Counter(s) except EOFError: break for c in string.ascii_lowercase: count = counter[c] print(f'{c} : {count}')
15
15
283
281
from collections import Counter counter = Counter() while True: try: s = eval(input()) for c in s: counter[c.lower()] += 1 except: break for c in range(ord("a"), ord("z") + 1): print(("{} : {}".format(chr(c), counter[chr(c)])))
from collections import Counter import string counter = Counter() while True: try: s = input().lower() counter += Counter(s) except EOFError: break for c in string.ascii_lowercase: count = counter[c] print(f"{c} : {count}")
false
0
[ "+import string", "- s = eval(input())", "- for c in s:", "- counter[c.lower()] += 1", "- except:", "+ s = input().lower()", "+ counter += Counter(s)", "+ except EOFError:", "-for c in range(ord(\"a\"), ord(\"z\") + 1):", "- print((\"{} : {}\".format...
false
0.036362
0.041559
0.874961
[ "s442168678", "s001715255" ]
u075012704
p03127
python
s672341646
s057021951
133
78
14,252
20,388
Accepted
Accepted
41.35
N = int(eval(input())) A = sorted(list(map(int, input().split()))) # 最大公約数 def gcd(a, b): while b: a, b = b, a % b return a while len(A) > 1: A.append(gcd(A.pop(), A.pop())) print((A[0]))
from math import gcd N = int(eval(input())) A = list(map(int, input().split())) while len(A) > 1: A.append(gcd(A.pop(), A.pop())) print((A[0]))
15
7
219
147
N = int(eval(input())) A = sorted(list(map(int, input().split()))) # 最大公約数 def gcd(a, b): while b: a, b = b, a % b return a while len(A) > 1: A.append(gcd(A.pop(), A.pop())) print((A[0]))
from math import gcd N = int(eval(input())) A = list(map(int, input().split())) while len(A) > 1: A.append(gcd(A.pop(), A.pop())) print((A[0]))
false
53.333333
[ "+from math import gcd", "+", "-A = sorted(list(map(int, input().split())))", "-# 最大公約数", "-def gcd(a, b):", "- while b:", "- a, b = b, a % b", "- return a", "-", "-", "+A = list(map(int, input().split()))" ]
false
0.007309
0.071687
0.101954
[ "s672341646", "s057021951" ]
u816872429
p03000
python
s482054034
s040715689
181
19
38,384
3,064
Accepted
Accepted
89.5
n, x = list(map(int, input().split())) ls = list(map(int, input().split())) s = 0 c = 1 for l in ls: s += l if s > x: break c += 1 print(c)
n, x = list(map(int, input().split())) d = [0] for l in map(int, input().split()): d.append(d[-1] + l) print((sum(dx <= x for dx in d)))
10
5
163
136
n, x = list(map(int, input().split())) ls = list(map(int, input().split())) s = 0 c = 1 for l in ls: s += l if s > x: break c += 1 print(c)
n, x = list(map(int, input().split())) d = [0] for l in map(int, input().split()): d.append(d[-1] + l) print((sum(dx <= x for dx in d)))
false
50
[ "-ls = list(map(int, input().split()))", "-s = 0", "-c = 1", "-for l in ls:", "- s += l", "- if s > x:", "- break", "- c += 1", "-print(c)", "+d = [0]", "+for l in map(int, input().split()):", "+ d.append(d[-1] + l)", "+print((sum(dx <= x for dx in d)))" ]
false
0.044911
0.042347
1.060551
[ "s482054034", "s040715689" ]
u732412551
p03608
python
s509226972
s273810359
1,716
1,527
4,796
4,796
Accepted
Accepted
11.01
from itertools import permutations import sys input = sys.stdin.readline def main(): N, M, RR = list(map(int, input().split())) R = list(map(int, input().split())) INF = float("inf") T = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = tuple(map(int, input().split())) ...
from itertools import permutations import sys input = sys.stdin.readline def main(): N, M, RR = list(map(int, input().split())) R = list(map(int, input().split())) INF = float("inf") T = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = tuple(map(int, input().split())) ...
28
22
766
672
from itertools import permutations import sys input = sys.stdin.readline def main(): N, M, RR = list(map(int, input().split())) R = list(map(int, input().split())) INF = float("inf") T = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = tuple(map(int, input().split())) T[...
from itertools import permutations import sys input = sys.stdin.readline def main(): N, M, RR = list(map(int, input().split())) R = list(map(int, input().split())) INF = float("inf") T = [[INF] * N for _ in range(N)] for _ in range(M): a, b, c = tuple(map(int, input().split())) T[...
false
21.428571
[ "- ans = INF", "- for rs in permutations(R):", "- cost = 0", "- for i in range(RR - 1):", "- cost += T[rs[i] - 1][rs[i + 1] - 1]", "- ans = min(ans, cost)", "- print(ans)", "+ print(", "+ (", "+ min(", "+ sum(T[rs[i] - ...
false
0.043375
0.044065
0.984354
[ "s509226972", "s273810359" ]
u808585569
p02647
python
s827294837
s377149448
631
279
169,096
169,404
Accepted
Accepted
55.78
N, K= list(map(int,input().split())) A = list(map(int,input().split())) a=A[:] for _ in range(K): B=[0]*(N+1) for i in range(N): t = a[i] B[max(i-t,0)] +=1 B[min(i+t+1,N)] -=1 for i in range(N): B[i+1] += B[i] a=B[:N] if min(a)==N: break print((*a))
N, K= list(map(int,input().split())) a = list(map(int,input().split())) #a=A[:] for _ in range(K): B=[0]*(N+1) for i in range(N): t = a[i] B[max(i-t,0)] +=1 B[min(i+t+1,N)] -=1 for i in range(N): B[i+1] += B[i] a=B[:N] if min(a)==N: break print((*a))
15
15
293
294
N, K = list(map(int, input().split())) A = list(map(int, input().split())) a = A[:] for _ in range(K): B = [0] * (N + 1) for i in range(N): t = a[i] B[max(i - t, 0)] += 1 B[min(i + t + 1, N)] -= 1 for i in range(N): B[i + 1] += B[i] a = B[:N] if min(a) == N: b...
N, K = list(map(int, input().split())) a = list(map(int, input().split())) # a=A[:] for _ in range(K): B = [0] * (N + 1) for i in range(N): t = a[i] B[max(i - t, 0)] += 1 B[min(i + t + 1, N)] -= 1 for i in range(N): B[i + 1] += B[i] a = B[:N] if min(a) == N: b...
false
0
[ "-A = list(map(int, input().split()))", "-a = A[:]", "+a = list(map(int, input().split()))", "+# a=A[:]" ]
false
0.046031
0.046415
0.991723
[ "s827294837", "s377149448" ]
u440566786
p02948
python
s102334670
s257224018
866
714
96,944
60,380
Accepted
Accepted
17.55
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() from heapq import heappop,heappush def resolve(): n,m=list(map(int,input().split())) V=[[] for _ in range(m)] for _ in range(n): a,b=list(map(int,input().split())) ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() from heapq import heappop,heappush def resolve(): n,m=list(map(int,input().split())) AB=[None]*n for i in range(n): a,b=list(map(int,input().split())) a-=1 ...
28
26
629
557
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) V = [[] for _ in range(m)] for _ in range(n): a, b = list(map(int, input().split(...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) AB = [None] * n for i in range(n): a, b = list(map(int, input().split())) ...
false
7.142857
[ "- V = [[] for _ in range(m)]", "- for _ in range(n):", "+ AB = [None] * n", "+ for i in range(n):", "- if a > m:", "- continue", "- heappush(V[a - 1], -b)", "+ a -= 1", "+ AB[i] = (a, b)", "+ AB.sort(reverse=1)", "+ Q = []", "- Q = [...
false
0.073419
0.040417
1.816532
[ "s102334670", "s257224018" ]
u996434204
p03147
python
s818338245
s088880906
24
20
3,064
3,064
Accepted
Accepted
16.67
n=int(eval(input())) h=[int(x) for x in input().split()] height=[] result=0 tmp=0 for i in range(max(h)): buf=[] for j in range(n): if h[j] > i: buf.append(1) else: buf.append(0) height.append(buf) for val in height: while(tmp < len(val)): ...
n=int(eval(input())) h=[int(x) for x in input().split()] buf=[0 for i in range(n)] ans=0 flag=False for i in range(max(h)): for j in range(n): if h[j] >= i+1: flag=True if flag and h[j] <= i: ans+=1 flag=False if flag: ans+=1 ...
31
20
558
340
n = int(eval(input())) h = [int(x) for x in input().split()] height = [] result = 0 tmp = 0 for i in range(max(h)): buf = [] for j in range(n): if h[j] > i: buf.append(1) else: buf.append(0) height.append(buf) for val in height: while tmp < len(val): if va...
n = int(eval(input())) h = [int(x) for x in input().split()] buf = [0 for i in range(n)] ans = 0 flag = False for i in range(max(h)): for j in range(n): if h[j] >= i + 1: flag = True if flag and h[j] <= i: ans += 1 flag = False if flag: ans += 1 ...
false
35.483871
[ "-height = []", "-result = 0", "-tmp = 0", "+buf = [0 for i in range(n)]", "+ans = 0", "+flag = False", "- buf = []", "- if h[j] > i:", "- buf.append(1)", "- else:", "- buf.append(0)", "- height.append(buf)", "-for val in height:", "- while tmp ...
false
0.038201
0.041825
0.91335
[ "s818338245", "s088880906" ]
u580697892
p03087
python
s874213551
s600640196
845
443
6,100
30,704
Accepted
Accepted
47.57
#coding: utf-8 N, Q = list(map(int, input().split())) S = eval(input()) T = [0] for i in range(N-1): if S[i] == "A" and S[i+1] == "C": T.append(T[i] + 1) else: T.append(T[i]) for j in range(Q): l, r = list(map(int, input().split())) print((T[r-1] - T[l-1]))
# coding: utf-8 n, q = list(map(int, input().split())) s = eval(input()) lr = [list(map(int, input().split())) for _ in range(q)] T = [0] cnt = 0 for i in range(n-1): if s[i] == "A" and s[i+1] == "C": cnt += 1 T.append(cnt) for l, r in lr: print((T[r-1] - T[l-1]))
12
12
280
281
# coding: utf-8 N, Q = list(map(int, input().split())) S = eval(input()) T = [0] for i in range(N - 1): if S[i] == "A" and S[i + 1] == "C": T.append(T[i] + 1) else: T.append(T[i]) for j in range(Q): l, r = list(map(int, input().split())) print((T[r - 1] - T[l - 1]))
# coding: utf-8 n, q = list(map(int, input().split())) s = eval(input()) lr = [list(map(int, input().split())) for _ in range(q)] T = [0] cnt = 0 for i in range(n - 1): if s[i] == "A" and s[i + 1] == "C": cnt += 1 T.append(cnt) for l, r in lr: print((T[r - 1] - T[l - 1]))
false
0
[ "-N, Q = list(map(int, input().split()))", "-S = eval(input())", "+n, q = list(map(int, input().split()))", "+s = eval(input())", "+lr = [list(map(int, input().split())) for _ in range(q)]", "-for i in range(N - 1):", "- if S[i] == \"A\" and S[i + 1] == \"C\":", "- T.append(T[i] + 1)", "- ...
false
0.058693
0.059328
0.989299
[ "s874213551", "s600640196" ]
u596276291
p03659
python
s581930418
s314119123
166
147
25,320
25,836
Accepted
Accepted
11.45
from collections import defaultdict from itertools import product, groupby from math import pi from collections import deque from bisect import bisect, bisect_left, bisect_right INF = 10 ** 20 def main(): N = int(eval(input())) a_list = list(map(int, input().split())) total = sum(a_list) ...
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.se...
26
38
582
946
from collections import defaultdict from itertools import product, groupby from math import pi from collections import deque from bisect import bisect, bisect_left, bisect_right INF = 10**20 def main(): N = int(eval(input())) a_list = list(map(int, input().split())) total = sum(a_list) dp1 = [0] * N ...
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecurs...
false
31.578947
[ "-from collections import defaultdict", "-from itertools import product, groupby", "-from math import pi", "+from collections import defaultdict, Counter", "+from itertools import product, groupby, count, permutations, combinations", "+from math import pi, sqrt", "+from string import ascii_lowercase", ...
false
0.065322
0.064314
1.015668
[ "s581930418", "s314119123" ]
u785266893
p02622
python
s960109356
s412172111
65
57
9,416
9,404
Accepted
Accepted
12.31
s = eval(input()) t = eval(input()) count = 0 for i in range(len(s)): if s[i] != t[i]: count += 1 print(count)
s = eval(input()) t = eval(input()) count = 0 for i,j in zip(s,t): if i != j: count += 1 print(count)
8
8
119
110
s = eval(input()) t = eval(input()) count = 0 for i in range(len(s)): if s[i] != t[i]: count += 1 print(count)
s = eval(input()) t = eval(input()) count = 0 for i, j in zip(s, t): if i != j: count += 1 print(count)
false
0
[ "-for i in range(len(s)):", "- if s[i] != t[i]:", "+for i, j in zip(s, t):", "+ if i != j:" ]
false
0.039633
0.047416
0.835869
[ "s960109356", "s412172111" ]
u346812984
p02888
python
s020843851
s260144709
1,478
1,345
3,188
3,188
Accepted
Accepted
9
import bisect import sys sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 2): for j in ran...
import sys from bisect import bisect_left sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N): ...
28
28
509
503
import bisect import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): ...
import sys from bisect import bisect_left sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N): a = L[i] for ...
false
0
[ "-import bisect", "+from bisect import bisect_left", "- for i in range(N - 2):", "- for j in range(i + 1, N - 1):", "- ab = L[i] + L[j]", "- idx = bisect.bisect_left(L, ab)", "- ans += max(idx - j - 1, 0)", "+ for i in range(N):", "+ a = L[i]", ...
false
0.066951
0.040517
1.652389
[ "s020843851", "s260144709" ]
u581187895
p02861
python
s323944689
s890062041
371
149
8,180
12,448
Accepted
Accepted
59.84
import math from itertools import permutations N = int(eval(input())) A = [tuple(map(int, input().split())) for _ in range(N)] P = list(permutations(A)) ans = 0 count = 0 for p in P: count += 1 for i in range(1,len(p)): ans += math.sqrt((p[i-1][0]-p[i][0])**2 + (p[i-1][1]-p[i][1])**2) print...
import numpy as np N = int(eval(input())) A = [input().split() for _ in range(N)] # sum(A, []) 次元をフラット化 XY = np.array(sum(A, []),np.int64) X = XY[::2] # x部分 Y = XY[1::2] # y部分 # Noneで次元を追加 X[:, None] shap(N,1) dx = X[:,None] - X[None,:] dy = Y[:,None] - Y[None,:] dist_mat = (dx*dx + dy*dy)**.5 ans = ...
13
16
332
344
import math from itertools import permutations N = int(eval(input())) A = [tuple(map(int, input().split())) for _ in range(N)] P = list(permutations(A)) ans = 0 count = 0 for p in P: count += 1 for i in range(1, len(p)): ans += math.sqrt((p[i - 1][0] - p[i][0]) ** 2 + (p[i - 1][1] - p[i][1]) ** 2) prin...
import numpy as np N = int(eval(input())) A = [input().split() for _ in range(N)] # sum(A, []) 次元をフラット化 XY = np.array(sum(A, []), np.int64) X = XY[::2] # x部分 Y = XY[1::2] # y部分 # Noneで次元を追加 X[:, None] shap(N,1) dx = X[:, None] - X[None, :] dy = Y[:, None] - Y[None, :] dist_mat = (dx * dx + dy * dy) ** 0.5 ans = dist...
false
18.75
[ "-import math", "-from itertools import permutations", "+import numpy as np", "-A = [tuple(map(int, input().split())) for _ in range(N)]", "-P = list(permutations(A))", "-ans = 0", "-count = 0", "-for p in P:", "- count += 1", "- for i in range(1, len(p)):", "- ans += math.sqrt((p[i...
false
0.035423
0.184906
0.191574
[ "s323944689", "s890062041" ]
u281303342
p03944
python
s260708750
s287557740
19
17
3,064
3,064
Accepted
Accepted
10.53
W,H,N = list(map(int,input().split())) X,Y,A = [],[],[] for i in range(N): x,y,a = list(map(int,input().split())) X.append(x) Y.append(y) A.append(a) x0,x1,y0,y1 = 0,W,0,H for i in range(N): if A[i]==1: x0 = max(x0,X[i]) elif A[i]==2: x1 = min(x1,X[i]) elif A[i]=...
# python3 (3.4.3) import sys input = sys.stdin.readline # main W,H,N = list(map(int,input().split())) XYA = [list(map(int,input().split())) for _ in range(N)] x_lb,x_ub,y_lb,y_ub = 0,W,0,H for x,y,a in XYA: if a==1: x_lb = max(x_lb,x) elif a==2: x_ub = min(x_ub,x) elif a==3...
19
24
416
448
W, H, N = list(map(int, input().split())) X, Y, A = [], [], [] for i in range(N): x, y, a = list(map(int, input().split())) X.append(x) Y.append(y) A.append(a) x0, x1, y0, y1 = 0, W, 0, H for i in range(N): if A[i] == 1: x0 = max(x0, X[i]) elif A[i] == 2: x1 = min(x1, X[i]) e...
# python3 (3.4.3) import sys input = sys.stdin.readline # main W, H, N = list(map(int, input().split())) XYA = [list(map(int, input().split())) for _ in range(N)] x_lb, x_ub, y_lb, y_ub = 0, W, 0, H for x, y, a in XYA: if a == 1: x_lb = max(x_lb, x) elif a == 2: x_ub = min(x_ub, x) elif a =...
false
20.833333
[ "+# python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# main", "-X, Y, A = [], [], []", "-for i in range(N):", "- x, y, a = list(map(int, input().split()))", "- X.append(x)", "- Y.append(y)", "- A.append(a)", "-x0, x1, y0, y1 = 0, W, 0, H", "-for i in range(N...
false
0.038582
0.045601
0.846077
[ "s260708750", "s287557740" ]
u771804983
p03013
python
s512834722
s523630687
206
184
7,668
8,612
Accepted
Accepted
10.68
N,M=list(map(int,input().split())) dp=[0]*(N+3) dp[0]=1 a=[0]*(N+3) for i in range(M): a[int(eval(input()))]=1 mod=10**9+7 for i in range(N+1): if a[i+1] != 1: dp[i+1]+=dp[i] dp[i+1]%=mod if a[i+2] != 1: dp[i+2]+=dp[i] dp[i+2]%=mod print((dp[N]))
N,M=list(map(int,input().split())) a=[int(eval(input())) for i in range(M)] tf=[0]*(N+1) for i in a: tf[i]=1 dp=[0]*(N+1) dp[0]=1 dp[1]=0 if 1 in a else 1 mod=10**9+7 for i in range(2,N+1): if tf[i] == 1: continue else: dp[i]=(dp[i-1]+dp[i-2])%mod print((dp[N]))
17
17
294
294
N, M = list(map(int, input().split())) dp = [0] * (N + 3) dp[0] = 1 a = [0] * (N + 3) for i in range(M): a[int(eval(input()))] = 1 mod = 10**9 + 7 for i in range(N + 1): if a[i + 1] != 1: dp[i + 1] += dp[i] dp[i + 1] %= mod if a[i + 2] != 1: dp[i + 2] += dp[i] dp[i + 2] %= mo...
N, M = list(map(int, input().split())) a = [int(eval(input())) for i in range(M)] tf = [0] * (N + 1) for i in a: tf[i] = 1 dp = [0] * (N + 1) dp[0] = 1 dp[1] = 0 if 1 in a else 1 mod = 10**9 + 7 for i in range(2, N + 1): if tf[i] == 1: continue else: dp[i] = (dp[i - 1] + dp[i - 2]) % mod pri...
false
0
[ "-dp = [0] * (N + 3)", "+a = [int(eval(input())) for i in range(M)]", "+tf = [0] * (N + 1)", "+for i in a:", "+ tf[i] = 1", "+dp = [0] * (N + 1)", "-a = [0] * (N + 3)", "-for i in range(M):", "- a[int(eval(input()))] = 1", "+dp[1] = 0 if 1 in a else 1", "-for i in range(N + 1):", "- i...
false
0.047537
0.047133
1.008576
[ "s512834722", "s523630687" ]
u498487134
p02899
python
s652405383
s050044131
509
283
74,988
102,188
Accepted
Accepted
44.4
N = int(eval(input())) A = list(map(int,input().split())) B = [[0,0] for _ in range(N)] ans = [0]*N for i in range(N): B[i][0]=A[i] B[i][1]=i+1 B.sort() for i in range(N): ans[i] = B[i][1] print((" ".join(map(str,ans))))
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() A=LI() L=[] for i in range(N): L.append([A[i],i]) L.sort() ...
14
23
240
429
N = int(eval(input())) A = list(map(int, input().split())) B = [[0, 0] for _ in range(N)] ans = [0] * N for i in range(N): B[i][0] = A[i] B[i][1] = i + 1 B.sort() for i in range(N): ans[i] = B[i][1] print((" ".join(map(str, ans))))
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N = I() A = LI() L = [] for i in range(N): L.append([A[i], i]) L.sor...
false
39.130435
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-B = [[0, 0] for _ in range(N)]", "-ans = [0] * N", "-for i in range(N):", "- B[i][0] = A[i]", "- B[i][1] = i + 1", "-B.sort()", "-for i in range(N):", "- ans[i] = B[i][1]", "-print((\" \".join(map(str, ans))))", "+im...
false
0.037715
0.040377
0.934068
[ "s652405383", "s050044131" ]
u022407960
p02272
python
s587660246
s760401451
4,320
3,740
67,748
67,856
Accepted
Accepted
13.43
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def merge(A, left, mid, right): global count L = A[left:mid] + [1e9] R = A[mid:right] + [1e9] i, j = 0, 0 for k in range(left, right): count += 1 if L[i] <= R[j]: A[k] = L[i] i +=...
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def merge(A, left, mid, right): global count L = A[left:mid] + [1e9] R = A[mid:right] + [1e9] i, j = 0, 0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: ...
43
42
898
906
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def merge(A, left, mid, right): global count L = A[left:mid] + [1e9] R = A[mid:right] + [1e9] i, j = 0, 0 for k in range(left, right): count += 1 if L[i] <= R[j]: A[k] = L[i] i += 1 else: ...
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def merge(A, left, mid, right): global count L = A[left:mid] + [1e9] R = A[mid:right] + [1e9] i, j = 0, 0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] ...
false
2.325581
[ "- count += 1", "+ count += right - left", "+ return A", "- merge_sort(A=array, left=0, right=array_length)", "- print((*array))", "+ print((*merge_sort(A=array, left=0, right=array_length)))" ]
false
0.048047
0.165412
0.290465
[ "s587660246", "s760401451" ]
u197955752
p03283
python
s107696943
s177577165
589
333
23,800
22,668
Accepted
Accepted
43.46
import sys input = sys.stdin.readline N, M, Q = [int(x) for x in input().split()] L = [0] * M R = [0] * M p = [0] * Q q = [0] * Q for i in range(M): L[i], R[i] = [int(x) for x in input().split()] for j in range(Q): p[j], q[j] = [int(x) for x in input().split()] train = [[0 for i in range(N + 1)] ...
# 20-08-06再トライ import sys input = sys.stdin.readline from itertools import accumulate N, M, Q = [int(x) for x in input().split()] train = [[0 for _ in range(N + 1)] for _ in range(N + 1)] for i in range(M): L, R = [int(x) for x in input().split()] train[L][R] += 1 cum = [list(accumulate(train[i])) ...
24
19
620
538
import sys input = sys.stdin.readline N, M, Q = [int(x) for x in input().split()] L = [0] * M R = [0] * M p = [0] * Q q = [0] * Q for i in range(M): L[i], R[i] = [int(x) for x in input().split()] for j in range(Q): p[j], q[j] = [int(x) for x in input().split()] train = [[0 for i in range(N + 1)] for _ in range...
# 20-08-06再トライ import sys input = sys.stdin.readline from itertools import accumulate N, M, Q = [int(x) for x in input().split()] train = [[0 for _ in range(N + 1)] for _ in range(N + 1)] for i in range(M): L, R = [int(x) for x in input().split()] train[L][R] += 1 cum = [list(accumulate(train[i])) for i in ra...
false
20.833333
[ "+# 20-08-06再トライ", "+from itertools import accumulate", "+", "-L = [0] * M", "-R = [0] * M", "-p = [0] * Q", "-q = [0] * Q", "+train = [[0 for _ in range(N + 1)] for _ in range(N + 1)]", "- L[i], R[i] = [int(x) for x in input().split()]", "-for j in range(Q):", "- p[j], q[j] = [int(x) for ...
false
0.03987
0.03695
1.079008
[ "s107696943", "s177577165" ]
u163703551
p03804
python
s431113981
s698786951
24
18
3,064
3,064
Accepted
Accepted
25
s = eval(input()) l = s.split() N = int(l[0]) M = int(l[1]) A = list() for i in range(N): s = eval(input()) A.append(s) B = list() for j in range(M): s = eval(input()) B.append(s) def g(n, m, a, b, i, j): for k in range(m): for l in range(m): if a[i + k][j ...
import sys # sys.stdin = open('b1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) N, M = read_int_list() A = [read_str() for i in r...
33
42
568
732
s = eval(input()) l = s.split() N = int(l[0]) M = int(l[1]) A = list() for i in range(N): s = eval(input()) A.append(s) B = list() for j in range(M): s = eval(input()) B.append(s) def g(n, m, a, b, i, j): for k in range(m): for l in range(m): if a[i + k][j + l] != b[k][l]: ...
import sys # sys.stdin = open('b1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def read_str(): return eval(input()) N, M = read_int_list() A = [read_str() for i in range(N)] B = [read_str()...
false
21.428571
[ "-s = eval(input())", "-l = s.split()", "-N = int(l[0])", "-M = int(l[1])", "-A = list()", "-for i in range(N):", "- s = eval(input())", "- A.append(s)", "-B = list()", "-for j in range(M):", "- s = eval(input())", "- B.append(s)", "+import sys", "+", "+# sys.stdin = open('b1...
false
0.036533
0.037409
0.976564
[ "s431113981", "s698786951" ]
u106118504
p02748
python
s281496596
s124171951
348
278
42,624
24,784
Accepted
Accepted
20.11
A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) X = [list(map(int, input().split())) for i in range(M)] ans = [min(a) + min(b)] for x in X: a_idx, b_index, c = x ans.append(a[a_idx - 1] + b[b_index - 1] - c) print((min(ans)))
a,b,m = list(map(int,input().split())) a_li = list(map(int,input().split())) b_li = list(map(int,input().split())) cost = min(a_li) + min(b_li) for i in range(m): x,y,c = list(map(int,input().split())) price = a_li[x-1] + b_li[y-1] - c if price < cost: cost = price print(cost)
11
10
309
285
A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) X = [list(map(int, input().split())) for i in range(M)] ans = [min(a) + min(b)] for x in X: a_idx, b_index, c = x ans.append(a[a_idx - 1] + b[b_index - 1] - c) print((min(ans)))
a, b, m = list(map(int, input().split())) a_li = list(map(int, input().split())) b_li = list(map(int, input().split())) cost = min(a_li) + min(b_li) for i in range(m): x, y, c = list(map(int, input().split())) price = a_li[x - 1] + b_li[y - 1] - c if price < cost: cost = price print(cost)
false
9.090909
[ "-A, B, M = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-b = list(map(int, input().split()))", "-X = [list(map(int, input().split())) for i in range(M)]", "-ans = [min(a) + min(b)]", "-for x in X:", "- a_idx, b_index, c = x", "- ans.append(a[a_idx - 1] + b[b_index ...
false
0.066464
0.04091
1.624647
[ "s281496596", "s124171951" ]
u510829608
p02315
python
s761355971
s840995380
1,100
980
26,084
26,848
Accepted
Accepted
10.91
N, W = list(map(int, input().split())) v = [0]* N w = [0]* N dp = [[-1 for i in range(W+1)] for j in range(N+1)] for i in range(N): v[i],w[i] = list(map(int, input().split())) def rec(i,j): if dp[i][j] != -1: return dp[i][j] if i == N: res = 0 elif j < w[i]: ...
N, W = list(map(int, input().split())) v = [0]* N w = [0]* N dp = [[0 for i in range(W+1)] for j in range(N+1)] for k in range(N): v[k], w[k] = list(map(int, input().split())) for i in range(N-1,-1,-1): for j in range(W+1): if j < w[i]: dp[i][j] = dp[i+1][j] else: ...
26
18
476
387
N, W = list(map(int, input().split())) v = [0] * N w = [0] * N dp = [[-1 for i in range(W + 1)] for j in range(N + 1)] for i in range(N): v[i], w[i] = list(map(int, input().split())) def rec(i, j): if dp[i][j] != -1: return dp[i][j] if i == N: res = 0 elif j < w[i]: res = rec(i...
N, W = list(map(int, input().split())) v = [0] * N w = [0] * N dp = [[0 for i in range(W + 1)] for j in range(N + 1)] for k in range(N): v[k], w[k] = list(map(int, input().split())) for i in range(N - 1, -1, -1): for j in range(W + 1): if j < w[i]: dp[i][j] = dp[i + 1][j] else: ...
false
30.769231
[ "-dp = [[-1 for i in range(W + 1)] for j in range(N + 1)]", "-for i in range(N):", "- v[i], w[i] = list(map(int, input().split()))", "-", "-", "-def rec(i, j):", "- if dp[i][j] != -1:", "- return dp[i][j]", "- if i == N:", "- res = 0", "- elif j < w[i]:", "- re...
false
0.038059
0.042543
0.89459
[ "s761355971", "s840995380" ]
u706929073
p02947
python
s946105472
s919394186
535
473
25,420
10,988
Accepted
Accepted
11.59
n = int(eval(input())) s = [sorted(eval(input())) for _ in range(n)] sorted_s = sorted(s) num = 0 num_same = 1 prev = sorted_s[0] for i in range(1, len(sorted_s)): if prev != sorted_s[i]: num += int(num_same * (num_same - 1) / 2) num_same = 1 prev = sorted_s[i] else: ...
n = int(eval(input())) s = ["".join(sorted(list(eval(input())))) for _ in range(n)] s.sort() def num_cmb(a, b): enum = 1 denom = 1 for i in range(b): enum *= (a - i) denom *= (b - i) return enum // denom sum = 0 count = 1 prev = s[0] for s_i in s[1::]: if prev =...
16
27
379
476
n = int(eval(input())) s = [sorted(eval(input())) for _ in range(n)] sorted_s = sorted(s) num = 0 num_same = 1 prev = sorted_s[0] for i in range(1, len(sorted_s)): if prev != sorted_s[i]: num += int(num_same * (num_same - 1) / 2) num_same = 1 prev = sorted_s[i] else: num_same += ...
n = int(eval(input())) s = ["".join(sorted(list(eval(input())))) for _ in range(n)] s.sort() def num_cmb(a, b): enum = 1 denom = 1 for i in range(b): enum *= a - i denom *= b - i return enum // denom sum = 0 count = 1 prev = s[0] for s_i in s[1::]: if prev == s_i: count +...
false
40.740741
[ "-s = [sorted(eval(input())) for _ in range(n)]", "-sorted_s = sorted(s)", "-num = 0", "-num_same = 1", "-prev = sorted_s[0]", "-for i in range(1, len(sorted_s)):", "- if prev != sorted_s[i]:", "- num += int(num_same * (num_same - 1) / 2)", "- num_same = 1", "- prev = sorte...
false
0.037836
0.040456
0.935244
[ "s946105472", "s919394186" ]
u367130284
p03722
python
s381424165
s956879650
756
373
76,504
45,660
Accepted
Accepted
50.66
#import numpy as np #from numpy import* #from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall #from scipy.sparse import csr_matrix from collections import* #defaultdict Counter deque appendleft from fractions import gcd from functools import* #reduce from iter...
import sys input=sys.stdin.readline #危険!基本オフにしろ! def BELLMANFORD(point,d,n): cost = [-float("inf")for node in range(n+1)] preference = [None for node in range(n+1)] #最適路のこと cost[point]= 0 for i in range(n-1): #経路の長さは最大n-1であるため for no...
59
50
1,953
1,352
# import numpy as np # from numpy import* # from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall # from scipy.sparse import csr_matrix from collections import * # defaultdict Counter deque appendleft from fractions import gcd from functools import * # reduce from ite...
import sys input = sys.stdin.readline # 危険!基本オフにしろ! def BELLMANFORD(point, d, n): cost = [-float("inf") for node in range(n + 1)] preference = [None for node in range(n + 1)] # 最適路のこと cost[point] = 0 for i in range(n - 1): # 経路の長さは最大n-1であるため for now, lis in list(d.items()): for...
false
15.254237
[ "-# import numpy as np", "-# from numpy import*", "-# from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall", "-# from scipy.sparse import csr_matrix", "-from collections import * # defaultdict Counter deque appendleft", "-from fractions import gcd", "-...
false
0.038255
0.112925
0.33876
[ "s381424165", "s956879650" ]
u434329006
p03634
python
s903032114
s555243134
1,426
1,214
51,840
78,052
Accepted
Accepted
14.87
N = int(eval(input())) route = [{} for _ in range(N)] dist = [-1] * N for i in range(N - 1): a, b, d = list(map(int, input().split())) route[a-1][b-1] = d route[b-1][a-1] = d Q, K = list(map(int, input().split())) dist[K-1] = 0 dfs_stack = [K-1] while dfs_stack: s = dfs_stack.pop() for...
from collections import deque n = int(eval(input())) path = {} for i in range(n-1): a, b, c = list(map(int, input().split())) if not a in list(path.keys()): path[a] = [(b, c)] else: path[a].append((b, c)) if not b in list(path.keys()): path[b] = [(a, c)] ...
21
31
547
758
N = int(eval(input())) route = [{} for _ in range(N)] dist = [-1] * N for i in range(N - 1): a, b, d = list(map(int, input().split())) route[a - 1][b - 1] = d route[b - 1][a - 1] = d Q, K = list(map(int, input().split())) dist[K - 1] = 0 dfs_stack = [K - 1] while dfs_stack: s = dfs_stack.pop() for t...
from collections import deque n = int(eval(input())) path = {} for i in range(n - 1): a, b, c = list(map(int, input().split())) if not a in list(path.keys()): path[a] = [(b, c)] else: path[a].append((b, c)) if not b in list(path.keys()): path[b] = [(a, c)] else: path...
false
32.258065
[ "-N = int(eval(input()))", "-route = [{} for _ in range(N)]", "-dist = [-1] * N", "-for i in range(N - 1):", "- a, b, d = list(map(int, input().split()))", "- route[a - 1][b - 1] = d", "- route[b - 1][a - 1] = d", "-Q, K = list(map(int, input().split()))", "-dist[K - 1] = 0", "-dfs_stack ...
false
0.073933
0.074106
0.997668
[ "s903032114", "s555243134" ]
u913662443
p02813
python
s436428347
s308154165
134
17
4,728
3,064
Accepted
Accepted
87.31
from itertools import permutations stdin = open(0).read().split('\n') N = int(stdin[0]) P=int("".join(list(stdin[1].split()))) Q=int("".join(list(stdin[2].split()))) l = [] for pp in permutations(list(range(1, N+1))): ll = [] for _p in pp: ll.append(str(_p)) l.append(int("".join(ll))) ...
def perm(N): if N==0:return 0 a=1 for i in range(1,N+1): a*=i return a def getposi(P): N=len(P) l=list(range(1,N+1)) a = 0 for i,num in enumerate(P): a+=perm(N-i-1)*l.index(num) l.remove(num) return a stdin = open(0).read().split('\n') N = i...
16
25
364
455
from itertools import permutations stdin = open(0).read().split("\n") N = int(stdin[0]) P = int("".join(list(stdin[1].split()))) Q = int("".join(list(stdin[2].split()))) l = [] for pp in permutations(list(range(1, N + 1))): ll = [] for _p in pp: ll.append(str(_p)) l.append(int("".join(ll))) a = l.i...
def perm(N): if N == 0: return 0 a = 1 for i in range(1, N + 1): a *= i return a def getposi(P): N = len(P) l = list(range(1, N + 1)) a = 0 for i, num in enumerate(P): a += perm(N - i - 1) * l.index(num) l.remove(num) return a stdin = open(0).read(...
false
36
[ "-from itertools import permutations", "+def perm(N):", "+ if N == 0:", "+ return 0", "+ a = 1", "+ for i in range(1, N + 1):", "+ a *= i", "+ return a", "+", "+", "+def getposi(P):", "+ N = len(P)", "+ l = list(range(1, N + 1))", "+ a = 0", "+ for i...
false
0.085156
0.084407
1.008873
[ "s436428347", "s308154165" ]
u969190727
p02744
python
s480983741
s719363921
459
153
56,668
12,976
Accepted
Accepted
66.67
import sys input=lambda: sys.stdin.readline().rstrip() n=int(eval(input())) def f(x): A=[] for _ in range(n): A.append(x%10) x//=10 return A[::-1] def g(X): cur=X[0] ret=-1 for i in range(1,n): if X[i]+1<=cur+1 and X[i]+1<=i: ret=i cur=max(cur,X[i]) return ret An...
import sys input=lambda: sys.stdin.readline().rstrip() n=int(eval(input())) A=[chr(97+int(i)) for i in range(n)] Ans=["a"] if n>=2: for _ in range(n-1): Ans2=[] for a in Ans: s=set() for aa in a: s.add(aa) ss=len(s) for i in range(ss+1): Ans2.append(a+A[...
43
20
610
374
import sys input = lambda: sys.stdin.readline().rstrip() n = int(eval(input())) def f(x): A = [] for _ in range(n): A.append(x % 10) x //= 10 return A[::-1] def g(X): cur = X[0] ret = -1 for i in range(1, n): if X[i] + 1 <= cur + 1 and X[i] + 1 <= i: ret ...
import sys input = lambda: sys.stdin.readline().rstrip() n = int(eval(input())) A = [chr(97 + int(i)) for i in range(n)] Ans = ["a"] if n >= 2: for _ in range(n - 1): Ans2 = [] for a in Ans: s = set() for aa in a: s.add(aa) ss = len(s) ...
false
53.488372
[ "-", "-", "-def f(x):", "- A = []", "- for _ in range(n):", "- A.append(x % 10)", "- x //= 10", "- return A[::-1]", "-", "-", "-def g(X):", "- cur = X[0]", "- ret = -1", "- for i in range(1, n):", "- if X[i] + 1 <= cur + 1 and X[i] + 1 <= i:", "- ...
false
0.102158
0.058957
1.732748
[ "s480983741", "s719363921" ]
u141610915
p03716
python
s832082719
s095910592
710
273
98,092
113,904
Accepted
Accepted
61.55
import sys import heapq input = sys.stdin.buffer.readline def minus(x): return -x N = int(eval(input())) a = list(map(int, input().split())) dpl = [0] * (N + 1) dpr = [0] * (N + 1) l = a[: N] m = a[N: 2 * N] r = list(map(minus, a[2 * N: ])) heapq.heapify(l) heapq.heapify(r) dpl[0] = sum(l) dpr[0] = sum...
import sys import heapq hpush = heapq.heappush hpop = heapq.heappop input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) h = [] ltable = [0] * (N + 1) for i in range(N): ltable[0] += a[i] hpush(h, a[i]) for i in range(N): hpush(h, a[N + i]) ltable[i + 1] = ltable[i...
26
29
605
655
import sys import heapq input = sys.stdin.buffer.readline def minus(x): return -x N = int(eval(input())) a = list(map(int, input().split())) dpl = [0] * (N + 1) dpr = [0] * (N + 1) l = a[:N] m = a[N : 2 * N] r = list(map(minus, a[2 * N :])) heapq.heapify(l) heapq.heapify(r) dpl[0] = sum(l) dpr[0] = sum(r) for ...
import sys import heapq hpush = heapq.heappush hpop = heapq.heappop input = sys.stdin.readline N = int(eval(input())) a = list(map(int, input().split())) h = [] ltable = [0] * (N + 1) for i in range(N): ltable[0] += a[i] hpush(h, a[i]) for i in range(N): hpush(h, a[N + i]) ltable[i + 1] = ltable[i] + a...
false
10.344828
[ "-input = sys.stdin.buffer.readline", "-", "-", "-def minus(x):", "- return -x", "-", "-", "+hpush = heapq.heappush", "+hpop = heapq.heappop", "+input = sys.stdin.readline", "-dpl = [0] * (N + 1)", "-dpr = [0] * (N + 1)", "-l = a[:N]", "-m = a[N : 2 * N]", "-r = list(map(minus, a[2 * ...
false
0.03894
0.085808
0.453799
[ "s832082719", "s095910592" ]
u745087332
p03287
python
s408220349
s067374321
115
91
16,300
17,284
Accepted
Accepted
20.87
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() A = inpl() S = [0] for i in range(N): S.append((S[-1] + A[i]) % M) del S[0] D = dict() D[0] = 0 for i in range(N): if S[i] in D: D[S[i]] += 1 else: D[S[i]] = 1 ans = 0 for num in D: ...
# coding:utf-8 import sys from collections import Counter input = sys.stdin.readline def inpl(): return list(map(int, input().split())) # Counterを使ったD - Candy Distributionの解法 def solve(N, M, A): # 累積和(mod M)を求める S = [0] for i in range(N): S.append((S[-1] + A[i]) % M) del...
31
37
450
634
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() A = inpl() S = [0] for i in range(N): S.append((S[-1] + A[i]) % M) del S[0] D = dict() D[0] = 0 for i in range(N): if S[i] in D: D[S[i]] += 1 else: D[S[i]] = 1 ans = 0 for num in D: tmp = D[num] # c...
# coding:utf-8 import sys from collections import Counter input = sys.stdin.readline def inpl(): return list(map(int, input().split())) # Counterを使ったD - Candy Distributionの解法 def solve(N, M, A): # 累積和(mod M)を求める S = [0] for i in range(N): S.append((S[-1] + A[i]) % M) del S[0] # 各要素の...
false
16.216216
[ "+import sys", "+from collections import Counter", "+", "+input = sys.stdin.readline", "+", "+", "+# Counterを使ったD - Candy Distributionの解法", "+def solve(N, M, A):", "+ # 累積和(mod M)を求める", "+ S = [0]", "+ for i in range(N):", "+ S.append((S[-1] + A[i]) % M)", "+ del S[0]", ...
false
0.085092
0.079439
1.071161
[ "s408220349", "s067374321" ]
u296518383
p02948
python
s386593554
s862011675
1,009
411
74,200
31,656
Accepted
Accepted
59.27
import heapq N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort() #print("AB:", AB) H = [] iab = 0 answer = 0 for i in range(M + 1): while iab <= N - 1 and AB[iab][0] <= i: heapq.heappush(H, -AB[iab][1]) iab += 1 if len(H): answer +...
import sys input = sys.stdin.buffer.readline from heapq import heappush, heappop N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort() h = [] index = 0 answer = 0 for i in range(1, M + 1): while index < N: a, b = AB[index] if a == i: ...
18
24
348
430
import heapq N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort() # print("AB:", AB) H = [] iab = 0 answer = 0 for i in range(M + 1): while iab <= N - 1 and AB[iab][0] <= i: heapq.heappush(H, -AB[iab][1]) iab += 1 if len(H): answer +=...
import sys input = sys.stdin.buffer.readline from heapq import heappush, heappop N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort() h = [] index = 0 answer = 0 for i in range(1, M + 1): while index < N: a, b = AB[index] if a == i: ...
false
25
[ "-import heapq", "+import sys", "+", "+input = sys.stdin.buffer.readline", "+from heapq import heappush, heappop", "-# print(\"AB:\", AB)", "-H = []", "-iab = 0", "+h = []", "+index = 0", "-for i in range(M + 1):", "- while iab <= N - 1 and AB[iab][0] <= i:", "- heapq.heappush(H, -...
false
0.14007
0.147587
0.94907
[ "s386593554", "s862011675" ]
u934442292
p03031
python
s687697083
s251886312
49
28
3,064
3,064
Accepted
Accepted
42.86
N, M = list(map(int, input().split())) k = [0] * M s = [0] * M for i in range(M): l = [int(j) for j in input().split()] k[i], s[i] = l[0], l[1:] p = [int(i) for i in input().split()] res = 0 for bit in range(2**N): sw = [0] * N for i in range(N): sw[i] = (bit >> i) & 1 are_shining = True ...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) k = [None] * M s = [None] * M for i in range(M): line = tuple(map(int, input().split())) k[i], s[i] = line[0], line[1:] p = tuple(map(int, input().split())) ans = 0 for...
25
39
529
869
N, M = list(map(int, input().split())) k = [0] * M s = [0] * M for i in range(M): l = [int(j) for j in input().split()] k[i], s[i] = l[0], l[1:] p = [int(i) for i in input().split()] res = 0 for bit in range(2**N): sw = [0] * N for i in range(N): sw[i] = (bit >> i) & 1 are_shining = True ...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) k = [None] * M s = [None] * M for i in range(M): line = tuple(map(int, input().split())) k[i], s[i] = line[0], line[1:] p = tuple(map(int, input().split())) ans = 0 for bit in range(2*...
false
35.897436
[ "-N, M = list(map(int, input().split()))", "-k = [0] * M", "-s = [0] * M", "-for i in range(M):", "- l = [int(j) for j in input().split()]", "- k[i], s[i] = l[0], l[1:]", "-p = [int(i) for i in input().split()]", "-res = 0", "-for bit in range(2**N):", "- sw = [0] * N", "- for i in r...
false
0.040042
0.081393
0.491965
[ "s687697083", "s251886312" ]
u380524497
p02762
python
s458510145
s213560781
669
575
34,240
40,168
Accepted
Accepted
14.05
def main(): import sys buf = sys.stdin.buffer class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size def get_root(self, node): parent = self.parent[node] if parent == -1: root =...
def main(): import sys buf = sys.stdin.buffer class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size def get_root(self, node): parent = self.parent[node] if parent == -1: root =...
66
58
1,950
1,782
def main(): import sys buf = sys.stdin.buffer class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size def get_root(self, node): parent = self.parent[node] if parent == -1: root = node ...
def main(): import sys buf = sys.stdin.buffer class UnionFind: def __init__(self, size): self.parent = [-1] * size self.rank = [1] * size def get_root(self, node): parent = self.parent[node] if parent == -1: root = node ...
false
12.121212
[ "-", "- def gen():", "- for num in buf.read().split():", "- yield int(num)", "-", "- generator = gen()", "- for _ in range(m):", "- a, b = generator.__next__(), generator.__next__()", "+ query = list(map(int, buf.read().split()))", "+ follows = query[: 2 * m...
false
0.081974
0.049393
1.65963
[ "s458510145", "s213560781" ]
u690536347
p03209
python
s766870137
s699288409
24
17
3,572
3,064
Accepted
Accepted
29.17
from functools import lru_cache @lru_cache() def f(n): if n==0: return 1 return 2*f(n-1)+1 @lru_cache() def g(n): if n==0: return 1 return 2*g(n-1)+3 N, X = list(map(int, input().split())) total = [g(i) for i in range(N+1)] p = [f(i) for i in range(N+1)] ans = 0 de...
N, X = list(map(int, input().split())) q = [1]*(N+1) p = [1]*(N+1) for i in range(1, N+1): q[i] = 2*q[i-1]+3 p[i] = 2*p[i-1]+1 ans = 0 def search(x, n): global ans if n==0: if x: ans += 1 return if x==0: return a = q[n-1] + 2 b = p[...
37
30
661
484
from functools import lru_cache @lru_cache() def f(n): if n == 0: return 1 return 2 * f(n - 1) + 1 @lru_cache() def g(n): if n == 0: return 1 return 2 * g(n - 1) + 3 N, X = list(map(int, input().split())) total = [g(i) for i in range(N + 1)] p = [f(i) for i in range(N + 1)] ans = 0...
N, X = list(map(int, input().split())) q = [1] * (N + 1) p = [1] * (N + 1) for i in range(1, N + 1): q[i] = 2 * q[i - 1] + 3 p[i] = 2 * p[i - 1] + 1 ans = 0 def search(x, n): global ans if n == 0: if x: ans += 1 return if x == 0: return a = q[n - 1] + 2 ...
false
18.918919
[ "-from functools import lru_cache", "-", "-", "-@lru_cache()", "-def f(n):", "- if n == 0:", "- return 1", "- return 2 * f(n - 1) + 1", "-", "-", "-@lru_cache()", "-def g(n):", "- if n == 0:", "- return 1", "- return 2 * g(n - 1) + 3", "-", "-", "-total = ...
false
0.082391
0.061192
1.346425
[ "s766870137", "s699288409" ]
u681444474
p02767
python
s657467493
s919972991
171
21
39,152
3,064
Accepted
Accepted
87.72
# coding: utf-8 N=int(eval(input())) X=list(map(int,input().split())) cost=0 for i in range(N): cost+=(X[i]-1)**2 for i in range(2,101): cost1=0 for j in range(N): cost1+=(X[j]-i)**2 if cost1<cost: cost=cost1 print(cost)
# coding: utf-8 N = int(eval(input())) X = list(map(int,input().split())) judge = float('inf') for i in range(1,101): p = i tmp = 0 for j in range(N): tmp += (X[j]-p)**2 if tmp < judge: judge = tmp ans = tmp print(ans)
14
15
264
276
# coding: utf-8 N = int(eval(input())) X = list(map(int, input().split())) cost = 0 for i in range(N): cost += (X[i] - 1) ** 2 for i in range(2, 101): cost1 = 0 for j in range(N): cost1 += (X[j] - i) ** 2 if cost1 < cost: cost = cost1 print(cost)
# coding: utf-8 N = int(eval(input())) X = list(map(int, input().split())) judge = float("inf") for i in range(1, 101): p = i tmp = 0 for j in range(N): tmp += (X[j] - p) ** 2 if tmp < judge: judge = tmp ans = tmp print(ans)
false
6.666667
[ "-cost = 0", "-for i in range(N):", "- cost += (X[i] - 1) ** 2", "-for i in range(2, 101):", "- cost1 = 0", "+judge = float(\"inf\")", "+for i in range(1, 101):", "+ p = i", "+ tmp = 0", "- cost1 += (X[j] - i) ** 2", "- if cost1 < cost:", "- cost = cost1", "-prin...
false
0.144448
0.032359
4.463845
[ "s657467493", "s919972991" ]
u067299340
p00008
python
s451810015
s912704014
170
140
5,496
4,196
Accepted
Accepted
17.65
import sys,itertools k=list(range(10)) for l in sys.stdin:print([sum(x)for x in list(itertools.product(k,k,k,k))].count(int(l)))
import sys def f(s,d,g,c): if d>3:return c for n in range(10): if s+n==g:return c+1 elif s+n>g:return c else:c=f(s+n,d+1,g,c) return c for l in sys.stdin: print(f(0,0,int(l),0))
3
10
122
195
import sys, itertools k = list(range(10)) for l in sys.stdin: print([sum(x) for x in list(itertools.product(k, k, k, k))].count(int(l)))
import sys def f(s, d, g, c): if d > 3: return c for n in range(10): if s + n == g: return c + 1 elif s + n > g: return c else: c = f(s + n, d + 1, g, c) return c for l in sys.stdin: print(f(0, 0, int(l), 0))
false
70
[ "-import sys, itertools", "+import sys", "-k = list(range(10))", "+", "+def f(s, d, g, c):", "+ if d > 3:", "+ return c", "+ for n in range(10):", "+ if s + n == g:", "+ return c + 1", "+ elif s + n > g:", "+ return c", "+ else:", "+ ...
false
0.038138
0.036528
1.04407
[ "s451810015", "s912704014" ]
u941753895
p04030
python
s920584535
s876004316
20
18
2,940
2,940
Accepted
Accepted
10
s=list(eval(input())) a='' for i in s: if i=='0' or i=='1': a+=i else: if len(a)!=0: a=a[:len(a)-1] print(a)
# 入力 s=eval(input()) a='' for x in s: if x=='0': a+='0' elif x=='1': a+='1' else: # 文字列が空でない場合、末尾を削除 if a!='': a=a[:-1] # 出力 print(a)
9
16
128
172
s = list(eval(input())) a = "" for i in s: if i == "0" or i == "1": a += i else: if len(a) != 0: a = a[: len(a) - 1] print(a)
# 入力 s = eval(input()) a = "" for x in s: if x == "0": a += "0" elif x == "1": a += "1" else: # 文字列が空でない場合、末尾を削除 if a != "": a = a[:-1] # 出力 print(a)
false
43.75
[ "-s = list(eval(input()))", "+# 入力", "+s = eval(input())", "-for i in s:", "- if i == \"0\" or i == \"1\":", "- a += i", "+for x in s:", "+ if x == \"0\":", "+ a += \"0\"", "+ elif x == \"1\":", "+ a += \"1\"", "- if len(a) != 0:", "- a = a[: l...
false
0.045271
0.044342
1.020953
[ "s920584535", "s876004316" ]
u573754721
p02832
python
s637202930
s906026349
100
91
26,268
26,140
Accepted
Accepted
9
n=int(eval(input())) *A,=list(map(int,input().split())) if 1 not in A: print((-1)) exit() c=1 for i in range(n): if c==A[i]: c+=1 print((len(A)-(c-1)))
n=int(eval(input())) A=list(map(int,input().split())) if 1 not in A: print((-1)) exit() bef=1 ans=0 for i in A: if i==bef: bef+=1 else: ans+=1 print(ans)
12
15
178
201
n = int(eval(input())) (*A,) = list(map(int, input().split())) if 1 not in A: print((-1)) exit() c = 1 for i in range(n): if c == A[i]: c += 1 print((len(A) - (c - 1)))
n = int(eval(input())) A = list(map(int, input().split())) if 1 not in A: print((-1)) exit() bef = 1 ans = 0 for i in A: if i == bef: bef += 1 else: ans += 1 print(ans)
false
20
[ "-(*A,) = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "-c = 1", "-for i in range(n):", "- if c == A[i]:", "- c += 1", "-print((len(A) - (c - 1)))", "+bef = 1", "+ans = 0", "+for i in A:", "+ if i == bef:", "+ bef += 1", "+ else:", "+ ...
false
0.046386
0.04426
1.048044
[ "s637202930", "s906026349" ]
u761320129
p03714
python
s988546811
s242097207
1,462
346
45,172
37,212
Accepted
Accepted
76.33
import heapq def solve(): n = int(input()) ar = input().split(' ') iar = [int(s) for s in ar] early = iar[:n] mid = iar[n:-n] late = iar[-n:] heapq.heapify(early) tmpsum = sum(early) esums = [tmpsum] for i in range(n): heapq.heappush(early, mid[i]) emin = heapq.heappop(e...
import heapq N = int(eval(input())) src = list(map(int,input().split())) lsum = sum(src[:N]) lmem = [lsum] lq = src[:N][:] heapq.heapify(lq) for a in src[N:2*N]: if a <= lq[0]: lmem.append(lmem[-1]) else: lsum += a - heapq.heappop(lq) heapq.heappush(lq, a) lmem.app...
41
32
968
693
import heapq def solve(): n = int(input()) ar = input().split(" ") iar = [int(s) for s in ar] early = iar[:n] mid = iar[n:-n] late = iar[-n:] heapq.heapify(early) tmpsum = sum(early) esums = [tmpsum] for i in range(n): heapq.heappush(early, mid[i]) emin = heapq....
import heapq N = int(eval(input())) src = list(map(int, input().split())) lsum = sum(src[:N]) lmem = [lsum] lq = src[:N][:] heapq.heapify(lq) for a in src[N : 2 * N]: if a <= lq[0]: lmem.append(lmem[-1]) else: lsum += a - heapq.heappop(lq) heapq.heappush(lq, a) lmem.append(lsum)...
false
21.95122
[ "-", "-def solve():", "- n = int(input())", "- ar = input().split(\" \")", "- iar = [int(s) for s in ar]", "- early = iar[:n]", "- mid = iar[n:-n]", "- late = iar[-n:]", "- heapq.heapify(early)", "- tmpsum = sum(early)", "- esums = [tmpsum]", "- for i in range(n):...
false
0.035091
0.127918
0.274323
[ "s988546811", "s242097207" ]
u796942881
p03457
python
s946944505
s594316376
223
197
21,080
21,080
Accepted
Accepted
11.66
from sys import stdin input = stdin.readline N = int(eval(input())) txy = [[int(j) for j in input().split()] for i in range(N)] def main(): pt = 0 px = 0 py = 0 flg = False for t, x, y in txy: # 到達 あるいは 通過 if abs(x - px) + abs(y - py) <= t - pt: ...
from sys import stdin input = stdin.readline N = int(eval(input())) txy = [[int(j) for j in input().split()] for i in range(N)] def main(): pt = 0 px = 0 py = 0 flg = False for t, x, y in txy: d = abs(x - px) + abs(y - py) dt = t - pt # 到達 あるいは 通過 ...
38
40
684
684
from sys import stdin input = stdin.readline N = int(eval(input())) txy = [[int(j) for j in input().split()] for i in range(N)] def main(): pt = 0 px = 0 py = 0 flg = False for t, x, y in txy: # 到達 あるいは 通過 if abs(x - px) + abs(y - py) <= t - pt: # 距離と時間の偶奇が一致しない 戻れない ...
from sys import stdin input = stdin.readline N = int(eval(input())) txy = [[int(j) for j in input().split()] for i in range(N)] def main(): pt = 0 px = 0 py = 0 flg = False for t, x, y in txy: d = abs(x - px) + abs(y - py) dt = t - pt # 到達 あるいは 通過 if d <= dt: ...
false
5
[ "+ d = abs(x - px) + abs(y - py)", "+ dt = t - pt", "- if abs(x - px) + abs(y - py) <= t - pt:", "+ if d <= dt:", "- if (abs(x - px) + abs(y - py)) % 2 != (t - pt) % 2:", "+ if d % 2 != dt % 2:" ]
false
0.281672
0.045145
6.239331
[ "s946944505", "s594316376" ]
u952164537
p02887
python
s931288866
s538229622
33
28
3,956
3,956
Accepted
Accepted
15.15
N = int(eval(input())) r = 0 S = '' for s in list(eval(input())): if S != s: r += 1 S = s print(r)
def func(): N = int(eval(input())) r = 0 S = '' for s in list(eval(input())): if S != s: r += 1 S = s return r print((func()))
8
10
113
173
N = int(eval(input())) r = 0 S = "" for s in list(eval(input())): if S != s: r += 1 S = s print(r)
def func(): N = int(eval(input())) r = 0 S = "" for s in list(eval(input())): if S != s: r += 1 S = s return r print((func()))
false
20
[ "-N = int(eval(input()))", "-r = 0", "-S = \"\"", "-for s in list(eval(input())):", "- if S != s:", "- r += 1", "- S = s", "-print(r)", "+def func():", "+ N = int(eval(input()))", "+ r = 0", "+ S = \"\"", "+ for s in list(eval(input())):", "+ if S != s:"...
false
0.070919
0.119557
0.593181
[ "s931288866", "s538229622" ]
u216928054
p02574
python
s299015259
s786829973
870
801
177,876
188,584
Accepted
Accepted
7.93
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10 ** 9 + 1 # sys.maxsize # float("inf") MOD = 10 ** 9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(N, AS): num_division = 0 maxAS = max(AS) eratree = [0] * (maxAS + 10) for p in range(2, maxAS + 1): ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10 ** 9 + 1 # sys.maxsize # float("inf") MOD = 10 ** 9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(N, AS): num_division = 0 maxAS = max(AS) eratree = [0] * (maxAS + 10) for p in range(2, maxAS + 1): ...
122
123
2,215
2,243
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10**9 + 1 # sys.maxsize # float("inf") MOD = 10**9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(N, AS): num_division = 0 maxAS = max(AS) eratree = [0] * (maxAS + 10) for p in range(2, maxAS + 1): if eratree...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) INF = 10**9 + 1 # sys.maxsize # float("inf") MOD = 10**9 + 7 def debug(*x): print(*x, file=sys.stderr) def solve(N, AS): num_division = 0 maxAS = max(AS) eratree = [0] * (maxAS + 10) for p in range(2, maxAS + 1): if eratree...
false
0.813008
[ "- x = p", "+ eratree[p] = p", "+ x = p * p" ]
false
0.106395
0.036935
2.880608
[ "s299015259", "s786829973" ]
u729133443
p03697
python
s797054614
s952990179
161
17
38,256
2,940
Accepted
Accepted
89.44
a,b=list(map(int,input().split()));print(([a+b,'error'][(a+b)//10]))
v=sum(map(ord,eval(input())))&31;print(('error'*(9<v)or v))
1
1
60
51
a, b = list(map(int, input().split())) print(([a + b, "error"][(a + b) // 10]))
v = sum(map(ord, eval(input()))) & 31 print(("error" * (9 < v) or v))
false
0
[ "-a, b = list(map(int, input().split()))", "-print(([a + b, \"error\"][(a + b) // 10]))", "+v = sum(map(ord, eval(input()))) & 31", "+print((\"error\" * (9 < v) or v))" ]
false
0.036486
0.036779
0.992051
[ "s797054614", "s952990179" ]
u994988729
p03835
python
s097602529
s508979358
1,955
150
3,060
12,872
Accepted
Accepted
92.33
k, s=list(map(int, input().split())) ans=0 for x in range(0, k+1): if x>s: break for y in range(0, k+1): if x+y>s: break z=s-x-y if 0<=z and z<=k: ans+=1 continue print(ans)
import numpy as np K, S = list(map(int, input().split())) fft_len = 1 << (K * 3).bit_length() x = np.ones(K + 1) Fx = np.fft.rfft(x, fft_len) Fx3 = Fx * Fx * Fx conv = np.fft.irfft(Fx3, fft_len) ans = conv[S] ans = int(ans + 0.5) print(ans)
14
13
257
250
k, s = list(map(int, input().split())) ans = 0 for x in range(0, k + 1): if x > s: break for y in range(0, k + 1): if x + y > s: break z = s - x - y if 0 <= z and z <= k: ans += 1 continue print(ans)
import numpy as np K, S = list(map(int, input().split())) fft_len = 1 << (K * 3).bit_length() x = np.ones(K + 1) Fx = np.fft.rfft(x, fft_len) Fx3 = Fx * Fx * Fx conv = np.fft.irfft(Fx3, fft_len) ans = conv[S] ans = int(ans + 0.5) print(ans)
false
7.142857
[ "-k, s = list(map(int, input().split()))", "-ans = 0", "-for x in range(0, k + 1):", "- if x > s:", "- break", "- for y in range(0, k + 1):", "- if x + y > s:", "- break", "- z = s - x - y", "- if 0 <= z and z <= k:", "- ans += 1", "- ...
false
0.035236
0.170613
0.206526
[ "s097602529", "s508979358" ]
u638902622
p02708
python
s836200904
s170309962
113
79
39,760
39,628
Accepted
Accepted
30.09
import sys ## io IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) MIIZ = lambda: list([x-1 for x in MII()]) ## dp INIT_VAL = 0 DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)] DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ i...
import sys ## io IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) MIIZ = lambda: list([x-1 for x in MII()]) ## dp INIT_VAL = 0 DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)] DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ i...
35
25
874
666
import sys ## io IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) MIIZ = lambda: list([x - 1 for x in MII()]) ## dp INIT_VAL = 0 DP2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)] DP3 = lambda d1, d2, d3: [[[INIT_VAL] * d3 for _ in range(d2)] for _ in ...
import sys ## io IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) MIIZ = lambda: list([x - 1 for x in MII()]) ## dp INIT_VAL = 0 DP2 = lambda d1, d2: [[INIT_VAL] * d2 for _ in range(d1)] DP3 = lambda d1, d2, d3: [[[INIT_VAL] * d3 for _ in range(d2)] for _ in ...
false
28.571429
[ "- # print(dd)", "- dd_a = [0]", "- for i in range(n + 1):", "- d = dd_a[i] + dd[i]", "- dd_a.append(d)", "- # print(dd_a)", "- dd_b = [0]", "- dd_r = dd[::-1]", "- for i in range(n + 1):", "- d = dd_b[i] + dd_r[i]", "- dd_b.append(d)", "- # ...
false
0.138831
0.101242
1.371288
[ "s836200904", "s170309962" ]
u238510421
p02862
python
s226520479
s492441597
397
367
129,656
129,712
Accepted
Accepted
7.56
MAX_NUM = 10**6 + 1 MOD = 10**9+7 fac = [0 for _ in range(MAX_NUM)] finv = [0 for _ in range(MAX_NUM)] inv = [0 for _ in range(MAX_NUM)] fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2,MAX_NUM): fac[i] = fac[i-1] * i % MOD inv[i] = MOD - inv[MOD%i] * (MOD // i) % MO...
MAX_NUM = 10**6 + 1 MOD = 10**9+7 fac = [0 for _ in range(MAX_NUM)] finv = [0 for _ in range(MAX_NUM)] inv = [0 for _ in range(MAX_NUM)] fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2,MAX_NUM): fac[i] = fac[i-1] * i % MOD inv[i] = MOD - inv[MOD%i] * (MOD // i) % MO...
37
35
762
783
MAX_NUM = 10**6 + 1 MOD = 10**9 + 7 fac = [0 for _ in range(MAX_NUM)] finv = [0 for _ in range(MAX_NUM)] inv = [0 for _ in range(MAX_NUM)] fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, MAX_NUM): fac[i] = fac[i - 1] * i % MOD inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD finv[i]...
MAX_NUM = 10**6 + 1 MOD = 10**9 + 7 fac = [0 for _ in range(MAX_NUM)] finv = [0 for _ in range(MAX_NUM)] inv = [0 for _ in range(MAX_NUM)] fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, MAX_NUM): fac[i] = fac[i - 1] * i % MOD inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD finv[i]...
false
5.405405
[ "-if (-Y + 2 * X) % 3 == 0 and (2 * Y - X) % 3 == 0:", "+if (-Y + 2 * X) % 3 != 0 or (2 * Y - X) % 3 != 0 or (-Y + 2 * X) < 0 or (2 * Y - X) < 0:", "+ print((0))", "+else:", "-else:", "- print((0))" ]
false
2.063694
1.928573
1.070062
[ "s226520479", "s492441597" ]
u585482323
p03222
python
s748315524
s154956854
184
166
40,048
38,256
Accepted
Accepted
9.78
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, ...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [lis...
122
59
2,782
1,465
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(m...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): r...
false
51.639344
[ "-from collections import defaultdict", "-from collections import deque", "+from collections import defaultdict, deque", "+from itertools import permutations, accumulate", "-import random", "- return list(map(int, sys.stdin.readline().split()))", "+ return [int(x) for x in sys.stdin.readline().spl...
false
0.079748
0.043915
1.815955
[ "s748315524", "s154956854" ]
u917013605
p03673
python
s860195008
s869285088
380
171
98,872
107,292
Accepted
Accepted
55
import collections N = int(eval(input())) A = list(map(int, input().split())) ans = collections.deque() for i in range(N): if N % 2 == 0: if i % 2 == 0: ans.append(A[i]) else: ans.appendleft(A[i]) else: if i % 2 == 0: ans.appendleft(A[i])...
from collections import deque n = int(eval(input())) a_li = list(map(int, input().split())) b_li = deque() for i in range(len(a_li)): if i % 2 == 0: b_li.append(a_li[i]) else: b_li.appendleft(a_li[i]) if len(a_li) % 2 == 0: print((*b_li)) else: print((*list(b_li)[::-1]))
17
15
373
310
import collections N = int(eval(input())) A = list(map(int, input().split())) ans = collections.deque() for i in range(N): if N % 2 == 0: if i % 2 == 0: ans.append(A[i]) else: ans.appendleft(A[i]) else: if i % 2 == 0: ans.appendleft(A[i]) else...
from collections import deque n = int(eval(input())) a_li = list(map(int, input().split())) b_li = deque() for i in range(len(a_li)): if i % 2 == 0: b_li.append(a_li[i]) else: b_li.appendleft(a_li[i]) if len(a_li) % 2 == 0: print((*b_li)) else: print((*list(b_li)[::-1]))
false
11.764706
[ "-import collections", "+from collections import deque", "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-ans = collections.deque()", "-for i in range(N):", "- if N % 2 == 0:", "- if i % 2 == 0:", "- ans.append(A[i])", "- else:", "- ans....
false
0.007712
0.030171
0.25561
[ "s860195008", "s869285088" ]
u545368057
p03128
python
s063149741
s856619139
684
112
30,452
29,684
Accepted
Accepted
83.63
## DP問題 N,M = list(map(int,input().split())) As = list(map(str,input().split())) match = {"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6} # test # N, M = 10000, 9 # As = [str(i) for i in range(1,10)] ws = {} #マッチの数に対しての、作れる数字の最大値を算出 for a in As: w = match[a] #...
## DP問題 N,M = list(map(int,input().split())) As = list(map(str,input().split())) match = {"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6} # test # N, M = 10000, 9 # As = [str(i) for i in range(1,10)] ws = {} #マッチの数に対しての、作れる数字の最大値を算出 for a in As: w = match[a] #...
45
45
1,142
1,146
## DP問題 N, M = list(map(int, input().split())) As = list(map(str, input().split())) match = {"1": 2, "2": 5, "3": 5, "4": 4, "5": 5, "6": 6, "7": 3, "8": 7, "9": 6} # test # N, M = 10000, 9 # As = [str(i) for i in range(1,10)] ws = {} # マッチの数に対しての、作れる数字の最大値を算出 for a in As: w = match[a] # 数aに使うマッチの数 try: ...
## DP問題 N, M = list(map(int, input().split())) As = list(map(str, input().split())) match = {"1": 2, "2": 5, "3": 5, "4": 4, "5": 5, "6": 6, "7": 3, "8": 7, "9": 6} # test # N, M = 10000, 9 # As = [str(i) for i in range(1,10)] ws = {} # マッチの数に対しての、作れる数字の最大値を算出 for a in As: w = match[a] # 数aに使うマッチの数 try: ...
false
0
[ "- else:", "- dp[i + k] = str(max(int(dp[i + k]), int(dp[i] + a)))", "+ # else:", "+ # dp[i+k] = str(max(int(dp[i+k]),int(dp[i]+a)))" ]
false
0.08838
0.077437
1.141311
[ "s063149741", "s856619139" ]
u835924161
p02732
python
s093480468
s420245310
519
341
26,140
26,268
Accepted
Accepted
34.3
n=int(eval(input())) A=list(map(int,input().split())) ma=int(200200) B=[0]*ma for i in range(n): now=A[i] B[now]+=1 ans=int(0) for i in range(ma): ans+=int((B[i]-1)*B[i]/2) for i in range(n): now=A[i] Ans=ans Ans-=int((B[now]-1)*B[now]/2) Ans+=int((B[now]-1)*(B[now]-2)/2)...
n=int(eval(input())) A=list(map(int,input().split())) ma=int(200200) B=[0]*ma for i in range(n): B[A[i]]+=1 ans=int(0) for i in range(ma): ans+=int((B[i]-1)*B[i]/2) for i in range(n): print((ans-B[A[i]]+1))
19
14
330
226
n = int(eval(input())) A = list(map(int, input().split())) ma = int(200200) B = [0] * ma for i in range(n): now = A[i] B[now] += 1 ans = int(0) for i in range(ma): ans += int((B[i] - 1) * B[i] / 2) for i in range(n): now = A[i] Ans = ans Ans -= int((B[now] - 1) * B[now] / 2) Ans += int((B[no...
n = int(eval(input())) A = list(map(int, input().split())) ma = int(200200) B = [0] * ma for i in range(n): B[A[i]] += 1 ans = int(0) for i in range(ma): ans += int((B[i] - 1) * B[i] / 2) for i in range(n): print((ans - B[A[i]] + 1))
false
26.315789
[ "- now = A[i]", "- B[now] += 1", "+ B[A[i]] += 1", "- now = A[i]", "- Ans = ans", "- Ans -= int((B[now] - 1) * B[now] / 2)", "- Ans += int((B[now] - 1) * (B[now] - 2) / 2)", "- print(Ans)", "+ print((ans - B[A[i]] + 1))" ]
false
0.176727
0.175589
1.006479
[ "s093480468", "s420245310" ]
u352394527
p00442
python
s971153132
s302957812
430
360
13,288
13,308
Accepted
Accepted
16.28
import sys sys.setrecursionlimit(100000) def main(): V, E = int(eval(input())), int(eval(input())) L = [] app = L.append visited = [0 for i in range(V)] edges = [[] for i in range(V)] def visit(x): if not visited[x]: visited[x] = 1 for e in edges[x]: visit(e) ...
import sys sys.setrecursionlimit(100000) def main(): V, E = int(eval(input())), int(eval(input())) L = [] app = L.append visited = [0 for i in range(V)] edges = [[] for i in range(V)] def visit(x): if not visited[x]: visited[x] = 1 for e in edges[x]: visit(e) ...
33
37
656
716
import sys sys.setrecursionlimit(100000) def main(): V, E = int(eval(input())), int(eval(input())) L = [] app = L.append visited = [0 for i in range(V)] edges = [[] for i in range(V)] def visit(x): if not visited[x]: visited[x] = 1 for e in edges[x]: ...
import sys sys.setrecursionlimit(100000) def main(): V, E = int(eval(input())), int(eval(input())) L = [] app = L.append visited = [0 for i in range(V)] edges = [[] for i in range(V)] def visit(x): if not visited[x]: visited[x] = 1 for e in edges[x]: ...
false
10.810811
[ "- for i in range(V):", "- print((L[i] + 1))", "- if not flag and i < V - 1 and (L[i + 1] not in edges[L[i]]):", "+ temp = L[0]", "+ print((temp + 1))", "+ for i in range(V - 1):", "+ v = L[i + 1]", "+ print((v + 1))", "+ if not flag and i < V - 1 and (...
false
0.066315
0.070736
0.937495
[ "s971153132", "s302957812" ]
u816631826
p03813
python
s408485755
s733895357
19
17
2,940
2,940
Accepted
Accepted
10.53
rate = int(eval(input())) if rate < 1200: print("ABC") else: print("ARC")
a= eval(input()) if a<"1200": print("ABC") else: print("ARC")
6
6
81
74
rate = int(eval(input())) if rate < 1200: print("ABC") else: print("ARC")
a = eval(input()) if a < "1200": print("ABC") else: print("ARC")
false
0
[ "-rate = int(eval(input()))", "-if rate < 1200:", "+a = eval(input())", "+if a < \"1200\":" ]
false
0.066397
0.066537
0.997905
[ "s408485755", "s733895357" ]
u028973125
p02603
python
s333829848
s536739144
33
29
9,144
9,172
Accepted
Accepted
12.12
import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().split())) money = 1000 min_price = float("inf") for i in range(N): if min_price > A[i]: min_price = A[i] elif min_price < A[i]: num = money // min_price money = money - min_price * num +...
import sys N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) yen = 1000 for i in range(1, N): if A[i-1] < A[i]: yen += (A[i] - A[i-1]) * (yen // A[i-1]) print(yen)
16
11
373
217
import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().split())) money = 1000 min_price = float("inf") for i in range(N): if min_price > A[i]: min_price = A[i] elif min_price < A[i]: num = money // min_price money = money - min_price * num + A[i] * num ...
import sys N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) yen = 1000 for i in range(1, N): if A[i - 1] < A[i]: yen += (A[i] - A[i - 1]) * (yen // A[i - 1]) print(yen)
false
31.25
[ "-N = int(sys.stdin.readline().strip())", "+N = int(sys.stdin.readline())", "-money = 1000", "-min_price = float(\"inf\")", "-for i in range(N):", "- if min_price > A[i]:", "- min_price = A[i]", "- elif min_price < A[i]:", "- num = money // min_price", "- money = money -...
false
0.044763
0.044481
1.00635
[ "s333829848", "s536739144" ]
u134712256
p04031
python
s140682400
s687798276
20
17
3,188
2,940
Accepted
Accepted
15
N = int(eval(input())) a = list(map(int,input().split())) ave = sum(a)/N ave = round(ave) sum = 0 for i in a: sum += (i-ave)**2 print(sum)
n=int(eval(input())) a=list(map(int,input().split())) ave = round(sum(a)/n) cost=0 for i in range(n): cost+=(a[i]-ave)**2 print(cost)
8
8
144
140
N = int(eval(input())) a = list(map(int, input().split())) ave = sum(a) / N ave = round(ave) sum = 0 for i in a: sum += (i - ave) ** 2 print(sum)
n = int(eval(input())) a = list(map(int, input().split())) ave = round(sum(a) / n) cost = 0 for i in range(n): cost += (a[i] - ave) ** 2 print(cost)
false
0
[ "-N = int(eval(input()))", "+n = int(eval(input()))", "-ave = sum(a) / N", "-ave = round(ave)", "-sum = 0", "-for i in a:", "- sum += (i - ave) ** 2", "-print(sum)", "+ave = round(sum(a) / n)", "+cost = 0", "+for i in range(n):", "+ cost += (a[i] - ave) ** 2", "+print(cost)" ]
false
0.048299
0.048857
0.988569
[ "s140682400", "s687798276" ]
u561083515
p02954
python
s704215165
s607886414
252
153
10,484
9,836
Accepted
Accepted
39.29
S = eval(input()) result = [1]*len(S) for i,x in enumerate(S): if x == "R": move_To = S.find("L", i)-1 result[i] -= 1 if (move_To - i) % 2 == 0: result[move_To] += 1 else: result[move_To+1] += 1 else: move_To = S.rfind("R", 0, i+1) + ...
""" 各人についての移動回数 偶数 -> 状態同じ 奇数 -> 一回移動 """ S = [False if s == "L" else True for s in eval(input())] N = len(S) from collections import deque F_idx = deque([idx for idx in range(N) if not S[idx]]) T_idx = deque([idx for idx in range(N) if S[idx]]) state = [0] * N # -> for i in range(N): if S[i]: ...
20
35
497
729
S = eval(input()) result = [1] * len(S) for i, x in enumerate(S): if x == "R": move_To = S.find("L", i) - 1 result[i] -= 1 if (move_To - i) % 2 == 0: result[move_To] += 1 else: result[move_To + 1] += 1 else: move_To = S.rfind("R", 0, i + 1) + 1 ...
""" 各人についての移動回数 偶数 -> 状態同じ 奇数 -> 一回移動 """ S = [False if s == "L" else True for s in eval(input())] N = len(S) from collections import deque F_idx = deque([idx for idx in range(N) if not S[idx]]) T_idx = deque([idx for idx in range(N) if S[idx]]) state = [0] * N # -> for i in range(N): if S[i]: if (F_idx[0]...
false
42.857143
[ "-S = eval(input())", "-result = [1] * len(S)", "-for i, x in enumerate(S):", "- if x == \"R\":", "- move_To = S.find(\"L\", i) - 1", "- result[i] -= 1", "- if (move_To - i) % 2 == 0:", "- result[move_To] += 1", "+\"\"\"", "+各人についての移動回数", "+偶数 -> 状態同じ", "+奇数 ...
false
0.104932
0.04817
2.178365
[ "s704215165", "s607886414" ]
u336624604
p02899
python
s157796867
s406485476
251
106
26,596
13,880
Accepted
Accepted
57.77
n = int(eval(input())) a = list(map(int, input().split())) b=[] for i in range(1,n+1): b.append(i) a, b = list(zip(*sorted(zip(a,b)))) print((*b))
n = int(eval(input())) a = list(map(int, input().split())) b=[0]*n for i,a in enumerate(a): b[a-1]=i+1 print((*b))
8
6
144
115
n = int(eval(input())) a = list(map(int, input().split())) b = [] for i in range(1, n + 1): b.append(i) a, b = list(zip(*sorted(zip(a, b)))) print((*b))
n = int(eval(input())) a = list(map(int, input().split())) b = [0] * n for i, a in enumerate(a): b[a - 1] = i + 1 print((*b))
false
25
[ "-b = []", "-for i in range(1, n + 1):", "- b.append(i)", "-a, b = list(zip(*sorted(zip(a, b))))", "+b = [0] * n", "+for i, a in enumerate(a):", "+ b[a - 1] = i + 1" ]
false
0.055437
0.036985
1.498892
[ "s157796867", "s406485476" ]
u367130284
p03665
python
s461452399
s624763763
22
18
3,572
3,188
Accepted
Accepted
18.18
from operator import mul from functools import reduce from math import factorial def cmb(n,r): r=min(n-r,r) if r == 0: return 1 over=reduce(mul,list(range(n,n-r,-1))) under=reduce(mul,list(range(1,r+1))) return over//under n,p,*a=list(map(int,open(0).read().split())) b=[i for i in a if i%2==0] ...
from math import factorial def cmb(n,r): if n-r<0: return 0 else: return factorial(n) // factorial(r) // factorial(n - r) n,p,*a=list(map(int,open(0).read().split())) odd=sum(i%2 for i in a) even=n-odd x=sum(cmb(even,i)for i in range(even+1)) y=sum(cmb(odd,i)for i in ...
26
18
550
346
from operator import mul from functools import reduce from math import factorial def cmb(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under n, p, *a = list(map(int, open(0).read().spli...
from math import factorial def cmb(n, r): if n - r < 0: return 0 else: return factorial(n) // factorial(r) // factorial(n - r) n, p, *a = list(map(int, open(0).read().split())) odd = sum(i % 2 for i in a) even = n - odd x = sum(cmb(even, i) for i in range(even + 1)) y = sum(cmb(odd, i) for i...
false
30.769231
[ "-from operator import mul", "-from functools import reduce", "- r = min(n - r, r)", "- if r == 0:", "- return 1", "- over = reduce(mul, list(range(n, n - r, -1)))", "- under = reduce(mul, list(range(1, r + 1)))", "- return over // under", "+ if n - r < 0:", "+ retu...
false
0.033487
0.037354
0.89649
[ "s461452399", "s624763763" ]
u075012704
p02631
python
s934379324
s152451843
166
150
136,972
31,840
Accepted
Accepted
9.64
N = int(input()) A = list(map(int, input().split())) xor_left = [0] for a in A: xor_left.append(xor_left[-1] ^ a) xor_left.append(0) xor_right = [0] for a in A[::-1]: xor_right.append(xor_right[-1] ^ a) xor_right.append(0) xor_right = xor_right[::-1] ans = [] for i in range(1, N + 1): ans...
from functools import reduce N = int(input()) A = list(map(int, input().split())) ALL_XOR = reduce(lambda x, y: x ^ y, A) print(*[a ^ ALL_XOR for a in A], sep=' ')
18
6
386
170
N = int(input()) A = list(map(int, input().split())) xor_left = [0] for a in A: xor_left.append(xor_left[-1] ^ a) xor_left.append(0) xor_right = [0] for a in A[::-1]: xor_right.append(xor_right[-1] ^ a) xor_right.append(0) xor_right = xor_right[::-1] ans = [] for i in range(1, N + 1): ans.append(xor_left[i ...
from functools import reduce N = int(input()) A = list(map(int, input().split())) ALL_XOR = reduce(lambda x, y: x ^ y, A) print(*[a ^ ALL_XOR for a in A], sep=" ")
false
66.666667
[ "+from functools import reduce", "+", "-xor_left = [0]", "-for a in A:", "- xor_left.append(xor_left[-1] ^ a)", "-xor_left.append(0)", "-xor_right = [0]", "-for a in A[::-1]:", "- xor_right.append(xor_right[-1] ^ a)", "-xor_right.append(0)", "-xor_right = xor_right[::-1]", "-ans = []", ...
false
0.048245
0.046648
1.034229
[ "s934379324", "s152451843" ]
u106311097
p02642
python
s964962638
s021186223
991
610
96,764
35,900
Accepted
Accepted
38.45
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d from collections import Counter def main(): N = eval(input()) A = sorted(map(int, input().split(' '))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: B[a] = 0 for i in ran...
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d from collections import Counter def main(): N = eval(input()) A = sorted(map(int, input().split(' '))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: B[a] = 0 for i in ran...
20
21
420
443
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d from collections import Counter def main(): N = eval(input()) A = sorted(map(int, input().split(" "))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: B[a] = 0 for i in range(2, A[-1] /...
#!python3.8 # -*- coding: utf-8 -*- # abc170/abc170_d from collections import Counter def main(): N = eval(input()) A = sorted(map(int, input().split(" "))) B = Counter(A) for a in A: if B[a] == 0: continue if B[a] > 1: B[a] = 0 for i in range(2, A[-1] /...
false
4.761905
[ "- B[a * i] = 0", "- print((Counter(list(B.values()))[1]))", "+ if B[a * i]:", "+ B[a * i] = 0", "+ print((sum(B.values())))" ]
false
0.041669
0.04646
0.896863
[ "s964962638", "s021186223" ]
u271176141
p03803
python
s306575770
s280904706
27
24
9,160
8,968
Accepted
Accepted
11.11
# AliceのスコアAとBobのスコアBを整数で入力 A,B = list(map(int,input().split())) # AとBが同じならDrawを出力 if A == B: print("Draw") # Aが1がBより大きいならAliceを出力 elif A == 1 or A > B and B!= 1 : print("Alice") # Bの方が強ければBobを出力 else: print("Bob")
# AliceのスコアAとBobのスコアBを整数で入力 A,B = list(map(int,input().split())) # AとBが同じならDrawを出力 if A == B: print("Draw") # Aが1か、Bが1でなく且つAがBより大きいならAliceを出力 elif A == 1 or B!= 1 and A > B: print("Alice") # Bの方が強ければBobを出力 else: print("Bob")
11
11
230
242
# AliceのスコアAとBobのスコアBを整数で入力 A, B = list(map(int, input().split())) # AとBが同じならDrawを出力 if A == B: print("Draw") # Aが1がBより大きいならAliceを出力 elif A == 1 or A > B and B != 1: print("Alice") # Bの方が強ければBobを出力 else: print("Bob")
# AliceのスコアAとBobのスコアBを整数で入力 A, B = list(map(int, input().split())) # AとBが同じならDrawを出力 if A == B: print("Draw") # Aが1か、Bが1でなく且つAがBより大きいならAliceを出力 elif A == 1 or B != 1 and A > B: print("Alice") # Bの方が強ければBobを出力 else: print("Bob")
false
0
[ "-# Aが1がBより大きいならAliceを出力", "-elif A == 1 or A > B and B != 1:", "+# Aが1か、Bが1でなく且つAがBより大きいならAliceを出力", "+elif A == 1 or B != 1 and A > B:" ]
false
0.036636
0.036142
1.013692
[ "s306575770", "s280904706" ]
u250583425
p03078
python
s141690047
s576112412
1,937
32
185,812
4,976
Accepted
Accepted
98.35
import sys from itertools import product def input(): return sys.stdin.readline().rstrip() def main(): X, Y, Z, K = list(map(int, input().split())) A, B, C = [sorted(map(int, input().split())) for _ in range(3)] AB = [a + b for a, b in product(A, B)] AB = sorted(AB, reverse=True)[:K] A...
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): X, Y, Z, K = list(map(int, input().split())) A, B, C = [sorted(map(int, input().split()), reverse=True) for _ in range(3)] hp = [] heapq.heappush(hp, (- A[0] - B[0] - C[0], 0, 0, 0)) exists = set([(0, 0...
18
26
476
926
import sys from itertools import product def input(): return sys.stdin.readline().rstrip() def main(): X, Y, Z, K = list(map(int, input().split())) A, B, C = [sorted(map(int, input().split())) for _ in range(3)] AB = [a + b for a, b in product(A, B)] AB = sorted(AB, reverse=True)[:K] ABC = [...
import sys import heapq def input(): return sys.stdin.readline().rstrip() def main(): X, Y, Z, K = list(map(int, input().split())) A, B, C = [sorted(map(int, input().split()), reverse=True) for _ in range(3)] hp = [] heapq.heappush(hp, (-A[0] - B[0] - C[0], 0, 0, 0)) exists = set([(0, 0, 0)]...
false
30.769231
[ "-from itertools import product", "+import heapq", "- A, B, C = [sorted(map(int, input().split())) for _ in range(3)]", "- AB = [a + b for a, b in product(A, B)]", "- AB = sorted(AB, reverse=True)[:K]", "- ABC = [ab + c for ab, c in product(AB, C)]", "- ABC = sorted(ABC, reverse=True)[:K]...
false
0.092791
0.050011
1.855393
[ "s141690047", "s576112412" ]
u309120194
p02847
python
s929060922
s538567292
26
22
9,092
8,928
Accepted
Accepted
15.38
S = eval(input()) if S == 'SUN': print((7)) elif S == 'MON': print((6)) elif S == 'TUE': print((5)) elif S == 'WED': print((4)) elif S == 'THU': print((3)) elif S == 'FRI': print((2)) elif S == 'SAT': print((1))
S = eval(input()) if S == 'SUN': print((7)) elif S == 'MON': print((6)) elif S == 'TUE': print((5)) elif S == 'WED': print((4)) elif S == 'THU': print((3)) elif S == 'FRI': print((2)) else: print((1))
8
8
199
188
S = eval(input()) if S == "SUN": print((7)) elif S == "MON": print((6)) elif S == "TUE": print((5)) elif S == "WED": print((4)) elif S == "THU": print((3)) elif S == "FRI": print((2)) elif S == "SAT": print((1))
S = eval(input()) if S == "SUN": print((7)) elif S == "MON": print((6)) elif S == "TUE": print((5)) elif S == "WED": print((4)) elif S == "THU": print((3)) elif S == "FRI": print((2)) else: print((1))
false
0
[ "-elif S == \"SAT\":", "+else:" ]
false
0.124758
0.049024
2.544847
[ "s929060922", "s538567292" ]
u556589653
p03262
python
s980699377
s683904205
102
91
16,280
20,376
Accepted
Accepted
10.78
import fractions from functools import reduce def gcd_list(numbers): return reduce(fractions.gcd, numbers) N,X = list(map(int,input().split())) A = list(map(int,input().split())) k = [] for i in range(N): k.append(abs(A[i]-X)) print((gcd_list(k)))
import math N,X = list(map(int,input().split())) x = list(map(int,input().split())) ls = [] for i in range(N): ls.append(abs(x[i]-X)) now = ls[0] for i in range(1,N): now = math.gcd(ls[i],now) print(now)
10
10
252
214
import fractions from functools import reduce def gcd_list(numbers): return reduce(fractions.gcd, numbers) N, X = list(map(int, input().split())) A = list(map(int, input().split())) k = [] for i in range(N): k.append(abs(A[i] - X)) print((gcd_list(k)))
import math N, X = list(map(int, input().split())) x = list(map(int, input().split())) ls = [] for i in range(N): ls.append(abs(x[i] - X)) now = ls[0] for i in range(1, N): now = math.gcd(ls[i], now) print(now)
false
0
[ "-import fractions", "-from functools import reduce", "-", "-", "-def gcd_list(numbers):", "- return reduce(fractions.gcd, numbers)", "-", "+import math", "-A = list(map(int, input().split()))", "-k = []", "+x = list(map(int, input().split()))", "+ls = []", "- k.append(abs(A[i] - X))",...
false
0.059527
0.0365
1.630881
[ "s980699377", "s683904205" ]
u634046173
p03730
python
s746265817
s563309412
67
59
63,044
61,812
Accepted
Accepted
11.94
A, B, C = list(map(int,input().split())) for i in range(1,10000): a = A*i if a % B == C: print('YES') exit() print('NO')
A, B, C = list(map(int,input().split())) for i in range(1,B+1): a = A*i if a % B == C: print('YES') exit() print('NO')
10
10
151
149
A, B, C = list(map(int, input().split())) for i in range(1, 10000): a = A * i if a % B == C: print("YES") exit() print("NO")
A, B, C = list(map(int, input().split())) for i in range(1, B + 1): a = A * i if a % B == C: print("YES") exit() print("NO")
false
0
[ "-for i in range(1, 10000):", "+for i in range(1, B + 1):" ]
false
0.039197
0.038802
1.010196
[ "s746265817", "s563309412" ]
u492910842
p02608
python
s657328680
s281520852
900
98
70,372
74,212
Accepted
Accepted
89.11
import math n=int(eval(input())) z=0 d=0 ans=0 for i in range(1,n+1): for x in range(1,int(math.sqrt(n)+1)): for y in range(1,int(math.sqrt(n)+1)): d=x*x+y*y+2*x*y-4*(x*x+y*y+x*y-i) if d<0: continue z=(math.sqrt(d)-(x+y))/2 if z.is_integer() and z>=1: ans+=1 ...
n=int(eval(input())) v=[0]*10001 for x in range(1,101): for y in range(1,101): for z in range(1,101): d=x*x+y*y+z*z+x*y+x*z+y*z if d>10000: continue else: v[d]+=1 for i in range(n): print((v[i+1]))
19
12
371
242
import math n = int(eval(input())) z = 0 d = 0 ans = 0 for i in range(1, n + 1): for x in range(1, int(math.sqrt(n) + 1)): for y in range(1, int(math.sqrt(n) + 1)): d = x * x + y * y + 2 * x * y - 4 * (x * x + y * y + x * y - i) if d < 0: continue z = (ma...
n = int(eval(input())) v = [0] * 10001 for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): d = x * x + y * y + z * z + x * y + x * z + y * z if d > 10000: continue else: v[d] += 1 for i in range(n): print((v[i + 1]))...
false
36.842105
[ "-import math", "-", "-z = 0", "-d = 0", "-ans = 0", "-for i in range(1, n + 1):", "- for x in range(1, int(math.sqrt(n) + 1)):", "- for y in range(1, int(math.sqrt(n) + 1)):", "- d = x * x + y * y + 2 * x * y - 4 * (x * x + y * y + x * y - i)", "- if d < 0:", "+v...
false
0.04516
0.57374
0.078711
[ "s657328680", "s281520852" ]
u086056891
p03240
python
s562313227
s274261780
129
37
3,064
3,188
Accepted
Accepted
71.32
n = int(eval(input())) p = [list(map(int, input().split())) for _ in range(n)] for cx in range(101): for cy in range(101): for xi, yi, hi in p: if hi > 0: h = abs(xi - cx) + abs(yi - cy) + hi break if all(max(h - abs(xi - cx) - abs(yi - cy), 0) =...
n = int(eval(input())) p = [list(map(int, input().split())) for _ in range(n)] p.sort(key=lambda x: x[2], reverse=True) for cx in range(101): for cy in range(101): x0, y0, h0 = p[0] h = abs(x0 - cx) + abs(y0 - cy) + h0 if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for xi, yi,...
12
11
390
374
n = int(eval(input())) p = [list(map(int, input().split())) for _ in range(n)] for cx in range(101): for cy in range(101): for xi, yi, hi in p: if hi > 0: h = abs(xi - cx) + abs(yi - cy) + hi break if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for x...
n = int(eval(input())) p = [list(map(int, input().split())) for _ in range(n)] p.sort(key=lambda x: x[2], reverse=True) for cx in range(101): for cy in range(101): x0, y0, h0 = p[0] h = abs(x0 - cx) + abs(y0 - cy) + h0 if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for xi, yi, hi in p)...
false
8.333333
[ "+p.sort(key=lambda x: x[2], reverse=True)", "- for xi, yi, hi in p:", "- if hi > 0:", "- h = abs(xi - cx) + abs(yi - cy) + hi", "- break", "+ x0, y0, h0 = p[0]", "+ h = abs(x0 - cx) + abs(y0 - cy) + h0" ]
false
0.039859
0.040082
0.99444
[ "s562313227", "s274261780" ]
u591503175
p02796
python
s060039234
s934641538
480
436
39,464
40,312
Accepted
Accepted
9.17
N = int(eval(input())) num_list = [[int(item) for item in input().split()] for _ in range(N)] num_list2 = [] for x, l in num_list: num_list2.append([x-l, x+l]) num_list2.sort(key=lambda x: x[1]) # print(num_list2) temp_max = num_list2[0][1] cnt = 1 for l, h in num_list2: if l >= temp_max: ...
def resolve(): ''' code here ''' N = int(eval(input())) robots = [[int(item) for item in input().split()] for _ in range(N)] arm_body_arm = [] for body, arm in robots: arm_body_arm.append([body - arm, body + arm]) arm_body_arm = sorted(arm_body_arm, key=lambd...
18
26
363
543
N = int(eval(input())) num_list = [[int(item) for item in input().split()] for _ in range(N)] num_list2 = [] for x, l in num_list: num_list2.append([x - l, x + l]) num_list2.sort(key=lambda x: x[1]) # print(num_list2) temp_max = num_list2[0][1] cnt = 1 for l, h in num_list2: if l >= temp_max: cnt += 1 ...
def resolve(): """ code here """ N = int(eval(input())) robots = [[int(item) for item in input().split()] for _ in range(N)] arm_body_arm = [] for body, arm in robots: arm_body_arm.append([body - arm, body + arm]) arm_body_arm = sorted(arm_body_arm, key=lambda x: x[1]) res = ...
false
30.769231
[ "-N = int(eval(input()))", "-num_list = [[int(item) for item in input().split()] for _ in range(N)]", "-num_list2 = []", "-for x, l in num_list:", "- num_list2.append([x - l, x + l])", "-num_list2.sort(key=lambda x: x[1])", "-# print(num_list2)", "-temp_max = num_list2[0][1]", "-cnt = 1", "-for...
false
0.04346
0.04517
0.962151
[ "s060039234", "s934641538" ]
u843175622
p03352
python
s720893645
s132824573
32
24
9,164
9,108
Accepted
Accepted
25
x = int(eval(input())) print((max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= x])))
x = int(eval(input())) table = [False] * -~x table[1] = True for i in range(2, 32): j = i * i while j <= x: table[j] = True j *= i print((max(i for i in range(x + 1) if table[i])))
3
11
116
209
x = int(eval(input())) print((max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= x])))
x = int(eval(input())) table = [False] * -~x table[1] = True for i in range(2, 32): j = i * i while j <= x: table[j] = True j *= i print((max(i for i in range(x + 1) if table[i])))
false
72.727273
[ "-print((max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= x])))", "+table = [False] * -~x", "+table[1] = True", "+for i in range(2, 32):", "+ j = i * i", "+ while j <= x:", "+ table[j] = True", "+ j *= i", "+print((max(i for i in range(x + 1) if table[i]...
false
0.04812
0.048049
1.001478
[ "s720893645", "s132824573" ]
u597374218
p03434
python
s487745050
s594740355
19
17
3,316
2,940
Accepted
Accepted
10.53
eval(input()) l=sorted(map(int,input().split()))[::-1] print((sum(l[::2])-sum(l[1::2])))
eval(input()) a=sorted(map(int,input().split()))[::-1] print((sum(a[::2])-sum(a[1::2])))
3
3
82
82
eval(input()) l = sorted(map(int, input().split()))[::-1] print((sum(l[::2]) - sum(l[1::2])))
eval(input()) a = sorted(map(int, input().split()))[::-1] print((sum(a[::2]) - sum(a[1::2])))
false
0
[ "-l = sorted(map(int, input().split()))[::-1]", "-print((sum(l[::2]) - sum(l[1::2])))", "+a = sorted(map(int, input().split()))[::-1]", "+print((sum(a[::2]) - sum(a[1::2])))" ]
false
0.036759
0.035105
1.0471
[ "s487745050", "s594740355" ]
u602677143
p02813
python
s165530017
s556988424
39
27
10,228
8,052
Accepted
Accepted
30.77
#ABC150C import itertools n = int(eval(input())) ls = [i+1 for i in range(n)] p = list(map(int,input().split())) q = list(map(int,input().split())) v = [ list(v) for v in itertools.permutations(ls, n)] a, b = v.index(p), v.index(q) print((abs(a-b)))
#ABC150C 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))))
9
7
249
204
# ABC150C import itertools n = int(eval(input())) ls = [i + 1 for i in range(n)] p = list(map(int, input().split())) q = list(map(int, input().split())) v = [list(v) for v in itertools.permutations(ls, n)] a, b = v.index(p), v.index(q) print((abs(a - b)))
# ABC150C 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
22.222222
[ "-ls = [i + 1 for i in range(n)]", "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "-v = [list(v) for v in itertools.permutations(ls, n)]", "-a, b = v.index(p), v.index(q)", "-print((abs(a - b)))", "+p = tuple(map(int, input().split()))", "+q = tuple(map(int, input().sp...
false
0.039472
0.061246
0.644479
[ "s165530017", "s556988424" ]
u888092736
p03786
python
s092496542
s340870612
312
91
14,432
14,432
Accepted
Accepted
70.83
from bisect import bisect_right from itertools import accumulate N = int(eval(input())) A = sorted(map(int, input().split())) acc_A = list(accumulate(A)) ans = 0 for i in range(N): prev = i while True: idx = bisect_right(A, 2 * acc_A[prev], lo=prev) - 1 if idx == N - 1: ...
from bisect import bisect_right from itertools import accumulate def can_survive(prev): while True: idx = bisect_right(A, 2 * acc_A[prev]) - 1 if idx == N - 1: return True if idx == prev: return False prev = idx def binary_search(left, right)...
19
28
420
651
from bisect import bisect_right from itertools import accumulate N = int(eval(input())) A = sorted(map(int, input().split())) acc_A = list(accumulate(A)) ans = 0 for i in range(N): prev = i while True: idx = bisect_right(A, 2 * acc_A[prev], lo=prev) - 1 if idx == N - 1: ans += 1 ...
from bisect import bisect_right from itertools import accumulate def can_survive(prev): while True: idx = bisect_right(A, 2 * acc_A[prev]) - 1 if idx == N - 1: return True if idx == prev: return False prev = idx def binary_search(left, right): while ri...
false
32.142857
[ "+", "+", "+def can_survive(prev):", "+ while True:", "+ idx = bisect_right(A, 2 * acc_A[prev]) - 1", "+ if idx == N - 1:", "+ return True", "+ if idx == prev:", "+ return False", "+ prev = idx", "+", "+", "+def binary_search(left, right):...
false
0.183003
0.037643
4.861555
[ "s092496542", "s340870612" ]
u860657719
p02744
python
s797897716
s107084716
155
88
29,500
9,068
Accepted
Accepted
43.23
n = int(eval(input())) dict = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"} ans = [["a", 1]] for i in range(n-1): newans = [] for lis in ans: now = lis[0] count = lis[1] for j in range(1, count + 2): newans.append([now + dict[j], max(j, coun...
n = int(eval(input())) dict = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"} dict2 = {"a":1, "b":2, "c":3, "d":4, "e":5, "f":6, "g":7, "h":8, "i":9, "j":10} #ans = [["a", 1]] #for i in range(n-1): # newans = [] # for lis in ans: # now = lis[0] # count = lis[1] # ...
13
23
372
637
n = int(eval(input())) dict = {1: "a", 2: "b", 3: "c", 4: "d", 5: "e", 6: "f", 7: "g", 8: "h", 9: "i", 10: "j"} ans = [["a", 1]] for i in range(n - 1): newans = [] for lis in ans: now = lis[0] count = lis[1] for j in range(1, count + 2): newans.append([now + dict[j], max(j, c...
n = int(eval(input())) dict = {1: "a", 2: "b", 3: "c", 4: "d", 5: "e", 6: "f", 7: "g", 8: "h", 9: "i", 10: "j"} dict2 = { "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9, "j": 10, } # ans = [["a", 1]] # for i in range(n-1): # newans = [] # for lis in ...
false
43.478261
[ "-ans = [[\"a\", 1]]", "-for i in range(n - 1):", "- newans = []", "- for lis in ans:", "- now = lis[0]", "- count = lis[1]", "- for j in range(1, count + 2):", "- newans.append([now + dict[j], max(j, count)])", "- ans = newans", "-for lis in ans:", "- ...
false
0.169536
0.126765
1.337402
[ "s797897716", "s107084716" ]
u586759271
p02912
python
s318437505
s188397712
655
402
94,232
72,088
Accepted
Accepted
38.63
import heapq n,m=list(map(int,input().split())) a=[-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): b=-heapq.heappop(a) heapq.heappush(a,-b/2) print((int( sum(-i//1 for i in a)) ))
n,m=list(map(int,input().split())) a=[-int(aa) for aa in input().split() ] import heapq heapq.heapify(a) for _ in range(m): now = -heapq.heappop(a) heapq.heappush(a,- (now//2) ) print((-sum(a)))
8
10
208
205
import heapq n, m = list(map(int, input().split())) a = [-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): b = -heapq.heappop(a) heapq.heappush(a, -b / 2) print((int(sum(-i // 1 for i in a))))
n, m = list(map(int, input().split())) a = [-int(aa) for aa in input().split()] import heapq heapq.heapify(a) for _ in range(m): now = -heapq.heappop(a) heapq.heappush(a, -(now // 2)) print((-sum(a)))
false
20
[ "+n, m = list(map(int, input().split()))", "+a = [-int(aa) for aa in input().split()]", "-n, m = list(map(int, input().split()))", "-a = [-int(i) for i in input().split()]", "-for i in range(m):", "- b = -heapq.heappop(a)", "- heapq.heappush(a, -b / 2)", "-print((int(sum(-i // 1 for i in a))))",...
false
0.040413
0.0597
0.676933
[ "s318437505", "s188397712" ]
u836737505
p03379
python
s591678858
s663596292
306
281
25,220
26,772
Accepted
Accepted
8.17
n = int(eval(input())) l = list(map(int,input().split())) lsort = sorted(l) l1 = lsort[n//2-1] l2 = lsort[n//2] for i in l: print((l1 if i>=l2 else l2))
n = int(eval(input())) x = list(map(int,input().split())) x_sort = sorted(x) mini = x_sort[n//2-1] maxi = x_sort[n//2] if mini == maxi: for _ in range(n): print(mini) else: for a in x: if a < maxi: print(maxi) else: print(mini)
7
14
154
290
n = int(eval(input())) l = list(map(int, input().split())) lsort = sorted(l) l1 = lsort[n // 2 - 1] l2 = lsort[n // 2] for i in l: print((l1 if i >= l2 else l2))
n = int(eval(input())) x = list(map(int, input().split())) x_sort = sorted(x) mini = x_sort[n // 2 - 1] maxi = x_sort[n // 2] if mini == maxi: for _ in range(n): print(mini) else: for a in x: if a < maxi: print(maxi) else: print(mini)
false
50
[ "-l = list(map(int, input().split()))", "-lsort = sorted(l)", "-l1 = lsort[n // 2 - 1]", "-l2 = lsort[n // 2]", "-for i in l:", "- print((l1 if i >= l2 else l2))", "+x = list(map(int, input().split()))", "+x_sort = sorted(x)", "+mini = x_sort[n // 2 - 1]", "+maxi = x_sort[n // 2]", "+if mini ...
false
0.046432
0.046219
1.004611
[ "s591678858", "s663596292" ]
u647766105
p00190
python
s537275175
s055213504
3,050
450
6,464
5,152
Accepted
Accepted
85.25
from math import factorial from queue import PriorityQueue FACTORIAL=[factorial(i) for i in range(13)] LEFT,UP,RIGHT,DOWN=0,1,2,3 MOVE=[[0] for u in range(13)] MOVE[0] =[-1,-1,-1, 2] MOVE[1] =[-1,-1, 2, 5] MOVE[2] =[ 1, 0, 3, 6] MOVE[3] =[ 2,-1,-1, 7] MOVE[4] =[-1,-1, 5,-1] MOVE[5] =[ 4, 1, 6, 9] MOVE[6] ...
from math import factorial from queue import PriorityQueue FACTORIAL=[factorial(i) for i in range(13)] LEFT,UP,RIGHT,DOWN=0,1,2,3 MOVE=[[0] for u in range(13)] MOVE[0] =[-1,-1,-1, 2] MOVE[1] =[-1,-1, 2, 5] MOVE[2] =[ 1, 0, 3, 6] MOVE[3] =[ 2,-1,-1, 7] MOVE[4] =[-1,-1, 5,-1] MOVE[5] =[ 4, 1, 6, 9] MOVE[6] ...
119
89
3,829
2,758
from math import factorial from queue import PriorityQueue FACTORIAL = [factorial(i) for i in range(13)] LEFT, UP, RIGHT, DOWN = 0, 1, 2, 3 MOVE = [[0] for u in range(13)] MOVE[0] = [-1, -1, -1, 2] MOVE[1] = [-1, -1, 2, 5] MOVE[2] = [1, 0, 3, 6] MOVE[3] = [2, -1, -1, 7] MOVE[4] = [-1, -1, 5, -1] MOVE[5] = [4, 1, 6, 9]...
from math import factorial from queue import PriorityQueue FACTORIAL = [factorial(i) for i in range(13)] LEFT, UP, RIGHT, DOWN = 0, 1, 2, 3 MOVE = [[0] for u in range(13)] MOVE[0] = [-1, -1, -1, 2] MOVE[1] = [-1, -1, 2, 5] MOVE[2] = [1, 0, 3, 6] MOVE[3] = [2, -1, -1, 7] MOVE[4] = [-1, -1, 5, -1] MOVE[5] = [4, 1, 6, 9]...
false
25.210084
[ "-\"\"\"", "-MOVE[0][LEFT]=MOVE[1][LEFT]=MOVE[4][LEFT]=MOVE[9][LEFT]=MOVE[12][LEFT]=False", "-MOVE[0][UP]=MOVE[1][UP]=MOVE[3][UP]=MOVE[4][UP]=MOVE[8][UP]=False", "-MOVE[0][RIGHT]=MOVE[3][RIGHT]=MOVE[8][RIGHT]=MOVE[11][RIGHT]=MOVE[12][RIGHT]=False", "-MOVE[4][DOWN]=MOVE[8][DOWN]=MOVE[9][DOWN]=MOVE[11][DOWN]=...
false
0.118381
0.106132
1.115418
[ "s537275175", "s055213504" ]
u686036872
p02887
python
s574622293
s235533086
46
38
4,084
4,644
Accepted
Accepted
17.39
N = int(eval(input())) S=list(eval(input())) x = S[0] ans = 1 for i in range(1, N): if x != S[i]: ans += 1 x = S[i] print(ans)
import itertools N = int(eval(input())) S = list(eval(input())) s = itertools.groupby(S) ans = [] for key, group in s: ans.append(key) print((len(ans)))
9
10
139
154
N = int(eval(input())) S = list(eval(input())) x = S[0] ans = 1 for i in range(1, N): if x != S[i]: ans += 1 x = S[i] print(ans)
import itertools N = int(eval(input())) S = list(eval(input())) s = itertools.groupby(S) ans = [] for key, group in s: ans.append(key) print((len(ans)))
false
10
[ "+import itertools", "+", "-x = S[0]", "-ans = 1", "-for i in range(1, N):", "- if x != S[i]:", "- ans += 1", "- x = S[i]", "-print(ans)", "+s = itertools.groupby(S)", "+ans = []", "+for key, group in s:", "+ ans.append(key)", "+print((len(ans)))" ]
false
0.008095
0.037518
0.215755
[ "s574622293", "s235533086" ]
u745385679
p03478
python
s802236645
s242792110
33
26
2,940
2,940
Accepted
Accepted
21.21
N, A, B = list(map(int, input().split())) u = 0 for i in range(N+1): num = sum(map(int, list(str(i)))) if num >= A and num <= B: u += i print(u)
def find_sum_of_digits(n): sum = 0 while (n > 0): sum += n % 10 n //= 10 return sum N, A, B = list(map(int, input().split())) u = 0 for i in range(N+1): # num = sum(map(int, list(str(i)))) num = find_sum_of_digits(i) if num >= A and num <= B: u += i print(u...
7
15
161
316
N, A, B = list(map(int, input().split())) u = 0 for i in range(N + 1): num = sum(map(int, list(str(i)))) if num >= A and num <= B: u += i print(u)
def find_sum_of_digits(n): sum = 0 while n > 0: sum += n % 10 n //= 10 return sum N, A, B = list(map(int, input().split())) u = 0 for i in range(N + 1): # num = sum(map(int, list(str(i)))) num = find_sum_of_digits(i) if num >= A and num <= B: u += i print(u)
false
53.333333
[ "+def find_sum_of_digits(n):", "+ sum = 0", "+ while n > 0:", "+ sum += n % 10", "+ n //= 10", "+ return sum", "+", "+", "- num = sum(map(int, list(str(i))))", "+ # num = sum(map(int, list(str(i))))", "+ num = find_sum_of_digits(i)" ]
false
0.038165
0.040595
0.940159
[ "s802236645", "s242792110" ]
u875291233
p03053
python
s365998496
s302088272
662
432
141,148
87,900
Accepted
Accepted
34.74
# coding: utf-8 # Your code here! import collections h,w = [int(i) for i in input().split()] board = [eval(input()) for j in range(h)] # 縦「n」行 d4 = [[1,0],[0,1],[-1,0],[0,-1]] memo = [[-1]*w for j in range(h)] dist = [[100000]*w for j in range(h)] q = collections.deque() for i in range(h): for j i...
import collections #deque h,w = [int(i) for i in input().split()] board = [eval(input()) for j in range(h)] # 縦「n」行 dx4=[0, 1, 0,-1] dy4=[1, 0,-1, 0] #dx8=[0, 1, 0,-1,1,-1,1,-1] #dy8=[1, 0,-1, 0,1,1,-1,-1] #memo: 負なら未確認、0以上なら最短距離 memo = [[-1]*w for _ in range(h)] q = collections.deque() #初期状態をキューに入れる-...
48
46
980
1,475
# coding: utf-8 # Your code here! import collections h, w = [int(i) for i in input().split()] board = [eval(input()) for j in range(h)] # 縦「n」行 d4 = [[1, 0], [0, 1], [-1, 0], [0, -1]] memo = [[-1] * w for j in range(h)] dist = [[100000] * w for j in range(h)] q = collections.deque() for i in range(h): for j in ra...
import collections # deque h, w = [int(i) for i in input().split()] board = [eval(input()) for j in range(h)] # 縦「n」行 dx4 = [0, 1, 0, -1] dy4 = [1, 0, -1, 0] # dx8=[0, 1, 0,-1,1,-1,1,-1] # dy8=[1, 0,-1, 0,1,1,-1,-1] # memo: 負なら未確認、0以上なら最短距離 memo = [[-1] * w for _ in range(h)] q = collections.deque() # 初期状態をキューに入れる--...
false
4.166667
[ "-# coding: utf-8", "-# Your code here!", "-import collections", "+import collections # deque", "-d4 = [[1, 0], [0, 1], [-1, 0], [0, -1]]", "-memo = [[-1] * w for j in range(h)]", "-dist = [[100000] * w for j in range(h)]", "+dx4 = [0, 1, 0, -1]", "+dy4 = [1, 0, -1, 0]", "+# dx8=[0, 1, 0,-1,1,-1,...
false
0.037588
0.036527
1.029059
[ "s365998496", "s302088272" ]
u572122511
p02688
python
s267962038
s592663651
26
22
9,184
9,192
Accepted
Accepted
15.38
N, K = list(map(int, input().split())) haves = [False for _ in range(N)] def judge_Flag(flags): As = list(map(int, input().split())) for A in As: flags[A - 1] = True for _ in range(K): people_num = int(eval(input())) judge_Flag(haves) print((haves.count(False)))
N, K = list(map(int, input().split())) haves = [False for _ in range(N)] def judge_Flag(flags, num): As = list(map(int, input().split())) for i in range(num): flags[As[i] - 1] = True for _ in range(K): people_num = int(eval(input())) judge_Flag(haves, people_num) print((hav...
12
12
291
329
N, K = list(map(int, input().split())) haves = [False for _ in range(N)] def judge_Flag(flags): As = list(map(int, input().split())) for A in As: flags[A - 1] = True for _ in range(K): people_num = int(eval(input())) judge_Flag(haves) print((haves.count(False)))
N, K = list(map(int, input().split())) haves = [False for _ in range(N)] def judge_Flag(flags, num): As = list(map(int, input().split())) for i in range(num): flags[As[i] - 1] = True for _ in range(K): people_num = int(eval(input())) judge_Flag(haves, people_num) print((haves.count(False)))
false
0
[ "-def judge_Flag(flags):", "+def judge_Flag(flags, num):", "- for A in As:", "- flags[A - 1] = True", "+ for i in range(num):", "+ flags[As[i] - 1] = True", "- judge_Flag(haves)", "+ judge_Flag(haves, people_num)" ]
false
0.036228
0.037374
0.969348
[ "s267962038", "s592663651" ]
u347640436
p02793
python
s019086375
s137131306
1,889
480
6,140
14,540
Accepted
Accepted
74.59
from sys import stdin from fractions import gcd from functools import reduce N = int(stdin.readline()) A = list(map(int, stdin.readline().split())) lcm = reduce(lambda a, b: a * b // gcd(a, b), A) print((sum(lcm // a for a in A) % 1000000007))
# エラトステネスの篩, フェルマーの小定理 max_A = 1000000 N = int(eval(input())) A = list(map(int, input().split())) sieve = [0] * (max_A + 1) sieve[0] = -1 sieve[1] = -1 for i in range(2, max_A + 1): if sieve[i] != 0: continue sieve[i] = i for j in range(i * i, max_A + 1, i): if sieve[j] == 0:...
9
42
252
935
from sys import stdin from fractions import gcd from functools import reduce N = int(stdin.readline()) A = list(map(int, stdin.readline().split())) lcm = reduce(lambda a, b: a * b // gcd(a, b), A) print((sum(lcm // a for a in A) % 1000000007))
# エラトステネスの篩, フェルマーの小定理 max_A = 1000000 N = int(eval(input())) A = list(map(int, input().split())) sieve = [0] * (max_A + 1) sieve[0] = -1 sieve[1] = -1 for i in range(2, max_A + 1): if sieve[i] != 0: continue sieve[i] = i for j in range(i * i, max_A + 1, i): if sieve[j] == 0: sie...
false
78.571429
[ "-from sys import stdin", "-from fractions import gcd", "-from functools import reduce", "-", "-N = int(stdin.readline())", "-A = list(map(int, stdin.readline().split()))", "-lcm = reduce(lambda a, b: a * b // gcd(a, b), A)", "-print((sum(lcm // a for a in A) % 1000000007))", "+# エラトステネスの篩, フェルマーの小定...
false
0.230801
0.817618
0.282284
[ "s019086375", "s137131306" ]
u263352518
p03835
python
s908261139
s421823010
1,888
1,637
3,060
3,060
Accepted
Accepted
13.29
nyu = eval(input()) nyu = nyu.split() k = int(nyu[0]) s = int(nyu[1]) n = 0 for x in range(k+1): for y in range(k+1): if x+y > s or s - (x+y) > k: #print(str(x) + " " + str(y)) continue; else: n +=1; print(n)
nyu = eval(input()) nyu = nyu.split() k = int(nyu[0]) s = int(nyu[1]) n = 0 for x in range(k+1): for y in range(k+1): if x+y > s: break elif s - (x+y) > k: #print(str(x) + " " + str(y)) continue; else: n +=1; print(n)
16
18
248
269
nyu = eval(input()) nyu = nyu.split() k = int(nyu[0]) s = int(nyu[1]) n = 0 for x in range(k + 1): for y in range(k + 1): if x + y > s or s - (x + y) > k: # print(str(x) + " " + str(y)) continue else: n += 1 print(n)
nyu = eval(input()) nyu = nyu.split() k = int(nyu[0]) s = int(nyu[1]) n = 0 for x in range(k + 1): for y in range(k + 1): if x + y > s: break elif s - (x + y) > k: # print(str(x) + " " + str(y)) continue else: n += 1 print(n)
false
11.111111
[ "- if x + y > s or s - (x + y) > k:", "+ if x + y > s:", "+ break", "+ elif s - (x + y) > k:" ]
false
0.046843
0.15653
0.299259
[ "s908261139", "s421823010" ]
u060938295
p03170
python
s530428502
s262531692
1,394
775
13,540
14,308
Accepted
Accepted
44.4
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 18:20:35 2020 """ import sys import numpy as np sys.setrecursionlimit(10 ** 9) #def input(): # return sys.stdin.readline()[:-1] mod = 10**9+7 #N = int(input()) N, K = list(map(int,input().split())) A = np.array(list(map(int,input().split()))) dp ...
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 18:20:35 2020 """ import sys import numpy as np sys.setrecursionlimit(10 ** 9) #def input(): # return sys.stdin.readline()[:-1] mod = 10**9+7 #N = int(input()) N, K = list(map(int,input().split())) A = np.array(list(map(int,input().split()))) dp ...
32
31
590
558
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 18:20:35 2020 """ import sys import numpy as np sys.setrecursionlimit(10**9) # def input(): # return sys.stdin.readline()[:-1] mod = 10**9 + 7 # N = int(input()) N, K = list(map(int, input().split())) A = np.array(list(map(int, input().split()))) dp = [True for i in...
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 18:20:35 2020 """ import sys import numpy as np sys.setrecursionlimit(10**9) # def input(): # return sys.stdin.readline()[:-1] mod = 10**9 + 7 # N = int(input()) N, K = list(map(int, input().split())) A = np.array(list(map(int, input().split()))) dp = [True for i in...
false
3.125
[ "-dp = [True for i in range(K + 1)]", "-for i in range(K, -1, -1):", "+dp = [True for i in range(K + A[-1] + 1)]", "+for i in range(K):", "- if i - a >= 0:", "- dp[i - a] = False", "+ dp[i + a] = False", "-if dp[0]:", "+if dp[K]:" ]
false
0.259935
0.382552
0.679476
[ "s530428502", "s262531692" ]
u747602774
p02838
python
s475273566
s176207190
992
769
122,936
137,144
Accepted
Accepted
22.48
n = int(eval(input())) a = list(map(int,input().split())) x = [0 for i in range(62)] for i in range(n): b = bin(a[i]) for i in range(len(b)-2): if b[-1-i] == '1': x[-i-1] += 1 mod = 10**9+7 ans = 0 two = 1 for i in range(1,62): ans = (ans + x[-i]*(n-x[-i])*two)%mod two =...
n = int(eval(input())) a = list(map(int,input().split())) mod = 10**9+7 ans = 0 for i in range(60): c = sum([1 for ai in a if (ai >> i) & 1]) ans += (1 << i) * c * (n-c) ans %= mod print(ans)
15
10
337
207
n = int(eval(input())) a = list(map(int, input().split())) x = [0 for i in range(62)] for i in range(n): b = bin(a[i]) for i in range(len(b) - 2): if b[-1 - i] == "1": x[-i - 1] += 1 mod = 10**9 + 7 ans = 0 two = 1 for i in range(1, 62): ans = (ans + x[-i] * (n - x[-i]) * two) % mod ...
n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 for i in range(60): c = sum([1 for ai in a if (ai >> i) & 1]) ans += (1 << i) * c * (n - c) ans %= mod print(ans)
false
33.333333
[ "-x = [0 for i in range(62)]", "-for i in range(n):", "- b = bin(a[i])", "- for i in range(len(b) - 2):", "- if b[-1 - i] == \"1\":", "- x[-i - 1] += 1", "-two = 1", "-for i in range(1, 62):", "- ans = (ans + x[-i] * (n - x[-i]) * two) % mod", "- two = two * 2 % mod",...
false
0.04114
0.047115
0.873183
[ "s475273566", "s176207190" ]
u985076807
p03680
python
s375954191
s786592975
107
94
24,228
24,228
Accepted
Accepted
12.15
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b import sys def model(): e = list(map(int, sys.stdin)) cur = e[1] for i in range(e[0]): if cur == 2: print((i + 1)) break cur = e[cur] else: print((-1)) def input_lines(): "...
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b import sys def model(): e = list(map(int, sys.stdin)) cur = e[1] for i in range(e[0]): if cur == 2: print((i + 1)) break cur = e[cur] else: print((-1)) def input_lines(): "...
50
50
981
981
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b import sys def model(): e = list(map(int, sys.stdin)) cur = e[1] for i in range(e[0]): if cur == 2: print((i + 1)) break cur = e[cur] else: print((-1)) def input_lines(): """hell?""" line...
# https://beta.atcoder.jp/contests/abc065/tasks/abc065_b import sys def model(): e = list(map(int, sys.stdin)) cur = e[1] for i in range(e[0]): if cur == 2: print((i + 1)) break cur = e[cur] else: print((-1)) def input_lines(): """hell?""" line...
false
0
[ "- if index == 2:", "+ if index is None:", "+ print((-1))", "+ exit()", "+ elif index == 2:", "- exit()", "- elif index is None:", "- print((-1))" ]
false
0.04493
0.046349
0.969385
[ "s375954191", "s786592975" ]
u562935282
p03805
python
s567090309
s708402450
70
27
4,288
3,064
Accepted
Accepted
61.43
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)] n, m = list(map(int, input().split())) e = ary(n, n, False) for i in range(m): a, b = list(map(int, input().split())) #頂点を0-indexedに変換 a -= 1 b -= 1 e[a][b] = True e[b][a] = True ps = set() ps.add('0') for cnt in ra...
def main(): import sys sys.setrecursionlimit(10 ** 7) N, M = list(map(int, input().split())) g = tuple(set() for _ in range(N)) for _ in range(M): a, b = (int(x) - 1 for x in input().split()) g[a].add(b) g[b].add(a) def dfs(v=0, visited=1 << 0): ...
34
39
703
758
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)] n, m = list(map(int, input().split())) e = ary(n, n, False) for i in range(m): a, b = list(map(int, input().split())) # 頂点を0-indexedに変換 a -= 1 b -= 1 e[a][b] = True e[b][a] = True ps = set() ps.add("0") for cnt in range(1, ...
def main(): import sys sys.setrecursionlimit(10**7) N, M = list(map(int, input().split())) g = tuple(set() for _ in range(N)) for _ in range(M): a, b = (int(x) - 1 for x in input().split()) g[a].add(b) g[b].add(a) def dfs(v=0, visited=1 << 0): if visited == (1 <...
false
12.820513
[ "-def ary(r, c, v):", "- return [[v for _ in range(c)] for _ in range(r)]", "+def main():", "+ import sys", "+", "+ sys.setrecursionlimit(10**7)", "+ N, M = list(map(int, input().split()))", "+ g = tuple(set() for _ in range(N))", "+ for _ in range(M):", "+ a, b = (int(x) ...
false
0.077351
0.037095
2.08521
[ "s567090309", "s708402450" ]
u028014940
p03043
python
s739802641
s302682873
303
51
21,384
7,832
Accepted
Accepted
83.17
import numpy as np n,k=list(map(int,input().split())) n_lis=[int(i) for i in range(1,n+1)] p=float(1/n) p_lis=[] for i in range(n): count=0 if n_lis[i]<k: atai=float(k/n_lis[i]) for j in range(10000): atai=float(atai/2) count+=1 if atai<=...
import math n,k=list(map(int,input().split())) n_lis=[int(i) for i in range(1,n+1)] p=float(1/n) p_lis=[] for i in range(n): if n_lis[i]<k: atai=float(k/n_lis[i]) kaisu=-(-math.log(atai,2)//1) # loop処理しなくてよいので記述が楽 p_lis.append((1/2)**(kaisu)) else: p_lis.append(1) p...
28
14
460
332
import numpy as np n, k = list(map(int, input().split())) n_lis = [int(i) for i in range(1, n + 1)] p = float(1 / n) p_lis = [] for i in range(n): count = 0 if n_lis[i] < k: atai = float(k / n_lis[i]) for j in range(10000): atai = float(atai / 2) count += 1 i...
import math n, k = list(map(int, input().split())) n_lis = [int(i) for i in range(1, n + 1)] p = float(1 / n) p_lis = [] for i in range(n): if n_lis[i] < k: atai = float(k / n_lis[i]) kaisu = -(-math.log(atai, 2) // 1) # loop処理しなくてよいので記述が楽 p_lis.append((1 / 2) ** (kaisu)) else: ...
false
50
[ "-import numpy as np", "+import math", "- count = 0", "- for j in range(10000):", "- atai = float(atai / 2)", "- count += 1", "- if atai <= 1:", "- break", "- p_lis.append((1 / 2) ** (count))", "+ kaisu = -(-math.log(atai, 2) ...
false
0.061376
0.053703
1.142874
[ "s739802641", "s302682873" ]
u724687935
p02632
python
s895704072
s403813901
865
241
122,836
138,400
Accepted
Accepted
72.14
def prepare(n): global MOD modFacts = [0] * (n + 1) modFacts[0] = 1 for i in range(n): modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD invs = [1] * (n + 1) invs[n] = pow(modFacts[n], MOD - 2, MOD) for i in range(n, 1, -1): invs[i - 1] = (invs[i] * i) % MOD r...
def prepare(n): global MOD modFacts = [0] * (n + 1) modFacts[0] = 1 for i in range(n): modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD invs = [1] * (n + 1) invs[n] = pow(modFacts[n], MOD - 2, MOD) for i in range(n, 1, -1): invs[i - 1] = (invs[i] * i) % MOD r...
29
35
674
840
def prepare(n): global MOD modFacts = [0] * (n + 1) modFacts[0] = 1 for i in range(n): modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD invs = [1] * (n + 1) invs[n] = pow(modFacts[n], MOD - 2, MOD) for i in range(n, 1, -1): invs[i - 1] = (invs[i] * i) % MOD return modFacts...
def prepare(n): global MOD modFacts = [0] * (n + 1) modFacts[0] = 1 for i in range(n): modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD invs = [1] * (n + 1) invs[n] = pow(modFacts[n], MOD - 2, MOD) for i in range(n, 1, -1): invs[i - 1] = (invs[i] * i) % MOD return modFacts...
false
17.142857
[ "+pow25 = [1] * max(L + 1, K + 1)", "+pow26 = [1] * max(L + 1, K + 1)", "+for i in range(max(L, K)):", "+ pow25[i + 1] = (pow25[i] * 25) % MOD", "+ pow26[i + 1] = (pow26[i] * 26) % MOD", "- nonSi = (pow(25, n - L, MOD) * pow(26, L + K - n, MOD)) % MOD", "+ nonSi = (pow25[n - L] * pow26[L + K...
false
0.104977
0.039263
2.673656
[ "s895704072", "s403813901" ]
u168578024
p03061
python
s429039297
s566941069
1,114
824
122,144
100,748
Accepted
Accepted
26.03
import copy class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = copy.deepcopy(I) self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = copy.deepcopy(x) def build(se...
import copy class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = x def build(self): for i in range(self.sz - 1, 0, ...
49
49
1,369
1,279
import copy class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = copy.deepcopy(I) self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = copy.deepcopy(x) def build(self): ...
import copy class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I for i in range(self.sz * 2)] def assign(self, k, x): self.seg[k + self.sz] = x def build(self): for i in range(self.sz - 1, 0, -1): ...
false
0
[ "- self.I = copy.deepcopy(I)", "- self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]", "+ self.I = I", "+ self.seg = [I for i in range(self.sz * 2)]", "- self.seg[k + self.sz] = copy.deepcopy(x)", "+ self.seg[k + self.sz] = x", "- self.seg[k] = cop...
false
0.15151
0.061742
2.453909
[ "s429039297", "s566941069" ]
u952708174
p03673
python
s909696241
s741253500
160
117
30,020
28,100
Accepted
Accepted
26.88
def c_pushpush(N, A): from collections import deque ans = deque([]) # リストの先頭への挿入はO(要素数)なので n_parity = N & 1 for i, a in enumerate(A, 1): if n_parity == i & 1: ans.appendleft(a) else: ans.append(a) return ' '.join(map(str, ans)) N = int(eval(input(...
def c_pushpush(): # Aの奇数番目の要素と偶数番目の要素をそれぞれ一塊にすることは変わらない。 # ただし、どちらを左右にするかは N の偶奇によって変わる N = int(eval(input())) A = [int(i) for i in input().split()] return ' '.join(map(str, A[int(N % 2 == 0)::2][::-1] + A[int(not N % 2 == 0)::2])) print((c_pushpush()))
14
8
381
273
def c_pushpush(N, A): from collections import deque ans = deque([]) # リストの先頭への挿入はO(要素数)なので n_parity = N & 1 for i, a in enumerate(A, 1): if n_parity == i & 1: ans.appendleft(a) else: ans.append(a) return " ".join(map(str, ans)) N = int(eval(input())) A = [...
def c_pushpush(): # Aの奇数番目の要素と偶数番目の要素をそれぞれ一塊にすることは変わらない。 # ただし、どちらを左右にするかは N の偶奇によって変わる N = int(eval(input())) A = [int(i) for i in input().split()] return " ".join( map(str, A[int(N % 2 == 0) :: 2][::-1] + A[int(not N % 2 == 0) :: 2]) ) print((c_pushpush()))
false
42.857143
[ "-def c_pushpush(N, A):", "- from collections import deque", "-", "- ans = deque([]) # リストの先頭への挿入はO(要素数)なので", "- n_parity = N & 1", "- for i, a in enumerate(A, 1):", "- if n_parity == i & 1:", "- ans.appendleft(a)", "- else:", "- ans.append(a)", "...
false
0.105853
0.127337
0.831279
[ "s909696241", "s741253500" ]
u280512618
p03244
python
s801106429
s980938787
118
105
20,144
20,564
Accepted
Accepted
11.02
from collections import Counter from collections import deque if __name__ == '__main__': n = int(eval(input())) vs0 = [] vs1 = [] for i,v in enumerate(map(int, input().split())): if i % 2 == 0: vs0.append(v) else: vs1.append(v) vs0 = deque(sorted(...
from collections import Counter if __name__ == '__main__': n = int(eval(input())) vs = [int(s) for s in input().split()] counter0 = list(Counter(vs[0::2]).items()) + [(100001, 0)] counter1 = list(Counter(vs[1::2]).items()) + [(100001, 0)] v0, c0 = max(counter0, key=lambda t: t[1]) v1, c...
40
19
1,166
660
from collections import Counter from collections import deque if __name__ == "__main__": n = int(eval(input())) vs0 = [] vs1 = [] for i, v in enumerate(map(int, input().split())): if i % 2 == 0: vs0.append(v) else: vs1.append(v) vs0 = deque(sorted(list(Counte...
from collections import Counter if __name__ == "__main__": n = int(eval(input())) vs = [int(s) for s in input().split()] counter0 = list(Counter(vs[0::2]).items()) + [(100001, 0)] counter1 = list(Counter(vs[1::2]).items()) + [(100001, 0)] v0, c0 = max(counter0, key=lambda t: t[1]) v1, c1 = max(...
false
52.5
[ "-from collections import deque", "- vs0 = []", "- vs1 = []", "- for i, v in enumerate(map(int, input().split())):", "- if i % 2 == 0:", "- vs0.append(v)", "- else:", "- vs1.append(v)", "- vs0 = deque(sorted(list(Counter(vs0).items()), key=lambda t: t[...
false
0.036683
0.03759
0.975897
[ "s801106429", "s980938787" ]
u814986259
p02779
python
s813975517
s057783192
178
91
33,996
25,684
Accepted
Accepted
48.88
import collections N = int(eval(input())) A = list(map(int, input().split())) table = collections.defaultdict(int) for x in A: table[x] += 1 if table[x] > 1: print("NO") exit(0) print("YES")
N = int(eval(input())) A = set(list(map(int, input().split()))) if len(A) == N: print("YES") else: print("NO")
12
6
222
118
import collections N = int(eval(input())) A = list(map(int, input().split())) table = collections.defaultdict(int) for x in A: table[x] += 1 if table[x] > 1: print("NO") exit(0) print("YES")
N = int(eval(input())) A = set(list(map(int, input().split()))) if len(A) == N: print("YES") else: print("NO")
false
50
[ "-import collections", "-", "-A = list(map(int, input().split()))", "-table = collections.defaultdict(int)", "-for x in A:", "- table[x] += 1", "- if table[x] > 1:", "- print(\"NO\")", "- exit(0)", "-print(\"YES\")", "+A = set(list(map(int, input().split())))", "+if len(A) ...
false
0.097036
0.087963
1.103143
[ "s813975517", "s057783192" ]
u498487134
p03038
python
s495669245
s547925628
902
649
73,752
68,588
Accepted
Accepted
28.05
N,M=list(map(int,input().split())) A=list(map(int,input().split())) CB=[[0,0] for _ in range(M)] for i in range(M): CB[i][1],CB[i][0]=list(map(int,input().split())) A.sort() CB.sort(reverse=True) #Aを小さい順に見る,Cが大きい順に変更操作をして確定していく cc=0 ans=0 for i in range(N): if cc<M: if A[i]<CB[cc][...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,M=MI() A=LI() CB=[[0,0]for _ in range(M)] A.sort() for i in range(M): CB[i]...
23
37
455
685
N, M = list(map(int, input().split())) A = list(map(int, input().split())) CB = [[0, 0] for _ in range(M)] for i in range(M): CB[i][1], CB[i][0] = list(map(int, input().split())) A.sort() CB.sort(reverse=True) # Aを小さい順に見る,Cが大きい順に変更操作をして確定していく cc = 0 ans = 0 for i in range(N): if cc < M: if A[i] < CB[cc]...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N, M = MI() A = LI() CB = [[0, 0] for _ in range(M)] A.sort() for i in range...
false
37.837838
[ "-N, M = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-CB = [[0, 0] for _ in range(M)]", "-for i in range(M):", "- CB[i][1], CB[i][0] = list(map(int, input().split()))", "-A.sort()", "-CB.sort(reverse=True)", "-# Aを小さい順に見る,Cが大きい順に変更操作をして確定していく", "-cc = 0", "-ans = ...
false
0.041557
0.035125
1.183111
[ "s495669245", "s547925628" ]
u790710233
p02583
python
s563135233
s447592245
132
119
9,168
9,188
Accepted
Accepted
9.85
from itertools import combinations n = int(eval(input())) L = list(map(int, input().split())) ans = 0 for subset in combinations(L, 3): subset = sorted(subset) if len(set(subset)) != 3: continue a, b, c = subset if c < a+b: ans += 1 print(ans)
n = int(eval(input())) L = list(map(int, input().split())) ans = 0 for i in range(n): for j in range(i+1, n): for k in range(j+1, n): a, b, c = sorted([L[i], L[j], L[k]]) if a == b or b == c or c == a: continue if c < a+b: ans += ...
13
12
283
328
from itertools import combinations n = int(eval(input())) L = list(map(int, input().split())) ans = 0 for subset in combinations(L, 3): subset = sorted(subset) if len(set(subset)) != 3: continue a, b, c = subset if c < a + b: ans += 1 print(ans)
n = int(eval(input())) L = list(map(int, input().split())) ans = 0 for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): a, b, c = sorted([L[i], L[j], L[k]]) if a == b or b == c or c == a: continue if c < a + b: ans += 1 pr...
false
7.692308
[ "-from itertools import combinations", "-", "-for subset in combinations(L, 3):", "- subset = sorted(subset)", "- if len(set(subset)) != 3:", "- continue", "- a, b, c = subset", "- if c < a + b:", "- ans += 1", "+for i in range(n):", "+ for j in range(i + 1, n):", ...
false
0.075948
0.044116
1.721566
[ "s563135233", "s447592245" ]
u354638986
p03436
python
s555248130
s942577901
1,319
26
3,564
3,564
Accepted
Accepted
98.03
from collections import deque h, w = list(map(int, input().split())) grid = [] for i in range(h): grid.append([j for j in eval(input())]) parent = [[-1 for j in range(w)] for i in range(h)] def bfs(s): q = deque() check = [[0 for j in range(w)] for i in range(h)] q.append(s) chec...
from collections import deque h, w = list(map(int, input().split())) grid = [] for i in range(h): grid.append([j for j in eval(input())]) parent = [[-1 for j in range(w)] for i in range(h)] def bfs(s): q = deque() check = [[0 for j in range(w)] for i in range(h)] q.append(s) chec...
53
59
1,219
1,477
from collections import deque h, w = list(map(int, input().split())) grid = [] for i in range(h): grid.append([j for j in eval(input())]) parent = [[-1 for j in range(w)] for i in range(h)] def bfs(s): q = deque() check = [[0 for j in range(w)] for i in range(h)] q.append(s) check[s[0]][s[1]] = 1...
from collections import deque h, w = list(map(int, input().split())) grid = [] for i in range(h): grid.append([j for j in eval(input())]) parent = [[-1 for j in range(w)] for i in range(h)] def bfs(s): q = deque() check = [[0 for j in range(w)] for i in range(h)] q.append(s) check[s[0]][s[1]] = 1...
false
10.169492
[ "- for i in range(h):", "- for j in range(w):", "- if grid[i][j] == \".\" and check[i][j] == 0:", "- dx, dy = abs(i - u[0]), abs(j - u[1])", "- if dx <= 1 and dy <= 1 and dx + dy < 2:", "- check[i][j] = 1", "- ...
false
0.036658
0.037724
0.971727
[ "s555248130", "s942577901" ]
u445624660
p03659
python
s306478732
s304207700
264
211
86,736
24,800
Accepted
Accepted
20.08
# 累積和をととっといて比較 n = int(eval(input())) arr = list(map(int, input().split())) ruiseki = [0 for _ in range(n)] ruiseki[0] = arr[0] for i in range(1, n): ruiseki[i] += ruiseki[i - 1] + arr[i] inf = 10 ** 20 ans = inf for i in range(n - 1): x = ruiseki[i] y = ruiseki[-1] - x ans = min(ans...
# 累積和が見える n = int(eval(input())) a = list(map(int, input().split())) ruiseki = [0 for _ in range(n)] ruiseki[0] = a[0] for i in range(1, n): ruiseki[i] = ruiseki[i-1] + a[i] ans = 10 ** 16 for i in range(n-1): ans = min(ans, abs(ruiseki[-1] - ruiseki[i]*2)) print(ans)
18
13
340
283
# 累積和をととっといて比較 n = int(eval(input())) arr = list(map(int, input().split())) ruiseki = [0 for _ in range(n)] ruiseki[0] = arr[0] for i in range(1, n): ruiseki[i] += ruiseki[i - 1] + arr[i] inf = 10**20 ans = inf for i in range(n - 1): x = ruiseki[i] y = ruiseki[-1] - x ans = min(ans, abs(x - y)) print(an...
# 累積和が見える n = int(eval(input())) a = list(map(int, input().split())) ruiseki = [0 for _ in range(n)] ruiseki[0] = a[0] for i in range(1, n): ruiseki[i] = ruiseki[i - 1] + a[i] ans = 10**16 for i in range(n - 1): ans = min(ans, abs(ruiseki[-1] - ruiseki[i] * 2)) print(ans)
false
27.777778
[ "-# 累積和をととっといて比較", "+# 累積和が見える", "-arr = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "-ruiseki[0] = arr[0]", "+ruiseki[0] = a[0]", "- ruiseki[i] += ruiseki[i - 1] + arr[i]", "-inf = 10**20", "-ans = inf", "+ ruiseki[i] = ruiseki[i - 1] + a[i]", "+ans = 10**16"...
false
0.076421
0.041465
1.843051
[ "s306478732", "s304207700" ]
u227082700
p02813
python
s187212659
s701451569
43
29
3,060
3,060
Accepted
Accepted
32.56
n=int(eval(input())) p=list(map(int,input().split())) q=list(map(int,input().split())) from itertools import permutations for i,j in enumerate(permutations([i+1 for i in range(n)],n)): if p==list(j):a=i if q==list(j):b=i print((abs(a-b)))
n=int(eval(input())) p=tuple(map(int,input().split())) q=tuple(map(int,input().split())) from itertools import permutations for i,x in enumerate(permutations([i+1 for i in range(n)],n)): if x==p:a=i if x==q:b=i print((abs(a-b)))
8
8
241
231
n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) from itertools import permutations for i, j in enumerate(permutations([i + 1 for i in range(n)], n)): if p == list(j): a = i if q == list(j): b = i print((abs(a - b)))
n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) from itertools import permutations for i, x in enumerate(permutations([i + 1 for i in range(n)], n)): if x == p: a = i if x == q: b = i print((abs(a - b)))
false
0
[ "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "+p = tuple(map(int, input().split()))", "+q = tuple(map(int, input().split()))", "-for i, j in enumerate(permutations([i + 1 for i in range(n)], n)):", "- if p == list(j):", "+for i, x in enumerate(permutations([i + 1 fo...
false
0.054592
0.032136
1.698761
[ "s187212659", "s701451569" ]
u649202997
p03073
python
s153532321
s037456782
45
35
3,188
3,188
Accepted
Accepted
22.22
def main(n): odd = "1" even= "0" if(n[0] =="0"): # zero mode odd = "0" even= "1" return sum((((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n))) print((main(eval(input()))))
def main(n): odd = "1" even= "0" if(n[0] =="0"): # zero mode odd = "0" even= "1" #return sum((((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n))) a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n),2)) b = sum((((i % 2 == 0) and n[i] == even...
10
16
229
472
def main(n): odd = "1" even = "0" if n[0] == "0": # zero mode odd = "0" even = "1" return sum( (((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n)) ) print((main(eval(input()))))
def main(n): odd = "1" even = "0" if n[0] == "0": # zero mode odd = "0" even = "1" # return sum((((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n))) a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n), 2)) b = sum(...
false
37.5
[ "- return sum(", "- (((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd))", "- for i in range(1, len(n))", "- )", "+ # return sum((((i % 2 == 0) and (n[i] == even)) or ((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n)))", "+ a = sum((((i % 2 != 0) and n[i] ...
false
0.047053
0.04846
0.970959
[ "s153532321", "s037456782" ]
u006657459
p03816
python
s465287269
s290510089
48
40
14,564
16,168
Accepted
Accepted
16.67
N = int(eval(input())) A = [int(Ai) for Ai in input().split()] cards = len(set(A)) print((cards if cards % 2 == 1 else cards - 1))
eval(input()) cards = len(set([Ai for Ai in input().split()])) print((cards if cards % 2 == 1 else cards - 1))
4
3
125
104
N = int(eval(input())) A = [int(Ai) for Ai in input().split()] cards = len(set(A)) print((cards if cards % 2 == 1 else cards - 1))
eval(input()) cards = len(set([Ai for Ai in input().split()])) print((cards if cards % 2 == 1 else cards - 1))
false
25
[ "-N = int(eval(input()))", "-A = [int(Ai) for Ai in input().split()]", "-cards = len(set(A))", "+eval(input())", "+cards = len(set([Ai for Ai in input().split()]))" ]
false
0.077106
0.037924
2.033179
[ "s465287269", "s290510089" ]
u532955973
p02606
python
s290492839
s753744851
31
25
9,252
9,196
Accepted
Accepted
19.35
#!/usr/bin/env python3 # atcoder # Türkler var mı? # Herkese memnün oldum import sys iimr = lambda: map(int, sys.stdin.readline().rstrip().split()) readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) MOD = (10 ** 9) + 7 # operować sobie na typie int32_t def 関数(l,r,d): res = 0 ...
#!/usr/bin/env python3 # atcoder # Türkler var mı? # Herkese memnün oldum import sys iimr = lambda: map(int, sys.stdin.readline().rstrip().split()) readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) MOD = (10 ** 9) + 7 # operować sobie na typie int32_t def 関数(l,r,d): res = 0 ...
27
26
559
540
#!/usr/bin/env python3 # atcoder # Türkler var mı? # Herkese memnün oldum import sys iimr = lambda: map(int, sys.stdin.readline().rstrip().split()) readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) MOD = (10**9) + 7 # operować sobie na typie int32_t def 関数(l, r, d): res = 0 for i in range(l,...
#!/usr/bin/env python3 # atcoder # Türkler var mı? # Herkese memnün oldum import sys iimr = lambda: map(int, sys.stdin.readline().rstrip().split()) readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) MOD = (10**9) + 7 # operować sobie na typie int32_t def 関数(l, r, d): res = 0 for i in range(l,...
false
3.703704
[ "- if i % d == 0:", "- res += 1", "+ res += i % d == 0" ]
false
0.037186
0.037052
1.003596
[ "s290492839", "s753744851" ]
u844005364
p03331
python
s645200971
s053249625
24
17
3,316
2,940
Accepted
Accepted
29.17
n = int(eval(input())) print((10 if n in [10 ** x for x in range(6)] else sum(map(int,str(n)))))
n=sum(map(int,eval(input()))) print((10 if n==1 else n))
3
2
92
49
n = int(eval(input())) print((10 if n in [10**x for x in range(6)] else sum(map(int, str(n)))))
n = sum(map(int, eval(input()))) print((10 if n == 1 else n))
false
33.333333
[ "-n = int(eval(input()))", "-print((10 if n in [10**x for x in range(6)] else sum(map(int, str(n)))))", "+n = sum(map(int, eval(input())))", "+print((10 if n == 1 else n))" ]
false
0.044226
0.037127
1.191225
[ "s645200971", "s053249625" ]
u972658925
p03073
python
s678336258
s337970312
90
76
11,088
9,992
Accepted
Accepted
15.56
from distutils.util import strtobool s = eval(input()) ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))] cnt = 0 for i in range(len(s)): if int(s[i]) != ss[i]: cnt += 1 print(cnt)
#from distutils.util import strtobool s = eval(input()) ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))] cnt = 0 for i in range(len(s)): if int(s[i]) != ss[i]: cnt += 1 print(cnt)
10
10
217
218
from distutils.util import strtobool s = eval(input()) ss = [int(s[0]) if x % 2 == 0 else int(s[0]) ^ 1 for x in range(len(s))] cnt = 0 for i in range(len(s)): if int(s[i]) != ss[i]: cnt += 1 print(cnt)
# from distutils.util import strtobool s = eval(input()) ss = [int(s[0]) if x % 2 == 0 else int(s[0]) ^ 1 for x in range(len(s))] cnt = 0 for i in range(len(s)): if int(s[i]) != ss[i]: cnt += 1 print(cnt)
false
0
[ "-from distutils.util import strtobool", "-", "+# from distutils.util import strtobool" ]
false
0.040273
0.032058
1.256232
[ "s678336258", "s337970312" ]
u018771977
p02583
python
s051651515
s550313618
129
93
9,156
9,060
Accepted
Accepted
27.91
#! env/bin/local python3 # -*- coding: utf-8 -*- from itertools import combinations def is_tri(_a, _b, _c): if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b): return True else: return False n = int(eval(input())) sticks = list(map(int, input().split())) h = combinatio...
#! env/bin/local python3 # -*- coding: utf-8 -*- from itertools import combinations def is_tri(_a, _b, _c): if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b): return True else: return False n = int(eval(input())) sticks = list(map(int, input().split())) h = combinatio...
26
26
503
518
#! env/bin/local python3 # -*- coding: utf-8 -*- from itertools import combinations def is_tri(_a, _b, _c): if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b): return True else: return False n = int(eval(input())) sticks = list(map(int, input().split())) h = combinations(sticks, 3) coun...
#! env/bin/local python3 # -*- coding: utf-8 -*- from itertools import combinations def is_tri(_a, _b, _c): if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b): return True else: return False n = int(eval(input())) sticks = list(map(int, input().split())) h = combinations(sticks, 3) coun...
false
0
[ "- a, b, c = sorted([a, b, c])", "- if (a != b) and (b != c):", "+ # a, b, c = sorted([a, b, c])", "+ if (a != b) and (b != c) and (c != a):" ]
false
0.11733
0.047993
2.44475
[ "s051651515", "s550313618" ]