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
u057964173
p02947
python
s167232316
s743928714
395
247
24,652
19,760
Accepted
Accepted
37.47
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(eval(input())) s=[sorted(list(eval(input()))) for i in range(n)] s.sort() ans=0 cnt=1 for i in range(n-1): if s[i]==s[i+1]: cnt+=1 if i ==n-2: ...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(eval(input())) # 文字列を一文字ずつのリストにして、辞書順にソートしたあと、文字列に戻す # ['aab','aab','aab','ccd','ccd']ってなってる l=[''.join(sorted(list(eval(input())))) for i in range(n)] from collections import Counter c=Counter(l)# ()にカウ...
20
18
463
500
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) s = [sorted(list(eval(input()))) for i in range(n)] s.sort() ans = 0 cnt = 1 for i in range(n - 1): if s[i] == s[i + 1]: cnt += 1 if i == n - 2: ...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) # 文字列を一文字ずつのリストにして、辞書順にソートしたあと、文字列に戻す # ['aab','aab','aab','ccd','ccd']ってなってる l = ["".join(sorted(list(eval(input())))) for i in range(n)] from collections import Counter c = Counter(l) # ...
false
10
[ "- s = [sorted(list(eval(input()))) for i in range(n)]", "- s.sort()", "+ # 文字列を一文字ずつのリストにして、辞書順にソートしたあと、文字列に戻す", "+ # ['aab','aab','aab','ccd','ccd']ってなってる", "+ l = [\"\".join(sorted(list(eval(input())))) for i in range(n)]", "+ from collections import Counter", "+", "+ c = Count...
false
0.104136
0.081343
1.280201
[ "s167232316", "s743928714" ]
u130900604
p02773
python
s516450154
s098612198
774
505
60,048
45,264
Accepted
Accepted
34.75
n=int(eval(input())) sl=[] for i in range(n): s=eval(input()) sl.append(s) import collections c=collections.Counter(sl) # print(c) d=(c.most_common()) e=[d[0][0]] tmp=d[0][1] for i,j in d: if tmp==j: e.append(i) else: break e=list(set(e)) e.sort() for i in e...
n,*s=list(map(str,open(0).read().split())) from collections import* c=Counter(s).most_common() maxm=c[0][1] ans=[] for i,j in c: if maxm==j: ans+=i, for b in sorted(ans): print(b)
24
10
324
191
n = int(eval(input())) sl = [] for i in range(n): s = eval(input()) sl.append(s) import collections c = collections.Counter(sl) # print(c) d = c.most_common() e = [d[0][0]] tmp = d[0][1] for i, j in d: if tmp == j: e.append(i) else: break e = list(set(e)) e.sort() for i in e: print(...
n, *s = list(map(str, open(0).read().split())) from collections import * c = Counter(s).most_common() maxm = c[0][1] ans = [] for i, j in c: if maxm == j: ans += (i,) for b in sorted(ans): print(b)
false
58.333333
[ "-n = int(eval(input()))", "-sl = []", "-for i in range(n):", "- s = eval(input())", "- sl.append(s)", "-import collections", "+n, *s = list(map(str, open(0).read().split()))", "+from collections import *", "-c = collections.Counter(sl)", "-# print(c)", "-d = c.most_common()", "-e = [d[0...
false
0.119926
0.066075
1.814993
[ "s516450154", "s098612198" ]
u531813438
p02801
python
s560562823
s150135592
19
17
2,940
2,940
Accepted
Accepted
10.53
C = str(eval(input())) alpha= 'abcdefghijklmnopqrstuvwxyz' print((alpha[alpha.index(C)+1]))
#アスキーコードから文字 chr() #文字からアスキーコード ord() print((chr(ord(eval(input()))+1)))
3
3
85
66
C = str(eval(input())) alpha = "abcdefghijklmnopqrstuvwxyz" print((alpha[alpha.index(C) + 1]))
# アスキーコードから文字 chr() # 文字からアスキーコード ord() print((chr(ord(eval(input())) + 1)))
false
0
[ "-C = str(eval(input()))", "-alpha = \"abcdefghijklmnopqrstuvwxyz\"", "-print((alpha[alpha.index(C) + 1]))", "+# アスキーコードから文字 chr()", "+# 文字からアスキーコード ord()", "+print((chr(ord(eval(input())) + 1)))" ]
false
0.162126
0.157034
1.032422
[ "s560562823", "s150135592" ]
u327466606
p02803
python
s194339254
s210834292
1,737
210
45,276
3,064
Accepted
Accepted
87.91
from itertools import count, combinations, product H,W = list(map(int,input().split())) grid = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): S = eval(input()) for j,v in zip(list(range(1,W+1)),S): grid[i][j] = v == '.' visited = [[0 if v else float('inf') for v in row] for ro...
from itertools import count, combinations, product H,W = list(map(int,input().split())) grid = [[False]*(W+2) for _ in range(H+2)] for i in range(1,H+1): S = eval(input()) for j,v in zip(list(range(1,W+1)),S): grid[i][j] = v == '.' visited = [[0 if v else float('inf') for v in row] for ro...
37
33
994
822
from itertools import count, combinations, product H, W = list(map(int, input().split())) grid = [[False] * (W + 2) for _ in range(H + 2)] for i in range(1, H + 1): S = eval(input()) for j, v in zip(list(range(1, W + 1)), S): grid[i][j] = v == "." visited = [[0 if v else float("inf") for v in row] for ...
from itertools import count, combinations, product H, W = list(map(int, input().split())) grid = [[False] * (W + 2) for _ in range(H + 2)] for i in range(1, H + 1): S = eval(input()) for j, v in zip(list(range(1, W + 1)), S): grid[i][j] = v == "." visited = [[0 if v else float("inf") for v in row] for ...
false
10.810811
[ "-", "-", "-def dist(p1, p2):", "- global cnt", "- q = [p1]", "- visited[p1[0]][p1[1]] = cnt", "+res = 0", "+for i, j in product(list(range(H + 2)), list(range(W + 2))):", "+ if not grid[i][j]:", "+ continue", "+ q = [(i, j)]", "+ visited[i][j] = cnt", "- ...
false
0.083349
0.037242
2.238047
[ "s194339254", "s210834292" ]
u009961299
p02389
python
s596285632
s681117340
30
20
6,724
5,592
Accepted
Accepted
33.33
[ a, b ] = list(map ( int, input ( ).split ( ) )) print(( "%s %s" % ( a * b, 2 * ( a + b ) ) ))
x = input().split() a, b = int(x[0]), int(x[1]) print(("%d %d" % (a * b, 2 * (a + b))))
2
5
89
92
[a, b] = list(map(int, input().split())) print(("%s %s" % (a * b, 2 * (a + b))))
x = input().split() a, b = int(x[0]), int(x[1]) print(("%d %d" % (a * b, 2 * (a + b))))
false
60
[ "-[a, b] = list(map(int, input().split()))", "-print((\"%s %s\" % (a * b, 2 * (a + b))))", "+x = input().split()", "+a, b = int(x[0]), int(x[1])", "+print((\"%d %d\" % (a * b, 2 * (a + b))))" ]
false
0.048781
0.048369
1.008521
[ "s596285632", "s681117340" ]
u197615397
p02346
python
s172642505
s527575795
2,400
680
18,596
10,740
Accepted
Accepted
71.67
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = [default] * (self.ele...
import sys class BinaryIndexedTree(object): __slots__ = ["tree"] def __init__(self, size: int): self.tree = [0]*(size+1) def add(self, index: int, value: int) -> None: tree = self.tree next_index = index + 1 while next_index < len(tree): tree[ne...
62
39
1,893
976
import math class SegmentTree: __slots__ = ["elem_size", "tree_size", "tree"] def __init__(self, a: list, default: int): real_size = len(a) self.elem_size = 1 << math.ceil(math.log2(real_size)) self.tree_size = 2 * self.elem_size + 1 self.tree = ( [default] * (self...
import sys class BinaryIndexedTree(object): __slots__ = ["tree"] def __init__(self, size: int): self.tree = [0] * (size + 1) def add(self, index: int, value: int) -> None: tree = self.tree next_index = index + 1 while next_index < len(tree): tree[next_index] +...
false
37.096774
[ "-import math", "+import sys", "-class SegmentTree:", "- __slots__ = [\"elem_size\", \"tree_size\", \"tree\"]", "+class BinaryIndexedTree(object):", "+ __slots__ = [\"tree\"]", "- def __init__(self, a: list, default: int):", "- real_size = len(a)", "- self.elem_size = 1 << mat...
false
0.05673
0.036516
1.553535
[ "s172642505", "s527575795" ]
u368796742
p03338
python
s715524163
s464614275
20
18
2,940
2,940
Accepted
Accepted
10
n = int(eval(input())) l = list(eval(input())) ans = 0 for i in range(n): l1 = l[i+1:] count = set() for j in range(i+1): if l[j] in l1: count.add(l[j]) ans = max(ans,len(count)) print(ans)
n = int(eval(input())) l = list(eval(input())) ans = 0 for i in range(n): count = len(set(l[:i])&set(l[i:])) ans = max(count,ans) print(ans)
13
7
214
142
n = int(eval(input())) l = list(eval(input())) ans = 0 for i in range(n): l1 = l[i + 1 :] count = set() for j in range(i + 1): if l[j] in l1: count.add(l[j]) ans = max(ans, len(count)) print(ans)
n = int(eval(input())) l = list(eval(input())) ans = 0 for i in range(n): count = len(set(l[:i]) & set(l[i:])) ans = max(count, ans) print(ans)
false
46.153846
[ "- l1 = l[i + 1 :]", "- count = set()", "- for j in range(i + 1):", "- if l[j] in l1:", "- count.add(l[j])", "- ans = max(ans, len(count))", "+ count = len(set(l[:i]) & set(l[i:]))", "+ ans = max(count, ans)" ]
false
0.037558
0.03976
0.944607
[ "s715524163", "s464614275" ]
u197615397
p02361
python
s482488498
s271729415
2,490
1,790
97,980
98,040
Accepted
Accepted
28.11
from heapq import heappush, heappop V, E, r = list(map(int, input().split())) inf = 10**10 edges = [[] for _ in [None]*V] vertices = [inf]*V vertices[r] = 0 for _ in [None]*E: s, t, d = list(map(int, input().split())) edges[s].append((t, d)) q = [(0, r)] rem = V-1 while q: cost, v = heappop(...
import sys from heapq import heappush, heappop readline = sys.stdin.readline V, E, r = list(map(int, readline().split())) inf = 10**10 edges = [[] for _ in [None]*V] vertices = [inf]*V vertices[r] = 0 for _ in [None]*E: s, t, d = list(map(int, readline().split())) edges[s].append((t, d)) q = [(0,...
27
27
656
680
from heapq import heappush, heappop V, E, r = list(map(int, input().split())) inf = 10**10 edges = [[] for _ in [None] * V] vertices = [inf] * V vertices[r] = 0 for _ in [None] * E: s, t, d = list(map(int, input().split())) edges[s].append((t, d)) q = [(0, r)] rem = V - 1 while q: cost, v = heappop(q) ...
import sys from heapq import heappush, heappop readline = sys.stdin.readline V, E, r = list(map(int, readline().split())) inf = 10**10 edges = [[] for _ in [None] * V] vertices = [inf] * V vertices[r] = 0 for _ in [None] * E: s, t, d = list(map(int, readline().split())) edges[s].append((t, d)) q = [(0, r)] rem...
false
0
[ "+import sys", "-V, E, r = list(map(int, input().split()))", "+readline = sys.stdin.readline", "+V, E, r = list(map(int, readline().split()))", "- s, t, d = list(map(int, input().split()))", "+ s, t, d = list(map(int, readline().split()))", "-while q:", "+while q and rem:", "+ rem -= 1", ...
false
0.03722
0.047518
0.783285
[ "s482488498", "s271729415" ]
u888092736
p04045
python
s045645659
s271523429
91
71
9,132
9,168
Accepted
Accepted
21.98
N, K = list(map(int, input().split())) D = {i for i in range(10)} - set(map(int, input().split())) for i in range(N, 100000): if all(j in D for j in map(int, str(i))): print(i) break
N, K, *D = list(map(int, open(0).read().split())) D = set(str(d) for d in D) for i in range(N, 100_000): if set(str(i)) & D: continue print(i) break
6
7
202
169
N, K = list(map(int, input().split())) D = {i for i in range(10)} - set(map(int, input().split())) for i in range(N, 100000): if all(j in D for j in map(int, str(i))): print(i) break
N, K, *D = list(map(int, open(0).read().split())) D = set(str(d) for d in D) for i in range(N, 100_000): if set(str(i)) & D: continue print(i) break
false
14.285714
[ "-N, K = list(map(int, input().split()))", "-D = {i for i in range(10)} - set(map(int, input().split()))", "-for i in range(N, 100000):", "- if all(j in D for j in map(int, str(i))):", "- print(i)", "- break", "+N, K, *D = list(map(int, open(0).read().split()))", "+D = set(str(d) for ...
false
0.044339
0.119403
0.371336
[ "s045645659", "s271523429" ]
u254871849
p03659
python
s077318846
s056132720
233
138
24,680
24,064
Accepted
Accepted
40.77
import sys input = sys.stdin.readline n = int(eval(input())) a = [int(a) for a in input().split()] s = [None] * n; s[0] = a[0] for i in range(n-1): s[i+1] = s[i] + a[i+1] mixi = abs(s[0] - (s[n-1] - s[0])) for i in range(1, n-1): mixi = min(mixi, abs(s[i] - (s[n-1] - s[i]))) # 全部取るのはダメ print(mixi)
import sys n, *a = list(map(int, sys.stdin.read().split())) def main(): x = 0 y = sum(a) res = [] for i in range(n-1): x += a[i] y -= a[i] res.append(abs(x - y)) return min(res) if __name__ == '__main__': ans = main() print(ans)
12
18
308
295
import sys input = sys.stdin.readline n = int(eval(input())) a = [int(a) for a in input().split()] s = [None] * n s[0] = a[0] for i in range(n - 1): s[i + 1] = s[i] + a[i + 1] mixi = abs(s[0] - (s[n - 1] - s[0])) for i in range(1, n - 1): mixi = min(mixi, abs(s[i] - (s[n - 1] - s[i]))) # 全部取るのはダメ print(mixi)
import sys n, *a = list(map(int, sys.stdin.read().split())) def main(): x = 0 y = sum(a) res = [] for i in range(n - 1): x += a[i] y -= a[i] res.append(abs(x - y)) return min(res) if __name__ == "__main__": ans = main() print(ans)
false
33.333333
[ "-input = sys.stdin.readline", "-n = int(eval(input()))", "-a = [int(a) for a in input().split()]", "-s = [None] * n", "-s[0] = a[0]", "-for i in range(n - 1):", "- s[i + 1] = s[i] + a[i + 1]", "-mixi = abs(s[0] - (s[n - 1] - s[0]))", "-for i in range(1, n - 1):", "- mixi = min(mixi, abs(s[i...
false
0.055806
0.055651
1.002784
[ "s077318846", "s056132720" ]
u329565519
p03599
python
s496471853
s802222231
104
64
3,828
3,188
Accepted
Accepted
38.46
A, B, C, D, E, F = list(map(int, input().split())) W = set() for a in range(0, F+1, 100*A): for b in range(0, F+1, 100*B): W.add(a+b) S = set() for c in range(0, F+1, C): for d in range(0, F+1, D): S.add(c+d) rate = -1 for w in W: for s in S: if 0 < w + s <= F and s * 1...
A, B, C, D, E, F = list(map(int, input().split())) ws = set() ss = set() for a in range(0, F+1, A*100): for b in range(0, F+1-a, B*100): ws.add(a + b) for c in range(0, F+1, C): for d in range(0, F+1-c, D): ss.add(c + d) mx = -1 ans = 0, 0 for w in ws: if w == 0: c...
18
24
453
474
A, B, C, D, E, F = list(map(int, input().split())) W = set() for a in range(0, F + 1, 100 * A): for b in range(0, F + 1, 100 * B): W.add(a + b) S = set() for c in range(0, F + 1, C): for d in range(0, F + 1, D): S.add(c + d) rate = -1 for w in W: for s in S: if 0 < w + s <= F and s *...
A, B, C, D, E, F = list(map(int, input().split())) ws = set() ss = set() for a in range(0, F + 1, A * 100): for b in range(0, F + 1 - a, B * 100): ws.add(a + b) for c in range(0, F + 1, C): for d in range(0, F + 1 - c, D): ss.add(c + d) mx = -1 ans = 0, 0 for w in ws: if w == 0: cont...
false
25
[ "-W = set()", "-for a in range(0, F + 1, 100 * A):", "- for b in range(0, F + 1, 100 * B):", "- W.add(a + b)", "-S = set()", "+ws = set()", "+ss = set()", "+for a in range(0, F + 1, A * 100):", "+ for b in range(0, F + 1 - a, B * 100):", "+ ws.add(a + b)", "- for d in rang...
false
0.088479
0.157028
0.563465
[ "s496471853", "s802222231" ]
u854931881
p02552
python
s095965172
s892730512
34
25
9,144
9,100
Accepted
Accepted
26.47
x=int(eval(input())) if x==1: print("0") elif x==0: print("1")
x=int(eval(input())) if x==1: print((0)) else: print((1))
5
5
64
59
x = int(eval(input())) if x == 1: print("0") elif x == 0: print("1")
x = int(eval(input())) if x == 1: print((0)) else: print((1))
false
0
[ "- print(\"0\")", "-elif x == 0:", "- print(\"1\")", "+ print((0))", "+else:", "+ print((1))" ]
false
0.043981
0.043107
1.020272
[ "s095965172", "s892730512" ]
u133936772
p02641
python
s845401208
s612323173
24
22
9,176
9,168
Accepted
Accepted
8.33
x,n,*p=list(map(int,open(0).read().split())) p=set(p) l=r=x while 1: if l not in p: print(l); break l-=1 if r not in p: print(r); break r+=1
x,n,*p=list(map(int,open(0).read().split())) l=r=x while 1: if l not in p: print(l); break l-=1 if r not in p: print(r); break r+=1
8
7
149
139
x, n, *p = list(map(int, open(0).read().split())) p = set(p) l = r = x while 1: if l not in p: print(l) break l -= 1 if r not in p: print(r) break r += 1
x, n, *p = list(map(int, open(0).read().split())) l = r = x while 1: if l not in p: print(l) break l -= 1 if r not in p: print(r) break r += 1
false
12.5
[ "-p = set(p)" ]
false
0.03578
0.036811
0.971988
[ "s845401208", "s612323173" ]
u225388820
p03171
python
s351396304
s378104162
301
263
77,148
41,580
Accepted
Accepted
12.62
# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点) import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n=int(eval(input())) a=list(map(int,input().split())) INF=-10**14 dp=[[0]*(i+1) for i in range(n)] for i in range(n): dp[i][i]=a[i] for i in range(1,n): for j in range(i-1,-1,-1): ...
import sys input = sys.stdin.readline n=int(eval(input())) a=list(map(int,input().split())) dp=[0]*3000 for i in range(n): dp[i]=a[i] for i in range(1,n): for j in range(i-1,-1,-1): dp[j]=max(a[i]-dp[j],a[j]-dp[j+1]) print((dp[0]))
14
11
384
249
# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点) import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) INF = -(10**14) dp = [[0] * (i + 1) for i in range(n)] for i in range(n): dp[i][i] = a[i] for i in range(1, n): for j in range(i - 1,...
import sys input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) dp = [0] * 3000 for i in range(n): dp[i] = a[i] for i in range(1, n): for j in range(i - 1, -1, -1): dp[j] = max(a[i] - dp[j], a[j] - dp[j + 1]) print((dp[0]))
false
21.428571
[ "-# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)", "-sys.setrecursionlimit(1000000000)", "-INF = -(10**14)", "-dp = [[0] * (i + 1) for i in range(n)]", "+dp = [0] * 3000", "- dp[i][i] = a[i]", "+ dp[i] = a[i]", "- dp[i][j] = max(a[i] - dp[i - 1][j], a[j] - dp[i][j + 1])", "-print((dp[-1...
false
0.122247
0.052376
2.334021
[ "s351396304", "s378104162" ]
u867826040
p02574
python
s992508474
s459090715
1,954
647
127,980
127,764
Accepted
Accepted
66.89
from functools import reduce from math import gcd, sqrt,ceil n = int(eval(input())) a = list(map(int,input().split())) m = 10**6 a_gcd = reduce(gcd,a) if a_gcd != 1: print("not coprime") exit(0) isset = a_gcd == 1 hurui = [i for i in range(m+1)] for i in range(2,ceil(sqrt(m))+1): for j in ...
from functools import reduce from math import gcd, sqrt,ceil n = int(eval(input())) a = list(map(int,input().split())) m = 10**6 a_gcd = reduce(gcd,a) if a_gcd != 1: print("not coprime") exit(0) isset = a_gcd == 1 hurui = [i for i in range(m+1)] for i in range(2,ceil(sqrt(m))+1): for j in ...
43
41
873
851
from functools import reduce from math import gcd, sqrt, ceil n = int(eval(input())) a = list(map(int, input().split())) m = 10**6 a_gcd = reduce(gcd, a) if a_gcd != 1: print("not coprime") exit(0) isset = a_gcd == 1 hurui = [i for i in range(m + 1)] for i in range(2, ceil(sqrt(m)) + 1): for j in range(2, ...
from functools import reduce from math import gcd, sqrt, ceil n = int(eval(input())) a = list(map(int, input().split())) m = 10**6 a_gcd = reduce(gcd, a) if a_gcd != 1: print("not coprime") exit(0) isset = a_gcd == 1 hurui = [i for i in range(m + 1)] for i in range(2, ceil(sqrt(m)) + 1): for j in range(2, ...
false
4.651163
[ "- p_f = False", "+ print(\"setwise coprime\")", "+ exit(0)", "-if p_f:", "- print(\"pairwise coprime\")", "-elif isset:", "- print(\"setwise coprime\")", "+print(\"pairwise coprime\")" ]
false
0.677842
1.041106
0.651079
[ "s992508474", "s459090715" ]
u392319141
p02716
python
s068987473
s478783629
272
152
50,652
31,684
Accepted
Accepted
44.12
N = int(eval(input())) A = list(map(int, input().split())) INF = 10**18 dp0 = [-INF] * (N + 2) dp1 = [-INF] * (N + 2) dp2 = [-INF] * (N + 2) dp0[0] = 0 dp0[1] = 0 dp1[0] = 0 dp1[1] = 0 for i, a in enumerate(A, start=2): dp0[i] = dp0[i - 2] + a dp1[i] = max(dp1[i - 2] + a, dp0[i - 1]) dp2[i]...
N = int(eval(input())) A = list(map(int, input().split())) INF = 10**18 dp0 = 0 dp1 = -INF dp2 = -INF for i, a in enumerate(A): if i % 2 == 0: dp1 = max(dp1, dp0) dp0 += a dp2 += a else: dp2 = max(dp2, dp1) dp1 += a if N % 2 == 1: print((max(dp1, ...
21
21
440
352
N = int(eval(input())) A = list(map(int, input().split())) INF = 10**18 dp0 = [-INF] * (N + 2) dp1 = [-INF] * (N + 2) dp2 = [-INF] * (N + 2) dp0[0] = 0 dp0[1] = 0 dp1[0] = 0 dp1[1] = 0 for i, a in enumerate(A, start=2): dp0[i] = dp0[i - 2] + a dp1[i] = max(dp1[i - 2] + a, dp0[i - 1]) dp2[i] = max(dp2[i - 2]...
N = int(eval(input())) A = list(map(int, input().split())) INF = 10**18 dp0 = 0 dp1 = -INF dp2 = -INF for i, a in enumerate(A): if i % 2 == 0: dp1 = max(dp1, dp0) dp0 += a dp2 += a else: dp2 = max(dp2, dp1) dp1 += a if N % 2 == 1: print((max(dp1, dp2))) else: prin...
false
0
[ "-dp0 = [-INF] * (N + 2)", "-dp1 = [-INF] * (N + 2)", "-dp2 = [-INF] * (N + 2)", "-dp0[0] = 0", "-dp0[1] = 0", "-dp1[0] = 0", "-dp1[1] = 0", "-for i, a in enumerate(A, start=2):", "- dp0[i] = dp0[i - 2] + a", "- dp1[i] = max(dp1[i - 2] + a, dp0[i - 1])", "- dp2[i] = max(dp2[i - 2] + a, ...
false
0.06802
0.038818
1.752248
[ "s068987473", "s478783629" ]
u562935282
p03112
python
s769313714
s537650155
1,506
1,301
16,176
16,152
Accepted
Accepted
13.61
from bisect import bisect_left A, B, Q = list(map(int, input().split())) s = [int(eval(input())) for _ in range(A)] t = [int(eval(input())) for _ in range(B)] x = [int(eval(input())) for _ in range(Q)] for xx in x: # 神先 ps_r = 0 s_r = bisect_left(s, xx) if s_r < A: ps_r += s[s_r] -...
from bisect import bisect_left from itertools import product inf = float('inf') a, b, q = list(map(int, input().split())) s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] x = [int(eval(input())) for _ in range(q)] for xx in x: ret ...
88
26
2,005
632
from bisect import bisect_left A, B, Q = list(map(int, input().split())) s = [int(eval(input())) for _ in range(A)] t = [int(eval(input())) for _ in range(B)] x = [int(eval(input())) for _ in range(Q)] for xx in x: # 神先 ps_r = 0 s_r = bisect_left(s, xx) if s_r < A: ps_r += s[s_r] - xx t...
from bisect import bisect_left from itertools import product inf = float("inf") a, b, q = list(map(int, input().split())) s = [-inf] + [int(eval(input())) for _ in range(a)] + [inf] t = [-inf] + [int(eval(input())) for _ in range(b)] + [inf] x = [int(eval(input())) for _ in range(q)] for xx in x: ret = inf sr ...
false
70.454545
[ "+from itertools import product", "-A, B, Q = list(map(int, input().split()))", "-s = [int(eval(input())) for _ in range(A)]", "-t = [int(eval(input())) for _ in range(B)]", "-x = [int(eval(input())) for _ in range(Q)]", "+inf = float(\"inf\")", "+a, b, q = list(map(int, input().split()))", "+s = [-in...
false
0.043776
0.03673
1.191831
[ "s769313714", "s537650155" ]
u596276291
p03424
python
s994708760
s688328713
284
26
4,420
3,960
Accepted
Accepted
90.85
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache INF = float("inf")...
#!/usr/bin/python3 from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cac...
27
31
599
750
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache INF = float("inf") impor...
#!/usr/bin/python3 from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import...
false
12.903226
[ "+#!/usr/bin/python3", "-", "-INF = float(\"inf\")", "+INF = float(\"inf\")", "+YES, Yes, yes, NO, No, no = \"YES\", \"Yes\", \"yes\", \"NO\", \"No\", \"no\"", "+dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]", "-def solve(N, S):", "- if \"Y\" in S:", "- return \"Four\"", "- else:", "- ...
false
0.084963
0.036817
2.307701
[ "s994708760", "s688328713" ]
u644907318
p03644
python
s708428348
s670946734
166
64
38,256
61,860
Accepted
Accepted
61.45
N = int(eval(input())) k = 0 while 2**k<=N: k += 1 print((2**(k-1)))
N = int(eval(input())) if N==1: print((1)) else: k = 1 while 2**k<=N: k += 1 print((2**(k-1)))
5
8
68
115
N = int(eval(input())) k = 0 while 2**k <= N: k += 1 print((2 ** (k - 1)))
N = int(eval(input())) if N == 1: print((1)) else: k = 1 while 2**k <= N: k += 1 print((2 ** (k - 1)))
false
37.5
[ "-k = 0", "-while 2**k <= N:", "- k += 1", "-print((2 ** (k - 1)))", "+if N == 1:", "+ print((1))", "+else:", "+ k = 1", "+ while 2**k <= N:", "+ k += 1", "+ print((2 ** (k - 1)))" ]
false
0.037154
0.036193
1.026551
[ "s708428348", "s670946734" ]
u732870425
p02755
python
s854652925
s749597156
19
17
2,940
3,060
Accepted
Accepted
10.53
A, B = list(map(int, input().split())) ans = -1 for i in range(10000): if i * 8 // 100 == A: if i * 10 // 100 == B: ans = i break print(ans)
A, B = list(map(int, input().split())) x = max((A*100+7)//8, B*100//10) y = min((A+1)*100/8, (B+1)*100/10) if x < y: ans = x else: ans = -1 print(ans)
10
11
181
165
A, B = list(map(int, input().split())) ans = -1 for i in range(10000): if i * 8 // 100 == A: if i * 10 // 100 == B: ans = i break print(ans)
A, B = list(map(int, input().split())) x = max((A * 100 + 7) // 8, B * 100 // 10) y = min((A + 1) * 100 / 8, (B + 1) * 100 / 10) if x < y: ans = x else: ans = -1 print(ans)
false
9.090909
[ "-ans = -1", "-for i in range(10000):", "- if i * 8 // 100 == A:", "- if i * 10 // 100 == B:", "- ans = i", "- break", "+x = max((A * 100 + 7) // 8, B * 100 // 10)", "+y = min((A + 1) * 100 / 8, (B + 1) * 100 / 10)", "+if x < y:", "+ ans = x", "+else:", "+ ...
false
0.175488
0.168679
1.040368
[ "s854652925", "s749597156" ]
u119148115
p03284
python
s780366091
s000888355
198
72
61,812
61,184
Accepted
Accepted
63.64
import sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = LI() if N % K == 0: print((0)) else: print((1))
import sys N,K = list(map(int,sys.stdin.readline().rstrip().split())) print((0 if N % K == 0 else 1))
10
5
161
99
import sys def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり N, K = LI() if N % K == 0: print((0)) else: print((1))
import sys N, K = list(map(int, sys.stdin.readline().rstrip().split())) print((0 if N % K == 0 else 1))
false
50
[ "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-N, K = LI()", "-if N % K == 0:", "- print((0))", "-else:", "- print((1))", "+N, K = list(map(int, sys.stdin.readline().rstrip().split()))", "+print((0 if N % K == 0 else 1))" ]
false
0.03855
0.074208
0.519485
[ "s780366091", "s000888355" ]
u828455902
p02400
python
s493094448
s089291917
20
10
4,220
4,220
Accepted
Accepted
50
r=eval(input());p=3.1415926535897932;print("%.9f"%(p*r*r),r*2*p)
r=eval(input());p=3.141592653589793;print("%.9f"%(p*r*r),r*2*p)
1
1
57
56
r = eval(input()) p = 3.1415926535897932 print("%.9f" % (p * r * r), r * 2 * p)
r = eval(input()) p = 3.141592653589793 print("%.9f" % (p * r * r), r * 2 * p)
false
0
[ "-p = 3.1415926535897932", "+p = 3.141592653589793" ]
false
0.04551
0.042228
1.077711
[ "s493094448", "s089291917" ]
u852690916
p02821
python
s621735643
s772189540
1,699
1,063
56,836
56,600
Accepted
Accepted
37.43
import bisect N,M=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() #和がx以上になる組み合わせの総数を求める関数 def pattern_num_ge_x(x): p=0 for a in A: p+=(N-bisect.bisect_left(A, x-a)) return(p) #pattern_num_ge_x(x)がM未満になる最小のxを探す(=r) #lはM以上になる最大のx l=-1 r=10**10+1 while r-l>1: ...
import bisect N,M=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() #和がx以上になる組み合わせの総数を求める関数 def pattern_num_ge_x(x): p=0 for a in A: p+=(N-bisect.bisect_left(A, x-a)) return(p) #pattern_num_ge_x(x)がM未満になる最小のxを探す(=r) #lはM以上になる最大のx l=-1 r=10**5*2+1 while r-l>1:...
37
37
642
643
import bisect N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() # 和がx以上になる組み合わせの総数を求める関数 def pattern_num_ge_x(x): p = 0 for a in A: p += N - bisect.bisect_left(A, x - a) return p # pattern_num_ge_x(x)がM未満になる最小のxを探す(=r) # lはM以上になる最大のx l = -1 r = 10**10 + 1 while r...
import bisect N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() # 和がx以上になる組み合わせの総数を求める関数 def pattern_num_ge_x(x): p = 0 for a in A: p += N - bisect.bisect_left(A, x - a) return p # pattern_num_ge_x(x)がM未満になる最小のxを探す(=r) # lはM以上になる最大のx l = -1 r = 10**5 * 2 + 1 whil...
false
0
[ "-r = 10**10 + 1", "+r = 10**5 * 2 + 1" ]
false
0.12928
0.058552
2.207952
[ "s621735643", "s772189540" ]
u761529120
p03162
python
s735617841
s948031612
629
331
75,608
103,736
Accepted
Accepted
47.38
def main(): N = int(eval(input())) work = [] for _ in range(N): a, b, c = list(map(int, input().split())) work.append((a,b,c)) dp = [[0] * 3 for _ in range(N)] for i in range(N): for j in range(3): if i == 0: dp[i][j] = work[i][j] ...
def main(): N = int(eval(input())) acts = [] for _ in range(N): a, b, c = list(map(int, input().split())) acts.append([a,b,c]) dp = [[0] * 3 for _ in range(N + 5)] dp[0][0] = acts[0][0] dp[0][1] = acts[0][1] dp[0][2] = acts[0][2] for i in range(1,N): ...
25
27
690
673
def main(): N = int(eval(input())) work = [] for _ in range(N): a, b, c = list(map(int, input().split())) work.append((a, b, c)) dp = [[0] * 3 for _ in range(N)] for i in range(N): for j in range(3): if i == 0: dp[i][j] = work[i][j] ...
def main(): N = int(eval(input())) acts = [] for _ in range(N): a, b, c = list(map(int, input().split())) acts.append([a, b, c]) dp = [[0] * 3 for _ in range(N + 5)] dp[0][0] = acts[0][0] dp[0][1] = acts[0][1] dp[0][2] = acts[0][2] for i in range(1, N): for j in r...
false
7.407407
[ "- work = []", "+ acts = []", "- work.append((a, b, c))", "- dp = [[0] * 3 for _ in range(N)]", "- for i in range(N):", "+ acts.append([a, b, c])", "+ dp = [[0] * 3 for _ in range(N + 5)]", "+ dp[0][0] = acts[0][0]", "+ dp[0][1] = acts[0][1]", "+ dp[0][2] = ac...
false
0.092832
0.041669
2.227851
[ "s735617841", "s948031612" ]
u057109575
p03111
python
s446021933
s591951122
237
107
43,480
74,188
Accepted
Accepted
54.85
N, A, B, C, *X = list(map(int, open(0).read().split())) def dfs(i, a, b, c): if i == N: if a * b * c == 0: return 10 ** 9 + 7 return abs(A - a) + abs(B - b) + abs(C - c) v0 = dfs(i + 1, a, b, c) v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10 v2 = dfs(i + 1, a, ...
N, A, B, C = list(map(int, input().split())) X = [int(eval(input())) for _ in range(N)] def dfs(idx, a, b, c, cnt): if idx == N: if min(a, b, c) > 0: return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30 else: return 10 ** 9 res = 10 ** 9 res = min(r...
17
21
462
573
N, A, B, C, *X = list(map(int, open(0).read().split())) def dfs(i, a, b, c): if i == N: if a * b * c == 0: return 10**9 + 7 return abs(A - a) + abs(B - b) + abs(C - c) v0 = dfs(i + 1, a, b, c) v1 = dfs(i + 1, a + X[i], b, c) + int(a > 0) * 10 v2 = dfs(i + 1, a, b + X[i], c)...
N, A, B, C = list(map(int, input().split())) X = [int(eval(input())) for _ in range(N)] def dfs(idx, a, b, c, cnt): if idx == N: if min(a, b, c) > 0: return abs(a - A) + abs(b - B) + abs(c - C) + cnt - 30 else: return 10**9 res = 10**9 res = min(res, dfs(idx + 1, a,...
false
19.047619
[ "-N, A, B, C, *X = list(map(int, open(0).read().split()))", "+N, A, B, C = list(map(int, input().split()))", "+X = [int(eval(input())) for _ in range(N)]", "-def dfs(i, a, b, c):", "- if i == N:", "- if a * b * c == 0:", "- return 10**9 + 7", "- return abs(A - a) + abs(B - ...
false
0.237702
0.270862
0.877575
[ "s446021933", "s591951122" ]
u729133443
p02782
python
s314732135
s285275763
717
344
161,268
82,164
Accepted
Accepted
52.02
def main(): M=10**9+7 a,b,c,d=list(map(int,input().split())) n=c+d+2 fac=[0]*(n+1) fac[0]=lt=1 for i in range(1,n+1):fac[i]=lt=lt*i%M inv=[0]*(n+1) inv[n]=lt=pow(fac[n],M-2,M) for i in range(n,0,-1):inv[i-1]=lt=lt*i%M comb=lambda n,k:fac[n]*inv[n-k]*inv[k] f=lambda r,c:fac[r+c+2]*inv[c+...
def main(): M=10**9+7 a,b,c,d=list(map(int,input().split())) n=c+d+2 fac=[0]*(n+1) fac[0]=lt=1 for i in range(1,n+1):fac[i]=lt=lt*i%M inv=lambda n:pow(fac[n],M-2,M) f=lambda r,c:fac[r+c+2]*inv(c+1)*inv(r+1)-c-r-2 print(((f(c,d)-f(c,b-1)-f(a-1,d)+f(a-1,b-1))%M)) main()
14
11
389
288
def main(): M = 10**9 + 7 a, b, c, d = list(map(int, input().split())) n = c + d + 2 fac = [0] * (n + 1) fac[0] = lt = 1 for i in range(1, n + 1): fac[i] = lt = lt * i % M inv = [0] * (n + 1) inv[n] = lt = pow(fac[n], M - 2, M) for i in range(n, 0, -1): inv[i - 1] = l...
def main(): M = 10**9 + 7 a, b, c, d = list(map(int, input().split())) n = c + d + 2 fac = [0] * (n + 1) fac[0] = lt = 1 for i in range(1, n + 1): fac[i] = lt = lt * i % M inv = lambda n: pow(fac[n], M - 2, M) f = lambda r, c: fac[r + c + 2] * inv(c + 1) * inv(r + 1) - c - r - 2 ...
false
21.428571
[ "- inv = [0] * (n + 1)", "- inv[n] = lt = pow(fac[n], M - 2, M)", "- for i in range(n, 0, -1):", "- inv[i - 1] = lt = lt * i % M", "- comb = lambda n, k: fac[n] * inv[n - k] * inv[k]", "- f = lambda r, c: fac[r + c + 2] * inv[c + 1] * inv[r + 1] - c - r - 2", "+ inv = lambda n: ...
false
0.048781
0.039635
1.230765
[ "s314732135", "s285275763" ]
u633068244
p00009
python
s577234371
s308063482
330
280
36,984
37,044
Accepted
Accepted
15.15
n = [] while True: try:n.append(int(input())) except:break R = max(n)+1 p = [1]*R p[0] = p[1] = 0 p[4::2] = [0 for i in range(4,R,2)] for i in range(3,int(R**0.5)+1,2): if p[i]: p[2*i::i] = [0 for j in range(2*i,R,i)] for i in n: print(sum(p[:i+1]))
R = 1000000 p = [1]*R p[0] = p[1] = 0 p[4::2] = [0 for i in range(4,R,2)] for i in range(3,int(R**0.5)+1,2): if p[i]: p[2*i::i] = [0]*len(p[2*i::i]) while True: try:print(sum(p[:int(input())+1])) except:break
13
10
289
240
n = [] while True: try: n.append(int(input())) except: break R = max(n) + 1 p = [1] * R p[0] = p[1] = 0 p[4::2] = [0 for i in range(4, R, 2)] for i in range(3, int(R**0.5) + 1, 2): if p[i]: p[2 * i :: i] = [0 for j in range(2 * i, R, i)] for i in n: print(sum(p[: i + 1]))
R = 1000000 p = [1] * R p[0] = p[1] = 0 p[4::2] = [0 for i in range(4, R, 2)] for i in range(3, int(R**0.5) + 1, 2): if p[i]: p[2 * i :: i] = [0] * len(p[2 * i :: i]) while True: try: print(sum(p[: int(input()) + 1])) except: break
false
23.076923
[ "-n = []", "-while True:", "- try:", "- n.append(int(input()))", "- except:", "- break", "-R = max(n) + 1", "+R = 1000000", "- p[2 * i :: i] = [0 for j in range(2 * i, R, i)]", "-for i in n:", "- print(sum(p[: i + 1]))", "+ p[2 * i :: i] = [0] * len(p[2 * i...
false
0.036133
0.166112
0.217522
[ "s577234371", "s308063482" ]
u434846982
p02678
python
s448951489
s857078212
616
538
59,956
61,176
Accepted
Accepted
12.66
(n,m),*e=[[*list(map(int, t.split()))] for t in open(0)] t=[[]for _ in range(n+1)] for a,b in e:t[a]+=[b];t[b]+=[a] q=[1] a=[0]*-~n while q:q=[a[j]==0and(a.__setitem__(j,i)or j)for i in q for j in t[i]] print(('Yes',*a[2:]))
(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)] q = [1] ans = [0] * -~n node = [[] for _ in range(-~n)] temp = set() for i, j in e: node[i].append(j) node[j].append(i) while q: for x in q: for y in node[x]: if ans[y] == 0: ans[y] = x ...
7
23
223
444
(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)] t = [[] for _ in range(n + 1)] for a, b in e: t[a] += [b] t[b] += [a] q = [1] a = [0] * -~n while q: q = [a[j] == 0 and (a.__setitem__(j, i) or j) for i in q for j in t[i]] print(("Yes", *a[2:]))
(n, m), *e = [[*list(map(int, t.split()))] for t in open(0)] q = [1] ans = [0] * -~n node = [[] for _ in range(-~n)] temp = set() for i, j in e: node[i].append(j) node[j].append(i) while q: for x in q: for y in node[x]: if ans[y] == 0: ans[y] = x temp.add(...
false
69.565217
[ "-t = [[] for _ in range(n + 1)]", "-for a, b in e:", "- t[a] += [b]", "- t[b] += [a]", "-a = [0] * -~n", "+ans = [0] * -~n", "+node = [[] for _ in range(-~n)]", "+temp = set()", "+for i, j in e:", "+ node[i].append(j)", "+ node[j].append(i)", "- q = [a[j] == 0 and (a.__setitem_...
false
0.039478
0.038978
1.012831
[ "s448951489", "s857078212" ]
u411203878
p03776
python
s751248872
s392632266
172
66
38,768
64,212
Accepted
Accepted
61.63
import math def combination(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) import collections n,a,b = list(map(int,input().split())) t = list(map(int,input().split())) c = collections.Counter(t) c = sorted(list(c.items()), key=lambda x:-x[0...
import math def combination(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) N,A,B = list(map(int,input().split())) V = list(map(int,input().split())) v_count = {} for v in V: if v not in v_count: v_count[v] = 1 else: v_count[v] += 1 v_cou...
38
39
850
863
import math def combination(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) import collections n, a, b = list(map(int, input().split())) t = list(map(int, input().split())) c = collections.Counter(t) c = sorted(list(c.items()), key=lambda x: -x[0]) memo = 0 for k, i in enumerate(c...
import math def combination(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n - k) N, A, B = list(map(int, input().split())) V = list(map(int, input().split())) v_count = {} for v in V: if v not in v_count: v_count[v] = 1 else: v_count[v] += 1 v_count = sorted(list...
false
2.564103
[ "-import collections", "-", "-n, a, b = list(map(int, input().split()))", "-t = list(map(int, input().split()))", "-c = collections.Counter(t)", "-c = sorted(list(c.items()), key=lambda x: -x[0])", "-memo = 0", "-for k, i in enumerate(c):", "- # print(k,i[0],i[1])", "- memo += i[1]", "- ...
false
0.037648
0.033447
1.125597
[ "s751248872", "s392632266" ]
u411203878
p03986
python
s313005388
s222331193
205
78
61,552
82,664
Accepted
Accepted
61.95
s=eval(input()) s=list(s) ans = ['G'] for i in s: if i == 'S': ans.append(i) else: if ans[-1] == 'S': ans.pop(-1) else: ans.append(i) print((len(ans)-1))
X=list(eval(input())) counter_s = 0 counter_t = 0 for i in range(len(X)): if counter_s == 0 and X[i] == 'T': counter_t += 1 elif 0 < counter_s and X[i] == 'T': counter_s -= 1 elif X[i] == 'S': counter_s += 1 print((counter_s+counter_t))
15
14
218
281
s = eval(input()) s = list(s) ans = ["G"] for i in s: if i == "S": ans.append(i) else: if ans[-1] == "S": ans.pop(-1) else: ans.append(i) print((len(ans) - 1))
X = list(eval(input())) counter_s = 0 counter_t = 0 for i in range(len(X)): if counter_s == 0 and X[i] == "T": counter_t += 1 elif 0 < counter_s and X[i] == "T": counter_s -= 1 elif X[i] == "S": counter_s += 1 print((counter_s + counter_t))
false
6.666667
[ "-s = eval(input())", "-s = list(s)", "-ans = [\"G\"]", "-for i in s:", "- if i == \"S\":", "- ans.append(i)", "- else:", "- if ans[-1] == \"S\":", "- ans.pop(-1)", "- else:", "- ans.append(i)", "-print((len(ans) - 1))", "+X = list(eval(input(...
false
0.036359
0.037941
0.958291
[ "s313005388", "s222331193" ]
u871980676
p02715
python
s845992546
s308285390
1,720
333
27,784
75,356
Accepted
Accepted
80.64
import numpy as np N,K = list(map(int,input().split())) res = np.zeros(K+1, dtype=np.int64) ans = 0 MOD = 10**9+7 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//...
N,K = list(map(int,input().split())) res = [0]*(K+1) ans = 0 MOD = 10**9+7 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors for k in rang...
23
22
577
489
import numpy as np N, K = list(map(int, input().split())) res = np.zeros(K + 1, dtype=np.int64) ans = 0 MOD = 10**9 + 7 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n /...
N, K = list(map(int, input().split())) res = [0] * (K + 1) ans = 0 MOD = 10**9 + 7 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors for k in ra...
false
4.347826
[ "-import numpy as np", "-", "-res = np.zeros(K + 1, dtype=np.int64)", "+res = [0] * (K + 1)", "- divisors.sort()", "- return np.array(divisors, dtype=np.int64)", "+ return divisors", "- ans += k * (tmp - res[k])", "- # print(res[k], tmp, ans)", "- res[y] += tmp - res[k]", "+ ...
false
1.277728
0.882521
1.447817
[ "s845992546", "s308285390" ]
u857759499
p03420
python
s971798058
s351073149
74
60
12,760
12,592
Accepted
Accepted
18.92
n,k = list(map(int,input().split())) print((sum([(i-k)*(n//i)+max(0,n%i-max(0,k-1)) for i in range(k+1,n+1)])))
n,k = list(map(int,input().split())) print((n**2 if not k else sum([(i-k)*(n//i)+max(0,n%i-k+1) for i in range(k+1,n+1)])))
2
2
104
116
n, k = list(map(int, input().split())) print( ( sum( [ (i - k) * (n // i) + max(0, n % i - max(0, k - 1)) for i in range(k + 1, n + 1) ] ) ) )
n, k = list(map(int, input().split())) print( ( n**2 if not k else sum( [(i - k) * (n // i) + max(0, n % i - k + 1) for i in range(k + 1, n + 1)] ) ) )
false
0
[ "- sum(", "- [", "- (i - k) * (n // i) + max(0, n % i - max(0, k - 1))", "- for i in range(k + 1, n + 1)", "- ]", "+ n**2", "+ if not k", "+ else sum(", "+ [(i - k) * (n // i) + max(0, n % i - k + 1) for i in ...
false
0.049684
0.049706
0.999551
[ "s971798058", "s351073149" ]
u896741788
p03087
python
s462522508
s844708148
862
535
7,856
18,936
Accepted
Accepted
37.94
n,q=list(map(int,input().split())) l=[0 for i in range(n)] for i,v in enumerate(list(input().replace("AC","X!"))): l[i]=l[i-1]+(v=="!") for c in range(q): h,m=list(map(int,input().split())) print((l[m-1]-l[h-1]))
n,q=list(map(int,input().split())) t=eval(input()) a=[0]*n from collections import defaultdict tail=defaultdict(int) for i in range(n-1): if t[i]=="A"and t[i+1]=="C": a[i+1]+=1 tail[i]+=1 from itertools import accumulate a=list(accumulate(a)) for _ in range(q): l,r=list(map(int,inp...
7
18
216
407
n, q = list(map(int, input().split())) l = [0 for i in range(n)] for i, v in enumerate(list(input().replace("AC", "X!"))): l[i] = l[i - 1] + (v == "!") for c in range(q): h, m = list(map(int, input().split())) print((l[m - 1] - l[h - 1]))
n, q = list(map(int, input().split())) t = eval(input()) a = [0] * n from collections import defaultdict tail = defaultdict(int) for i in range(n - 1): if t[i] == "A" and t[i + 1] == "C": a[i + 1] += 1 tail[i] += 1 from itertools import accumulate a = list(accumulate(a)) for _ in range(q): l, ...
false
61.111111
[ "-l = [0 for i in range(n)]", "-for i, v in enumerate(list(input().replace(\"AC\", \"X!\"))):", "- l[i] = l[i - 1] + (v == \"!\")", "-for c in range(q):", "- h, m = list(map(int, input().split()))", "- print((l[m - 1] - l[h - 1]))", "+t = eval(input())", "+a = [0] * n", "+from collections i...
false
0.040786
0.036364
1.121616
[ "s462522508", "s844708148" ]
u822961851
p03805
python
s721719592
s880000301
29
25
3,064
3,064
Accepted
Accepted
13.79
# サンプルコード計算量お試し import itertools 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 cnt = 0 for each in itertools.permutations(list(range(N))): if e...
import itertools def resolve(): n, m = list(map(int, input().split())) S = [[0] * n for i in range(n)] for i in range(m): a, b = list(map(int, input().split())) S[a - 1][b - 1] = 1 S[b - 1][a - 1] = 1 ans = 0 for p in itertools.permutations(list(range(n))): ...
23
24
454
508
# サンプルコード計算量お試し import itertools 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 cnt = 0 for each in itertools.permutations(list(range(N))): if each[0] != ...
import itertools def resolve(): n, m = list(map(int, input().split())) S = [[0] * n for i in range(n)] for i in range(m): a, b = list(map(int, input().split())) S[a - 1][b - 1] = 1 S[b - 1][a - 1] = 1 ans = 0 for p in itertools.permutations(list(range(n))): if p[0] ...
false
4.166667
[ "-# サンプルコード計算量お試し", "-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", "-cnt = 0", "-for each in itertools.permutations...
false
0.064357
0.045266
1.421755
[ "s721719592", "s880000301" ]
u656391577
p02761
python
s564997169
s199852668
20
18
3,064
3,064
Accepted
Accepted
10
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) Set = [] for i in range(M): Set.append(list(map(int, input().split()))) for i in range(10**N): num = str(i) if len(num) == N and all(num[s-1]==str(c) for s,c in Set): ...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) Set = [list(map(int,input().split())) for i in range(M)] for i in range(10**N): num = str(i) if len(num) == N and all(num[s-1]==str(c) for s,c in Set): print(i) bre...
21
19
419
390
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) Set = [] for i in range(M): Set.append(list(map(int, input().split()))) for i in range(10**N): num = str(i) if len(num) == N and all(num[s - 1] == str(c) for s, c in Set): prin...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) Set = [list(map(int, input().split())) for i in range(M)] for i in range(10**N): num = str(i) if len(num) == N and all(num[s - 1] == str(c) for s, c in Set): print(i) break ...
false
9.52381
[ "- Set = []", "- for i in range(M):", "- Set.append(list(map(int, input().split())))", "+ Set = [list(map(int, input().split())) for i in range(M)]" ]
false
0.045605
0.045439
1.003663
[ "s564997169", "s199852668" ]
u514401521
p02708
python
s874943027
s276379772
152
116
9,200
9,184
Accepted
Accepted
23.68
N, K = list(map(int, input().split())) ans = 0 mod = 10**9+7 for i in range(K, N+2): _min = (i+1)*i//2 _max = ((N+1) + (N+1-i+1)) * i // 2 ans += (_max - _min + 1) % mod ans %= mod print(ans)
N, K = list(map(int, input().split())) M = 10**9 + 7 ans = 0 for i in range(K, N+2): _min = (i-1)*i//2 _max = (N + N-i+1) * i //2 ans += (_max - _min + 1) print((ans % M))
9
8
209
186
N, K = list(map(int, input().split())) ans = 0 mod = 10**9 + 7 for i in range(K, N + 2): _min = (i + 1) * i // 2 _max = ((N + 1) + (N + 1 - i + 1)) * i // 2 ans += (_max - _min + 1) % mod ans %= mod print(ans)
N, K = list(map(int, input().split())) M = 10**9 + 7 ans = 0 for i in range(K, N + 2): _min = (i - 1) * i // 2 _max = (N + N - i + 1) * i // 2 ans += _max - _min + 1 print((ans % M))
false
11.111111
[ "+M = 10**9 + 7", "-mod = 10**9 + 7", "- _min = (i + 1) * i // 2", "- _max = ((N + 1) + (N + 1 - i + 1)) * i // 2", "- ans += (_max - _min + 1) % mod", "- ans %= mod", "-print(ans)", "+ _min = (i - 1) * i // 2", "+ _max = (N + N - i + 1) * i // 2", "+ ans += _max - _min + 1", ...
false
0.322362
0.049543
6.506724
[ "s874943027", "s276379772" ]
u141610915
p03912
python
s475852678
s103731998
308
248
73,964
53,212
Accepted
Accepted
19.48
from collections import defaultdict as dd N, M = list(map(int, input().split())) c = list(map(int, input().split())) c.sort() m = dd(int) d = dd(int) for n in c: d[n] += 1 m[n % M] += 1 res = 0 for i in range(M): temp = min(m[i], m[(M - i) % M]) if i == (M - i) % M: temp = m[i] // 2 m[i] -= ...
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() m = [0] * M d = [0] * (max(a) + 1) for x in a: d[x] += 1 m[x % M] += 1 res = 0 for i in range(M): t = min(m[i], m[(M - i) % M]) if i == (M - i) % M: t = m[i] // 2 m[i]...
27
30
567
553
from collections import defaultdict as dd N, M = list(map(int, input().split())) c = list(map(int, input().split())) c.sort() m = dd(int) d = dd(int) for n in c: d[n] += 1 m[n % M] += 1 res = 0 for i in range(M): temp = min(m[i], m[(M - i) % M]) if i == (M - i) % M: temp = m[i] // 2 m[i] -=...
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() m = [0] * M d = [0] * (max(a) + 1) for x in a: d[x] += 1 m[x % M] += 1 res = 0 for i in range(M): t = min(m[i], m[(M - i) % M]) if i == (M - i) % M: t = m[i] // 2 m[i] -...
false
10
[ "-from collections import defaultdict as dd", "+import sys", "+input = sys.stdin.readline", "-c = list(map(int, input().split()))", "-c.sort()", "-m = dd(int)", "-d = dd(int)", "-for n in c:", "- d[n] += 1", "- m[n % M] += 1", "+a = list(map(int, input().split()))", "+a.sort()", "+m = ...
false
0.044489
0.151311
0.294026
[ "s475852678", "s103731998" ]
u548464743
p02844
python
s616478329
s013950905
562
166
9,324
10,264
Accepted
Accepted
70.46
n = int(eval(input())) num = eval(input()) password_list = [] initial_list = [] initial_list2 = [] initial_list3 = [] for i in range(len(num)-2): initial_list2 = [] if num[i] in initial_list: continue elif len(initial_list) == 10: break else: initial_list.appen...
n = int(eval(input())) num_list = list(map(int,eval(input()))) cnt = 0 for i in range(10): if i not in num_list: continue else: first_pwd = num_list.index(i) new_num_list = num_list[first_pwd + 1:] for j in range(10): if j not in new_num_list: ...
36
24
1,114
655
n = int(eval(input())) num = eval(input()) password_list = [] initial_list = [] initial_list2 = [] initial_list3 = [] for i in range(len(num) - 2): initial_list2 = [] if num[i] in initial_list: continue elif len(initial_list) == 10: break else: initial_list.append(num[i]) ...
n = int(eval(input())) num_list = list(map(int, eval(input()))) cnt = 0 for i in range(10): if i not in num_list: continue else: first_pwd = num_list.index(i) new_num_list = num_list[first_pwd + 1 :] for j in range(10): if j not in new_num_list: contin...
false
33.333333
[ "-num = eval(input())", "-password_list = []", "-initial_list = []", "-initial_list2 = []", "-initial_list3 = []", "-for i in range(len(num) - 2):", "- initial_list2 = []", "- if num[i] in initial_list:", "+num_list = list(map(int, eval(input())))", "+cnt = 0", "+for i in range(10):", "+...
false
0.082636
0.046259
1.786379
[ "s616478329", "s013950905" ]
u950708010
p03472
python
s554355407
s694470728
1,932
221
12,784
12,892
Accepted
Accepted
88.56
from math import ceil n,h = (int(i) for i in input().split()) a = [] b = [0] for i in range(n): tmp1,tmp2= (int(i) for i in input().split()) a.append(tmp1) b.append(tmp2) a2 = sorted(a,reverse = True) b2 = sorted(b,reverse = True) count = 0 while h > 0: if a2[0] > b2[0]: tmp3 = ceil(h/a2[0]) ...
import sys input = sys.stdin.readline from collections import deque import math def solve(): n,h = (int(i) for i in input().split()) a = [] b = [] for i in range(n): ta,tb = (int(i) for i in input().split()) a.append(ta) b.append(tb) amax = max(a) b = deque(sorted(b,reverse=True)) ...
22
34
427
680
from math import ceil n, h = (int(i) for i in input().split()) a = [] b = [0] for i in range(n): tmp1, tmp2 = (int(i) for i in input().split()) a.append(tmp1) b.append(tmp2) a2 = sorted(a, reverse=True) b2 = sorted(b, reverse=True) count = 0 while h > 0: if a2[0] > b2[0]: tmp3 = ceil(h / a2[0])...
import sys input = sys.stdin.readline from collections import deque import math def solve(): n, h = (int(i) for i in input().split()) a = [] b = [] for i in range(n): ta, tb = (int(i) for i in input().split()) a.append(ta) b.append(tb) amax = max(a) b = deque(sorted(b,...
false
35.294118
[ "-from math import ceil", "+import sys", "-n, h = (int(i) for i in input().split())", "-a = []", "-b = [0]", "-for i in range(n):", "- tmp1, tmp2 = (int(i) for i in input().split())", "- a.append(tmp1)", "- b.append(tmp2)", "-a2 = sorted(a, reverse=True)", "-b2 = sorted(b, reverse=True)...
false
0.085362
0.165826
0.514766
[ "s554355407", "s694470728" ]
u645250356
p03633
python
s646053736
s504526040
39
36
5,264
5,068
Accepted
Accepted
7.69
from collections import Counter,defaultdict import sys,heapq,bisect,math,itertools,string,queue,fractions mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) def inpl_str():...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(m...
16
16
523
494
from collections import Counter, defaultdict import sys, heapq, bisect, math, itertools, string, queue, fractions mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.stdin.readline()) for i in ra...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): ...
false
0
[ "-from collections import Counter, defaultdict", "-import sys, heapq, bisect, math, itertools, string, queue, fractions", "+from collections import Counter, defaultdict, deque", "+from heapq import heappop, heappush, heapify", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools,...
false
0.103246
0.049484
2.086471
[ "s646053736", "s504526040" ]
u629614915
p02689
python
s498517427
s452770043
308
249
31,244
20,140
Accepted
Accepted
19.16
## import ## function definition ## main process if __name__ == '__main__': ## input N, M = list(map(int,input().split())) HEIGHT_LIST = list(map(int,input().split())) ROAD_LIST = [] for j in range(M): ROAD_LIST.append( tuple(map(int,input().split())) ...
## import ## function definition ## main process if __name__ == '__main__': N, M = list(map(int,input().split())) HEIGHT_LIST = list(map(int,input().split())) ans = [1] * N for j in range(M): a, b = list(map(int,input().split())) a -= 1 b -= 1 ...
38
27
840
573
## import ## function definition ## main process if __name__ == "__main__": ## input N, M = list(map(int, input().split())) HEIGHT_LIST = list(map(int, input().split())) ROAD_LIST = [] for j in range(M): ROAD_LIST.append(tuple(map(int, input().split()))) ## business logic ans = [1] *...
## import ## function definition ## main process if __name__ == "__main__": N, M = list(map(int, input().split())) HEIGHT_LIST = list(map(int, input().split())) ans = [1] * N for j in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 height_a = HEIGHT_LIST[a]...
false
28.947368
[ "- ## input", "- ROAD_LIST = []", "+ ans = [1] * N", "- ROAD_LIST.append(tuple(map(int, input().split())))", "- ## business logic", "- ans = [1] * N", "- for j in list(range(M)):", "- point_a = ROAD_LIST[j][0]", "- point_b = ROAD_LIST[j][1]", "- point_...
false
0.099976
0.114393
0.873968
[ "s498517427", "s452770043" ]
u167681750
p03006
python
s719133279
s900193938
159
34
3,060
3,064
Accepted
Accepted
78.62
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] count = 0 for i in range(n-1): for j in range(i+1, n): p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1] count = max(count, sum((x-p,y-q) in set(xy) for x, y in xy)) print((n - count))
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] s_xy = set(xy) count = 0 for i in range(n-1): for j in range(i+1, n): p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1] count = max(count, sum((x-p,y-q) in s_xy for x, y in s_xy)) print((n - count))
10
11
287
302
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] count = 0 for i in range(n - 1): for j in range(i + 1, n): p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1] count = max(count, sum((x - p, y - q) in set(xy) for x, y in xy)) print((n - count))
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] s_xy = set(xy) count = 0 for i in range(n - 1): for j in range(i + 1, n): p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1] count = max(count, sum((x - p, y - q) in s_xy for x, y in s_xy)) print((n - count))
false
9.090909
[ "+s_xy = set(xy)", "- count = max(count, sum((x - p, y - q) in set(xy) for x, y in xy))", "+ count = max(count, sum((x - p, y - q) in s_xy for x, y in s_xy))" ]
false
0.052747
0.053029
0.994683
[ "s719133279", "s900193938" ]
u418149936
p02614
python
s740756347
s271545016
72
49
9,008
9,132
Accepted
Accepted
31.94
h, w, k = list(map(int, input().split(' '))) ls = [0] * h result = 0 for i in range(h): ls[i] = eval(input()) for i in range(1<<h): for j in range(1<<w): cnt = 0 for s in range(h): for t in range(w): if ((i>>s) & 1) & ((j>>t) & 1): ...
H, W, K = list(map(int, input().split(' '))) ls = [] for i in range(H): ls.append(list(eval(input()))) rst = 0 for i in range(1 << H): for s in range(1 << W): cnt = 0 for j in range(H): if i>>j & 1: continue for t in range(W): ...
18
21
423
476
h, w, k = list(map(int, input().split(" "))) ls = [0] * h result = 0 for i in range(h): ls[i] = eval(input()) for i in range(1 << h): for j in range(1 << w): cnt = 0 for s in range(h): for t in range(w): if ((i >> s) & 1) & ((j >> t) & 1): if ls[s]...
H, W, K = list(map(int, input().split(" "))) ls = [] for i in range(H): ls.append(list(eval(input()))) rst = 0 for i in range(1 << H): for s in range(1 << W): cnt = 0 for j in range(H): if i >> j & 1: continue for t in range(W): if s >> t &...
false
14.285714
[ "-h, w, k = list(map(int, input().split(\" \")))", "-ls = [0] * h", "-result = 0", "-for i in range(h):", "- ls[i] = eval(input())", "-for i in range(1 << h):", "- for j in range(1 << w):", "+H, W, K = list(map(int, input().split(\" \")))", "+ls = []", "+for i in range(H):", "+ ls.appen...
false
0.040815
0.041206
0.990505
[ "s740756347", "s271545016" ]
u606045429
p03659
python
s533109221
s592196338
173
124
23,800
24,168
Accepted
Accepted
28.32
N = int(eval(input())) A = [int(i) for i in input().split()] su = sum(A) x = 0 mi = 1e15 for a in A[:-1]: x += a mi = min(mi, abs(su - 2 * x)) print(mi)
from itertools import accumulate N = int(eval(input())) A = [int(i) for i in input().split()] *B, su = list(accumulate(A)) print((min(abs(su - 2 * b) for b in B)))
10
7
164
164
N = int(eval(input())) A = [int(i) for i in input().split()] su = sum(A) x = 0 mi = 1e15 for a in A[:-1]: x += a mi = min(mi, abs(su - 2 * x)) print(mi)
from itertools import accumulate N = int(eval(input())) A = [int(i) for i in input().split()] *B, su = list(accumulate(A)) print((min(abs(su - 2 * b) for b in B)))
false
30
[ "+from itertools import accumulate", "+", "-su = sum(A)", "-x = 0", "-mi = 1e15", "-for a in A[:-1]:", "- x += a", "- mi = min(mi, abs(su - 2 * x))", "-print(mi)", "+*B, su = list(accumulate(A))", "+print((min(abs(su - 2 * b) for b in B)))" ]
false
0.037682
0.036078
1.044447
[ "s533109221", "s592196338" ]
u086503932
p02984
python
s932303915
s250252043
163
126
23,556
23,620
Accepted
Accepted
22.7
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate def main(): N = int(eval(input())) A = list(map(int, input().split())) sumA = sum(A)//2 B = A odd = list(accumulate([0] + B[...
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate def main(): N = int(eval(input())) A = list(map(int, input().split())) sumA = sum(A)//2 B = A odd = list(accumulate([0] + B[...
28
32
800
913
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate def main(): N = int(eval(input())) A = list(map(int, input().split())) sumA = sum(A) // 2 B = A odd = list(accumulate([0] + B[::2] + B[...
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate def main(): N = int(eval(input())) A = list(map(int, input().split())) sumA = sum(A) // 2 B = A odd = list(accumulate([0] + B[::2] + B[...
false
12.5
[ "- # print(B,sumA)", "- # print(odd)", "- # print(even)", "+ # ans = [None] * N", "+ # for i in range(N):", "+ # if i % 2 == 0:# evenから引く", "+ # # print(even[N//2+i//2],even[i//2])", "+ # ans[i] = 2*(sumA-(even[N//2+i//2]-even[i//2]))", "+ # else:",...
false
0.043873
0.044089
0.995098
[ "s932303915", "s250252043" ]
u150984829
p02234
python
s122369231
s785902134
130
110
5,728
5,716
Accepted
Accepted
15.38
def s(): n=int(eval(input()))+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for l in range(2,n): for i in range(1,n-l+1): j=i+l-1;m[i][j]=1e6 for k in range(i,j):m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]) print((m[1][n-1])) ...
def s(): n=int(eval(input()))+1 e=[input().split()for _ in[0]*~-n] p=[int(e[0][0])]+list(int(x[1])for x in e) m=[[0]*n for _ in[0]*n] for i in range(n): for r in range(n-i-1): c=r+i+1 for j in range(r+1,c): x=m[r][j]+m[j][c]+p[r]*p[j]*p[c] if 1>m[r][c]or m[r][c]>x:m[r][c]=x print((m[r]...
11
13
339
346
def s(): n = int(eval(input())) + 1 e = [input().split() for _ in [0] * ~-n] p = [int(e[0][0])] + list(int(x[1]) for x in e) m = [[0] * n for _ in [0] * n] for l in range(2, n): for i in range(1, n - l + 1): j = i + l - 1 m[i][j] = 1e6 for k in range(i, j)...
def s(): n = int(eval(input())) + 1 e = [input().split() for _ in [0] * ~-n] p = [int(e[0][0])] + list(int(x[1]) for x in e) m = [[0] * n for _ in [0] * n] for i in range(n): for r in range(n - i - 1): c = r + i + 1 for j in range(r + 1, c): x = m[r][j...
false
15.384615
[ "- for l in range(2, n):", "- for i in range(1, n - l + 1):", "- j = i + l - 1", "- m[i][j] = 1e6", "- for k in range(i, j):", "- m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])", "- print((m[1][n - 1]))", "+ for i ...
false
0.039865
0.037157
1.072887
[ "s122369231", "s785902134" ]
u192154323
p03575
python
s856479413
s780619409
25
23
3,316
3,316
Accepted
Accepted
8
from collections import deque n,m = list(map(int,input().split())) edge_ls = [0] * m for i in range(m): a,b = list(map(int,input().split())) edge_ls[i] = [a,b] class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.par...
from collections import deque num_ver, num_edge = list(map(int,input().split())) edges_ls = [0] * num_edge for i in range(num_edge): a,b = list(map(int,input().split())) a -= 1 b -= 1 edges_ls[i] = [a,b] num_bridge = 0 for ind_take_edge in range(num_edge): graph_ls = [[] for _ in range(n...
68
39
1,697
915
from collections import deque n, m = list(map(int, input().split())) edge_ls = [0] * m for i in range(m): a, b = list(map(int, input().split())) edge_ls[i] = [a, b] class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x...
from collections import deque num_ver, num_edge = list(map(int, input().split())) edges_ls = [0] * num_edge for i in range(num_edge): a, b = list(map(int, input().split())) a -= 1 b -= 1 edges_ls[i] = [a, b] num_bridge = 0 for ind_take_edge in range(num_edge): graph_ls = [[] for _ in range(num_ver)...
false
42.647059
[ "-n, m = list(map(int, input().split()))", "-edge_ls = [0] * m", "-for i in range(m):", "+num_ver, num_edge = list(map(int, input().split()))", "+edges_ls = [0] * num_edge", "+for i in range(num_edge):", "- edge_ls[i] = [a, b]", "-", "-", "-class UnionFind:", "- def __init__(self, n):", ...
false
0.09754
0.060583
1.610027
[ "s856479413", "s780619409" ]
u301624971
p03427
python
s887834936
s016443179
22
18
3,064
3,064
Accepted
Accepted
18.18
def myAnswer(N:int)->int: K = len(str(N)) #桁数 if(K == 1):return N c = N // 10**(K-1) #最上位の桁の数 if((c*10**(K-1) + int("9"*(K-1)))<= N): return c + 9 *(K - 1) else: return c + 9 *(K - 1) -1 def modelAnswer(): tmp=1 def main(): N = int(eval(input())) print((myAnswer(N)...
def myAnswer(N:int)->int: length = len(str(N)) if(length == 1): return N l = list(str(N)) tmp = 0 for n in l[1:]: tmp += int(n) total = length * 9 if(tmp == total - 9): return tmp + int(l[0]) else: total += -9 + int(l[0]) - 1 return total def modelAnswer(): ...
19
21
355
426
def myAnswer(N: int) -> int: K = len(str(N)) # 桁数 if K == 1: return N c = N // 10 ** (K - 1) # 最上位の桁の数 if (c * 10 ** (K - 1) + int("9" * (K - 1))) <= N: return c + 9 * (K - 1) else: return c + 9 * (K - 1) - 1 def modelAnswer(): tmp = 1 def main(): N = int(eval(i...
def myAnswer(N: int) -> int: length = len(str(N)) if length == 1: return N l = list(str(N)) tmp = 0 for n in l[1:]: tmp += int(n) total = length * 9 if tmp == total - 9: return tmp + int(l[0]) else: total += -9 + int(l[0]) - 1 return total def mo...
false
9.52381
[ "- K = len(str(N)) # 桁数", "- if K == 1:", "+ length = len(str(N))", "+ if length == 1:", "- c = N // 10 ** (K - 1) # 最上位の桁の数", "- if (c * 10 ** (K - 1) + int(\"9\" * (K - 1))) <= N:", "- return c + 9 * (K - 1)", "+ l = list(str(N))", "+ tmp = 0", "+ for n in l[1...
false
0.034591
0.034496
1.002752
[ "s887834936", "s016443179" ]
u721316601
p03045
python
s627281016
s240666204
611
518
7,088
27,368
Accepted
Accepted
15.22
def search(n): idx = n while A[n-1] != n: n = A[n-1] A[idx-1] = n return n N, M = list(map(int, input().split())) A = [i for i in range(1, N+1)] ans = 0 for i in range(M): X, Y, Z = list(map(int, input().split())) X_root, Y_root = search(X), search(Y) if X_root !=...
import sys input = sys.stdin.readline def search(x, y): while root[x] != x: x = root[x] while root[y] != y: y = root[y] return x, y def rebuild(x, y, r): while root[x] != r: x, root[x] = root[x], r while root[y] != r: y, root[y] = root[y], r N, M = list(map(int, input().spli...
21
32
392
661
def search(n): idx = n while A[n - 1] != n: n = A[n - 1] A[idx - 1] = n return n N, M = list(map(int, input().split())) A = [i for i in range(1, N + 1)] ans = 0 for i in range(M): X, Y, Z = list(map(int, input().split())) X_root, Y_root = search(X), search(Y) if X_root != Y_root: ...
import sys input = sys.stdin.readline def search(x, y): while root[x] != x: x = root[x] while root[y] != y: y = root[y] return x, y def rebuild(x, y, r): while root[x] != r: x, root[x] = root[x], r while root[y] != r: y, root[y] = root[y], r N, M = list(map(int...
false
34.375
[ "-def search(n):", "- idx = n", "- while A[n - 1] != n:", "- n = A[n - 1]", "- A[idx - 1] = n", "- return n", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "+def search(x, y):", "+ while root[x] != x:", "+ x = root[x]", "+ while root[y] != y...
false
0.060395
0.069135
0.873577
[ "s627281016", "s240666204" ]
u235376569
p02983
python
s015180833
s482073238
77
66
3,060
9,176
Accepted
Accepted
14.29
import sys L,R=[int(x) for x in input().strip().split()] tmp=10**9+1 ans=10**9+1 for i in range(L,R,1): for j in range(L+1,R+1,1): if i<j: ans=min((i*j)%2019,ans) if ans==0: print((0)) sys.exit() print(ans) # 332701087 1753412895
l,r=list(map(int,input().split())) import sys mod=2019 ans=float('inf') for i in range(l,r+1): for j in range(i+1,r+1): ans=min((i*j)%mod,ans) if ans==0: print((0)) sys.exit() print(ans)
18
12
285
212
import sys L, R = [int(x) for x in input().strip().split()] tmp = 10**9 + 1 ans = 10**9 + 1 for i in range(L, R, 1): for j in range(L + 1, R + 1, 1): if i < j: ans = min((i * j) % 2019, ans) if ans == 0: print((0)) sys.exit() print(ans) # 332701087 17...
l, r = list(map(int, input().split())) import sys mod = 2019 ans = float("inf") for i in range(l, r + 1): for j in range(i + 1, r + 1): ans = min((i * j) % mod, ans) if ans == 0: print((0)) sys.exit() print(ans)
false
33.333333
[ "+l, r = list(map(int, input().split()))", "-L, R = [int(x) for x in input().strip().split()]", "-tmp = 10**9 + 1", "-ans = 10**9 + 1", "-for i in range(L, R, 1):", "- for j in range(L + 1, R + 1, 1):", "- if i < j:", "- ans = min((i * j) % 2019, ans)", "- if ans == 0...
false
0.036905
0.038655
0.954724
[ "s015180833", "s482073238" ]
u989345508
p03494
python
s597947812
s491602673
169
19
38,768
2,940
Accepted
Accepted
88.76
n=int(eval(input())) a=list(map(int,input().split())) ans=0 def check_all(): global a,n for i in range(n): if a[i]%2!=0: return False return True while check_all(): ans+=1 for i in range(n): a[i]//=2 print(ans)
n=int(eval(input())) a=list(map(int,input().split())) ans=0 while all(i%2==0 for i in a): ans+=1 for j in range(n): a[j]//=2 print(ans)
14
9
266
155
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 def check_all(): global a, n for i in range(n): if a[i] % 2 != 0: return False return True while check_all(): ans += 1 for i in range(n): a[i] //= 2 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 while all(i % 2 == 0 for i in a): ans += 1 for j in range(n): a[j] //= 2 print(ans)
false
35.714286
[ "-", "-", "-def check_all():", "- global a, n", "- for i in range(n):", "- if a[i] % 2 != 0:", "- return False", "- return True", "-", "-", "-while check_all():", "+while all(i % 2 == 0 for i in a):", "- for i in range(n):", "- a[i] //= 2", "+ for ...
false
0.052485
0.034954
1.501564
[ "s597947812", "s491602673" ]
u912237403
p00028
python
s512049873
s703680107
20
10
4,216
4,212
Accepted
Accepted
50
d=[0 for i in range(101)] while True: try: n=eval(input()) d[n]+=1 except: break for e in [i for i,e in enumerate(d) if e==max(d)]: print(e)
d=[0]*101 while True: try: n=eval(input()) d[n]+=1 except: break tmp=max(d) for i in range(101): if d[i]==tmp: print(i)
11
12
181
161
d = [0 for i in range(101)] while True: try: n = eval(input()) d[n] += 1 except: break for e in [i for i, e in enumerate(d) if e == max(d)]: print(e)
d = [0] * 101 while True: try: n = eval(input()) d[n] += 1 except: break tmp = max(d) for i in range(101): if d[i] == tmp: print(i)
false
8.333333
[ "-d = [0 for i in range(101)]", "+d = [0] * 101", "-for e in [i for i, e in enumerate(d) if e == max(d)]:", "- print(e)", "+tmp = max(d)", "+for i in range(101):", "+ if d[i] == tmp:", "+ print(i)" ]
false
0.04446
0.00825
5.388823
[ "s512049873", "s703680107" ]
u761638117
p02887
python
s397459955
s312117389
50
43
3,956
3,956
Accepted
Accepted
14
n = int(eval(input())) colors = eval(input()) i = 0 leght = n result = list(colors[0]) for i in range(n-1): if colors[i] != colors[i+1]: result.append(colors[i+1]) print((len(result)))
n = int(eval(input())) str = eval(input()) slim = [str[0]] for i in range(n): if str[i] != slim[-1]: slim.append(str[i]) print((len(slim)))
12
8
193
141
n = int(eval(input())) colors = eval(input()) i = 0 leght = n result = list(colors[0]) for i in range(n - 1): if colors[i] != colors[i + 1]: result.append(colors[i + 1]) print((len(result)))
n = int(eval(input())) str = eval(input()) slim = [str[0]] for i in range(n): if str[i] != slim[-1]: slim.append(str[i]) print((len(slim)))
false
33.333333
[ "-colors = eval(input())", "-i = 0", "-leght = n", "-result = list(colors[0])", "-for i in range(n - 1):", "- if colors[i] != colors[i + 1]:", "- result.append(colors[i + 1])", "-print((len(result)))", "+str = eval(input())", "+slim = [str[0]]", "+for i in range(n):", "+ if str[i]...
false
0.074159
0.089432
0.829226
[ "s397459955", "s312117389" ]
u200887663
p02995
python
s155994964
s449458667
35
30
5,048
9,000
Accepted
Accepted
14.29
#n=int(input()) a,b,c,d=list(map(int,input().split())) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] import fractions lcm=(c*d)//fractions.gcd(c,d)#最小公倍数 brng=b-(b//c+b//d)+b//lcm arng=(a-1)-((a-1)//c+(a-1)//d)+(a-1)//lcm ans=brng-arng print(ans)
#n=int(input()) a,b,c,d=list(map(int,input().split())) #t=int(input()) #al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] import math lcm=(c//math.gcd(c,d))*d #最小公倍数 cnum=b//c-(a-1)//c dnum=b//d-(a-1)//d cdnum=b//lcm-(a-1)//lcm ans=b-a+1-(cnum+dnum)+cdnum print(ans...
11
15
293
316
# n=int(input()) a, b, c, d = list(map(int, input().split())) # l=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] import fractions lcm = (c * d) // fractions.gcd(c, d) # 最小公倍数 brng = b - (b // c + b // d) + b // lcm arng = (a - 1) - ((a - 1) // c + (a - 1) // d) + (a - 1) // lcm ...
# n=int(input()) a, b, c, d = list(map(int, input().split())) # t=int(input()) # al=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] import math lcm = (c // math.gcd(c, d)) * d # 最小公倍数 cnum = b // c - (a - 1) // c dnum = b // d - (a - 1) // d cdnum = b // lcm - (a - 1) // lcm ans ...
false
26.666667
[ "-# l=list(map(int,input().split()))", "+# t=int(input())", "+# al=list(map(int,input().split()))", "-import fractions", "+import math", "-lcm = (c * d) // fractions.gcd(c, d) # 最小公倍数", "-brng = b - (b // c + b // d) + b // lcm", "-arng = (a - 1) - ((a - 1) // c + (a - 1) // d) + (a - 1) // lcm", "...
false
0.050342
0.036767
1.369206
[ "s155994964", "s449458667" ]
u407160848
p02698
python
s766684891
s689934525
1,409
1,201
366,540
350,892
Accepted
Accepted
14.76
from bisect import bisect_left import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [ int(s) for s in input().split(" ")] def log(*args): print("DEBUG:", *args, file=sys.stderr) INF = 999999999999999999999999 n = int(input(...
from bisect import bisect_left import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [ int(s) for s in input().split(" ")] def log(*args): print("DEBUG:", *args, file=sys.stderr) INF = 999999999999999999...
63
64
1,197
1,227
from bisect import bisect_left import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [int(s) for s in input().split(" ")] def log(*args): print("DEBUG:", *args, file=sys.stderr) INF = 999999999999999999999999 n = int(input()) A = [-INF] ...
from bisect import bisect_left import sys sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() # スペース区切りの入力を読み込んで数値リストにして返します。 def get_nums_l(): return [int(s) for s in input().split(" ")] def log(*args): print("DEBUG:", *args, file=sys.stderr) INF = 99999999999999999999999...
false
1.5625
[ "-input = sys.stdin.readline", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "-log(n)", "-log(A)", "+# log(n)", "+# log(A)", "- log(line)", "+ # log(line)" ]
false
0.037833
0.041182
0.918685
[ "s766684891", "s689934525" ]
u685263709
p03038
python
s591978271
s861612914
967
576
103,832
33,784
Accepted
Accepted
40.43
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True) if N == 1: print((max(A[0], BC[0][1]))) quit() heapq.heapify(A) for b, c in BC: a = A[0] if a >= c:...
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True) if N == 1: print((max(A[0], BC[0][1]))) quit() heapq.heapify(A) for b, c in BC: a = A[0] if a >= c: ...
51
27
1,072
627
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) BC = sorted( [list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True, ) if N == 1: print((max(A[0], BC[0][1]))) quit() heapq.heapify(A) for b, c in BC: a = A[0] if a >= c: ...
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) BC = sorted( [list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True, ) if N == 1: print((max(A[0], BC[0][1]))) quit() heapq.heapify(A) for b, c in BC: a = A[0] if a >= c: ...
false
47.058824
[ "-\"\"\"", "-import bisect", "-N, M = map(int, input().split())", "-A = sorted(list(map(int, input().split())))", "-BC = [list(map(int, input().split())) for i in range(M)]", "-if N == 1:", "- print(max(A[0], BC[0][1]))", "- quit()", "-for b, c in BC:", "- a = A[0]", "- if a >= c:", ...
false
0.041061
0.040973
1.002142
[ "s591978271", "s861612914" ]
u936985471
p02936
python
s053934585
s746628106
856
782
65,932
67,328
Accepted
Accepted
8.64
import sys readline = sys.stdin.readline N,Q = list(map(int,readline().split())) G = [[] for i in range(N)] for i in range(N - 1): a,b = list(map(int,readline().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) P = [0 for i in range(N)] for i in range(Q): p,x = list(map(int,readline().split(...
import sys readline = sys.stdin.readline N,Q = list(map(int,readline().split())) G = [[] for i in range(N)] for i in range(N - 1): a,b = list(map(int,readline().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) P = [0] * N for i in range(Q): p,x = list(map(int,readline().split())) P[p -...
25
31
523
585
import sys readline = sys.stdin.readline N, Q = list(map(int, readline().split())) G = [[] for i in range(N)] for i in range(N - 1): a, b = list(map(int, readline().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) P = [0 for i in range(N)] for i in range(Q): p, x = list(map(int, readline().split...
import sys readline = sys.stdin.readline N, Q = list(map(int, readline().split())) G = [[] for i in range(N)] for i in range(N - 1): a, b = list(map(int, readline().split())) G[a - 1].append(b - 1) G[b - 1].append(a - 1) P = [0] * N for i in range(Q): p, x = list(map(int, readline().split())) P[p -...
false
19.354839
[ "-P = [0 for i in range(N)]", "+P = [0] * N", "-stack = [[0, 0, -1]]", "+ans = [0] * N", "+stack = []", "+# 頂点, 親, そこまでの点数", "+stack.append([0, -1, 0])", "- v, point, parent = stack.pop()", "- P[v] += point", "+ v, parent, point = stack.pop()", "+ point += P[v]", "+ ans[v] = poi...
false
0.046424
0.038479
1.206486
[ "s053934585", "s746628106" ]
u597374218
p02711
python
s676498059
s810525464
23
21
9,068
9,036
Accepted
Accepted
8.7
print(("Yes" if input().count("7")>0 else "No"))
N = eval(input()) print(("Yes" if N.count("7") > 0 else "No"))
1
2
46
55
print(("Yes" if input().count("7") > 0 else "No"))
N = eval(input()) print(("Yes" if N.count("7") > 0 else "No"))
false
50
[ "-print((\"Yes\" if input().count(\"7\") > 0 else \"No\"))", "+N = eval(input())", "+print((\"Yes\" if N.count(\"7\") > 0 else \"No\"))" ]
false
0.036911
0.037507
0.984118
[ "s676498059", "s810525464" ]
u934246119
p03339
python
s825739995
s731804161
364
314
32,084
29,740
Accepted
Accepted
13.74
n = int(eval(input())) s = eval(input()) num = [0 for i in range(n)] w = [0 for i in range(n)] if s[0] == 'W': w[0] = 1 for i in range(1, n): if s[i] == 'W': w[i] = (w[i-1] + 1) else: w[i] = w[i-1] e = [0 for i in range(n)] if s[n-1] == 'E': e[n-1] = 1 for i in range(2, n+1...
n = int(eval(input())) s = eval(input()) west = [0 for _ in range(n)] if s[0] == 'W': west[0] = 1 for _ in range(1, n): if s[_] == 'W': west[_] = west[_-1] + 1 else: west[_] = west[_-1] east = [0 for _ in range(n)] if s[n-1] == 'E': east[n-1] = 1 for _ in range(n-2, -1, -1):...
25
25
540
552
n = int(eval(input())) s = eval(input()) num = [0 for i in range(n)] w = [0 for i in range(n)] if s[0] == "W": w[0] = 1 for i in range(1, n): if s[i] == "W": w[i] = w[i - 1] + 1 else: w[i] = w[i - 1] e = [0 for i in range(n)] if s[n - 1] == "E": e[n - 1] = 1 for i in range(2, n + 1): ...
n = int(eval(input())) s = eval(input()) west = [0 for _ in range(n)] if s[0] == "W": west[0] = 1 for _ in range(1, n): if s[_] == "W": west[_] = west[_ - 1] + 1 else: west[_] = west[_ - 1] east = [0 for _ in range(n)] if s[n - 1] == "E": east[n - 1] = 1 for _ in range(n - 2, -1, -1): ...
false
0
[ "-num = [0 for i in range(n)]", "-w = [0 for i in range(n)]", "+west = [0 for _ in range(n)]", "- w[0] = 1", "-for i in range(1, n):", "- if s[i] == \"W\":", "- w[i] = w[i - 1] + 1", "+ west[0] = 1", "+for _ in range(1, n):", "+ if s[_] == \"W\":", "+ west[_] = west[_ -...
false
0.047125
0.043987
1.071343
[ "s825739995", "s731804161" ]
u102461423
p04004
python
s545596466
s285485376
543
411
131,224
90,576
Accepted
Accepted
24.31
import sys input = sys.stdin.readline import numpy as np MOD = 10**9 + 7 N,M,K = list(map(int,input().split())) def cumprod(arr): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq) for n in range(1,Lsq): arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD for n i...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,M,K = list(map(int,read().split())) MOD = 10 ** 9 + 7 def cumprod(arr,MOD): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq) ...
45
54
1,377
1,656
import sys input = sys.stdin.readline import numpy as np MOD = 10**9 + 7 N, M, K = list(map(int, input().split())) def cumprod(arr): L = len(arr) Lsq = int(L**0.5 + 1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): arr[:, n] *= arr[:, n - 1] arr[:, n] %= MOD ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, M, K = list(map(int, read().split())) MOD = 10**9 + 7 def cumprod(arr, MOD): L = len(arr) Lsq = int(L**0.5 + 1) arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq) for...
false
16.666667
[ "-input = sys.stdin.readline", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+N, M, K = list(map(int, read().split()))", "-N, M, K = list(map(int, input().split()))", "-def cumprod(arr):", "+def cumprod(arr, MOD):", "+def make_f...
false
0.792876
2.257506
0.351218
[ "s545596466", "s285485376" ]
u669240121
p03038
python
s063777488
s662091351
740
493
37,048
23,288
Accepted
Accepted
33.38
import heapq N, M = list(map(int, input().split())) nums = list(map(int, input().split())) n = len(nums) heap = [] for i in range(M): B, C = list(map(int, input().split())) heap.append([-C, B]) for num in nums: heap.append([-num, 1]) s = 0 heapq.heapify(heap) while n > 0: num, cnt = heapq.h...
def getInput(): return [int(x) for x in input().split()] N, M = getInput() nums = getInput() nums = sorted(nums) rep = [] for i in range(M): b, c = getInput() rep.append((b, c)) rep = sorted(rep, key=lambda x: x[1], reverse=True) ans = 0 minIndex = 0 isFinished = False for b, c in rep: f...
18
28
400
620
import heapq N, M = list(map(int, input().split())) nums = list(map(int, input().split())) n = len(nums) heap = [] for i in range(M): B, C = list(map(int, input().split())) heap.append([-C, B]) for num in nums: heap.append([-num, 1]) s = 0 heapq.heapify(heap) while n > 0: num, cnt = heapq.heappop(heap)...
def getInput(): return [int(x) for x in input().split()] N, M = getInput() nums = getInput() nums = sorted(nums) rep = [] for i in range(M): b, c = getInput() rep.append((b, c)) rep = sorted(rep, key=lambda x: x[1], reverse=True) ans = 0 minIndex = 0 isFinished = False for b, c in rep: for _ in range(...
false
35.714286
[ "-import heapq", "+def getInput():", "+ return [int(x) for x in input().split()]", "-N, M = list(map(int, input().split()))", "-nums = list(map(int, input().split()))", "-n = len(nums)", "-heap = []", "+", "+N, M = getInput()", "+nums = getInput()", "+nums = sorted(nums)", "+rep = []", "-...
false
0.088696
0.036356
2.439692
[ "s063777488", "s662091351" ]
u107639613
p03546
python
s429294366
s457580307
141
88
73,884
74,084
Accepted
Accepted
37.59
import sys from collections import defaultdict from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] cost = [10**18] * 10 cost[1] = 0 q = [(0, 1)]...
import sys from collections import defaultdict from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] """ 備忘録としてワ―シャルフロイドによる実装も試してみる。 wikipediaの解説が意外...
33
29
831
730
import sys from collections import defaultdict from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] cost = [10**18] * 10 cost[1] = 0 q = [(0, 1)] wh...
import sys from collections import defaultdict from heapq import heappush, heappop def input(): return sys.stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] """ 備忘録としてワ―シャルフロイドによる実装も試してみる。 wikipediaの解説が意外とわかりや...
false
12.121212
[ "- cost = [10**18] * 10", "- cost[1] = 0", "- q = [(0, 1)]", "- while q:", "- c, u = heappop(q)", "- if c > cost[u]:", "- continue", "+ \"\"\"", "+ 備忘録としてワ―シャルフロイドによる実装も試してみる。", "+ wikipediaの解説が意外とわかりやすい?", "+ \"\"\"", "+ for k in range(10):"...
false
0.040361
0.081422
0.495704
[ "s429294366", "s457580307" ]
u327172575
p02570
python
s810372916
s632155787
26
24
9,000
9,100
Accepted
Accepted
7.69
D,T,S = list(map(int,input().split())) if D/S <= T: print("Yes") else: print("No")
D,T,S = list(map(float,input().split())) if D/S <= T: print("Yes") else: print("No")
5
5
84
86
D, T, S = list(map(int, input().split())) if D / S <= T: print("Yes") else: print("No")
D, T, S = list(map(float, input().split())) if D / S <= T: print("Yes") else: print("No")
false
0
[ "-D, T, S = list(map(int, input().split()))", "+D, T, S = list(map(float, input().split()))" ]
false
0.084551
0.038801
2.179124
[ "s810372916", "s632155787" ]
u163320134
p03363
python
s405877713
s480530133
254
168
26,720
40,044
Accepted
Accepted
33.86
n=int(eval(input())) arr=list(map(int,input().split())) acum=[0]*(n+1) cnt=0 for i in range(1,n+1): acum[i]=acum[i-1]+arr[i-1] acum=sorted(acum) acum.append(10**10) tmp=1 for i in range(1,len(acum)): if acum[i]==acum[i-1]: tmp+=1 else: cnt+=tmp*(tmp-1)//2 tmp=1 print(cnt)
import collections n=int(eval(input())) arr=[0]+list(map(int,input().split())) for i in range(n): arr[i+1]+=arr[i] cnt=collections.Counter(arr) ans=0 for val in list(cnt.values()): ans+=val*(val-1)//2 print(ans)
16
11
300
214
n = int(eval(input())) arr = list(map(int, input().split())) acum = [0] * (n + 1) cnt = 0 for i in range(1, n + 1): acum[i] = acum[i - 1] + arr[i - 1] acum = sorted(acum) acum.append(10**10) tmp = 1 for i in range(1, len(acum)): if acum[i] == acum[i - 1]: tmp += 1 else: cnt += tmp * (tmp - 1...
import collections n = int(eval(input())) arr = [0] + list(map(int, input().split())) for i in range(n): arr[i + 1] += arr[i] cnt = collections.Counter(arr) ans = 0 for val in list(cnt.values()): ans += val * (val - 1) // 2 print(ans)
false
31.25
[ "+import collections", "+", "-arr = list(map(int, input().split()))", "-acum = [0] * (n + 1)", "-cnt = 0", "-for i in range(1, n + 1):", "- acum[i] = acum[i - 1] + arr[i - 1]", "-acum = sorted(acum)", "-acum.append(10**10)", "-tmp = 1", "-for i in range(1, len(acum)):", "- if acum[i] == ...
false
0.036132
0.034321
1.052784
[ "s405877713", "s480530133" ]
u366959492
p03162
python
s870892322
s198754417
648
333
65,880
54,636
Accepted
Accepted
48.61
n=int(eval(input())) dp=[[0]*(n) for _ in range(3)] l=[] for i in range(n): a,b,c=list(map(int,input().split())) l.append([a,b,c]) dp[0][0],dp[1][0],dp[2][0]=l[0][0],l[0][1],l[0][2] for i in range(0,n-1): dp[0][i+1]=max(dp[1][i]+l[i+1][0],dp[2][i]+l[i+1][0]) dp[1][i+1]=max(dp[0][i]+l[i+1][1],dp...
import sys input=sys.stdin.readline n=int(eval(input())) dp=[[0]*3 for _ in range(n)] a,b,c=list(map(int,input().split())) dp[0]=[a,b,c] for i in range(1,n): a,b,c=list(map(int,input().split())) dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b dp[i][2]=max(dp[i-1]...
12
13
433
341
n = int(eval(input())) dp = [[0] * (n) for _ in range(3)] l = [] for i in range(n): a, b, c = list(map(int, input().split())) l.append([a, b, c]) dp[0][0], dp[1][0], dp[2][0] = l[0][0], l[0][1], l[0][2] for i in range(0, n - 1): dp[0][i + 1] = max(dp[1][i] + l[i + 1][0], dp[2][i] + l[i + 1][0]) dp[1][i ...
import sys input = sys.stdin.readline n = int(eval(input())) dp = [[0] * 3 for _ in range(n)] a, b, c = list(map(int, input().split())) dp[0] = [a, b, c] for i in range(1, n): a, b, c = list(map(int, input().split())) dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a dp[i][1] = max(dp[i - 1][0], dp[i - 1][2])...
false
7.692308
[ "+import sys", "+", "+input = sys.stdin.readline", "-dp = [[0] * (n) for _ in range(3)]", "-l = []", "-for i in range(n):", "+dp = [[0] * 3 for _ in range(n)]", "+a, b, c = list(map(int, input().split()))", "+dp[0] = [a, b, c]", "+for i in range(1, n):", "- l.append([a, b, c])", "-dp[0][0],...
false
0.035683
0.036364
0.981295
[ "s870892322", "s198754417" ]
u832039789
p02783
python
s238114625
s291434139
21
19
3,316
3,064
Accepted
Accepted
9.52
h,a = list(map(int,input().split())) print(((h + a - 1) // a))
h,a = list(map(int,input().split())) cnt = 0 while h > 0: h -= a cnt += 1 print(cnt)
2
6
55
92
h, a = list(map(int, input().split())) print(((h + a - 1) // a))
h, a = list(map(int, input().split())) cnt = 0 while h > 0: h -= a cnt += 1 print(cnt)
false
66.666667
[ "-print(((h + a - 1) // a))", "+cnt = 0", "+while h > 0:", "+ h -= a", "+ cnt += 1", "+print(cnt)" ]
false
0.040861
0.041771
0.978225
[ "s238114625", "s291434139" ]
u645487439
p02761
python
s501250488
s990969611
19
17
3,064
3,064
Accepted
Accepted
10.53
n, m = list(map(int, input().split())) num_list = ['X'] * n def ans(): if n == 1 and m == 0: return 0 for i in range(m): set = list(map(str, input().split())) if set[0] == '1' and set[1] == '0' and n != 1: return -1 else: if num_list[int(set[0]...
n, m = list(map(int, input().split())) num_list = ['X'] * n def ans(): if n == 1 and m == 0: return 0 for i in range(m): set = list(map(str, input().split())) if set[0] == '1' and set[1] == '0' and n != 1: return -1 else: if num_list[int(set[0]...
28
25
727
664
n, m = list(map(int, input().split())) num_list = ["X"] * n def ans(): if n == 1 and m == 0: return 0 for i in range(m): set = list(map(str, input().split())) if set[0] == "1" and set[1] == "0" and n != 1: return -1 else: if num_list[int(set[0]) - 1] == ...
n, m = list(map(int, input().split())) num_list = ["X"] * n def ans(): if n == 1 and m == 0: return 0 for i in range(m): set = list(map(str, input().split())) if set[0] == "1" and set[1] == "0" and n != 1: return -1 else: if num_list[int(set[0]) - 1] == ...
false
10.714286
[ "- if i == 0:", "- num_list[i] = \"1\"", "- else:", "- num_list[i] = \"0\"", "+ num_list[i] = \"1\" if i == 0 else \"0\"" ]
false
0.047974
0.047127
1.017971
[ "s501250488", "s990969611" ]
u485716382
p03127
python
s577870847
s177532378
274
203
24,056
15,020
Accepted
Accepted
25.91
from fractions import gcd import numpy as np N = int(eval(input())) A = np.array([int(i) for i in input().split()]) a = A[0] for b in A[1:]: # print(a) a = gcd(a, b) print(a)
def gcd(a, b): if b == 0: return a return gcd(b, a%b) def main(): N = int(eval(input())) An = list(map(int, input().split(' '))) An = sorted(An) An = [gcd(a_n, An[0]) for a_n in An] print((min(An))) main()
12
15
186
251
from fractions import gcd import numpy as np N = int(eval(input())) A = np.array([int(i) for i in input().split()]) a = A[0] for b in A[1:]: # print(a) a = gcd(a, b) print(a)
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def main(): N = int(eval(input())) An = list(map(int, input().split(" "))) An = sorted(An) An = [gcd(a_n, An[0]) for a_n in An] print((min(An))) main()
false
20
[ "-from fractions import gcd", "-import numpy as np", "+def gcd(a, b):", "+ if b == 0:", "+ return a", "+ return gcd(b, a % b)", "-N = int(eval(input()))", "-A = np.array([int(i) for i in input().split()])", "-a = A[0]", "-for b in A[1:]:", "- # print(a)", "- a = gcd(a, b)", ...
false
0.221035
0.037141
5.951172
[ "s577870847", "s177532378" ]
u368249389
p03712
python
s893214039
s102433364
30
21
4,468
3,064
Accepted
Accepted
30
H, W = map(int, input().split()) mark_list = [["#"]*(W+2) for i in range(H+2)] for i in range(1,H+1): w_list = input() for j in range(1,W+1): mark_list[i][j] = w_list[j-1] # output for i in mark_list[0]: print(i, end="") print("") for i in range(1,H+1): for j in range(W+2): print(mark_list...
# Problem B - Picture Frame # input H, W = list(map(int, input().split())) a_list = [['']*W for i in range(H)] for i in range(H): a_nums = list(eval(input())) for j in range(W): a_list[i][j] = a_nums[j] # output ans = "#"*(W+2) ans += "\n" for i in range(H): ans += "#" for j in ...
18
20
400
395
H, W = map(int, input().split()) mark_list = [["#"] * (W + 2) for i in range(H + 2)] for i in range(1, H + 1): w_list = input() for j in range(1, W + 1): mark_list[i][j] = w_list[j - 1] # output for i in mark_list[0]: print(i, end="") print("") for i in range(1, H + 1): for j in range(W + 2): ...
# Problem B - Picture Frame # input H, W = list(map(int, input().split())) a_list = [[""] * W for i in range(H)] for i in range(H): a_nums = list(eval(input())) for j in range(W): a_list[i][j] = a_nums[j] # output ans = "#" * (W + 2) ans += "\n" for i in range(H): ans += "#" for j in range(W): ...
false
10
[ "-H, W = map(int, input().split())", "-mark_list = [[\"#\"] * (W + 2) for i in range(H + 2)]", "-for i in range(1, H + 1):", "- w_list = input()", "- for j in range(1, W + 1):", "- mark_list[i][j] = w_list[j - 1]", "+# Problem B - Picture Frame", "+# input", "+H, W = list(map(int, input...
false
0.037028
0.078317
0.47279
[ "s893214039", "s102433364" ]
u600717568
p02959
python
s000563919
s524716795
158
146
18,476
18,476
Accepted
Accepted
7.59
N=int(eval(input())) A=list(map(int,input().split())) B=list(map(int,input().split())) x=0 for i in range(N): if A[i]+A[i+1]<=B[i]: x+=A[i]+A[i+1] A[i+1]=0 elif A[i]>=B[i]: x+=B[i] elif A[i]<B[i]: x+=B[i] A[i+1]=A[i+1]-(B[i]-A[i]) print(x)
N=int(eval(input())) A=list(map(int,input().split())) B=list(map(int,input().split())) count=0 for i in range(N): if A[i]+A[i+1]<=B[i]: count+=A[i]+A[i+1] A[i+1]=0 elif A[i]<=B[i]: count+=B[i] A[i+1]=A[i+1]-(B[i]-A[i]) else: count+=B[i] print(count)
14
16
272
304
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) x = 0 for i in range(N): if A[i] + A[i + 1] <= B[i]: x += A[i] + A[i + 1] A[i + 1] = 0 elif A[i] >= B[i]: x += B[i] elif A[i] < B[i]: x += B[i] A[i + 1] = A[i + 1] - (B[i] -...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) count = 0 for i in range(N): if A[i] + A[i + 1] <= B[i]: count += A[i] + A[i + 1] A[i + 1] = 0 elif A[i] <= B[i]: count += B[i] A[i + 1] = A[i + 1] - (B[i] - A[i]) else: cou...
false
12.5
[ "-x = 0", "+count = 0", "- x += A[i] + A[i + 1]", "+ count += A[i] + A[i + 1]", "- elif A[i] >= B[i]:", "- x += B[i]", "- elif A[i] < B[i]:", "- x += B[i]", "+ elif A[i] <= B[i]:", "+ count += B[i]", "-print(x)", "+ else:", "+ count += B[...
false
0.036276
0.03507
1.034406
[ "s000563919", "s524716795" ]
u533039576
p02821
python
s004363816
s401737538
1,170
448
14,428
17,940
Accepted
Accepted
61.71
from bisect import bisect_left, bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() # print(a) a_cs = [0] * (n + 1) for i in range(n): a_cs[i + 1] = a_cs[i] + a[n - 1 - i] def check(x): # M回の握手の幸福度の最小値をx以上にできるか # つまり、M回の任意の握手の幸福度をx以上にできるか cnt...
from bisect import bisect_left, bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() # print(a) a_cnt = [0] * (2 * a[-1] + 5) for ai in a: a_cnt[ai] += 1 for i in reversed(list(range(len(a_cnt) - 1))): a_cnt[i] += a_cnt[i + 1] a_cs = [0] * (n + 1) for i i...
40
50
764
959
from bisect import bisect_left, bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() # print(a) a_cs = [0] * (n + 1) for i in range(n): a_cs[i + 1] = a_cs[i] + a[n - 1 - i] def check(x): # M回の握手の幸福度の最小値をx以上にできるか # つまり、M回の任意の握手の幸福度をx以上にできるか cnt = 0 for a...
from bisect import bisect_left, bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() # print(a) a_cnt = [0] * (2 * a[-1] + 5) for ai in a: a_cnt[ai] += 1 for i in reversed(list(range(len(a_cnt) - 1))): a_cnt[i] += a_cnt[i + 1] a_cs = [0] * (n + 1) for i in range(n): ...
false
20
[ "+a_cnt = [0] * (2 * a[-1] + 5)", "+for ai in a:", "+ a_cnt[ai] += 1", "+for i in reversed(list(range(len(a_cnt) - 1))):", "+ a_cnt[i] += a_cnt[i + 1]", "- idx = bisect_left(a, x - ai)", "- cnt += n - idx", "+ if x >= ai:", "+ cnt += a_cnt[x - ai]", "+ ...
false
0.114269
0.148124
0.771442
[ "s004363816", "s401737538" ]
u461833298
p02947
python
s945878154
s067685107
534
290
31,792
20,196
Accepted
Accepted
45.69
import itertools import collections N = int(eval(input())) S = [[str(x) for x in eval(input())] for _ in range(N)] S = [''.join(sorted(x)) for x in S] cnt=0 reg = collections.defaultdict(int) for s in S: reg[s] += 1 if reg[s] > 1: cnt += reg[s] - 1 print(cnt)
import collections N = int(eval(input())) S = [eval(input()) for _ in range(N)] S = [''.join(sorted(x)) for x in S] S = collections.Counter(S) ans = [x*(x-1)//2 for x in list(S.values())] print((sum(ans)))
13
9
276
195
import itertools import collections N = int(eval(input())) S = [[str(x) for x in eval(input())] for _ in range(N)] S = ["".join(sorted(x)) for x in S] cnt = 0 reg = collections.defaultdict(int) for s in S: reg[s] += 1 if reg[s] > 1: cnt += reg[s] - 1 print(cnt)
import collections N = int(eval(input())) S = [eval(input()) for _ in range(N)] S = ["".join(sorted(x)) for x in S] S = collections.Counter(S) ans = [x * (x - 1) // 2 for x in list(S.values())] print((sum(ans)))
false
30.769231
[ "-import itertools", "-S = [[str(x) for x in eval(input())] for _ in range(N)]", "+S = [eval(input()) for _ in range(N)]", "-cnt = 0", "-reg = collections.defaultdict(int)", "-for s in S:", "- reg[s] += 1", "- if reg[s] > 1:", "- cnt += reg[s] - 1", "-print(cnt)", "+S = collections....
false
0.038094
0.08589
0.443522
[ "s945878154", "s067685107" ]
u767797498
p02597
python
s151491888
s410170707
109
59
11,328
9,344
Accepted
Accepted
45.87
# -*- coding: utf-8 -*- # template: v1.3.1 import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 200000 """+("R"*200000) _EXPECTED = """\ 2 """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] ...
n=int(eval(input())) s=eval(input()) li=0 ri=len(s) cnt=0 while li<ri: if s[li] == "W": while li<ri: ri-=1 if s[ri] == "R": cnt+=1 break li+=1 print(cnt)
73
16
1,380
202
# -*- coding: utf-8 -*- # template: v1.3.1 import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 200000 """ + ( "R" * 200000 ) _EXPECTED = """\ 2 """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] {str}"...
n = int(eval(input())) s = eval(input()) li = 0 ri = len(s) cnt = 0 while li < ri: if s[li] == "W": while li < ri: ri -= 1 if s[ri] == "R": cnt += 1 break li += 1 print(cnt)
false
78.082192
[ "-# -*- coding: utf-8 -*-", "-# template: v1.3.1", "-import io", "-import sys", "-import math", "-", "-### DEBUG ###", "-_DEB = 0 # 1:ON / 0:OFF", "-_INPUT = \"\"\"\\", "-200000", "-\"\"\" + (", "- \"R\" * 200000", "-)", "-_EXPECTED = \"\"\"\\", "-2", "-\"\"\"", "-if _DEB:", "-...
false
0.038373
0.036507
1.051108
[ "s151491888", "s410170707" ]
u893063840
p03364
python
s651345947
s648313329
1,450
224
123,228
13,184
Accepted
Accepted
84.55
n = int(eval(input())) s = [list(ord(e) - ord("a") for e in eval(input())) for _ in range(n)] ans = 0 for b in range(n): t = [[-1] * n for _ in range(n)] for hi in range(n): for wi in range(n): nh = hi nw = (wi + b) % n t[nh][nw] = s[hi][wi] bl = Tru...
import numpy as np n = int(eval(input())) s = np.array([list(ord(e) - ord("a") for e in eval(input())) for _ in range(n)], np.int8) s = np.hstack((s, s)) ans = 0 for b in range(n): t = s[:, b:b+n] if (t == t.T).all(): ans += 1 ans *= n print(ans)
22
14
467
267
n = int(eval(input())) s = [list(ord(e) - ord("a") for e in eval(input())) for _ in range(n)] ans = 0 for b in range(n): t = [[-1] * n for _ in range(n)] for hi in range(n): for wi in range(n): nh = hi nw = (wi + b) % n t[nh][nw] = s[hi][wi] bl = True for i in...
import numpy as np n = int(eval(input())) s = np.array( [list(ord(e) - ord("a") for e in eval(input())) for _ in range(n)], np.int8 ) s = np.hstack((s, s)) ans = 0 for b in range(n): t = s[:, b : b + n] if (t == t.T).all(): ans += 1 ans *= n print(ans)
false
36.363636
[ "+import numpy as np", "+", "-s = [list(ord(e) - ord(\"a\") for e in eval(input())) for _ in range(n)]", "+s = np.array(", "+ [list(ord(e) - ord(\"a\") for e in eval(input())) for _ in range(n)], np.int8", "+)", "+s = np.hstack((s, s))", "- t = [[-1] * n for _ in range(n)]", "- for hi in ra...
false
0.037788
0.758664
0.049809
[ "s651345947", "s648313329" ]
u998741086
p03331
python
s763643733
s550978263
273
31
9,128
9,220
Accepted
Accepted
88.64
#!/usr/bin/env python n = int(eval(input())) def sumdigits(n): ret = 0 s = list(str(n)) for i in range(len(s)): ret += int(s[i]) return ret a = 1 ans = 1000000 while n-a > 0: tmp = sumdigits(a) + sumdigits(n-a) if ans >= tmp: ans = tmp a += 1 print(...
#!/usr/bin/env python import math n = int(eval(input())) m = math.log10(n) if int(m) == m: print((10)) exit() ans = sum(map(int, list(str(n)))) print(ans)
20
11
319
167
#!/usr/bin/env python n = int(eval(input())) def sumdigits(n): ret = 0 s = list(str(n)) for i in range(len(s)): ret += int(s[i]) return ret a = 1 ans = 1000000 while n - a > 0: tmp = sumdigits(a) + sumdigits(n - a) if ans >= tmp: ans = tmp a += 1 print(ans)
#!/usr/bin/env python import math n = int(eval(input())) m = math.log10(n) if int(m) == m: print((10)) exit() ans = sum(map(int, list(str(n)))) print(ans)
false
45
[ "+import math", "+", "-", "-", "-def sumdigits(n):", "- ret = 0", "- s = list(str(n))", "- for i in range(len(s)):", "- ret += int(s[i])", "- return ret", "-", "-", "-a = 1", "-ans = 1000000", "-while n - a > 0:", "- tmp = sumdigits(a) + sumdigits(n - a)", "- ...
false
0.157458
0.036144
4.356411
[ "s763643733", "s550978263" ]
u481187938
p02558
python
s050839875
s538599470
2,887
352
130,088
130,240
Accepted
Accepted
87.81
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline...
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline...
84
81
2,830
2,793
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline().spl...
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline().spl...
false
3.571429
[ "- self._parent = [i for i in range(n)]", "- self._rank = [0 for _ in range(n)]", "- self._group_size = [1 for _ in range(n)]", "+ self._parent, self._rank, self._group_size = (", "+ [i for i in range(n)],", "+ [0 for _ in range(n)],", "+ [1 f...
false
0.038029
0.007414
5.129554
[ "s050839875", "s538599470" ]
u919633157
p03837
python
s422227729
s906294194
261
187
44,652
14,764
Accepted
Accepted
28.35
n,m=list(map(int,input().split())) d=[[float('inf') for i in range(n)] for i in range(n)] r=[list(map(int,input().split())) for i in range(m)] def wf(d): for k in range(n): for i in range(n): for j in range(n): d[i][j]=min(d[i][j],d[i][k]+d[k][j]) return d for ...
n,m=list(map(int,input().split())) d=[[float('inf') for i in range(n)] for i in range(n)] r=[list(map(int,input().split())) for i in range(m)] from scipy.sparse.csgraph import floyd_warshall for u,v,c in r: u,v=u-1,v-1 d[u][v]=d[v][u]=c d=floyd_warshall(d).tolist() cnt=0 for u,v,c in r: u,...
24
18
465
371
n, m = list(map(int, input().split())) d = [[float("inf") for i in range(n)] for i in range(n)] r = [list(map(int, input().split())) for i in range(m)] def wf(d): for k in range(n): for i in range(n): for j in range(n): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d f...
n, m = list(map(int, input().split())) d = [[float("inf") for i in range(n)] for i in range(n)] r = [list(map(int, input().split())) for i in range(m)] from scipy.sparse.csgraph import floyd_warshall for u, v, c in r: u, v = u - 1, v - 1 d[u][v] = d[v][u] = c d = floyd_warshall(d).tolist() cnt = 0 for u, v, c ...
false
25
[ "-", "-", "-def wf(d):", "- for k in range(n):", "- for i in range(n):", "- for j in range(n):", "- d[i][j] = min(d[i][j], d[i][k] + d[k][j])", "- return d", "-", "+from scipy.sparse.csgraph import floyd_warshall", "-wf(d)", "+d = floyd_warshall(d).tolist...
false
0.046978
0.432689
0.108572
[ "s422227729", "s906294194" ]
u226108478
p02767
python
s253633838
s769991343
26
20
2,940
3,060
Accepted
Accepted
23.08
# -*- coding: utf-8 -*- def main(): n = int(eval(input())) x = list(map(int, input().split())) ans = float('inf') for p in range(-100, 201): summed = 0 for xi in x: summed += (xi - p) ** 2 ans = min(ans, summed) print(ans) if __name__ ==...
# -*- coding: utf-8 -*- def main(): n = int(eval(input())) x = list(map(int, input().split())) ans = float('inf') # KeyInsight: # xの座標の最小値から最大値までを探索すればよい # See: https://img.atcoder.jp/abc156/editorial.pdf left = min(x) right = max(x) for p in range(left, right + 1):...
21
27
339
492
# -*- coding: utf-8 -*- def main(): n = int(eval(input())) x = list(map(int, input().split())) ans = float("inf") for p in range(-100, 201): summed = 0 for xi in x: summed += (xi - p) ** 2 ans = min(ans, summed) print(ans) if __name__ == "__main__": main()
# -*- coding: utf-8 -*- def main(): n = int(eval(input())) x = list(map(int, input().split())) ans = float("inf") # KeyInsight: # xの座標の最小値から最大値までを探索すればよい # See: https://img.atcoder.jp/abc156/editorial.pdf left = min(x) right = max(x) for p in range(left, right + 1): summed = ...
false
22.222222
[ "- for p in range(-100, 201):", "+ # KeyInsight:", "+ # xの座標の最小値から最大値までを探索すればよい", "+ # See: https://img.atcoder.jp/abc156/editorial.pdf", "+ left = min(x)", "+ right = max(x)", "+ for p in range(left, right + 1):" ]
false
0.043927
0.046169
0.951435
[ "s253633838", "s769991343" ]
u127499732
p03044
python
s268448741
s981345033
510
471
73,448
54,596
Accepted
Accepted
7.65
def main(): from collections import deque, defaultdict n, *uvw = list(map(int, open(0).read().split())) l = defaultdict(dict) g = [[] for _ in range(n + 1)] for u, v, w in zip(uvw[::3], uvw[1::3], uvw[2::3]): g[u].append(v) g[v].append(u) l[u].update({v: w % 2}) ...
def main(): from collections import deque, defaultdict n, *uvw = map(int, open(0).read().split()) l = defaultdict(dict) g = [[] for _ in range(n + 1)] for u, v, w in zip(uvw[::3], uvw[1::3], uvw[2::3]): g[u].append(v) g[v].append(u) l[u].update({v: w % 2}) l[...
37
35
810
768
def main(): from collections import deque, defaultdict n, *uvw = list(map(int, open(0).read().split())) l = defaultdict(dict) g = [[] for _ in range(n + 1)] for u, v, w in zip(uvw[::3], uvw[1::3], uvw[2::3]): g[u].append(v) g[v].append(u) l[u].update({v: w % 2}) l[v]...
def main(): from collections import deque, defaultdict n, *uvw = map(int, open(0).read().split()) l = defaultdict(dict) g = [[] for _ in range(n + 1)] for u, v, w in zip(uvw[::3], uvw[1::3], uvw[2::3]): g[u].append(v) g[v].append(u) l[u].update({v: w % 2}) l[0].update({1...
false
5.405405
[ "- n, *uvw = list(map(int, open(0).read().split()))", "+ n, *uvw = map(int, open(0).read().split())", "- l[v].update({u: w % 2})", "- c = k if l[i][j] == 0 else 1 - k", "+ c = k if l[min(i, j)][max(i, j)] == 0 else 1 - k", "- ans = \"\\n\".join(map(str, col[1:]))", "- pr...
false
0.036411
0.03577
1.017927
[ "s268448741", "s981345033" ]
u396495667
p04012
python
s339736369
s399336579
20
17
2,940
2,940
Accepted
Accepted
15
w = eval(input()) ans =1 for i in w: if w.count(i) %2 !=0: ans =0 print(('Yes' if ans==1 else 'No'))
w = eval(input()) l = list(set(w)) ans =0 for i in range(len(l)): a = w.count(l[i]) if a %2 !=0: ans =1 print(('Yes' if ans ==0 else 'No'))
6
8
103
146
w = eval(input()) ans = 1 for i in w: if w.count(i) % 2 != 0: ans = 0 print(("Yes" if ans == 1 else "No"))
w = eval(input()) l = list(set(w)) ans = 0 for i in range(len(l)): a = w.count(l[i]) if a % 2 != 0: ans = 1 print(("Yes" if ans == 0 else "No"))
false
25
[ "-ans = 1", "-for i in w:", "- if w.count(i) % 2 != 0:", "- ans = 0", "-print((\"Yes\" if ans == 1 else \"No\"))", "+l = list(set(w))", "+ans = 0", "+for i in range(len(l)):", "+ a = w.count(l[i])", "+ if a % 2 != 0:", "+ ans = 1", "+print((\"Yes\" if ans == 0 else \"No\...
false
0.068647
0.067264
1.020557
[ "s339736369", "s399336579" ]
u941753895
p03416
python
s645083097
s045706909
76
53
2,940
2,940
Accepted
Accepted
30.26
a,b=list(map(int,input().split())) x=0 for i in range(a,b+1): if str(i)[:2]==str(i)[3:5][::-1]: x+=1 print(x)
# 入力 A,B=list(map(int,input().split())) c=0 for i in range(A,B+1): i=str(i) # 1桁目と5桁目が一致する # かつ2桁目と4桁目が一致する場合 if i[0]==i[4] and i[1]==i[3]: c+=1 # 出力 print(c)
6
14
111
180
a, b = list(map(int, input().split())) x = 0 for i in range(a, b + 1): if str(i)[:2] == str(i)[3:5][::-1]: x += 1 print(x)
# 入力 A, B = list(map(int, input().split())) c = 0 for i in range(A, B + 1): i = str(i) # 1桁目と5桁目が一致する # かつ2桁目と4桁目が一致する場合 if i[0] == i[4] and i[1] == i[3]: c += 1 # 出力 print(c)
false
57.142857
[ "-a, b = list(map(int, input().split()))", "-x = 0", "-for i in range(a, b + 1):", "- if str(i)[:2] == str(i)[3:5][::-1]:", "- x += 1", "-print(x)", "+# 入力", "+A, B = list(map(int, input().split()))", "+c = 0", "+for i in range(A, B + 1):", "+ i = str(i)", "+ # 1桁目と5桁目が一致する", ...
false
0.063786
0.052925
1.205222
[ "s645083097", "s045706909" ]
u216015528
p02861
python
s822392059
s982571953
204
29
9,132
9,136
Accepted
Accepted
85.78
#!/usr/bin/env python3 def main(): from itertools import permutations from math import sqrt N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 cnt = 0 for can_order in permutations(xy): cnt += 1 for k in range(1, N): ...
#!/usr/bin/env python3 def main(): from itertools import combinations from math import sqrt N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 for can_move in combinations(xy, 2): xi, yi = can_move[0] xj, yj = can_move[1] ...
22
18
538
438
#!/usr/bin/env python3 def main(): from itertools import permutations from math import sqrt N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 cnt = 0 for can_order in permutations(xy): cnt += 1 for k in range(1, N): xi, yi = ...
#!/usr/bin/env python3 def main(): from itertools import combinations from math import sqrt N = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(N)] ans = 0 for can_move in combinations(xy, 2): xi, yi = can_move[0] xj, yj = can_move[1] ans += sqrt(...
false
18.181818
[ "- from itertools import permutations", "+ from itertools import combinations", "- cnt = 0", "- for can_order in permutations(xy):", "- cnt += 1", "- for k in range(1, N):", "- xi, yi = can_order[k - 1]", "- xj, yj = can_order[k]", "- ans +=...
false
0.04141
0.039178
1.056954
[ "s822392059", "s982571953" ]
u019489252
p02610
python
s273003434
s202037434
951
876
50,744
51,340
Accepted
Accepted
7.89
from heapq import* i=input for s in[0]*int(i()): n,x,*y=int(i()),[] for _ in'_'*n:k,l,r=t=[*list(map(int,i().split()))];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r) for x in x,y: x.sort();h=[] for k,l,r in x: s+=r if k:s+=l-r;heappush(h,l-r) if len(h)>k:s-=heappop(h) print(s)
from heapq import* i=input for s in[0]*int(i()): n,*x=int(i()),[],[] for _ in'_'*n:k,l,r=t=[*list(map(int,i().split()))];x[l>r]+=[[[n-k,r,l],t][l>r]] for x in x: h=[] for k,l,r in sorted(x):heappush(h,l-r);s+=l-(k<len(h)and heappop(h)) print(s)
12
9
288
254
from heapq import * i = input for s in [0] * int(i()): n, x, *y = int(i()), [] for _ in "_" * n: k, l, r = t = [*list(map(int, i().split()))] x += [t] * (l > r) y += [[n - k, r, l]] * (l <= r) for x in x, y: x.sort() h = [] for k, l, r in x: s += ...
from heapq import * i = input for s in [0] * int(i()): n, *x = int(i()), [], [] for _ in "_" * n: k, l, r = t = [*list(map(int, i().split()))] x[l > r] += [[[n - k, r, l], t][l > r]] for x in x: h = [] for k, l, r in sorted(x): heappush(h, l - r) s +=...
false
25
[ "- n, x, *y = int(i()), []", "+ n, *x = int(i()), [], []", "- x += [t] * (l > r)", "- y += [[n - k, r, l]] * (l <= r)", "- for x in x, y:", "- x.sort()", "+ x[l > r] += [[[n - k, r, l], t][l > r]]", "+ for x in x:", "- for k, l, r in x:", "- ...
false
0.044153
0.042518
1.038467
[ "s273003434", "s202037434" ]
u869790980
p02959
python
s860344153
s638796348
139
107
50,004
49,128
Accepted
Accepted
23.02
import collections n = int(input()) cities = collections.deque(list(map(int, input().split(' ')))) q = collections.deque(list(map(int, input().split(' ')))) res = 0 p = 0 while(q): w = q.pop() if cities[-1]: m = min(w, cities[-1]) cities[-1]-=m w -= m res += m cities.pop() if cities[-1]: m ...
import collections n = int(input()) cities,q = collections.deque(list(map(int, input().split(' ')))), collections.deque(list(map(int, input().split(' ')))) res = 0 while(q): u = q.pop() for _ in range(2): c = cities.pop() m = min(u, c) c -=m u -= m res += m cities.append(c) print(res)
20
14
390
310
import collections n = int(input()) cities = collections.deque(list(map(int, input().split(" ")))) q = collections.deque(list(map(int, input().split(" ")))) res = 0 p = 0 while q: w = q.pop() if cities[-1]: m = min(w, cities[-1]) cities[-1] -= m w -= m res += m cities.pop() ...
import collections n = int(input()) cities, q = collections.deque(list(map(int, input().split(" ")))), collections.deque( list(map(int, input().split(" "))) ) res = 0 while q: u = q.pop() for _ in range(2): c = cities.pop() m = min(u, c) c -= m u -= m res += m ci...
false
30
[ "-cities = collections.deque(list(map(int, input().split(\" \"))))", "-q = collections.deque(list(map(int, input().split(\" \"))))", "+cities, q = collections.deque(list(map(int, input().split(\" \")))), collections.deque(", "+ list(map(int, input().split(\" \")))", "+)", "-p = 0", "- w = q.pop()"...
false
0.072445
0.044452
1.629731
[ "s860344153", "s638796348" ]
u816631826
p02771
python
s988974630
s604598597
160
17
13,220
2,940
Accepted
Accepted
89.38
import numpy A,B,C = input().split() a = A b = B c = C if (a==b and a==c): print("No") elif (a==b or b==c or a==c): print("Yes") elif (a!=b or b!=c): print("No")
a, b, c = list (map (int, input ().split ())) k = a ^ b ^ c print(("Yes" if ((k == a) + (k == b) + (k == c) == 1) else "No"))
11
3
183
126
import numpy A, B, C = input().split() a = A b = B c = C if a == b and a == c: print("No") elif a == b or b == c or a == c: print("Yes") elif a != b or b != c: print("No")
a, b, c = list(map(int, input().split())) k = a ^ b ^ c print(("Yes" if ((k == a) + (k == b) + (k == c) == 1) else "No"))
false
72.727273
[ "-import numpy", "-", "-A, B, C = input().split()", "-a = A", "-b = B", "-c = C", "-if a == b and a == c:", "- print(\"No\")", "-elif a == b or b == c or a == c:", "- print(\"Yes\")", "-elif a != b or b != c:", "- print(\"No\")", "+a, b, c = list(map(int, input().split()))", "+k =...
false
0.033149
0.030914
1.072292
[ "s988974630", "s604598597" ]
u404244809
p03043
python
s754528920
s946663909
226
52
5,548
5,548
Accepted
Accepted
76.99
import sys from itertools import combinations, permutations, product, combinations_with_replacement, accumulate from heapq import heapify, heappop, heappush, heappushpop from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from math import sqrt, log, floor, ceil, factori...
import sys from itertools import combinations, permutations, product, combinations_with_replacement, accumulate from heapq import heapify, heappop, heappush, heappushpop from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from math import sqrt, log, floor, ceil, factori...
63
60
2,026
1,928
import sys from itertools import ( combinations, permutations, product, combinations_with_replacement, accumulate, ) from heapq import heapify, heappop, heappush, heappushpop from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from math import sqrt, log, ...
import sys from itertools import ( combinations, permutations, product, combinations_with_replacement, accumulate, ) from heapq import heapify, heappop, heappush, heappushpop from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from math import sqrt, log, ...
false
4.761905
[ "-def EPR(msg=\"\"):", "+def EPR(msg):", "- for i in range(1, N + 1):", "+ for i in range(1, N + 1): # サイコロの出た目", "- win = True # 勝ち続けているか", "- while True:", "- if K <= scr: # 勝ち", "- EPR(scr)", "- break", "- elif 0 < scr <...
false
0.248317
0.046886
5.29621
[ "s754528920", "s946663909" ]
u545368057
p03108
python
s684423177
s078531637
900
703
23,312
44,684
Accepted
Accepted
21.89
class UnionFind: def __init__(self, n): self.par = [-1 for i in range(n+1)] self.size = [1 for i in range(n+1)] # 検索 def find(self, x): path = [] curr = x # 親ノードの手前で止まる(どの根に紐づくかの情報を持ちながら) while self.par[curr] != -1: # 自分自身じゃない場合は、上にさかのぼって...
n, m = list(map(int, input().split())) # 逆順にunionfind from collections import defaultdict class UnionFind: def __init__(self, n): class KeyDict(dict): # 辞書にないときの対応 def __missing__(self,key): self[key] = key return key self.parent = Ke...
46
67
1,242
1,715
class UnionFind: def __init__(self, n): self.par = [-1 for i in range(n + 1)] self.size = [1 for i in range(n + 1)] # 検索 def find(self, x): path = [] curr = x # 親ノードの手前で止まる(どの根に紐づくかの情報を持ちながら) while self.par[curr] != -1: # 自分自身じゃない場合は、上にさかのぼって検索(再帰...
n, m = list(map(int, input().split())) # 逆順にunionfind from collections import defaultdict class UnionFind: def __init__(self, n): class KeyDict(dict): # 辞書にないときの対応 def __missing__(self, key): self[key] = key return key self.parent = KeyDict(...
false
31.343284
[ "+n, m = list(map(int, input().split()))", "+# 逆順にunionfind", "+from collections import defaultdict", "+", "+", "- self.par = [-1 for i in range(n + 1)]", "- self.size = [1 for i in range(n + 1)]", "+ class KeyDict(dict):", "+ # 辞書にないときの対応", "+ def __miss...
false
0.043689
0.042926
1.017772
[ "s684423177", "s078531637" ]
u600402037
p02769
python
s268865969
s851423503
1,902
282
51,524
53,576
Accepted
Accepted
85.17
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10 ** 9 + 7 # K回の移動が終わった後、人がいる部屋の数はNからN-K def cmb(n, k): if k < 0 or k > n: return 0 return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] ...
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10 ** 9 + 7 def cmb(n, k): if k < 0 or k > n: return 0 return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD def cumprod(arr, MOD):...
45
39
1,201
1,134
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10**9 + 7 # K回の移動が終わった後、人がいる部屋の数はNからN-K def cmb(n, k): if k < 0 or k > n: return 0 return fact[n] * fact_inv[k] % MOD * fact_inv[n - k] % MOD ...
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10**9 + 7 def cmb(n, k): if k < 0 or k > n: return 0 return fact[n] * fact_inv[k] % MOD * fact_inv[n - k] % MOD def cumprod(arr, MOD): ...
false
13.333333
[ "-# K回の移動が終わった後、人がいる部屋の数はNからN-K", "+", "+", "-answer = 0", "-for x in range(N, max(0, N - K - 1), -1):", "- # x個の家には1人以上いるのでこの人たちは除く", "- can_move = N - x", "- # x-1の壁をcan_move+1の場所に入れる", "- answer += cmb(N, x) * cmb(x - 1 + can_move, can_move)", "- answer %= MOD", "+K = min(K, N ...
false
0.432612
0.294689
1.46803
[ "s268865969", "s851423503" ]
u977389981
p03854
python
s464768427
s879043327
36
28
3,956
3,956
Accepted
Accepted
22.22
s = list(eval(input())) while len(s) > 0: if ''.join(s[-7:]) == 'dreamer': del s[-7:] elif ''.join(s[-6:]) == 'eraser': del s[-6:] elif ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase': del s[-5:] else: break print(('YES' if len(s) == 0 else 'NO'))
S = list(eval(input())) a = list('dream') b = list('dreamer') c = list('erase') d = list('eraser') while True: if S[-5:] == a: del S[-5:] elif S[-7:] == b: del S[-7:] elif S[-5:] == c: del S[-5:] elif S[-6:] == d: del S[-6:] else: break ...
12
22
308
376
s = list(eval(input())) while len(s) > 0: if "".join(s[-7:]) == "dreamer": del s[-7:] elif "".join(s[-6:]) == "eraser": del s[-6:] elif "".join(s[-5:]) == "dream" or "".join(s[-5:]) == "erase": del s[-5:] else: break print(("YES" if len(s) == 0 else "NO"))
S = list(eval(input())) a = list("dream") b = list("dreamer") c = list("erase") d = list("eraser") while True: if S[-5:] == a: del S[-5:] elif S[-7:] == b: del S[-7:] elif S[-5:] == c: del S[-5:] elif S[-6:] == d: del S[-6:] else: break if len(S) == 0: pri...
false
45.454545
[ "-s = list(eval(input()))", "-while len(s) > 0:", "- if \"\".join(s[-7:]) == \"dreamer\":", "- del s[-7:]", "- elif \"\".join(s[-6:]) == \"eraser\":", "- del s[-6:]", "- elif \"\".join(s[-5:]) == \"dream\" or \"\".join(s[-5:]) == \"erase\":", "- del s[-5:]", "+S = list(...
false
0.034355
0.034072
1.008289
[ "s464768427", "s879043327" ]
u571281863
p02628
python
s768880397
s516930353
34
25
9,208
9,200
Accepted
Accepted
26.47
N,K=list(map(int,input().split())) P=sorted(map(int,input().split())) r=0 for i in range(K): r+=P[i] print(r)
N,K=list(map(int,input().split())) P=sorted(map(int,input().split())) print((sum(P[:K])))
6
3
110
83
N, K = list(map(int, input().split())) P = sorted(map(int, input().split())) r = 0 for i in range(K): r += P[i] print(r)
N, K = list(map(int, input().split())) P = sorted(map(int, input().split())) print((sum(P[:K])))
false
50
[ "-r = 0", "-for i in range(K):", "- r += P[i]", "-print(r)", "+print((sum(P[:K])))" ]
false
0.058382
0.037188
1.569906
[ "s768880397", "s516930353" ]
u670180528
p03674
python
s806015424
s075227631
340
260
21,468
16,228
Accepted
Accepted
23.53
from collections import Counter n,*a = list(map(int,open(0).read().split())) dbl = Counter(a).most_common()[0][0] l,r = [i for i,j in enumerate(a) if j==dbl] const = n+l-r m = n + 1 mod = 10**9+7 fac = [1]*(m+1) inv = [1]*(m+1) for i in range(1,m+1): fac[i] = fac[i-1] * i % mod inv[-1] = pow(fac[-1], mod - ...
def main(): n,*a = list(map(int,open(0).read().split())) dbl = sum(a)-n*(n+1)//2 l,r = [i for i,j in enumerate(a) if j==dbl] const = n+l-r m = n + 1 mod = 10**9+7 fac = [1]*(m+1) inv = [1]*(m+1) for i in range(1,m+1): fac[i] = fac[i-1] * i % mod inv[-1] = pow(fac[-1], mod - 2, mod) for i in ran...
19
20
527
544
from collections import Counter n, *a = list(map(int, open(0).read().split())) dbl = Counter(a).most_common()[0][0] l, r = [i for i, j in enumerate(a) if j == dbl] const = n + l - r m = n + 1 mod = 10**9 + 7 fac = [1] * (m + 1) inv = [1] * (m + 1) for i in range(1, m + 1): fac[i] = fac[i - 1] * i % mod inv[-1] = p...
def main(): n, *a = list(map(int, open(0).read().split())) dbl = sum(a) - n * (n + 1) // 2 l, r = [i for i, j in enumerate(a) if j == dbl] const = n + l - r m = n + 1 mod = 10**9 + 7 fac = [1] * (m + 1) inv = [1] * (m + 1) for i in range(1, m + 1): fac[i] = fac[i - 1] * i % m...
false
5
[ "-from collections import Counter", "+def main():", "+ n, *a = list(map(int, open(0).read().split()))", "+ dbl = sum(a) - n * (n + 1) // 2", "+ l, r = [i for i, j in enumerate(a) if j == dbl]", "+ const = n + l - r", "+ m = n + 1", "+ mod = 10**9 + 7", "+ fac = [1] * (m + 1)", ...
false
0.132539
0.038777
3.417968
[ "s806015424", "s075227631" ]
u437860615
p02832
python
s304447956
s496123094
206
166
25,716
26,268
Accepted
Accepted
19.42
n = int(eval(input())) array = list(map(int, input().split())) bt = 0 #break times i = 0 j = 0 #iterator while i < n: while j < n: if array[j] == i+1: bt += 1 break else: if j == n-1: if i == 0: bt = -1 i = n+1 j = n+1 ...
n = int(eval(input())) a = list(map(int, input().split())) i = 0 j = 0 bt = 0 while i < n: while j < n - i: if a[i+j] == i+1: bt += 1 break if j + i == n-1: if i == 0: bt = -1 j = n + 1 i = n + 1 j += 1 i += 1 if bt != -1: bt = n ...
32
25
476
333
n = int(eval(input())) array = list(map(int, input().split())) bt = 0 # break times i = 0 j = 0 # iterator while i < n: while j < n: if array[j] == i + 1: bt += 1 break else: if j == n - 1: if i == 0: bt = -1 ...
n = int(eval(input())) a = list(map(int, input().split())) i = 0 j = 0 bt = 0 while i < n: while j < n - i: if a[i + j] == i + 1: bt += 1 break if j + i == n - 1: if i == 0: bt = -1 j = n + 1 i = n + 1 j += 1 i +...
false
21.875
[ "-array = list(map(int, input().split()))", "-bt = 0 # break times", "+a = list(map(int, input().split()))", "-j = 0 # iterator", "+j = 0", "+bt = 0", "- while j < n:", "- if array[j] == i + 1:", "+ while j < n - i:", "+ if a[i + j] == i + 1:", "- else:", "- ...
false
0.0703
0.100225
0.701422
[ "s304447956", "s496123094" ]
u729133443
p02760
python
s647302514
s129256959
26
18
3,060
3,064
Accepted
Accepted
30.77
f=lambda a:any(all(b)for b in a)|all(a[i][i]for i in(0,1,2)) a=eval('list(map(int,input().split())),'*3) exec('b=int(input());a=[[u*(u!=b)for u in t]for t in a];'*int(eval(input()))) a=[[not u for u in t]for t in a] print(('NYoe s'[f(a)|f([t[::-1]for t in zip(*a)])::2]))
f=lambda a:any(all(b)for b in a)|all(a[i][i]for i in(0,1,2)) *t,=list(map(int,open(0).read().split())) a=t[:9] s=eval('[0]*3,'*3) for b in t[10:]: if b in a: i=a.index(b) s[i//3][i%3]=1 print(('NYoe s'[f(s)|f([t[::-1]for t in zip(*s)])::2]))
5
9
270
251
f = lambda a: any(all(b) for b in a) | all(a[i][i] for i in (0, 1, 2)) a = eval("list(map(int,input().split()))," * 3) exec("b=int(input());a=[[u*(u!=b)for u in t]for t in a];" * int(eval(input()))) a = [[not u for u in t] for t in a] print(("NYoe s"[f(a) | f([t[::-1] for t in zip(*a)]) :: 2]))
f = lambda a: any(all(b) for b in a) | all(a[i][i] for i in (0, 1, 2)) (*t,) = list(map(int, open(0).read().split())) a = t[:9] s = eval("[0]*3," * 3) for b in t[10:]: if b in a: i = a.index(b) s[i // 3][i % 3] = 1 print(("NYoe s"[f(s) | f([t[::-1] for t in zip(*s)]) :: 2]))
false
44.444444
[ "-a = eval(\"list(map(int,input().split())),\" * 3)", "-exec(\"b=int(input());a=[[u*(u!=b)for u in t]for t in a];\" * int(eval(input())))", "-a = [[not u for u in t] for t in a]", "-print((\"NYoe s\"[f(a) | f([t[::-1] for t in zip(*a)]) :: 2]))", "+(*t,) = list(map(int, open(0).read().split()))", "+a = t[...
false
0.03202
0.061629
0.519559
[ "s647302514", "s129256959" ]
u901582103
p02684
python
s745207459
s757471415
209
158
32,280
32,216
Accepted
Accepted
24.4
n,k=list(map(int,input().split())) A=list(map(int,input().split())) C=[0]+[-1]*(n-1) p=1 c=0 s=-1 e=-1 for i in range(n): p=A[p-1] c+=1 if C[p-1]==-1: C[p-1]=c else: s=C[p-1] e=c break P=1 if s!=-1 and e!=-1: if k<=s: while k>0: ...
n,k=list(map(int,input().split())) A=list(map(int,input().split())) p=1 if k<=n: for i in range(k): p=A[p-1] print(p) else: D=[0]+[-1]*(n-1) for i in range(n): p=A[p-1] if D[p-1]==-1: D[p-1]=i+1 else: l=D[p-1] r=i+1-D[p-1...
39
22
640
424
n, k = list(map(int, input().split())) A = list(map(int, input().split())) C = [0] + [-1] * (n - 1) p = 1 c = 0 s = -1 e = -1 for i in range(n): p = A[p - 1] c += 1 if C[p - 1] == -1: C[p - 1] = c else: s = C[p - 1] e = c break P = 1 if s != -1 and e != -1: if k <= s:...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) p = 1 if k <= n: for i in range(k): p = A[p - 1] print(p) else: D = [0] + [-1] * (n - 1) for i in range(n): p = A[p - 1] if D[p - 1] == -1: D[p - 1] = i + 1 else: l = D[p - ...
false
43.589744
[ "-C = [0] + [-1] * (n - 1)", "-c = 0", "-s = -1", "-e = -1", "-for i in range(n):", "- p = A[p - 1]", "- c += 1", "- if C[p - 1] == -1:", "- C[p - 1] = c", "- else:", "- s = C[p - 1]", "- e = c", "- break", "-P = 1", "-if s != -1 and e != -1:", "...
false
0.046103
0.048513
0.95032
[ "s745207459", "s757471415" ]
u995062424
p03161
python
s038218428
s105187544
1,988
1,624
13,980
20,552
Accepted
Accepted
18.31
def main(): N, K = list(map(int, input().split())) h = list(map(int, input().split())) DP = [0]*N DP[1] = abs(h[1]-h[0]) for i in range(2, N): DP[i] = min(abs(h[i]-h[j]) + DP[j] for j in range(max(0, i-K), i)) print((DP[-1])) main()
def main(): N, K = list(map(int, input().split())) h = list(map(int, input().split())) DP = [10**10 for _ in range(N)] DP[0] = 0 DP[1] = abs(h[0]-h[1]) for i in range(2, N): DP[i] = min(DP[k]+abs(h[i]-h[k]) for k in range(max(0, i-K), i)) print((DP[N-1])) main()
12
12
274
311
def main(): N, K = list(map(int, input().split())) h = list(map(int, input().split())) DP = [0] * N DP[1] = abs(h[1] - h[0]) for i in range(2, N): DP[i] = min(abs(h[i] - h[j]) + DP[j] for j in range(max(0, i - K), i)) print((DP[-1])) main()
def main(): N, K = list(map(int, input().split())) h = list(map(int, input().split())) DP = [10**10 for _ in range(N)] DP[0] = 0 DP[1] = abs(h[0] - h[1]) for i in range(2, N): DP[i] = min(DP[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)) print((DP[N - 1])) main()
false
0
[ "- DP = [0] * N", "- DP[1] = abs(h[1] - h[0])", "+ DP = [10**10 for _ in range(N)]", "+ DP[0] = 0", "+ DP[1] = abs(h[0] - h[1])", "- DP[i] = min(abs(h[i] - h[j]) + DP[j] for j in range(max(0, i - K), i))", "- print((DP[-1]))", "+ DP[i] = min(DP[k] + abs(h[i] - h[k]) for...
false
0.041678
0.037719
1.104959
[ "s038218428", "s105187544" ]
u587518324
p02676
python
s594134148
s678143297
24
22
9,136
9,028
Accepted
Accepted
8.33
#!/usr/bin/env python """AtCoder Beginner Contest 168: B - https://atcoder.jp/contests/abc168/tasks/abc168_b """ __author__ = 'bugttle <bugttle@gmail.com>' def main(): K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) else: print(("{}...".format(S[0:K]...
#!/usr/bin/env python """AtCoder Beginner Contest 168: B - ... (Triple Dots) https://atcoder.jp/contests/abc168/tasks/abc168_b """ def main(): K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) else: print(("{}...".format(S[0:K]))) if __name__ == '__ma...
19
18
352
325
#!/usr/bin/env python """AtCoder Beginner Contest 168: B - https://atcoder.jp/contests/abc168/tasks/abc168_b """ __author__ = "bugttle <bugttle@gmail.com>" def main(): K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) else: print(("{}...".format(S[0:K]))) if __name__...
#!/usr/bin/env python """AtCoder Beginner Contest 168: B - ... (Triple Dots) https://atcoder.jp/contests/abc168/tasks/abc168_b """ def main(): K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) else: print(("{}...".format(S[0:K]))) if __name__ == "__main__": main()...
false
5.263158
[ "-\"\"\"AtCoder Beginner Contest 168: B -", "+\"\"\"AtCoder Beginner Contest 168: B - ... (Triple Dots)", "-__author__ = \"bugttle <bugttle@gmail.com>\"" ]
false
0.043845
0.044374
0.988092
[ "s594134148", "s678143297" ]
u489959379
p03147
python
s897038815
s048191111
255
232
3,060
3,064
Accepted
Accepted
9.02
n = int(eval(input())) h = list(map(int, input().split())) res = 0 i = 0 while sum(h) != 0: if h[i] != 0: while i < n and h[i] != 0: h[i] -= 1 i += 1 res += 1 i = 0 else: i += 1 print(res)
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) H = list(map(int, input().split())) res = 0 i = 0 while sum(H) != 0: if H[i] != 0: while i < n and H[i] != 0: ...
16
29
264
502
n = int(eval(input())) h = list(map(int, input().split())) res = 0 i = 0 while sum(h) != 0: if h[i] != 0: while i < n and h[i] != 0: h[i] -= 1 i += 1 res += 1 i = 0 else: i += 1 print(res)
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) H = list(map(int, input().split())) res = 0 i = 0 while sum(H) != 0: if H[i] != 0: while i < n and H[i] != 0: H[i] -= 1...
false
44.827586
[ "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-res = 0", "-i = 0", "-while sum(h) != 0:", "- if h[i] != 0:", "- while i < n and h[i] != 0:", "- h[i] -= 1", "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+input = sys.stdin.readline", "+f_inf =...
false
0.036996
0.035485
1.042584
[ "s897038815", "s048191111" ]
u350093546
p02678
python
s563573228
s642976415
1,400
480
34,728
98,628
Accepted
Accepted
65.71
n,m=list(map(int,input().split())) lst=[[] for i in range(n)] visited=[False for i in range(n)] ans=[0]*n for i in range(m): a,b=list(map(int,input().split())) lst[a-1].append(b-1) lst[b-1].append(a-1) Q=[0] visited[0]=True while Q: v=Q.pop(0) for i in lst[v]: if visited...
#ABC168D from collections import deque n,m=list(map(int,input().split())) lst=[[] for i in range(n)] visited=[False for i in range(n)] ans=[0]*n for i in range(m): a,b=list(map(int,input().split())) lst[a-1].append(b-1) lst[b-1].append(a-1) Q=deque() Q.append((0)) visited[0]=True ...
25
29
464
531
n, m = list(map(int, input().split())) lst = [[] for i in range(n)] visited = [False for i in range(n)] ans = [0] * n for i in range(m): a, b = list(map(int, input().split())) lst[a - 1].append(b - 1) lst[b - 1].append(a - 1) Q = [0] visited[0] = True while Q: v = Q.pop(0) for i in lst[v]: i...
# ABC168D from collections import deque n, m = list(map(int, input().split())) lst = [[] for i in range(n)] visited = [False for i in range(n)] ans = [0] * n for i in range(m): a, b = list(map(int, input().split())) lst[a - 1].append(b - 1) lst[b - 1].append(a - 1) Q = deque() Q.append((0)) visited[0] = Tr...
false
13.793103
[ "+# ABC168D", "+from collections import deque", "+", "-Q = [0]", "+Q = deque()", "+Q.append((0))", "- v = Q.pop(0)", "+ v = Q.popleft()", "- Q.append(i)", "+ Q.append((i))" ]
false
0.077823
0.036272
2.145567
[ "s563573228", "s642976415" ]
u040298438
p03262
python
s243478978
s378943989
101
82
25,640
25,684
Accepted
Accepted
18.81
from math import gcd from functools import reduce _, X = list(map(int, input().split())) x = set(map(int, input().split())) x.add(X) x = sorted(x) print((reduce(gcd, (j - i for i, j in zip(x[:-1], x[1:])))))
from math import gcd from functools import reduce _, X = list(map(int, input().split())) print((reduce(gcd, (abs(i - X) for i in set(map(int, input().split()))))))
8
5
207
160
from math import gcd from functools import reduce _, X = list(map(int, input().split())) x = set(map(int, input().split())) x.add(X) x = sorted(x) print((reduce(gcd, (j - i for i, j in zip(x[:-1], x[1:])))))
from math import gcd from functools import reduce _, X = list(map(int, input().split())) print((reduce(gcd, (abs(i - X) for i in set(map(int, input().split()))))))
false
37.5
[ "-x = set(map(int, input().split()))", "-x.add(X)", "-x = sorted(x)", "-print((reduce(gcd, (j - i for i, j in zip(x[:-1], x[1:])))))", "+print((reduce(gcd, (abs(i - X) for i in set(map(int, input().split()))))))" ]
false
0.043575
0.040662
1.071632
[ "s243478978", "s378943989" ]
u729133443
p02999
python
s330745162
s372967819
165
17
38,256
2,940
Accepted
Accepted
89.7
x,_,a=eval(input());print((10*(x>=a)))
s=eval(input());print((10*(s>s[2])))
1
1
30
28
x, _, a = eval(input()) print((10 * (x >= a)))
s = eval(input()) print((10 * (s > s[2])))
false
0
[ "-x, _, a = eval(input())", "-print((10 * (x >= a)))", "+s = eval(input())", "+print((10 * (s > s[2])))" ]
false
0.037701
0.039676
0.950206
[ "s330745162", "s372967819" ]