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
u133936772
p02733
python
s858711439
s084686574
1,424
361
3,436
43,868
Accepted
Accepted
74.65
f=range h,w,k=list(map(int,input().split())) g=[[int(i) for i in eval(input())] for _ in f(h)] s=[[0]*-~w for _ in f(h+1)] for i in f(h): for j in f(w): s[i+1][j+1]=s[i+1][j]+s[i][j+1]+g[i][j]-s[i][j] a=h+w for i in f(2**~-h): u=d=l=r=c=0 e=[] while d<h: d+=1 if i>>d-1&1: e+=[(u,d)]; c+...
f=range h,w,k=list(map(int,input().split())) g=[[int(i) for i in eval(input())] for _ in f(h)] s=[[0]*-~w for _ in f(h+1)] for i in f(h): for j in f(w): s[i+1][j+1]=s[i+1][j]+s[i][j+1]+g[i][j]-s[i][j] a=h+w for i in f(2**~-h): u=d=l=r=c=0 e=[] for d in f(h): if i>>d&1: e+=[(u,d+1)]; c+=1; u=...
22
20
487
477
f = range h, w, k = list(map(int, input().split())) g = [[int(i) for i in eval(input())] for _ in f(h)] s = [[0] * -~w for _ in f(h + 1)] for i in f(h): for j in f(w): s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] + g[i][j] - s[i][j] a = h + w for i in f(2 ** ~-h): u = d = l = r = c = 0 e = [] whi...
f = range h, w, k = list(map(int, input().split())) g = [[int(i) for i in eval(input())] for _ in f(h)] s = [[0] * -~w for _ in f(h + 1)] for i in f(h): for j in f(w): s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] + g[i][j] - s[i][j] a = h + w for i in f(2 ** ~-h): u = d = l = r = c = 0 e = [] for...
false
9.090909
[ "- while d < h:", "- d += 1", "- if i >> d - 1 & 1:", "- e += [(u, d)]", "+ for d in f(h):", "+ if i >> d & 1:", "+ e += [(u, d + 1)]", "- u = d", "+ u = d + 1", "- while r < w:", "+ for r in f(w):", "- r += 1"...
false
0.037199
0.034764
1.070043
[ "s858711439", "s084686574" ]
u241159583
p03212
python
s415441569
s104540311
92
56
2,940
4,060
Accepted
Accepted
39.13
N = int(eval(input())) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) > 0 for c in "753") else 0 for c in "753": ret += dfs(s+c) return ret print((dfs("0")))
import itertools n = eval(input()) number = list("753") N = [] flag = False for i in range(3, 10): for v in itertools.product(number, repeat=i): if "7" in v and "5" in v and "3" in v: if int("".join(v)) <= int(n): N.append(int("".join(v))) print((len(N)))
9
10
185
268
N = int(eval(input())) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) > 0 for c in "753") else 0 for c in "753": ret += dfs(s + c) return ret print((dfs("0")))
import itertools n = eval(input()) number = list("753") N = [] flag = False for i in range(3, 10): for v in itertools.product(number, repeat=i): if "7" in v and "5" in v and "3" in v: if int("".join(v)) <= int(n): N.append(int("".join(v))) print((len(N)))
false
10
[ "-N = int(eval(input()))", "+import itertools", "-", "-def dfs(s):", "- if int(s) > N:", "- return 0", "- ret = 1 if all(s.count(c) > 0 for c in \"753\") else 0", "- for c in \"753\":", "- ret += dfs(s + c)", "- return ret", "-", "-", "-print((dfs(\"0\")))", "+n =...
false
0.085953
0.085642
1.003638
[ "s415441569", "s104540311" ]
u131984977
p02394
python
s894504528
s993547820
40
20
6,724
7,712
Accepted
Accepted
50
(W,H,x,y,r) = input().rstrip().split(' ') W = int(W) H = int(H) x = int(x) y = int(y) r = int(r) if x - r >= 0 and y - r >= 0 and x + r <= W and y + r<= H: print('Yes') else: print('No')
W, H, x, y, r = [int(i) for i in input().split()] if x + r <= W and y - r >= 0 and x - r >= 0 and y + r <= H: print("Yes") else: print("No")
11
6
205
154
(W, H, x, y, r) = input().rstrip().split(" ") W = int(W) H = int(H) x = int(x) y = int(y) r = int(r) if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H: print("Yes") else: print("No")
W, H, x, y, r = [int(i) for i in input().split()] if x + r <= W and y - r >= 0 and x - r >= 0 and y + r <= H: print("Yes") else: print("No")
false
45.454545
[ "-(W, H, x, y, r) = input().rstrip().split(\" \")", "-W = int(W)", "-H = int(H)", "-x = int(x)", "-y = int(y)", "-r = int(r)", "-if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H:", "+W, H, x, y, r = [int(i) for i in input().split()]", "+if x + r <= W and y - r >= 0 and x - r >= 0 and y + r...
false
0.068918
0.047055
1.464622
[ "s894504528", "s993547820" ]
u759934006
p00102
python
s265523104
s547959415
20
10
4,252
4,252
Accepted
Accepted
50
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in rang...
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in rang...
17
15
459
435
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] ...
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] ...
false
11.764706
[ "- s = \"\"", "- s += \"\".join([str(x).rjust(5, \" \") for x in a[i]]) + \"\\n\"", "- print(s, end=\" \")", "+ print(\"\".join([str(x).rjust(5, \" \") for x in a[i]]) + \"\\n\", end=\" \")" ]
false
0.035899
0.0573
0.62652
[ "s265523104", "s547959415" ]
u133356863
p02773
python
s766649264
s562734874
756
672
59,360
59,360
Accepted
Accepted
11.11
import collections n=int(eval(input())) s=list(eval(input()) for _ in range(n)) s1=collections.Counter(s) s2=max(s1.values()) count=list(s1.values()).count(s2) values, counts = list(zip(*s1.most_common(count))) ans=list(values) ans.sort() print(('\n'.join(ans)))
import collections n=int(eval(input())) s=list(eval(input()) for _ in range(n)) s1=collections.Counter(s) count=list(s1.values()).count(max(s1.values())) values, counts = list(zip(*s1.most_common(count))) ans=list(values) ans.sort() print(('\n'.join(ans)))
11
9
254
244
import collections n = int(eval(input())) s = list(eval(input()) for _ in range(n)) s1 = collections.Counter(s) s2 = max(s1.values()) count = list(s1.values()).count(s2) values, counts = list(zip(*s1.most_common(count))) ans = list(values) ans.sort() print(("\n".join(ans)))
import collections n = int(eval(input())) s = list(eval(input()) for _ in range(n)) s1 = collections.Counter(s) count = list(s1.values()).count(max(s1.values())) values, counts = list(zip(*s1.most_common(count))) ans = list(values) ans.sort() print(("\n".join(ans)))
false
18.181818
[ "-s2 = max(s1.values())", "-count = list(s1.values()).count(s2)", "+count = list(s1.values()).count(max(s1.values()))" ]
false
0.036486
0.036527
0.998871
[ "s766649264", "s562734874" ]
u134238756
p02931
python
s449251309
s773123409
764
578
25,788
54,528
Accepted
Accepted
24.35
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) def par(a): if P[a] < 0: return a t = par(P[a]) P[a] = t return t def unite(a, b): if par(a) == par(b): return 0 C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)] if P[par(b)] == P[par(a)]: ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) N, H, W = list(map(int, input().split())) P = [-1 for i in range(H+W)] C = [1] * (H+W) arr = [] for _ in range(N): r, c, a = list(map(int, input().split())) arr.append((a, r-1, c+H-1)) arr = sorted(arr) ans = 0 def find(a): if...
35
39
798
773
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) def par(a): if P[a] < 0: return a t = par(P[a]) P[a] = t return t def unite(a, b): if par(a) == par(b): return 0 C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)] if P[par(b)] == P[par(a...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) N, H, W = list(map(int, input().split())) P = [-1 for i in range(H + W)] C = [1] * (H + W) arr = [] for _ in range(N): r, c, a = list(map(int, input().split())) arr.append((a, r - 1, c + H - 1)) arr = sorted(arr) ans = 0 def find(a): if P...
false
10.25641
[ "+N, H, W = list(map(int, input().split()))", "+P = [-1 for i in range(H + W)]", "+C = [1] * (H + W)", "+arr = []", "+for _ in range(N):", "+ r, c, a = list(map(int, input().split()))", "+ arr.append((a, r - 1, c + H - 1))", "+arr = sorted(arr)", "+ans = 0", "-def par(a):", "+def find(a):"...
false
0.062709
0.054752
1.14533
[ "s449251309", "s773123409" ]
u197457087
p03682
python
s042709392
s717135305
1,901
1,687
131,980
150,620
Accepted
Accepted
11.26
class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def...
class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索して親を出す。 """ if self.par[x] == x: return x ...
60
64
1,477
1,624
class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) ...
class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索して親を出す。 """ if self.par[x] == x: return x else: ...
false
6.25
[ "+ \"\"\"", "+ x が属するグループを探索して親を出す。", "+ \"\"\"", "+ \"\"\"", "+ x と y のグループを結合", "+ \"\"\"", "+ \"\"\"", "+ x と y が同じグループか否か", "+ \"\"\"", "+ \"\"\"", "+ x が属するグループの要素数", "+ \"\"\"", "-import sys", "-", ...
false
0.048503
0.048219
1.005899
[ "s042709392", "s717135305" ]
u011438316
p02658
python
s653241916
s135848504
88
52
21,576
21,652
Accepted
Accepted
40.91
n = int(eval(input())) MX = 10**18 a = list(map(int, input().split())) a.sort() ans = 1 for x in a: ans *= x if ans > MX: print((-1)) exit(0) print(ans)
n = int(eval(input())) MX = 10**18 a = list(map(int, input().split())) for x in a: if x == 0: print((0)) exit(0) ans = 1 for x in a: ans *= x if ans > MX: print((-1)) exit(0) print(ans)
11
14
167
211
n = int(eval(input())) MX = 10**18 a = list(map(int, input().split())) a.sort() ans = 1 for x in a: ans *= x if ans > MX: print((-1)) exit(0) print(ans)
n = int(eval(input())) MX = 10**18 a = list(map(int, input().split())) for x in a: if x == 0: print((0)) exit(0) ans = 1 for x in a: ans *= x if ans > MX: print((-1)) exit(0) print(ans)
false
21.428571
[ "-a.sort()", "+for x in a:", "+ if x == 0:", "+ print((0))", "+ exit(0)" ]
false
0.042239
0.036996
1.141717
[ "s653241916", "s135848504" ]
u226108478
p02939
python
s909231471
s620674234
58
41
3,500
3,500
Accepted
Accepted
29.31
# -*- coding: utf-8 -*- def main(): s = eval(input()) n = len(s) pre = '' ans = 0 i = 0 # See: # https://atcoder.jp/contests/agc037/submissions/6955216 while i < n: cur = s[i] if pre == cur: if i + 1 < n: pre = cur + s[i + ...
# -*- coding: utf-8 -*- def main(): s = eval(input()) prev, cur = '', '' ans = 0 for si in s: cur += si # KeyInsight: curに1文字加える # prevとcurが異なる if cur != prev: ans += 1 # prevとcurを更新 prev = cur cur = '' ...
34
24
585
370
# -*- coding: utf-8 -*- def main(): s = eval(input()) n = len(s) pre = "" ans = 0 i = 0 # See: # https://atcoder.jp/contests/agc037/submissions/6955216 while i < n: cur = s[i] if pre == cur: if i + 1 < n: pre = cur + s[i + 1] # ...
# -*- coding: utf-8 -*- def main(): s = eval(input()) prev, cur = "", "" ans = 0 for si in s: cur += si # KeyInsight: curに1文字加える # prevとcurが異なる if cur != prev: ans += 1 # prevとcurを更新 prev = cur cur = "" print(ans) if __name__...
false
29.411765
[ "- n = len(s)", "- pre = \"\"", "+ prev, cur = \"\", \"\"", "- i = 0", "- # See:", "- # https://atcoder.jp/contests/agc037/submissions/6955216", "- while i < n:", "- cur = s[i]", "- if pre == cur:", "- if i + 1 < n:", "- pre = cur + s[...
false
0.036633
0.042893
0.854061
[ "s909231471", "s620674234" ]
u723711163
p02863
python
s769213036
s590505080
573
243
116,568
145,868
Accepted
Accepted
57.59
def knapsack(n, w, info): dp = [[0]*(w + 1) for i in range(n + 1)] for i in range(n): for j in range(w + 1): weight, value = info[i] if j < weight: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value) return dp N,T = list(map(int...
N,T = list(map(int,input().split())) foods = [] for _ in range(N): a,b = list(map(int,input().split())) foods.append([a,b]) foods.sort(key=lambda x: x[0]) # dp[i][j] = 1~i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 dp = [ [0]*(T+1) for _ in range(N+1) ] for i in range(N): a,b = foods[i] for j in range(T+1): ...
28
28
628
575
def knapsack(n, w, info): dp = [[0] * (w + 1) for i in range(n + 1)] for i in range(n): for j in range(w + 1): weight, value = info[i] if j < weight: dp[i + 1][j] = dp[i][j] else: dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value) ...
N, T = list(map(int, input().split())) foods = [] for _ in range(N): a, b = list(map(int, input().split())) foods.append([a, b]) foods.sort(key=lambda x: x[0]) # dp[i][j] = 1~i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 dp = [[0] * (T + 1) for _ in range(N + 1)] for i in range(N): a, b = foods[i] for j in range(T + ...
false
0
[ "-def knapsack(n, w, info):", "- dp = [[0] * (w + 1) for i in range(n + 1)]", "- for i in range(n):", "- for j in range(w + 1):", "- weight, value = info[i]", "- if j < weight:", "- dp[i + 1][j] = dp[i][j]", "- else:", "- dp...
false
0.036087
0.047707
0.756427
[ "s769213036", "s590505080" ]
u307622233
p02708
python
s876577594
s328439236
667
373
36,184
36,248
Accepted
Accepted
44.08
import numpy as np n, k = list(map(int, input().split())) MOD = 10 ** 9 + 7 ref = np.array(list(range(n + 1)), dtype='int64') ans = 0 for i in range(k, n + 2): min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2 max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2 ans += max_sum - min_sum + 1 ans ...
import numpy as np n, k = list(map(int, input().split())) MOD = 10 ** 9 + 7 ref = np.array(list(range(n + 1)), dtype='int64') max_sum = np.sum(ref[-k + 1:]) min_sum = np.sum(ref[:k - 1]) if k == 1: max_sum = min_sum = 0 ans = 0 for i in range(k, n + 2): min_sum += ref[i - 1] max_sum += ref[...
15
19
334
382
import numpy as np n, k = list(map(int, input().split())) MOD = 10**9 + 7 ref = np.array(list(range(n + 1)), dtype="int64") ans = 0 for i in range(k, n + 2): min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2 max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2 ans += max_sum - min_sum + 1 ans %= MOD print(ans...
import numpy as np n, k = list(map(int, input().split())) MOD = 10**9 + 7 ref = np.array(list(range(n + 1)), dtype="int64") max_sum = np.sum(ref[-k + 1 :]) min_sum = np.sum(ref[: k - 1]) if k == 1: max_sum = min_sum = 0 ans = 0 for i in range(k, n + 2): min_sum += ref[i - 1] max_sum += ref[-i] ans += m...
false
21.052632
[ "+max_sum = np.sum(ref[-k + 1 :])", "+min_sum = np.sum(ref[: k - 1])", "+if k == 1:", "+ max_sum = min_sum = 0", "- min_sum = (ref[i - 1] * (ref[i - 1] + 1)) // 2", "- max_sum = (n + ref[-i]) * (n - ref[-i] + 1) // 2", "+ min_sum += ref[i - 1]", "+ max_sum += ref[-i]" ]
false
0.45135
0.212825
2.12076
[ "s876577594", "s328439236" ]
u413165887
p02913
python
s730580805
s124221407
1,507
1,133
3,188
3,188
Accepted
Accepted
24.82
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n-1) and (s[i:j] in s[:i]+"0"+s[j:]): j += 1 result.append(j-i-1) print((max(result)))
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n-1) and (s[i:j] in s[j:]): j += 1 result.append(j-i-1) print((max(result)))
9
9
185
175
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n - 1) and (s[i:j] in s[:i] + "0" + s[j:]): j += 1 result.append(j - i - 1) print((max(result)))
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n - 1) and (s[i:j] in s[j:]): j += 1 result.append(j - i - 1) print((max(result)))
false
0
[ "- while (j < n - 1) and (s[i:j] in s[:i] + \"0\" + s[j:]):", "+ while (j < n - 1) and (s[i:j] in s[j:]):" ]
false
0.037837
0.112788
0.335469
[ "s730580805", "s124221407" ]
u222668979
p02614
python
s521016925
s902373955
154
88
71,740
74,380
Accepted
Accepted
42.86
from itertools import product from copy import deepcopy h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for hl in product([0, 1], repeat=h): for wl in product([0, 1], repeat=w): cnt = 0 cc = deepcopy(c) for ci, hi in zip(c, hl): ...
from itertools import product h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for hl in product([0, 1], repeat=h): for wl in product([0, 1], repeat=w): cnt = 0 for ci, hi in zip(c, hl): for cij, wj in zip(ci, wl): ...
18
15
487
413
from itertools import product from copy import deepcopy h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for hl in product([0, 1], repeat=h): for wl in product([0, 1], repeat=w): cnt = 0 cc = deepcopy(c) for ci, hi in zip(c, hl): for ...
from itertools import product h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for hl in product([0, 1], repeat=h): for wl in product([0, 1], repeat=w): cnt = 0 for ci, hi in zip(c, hl): for cij, wj in zip(ci, wl): if hi == 0 ...
false
16.666667
[ "-from copy import deepcopy", "- cc = deepcopy(c)", "- if cij == \"#\" and hi == 0 and wj == 0:", "- cnt += 1", "- if cnt == k:", "- ans += 1", "+ if hi == 0 and wj == 0:", "+ cnt += cij == \"#\"", "+ ...
false
0.155136
0.134437
1.153966
[ "s521016925", "s902373955" ]
u906501980
p02744
python
s868482947
s883337525
450
244
49,088
21,824
Accepted
Accepted
45.78
n = int(eval(input())) s = "abcdefghij" class Node: def __init__(self, string, index): self.children = [] self.string = string self.index = index def get_children(self): parent = self.string for i, c in enumerate(s[:self.index+1], 1): self.childr...
n = int(eval(input())) s = "abcdefghij" class Node: __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None]*(self.index+2) for i, c in enumerate(...
23
24
616
643
n = int(eval(input())) s = "abcdefghij" class Node: def __init__(self, string, index): self.children = [] self.string = string self.index = index def get_children(self): parent = self.string for i, c in enumerate(s[: self.index + 1], 1): self.children.appen...
n = int(eval(input())) s = "abcdefghij" class Node: __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None] * (self.index + 2) for i, c in enumerate(s[: se...
false
4.166667
[ "+ __slots__ = [\"string\", \"index\"]", "+", "- self.children = []", "+ out = [None] * (self.index + 2)", "- self.children.append(Node(parent + c, max(i, self.index)))", "- return self.children", "+ out[i] = Node(parent + c, max(i, self.index))", "+ ...
false
0.037387
0.115269
0.324346
[ "s868482947", "s883337525" ]
u186838327
p03435
python
s495597975
s657689255
188
169
38,512
38,256
Accepted
Accepted
10.11
l = [0]*3 for i in range(3): l[i] = list(map(int, input().split())) for i in range(2): if l[0][i]-l[1][i] != l[0][i+1]-l[1][i+1]: print('No') exit() if l[1][i]-l[2][i] != l[1][i+1]-l[2][i+1]: print('No') exit() else: print('Yes')
C = [list(map(int, input().split())) for _ in range(3)] D = [[0]*3 for _ in range(2)] for i in range(2): for j in range(3): D[i][j] = C[i+1][j]-C[i][j] flag = True if D[0][0] == D[0][1] and D[0][1] == D[0][2] and D[0][2] == D[0][0]: pass else: flag = False if D[1][0] == D[1][1] and D...
13
22
266
451
l = [0] * 3 for i in range(3): l[i] = list(map(int, input().split())) for i in range(2): if l[0][i] - l[1][i] != l[0][i + 1] - l[1][i + 1]: print("No") exit() if l[1][i] - l[2][i] != l[1][i + 1] - l[2][i + 1]: print("No") exit() else: print("Yes")
C = [list(map(int, input().split())) for _ in range(3)] D = [[0] * 3 for _ in range(2)] for i in range(2): for j in range(3): D[i][j] = C[i + 1][j] - C[i][j] flag = True if D[0][0] == D[0][1] and D[0][1] == D[0][2] and D[0][2] == D[0][0]: pass else: flag = False if D[1][0] == D[1][1] and D[1][1] == ...
false
40.909091
[ "-l = [0] * 3", "-for i in range(3):", "- l[i] = list(map(int, input().split()))", "+C = [list(map(int, input().split())) for _ in range(3)]", "+D = [[0] * 3 for _ in range(2)]", "- if l[0][i] - l[1][i] != l[0][i + 1] - l[1][i + 1]:", "- print(\"No\")", "- exit()", "- if l[1][...
false
0.037661
0.047694
0.789621
[ "s495597975", "s657689255" ]
u528470578
p03160
python
s843041676
s788673491
126
95
20,492
83,644
Accepted
Accepted
24.6
N = int(eval(input())) h = list(map(int, input().split())) # DP inf = float("inf") dp = [inf for _ in range(N)] dp[0] = 0 for i in range(1, N): if i == 1: dp[i] = abs(h[i] - h[i-1]) else: dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1])) print((dp[-1]))
# Frog1 N = int(eval(input())) h = list(map(int, input().split())) inf = float("inf") dp = [inf for _ in range(N)] dp[0] = 0 for i in range(N): for j in (1, 2): if i + j >= N: continue dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i+j])) print((dp[-1]))
13
12
304
290
N = int(eval(input())) h = list(map(int, input().split())) # DP inf = float("inf") dp = [inf for _ in range(N)] dp[0] = 0 for i in range(1, N): if i == 1: dp[i] = abs(h[i] - h[i - 1]) else: dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1])) print((dp[-1]))
# Frog1 N = int(eval(input())) h = list(map(int, input().split())) inf = float("inf") dp = [inf for _ in range(N)] dp[0] = 0 for i in range(N): for j in (1, 2): if i + j >= N: continue dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j])) print((dp[-1]))
false
7.692308
[ "+# Frog1", "-# DP", "-for i in range(1, N):", "- if i == 1:", "- dp[i] = abs(h[i] - h[i - 1])", "- else:", "- dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))", "+for i in range(N):", "+ for j in (1, 2):", "+ if i + j >= N:", "+ ...
false
0.070048
0.033799
2.072513
[ "s843041676", "s788673491" ]
u729133443
p03844
python
s485947350
s117511617
39
17
27,884
2,940
Accepted
Accepted
56.41
print(eval(input()))
print((eval(input())))
1
1
13
20
print(eval(input()))
print((eval(input())))
false
0
[ "-print(eval(input()))", "+print((eval(input())))" ]
false
0.044762
0.044758
1.000093
[ "s485947350", "s117511617" ]
u844789719
p02579
python
s847695301
s626293928
820
564
118,308
91,724
Accepted
Accepted
31.22
H, W, ch, cw, dh, dw, *S = open(0).read().split() H, W, ch, cw, dh, dw = [int(_) for _ in [H, W, ch, cw, dh, dw]] ch -= 1 cw -= 1 dh -= 1 dw -= 1 stack = [[ch, cw]] dist = [[None] * W for _ in range(H)] d = 0 while True: stack2 = [] warp = set() while stack: x, y = stack.pop() ...
H, W, ch, cw, dh, dw, *S = open(0).read().split() H, W, ch, cw, dh, dw = [int(_) - 1 for _ in [H, W, ch, cw, dh, dw]] H += 1 W += 1 stack = [[ch, cw]] d = 0 INF = 10**10 dists = [[INF] * W for _ in range(H)] dists[ch][cw] = 0 def valid(x, y): return 0 <= x < H and 0 <= y < W while stack: s...
41
41
1,171
1,104
H, W, ch, cw, dh, dw, *S = open(0).read().split() H, W, ch, cw, dh, dw = [int(_) for _ in [H, W, ch, cw, dh, dw]] ch -= 1 cw -= 1 dh -= 1 dw -= 1 stack = [[ch, cw]] dist = [[None] * W for _ in range(H)] d = 0 while True: stack2 = [] warp = set() while stack: x, y = stack.pop() if (x, y) == (...
H, W, ch, cw, dh, dw, *S = open(0).read().split() H, W, ch, cw, dh, dw = [int(_) - 1 for _ in [H, W, ch, cw, dh, dw]] H += 1 W += 1 stack = [[ch, cw]] d = 0 INF = 10**10 dists = [[INF] * W for _ in range(H)] dists[ch][cw] = 0 def valid(x, y): return 0 <= x < H and 0 <= y < W while stack: se = set() whil...
false
0
[ "-H, W, ch, cw, dh, dw = [int(_) for _ in [H, W, ch, cw, dh, dw]]", "-ch -= 1", "-cw -= 1", "-dh -= 1", "-dw -= 1", "+H, W, ch, cw, dh, dw = [int(_) - 1 for _ in [H, W, ch, cw, dh, dw]]", "+H += 1", "+W += 1", "-dist = [[None] * W for _ in range(H)]", "-while True:", "- stack2 = []", "- ...
false
0.037973
0.034891
1.088312
[ "s847695301", "s626293928" ]
u472065247
p03798
python
s486756903
s940680318
131
112
5,644
5,616
Accepted
Accepted
14.5
N = int(eval(input())) s = eval(input()) s += s[0] # S: 1, W: 0 for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)): l = [a0, a1] for i in range(1, N + 1): if s[i] == 'o': a0, a1 = a1, not (a0 ^ a1) else: a0, a1 = a1, (a0 ^ a1) l.append(a1) if (l[0] == l[-2]) and (l[1] == l[-1...
N = int(eval(input())) s = eval(input()) s += s[0] # S: 1, W: 0 for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)): l = [a0, a1] for c in s[1:]: if c == 'o': a0, a1 = a1, not (a0 ^ a1) else: a0, a1 = a1, (a0 ^ a1) l.append(a1) if (l[0] == l[-2]) and (l[1] == l[-1]): s = ...
21
21
409
394
N = int(eval(input())) s = eval(input()) s += s[0] # S: 1, W: 0 for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)): l = [a0, a1] for i in range(1, N + 1): if s[i] == "o": a0, a1 = a1, not (a0 ^ a1) else: a0, a1 = a1, (a0 ^ a1) l.append(a1) if (l[0] == l[-2]) and (...
N = int(eval(input())) s = eval(input()) s += s[0] # S: 1, W: 0 for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)): l = [a0, a1] for c in s[1:]: if c == "o": a0, a1 = a1, not (a0 ^ a1) else: a0, a1 = a1, (a0 ^ a1) l.append(a1) if (l[0] == l[-2]) and (l[1] == l[-1]...
false
0
[ "- for i in range(1, N + 1):", "- if s[i] == \"o\":", "+ for c in s[1:]:", "+ if c == \"o\":", "- s = \"\".join([\"S\" if i == 1 else \"W\" for i in l[:-2]])", "+ s = \"\".join(\"S\" if i == 1 else \"W\" for i in l[:-2])" ]
false
0.058557
0.046105
1.270096
[ "s486756903", "s940680318" ]
u130900604
p02582
python
s140118956
s804753984
77
69
61,636
61,676
Accepted
Accepted
10.39
# coding: utf-8 # Your code here! s=eval(input()) if "RRR"==s: print((3)) elif "RR" in s: print((2)) elif "R" in s: print((1)) else: print((0))
s=eval(input()) if s=="RRR": print((3)) elif s=="SSS": print((0)) elif "RR" in s: print((2)) else: print((1))
13
9
159
111
# coding: utf-8 # Your code here! s = eval(input()) if "RRR" == s: print((3)) elif "RR" in s: print((2)) elif "R" in s: print((1)) else: print((0))
s = eval(input()) if s == "RRR": print((3)) elif s == "SSS": print((0)) elif "RR" in s: print((2)) else: print((1))
false
30.769231
[ "-# coding: utf-8", "-# Your code here!", "-if \"RRR\" == s:", "+if s == \"RRR\":", "+elif s == \"SSS\":", "+ print((0))", "-elif \"R\" in s:", "+else:", "-else:", "- print((0))" ]
false
0.043223
0.154596
0.279585
[ "s140118956", "s804753984" ]
u254871849
p04013
python
s299444668
s091199355
309
25
21,908
3,444
Accepted
Accepted
91.91
import sys import numpy as np n, a, *x = list(map(int, sys.stdin.read().split())) def main(): dp = np.zeros((n + 1, 2501), dtype=np.int64) dp[0, 0] = 1 for i in range(n): dp[1:, x[i]:] += dp[:-1, :-x[i]].copy() i = np.arange(1, n + 1) print((dp[i, i * a].sum())) if __name__ =...
import sys from collections import defaultdict n, a, *x = list(map(int, sys.stdin.read().split())) for i in range(n): x[i] -= a def main(): dp = defaultdict(int); dp[0] = 1 for i in range(n): ndp = dp.copy() for k, v in list(dp.items()): ndp[k+x[i]] += v dp = ndp print((dp[0] - 1)...
15
17
338
349
import sys import numpy as np n, a, *x = list(map(int, sys.stdin.read().split())) def main(): dp = np.zeros((n + 1, 2501), dtype=np.int64) dp[0, 0] = 1 for i in range(n): dp[1:, x[i] :] += dp[:-1, : -x[i]].copy() i = np.arange(1, n + 1) print((dp[i, i * a].sum())) if __name__ == "__main...
import sys from collections import defaultdict n, a, *x = list(map(int, sys.stdin.read().split())) for i in range(n): x[i] -= a def main(): dp = defaultdict(int) dp[0] = 1 for i in range(n): ndp = dp.copy() for k, v in list(dp.items()): ndp[k + x[i]] += v dp = ndp ...
false
11.764706
[ "-import numpy as np", "+from collections import defaultdict", "+for i in range(n):", "+ x[i] -= a", "- dp = np.zeros((n + 1, 2501), dtype=np.int64)", "- dp[0, 0] = 1", "+ dp = defaultdict(int)", "+ dp[0] = 1", "- dp[1:, x[i] :] += dp[:-1, : -x[i]].copy()", "- i = np.arang...
false
0.477383
0.03863
12.357859
[ "s299444668", "s091199355" ]
u171366497
p03504
python
s078547018
s415879321
673
519
47,536
27,704
Accepted
Accepted
22.88
N,C=list(map(int,input().split())) from collections import defaultdict cannel={i:[] for i in range(1,1+C)} check=[tuple(map(int,input().split())) for i in range(N)] check.sort(key=lambda x:x[0]) for x in check: s,t,c=x if cannel[c]==[]: cannel[c].append((max(0,s-1),t)) elif s-cannel[c][-1][...
N,C=list(map(int,input().split())) from collections import defaultdict Cbef=defaultdict(int) time=defaultdict(int) TV=[tuple(map(int,input().split())) for i in range(N)] TV.sort(key=lambda x:x[0]) for s,t,c in TV: if Cbef[c]==s: time[s]+=1 time[t]-=1 Cbef[c]=t else: t...
25
22
658
473
N, C = list(map(int, input().split())) from collections import defaultdict cannel = {i: [] for i in range(1, 1 + C)} check = [tuple(map(int, input().split())) for i in range(N)] check.sort(key=lambda x: x[0]) for x in check: s, t, c = x if cannel[c] == []: cannel[c].append((max(0, s - 1), t)) elif ...
N, C = list(map(int, input().split())) from collections import defaultdict Cbef = defaultdict(int) time = defaultdict(int) TV = [tuple(map(int, input().split())) for i in range(N)] TV.sort(key=lambda x: x[0]) for s, t, c in TV: if Cbef[c] == s: time[s] += 1 time[t] -= 1 Cbef[c] = t else...
false
12
[ "-cannel = {i: [] for i in range(1, 1 + C)}", "-check = [tuple(map(int, input().split())) for i in range(N)]", "-check.sort(key=lambda x: x[0])", "-for x in check:", "- s, t, c = x", "- if cannel[c] == []:", "- cannel[c].append((max(0, s - 1), t))", "- elif s - cannel[c][-1][1] <= 1:",...
false
0.204891
0.173641
1.17997
[ "s078547018", "s415879321" ]
u029000441
p02837
python
s735211342
s765982379
1,426
167
3,776
75,380
Accepted
Accepted
88.29
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 fr...
# 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 from bisect import bisect_l...
47
52
1,341
1,376
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 mat...
# 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 from bisect import bisect_left, bi...
false
9.615385
[ "+# coding: utf-8", "+# hello worldと表示する", "+# float型を許すな", "+# numpyはpythonで", "-from math import floor, ceil", "+from math import floor, ceil, pi, factorial, sqrt", "+def SI():", "+ return input().rstrip()", "+", "+", "-# s=input().rstrip()", "- u = I()", "- for j in range(u):", ...
false
0.11273
0.087524
1.287989
[ "s735211342", "s765982379" ]
u285891772
p03295
python
s346681173
s163746453
279
241
36,224
30,028
Accepted
Accepted
13.62
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
36
36
1,124
1,116
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
false
0
[ "-ab.sort(key=lambda x: (x[1], x[0]))", "+ab.sort(key=lambda x: x[1])" ]
false
0.043199
0.044078
0.980047
[ "s346681173", "s163746453" ]
u185464141
p02836
python
s300568688
s359493708
833
17
22,984
2,940
Accepted
Accepted
97.96
# coding: utf-8 # submission # - User: herp_sy # https://atcoder.jp/contests/ # # lang: Python3 (3.4.3) import math import statistics import numpy as np import queue s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[len(s) - 1 - i]: cnt += 1 print(cnt)
# coding: utf-8 # submission # - User: herp_sy # https://atcoder.jp/contests/ # # lang: Python3 (3.4.3) s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[len(s) - 1 - i]: cnt += 1 print(cnt)
19
14
292
225
# coding: utf-8 # submission # - User: herp_sy # https://atcoder.jp/contests/ # # lang: Python3 (3.4.3) import math import statistics import numpy as np import queue s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[len(s) - 1 - i]: cnt += 1 print(cnt)
# coding: utf-8 # submission # - User: herp_sy # https://atcoder.jp/contests/ # # lang: Python3 (3.4.3) s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[len(s) - 1 - i]: cnt += 1 print(cnt)
false
26.315789
[ "-import math", "-import statistics", "-import numpy as np", "-import queue", "-" ]
false
0.112045
0.037687
2.973022
[ "s300568688", "s359493708" ]
u079827881
p02923
python
s791485477
s697484959
138
98
14,480
15,020
Accepted
Accepted
28.99
n = int(eval(input())) h = list(map(int,input().split())) count = [0]*(n-1) j = 0 count2 = [0]*(n-2) for i in range(n-1): if h[i] > h[i+1]: count[i] = 1 if h[i] < h[i+1]: count[i] = 0 if h[i] == h[i+1]: count[i] = 1 # print(count) z = 0 for i in range(n-2): i...
n = int(eval(input())) h = list(map(int,input().split())) count = 0 ans = 0 h.reverse() for i in range(n-1): if h[i]<=h[i+1]: count += 1 else: count = 0 ans = max(ans,count) print(ans)
32
12
509
217
n = int(eval(input())) h = list(map(int, input().split())) count = [0] * (n - 1) j = 0 count2 = [0] * (n - 2) for i in range(n - 1): if h[i] > h[i + 1]: count[i] = 1 if h[i] < h[i + 1]: count[i] = 0 if h[i] == h[i + 1]: count[i] = 1 # print(count) z = 0 for i in range(n - 2): if ...
n = int(eval(input())) h = list(map(int, input().split())) count = 0 ans = 0 h.reverse() for i in range(n - 1): if h[i] <= h[i + 1]: count += 1 else: count = 0 ans = max(ans, count) print(ans)
false
62.5
[ "-count = [0] * (n - 1)", "-j = 0", "-count2 = [0] * (n - 2)", "+count = 0", "+ans = 0", "+h.reverse()", "- if h[i] > h[i + 1]:", "- count[i] = 1", "- if h[i] < h[i + 1]:", "- count[i] = 0", "- if h[i] == h[i + 1]:", "- count[i] = 1", "-# print(count)", "-z = ...
false
0.037791
0.037601
1.005061
[ "s791485477", "s697484959" ]
u609061751
p03037
python
s945011589
s049626129
343
198
11,096
3,064
Accepted
Accepted
42.27
N,M = list(map(int,input().split())) A = [] B = [] for _ in range(M): temp = list(map(int,input().split())) A.append(temp[0]) B.append(temp[1]) cnt = 0 minA = max(A) maxA = min(B) if maxA - minA + 1 > 0: print((maxA - minA + 1)) else: print((0))
import sys input = lambda : sys.stdin.readline().rstrip() n, m = list(map(int, input().split())) left = -1 right = n + 1 for _ in range(m): l, r = list(map(int, input().split())) if r < left or l > right: print((0)) sys.exit() left = max(left, l) right = min(right, r) ...
15
17
284
330
N, M = list(map(int, input().split())) A = [] B = [] for _ in range(M): temp = list(map(int, input().split())) A.append(temp[0]) B.append(temp[1]) cnt = 0 minA = max(A) maxA = min(B) if maxA - minA + 1 > 0: print((maxA - minA + 1)) else: print((0))
import sys input = lambda: sys.stdin.readline().rstrip() n, m = list(map(int, input().split())) left = -1 right = n + 1 for _ in range(m): l, r = list(map(int, input().split())) if r < left or l > right: print((0)) sys.exit() left = max(left, l) right = min(right, r) print((right - left...
false
11.764706
[ "-N, M = list(map(int, input().split()))", "-A = []", "-B = []", "-for _ in range(M):", "- temp = list(map(int, input().split()))", "- A.append(temp[0])", "- B.append(temp[1])", "-cnt = 0", "-minA = max(A)", "-maxA = min(B)", "-if maxA - minA + 1 > 0:", "- print((maxA - minA + 1))"...
false
0.04368
0.037613
1.161287
[ "s945011589", "s049626129" ]
u761154175
p03854
python
s468055832
s646734249
1,122
75
3,832
3,316
Accepted
Accepted
93.32
s = eval(input()) t = '' result = 'YES' scripts = ['dream', 'dreamer', 'erase', 'eraser'] while len(s) > len(t) and result == 'YES': restmp = False for script in scripts: tmp = t + script if tmp == s[:len(tmp)]: if tmp == s: t = tmp rest...
s = eval(input()) t = '' result = 'NO' scripts = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(len(scripts)): script = scripts[i] script = script[::-1] scripts[i] = script s_rev = s[::-1] while len(s) > 0: for script in scripts: if s_rev[:len(script)] == script: ...
29
24
686
449
s = eval(input()) t = "" result = "YES" scripts = ["dream", "dreamer", "erase", "eraser"] while len(s) > len(t) and result == "YES": restmp = False for script in scripts: tmp = t + script if tmp == s[: len(tmp)]: if tmp == s: t = tmp restmp = True ...
s = eval(input()) t = "" result = "NO" scripts = ["dream", "dreamer", "erase", "eraser"] for i in range(len(scripts)): script = scripts[i] script = script[::-1] scripts[i] = script s_rev = s[::-1] while len(s) > 0: for script in scripts: if s_rev[: len(script)] == script: s_rev = s_r...
false
17.241379
[ "-result = \"YES\"", "+result = \"NO\"", "-while len(s) > len(t) and result == \"YES\":", "- restmp = False", "+for i in range(len(scripts)):", "+ script = scripts[i]", "+ script = script[::-1]", "+ scripts[i] = script", "+s_rev = s[::-1]", "+while len(s) > 0:", "- tmp = t + s...
false
0.076034
0.034187
2.224056
[ "s468055832", "s646734249" ]
u906428167
p03170
python
s268818618
s675247520
347
271
44,912
50,140
Accepted
Accepted
21.9
n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] dp = [-1 for _ in range(k+1)] for i in range(min(a)): dp[i] = 1 for i in range(k+1): tmp = 0 for x in a: if i-x < 0: continue else: tmp += dp[i-x] if tmp > 0: d...
n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] dp = [] for i in range(k+1): First_win = any([not dp[i-x] if i-x >= 0 else False for x in a]) dp.append(First_win) print(('First' if dp[k] else 'Second'))
21
10
399
249
n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] dp = [-1 for _ in range(k + 1)] for i in range(min(a)): dp[i] = 1 for i in range(k + 1): tmp = 0 for x in a: if i - x < 0: continue else: tmp += dp[i - x] if tmp > 0: dp[i] = 0 ...
n, k = list(map(int, input().split())) a = [int(x) for x in input().split()] dp = [] for i in range(k + 1): First_win = any([not dp[i - x] if i - x >= 0 else False for x in a]) dp.append(First_win) print(("First" if dp[k] else "Second"))
false
52.380952
[ "-dp = [-1 for _ in range(k + 1)]", "-for i in range(min(a)):", "- dp[i] = 1", "+dp = []", "- tmp = 0", "- for x in a:", "- if i - x < 0:", "- continue", "- else:", "- tmp += dp[i - x]", "- if tmp > 0:", "- dp[i] = 0", "- else:", "-...
false
0.039994
0.052965
0.755098
[ "s268818618", "s675247520" ]
u994988729
p03640
python
s690712097
s719614667
30
26
3,956
3,956
Accepted
Accepted
13.33
H, W = list(map(int, input().split())) N = int(eval(input())) A = list(map(int, input().split())) tmp = [] for i, a in enumerate(A, start=1): tmp.extend([i] * a) ans = [] rev = 0 add = [] for i in range(1, H * W + 1): add.append(tmp[i-1]) if i % W == 0: if rev: add = a...
H, W = list(map(int, input().split())) N = int(eval(input())) A = list(map(int, input().split())) col = [] for i, a in enumerate(A, start=1): col.extend([i] * a) grid = [] for h in range(H): x = col[h * W: (h + 1) * W] if h % 2 == 0: x.reverse() grid.append(x) for g in grid: ...
23
16
415
318
H, W = list(map(int, input().split())) N = int(eval(input())) A = list(map(int, input().split())) tmp = [] for i, a in enumerate(A, start=1): tmp.extend([i] * a) ans = [] rev = 0 add = [] for i in range(1, H * W + 1): add.append(tmp[i - 1]) if i % W == 0: if rev: add = add[::-1] ...
H, W = list(map(int, input().split())) N = int(eval(input())) A = list(map(int, input().split())) col = [] for i, a in enumerate(A, start=1): col.extend([i] * a) grid = [] for h in range(H): x = col[h * W : (h + 1) * W] if h % 2 == 0: x.reverse() grid.append(x) for g in grid: print((*g))
false
30.434783
[ "-tmp = []", "+col = []", "- tmp.extend([i] * a)", "-ans = []", "-rev = 0", "-add = []", "-for i in range(1, H * W + 1):", "- add.append(tmp[i - 1])", "- if i % W == 0:", "- if rev:", "- add = add[::-1]", "- ans.append(add)", "- rev = 1 - rev", "- ...
false
0.173537
0.123869
1.400977
[ "s690712097", "s719614667" ]
u894258749
p03253
python
s493270872
s034333234
44
19
3,064
3,064
Accepted
Accepted
56.82
inpl = lambda: list(map(int,input().split())) MOD = 10**9 + 7 N, M = inpl() def factorize(n): prime_list = [] factorize_list = [] i = 2 while i*i <= n: for p in prime_list: if i % p == 0: break else: prime_list.append(i) k = 0 while n % i == 0: n...
inpl = lambda: list(map(int,input().split())) MOD = 10**9 + 7 N, M = inpl() def factorize(n): factorize_list = [] i = 2 while i*i <= n: k = 0 while n % i == 0: n //= i k += 1 if k > 0: factorize_list.append(k) i += 1 if n > 1: factorize_list.append(1) r...
40
35
685
571
inpl = lambda: list(map(int, input().split())) MOD = 10**9 + 7 N, M = inpl() def factorize(n): prime_list = [] factorize_list = [] i = 2 while i * i <= n: for p in prime_list: if i % p == 0: break else: prime_list.append(i) k = 0 ...
inpl = lambda: list(map(int, input().split())) MOD = 10**9 + 7 N, M = inpl() def factorize(n): factorize_list = [] i = 2 while i * i <= n: k = 0 while n % i == 0: n //= i k += 1 if k > 0: factorize_list.append(k) i += 1 if n > 1: ...
false
12.5
[ "- prime_list = []", "- for p in prime_list:", "- if i % p == 0:", "- break", "- else:", "- prime_list.append(i)", "- k = 0", "- while n % i == 0:", "- n //= i", "- k += 1", "+ k = 0"...
false
0.088309
0.153013
0.577133
[ "s493270872", "s034333234" ]
u296518383
p02972
python
s074646979
s865303807
346
312
72,156
70,876
Accepted
Accepted
9.83
N=int(eval(input())) A=list(map(int,input().split())) A=[0]+A B=[0]*(N+1) #print(A) for i in range(N,0,-1): tmp=0 for j in range(2,N//i+1): if B[i*j]: tmp+=1 B[i]=(A[i]+tmp)%2 #print(B) C=[] for i in range(1,N+1): if B[i]: C.append(i) #print(C) print((len(C))) if len(C): print((*C))
M = int(eval(input())) A = [0] + list(map(int, input().split())) B = [0] * (M + 1) for i in range(M, 0, -1): j = 2 tmp = 0 while i * j <= M: B[i] += B[i * j] j += 1 B[i] += A[i] B[i] %= 2 answer = [] for i in range(M + 1): if B[i]: answer.append(i) if len(answer): pri...
20
24
309
366
N = int(eval(input())) A = list(map(int, input().split())) A = [0] + A B = [0] * (N + 1) # print(A) for i in range(N, 0, -1): tmp = 0 for j in range(2, N // i + 1): if B[i * j]: tmp += 1 B[i] = (A[i] + tmp) % 2 # print(B) C = [] for i in range(1, N + 1): if B[i]: C.append(i) ...
M = int(eval(input())) A = [0] + list(map(int, input().split())) B = [0] * (M + 1) for i in range(M, 0, -1): j = 2 tmp = 0 while i * j <= M: B[i] += B[i * j] j += 1 B[i] += A[i] B[i] %= 2 answer = [] for i in range(M + 1): if B[i]: answer.append(i) if len(answer): pri...
false
16.666667
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-A = [0] + A", "-B = [0] * (N + 1)", "-# print(A)", "-for i in range(N, 0, -1):", "+M = int(eval(input()))", "+A = [0] + list(map(int, input().split()))", "+B = [0] * (M + 1)", "+for i in range(M, 0, -1):", "+ j = 2", "- ...
false
0.100453
0.0425
2.363594
[ "s074646979", "s865303807" ]
u227082700
p03087
python
s677190682
s429169537
870
457
7,668
30,696
Accepted
Accepted
47.47
n,q=list(map(int,input().split())) s=eval(input()) a=[0]*n for i in range(1,n): if s[i-1]=="A" and s[i]=="C":a[i]+=1 a[i]+=a[i-1] for i in range(q): aa,b=list(map(int,input().split())) print((a[b-1]-a[aa-1]))
n,q=list(map(int,input().split())) s=eval(input()) lr=[list(map(int,input().split()))for _ in range(q)] b=[0,0] for i in range(1,n): b.append(b[-1]) if s[i-1:i+1]=="AC":b[-1]+=1 for l,r in lr:print((b[r]-b[l]))
9
8
204
207
n, q = list(map(int, input().split())) s = eval(input()) a = [0] * n for i in range(1, n): if s[i - 1] == "A" and s[i] == "C": a[i] += 1 a[i] += a[i - 1] for i in range(q): aa, b = list(map(int, input().split())) print((a[b - 1] - a[aa - 1]))
n, q = list(map(int, input().split())) s = eval(input()) lr = [list(map(int, input().split())) for _ in range(q)] b = [0, 0] for i in range(1, n): b.append(b[-1]) if s[i - 1 : i + 1] == "AC": b[-1] += 1 for l, r in lr: print((b[r] - b[l]))
false
11.111111
[ "-a = [0] * n", "+lr = [list(map(int, input().split())) for _ in range(q)]", "+b = [0, 0]", "- if s[i - 1] == \"A\" and s[i] == \"C\":", "- a[i] += 1", "- a[i] += a[i - 1]", "-for i in range(q):", "- aa, b = list(map(int, input().split()))", "- print((a[b - 1] - a[aa - 1]))", "+...
false
0.080689
0.042732
1.888244
[ "s677190682", "s429169537" ]
u312025627
p03493
python
s598665086
s124832842
179
165
38,256
38,384
Accepted
Accepted
7.82
s = eval(input()) print((s.count("1")))
def main(): S = eval(input()) print((sum(1 if s == "1" else 0 for s in S))) if __name__ == '__main__': main()
2
7
32
122
s = eval(input()) print((s.count("1")))
def main(): S = eval(input()) print((sum(1 if s == "1" else 0 for s in S))) if __name__ == "__main__": main()
false
71.428571
[ "-s = eval(input())", "-print((s.count(\"1\")))", "+def main():", "+ S = eval(input())", "+ print((sum(1 if s == \"1\" else 0 for s in S)))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.055897
0.041317
1.352868
[ "s598665086", "s124832842" ]
u652068981
p02571
python
s554821741
s619372533
82
71
9,036
9,120
Accepted
Accepted
13.41
s, t = [eval(input()) for _ in range(2)] max_count = 0 for i in range(len(s) - len(t) + 1): m_count = 0 for j in range(len(t)): if s[i:][j] == t[j]: m_count += 1 if max_count < m_count: max_count = m_count print((len(t)-max_count))
s, t = [eval(input()) for _ in range(2)] max_count = 0 for i in range(len(s) - len(t) + 1): m_count = 0 for j in range(len(t)): if s[i+j] == t[j]: m_count += 1 if max_count < m_count: max_count = m_count print((len(t)-max_count))
12
11
277
273
s, t = [eval(input()) for _ in range(2)] max_count = 0 for i in range(len(s) - len(t) + 1): m_count = 0 for j in range(len(t)): if s[i:][j] == t[j]: m_count += 1 if max_count < m_count: max_count = m_count print((len(t) - max_count))
s, t = [eval(input()) for _ in range(2)] max_count = 0 for i in range(len(s) - len(t) + 1): m_count = 0 for j in range(len(t)): if s[i + j] == t[j]: m_count += 1 if max_count < m_count: max_count = m_count print((len(t) - max_count))
false
8.333333
[ "- if s[i:][j] == t[j]:", "+ if s[i + j] == t[j]:" ]
false
0.044576
0.043034
1.035851
[ "s554821741", "s619372533" ]
u944325914
p03309
python
s929543358
s479085666
342
230
44,292
37,788
Accepted
Accepted
32.75
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) for i in range(n): a[i]=a[i]-(i+1) ac=Counter(a) if len(a)%2==0: dist=len(a)//2 else: dist=len(a)//2+1 temp=0 for i,j in sorted(ac.items()): temp+=j if temp>=dist: ans=0 for k in rang...
n=int(eval(input())) a=list(map(int,input().split())) for i in range(n): a[i]=a[i]-(i+1) import numpy as np an=np.array(a) b=int(np.median(an)) ans=0 for i in a: ans+=abs(i-b) print(ans)
20
11
395
198
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) for i in range(n): a[i] = a[i] - (i + 1) ac = Counter(a) if len(a) % 2 == 0: dist = len(a) // 2 else: dist = len(a) // 2 + 1 temp = 0 for i, j in sorted(ac.items()): temp += j if temp >= dist: ans = 0...
n = int(eval(input())) a = list(map(int, input().split())) for i in range(n): a[i] = a[i] - (i + 1) import numpy as np an = np.array(a) b = int(np.median(an)) ans = 0 for i in a: ans += abs(i - b) print(ans)
false
45
[ "-from collections import Counter", "-", "-ac = Counter(a)", "-if len(a) % 2 == 0:", "- dist = len(a) // 2", "-else:", "- dist = len(a) // 2 + 1", "-temp = 0", "-for i, j in sorted(ac.items()):", "- temp += j", "- if temp >= dist:", "- ans = 0", "- for k in range(n)...
false
0.037329
0.27517
0.135656
[ "s929543358", "s479085666" ]
u129978636
p03337
python
s235711197
s327262315
21
19
3,316
3,316
Accepted
Accepted
9.52
A, B = list(map( int, input().split())) C = [] C1 = A + B C.append(C1) C2 = A - B C.append(C2) C3 = A * B C.append(C3) C = sorted(C) print((C[2]))
A, B = list(map( int, input().split())) C1 = A + B C2 = A - B C3 = A * B C = [ C1, C2, C3] C = sorted(C) print((C[2]))
15
13
157
129
A, B = list(map(int, input().split())) C = [] C1 = A + B C.append(C1) C2 = A - B C.append(C2) C3 = A * B C.append(C3) C = sorted(C) print((C[2]))
A, B = list(map(int, input().split())) C1 = A + B C2 = A - B C3 = A * B C = [C1, C2, C3] C = sorted(C) print((C[2]))
false
13.333333
[ "-C = []", "-C.append(C1)", "-C.append(C2)", "-C.append(C3)", "+C = [C1, C2, C3]" ]
false
0.036998
0.145108
0.254966
[ "s235711197", "s327262315" ]
u981931040
p02726
python
s338539010
s585494914
681
468
74,332
48,604
Accepted
Accepted
31.28
N, X, Y = list(map(int, input().split())) Graph = [[] for _ in range(N)] for i in range(N): if i < N - 1: Graph[i].append(i + 1) Graph[i + 1].append(i) if X == i: Graph[X - 1].append(Y - 1) Graph[Y - 1].append(X - 1) # print(Graph) ans = [0] * (N - 1) from collections ...
N, X, Y = list(map(int, input().split())) Graph = [[] for _ in range(N)] for i in range(N): if i < N - 1: Graph[i].append(i + 1) Graph[i + 1].append(i) if X == i: Graph[X - 1].append(Y - 1) Graph[Y - 1].append(X - 1) # print(Graph) ans = [0] * (N - 1) from collections ...
33
30
809
729
N, X, Y = list(map(int, input().split())) Graph = [[] for _ in range(N)] for i in range(N): if i < N - 1: Graph[i].append(i + 1) Graph[i + 1].append(i) if X == i: Graph[X - 1].append(Y - 1) Graph[Y - 1].append(X - 1) # print(Graph) ans = [0] * (N - 1) from collections import dequ...
N, X, Y = list(map(int, input().split())) Graph = [[] for _ in range(N)] for i in range(N): if i < N - 1: Graph[i].append(i + 1) Graph[i + 1].append(i) if X == i: Graph[X - 1].append(Y - 1) Graph[Y - 1].append(X - 1) # print(Graph) ans = [0] * (N - 1) from collections import dequ...
false
9.090909
[ "-from collections import deque, Counter", "+from collections import deque", "- dist_Counter = Counter(dist)", "- for key, val in list(dist_Counter.items()):", "- if key != 0:", "- ans[key - 1] += val", "+ for d in dist:", "+ if d > 0:", "+ ans[d - 1] += ...
false
0.153851
0.166909
0.921764
[ "s338539010", "s585494914" ]
u848535504
p02780
python
s908631377
s156187796
225
203
32,628
33,068
Accepted
Accepted
9.78
N,K = list(map(int,input().split())) p = list(map(int,input().split())) l = [] for i in range(N): l.append(((1+p[i])*p[i]/2)/p[i]) s = [0]*(N+1) for i in range(1,N+1): s[i] = l[i-1]+s[i-1] ans = 0 for i in range(K,len(s)): ans = max(ans,s[i]-s[i-K]) if N == K: print((max(s))) else: ...
N,K = list(map(int,input().split())) p = list(map(int,input().split())) l = [] for i in p: l.append((1/2*i*(i+1))/i) s = [0]*len(l) s[0] = l[0] for i in range(1,len(l)): s[i] = s[i-1]+l[i] ans = 0 for i in range(K,len(s)): ans = max(ans,s[i]-s[i-K]) if N == K: print((max(s))) e...
19
21
327
331
N, K = list(map(int, input().split())) p = list(map(int, input().split())) l = [] for i in range(N): l.append(((1 + p[i]) * p[i] / 2) / p[i]) s = [0] * (N + 1) for i in range(1, N + 1): s[i] = l[i - 1] + s[i - 1] ans = 0 for i in range(K, len(s)): ans = max(ans, s[i] - s[i - K]) if N == K: print((max(s)...
N, K = list(map(int, input().split())) p = list(map(int, input().split())) l = [] for i in p: l.append((1 / 2 * i * (i + 1)) / i) s = [0] * len(l) s[0] = l[0] for i in range(1, len(l)): s[i] = s[i - 1] + l[i] ans = 0 for i in range(K, len(s)): ans = max(ans, s[i] - s[i - K]) if N == K: print((max(s))) ...
false
9.52381
[ "-for i in range(N):", "- l.append(((1 + p[i]) * p[i] / 2) / p[i])", "-s = [0] * (N + 1)", "-for i in range(1, N + 1):", "- s[i] = l[i - 1] + s[i - 1]", "+for i in p:", "+ l.append((1 / 2 * i * (i + 1)) / i)", "+s = [0] * len(l)", "+s[0] = l[0]", "+for i in range(1, len(l)):", "+ s[i...
false
0.057542
0.056728
1.014355
[ "s908631377", "s156187796" ]
u325119213
p03400
python
s928870570
s039772918
31
27
8,960
9,116
Accepted
Accepted
12.9
def actual(N, D, X, A): # 2 * [食べる日数] + 1 <= D かつ [食べる日数] は整数を解けばよい count_eating_days = lambda a_i: (D - 1) // a_i + 1 eating_day_counts = sum([count_eating_days(a_i) for a_i in A]) return X + eating_day_counts N = int(eval(input())) D, X = list(map(int, input().split())) A = [int(eval(inp...
def actual(N, D, X, A): # 2 * [食べたチョコ] + 1 <= D かつ [食べたチョコ]は左の式を超えない整数 を解けばよい count_chocolates = lambda a_i: (D - 1) // a_i + 1 return X + sum([count_chocolates(a_i) for a_i in A]) N = int(eval(input())) D, X = list(map(int, input().split())) A = [int(eval(input())) for _ in range(N)] print((ac...
13
11
357
319
def actual(N, D, X, A): # 2 * [食べる日数] + 1 <= D かつ [食べる日数] は整数を解けばよい count_eating_days = lambda a_i: (D - 1) // a_i + 1 eating_day_counts = sum([count_eating_days(a_i) for a_i in A]) return X + eating_day_counts N = int(eval(input())) D, X = list(map(int, input().split())) A = [int(eval(input())) for _...
def actual(N, D, X, A): # 2 * [食べたチョコ] + 1 <= D かつ [食べたチョコ]は左の式を超えない整数 を解けばよい count_chocolates = lambda a_i: (D - 1) // a_i + 1 return X + sum([count_chocolates(a_i) for a_i in A]) N = int(eval(input())) D, X = list(map(int, input().split())) A = [int(eval(input())) for _ in range(N)] print((actual(N, D, ...
false
15.384615
[ "- # 2 * [食べる日数] + 1 <= D かつ [食べる日数] は整数を解けばよい", "- count_eating_days = lambda a_i: (D - 1) // a_i + 1", "- eating_day_counts = sum([count_eating_days(a_i) for a_i in A])", "- return X + eating_day_counts", "+ # 2 * [食べたチョコ] + 1 <= D かつ [食べたチョコ]は左の式を超えない整数 を解けばよい", "+ count_chocolates = ...
false
0.048128
0.046656
1.031566
[ "s928870570", "s039772918" ]
u564589929
p02707
python
s146382619
s820300116
137
117
32,288
32,932
Accepted
Accepted
14.6
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): retur...
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
28
35
625
1,122
import sys sys.setrecursionlimit(10**6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def...
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())...
false
20
[ "-sys.setrecursionlimit(10**6)", "+sys.setrecursionlimit(10**9)", "-int1 = lambda x: int(x) - 1", "+def int1(x):", "+ return int(x) - 1", "-INF = float(\"inf\")", "+def MS():", "+ return input().split()", "+def LS():", "+ return list(eval(input()))", "+", "+", "+def LLS(rows_number)...
false
0.046879
0.048967
0.957356
[ "s146382619", "s820300116" ]
u006657459
p03262
python
s657891986
s573612287
137
89
16,308
16,280
Accepted
Accepted
35.04
from functools import reduce from fractions import gcd N, X = list(map(int, input().split())) x = [int(xi) for xi in input().split()] x.append(X) x = sorted(x) diffs = [x[i+1] - x[i] for i in range(N)] if len(diffs) == 1: print((diffs[0])) else: print((reduce(gcd, diffs)))
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(xi - X) for xi in x] print((reduce(gcd, d)))
12
6
284
180
from functools import reduce from fractions import gcd N, X = list(map(int, input().split())) x = [int(xi) for xi in input().split()] x.append(X) x = sorted(x) diffs = [x[i + 1] - x[i] for i in range(N)] if len(diffs) == 1: print((diffs[0])) else: print((reduce(gcd, diffs)))
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(xi - X) for xi in x] print((reduce(gcd, d)))
false
50
[ "+from fractions import gcd", "-from fractions import gcd", "-x = [int(xi) for xi in input().split()]", "-x.append(X)", "-x = sorted(x)", "-diffs = [x[i + 1] - x[i] for i in range(N)]", "-if len(diffs) == 1:", "- print((diffs[0]))", "-else:", "- print((reduce(gcd, diffs)))", "+x = list(map...
false
0.099489
0.095906
1.037365
[ "s657891986", "s573612287" ]
u562935282
p03045
python
s581730991
s495011381
731
530
7,940
5,492
Accepted
Accepted
27.5
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = self.find(x) y =...
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = self.find(x) y =...
45
39
1,018
894
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = self.find(x) y = self.find(y)...
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = self.find(x) y = self.find(y)...
false
13.333333
[ "-uf = UnionFind(N * 2)", "+uf = UnionFind(N)", "- if z & 1:", "- uf.unite(x + N, y)", "- uf.unite(x, y + N)", "- else:", "- uf.unite(x, y)", "- uf.unite(x + N, y + N)", "+ uf.unite(x, y)" ]
false
0.112835
0.038083
2.962843
[ "s581730991", "s495011381" ]
u094191970
p02995
python
s219416001
s674559576
36
25
5,048
9,120
Accepted
Accepted
30.56
from fractions import gcd a,b,c,d=list(map(int,input().split())) ok1=b-a+1 a-=1 ng1=b//c-a//c ng2=b//d-a//d lcm=(c*d)//gcd(c,d) ok2=b//lcm-a//lcm print((ok1-ng1-ng2+ok2))
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) from math import gcd a,b,c,d=nii() a_c=(a-1)//c b_c=b//c a_d=(a-1)//d b_d=b//d lcm=(c*d)//gcd(c,d) a_lcm=(a-1)//lcm b_lcm=b//lcm print(((b-a+1)-(b_c-a_c)-(b_d-a_d)+(b_lcm-a_...
12
18
177
318
from fractions import gcd a, b, c, d = list(map(int, input().split())) ok1 = b - a + 1 a -= 1 ng1 = b // c - a // c ng2 = b // d - a // d lcm = (c * d) // gcd(c, d) ok2 = b // lcm - a // lcm print((ok1 - ng1 - ng2 + ok2))
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) from math import gcd a, b, c, d = nii() a_c = (a - 1) // c b_c = b // c a_d = (a - 1) // d b_d = b // d lcm = (c * d) // gcd(c, d) a_lcm = (a - 1) // lcm b_lcm = b // lcm print(((b - a ...
false
33.333333
[ "-from fractions import gcd", "+from sys import stdin", "-a, b, c, d = list(map(int, input().split()))", "-ok1 = b - a + 1", "-a -= 1", "-ng1 = b // c - a // c", "-ng2 = b // d - a // d", "+nii = lambda: list(map(int, stdin.readline().split()))", "+lnii = lambda: list(map(int, stdin.readline().split...
false
0.15581
0.038438
4.053538
[ "s219416001", "s674559576" ]
u767664985
p02947
python
s881109050
s782698790
418
378
23,596
23,436
Accepted
Accepted
9.57
from operator import mul from functools import reduce import collections def cmb(n, r): r = min(n - r, r) if r == 0: return 1 elif r < 0: return 0 numer = reduce(mul, list(range(n, n - r, -1))) denom = reduce(mul, list(range(1, r + 1))) return numer // denom N...
import collections N = int(eval(input())) s = ["".join(sorted(eval(input()))) for _ in range(N)] c = collections.Counter(s) ans = 0 for si in set(s): n = c[si] ans += n * (n - 1) // 2 print(ans)
24
10
479
201
from operator import mul from functools import reduce import collections def cmb(n, r): r = min(n - r, r) if r == 0: return 1 elif r < 0: return 0 numer = reduce(mul, list(range(n, n - r, -1))) denom = reduce(mul, list(range(1, r + 1))) return numer // denom N = int(eval(inpu...
import collections N = int(eval(input())) s = ["".join(sorted(eval(input()))) for _ in range(N)] c = collections.Counter(s) ans = 0 for si in set(s): n = c[si] ans += n * (n - 1) // 2 print(ans)
false
58.333333
[ "-from operator import mul", "-from functools import reduce", "-", "-", "-def cmb(n, r):", "- r = min(n - r, r)", "- if r == 0:", "- return 1", "- elif r < 0:", "- return 0", "- numer = reduce(mul, list(range(n, n - r, -1)))", "- denom = reduce(mul, list(range(1, r...
false
0.033453
0.034928
0.957777
[ "s881109050", "s782698790" ]
u118642796
p03215
python
s702069584
s755515112
748
597
25,240
24,748
Accepted
Accepted
20.19
import copy N,K = list(map(int,input().split())) A = list(map(int,input().split())) A_sum = [0] for a in A: A_sum.append(A_sum[-1]+a) score = [] for r in range(1,N+1): for l in range(0,r): score.append(A_sum[r]-A_sum[l]) ans = 0 for i in range(40,-1,-1): count = 0 score_a = []...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) A_sum = [0] for a in A: A_sum.append(A_sum[-1]+a) score = [] for r in range(1,N+1): for l in range(0,r): score.append(A_sum[r]-A_sum[l]) ans = 0 for i in range(40,-1,-1): count = 0 score_a = [] for j i...
26
25
508
493
import copy N, K = list(map(int, input().split())) A = list(map(int, input().split())) A_sum = [0] for a in A: A_sum.append(A_sum[-1] + a) score = [] for r in range(1, N + 1): for l in range(0, r): score.append(A_sum[r] - A_sum[l]) ans = 0 for i in range(40, -1, -1): count = 0 score_a = [] ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) A_sum = [0] for a in A: A_sum.append(A_sum[-1] + a) score = [] for r in range(1, N + 1): for l in range(0, r): score.append(A_sum[r] - A_sum[l]) ans = 0 for i in range(40, -1, -1): count = 0 score_a = [] for j in scor...
false
3.846154
[ "-import copy", "-", "- score = copy.deepcopy(score_a)", "+ score = [i for i in score_a]" ]
false
0.046849
0.043088
1.087271
[ "s702069584", "s755515112" ]
u342869120
p02580
python
s650863954
s608605775
983
623
191,396
180,960
Accepted
Accepted
36.62
from collections import defaultdict H, W, M = list(map(int, input().split())) r = defaultdict(int) c = defaultdict(int) rc = defaultdict(int) for i in range(M): h, w = list(map(int, input().split())) rc[(h, w)] += 1 r[w] += 1 c[h] += 1 ri, rmax = 0, 0 ci, cmax = 0, 0 for i in list(r.keys()...
H, W, M = list(map(int, input().split())) r = [0]*(W+1) c = [0]*(H+1) rc = {} for i in range(M): h, w = list(map(int, input().split())) rc[(h, w)] = True r[w] += 1 c[h] += 1 rm = max(r) cm = max(c) ri = {i for i, v in enumerate(r) if v == rm} ci = {i for i, v in enumerate(c) if v == cm} ...
44
18
840
398
from collections import defaultdict H, W, M = list(map(int, input().split())) r = defaultdict(int) c = defaultdict(int) rc = defaultdict(int) for i in range(M): h, w = list(map(int, input().split())) rc[(h, w)] += 1 r[w] += 1 c[h] += 1 ri, rmax = 0, 0 ci, cmax = 0, 0 for i in list(r.keys()): v = r[...
H, W, M = list(map(int, input().split())) r = [0] * (W + 1) c = [0] * (H + 1) rc = {} for i in range(M): h, w = list(map(int, input().split())) rc[(h, w)] = True r[w] += 1 c[h] += 1 rm = max(r) cm = max(c) ri = {i for i, v in enumerate(r) if v == rm} ci = {i for i, v in enumerate(c) if v == cm} cnt = su...
false
59.090909
[ "-from collections import defaultdict", "-", "-r = defaultdict(int)", "-c = defaultdict(int)", "-rc = defaultdict(int)", "+r = [0] * (W + 1)", "+c = [0] * (H + 1)", "+rc = {}", "- rc[(h, w)] += 1", "+ rc[(h, w)] = True", "-ri, rmax = 0, 0", "-ci, cmax = 0, 0", "-for i in list(r.keys())...
false
0.046987
0.045793
1.02606
[ "s650863954", "s608605775" ]
u391589398
p03111
python
s403366554
s275657390
129
96
75,080
73,888
Accepted
Accepted
25.58
n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] targets = [a, b, c] ans = 10**9 from itertools import product for comb in product([0, 1, 2, 3], repeat=n): if len(set(comb)) in [1, 2]: continue # a, b, c ls = [[], [], []] for i, c in enumerate(c...
n, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] INF = 10**9 def rec(cur, a, b, c): if cur == n: return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF ret0 = rec(cur+1, a, b, c) ret1 = rec(cur+1, a+L[cur], b, c) + 10 ret2 = rec(c...
27
14
631
445
n, a, b, c = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] targets = [a, b, c] ans = 10**9 from itertools import product for comb in product([0, 1, 2, 3], repeat=n): if len(set(comb)) in [1, 2]: continue # a, b, c ls = [[], [], []] for i, c in enumerate(comb): ...
n, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ in range(n)] INF = 10**9 def rec(cur, a, b, c): if cur == n: return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF ret0 = rec(cur + 1, a, b, c) ret1 = rec(cur + 1, a + L[cur], b, c) + 10 ret2 = r...
false
48.148148
[ "-n, a, b, c = list(map(int, input().split()))", "+n, A, B, C = list(map(int, input().split()))", "-targets = [a, b, c]", "-ans = 10**9", "-from itertools import product", "+INF = 10**9", "-for comb in product([0, 1, 2, 3], repeat=n):", "- if len(set(comb)) in [1, 2]:", "- continue", "- ...
false
0.207215
0.058639
3.53373
[ "s403366554", "s275657390" ]
u151785909
p03353
python
s571964259
s001774461
1,535
36
3,956
4,464
Accepted
Accepted
97.65
s = eval(input()) k = int(eval(input())) x = [] n = len(s) for i in range(k): for j in range(n-i): t = s[j:j+i+1] if not t in x: x.append(t) x.sort() print((x[k-1]))
s = eval(input()) k = int(eval(input())) x = set() n = len(s) for i in range(k): for j in range(n-i): t = s[j:j+i+1] if not t in x: x.add(t) x=list(x) x.sort() print((x[k-1]))
11
12
193
204
s = eval(input()) k = int(eval(input())) x = [] n = len(s) for i in range(k): for j in range(n - i): t = s[j : j + i + 1] if not t in x: x.append(t) x.sort() print((x[k - 1]))
s = eval(input()) k = int(eval(input())) x = set() n = len(s) for i in range(k): for j in range(n - i): t = s[j : j + i + 1] if not t in x: x.add(t) x = list(x) x.sort() print((x[k - 1]))
false
8.333333
[ "-x = []", "+x = set()", "- x.append(t)", "+ x.add(t)", "+x = list(x)" ]
false
0.075926
0.040524
1.873595
[ "s571964259", "s001774461" ]
u561231954
p03176
python
s452696103
s590337869
762
637
123,084
118,396
Accepted
Accepted
16.4
INF = 10 ** 9 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from copy import deepcopy from bisect import bisect_left class SegmentTree(): def __init__(self,init_val,func,unit): #init_valは長さnの配列 O(2*n) n = len(init_val) self.unit = unit #unitは単位元 ...
import sys sys.setrecursionlimit(100000000) input = sys.stdin.readline MOD = 10 ** 9 + 7 class SegmentTree(): f = max unit = 0 def __init__(self,array): self.N = len(array) self.tree = [self.unit] * (2*self.N) #self._build(array) def _build(self,array): ...
74
62
2,029
1,611
INF = 10**9 import sys sys.setrecursionlimit(100000000) dy = (-1, 0, 1, 0) dx = (0, 1, 0, -1) from copy import deepcopy from bisect import bisect_left class SegmentTree: def __init__(self, init_val, func, unit): # init_valは長さnの配列 O(2*n) n = len(init_val) self.unit = unit # unitは単位元 self...
import sys sys.setrecursionlimit(100000000) input = sys.stdin.readline MOD = 10**9 + 7 class SegmentTree: f = max unit = 0 def __init__(self, array): self.N = len(array) self.tree = [self.unit] * (2 * self.N) # self._build(array) def _build(self, array): for i, x in ...
false
16.216216
[ "-INF = 10**9", "-dy = (-1, 0, 1, 0)", "-dx = (0, 1, 0, -1)", "-from copy import deepcopy", "-from bisect import bisect_left", "+input = sys.stdin.readline", "+MOD = 10**9 + 7", "- def __init__(self, init_val, func, unit): # init_valは長さnの配列 O(2*n)", "- n = len(init_val)", "- self...
false
0.038483
0.037723
1.020159
[ "s452696103", "s590337869" ]
u761989513
p02813
python
s966193939
s639922919
33
29
8,308
8,052
Accepted
Accepted
12.12
import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) junretsu = [] for i in itertools.permutations(list(range(1, n + 1))): junretsu.append(i) junretsu = sorted(junretsu) a = junretsu.index(p) b = junretsu.index(q) print((abs(a - b)))
import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) junretsu = itertools.permutations(list(range(1, n + 1))) junretsu = sorted(junretsu) a = junretsu.index(p) b = junretsu.index(q) print((abs(a - b)))
15
13
302
265
import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) junretsu = [] for i in itertools.permutations(list(range(1, n + 1))): junretsu.append(i) junretsu = sorted(junretsu) a = junretsu.index(p) b = junretsu.index(q) print((abs(a - b)))
import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) junretsu = itertools.permutations(list(range(1, n + 1))) junretsu = sorted(junretsu) a = junretsu.index(p) b = junretsu.index(q) print((abs(a - b)))
false
13.333333
[ "-junretsu = []", "-for i in itertools.permutations(list(range(1, n + 1))):", "- junretsu.append(i)", "+junretsu = itertools.permutations(list(range(1, n + 1)))" ]
false
0.078196
0.031301
2.498193
[ "s966193939", "s639922919" ]
u718706790
p02909
python
s469793645
s751675385
19
17
3,060
2,940
Accepted
Accepted
10.53
S = eval(input()) if S == 'Sunny': print('Cloudy') elif S == 'Cloudy': print('Rainy') else: print('Sunny')
list = ['Sunny', 'Cloudy', 'Rainy'] s = eval(input()) i = list.index(s) if i == 0: print('Cloudy') elif i == 1: print('Rainy') else: print('Sunny')
7
10
112
157
S = eval(input()) if S == "Sunny": print("Cloudy") elif S == "Cloudy": print("Rainy") else: print("Sunny")
list = ["Sunny", "Cloudy", "Rainy"] s = eval(input()) i = list.index(s) if i == 0: print("Cloudy") elif i == 1: print("Rainy") else: print("Sunny")
false
30
[ "-S = eval(input())", "-if S == \"Sunny\":", "+list = [\"Sunny\", \"Cloudy\", \"Rainy\"]", "+s = eval(input())", "+i = list.index(s)", "+if i == 0:", "-elif S == \"Cloudy\":", "+elif i == 1:" ]
false
0.045679
0.047267
0.966411
[ "s469793645", "s751675385" ]
u347640436
p02946
python
s747114099
s065966782
20
17
3,064
3,060
Accepted
Accepted
15
k, x = list(map(int, input().split())) l = max(-1000000, x - k + 1) r = min(1000000, x + k - 1) for i in range(l, r + 1): print(i)
K, X = list(map(int, input().split())) l = max(-1000000, X - K + 1) r = min(1000000, X + K - 1) print((*[i for i in range(l, r + 1)]))
5
5
131
132
k, x = list(map(int, input().split())) l = max(-1000000, x - k + 1) r = min(1000000, x + k - 1) for i in range(l, r + 1): print(i)
K, X = list(map(int, input().split())) l = max(-1000000, X - K + 1) r = min(1000000, X + K - 1) print((*[i for i in range(l, r + 1)]))
false
0
[ "-k, x = list(map(int, input().split()))", "-l = max(-1000000, x - k + 1)", "-r = min(1000000, x + k - 1)", "-for i in range(l, r + 1):", "- print(i)", "+K, X = list(map(int, input().split()))", "+l = max(-1000000, X - K + 1)", "+r = min(1000000, X + K - 1)", "+print((*[i for i in range(l, r + 1)...
false
0.048088
0.049364
0.974151
[ "s747114099", "s065966782" ]
u581187895
p02984
python
s100953012
s732332647
880
129
65,968
14,092
Accepted
Accepted
85.34
from scipy.sparse import csr_matrix from scipy.sparse.linalg import spsolve import numpy as np N = int(eval(input())) A = np.array(input().split()) rows = np.concatenate([np.arange(N), np.arange(N)]) cols = np.concatenate([np.arange(N), np.arange(1, N+1)%N]) mat = csr_matrix(([1]*(2*N), (rows, cols)), (N, N)...
N = int(eval(input())) A = list(map(int, input().split())) X = [0]*N # 全体の和 - 偶数の和*2 = 一番目の値 # もしくは、(x/2)+(y/2)=A, ..B,..C -> x+y+z = A+B+C X[0] = sum(A) - sum(A[1::2])*2 #最初の値から順番にダムの値を引けば答え for i in range(1, N): X[i] = A[i-1]*2 - X[i-1] print((*X))
12
13
379
263
from scipy.sparse import csr_matrix from scipy.sparse.linalg import spsolve import numpy as np N = int(eval(input())) A = np.array(input().split()) rows = np.concatenate([np.arange(N), np.arange(N)]) cols = np.concatenate([np.arange(N), np.arange(1, N + 1) % N]) mat = csr_matrix(([1] * (2 * N), (rows, cols)), (N, N)) ...
N = int(eval(input())) A = list(map(int, input().split())) X = [0] * N # 全体の和 - 偶数の和*2 = 一番目の値 # もしくは、(x/2)+(y/2)=A, ..B,..C -> x+y+z = A+B+C X[0] = sum(A) - sum(A[1::2]) * 2 # 最初の値から順番にダムの値を引けば答え for i in range(1, N): X[i] = A[i - 1] * 2 - X[i - 1] print((*X))
false
7.692308
[ "-from scipy.sparse import csr_matrix", "-from scipy.sparse.linalg import spsolve", "-import numpy as np", "-", "-A = np.array(input().split())", "-rows = np.concatenate([np.arange(N), np.arange(N)])", "-cols = np.concatenate([np.arange(N), np.arange(1, N + 1) % N])", "-mat = csr_matrix(([1] * (2 * N)...
false
0.294209
0.041079
7.162116
[ "s100953012", "s732332647" ]
u699089116
p03325
python
s744339126
s169061244
204
184
42,220
40,560
Accepted
Accepted
9.8
n = int(eval(input())) a = list(map(int, input().split())) def trial_division(n): #2で割った因数を格納するリスト factor = [] #2で割れなくなった時点でストップ while n % 2 == 0: n //= 2 # 2で割った商を切り捨てて代入 factor.append(2) #nが一度も2で割れなかったらそのまま返す if not factor: return [n] else: ...
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in a: while i % 2 == 0: i = i // 2 cnt += 1 print(cnt)
25
10
458
153
n = int(eval(input())) a = list(map(int, input().split())) def trial_division(n): # 2で割った因数を格納するリスト factor = [] # 2で割れなくなった時点でストップ while n % 2 == 0: n //= 2 # 2で割った商を切り捨てて代入 factor.append(2) # nが一度も2で割れなかったらそのまま返す if not factor: return [n] else: factor.appe...
n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in a: while i % 2 == 0: i = i // 2 cnt += 1 print(cnt)
false
60
[ "-", "-", "-def trial_division(n):", "- # 2で割った因数を格納するリスト", "- factor = []", "- # 2で割れなくなった時点でストップ", "- while n % 2 == 0:", "- n //= 2 # 2で割った商を切り捨てて代入", "- factor.append(2)", "- # nが一度も2で割れなかったらそのまま返す", "- if not factor:", "- return [n]", "- else:"...
false
0.035772
0.061545
0.581228
[ "s744339126", "s169061244" ]
u156815136
p03607
python
s602364602
s838029618
184
110
21,836
20,560
Accepted
Accepted
40.22
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Co...
34
49
772
1,116
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations, permutations, accumulate, product # (string,3) 3回 # from collections import deque from collections import deque, defaultdict...
false
30.612245
[ "-from fractions import gcd", "-from itertools import combinations, permutations, accumulate # (string,3) 3回", "+from math import gcd", "+from itertools import combinations, permutations, accumulate, product # (string,3) 3回", "+import decimal", "+import re", "+import math", "+import bisect", "+imp...
false
0.007055
0.032272
0.218605
[ "s602364602", "s838029618" ]
u814265211
p02726
python
s512093321
s653026084
1,456
1,144
3,444
3,572
Accepted
Accepted
21.43
n, x, y = [int(i) for i in input().split()] ans = [0]*n for i in range(n-1): for j in range(i+1, n): ans[min(j-i, abs(x-(i+1))+abs((j+1)-y)+1)] += 1 print(*ans[1:], sep='\n')
n, x, y = [int(i) for i in input().split()] ans = [0]*n for i in range(1, n): for j in range(i+1, n+1): ans[min(j-i, abs(x-i)+abs(j-y)+1)] += 1 print(*ans[1:], sep='\n')
7
8
194
190
n, x, y = [int(i) for i in input().split()] ans = [0] * n for i in range(n - 1): for j in range(i + 1, n): ans[min(j - i, abs(x - (i + 1)) + abs((j + 1) - y) + 1)] += 1 print(*ans[1:], sep="\n")
n, x, y = [int(i) for i in input().split()] ans = [0] * n for i in range(1, n): for j in range(i + 1, n + 1): ans[min(j - i, abs(x - i) + abs(j - y) + 1)] += 1 print(*ans[1:], sep="\n")
false
12.5
[ "-for i in range(n - 1):", "- for j in range(i + 1, n):", "- ans[min(j - i, abs(x - (i + 1)) + abs((j + 1) - y) + 1)] += 1", "+for i in range(1, n):", "+ for j in range(i + 1, n + 1):", "+ ans[min(j - i, abs(x - i) + abs(j - y) + 1)] += 1" ]
false
0.112974
0.047684
2.369189
[ "s512093321", "s653026084" ]
u811434779
p00501
python
s947586589
s643977152
750
530
6,436
6,468
Accepted
Accepted
29.33
n = eval(input()) s = input() cnt = 0 for i in range(n): judge = False p = input() for k in range(len(p)): for j in range(1, len(p)): for l in range(len(s)): if k+l*j < len(p) and p[k+l*j] == s[l]: if l+1 >= len(s): judge = True ...
n = eval(input()) s = input() cnt = 0 for i in range(n): judge = False p = input() for k in range(len(p)): if judge: break for j in range(1, len(p)): if judge: break for l in range(len(s)): if k+l*j < len(p) and p[k+l*j] == s[l]: ...
15
17
404
458
n = eval(input()) s = input() cnt = 0 for i in range(n): judge = False p = input() for k in range(len(p)): for j in range(1, len(p)): for l in range(len(s)): if k + l * j < len(p) and p[k + l * j] == s[l]: if l + 1 >= len(s): ju...
n = eval(input()) s = input() cnt = 0 for i in range(n): judge = False p = input() for k in range(len(p)): if judge: break for j in range(1, len(p)): if judge: break for l in range(len(s)): if k + l * j < len(p) and p[k + l ...
false
11.764706
[ "+ if judge:", "+ break", "+ if judge:", "+ break" ]
false
0.036425
0.037373
0.974618
[ "s947586589", "s643977152" ]
u597374218
p02818
python
s307242565
s211683754
30
26
9,112
9,036
Accepted
Accepted
13.33
A, B, K = list(map(int, input().split())) if K <= A: print((A-K, B)) elif K <= A+B: print((0, B-(K-A))) else: print((0, 0))
A, B, K = list(map(int, input().split())) print((max(0, A-K), max(0, B-max(0, K-A))))
7
2
129
78
A, B, K = list(map(int, input().split())) if K <= A: print((A - K, B)) elif K <= A + B: print((0, B - (K - A))) else: print((0, 0))
A, B, K = list(map(int, input().split())) print((max(0, A - K), max(0, B - max(0, K - A))))
false
71.428571
[ "-if K <= A:", "- print((A - K, B))", "-elif K <= A + B:", "- print((0, B - (K - A)))", "-else:", "- print((0, 0))", "+print((max(0, A - K), max(0, B - max(0, K - A))))" ]
false
0.083797
0.109235
0.767128
[ "s307242565", "s211683754" ]
u102461423
p03161
python
s714479907
s644036783
1,776
146
12,444
33,460
Accepted
Accepted
91.78
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,K,*H = list(map(int,read().split())) H = [H[0]]*K+H dp = [0]*(K+N) for n in range(K,N+K): h = H[n] dp[n] = min(x+abs(y-h) for x,y in zip(dp[n-K:n],H[n-K:n])) answer = dp[-1] ...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(H, K): N = len(H) INF = 10**9 dp = np.full(N + K, INF, np.int32) dp[0] = 0 for n in range(N): for k in range(1, K + 1): ...
17
30
328
707
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, *H = list(map(int, read().split())) H = [H[0]] * K + H dp = [0] * (K + N) for n in range(K, N + K): h = H[n] dp[n] = min(x + abs(y - h) for x, y in zip(dp[n - K : n], H[n - K : n])) answer ...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(H, K): N = len(H) INF = 10**9 dp = np.full(N + K, INF, np.int32) dp[0] = 0 for n in range(N): for k in range(1, K + 1): dp[n + k] = m...
false
43.333333
[ "+import numpy as np", "-N, K, *H = list(map(int, read().split()))", "-H = [H[0]] * K + H", "-dp = [0] * (K + N)", "-for n in range(K, N + K):", "- h = H[n]", "- dp[n] = min(x + abs(y - h) for x, y in zip(dp[n - K : n], H[n - K : n]))", "-answer = dp[-1]", "-print(answer)", "+", "+", "+d...
false
0.153812
0.190827
0.806028
[ "s714479907", "s644036783" ]
u785578220
p03449
python
s314270809
s034578000
20
18
3,064
3,060
Accepted
Accepted
10
def a():return eval(input())#s def ai():return int(eval(input()))#a,n or k def ma():return list(map(int, input().split()))#a,b,c,d or n,k def ms():return list(map(str, input().split()))#,a,b,c,d def lma():return list(map(int, input().split()))#x or y def lms():return list(map(str, input().split()))#x or y a = ai(...
a = int(eval(input())) l = list(map(int,input().split())) L = list(map(int,input().split())) m = 0 for i in range(a): m = max(m,sum(l[:i+1])+sum(L[i:])) print(m)
28
8
596
168
def a(): return eval(input()) # s def ai(): return int(eval(input())) # a,n or k def ma(): return list(map(int, input().split())) # a,b,c,d or n,k def ms(): return list(map(str, input().split())) # ,a,b,c,d def lma(): return list(map(int, input().split())) # x or y def lms(): retu...
a = int(eval(input())) l = list(map(int, input().split())) L = list(map(int, input().split())) m = 0 for i in range(a): m = max(m, sum(l[: i + 1]) + sum(L[i:])) print(m)
false
71.428571
[ "-def a():", "- return eval(input()) # s", "-", "-", "-def ai():", "- return int(eval(input())) # a,n or k", "-", "-", "-def ma():", "- return list(map(int, input().split())) # a,b,c,d or n,k", "-", "-", "-def ms():", "- return list(map(str, input().split())) # ,a,b,c,d", ...
false
0.037113
0.034022
1.090862
[ "s314270809", "s034578000" ]
u631277801
p03651
python
s603743742
s523663990
76
70
14,596
14,596
Accepted
Accepted
7.89
def findGCD(a:int, b:int) -> int: # バリデーション a,bは0以上 if a <= 0: raise ValueError("aは0より大きくなければいけません。(a:{})".format(a)) elif b <= 0: raise ValueError("bは0より大きくなければいけません。(b:{})".format(b)) # ユークリッドの互除法 while 1: if a%b == 0: return b else: ...
def findGCD(a:int, b:int) -> int: # ユークリッドの互除法 while 1: if a%b == 0: return b else: a = a%b if b%a == 0: return a else: b = b%a from functools import reduce n,k = list(map(int, input().split()))...
31
25
663
472
def findGCD(a: int, b: int) -> int: # バリデーション a,bは0以上 if a <= 0: raise ValueError("aは0より大きくなければいけません。(a:{})".format(a)) elif b <= 0: raise ValueError("bは0より大きくなければいけません。(b:{})".format(b)) # ユークリッドの互除法 while 1: if a % b == 0: return b else: a = ...
def findGCD(a: int, b: int) -> int: # ユークリッドの互除法 while 1: if a % b == 0: return b else: a = a % b if b % a == 0: return a else: b = b % a from functools import reduce n, k = list(map(int, input().split())) a = list(map(int, input...
false
19.354839
[ "- # バリデーション a,bは0以上", "- if a <= 0:", "- raise ValueError(\"aは0より大きくなければいけません。(a:{})\".format(a))", "- elif b <= 0:", "- raise ValueError(\"bは0より大きくなければいけません。(b:{})\".format(b))" ]
false
0.074155
0.057915
1.280419
[ "s603743742", "s523663990" ]
u670180528
p02763
python
s120183802
s526777733
645
556
48,672
48,076
Accepted
Accepted
13.8
class SegmentTree: def __init__(self, orig, func, unit): _len = len(orig) self.func = func self.size = 1 << (_len - 1).bit_length() self.tree = [unit] * self.size + orig + [unit] * (self.size - _len) self.unit = unit for i in range(self.size - 1, 0, -1): self.tree[i] = func(self.tree[i * 2], s...
class SegmentTree: def __init__(self, orig, func, unit): _len = len(orig) self.func = func self.size = 1 << (_len - 1).bit_length() self.tree = [unit] * self.size + orig + [unit] * (self.size - _len) self.unit = unit for i in range(self.size - 1, 0, -1): self.tree[i] = func(self.tree[i * 2], s...
57
51
1,191
1,183
class SegmentTree: def __init__(self, orig, func, unit): _len = len(orig) self.func = func self.size = 1 << (_len - 1).bit_length() self.tree = [unit] * self.size + orig + [unit] * (self.size - _len) self.unit = unit for i in range(self.size - 1, 0, -1): s...
class SegmentTree: def __init__(self, orig, func, unit): _len = len(orig) self.func = func self.size = 1 << (_len - 1).bit_length() self.tree = [unit] * self.size + orig + [unit] * (self.size - _len) self.unit = unit for i in range(self.size - 1, 0, -1): s...
false
10.526316
[ "-n = int(eval(input()))", "-s = eval(input())", "-li = [1 << ord(x) - 97 for x in s[:-1]]", "-seg = SegmentTree(li, or_, 0)", "-ans = []", "-for _ in range(int(eval(input()))):", "- f, x, y = input().split()", "- if f == \"1\":", "- x = int(x)", "- seg.update(x - 1, 1 << ord(y...
false
0.034277
0.095495
0.358937
[ "s120183802", "s526777733" ]
u707498674
p02698
python
s319133625
s287366382
1,050
785
273,032
75,740
Accepted
Accepted
25.24
import sys from bisect import bisect_left sys.setrecursionlimit(10**7) def input():return sys.stdin.readline().strip() def main(): N = int(input()) A = tuple(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(N-1): u, v = map(int, input().split()) u -= 1 ...
from collections import deque from bisect import bisect_left import sys def input():return sys.stdin.readline().strip() def main(): N = int(input()) A = tuple(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(N-1): a, b = map(int, input().split()) a -= 1...
45
58
879
1,260
import sys from bisect import bisect_left sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline().strip() def main(): N = int(input()) A = tuple(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(N - 1): u, v = map(int, input().split()) u -= 1 ...
from collections import deque from bisect import bisect_left import sys def input(): return sys.stdin.readline().strip() def main(): N = int(input()) A = tuple(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 ...
false
22.413793
[ "+from collections import deque", "+from bisect import bisect_left", "-from bisect import bisect_left", "-", "-sys.setrecursionlimit(10**7)", "- u, v = map(int, input().split())", "- u -= 1", "- v -= 1", "- to[u].append(v)", "- to[v].append(u)", "+ a, b ...
false
0.043568
0.079914
0.545187
[ "s319133625", "s287366382" ]
u343977188
p03448
python
s321368469
s641909664
51
29
2,940
9,132
Accepted
Accepted
43.14
A, B, C, X = list(map(int, open(0).read().split())) count=0 for i in range(A+1): for j in range(B+1): for k in range(C+1): if 500*i + 100*j + 50*k == X: count+=1 print(count)
a=int(eval(input())) b=int(eval(input())) c=int(eval(input())) x=int(eval(input())) ans=0 for i in range(a+1): A=500*i if A>x: break for j in range(b+1): B=100*j k = (x - A - B)/50 if 0<=k<=c and k%1==0: ans+=1 print(ans)
10
15
199
239
A, B, C, X = list(map(int, open(0).read().split())) count = 0 for i in range(A + 1): for j in range(B + 1): for k in range(C + 1): if 500 * i + 100 * j + 50 * k == X: count += 1 print(count)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) ans = 0 for i in range(a + 1): A = 500 * i if A > x: break for j in range(b + 1): B = 100 * j k = (x - A - B) / 50 if 0 <= k <= c and k % 1 == 0: ans += 1 print(ans)
false
33.333333
[ "-A, B, C, X = list(map(int, open(0).read().split()))", "-count = 0", "-for i in range(A + 1):", "- for j in range(B + 1):", "- for k in range(C + 1):", "- if 500 * i + 100 * j + 50 * k == X:", "- count += 1", "-print(count)", "+a = int(eval(input()))", "+b = in...
false
0.098419
0.036417
2.702575
[ "s321368469", "s641909664" ]
u887207211
p02900
python
s649944006
s956079945
500
195
3,500
3,276
Accepted
Accepted
61
import sys stdin = sys.stdin ns = lambda : stdin.readline().rstrip() ni = lambda : int(ns()) na = lambda : list(map(int, stdin.readline().split())) def divi(n): res = [] for i in range(1, int(n**0.5)+1): if n % i == 0: res.append(i) if i != n // i: res.append(n // i) retu...
def gcd(n, m): while m: n, m = m, n%m return n def isprime(n): if n == 1: return False for i in range(2, int(n**0.5) + 1): if (n % i == 0): return False return True def divi(n): res = [] for i in range(1, int(n**0.5)+1): if n % i == 0: res.append(i) if...
36
40
669
679
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) def divi(n): res = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: res.append(i) if i != n // i: res.append(n ...
def gcd(n, m): while m: n, m = m, n % m return n def isprime(n): if n == 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def divi(n): res = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: ...
false
10
[ "-import sys", "+def gcd(n, m):", "+ while m:", "+ n, m = m, n % m", "+ return n", "-stdin = sys.stdin", "-ns = lambda: stdin.readline().rstrip()", "-ni = lambda: int(ns())", "-na = lambda: list(map(int, stdin.readline().split()))", "+", "+def isprime(n):", "+ if n == 1:", "+...
false
0.066362
0.036847
1.801029
[ "s649944006", "s956079945" ]
u075012704
p03837
python
s129562764
s535787189
628
323
3,556
3,556
Accepted
Accepted
48.57
N, M = list(map(int, input().split())) graph = [[float('inf')]*N for i in range(N)] graph2 = [[float('inf')]*N for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) graph[a-1][b-1] = c graph[b-1][a-1] = c graph2[a-1][b-1] = c graph2[b-1][a-1] = c edge = set() ...
N, M = list(map(int, input().split())) G = [[float('inf')]*N for i in range(N)] G2 = [[float('inf')]*N for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) G[a-1][b-1] = c G[b-1][a-1] = c G2[a-1][b-1] = c G2[b-1][a-1] = c for k in range(N): for i in range(N...
26
24
706
599
N, M = list(map(int, input().split())) graph = [[float("inf")] * N for i in range(N)] graph2 = [[float("inf")] * N for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) graph[a - 1][b - 1] = c graph[b - 1][a - 1] = c graph2[a - 1][b - 1] = c graph2[b - 1][a - 1] = c edge = ...
N, M = list(map(int, input().split())) G = [[float("inf")] * N for i in range(N)] G2 = [[float("inf")] * N for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) G[a - 1][b - 1] = c G[b - 1][a - 1] = c G2[a - 1][b - 1] = c G2[b - 1][a - 1] = c for k in range(N): for i in...
false
7.692308
[ "-graph = [[float(\"inf\")] * N for i in range(N)]", "-graph2 = [[float(\"inf\")] * N for i in range(N)]", "+G = [[float(\"inf\")] * N for i in range(N)]", "+G2 = [[float(\"inf\")] * N for i in range(N)]", "- graph[a - 1][b - 1] = c", "- graph[b - 1][a - 1] = c", "- graph2[a - 1][b - 1] = c", ...
false
0.038725
0.042415
0.913018
[ "s129562764", "s535787189" ]
u451012573
p02768
python
s594388280
s182330428
675
213
10,940
18,848
Accepted
Accepted
68.44
N, A, B = list(map(int, input().split())) MAX = max(A, B) + 1 MOD = 1000000007 nCk = [0] * MAX nCk[0] = 0 nCk[1] = N def mod_pow(a, n, m): res = 1 while n != 0: if n & 1: res = (res * a) % m n = n >> 1 a = (a * a) % m return res def mod_inv(a, m): ...
N, A, B = list(map(int, input().split())) MAX = max(A, B) + 1 MOD = 1000000007 nCk = [0] * MAX nCk[0] = 0 nCk[1] = N inv = [0] * MAX inv[1] = 1 for i in range(2, MAX): inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD nCk[i] = (nCk[i - 1] * (N - i + 1) * inv[i]) % MOD count = (pow(2, N, MOD) - 1 -...
39
16
687
357
N, A, B = list(map(int, input().split())) MAX = max(A, B) + 1 MOD = 1000000007 nCk = [0] * MAX nCk[0] = 0 nCk[1] = N def mod_pow(a, n, m): res = 1 while n != 0: if n & 1: res = (res * a) % m n = n >> 1 a = (a * a) % m return res def mod_inv(a, m): b = m u = 1 ...
N, A, B = list(map(int, input().split())) MAX = max(A, B) + 1 MOD = 1000000007 nCk = [0] * MAX nCk[0] = 0 nCk[1] = N inv = [0] * MAX inv[1] = 1 for i in range(2, MAX): inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD nCk[i] = (nCk[i - 1] * (N - i + 1) * inv[i]) % MOD count = (pow(2, N, MOD) - 1 - nCk[A] - nCk[B])...
false
58.974359
[ "-", "-", "-def mod_pow(a, n, m):", "- res = 1", "- while n != 0:", "- if n & 1:", "- res = (res * a) % m", "- n = n >> 1", "- a = (a * a) % m", "- return res", "-", "-", "-def mod_inv(a, m):", "- b = m", "- u = 1", "- v = 0", "- w...
false
0.627714
0.13814
4.544044
[ "s594388280", "s182330428" ]
u784022244
p02924
python
s364435000
s939949487
180
63
38,256
61,672
Accepted
Accepted
65
N=int(eval(input())) ans=N*(N-1)//2 print(ans)
N=int(eval(input())) print((N*(N+1)//2 - N))
3
2
42
37
N = int(eval(input())) ans = N * (N - 1) // 2 print(ans)
N = int(eval(input())) print((N * (N + 1) // 2 - N))
false
33.333333
[ "-ans = N * (N - 1) // 2", "-print(ans)", "+print((N * (N + 1) // 2 - N))" ]
false
0.041047
0.037355
1.098852
[ "s364435000", "s939949487" ]
u687574784
p02982
python
s824999246
s587717414
34
29
10,008
9,488
Accepted
Accepted
14.71
n,d = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(n)] def dist_squere(x, y): d = 0 for i,j in zip(x,y): d += (i-j)**2 return d squares = set([i*i for i in range(10000)]) def is_square(x): return x in squares from itertools import combinatio...
n,d = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(n)] def dist_squere(x, y): d = 0 for i,j in zip(x,y): d += (i-j)**2 return d**.5 from itertools import combinations ans = 0 for x,y in combinations(X, 2): if dist_squere(x, y).is_integer(): ...
21
17
435
351
n, d = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(n)] def dist_squere(x, y): d = 0 for i, j in zip(x, y): d += (i - j) ** 2 return d squares = set([i * i for i in range(10000)]) def is_square(x): return x in squares from itertools import combinati...
n, d = list(map(int, input().split())) X = [list(map(int, input().split())) for _ in range(n)] def dist_squere(x, y): d = 0 for i, j in zip(x, y): d += (i - j) ** 2 return d**0.5 from itertools import combinations ans = 0 for x, y in combinations(X, 2): if dist_squere(x, y).is_integer(): ...
false
19.047619
[ "- return d", "-", "-", "-squares = set([i * i for i in range(10000)])", "-", "-", "-def is_square(x):", "- return x in squares", "+ return d**0.5", "- if is_square(dist_squere(x, y)):", "+ if dist_squere(x, y).is_integer():" ]
false
0.098326
0.064795
1.51748
[ "s824999246", "s587717414" ]
u025501820
p03290
python
s243646373
s628779994
153
27
3,064
3,064
Accepted
Accepted
82.35
D, G = list(map(int, input().split())) p = [] c = [] for _ in range(D): p_i, c_i = list(map(int, input().split())) p.append(p_i) c.append(c_i) ans = sum(p) for i in range(pow(2, D) - 1): status = bin(i)[2:].zfill(D) all_index = [j for j, k in enumerate(status) if k == str(1)] not_all_...
#!/usr/bin/env python3 import math D, G = list(map(int, input().split())) data = [] for i in range(D): p, c = list(map(int, input().split())) data.append([100 * (i + 1), p, c]) data = sorted(data)[::-1] ans = float("inf") for i in range(2 ** D): total = 0 num = 0 idx = [] for ...
31
38
868
892
D, G = list(map(int, input().split())) p = [] c = [] for _ in range(D): p_i, c_i = list(map(int, input().split())) p.append(p_i) c.append(c_i) ans = sum(p) for i in range(pow(2, D) - 1): status = bin(i)[2:].zfill(D) all_index = [j for j, k in enumerate(status) if k == str(1)] not_all_index = [j ...
#!/usr/bin/env python3 import math D, G = list(map(int, input().split())) data = [] for i in range(D): p, c = list(map(int, input().split())) data.append([100 * (i + 1), p, c]) data = sorted(data)[::-1] ans = float("inf") for i in range(2**D): total = 0 num = 0 idx = [] for k in range(D): ...
false
18.421053
[ "+#!/usr/bin/env python3", "+import math", "+", "-p = []", "-c = []", "-for _ in range(D):", "- p_i, c_i = list(map(int, input().split()))", "- p.append(p_i)", "- c.append(c_i)", "-ans = sum(p)", "-for i in range(pow(2, D) - 1):", "- status = bin(i)[2:].zfill(D)", "- all_index...
false
0.043535
0.09828
0.442966
[ "s243646373", "s628779994" ]
u390727364
p02762
python
s272680118
s846120460
619
513
60,252
59,228
Accepted
Accepted
17.12
from sys import stdin, setrecursionlimit class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def find(self, x): p = self.parent while p[x] >= 0: x, p[x] = p[x], p[p[x]] return x def union(self, x, y): x = self.find(x) ...
from sys import stdin, setrecursionlimit class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def find(self, x): p = self.parent while p[x] >= 0: x, p[x] = p[x], p[p[x]] return x def union(self, x, y): x = self.find(x) ...
54
55
1,214
1,222
from sys import stdin, setrecursionlimit class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def find(self, x): p = self.parent while p[x] >= 0: x, p[x] = p[x], p[p[x]] return x def union(self, x, y): x = self.find(x) y = self.fi...
from sys import stdin, setrecursionlimit class UnionFindTree: def __init__(self, n): self.parent = [-1] * n def find(self, x): p = self.parent while p[x] >= 0: x, p[x] = p[x], p[p[x]] return x def union(self, x, y): x = self.find(x) y = self.fi...
false
1.818182
[ "- n, m, k = list(map(int, stdin.readline().split()))", "+ input = stdin.buffer.readline", "+ n, m, k = list(map(int, input().split()))", "- a, b = list(map(int, stdin.readline().split()))", "+ a, b = list(map(int, input().split()))", "- c, d = list(map(int, stdin.readline()....
false
0.104545
0.04342
2.407744
[ "s272680118", "s846120460" ]
u707124227
p03039
python
s260328421
s977499816
454
153
33,164
66,772
Accepted
Accepted
66.3
n,m,k=list(map(int,input().split())) mod=pow(10,9)+7 # コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる def cmb(n,r,mod): if (r<0 or r>n): return 0 r=min(r,n-r) return g1[n]*g2[r]*g2[n-r]%mod g1=[1,1] # g1[i]=i! % mod :階乗 g2=[1,1] # g2[i]=(i!)^(-1) % mod :階乗の逆元 inverse=[0,1] for i in range(2,n*m+1):...
n,m,k=list(map(int,input().split())) mod=pow(10,9)+7 ans=0 #n*m-2個の中からk-2個選ぶときの組み合わせ数 cmb=1 for i in range(k-2): cmb*=n*m-i-2 cmb%=mod cmb*=pow(i+1,mod-2,mod) cmb%=mod for i in range(1,n): tmp=i*(n-i) tmp*=m**2 tmp%=mod tmp*=cmb tmp%=mod ans+=tmp ans%=mod for i in range(1,m): ...
32
28
663
412
n, m, k = list(map(int, input().split())) mod = pow(10, 9) + 7 # コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod g1 = [1, 1] # g1[i]=i! % mod :階乗 g2 = [1, 1] # g2[i]=(i!)^(-1) % mod :階乗の逆元 invers...
n, m, k = list(map(int, input().split())) mod = pow(10, 9) + 7 ans = 0 # n*m-2個の中からk-2個選ぶときの組み合わせ数 cmb = 1 for i in range(k - 2): cmb *= n * m - i - 2 cmb %= mod cmb *= pow(i + 1, mod - 2, mod) cmb %= mod for i in range(1, n): tmp = i * (n - i) tmp *= m**2 tmp %= mod tmp *= cmb tmp %...
false
12.5
[ "-# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる", "-def cmb(n, r, mod):", "- if r < 0 or r > n:", "- return 0", "- r = min(r, n - r)", "- return g1[n] * g2[r] * g2[n - r] % mod", "-", "-", "-g1 = [1, 1] # g1[i]=i! % mod :階乗", "-g2 = [1, 1] # g2[i]=(i!)^(-1) % mod :階乗の逆元", "-inv...
false
0.128266
0.125297
1.023698
[ "s260328421", "s977499816" ]
u131984977
p02419
python
s587982932
s056797061
40
20
6,728
7,352
Accepted
Accepted
50
target = eval(input()) count = 0 while True: line = eval(input()) if line == 'END_OF_TEXT': break for word in line.split(): if word.lower() == target.lower(): count += 1 print(count)
W = eval(input()) count = 0 while True: line = eval(input()) if line == 'END_OF_TEXT': break for s in line.lower().split(): if s == W: count += 1 print(count)
13
13
225
201
target = eval(input()) count = 0 while True: line = eval(input()) if line == "END_OF_TEXT": break for word in line.split(): if word.lower() == target.lower(): count += 1 print(count)
W = eval(input()) count = 0 while True: line = eval(input()) if line == "END_OF_TEXT": break for s in line.lower().split(): if s == W: count += 1 print(count)
false
0
[ "-target = eval(input())", "+W = eval(input())", "- for word in line.split():", "- if word.lower() == target.lower():", "+ for s in line.lower().split():", "+ if s == W:" ]
false
0.166389
0.044051
3.777203
[ "s587982932", "s056797061" ]
u021548497
p02868
python
s890402588
s444377644
830
406
100,800
101,572
Accepted
Accepted
51.08
import sys input = sys.stdin.readline class Segment_tree_Lazy: def __init__(self, n): self.init(n) #この次の処理は、求められる動作に応じて変化させる。ここでは区間最小問題のコードを書く。 self.node = [self.inf]*self.size self.lazy = [self.inf]*self.size def ...
import sys from heapq import * input = sys.stdin.readline def main(): n, m = list(map(int, input().split())) tree = [[] for _ in range(n)] for i in range(m): s, t, c = list(map(int, input().split())) tree[t-1].append((s-1, c)) tree[s-1].append((t-1, c)) fo...
116
39
2,908
838
import sys input = sys.stdin.readline class Segment_tree_Lazy: def __init__(self, n): self.init(n) # この次の処理は、求められる動作に応じて変化させる。ここでは区間最小問題のコードを書く。 self.node = [self.inf] * self.size self.lazy = [self.inf] * self.size def init(self, n): self.inf = pow(2, 60) self...
import sys from heapq import * input = sys.stdin.readline def main(): n, m = list(map(int, input().split())) tree = [[] for _ in range(n)] for i in range(m): s, t, c = list(map(int, input().split())) tree[t - 1].append((s - 1, c)) tree[s - 1].append((t - 1, c)) for i in range(...
false
66.37931
[ "+from heapq import *", "-class Segment_tree_Lazy:", "- def __init__(self, n):", "- self.init(n)", "- # この次の処理は、求められる動作に応じて変化させる。ここでは区間最小問題のコードを書く。", "- self.node = [self.inf] * self.size", "- self.lazy = [self.inf] * self.size", "-", "- def init(self, n):", "- ...
false
0.037818
0.036738
1.029402
[ "s890402588", "s444377644" ]
u811733736
p00206
python
s601376107
s784964090
50
40
7,744
7,752
Accepted
Accepted
20
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0206 """ import sys from sys import stdin input = stdin.readline def main(args): while True: L = int(eval(input())) if L == 0: break ans = 'NA' for i in range(1, 12+1):...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0206 """ import sys from sys import stdin input = stdin.readline def main(args): while True: L = int(eval(input())) if L == 0: break ans = 'NA' for i in range(1, 12+1):...
27
29
552
604
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0206 """ import sys from sys import stdin input = stdin.readline def main(args): while True: L = int(eval(input())) if L == 0: break ans = "NA" for i in range(1, 12 + 1): M...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0206 """ import sys from sys import stdin input = stdin.readline def main(args): while True: L = int(eval(input())) if L == 0: break ans = "NA" for i in range(1, 12 + 1): i...
false
6.896552
[ "- M, N = list(map(int, input().split()))", "+ M, N = list(map(int, input().split()))", "+ else:", "+ _ = eval(input())" ]
false
0.042547
0.042395
1.003597
[ "s601376107", "s784964090" ]
u453500284
p02953
python
s477677494
s668517725
227
84
63,856
15,020
Accepted
Accepted
63
n = int(eval(input())) arr = list(map(int, input().split())) for i in range(n): if i == 0: continue if arr[i] < arr[i-1]: print("No") exit() if arr[i] > arr[i-1]: arr[i] -= 1 print("Yes")
N = int(eval(input())) H = list(map(int, input().split())) a = H[0] for i in range(1,N-1): a = max(H[i], a) b = H[i+1] if a - b >= 2: print("No") exit() print("Yes")
12
10
204
196
n = int(eval(input())) arr = list(map(int, input().split())) for i in range(n): if i == 0: continue if arr[i] < arr[i - 1]: print("No") exit() if arr[i] > arr[i - 1]: arr[i] -= 1 print("Yes")
N = int(eval(input())) H = list(map(int, input().split())) a = H[0] for i in range(1, N - 1): a = max(H[i], a) b = H[i + 1] if a - b >= 2: print("No") exit() print("Yes")
false
16.666667
[ "-n = int(eval(input()))", "-arr = list(map(int, input().split()))", "-for i in range(n):", "- if i == 0:", "- continue", "- if arr[i] < arr[i - 1]:", "+N = int(eval(input()))", "+H = list(map(int, input().split()))", "+a = H[0]", "+for i in range(1, N - 1):", "+ a = max(H[i], a)...
false
0.03721
0.034448
1.080178
[ "s477677494", "s668517725" ]
u327466606
p02599
python
s124016216
s338966176
1,915
1,635
266,316
242,060
Accepted
Accepted
14.62
class BinaryIndexedTree: def __init__(self, size): self.data = [0] * (size+1) self.msb = 1 << (size.bit_length()-1) def _add(self, i, w): i += 1 while i < len(self.data): self.data[i] += w i += i & -i def _get_sum(self, i): ...
class BinaryIndexedTree: def __init__(self, size): self.data = [0] * (size+1) self.size = size+1 self.msb = 1 << (size.bit_length()-1) def _add(self, i, w): i += 1 while i < self.size: self.data[i] += w i += i & -i def _ge...
104
120
2,463
2,880
class BinaryIndexedTree: def __init__(self, size): self.data = [0] * (size + 1) self.msb = 1 << (size.bit_length() - 1) def _add(self, i, w): i += 1 while i < len(self.data): self.data[i] += w i += i & -i def _get_sum(self, i): res = 0 ...
class BinaryIndexedTree: def __init__(self, size): self.data = [0] * (size + 1) self.size = size + 1 self.msb = 1 << (size.bit_length() - 1) def _add(self, i, w): i += 1 while i < self.size: self.data[i] += w i += i & -i def _get_sum(self, i)...
false
13.333333
[ "+ self.size = size + 1", "- while i < len(self.data):", "+ while i < self.size:", "+ Q = len(queries)", "- last_ind = [None] * (5 * 10**5 + 1)", "- queries = sorted(", "- ((r, l - 1, i) for i, (l, r) in enumerate(queries)), key=lambda x: x[0]", "- )", "- q...
false
0.047506
0.039521
1.202031
[ "s124016216", "s338966176" ]
u753803401
p04039
python
s455233767
s394285646
80
28
2,940
3,060
Accepted
Accepted
65
n, k = list(map(int, input().split())) d = tuple(map(str, input().split())) for i in range(n, 10 ** 9): b = True for s in tuple(str(i)): if s in d: b = False break if b: print(i) exit()
import itertools n, k = list(map(int, input().split())) d = list(map(int, input().split())) u = [] for i in range(0, 10): if i not in d: u.append(i) for j in range(1, 6): for i in itertools.product(u, repeat=j): t = int("".join(map(str, i))) if n <= t <= 100000: pr...
11
13
250
341
n, k = list(map(int, input().split())) d = tuple(map(str, input().split())) for i in range(n, 10**9): b = True for s in tuple(str(i)): if s in d: b = False break if b: print(i) exit()
import itertools n, k = list(map(int, input().split())) d = list(map(int, input().split())) u = [] for i in range(0, 10): if i not in d: u.append(i) for j in range(1, 6): for i in itertools.product(u, repeat=j): t = int("".join(map(str, i))) if n <= t <= 100000: print(t) ...
false
15.384615
[ "+import itertools", "+", "-d = tuple(map(str, input().split()))", "-for i in range(n, 10**9):", "- b = True", "- for s in tuple(str(i)):", "- if s in d:", "- b = False", "- break", "- if b:", "- print(i)", "- exit()", "+d = list(map(int, i...
false
0.068653
0.041465
1.655664
[ "s455233767", "s394285646" ]
u705617253
p03835
python
s933710893
s838855989
1,506
1,220
2,940
2,940
Accepted
Accepted
18.99
k, s = list(map(int, input().split())) result = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z <= k: result += 1 print(result)
k, s = list(map(int, input().split())) result = 0 for x in range(0, k + 1): for y in range(0, k + 1): if 0 <= s - x - y <= k: result += 1 print(result)
10
9
189
180
k, s = list(map(int, input().split())) result = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z <= k: result += 1 print(result)
k, s = list(map(int, input().split())) result = 0 for x in range(0, k + 1): for y in range(0, k + 1): if 0 <= s - x - y <= k: result += 1 print(result)
false
10
[ "-for x in range(k + 1):", "- for y in range(k + 1):", "- z = s - x - y", "- if 0 <= z <= k:", "+for x in range(0, k + 1):", "+ for y in range(0, k + 1):", "+ if 0 <= s - x - y <= k:" ]
false
0.049788
0.047879
1.039862
[ "s933710893", "s838855989" ]
u606878291
p02660
python
s748753968
s525518134
201
173
9,480
9,308
Accepted
Accepted
13.93
from collections import Counter N = int(eval(input())) n = N counter = Counter() while n % 2 == 0: counter[2] += 1 n //= 2 p = 3 while p ** 2 <= N: if n % p == 0: counter[p] += 1 n //= p else: p += 2 if n != 1: counter[N] += 1 ans = 0 for key in list(co...
from collections import Counter def prime_factorization(n): counter = Counter() max_pp = n while n % 2 == 0: counter[2] += 1 n //= 2 p = 3 while p ** 2 <= max_pp: if n % p == 0: counter[p] += 1 n //= p else: p += 2 ...
28
34
439
677
from collections import Counter N = int(eval(input())) n = N counter = Counter() while n % 2 == 0: counter[2] += 1 n //= 2 p = 3 while p**2 <= N: if n % p == 0: counter[p] += 1 n //= p else: p += 2 if n != 1: counter[N] += 1 ans = 0 for key in list(counter.keys()): e = 1...
from collections import Counter def prime_factorization(n): counter = Counter() max_pp = n while n % 2 == 0: counter[2] += 1 n //= 2 p = 3 while p**2 <= max_pp: if n % p == 0: counter[p] += 1 n //= p else: p += 2 if n != 1: ...
false
17.647059
[ "+", "+def prime_factorization(n):", "+ counter = Counter()", "+ max_pp = n", "+ while n % 2 == 0:", "+ counter[2] += 1", "+ n //= 2", "+ p = 3", "+ while p**2 <= max_pp:", "+ if n % p == 0:", "+ counter[p] += 1", "+ n //= p", "+ ...
false
0.073205
0.141767
0.516376
[ "s748753968", "s525518134" ]
u562935282
p03835
python
s491945648
s848362562
1,701
1,538
2,940
2,940
Accepted
Accepted
9.58
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - (x + y) if (0 <= z) and (z <= k): cnt += 1 print(cnt)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - (x + y) if not (0 <= z <= k): continue cnt += 1 print(cnt)
8
10
187
204
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - (x + y) if (0 <= z) and (z <= k): cnt += 1 print(cnt)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - (x + y) if not (0 <= z <= k): continue cnt += 1 print(cnt)
false
20
[ "- if (0 <= z) and (z <= k):", "- cnt += 1", "+ if not (0 <= z <= k):", "+ continue", "+ cnt += 1" ]
false
0.046158
0.046564
0.991292
[ "s491945648", "s848362562" ]
u254871849
p03474
python
s044316657
s026220347
25
17
3,772
3,060
Accepted
Accepted
32
import sys # import collections # import math import string # import bisect # import re # import itertools # import statistics def main(): a, b = (int(x) for x in sys.stdin.readline().split()) s = sys.stdin.readline().rstrip() if s[a] == '-': s_a, s_b = s[:a], s[a+1:] for i in...
import sys a, b = list(map(int, sys.stdin.readline().split())) s = sys.stdin.readline().rstrip() def main(): return 'Yes' if s[a] == '-' and not '-' in set(s[:a] + s[a+1:]) else 'No' if __name__ == '__main__': ans = main() print(ans)
35
11
813
252
import sys # import collections # import math import string # import bisect # import re # import itertools # import statistics def main(): a, b = (int(x) for x in sys.stdin.readline().split()) s = sys.stdin.readline().rstrip() if s[a] == "-": s_a, s_b = s[:a], s[a + 1 :] for i in s_a: ...
import sys a, b = list(map(int, sys.stdin.readline().split())) s = sys.stdin.readline().rstrip() def main(): return "Yes" if s[a] == "-" and not "-" in set(s[:a] + s[a + 1 :]) else "No" if __name__ == "__main__": ans = main() print(ans)
false
68.571429
[ "-# import collections", "-# import math", "-import string", "+a, b = list(map(int, sys.stdin.readline().split()))", "+s = sys.stdin.readline().rstrip()", "-# import bisect", "-# import re", "-# import itertools", "-# import statistics", "+", "- a, b = (int(x) for x in sys.stdin.readline().sp...
false
0.188311
0.103433
1.820603
[ "s044316657", "s026220347" ]
u077291787
p02684
python
s469792306
s852557667
124
108
32,560
31,808
Accepted
Accepted
12.9
def main(): N, K, *A = list(map(int, open(0).read().split())) A = [0] + A cur = 1 visited = [-1] * (N + 1) visited[cur] = 0 for i in range(1, K + 1): next = A[cur] if cur == next: print(next) return elif (j := visited[next]) != -1: ...
def main(): N, K, *A = list(map(int, open(0).read().split())) A = [0] + A cur_pos = 1 last_visit = [-1] * (N + 1) last_visit[cur_pos] = 0 for i in range(1, K + 1): nxt_pos = A[cur_pos] if cur_pos == nxt_pos: print(nxt_pos) return elif (...
24
22
562
597
def main(): N, K, *A = list(map(int, open(0).read().split())) A = [0] + A cur = 1 visited = [-1] * (N + 1) visited[cur] = 0 for i in range(1, K + 1): next = A[cur] if cur == next: print(next) return elif (j := visited[next]) != -1: prin...
def main(): N, K, *A = list(map(int, open(0).read().split())) A = [0] + A cur_pos = 1 last_visit = [-1] * (N + 1) last_visit[cur_pos] = 0 for i in range(1, K + 1): nxt_pos = A[cur_pos] if cur_pos == nxt_pos: print(nxt_pos) return elif (j := last_vi...
false
8.333333
[ "- cur = 1", "- visited = [-1] * (N + 1)", "- visited[cur] = 0", "+ cur_pos = 1", "+ last_visit = [-1] * (N + 1)", "+ last_visit[cur_pos] = 0", "- next = A[cur]", "- if cur == next:", "- print(next)", "+ nxt_pos = A[cur_pos]", "+ if cur_po...
false
0.045253
0.046877
0.965366
[ "s469792306", "s852557667" ]
u796942881
p03409
python
s052495174
s699607440
20
18
3,064
3,064
Accepted
Accepted
10
def main(): N = int(eval(input())) ab = [tuple(int(j) for j in input().split()) for i in range(N)] cd = [tuple(int(j) for j in input().split()) for i in range(N)] # y 降順 ab.sort(key=lambda x:x[1], reverse=True) # x 昇順 cd.sort() # ペアになった赤 done = [False] * N for bx, by in...
def main(): N = int(eval(input())) ab = [tuple(int(j) for j in input().split()) for i in range(N)] cd = [tuple(int(j) for j in input().split()) for i in range(N)] # y 降順 ab.sort(key=lambda x:x[1], reverse=True) # x 昇順 cd.sort() ans = 0 for bx, by in cd: for rx, ry i...
20
20
526
483
def main(): N = int(eval(input())) ab = [tuple(int(j) for j in input().split()) for i in range(N)] cd = [tuple(int(j) for j in input().split()) for i in range(N)] # y 降順 ab.sort(key=lambda x: x[1], reverse=True) # x 昇順 cd.sort() # ペアになった赤 done = [False] * N for bx, by in cd: ...
def main(): N = int(eval(input())) ab = [tuple(int(j) for j in input().split()) for i in range(N)] cd = [tuple(int(j) for j in input().split()) for i in range(N)] # y 降順 ab.sort(key=lambda x: x[1], reverse=True) # x 昇順 cd.sort() ans = 0 for bx, by in cd: for rx, ry in ab: ...
false
0
[ "- # ペアになった赤", "- done = [False] * N", "+ ans = 0", "- for k, ((rx, ry), d) in enumerate(zip(ab, done)):", "- if not d and rx < bx and ry < by:", "- done[k] = True", "+ for rx, ry in ab:", "+ if rx < bx and ry < by:", "+ ab.r...
false
0.037447
0.036642
1.021952
[ "s052495174", "s699607440" ]
u631277801
p03546
python
s718811220
s850569899
37
32
3,700
3,316
Accepted
Accepted
13.51
import sys from heapq import heappush, heappop stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readli...
h,w = list(map(int, input().split())) cost = [list(map(int, input().split())) for _ in range(10)] wall = [list(map(int, input().split())) for _ in range(h)] nums = 10 for k in range(nums): for i in range(nums): for j in range(nums): cost[i][j] = min(cost[i][j], cost[i][k] ...
59
18
1,514
436
import sys from heapq import heappush, heappop stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return s...
h, w = list(map(int, input().split())) cost = [list(map(int, input().split())) for _ in range(10)] wall = [list(map(int, input().split())) for _ in range(h)] nums = 10 for k in range(nums): for i in range(nums): for j in range(nums): cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]) ans = 0 ...
false
69.491525
[ "-import sys", "-from heapq import heappush, heappop", "-", "-stdin = sys.stdin", "-sys.setrecursionlimit(10**5)", "-", "-", "-def li():", "- return list(map(int, stdin.readline().split()))", "-", "-", "-def li_():", "- return [int(x) - 1 for x in stdin.readline().split()]", "-", "...
false
0.108058
0.035541
3.040382
[ "s718811220", "s850569899" ]
u803617136
p03598
python
s117628029
s116275822
20
17
3,316
2,940
Accepted
Accepted
15
n = int(eval(input())) k = int(eval(input())) x = list(map(int, input().split())) ans = 0 for xi in x: ans += min(xi, k - xi) * 2 print(ans)
n = int(eval(input())) k = int(eval(input())) ans = 0 x = list(map(int, input().split())) for v in x: ans += min(v, k - v) * 2 print(ans)
7
7
138
135
n = int(eval(input())) k = int(eval(input())) x = list(map(int, input().split())) ans = 0 for xi in x: ans += min(xi, k - xi) * 2 print(ans)
n = int(eval(input())) k = int(eval(input())) ans = 0 x = list(map(int, input().split())) for v in x: ans += min(v, k - v) * 2 print(ans)
false
0
[ "+ans = 0", "-ans = 0", "-for xi in x:", "- ans += min(xi, k - xi) * 2", "+for v in x:", "+ ans += min(v, k - v) * 2" ]
false
0.064427
0.039255
1.641224
[ "s117628029", "s116275822" ]
u063052907
p03986
python
s045872566
s093255133
315
49
3,756
3,500
Accepted
Accepted
84.44
# coding: utf-8 X = eval(input()) tmp = " " cnt = 0 for x in X: if x == "S": tmp += x cnt += 1 elif x == "T" and tmp[-1]=="S": cnt -= 1 tmp = tmp[0:len(tmp)-1] else: tmp += x cnt += 1 print(cnt)
# coding: utf-8 n_S, n_T = 0, 0 for c in eval(input()): if c == "S": n_S += 1 else: if n_S: n_S -= 1 else: n_T += 1 print((n_S + n_T))
15
12
271
194
# coding: utf-8 X = eval(input()) tmp = " " cnt = 0 for x in X: if x == "S": tmp += x cnt += 1 elif x == "T" and tmp[-1] == "S": cnt -= 1 tmp = tmp[0 : len(tmp) - 1] else: tmp += x cnt += 1 print(cnt)
# coding: utf-8 n_S, n_T = 0, 0 for c in eval(input()): if c == "S": n_S += 1 else: if n_S: n_S -= 1 else: n_T += 1 print((n_S + n_T))
false
20
[ "-X = eval(input())", "-tmp = \" \"", "-cnt = 0", "-for x in X:", "- if x == \"S\":", "- tmp += x", "- cnt += 1", "- elif x == \"T\" and tmp[-1] == \"S\":", "- cnt -= 1", "- tmp = tmp[0 : len(tmp) - 1]", "+n_S, n_T = 0, 0", "+for c in eval(input()):", "+ ...
false
0.038175
0.036518
1.045355
[ "s045872566", "s093255133" ]
u021019433
p02669
python
s566216519
s487010049
527
257
10,960
10,868
Accepted
Accepted
51.23
a = 2, 3, 5 def f(n): m = memo.get(n) if m is None: m = d * n for p, c in zip(a, b): m = min(m, *(f(k) + abs(p * k - n) * d + c for k in (n // p, -(-n // p)))) memo[n] = m return m t = int(eval(input())) for _ in range(t): n, *b, d = list(map(int, input().split())) memo = {0:...
a = 2, 3, 5 def f(n): m = memo.get(n) if m is None: m = d * n for p, c in zip(a, b): k, r = divmod(n, p); m = min(m, f(k) + r * d + c, r and f(k + 1) + (p - r) * d + c or m) memo[n] = m return m t = int(eval(input())) for _ in range(t): n, *b, d = list(map(int, input()...
16
17
333
356
a = 2, 3, 5 def f(n): m = memo.get(n) if m is None: m = d * n for p, c in zip(a, b): m = min(m, *(f(k) + abs(p * k - n) * d + c for k in (n // p, -(-n // p)))) memo[n] = m return m t = int(eval(input())) for _ in range(t): n, *b, d = list(map(int, input().split())...
a = 2, 3, 5 def f(n): m = memo.get(n) if m is None: m = d * n for p, c in zip(a, b): k, r = divmod(n, p) m = min(m, f(k) + r * d + c, r and f(k + 1) + (p - r) * d + c or m) memo[n] = m return m t = int(eval(input())) for _ in range(t): n, *b, d = list(...
false
5.882353
[ "- m = min(m, *(f(k) + abs(p * k - n) * d + c for k in (n // p, -(-n // p))))", "+ k, r = divmod(n, p)", "+ m = min(m, f(k) + r * d + c, r and f(k + 1) + (p - r) * d + c or m)" ]
false
0.156493
0.104557
1.496716
[ "s566216519", "s487010049" ]
u493520238
p02899
python
s236282318
s192610866
286
193
92,988
24,796
Accepted
Accepted
32.52
n = int(eval(input())) al = list(map(int, input().split())) ail = [] for i,a in enumerate(al): ail.append((a,i+1)) ail.sort() ans = [] for a,i in ail: ans.append(i) print((*ans))
n = int(eval(input())) al = list(map(int, input().split())) ail = [] for i,a in enumerate(al): ail.append((a,i+1)) ail.sort() ans = [] for i,a in ail: ans.append(a) print((*ans))
13
12
193
191
n = int(eval(input())) al = list(map(int, input().split())) ail = [] for i, a in enumerate(al): ail.append((a, i + 1)) ail.sort() ans = [] for a, i in ail: ans.append(i) print((*ans))
n = int(eval(input())) al = list(map(int, input().split())) ail = [] for i, a in enumerate(al): ail.append((a, i + 1)) ail.sort() ans = [] for i, a in ail: ans.append(a) print((*ans))
false
7.692308
[ "-for a, i in ail:", "- ans.append(i)", "+for i, a in ail:", "+ ans.append(a)" ]
false
0.041521
0.106596
0.389512
[ "s236282318", "s192610866" ]
u934442292
p02756
python
s375893978
s914540135
174
116
42,604
6,516
Accepted
Accepted
33.33
import sys from collections import deque input = sys.stdin.readline def main(): S = input().rstrip() Q = int(eval(input())) query = [None] * Q for i in range(Q): query[i] = input().split() prefix = deque() surfix = deque() prefix_append = prefix.appendleft sur...
import sys from collections import deque input = sys.stdin.readline def main(): S = input().rstrip() Q = int(eval(input())) prefix = deque() surfix = deque() prefix_append = prefix.appendleft surfix_append = surfix.append is_reversed = False for _ in range(Q): ...
43
40
978
910
import sys from collections import deque input = sys.stdin.readline def main(): S = input().rstrip() Q = int(eval(input())) query = [None] * Q for i in range(Q): query[i] = input().split() prefix = deque() surfix = deque() prefix_append = prefix.appendleft surfix_append = surf...
import sys from collections import deque input = sys.stdin.readline def main(): S = input().rstrip() Q = int(eval(input())) prefix = deque() surfix = deque() prefix_append = prefix.appendleft surfix_append = surfix.append is_reversed = False for _ in range(Q): q = input().spli...
false
6.976744
[ "- query = [None] * Q", "- for i in range(Q):", "- query[i] = input().split()", "- for q in query:", "+ for _ in range(Q):", "+ q = input().split()", "- F, C = q[1], q[2]", "- if F == \"1\":", "+ if q[1] == \"1\":", "- s...
false
0.0463
0.117275
0.3948
[ "s375893978", "s914540135" ]
u133936772
p02632
python
s935116684
s647532838
1,884
632
11,040
75,316
Accepted
Accepted
66.45
M=10**9+7 k,n=int(eval(input())),len(eval(input())) a=t=pow(26,k,M) for i in range(k): t=t*25*(i+n)*pow(26*-~i,-1,M)%M a+=t print((a%M))
M=10**9+7 k,n=int(eval(input())),len(eval(input())) a=t=pow(26,k,M) for i in range(k): t=t*25*(i+n)*pow(26*-~i,M-2,M)%M a+=t print((a%M))
7
7
132
133
M = 10**9 + 7 k, n = int(eval(input())), len(eval(input())) a = t = pow(26, k, M) for i in range(k): t = t * 25 * (i + n) * pow(26 * -~i, -1, M) % M a += t print((a % M))
M = 10**9 + 7 k, n = int(eval(input())), len(eval(input())) a = t = pow(26, k, M) for i in range(k): t = t * 25 * (i + n) * pow(26 * -~i, M - 2, M) % M a += t print((a % M))
false
0
[ "- t = t * 25 * (i + n) * pow(26 * -~i, -1, M) % M", "+ t = t * 25 * (i + n) * pow(26 * -~i, M - 2, M) % M" ]
false
0.039282
0.077245
0.508532
[ "s935116684", "s647532838" ]
u631277801
p04046
python
s524232114
s491184318
369
334
39,000
27,064
Accepted
Accepted
9.49
# nの逆元のリスト def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nの階乗のリスト def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.app...
# nの逆元のリスト def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nの階乗のリスト def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.app...
51
50
1,143
1,088
# nの逆元のリスト def inv_mod(n: int, mod: int) -> list: inv = [0, 1] for i in range(2, n + 1): inv.append(mod - ((mod // i) * inv[mod % i]) % mod) return inv # nの階乗のリスト def fact(n: int, mod: int) -> list: fac = [1, 1] res = 1 for i in range(2, n + 1): res = res * i % mod fac....
# nの逆元のリスト def inv_mod(n: int, mod: int) -> list: inv = [0, 1] for i in range(2, n + 1): inv.append(mod - ((mod // i) * inv[mod % i]) % mod) return inv # nの階乗のリスト def fact(n: int, mod: int) -> list: fac = [1, 1] res = 1 for i in range(2, n + 1): res = res * i % mod fac....
false
1.960784
[ "- if n == 0 and r == 0:", "- return 1", "- elif not (0 <= r and r <= n):", "+ if not (0 <= r and r <= n):", "-H, W, A, B = list(map(int, input().split()))", "-mod = 10**9 + 7", "-inv = inv_mod(H + W, mod)", "-fac = fact(H + W, mod)", "-facInv = fact_inv(H + W, inv, mod)", "-checkP...
false
0.045936
0.125126
0.367115
[ "s524232114", "s491184318" ]
u040298438
p02836
python
s073662040
s375576277
31
27
8,996
9,036
Accepted
Accepted
12.9
s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[-(i + 1)]: cnt += 1 print(cnt)
s = eval(input()) cnt = 0 for a, b in zip(s, s[::-1]): if a != b: cnt += 1 print((cnt // 2))
6
6
109
101
s = eval(input()) cnt = 0 for i in range(len(s) // 2): if s[i] != s[-(i + 1)]: cnt += 1 print(cnt)
s = eval(input()) cnt = 0 for a, b in zip(s, s[::-1]): if a != b: cnt += 1 print((cnt // 2))
false
0
[ "-for i in range(len(s) // 2):", "- if s[i] != s[-(i + 1)]:", "+for a, b in zip(s, s[::-1]):", "+ if a != b:", "-print(cnt)", "+print((cnt // 2))" ]
false
0.066465
0.095271
0.697642
[ "s073662040", "s375576277" ]
u018679195
p02791
python
s411408421
s684096282
103
90
24,596
24,744
Accepted
Accepted
12.62
from sys import stdin def main(): n = int(stdin.readline().strip()) l = list(map(int,stdin.readline().split())) ar = [-1 for _ in range(n)] ar[0] = l[0] ans = 1 for i in range(1,n): if(l[i] <= ar[i-1]): ans+=1 ar[i] = l[i] else: a...
_ = int(eval(input())) numbers = list(map(int, input().split())) curr_min = numbers[0] count = 0 for num in numbers: if num <= curr_min: count += 1 curr_min = num print(count)
17
11
369
201
from sys import stdin def main(): n = int(stdin.readline().strip()) l = list(map(int, stdin.readline().split())) ar = [-1 for _ in range(n)] ar[0] = l[0] ans = 1 for i in range(1, n): if l[i] <= ar[i - 1]: ans += 1 ar[i] = l[i] else: ar[i] = ...
_ = int(eval(input())) numbers = list(map(int, input().split())) curr_min = numbers[0] count = 0 for num in numbers: if num <= curr_min: count += 1 curr_min = num print(count)
false
35.294118
[ "-from sys import stdin", "-", "-", "-def main():", "- n = int(stdin.readline().strip())", "- l = list(map(int, stdin.readline().split()))", "- ar = [-1 for _ in range(n)]", "- ar[0] = l[0]", "- ans = 1", "- for i in range(1, n):", "- if l[i] <= ar[i - 1]:", "- ...
false
0.045797
0.073746
0.621002
[ "s411408421", "s684096282" ]
u955248595
p02719
python
s366123076
s446777669
24
20
9,044
9,140
Accepted
Accepted
16.67
N,K = (int(X) for X in input().split()) if N%K > abs(N%K-K): print((abs(N%K-K))) else: print((N%K))
N,K = (int(X) for X in input().split()) print((min(N%K,abs(N%K-K))))
5
2
108
68
N, K = (int(X) for X in input().split()) if N % K > abs(N % K - K): print((abs(N % K - K))) else: print((N % K))
N, K = (int(X) for X in input().split()) print((min(N % K, abs(N % K - K))))
false
60
[ "-if N % K > abs(N % K - K):", "- print((abs(N % K - K)))", "-else:", "- print((N % K))", "+print((min(N % K, abs(N % K - K))))" ]
false
0.077121
0.041458
1.860193
[ "s366123076", "s446777669" ]
u638456847
p02661
python
s295865417
s824512597
432
220
55,368
54,580
Accepted
Accepted
49.07
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N,*ab = list(map(int, read().split())) AB = [] for a, b in zip(*[iter(ab)]*2): AB.append((a, b)) if N % 2 == 0: AB.sort() a1, _ = AB[N // 2 - 1] a2...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N,*ab = list(map(int, read().split())) A, B = [], [] for a, b in zip(*[iter(ab)]*2): A.append(a) B.append(b) A.sort() B.sort() if N % 2 == 0: a1...
37
33
709
594
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N, *ab = list(map(int, read().split())) AB = [] for a, b in zip(*[iter(ab)] * 2): AB.append((a, b)) if N % 2 == 0: AB.sort() a1, _ = AB[N // 2 - 1] a2, _ = AB[N /...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N, *ab = list(map(int, read().split())) A, B = [], [] for a, b in zip(*[iter(ab)] * 2): A.append(a) B.append(b) A.sort() B.sort() if N % 2 == 0: a1, a2 = A[N // 2...
false
10.810811
[ "- AB = []", "+ A, B = [], []", "- AB.append((a, b))", "+ A.append(a)", "+ B.append(b)", "+ A.sort()", "+ B.sort()", "- AB.sort()", "- a1, _ = AB[N // 2 - 1]", "- a2, _ = AB[N // 2]", "- AB.sort(key=lambda x: x[1])", "- _, b1 ...
false
0.114764
0.040612
2.825848
[ "s295865417", "s824512597" ]
u201234972
p03253
python
s423634514
s254170413
1,949
18
114,384
3,064
Accepted
Accepted
99.08
from collections import Counter from math import factorial Q = 10**9+7 def primes(n): primfac = [0] d = 2 while d*d <= n: while n%d == 0: primfac[-1] += 1 n //= d d += 1 if primfac[-1] != 0: primfac.append(0) if n > 1: if ...
from math import factorial Q = 10**9+7 def primes(n): primfac = [0] d = 2 while d*d <= n: while n%d == 0: primfac[-1] += 1 n //= d d += 1 if primfac[-1] != 0: primfac.append(0) if n > 1: if primfac[-1] == 0: pr...
30
30
691
629
from collections import Counter from math import factorial Q = 10**9 + 7 def primes(n): primfac = [0] d = 2 while d * d <= n: while n % d == 0: primfac[-1] += 1 n //= d d += 1 if primfac[-1] != 0: primfac.append(0) if n > 1: if primf...
from math import factorial Q = 10**9 + 7 def primes(n): primfac = [0] d = 2 while d * d <= n: while n % d == 0: primfac[-1] += 1 n //= d d += 1 if primfac[-1] != 0: primfac.append(0) if n > 1: if primfac[-1] == 0: primfac...
false
0
[ "-from collections import Counter", "-def combination(a, b):", "- return ((factorial(a) // factorial(b)) // factorial(a - b)) % Q", "-", "-", "- ans = (ans * combination(x + N - 1, N - 1)) % Q", "+ for i in range(x):", "+ ans *= N + i", "+ ans //= factorial(x)", ...
false
0.316995
0.042779
7.409979
[ "s423634514", "s254170413" ]
u176645218
p03033
python
s780717418
s240292313
1,848
1,500
171,892
194,848
Accepted
Accepted
18.83
import sys import bisect from heapq import heappop, heappush, heapify input = sys.stdin.readline sys.setrecursionlimit(10**9) N,Q= list(map(int,input().split())) STX = [list(map(int,input().split())) for i in range(N)] D = [int(eval(input())) for i in range(Q)] ''' import random N = 2*10**5 Q = 2*10**5 ST...
import sys import bisect from heapq import heappop, heappush, heapify input = sys.stdin.readline from itertools import chain sys.setrecursionlimit(10**9) N,Q= list(map(int,input().split())) STX = [list(map(int,input().split())) for i in range(N)] D = [int(eval(input())) for i in range(Q)] inf = 10**15 TEMP ...
55
38
1,156
851
import sys import bisect from heapq import heappop, heappush, heapify input = sys.stdin.readline sys.setrecursionlimit(10**9) N, Q = list(map(int, input().split())) STX = [list(map(int, input().split())) for i in range(N)] D = [int(eval(input())) for i in range(Q)] """ import random N = 2*10**5 Q = 2*10**5 STX = [] fo...
import sys import bisect from heapq import heappop, heappush, heapify input = sys.stdin.readline from itertools import chain sys.setrecursionlimit(10**9) N, Q = list(map(int, input().split())) STX = [list(map(int, input().split())) for i in range(N)] D = [int(eval(input())) for i in range(Q)] inf = 10**15 TEMP = [[(s...
false
30.909091
[ "+from itertools import chain", "+", "-\"\"\"", "-import random", "-N = 2*10**5", "-Q = 2*10**5", "-STX = []", "-for i in range(N):", "- S,T = sorted([random.randint(0,10**9-1) for i in range(2)])", "- if S == T:", "- T += 1", "- X = random.randint(1,10**9)", "- STX.append...
false
0.041008
0.038585
1.062808
[ "s780717418", "s240292313" ]
u506858457
p03607
python
s143090528
s224528584
188
167
19,272
20,852
Accepted
Accepted
11.17
n = int(eval(input())) d = dict() for _ in range(n): a = int(eval(input())) d.setdefault(a, -1) d[a] *= -1 ans = 0 for k, v in list(d.items()): if v == 1: ans += 1 print(ans)
from collections import Counter n = int(eval(input())) a = [int(eval(input())) for i in range(n)] p = Counter(a) ans = 0 for i in p: if p[i] % 2 == 1: ans += 1 print(ans)
12
9
197
179
n = int(eval(input())) d = dict() for _ in range(n): a = int(eval(input())) d.setdefault(a, -1) d[a] *= -1 ans = 0 for k, v in list(d.items()): if v == 1: ans += 1 print(ans)
from collections import Counter n = int(eval(input())) a = [int(eval(input())) for i in range(n)] p = Counter(a) ans = 0 for i in p: if p[i] % 2 == 1: ans += 1 print(ans)
false
25
[ "+from collections import Counter", "+", "-d = dict()", "-for _ in range(n):", "- a = int(eval(input()))", "- d.setdefault(a, -1)", "- d[a] *= -1", "+a = [int(eval(input())) for i in range(n)]", "+p = Counter(a)", "-for k, v in list(d.items()):", "- if v == 1:", "+for i in p:", "...
false
0.105619
0.007435
14.204847
[ "s143090528", "s224528584" ]