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
u347640436
p02973
python
s374382229
s969861331
510
229
8,828
11,752
Accepted
Accepted
55.1
from collections import deque from bisect import bisect_left N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] t = deque([A[0]]) for a in A[1:]: i = bisect_left(t, a) - 1 if i == -1: t.appendleft(a) else: t[i] = a print((len(t)))
from bisect import bisect_right N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] t = [-A[0]] for a in A[1:]: if a <= -t[-1]: t.append(-a) else: t[bisect_right(t, -a)] = -a print((len(t)))
14
12
275
228
from collections import deque from bisect import bisect_left N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] t = deque([A[0]]) for a in A[1:]: i = bisect_left(t, a) - 1 if i == -1: t.appendleft(a) else: t[i] = a print((len(t)))
from bisect import bisect_right N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] t = [-A[0]] for a in A[1:]: if a <= -t[-1]: t.append(-a) else: t[bisect_right(t, -a)] = -a print((len(t)))
false
14.285714
[ "-from collections import deque", "-from bisect import bisect_left", "+from bisect import bisect_right", "-t = deque([A[0]])", "+t = [-A[0]]", "- i = bisect_left(t, a) - 1", "- if i == -1:", "- t.appendleft(a)", "+ if a <= -t[-1]:", "+ t.append(-a)", "- t[i] = a", ...
false
0.044646
0.043311
1.030824
[ "s374382229", "s969861331" ]
u225388820
p03166
python
s242099194
s651400245
482
393
59,056
194,100
Accepted
Accepted
18.46
#解説AC import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n,m=list(map(int,input().split())) es=[[] for i in range(n)] for i in range(m): x,y=list(map(int,input().split())) es[x-1].append(y-1) dp=[-1]*n def memo(v): if dp[v]+1: #更新済 dp[v]!=-1 return dp[v] ...
# 根付き木に対して根から最大でどれだけかかるかを使う方法 import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n, m = list(map(int, input().split())) co = [[] for i in range(n)] # 有効辺の向きを逆にした for i in range(m): a, b = list(map(int, input().split())) co[b - 1].append(a - 1) dp = [-1] * n def memo(v): ...
28
33
457
610
# 解説AC import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n, m = list(map(int, input().split())) es = [[] for i in range(n)] for i in range(m): x, y = list(map(int, input().split())) es[x - 1].append(y - 1) dp = [-1] * n def memo(v): if dp[v] + 1: # 更新済 dp[v]!=-1 return dp[v...
# 根付き木に対して根から最大でどれだけかかるかを使う方法 import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n, m = list(map(int, input().split())) co = [[] for i in range(n)] # 有効辺の向きを逆にした for i in range(m): a, b = list(map(int, input().split())) co[b - 1].append(a - 1) dp = [-1] * n def memo(v): if dp[v] != ...
false
15.151515
[ "-# 解説AC", "+# 根付き木に対して根から最大でどれだけかかるかを使う方法", "-es = [[] for i in range(n)]", "+co = [[] for i in range(n)] # 有効辺の向きを逆にした", "- x, y = list(map(int, input().split()))", "- es[x - 1].append(y - 1)", "+ a, b = list(map(int, input().split()))", "+ co[b - 1].append(a - 1)", "- if dp[v] + 1...
false
0.04606
0.082443
0.558692
[ "s242099194", "s651400245" ]
u864013199
p03286
python
s050796065
s764044644
176
17
13,356
3,064
Accepted
Accepted
90.34
from numpy import cumsum N = int(eval(input())) lis = [0]*40 tmp = [0,2]+[2**(i*2) for i in range(1,23)] rui = cumsum(tmp) for i in range(40): if i==0: if N%2 == 1: lis[0]=1 else: if (N-rui[(i+1)//2])%((2**i) *2) < 2**i: lis[i]=1 print((int("".join(map(str...
N = int(eval(input())) lis = [0]*40 tmp = [2]+[2**(i*2) for i in range(1,23)] rui = [0] for t in tmp: rui.append(rui[-1]+t) for i in range(40): if i==0: if N%2 == 1: lis[0]=1 else: if (N-rui[(i+1)//2])%((2**i) *2) < 2**i: lis[i]=1 print((int("".join(m...
15
16
332
338
from numpy import cumsum N = int(eval(input())) lis = [0] * 40 tmp = [0, 2] + [2 ** (i * 2) for i in range(1, 23)] rui = cumsum(tmp) for i in range(40): if i == 0: if N % 2 == 1: lis[0] = 1 else: if (N - rui[(i + 1) // 2]) % ((2**i) * 2) < 2**i: lis[i] = 1 print((int(""....
N = int(eval(input())) lis = [0] * 40 tmp = [2] + [2 ** (i * 2) for i in range(1, 23)] rui = [0] for t in tmp: rui.append(rui[-1] + t) for i in range(40): if i == 0: if N % 2 == 1: lis[0] = 1 else: if (N - rui[(i + 1) // 2]) % ((2**i) * 2) < 2**i: lis[i] = 1 print((in...
false
6.25
[ "-from numpy import cumsum", "-", "-tmp = [0, 2] + [2 ** (i * 2) for i in range(1, 23)]", "-rui = cumsum(tmp)", "+tmp = [2] + [2 ** (i * 2) for i in range(1, 23)]", "+rui = [0]", "+for t in tmp:", "+ rui.append(rui[-1] + t)" ]
false
0.552438
0.047144
11.718165
[ "s050796065", "s764044644" ]
u699089116
p02832
python
s796306845
s539041019
240
108
77,516
26,140
Accepted
Accepted
55
n = int(eval(input())) a = list(map(int, input().split())) if 1 not in a: print((-1)) exit() now = 1 ans = 0 for i in a: if i != now: ans += 1 else: now += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 now = 1 for i, v in enumerate(a): if v == now: now += 1 continue else: cnt += 1 print((cnt if cnt != len(a) else -1))
16
13
210
222
n = int(eval(input())) a = list(map(int, input().split())) if 1 not in a: print((-1)) exit() now = 1 ans = 0 for i in a: if i != now: ans += 1 else: now += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 now = 1 for i, v in enumerate(a): if v == now: now += 1 continue else: cnt += 1 print((cnt if cnt != len(a) else -1))
false
18.75
[ "-if 1 not in a:", "- print((-1))", "- exit()", "+cnt = 0", "-ans = 0", "-for i in a:", "- if i != now:", "- ans += 1", "+for i, v in enumerate(a):", "+ if v == now:", "+ now += 1", "+ continue", "- now += 1", "-print(ans)", "+ cnt += 1", ...
false
0.033955
0.033454
1.014973
[ "s796306845", "s539041019" ]
u906428167
p02686
python
s397783588
s498214617
1,110
1,019
181,276
227,984
Accepted
Accepted
8.2
n = int(eval(input())) left = [] mid = [] midminus = [] right = [] L = [] R = [] for i in range(n): s = eval(input()) l = 0 r = 0 for x in s: if x == '(': l += 1 else: if l > 0: l -= 1 else: r += 1 ...
n = int(eval(input())) left = [] mid = [] zero = [] midminus = [] right = [] L = [] R = [] for i in range(n): s = eval(input()) l = 0 r = 0 for x in s: if x == '(': l += 1 else: if l > 0: l -= 1 else: ...
57
60
967
1,039
n = int(eval(input())) left = [] mid = [] midminus = [] right = [] L = [] R = [] for i in range(n): s = eval(input()) l = 0 r = 0 for x in s: if x == "(": l += 1 else: if l > 0: l -= 1 else: r += 1 if l > 0 and r == ...
n = int(eval(input())) left = [] mid = [] zero = [] midminus = [] right = [] L = [] R = [] for i in range(n): s = eval(input()) l = 0 r = 0 for x in s: if x == "(": l += 1 else: if l > 0: l -= 1 else: r += 1 if l > 0...
false
5
[ "+zero = []", "+ elif l == r:", "+ zero.append((r, l))", "-midminus = sorted(midminus, key=lambda x: x[0] - x[1])", "-mid += midminus", "+midminus = sorted(midminus, key=lambda x: -x[1])", "+mid += zero + midminus" ]
false
0.047371
0.046034
1.029043
[ "s397783588", "s498214617" ]
u102275718
p02873
python
s235237307
s587654128
695
433
32,552
31,132
Accepted
Accepted
37.7
import sys input = sys.stdin.readline import numpy as np s = input()[:-1] cnts = [] tmp = 1 for i in range(len(s)-1): if s[i] == s[i+1]: tmp += 1 else: if s[i] == '>': tmp *= -1 cnts.append(tmp) tmp = 1 if s[-1] == '>': tmp *= -1 cnts.appen...
import sys input = sys.stdin.readline s = input()[:-1] a = [0]*(len(s)+1) l = [0]*len(a) r = [0]*len(a) for i in range(1, len(a)): if s[i-1] == '<': l[i] = l[i-1] + 1 for i in range(len(a)-2, -1, -1): if s[i] == '>': r[i] = r[i+1] + 1 for i in range(len(a)): a[...
47
21
889
357
import sys input = sys.stdin.readline import numpy as np s = input()[:-1] cnts = [] tmp = 1 for i in range(len(s) - 1): if s[i] == s[i + 1]: tmp += 1 else: if s[i] == ">": tmp *= -1 cnts.append(tmp) tmp = 1 if s[-1] == ">": tmp *= -1 cnts.append(tmp) idx = 0 a =...
import sys input = sys.stdin.readline s = input()[:-1] a = [0] * (len(s) + 1) l = [0] * len(a) r = [0] * len(a) for i in range(1, len(a)): if s[i - 1] == "<": l[i] = l[i - 1] + 1 for i in range(len(a) - 2, -1, -1): if s[i] == ">": r[i] = r[i + 1] + 1 for i in range(len(a)): a[i] = max(l[i],...
false
55.319149
[ "-import numpy as np", "-", "-cnts = []", "-tmp = 1", "-for i in range(len(s) - 1):", "- if s[i] == s[i + 1]:", "- tmp += 1", "- else:", "- if s[i] == \">\":", "- tmp *= -1", "- cnts.append(tmp)", "- tmp = 1", "-if s[-1] == \">\":", "- tmp *=...
false
0.045534
0.036755
1.238835
[ "s235237307", "s587654128" ]
u896741788
p04000
python
s438315829
s622544717
2,316
676
19,056
119,736
Accepted
Accepted
70.81
h,w,n=map(int,input().split()) spots=set([eval(input().replace(' ','*w+'))-w-1 for i in range(n)]) anss=[0]*10 from itertools import product as pr moves=(tuple(x+w*y for x,y in pr(range(0,3),repeat=2))) for i in spots: a,b=divmod(i,w) pre=[0]*9 for x in range(max(0,a-2),min(h-2,a+1)): for y...
h,w,n=map(int,input().split()) from itertools import product as pr from collections import Counter as co ans=[(h-2)*(w-2)]+[0]*9 io=[tuple(map(int,input().split())) for i in range(n)] for k,v in co(co([(a-x)*w+b-y for x,y in pr(range(3),repeat=2) for a,b in io if h-1>a-x>0<b-y<w-1]).values()).items(): ans[k]=...
21
9
615
358
h, w, n = map(int, input().split()) spots = set([eval(input().replace(" ", "*w+")) - w - 1 for i in range(n)]) anss = [0] * 10 from itertools import product as pr moves = tuple(x + w * y for x, y in pr(range(0, 3), repeat=2)) for i in spots: a, b = divmod(i, w) pre = [0] * 9 for x in range(max(0, a - 2), m...
h, w, n = map(int, input().split()) from itertools import product as pr from collections import Counter as co ans = [(h - 2) * (w - 2)] + [0] * 9 io = [tuple(map(int, input().split())) for i in range(n)] for k, v in co( co( [ (a - x) * w + b - y for x, y in pr(range(3), repeat=2) ...
false
57.142857
[ "-spots = set([eval(input().replace(\" \", \"*w+\")) - w - 1 for i in range(n)])", "-anss = [0] * 10", "+from collections import Counter as co", "-moves = tuple(x + w * y for x, y in pr(range(0, 3), repeat=2))", "-for i in spots:", "- a, b = divmod(i, w)", "- pre = [0] * 9", "- for x in range...
false
0.042789
0.037853
1.130395
[ "s438315829", "s622544717" ]
u644972721
p02540
python
s178005900
s274550944
1,983
1,554
149,008
140,176
Accepted
Accepted
21.63
import heapq from collections import deque def bfs(i, c): color[i] = c cnt[c] += 1 q = deque() q.append(i) while q: j = q.popleft() for k in G[j]: if color[k] == -1: color[k] = c cnt[c] += 1 q.append(k) r...
import heapq from collections import deque def bfs(i, c): color[i] = c cnt[c] += 1 q = deque() q.append(i) while q: j = q.popleft() for k in G[j]: if color[k] == -1: color[k] = c cnt[c] += 1 q.append(k) r...
49
51
1,003
1,064
import heapq from collections import deque def bfs(i, c): color[i] = c cnt[c] += 1 q = deque() q.append(i) while q: j = q.popleft() for k in G[j]: if color[k] == -1: color[k] = c cnt[c] += 1 q.append(k) return n = in...
import heapq from collections import deque def bfs(i, c): color[i] = c cnt[c] += 1 q = deque() q.append(i) while q: j = q.popleft() for k in G[j]: if color[k] == -1: color[k] = c cnt[c] += 1 q.append(k) return n = in...
false
3.921569
[ "- heapq.heappush(h, [xy[i][1], xy[i][2]])", "+ # heapq.heappush(h, [xy[i][1], xy[i][2]])", "+ else:", "+ heapq.heappush(h, [xy[i][1], xy[i][2]])" ]
false
0.049683
0.044143
1.125497
[ "s178005900", "s274550944" ]
u285681431
p04000
python
s920336501
s421882453
1,059
705
164,288
249,012
Accepted
Accepted
33.43
from collections import defaultdict from collections import Counter H, W, N = list(map(int, input().split())) # 3*3マスの処理用リスト dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] # そのマスを中心とする3*3グリッドに含まれる黒マスの数 dict = defaultdict(int) for i in range(N): a, b = li...
from collections import Counter H, W, N = list(map(int, input().split())) # 3*3マスの処理用リスト dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] # そのマスを中心とする3*3グリッドに含まれる黒マスの数 dict = {} for i in range(N): a, b = list(map(int, input().split())) for dy, dx in di...
33
35
833
895
from collections import defaultdict from collections import Counter H, W, N = list(map(int, input().split())) # 3*3マスの処理用リスト dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] # そのマスを中心とする3*3グリッドに含まれる黒マスの数 dict = defaultdict(int) for i in range(N): a, b = list(map(int, input().spl...
from collections import Counter H, W, N = list(map(int, input().split())) # 3*3マスの処理用リスト dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]] # そのマスを中心とする3*3グリッドに含まれる黒マスの数 dict = {} for i in range(N): a, b = list(map(int, input().split())) for dy, dx in dir: # 3*3グリッドは、H...
false
5.714286
[ "-from collections import defaultdict", "-dict = defaultdict(int)", "+dict = {}", "- dict[(a + dy, b + dx)] += 1", "+ if (a + dy, b + dx) not in dict:", "+ dict[(a + dy, b + dx)] = 1", "+ else:", "+ dict[(a + dy, b + dx)] += 1" ]
false
0.036729
0.043409
0.8461
[ "s920336501", "s421882453" ]
u562016607
p02886
python
s927670451
s706612603
172
17
38,512
2,940
Accepted
Accepted
90.12
N=int(eval(input())) d=[int(i) for i in input().split()] ans=0 for i in range(N): for j in range(i+1,N): ans+=d[i]*d[j] print(ans)
N=int(eval(input())) d=[int(i) for i in input().split()] X=sum([i*i for i in d]) print(((sum(d)**2-X)//2))
7
4
137
102
N = int(eval(input())) d = [int(i) for i in input().split()] ans = 0 for i in range(N): for j in range(i + 1, N): ans += d[i] * d[j] print(ans)
N = int(eval(input())) d = [int(i) for i in input().split()] X = sum([i * i for i in d]) print(((sum(d) ** 2 - X) // 2))
false
42.857143
[ "-ans = 0", "-for i in range(N):", "- for j in range(i + 1, N):", "- ans += d[i] * d[j]", "-print(ans)", "+X = sum([i * i for i in d])", "+print(((sum(d) ** 2 - X) // 2))" ]
false
0.047617
0.042679
1.115685
[ "s927670451", "s706612603" ]
u794173881
p03173
python
s840662623
s681115635
546
406
47,196
43,500
Accepted
Accepted
25.64
n = int(eval(input())) a = list(map(int, input().split())) #dp[l][r] = [l, r)区間のスライムを合体するときのコストの最小値 dp = [[float("inf")]*(n+1) for i in range(n+1)] for i in range(n): dp[i][i] = 0 #cost[r]-cost[l] = [l, r)区間を合計したときのスライムの総和 cost = [0]*(n+1) for i in range(n): cost[i+1] = cost[i] + a[i] #メモ化再帰でdp[...
n = int(eval(input())) a = list(map(int, input().split())) ruiseki = [0] * (n+1) for i in range(n): ruiseki[i+1] = ruiseki[i] + a[i] dp = [[-1]*(n+1) for i in range(n+1)] def solve(l, r): if dp[l][r] != -1: return dp[l][r] if r - l == 1: dp[l][r] = 0 return dp[l][r] ...
30
22
768
508
n = int(eval(input())) a = list(map(int, input().split())) # dp[l][r] = [l, r)区間のスライムを合体するときのコストの最小値 dp = [[float("inf")] * (n + 1) for i in range(n + 1)] for i in range(n): dp[i][i] = 0 # cost[r]-cost[l] = [l, r)区間を合計したときのスライムの総和 cost = [0] * (n + 1) for i in range(n): cost[i + 1] = cost[i] + a[i] # メモ化再帰でdp[0...
n = int(eval(input())) a = list(map(int, input().split())) ruiseki = [0] * (n + 1) for i in range(n): ruiseki[i + 1] = ruiseki[i] + a[i] dp = [[-1] * (n + 1) for i in range(n + 1)] def solve(l, r): if dp[l][r] != -1: return dp[l][r] if r - l == 1: dp[l][r] = 0 return dp[l][r] a...
false
26.666667
[ "-# dp[l][r] = [l, r)区間のスライムを合体するときのコストの最小値", "-dp = [[float(\"inf\")] * (n + 1) for i in range(n + 1)]", "+ruiseki = [0] * (n + 1)", "- dp[i][i] = 0", "-# cost[r]-cost[l] = [l, r)区間を合計したときのスライムの総和", "-cost = [0] * (n + 1)", "-for i in range(n):", "- cost[i + 1] = cost[i] + a[i]", "-# メモ化再帰でdp...
false
0.059159
0.034969
1.691729
[ "s840662623", "s681115635" ]
u150984829
p02386
python
s414241098
s078814861
130
70
5,608
5,608
Accepted
Accepted
46.15
n=int(eval(input())) a=[list(map(int,input().split()))for _ in range(n)] def f(): for i in range(n-1): d=a[i][:];d[3],d[4]=d[4],d[3] for j in range(i+1,n): e=a[j][:];e[3],e[4]=e[4],e[3] for p in('012345','152043','215304','302541','410352','514320'): f=[d[int(k)]for k in p] g=f[1:5]*2 f...
n=int(eval(input())) a=[list(map(int,input().split()))for _ in range(n)] def f(): for i in range(n-1): d=a[i][:];d[3],d[4]=d[4],d[3] for j in range(i+1,n): e=a[j][:];e[3],e[4]=e[4],e[3] for p in('012345','152043','215304','302541','410352','514320'): f=[d[int(k)]for k in p] if f[0]==e[0]: ...
16
16
442
444
n = int(eval(input())) a = [list(map(int, input().split())) for _ in range(n)] def f(): for i in range(n - 1): d = a[i][:] d[3], d[4] = d[4], d[3] for j in range(i + 1, n): e = a[j][:] e[3], e[4] = e[4], e[3] for p in ("012345", "152043", "215304", "3025...
n = int(eval(input())) a = [list(map(int, input().split())) for _ in range(n)] def f(): for i in range(n - 1): d = a[i][:] d[3], d[4] = d[4], d[3] for j in range(i + 1, n): e = a[j][:] e[3], e[4] = e[4], e[3] for p in ("012345", "152043", "215304", "3025...
false
0
[ "- g = f[1:5] * 2", "- for k in range(4):", "- if g[k : k + 4] == e[1:5]:", "- if f[0] == e[0]:", "- if f[5] == e[5]:", "+ if f[0] == e[0]:", "+ if f[5] == e[5]:", "+ ...
false
0.03738
0.03792
0.985778
[ "s414241098", "s078814861" ]
u795630164
p03854
python
s858265442
s289180990
120
62
3,444
3,188
Accepted
Accepted
48.33
import re S = eval(input()) S = S[::-1] # 文字列反転 pattern = ["dream", "dreamer", "erase", "eraser"] for i in range(len(pattern)): pattern[i] = pattern[i][::-1] fin = False while not fin: if S == '': print("YES") exit() fin = True for x in pattern: if re.match(x...
S = eval(input()) s = '' ar = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(1, len(S)+1): s = S[-i] + s if s in ar: s = '' if len(s) > 10: break if len(s) == 0: print('YES') else: print('NO')
23
14
415
244
import re S = eval(input()) S = S[::-1] # 文字列反転 pattern = ["dream", "dreamer", "erase", "eraser"] for i in range(len(pattern)): pattern[i] = pattern[i][::-1] fin = False while not fin: if S == "": print("YES") exit() fin = True for x in pattern: if re.match(x, S): S...
S = eval(input()) s = "" ar = ["dream", "dreamer", "erase", "eraser"] for i in range(1, len(S) + 1): s = S[-i] + s if s in ar: s = "" if len(s) > 10: break if len(s) == 0: print("YES") else: print("NO")
false
39.130435
[ "-import re", "-", "-S = S[::-1] # 文字列反転", "-pattern = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "-for i in range(len(pattern)):", "- pattern[i] = pattern[i][::-1]", "-fin = False", "-while not fin:", "- if S == \"\":", "- print(\"YES\")", "- exit()", "- fin = T...
false
0.062569
0.044325
1.411594
[ "s858265442", "s289180990" ]
u897329068
p03720
python
s042190608
s601301097
19
17
3,064
3,060
Accepted
Accepted
10.53
n,m = list(map(int,input().split())) abm = [list(map(int,input().split())) for _ in range(m)] countDic = {} for nn in range(n+1): countDic[nn] = 0 for ab in abm: countDic[ab[0]] += 1 countDic[ab[1]] += 1 ks = list(countDic.keys()) ks = sorted(ks)[1:] for k in ks: print((countDic[k]))
n,m = list(map(int,input().split())) ans = [0]*n for _ in range(m): a,b = list(map(int,input().split())) ans[a-1]+=1 ans[b-1]+=1 for an in ans: print(an)
17
10
296
157
n, m = list(map(int, input().split())) abm = [list(map(int, input().split())) for _ in range(m)] countDic = {} for nn in range(n + 1): countDic[nn] = 0 for ab in abm: countDic[ab[0]] += 1 countDic[ab[1]] += 1 ks = list(countDic.keys()) ks = sorted(ks)[1:] for k in ks: print((countDic[k]))
n, m = list(map(int, input().split())) ans = [0] * n for _ in range(m): a, b = list(map(int, input().split())) ans[a - 1] += 1 ans[b - 1] += 1 for an in ans: print(an)
false
41.176471
[ "-abm = [list(map(int, input().split())) for _ in range(m)]", "-countDic = {}", "-for nn in range(n + 1):", "- countDic[nn] = 0", "-for ab in abm:", "- countDic[ab[0]] += 1", "- countDic[ab[1]] += 1", "-ks = list(countDic.keys())", "-ks = sorted(ks)[1:]", "-for k in ks:", "- print((c...
false
0.039805
0.036468
1.091507
[ "s042190608", "s601301097" ]
u761320129
p04035
python
s870881805
s644027366
108
96
14,052
14,052
Accepted
Accepted
11.11
N,L = map(int,input().split()) A = list(map(int,input().split())) last = -1 for i,(a,b) in enumerate(zip(A,A[1:])): if a+b >= L: last = i+1 break else: print('Impossible') exit() print('Possible') ans = [n for n in range(1,last)] + [n for n in range(N-1,last,-1)] ans.append(l...
N,L = map(int,input().split()) A = list(map(int,input().split())) last = -1 for i,(a,b) in enumerate(zip(A,A[1:])): if a+b >= L: last = i break if last < 0: print('Impossible') exit() print('Possible') ans = list(range(1,i+1)) + list(range(N-1,i,-1)) print(*ans, sep='\n')
16
15
347
316
N, L = map(int, input().split()) A = list(map(int, input().split())) last = -1 for i, (a, b) in enumerate(zip(A, A[1:])): if a + b >= L: last = i + 1 break else: print("Impossible") exit() print("Possible") ans = [n for n in range(1, last)] + [n for n in range(N - 1, last, -1)] ans.append(la...
N, L = map(int, input().split()) A = list(map(int, input().split())) last = -1 for i, (a, b) in enumerate(zip(A, A[1:])): if a + b >= L: last = i break if last < 0: print("Impossible") exit() print("Possible") ans = list(range(1, i + 1)) + list(range(N - 1, i, -1)) print(*ans, sep="\n")
false
6.25
[ "- last = i + 1", "+ last = i", "-else:", "+if last < 0:", "-ans = [n for n in range(1, last)] + [n for n in range(N - 1, last, -1)]", "-ans.append(last)", "+ans = list(range(1, i + 1)) + list(range(N - 1, i, -1))" ]
false
0.035636
0.034104
1.044947
[ "s870881805", "s644027366" ]
u493520238
p02973
python
s106458545
s661673195
180
100
80,644
77,440
Accepted
Accepted
44.44
from bisect import bisect_left, bisect_right n = int(eval(input())) col_maxs = [] for _ in range(n): a = int(eval(input())) * (-1) if not col_maxs: col_maxs.append(a) continue curr_max = col_maxs[-1] if a >= curr_max: col_maxs.append(a) else: # aより大きい最...
from bisect import bisect_left, bisect_right import sys input = sys.stdin.readline n = int(eval(input())) col_maxs = [] for _ in range(n): a = int(eval(input())) * (-1) if not col_maxs: col_maxs.append(a) continue curr_max = col_maxs[-1] if a >= curr_max: col_maxs...
19
21
415
455
from bisect import bisect_left, bisect_right n = int(eval(input())) col_maxs = [] for _ in range(n): a = int(eval(input())) * (-1) if not col_maxs: col_maxs.append(a) continue curr_max = col_maxs[-1] if a >= curr_max: col_maxs.append(a) else: # aより大きい最小要素のindex/value...
from bisect import bisect_left, bisect_right import sys input = sys.stdin.readline n = int(eval(input())) col_maxs = [] for _ in range(n): a = int(eval(input())) * (-1) if not col_maxs: col_maxs.append(a) continue curr_max = col_maxs[-1] if a >= curr_max: col_maxs.append(a) ...
false
9.52381
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.048062
0.046545
1.032582
[ "s106458545", "s661673195" ]
u073852194
p03855
python
s924623881
s225481769
966
893
134,008
126,088
Accepted
Accepted
7.56
import sys from collections import defaultdict input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self...
import sys from collections import defaultdict input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self...
67
61
1,632
1,467
import sys from collections import defaultdict input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) ...
import sys from collections import defaultdict input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) ...
false
8.955224
[ "- def roots(self):", "- return [i for i, x in enumerate(self.parents) if x < 0]", "-", "- def group_count(self):", "- return len(self.roots())", "-", "- Roots.append(str(uf_r.find(i)) + \" \" + str(uf_t.find(i)))", "+ Roots.append((uf_r.find(i), uf_t.find(i)))" ]
false
0.128379
0.04946
2.595587
[ "s924623881", "s225481769" ]
u995004106
p02678
python
s670910800
s399994250
909
530
112,968
99,124
Accepted
Accepted
41.69
from math import floor,ceil,sqrt import fractions from collections import deque import itertools from collections import deque import heapq N,M=list(map(int,input().split())) tree=[[] for _ in range(N)] for i in range(M): a,b=list(map(int,input().split())) tree[a-1].append(b-1) tree[b-1].append(a...
from math import floor,ceil,sqrt import fractions import itertools from collections import deque import heapq N,M=list(map(int,input().split())) tree=[[] for _ in range(N)] for i in range(M): a,b=list(map(int,input().split())) tree[a-1].append(b-1) tree[b-1].append(a-1) prev=[-1]*N d=[float("inf...
45
27
880
541
from math import floor, ceil, sqrt import fractions from collections import deque import itertools from collections import deque import heapq N, M = list(map(int, input().split())) tree = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) tree[a - 1].append(b - 1) tree[b - 1]....
from math import floor, ceil, sqrt import fractions import itertools from collections import deque import heapq N, M = list(map(int, input().split())) tree = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) tree[a - 1].append(b - 1) tree[b - 1].append(a - 1) prev = [-1] * N ...
false
40
[ "-from collections import deque", "-d = [float(\"inf\") for _ in range(N)]", "-d[0] = 0", "-q = []", "-q.append([0, 0])", "-q1 = q", "-flag = 1", "-# print(q)", "-heapq.heapify(q)", "-# print(q1)", "-while len(q) > 0:", "- dist, u = heapq.heappop(q)", "- if d[u] < dist:", "- c...
false
0.046276
0.03838
1.205726
[ "s670910800", "s399994250" ]
u548272916
p02584
python
s924350409
s055650335
32
28
9,008
9,196
Accepted
Accepted
12.5
x,k,d = list(map(int, input().split())) lists = [] x = abs(x) step = int(x/d) if step >= k: answer = x - k * d elif step < k: k_left = k - int(step) if k_left % 2 == 0: answer = x % d if k_left % 2 == 1: answer = abs(x - step * d - d) print(answer)
x,k,d = list(map(int, input().split())) lists = [] x = abs(x) step = int(x/d) if step >= k: answer = x - k * d elif step < k: k_left = k - int(step) if k_left % 2 == 0: answer = x % d if k_left % 2 == 1: answer = min(abs(x % d - d), abs(x % d + d)) print(answer)
16
16
277
294
x, k, d = list(map(int, input().split())) lists = [] x = abs(x) step = int(x / d) if step >= k: answer = x - k * d elif step < k: k_left = k - int(step) if k_left % 2 == 0: answer = x % d if k_left % 2 == 1: answer = abs(x - step * d - d) print(answer)
x, k, d = list(map(int, input().split())) lists = [] x = abs(x) step = int(x / d) if step >= k: answer = x - k * d elif step < k: k_left = k - int(step) if k_left % 2 == 0: answer = x % d if k_left % 2 == 1: answer = min(abs(x % d - d), abs(x % d + d)) print(answer)
false
0
[ "- answer = abs(x - step * d - d)", "+ answer = min(abs(x % d - d), abs(x % d + d))" ]
false
0.044133
0.045431
0.971417
[ "s924350409", "s055650335" ]
u348805958
p02793
python
s307244213
s313501583
1,968
966
4,596
6,136
Accepted
Accepted
50.91
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def factor(n): ans = [] i = 0 while n & 1 == 0: n >>= 1 i += 1 if i > 0: ans.append((2, i)) for i in range(3, int(n**.5) +1, 2): x, y = divmod(n, i) if y == 0: ...
#!python3 from fractions import gcd iim = lambda: list(map(int, input().rstrip().split())) def factor(n): ans = [] i = 0 while n & 1 == 0: n >>= 1 i += 1 if i > 0: ans.append((2, i)) for i in range(3, int(n**.5) +1, 2): x, y = divmod(n, i) ...
61
65
1,150
1,263
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def factor(n): ans = [] i = 0 while n & 1 == 0: n >>= 1 i += 1 if i > 0: ans.append((2, i)) for i in range(3, int(n**0.5) + 1, 2): x, y = divmod(n, i) if y == 0: j = 1 x...
#!python3 from fractions import gcd iim = lambda: list(map(int, input().rstrip().split())) def factor(n): ans = [] i = 0 while n & 1 == 0: n >>= 1 i += 1 if i > 0: ans.append((2, i)) for i in range(3, int(n**0.5) + 1, 2): x, y = divmod(n, i) if y == 0: ...
false
6.153846
[ "+from fractions import gcd", "+", "- c = 1", "- c2 = dict()", "+ lcm = 1", "+ # c2 = dict()", "+ # for a in A:", "+ # for n, m in factor(a):", "+ # if n in c2:", "+ # c2[n] = max(c2[n], m)", "+ # else:", "+ # c2[n] = m", "...
false
0.062819
0.049472
1.269775
[ "s307244213", "s313501583" ]
u075012704
p02691
python
s622746864
s251284552
274
198
66,788
50,664
Accepted
Accepted
27.74
from collections import defaultdict N = int(eval(input())) A = list(map(int, input().split())) B = A[:] for n in range(N): B[n] -= (n + 1) D = defaultdict(int) ans = 0 for i, a, b in zip(reversed(list(range(N))), A[::-1], B[::-1]): ans += D[-(i + a + 1)] D[b] += 1 print(ans)
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) P = [i + a for i, a in enumerate(A, start=1)] Q = [j - a for j, a in enumerate(A, start=1)] ans = 0 QC = Counter(Q) for p in P: ans += QC[p] print(ans)
14
13
291
256
from collections import defaultdict N = int(eval(input())) A = list(map(int, input().split())) B = A[:] for n in range(N): B[n] -= n + 1 D = defaultdict(int) ans = 0 for i, a, b in zip(reversed(list(range(N))), A[::-1], B[::-1]): ans += D[-(i + a + 1)] D[b] += 1 print(ans)
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) P = [i + a for i, a in enumerate(A, start=1)] Q = [j - a for j, a in enumerate(A, start=1)] ans = 0 QC = Counter(Q) for p in P: ans += QC[p] print(ans)
false
7.142857
[ "-from collections import defaultdict", "+from collections import Counter", "-B = A[:]", "-for n in range(N):", "- B[n] -= n + 1", "-D = defaultdict(int)", "+P = [i + a for i, a in enumerate(A, start=1)]", "+Q = [j - a for j, a in enumerate(A, start=1)]", "-for i, a, b in zip(reversed(list(range(...
false
0.191551
0.048643
3.937895
[ "s622746864", "s251284552" ]
u930705402
p02708
python
s963371503
s916382175
73
19
9,180
9,168
Accepted
Accepted
73.97
N,K=list(map(int,input().split())) ans=0 for i in range(K,N+2): kos=i*(N-i+1)+1 ans=(ans+kos)%(10**9+7) print(ans)
N,k=list(map(int,input().split())) print((((2+N-k)*(6+N+N**2+2*k+k*N-k**2*2)//6)%(10**9+7)))
6
2
121
85
N, K = list(map(int, input().split())) ans = 0 for i in range(K, N + 2): kos = i * (N - i + 1) + 1 ans = (ans + kos) % (10**9 + 7) print(ans)
N, k = list(map(int, input().split())) print( (((2 + N - k) * (6 + N + N**2 + 2 * k + k * N - k**2 * 2) // 6) % (10**9 + 7)) )
false
66.666667
[ "-N, K = list(map(int, input().split()))", "-ans = 0", "-for i in range(K, N + 2):", "- kos = i * (N - i + 1) + 1", "- ans = (ans + kos) % (10**9 + 7)", "-print(ans)", "+N, k = list(map(int, input().split()))", "+print(", "+ (((2 + N - k) * (6 + N + N**2 + 2 * k + k * N - k**2 * 2) // 6) % ...
false
0.281174
0.057924
4.854149
[ "s963371503", "s916382175" ]
u588794534
p03161
python
s014405204
s341826314
450
357
60,768
56,544
Accepted
Accepted
20.67
n,k=list(map(int,input().split())) a=list(map(int,input().split())) dp=["INF" for _ in range(n)] dp[0]=0 #print(r) for i in range(n): for j in range(min(k,n-i-1)): if dp[i+j+1]=="INF": dp[i+j+1]=dp[i]+abs(a[i+j+1]-a[i]) else: dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(a[i+j+1]-a[i])) #...
n,k=list(map(int,input().split())) a=list(map(int,input().split())) dp=[100000000000000000 for _ in range(n)] dp[0]=0 #print(r) for i in range(n): for j in range(min(k,n-i-1)): dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(a[i+j+1]-a[i])) #print(i,i+j,">>",r) print((dp[-1]))
16
13
353
285
n, k = list(map(int, input().split())) a = list(map(int, input().split())) dp = ["INF" for _ in range(n)] dp[0] = 0 # print(r) for i in range(n): for j in range(min(k, n - i - 1)): if dp[i + j + 1] == "INF": dp[i + j + 1] = dp[i] + abs(a[i + j + 1] - a[i]) else: dp[i + j + 1]...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) dp = [100000000000000000 for _ in range(n)] dp[0] = 0 # print(r) for i in range(n): for j in range(min(k, n - i - 1)): dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(a[i + j + 1] - a[i])) # print(i,i+j,">>",r) print((dp[-1]))...
false
18.75
[ "-dp = [\"INF\" for _ in range(n)]", "+dp = [100000000000000000 for _ in range(n)]", "- if dp[i + j + 1] == \"INF\":", "- dp[i + j + 1] = dp[i] + abs(a[i + j + 1] - a[i])", "- else:", "- dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(a[i + j + 1] - a[i]))", "- ...
false
0.190341
0.046279
4.112876
[ "s014405204", "s341826314" ]
u432805419
p04030
python
s008606105
s898483046
19
17
3,060
3,060
Accepted
Accepted
10.53
a = list(eval(input())) b = [] for i in range(len(a)): if a[i] == "0": b.append("0") elif a[i] == "1": b.append("1") elif a[i] == "B" and len(b) != 0: b.pop() else: continue print(("".join(b)))
moji = list(eval(input())) ans = [] for i in moji: if i == "0": ans.append("0") elif i == "1": ans.append("1") else: if len(ans) != 0: ans.pop() else: continue print(("".join(ans)))
14
15
228
227
a = list(eval(input())) b = [] for i in range(len(a)): if a[i] == "0": b.append("0") elif a[i] == "1": b.append("1") elif a[i] == "B" and len(b) != 0: b.pop() else: continue print(("".join(b)))
moji = list(eval(input())) ans = [] for i in moji: if i == "0": ans.append("0") elif i == "1": ans.append("1") else: if len(ans) != 0: ans.pop() else: continue print(("".join(ans)))
false
6.666667
[ "-a = list(eval(input()))", "-b = []", "-for i in range(len(a)):", "- if a[i] == \"0\":", "- b.append(\"0\")", "- elif a[i] == \"1\":", "- b.append(\"1\")", "- elif a[i] == \"B\" and len(b) != 0:", "- b.pop()", "+moji = list(eval(input()))", "+ans = []", "+for i i...
false
0.057178
0.04002
1.428748
[ "s008606105", "s898483046" ]
u060938295
p03163
python
s121885540
s821428544
1,069
171
128,480
14,000
Accepted
Accepted
84
# -*- coding: utf-8 -*- """ Created on Sat Mar 23 21:51:02 2019 @author: Yamazaki Kenichi """ N,W = list(map(int,input().split())) A = [list(map(int,input().split())) for i in range(N)] ans = [[-1 for i in range(N+1)]] ans[0][N] = 0 for i in range(1,W+1): tmp = -1 maxv = ans[-1][N] # print(...
import sys import numpy as np sys.setrecursionlimit(10 ** 9) N, W = list(map(int,input().split())) wv = [list(map(int,input().split())) for _ in range(N)] wv.sort() ans = 0 dp = np.zeros(W + 1, dtype=int) for w, v in wv: np.maximum(dp[:-w] + v, dp[w:], out = dp[w:]) ans = dp[-1] print(ans) ...
32
20
863
316
# -*- coding: utf-8 -*- """ Created on Sat Mar 23 21:51:02 2019 @author: Yamazaki Kenichi """ N, W = list(map(int, input().split())) A = [list(map(int, input().split())) for i in range(N)] ans = [[-1 for i in range(N + 1)]] ans[0][N] = 0 for i in range(1, W + 1): tmp = -1 maxv = ans[-1][N] # print('aa',m...
import sys import numpy as np sys.setrecursionlimit(10**9) N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(N)] wv.sort() ans = 0 dp = np.zeros(W + 1, dtype=int) for w, v in wv: np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) ans = dp[-1] print(ans)
false
37.5
[ "-# -*- coding: utf-8 -*-", "-\"\"\"", "-Created on Sat Mar 23 21:51:02 2019", "-@author: Yamazaki Kenichi", "-\"\"\"", "+import sys", "+import numpy as np", "+", "+sys.setrecursionlimit(10**9)", "-A = [list(map(int, input().split())) for i in range(N)]", "-ans = [[-1 for i in range(N + 1)]]", ...
false
0.039067
0.206574
0.189121
[ "s121885540", "s821428544" ]
u780354103
p03835
python
s898266742
s483556874
1,436
1,247
2,940
2,940
Accepted
Accepted
13.16
K,S = list(map(int,input().split())) a = 0 for y in range(K + 1): for z in range(K + 1): if 0 <= S - y - z <= K: a += 1 print(a)
K,S = list(map(int,input().split())) a = 0 for X in range(K + 1): for Y in range(K + 1): if 0 <= S - X - Y <= K: a += 1 print(a)
8
8
155
154
K, S = list(map(int, input().split())) a = 0 for y in range(K + 1): for z in range(K + 1): if 0 <= S - y - z <= K: a += 1 print(a)
K, S = list(map(int, input().split())) a = 0 for X in range(K + 1): for Y in range(K + 1): if 0 <= S - X - Y <= K: a += 1 print(a)
false
0
[ "-for y in range(K + 1):", "- for z in range(K + 1):", "- if 0 <= S - y - z <= K:", "+for X in range(K + 1):", "+ for Y in range(K + 1):", "+ if 0 <= S - X - Y <= K:" ]
false
0.032387
0.031306
1.034552
[ "s898266742", "s483556874" ]
u164898518
p03994
python
s571661466
s320439545
1,563
100
11,716
12,164
Accepted
Accepted
93.6
s = input() K = int(input()) _s, _K = s[:], K a = "abcdefghijklmnopqrstuvwxyz" ai = a.index("a") zi = a.index("z") si = [zi - a.index(c) + 1 if c != "a" else 0 for c in s] for i, (c, ci) in enumerate(zip(s, si)): if K == 0: break if c == "a": continue if ci <= K: s =...
s = input() s = list(s) K = int(input()) # _s, _K = s[:], K a = "abcdefghijklmnopqrstuvwxyz" # ai = a.index("a") zi = a.index("z") si = [zi - a.index(c) + 1 if c != "a" else 0 for c in s] for i, (c, ci) in enumerate(zip(s, si)): if K == 0: break if c == "a": continue if ci <...
22
23
452
457
s = input() K = int(input()) _s, _K = s[:], K a = "abcdefghijklmnopqrstuvwxyz" ai = a.index("a") zi = a.index("z") si = [zi - a.index(c) + 1 if c != "a" else 0 for c in s] for i, (c, ci) in enumerate(zip(s, si)): if K == 0: break if c == "a": continue if ci <= K: s = s[0:i] + "a" + s...
s = input() s = list(s) K = int(input()) # _s, _K = s[:], K a = "abcdefghijklmnopqrstuvwxyz" # ai = a.index("a") zi = a.index("z") si = [zi - a.index(c) + 1 if c != "a" else 0 for c in s] for i, (c, ci) in enumerate(zip(s, si)): if K == 0: break if c == "a": continue if ci <= K: s[i]...
false
4.347826
[ "+s = list(s)", "-_s, _K = s[:], K", "+# _s, _K = s[:], K", "-ai = a.index(\"a\")", "+# ai = a.index(\"a\")", "- s = s[0:i] + \"a\" + s[i + 1 :]", "+ s[i] = \"a\"", "- s = s[:-1] + a[a.index(s[-1]) + K]", "-print(s)", "+ s[-1] = a[a.index(s[-1]) + K]", "+print((\"\".join(s)))...
false
0.058244
0.049645
1.173196
[ "s571661466", "s320439545" ]
u256678932
p02389
python
s807199388
s680857890
30
20
7,524
5,584
Accepted
Accepted
33.33
a, b = list(map(int, input().split(' '))) s = a*b c = a*2 + b*2 print((s, c))
(a, b) = list(map(int, input().split(' '))) s = a*b r = 2*(a+b) print((s, r))
6
7
76
79
a, b = list(map(int, input().split(" "))) s = a * b c = a * 2 + b * 2 print((s, c))
(a, b) = list(map(int, input().split(" "))) s = a * b r = 2 * (a + b) print((s, r))
false
14.285714
[ "-a, b = list(map(int, input().split(\" \")))", "+(a, b) = list(map(int, input().split(\" \")))", "-c = a * 2 + b * 2", "-print((s, c))", "+r = 2 * (a + b)", "+print((s, r))" ]
false
0.049946
0.048998
1.019339
[ "s807199388", "s680857890" ]
u278855471
p03073
python
s609112561
s236779656
952
45
10,452
9,204
Accepted
Accepted
95.27
S = eval(input()) counter = 0 for i in range(1, len(S)): previous_color = S[i - 1] checking_color = S[i] if previous_color == checking_color: counter += 1 if previous_color == '0': S = S[:i] + '1' + S[i + 1:] else: S = S[:i] + '0' + S[i + 1:] print(...
S = eval(input()) if S[0] == '0': A = '01' * len(S) else: A = '10' * len(S) cnt = 0 for i in range(len(S)): if S[i] != A[i]: cnt += 1 print((min(cnt, abs(len(S) - cnt))))
12
13
351
198
S = eval(input()) counter = 0 for i in range(1, len(S)): previous_color = S[i - 1] checking_color = S[i] if previous_color == checking_color: counter += 1 if previous_color == "0": S = S[:i] + "1" + S[i + 1 :] else: S = S[:i] + "0" + S[i + 1 :] print((min(coun...
S = eval(input()) if S[0] == "0": A = "01" * len(S) else: A = "10" * len(S) cnt = 0 for i in range(len(S)): if S[i] != A[i]: cnt += 1 print((min(cnt, abs(len(S) - cnt))))
false
7.692308
[ "-counter = 0", "-for i in range(1, len(S)):", "- previous_color = S[i - 1]", "- checking_color = S[i]", "- if previous_color == checking_color:", "- counter += 1", "- if previous_color == \"0\":", "- S = S[:i] + \"1\" + S[i + 1 :]", "- else:", "- ...
false
0.060242
0.006855
8.787779
[ "s609112561", "s236779656" ]
u894258749
p03339
python
s483488666
s285255894
212
189
60,248
41,560
Accepted
Accepted
10.85
inpl = lambda: list(map(int,input().split())) def get_sequence(arr): if len(arr) == 0: return [], [] elements = [] nums = [] n = 1 prev = arr[0] for c in arr[1:]: if c == prev: n += 1 else: elements.append(prev) nums.append...
inpl = lambda: list(map(int,input().split())) N = int(eval(input())) S = eval(input()) NE = S.count('E') ans = cur = NE for s in S: if s == 'E': cur -= 1 if cur < ans: ans = cur else: cur += 1 print(ans)
34
13
738
247
inpl = lambda: list(map(int, input().split())) def get_sequence(arr): if len(arr) == 0: return [], [] elements = [] nums = [] n = 1 prev = arr[0] for c in arr[1:]: if c == prev: n += 1 else: elements.append(prev) nums.append(n) ...
inpl = lambda: list(map(int, input().split())) N = int(eval(input())) S = eval(input()) NE = S.count("E") ans = cur = NE for s in S: if s == "E": cur -= 1 if cur < ans: ans = cur else: cur += 1 print(ans)
false
61.764706
[ "-", "-", "-def get_sequence(arr):", "- if len(arr) == 0:", "- return [], []", "- elements = []", "- nums = []", "- n = 1", "- prev = arr[0]", "- for c in arr[1:]:", "- if c == prev:", "- n += 1", "- else:", "- elements.append(pr...
false
0.151756
0.037056
4.095274
[ "s483488666", "s285255894" ]
u430928274
p03738
python
s973064358
s071767349
28
25
9,216
9,144
Accepted
Accepted
10.71
import math a = int(eval(input())) b = int(eval(input())) a = math.log10(a) b = math.log10(b) if a > b : print("GREATER") elif a == b : print("EQUAL") else : print("LESS")
import math a = int(eval(input())) b = int(eval(input())) if a > b : print("GREATER") elif a == b : print("EQUAL") else : print("LESS")
11
9
182
144
import math a = int(eval(input())) b = int(eval(input())) a = math.log10(a) b = math.log10(b) if a > b: print("GREATER") elif a == b: print("EQUAL") else: print("LESS")
import math a = int(eval(input())) b = int(eval(input())) if a > b: print("GREATER") elif a == b: print("EQUAL") else: print("LESS")
false
18.181818
[ "-a = math.log10(a)", "-b = math.log10(b)" ]
false
0.043285
0.04266
1.014647
[ "s973064358", "s071767349" ]
u370086573
p02264
python
s612532177
s356873484
510
330
16,084
16,168
Accepted
Accepted
35.29
def initialize(): global head, tail def isEmpty(): global head, tail return head == tail def isFull(): global head, tail, MAX return head == (tail + 1) % MAX def enqueue(x): global head, tail, Q, MAX if isFull(): print("?????????????????????") else: ...
from collections import deque if __name__ == '__main__': n, q = list(map(int, input().split())) Q = deque() for i in range(n): name,time = input().split() Q.append([name, int(time)]) runtime = 0 while Q: qt = Q.popleft() if qt[1] > q: runtime ...
59
18
1,210
447
def initialize(): global head, tail def isEmpty(): global head, tail return head == tail def isFull(): global head, tail, MAX return head == (tail + 1) % MAX def enqueue(x): global head, tail, Q, MAX if isFull(): print("?????????????????????") else: Q[tail] = x ...
from collections import deque if __name__ == "__main__": n, q = list(map(int, input().split())) Q = deque() for i in range(n): name, time = input().split() Q.append([name, int(time)]) runtime = 0 while Q: qt = Q.popleft() if qt[1] > q: runtime += q ...
false
69.491525
[ "-def initialize():", "- global head, tail", "-", "-", "-def isEmpty():", "- global head, tail", "- return head == tail", "-", "-", "-def isFull():", "- global head, tail, MAX", "- return head == (tail + 1) % MAX", "-", "-", "-def enqueue(x):", "- global head, tail, Q...
false
0.040304
0.039086
1.031177
[ "s612532177", "s356873484" ]
u857293613
p03160
python
s409306130
s769187497
181
128
13,928
13,980
Accepted
Accepted
29.28
n = int(eval(input())) hlis = list(map(int, input().split())) hlis.append(float('inf')) dp = [0] + [abs(hlis[0] - hlis[1])] + [float('inf')]*(n-1) for i in range(n-1): one = abs(hlis[i]-hlis[i+1]) two = abs(hlis[i]-hlis[i+2]) dp[i+1] = min(dp[i]+one, dp[i+1]) dp[i+2] = min(dp[i]+two, dp[i+2]) p...
N = int(eval(input())) hlis = list(map(int, input().split())) dp = [-1]*N dp[0] = 0 dp[1] = abs(hlis[0] - hlis[1]) for i in range(2, N): dp[i] = min(dp[i-1]+abs(hlis[i]-hlis[i-1]), dp[i-2]+abs(hlis[i]-hlis[i-2])) print((dp[-1]))
10
8
327
231
n = int(eval(input())) hlis = list(map(int, input().split())) hlis.append(float("inf")) dp = [0] + [abs(hlis[0] - hlis[1])] + [float("inf")] * (n - 1) for i in range(n - 1): one = abs(hlis[i] - hlis[i + 1]) two = abs(hlis[i] - hlis[i + 2]) dp[i + 1] = min(dp[i] + one, dp[i + 1]) dp[i + 2] = min(dp[i] + ...
N = int(eval(input())) hlis = list(map(int, input().split())) dp = [-1] * N dp[0] = 0 dp[1] = abs(hlis[0] - hlis[1]) for i in range(2, N): dp[i] = min( dp[i - 1] + abs(hlis[i] - hlis[i - 1]), dp[i - 2] + abs(hlis[i] - hlis[i - 2]) ) print((dp[-1]))
false
20
[ "-n = int(eval(input()))", "+N = int(eval(input()))", "-hlis.append(float(\"inf\"))", "-dp = [0] + [abs(hlis[0] - hlis[1])] + [float(\"inf\")] * (n - 1)", "-for i in range(n - 1):", "- one = abs(hlis[i] - hlis[i + 1])", "- two = abs(hlis[i] - hlis[i + 2])", "- dp[i + 1] = min(dp[i] + one, dp[...
false
0.101067
0.039462
2.561085
[ "s409306130", "s769187497" ]
u810356688
p03244
python
s344356522
s149530823
277
98
65,132
21,944
Accepted
Accepted
64.62
import sys def input(): return sys.stdin.readline().rstrip() from collections import Counter from operator import itemgetter def main(): n=int(eval(input())) V=[int(_) for _ in input().split()] even=V[0::2] odd=V[1::2] even_c=Counter(even) odd_c=Counter(odd) even_ci,odd_ci=list(ev...
import sys def input(): return sys.stdin.readline().rstrip() from collections import Counter from operator import itemgetter def main(): n=int(eval(input())) V=[int(_) for _ in input().split()] even,odd=V[0::2],V[1::2] even_c,odd_c=Counter(even),Counter(odd) even_ci,odd_ci=list(even_c.items...
29
27
1,116
1,106
import sys def input(): return sys.stdin.readline().rstrip() from collections import Counter from operator import itemgetter def main(): n = int(eval(input())) V = [int(_) for _ in input().split()] even = V[0::2] odd = V[1::2] even_c = Counter(even) odd_c = Counter(odd) even_ci, od...
import sys def input(): return sys.stdin.readline().rstrip() from collections import Counter from operator import itemgetter def main(): n = int(eval(input())) V = [int(_) for _ in input().split()] even, odd = V[0::2], V[1::2] even_c, odd_c = Counter(even), Counter(odd) even_ci, odd_ci = l...
false
6.896552
[ "- even = V[0::2]", "- odd = V[1::2]", "- even_c = Counter(even)", "- odd_c = Counter(odd)", "+ even, odd = V[0::2], V[1::2]", "+ even_c, odd_c = Counter(even), Counter(odd)" ]
false
0.097206
0.097553
0.99644
[ "s344356522", "s149530823" ]
u054825571
p03032
python
s128424062
s738371534
44
40
9,116
9,228
Accepted
Accepted
9.09
N,K=list(map(int,input().split())) V=list(map(int,input().split())) r=min(N,K) ans=0 for a in range(r+1): for b in range(r-a+1): tmp,minus=0,[] for i in range(a): t=V[i] tmp+=t if t<0: minus.append(t) for j in range(b): ...
N,K=list(map(int,input().split())) V=list(map(int,input().split())) r,ans=min(N,K),0 for a in range(r+1): for b in range(r-a+1): tmp,minus=0,[] for i in range(a): tmp+=V[i] if V[i]<0: minus.append(V[i]) for j in range(b): tmp+=V[N-j-1] if V[N-j-1]<0: mi...
20
17
485
407
N, K = list(map(int, input().split())) V = list(map(int, input().split())) r = min(N, K) ans = 0 for a in range(r + 1): for b in range(r - a + 1): tmp, minus = 0, [] for i in range(a): t = V[i] tmp += t if t < 0: minus.append(t) for j in ra...
N, K = list(map(int, input().split())) V = list(map(int, input().split())) r, ans = min(N, K), 0 for a in range(r + 1): for b in range(r - a + 1): tmp, minus = 0, [] for i in range(a): tmp += V[i] if V[i] < 0: minus.append(V[i]) for j in range(b): ...
false
15
[ "-r = min(N, K)", "-ans = 0", "+r, ans = min(N, K), 0", "- t = V[i]", "- tmp += t", "- if t < 0:", "- minus.append(t)", "+ tmp += V[i]", "+ if V[i] < 0:", "+ minus.append(V[i])", "- t = V[N - 1 - j]",...
false
0.11312
0.038753
2.919011
[ "s128424062", "s738371534" ]
u102461423
p02793
python
s026975020
s051850583
1,081
579
5,984
5,880
Accepted
Accepted
46.44
import sys read = sys.stdin.buffer.read from fractions import gcd N,*A = list(map(int,read().split())) lcm = 1 answer = 0 for x in A: n = x//gcd(lcm,x) lcm *= n answer *= n answer += lcm//x answer %= (10**9 + 7) print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from fractions import gcd from functools import reduce N,*A = list(map(int,read().split())) MOD = 10 ** 9 + 7 lcm = reduce(lambda x,y: y//gcd(x,y)*x, A) lcm %= MOD coef = sum(pow(x, MO...
17
19
250
379
import sys read = sys.stdin.buffer.read from fractions import gcd N, *A = list(map(int, read().split())) lcm = 1 answer = 0 for x in A: n = x // gcd(lcm, x) lcm *= n answer *= n answer += lcm // x answer %= 10**9 + 7 print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from fractions import gcd from functools import reduce N, *A = list(map(int, read().split())) MOD = 10**9 + 7 lcm = reduce(lambda x, y: y // gcd(x, y) * x, A) lcm %= MOD coef = sum(pow(x, MOD - 2, MOD) ...
false
10.526316
[ "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+from functools import reduce", "-lcm = 1", "-answer = 0", "-for x in A:", "- n = x // gcd(lcm, x)", "- lcm *= n", "- answer *= n", "- answer += lcm // x", "-answer %= 10**9 + 7", "+MOD = 10**9 + 7...
false
0.098586
0.119151
0.827403
[ "s026975020", "s051850583" ]
u089230684
p03239
python
s091964788
s209719413
167
17
38,460
3,064
Accepted
Accepted
89.82
def a(): n=list(map(int, input().split())) c=list() t = list() for i in range(n[0]): s = list(map(int, input().split())) c.append(s[0]) t.append(s[1]) z=list() z[len(z):]=t[:len(t)] z.sort() if z[0]>n[1]: print("TLE") return 0 l=0...
def MRX(): N,T = input().split() N,T= int(N),int(T) travel = {} for i in range(N): c , t = input().split() travel[int(c)] = int(t) for j in sorted(travel): if travel[j] <= T: return j return "TLE" print((MRX()))
21
15
447
286
def a(): n = list(map(int, input().split())) c = list() t = list() for i in range(n[0]): s = list(map(int, input().split())) c.append(s[0]) t.append(s[1]) z = list() z[len(z) :] = t[: len(t)] z.sort() if z[0] > n[1]: print("TLE") return 0 l = 0...
def MRX(): N, T = input().split() N, T = int(N), int(T) travel = {} for i in range(N): c, t = input().split() travel[int(c)] = int(t) for j in sorted(travel): if travel[j] <= T: return j return "TLE" print((MRX()))
false
28.571429
[ "-def a():", "- n = list(map(int, input().split()))", "- c = list()", "- t = list()", "- for i in range(n[0]):", "- s = list(map(int, input().split()))", "- c.append(s[0])", "- t.append(s[1])", "- z = list()", "- z[len(z) :] = t[: len(t)]", "- z.sort()",...
false
0.043448
0.043095
1.0082
[ "s091964788", "s209719413" ]
u241159583
p02819
python
s784136897
s180673519
103
18
5,400
2,940
Accepted
Accepted
82.52
import bisect x = int(eval(input())) def get_prime(n): if n <= 1: return [] limit = int(n**0.5) prime = [2] data = [i+1 for i in range(2,n,2)] while limit >= data[0]: prime.append(data[0]) data = [j for j in data if j % data[0] != 0] return prime + data l = get_prime(10**5+3) i = bis...
x = int(eval(input())) def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True if not is_prime(x): while not is_prime(x): x += 1 print(x)
17
12
381
219
import bisect x = int(eval(input())) def get_prime(n): if n <= 1: return [] limit = int(n**0.5) prime = [2] data = [i + 1 for i in range(2, n, 2)] while limit >= data[0]: prime.append(data[0]) data = [j for j in data if j % data[0] != 0] return prime + data l = get_p...
x = int(eval(input())) def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True if not is_prime(x): while not is_prime(x): x += 1 print(x)
false
29.411765
[ "-import bisect", "-", "-def get_prime(n):", "+def is_prime(n):", "- return []", "- limit = int(n**0.5)", "- prime = [2]", "- data = [i + 1 for i in range(2, n, 2)]", "- while limit >= data[0]:", "- prime.append(data[0])", "- data = [j for j in data if j % data[0...
false
0.118669
0.071251
1.665514
[ "s784136897", "s180673519" ]
u228223940
p03805
python
s619747524
s438210799
28
24
3,064
3,064
Accepted
Accepted
14.29
N, M = list(map(int, input().split())) adj_matrix = [[0]* N for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a-1][b-1] = 1 adj_matrix[b-1][a-1] = 1 def dfs(v, used): if not False in used: return 1 ans = 0 for i in range(N): ...
import bisect n,m = list(map(int,input().split())) g = [[ ] for i in range(n+1)] for i in range(m): a,b = list(map(int,input().split())) g[a].append(b) g[b].append(a) #print(bisect.bisect_left(g[a],b)) #g[a][] = b #g[a].append(b) #g[b].append(a) #g[4].sort() ans = 0...
29
44
572
781
N, M = list(map(int, input().split())) adj_matrix = [[0] * N for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a - 1][b - 1] = 1 adj_matrix[b - 1][a - 1] = 1 def dfs(v, used): if not False in used: return 1 ans = 0 for i in range(N): if not...
import bisect n, m = list(map(int, input().split())) g = [[] for i in range(n + 1)] for i in range(m): a, b = list(map(int, input().split())) g[a].append(b) g[b].append(a) # print(bisect.bisect_left(g[a],b)) # g[a][] = b # g[a].append(b) # g[b].append(a) # g[4].sort() ans = 0 def dfs(x, c...
false
34.090909
[ "-N, M = list(map(int, input().split()))", "-adj_matrix = [[0] * N for _ in range(N)]", "-for i in range(M):", "+import bisect", "+", "+n, m = list(map(int, input().split()))", "+g = [[] for i in range(n + 1)]", "+for i in range(m):", "- adj_matrix[a - 1][b - 1] = 1", "- adj_matrix[b - 1][a ...
false
0.033389
0.046463
0.718605
[ "s619747524", "s438210799" ]
u038819082
p02701
python
s424898957
s248700564
300
277
35,572
35,680
Accepted
Accepted
7.67
N=int(eval(input())) S=[] for i in range(N): S.append(str(eval(input()))) print((len(set(S))))
N=int(eval(input())) a=[] for i in range(N): a.append(eval(input())) print((len(set(a))))
5
5
86
81
N = int(eval(input())) S = [] for i in range(N): S.append(str(eval(input()))) print((len(set(S))))
N = int(eval(input())) a = [] for i in range(N): a.append(eval(input())) print((len(set(a))))
false
0
[ "-S = []", "+a = []", "- S.append(str(eval(input())))", "-print((len(set(S))))", "+ a.append(eval(input()))", "+print((len(set(a))))" ]
false
0.102965
0.007655
13.450282
[ "s424898957", "s248700564" ]
u075012704
p02955
python
s965972529
s624591415
275
240
42,844
3,188
Accepted
Accepted
12.73
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) M = sum(A) ans_candidates = [] for n in range(1, int(M ** 0.5) + 1): if M % n == 0: ans_candidates.append(n) ans_candidates.append(M // n) ans = 0 for X in ans_candidates: ...
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) M = sum(A) # 答えの候補を列挙 ans_candidates = [] for n in range(1, int(M ** 0.5) + 1): if M % n == 0: ans_candidates.append(n) ans_candidates.append(M // n) ans = 0 for X in ans_cand...
30
31
646
666
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) M = sum(A) ans_candidates = [] for n in range(1, int(M**0.5) + 1): if M % n == 0: ans_candidates.append(n) ans_candidates.append(M // n) ans = 0 for X in ans_candidates: alpha = sorted([(...
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) M = sum(A) # 答えの候補を列挙 ans_candidates = [] for n in range(1, int(M**0.5) + 1): if M % n == 0: ans_candidates.append(n) ans_candidates.append(M // n) ans = 0 for X in ans_candidates: A_mod ...
false
3.225806
[ "+# 答えの候補を列挙", "- alpha = sorted([(a % X) for a in A])", "- beta = [X - a for a in alpha]", "- alpha = list(accumulate(alpha))", "- beta = list(accumulate(beta))", "+ A_mod = sorted([a % X for a in A])", "+ U = [X - a for a in A_mod]", "+ D = [-a for a in A_mod] # わかりやすいので", "+...
false
0.039888
0.063482
0.62833
[ "s965972529", "s624591415" ]
u553987207
p02684
python
s321976617
s253760994
205
166
32,192
32,460
Accepted
Accepted
19.02
N, K = list(map(int, input().split())) A = list([int(x) - 1 for x in input().split()]) R = [] done = set() todo = [0] done = set() bp = None while todo: p = todo.pop() R.append(p) done.add(p) np = A[p] if np in done: bp = np else: todo.append(np) b = R.index(bp)...
N, K = list(map(int, input().split())) A = tuple(int(x) - 1 for x in input().split()) done = {0} rt = [0] loop_point = 0 while True: p = rt[-1] np = A[p] if np in done: loop_point = np break done.add(np) rt.append(np) if K < len(rt): ans = rt[K] + 1 else: K ...
25
21
423
401
N, K = list(map(int, input().split())) A = list([int(x) - 1 for x in input().split()]) R = [] done = set() todo = [0] done = set() bp = None while todo: p = todo.pop() R.append(p) done.add(p) np = A[p] if np in done: bp = np else: todo.append(np) b = R.index(bp) if K < b: ans...
N, K = list(map(int, input().split())) A = tuple(int(x) - 1 for x in input().split()) done = {0} rt = [0] loop_point = 0 while True: p = rt[-1] np = A[p] if np in done: loop_point = np break done.add(np) rt.append(np) if K < len(rt): ans = rt[K] + 1 else: K -= len(rt) rt ...
false
16
[ "-A = list([int(x) - 1 for x in input().split()])", "-R = []", "-done = set()", "-todo = [0]", "-done = set()", "-bp = None", "-while todo:", "- p = todo.pop()", "- R.append(p)", "- done.add(p)", "+A = tuple(int(x) - 1 for x in input().split())", "+done = {0}", "+rt = [0]", "+loop...
false
0.044061
0.043855
1.004708
[ "s321976617", "s253760994" ]
u562935282
p03212
python
s124712416
s574137741
136
92
3,692
2,940
Accepted
Accepted
32.35
n = int(eval(input())) ans = 0 t = [3, 5, 7] while len(t) > 0: x = t.pop(0) if x * 10 + 3 <= n: t.append(x * 10 + 3) if x * 10 + 5 <= n: t.append(x * 10 + 5) if x * 10 + 7 <= n: t.append(x * 10 + 7) if 357 <= x <= n: s = str(x) ...
# https://img.atcoder.jp/abc114/editorial.pdf N = int(eval(input())) def dfs(s): # 文字列 s で始まる七五三数の個数 if int(s) > N: return 0 ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1 for c in '753': ret += dfs(s + c) return ret print((dfs('0'))) # 本当は dfs('...
17
14
394
341
n = int(eval(input())) ans = 0 t = [3, 5, 7] while len(t) > 0: x = t.pop(0) if x * 10 + 3 <= n: t.append(x * 10 + 3) if x * 10 + 5 <= n: t.append(x * 10 + 5) if x * 10 + 7 <= n: t.append(x * 10 + 7) if 357 <= x <= n: s = str(x) if "3" i...
# https://img.atcoder.jp/abc114/editorial.pdf N = int(eval(input())) def dfs(s): # 文字列 s で始まる七五三数の個数 if int(s) > N: return 0 ret = 1 if all(s.count(c) > 0 for c in "753") else 0 # s 自体が七五三数なら +1 for c in "753": ret += dfs(s + c) return ret print((dfs("0"))) # 本当は dfs('') と書きたいが 6 ...
false
17.647059
[ "-n = int(eval(input()))", "-ans = 0", "-t = [3, 5, 7]", "-while len(t) > 0:", "- x = t.pop(0)", "- if x * 10 + 3 <= n:", "- t.append(x * 10 + 3)", "- if x * 10 + 5 <= n:", "- t.append(x * 10 + 5)", "- if x * 10 + 7 <= n:", "- t.append(x *...
false
0.050542
0.047277
1.06905
[ "s124712416", "s574137741" ]
u867069435
p03426
python
s678239928
s278029447
1,836
1,664
51,936
51,896
Accepted
Accepted
9.37
from functools import lru_cache h, w, d = list(map(int, input().split())) pos = [[] for j in range(h*w)] for a in range(h): s = list(map(int, input().split())) for g in range(w): pos[s[g] -1] = [s[g], a+1, g+1] q = int(eval(input())) def soo(now, start): next = now + d prevy, prevx =...
from functools import lru_cache h, w, d = list(map(int, input().split())) pos = [[] for j in range(h*w)] for a in range(h): s = list(map(int, input().split())) for g in range(w): pos[s[g] -1] = [s[g], a+1, g+1] q = int(eval(input())) time = [0 for h in range(h*w)] for l in range(h*w - d): ...
37
23
993
596
from functools import lru_cache h, w, d = list(map(int, input().split())) pos = [[] for j in range(h * w)] for a in range(h): s = list(map(int, input().split())) for g in range(w): pos[s[g] - 1] = [s[g], a + 1, g + 1] q = int(eval(input())) def soo(now, start): next = now + d prevy, prevx = p...
from functools import lru_cache h, w, d = list(map(int, input().split())) pos = [[] for j in range(h * w)] for a in range(h): s = list(map(int, input().split())) for g in range(w): pos[s[g] - 1] = [s[g], a + 1, g + 1] q = int(eval(input())) time = [0 for h in range(h * w)] for l in range(h * w - d): ...
false
37.837838
[ "-", "-", "-def soo(now, start):", "- next = now + d", "- prevy, prevx = pos[now - 1][1], pos[now - 1][2]", "- nexty, nextx = pos[next - 1][1], pos[next - 1][2]", "- return abs(nexty - prevy) + abs(nextx - prevx)", "-", "-", "-def solve(start, end):", "- now = 0", "- ans = 0"...
false
0.049928
0.036332
1.374209
[ "s678239928", "s278029447" ]
u667024514
p03107
python
s787732459
s777729522
25
18
3,572
3,188
Accepted
Accepted
28
from collections import Counter s = str(eval(input())) print((len(s)-abs(s.count("1")-s.count("0"))))
s = str(eval(input())) print((len(s)-abs(s.count("1")-s.count("0"))))
3
2
95
62
from collections import Counter s = str(eval(input())) print((len(s) - abs(s.count("1") - s.count("0"))))
s = str(eval(input())) print((len(s) - abs(s.count("1") - s.count("0"))))
false
33.333333
[ "-from collections import Counter", "-" ]
false
0.034948
0.040786
0.856871
[ "s787732459", "s777729522" ]
u492605584
p03212
python
s420172577
s058401008
112
38
3,060
4,340
Accepted
Accepted
66.07
N = int(eval(input())) def check_753(s): s = str(int(s)) a = ''.join(sorted(list(set(s)))) if a == '357': return True else: return False def shi(s): if int(s) > N: return 0 if check_753(s): ret = 1 else: ret = 0 for i in '753': ret += shi(s+i) return ret ...
import itertools as t N = int(eval(input())) L = [ int(''.join(j)) for i in range(10) for j in t.product(['3','5','7'], repeat=i) if '3' in j and '5' in j and '7' in j] L = [i for i in L if i <= N] print((len(L)))
22
7
331
214
N = int(eval(input())) def check_753(s): s = str(int(s)) a = "".join(sorted(list(set(s)))) if a == "357": return True else: return False def shi(s): if int(s) > N: return 0 if check_753(s): ret = 1 else: ret = 0 for i in "753": ret += s...
import itertools as t N = int(eval(input())) L = [ int("".join(j)) for i in range(10) for j in t.product(["3", "5", "7"], repeat=i) if "3" in j and "5" in j and "7" in j ] L = [i for i in L if i <= N] print((len(L)))
false
68.181818
[ "+import itertools as t", "+", "-", "-", "-def check_753(s):", "- s = str(int(s))", "- a = \"\".join(sorted(list(set(s))))", "- if a == \"357\":", "- return True", "- else:", "- return False", "-", "-", "-def shi(s):", "- if int(s) > N:", "- return 0...
false
0.126646
0.081765
1.548894
[ "s420172577", "s058401008" ]
u863442865
p03325
python
s590717329
s702476528
114
59
4,148
4,148
Accepted
Accepted
48.25
n = int(eval(input())) ni = list(map(int, input().split())) cnt = 0 for i in ni: while not i % 2: i /= 2 cnt += 1 print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) def f(n): cnt = 0 while(n%2==0): n = n//2 cnt +=1 return cnt total = 0 for e in a: total += f(e) print(total)
8
14
135
195
n = int(eval(input())) ni = list(map(int, input().split())) cnt = 0 for i in ni: while not i % 2: i /= 2 cnt += 1 print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) def f(n): cnt = 0 while n % 2 == 0: n = n // 2 cnt += 1 return cnt total = 0 for e in a: total += f(e) print(total)
false
42.857143
[ "-n = int(eval(input()))", "-ni = list(map(int, input().split()))", "-cnt = 0", "-for i in ni:", "- while not i % 2:", "- i /= 2", "+N = int(eval(input()))", "+a = list(map(int, input().split()))", "+", "+", "+def f(n):", "+ cnt = 0", "+ while n % 2 == 0:", "+ n = n ...
false
0.042374
0.038503
1.100548
[ "s590717329", "s702476528" ]
u968166680
p03634
python
s594122212
s170716657
492
376
65,164
65,404
Accepted
Accepted
23.58
import sys from heapq import heappush, heappop read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) G = [[] for _ in range(N)] for i in range(N - 1): a, b, c...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) G = [[] for _ in range(N)] for i in range(N - 1): a, b, c = map...
44
42
988
930
import sys from heapq import heappush, heappop read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) G = [[] for _ in range(N)] for i in range(N - 1): a, b, c = map(int, readl...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) G = [[] for _ in range(N)] for i in range(N - 1): a, b, c = map(int, readline()....
false
4.545455
[ "-from heapq import heappush, heappop", "+from collections import deque", "- hq = [(0, K)]", "+ stack = deque([K])", "- while hq:", "- d, v = heappop(hq)", "- if dist[v] < d:", "- continue", "+ while stack:", "+ v = stack.pop()", "- if dist[...
false
0.044875
0.036849
1.217806
[ "s594122212", "s170716657" ]
u677523557
p02868
python
s755994766
s782784558
1,079
616
34,176
71,600
Accepted
Accepted
42.91
# instead of AVLTree INF = 10**14 class BIT(): def __init__(self, max): self.max = max self.data = [INF]*(self.max+1) def update(self, i, x): while i > 0: self.data[i] = min(self.data[i], x) i -= i & -i def read(self, i): m = INF...
import sys input = sys.stdin.readline import heapq as hp N, M = list(map(int, input().split())) graph = [[] for _ in range(N)] for _ in range(M): l, r, c = list(map(int, input().split())) graph[l-1].append((c, r-1)) for i in range(N-1): graph[i+1].append((0, i)) INF = 10**16 D = [INF for _ ...
41
33
807
723
# instead of AVLTree INF = 10**14 class BIT: def __init__(self, max): self.max = max self.data = [INF] * (self.max + 1) def update(self, i, x): while i > 0: self.data[i] = min(self.data[i], x) i -= i & -i def read(self, i): m = INF while i ...
import sys input = sys.stdin.readline import heapq as hp N, M = list(map(int, input().split())) graph = [[] for _ in range(N)] for _ in range(M): l, r, c = list(map(int, input().split())) graph[l - 1].append((c, r - 1)) for i in range(N - 1): graph[i + 1].append((0, i)) INF = 10**16 D = [INF for _ in rang...
false
19.512195
[ "-# instead of AVLTree", "-INF = 10**14", "-", "-", "-class BIT:", "- def __init__(self, max):", "- self.max = max", "- self.data = [INF] * (self.max + 1)", "-", "- def update(self, i, x):", "- while i > 0:", "- self.data[i] = min(self.data[i], x)", "- ...
false
0.053417
0.052573
1.016061
[ "s755994766", "s782784558" ]
u796942881
p03495
python
s685350583
s406646120
103
93
35,980
35,996
Accepted
Accepted
9.71
from collections import Counter from sys import stdin input = stdin.readline N, K = list(map(int, input().split())) An = Counter(input().split()) def main(): # 要素数(v) 昇順 # 先頭 から インデックス len(An) - K - 1 まで # 要素数(v) 合計 print((sum(sorted(An.values())[:len(An) - K]))) return ...
from collections import Counter N, K = list(map(int, input().split())) An = Counter(input().split()) def main(): # 要素数(v) 昇順 # 先頭 から インデックス len(An) - K - 1 まで # 要素数(v) 合計 print((sum(sorted(An.values())[:len(An) - K]))) return main()
21
17
319
268
from collections import Counter from sys import stdin input = stdin.readline N, K = list(map(int, input().split())) An = Counter(input().split()) def main(): # 要素数(v) 昇順 # 先頭 から インデックス len(An) - K - 1 まで # 要素数(v) 合計 print((sum(sorted(An.values())[: len(An) - K]))) return main()
from collections import Counter N, K = list(map(int, input().split())) An = Counter(input().split()) def main(): # 要素数(v) 昇順 # 先頭 から インデックス len(An) - K - 1 まで # 要素数(v) 合計 print((sum(sorted(An.values())[: len(An) - K]))) return main()
false
19.047619
[ "-from sys import stdin", "-input = stdin.readline" ]
false
0.046217
0.046115
1.002229
[ "s685350583", "s406646120" ]
u606989659
p02408
python
s677574269
s660624744
30
20
7,540
7,740
Accepted
Accepted
33.33
N = int(eval(input())) cards = [] for i in range(N): s,r = input().split() cards.append((s,int(r))) for s,r in [(s,r) for s in 'SHCD' for r in range(1,14) if (s,r) not in cards]: print((s, r))
marks = ["S","H","C","D"] all_cards = [] for i in marks: for j in range(1,14): all_cards.append(str(i) + " " + str(j)) n = int(eval(input())) p_cards = [] for x in range(n): p_cards.append(str(eval(input()))) for y in p_cards: all_cards.remove(y) for z in all_cards: print(z)
7
17
202
307
N = int(eval(input())) cards = [] for i in range(N): s, r = input().split() cards.append((s, int(r))) for s, r in [(s, r) for s in "SHCD" for r in range(1, 14) if (s, r) not in cards]: print((s, r))
marks = ["S", "H", "C", "D"] all_cards = [] for i in marks: for j in range(1, 14): all_cards.append(str(i) + " " + str(j)) n = int(eval(input())) p_cards = [] for x in range(n): p_cards.append(str(eval(input()))) for y in p_cards: all_cards.remove(y) for z in all_cards: print(z)
false
58.823529
[ "-N = int(eval(input()))", "-cards = []", "-for i in range(N):", "- s, r = input().split()", "- cards.append((s, int(r)))", "-for s, r in [(s, r) for s in \"SHCD\" for r in range(1, 14) if (s, r) not in cards]:", "- print((s, r))", "+marks = [\"S\", \"H\", \"C\", \"D\"]", "+all_cards = []",...
false
0.040721
0.041954
0.970594
[ "s677574269", "s660624744" ]
u840579553
p02726
python
s610114428
s963555064
499
265
48,220
46,428
Accepted
Accepted
46.89
from collections import defaultdict, deque N, X, Y = list(map(int, input().split())) G = defaultdict(list) for i in range(1, N): G[i].append(i+1) G[i+1].append(i) #print(G) G[X].append(Y) G[Y].append(X) #print(G) d = [0] * N for i in range(1, N+1): q = deque() q.append(i) visit...
N, X, Y = list(map(int, input().split())) d = [0] * N for i in range(0, N-1): for j in range(i+1, N): k = min(j-i, abs(X-1-i) + 1 + abs(Y-1-j)) d[k] += 1 for i in range(1, N): print((d[i]))
32
10
632
217
from collections import defaultdict, deque N, X, Y = list(map(int, input().split())) G = defaultdict(list) for i in range(1, N): G[i].append(i + 1) G[i + 1].append(i) # print(G) G[X].append(Y) G[Y].append(X) # print(G) d = [0] * N for i in range(1, N + 1): q = deque() q.append(i) visit = [-1] * N ...
N, X, Y = list(map(int, input().split())) d = [0] * N for i in range(0, N - 1): for j in range(i + 1, N): k = min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j)) d[k] += 1 for i in range(1, N): print((d[i]))
false
68.75
[ "-from collections import defaultdict, deque", "-", "-G = defaultdict(list)", "+d = [0] * N", "+for i in range(0, N - 1):", "+ for j in range(i + 1, N):", "+ k = min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j))", "+ d[k] += 1", "- G[i].append(i + 1)", "- G[i + 1].append(i)", ...
false
0.068878
0.040836
1.686696
[ "s610114428", "s963555064" ]
u692746605
p03330
python
s963532470
s500906019
685
539
5,492
7,284
Accepted
Accepted
21.31
N,C=list(map(int,input().split())) D=[[int(x) for x in input().split()] for y in range(C)] c=[[int(x)-1 for x in input().split()] for y in range(N)] d=[[0 for x in range(C)] for y in range(3)] for i in range(N): for j in range(N): d[(i+j)%3][c[i][j]] += 1 a=10**9 for c0 in range(C): for c1 in range...
N,C=list(map(int,input().split())) D=[[int(x) for x in input().split()] for y in range(C)] c=[[int(x)-1 for x in input().split()] for y in range(N)] d=[[0 for x in range(C)] for y in range(3)] for i in range(N): for j in range(N): d[(i+j)%3][c[i][j]]+=1 a=10**9 for c0 in range(C): for c1 in range(C...
20
16
530
486
N, C = list(map(int, input().split())) D = [[int(x) for x in input().split()] for y in range(C)] c = [[int(x) - 1 for x in input().split()] for y in range(N)] d = [[0 for x in range(C)] for y in range(3)] for i in range(N): for j in range(N): d[(i + j) % 3][c[i][j]] += 1 a = 10**9 for c0 in range(C): fo...
N, C = list(map(int, input().split())) D = [[int(x) for x in input().split()] for y in range(C)] c = [[int(x) - 1 for x in input().split()] for y in range(N)] d = [[0 for x in range(C)] for y in range(3)] for i in range(N): for j in range(N): d[(i + j) % 3][c[i][j]] += 1 a = 10**9 for c0 in range(C): fo...
false
20
[ "- if c0 == c1 or c1 == c2 or c0 == c2:", "- continue", "- s = 0", "- for c in range(C):", "- s += d[0][c] * D[c][c0] + d[1][c] * D[c][c1] + d[2][c] * D[c][c2]", "- a = min(a, s)", "+ if c0 != c1 and c1 != c2 and c0 != ...
false
0.035653
0.035704
0.998568
[ "s963532470", "s500906019" ]
u633068244
p00488
python
s254873679
s688908617
20
10
4,192
4,192
Accepted
Accepted
50
print(min([eval(input()) for i in [1,1,1]])+min([eval(input()) for i in [1,1]]) -50)
a=[eval(input()) for i in [1]*5] print(min(a[:3])+min(a[3:])-50)
1
2
71
58
print( min([eval(input()) for i in [1, 1, 1]]) + min([eval(input()) for i in [1, 1]]) - 50 )
a = [eval(input()) for i in [1] * 5] print(min(a[:3]) + min(a[3:]) - 50)
false
50
[ "-print(", "- min([eval(input()) for i in [1, 1, 1]]) + min([eval(input()) for i in [1, 1]]) - 50", "-)", "+a = [eval(input()) for i in [1] * 5]", "+print(min(a[:3]) + min(a[3:]) - 50)" ]
false
0.045313
0.046233
0.98009
[ "s254873679", "s688908617" ]
u114641312
p02756
python
s996038520
s455290239
1,300
411
17,064
21,204
Accepted
Accepted
68.38
s = eval(input()) q = int(eval(input())) query_list = [] for _ in range(q): query_list += [eval(input())] def query1(s): s = s[::-1] return s def query2_1(letters,s): s = letters[4] + s return s def query2_2(letters,s): s = s + letters[4] return s true_position = T...
from collections import deque s = eval(input()) q = int(eval(input())) query_list = [] for _ in range(q): query_list += [eval(input())] deq = deque(s) true_position = True for i in range(q): if len(query_list[i])==1: true_position = not true_position # print(s) else: ...
46
35
935
770
s = eval(input()) q = int(eval(input())) query_list = [] for _ in range(q): query_list += [eval(input())] def query1(s): s = s[::-1] return s def query2_1(letters, s): s = letters[4] + s return s def query2_2(letters, s): s = s + letters[4] return s true_position = True left = "" rig...
from collections import deque s = eval(input()) q = int(eval(input())) query_list = [] for _ in range(q): query_list += [eval(input())] deq = deque(s) true_position = True for i in range(q): if len(query_list[i]) == 1: true_position = not true_position # print(s) else: if query_list...
false
23.913043
[ "+from collections import deque", "+", "-", "-", "-def query1(s):", "- s = s[::-1]", "- return s", "-", "-", "-def query2_1(letters, s):", "- s = letters[4] + s", "- return s", "-", "-", "-def query2_2(letters, s):", "- s = s + letters[4]", "- return s", "-", "-...
false
0.035177
0.041028
0.85739
[ "s996038520", "s455290239" ]
u936985471
p03651
python
s832821041
s929667167
94
62
14,224
19,764
Accepted
Accepted
34.04
N,K=list(map(int,input().split())) A=list(map(int,input().split())) diffs=[] for i in range(len(A)): if A[i]>=K: diffs.append(A[i]-K) def gcd(a,b): if a>b: a,b=b,a while a%b>0: a,b=b,a%b return b g=A[0] for i in range(1,len(A)): g=gcd(g,A[i]) for dif in diffs: if di...
import sys readline = sys.stdin.readline n,k = list(map(int, readline().split())) a = list(map(int,readline().split())) import math from functools import reduce g = reduce(math.gcd, a) if k <= max(a) and k % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
25
15
385
275
N, K = list(map(int, input().split())) A = list(map(int, input().split())) diffs = [] for i in range(len(A)): if A[i] >= K: diffs.append(A[i] - K) def gcd(a, b): if a > b: a, b = b, a while a % b > 0: a, b = b, a % b return b g = A[0] for i in range(1, len(A)): g = gcd(g,...
import sys readline = sys.stdin.readline n, k = list(map(int, readline().split())) a = list(map(int, readline().split())) import math from functools import reduce g = reduce(math.gcd, a) if k <= max(a) and k % g == 0: print("POSSIBLE") else: print("IMPOSSIBLE")
false
40
[ "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-diffs = []", "-for i in range(len(A)):", "- if A[i] >= K:", "- diffs.append(A[i] - K)", "+import sys", "+readline = sys.stdin.readline", "+n, k = list(map(int, readline().split()))", "+a = list(map(int, ...
false
0.036005
0.037374
0.963389
[ "s832821041", "s929667167" ]
u279605379
p02297
python
s836979471
s455782788
30
20
7,720
7,728
Accepted
Accepted
33.33
x=list(range(int(eval(input())))) P=[] for _ in reversed(x):P+=[[int(i) for i in input().split()]] P+=[P[0]] for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0] print((_*0.5))
x=list(range(int(eval(input()))-1,-1,-1)) P=[] for _ in x:P+=[[int(i) for i in input().split()]] P+=[P[0]] for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0] print((_*0.5))
6
6
164
162
x = list(range(int(eval(input())))) P = [] for _ in reversed(x): P += [[int(i) for i in input().split()]] P += [P[0]] for j in x: _ += P[j + 1][1] * P[j][0] - P[j][1] * P[j + 1][0] print((_ * 0.5))
x = list(range(int(eval(input())) - 1, -1, -1)) P = [] for _ in x: P += [[int(i) for i in input().split()]] P += [P[0]] for j in x: _ += P[j + 1][1] * P[j][0] - P[j][1] * P[j + 1][0] print((_ * 0.5))
false
0
[ "-x = list(range(int(eval(input()))))", "+x = list(range(int(eval(input())) - 1, -1, -1))", "-for _ in reversed(x):", "+for _ in x:" ]
false
0.089836
0.043161
2.081416
[ "s836979471", "s455782788" ]
u119148115
p03391
python
s008827256
s533241295
257
90
75,924
74,948
Accepted
Accepted
64.98
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() ans = 0 A,B = [],[] for i in range(N): a,b = MI() A.append(a) B.append(b) if A == B: print((0)) exit() s = sum(B) m = s for i in range(N): ...
29
23
729
372
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) N = I() ans = 0 A, B = [], [] for i in range(N): a, b = MI() A.append(a) B.append(b) if A == B: print((0)) exit() s = sum(B) m = s for i in range(N): ...
false
20.689655
[ "-", "-sys.setrecursionlimit(10**7)", "-", "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし", "-", "-", "-def S():", "- return sys.stdin.readline()....
false
0.039464
0.0375
1.052395
[ "s008827256", "s533241295" ]
u785989355
p03326
python
s561692446
s872851063
36
28
3,428
3,188
Accepted
Accepted
22.22
N,M=list(map(int,input().split())) X = [[] for i in range(8)] for i in range(N): x,y,z=list(map(int,input().split())) for i in range(8): X[i].append(int(2*((i%2)-1/2))*x + int(2*(((i//2)%2)-1/2))*y + int(2*(((i//4)%2)-1/2))*z) ans=0 for i in range(8): X[i].sort() X[i]=X[i][::-1] an...
N,M = list(map(int,input().split())) X = [] for i in range(N): x,y,z = list(map(int,input().split())) X.append([x,y,z]) max_score = 0 for i in range(8): a = i%2 j = i//2 b = j%2 k = j//2 c = k%2 a,b,c = 2*a-1,2*b-1,2*c-1 Z = [] for j in range(N): Z.ap...
13
23
362
444
N, M = list(map(int, input().split())) X = [[] for i in range(8)] for i in range(N): x, y, z = list(map(int, input().split())) for i in range(8): X[i].append( int(2 * ((i % 2) - 1 / 2)) * x + int(2 * (((i // 2) % 2) - 1 / 2)) * y + int(2 * (((i // 4) % 2) - 1 / 2)) * ...
N, M = list(map(int, input().split())) X = [] for i in range(N): x, y, z = list(map(int, input().split())) X.append([x, y, z]) max_score = 0 for i in range(8): a = i % 2 j = i // 2 b = j % 2 k = j // 2 c = k % 2 a, b, c = 2 * a - 1, 2 * b - 1, 2 * c - 1 Z = [] for j in range(N): ...
false
43.478261
[ "-X = [[] for i in range(8)]", "+X = []", "- for i in range(8):", "- X[i].append(", "- int(2 * ((i % 2) - 1 / 2)) * x", "- + int(2 * (((i // 2) % 2) - 1 / 2)) * y", "- + int(2 * (((i // 4) % 2) - 1 / 2)) * z", "- )", "-ans = 0", "+ X.append([x, ...
false
0.042702
0.0344
1.241334
[ "s561692446", "s872851063" ]
u680851063
p02911
python
s485896923
s557147165
272
246
8,632
10,472
Accepted
Accepted
9.56
n, k, q = list(map(int, input().split())) l = [0] * n katen = [] my_append = katen.append # appendを(間接的に)直接呼び出す for i in range(q): my_append(int(eval(input()))) for j in katen: # pop、insertを使わない、使うとTLE! l[j-1] += 1 for y in range(n): if l[y] > q-k: print('Yes') else: p...
n, k, q = list(map(int,input().split())) l = [int(eval(input())) for _ in range(q)] score = [k-q] * n for i in l: score[i-1] += 1 for j in score: if j > 0: print('Yes') else: print('No')
16
12
318
215
n, k, q = list(map(int, input().split())) l = [0] * n katen = [] my_append = katen.append # appendを(間接的に)直接呼び出す for i in range(q): my_append(int(eval(input()))) for j in katen: # pop、insertを使わない、使うとTLE! l[j - 1] += 1 for y in range(n): if l[y] > q - k: print("Yes") else: print("No")
n, k, q = list(map(int, input().split())) l = [int(eval(input())) for _ in range(q)] score = [k - q] * n for i in l: score[i - 1] += 1 for j in score: if j > 0: print("Yes") else: print("No")
false
25
[ "-l = [0] * n", "-katen = []", "-my_append = katen.append # appendを(間接的に)直接呼び出す", "-for i in range(q):", "- my_append(int(eval(input())))", "-for j in katen: # pop、insertを使わない、使うとTLE!", "- l[j - 1] += 1", "-for y in range(n):", "- if l[y] > q - k:", "+l = [int(eval(input())) for _ in ra...
false
0.050203
0.048413
1.036976
[ "s485896923", "s557147165" ]
u077291787
p02558
python
s547266691
s604443187
265
211
144,916
84,140
Accepted
Accepted
20.38
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): ...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): ...
39
40
897
928
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): x = self[x] ...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): x = self[x] ...
false
2.5
[ "-read = sys.stdin.buffer.read", "-N, Q, *TUV = list(map(int, read().split()))", "+readline = sys.stdin.buffer.readline", "+N, Q = list(map(int, readline().split()))", "-for t, u, v in zip(*[iter(TUV)] * 3):", "+for _ in range(Q):", "+ t, u, v = list(map(int, readline().split()))" ]
false
0.044462
0.039912
1.113999
[ "s547266691", "s604443187" ]
u889914341
p03108
python
s728933543
s835657851
453
408
26,048
26,056
Accepted
Accepted
9.93
import sys readline = sys.stdin.readline N, M = map(int, input().split()) ab = [tuple(map(lambda x: int(x) - 1, readline().split())) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1] * size self.number = [1] * size def find(self, x): while self.rank[...
import sys readline = sys.stdin.readline N, M = map(int, input().split()) ab = [tuple(map(int, readline().split())) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1] * (size + 1) self.number = [1] * (size + 1) def find(self, x): while self.rank[x] >=...
36
36
1,082
1,077
import sys readline = sys.stdin.readline N, M = map(int, input().split()) ab = [tuple(map(lambda x: int(x) - 1, readline().split())) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1] * size self.number = [1] * size def find(self, x): while self.rank[x] >=...
import sys readline = sys.stdin.readline N, M = map(int, input().split()) ab = [tuple(map(int, readline().split())) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1] * (size + 1) self.number = [1] * (size + 1) def find(self, x): while self.rank[x] >= 0: ...
false
0
[ "-ab = [tuple(map(lambda x: int(x) - 1, readline().split())) for _ in range(M)]", "+ab = [tuple(map(int, readline().split())) for _ in range(M)]", "- self.rank = [-1] * size", "- self.number = [1] * size", "+ self.rank = [-1] * (size + 1)", "+ self.number = [1] * (size + 1)" ]
false
0.046389
0.045366
1.02253
[ "s728933543", "s835657851" ]
u759934006
p00163
python
s808298493
s434991891
20
10
4,288
4,268
Accepted
Accepted
50
# Highway Toll PRICE_LIST = ( (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 300, 500, 600, 700, 1350, 1650), (0, 6, 0, 350, 450, 600, 1150, 1500), (0, 13, 7, 0, 250, 400, 1000, 1350), (0, 18, 12, 5, 0, 250, 850, 1300), (0, 23, 17, 10, 5, 0, 600, 1150), (0, 43, 37, 30, 25, 20, 0, 500), (0, ...
# Highway Toll PRICE_LIST = ( (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 300, 500, 600, 700, 1350, 1650), (0, 6, 0, 350, 450, 600, 1150, 1500), (0, 13, 7, 0, 250, 400, 1000, 1350), (0, 18, 12, 5, 0, 250, 850, 1300), (0, 23, 17, 10, 5, 0, 600, 1150), (0, 43, 37, 30, 25, 20, 0, 500), (0, ...
33
31
803
814
# Highway Toll PRICE_LIST = ( (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 300, 500, 600, 700, 1350, 1650), (0, 6, 0, 350, 450, 600, 1150, 1500), (0, 13, 7, 0, 250, 400, 1000, 1350), (0, 18, 12, 5, 0, 250, 850, 1300), (0, 23, 17, 10, 5, 0, 600, 1150), (0, 43, 37, 30, 25, 20, 0, 500), (0, 58, 52, 45,...
# Highway Toll PRICE_LIST = ( (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 300, 500, 600, 700, 1350, 1650), (0, 6, 0, 350, 450, 600, 1150, 1500), (0, 13, 7, 0, 250, 400, 1000, 1350), (0, 18, 12, 5, 0, 250, 850, 1300), (0, 23, 17, 10, 5, 0, 600, 1150), (0, 43, 37, 30, 25, 20, 0, 500), (0, 58, 52, 45,...
false
6.060606
[ "+ price = PRICE_LIST[i][o]", "- p = PRICE_LIST[i][o]", "- if half:", "- p /= 2", "- if p % 50:", "- p = (p / 50) * 50 + 50", "- print(p)", "+ price /= 2", "+ if price % 50:", "+ price = price - (price % 50) + 50", "+ print(price)"...
false
0.041276
0.041525
0.993996
[ "s808298493", "s434991891" ]
u186838327
p03993
python
s130256247
s958750323
223
205
57,132
52,912
Accepted
Accepted
8.07
n = int(eval(input())) A = list(map(int, input().split())) A = [a-1 for a in A] ans = 0 for i in range(n): if A[A[i]] == i: ans += 1 print((ans//2))
n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(n): if A[A[i]-1] == i+1: ans += 1 print((ans//2))
8
7
160
142
n = int(eval(input())) A = list(map(int, input().split())) A = [a - 1 for a in A] ans = 0 for i in range(n): if A[A[i]] == i: ans += 1 print((ans // 2))
n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(n): if A[A[i] - 1] == i + 1: ans += 1 print((ans // 2))
false
12.5
[ "-A = [a - 1 for a in A]", "- if A[A[i]] == i:", "+ if A[A[i] - 1] == i + 1:" ]
false
0.079365
0.07102
1.117516
[ "s130256247", "s958750323" ]
u401487574
p02559
python
s548563174
s934241282
1,490
598
133,132
128,172
Accepted
Accepted
59.87
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") ips = lambda:input().split() import collections import math import itertools import heapq as hq class F...
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") ips = lambda:input().split() import collections import math import itertools import heapq as hq import sy...
42
43
963
999
ma = lambda: map(int, input().split()) lma = lambda: list(map(int, input().split())) tma = lambda: tuple(map(int, input().split())) ni = lambda: int(input()) yn = lambda fl: print("Yes") if fl else print("No") ips = lambda: input().split() import collections import math import itertools import heapq as hq class Fenwi...
ma = lambda: map(int, input().split()) lma = lambda: list(map(int, input().split())) tma = lambda: tuple(map(int, input().split())) ni = lambda: int(input()) yn = lambda fl: print("Yes") if fl else print("No") ips = lambda: input().split() import collections import math import itertools import heapq as hq import sys i...
false
2.325581
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.00825
0.036314
0.227186
[ "s548563174", "s934241282" ]
u347640436
p03295
python
s109461501
s318801580
229
205
23,300
28,700
Accepted
Accepted
10.48
from sys import stdin readline = stdin.readline N, M = list(map(int, readline().split())) ab = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, readline().split())) ab[a].append(b) dp = [0] * (N + 1) for i in range(1, N + 1): dp[i] = max(dp[i], dp[i - 1]) for j in ab[i]...
from sys import stdin readline = stdin.readline N, M = list(map(int, readline().split())) ab = [list(map(int, readline().split())) for _ in range(M)] ab.sort(key=lambda x: x[1]) result = 0 t = -1 for a, b in ab: a, b = a - 1, b - 1 if a <= t < b: continue result += 1 t = b - 1 ...
17
17
365
329
from sys import stdin readline = stdin.readline N, M = list(map(int, readline().split())) ab = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, readline().split())) ab[a].append(b) dp = [0] * (N + 1) for i in range(1, N + 1): dp[i] = max(dp[i], dp[i - 1]) for j in ab[i]: dp[j]...
from sys import stdin readline = stdin.readline N, M = list(map(int, readline().split())) ab = [list(map(int, readline().split())) for _ in range(M)] ab.sort(key=lambda x: x[1]) result = 0 t = -1 for a, b in ab: a, b = a - 1, b - 1 if a <= t < b: continue result += 1 t = b - 1 print(result)
false
0
[ "-ab = [[] for _ in range(N + 1)]", "-for _ in range(M):", "- a, b = list(map(int, readline().split()))", "- ab[a].append(b)", "-dp = [0] * (N + 1)", "-for i in range(1, N + 1):", "- dp[i] = max(dp[i], dp[i - 1])", "- for j in ab[i]:", "- dp[j] = max(dp[j], dp[i] + 1)", "-print(...
false
0.04323
0.045643
0.947117
[ "s109461501", "s318801580" ]
u603958124
p02796
python
s090499111
s963016257
306
280
25,460
27,440
Accepted
Accepted
8.5
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from opera...
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from opera...
32
30
1,007
959
from math import ( ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf, comb, ) from itertools import ( accumulate, groupby, permutations, combinations, product, combinations_with_...
from math import ( ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf, comb, ) from itertools import ( accumulate, groupby, permutations, combinations, product, combinations_with_...
false
6.25
[ "-x = [[0] * 2 for i in range(n)]", "+ls = []", "- x[i][0], x[i][1] = MAP()", "-x.sort()", "-tmp = -inf", "+ x, l = MAP()", "+ ls.append([x - l, x + l])", "+ls = sorted(ls, key=itemgetter(1))", "-for i in range(n):", "- if tmp > x[i][0] - x[i][1]:", "+for i in range(1, n):", "+ ...
false
0.034015
0.034383
0.989299
[ "s090499111", "s963016257" ]
u408260374
p00489
python
s473607080
s889339967
80
70
7,500
7,496
Accepted
Accepted
12.5
n=int(eval(input()));score=[list([int(x)-1 for x in input().split()]) for _ in range(int(n*(n-1)/2))];points= [0]*n for a,b,c,d in score: if c>d:points[a]+=3 elif c<d:points[b]+=3 else:points[a]+=1;points[b]+=1 rank=sorted(points,reverse=True) for p in points:print((rank.index(p)+1))
n=int(eval(input()));s=[list(map(int,input().split())) for _ in range(int(n*(n-1)/2))];p=[0]*n for a,b,c,d in s: if c>d:p[a-1]+=3 elif c<d:p[b-1]+=3 else:p[a-1]+=1;p[b-1]+=1 r=sorted(p,reverse=True) for q in p:print((r.index(q)+1))
7
7
300
244
n = int(eval(input())) score = [ list([int(x) - 1 for x in input().split()]) for _ in range(int(n * (n - 1) / 2)) ] points = [0] * n for a, b, c, d in score: if c > d: points[a] += 3 elif c < d: points[b] += 3 else: points[a] += 1 points[b] += 1 rank = sorted(points, reve...
n = int(eval(input())) s = [list(map(int, input().split())) for _ in range(int(n * (n - 1) / 2))] p = [0] * n for a, b, c, d in s: if c > d: p[a - 1] += 3 elif c < d: p[b - 1] += 3 else: p[a - 1] += 1 p[b - 1] += 1 r = sorted(p, reverse=True) for q in p: print((r.index(q)...
false
0
[ "-score = [", "- list([int(x) - 1 for x in input().split()]) for _ in range(int(n * (n - 1) / 2))", "-]", "-points = [0] * n", "-for a, b, c, d in score:", "+s = [list(map(int, input().split())) for _ in range(int(n * (n - 1) / 2))]", "+p = [0] * n", "+for a, b, c, d in s:", "- points[a] +...
false
0.089046
0.055722
1.598048
[ "s473607080", "s889339967" ]
u463655976
p03559
python
s918272806
s208319882
1,273
575
121,904
43,892
Accepted
Accepted
54.83
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) L = [] L.extend(((x, 3) for x in A)) L.extend(((x, 2) for x in B)) L.extend(((x, 1) for x in C)) L = sorted(L, reverse=True) cnt_C = 0 cnt_B = 0 cnt_A = 0 for x, i in...
N = int(eval(input())) L = [] L.extend(((int(x), 3) for x in input().split())) L.extend(((int(x), 2) for x in input().split())) L.extend(((int(x), 1) for x in input().split())) L = sorted(L, reverse=True) cnt_C = 0 cnt_B = 0 cnt_A = 0 for x, i in L: if i == 1: cnt_C += 1 elif i == 2...
25
21
436
398
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) L = [] L.extend(((x, 3) for x in A)) L.extend(((x, 2) for x in B)) L.extend(((x, 1) for x in C)) L = sorted(L, reverse=True) cnt_C = 0 cnt_B = 0 cnt_A = 0 for x, i in L: if i == 1: ...
N = int(eval(input())) L = [] L.extend(((int(x), 3) for x in input().split())) L.extend(((int(x), 2) for x in input().split())) L.extend(((int(x), 1) for x in input().split())) L = sorted(L, reverse=True) cnt_C = 0 cnt_B = 0 cnt_A = 0 for x, i in L: if i == 1: cnt_C += 1 elif i == 2: cnt_B += cn...
false
16
[ "-A = list(map(int, input().split()))", "-B = list(map(int, input().split()))", "-C = list(map(int, input().split()))", "-L.extend(((x, 3) for x in A))", "-L.extend(((x, 2) for x in B))", "-L.extend(((x, 1) for x in C))", "+L.extend(((int(x), 3) for x in input().split()))", "+L.extend(((int(x), 2) for...
false
0.036122
0.035886
1.006564
[ "s918272806", "s208319882" ]
u761320129
p04000
python
s456042328
s592728667
2,176
1,154
180,344
177,868
Accepted
Accepted
46.97
from collections import Counter H,W,N = map(int,input().split()) src = [tuple(map(int,input().split())) for i in range(N)] blacks = Counter() for y,x in src: for i in range(-1,2): if not 0 <= y+i < H: continue for j in range(-1,2): if not 0 <= x+j < W: continue bla...
import sys input = sys.stdin.readline H,W,N = map(int,input().split()) AB = [tuple(map(int,input().split())) for i in range(N)] from collections import defaultdict dic = defaultdict(lambda: 0) for y,x in AB: for dx in range(-1,2): for dy in range(-1,2): nx,ny = x+dx,y+dy if...
18
22
495
595
from collections import Counter H, W, N = map(int, input().split()) src = [tuple(map(int, input().split())) for i in range(N)] blacks = Counter() for y, x in src: for i in range(-1, 2): if not 0 <= y + i < H: continue for j in range(-1, 2): if not 0 <= x + j < W: ...
import sys input = sys.stdin.readline H, W, N = map(int, input().split()) AB = [tuple(map(int, input().split())) for i in range(N)] from collections import defaultdict dic = defaultdict(lambda: 0) for y, x in AB: for dx in range(-1, 2): for dy in range(-1, 2): nx, ny = x + dx, y + dy ...
false
18.181818
[ "-from collections import Counter", "+import sys", "+input = sys.stdin.readline", "-src = [tuple(map(int, input().split())) for i in range(N)]", "-blacks = Counter()", "-for y, x in src:", "- for i in range(-1, 2):", "- if not 0 <= y + i < H:", "- continue", "- for j in...
false
0.065766
0.036221
1.815692
[ "s456042328", "s592728667" ]
u150984829
p02397
python
s801789020
s453198653
40
30
5,980
5,884
Accepted
Accepted
25
a=[] while 1: n=input() if n=='0 0':break a.append(n) for s in a: x,y=map(int,s.split()) print(y,x) if x>y else print(s)
a=[] while 1: n=input() if n=='0 0':break a.append(n) for s in a: x,y=map(int,s.split()) print(f'{y} {x}') if x>y else print(s)
8
8
132
139
a = [] while 1: n = input() if n == "0 0": break a.append(n) for s in a: x, y = map(int, s.split()) print(y, x) if x > y else print(s)
a = [] while 1: n = input() if n == "0 0": break a.append(n) for s in a: x, y = map(int, s.split()) print(f"{y} {x}") if x > y else print(s)
false
0
[ "- print(y, x) if x > y else print(s)", "+ print(f\"{y} {x}\") if x > y else print(s)" ]
false
0.048583
0.036847
1.318512
[ "s801789020", "s453198653" ]
u644907318
p03030
python
s629221903
s982724871
149
62
61,948
62,788
Accepted
Accepted
58.39
N = int(eval(input())) A = [list(input().split()) for _ in range(N)] A = sorted([(A[i][0],int(A[i][1]),i+1) for i in range(N)],key=lambda x:x[1],reverse=True) A = sorted(A,key=lambda x:x[0]) for i in range(N): print((A[i][2]))
N = int(eval(input())) A = [list(input().split()) for _ in range(N)] A = [(A[i][0],int(A[i][1]),i+1) for i in range(N)] A = sorted(A,key=lambda x:x[1],reverse=True) A = sorted(A,key=lambda x:x[0]) for i in range(N): print((A[i][2]))
6
7
227
234
N = int(eval(input())) A = [list(input().split()) for _ in range(N)] A = sorted( [(A[i][0], int(A[i][1]), i + 1) for i in range(N)], key=lambda x: x[1], reverse=True ) A = sorted(A, key=lambda x: x[0]) for i in range(N): print((A[i][2]))
N = int(eval(input())) A = [list(input().split()) for _ in range(N)] A = [(A[i][0], int(A[i][1]), i + 1) for i in range(N)] A = sorted(A, key=lambda x: x[1], reverse=True) A = sorted(A, key=lambda x: x[0]) for i in range(N): print((A[i][2]))
false
14.285714
[ "-A = sorted(", "- [(A[i][0], int(A[i][1]), i + 1) for i in range(N)], key=lambda x: x[1], reverse=True", "-)", "+A = [(A[i][0], int(A[i][1]), i + 1) for i in range(N)]", "+A = sorted(A, key=lambda x: x[1], reverse=True)" ]
false
0.181802
0.037277
4.87699
[ "s629221903", "s982724871" ]
u853728588
p02547
python
s621415963
s856530168
32
28
9,120
9,044
Accepted
Accepted
12.5
n = int(eval(input())) a = [] for _ in range(n): aa, b = list(map(int,input().split())) if aa == b: a.append("1") else: a.append("0") if "111" in "".join(a): print("Yes") else: print("No")
n = int(eval(input())) count = 0 for _ in range(n): d1, d2 = list(map(int, input().split())) if d1 == d2: count += 1 if count >= 3: print("Yes") exit() else: count = 0 print("No")
13
13
207
211
n = int(eval(input())) a = [] for _ in range(n): aa, b = list(map(int, input().split())) if aa == b: a.append("1") else: a.append("0") if "111" in "".join(a): print("Yes") else: print("No")
n = int(eval(input())) count = 0 for _ in range(n): d1, d2 = list(map(int, input().split())) if d1 == d2: count += 1 if count >= 3: print("Yes") exit() else: count = 0 print("No")
false
0
[ "-a = []", "+count = 0", "- aa, b = list(map(int, input().split()))", "- if aa == b:", "- a.append(\"1\")", "+ d1, d2 = list(map(int, input().split()))", "+ if d1 == d2:", "+ count += 1", "+ if count >= 3:", "+ print(\"Yes\")", "+ exit()", ...
false
0.040627
0.043649
0.930771
[ "s621415963", "s856530168" ]
u644907318
p02714
python
s910609965
s496073725
947
245
78,600
74,100
Accepted
Accepted
74.13
from bisect import bisect_right N = int(eval(input())) S = input().strip() R = [] G = [] B = [] Ron = [0 for _ in range(len(S))] Gon = [0 for _ in range(len(S))] Bon = [0 for _ in range(len(S))] for i in range(N): if S[i]=="R": R.append(i) Ron[i]=1 elif S[i]=="G": G.append(...
N = int(eval(input())) S = input().strip() C = {"R":[],"G":[],"B":[]} for i in range(N): C[S[i]].append(i) C["B"] = set(C["B"]) cnt = 0 for r in C["R"]: for g in C["G"]: if r<g: i = r j = g else: i = g j = r cnt += len(C["B"]...
88
23
2,934
502
from bisect import bisect_right N = int(eval(input())) S = input().strip() R = [] G = [] B = [] Ron = [0 for _ in range(len(S))] Gon = [0 for _ in range(len(S))] Bon = [0 for _ in range(len(S))] for i in range(N): if S[i] == "R": R.append(i) Ron[i] = 1 elif S[i] == "G": G.append(i) ...
N = int(eval(input())) S = input().strip() C = {"R": [], "G": [], "B": []} for i in range(N): C[S[i]].append(i) C["B"] = set(C["B"]) cnt = 0 for r in C["R"]: for g in C["G"]: if r < g: i = r j = g else: i = g j = r cnt += len(C["B"]) ...
false
73.863636
[ "-from bisect import bisect_right", "-", "-R = []", "-G = []", "-B = []", "-Ron = [0 for _ in range(len(S))]", "-Gon = [0 for _ in range(len(S))]", "-Bon = [0 for _ in range(len(S))]", "+C = {\"R\": [], \"G\": [], \"B\": []}", "- if S[i] == \"R\":", "- R.append(i)", "- Ron[i] ...
false
0.076029
0.038588
1.970276
[ "s910609965", "s496073725" ]
u665873062
p03722
python
s770499970
s522368607
1,767
1,168
3,572
3,572
Accepted
Accepted
33.9
#Nは頂点数, Mは辺数(2 <= N <= 1000, 1 <= M <= min(N(N-1, 2000))) #頂点1から頂点Nに移動して、移動スコアを最大にする #->移動スコアを正負反転させれば最短経路問題 #->負閉路を考慮してベルマンフォード法を利用 INF = 1 << 50 N,M = list(map(int,input().split())) #辺を登録 Sides = [] for i in range (M): Side = list(map(int,input().split())) Sides.append(Side) #コストを反転 Sides[...
#Nは頂点数, Mは辺数(2 <= N <= 1000, 1 <= M <= min(N(N-1, 2000))) #頂点1から頂点Nに移動して、移動スコアを最大にする #->移動スコアを正負反転させれば最短経路問題 #->負閉路を考慮してベルマンフォード法を利用 INF = 1 << 50 N,M = list(map(int,input().split())) #辺を登録 Sides = [] for i in range (M): Side = list(map(int,input().split())) Sides.append(Side) #コストを反転 Sides[...
51
52
1,119
1,175
# Nは頂点数, Mは辺数(2 <= N <= 1000, 1 <= M <= min(N(N-1, 2000))) # 頂点1から頂点Nに移動して、移動スコアを最大にする # ->移動スコアを正負反転させれば最短経路問題 # ->負閉路を考慮してベルマンフォード法を利用 INF = 1 << 50 N, M = list(map(int, input().split())) # 辺を登録 Sides = [] for i in range(M): Side = list(map(int, input().split())) Sides.append(Side) # コストを反転 Sides[i][2...
# Nは頂点数, Mは辺数(2 <= N <= 1000, 1 <= M <= min(N(N-1, 2000))) # 頂点1から頂点Nに移動して、移動スコアを最大にする # ->移動スコアを正負反転させれば最短経路問題 # ->負閉路を考慮してベルマンフォード法を利用 INF = 1 << 50 N, M = list(map(int, input().split())) # 辺を登録 Sides = [] for i in range(M): Side = list(map(int, input().split())) Sides.append(Side) # コストを反転 Sides[i][2...
false
1.923077
[ "+ # N回目の更新で更新された場合は負閉路あり", "-# 負閉路の確認", "+# 負閉路が終点までにあるか確認", "- if negative[from_v]:", "+ if negative[from_v] and negative[to_v] is False:", "- # if flag ==0:", "- # break", "+ if flag == 0:", "+ break" ]
false
0.067533
0.0653
1.034191
[ "s770499970", "s522368607" ]
u341543478
p03775
python
s057092216
s487721091
66
43
3,060
3,060
Accepted
Accepted
34.85
def calc_digit(n): d = 0 while n > 0: d += 1 n //= 10 return d n = int(eval(input())) temp = -1 ans = 12 i = 1 while i * i <= n: if n % i == 0: temp = max(calc_digit(i), calc_digit(n // i)) ans = min(temp,ans) i += 1 print(ans)
def count_digit(n): d = 0 while n > 0: n //= 10 d += 1 return d n = int(eval(input())) i = 1 ans = 11 while i * i <= n: if n % i == 0: temp = max(count_digit(i), count_digit(n // i)) if ans > temp: ans = temp i += 1 print(ans)
18
19
289
305
def calc_digit(n): d = 0 while n > 0: d += 1 n //= 10 return d n = int(eval(input())) temp = -1 ans = 12 i = 1 while i * i <= n: if n % i == 0: temp = max(calc_digit(i), calc_digit(n // i)) ans = min(temp, ans) i += 1 print(ans)
def count_digit(n): d = 0 while n > 0: n //= 10 d += 1 return d n = int(eval(input())) i = 1 ans = 11 while i * i <= n: if n % i == 0: temp = max(count_digit(i), count_digit(n // i)) if ans > temp: ans = temp i += 1 print(ans)
false
5.263158
[ "-def calc_digit(n):", "+def count_digit(n):", "+ n //= 10", "- n //= 10", "-temp = -1", "-ans = 12", "+ans = 11", "- temp = max(calc_digit(i), calc_digit(n // i))", "- ans = min(temp, ans)", "+ temp = max(count_digit(i), count_digit(n // i))", "+ if ans > t...
false
0.255086
0.070709
3.60755
[ "s057092216", "s487721091" ]
u893063840
p03682
python
s506628264
s216462617
1,533
1,339
99,440
78,780
Accepted
Accepted
12.65
from operator import itemgetter from scipy.sparse.csgraph import minimum_spanning_tree from scipy.sparse import csr_matrix n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] xyi = [[x, y, i] for i, (x, y) in enumerate(xy)] edge = set() xyi.sort() for (x1, y1, i1), (x2, y2, i2)...
from operator import itemgetter from collections import defaultdict from scipy.sparse.csgraph import minimum_spanning_tree from scipy.sparse import csr_matrix n = int(eval(input())) xy = [list(map(int, input().split())) + [i] for i in range(n)] INF = 10 ** 9 + 1 d = defaultdict(lambda: INF) for key in (it...
26
29
738
782
from operator import itemgetter from scipy.sparse.csgraph import minimum_spanning_tree from scipy.sparse import csr_matrix n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] xyi = [[x, y, i] for i, (x, y) in enumerate(xy)] edge = set() xyi.sort() for (x1, y1, i1), (x2, y2, i2) in zip(xyi, ...
from operator import itemgetter from collections import defaultdict from scipy.sparse.csgraph import minimum_spanning_tree from scipy.sparse import csr_matrix n = int(eval(input())) xy = [list(map(int, input().split())) + [i] for i in range(n)] INF = 10**9 + 1 d = defaultdict(lambda: INF) for key in (itemgetter(0), it...
false
10.344828
[ "+from collections import defaultdict", "-xy = [list(map(int, input().split())) for _ in range(n)]", "-xyi = [[x, y, i] for i, (x, y) in enumerate(xy)]", "-edge = set()", "-xyi.sort()", "-for (x1, y1, i1), (x2, y2, i2) in zip(xyi, xyi[1:]):", "- c = min(abs(x1 - x2), abs(y1 - y2))", "- edge.add(...
false
0.33783
0.30908
1.09302
[ "s506628264", "s216462617" ]
u796942881
p03779
python
s661680404
s060471397
32
27
2,940
3,060
Accepted
Accepted
15.62
def main(): X = int(eval(input())) ans = 1 while ans * (ans + 1) * 0.5 < X: ans += 1 print(ans) return main()
from operator import rshift def main(): X = int(eval(input())) ans = 1 while rshift(ans * (ans + 1), 1) < X: ans += 1 print(ans) return main()
10
13
143
181
def main(): X = int(eval(input())) ans = 1 while ans * (ans + 1) * 0.5 < X: ans += 1 print(ans) return main()
from operator import rshift def main(): X = int(eval(input())) ans = 1 while rshift(ans * (ans + 1), 1) < X: ans += 1 print(ans) return main()
false
23.076923
[ "+from operator import rshift", "+", "+", "- while ans * (ans + 1) * 0.5 < X:", "+ while rshift(ans * (ans + 1), 1) < X:" ]
false
0.038013
0.035114
1.082554
[ "s661680404", "s060471397" ]
u844646164
p02787
python
s875462329
s967576287
1,429
1,053
412,692
314,376
Accepted
Accepted
26.31
h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] max_a = 0 for a, b in ab: max_a = max(max_a, a) # i番目まで見たときに、モンスターの体力をj減らした時の、トキの消耗した魔力の最小値 dp = [[float('inf')]*(h+max_a+1) for _ in range(n+1)] for i in range(n+1): dp[i][0] = 0 for i in range(n): a, b = a...
import sys input = sys.stdin.readline H, N = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(N)] mx = max([a for a,b in ab]) dp = [[float('inf')]*(H+1+mx) for _ in range(N+1)] # i番目までの魔法を使った時にモンスターの体力をj減らすするのに必要な魔力の最少値 dp[0][0] = 0 for i in range(N): a, b = ab[i] f...
23
22
554
537
h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] max_a = 0 for a, b in ab: max_a = max(max_a, a) # i番目まで見たときに、モンスターの体力をj減らした時の、トキの消耗した魔力の最小値 dp = [[float("inf")] * (h + max_a + 1) for _ in range(n + 1)] for i in range(n + 1): dp[i][0] = 0 for i in range(n): a, ...
import sys input = sys.stdin.readline H, N = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(N)] mx = max([a for a, b in ab]) dp = [[float("inf")] * (H + 1 + mx) for _ in range(N + 1)] # i番目までの魔法を使った時にモンスターの体力をj減らすするのに必要な魔力の最少値 dp[0][0] = 0 for i in range(N): a, b = ab[i] f...
false
4.347826
[ "-h, n = list(map(int, input().split()))", "-ab = [list(map(int, input().split())) for _ in range(n)]", "-max_a = 0", "-for a, b in ab:", "- max_a = max(max_a, a)", "-# i番目まで見たときに、モンスターの体力をj減らした時の、トキの消耗した魔力の最小値", "-dp = [[float(\"inf\")] * (h + max_a + 1) for _ in range(n + 1)]", "-for i in range(n...
false
0.385107
0.157469
2.445601
[ "s875462329", "s967576287" ]
u325282913
p03779
python
s325550767
s892592713
31
25
2,940
2,940
Accepted
Accepted
19.35
X = int(eval(input())) ans = 0 for i in range(1,X+1): if ans + i <= X: ans += i else: print(i) exit() if ans == X: print(i) exit()
X = int(eval(input())) ans = 0 for i in range(1,X+1): ans += i if X <= ans: print(i) exit()
11
7
186
115
X = int(eval(input())) ans = 0 for i in range(1, X + 1): if ans + i <= X: ans += i else: print(i) exit() if ans == X: print(i) exit()
X = int(eval(input())) ans = 0 for i in range(1, X + 1): ans += i if X <= ans: print(i) exit()
false
36.363636
[ "- if ans + i <= X:", "- ans += i", "- else:", "+ ans += i", "+ if X <= ans:", "- if ans == X:", "- print(i)", "- exit()" ]
false
0.032586
0.040802
0.798641
[ "s325550767", "s892592713" ]
u518042385
p03557
python
s560306667
s101586828
412
329
24,000
23,328
Accepted
Accepted
20.15
import bisect n=int(eval(input())) la=sorted(map(int,input().split())) lb=sorted(map(int,input().split())) lc=sorted(map(int,input().split())) countb=[] count1=0 for i in range(n): index=bisect.bisect_left(la,lb[i]) countb.append(index) countb2=[] sum=0 for i in range(n): sum+=countb[i] countb2.ap...
import bisect n=int(eval(input())) la=sorted(map(int,input().split())) lb=sorted(map(int,input().split())) lc=sorted(map(int,input().split())) ans=0 for i in range(n): index1=bisect.bisect_left(la,lb[i]) index2=bisect.bisect_right(lc,lb[i]) ans+=index1*(n-index2) print(ans)
23
11
462
284
import bisect n = int(eval(input())) la = sorted(map(int, input().split())) lb = sorted(map(int, input().split())) lc = sorted(map(int, input().split())) countb = [] count1 = 0 for i in range(n): index = bisect.bisect_left(la, lb[i]) countb.append(index) countb2 = [] sum = 0 for i in range(n): sum += count...
import bisect n = int(eval(input())) la = sorted(map(int, input().split())) lb = sorted(map(int, input().split())) lc = sorted(map(int, input().split())) ans = 0 for i in range(n): index1 = bisect.bisect_left(la, lb[i]) index2 = bisect.bisect_right(lc, lb[i]) ans += index1 * (n - index2) print(ans)
false
52.173913
[ "-countb = []", "-count1 = 0", "-for i in range(n):", "- index = bisect.bisect_left(la, lb[i])", "- countb.append(index)", "-countb2 = []", "-sum = 0", "-for i in range(n):", "- sum += countb[i]", "- countb2.append(sum)", "- index = bisect.bisect_left(lb, lc[i])", "- if index...
false
0.042001
0.085749
0.489817
[ "s560306667", "s101586828" ]
u078042885
p00003
python
s458541255
s040962236
40
30
7,648
7,428
Accepted
Accepted
25
for _ in range(int(eval(input()))): a=sorted(map(int,input().split())) print(('YES' if a[0]**2+a[1]**2==a[2]**2 else'NO'))
for _ in[0]*int(eval(input())):a,b,c=sorted(map(int,input().split()));print((['NO','YES'][a*a+b*b==c*c]))
3
1
124
97
for _ in range(int(eval(input()))): a = sorted(map(int, input().split())) print(("YES" if a[0] ** 2 + a[1] ** 2 == a[2] ** 2 else "NO"))
for _ in [0] * int(eval(input())): a, b, c = sorted(map(int, input().split())) print((["NO", "YES"][a * a + b * b == c * c]))
false
66.666667
[ "-for _ in range(int(eval(input()))):", "- a = sorted(map(int, input().split()))", "- print((\"YES\" if a[0] ** 2 + a[1] ** 2 == a[2] ** 2 else \"NO\"))", "+for _ in [0] * int(eval(input())):", "+ a, b, c = sorted(map(int, input().split()))", "+ print(([\"NO\", \"YES\"][a * a + b * b == c * c]...
false
0.036325
0.036926
0.983735
[ "s458541255", "s040962236" ]
u169200126
p02658
python
s156439007
s098192277
81
61
21,600
21,588
Accepted
Accepted
24.69
n = int(eval(input())) An = [int(x) for x in input().split()] An.sort(reverse=True) if 0 in An: print((0)) exit() j = 10 ** 18 ans = 1 for i in range(n): if ans > j: print((-1)) quit() ans *= An[i] if ans > j : print((-1)) else : print(ans)
n = int(eval(input())) An = [int(x) for x in input().split()] for i in range(n): if An[i] == 0: print((0)) quit() j = 10 ** 18 ans = 1 for i in range(n): if ans > j: print((-1)) quit() ans *= An[i] if ans > j : print((-1)) else : print(an...
23
23
301
313
n = int(eval(input())) An = [int(x) for x in input().split()] An.sort(reverse=True) if 0 in An: print((0)) exit() j = 10**18 ans = 1 for i in range(n): if ans > j: print((-1)) quit() ans *= An[i] if ans > j: print((-1)) else: print(ans)
n = int(eval(input())) An = [int(x) for x in input().split()] for i in range(n): if An[i] == 0: print((0)) quit() j = 10**18 ans = 1 for i in range(n): if ans > j: print((-1)) quit() ans *= An[i] if ans > j: print((-1)) else: print(ans)
false
0
[ "-An.sort(reverse=True)", "-if 0 in An:", "- print((0))", "- exit()", "+for i in range(n):", "+ if An[i] == 0:", "+ print((0))", "+ quit()" ]
false
0.083874
0.007678
10.923378
[ "s156439007", "s098192277" ]
u867826040
p02987
python
s924304693
s646170233
24
21
3,444
3,316
Accepted
Accepted
12.5
from collections import Counter as co s=co(eval(input())) if all([i==2 for i in list(s.values())]) and len(list(s.keys()))==2: print("Yes") else: print("No")
from collections import Counter s = eval(input()) c = Counter(s) if len(c)==2 and all(vi==2 for vi in list(c.values())): print("Yes") else: print("No")
6
7
148
153
from collections import Counter as co s = co(eval(input())) if all([i == 2 for i in list(s.values())]) and len(list(s.keys())) == 2: print("Yes") else: print("No")
from collections import Counter s = eval(input()) c = Counter(s) if len(c) == 2 and all(vi == 2 for vi in list(c.values())): print("Yes") else: print("No")
false
14.285714
[ "-from collections import Counter as co", "+from collections import Counter", "-s = co(eval(input()))", "-if all([i == 2 for i in list(s.values())]) and len(list(s.keys())) == 2:", "+s = eval(input())", "+c = Counter(s)", "+if len(c) == 2 and all(vi == 2 for vi in list(c.values())):" ]
false
0.045483
0.041441
1.097555
[ "s924304693", "s646170233" ]
u744920373
p03546
python
s956865179
s320018443
369
227
46,044
43,100
Accepted
Accepted
38.48
import sys sys.setrecursionlimit(10**9) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): ret...
import sys sys.setrecursionlimit(10**9) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): ret...
58
75
1,496
1,998
import sys sys.setrecursionlimit(10**9) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] de...
import sys sys.setrecursionlimit(10**9) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] de...
false
22.666667
[ "-flag = -1", "+tmp = -1", "- global flag", "- flag = max(m, flag)", "+ global tmp", "+ tmp = max(m, tmp)", "- if i!=column and C[column][i] < m:", "+ if i != column and C[column][i] < m:", "- if flag != -1:", "- memo[i] = C[i][1]-flag", ...
false
0.047572
0.164317
0.289512
[ "s956865179", "s320018443" ]
u839675792
p03281
python
s896391420
s857152027
24
18
2,940
2,940
Accepted
Accepted
25
n = int(eval(input())) r = 0 for i in range(0, n, 2): c = 0 for j in range(0, i + 1, 2): if (i + 1) % (j + 1) == 0: c += 1 if c == 8: r += 1 print(r)
n = int(eval(input())) r = 0 for i in range(0, n, 2): c = 1 for j in range(2, i + 1, 2): if (i + 1) % (j + 1) == 0: c += 1 if c == 8: r += 1 print(r)
14
14
201
201
n = int(eval(input())) r = 0 for i in range(0, n, 2): c = 0 for j in range(0, i + 1, 2): if (i + 1) % (j + 1) == 0: c += 1 if c == 8: r += 1 print(r)
n = int(eval(input())) r = 0 for i in range(0, n, 2): c = 1 for j in range(2, i + 1, 2): if (i + 1) % (j + 1) == 0: c += 1 if c == 8: r += 1 print(r)
false
0
[ "- c = 0", "- for j in range(0, i + 1, 2):", "+ c = 1", "+ for j in range(2, i + 1, 2):" ]
false
0.041102
0.041734
0.984865
[ "s896391420", "s857152027" ]
u706414019
p03860
python
s202798600
s507508541
31
26
9,032
8,804
Accepted
Accepted
16.13
A,B,C = input().split() print((A[0]+B[0]+C[0]))
print(('A'+str(eval(input()))[8]+'C'))
2
1
46
30
A, B, C = input().split() print((A[0] + B[0] + C[0]))
print(("A" + str(eval(input()))[8] + "C"))
false
50
[ "-A, B, C = input().split()", "-print((A[0] + B[0] + C[0]))", "+print((\"A\" + str(eval(input()))[8] + \"C\"))" ]
false
0.037559
0.039757
0.944715
[ "s202798600", "s507508541" ]
u918601425
p02912
python
s499208354
s267259314
368
170
21,316
14,180
Accepted
Accepted
53.8
import heapq N,M=[int(s) for s in input().split()] ls=[int(s) for s in input().split()] h = [] for e in ls: heapq.heappush(h, (-e,e)) for i in range(M): x=heapq.heappop(h) y=x[1]//2 heapq.heappush(h,(-y,y)) ls2=[e[1] for e in h] print((sum(ls2)))
import heapq N,M=[int(s) for s in input().split()] ls=input().split() h = [] for e in ls: heapq.heappush(h, -int(e)) for i in range(M): x=heapq.heappop(h) y=(-x)//2 heapq.heappush(h,-y) print((-sum(h)))
12
11
264
219
import heapq N, M = [int(s) for s in input().split()] ls = [int(s) for s in input().split()] h = [] for e in ls: heapq.heappush(h, (-e, e)) for i in range(M): x = heapq.heappop(h) y = x[1] // 2 heapq.heappush(h, (-y, y)) ls2 = [e[1] for e in h] print((sum(ls2)))
import heapq N, M = [int(s) for s in input().split()] ls = input().split() h = [] for e in ls: heapq.heappush(h, -int(e)) for i in range(M): x = heapq.heappop(h) y = (-x) // 2 heapq.heappush(h, -y) print((-sum(h)))
false
8.333333
[ "-ls = [int(s) for s in input().split()]", "+ls = input().split()", "- heapq.heappush(h, (-e, e))", "+ heapq.heappush(h, -int(e))", "- y = x[1] // 2", "- heapq.heappush(h, (-y, y))", "-ls2 = [e[1] for e in h]", "-print((sum(ls2)))", "+ y = (-x) // 2", "+ heapq.heappush(h, -y)", ...
false
0.050879
0.048818
1.042223
[ "s499208354", "s267259314" ]
u761320129
p02615
python
s758273067
s018474682
180
162
31,440
31,340
Accepted
Accepted
10
N = int(eval(input())) A = list(map(int,input().split())) A.sort() ans = A[-1] i = N-1 N -= 2 while N: i -= 1 for _ in range(2): N -= 1 ans += A[i] if N<=0: break print(ans)
N = int(eval(input())) A = list(map(int,input().split())) A.sort() if N==2: print((max(A))) exit() ans = A.pop() n = N-2 while A: a = A.pop() for _ in range(2): n -= 1 ans += a if n==0: print(ans) exit()
13
17
211
276
N = int(eval(input())) A = list(map(int, input().split())) A.sort() ans = A[-1] i = N - 1 N -= 2 while N: i -= 1 for _ in range(2): N -= 1 ans += A[i] if N <= 0: break print(ans)
N = int(eval(input())) A = list(map(int, input().split())) A.sort() if N == 2: print((max(A))) exit() ans = A.pop() n = N - 2 while A: a = A.pop() for _ in range(2): n -= 1 ans += a if n == 0: print(ans) exit()
false
23.529412
[ "-ans = A[-1]", "-i = N - 1", "-N -= 2", "-while N:", "- i -= 1", "+if N == 2:", "+ print((max(A)))", "+ exit()", "+ans = A.pop()", "+n = N - 2", "+while A:", "+ a = A.pop()", "- N -= 1", "- ans += A[i]", "- if N <= 0:", "- break", "-print(...
false
0.042648
0.039848
1.070272
[ "s758273067", "s018474682" ]
u836737505
p03705
python
s032813413
s489822359
175
17
38,544
3,060
Accepted
Accepted
90.29
n,a,b = list(map(int,input().split())) if n == 1 and a == b: print((1)) elif (n == 1 and a != b) or a > b: print((0)) else: print(((n-1)*b+a-((n-1)*a+b)+1))
n,a,b = list(map(int, input().split())) if n == 1 and a==b: print((1)) elif n == 1 or a > b: print((0)) else: print(((n-2)*(b-a)+1))
7
7
162
138
n, a, b = list(map(int, input().split())) if n == 1 and a == b: print((1)) elif (n == 1 and a != b) or a > b: print((0)) else: print(((n - 1) * b + a - ((n - 1) * a + b) + 1))
n, a, b = list(map(int, input().split())) if n == 1 and a == b: print((1)) elif n == 1 or a > b: print((0)) else: print(((n - 2) * (b - a) + 1))
false
0
[ "-elif (n == 1 and a != b) or a > b:", "+elif n == 1 or a > b:", "- print(((n - 1) * b + a - ((n - 1) * a + b) + 1))", "+ print(((n - 2) * (b - a) + 1))" ]
false
0.093896
0.071979
1.304494
[ "s032813413", "s489822359" ]
u238940874
p03598
python
s033988795
s456815716
20
18
3,060
3,060
Accepted
Accepted
10
n=int(eval(input())) k=int(eval(input())) x=list(map(int,input().split())) ans=0 for i in range(n): ans+=min((x[i]-0)*2,(abs(x[i]-k))*2) print(ans)
n=int(eval(input())) k=int(eval(input())) x=list(map(int,input().split())) ans=0 for i in range(n): ans+=min(abs(x[i]-0)*2,abs(x[i]-k)*2) print(ans)
8
7
147
146
n = int(eval(input())) k = int(eval(input())) x = list(map(int, input().split())) ans = 0 for i in range(n): ans += min((x[i] - 0) * 2, (abs(x[i] - k)) * 2) print(ans)
n = int(eval(input())) k = int(eval(input())) x = list(map(int, input().split())) ans = 0 for i in range(n): ans += min(abs(x[i] - 0) * 2, abs(x[i] - k) * 2) print(ans)
false
12.5
[ "- ans += min((x[i] - 0) * 2, (abs(x[i] - k)) * 2)", "+ ans += min(abs(x[i] - 0) * 2, abs(x[i] - k) * 2)" ]
false
0.037576
0.034723
1.082181
[ "s033988795", "s456815716" ]
u796942881
p03862
python
s886146439
s096259073
90
81
14,092
14,092
Accepted
Accepted
10
def main(): N, x, *an = list(map(int, open(0).read().split())) ans = 0 for i in range(N - 1): if x < an[i] + an[i + 1]: cur = an[i] + an[i + 1] - x ans += cur if an[i + 1] <= cur: an[i + 1] = 0 else: an[i + 1] ...
def main(): N, x, *a = list(map(int, open(0).read().split())) ans = 0 pre = a[0] for i in range(1, N): if x < pre + a[i]: cur = pre + a[i] - x ans += cur a[i] = a[i] - cur if cur < a[i] else 0 pre = a[i] print(ans) return main()...
16
15
361
315
def main(): N, x, *an = list(map(int, open(0).read().split())) ans = 0 for i in range(N - 1): if x < an[i] + an[i + 1]: cur = an[i] + an[i + 1] - x ans += cur if an[i + 1] <= cur: an[i + 1] = 0 else: an[i + 1] -= cur ...
def main(): N, x, *a = list(map(int, open(0).read().split())) ans = 0 pre = a[0] for i in range(1, N): if x < pre + a[i]: cur = pre + a[i] - x ans += cur a[i] = a[i] - cur if cur < a[i] else 0 pre = a[i] print(ans) return main()
false
6.25
[ "- N, x, *an = list(map(int, open(0).read().split()))", "+ N, x, *a = list(map(int, open(0).read().split()))", "- for i in range(N - 1):", "- if x < an[i] + an[i + 1]:", "- cur = an[i] + an[i + 1] - x", "+ pre = a[0]", "+ for i in range(1, N):", "+ if x < pre + ...
false
0.036096
0.049122
0.734823
[ "s886146439", "s096259073" ]
u991567869
p02984
python
s688320347
s302416199
120
106
20,644
20,536
Accepted
Accepted
11.67
n = int(input()) a = list(map(int, input().split())) ans = a[0] l = [] for i in range(1, n, 2): ans -= a[i] ans += a[i + 1] l.append(ans) for i in range(n - 1): ans = (a[i] - ans//2)*2 l.append(ans) for i in l: print(i, end = " ")
n = int(eval(input())) a = list(map(int, input().split())) ans = a[0] l = [] for i in range(1, n, 2): ans -= a[i] ans += a[i + 1] l.append(ans) for i in range(n - 1): ans = a[i]*2 - ans l.append(ans) print((*l))
17
16
270
238
n = int(input()) a = list(map(int, input().split())) ans = a[0] l = [] for i in range(1, n, 2): ans -= a[i] ans += a[i + 1] l.append(ans) for i in range(n - 1): ans = (a[i] - ans // 2) * 2 l.append(ans) for i in l: print(i, end=" ")
n = int(eval(input())) a = list(map(int, input().split())) ans = a[0] l = [] for i in range(1, n, 2): ans -= a[i] ans += a[i + 1] l.append(ans) for i in range(n - 1): ans = a[i] * 2 - ans l.append(ans) print((*l))
false
5.882353
[ "-n = int(input())", "+n = int(eval(input()))", "- ans = (a[i] - ans // 2) * 2", "+ ans = a[i] * 2 - ans", "-for i in l:", "- print(i, end=\" \")", "+print((*l))" ]
false
0.032974
0.036928
0.892921
[ "s688320347", "s302416199" ]
u801049006
p03436
python
s699818204
s138988869
30
27
3,444
3,316
Accepted
Accepted
10
from collections import deque def bfs(): d = [[float("inf")] * w for i in range(h)] dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] que = deque([]) que.append((sx, sy)) d[sx][sy] = 0 while que: p = que.popleft() if p[0] == gx and p[1] == gy: break ...
from collections import deque H, W = list(map(int, input().split())) s = [list(eval(input())) for _ in range(H)] block_count = 0 for i in range(H): for j in range(W): if s[i][j] == '#': block_count += 1 d = [[0] * W for _ in range(H)] dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)] ...
44
32
933
708
from collections import deque def bfs(): d = [[float("inf")] * w for i in range(h)] dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] que = deque([]) que.append((sx, sy)) d[sx][sy] = 0 while que: p = que.popleft() if p[0] == gx and p[1] == gy: break for i in range(4...
from collections import deque H, W = list(map(int, input().split())) s = [list(eval(input())) for _ in range(H)] block_count = 0 for i in range(H): for j in range(W): if s[i][j] == "#": block_count += 1 d = [[0] * W for _ in range(H)] dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)] que = deque([]) qu...
false
27.272727
[ "-", "-def bfs():", "- d = [[float(\"inf\")] * w for i in range(h)]", "- dx = [1, 0, -1, 0]", "- dy = [0, 1, 0, -1]", "- que = deque([])", "- que.append((sx, sy))", "- d[sx][sy] = 0", "- while que:", "- p = que.popleft()", "- if p[0] == gx and p[1] == gy:", "...
false
0.036302
0.080423
0.451391
[ "s699818204", "s138988869" ]
u261103969
p02627
python
s053763013
s285994106
73
24
61,684
8,988
Accepted
Accepted
67.12
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): a = eval(input()) if a == a.upper(): print("A") else: print("a") if __name__ == '__main__': main()
s = eval(input()) if s == s.upper(): print("A") else: print("a")
19
6
270
72
import sys readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): a = eval(input()) if a == a.upper(): print("A") else: print("a") if __name__ == "__main__": main()
s = eval(input()) if s == s.upper(): print("A") else: print("a")
false
68.421053
[ "-import sys", "-", "-readline = sys.stdin.readline", "-MOD = 10**9 + 7", "-INF = float(\"INF\")", "-sys.setrecursionlimit(10**5)", "-", "-", "-def main():", "- a = eval(input())", "- if a == a.upper():", "- print(\"A\")", "- else:", "- print(\"a\")", "-", "-", ...
false
0.0378
0.057806
0.653916
[ "s053763013", "s285994106" ]
u426534722
p02327
python
s920720788
s216163565
3,380
1,600
54,324
8,188
Accepted
Accepted
52.66
from sys import stdin from collections import deque readline = stdin.readline h, w = list(map(int, readline().split())) w += 1 dp = [list(map(int, readline().split())) + [1] for _ in range(h)] for i in range(h): for j in range(w): dp[i][j] ^= 1 for i in range(1, h): for j in range(w): ...
from sys import stdin from collections import deque def judge(n,hs): stack = deque() ans = 0 for i, h in enumerate(hs): j = -1 while stack and stack[-1][1] > h: j, h2 = stack.pop() ans = max(ans, (i - j) * h2) if not stack or stack[-1][1] < h: ...
28
22
866
681
from sys import stdin from collections import deque readline = stdin.readline h, w = list(map(int, readline().split())) w += 1 dp = [list(map(int, readline().split())) + [1] for _ in range(h)] for i in range(h): for j in range(w): dp[i][j] ^= 1 for i in range(1, h): for j in range(w): if dp[i][...
from sys import stdin from collections import deque def judge(n, hs): stack = deque() ans = 0 for i, h in enumerate(hs): j = -1 while stack and stack[-1][1] > h: j, h2 = stack.pop() ans = max(ans, (i - j) * h2) if not stack or stack[-1][1] < h: s...
false
21.428571
[ "-readline = stdin.readline", "-h, w = list(map(int, readline().split()))", "-w += 1", "-dp = [list(map(int, readline().split())) + [1] for _ in range(h)]", "-for i in range(h):", "- for j in range(w):", "- dp[i][j] ^= 1", "-for i in range(1, h):", "- for j in range(w):", "- if...
false
0.037761
0.149315
0.252896
[ "s920720788", "s216163565" ]
u255673886
p03805
python
s950656882
s894290346
286
85
46,956
70,624
Accepted
Accepted
70.28
import sys readline = sys.stdin.buffer.readline from collections import deque from copy import copy,deepcopy from itertools import permutations def myinput(): return list(map(int,readline().split())) def mycol(data,col): return [ row[col] for row in data ] n,m = myinput() ab = [ list(myinput()...
from collections import deque from heapq import heapify,heappop,heappush,heappushpop from copy import copy,deepcopy from itertools import product,permutations,combinations,combinations_with_replacement from collections import defaultdict,Counter from bisect import bisect_left,bisect_right # from math import gcd,c...
44
131
882
2,834
import sys readline = sys.stdin.buffer.readline from collections import deque from copy import copy, deepcopy from itertools import permutations def myinput(): return list(map(int, readline().split())) def mycol(data, col): return [row[col] for row in data] n, m = myinput() ab = [list(myinput()) for _ in...
from collections import deque from heapq import heapify, heappop, heappush, heappushpop from copy import copy, deepcopy from itertools import product, permutations, combinations, combinations_with_replacement from collections import defaultdict, Counter from bisect import bisect_left, bisect_right # from math import g...
false
66.412214
[ "-import sys", "+from collections import deque", "+from heapq import heapify, heappop, heappush, heappushpop", "+from copy import copy, deepcopy", "+from itertools import product, permutations, combinations, combinations_with_replacement", "+from collections import defaultdict, Counter", "+from bisect i...
false
0.065533
0.058291
1.124249
[ "s950656882", "s894290346" ]
u179169725
p03450
python
s416699831
s798654431
1,140
692
80,552
118,616
Accepted
Accepted
39.3
# https://atcoder.jp/contests/abc087/tasks/arc090_b # ノードL→RへのコストはDであるとすれば、有向グラフと見なせる # 任意のノードからbfsをして座標をメモしていけば良い。 # 探索済みのノードに到達したときに座標があっているかチェック、あっていればそれ以上探索する必要はない。 # 連結していないグラフがあるかもしれない。(だけど連結していないグラフはお互いに独立) # 0以上10**9以下っていう制約なのでそこでWAを出されるかと思ったがそんなことなかった import sys read = sys.stdin.readline def ...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ...
64
97
1,384
2,029
# https://atcoder.jp/contests/abc087/tasks/arc090_b # ノードL→RへのコストはDであるとすれば、有向グラフと見なせる # 任意のノードからbfsをして座標をメモしていけば良い。 # 探索済みのノードに到達したときに座標があっているかチェック、あっていればそれ以上探索する必要はない。 # 連結していないグラフがあるかもしれない。(だけど連結していないグラフはお互いに独立) # 0以上10**9以下っていう制約なのでそこでWAを出されるかと思ったがそんなことなかった import sys read = sys.stdin.readline def read_ints(): ...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tupl...
false
34.020619
[ "-# https://atcoder.jp/contests/abc087/tasks/arc090_b", "-# ノードL→RへのコストはDであるとすれば、有向グラフと見なせる", "-# 任意のノードからbfsをして座標をメモしていけば良い。", "-# 探索済みのノードに到達したときに座標があっているかチェック、あっていればそれ以上探索する必要はない。", "-# 連結していないグラフがあるかもしれない。(だけど連結していないグラフはお互いに独立)", "-# 0以上10**9以下っていう制約なのでそこでWAを出されるかと思ったがそんなことなかった", "+sys.setrecursionl...
false
0.059027
0.105218
0.560997
[ "s416699831", "s798654431" ]
u057109575
p03088
python
s385161531
s555224376
311
118
48,220
75,908
Accepted
Accepted
62.06
N = int(eval(input())) MOD = 10 ** 9 + 7 memo = [{} for i in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if ''.join(t).count('AGC') >= 1: return False return True def dfs(cur, last3): ...
N = int(eval(input())) MOD = 10 ** 9 + 7 memo = [{} for _ in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if "".join(t).count("AGC") > 0: return False return True def dfs(cur, l...
29
34
614
615
N = int(eval(input())) MOD = 10**9 + 7 memo = [{} for i in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if "".join(t).count("AGC") >= 1: return False return True def dfs(cur, last3): if last3 in...
N = int(eval(input())) MOD = 10**9 + 7 memo = [{} for _ in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if "".join(t).count("AGC") > 0: return False return True def dfs(cur, last3): if last3 in ...
false
14.705882
[ "-memo = [{} for i in range(N + 1)]", "+memo = [{} for _ in range(N + 1)]", "- if \"\".join(t).count(\"AGC\") >= 1:", "+ if \"\".join(t).count(\"AGC\") > 0:" ]
false
0.070798
0.068371
1.035498
[ "s385161531", "s555224376" ]
u256256172
p02407
python
s388319370
s066430616
50
30
7,440
7,448
Accepted
Accepted
40
x = eval(input()) a = [] b = input().split() for i in b: a.append(i) a.reverse() print((" ".join(a)))
eval(input()) a = list(input().split()) a.reverse() print((" ".join(a)))
7
4
103
67
x = eval(input()) a = [] b = input().split() for i in b: a.append(i) a.reverse() print((" ".join(a)))
eval(input()) a = list(input().split()) a.reverse() print((" ".join(a)))
false
42.857143
[ "-x = eval(input())", "-a = []", "-b = input().split()", "-for i in b:", "- a.append(i)", "+eval(input())", "+a = list(input().split())" ]
false
0.116255
0.195506
0.594637
[ "s388319370", "s066430616" ]