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
u222668979
p02691
python
s160642180
s912075110
216
190
61,400
61,324
Accepted
Accepted
12.04
from collections import Counter import sys input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) minus = Counter([i-a[i] for i in range(n)]) plus = Counter([i+a[i] for i in range(n)]) cnt = 0 for i in minus: if i in plus: cnt += minus[i] * plus[i] print(cnt)
from collections import Counter import sys input = sys.stdin.readline n: int = int(eval(input())) a = list(map(int, input().split())) minus = Counter([i-a[i] for i in range(n)]) plus = Counter([i+a[i] for i in range(n)]) cnt: int = 0 i: int for i in minus: if i in plus: cnt += minus[i] * plus...
14
15
312
330
from collections import Counter import sys input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) minus = Counter([i - a[i] for i in range(n)]) plus = Counter([i + a[i] for i in range(n)]) cnt = 0 for i in minus: if i in plus: cnt += minus[i] * plus[i] print(cnt)
from collections import Counter import sys input = sys.stdin.readline n: int = int(eval(input())) a = list(map(int, input().split())) minus = Counter([i - a[i] for i in range(n)]) plus = Counter([i + a[i] for i in range(n)]) cnt: int = 0 i: int for i in minus: if i in plus: cnt += minus[i] * plus[i] print(...
false
6.666667
[ "-n = int(eval(input()))", "+n: int = int(eval(input()))", "-cnt = 0", "+cnt: int = 0", "+i: int" ]
false
0.040286
0.041379
0.973581
[ "s160642180", "s912075110" ]
u504836877
p03801
python
s383284990
s051032580
584
282
77,284
14,208
Accepted
Accepted
51.71
N = int(eval(input())) A = [int(a) for a in input().split()] S = sum(A) for i in range(N): A[i] = [A[i], i+1] A.sort(reverse=True) ans = [0]*(N+1) i = 0 num = N+1 while i < N-1: num = min(num, A[i][1]) while i < N-1 and A[i][0] == A[i+1][0]: num = min(num, A[i+1][1]) i += 1 ...
N = int(eval(input())) A = [int(a) for a in input().split()] ans = [0]*N num = 0 B = sorted(A) j = 0 for i in range(N): cnt = 0 while j < N and B[j] <= A[i]: cnt += max(0, B[j]-num) j += 1 ans[i] = cnt + max(0, (N-j)*(A[i]-num)) num = max(num, A[i]) for a in ans: pr...
24
17
469
320
N = int(eval(input())) A = [int(a) for a in input().split()] S = sum(A) for i in range(N): A[i] = [A[i], i + 1] A.sort(reverse=True) ans = [0] * (N + 1) i = 0 num = N + 1 while i < N - 1: num = min(num, A[i][1]) while i < N - 1 and A[i][0] == A[i + 1][0]: num = min(num, A[i + 1][1]) i += 1 ...
N = int(eval(input())) A = [int(a) for a in input().split()] ans = [0] * N num = 0 B = sorted(A) j = 0 for i in range(N): cnt = 0 while j < N and B[j] <= A[i]: cnt += max(0, B[j] - num) j += 1 ans[i] = cnt + max(0, (N - j) * (A[i] - num)) num = max(num, A[i]) for a in ans: print(a)
false
29.166667
[ "-S = sum(A)", "+ans = [0] * N", "+num = 0", "+B = sorted(A)", "+j = 0", "- A[i] = [A[i], i + 1]", "-A.sort(reverse=True)", "-ans = [0] * (N + 1)", "-i = 0", "-num = N + 1", "-while i < N - 1:", "- num = min(num, A[i][1])", "- while i < N - 1 and A[i][0] == A[i + 1][0]:", "- ...
false
0.085462
0.007799
10.957712
[ "s383284990", "s051032580" ]
u809819902
p02981
python
s742475176
s981220918
29
24
9,156
9,064
Accepted
Accepted
17.24
n,a,b = list(map(int, input().split())) den = n * a tax = b print((tax if tax<den else den))
n,a,b=list(map(int,input().split())) print((min(a*n,b)))
4
2
87
49
n, a, b = list(map(int, input().split())) den = n * a tax = b print((tax if tax < den else den))
n, a, b = list(map(int, input().split())) print((min(a * n, b)))
false
50
[ "-den = n * a", "-tax = b", "-print((tax if tax < den else den))", "+print((min(a * n, b)))" ]
false
0.040897
0.042549
0.961154
[ "s742475176", "s981220918" ]
u762199573
p02887
python
s324719391
s502307819
47
43
4,668
3,316
Accepted
Accepted
8.51
N = int(eval(input())) S = list(eval(input())) + ['end'] cnt = 0 for i in range(N): if S[i] != S[i+1]: cnt += 1 print(cnt)
N = int(eval(input())) S = eval(input()) cnt = 0 for i in range(1, N): if S[i] != S[i-1]: cnt += 1 print((cnt+1))
8
7
130
118
N = int(eval(input())) S = list(eval(input())) + ["end"] cnt = 0 for i in range(N): if S[i] != S[i + 1]: cnt += 1 print(cnt)
N = int(eval(input())) S = eval(input()) cnt = 0 for i in range(1, N): if S[i] != S[i - 1]: cnt += 1 print((cnt + 1))
false
12.5
[ "-S = list(eval(input())) + [\"end\"]", "+S = eval(input())", "-for i in range(N):", "- if S[i] != S[i + 1]:", "+for i in range(1, N):", "+ if S[i] != S[i - 1]:", "-print(cnt)", "+print((cnt + 1))" ]
false
0.041117
0.039353
1.044819
[ "s324719391", "s502307819" ]
u729133443
p04029
python
s905547157
s666533247
35
17
27,884
2,940
Accepted
Accepted
51.43
n=eval(input());print((n*-~n/2))
n=int(eval(input())) print((n*-~n//2))
1
2
24
31
n = eval(input()) print((n * -~n / 2))
n = int(eval(input())) print((n * -~n // 2))
false
50
[ "-n = eval(input())", "-print((n * -~n / 2))", "+n = int(eval(input()))", "+print((n * -~n // 2))" ]
false
0.036027
0.061493
0.585875
[ "s905547157", "s666533247" ]
u747703115
p03944
python
s380619083
s563367756
282
17
21,552
3,064
Accepted
Accepted
93.97
import numpy as np w, h, n = list(map(int, input().split())) box = np.ones((h, w)) for i in range(n): x, y, a = list(map(int, input().split())) if a==1: box[:, :x] = 0 elif a==2: box[:, x:] = 0 elif a==3: box[:y, :] = 0 elif a==4: box[y:, :] = 0 print((su...
w, h, n = list(map(int, input().split())) y0 = 0 y1 = h x0 = 0 x1 = w for i in range(n): x, y, a = list(map(int, input().split())) if a==1: x0 = max(x0, x) elif a==2: x1 = min(x1, x) elif a==3: y0 = max(y0, y) elif a==4: y1 = min(y1, y) if (x1-x0>0) and...
14
19
319
368
import numpy as np w, h, n = list(map(int, input().split())) box = np.ones((h, w)) for i in range(n): x, y, a = list(map(int, input().split())) if a == 1: box[:, :x] = 0 elif a == 2: box[:, x:] = 0 elif a == 3: box[:y, :] = 0 elif a == 4: box[y:, :] = 0 print((sum(su...
w, h, n = list(map(int, input().split())) y0 = 0 y1 = h x0 = 0 x1 = w for i in range(n): x, y, a = list(map(int, input().split())) if a == 1: x0 = max(x0, x) elif a == 2: x1 = min(x1, x) elif a == 3: y0 = max(y0, y) elif a == 4: y1 = min(y1, y) if (x1 - x0 > 0) and (y...
false
26.315789
[ "-import numpy as np", "-", "-box = np.ones((h, w))", "+y0 = 0", "+y1 = h", "+x0 = 0", "+x1 = w", "- box[:, :x] = 0", "+ x0 = max(x0, x)", "- box[:, x:] = 0", "+ x1 = min(x1, x)", "- box[:y, :] = 0", "+ y0 = max(y0, y)", "- box[y:, :] = 0", ...
false
0.318044
0.036257
8.772034
[ "s380619083", "s563367756" ]
u816631826
p03556
python
s692551904
s686969871
29
17
2,940
3,060
Accepted
Accepted
41.38
n = int(eval(input())) ma = 0 while (ma+1)**2 <= n: ma += 1 print((ma**2))
y = int(eval(input())) p = (pow(y , 0.5)) print((pow(int(p) , 2)))
5
3
74
60
n = int(eval(input())) ma = 0 while (ma + 1) ** 2 <= n: ma += 1 print((ma**2))
y = int(eval(input())) p = pow(y, 0.5) print((pow(int(p), 2)))
false
40
[ "-n = int(eval(input()))", "-ma = 0", "-while (ma + 1) ** 2 <= n:", "- ma += 1", "-print((ma**2))", "+y = int(eval(input()))", "+p = pow(y, 0.5)", "+print((pow(int(p), 2)))" ]
false
0.067316
0.060854
1.106186
[ "s692551904", "s686969871" ]
u189487046
p03208
python
s210992641
s984997429
250
159
7,504
7,472
Accepted
Accepted
36.4
n, k = list(map(int, input().split())) tree = [] for _ in range(n): tree.append(int(eval(input()))) tree.sort() ans = 10**9 for i in range(n-k+1): ans = min(ans, tree[i+k-1]-tree[i]) print(ans)
import sys sys.setrecursionlimit(10 ** 6) def input(): return sys.stdin.readline()[:-1] N, K = list(map(int, input().split())) H = [0]*N for i in range(N): H[i] = int(eval(input())) H.sort() ans = 10**10 for i in range(N-(K-1)): ans = min(ans, H[i+(K-1)]-H[i]) print(ans)
11
18
202
294
n, k = list(map(int, input().split())) tree = [] for _ in range(n): tree.append(int(eval(input()))) tree.sort() ans = 10**9 for i in range(n - k + 1): ans = min(ans, tree[i + k - 1] - tree[i]) print(ans)
import sys sys.setrecursionlimit(10**6) def input(): return sys.stdin.readline()[:-1] N, K = list(map(int, input().split())) H = [0] * N for i in range(N): H[i] = int(eval(input())) H.sort() ans = 10**10 for i in range(N - (K - 1)): ans = min(ans, H[i + (K - 1)] - H[i]) print(ans)
false
38.888889
[ "-n, k = list(map(int, input().split()))", "-tree = []", "-for _ in range(n):", "- tree.append(int(eval(input())))", "-tree.sort()", "-ans = 10**9", "-for i in range(n - k + 1):", "- ans = min(ans, tree[i + k - 1] - tree[i])", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+", "...
false
0.0375
0.080293
0.467035
[ "s210992641", "s984997429" ]
u034128150
p02558
python
s592837952
s832586166
396
260
113,004
76,160
Accepted
Accepted
34.34
class UnionFind(): "Either 0-indexed or 1-indexed" __slots__ = ["parent"] def __init__(self, size): self.parent = [-1] * (size + 1) def find(self, a): path = [] while self.parent[a] > 0: path.append(a) a = self.parent[a] for chi...
class UnionFind(): "Either 0-indexed or 1-indexed" __slots__ = ["parent"] def __init__(self, size): self.parent = [-1] * (size + 1) def find(self, a): path = [] while self.parent[a] > 0: path.append(a) a = self.parent[a] for chi...
54
54
1,321
1,293
class UnionFind: "Either 0-indexed or 1-indexed" __slots__ = ["parent"] def __init__(self, size): self.parent = [-1] * (size + 1) def find(self, a): path = [] while self.parent[a] > 0: path.append(a) a = self.parent[a] for child in path: ...
class UnionFind: "Either 0-indexed or 1-indexed" __slots__ = ["parent"] def __init__(self, size): self.parent = [-1] * (size + 1) def find(self, a): path = [] while self.parent[a] > 0: path.append(a) a = self.parent[a] for child in path: ...
false
0
[ "- tuvs = list(map(int, sys.stdin.buffer.read().split()))", "- for t, u, v in zip(tuvs, tuvs, tuvs):", "+ for _ in range(Q):", "+ t, u, v = list(map(int, input().split()))" ]
false
0.039741
0.037345
1.064136
[ "s592837952", "s832586166" ]
u606045429
p02973
python
s915771458
s525285596
1,428
1,116
25,228
25,040
Accepted
Accepted
21.85
class BIT: def __init__(self, N): self.size = N self.tree = [0] * (N + 1) self.MSB = 1 << (N.bit_length() - 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): whil...
class BIT: def __init__(self, N): self.size = N self.tree = [0] * (N + 1) self.bisect_K = [1 << k for k in reversed(list(range(N.bit_length())))] def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s ...
42
41
981
955
class BIT: def __init__(self, N): self.size = N self.tree = [0] * (N + 1) self.MSB = 1 << (N.bit_length() - 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.si...
class BIT: def __init__(self, N): self.size = N self.tree = [0] * (N + 1) self.bisect_K = [1 << k for k in reversed(list(range(N.bit_length())))] def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self...
false
2.380952
[ "- self.MSB = 1 << (N.bit_length() - 1)", "+ self.bisect_K = [1 << k for k in reversed(list(range(N.bit_length())))]", "- K = N.bit_length()", "- for k in (1 << k for k in reversed(list(range(K)))):", "+ for k in self.bisect_K:", "- w -= bit[i + k]", "+ ...
false
0.036705
0.036311
1.010855
[ "s915771458", "s525285596" ]
u480138356
p03045
python
s079132439
s351393210
797
734
41,460
32,884
Accepted
Accepted
7.9
class Node: def __init__(self, val): self.num = val self.val = val self.is_parent = True self.parent = None self.childs = [] def show(self): print(self.num, end=" ") print(self.is_parent, end=" ") for child in self.childs: ...
class Node: def __init__(self, val): self.num = val self.val = val self.is_parent = True self.parent = None def root(node): depth = 0 while node.parent != None: node = node.parent depth += 1 return node, depth N, M = list(map(int, input().s...
51
41
1,318
998
class Node: def __init__(self, val): self.num = val self.val = val self.is_parent = True self.parent = None self.childs = [] def show(self): print(self.num, end=" ") print(self.is_parent, end=" ") for child in self.childs: print(child....
class Node: def __init__(self, val): self.num = val self.val = val self.is_parent = True self.parent = None def root(node): depth = 0 while node.parent != None: node = node.parent depth += 1 return node, depth N, M = list(map(int, input().split())) roo...
false
19.607843
[ "- self.childs = []", "-", "- def show(self):", "- print(self.num, end=\" \")", "- print(self.is_parent, end=\" \")", "- for child in self.childs:", "- print(child.num, end=\" \")", "-N, M = map(int, input().split())", "+N, M = list(map(int, input().split())...
false
0.069577
0.127611
0.545231
[ "s079132439", "s351393210" ]
u905203728
p03944
python
s327440815
s628999560
373
71
21,008
3,188
Accepted
Accepted
80.97
import numpy as np W,H,N=list(map(int,input().split())) MAP=[[0 for i in range(W)] for j in range(H)] command=[list(map(int,input().split())) for i in range(N)] for x,y,a in command: if a==1: for i in range(H): for j in range(x): MAP[i][j]=1 elif a==2: for i...
W,H,N=list(map(int,input().split())) MAP=[[0 for i in range(W)] for j in range(H)] command=[list(map(int,input().split())) for i in range(N)] for x,y,a in command: if a==1: for i in range(H): for j in range(x):MAP[i][j]=1 elif a==2: for i in range(H): for j in ra...
26
20
686
571
import numpy as np W, H, N = list(map(int, input().split())) MAP = [[0 for i in range(W)] for j in range(H)] command = [list(map(int, input().split())) for i in range(N)] for x, y, a in command: if a == 1: for i in range(H): for j in range(x): MAP[i][j] = 1 elif a == 2: ...
W, H, N = list(map(int, input().split())) MAP = [[0 for i in range(W)] for j in range(H)] command = [list(map(int, input().split())) for i in range(N)] for x, y, a in command: if a == 1: for i in range(H): for j in range(x): MAP[i][j] = 1 elif a == 2: for i in range(H...
false
23.076923
[ "-import numpy as np", "-", "-# print(np.array(MAP))" ]
false
0.036633
0.036561
1.001953
[ "s327440815", "s628999560" ]
u790710233
p02863
python
s023208312
s379570025
290
158
145,884
74,864
Accepted
Accepted
45.52
n, W = list(map(int, input().split())) ab = [tuple(map(int, input().split()))for _ in range(n)] ab.sort() dp = [[0]*W for _ in range(n+1)] for i in range(1, n+1): w, v = ab[i-1] for j in range(W): if dp[i][j] < dp[i-1][j]: dp[i][j] = dp[i-1][j] if 0 <= j-w and dp[i][j] <...
n, W = list(map(int, input().split())) ab = [tuple(map(int, input().split()))for _ in range(n)] ab.sort() ans = 0 dp = [0]*W for a, b in ab: if ans < dp[-1]+b: ans = dp[-1]+b for j in reversed(list(range(W))): if j-a < 0: break if dp[j] < dp[j-a]+b: ...
21
15
489
338
n, W = list(map(int, input().split())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort() dp = [[0] * W for _ in range(n + 1)] for i in range(1, n + 1): w, v = ab[i - 1] for j in range(W): if dp[i][j] < dp[i - 1][j]: dp[i][j] = dp[i - 1][j] if 0 <= j - w and dp[i][j]...
n, W = list(map(int, input().split())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort() ans = 0 dp = [0] * W for a, b in ab: if ans < dp[-1] + b: ans = dp[-1] + b for j in reversed(list(range(W))): if j - a < 0: break if dp[j] < dp[j - a] + b: d...
false
28.571429
[ "-dp = [[0] * W for _ in range(n + 1)]", "-for i in range(1, n + 1):", "- w, v = ab[i - 1]", "- for j in range(W):", "- if dp[i][j] < dp[i - 1][j]:", "- dp[i][j] = dp[i - 1][j]", "- if 0 <= j - w and dp[i][j] < dp[i - 1][j - w] + v:", "- dp[i][j] = dp[i - 1][j...
false
0.087809
0.071007
1.236629
[ "s023208312", "s379570025" ]
u037430802
p03816
python
s649296789
s750505369
95
66
23,676
21,076
Accepted
Accepted
30.53
n = int(eval(input())) a = list(map(int, input().split())) set_a = set(a) nums = {} cnt = 0 for i in range(n): nums[a[i]] = nums.get(a[i], 0) + 1 for i in set_a: if nums[i] % 2 == 0: cnt += 1 elif nums[i] != 1: cnt += 2 print((len(set_a) - cnt%2))
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) c = Counter(A) cnt = 0 for v in list(c.values()): cnt += v - 1 ans = len(set(A)) if cnt % 2 == 0 else len(set(A)) - 1 if ans == 0: ans = 1 print(ans)
18
13
289
248
n = int(eval(input())) a = list(map(int, input().split())) set_a = set(a) nums = {} cnt = 0 for i in range(n): nums[a[i]] = nums.get(a[i], 0) + 1 for i in set_a: if nums[i] % 2 == 0: cnt += 1 elif nums[i] != 1: cnt += 2 print((len(set_a) - cnt % 2))
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) c = Counter(A) cnt = 0 for v in list(c.values()): cnt += v - 1 ans = len(set(A)) if cnt % 2 == 0 else len(set(A)) - 1 if ans == 0: ans = 1 print(ans)
false
27.777778
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-set_a = set(a)", "-nums = {}", "+from collections import Counter", "+", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+c = Counter(A)", "-for i in range(n):", "- nums[a[i]] = nums.get(a[i], 0) + 1", "...
false
0.045516
0.041919
1.085802
[ "s649296789", "s750505369" ]
u747602774
p03295
python
s820798468
s603809864
580
434
27,872
29,084
Accepted
Accepted
25.17
n,m = list(map(int,input().split())) ab = [list(map(int,input().split())) for i in range(m)] ab.sort() l,r = ab[0][0],ab[0][1]-1 ans = 1 for i in range(1,m): l = max(l,ab[i][0]) r = min(r,ab[i][1]-1) if l > r: ans += 1 l,r = ab[i][0],ab[i][1]-1 print(ans)
N,M = list(map(int,input().split())) AB = [list(map(int,input().split())) for _ in range(M)] AB.sort(key=lambda x: x[1]) ans = 1 t = AB[0][1]-1 for i in range(M): if t < AB[i][0]: t = AB[i][1]-1 ans += 1 print(ans)
16
12
296
242
n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for i in range(m)] ab.sort() l, r = ab[0][0], ab[0][1] - 1 ans = 1 for i in range(1, m): l = max(l, ab[i][0]) r = min(r, ab[i][1] - 1) if l > r: ans += 1 l, r = ab[i][0], ab[i][1] - 1 print(ans)
N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for _ in range(M)] AB.sort(key=lambda x: x[1]) ans = 1 t = AB[0][1] - 1 for i in range(M): if t < AB[i][0]: t = AB[i][1] - 1 ans += 1 print(ans)
false
25
[ "-n, m = list(map(int, input().split()))", "-ab = [list(map(int, input().split())) for i in range(m)]", "-ab.sort()", "-l, r = ab[0][0], ab[0][1] - 1", "+N, M = list(map(int, input().split()))", "+AB = [list(map(int, input().split())) for _ in range(M)]", "+AB.sort(key=lambda x: x[1])", "-for i in ran...
false
0.045653
0.043801
1.042286
[ "s820798468", "s603809864" ]
u644907318
p02804
python
s272773654
s985863336
286
161
77,488
100,980
Accepted
Accepted
43.71
def pow(x,m): if m==0: return 1 if m==1: return x if m%2==0: return (pow(x,m//2)**2)%p else: return (x*(pow(x,(m-1)//2)**2)%p)%p p = 10**9+7 N,K = list(map(int,input().split())) F = [1 for _ in range(N)] for i in range(2,N): F[i] = (F[i-1]*i)%p IF = [1 f...
p = 10**9+7 def pow(x,m): if m==0: return 1 if m==1: return x if m%2==0: return (pow(x,m//2)**2)%p else: return (x*(pow(x,(m-1)//2)**2)%p)%p N,K = list(map(int,input().split())) Z = list(map(int,input().split())) A = [1 for _ in range(N+1)] for i in range(2,N...
27
33
665
743
def pow(x, m): if m == 0: return 1 if m == 1: return x if m % 2 == 0: return (pow(x, m // 2) ** 2) % p else: return (x * (pow(x, (m - 1) // 2) ** 2) % p) % p p = 10**9 + 7 N, K = list(map(int, input().split())) F = [1 for _ in range(N)] for i in range(2, N): F[i] = ...
p = 10**9 + 7 def pow(x, m): if m == 0: return 1 if m == 1: return x if m % 2 == 0: return (pow(x, m // 2) ** 2) % p else: return (x * (pow(x, (m - 1) // 2) ** 2) % p) % p N, K = list(map(int, input().split())) Z = list(map(int, input().split())) A = [1 for _ in range...
false
18.181818
[ "+p = 10**9 + 7", "+", "+", "-p = 10**9 + 7", "-F = [1 for _ in range(N)]", "-for i in range(2, N):", "- F[i] = (F[i - 1] * i) % p", "-IF = [1 for _ in range(N)]", "-IF[N - 1] = pow(F[N - 1], p - 2)", "-for i in range(N - 2, 1, -1):", "- IF[i] = (IF[i + 1] * (i + 1)) % p", "-A = sorted(l...
false
0.088813
0.086151
1.030896
[ "s272773654", "s985863336" ]
u506858457
p02814
python
s697992501
s697483143
172
122
15,060
16,320
Accepted
Accepted
29.07
n,m=list(map(int,input().split())) a=list(map(int,input().split())) def gcd(a,b): while b:a,b=b,a%b return a def lcm(a,b):return a*b//gcd(a,b) l=a[0]//2 ll=a[0] for i in range(1,n): if a[i]%2:odd=True else:even=True l=lcm(l,a[i]//2) ll=lcm(ll,a[i]) if l>m:print((0));exit() for i in range(n):...
'''ika tako 小数が出てくるとややこしいが、 bi=ai/2 として、 X=bi*(2p+1) としてしまえばいい。 これで、以下の2つを満たせばよいことがわかりやすくなる。 X は全ての bi の公倍数 X を bi で割った商は全て奇数 なので、とりあえず全ての bi の最小公倍数を求めて、それが bi で割ると全て奇数となるか確認する。 1つでも偶数となるものがあれば、達成不可能。 全て奇数なら、最小公倍数の奇数倍が全て条件を満たす。 2数 n,m の最小公倍数は、最大公約数を g として n*m/g で求められる。3数以上なら、これを繰り返し適用しつづ...
17
34
364
831
n, m = list(map(int, input().split())) a = list(map(int, input().split())) def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) l = a[0] // 2 ll = a[0] for i in range(1, n): if a[i] % 2: odd = True else: even = True l = lcm(l, a[...
"""ika tako 小数が出てくるとややこしいが、 bi=ai/2 として、 X=bi*(2p+1) としてしまえばいい。 これで、以下の2つを満たせばよいことがわかりやすくなる。 X は全ての bi の公倍数 X を bi で割った商は全て奇数 なので、とりあえず全ての bi の最小公倍数を求めて、それが bi で割ると全て奇数となるか確認する。 1つでも偶数となるものがあれば、達成不可能。 全て奇数なら、最小公倍数の奇数倍が全て条件を満たす。 2数 n,m の最小公倍数は、最大公約数を g として n*m/g で求められる。3数以上なら、これを繰り返し適用しつづければよい。 ただし ...
false
50
[ "-n, m = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "+\"\"\"ika tako", "+小数が出てくるとややこしいが、 bi=ai/2 として、", "+X=bi*(2p+1) としてしまえばいい。", "+これで、以下の2つを満たせばよいことがわかりやすくなる。", "+X は全ての bi の公倍数", "+X を bi で割った商は全て奇数", "+なので、とりあえず全ての bi の最小公倍数を求めて、それが", "+bi で割ると全て奇数となる...
false
0.155403
0.044305
3.507614
[ "s697992501", "s697483143" ]
u088063513
p03861
python
s177454744
s326146011
37
17
5,204
2,940
Accepted
Accepted
54.05
from decimal import * #exp = Decimal(10**23) #rint((Decimal(11)*exp)/Decimal(10)) ## coding: UTF-8 s = input().split() t = [int(p) for p in s] #print(t) a = t[0] b = t[1] x = t[2] ''' start = a goal = b while True: if(start % x == 0): break else: start += 1 #print(start) ...
a, b, x = list(map(int,input().split())) if(a%x == 0): A = a//x else: A = a//x + 1 B = b//x print((B-A+1))
44
9
838
116
from decimal import * # exp = Decimal(10**23) # rint((Decimal(11)*exp)/Decimal(10)) ## coding: UTF-8 s = input().split() t = [int(p) for p in s] # print(t) a = t[0] b = t[1] x = t[2] """ start = a goal = b while True: if(start % x == 0): break else: start += 1 #print(start) while True: if(g...
a, b, x = list(map(int, input().split())) if a % x == 0: A = a // x else: A = a // x + 1 B = b // x print((B - A + 1))
false
79.545455
[ "-from decimal import *", "-", "-# exp = Decimal(10**23)", "-# rint((Decimal(11)*exp)/Decimal(10))", "-## coding: UTF-8", "-s = input().split()", "-t = [int(p) for p in s]", "-# print(t)", "-a = t[0]", "-b = t[1]", "-x = t[2]", "-\"\"\"", "-start = a", "-goal = b", "-while True:", "- ...
false
0.045703
0.041908
1.090559
[ "s177454744", "s326146011" ]
u930705402
p02973
python
s939147691
s397973104
600
359
51,032
76,228
Accepted
Accepted
40.17
from collections import deque from bisect import bisect_left N=int(eval(input())) li=[] ans=0 for i in range(N): a=-int(eval(input())) b=bisect_left(li,a+1) if b==len(li): li.append(a) ans+=1 else: li[b]=a print(ans)
from collections import deque from bisect import bisect_left N=int(eval(input())) d=deque() for i in range(N): A=int(eval(input())) b=bisect_left(d,A)-1 if b==-1: d.appendleft(A) else: d[b]=A print((len(d)))
14
12
257
236
from collections import deque from bisect import bisect_left N = int(eval(input())) li = [] ans = 0 for i in range(N): a = -int(eval(input())) b = bisect_left(li, a + 1) if b == len(li): li.append(a) ans += 1 else: li[b] = a print(ans)
from collections import deque from bisect import bisect_left N = int(eval(input())) d = deque() for i in range(N): A = int(eval(input())) b = bisect_left(d, A) - 1 if b == -1: d.appendleft(A) else: d[b] = A print((len(d)))
false
14.285714
[ "-li = []", "-ans = 0", "+d = deque()", "- a = -int(eval(input()))", "- b = bisect_left(li, a + 1)", "- if b == len(li):", "- li.append(a)", "- ans += 1", "+ A = int(eval(input()))", "+ b = bisect_left(d, A) - 1", "+ if b == -1:", "+ d.appendleft(A)", "...
false
0.117353
0.178757
0.656495
[ "s939147691", "s397973104" ]
u638456847
p02850
python
s627527693
s736545150
487
213
18,608
25,900
Accepted
Accepted
56.26
from collections import deque def main(): N = int(eval(input())) # 辺の集合を隣接リストとして入力 E = [[] for i in range(N+1)] edge_order = [] for i in range(N-1): a,b = list(map(int, input().split())) E[a].append(b) edge_order.append(b) # 頂点1から幅優先探索 queue = deque([...
import sys from collections import deque read = sys.stdin.read def main(): N, *ab = list(map(int, read().split())) E = [[] for _ in range(N + 1)] edge_order = [] for a, b in zip(*[iter(ab)] * 2): E[a].append(b) edge_order.append(b) # 頂点1から幅優先探索 queue = de...
31
33
674
685
from collections import deque def main(): N = int(eval(input())) # 辺の集合を隣接リストとして入力 E = [[] for i in range(N + 1)] edge_order = [] for i in range(N - 1): a, b = list(map(int, input().split())) E[a].append(b) edge_order.append(b) # 頂点1から幅優先探索 queue = deque([1]) co...
import sys from collections import deque read = sys.stdin.read def main(): N, *ab = list(map(int, read().split())) E = [[] for _ in range(N + 1)] edge_order = [] for a, b in zip(*[iter(ab)] * 2): E[a].append(b) edge_order.append(b) # 頂点1から幅優先探索 queue = deque([1]) color = [...
false
6.060606
[ "+import sys", "+", "+read = sys.stdin.read", "- N = int(eval(input()))", "- # 辺の集合を隣接リストとして入力", "- E = [[] for i in range(N + 1)]", "+ N, *ab = list(map(int, read().split()))", "+ E = [[] for _ in range(N + 1)]", "- for i in range(N - 1):", "- a, b = list(map(int, input()...
false
0.046653
0.047957
0.972811
[ "s627527693", "s736545150" ]
u995062424
p03592
python
s936627010
s291147312
325
288
3,060
2,940
Accepted
Accepted
11.38
N, M, K = list(map(int, input().split())) Flg = "No" for i in range(N+1): for j in range(M+1): if(i*(M-j)+(N-i)*j == K): Flg = "Yes" break print(Flg)
N, M, K = list(map(int, input().split())) Flg = "No" for i in range(N+1): for j in range(M+1): if((M-j)*i+(N-i)*j ==K): Flg = "Yes" break print(Flg)
9
9
188
187
N, M, K = list(map(int, input().split())) Flg = "No" for i in range(N + 1): for j in range(M + 1): if i * (M - j) + (N - i) * j == K: Flg = "Yes" break print(Flg)
N, M, K = list(map(int, input().split())) Flg = "No" for i in range(N + 1): for j in range(M + 1): if (M - j) * i + (N - i) * j == K: Flg = "Yes" break print(Flg)
false
0
[ "- if i * (M - j) + (N - i) * j == K:", "+ if (M - j) * i + (N - i) * j == K:" ]
false
0.046796
0.040292
1.161406
[ "s936627010", "s291147312" ]
u312025627
p03435
python
s235837299
s973046552
206
187
39,880
38,256
Accepted
Accepted
9.22
def main(): A = [[int(i) for i in input().split()] for j in range(3)] from itertools import product for a1, a2, a3 in product(range(101), repeat=3): c1 = A[0][0] - a1 == A[1][0] - a2 == A[2][0] - a3 c2 = A[0][1] - a1 == A[1][1] - a2 == A[2][1] - a3 c3 = A[0][2] - a1 == A[1][2] ...
def main(): A = [[int(i) for i in input().split()] for j in range(3)] for i in range(1, 3): for j in range(3): A[i][j] -= A[0][j] if (A[1][0] == A[1][1] == A[1][2]) and (A[2][0] == A[2][1] == A[2][2]): print("Yes") else: print("No") if __name__ == '__main...
14
13
465
337
def main(): A = [[int(i) for i in input().split()] for j in range(3)] from itertools import product for a1, a2, a3 in product(range(101), repeat=3): c1 = A[0][0] - a1 == A[1][0] - a2 == A[2][0] - a3 c2 = A[0][1] - a1 == A[1][1] - a2 == A[2][1] - a3 c3 = A[0][2] - a1 == A[1][2] - a2 ...
def main(): A = [[int(i) for i in input().split()] for j in range(3)] for i in range(1, 3): for j in range(3): A[i][j] -= A[0][j] if (A[1][0] == A[1][1] == A[1][2]) and (A[2][0] == A[2][1] == A[2][2]): print("Yes") else: print("No") if __name__ == "__main__": ma...
false
7.142857
[ "- from itertools import product", "-", "- for a1, a2, a3 in product(range(101), repeat=3):", "- c1 = A[0][0] - a1 == A[1][0] - a2 == A[2][0] - a3", "- c2 = A[0][1] - a1 == A[1][1] - a2 == A[2][1] - a3", "- c3 = A[0][2] - a1 == A[1][2] - a2 == A[2][2] - a3", "- if c1 an...
false
0.691521
0.04395
15.73437
[ "s235837299", "s973046552" ]
u562935282
p03660
python
s740742549
s501791781
872
394
149,112
40,716
Accepted
Accepted
54.82
def main(): import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline def dfs(v, d): for u in g[v]: if d[u] != init: continue d[u] = d[v] + 1 dfs(u, d) n = int(eval(input())) g = tuple(set() for _ in rang...
def main(): from collections import deque import sys input = sys.stdin.readline def dfs(s) -> list: init = n d = [init] * n d[s] = 0 q = deque() q.append(s) while q: v = q.popleft() for u in g[v]: ...
43
46
816
905
def main(): import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline def dfs(v, d): for u in g[v]: if d[u] != init: continue d[u] = d[v] + 1 dfs(u, d) n = int(eval(input())) g = tuple(set() for _ in range(n)) for _ in r...
def main(): from collections import deque import sys input = sys.stdin.readline def dfs(s) -> list: init = n d = [init] * n d[s] = 0 q = deque() q.append(s) while q: v = q.popleft() for u in g[v]: if d[u] != init: ...
false
6.521739
[ "+ from collections import deque", "- sys.setrecursionlimit(10**7)", "- def dfs(v, d):", "- for u in g[v]:", "- if d[u] != init:", "- continue", "- d[u] = d[v] + 1", "- dfs(u, d)", "+ def dfs(s) -> list:", "+ init = n", "+...
false
0.040178
0.058279
0.689407
[ "s740742549", "s501791781" ]
u436634575
p00009
python
s075723666
s817952157
4,820
1,300
29,100
14,528
Accepted
Accepted
73.03
while True: try: n = int(eval(input())) except: break a = [0 for i in range(n + 1)] # sieve i = 3 while i * i <= n: for j in range(3 * i, n + 1, 2 * i): a[j] = 1 i += 2 count = int(n >= 2) count += sum(a[i] == 0 for i in range(3, n + 1, 2...
a = [True for i in range(1000000)] i = 3 while i * i < 1000000: for j in range(3 * i, 1000000, 2 * i): a[j] = False i += 2 while True: try: n = int(eval(input())) except: break count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2)) print(count)
17
14
334
298
while True: try: n = int(eval(input())) except: break a = [0 for i in range(n + 1)] # sieve i = 3 while i * i <= n: for j in range(3 * i, n + 1, 2 * i): a[j] = 1 i += 2 count = int(n >= 2) count += sum(a[i] == 0 for i in range(3, n + 1, 2)) ...
a = [True for i in range(1000000)] i = 3 while i * i < 1000000: for j in range(3 * i, 1000000, 2 * i): a[j] = False i += 2 while True: try: n = int(eval(input())) except: break count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2)) print(count)
false
17.647059
[ "+a = [True for i in range(1000000)]", "+i = 3", "+while i * i < 1000000:", "+ for j in range(3 * i, 1000000, 2 * i):", "+ a[j] = False", "+ i += 2", "- a = [0 for i in range(n + 1)]", "- # sieve", "- i = 3", "- while i * i <= n:", "- for j in range(3 * i, n + 1, ...
false
0.078541
0.811252
0.096814
[ "s075723666", "s817952157" ]
u518042385
p03633
python
s618443308
s967468798
38
18
5,048
2,940
Accepted
Accepted
52.63
n=int(eval(input())) t=1 import fractions for i in range(n): j=int(eval(input())) t=t*j//fractions.gcd(t,j) print(t)
def lcm(n,m): while m!=0: n,m=m,n%m return n def gcd(n,m): return n*m//lcm(n,m) n=int(eval(input())) c=int(eval(input())) for i in range(n-1): c1=int(eval(input())) c=gcd(c,c1) print(c)
7
12
114
192
n = int(eval(input())) t = 1 import fractions for i in range(n): j = int(eval(input())) t = t * j // fractions.gcd(t, j) print(t)
def lcm(n, m): while m != 0: n, m = m, n % m return n def gcd(n, m): return n * m // lcm(n, m) n = int(eval(input())) c = int(eval(input())) for i in range(n - 1): c1 = int(eval(input())) c = gcd(c, c1) print(c)
false
41.666667
[ "+def lcm(n, m):", "+ while m != 0:", "+ n, m = m, n % m", "+ return n", "+", "+", "+def gcd(n, m):", "+ return n * m // lcm(n, m)", "+", "+", "-t = 1", "-import fractions", "-", "-for i in range(n):", "- j = int(eval(input()))", "- t = t * j // fractions.gcd(t, j...
false
0.060864
0.037167
1.637587
[ "s618443308", "s967468798" ]
u520276780
p03830
python
s829618899
s921632717
173
39
38,896
3,064
Accepted
Accepted
77.46
#n<=10**3 n = int(eval(input())) fct = [1]*(n+1) fct[1] = 0 fct[0] = 0 mod = 10**9+7 #print(mod) sq = int(n**(1/2))+5###1//2はゼロだwww #print(sq) for i in range(2,sq): for j in range(2,(n//i)+10): if i*j<=n: fct[i*j] = 0 #if i==7 or j ==11: # print("test...
n = int(eval(input())) fct = [1]*(n+7) for i in range(2,int(n**(1/2))+7): if fct[i]: for j in range(2*i,n+1,i): fct[j]=0 fct2 = {i:1 for i in range(2,n+1) if fct[i]} fct3 = [i for i in range(2,n+1) if fct[i]] for i in range(2,n+1): for j in fct3: i2 = i while i2%j=...
41
22
651
463
# n<=10**3 n = int(eval(input())) fct = [1] * (n + 1) fct[1] = 0 fct[0] = 0 mod = 10**9 + 7 # print(mod) sq = int(n ** (1 / 2)) + 5 ###1//2はゼロだwww # print(sq) for i in range(2, sq): for j in range(2, (n // i) + 10): if i * j <= n: fct[i * j] = 0 # if i==7 or j ==11: # ...
n = int(eval(input())) fct = [1] * (n + 7) for i in range(2, int(n ** (1 / 2)) + 7): if fct[i]: for j in range(2 * i, n + 1, i): fct[j] = 0 fct2 = {i: 1 for i in range(2, n + 1) if fct[i]} fct3 = [i for i in range(2, n + 1) if fct[i]] for i in range(2, n + 1): for j in fct3: i2 = i ...
false
46.341463
[ "-# n<=10**3", "-fct = [1] * (n + 1)", "-fct[1] = 0", "-fct[0] = 0", "+fct = [1] * (n + 7)", "+for i in range(2, int(n ** (1 / 2)) + 7):", "+ if fct[i]:", "+ for j in range(2 * i, n + 1, i):", "+ fct[j] = 0", "+fct2 = {i: 1 for i in range(2, n + 1) if fct[i]}", "+fct3 = [i f...
false
0.084421
0.086481
0.976183
[ "s829618899", "s921632717" ]
u094191970
p03487
python
s881751232
s176521912
240
120
70,052
20,976
Accepted
Accepted
50
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) a_s=list(set(a)) c_l=Counter(a) cnt=0 for i in a_s: if c_l[i]<i: cnt+=c_l[i] else: cnt+=c_l[i]-i print(cnt)
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) a_s=list(set(a)) c_l=Counter(a) cnt=0 for i in a_s: cnt+=c_l[i] if c_l[i]<i else c_l[i]-i print(cnt)
14
11
226
196
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) a_s = list(set(a)) c_l = Counter(a) cnt = 0 for i in a_s: if c_l[i] < i: cnt += c_l[i] else: cnt += c_l[i] - i print(cnt)
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) a_s = list(set(a)) c_l = Counter(a) cnt = 0 for i in a_s: cnt += c_l[i] if c_l[i] < i else c_l[i] - i print(cnt)
false
21.428571
[ "- if c_l[i] < i:", "- cnt += c_l[i]", "- else:", "- cnt += c_l[i] - i", "+ cnt += c_l[i] if c_l[i] < i else c_l[i] - i" ]
false
0.110419
0.053519
2.063175
[ "s881751232", "s176521912" ]
u569960318
p02422
python
s078711994
s380909431
50
30
7,688
7,688
Accepted
Accepted
40
s = eval(input()) for _ in range(int(eval(input()))): code=input().split() if code[0]=='print' : print(("".join(s[int(code[1]):int(code[2])+1]))) elif code[0]=='reverse': s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:] elif code[0]=='replace': ...
s = eval(input()) for _ in range(int(eval(input()))): code=input().split() if code[0]=='print' : print((s[int(code[1]):int(code[2])+1])) elif code[0]=='reverse': s = s[:int(code[1])] + s[int(code[1]):int(code[2])+1][::-1] + s[int(code[2])+1:] elif code[0]=='replace': s =...
9
9
363
354
s = eval(input()) for _ in range(int(eval(input()))): code = input().split() if code[0] == "print": print(("".join(s[int(code[1]) : int(code[2]) + 1]))) elif code[0] == "reverse": s = ( s[: int(code[1])] + s[int(code[1]) : int(code[2]) + 1][::-1] + s[int(c...
s = eval(input()) for _ in range(int(eval(input()))): code = input().split() if code[0] == "print": print((s[int(code[1]) : int(code[2]) + 1])) elif code[0] == "reverse": s = ( s[: int(code[1])] + s[int(code[1]) : int(code[2]) + 1][::-1] + s[int(code[2]) +...
false
0
[ "- print((\"\".join(s[int(code[1]) : int(code[2]) + 1])))", "+ print((s[int(code[1]) : int(code[2]) + 1]))" ]
false
0.045602
0.043007
1.060344
[ "s078711994", "s380909431" ]
u343977188
p02630
python
s974128167
s816420438
509
430
94,656
84,928
Accepted
Accepted
15.52
import collections N=int(eval(input())) A=list(map(int,input().split())) s=sum(A) Q=int(eval(input())) d=collections.Counter(A) for i in range(Q): B,C=list(map(int,input().split())) s += d[B]*C - d[B]*B print(s) if C in d: d[C]+=d[B] else: d[C]=d[B] d[B]=0
N=int(eval(input())) A=list(map(int,input().split())) s=sum(A) Q=int(eval(input())) d=[0]*(10**5 +1)#各数字の個数 for i in A: d[i]+=1 for i in range(Q): B,C=list(map(int,input().split())) s += (C-B)*d[B] print(s) d[C]+=d[B] d[B]=0
15
14
272
232
import collections N = int(eval(input())) A = list(map(int, input().split())) s = sum(A) Q = int(eval(input())) d = collections.Counter(A) for i in range(Q): B, C = list(map(int, input().split())) s += d[B] * C - d[B] * B print(s) if C in d: d[C] += d[B] else: d[C] = d[B] d[B] =...
N = int(eval(input())) A = list(map(int, input().split())) s = sum(A) Q = int(eval(input())) d = [0] * (10**5 + 1) # 各数字の個数 for i in A: d[i] += 1 for i in range(Q): B, C = list(map(int, input().split())) s += (C - B) * d[B] print(s) d[C] += d[B] d[B] = 0
false
6.666667
[ "-import collections", "-", "-d = collections.Counter(A)", "+d = [0] * (10**5 + 1) # 各数字の個数", "+for i in A:", "+ d[i] += 1", "- s += d[B] * C - d[B] * B", "+ s += (C - B) * d[B]", "- if C in d:", "- d[C] += d[B]", "- else:", "- d[C] = d[B]", "+ d[C] += d[B]" ...
false
0.157561
0.068501
2.300123
[ "s974128167", "s816420438" ]
u620084012
p03086
python
s228557650
s752520025
185
18
38,256
2,940
Accepted
Accepted
90.27
S = eval(input()) T = ["A", "C", "G", "T"] ans = 0 t = 0 for e in S: if e in T: t += 1 else: t = 0 ans = max(ans,t) print(ans)
S = eval(input()) L = ["A","T","C","G"] ans = 0 t = 0 for e in S: if e in L: t += 1 ans = max(ans,t) else: t = 0 print(ans)
11
11
159
160
S = eval(input()) T = ["A", "C", "G", "T"] ans = 0 t = 0 for e in S: if e in T: t += 1 else: t = 0 ans = max(ans, t) print(ans)
S = eval(input()) L = ["A", "T", "C", "G"] ans = 0 t = 0 for e in S: if e in L: t += 1 ans = max(ans, t) else: t = 0 print(ans)
false
0
[ "-T = [\"A\", \"C\", \"G\", \"T\"]", "+L = [\"A\", \"T\", \"C\", \"G\"]", "- if e in T:", "+ if e in L:", "+ ans = max(ans, t)", "- ans = max(ans, t)" ]
false
0.098493
0.032609
3.020411
[ "s228557650", "s752520025" ]
u162612857
p03652
python
s316370091
s105069941
1,510
1,312
10,272
10,188
Accepted
Accepted
13.11
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた! # 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン # 愚直にやると2^Nを調べねばならず無理。 # したがって「一部を調べればよい」に帰着するのが多いだろう。 # 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。 # 今回は全体集合から1つずつ取り去るのを考えるとできる。 # 全体集合である競技m0が最多の人数p0人を集めたとする。 # すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。 # ここで「m0...
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた! # 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン # 愚直にやると2^Nを調べねばならず無理。 # したがって「一部を調べればよい」に帰着するのが多いだろう。 # 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。 # 今回は全体集合から1つずつ取り去るのを考えるとできる。 # 全体集合である競技m0が最多の人数p0人を集めたとする。 # すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。 # ここで「m0...
39
39
1,107
1,091
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた! # 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン # 愚直にやると2^Nを調べねばならず無理。 # したがって「一部を調べればよい」に帰着するのが多いだろう。 # 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。 # 今回は全体集合から1つずつ取り去るのを考えるとできる。 # 全体集合である競技m0が最多の人数p0人を集めたとする。 # すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。 # ここで「m0を含む集合」について一気...
# chokudaiブログの典型力の話を意識しつつ考えたら思いついた! # 「ある集合の部分集合の中で、〜〜〜の値が最小になるものを求めよ」のパターン # 愚直にやると2^Nを調べねばならず無理。 # したがって「一部を調べればよい」に帰着するのが多いだろう。 # 何らかの形でソートしておいて、空集合から1つずつ付け加えるとか。全体集合から1つずつ取り去るとか。 # 今回は全体集合から1つずつ取り去るのを考えるとできる。 # 全体集合である競技m0が最多の人数p0人を集めたとする。 # すると、全ての部分集合のうち「m0を含む集合」を考えると、競技m0は必ずp0人以上集まるので解もp0以上。 # ここで「m0を含む集合」について一気...
false
0
[ "- for s in range(m):", "- if pref[s] in held_sports:", "- parti[pref[s]] += 1", "+ for s in pref:", "+ if s in held_sports:", "+ parti[s] += 1" ]
false
0.062668
0.048122
1.302277
[ "s316370091", "s105069941" ]
u330314953
p03073
python
s148450049
s174901987
53
42
3,188
3,188
Accepted
Accepted
20.75
s = eval(input()) cnt = 0 for i in range(len(s)): if i%2 == 0: if s[i] == "0": cnt += 1 else: if s[i] == "1": cnt += 1 print((min(cnt,len(s)-cnt)))
s = eval(input()) cnt = 0 t = "01"*(-((-1)*len(s)//2)) cnt_1 = 0 cnt_2 = 0 for i in range(len(s)): if s[i] == t[i]: cnt_1 += 1 else: cnt_2 += 1 print((min(cnt_1,cnt_2)))
13
16
184
205
s = eval(input()) cnt = 0 for i in range(len(s)): if i % 2 == 0: if s[i] == "0": cnt += 1 else: if s[i] == "1": cnt += 1 print((min(cnt, len(s) - cnt)))
s = eval(input()) cnt = 0 t = "01" * (-((-1) * len(s) // 2)) cnt_1 = 0 cnt_2 = 0 for i in range(len(s)): if s[i] == t[i]: cnt_1 += 1 else: cnt_2 += 1 print((min(cnt_1, cnt_2)))
false
18.75
[ "+t = \"01\" * (-((-1) * len(s) // 2))", "+cnt_1 = 0", "+cnt_2 = 0", "- if i % 2 == 0:", "- if s[i] == \"0\":", "- cnt += 1", "+ if s[i] == t[i]:", "+ cnt_1 += 1", "- if s[i] == \"1\":", "- cnt += 1", "-print((min(cnt, len(s) - cnt)))", "+ ...
false
0.08083
0.036292
2.227222
[ "s148450049", "s174901987" ]
u411237324
p03073
python
s431589288
s196738116
38
32
4,268
4,396
Accepted
Accepted
15.79
S = list(eval(input())) # min(全部01010、全部10101) cnt0 = 0 cnt1 = 0 for e in S[::2]: if e == '1': cnt0 += 1 for e in S[1::2]: if e == '0': cnt0 += 1 for e in S[::2]: if e == '0': cnt1 += 1 for e in S[1::2]: if e == '1': cnt1 += 1 print((min(cnt0, cnt1)))
S = list(eval(input())) # min(全部01010、全部10101) cnt0 = 0 cnt1 = 0 for e in S[::2]: if e == '1': cnt0 += 1 else: cnt1 += 1 for e in S[1::2]: if e == '0': cnt0 += 1 else: cnt1 += 1 print((min(cnt0, cnt1)))
17
15
308
257
S = list(eval(input())) # min(全部01010、全部10101) cnt0 = 0 cnt1 = 0 for e in S[::2]: if e == "1": cnt0 += 1 for e in S[1::2]: if e == "0": cnt0 += 1 for e in S[::2]: if e == "0": cnt1 += 1 for e in S[1::2]: if e == "1": cnt1 += 1 print((min(cnt0, cnt1)))
S = list(eval(input())) # min(全部01010、全部10101) cnt0 = 0 cnt1 = 0 for e in S[::2]: if e == "1": cnt0 += 1 else: cnt1 += 1 for e in S[1::2]: if e == "0": cnt0 += 1 else: cnt1 += 1 print((min(cnt0, cnt1)))
false
11.764706
[ "+ else:", "+ cnt1 += 1", "-for e in S[::2]:", "- if e == \"0\":", "- cnt1 += 1", "-for e in S[1::2]:", "- if e == \"1\":", "+ else:" ]
false
0.090035
0.035458
2.539229
[ "s431589288", "s196738116" ]
u970197315
p03612
python
s264081768
s334338758
99
86
13,812
14,008
Accepted
Accepted
13.13
from math import ceil n=int(eval(input())) p=list(map(int,input().split())) m=[] l=[0]*n for i in range(n): if p[i]==i+1: l[i]=1 # print(l) t=0 for i in range(n): if i==n-1: if l[i]==1: t+=1 m.append(t) break if l[i]==1: t+=1 if...
n=int(eval(input())) p=list(map(int,input().split())) ans=0 for i in range(n-1): if p[i]==i+1: ans+=1 x,y=p[i+1],p[i] p[i+1],p[i]=y,x if i==n-2: if p[-1]==n: ans+=1 print(ans)
28
13
448
209
from math import ceil n = int(eval(input())) p = list(map(int, input().split())) m = [] l = [0] * n for i in range(n): if p[i] == i + 1: l[i] = 1 # print(l) t = 0 for i in range(n): if i == n - 1: if l[i] == 1: t += 1 m.append(t) break if l[i] == 1: t += ...
n = int(eval(input())) p = list(map(int, input().split())) ans = 0 for i in range(n - 1): if p[i] == i + 1: ans += 1 x, y = p[i + 1], p[i] p[i + 1], p[i] = y, x if i == n - 2: if p[-1] == n: ans += 1 print(ans)
false
53.571429
[ "-from math import ceil", "-", "-m = []", "-l = [0] * n", "-for i in range(n):", "+ans = 0", "+for i in range(n - 1):", "- l[i] = 1", "-# print(l)", "-t = 0", "-for i in range(n):", "- if i == n - 1:", "- if l[i] == 1:", "- t += 1", "- m.append(t)", "...
false
0.0338
0.10833
0.312005
[ "s264081768", "s334338758" ]
u357487020
p04016
python
s646549121
s482647692
264
170
21,740
16,368
Accepted
Accepted
35.61
import sys sys.setrecursionlimit(10**9) def divisor(x): div=[] for i in range(1,int(x**0.5)+1): if x%i==0: div.append(i) if i!=x/i: div.append(x/i) return div def f(b,n): if n<b: return n else: return f(b,n/b)+n%b n...
import sys sys.setrecursionlimit(10**9) def divisor(x): div=[] for i in range(1,int(x**0.5)+1): if x%i==0: div.append(i) if i!=x/i: div.append(x/i) return div def f(b,n): if n<b: return n else: return f(b,n/b)+n%b n...
49
41
843
641
import sys sys.setrecursionlimit(10**9) def divisor(x): div = [] for i in range(1, int(x**0.5) + 1): if x % i == 0: div.append(i) if i != x / i: div.append(x / i) return div def f(b, n): if n < b: return n else: return f(b, n / b) ...
import sys sys.setrecursionlimit(10**9) def divisor(x): div = [] for i in range(1, int(x**0.5) + 1): if x % i == 0: div.append(i) if i != x / i: div.append(x / i) return div def f(b, n): if n < b: return n else: return f(b, n / b) ...
false
16.326531
[ "-if n <= 10**6:", "- for i in range(2, n + 2):", "- if f(i, n) == s:", "- print(i)", "- quit()", "- print((-1))", "-else:", "- for i in range(2, 10**6 + 1):", "- if f(i, n) == s:", "- print(i)", "- quit()", "- div = divisor...
false
0.086303
0.105456
0.818379
[ "s646549121", "s482647692" ]
u033602950
p03684
python
s097474875
s148100091
1,945
1,110
137,864
47,812
Accepted
Accepted
42.93
import sys #import time import copy #from collections import deque, Counter, defaultdict #from fractions import gcd #import bisect #import heapq #import time input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda : int(eval(input())) rs = lambda : input().strip(...
import sys #import time import copy #from collections import deque, Counter, defaultdict #from fractions import gcd #import bisect #import heapq #import time input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda : int(eval(input())) rs = lambda : input().strip(...
75
75
1,791
1,779
import sys # import time import copy # from collections import deque, Counter, defaultdict # from fractions import gcd # import bisect # import heapq # import time input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda: int(eval(input())) rs = lambda: input().strip() rl = la...
import sys # import time import copy # from collections import deque, Counter, defaultdict # from fractions import gcd # import bisect # import heapq # import time input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda: int(eval(input())) rs = lambda: input().strip() rl = la...
false
0
[ "-d2 = copy.deepcopy(d1)", "+d2 = d1[:]" ]
false
0.041521
0.091676
0.452912
[ "s097474875", "s148100091" ]
u761320129
p03854
python
s450245226
s569792829
154
33
3,316
3,188
Accepted
Accepted
78.57
S = eval(input()) S = S[::-1] words = ['dream','dreamer','erase','eraser'] i = 0 while i < len(S): for word in words: if S[i:].startswith(word[::-1]): i += len(word) break else: print('NO') exit() print('YES')
S = eval(input()) ws = ['dreamer','eraser','dream','erase'] e = len(S) while e: for w in ws: if S[e-len(w):e] == w: e -= len(w) break else: print('NO') exit() print('YES')
14
12
273
232
S = eval(input()) S = S[::-1] words = ["dream", "dreamer", "erase", "eraser"] i = 0 while i < len(S): for word in words: if S[i:].startswith(word[::-1]): i += len(word) break else: print("NO") exit() print("YES")
S = eval(input()) ws = ["dreamer", "eraser", "dream", "erase"] e = len(S) while e: for w in ws: if S[e - len(w) : e] == w: e -= len(w) break else: print("NO") exit() print("YES")
false
14.285714
[ "-S = S[::-1]", "-words = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "-i = 0", "-while i < len(S):", "- for word in words:", "- if S[i:].startswith(word[::-1]):", "- i += len(word)", "+ws = [\"dreamer\", \"eraser\", \"dream\", \"erase\"]", "+e = len(S)", "+while e:", ...
false
0.172933
0.037531
4.607668
[ "s450245226", "s569792829" ]
u241159583
p03212
python
s303902817
s178117984
51
45
9,076
10,180
Accepted
Accepted
11.76
import itertools n = int(eval(input())) cnt = 0 for i in range(3,len(str(n))+1): for v in itertools.product(["3","5","7"], repeat=i): if len(set(v))!=3: continue x = int("".join(v)) if n >= x: cnt += 1 print(cnt)
import itertools import bisect n = int(eval(input())) numbers = [] for i in range(3,10): for v in itertools.product(["7","5","3"], repeat=i): if "5" in v and "7" in v and "3" in v:numbers.append(int("".join(v))) numbers.sort() print((bisect.bisect_right(numbers,n)))
10
9
244
278
import itertools n = int(eval(input())) cnt = 0 for i in range(3, len(str(n)) + 1): for v in itertools.product(["3", "5", "7"], repeat=i): if len(set(v)) != 3: continue x = int("".join(v)) if n >= x: cnt += 1 print(cnt)
import itertools import bisect n = int(eval(input())) numbers = [] for i in range(3, 10): for v in itertools.product(["7", "5", "3"], repeat=i): if "5" in v and "7" in v and "3" in v: numbers.append(int("".join(v))) numbers.sort() print((bisect.bisect_right(numbers, n)))
false
10
[ "+import bisect", "-cnt = 0", "-for i in range(3, len(str(n)) + 1):", "- for v in itertools.product([\"3\", \"5\", \"7\"], repeat=i):", "- if len(set(v)) != 3:", "- continue", "- x = int(\"\".join(v))", "- if n >= x:", "- cnt += 1", "-print(cnt)", "+...
false
0.04306
0.071972
0.598284
[ "s303902817", "s178117984" ]
u191874006
p03599
python
s015827413
s605254111
114
94
22,488
74,232
Accepted
Accepted
17.54
#!/usr/bin/env python3 #ABC74 C a,b,c,d,e,f = list(map(int,input().split())) s = f//(100*a) t = f//(100*b) u = f//c v = f//d concentration = 0 water = [100*a*A + 100*b*B for B in range(t+1) for A in range(s+1) if 100*a*A + 100*b*B != 0] suger = [c*C + d*D for D in range(v+1) for C in range(u+1)] ans1 = ...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
28
42
673
1,167
#!/usr/bin/env python3 # ABC74 C a, b, c, d, e, f = list(map(int, input().split())) s = f // (100 * a) t = f // (100 * b) u = f // c v = f // d concentration = 0 water = [ 100 * a * A + 100 * b * B for B in range(t + 1) for A in range(s + 1) if 100 * a * A + 100 * b * B != 0 ] suger = [c * C + d * D for...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
false
33.333333
[ "-# ABC74 C", "-a, b, c, d, e, f = list(map(int, input().split()))", "-s = f // (100 * a)", "-t = f // (100 * b)", "-u = f // c", "-v = f // d", "-concentration = 0", "-water = [", "- 100 * a * A + 100 * b * B", "- for B in range(t + 1)", "- for A in range(s + 1)", "- if 100 * a * ...
false
0.097676
0.6637
0.147168
[ "s015827413", "s605254111" ]
u691018832
p03273
python
s541297351
s430000786
24
21
3,064
3,064
Accepted
Accepted
12.5
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) h, w = list(map(int, readline().split())) a = [eval(input()) for i in range(h)] ans = [] memo_x = [] memo_y = [] for i in range(h): cnt = 0 for j in ra...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) h, w = list(map(int, readline().split())) a = [readline().rstrip().decode() for i in range(h)] memo_w = [False] * h memo_h = [False] * w for i in range(h): f...
34
33
782
808
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) h, w = list(map(int, readline().split())) a = [eval(input()) for i in range(h)] ans = [] memo_x = [] memo_y = [] for i in range(h): cnt = 0 for j in range(w): ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) h, w = list(map(int, readline().split())) a = [readline().rstrip().decode() for i in range(h)] memo_w = [False] * h memo_h = [False] * w for i in range(h): flag = True ...
false
2.941176
[ "-a = [eval(input()) for i in range(h)]", "-ans = []", "-memo_x = []", "-memo_y = []", "+a = [readline().rstrip().decode() for i in range(h)]", "+memo_w = [False] * h", "+memo_h = [False] * w", "- cnt = 0", "+ flag = True", "- if a[i][j] == \".\":", "- cnt += 1", "- ...
false
0.049401
0.049862
0.99077
[ "s541297351", "s430000786" ]
u600402037
p03069
python
s490186530
s188891870
197
102
30,056
3,500
Accepted
Accepted
48.22
N = int(eval(input())) S = eval(input()) dp = [[] for _ in range(N)] white = black = 0 for i in range(N): if S[i] == '.': white += 1 else: black += 1 dp[i] = [white, black] W = S.count('.') B = N - W #黒石の数 answer = W for i in range(N): # iの場所より左側を全て白、右側を黒にする change = d...
N = int(eval(input())) S = eval(input()) white = black = 0 W = S.count('.') B = N - W #黒石の数 answer = W for i in range(N): if S[i] == '.': white += 1 else: black += 1 change = black + W - white if change < answer: answer = change print(answer)
19
16
397
290
N = int(eval(input())) S = eval(input()) dp = [[] for _ in range(N)] white = black = 0 for i in range(N): if S[i] == ".": white += 1 else: black += 1 dp[i] = [white, black] W = S.count(".") B = N - W # 黒石の数 answer = W for i in range(N): # iの場所より左側を全て白、右側を黒にする change = dp[i][1] + (W ...
N = int(eval(input())) S = eval(input()) white = black = 0 W = S.count(".") B = N - W # 黒石の数 answer = W for i in range(N): if S[i] == ".": white += 1 else: black += 1 change = black + W - white if change < answer: answer = change print(answer)
false
15.789474
[ "-dp = [[] for _ in range(N)]", "+W = S.count(\".\")", "+B = N - W # 黒石の数", "+answer = W", "- dp[i] = [white, black]", "-W = S.count(\".\")", "-B = N - W # 黒石の数", "-answer = W", "-for i in range(N):", "- # iの場所より左側を全て白、右側を黒にする", "- change = dp[i][1] + (W - dp[i][0])", "+ change =...
false
0.06155
0.035645
1.726739
[ "s490186530", "s188891870" ]
u057964173
p03379
python
s955613879
s281180028
463
423
96,064
86,100
Accepted
Accepted
8.64
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(eval(input())) l=list(map(int,input().split())) l2=sorted(l) x=l2[n//2-1] y=l2[n//2] if x==y: for i in range(n): print(x) else: setx=set(l2[:n//2]) sety=set(l2[...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) l = list(map(int, input().split())) lsort = sorted(l) left = lsort[n // 2 - 1] right = lsort[n // 2] for i in l: if i <= left: print(right) else: ...
21
18
451
344
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) l = list(map(int, input().split())) l2 = sorted(l) x = l2[n // 2 - 1] y = l2[n // 2] if x == y: for i in range(n): print(x) else: setx = set(l2[: n // 2]) ...
import sys def input(): return sys.stdin.readline().strip() def resolve(): n = int(eval(input())) l = list(map(int, input().split())) lsort = sorted(l) left = lsort[n // 2 - 1] right = lsort[n // 2] for i in l: if i <= left: print(right) else: prin...
false
14.285714
[ "- l2 = sorted(l)", "- x = l2[n // 2 - 1]", "- y = l2[n // 2]", "- if x == y:", "- for i in range(n):", "- print(x)", "- else:", "- setx = set(l2[: n // 2])", "- sety = set(l2[n // 2 :])", "- for i in l:", "- if i in setx:", "- ...
false
0.085693
0.042965
1.994486
[ "s955613879", "s281180028" ]
u631277801
p03994
python
s874370390
s642978692
81
59
4,340
5,048
Accepted
Accepted
27.16
# 入力 import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc...
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
31
35
695
780
# 入力 import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.rea...
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
false
11.428571
[ "-# 入力", "+sys.setrecursionlimit(10**7)", "- return [int(x) for x in stdin.readline().split()]", "+ return list(map(int, stdin.readline().split()))", "- return [float(x) for x in stdin.readline().split()]", "+ return list(map(float, stdin.readline().split()))", "- return int(ns())", "+ ...
false
0.041027
0.062029
0.661411
[ "s874370390", "s642978692" ]
u211160392
p02991
python
s965554333
s205008856
1,926
650
78,128
38,072
Accepted
Accepted
66.25
import sys input = sys.stdin.readline N,M = list(map(int,input().split())) S = [[]for i in range(N)] for i in range(M): u,v = list(map(int,input().split())) S[u-1].append(v-1) St,T = list(map(int,input().split())) D = [[float('inf')]*3 for i in range(N)] D[St-1][0] = 0 queue = [St-1] i = 0 while...
from collections import deque import sys input = sys.stdin.readline N,M = list(map(int,input().split())) S = [[]for i in range(N)] for i in range(M): u,v = list(map(int,input().split())) S[u-1].append(v-1) St,T = list(map(int,input().split())) D = [[float('inf')]*3 for i in range(N)] D[St-1][0] = ...
30
31
669
691
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) S = [[] for i in range(N)] for i in range(M): u, v = list(map(int, input().split())) S[u - 1].append(v - 1) St, T = list(map(int, input().split())) D = [[float("inf")] * 3 for i in range(N)] D[St - 1][0] = 0 queue = [St - 1] i = 0 whi...
from collections import deque import sys input = sys.stdin.readline N, M = list(map(int, input().split())) S = [[] for i in range(N)] for i in range(M): u, v = list(map(int, input().split())) S[u - 1].append(v - 1) St, T = list(map(int, input().split())) D = [[float("inf")] * 3 for i in range(N)] D[St - 1][0] ...
false
3.225806
[ "+from collections import deque", "-queue = [St - 1]", "-i = 0", "-while queue != []:", "- i += 1", "- hoge = []", "- for q in queue:", "- for s in S[q]:", "- if D[s][i % 3] > i:", "- D[s][i % 3] = i", "- if not s in hoge:", "- ...
false
0.038587
0.039438
0.978418
[ "s965554333", "s205008856" ]
u047796752
p02820
python
s322119518
s588182472
359
200
68,336
49,264
Accepted
Accepted
44.29
def calc(l): n = len(l) dp = [[0]*3 for _ in range(n+1)] for i in range(n): if l[i]=='r': dp[i+1][0] = max(dp[i][1], dp[i][2]) dp[i+1][1] = max(dp[i][0], dp[i][2]) dp[i+1][2] = max(dp[i][0], dp[i][1])+P elif l[i]=='s': dp[i+1][0]...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = list(eval(input())) score = {'r': P, 's': R, 'p': S} ans = 0 for i in range(N): if i<K: ans += score[T[i]] else: if T[i]!=T[i-K]: ans += score[T[...
35
19
884
370
def calc(l): n = len(l) dp = [[0] * 3 for _ in range(n + 1)] for i in range(n): if l[i] == "r": dp[i + 1][0] = max(dp[i][1], dp[i][2]) dp[i + 1][1] = max(dp[i][0], dp[i][2]) dp[i + 1][2] = max(dp[i][0], dp[i][1]) + P elif l[i] == "s": dp[i + 1]...
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = list(eval(input())) score = {"r": P, "s": R, "p": S} ans = 0 for i in range(N): if i < K: ans += score[T[i]] else: if T[i] != T[i - K]: ans += score[T[i]] ...
false
45.714286
[ "-def calc(l):", "- n = len(l)", "- dp = [[0] * 3 for _ in range(n + 1)]", "- for i in range(n):", "- if l[i] == \"r\":", "- dp[i + 1][0] = max(dp[i][1], dp[i][2])", "- dp[i + 1][1] = max(dp[i][0], dp[i][2])", "- dp[i + 1][2] = max(dp[i][0], dp[i][1]) +...
false
0.042326
0.092844
0.455885
[ "s322119518", "s588182472" ]
u589726284
p03285
python
s098110673
s803366723
19
17
2,940
2,940
Accepted
Accepted
10.53
N = int(eval(input())) result = "No" for i in range(101): for j in range(101): total = 4 * i + 7 * j if N == total : result = "Yes" break print(result)
N = int(eval(input())) cMax = round(100 / 4) dMax = round(100 / 7) result = "No" for c in range(cMax): for d in range(dMax): if 4 * c + 7 * d == N: result = "Yes" break print(result)
9
10
176
203
N = int(eval(input())) result = "No" for i in range(101): for j in range(101): total = 4 * i + 7 * j if N == total: result = "Yes" break print(result)
N = int(eval(input())) cMax = round(100 / 4) dMax = round(100 / 7) result = "No" for c in range(cMax): for d in range(dMax): if 4 * c + 7 * d == N: result = "Yes" break print(result)
false
10
[ "+cMax = round(100 / 4)", "+dMax = round(100 / 7)", "-for i in range(101):", "- for j in range(101):", "- total = 4 * i + 7 * j", "- if N == total:", "+for c in range(cMax):", "+ for d in range(dMax):", "+ if 4 * c + 7 * d == N:" ]
false
0.128022
0.14262
0.897643
[ "s098110673", "s803366723" ]
u796942881
p03043
python
s174145280
s439845848
123
22
3,572
3,444
Accepted
Accepted
82.11
from functools import reduce from math import log2 from operator import mul def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) MAX_SHIFT = int(log2(K) + 1) print((sum(reduce(mul, (0.5 if i << j < K ...
import math def main(): N, K = list(map(int, input().split())) k = int(math.log2(K)) + 1 print(((max(0, N - K + 1) + sum( max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i - max(0, N - (math.ceil(K * (1 / 2) ** (i - 1))) + 1) * (1 / 2) ** i for i in range(1, k +...
21
14
466
348
from functools import reduce from math import log2 from operator import mul def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) MAX_SHIFT = int(log2(K) + 1) print( ( sum( reduce( mul, (0...
import math def main(): N, K = list(map(int, input().split())) k = int(math.log2(K)) + 1 print( ( ( max(0, N - K + 1) + sum( max(0, N - (math.ceil(K * (1 / 2) ** i)) + 1) * (1 / 2) ** i - max(0, N - (math.ceil(K * ...
false
33.333333
[ "-from functools import reduce", "-from math import log2", "-from operator import mul", "-", "-", "-def end_of_loop():", "- raise StopIteration", "+import math", "- MAX_SHIFT = int(log2(K) + 1)", "+ k = int(math.log2(K)) + 1", "- sum(", "- reduce(", "- ...
false
0.048278
0.090033
0.536221
[ "s174145280", "s439845848" ]
u822090837
p02641
python
s420935423
s505676039
31
24
9,180
9,172
Accepted
Accepted
22.58
X, N = list(map(int, input().split())) p_list = list(map(int, input().split())) if N == 0: print(X) else: for i in range(0,100): if not X-i in p_list: print((X-i)) break elif not X+i in p_list: print((X+i)) break
X,N=list(map(int, input().split())) p=list(map(int,input().split())) if N==0: print(X) else: for k in range(0,51): if not X-k in p: print((X-k)) break elif not X+k in p: print((X+k)) break
13
12
280
265
X, N = list(map(int, input().split())) p_list = list(map(int, input().split())) if N == 0: print(X) else: for i in range(0, 100): if not X - i in p_list: print((X - i)) break elif not X + i in p_list: print((X + i)) break
X, N = list(map(int, input().split())) p = list(map(int, input().split())) if N == 0: print(X) else: for k in range(0, 51): if not X - k in p: print((X - k)) break elif not X + k in p: print((X + k)) break
false
7.692308
[ "-p_list = list(map(int, input().split()))", "+p = list(map(int, input().split()))", "- for i in range(0, 100):", "- if not X - i in p_list:", "- print((X - i))", "+ for k in range(0, 51):", "+ if not X - k in p:", "+ print((X - k))", "- elif not X + ...
false
0.008537
0.081194
0.105138
[ "s420935423", "s505676039" ]
u539123425
p03944
python
s256529882
s284817353
79
26
9,256
9,156
Accepted
Accepted
67.09
w,h,n = list(map(int,input().split())) cnt = 0 k = [[False for i in range(w)] for j in range(h)] while(cnt < n): x,y,a = list(map(int,input().split())) if(a == 1): for i in range(h): for j in range(x): k[i][j] = True elif(a == 2): for i in range(h)...
#数学的に解く w,h,n = list(map(int,input().split())) cnt = 0 X = 0 Y = 0 while(cnt < n): x,y,a = list(map(int,input().split())) if(a == 1): X = max(X,x) elif(a == 2): w = min(w,x) elif(a == 3): Y = max(Y,y) elif(a == 4): h = min(h,y) #print(w,h,X,Y)...
27
19
684
352
w, h, n = list(map(int, input().split())) cnt = 0 k = [[False for i in range(w)] for j in range(h)] while cnt < n: x, y, a = list(map(int, input().split())) if a == 1: for i in range(h): for j in range(x): k[i][j] = True elif a == 2: for i in range(h): ...
# 数学的に解く w, h, n = list(map(int, input().split())) cnt = 0 X = 0 Y = 0 while cnt < n: x, y, a = list(map(int, input().split())) if a == 1: X = max(X, x) elif a == 2: w = min(w, x) elif a == 3: Y = max(Y, y) elif a == 4: h = min(h, y) # print(w,h,X,Y) cnt += 1 ...
false
29.62963
[ "+# 数学的に解く", "-k = [[False for i in range(w)] for j in range(h)]", "+X = 0", "+Y = 0", "- for i in range(h):", "- for j in range(x):", "- k[i][j] = True", "+ X = max(X, x)", "- for i in range(h):", "- for j in range(x, w):", "- ...
false
0.037482
0.053003
0.707162
[ "s256529882", "s284817353" ]
u332906195
p02689
python
s328697468
s970203313
354
300
23,540
20,112
Accepted
Accepted
15.25
N, M = list(map(int, input().split())) H = list(map(int, input().split())) Hneig = [[] for _ in range(N)] for _ in range(M): A, B = list(map(int, input().split())) Hneig[A - 1].append(H[B - 1]) Hneig[B - 1].append(H[A - 1]) print((sum([1 for n in range(N) if len(Hneig[n]) == 0 or H[n] > max(Hneig[n])...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) Hn = [0] * N for _ in range(M): A, B = list(map(int, input().split())) Hn[A - 1] = max(Hn[A - 1], H[B - 1]) Hn[B - 1] = max(Hn[B - 1], H[A - 1]) print((sum([1 for n in range(N) if H[n] > Hn[n]])))
8
8
311
277
N, M = list(map(int, input().split())) H = list(map(int, input().split())) Hneig = [[] for _ in range(N)] for _ in range(M): A, B = list(map(int, input().split())) Hneig[A - 1].append(H[B - 1]) Hneig[B - 1].append(H[A - 1]) print((sum([1 for n in range(N) if len(Hneig[n]) == 0 or H[n] > max(Hneig[n])])))
N, M = list(map(int, input().split())) H = list(map(int, input().split())) Hn = [0] * N for _ in range(M): A, B = list(map(int, input().split())) Hn[A - 1] = max(Hn[A - 1], H[B - 1]) Hn[B - 1] = max(Hn[B - 1], H[A - 1]) print((sum([1 for n in range(N) if H[n] > Hn[n]])))
false
0
[ "-Hneig = [[] for _ in range(N)]", "+Hn = [0] * N", "- Hneig[A - 1].append(H[B - 1])", "- Hneig[B - 1].append(H[A - 1])", "-print((sum([1 for n in range(N) if len(Hneig[n]) == 0 or H[n] > max(Hneig[n])])))", "+ Hn[A - 1] = max(Hn[A - 1], H[B - 1])", "+ Hn[B - 1] = max(Hn[B - 1], H[A - 1])", ...
false
0.044097
0.064496
0.68371
[ "s328697468", "s970203313" ]
u170201762
p02889
python
s068109214
s876930156
1,993
1,627
77,784
17,964
Accepted
Accepted
18.36
INF = float('inf') N,M,L = list(map(int,input().split())) cost = [[INF]*N for _ in range(N)] for i in range(M): a,b,c = list(map(int,input().split())) cost[a-1][b-1] = c cost[b-1][a-1] = c for k in range(N): for i in range(N): for j in range(N): if cost[i][j] > cost[i][k]...
from scipy.sparse.csgraph import floyd_warshall as fw INF = float('inf') N,M,L = list(map(int,input().split())) cost = [[INF]*N for _ in range(N)] for i in range(M): a,b,c = list(map(int,input().split())) cost[a-1][b-1] = c cost[b-1][a-1] = c cost = fw(cost) for i in range(N): for j in ran...
40
32
955
694
INF = float("inf") N, M, L = list(map(int, input().split())) cost = [[INF] * N for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) cost[a - 1][b - 1] = c cost[b - 1][a - 1] = c for k in range(N): for i in range(N): for j in range(N): if cost[i][j] > cost[i...
from scipy.sparse.csgraph import floyd_warshall as fw INF = float("inf") N, M, L = list(map(int, input().split())) cost = [[INF] * N for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) cost[a - 1][b - 1] = c cost[b - 1][a - 1] = c cost = fw(cost) for i in range(N): for j in ...
false
20
[ "+from scipy.sparse.csgraph import floyd_warshall as fw", "+", "-for k in range(N):", "- for i in range(N):", "- for j in range(N):", "- if cost[i][j] > cost[i][k] + cost[k][j]:", "- cost[i][j] = cost[i][k] + cost[k][j]", "+cost = fw(cost)", "-for k in range(N):",...
false
0.041143
0.359324
0.114502
[ "s068109214", "s876930156" ]
u532966492
p02850
python
s278722846
s296875586
786
634
87,256
47,284
Accepted
Accepted
19.34
def main(): n=int(eval(input())) ab=[list(map(int,input().split())) for _ in [0]*(n-1)] g=[[] for _ in [0]*n] [g[a-1].append(b-1) for a,b in ab] [g[b-1].append(a-1) for a,b in ab] color=[-1]*n color[0]=0 q=[[0,0]] while q: qq=[] while q: i,root...
def main(): n=int(eval(input())) ab=[list(map(int,input().split())) for _ in [0]*(n-1)] g=[[] for _ in [0]*n] [g[a-1].append(b-1) for a,b in ab] [g[b-1].append(a-1) for a,b in ab] color=[-1]*n color[0]=0 q=[[0,0]] while q: qq=[] while q: i,root...
27
45
675
1,021
def main(): n = int(eval(input())) ab = [list(map(int, input().split())) for _ in [0] * (n - 1)] g = [[] for _ in [0] * n] [g[a - 1].append(b - 1) for a, b in ab] [g[b - 1].append(a - 1) for a, b in ab] color = [-1] * n color[0] = 0 q = [[0, 0]] while q: qq = [] while...
def main(): n = int(eval(input())) ab = [list(map(int, input().split())) for _ in [0] * (n - 1)] g = [[] for _ in [0] * n] [g[a - 1].append(b - 1) for a, b in ab] [g[b - 1].append(a - 1) for a, b in ab] color = [-1] * n color[0] = 0 q = [[0, 0]] while q: qq = [] while...
false
40
[ "+ d = [-1] * n", "+ d[0] = 0", "+ q = [0]", "+ cnt = 0", "+ while q:", "+ qq = []", "+ cnt += 1", "+ while q:", "+ i = q.pop()", "+ for j in g[i]:", "+ if d[j] == -1:", "+ d[j] = cnt", "+ ...
false
0.141583
0.037608
3.764718
[ "s278722846", "s296875586" ]
u299869545
p02837
python
s375547351
s212301319
1,357
326
3,188
50,904
Accepted
Accepted
75.98
n = int(eval(input())) shogens = [] for i in range(n): a = int(eval(input())) shogens.append([]) for j in range(a): x, y = list(map(int, input().split())) x -= 1 shogens[-1].append((x,y)) def is_honest(i, j): return (i >> j) % 2 == 1 def honest_cnt(i): ans =...
n = int(eval(input())) a = [0] * n x = [[0] * n for i in range(n)] y = [[0] * n for i in range(n)] for i in range(n): a[i] = int(eval(input())) for j in range(a[i]): x[i][j], y[i][j] = list(map(int, input().split())) x[i][j] -= 1 def check(honest): for i in range(n): ...
34
31
715
763
n = int(eval(input())) shogens = [] for i in range(n): a = int(eval(input())) shogens.append([]) for j in range(a): x, y = list(map(int, input().split())) x -= 1 shogens[-1].append((x, y)) def is_honest(i, j): return (i >> j) % 2 == 1 def honest_cnt(i): ans = 0 for j ...
n = int(eval(input())) a = [0] * n x = [[0] * n for i in range(n)] y = [[0] * n for i in range(n)] for i in range(n): a[i] = int(eval(input())) for j in range(a[i]): x[i][j], y[i][j] = list(map(int, input().split())) x[i][j] -= 1 def check(honest): for i in range(n): if not honest[...
false
8.823529
[ "-shogens = []", "+a = [0] * n", "+x = [[0] * n for i in range(n)]", "+y = [[0] * n for i in range(n)]", "- a = int(eval(input()))", "- shogens.append([])", "- for j in range(a):", "- x, y = list(map(int, input().split()))", "- x -= 1", "- shogens[-1].append((x, y))",...
false
0.046682
0.046289
1.008474
[ "s375547351", "s212301319" ]
u453815934
p03805
python
s117385214
s818883991
58
36
3,064
4,084
Accepted
Accepted
37.93
import itertools a,b=list(map(int,input().split())) A=[] for _ in range(a-1): A.append(_+2) List=[list(map(int,input().split())) for i in range(b)] count=0 for i in itertools.permutations(A): ju=True if [1,i[0]] in List or [i[0],1] in List: ju=True else: ju=False for j in range(a-2): ...
import math import sys from collections import deque import copy import itertools from itertools import permutations def mi() : return list(map(int,input().split())) def i() : return int(eval(input())) a,b=mi() ans=0 l=[[] for _ in range(a)] for i in range(b): u,v=mi() l[u-1].append(v-1) l[v-1].appe...
19
30
430
543
import itertools a, b = list(map(int, input().split())) A = [] for _ in range(a - 1): A.append(_ + 2) List = [list(map(int, input().split())) for i in range(b)] count = 0 for i in itertools.permutations(A): ju = True if [1, i[0]] in List or [i[0], 1] in List: ju = True else: ju = False ...
import math import sys from collections import deque import copy import itertools from itertools import permutations def mi(): return list(map(int, input().split())) def i(): return int(eval(input())) a, b = mi() ans = 0 l = [[] for _ in range(a)] for i in range(b): u, v = mi() l[u - 1].append(v -...
false
36.666667
[ "+import math", "+import sys", "+from collections import deque", "+import copy", "+from itertools import permutations", "-a, b = list(map(int, input().split()))", "-A = []", "-for _ in range(a - 1):", "- A.append(_ + 2)", "-List = [list(map(int, input().split())) for i in range(b)]", "-count ...
false
0.165254
0.095484
1.730705
[ "s117385214", "s818883991" ]
u768896740
p03644
python
s114692360
s355916428
20
17
3,316
3,064
Accepted
Accepted
15
n = int(eval(input())) for i in range(7): a = 2 ** i if a <= n: ans = a print(ans)
n = int(eval(input())) l = [1, 2, 4, 8, 16, 32, 64] num = 0 for i in range(n+1): if i in l: num = i print(num)
7
8
100
124
n = int(eval(input())) for i in range(7): a = 2**i if a <= n: ans = a print(ans)
n = int(eval(input())) l = [1, 2, 4, 8, 16, 32, 64] num = 0 for i in range(n + 1): if i in l: num = i print(num)
false
12.5
[ "-for i in range(7):", "- a = 2**i", "- if a <= n:", "- ans = a", "-print(ans)", "+l = [1, 2, 4, 8, 16, 32, 64]", "+num = 0", "+for i in range(n + 1):", "+ if i in l:", "+ num = i", "+print(num)" ]
false
0.071781
0.075193
0.954627
[ "s114692360", "s355916428" ]
u729133443
p02854
python
s265978262
s487015942
211
147
26,220
25,124
Accepted
Accepted
30.33
n=int(eval(input())) *a,=list(map(int,input().split())) length=sum(a) for i in range(1,n):a[i]+=a[i-1] m=10**18 for i in range(n-1): left=a[i] right=length-left m=min(m,abs(left-right)) print(m)
n,*a=list(map(int,open(0).read().split())) s=sum(a) for i in range(1,n):a[i]+=a[i-1] print((min(abs(t*2-s)for t in a)))
10
4
203
114
n = int(eval(input())) (*a,) = list(map(int, input().split())) length = sum(a) for i in range(1, n): a[i] += a[i - 1] m = 10**18 for i in range(n - 1): left = a[i] right = length - left m = min(m, abs(left - right)) print(m)
n, *a = list(map(int, open(0).read().split())) s = sum(a) for i in range(1, n): a[i] += a[i - 1] print((min(abs(t * 2 - s) for t in a)))
false
60
[ "-n = int(eval(input()))", "-(*a,) = list(map(int, input().split()))", "-length = sum(a)", "+n, *a = list(map(int, open(0).read().split()))", "+s = sum(a)", "-m = 10**18", "-for i in range(n - 1):", "- left = a[i]", "- right = length - left", "- m = min(m, abs(left - right))", "-print(m...
false
0.035821
0.126778
0.282552
[ "s265978262", "s487015942" ]
u485319545
p02995
python
s061224657
s083202421
35
31
5,076
9,176
Accepted
Accepted
11.43
a,b,c,d = list(map(int,input().split())) from fractions import gcd lcm = c*d//gcd(c,d) num_b_c = b//c num_b_d = b//d num_b_cd = b//lcm if a%c==0: num_a_c = a//c - 1 else: num_a_c = a//c if a%d==0: num_a_d = a//d - 1 else: num_a_d = a//d if a%lcm==0: num_a_cd = a//lcm - 1 e...
a,b,c,d = list(map(int,input().split())) from math import gcd lcm = (c*d)//gcd(c,d) b_div_c = b//c a_div_c = (a-1)//c b_div_d =b//d a_div_d = (a-1)//d b_div_cd = b//lcm a_div_cd = (a-1)//lcm ans1 = b_div_c - a_div_c ans2 = b_div_d - a_div_d ans3 = b_div_cd - a_div_cd ans = b -(a-1) - ans1 ...
37
23
502
339
a, b, c, d = list(map(int, input().split())) from fractions import gcd lcm = c * d // gcd(c, d) num_b_c = b // c num_b_d = b // d num_b_cd = b // lcm if a % c == 0: num_a_c = a // c - 1 else: num_a_c = a // c if a % d == 0: num_a_d = a // d - 1 else: num_a_d = a // d if a % lcm == 0: num_a_cd = a /...
a, b, c, d = list(map(int, input().split())) from math import gcd lcm = (c * d) // gcd(c, d) b_div_c = b // c a_div_c = (a - 1) // c b_div_d = b // d a_div_d = (a - 1) // d b_div_cd = b // lcm a_div_cd = (a - 1) // lcm ans1 = b_div_c - a_div_c ans2 = b_div_d - a_div_d ans3 = b_div_cd - a_div_cd ans = b - (a - 1) - ans...
false
37.837838
[ "-from fractions import gcd", "+from math import gcd", "-lcm = c * d // gcd(c, d)", "-num_b_c = b // c", "-num_b_d = b // d", "-num_b_cd = b // lcm", "-if a % c == 0:", "- num_a_c = a // c - 1", "-else:", "- num_a_c = a // c", "-if a % d == 0:", "- num_a_d = a // d - 1", "-else:", ...
false
0.047607
0.169671
0.280582
[ "s061224657", "s083202421" ]
u562935282
p02775
python
s331085763
s241972037
730
583
154,112
139,636
Accepted
Accepted
20.14
# 解説放送 # 写経 def main(): inf = 18 * (10 ** 6 + 1) s = eval(input()) s = '0' + s *s, = list(map(int, s)) # 先に一括でintにした n = len(s) dp = [[inf] * 2 for _ in range(n + 1)] dp[0][0] = 0 for i, c in enumerate(s[::-1]): for j in range(2): x = c + j ...
# 解説放送 # 写経 def main(): from itertools import islice inf = 18 * (10 ** 6 + 1) s = '0' + eval(input()) n = len(s) s = list(map(int, reversed(s))) # 先に一括でintにした dp = [[inf] * 2 for _ in range(n + 1)] dp[0][0] = 0 for i, c in enumerate(islice(s, 0, n, 1)): fo...
28
29
579
623
# 解説放送 # 写経 def main(): inf = 18 * (10**6 + 1) s = eval(input()) s = "0" + s (*s,) = list(map(int, s)) # 先に一括でintにした n = len(s) dp = [[inf] * 2 for _ in range(n + 1)] dp[0][0] = 0 for i, c in enumerate(s[::-1]): for j in range(2): x = c + j if x < 10: ...
# 解説放送 # 写経 def main(): from itertools import islice inf = 18 * (10**6 + 1) s = "0" + eval(input()) n = len(s) s = list(map(int, reversed(s))) # 先に一括でintにした dp = [[inf] * 2 for _ in range(n + 1)] dp[0][0] = 0 for i, c in enumerate(islice(s, 0, n, 1)): for j in range(2): ...
false
3.448276
[ "+ from itertools import islice", "+", "- s = eval(input())", "- s = \"0\" + s", "- (*s,) = list(map(int, s)) # 先に一括でintにした", "+ s = \"0\" + eval(input())", "+ s = list(map(int, reversed(s))) # 先に一括でintにした", "- for i, c in enumerate(s[::-1]):", "+ for i, c in enumerate(isli...
false
0.077817
0.039416
1.974222
[ "s331085763", "s241972037" ]
u269969976
p03220
python
s657832418
s353226725
20
18
3,064
3,060
Accepted
Accepted
10
# coding: utf-8 pointCount = int(eval(input())) (t, a) = [int(i) for i in input().rstrip().split(" ")] point_lit = [int(i) for i in input().rstrip().split(" ")] min_diff = 100000 ans = 0 for i in range(len(point_lit)): kion = t - (point_lit[i] * 0.006) diff = abs(a - kion) if diff < min_dif...
# coding: utf-8 n = int(eval(input())) (t, a) = [int(i) for i in input().rstrip().split(" ")] point_list = [int(i) for i in input().rstrip().split(" ")] ans = -1 nearest = 100000 for i in range(n): kion = abs(t - (point_list[i] * 0.006) - a) if kion < nearest: ans = i + 1 neare...
18
17
376
338
# coding: utf-8 pointCount = int(eval(input())) (t, a) = [int(i) for i in input().rstrip().split(" ")] point_lit = [int(i) for i in input().rstrip().split(" ")] min_diff = 100000 ans = 0 for i in range(len(point_lit)): kion = t - (point_lit[i] * 0.006) diff = abs(a - kion) if diff < min_diff: min_di...
# coding: utf-8 n = int(eval(input())) (t, a) = [int(i) for i in input().rstrip().split(" ")] point_list = [int(i) for i in input().rstrip().split(" ")] ans = -1 nearest = 100000 for i in range(n): kion = abs(t - (point_list[i] * 0.006) - a) if kion < nearest: ans = i + 1 nearest = kion print(an...
false
5.555556
[ "-pointCount = int(eval(input()))", "+n = int(eval(input()))", "-point_lit = [int(i) for i in input().rstrip().split(\" \")]", "-min_diff = 100000", "-ans = 0", "-for i in range(len(point_lit)):", "- kion = t - (point_lit[i] * 0.006)", "- diff = abs(a - kion)", "- if diff < min_diff:", "-...
false
0.039889
0.039054
1.021378
[ "s657832418", "s353226725" ]
u077291787
p02996
python
s816851945
s338239792
1,107
474
45,960
48,700
Accepted
Accepted
57.18
# ABC131D - Megalomania from itertools import accumulate as acc from operator import itemgetter as gt def main(): N = int(eval(input())) A = sorted([tuple(map(int, input().split())) for _ in range(N)], key=gt(1)) T, D = list(zip(*A)) # tasks, deadlines # all tasks finish within each deadline...
# ABC131D - Megalomania from itertools import accumulate as acc from operator import itemgetter as gt def main(): N, *AB = list(map(int, open(0).read().split())) T, D = list(zip(*sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1)))) flg = all(t <= d for t, d in zip(acc(T), D)) # all task...
16
14
438
414
# ABC131D - Megalomania from itertools import accumulate as acc from operator import itemgetter as gt def main(): N = int(eval(input())) A = sorted([tuple(map(int, input().split())) for _ in range(N)], key=gt(1)) T, D = list(zip(*A)) # tasks, deadlines # all tasks finish within each deadline? flg...
# ABC131D - Megalomania from itertools import accumulate as acc from operator import itemgetter as gt def main(): N, *AB = list(map(int, open(0).read().split())) T, D = list(zip(*sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1)))) flg = all(t <= d for t, d in zip(acc(T), D)) # all tasks finish...
false
12.5
[ "- N = int(eval(input()))", "- A = sorted([tuple(map(int, input().split())) for _ in range(N)], key=gt(1))", "- T, D = list(zip(*A)) # tasks, deadlines", "- # all tasks finish within each deadline?", "- flg = all(t <= d for t, d in zip(acc(T), D))", "+ N, *AB = list(map(int, open(0).rea...
false
0.046125
0.038141
1.209316
[ "s816851945", "s338239792" ]
u729939940
p02911
python
s042258326
s251958265
119
67
12,636
12,624
Accepted
Accepted
43.7
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * N for a in A: score[a - 1] += 1 for s in score: print(('Yes' if s > 0 else 'No'))
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * (N + 1) for a in A: score[a] += 1 print(("\n".join('Yes' if s > 0 else 'No' for s in score[1:])))
8
7
202
215
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * N for a in A: score[a - 1] += 1 for s in score: print(("Yes" if s > 0 else "No"))
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * (N + 1) for a in A: score[a] += 1 print(("\n".join("Yes" if s > 0 else "No" for s in score[1:])))
false
12.5
[ "-score = [K - Q] * N", "+score = [K - Q] * (N + 1)", "- score[a - 1] += 1", "-for s in score:", "- print((\"Yes\" if s > 0 else \"No\"))", "+ score[a] += 1", "+print((\"\\n\".join(\"Yes\" if s > 0 else \"No\" for s in score[1:])))" ]
false
0.096534
0.039392
2.450636
[ "s042258326", "s251958265" ]
u704284486
p02861
python
s195533997
s178251876
634
554
9,332
9,332
Accepted
Accepted
12.62
def n_n(n): c = 1 for i in range(1,n+1): c = c * i return c import itertools as itr N = int(eval(input())) n = n_n(N) rr=[] xy = [[0,0]] * (N) for i in range(N): xy[i] = list(map(int,input().split())) all = list(itr.permutations(xy)) for line in all: r = [0] * (N+1) x = [0]*(N+1) ...
import itertools as itr n = int(eval(input())) xy = [] for i in range(n): x, y = list(map(int, input().split(" "))) xy.append([x, y]) all = list(itr.permutations(xy)) n_n = 1 ans = [] for i in range(2,n+1): n_n = n_n*i for line in all: r = [0] * (n+1) x = [0]*(n+1) y = [0]*(n+1) ...
25
21
538
514
def n_n(n): c = 1 for i in range(1, n + 1): c = c * i return c import itertools as itr N = int(eval(input())) n = n_n(N) rr = [] xy = [[0, 0]] * (N) for i in range(N): xy[i] = list(map(int, input().split())) all = list(itr.permutations(xy)) for line in all: r = [0] * (N + 1) x = [0] *...
import itertools as itr n = int(eval(input())) xy = [] for i in range(n): x, y = list(map(int, input().split(" "))) xy.append([x, y]) all = list(itr.permutations(xy)) n_n = 1 ans = [] for i in range(2, n + 1): n_n = n_n * i for line in all: r = [0] * (n + 1) x = [0] * (n + 1) y = [0] * (n + 1) ...
false
16
[ "-def n_n(n):", "- c = 1", "- for i in range(1, n + 1):", "- c = c * i", "- return c", "-", "-", "-N = int(eval(input()))", "-n = n_n(N)", "-rr = []", "-xy = [[0, 0]] * (N)", "-for i in range(N):", "- xy[i] = list(map(int, input().split()))", "+n = int(eval(input()))", ...
false
0.036586
0.036034
1.015331
[ "s195533997", "s178251876" ]
u644907318
p03633
python
s252300126
s723447968
177
67
38,256
62,420
Accepted
Accepted
62.15
def gcd(x,y): while y>0: x,y = y,x%y return x N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] ans = T[0] for i in range(1,N): a = gcd(ans,T[i]) ans = (ans//a)*T[i] print(ans)
def gcd(x,y): while y>0: x,y = y,x%y return x N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] a = T[0] for i in range(1,N): b = T[i] c = gcd(a,b) a = (a//c)*b print(a)
11
12
214
212
def gcd(x, y): while y > 0: x, y = y, x % y return x N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] ans = T[0] for i in range(1, N): a = gcd(ans, T[i]) ans = (ans // a) * T[i] print(ans)
def gcd(x, y): while y > 0: x, y = y, x % y return x N = int(eval(input())) T = [int(eval(input())) for _ in range(N)] a = T[0] for i in range(1, N): b = T[i] c = gcd(a, b) a = (a // c) * b print(a)
false
8.333333
[ "-ans = T[0]", "+a = T[0]", "- a = gcd(ans, T[i])", "- ans = (ans // a) * T[i]", "-print(ans)", "+ b = T[i]", "+ c = gcd(a, b)", "+ a = (a // c) * b", "+print(a)" ]
false
0.036698
0.040603
0.903819
[ "s252300126", "s723447968" ]
u020390084
p03475
python
s414023857
s007089241
82
67
3,188
3,188
Accepted
Accepted
18.29
#!/usr/bin/env python3 import sys import math def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"): for i in range(N-1): ##i駅からスタート t = 0 for j in range(i,N-1): if t > S[j]: t = (S[j]+(math.ceil((t-S[j])/F[j]))*F[j]) + C[j] else: ...
#!/usr/bin/env python3 import sys import math def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"): # 駅間をC秒ではしる for i in range(N-1): cur = 0 for j in range(i,N-1): if cur <= S[j]: cur = S[j] else: cur = -(-(cur-S...
36
38
946
966
#!/usr/bin/env python3 import sys import math def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"): for i in range(N - 1): ##i駅からスタート t = 0 for j in range(i, N - 1): if t > S[j]: t = (S[j] + (math.ceil((t - S[j]) / F[j])) * F[j]) + C[j] else: ...
#!/usr/bin/env python3 import sys import math def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"): # 駅間をC秒ではしる for i in range(N - 1): cur = 0 for j in range(i, N - 1): if cur <= S[j]: cur = S[j] else: cur = -(-(cur - S[j]) /...
false
5.263158
[ "- for i in range(N - 1): ##i駅からスタート", "- t = 0", "+ # 駅間をC秒ではしる", "+ for i in range(N - 1):", "+ cur = 0", "- if t > S[j]:", "- t = (S[j] + (math.ceil((t - S[j]) / F[j])) * F[j]) + C[j]", "+ if cur <= S[j]:", "+ cur = S[j]"...
false
0.037467
0.038096
0.983483
[ "s414023857", "s007089241" ]
u658993896
p03700
python
s394216093
s681940543
1,715
1,499
7,068
7,068
Accepted
Accepted
12.59
import math """ def search(min_,max_,A,B,arr): # print(min_,max_) if min_==max_: return min_ mid=(max_+min_)//2 tmp=arr-mid*B if len(tmp)==0: return search(min_,mid,A,B,arr) tmp=map(lambda x:math.ceil(x/(A-B)),tmp) sum_=sum(list(tmp)) if sum_<...
import math N,A,B=list(map(int,input().split())) arr=[] for i in range(N): arr.append(int(eval(input()))) max_=max(arr)//B+1 min_=min(arr)//A d=A-B while min_!=max_: mid=(max_+min_)//2 sum_=0 for x in arr: y=(x-mid*B) if y<=0: continu...
60
29
1,174
438
import math """ def search(min_,max_,A,B,arr): # print(min_,max_) if min_==max_: return min_ mid=(max_+min_)//2 tmp=arr-mid*B if len(tmp)==0: return search(min_,mid,A,B,arr) tmp=map(lambda x:math.ceil(x/(A-B)),tmp) sum_=sum(list(tmp)) if sum_<=mid: return search(m...
import math N, A, B = list(map(int, input().split())) arr = [] for i in range(N): arr.append(int(eval(input()))) max_ = max(arr) // B + 1 min_ = min(arr) // A d = A - B while min_ != max_: mid = (max_ + min_) // 2 sum_ = 0 for x in arr: y = x - mid * B if y <= 0: continue ...
false
51.666667
[ "-\"\"\"", "-def search(min_,max_,A,B,arr):", "-# print(min_,max_)", "- if min_==max_:", "- return min_", "- mid=(max_+min_)//2", "- tmp=arr-mid*B", "- if len(tmp)==0:", "- return search(min_,mid,A,B,arr)", "- tmp=map(lambda x:math.ceil(x/(A-B)),tmp)", "- sum_=...
false
0.007519
0.066138
0.113688
[ "s394216093", "s681940543" ]
u747602774
p02901
python
s708782499
s751752108
331
247
76,012
43,356
Accepted
Accepted
25.38
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N,M = list(map(int,readline().split())) k = 2**N dp = [[INF]*k for i in range(M+1)] dp[0][0] = 0 for i in range(M): a,b = list(map(int,readline().split())) c = list(map...
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N,M = list(map(int,readline().split())) k = 2**N dp = [INF]*k dp[0] = 0 for i in range(M): a,b = list(map(int,readline().split())) c = list(map(int,readline().split())...
24
25
565
505
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9 + 7 # mod = 998244353 INF = 10**18 eps = 10**-7 N, M = list(map(int, readline().split())) k = 2**N dp = [[INF] * k for i in range(M + 1)] dp[0][0] = 0 for i in range(M): a, b = list(map(int, readline().split())) c = list(map(int,...
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9 + 7 # mod = 998244353 INF = 10**18 eps = 10**-7 N, M = list(map(int, readline().split())) k = 2**N dp = [INF] * k dp[0] = 0 for i in range(M): a, b = list(map(int, readline().split())) c = list(map(int, readline().split())) d...
false
4
[ "-dp = [[INF] * k for i in range(M + 1)]", "-dp[0][0] = 0", "+dp = [INF] * k", "+dp[0] = 0", "+ dpnew = dp[:]", "- dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])", "- dp[i + 1][j | d] = min(dp[i][j | d], dp[i][j] + a, dp[i + 1][j | d])", "-print((dp[M][2**N - 1] if dp[M][2**N - 1] != INF ...
false
0.037318
0.038017
0.981603
[ "s708782499", "s751752108" ]
u747602774
p03252
python
s863794949
s471402961
1,364
185
3,632
3,632
Accepted
Accepted
86.44
S = eval(input()) T = eval(input()) N = len(S) d = {chr(i):chr(i) for i in range(97,97+26)} ans = 'Yes' for i in range(N): now_si = d[S[i]] for k,v in list(d.items()): if v == now_si: d[k] = T[i] elif v == T[i]: d[k] = now_si for i in range(N): i...
S = eval(input()) T = eval(input()) N = len(S) start = [-1 for i in range(26)] goal = [-1 for i in range(26)] a = ord('a') ans = 'Yes' for i in range(N): s = ord(S[i])-a t = ord(T[i])-a if start[s] != -1 or goal[t] != -1: if start[s] != t or goal[t] != s: ans = 'No' st...
22
19
373
352
S = eval(input()) T = eval(input()) N = len(S) d = {chr(i): chr(i) for i in range(97, 97 + 26)} ans = "Yes" for i in range(N): now_si = d[S[i]] for k, v in list(d.items()): if v == now_si: d[k] = T[i] elif v == T[i]: d[k] = now_si for i in range(N): if d[S[i]] != T[i]...
S = eval(input()) T = eval(input()) N = len(S) start = [-1 for i in range(26)] goal = [-1 for i in range(26)] a = ord("a") ans = "Yes" for i in range(N): s = ord(S[i]) - a t = ord(T[i]) - a if start[s] != -1 or goal[t] != -1: if start[s] != t or goal[t] != s: ans = "No" start[s] = t ...
false
13.636364
[ "-d = {chr(i): chr(i) for i in range(97, 97 + 26)}", "+start = [-1 for i in range(26)]", "+goal = [-1 for i in range(26)]", "+a = ord(\"a\")", "- now_si = d[S[i]]", "- for k, v in list(d.items()):", "- if v == now_si:", "- d[k] = T[i]", "- elif v == T[i]:", "- ...
false
0.038419
0.038285
1.003522
[ "s863794949", "s471402961" ]
u348805958
p02781
python
s753797022
s255649454
45
23
3,428
3,440
Accepted
Accepted
48.89
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): N = list(map(int, eval(input()))) K = int(eval(input())) size = len(N) if size < K: print((0)) return dp = [[[0]*(size+1) for j in range(2)] for i in range(size+1)] dp[0][0][0] =...
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): N = list(map(int, eval(input()))) K = int(eval(input())) size = len(N) if size < K: print((0)) return dp = [[[0]*(size+1) for j in range(2)] for i in range(size+1)] dp[0][0][0] =...
29
37
748
814
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): N = list(map(int, eval(input()))) K = int(eval(input())) size = len(N) if size < K: print((0)) return dp = [[[0] * (size + 1) for j in range(2)] for i in range(size + 1)] dp[0][0][0] = 1 for i i...
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): N = list(map(int, eval(input()))) K = int(eval(input())) size = len(N) if size < K: print((0)) return dp = [[[0] * (size + 1) for j in range(2)] for i in range(size + 1)] dp[0][0][0] = 1 for i i...
false
21.621622
[ "- for less in range(2):", "- for k in range(i + 1):", "- for x in range(10 if less else N[i] + 1):", "- # print((i, less, k), x, (i+1, int(less or x < N[i]), k + (1 if x else 0)))", "- dp[i + 1][less or x < N[i]][k + (1 if x else 0)] +=...
false
0.035615
0.077037
0.462309
[ "s753797022", "s255649454" ]
u020390084
p03208
python
s587142244
s587690702
284
114
11,216
14,092
Accepted
Accepted
59.86
n, k = list(map(int,input().split())) h = [int(eval(input())) for _ in range(n)] h.sort() between = [h[i+1]-h[i] for i in range(n-1)] answer = 10**9 for i in range(1,n-1): between[i] += between[i-1] between.insert(0,0) for i in range(n-k+1): answer = min(answer, between[i+k-1]-between[i]) print(answ...
n, k, *h = list(map(int, open(0).read().split())) h.sort() ans = 10e9+7 for i in range(n-k+1): ans = min(ans, h[i+k-1]-h[i]) print(ans)
13
6
311
136
n, k = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] h.sort() between = [h[i + 1] - h[i] for i in range(n - 1)] answer = 10**9 for i in range(1, n - 1): between[i] += between[i - 1] between.insert(0, 0) for i in range(n - k + 1): answer = min(answer, between[i + k - 1] - between[i])...
n, k, *h = list(map(int, open(0).read().split())) h.sort() ans = 10e9 + 7 for i in range(n - k + 1): ans = min(ans, h[i + k - 1] - h[i]) print(ans)
false
53.846154
[ "-n, k = list(map(int, input().split()))", "-h = [int(eval(input())) for _ in range(n)]", "+n, k, *h = list(map(int, open(0).read().split()))", "-between = [h[i + 1] - h[i] for i in range(n - 1)]", "-answer = 10**9", "-for i in range(1, n - 1):", "- between[i] += between[i - 1]", "-between.insert(0...
false
0.116811
0.03881
3.009805
[ "s587142244", "s587690702" ]
u348805958
p02642
python
s054267774
s949146355
164
132
105,292
105,604
Accepted
Accepted
19.51
#!python3 import sys iim = lambda: list(map(int, sys.stdin.readline().rstrip().split())) def resolve(): it = list(map(int, sys.stdin.read().split())) N = next(it) A = [next(it) for i in range(N)] if N == 1: print((1)) return ax = max(A)+1 dp = [0]*ax for a...
#!python3 import sys iim = lambda: list(map(int, sys.stdin.readline().rstrip().split())) def resolve(): it = list(map(int, sys.stdin.read().split())) N = next(it) A = [next(it) for i in range(N)] if N == 1: print((1)) return ax = max(A)+1 dp = [0]*ax for a...
30
33
582
632
#!python3 import sys iim = lambda: list(map(int, sys.stdin.readline().rstrip().split())) def resolve(): it = list(map(int, sys.stdin.read().split())) N = next(it) A = [next(it) for i in range(N)] if N == 1: print((1)) return ax = max(A) + 1 dp = [0] * ax for ai in A: ...
#!python3 import sys iim = lambda: list(map(int, sys.stdin.readline().rstrip().split())) def resolve(): it = list(map(int, sys.stdin.read().split())) N = next(it) A = [next(it) for i in range(N)] if N == 1: print((1)) return ax = max(A) + 1 dp = [0] * ax for ai in A: ...
false
9.090909
[ "- # print(dp)", "- print((dp.count(1)))", "+ ans = 0", "+ for ai in A:", "+ if dp[ai] == 1:", "+ ans += 1", "+ print(ans)" ]
false
0.06437
0.045844
1.404084
[ "s054267774", "s949146355" ]
u326609687
p03037
python
s850456716
s566543420
319
170
3,188
22,832
Accepted
Accepted
46.71
N, M = list(map(int, input().split())) nmin = 1 nmax = N for _ in range(M): l, r = list(map(int, input().split())) nmin = max(nmin, l) nmax = min(nmax, r) if nmin > nmax: print((0)) else: print((nmax - nmin + 1))
import sys import numpy as np def main(lines): N, M = np.fromstring(lines[0], dtype=int, sep=" ") a = np.fromstring(''.join(lines[1:]), dtype=int, sep=" ").reshape((2, M), order='F') lmax = a[0].max() rmin = a[1].min() if lmax > rmin: print((0)) else: print((rmin - lmax + 1)) line...
11
16
226
354
N, M = list(map(int, input().split())) nmin = 1 nmax = N for _ in range(M): l, r = list(map(int, input().split())) nmin = max(nmin, l) nmax = min(nmax, r) if nmin > nmax: print((0)) else: print((nmax - nmin + 1))
import sys import numpy as np def main(lines): N, M = np.fromstring(lines[0], dtype=int, sep=" ") a = np.fromstring("".join(lines[1:]), dtype=int, sep=" ").reshape((2, M), order="F") lmax = a[0].max() rmin = a[1].min() if lmax > rmin: print((0)) else: print((rmin - lmax + 1)) ...
false
31.25
[ "-N, M = list(map(int, input().split()))", "-nmin = 1", "-nmax = N", "-for _ in range(M):", "- l, r = list(map(int, input().split()))", "- nmin = max(nmin, l)", "- nmax = min(nmax, r)", "-if nmin > nmax:", "- print((0))", "-else:", "- print((nmax - nmin + 1))", "+import sys", ...
false
0.036748
0.198566
0.185069
[ "s850456716", "s566543420" ]
u698693989
p02390
python
s036692828
s980244188
30
20
7,632
5,588
Accepted
Accepted
33.33
S=int(eval(input())) h = int(S/(60*60)) m = int(S/60)%60 s = S%60 print(("{0}:{1}:{2}".format(h,m,s)))
x=int(eval(input())) h=x//(60*60) x=x%(60*60) m=x//60 x=x%60 print((str(h)+":"+str(m)+":"+str(x)))
5
6
119
96
S = int(eval(input())) h = int(S / (60 * 60)) m = int(S / 60) % 60 s = S % 60 print(("{0}:{1}:{2}".format(h, m, s)))
x = int(eval(input())) h = x // (60 * 60) x = x % (60 * 60) m = x // 60 x = x % 60 print((str(h) + ":" + str(m) + ":" + str(x)))
false
16.666667
[ "-S = int(eval(input()))", "-h = int(S / (60 * 60))", "-m = int(S / 60) % 60", "-s = S % 60", "-print((\"{0}:{1}:{2}\".format(h, m, s)))", "+x = int(eval(input()))", "+h = x // (60 * 60)", "+x = x % (60 * 60)", "+m = x // 60", "+x = x % 60", "+print((str(h) + \":\" + str(m) + \":\" + str(x)))" ]
false
0.066534
0.065575
1.014622
[ "s036692828", "s980244188" ]
u852690916
p02793
python
s078606482
s299102316
1,744
361
287,112
57,052
Accepted
Accepted
79.3
N=int(eval(input())) *A,=list(map(int, input().split())) M=10**3 P=[] isp=[True]*M for n in range(2,M): if isp[n]==False: continue P.append(n) for m in range(n*n, M, n): isp[m]=False from collections import defaultdict D=[defaultdict(int) for _ in range(N)] for i in range(N): a=...
N=int(eval(input())) *A,=list(map(int, input().split())) M=10**3 P=[] isp=[True]*M for n in range(2,M): if isp[n]==False: continue P.append(n) for m in range(n*n, M, n): isp[m]=False from collections import defaultdict D=[defaultdict(int) for _ in range(N)] for i in range(N): a=...
37
108
725
2,815
N = int(eval(input())) (*A,) = list(map(int, input().split())) M = 10**3 P = [] isp = [True] * M for n in range(2, M): if isp[n] == False: continue P.append(n) for m in range(n * n, M, n): isp[m] = False from collections import defaultdict D = [defaultdict(int) for _ in range(N)] for i in r...
N = int(eval(input())) (*A,) = list(map(int, input().split())) M = 10**3 P = [] isp = [True] * M for n in range(2, M): if isp[n] == False: continue P.append(n) for m in range(n * n, M, n): isp[m] = False from collections import defaultdict D = [defaultdict(int) for _ in range(N)] for i in r...
false
65.740741
[ "-gcd = 1", "+MOD = 10**9 + 7", "+", "+", "+class Mint:", "+ def __init__(self, value=0):", "+ self.value = value % MOD", "+ if self.value < 0:", "+ self.value += MOD", "+", "+ @staticmethod", "+ def get_value(x):", "+ return x.value if isinstance(x, ...
false
0.077788
0.038006
2.046719
[ "s078606482", "s299102316" ]
u054825571
p02924
python
s117918190
s604884871
180
120
38,524
61,608
Accepted
Accepted
33.33
n=int(eval(input())) print((((n-1)*n)//2))
N=int(eval(input())) print((N*(N-1)//2))
2
2
35
33
n = int(eval(input())) print((((n - 1) * n) // 2))
N = int(eval(input())) print((N * (N - 1) // 2))
false
0
[ "-n = int(eval(input()))", "-print((((n - 1) * n) // 2))", "+N = int(eval(input()))", "+print((N * (N - 1) // 2))" ]
false
0.045628
0.041204
1.107363
[ "s117918190", "s604884871" ]
u340781749
p03588
python
s272705225
s338414179
331
286
3,188
3,060
Accepted
Accepted
13.6
from operator import add n = int(eval(input())) print((min(add(*list(map(int, input().split()))) for _ in range(n))))
print((min(sum(map(int,input().split()))for _ in range(int(eval(input()))))))
4
1
108
70
from operator import add n = int(eval(input())) print((min(add(*list(map(int, input().split()))) for _ in range(n))))
print((min(sum(map(int, input().split())) for _ in range(int(eval(input()))))))
false
75
[ "-from operator import add", "-", "-n = int(eval(input()))", "-print((min(add(*list(map(int, input().split()))) for _ in range(n))))", "+print((min(sum(map(int, input().split())) for _ in range(int(eval(input()))))))" ]
false
0.043812
0.102778
0.426282
[ "s272705225", "s338414179" ]
u847497464
p02983
python
s289517098
s499470699
228
143
3,060
3,060
Accepted
Accepted
37.28
#ABC 133 Remainder Minimization 2019 l, r = [ int(_) for _ in input().split() ] ls = [2018] for i in range(l,r): for j in range(i+1,r+1): y = (i*j) % 2019 if (i*j) % 2019 < min(x%2019 for x in ls): ls.append(i*j) if y == 0: break if y == 0: ...
#ABC 133 Remainder Minimization 2019 l, r = [ int(_) for _ in input().split() ] ls = [2018] for i in range(l,r): for j in range(i+1,r+1): y = (i*j) % 2019 if y < min(x for x in ls): ls.append(y) if y == 0: break if y == 0: break print...
16
16
366
343
# ABC 133 Remainder Minimization 2019 l, r = [int(_) for _ in input().split()] ls = [2018] for i in range(l, r): for j in range(i + 1, r + 1): y = (i * j) % 2019 if (i * j) % 2019 < min(x % 2019 for x in ls): ls.append(i * j) if y == 0: break if y == 0: br...
# ABC 133 Remainder Minimization 2019 l, r = [int(_) for _ in input().split()] ls = [2018] for i in range(l, r): for j in range(i + 1, r + 1): y = (i * j) % 2019 if y < min(x for x in ls): ls.append(y) if y == 0: break if y == 0: break print((min([x for x ...
false
0
[ "- if (i * j) % 2019 < min(x % 2019 for x in ls):", "- ls.append(i * j)", "+ if y < min(x for x in ls):", "+ ls.append(y)", "-print((min([x % 2019 for x in ls])))", "+print((min([x for x in ls])))" ]
false
0.037188
0.035864
1.036906
[ "s289517098", "s499470699" ]
u852690916
p02838
python
s449845826
s566248795
505
300
123,148
123,560
Accepted
Accepted
40.59
import sys def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) d = [0] * 60 for a in A: b = 0 while a: if a&1: d[b] += 1 a >>= 1 b += 1 ans = Mint() for i in range(60): a...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys def main(N, A): b1 = [0] * 60 for a in A: for i in range(60): if a & (1 << i): b1[i] += 1 ans = Mint() for i in range(60): ans += Mint(1 << i) * b1[i] * (N - b1[i]) print(ans) MOD = 10**9 + 7 class Mi...
87
94
2,532
2,545
import sys def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) d = [0] * 60 for a in A: b = 0 while a: if a & 1: d[b] += 1 a >>= 1 b += 1 ans = Mint() for i in range(60): ...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys def main(N, A): b1 = [0] * 60 for a in A: for i in range(60): if a & (1 << i): b1[i] += 1 ans = Mint() for i in range(60): ans += Mint(1 << i) * b1[i] * (N - b1[i]) print(ans) MOD = 10**9 + 7 ...
false
7.446809
[ "+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)", "-def main():", "- input = sys.stdin.readline", "- N = int(eval(input()))", "- A = list(map(int, input().split()))", "- d = [0] * 60", "+def main(N, A):", "+ b1 = [0] * 60", "- b = 0", "- while a:", "- if ...
false
0.039723
0.038567
1.029981
[ "s449845826", "s566248795" ]
u426764965
p02971
python
s242306290
s296807028
1,328
559
15,564
14,068
Accepted
Accepted
57.91
import numpy as np N = int(eval(input())) A = np.zeros(N, np.int32) for i in range(N): A[i] = int(eval(input())) A_asc = np.sort(A) max1 = A_asc[-1] max2 = A_asc[-2] for a in A: if a == max1: print(max2) else: print(max1)
N = int(eval(input())) A = [] for i in range(N): A.append(int(eval(input()))) A_asc = sorted(A) max1 = A_asc[-1] max2 = A_asc[-2] for a in A: if a == max1: print(max2) else: print(max1)
16
14
241
202
import numpy as np N = int(eval(input())) A = np.zeros(N, np.int32) for i in range(N): A[i] = int(eval(input())) A_asc = np.sort(A) max1 = A_asc[-1] max2 = A_asc[-2] for a in A: if a == max1: print(max2) else: print(max1)
N = int(eval(input())) A = [] for i in range(N): A.append(int(eval(input()))) A_asc = sorted(A) max1 = A_asc[-1] max2 = A_asc[-2] for a in A: if a == max1: print(max2) else: print(max1)
false
12.5
[ "-import numpy as np", "-", "-A = np.zeros(N, np.int32)", "+A = []", "- A[i] = int(eval(input()))", "-A_asc = np.sort(A)", "+ A.append(int(eval(input())))", "+A_asc = sorted(A)" ]
false
0.248102
0.084009
2.953286
[ "s242306290", "s296807028" ]
u936985471
p02659
python
s382091575
s829280530
24
22
9,120
9,144
Accepted
Accepted
8.33
import sys readline = sys.stdin.readline A,B = readline().split() A = int(A) B = int(float(B) * 100 + 0.5) print((A * B // 100))
import sys readline = sys.stdin.readline A,B = readline().split() A = int(A) B = round(float(B) * 100) print((A * B // 100))
8
9
135
134
import sys readline = sys.stdin.readline A, B = readline().split() A = int(A) B = int(float(B) * 100 + 0.5) print((A * B // 100))
import sys readline = sys.stdin.readline A, B = readline().split() A = int(A) B = round(float(B) * 100) print((A * B // 100))
false
11.111111
[ "-B = int(float(B) * 100 + 0.5)", "+B = round(float(B) * 100)" ]
false
0.045422
0.035083
1.294714
[ "s382091575", "s829280530" ]
u867848444
p02837
python
s197409325
s734323290
535
432
44,396
3,064
Accepted
Accepted
19.25
def solve(): n=int(eval(input())) ev=[[] for _ in range(n)] for i in range(n): a=int(eval(input())) l=[] for j in range(a):#証言 x,y=list(map(int,input().split())) l.append([x-1,y]) ev[i]=l ans=0 for i in range(2*...
n=int(eval(input())) evi=[] for i in range(n): a=int(eval(input())) l=[list(map(int,input().split())) for i in range(a)] evi+=[l]#証言をすべて集める ans=0 for i in range(2**n): mujyun=[] h_list=[] count=0 for j in range(n): if ((i>>j)&1):#各桁が1かどうか count+=1 ...
40
26
911
575
def solve(): n = int(eval(input())) ev = [[] for _ in range(n)] for i in range(n): a = int(eval(input())) l = [] for j in range(a): # 証言 x, y = list(map(int, input().split())) l.append([x - 1, y]) ev[i] = l ans = 0 for i in range(2**n): ...
n = int(eval(input())) evi = [] for i in range(n): a = int(eval(input())) l = [list(map(int, input().split())) for i in range(a)] evi += [l] # 証言をすべて集める ans = 0 for i in range(2**n): mujyun = [] h_list = [] count = 0 for j in range(n): if (i >> j) & 1: # 各桁が1かどうか count ...
false
35
[ "-def solve():", "- n = int(eval(input()))", "- ev = [[] for _ in range(n)]", "- for i in range(n):", "- a = int(eval(input()))", "- l = []", "- for j in range(a): # 証言", "- x, y = list(map(int, input().split()))", "- l.append([x - 1, y])", "- ...
false
0.046467
0.037528
1.238187
[ "s197409325", "s734323290" ]
u404676457
p03651
python
s514180764
s547188199
308
213
18,552
14,480
Accepted
Accepted
30.84
import sys n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() if a[-1] < k: print('IMPOSSIBLE') sys.exit(0) seta = set(a) if k in seta: print('POSSIBLE') sys.exit(0) change = True while change: change = False setb = seta.copy() sorteda = so...
import sys n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() if a[-1] < k: print('IMPOSSIBLE') sys.exit(0) seta = set(a) if k in seta: print('POSSIBLE') sys.exit(0) change = True lena = 0 while lena != len(seta): change = False sorteda = sorte...
33
31
685
628
import sys n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() if a[-1] < k: print("IMPOSSIBLE") sys.exit(0) seta = set(a) if k in seta: print("POSSIBLE") sys.exit(0) change = True while change: change = False setb = seta.copy() sorteda = sorted(seta) min...
import sys n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() if a[-1] < k: print("IMPOSSIBLE") sys.exit(0) seta = set(a) if k in seta: print("POSSIBLE") sys.exit(0) change = True lena = 0 while lena != len(seta): change = False sorteda = sorted(seta) mini =...
false
6.060606
[ "-while change:", "+lena = 0", "+while lena != len(seta):", "- setb = seta.copy()", "- setb.add(sorteda[i] % mini)", "- if len(setb) != len(seta):", "- change = True", "- seta = setb", "+ seta.add(sorteda[i] % mini)", "+ lena = len(seta)" ]
false
0.09204
0.086007
1.070152
[ "s514180764", "s547188199" ]
u859773831
p02959
python
s583522175
s587228392
178
163
18,624
18,624
Accepted
Accepted
8.43
n=int(eval(input())) monsters=[int(x) for x in input().split(' ')] powers=[int(x) for x in input().split(' ')] ans=0 for i in range(n): t=min(monsters[i],powers[i]) ans+=t t2=min(monsters[i+1],powers[i]-t) ans+=t2 monsters[i+1]-=t2 print(ans)
n=int(eval(input())) A=[int(x) for x in input().split(' ')] B=[int(x) for x in input().split(' ')] ans=0 for i in range(n): if (A[i]>=B[i]): ans+=B[i] else: ans+=A[i] B[i]-=A[i] if (A[i+1]>=B[i]): ans+=B[i] A[i+1]-=B[i] else: ans+=A[i+1] A[i+1]=0 print(ans)
11
18
251
293
n = int(eval(input())) monsters = [int(x) for x in input().split(" ")] powers = [int(x) for x in input().split(" ")] ans = 0 for i in range(n): t = min(monsters[i], powers[i]) ans += t t2 = min(monsters[i + 1], powers[i] - t) ans += t2 monsters[i + 1] -= t2 print(ans)
n = int(eval(input())) A = [int(x) for x in input().split(" ")] B = [int(x) for x in input().split(" ")] ans = 0 for i in range(n): if A[i] >= B[i]: ans += B[i] else: ans += A[i] B[i] -= A[i] if A[i + 1] >= B[i]: ans += B[i] A[i + 1] -= B[i] else: ...
false
38.888889
[ "-monsters = [int(x) for x in input().split(\" \")]", "-powers = [int(x) for x in input().split(\" \")]", "+A = [int(x) for x in input().split(\" \")]", "+B = [int(x) for x in input().split(\" \")]", "- t = min(monsters[i], powers[i])", "- ans += t", "- t2 = min(monsters[i + 1], powers[i] - t)"...
false
0.049383
0.045081
1.095413
[ "s583522175", "s587228392" ]
u014333473
p04044
python
s651762846
s238246335
31
28
9,068
9,088
Accepted
Accepted
9.68
N,L=map(int,input().split());print(*(sorted([input() for _ in range(N)])),sep='')
n,l=map(int,input().split());print(*sorted([input() for _ in range(n)]),sep='')
1
1
81
79
N, L = map(int, input().split()) print(*(sorted([input() for _ in range(N)])), sep="")
n, l = map(int, input().split()) print(*sorted([input() for _ in range(n)]), sep="")
false
0
[ "-N, L = map(int, input().split())", "-print(*(sorted([input() for _ in range(N)])), sep=\"\")", "+n, l = map(int, input().split())", "+print(*sorted([input() for _ in range(n)]), sep=\"\")" ]
false
0.139607
0.11143
1.252865
[ "s651762846", "s238246335" ]
u691018832
p02762
python
s013631936
s198308650
887
684
58,988
102,492
Accepted
Accepted
22.89
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ...
70
73
1,790
1,801
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x ...
false
4.109589
[ "-uf_p = UnionFind(n + 1)", "+uf = UnionFind(n + 1)", "+cnt = [-1] * n", "- uf_p.union(a, b)", "-ans = [uf_p.size(i) - 1 for i in range(1, n + 1)]", "+ uf.union(a, b)", "+for i in range(n):", "+ cnt[i] += uf.size(i + 1)", "- ans[a - 1] -= 1", "- ans[b - 1] -= 1", "+ cnt[a - 1] ...
false
0.041345
0.074299
0.556469
[ "s013631936", "s198308650" ]
u647999897
p02683
python
s507222396
s917079900
312
90
85,492
74,284
Accepted
Accepted
71.15
def solve(): N,M,X = list(map(int,input().split())) C = [] A = [] for i in range(N): val = list(map(int,input().split())) C.append(val[0]) A.append(val[1:]) ans = float('inf') for i in range(1 << N): money = 0 points = [0] * M for...
def solve(): N,M,X = list(map(int,input().split())) C = [] A = [] for _ in range(N): CA = list(map(int,input().split())) C.append(CA[0]) A.append(CA[1:]) ans = float('inf') for i in range(1<<N): cost_sum = 0 power = [0] * M for j ...
31
32
721
780
def solve(): N, M, X = list(map(int, input().split())) C = [] A = [] for i in range(N): val = list(map(int, input().split())) C.append(val[0]) A.append(val[1:]) ans = float("inf") for i in range(1 << N): money = 0 points = [0] * M for j in range(N)...
def solve(): N, M, X = list(map(int, input().split())) C = [] A = [] for _ in range(N): CA = list(map(int, input().split())) C.append(CA[0]) A.append(CA[1:]) ans = float("inf") for i in range(1 << N): cost_sum = 0 power = [0] * M for j in range(N):...
false
3.125
[ "- for i in range(N):", "- val = list(map(int, input().split()))", "- C.append(val[0])", "- A.append(val[1:])", "+ for _ in range(N):", "+ CA = list(map(int, input().split()))", "+ C.append(CA[0])", "+ A.append(CA[1:])", "- money = 0", "- ...
false
0.040148
0.041182
0.974903
[ "s507222396", "s917079900" ]
u525065967
p03290
python
s757163864
s270267506
29
22
3,188
3,064
Accepted
Accepted
24.14
d,g = list(map(int,input().split())) P,C = [0]*d,[0]*d for i in range(d): P[i],C[i] = list(map(int,input().split())) ans = 10**9 for bin in range(1, 1<<d): cnt = tot = 0 for i in range(d): if bin & 1<<i: cnt += P[i] tot += P[i]*(i+1)*100 + C[i] if tot < g: continue ...
d,g = list(map(int,input().split())) P,C = [0]*d,[0]*d for i in range(d): P[i],C[i] = list(map(int,input().split())) ans = 10**9 for bin in range(0, 1<<d): cnt = tot = 0 rest_max_bit = -1 for i in range(d): if bin & 1<<i: t = (i+1)*100 tot += P[i]*t + C[i] ...
19
22
566
627
d, g = list(map(int, input().split())) P, C = [0] * d, [0] * d for i in range(d): P[i], C[i] = list(map(int, input().split())) ans = 10**9 for bin in range(1, 1 << d): cnt = tot = 0 for i in range(d): if bin & 1 << i: cnt += P[i] tot += P[i] * (i + 1) * 100 + C[i] if tot ...
d, g = list(map(int, input().split())) P, C = [0] * d, [0] * d for i in range(d): P[i], C[i] = list(map(int, input().split())) ans = 10**9 for bin in range(0, 1 << d): cnt = tot = 0 rest_max_bit = -1 for i in range(d): if bin & 1 << i: t = (i + 1) * 100 tot += P[i] * t + ...
false
13.636364
[ "-for bin in range(1, 1 << d):", "+for bin in range(0, 1 << d):", "- for i in range(d):", "- if bin & 1 << i:", "- cnt += P[i]", "- tot += P[i] * (i + 1) * 100 + C[i]", "- if tot < g:", "- continue", "- ans = min(ans, cnt)", "+ rest_max_bit = -1", ...
false
0.035876
0.060317
0.594796
[ "s757163864", "s270267506" ]
u608088992
p03600
python
s795403188
s050028045
630
408
42,716
42,716
Accepted
Accepted
35.24
import sys from itertools import permutations, combinations def solve(): input = sys.stdin.readline N = int(eval(input())) A = [[int(a) for a in input().split()] for _ in range(N)] length = 0 possible = True for a in range(N): for b, l in enumerate(A[a]): for ...
import sys from itertools import permutations, combinations def solve(): input = sys.stdin.readline N = int(eval(input())) A = [[int(a) for a in input().split()] for _ in range(N)] length = 0 possible = True for a, b in combinations(list(range(N)), 2): Lab = A[a][b] ...
29
29
765
738
import sys from itertools import permutations, combinations def solve(): input = sys.stdin.readline N = int(eval(input())) A = [[int(a) for a in input().split()] for _ in range(N)] length = 0 possible = True for a in range(N): for b, l in enumerate(A[a]): for k in range(N):...
import sys from itertools import permutations, combinations def solve(): input = sys.stdin.readline N = int(eval(input())) A = [[int(a) for a in input().split()] for _ in range(N)] length = 0 possible = True for a, b in combinations(list(range(N)), 2): Lab = A[a][b] for k in ra...
false
0
[ "- for a in range(N):", "- for b, l in enumerate(A[a]):", "- for k in range(N):", "- if k != a and k != b:", "- if l > A[a][k] + A[k][b]:", "- possible = False", "- break", "- elif l...
false
0.063741
0.063241
1.007896
[ "s795403188", "s050028045" ]
u370331385
p04045
python
s487263174
s743614606
151
113
8,736
3,060
Accepted
Accepted
25.17
import itertools N,K = list(map(int,input().split())) D = list(map(int,input().split())) #使用可能数字の取り出し Num1 = [] for i in range(10): if(i in D): continue else: Num1.append(i) #組み合わせ Comb = [] n = len(str(N)) for i in range(n+1): Comb.append(Num1) Comb = list(itertools.product(*Comb)) ans = -1 ...
N,K = list(map(int,input().split())) D = list(input().split()) for x in range(N,10**6): x = str(x) judge = 1 for xi in x: if(xi in D): judge = 0 if(judge == 1): ans = x break print(ans)
37
14
724
229
import itertools N, K = list(map(int, input().split())) D = list(map(int, input().split())) # 使用可能数字の取り出し Num1 = [] for i in range(10): if i in D: continue else: Num1.append(i) # 組み合わせ Comb = [] n = len(str(N)) for i in range(n + 1): Comb.append(Num1) Comb = list(itertools.product(*Comb)) a...
N, K = list(map(int, input().split())) D = list(input().split()) for x in range(N, 10**6): x = str(x) judge = 1 for xi in x: if xi in D: judge = 0 if judge == 1: ans = x break print(ans)
false
62.162162
[ "-import itertools", "-", "-D = list(map(int, input().split()))", "-# 使用可能数字の取り出し", "-Num1 = []", "-for i in range(10):", "- if i in D:", "- continue", "- else:", "- Num1.append(i)", "-# 組み合わせ", "-Comb = []", "-n = len(str(N))", "-for i in range(n + 1):", "- Comb.a...
false
0.048269
0.050882
0.948648
[ "s487263174", "s743614606" ]
u968166680
p02949
python
s380860959
s415907568
522
391
74,456
70,876
Accepted
Accepted
25.1
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, P, *ABC = list(map(int, read().split())) edge = [0] * M for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)): ...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, P, *ABC = list(map(int, read().split())) G = [[] for _ in range(N)] G_rev = [[] for ...
42
70
939
1,606
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, P, *ABC = list(map(int, read().split())) edge = [0] * M for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)): edge[i] = (a -...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, M, P, *ABC = list(map(int, read().split())) G = [[] for _ in range(N)] G_rev = [[] for _ in range(N)] ...
false
40
[ "+from collections import deque", "- edge = [0] * M", "- for i, (a, b, c) in enumerate(zip(*[iter(ABC)] * 3)):", "- edge[i] = (a - 1, b - 1, -(c - P))", "+ G = [[] for _ in range(N)]", "+ G_rev = [[] for _ in range(N)]", "+ edge = []", "+ for a, b, c in zip(*[iter(ABC)] * 3):"...
false
0.123311
0.044009
2.801969
[ "s380860959", "s415907568" ]
u062147869
p03289
python
s791648837
s085910961
173
17
38,384
3,064
Accepted
Accepted
90.17
import sys S=eval(input()) N=len(S) #L=['B','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if S[0]!='A': print('WA') sys.exit() ans=0 for i in range(2,N-1) : if S[i]=='C': ans+=1 if ans!=1: print('WA') sys.exit() for i in range(N) :...
import sys S=eval(input()) N=len(S) #L=['B','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if S[0]!='A': print('WA') sys.exit() ans=0 for i in range(2,N-1) : if S[i]=='C': ans+=1 if ans!=1: print('WA') sys.exit() num=0 for i in ran...
21
22
432
428
import sys S = eval(input()) N = len(S) # L=['B','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if S[0] != "A": print("WA") sys.exit() ans = 0 for i in range(2, N - 1): if S[i] == "C": ans += 1 if ans != 1: print("WA") sys.exit() for i in range(...
import sys S = eval(input()) N = len(S) # L=['B','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if S[0] != "A": print("WA") sys.exit() ans = 0 for i in range(2, N - 1): if S[i] == "C": ans += 1 if ans != 1: print("WA") sys.exit() num = 0 for i i...
false
4.545455
[ "+num = 0", "- if S[i] in \"AC\":", "- continue", "- if S[i].isupper():", "- print(\"WA\")", "- sys.exit()", "+ if S[i] >= \"A\" and S[i] <= \"Z\":", "+ num += 1", "+if num != 2:", "+ print(\"WA\")", "+ sys.exit()" ]
false
0.040433
0.04166
0.970545
[ "s791648837", "s085910961" ]
u762540523
p02713
python
s543249536
s729923623
1,482
1,101
9,308
15,880
Accepted
Accepted
25.71
def gcd(a, b): while b: a, b = b, a % b return a def resolve(): k = int(eval(input())) l = [None] * k ** 2 for i in range(k): for j in range(k): l[i * k + j] = gcd(i + 1, j + 1) ans = 0 for i in l: for j in range(k): ans += gcd...
from functools import lru_cache @lru_cache(maxsize=100000) def gcd(a, b): while b: a, b = b, a % b return a def resolve(): k = int(eval(input())) l = [None] * k ** 2 for i in range(k): for j in range(k): l[i * k + j] = gcd(i + 1, j + 1) ans = 0 ...
21
24
388
451
def gcd(a, b): while b: a, b = b, a % b return a def resolve(): k = int(eval(input())) l = [None] * k**2 for i in range(k): for j in range(k): l[i * k + j] = gcd(i + 1, j + 1) ans = 0 for i in l: for j in range(k): ans += gcd(i, j + 1) pr...
from functools import lru_cache @lru_cache(maxsize=100000) def gcd(a, b): while b: a, b = b, a % b return a def resolve(): k = int(eval(input())) l = [None] * k**2 for i in range(k): for j in range(k): l[i * k + j] = gcd(i + 1, j + 1) ans = 0 for i in l: ...
false
12.5
[ "+from functools import lru_cache", "+", "+", "+@lru_cache(maxsize=100000)" ]
false
0.127862
0.108412
1.179405
[ "s543249536", "s729923623" ]
u640603056
p03478
python
s596850116
s048384649
36
26
3,060
2,940
Accepted
Accepted
27.78
n,a,b = list(map(int, input().split())) value = cnt = 0 for i in range(1, n+1): lst = [] lst = list(str(i)) for num in lst: value += int(num) if a <= value <= b: cnt += i value = 0 print(cnt)
def sums(n): ans = 0 while n > 0: a = n%10 n = n//10 ans += a return(ans) N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N+1): sum = sums(i) if A <= sum <= B: ans += i print(ans)
11
15
228
261
n, a, b = list(map(int, input().split())) value = cnt = 0 for i in range(1, n + 1): lst = [] lst = list(str(i)) for num in lst: value += int(num) if a <= value <= b: cnt += i value = 0 print(cnt)
def sums(n): ans = 0 while n > 0: a = n % 10 n = n // 10 ans += a return ans N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N + 1): sum = sums(i) if A <= sum <= B: ans += i print(ans)
false
26.666667
[ "-n, a, b = list(map(int, input().split()))", "-value = cnt = 0", "-for i in range(1, n + 1):", "- lst = []", "- lst = list(str(i))", "- for num in lst:", "- value += int(num)", "- if a <= value <= b:", "- cnt += i", "- value = 0", "-print(cnt)", "+def sums(n):", ...
false
0.03501
0.040023
0.874732
[ "s596850116", "s048384649" ]
u022407960
p02364
python
s644486997
s387905917
640
500
32,748
38,924
Accepted
Accepted
21.88
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 6 9 0 1 1 0 2 3 1 2 1 1 3 7 2 4 1 1 4 3 3 4 1 3 5 1 4 5 6 output: 5 """ import sys from operator import attrgetter class Edge(object): __slots__ = ('source', 'target', 'weight') def __init__(self): self.weight = f...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 6 9 0 1 1 0 2 3 1 2 1 1 3 7 2 4 1 1 4 3 3 4 1 3 5 1 4 5 6 output: 5 """ import sys import heapq as hp WHITE, GRAY, BLACK = 0, 1, 2 def generate_adj_table(v_table): for each in v_table: v_from, v_to, edge_weight = list...
91
69
2,309
1,576
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 6 9 0 1 1 0 2 3 1 2 1 1 3 7 2 4 1 1 4 3 3 4 1 3 5 1 4 5 6 output: 5 """ import sys from operator import attrgetter class Edge(object): __slots__ = ("source", "target", "weight") def __init__(self): self.weight = float("inf") self.source...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 6 9 0 1 1 0 2 3 1 2 1 1 3 7 2 4 1 1 4 3 3 4 1 3 5 1 4 5 6 output: 5 """ import sys import heapq as hp WHITE, GRAY, BLACK = 0, 1, 2 def generate_adj_table(v_table): for each in v_table: v_from, v_to, edge_weight = list(map(int, each)) init_a...
false
24.175824
[ "-from operator import attrgetter", "+import heapq as hp", "+", "+WHITE, GRAY, BLACK = 0, 1, 2", "-class Edge(object):", "- __slots__ = (\"source\", \"target\", \"weight\")", "-", "- def __init__(self):", "- self.weight = float(\"inf\")", "- self.source, self.target = None, Non...
false
0.083178
0.042819
1.94256
[ "s644486997", "s387905917" ]
u029000441
p03543
python
s336241203
s591157407
171
30
38,256
9,256
Accepted
Accepted
82.46
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush f...
# coding: utf-8 # hello worldと表示する # coding: utf-8 # hello worldと表示する #float型を許すな #numpyはpythonで import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby,...
25
36
800
1,012
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from ...
# coding: utf-8 # hello worldと表示する # coding: utf-8 # hello worldと表示する # float型を許すな # numpyはpythonで import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product...
false
30.555556
[ "+# coding: utf-8", "+# hello worldと表示する", "+# coding: utf-8", "+# hello worldと表示する", "+# float型を許すな", "+# numpyはpythonで", "-", "-# from collections import defaultdict", "+from collections import defaultdict", "-from math import floor, ceil, pi", "-", "-# from operator import itemgetter", "-...
false
0.03728
0.04672
0.797944
[ "s336241203", "s591157407" ]
u357751375
p02707
python
s323902838
s641271640
164
145
33,920
32,164
Accepted
Accepted
11.59
n = int(eval(input())) l = [0] * n a = list(map(int,input().split())) for i in range(n - 1): l[a[i] - 1] += 1 for i in range(n): print((l[i]))
n = int(eval(input())) a = list(map(int,input().split())) m = [0] * (n+1) for i in a: m[i] += 1 for i in m[1:]: print(i)
9
7
152
128
n = int(eval(input())) l = [0] * n a = list(map(int, input().split())) for i in range(n - 1): l[a[i] - 1] += 1 for i in range(n): print((l[i]))
n = int(eval(input())) a = list(map(int, input().split())) m = [0] * (n + 1) for i in a: m[i] += 1 for i in m[1:]: print(i)
false
22.222222
[ "-l = [0] * n", "-for i in range(n - 1):", "- l[a[i] - 1] += 1", "-for i in range(n):", "- print((l[i]))", "+m = [0] * (n + 1)", "+for i in a:", "+ m[i] += 1", "+for i in m[1:]:", "+ print(i)" ]
false
0.042362
0.059156
0.716112
[ "s323902838", "s641271640" ]
u265506056
p02787
python
s591382588
s382284736
1,632
1,494
3,668
3,644
Accepted
Accepted
8.46
H,N=list(map(int,input().split())) ab=[list(map(int,input().split())) for _ in range(N)] x=max(a for a,b in ab) dp=[0]*(H+x) for i in range (1,H+x): dp[i]=min(dp[i-a]+b for a,b in ab) print((dp[H]))
H,N=list(map(int,input().split())) ab=[list(map(int,input().split())) for _ in range(N)] x=max(a for a,b in ab) dp=[0]*(H+x) for i in range (1,H+1): dp[i]=min(dp[i-a]+b for a,b in ab) print((dp[H]))
7
7
200
200
H, N = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(N)] x = max(a for a, b in ab) dp = [0] * (H + x) for i in range(1, H + x): dp[i] = min(dp[i - a] + b for a, b in ab) print((dp[H]))
H, N = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(N)] x = max(a for a, b in ab) dp = [0] * (H + x) for i in range(1, H + 1): dp[i] = min(dp[i - a] + b for a, b in ab) print((dp[H]))
false
0
[ "-for i in range(1, H + x):", "+for i in range(1, H + 1):" ]
false
0.051111
0.052207
0.979012
[ "s591382588", "s382284736" ]
u623687794
p02889
python
s222505574
s356493236
1,965
1,264
58,712
56,796
Accepted
Accepted
35.67
n,m,l=list(map(int,input().split())) INF=10**10 graph=[[INF for i in range(n)] for j in range(n)] fuel=[[INF for i in range(n)] for j in range(n)] for i in range(n): graph[i][i]=0 for i in range(m): a,b,c=list(map(int,input().split())) a-=1;b-=1 if c>l:continue graph[a][b],graph[b][a]=c,c ...
import sys input=sys.stdin.readline n,m,l=list(map(int,input().split())) INF=10**10 graph=[[INF for i in range(n)] for j in range(n)] fuel=[[INF for i in range(n)] for j in range(n)] for i in range(n): graph[i][i]=0 for i in range(m): a,b,c=list(map(int,input().split())) a-=1;b-=1 if c>l:cont...
29
31
803
841
n, m, l = list(map(int, input().split())) INF = 10**10 graph = [[INF for i in range(n)] for j in range(n)] fuel = [[INF for i in range(n)] for j in range(n)] for i in range(n): graph[i][i] = 0 for i in range(m): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 if c > l: continue g...
import sys input = sys.stdin.readline n, m, l = list(map(int, input().split())) INF = 10**10 graph = [[INF for i in range(n)] for j in range(n)] fuel = [[INF for i in range(n)] for j in range(n)] for i in range(n): graph[i][i] = 0 for i in range(m): a, b, c = list(map(int, input().split())) a -= 1 b -=...
false
6.451613
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.038283
0.039617
0.966307
[ "s222505574", "s356493236" ]
u533039576
p02881
python
s338525852
s944014815
351
299
2,940
2,940
Accepted
Accepted
14.81
n = int(eval(input())) ans = n - 1 for i in range(2, n): if i * i > n: break if n % i == 0: ans = min(ans, i + n // i - 2) print(ans)
n = int(eval(input())) ans = n - 1 for i in range(1, n): if i * i > n: break if n % i != 0: continue ans = min(ans, i + (n // i) - 2) print(ans)
11
11
165
179
n = int(eval(input())) ans = n - 1 for i in range(2, n): if i * i > n: break if n % i == 0: ans = min(ans, i + n // i - 2) print(ans)
n = int(eval(input())) ans = n - 1 for i in range(1, n): if i * i > n: break if n % i != 0: continue ans = min(ans, i + (n // i) - 2) print(ans)
false
0
[ "-for i in range(2, n):", "+for i in range(1, n):", "- if n % i == 0:", "- ans = min(ans, i + n // i - 2)", "+ if n % i != 0:", "+ continue", "+ ans = min(ans, i + (n // i) - 2)" ]
false
0.046009
0.044491
1.034104
[ "s338525852", "s944014815" ]
u852690916
p03387
python
s106705750
s988143170
179
17
38,408
2,940
Accepted
Accepted
90.5
*I,=list(map(int, input().split())) sm=sum(I) mx=max(I) h=(3*mx-sm) print((h//2 if h&1==0 else (h+3)//2))
*i, = list(map(int, input().split())) mx = max(i) sm = sum(i) print(((3 * mx - sm) // 2 if (mx + sm) % 2 == 0 else (3 * mx + 3 - sm) // 2))
5
4
101
135
(*I,) = list(map(int, input().split())) sm = sum(I) mx = max(I) h = 3 * mx - sm print((h // 2 if h & 1 == 0 else (h + 3) // 2))
(*i,) = list(map(int, input().split())) mx = max(i) sm = sum(i) print(((3 * mx - sm) // 2 if (mx + sm) % 2 == 0 else (3 * mx + 3 - sm) // 2))
false
20
[ "-(*I,) = list(map(int, input().split()))", "-sm = sum(I)", "-mx = max(I)", "-h = 3 * mx - sm", "-print((h // 2 if h & 1 == 0 else (h + 3) // 2))", "+(*i,) = list(map(int, input().split()))", "+mx = max(i)", "+sm = sum(i)", "+print(((3 * mx - sm) // 2 if (mx + sm) % 2 == 0 else (3 * mx + 3 - sm) // ...
false
0.167452
0.041005
4.083702
[ "s106705750", "s988143170" ]
u197300773
p03476
python
s639743184
s916743657
1,337
862
17,380
5,144
Accepted
Accepted
35.53
import math def Sieve_of_Eratosthenes(N): prime={} for i in range(2,N+1): prime[i]=1 for i in range(2,math.ceil(N**0.5)+1): tmp=set() for j in prime: if j>i and j%i==0: tmp.add(j) for j in tmp: prime.pop(j) return prime N=10**5 prime=Sieve_of_Eratosthenes(N) a=[0]*(N) for i in ran...
import math def sieve(n): if n < 2: is_prime = [False for _ in range(n+1)] return is_prime is_prime = [True for _ in range(n+1)] is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5)+1): if is_prime[i]: for j in range(i*2, n+1, i): ...
25
27
486
594
import math def Sieve_of_Eratosthenes(N): prime = {} for i in range(2, N + 1): prime[i] = 1 for i in range(2, math.ceil(N**0.5) + 1): tmp = set() for j in prime: if j > i and j % i == 0: tmp.add(j) for j in tmp: prime.pop(j) retur...
import math def sieve(n): if n < 2: is_prime = [False for _ in range(n + 1)] return is_prime is_prime = [True for _ in range(n + 1)] is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if is_prime[i]: for j in range(i * 2, n + 1, i): ...
false
7.407407
[ "-def Sieve_of_Eratosthenes(N):", "- prime = {}", "- for i in range(2, N + 1):", "- prime[i] = 1", "- for i in range(2, math.ceil(N**0.5) + 1):", "- tmp = set()", "- for j in prime:", "- if j > i and j % i == 0:", "- tmp.add(j)", "- fo...
false
1.562751
0.254143
6.149099
[ "s639743184", "s916743657" ]