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
u690536347
p04013
python
s960147013
s700699560
688
417
171,400
92,636
Accepted
Accepted
39.39
n,a=list(map(int,input().split())) *x,=list(map(int,input().split())) dp=[[[None]*(n*50+1) for i in range(n+1)] for _ in range(n+1)] for i in range(n+1): for j in range(n+1): for k in range(n*50+1): if i==0 and j==0 and k==0: dp[i][j][k]=1 elif i and k<x[i-1...
n,a=list(map(int,input().split())) *x,=list(map(int,input().split())) dp=[[[0]*(n*50+1) for i in range(n+1)] for _ in range(n+1)] for i in range(n+1): for j in range(n+1): for k in range(n*50+1): if i==0 and j==0 and k==0: dp[i][j][k]=1 elif i and k<x[i-1]: ...
17
18
561
520
n, a = list(map(int, input().split())) (*x,) = list(map(int, input().split())) dp = [[[None] * (n * 50 + 1) for i in range(n + 1)] for _ in range(n + 1)] for i in range(n + 1): for j in range(n + 1): for k in range(n * 50 + 1): if i == 0 and j == 0 and k == 0: dp[i][j][k] = 1 ...
n, a = list(map(int, input().split())) (*x,) = list(map(int, input().split())) dp = [[[0] * (n * 50 + 1) for i in range(n + 1)] for _ in range(n + 1)] for i in range(n + 1): for j in range(n + 1): for k in range(n * 50 + 1): if i == 0 and j == 0 and k == 0: dp[i][j][k] = 1 ...
false
5.555556
[ "-dp = [[[None] * (n * 50 + 1) for i in range(n + 1)] for _ in range(n + 1)]", "+dp = [[[0] * (n * 50 + 1) for i in range(n + 1)] for _ in range(n + 1)]", "- else:", "- dp[i][j][k] = 0", "-print((sum(dp[n][i][i * a] for i in range(1, n + 1))))", "+v = 0", "+for i in range(1, n ...
false
0.044886
0.042057
1.067255
[ "s960147013", "s700699560" ]
u707808519
p02720
python
s515953646
s591356139
1,010
137
13,040
12,304
Accepted
Accepted
86.44
import queue K = int(eval(input())) q = queue.Queue() for i in range(1, 10): q.put(i) for _ in range(K): x = q.get() d = x%10 t = x*10 if d != 0: q.put(t-1+d) q.put(t+d) if d != 9: q.put(t+1+d) print(x)
# coding: utf-8 # d 現在の桁 # val 現在の値 # all 格納 def rec(d, val, all): # 格納 all.append(val) # 10桁なら終了 if d == 10: return # 再帰 for i in range(-1, 2): add = val%10 + i if 0 <= add <= 9: rec(d+1, val*10+add, all) # main K = int(eval(input())) all =...
15
26
254
409
import queue K = int(eval(input())) q = queue.Queue() for i in range(1, 10): q.put(i) for _ in range(K): x = q.get() d = x % 10 t = x * 10 if d != 0: q.put(t - 1 + d) q.put(t + d) if d != 9: q.put(t + 1 + d) print(x)
# coding: utf-8 # d 現在の桁 # val 現在の値 # all 格納 def rec(d, val, all): # 格納 all.append(val) # 10桁なら終了 if d == 10: return # 再帰 for i in range(-1, 2): add = val % 10 + i if 0 <= add <= 9: rec(d + 1, val * 10 + add, all) # main K = int(eval(input())) all = [] # 1~9...
false
42.307692
[ "-import queue", "+# coding: utf-8", "+# d 現在の桁", "+# val 現在の値", "+# all 格納", "+def rec(d, val, all):", "+ # 格納", "+ all.append(val)", "+ # 10桁なら終了", "+ if d == 10:", "+ return", "+ # 再帰", "+ for i in range(-1, 2):", "+ add = val % 10 + i", "+ if 0 ...
false
0.226947
0.204817
1.108046
[ "s515953646", "s591356139" ]
u391589398
p03031
python
s528678560
s857510246
182
73
73,664
70,896
Accepted
Accepted
59.89
n, m = list(map(int, input().split())) denq = [] for _ in range(m): ks = tuple([int(x)-1 for x in input().split()]) denq.append(set(ks[1:])) P = tuple(map(int, input().split())) ans = 0 for i in range(2**n): kk = [0] * m for j in range(n): # スイッチjがonの場合 if (i>>j)&1: ...
n, m = list(map(int, input().split())) denq = [] for _ in range(m): ks = tuple([int(x)-1 for x in input().split()]) denq.append(ks[1:]) P = tuple(map(int, input().split())) ans = 0 for i in range(2**n): kk = [0] * m switch_states = [(i>>j)&1 for j in range(n)] for idq, dq in enumerate(de...
25
20
616
498
n, m = list(map(int, input().split())) denq = [] for _ in range(m): ks = tuple([int(x) - 1 for x in input().split()]) denq.append(set(ks[1:])) P = tuple(map(int, input().split())) ans = 0 for i in range(2**n): kk = [0] * m for j in range(n): # スイッチjがonの場合 if (i >> j) & 1: for...
n, m = list(map(int, input().split())) denq = [] for _ in range(m): ks = tuple([int(x) - 1 for x in input().split()]) denq.append(ks[1:]) P = tuple(map(int, input().split())) ans = 0 for i in range(2**n): kk = [0] * m switch_states = [(i >> j) & 1 for j in range(n)] for idq, dq in enumerate(denq): ...
false
20
[ "- denq.append(set(ks[1:]))", "+ denq.append(ks[1:])", "- for j in range(n):", "- # スイッチjがonの場合", "- if (i >> j) & 1:", "- for idq, dq in enumerate(denq):", "- # すべての電球に対して", "- # スイッチjが電球に紐付けられていれば、onをカウント", "- if j in d...
false
0.045696
0.066775
0.68433
[ "s528678560", "s857510246" ]
u883048396
p03673
python
s417355849
s873492367
123
46
27,940
24,388
Accepted
Accepted
62.6
iN = int(eval(input())) aA = [int(_) for _ in input().split()] if iN == 1: print((aA[0])) else: print((" " .join([str(_) for _ in aA[-1::-2] + aA[iN%2::2] ])))
iN = int(eval(input())) aA = input().rstrip().split() if iN == 1: print((aA[0])) else: print((" " .join(aA[-1::-2] + aA[iN%2::2])))
9
8
169
139
iN = int(eval(input())) aA = [int(_) for _ in input().split()] if iN == 1: print((aA[0])) else: print((" ".join([str(_) for _ in aA[-1::-2] + aA[iN % 2 :: 2]])))
iN = int(eval(input())) aA = input().rstrip().split() if iN == 1: print((aA[0])) else: print((" ".join(aA[-1::-2] + aA[iN % 2 :: 2])))
false
11.111111
[ "-aA = [int(_) for _ in input().split()]", "+aA = input().rstrip().split()", "- print((\" \".join([str(_) for _ in aA[-1::-2] + aA[iN % 2 :: 2]])))", "+ print((\" \".join(aA[-1::-2] + aA[iN % 2 :: 2])))" ]
false
0.044378
0.041251
1.075809
[ "s417355849", "s873492367" ]
u706786134
p02725
python
s920317161
s507606635
299
235
35,204
35,204
Accepted
Accepted
21.4
import numpy as np K, N = list(map(int, input().split())) A = np.array([int(i) for i in input().split()]) B = A[1:] B = np.insert(B, N - 1, A[0] + K) X = B - A print((sum(X) - max(X)))
import numpy as np K, N = list(map(int, input().split())) A = np.array([int(i) for i in input().split()]) B = A[1:] B = np.insert(B, N - 1, A[0] + K) X = B - A print((K - max(X)))
7
7
182
178
import numpy as np K, N = list(map(int, input().split())) A = np.array([int(i) for i in input().split()]) B = A[1:] B = np.insert(B, N - 1, A[0] + K) X = B - A print((sum(X) - max(X)))
import numpy as np K, N = list(map(int, input().split())) A = np.array([int(i) for i in input().split()]) B = A[1:] B = np.insert(B, N - 1, A[0] + K) X = B - A print((K - max(X)))
false
0
[ "-print((sum(X) - max(X)))", "+print((K - max(X)))" ]
false
0.186049
0.170467
1.091404
[ "s920317161", "s507606635" ]
u624475441
p03201
python
s300302337
s766810859
664
438
55,920
33,712
Accepted
Accepted
34.04
import math from collections import defaultdict def larger_nibeki(i): return 2 ** len(format(i, 'b')) N = int(eval(input())) A = sorted(map(int, input().split()), reverse=True) C = defaultdict(int) for a in A: C[a] += 1 ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partn...
from collections import Counter N, *A = list(map(int, open(0).read().split())) A.sort(reverse=True) C = Counter(A) ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partner = (1 << (a.bit_length())) - a if C[partner] > 0: ans += 1 C[partner] -= 1 print(ans)
19
14
418
307
import math from collections import defaultdict def larger_nibeki(i): return 2 ** len(format(i, "b")) N = int(eval(input())) A = sorted(map(int, input().split()), reverse=True) C = defaultdict(int) for a in A: C[a] += 1 ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partner = large...
from collections import Counter N, *A = list(map(int, open(0).read().split())) A.sort(reverse=True) C = Counter(A) ans = 0 for a in A: if C[a] == 0: continue C[a] -= 1 partner = (1 << (a.bit_length())) - a if C[partner] > 0: ans += 1 C[partner] -= 1 print(ans)
false
26.315789
[ "-import math", "-from collections import defaultdict", "+from collections import Counter", "-", "-def larger_nibeki(i):", "- return 2 ** len(format(i, \"b\"))", "-", "-", "-N = int(eval(input()))", "-A = sorted(map(int, input().split()), reverse=True)", "-C = defaultdict(int)", "-for a in ...
false
0.042311
0.095826
0.441534
[ "s300302337", "s766810859" ]
u271934630
p03329
python
s795534495
s652648397
457
219
3,060
44,880
Accepted
Accepted
52.08
n = int(eval(input())) ans = n for i in range(n+1): count = 0 t = i while(t): count += t % 6 t = int(t/6) t = n-i while(t): count += t % 9 t = int(t/9) ans = min(ans, count) print(ans)
N = int(eval(input())) dp = [float('inf')] * (N+1) dp[0] = 0 for n in range(1, N+1): power = 1 while (power <= n): dp[n] = min(dp[n], dp[n-power] + 1) power *= 6 power = 1 while (power <= n): dp[n] = min(dp[n], dp[n-power] + 1) power *= 9 print((dp[N]))
15
16
250
312
n = int(eval(input())) ans = n for i in range(n + 1): count = 0 t = i while t: count += t % 6 t = int(t / 6) t = n - i while t: count += t % 9 t = int(t / 9) ans = min(ans, count) print(ans)
N = int(eval(input())) dp = [float("inf")] * (N + 1) dp[0] = 0 for n in range(1, N + 1): power = 1 while power <= n: dp[n] = min(dp[n], dp[n - power] + 1) power *= 6 power = 1 while power <= n: dp[n] = min(dp[n], dp[n - power] + 1) power *= 9 print((dp[N]))
false
6.25
[ "-n = int(eval(input()))", "-ans = n", "-for i in range(n + 1):", "- count = 0", "- t = i", "- while t:", "- count += t % 6", "- t = int(t / 6)", "- t = n - i", "- while t:", "- count += t % 9", "- t = int(t / 9)", "- ans = min(ans, count)", "-...
false
0.306189
0.168637
1.815665
[ "s795534495", "s652648397" ]
u086503932
p02702
python
s406086739
s448026531
319
149
16,460
75,968
Accepted
Accepted
53.29
#!/usr/bin/env python3 from collections import Counter def main(): S = eval(input()) N = len(S) T = [0] * (N+1) for i in range(N-1,-1,-1): T[i] = (T[i+1] + int(S[i]) * pow(10,N-i,2019)) % 2019 l = Counter(T) ans = 0 for v in list(l.values()): ans += v * (v-...
from collections import Counter S = eval(input()) N = len(S) mod = [0] * (N+1) now = 0 for i in range(N): now += int(S[N-1-i]) * pow(10,i,2019) % 2019 now %= 2019 mod[N-i-1] = now ans = 0 for l in list(Counter(mod).values()): ans += l * (l-1) // 2 print(ans)
18
15
374
278
#!/usr/bin/env python3 from collections import Counter def main(): S = eval(input()) N = len(S) T = [0] * (N + 1) for i in range(N - 1, -1, -1): T[i] = (T[i + 1] + int(S[i]) * pow(10, N - i, 2019)) % 2019 l = Counter(T) ans = 0 for v in list(l.values()): ans += v * (v - 1) ...
from collections import Counter S = eval(input()) N = len(S) mod = [0] * (N + 1) now = 0 for i in range(N): now += int(S[N - 1 - i]) * pow(10, i, 2019) % 2019 now %= 2019 mod[N - i - 1] = now ans = 0 for l in list(Counter(mod).values()): ans += l * (l - 1) // 2 print(ans)
false
16.666667
[ "-#!/usr/bin/env python3", "-", "-def main():", "- S = eval(input())", "- N = len(S)", "- T = [0] * (N + 1)", "- for i in range(N - 1, -1, -1):", "- T[i] = (T[i + 1] + int(S[i]) * pow(10, N - i, 2019)) % 2019", "- l = Counter(T)", "- ans = 0", "- for v in list(l.value...
false
0.038661
0.081323
0.475398
[ "s406086739", "s448026531" ]
u453055089
p02913
python
s130130787
s682596988
174
133
103,428
99,292
Accepted
Accepted
23.56
N = int(eval(input())) S = eval(input()) ok, ng = 0, N + 1 while abs(ok - ng) > 1: x = (ok + ng) // 2 check = set() for i in range(N - x + 1): check.add(S[i: i + x]) if S[i + x: i + 2 * x] in check: ok = x break else: ng = x print(ok)
n = int(eval(input())) s = eval(input()) left = 0 right = n // 2 + 1 while right - left > 1: mid = (right + left) // 2 length = mid check = set() for i in range(n - length + 1): s1 = s[i:i+length] check.add(s1) if s[i+length: i + 2*length] in check: left =...
15
17
301
376
N = int(eval(input())) S = eval(input()) ok, ng = 0, N + 1 while abs(ok - ng) > 1: x = (ok + ng) // 2 check = set() for i in range(N - x + 1): check.add(S[i : i + x]) if S[i + x : i + 2 * x] in check: ok = x break else: ng = x print(ok)
n = int(eval(input())) s = eval(input()) left = 0 right = n // 2 + 1 while right - left > 1: mid = (right + left) // 2 length = mid check = set() for i in range(n - length + 1): s1 = s[i : i + length] check.add(s1) if s[i + length : i + 2 * length] in check: left = mi...
false
11.764706
[ "-N = int(eval(input()))", "-S = eval(input())", "-ok, ng = 0, N + 1", "-while abs(ok - ng) > 1:", "- x = (ok + ng) // 2", "+n = int(eval(input()))", "+s = eval(input())", "+left = 0", "+right = n // 2 + 1", "+while right - left > 1:", "+ mid = (right + left) // 2", "+ length = mid", ...
false
0.044547
0.039753
1.120582
[ "s130130787", "s682596988" ]
u413021823
p03371
python
s713305515
s282804828
165
27
38,384
9,152
Accepted
Accepted
83.64
import sys from collections import deque from itertools import * def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) ...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) A,B,C,X,Y = LI() ave = (A+B)/2 cost = 0 if ave > C: cost += C ...
37
27
729
607
import sys from collections import deque from itertools import * def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) ...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) A, B, C, X, Y = LI() ave = (A + B) / 2 cost = 0 if ave...
false
27.027027
[ "-from collections import deque", "-from itertools import *", "-avg = (A + B) / 2", "-ans = 0", "-if avg > C:", "- ans += C * min(X, Y) * 2", "+ave = (A + B) / 2", "+cost = 0", "+if ave > C:", "+ cost += C * min(X, Y) * 2", "- ans += C * (X - Y) * 2", "+ cost += C *...
false
0.034874
0.034969
0.997304
[ "s713305515", "s282804828" ]
u346812984
p03583
python
s678633272
s620455896
1,960
1,083
3,064
3,064
Accepted
Accepted
44.74
def solve(): N = int(eval(input())) M = 3501 for h in range(1, M): for n in range(h, M): numerator = N * h * n denominator = 4 * n * h - N * h - N * n if numerator <= 0 or denominator <= 0: continue if numerator % denominator...
import sys sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def solve(N): M = 3501 for h in range(1, M): for n in range(h, M): denominator = 4 * n * h - N * h - N * n if denominator <= ...
16
33
415
614
def solve(): N = int(eval(input())) M = 3501 for h in range(1, M): for n in range(h, M): numerator = N * h * n denominator = 4 * n * h - N * h - N * n if numerator <= 0 or denominator <= 0: continue if numerator % denominator == 0: ...
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def solve(N): M = 3501 for h in range(1, M): for n in range(h, M): denominator = 4 * n * h - N * h - N * n if denominator <= 0: con...
false
51.515152
[ "-def solve():", "- N = int(eval(input()))", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+INF = float(\"inf\")", "+MOD = 10**9 + 7", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "+def solve(N):", "+ denominator = 4 * n * h - N *...
false
2.057079
0.367812
5.59275
[ "s678633272", "s620455896" ]
u934442292
p03160
python
s789288572
s253543364
97
86
24,964
20,320
Accepted
Accepted
11.34
import sys input = sys.stdin.readline def main(): N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)])) h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)])) for i in...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) for i in range(2, N): h2 = h[i] - h[i - 2] if h2 < 0: a = dp[i - 2] - h2 else: a = dp...
27
33
555
616
import sys input = sys.stdin.readline def main(): N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)])) h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)])) for i in range(N - 2):...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) for i in range(2, N): h2 = h[i] - h[i - 2] if h2 < 0: a = dp[i - 2] - h2 else: a = dp[i - 2] + h2 ...
false
18.181818
[ "- h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)]))", "- h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)]))", "- for i in range(N - 2):", "- a = dp[i] + h2[i]", "- b = dp[i + 1] + h1[i]", "+ for i in range(2, N):", "+ h2 = h[i] - h[i - 2]", "+ ...
false
0.035353
0.035296
1.001601
[ "s789288572", "s253543364" ]
u562935282
p03074
python
s093738824
s348543741
140
96
4,768
9,468
Accepted
Accepted
31.43
N, K = list(map(int, input().split())) s = eval(input()) s = list(map(int, s)) v = [] now = 1 # 現在見ている数 cnt = 0 # nowが並ぶ数 for ss in s: if ss == now: cnt += 1 else: v.append(cnt) now = 1 - now # 0と1を切り替える計算 now ^= 1 cnt = 1 # ss分を計上 if cnt > 0: v.append(cnt...
from itertools import accumulate N, K = list(map(int, input().split())) s = eval(input()) s = list(map(int, s)) v = [] now = 1 # 現在見ている数 cnt = 0 # nowが並ぶ数 for ss in s: if ss == now: cnt += 1 else: v.append(cnt) now = 1 - now # 0と1を切り替える計算 now ^= 1 cnt = 1 # s...
45
48
864
869
N, K = list(map(int, input().split())) s = eval(input()) s = list(map(int, s)) v = [] now = 1 # 現在見ている数 cnt = 0 # nowが並ぶ数 for ss in s: if ss == now: cnt += 1 else: v.append(cnt) now = 1 - now # 0と1を切り替える計算 now ^= 1 cnt = 1 # ss分を計上 if cnt > 0: v.append(cnt) # 1-0-1-0-1-0-...
from itertools import accumulate N, K = list(map(int, input().split())) s = eval(input()) s = list(map(int, s)) v = [] now = 1 # 現在見ている数 cnt = 0 # nowが並ぶ数 for ss in s: if ss == now: cnt += 1 else: v.append(cnt) now = 1 - now # 0と1を切り替える計算 now ^= 1 cnt = 1 # ss分を計上 if cnt > 0...
false
6.25
[ "+from itertools import accumulate", "+", "+c_sum = [0] + list(accumulate(v))", "+# accumulate:=[1項目, 1,2項目の和, ...]", "-left, right = 0, 0", "-cur_total = 0", "- nextLeft = i", "- nextRight = min(2 * K + 1 + i, lv)", "- while left < nextLeft:", "- cur_total -= v[left]", "- ...
false
0.047709
0.038729
1.23186
[ "s093738824", "s348543741" ]
u535423069
p03273
python
s306040923
s290704651
217
29
43,480
4,724
Accepted
Accepted
86.64
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] nsl =...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range...
47
52
1,059
1,277
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] nsl = lambda y: [lis...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdi...
false
9.615385
[ "+nf = lambda: float(ns())", "+nfn = lambda y: [nf() for _ in range(y)]", "+nfa = lambda: list(map(float, stdin.readline().split()))", "+nfan = lambda y: [nfa() for _ in range(y)]", "-nsl = lambda y: [list(ns()) for _ in range(y)]", "+ncl = lambda y: [list(ns()) for _ in range(y)]", "-H, W = na()", "-...
false
0.1201
0.038669
3.105858
[ "s306040923", "s290704651" ]
u671060652
p03075
python
s309765202
s301355204
276
66
64,364
61,944
Accepted
Accepted
76.09
import itertools import math import fractions import functools import copy a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input())) k = int(eval(input())) if b-a > k or c-a > k or d-a > k or e-a > k or c-b > k or d-b > k or e-b > k or d-c > k or e...
def main(): # n = int(input()) # n, m = map(int, input().split()) # a = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input()))...
17
20
346
558
import itertools import math import fractions import functools import copy a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input())) k = int(eval(input())) if ( b - a > k or c - a > k or d - a > k or e - a > k or c - b > k or d - b > k ...
def main(): # n = int(input()) # n, m = map(int, input().split()) # a = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) d = int(eval(input())) e = int(eval(input())) k = i...
false
15
[ "-import itertools", "-import math", "-import fractions", "-import functools", "-import copy", "+def main():", "+ # n = int(input())", "+ # n, m = map(int, input().split())", "+ # a = list(map(int, input().split()))", "+ # s = input()", "+ # h = [int(input()) for _ in rane(n)]", ...
false
0.03603
0.037751
0.954416
[ "s309765202", "s301355204" ]
u159994501
p03325
python
s678278301
s052858511
98
90
4,140
4,148
Accepted
Accepted
8.16
N = int(eval(input())) a = list(map(int,input().split())) c = 0 for i in range(N): j = 2 while True: if a[i] % j != 0: break j *= 2 c += 1 print(c)
import math N = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while True: if i % 2 == 0: ans += 1 i //= 2 else: break print(ans)
11
14
196
223
N = int(eval(input())) a = list(map(int, input().split())) c = 0 for i in range(N): j = 2 while True: if a[i] % j != 0: break j *= 2 c += 1 print(c)
import math N = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while True: if i % 2 == 0: ans += 1 i //= 2 else: break print(ans)
false
21.428571
[ "+import math", "+", "-c = 0", "-for i in range(N):", "- j = 2", "+ans = 0", "+for i in a:", "- if a[i] % j != 0:", "+ if i % 2 == 0:", "+ ans += 1", "+ i //= 2", "+ else:", "- j *= 2", "- c += 1", "-print(c)", "+print(ans)" ]
false
0.047686
0.048207
0.989191
[ "s678278301", "s052858511" ]
u556358547
p02922
python
s948767041
s895270761
73
64
61,608
61,636
Accepted
Accepted
12.33
#!/usr/bin/env python3 import sys def solve(A: int, B: int): p = 1 ans = 0 while True: if p >= B: print(ans) break p -= 1 p += A ans += 1 return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You ...
#!/usr/bin/env python3 import sys def solve(A: int, B: int): t = 1 ans = 0 while True: if t >= B: print(ans) break t += A-1 ans += 1 return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the defaul...
30
29
715
701
#!/usr/bin/env python3 import sys def solve(A: int, B: int): p = 1 ans = 0 while True: if p >= B: print(ans) break p -= 1 p += A ans += 1 return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default t...
#!/usr/bin/env python3 import sys def solve(A: int, B: int): t = 1 ans = 0 while True: if t >= B: print(ans) break t += A - 1 ans += 1 return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now...
false
3.333333
[ "- p = 1", "+ t = 1", "- if p >= B:", "+ if t >= B:", "- p -= 1", "- p += A", "+ t += A - 1" ]
false
0.080658
0.059468
1.356338
[ "s948767041", "s895270761" ]
u189487046
p02719
python
s554802730
s920261746
20
17
3,316
2,940
Accepted
Accepted
15
N, K = list(map(int, input().split())) # if N == K: # print(0) # exit(0) # elif N < K: # print(N) # exit(0) ans = [] before = abs(N - K) N = N % K for i in range(10000): ze = abs(N - K) ans.append(ze) before = ze N = ze print((min(ans)))
N, K = list(map(int, input().split())) N = N % K ans1 = abs(N - K) ans2 = abs(ans1-K) print((min(ans1, ans2)))
18
7
281
111
N, K = list(map(int, input().split())) # if N == K: # print(0) # exit(0) # elif N < K: # print(N) # exit(0) ans = [] before = abs(N - K) N = N % K for i in range(10000): ze = abs(N - K) ans.append(ze) before = ze N = ze print((min(ans)))
N, K = list(map(int, input().split())) N = N % K ans1 = abs(N - K) ans2 = abs(ans1 - K) print((min(ans1, ans2)))
false
61.111111
[ "-# if N == K:", "-# print(0)", "-# exit(0)", "-# elif N < K:", "-# print(N)", "-# exit(0)", "-ans = []", "-before = abs(N - K)", "-for i in range(10000):", "- ze = abs(N - K)", "- ans.append(ze)", "- before = ze", "- N = ze", "-print((min(ans)))", "+ans1 = ab...
false
0.052662
0.045699
1.152361
[ "s554802730", "s920261746" ]
u827202523
p02879
python
s440926429
s173846291
193
171
38,384
38,384
Accepted
Accepted
11.4
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) def solve(): return def main(): a, b = getList() if a <= 9 and b <= 9: print((a*b)) else: print((-1)...
def getList(): return list(map(int, input().split())) a, b = getList() if a > 9 or b > 9: print((-1)) else: print((a*b))
23
7
356
130
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) def solve(): return def main(): a, b = getList() if a <= 9 and b <= 9: print((a * b)) else: print((-1)) if __...
def getList(): return list(map(int, input().split())) a, b = getList() if a > 9 or b > 9: print((-1)) else: print((a * b))
false
69.565217
[ "-import sys", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(100000)", "-", "-", "-def getN():", "- return int(eval(input()))", "-", "-", "-def solve():", "- return", "-", "-", "-def main():", "- a, b = getList()", "- if a <= 9 and b <= 9:", "- prin...
false
0.036624
0.060484
0.605516
[ "s440926429", "s173846291" ]
u525065967
p02597
python
s467151624
s664317841
82
73
10,620
10,676
Accepted
Accepted
10.98
n = int(eval(input())) C = list(eval(input())) l, r, c = 0, n-1, 0 while l < r: if C[l] == 'W' and C[r] == 'R': C[l], C[r] = C[r], C[l] l += 1 r -= 1 c += 1 elif C[l] != 'W': l += 1 elif C[r] != 'R': r -= 1 print(c)
n = int(eval(input())) C = list(eval(input())) l, r, c = 0, n-1, 0 while l < r: if C[l] != 'W': l += 1; continue if C[r] != 'R': r -= 1; continue l += 1 r -= 1 c += 1 print(c)
12
10
259
193
n = int(eval(input())) C = list(eval(input())) l, r, c = 0, n - 1, 0 while l < r: if C[l] == "W" and C[r] == "R": C[l], C[r] = C[r], C[l] l += 1 r -= 1 c += 1 elif C[l] != "W": l += 1 elif C[r] != "R": r -= 1 print(c)
n = int(eval(input())) C = list(eval(input())) l, r, c = 0, n - 1, 0 while l < r: if C[l] != "W": l += 1 continue if C[r] != "R": r -= 1 continue l += 1 r -= 1 c += 1 print(c)
false
16.666667
[ "- if C[l] == \"W\" and C[r] == \"R\":", "- C[l], C[r] = C[r], C[l]", "+ if C[l] != \"W\":", "+ continue", "+ if C[r] != \"R\":", "- c += 1", "- elif C[l] != \"W\":", "- l += 1", "- elif C[r] != \"R\":", "- r -= 1", "+ continue", "+ l...
false
0.045748
0.04419
1.035261
[ "s467151624", "s664317841" ]
u019685451
p02585
python
s753568972
s305006283
517
336
75,300
74,712
Accepted
Accepted
35.01
N, K = list(map(int, input().split())) P = list(map(int, input().split())) P = [p - 1 for p in P] C = list(map(int, input().split())) vis = [False] * N ans = [-float('inf')] * N for root in range(N): if vis[root]: continue cycle = [root] costs = [C[root]] u = P[root] while ...
N, K = list(map(int, input().split())) P = list(map(int, input().split())) P = [p - 1 for p in P] C = list(map(int, input().split())) vis = [False] * N ans = [-float('inf')] * N for root in range(N): if vis[root]: continue cycle = [root] costs = [C[root]] u = P[root] while ...
46
51
1,208
1,370
N, K = list(map(int, input().split())) P = list(map(int, input().split())) P = [p - 1 for p in P] C = list(map(int, input().split())) vis = [False] * N ans = [-float("inf")] * N for root in range(N): if vis[root]: continue cycle = [root] costs = [C[root]] u = P[root] while u != root: ...
N, K = list(map(int, input().split())) P = list(map(int, input().split())) P = [p - 1 for p in P] C = list(map(int, input().split())) vis = [False] * N ans = [-float("inf")] * N for root in range(N): if vis[root]: continue cycle = [root] costs = [C[root]] u = P[root] while u != root: ...
false
9.803922
[ "- # Rewrite [1, K] as form q * L + r, :", "+ # Rewrite [1, K] as form q * L + r,", "- # tL + 1, tL + 2, ... (t = floor((K - r) / L))", "+ # tL + 1, tL + 2, ...", "- # since the total cost of loop is either positive or negative", "- # When positive, 0L + r < 1L + ...
false
0.036574
0.119755
0.305407
[ "s753568972", "s305006283" ]
u977389981
p03339
python
s866817195
s054461170
226
184
3,700
3,700
Accepted
Accepted
18.58
n = int(eval(input())) S = eval(input()) ans = n temp = 0 for i in range(1, n): if S[i] =='E': temp += 1 ans = min(ans, temp) for i in range(1, n): if S[i - 1] == 'W': temp += 1 if S[i] == 'E': temp -= 1 ans = min(ans, temp) print(ans)
n = int(eval(input())) s = eval(input()) count = s[1:].count('E') ans = count for i in range(1, n): if s[i -1] == 'W': count += 1 if s[i] == 'E': count -= 1 ans = min(ans, count) print(ans)
18
13
291
219
n = int(eval(input())) S = eval(input()) ans = n temp = 0 for i in range(1, n): if S[i] == "E": temp += 1 ans = min(ans, temp) for i in range(1, n): if S[i - 1] == "W": temp += 1 if S[i] == "E": temp -= 1 ans = min(ans, temp) print(ans)
n = int(eval(input())) s = eval(input()) count = s[1:].count("E") ans = count for i in range(1, n): if s[i - 1] == "W": count += 1 if s[i] == "E": count -= 1 ans = min(ans, count) print(ans)
false
27.777778
[ "-S = eval(input())", "-ans = n", "-temp = 0", "+s = eval(input())", "+count = s[1:].count(\"E\")", "+ans = count", "- if S[i] == \"E\":", "- temp += 1", "-ans = min(ans, temp)", "-for i in range(1, n):", "- if S[i - 1] == \"W\":", "- temp += 1", "- if S[i] == \"E\":",...
false
0.040321
0.040474
0.996215
[ "s866817195", "s054461170" ]
u203843959
p03330
python
s305103065
s639979686
892
754
5,620
3,064
Accepted
Accepted
15.47
N,C=list(map(int,input().split())) Dmat=[] for i in range(C): array=list(map(int,input().split())) Dmat.append(array) #print(Dmat) cmat=[] for i in range(N): array=list(map(int,input().split())) cmat.append(array) #print(cmat) grid_list=[{},{},{}] for i in range(N): for j in range(N): c=...
N,C=list(map(int,input().split())) Dmat=[] for i in range(C): array=list(map(int,input().split())) Dmat.append(array) #print(Dmat) grid_list=[{},{},{}] for i in range(N): array=list(map(int,input().split())) for j in range(N): c=array[j]-1 mod=(i+j)%3 if c in grid_list[mod]: ...
50
43
1,032
918
N, C = list(map(int, input().split())) Dmat = [] for i in range(C): array = list(map(int, input().split())) Dmat.append(array) # print(Dmat) cmat = [] for i in range(N): array = list(map(int, input().split())) cmat.append(array) # print(cmat) grid_list = [{}, {}, {}] for i in range(N): for j in rang...
N, C = list(map(int, input().split())) Dmat = [] for i in range(C): array = list(map(int, input().split())) Dmat.append(array) # print(Dmat) grid_list = [{}, {}, {}] for i in range(N): array = list(map(int, input().split())) for j in range(N): c = array[j] - 1 mod = (i + j) % 3 i...
false
14
[ "-cmat = []", "+grid_list = [{}, {}, {}]", "- cmat.append(array)", "-# print(cmat)", "-grid_list = [{}, {}, {}]", "-for i in range(N):", "- c = cmat[i][j] - 1", "+ c = array[j] - 1", "- for c in grid_list[0]:", "- num = grid_list[0][c]", "+ f...
false
0.055374
0.057186
0.968307
[ "s305103065", "s639979686" ]
u353895424
p03497
python
s271378394
s057383492
180
128
25,748
27,172
Accepted
Accepted
28.89
n, k = list(map(int, input().split())) a = list(map(int, input().split())) K = len(list(set(a))) if K <= k: print((0)) else: rewrite = K - k ans = 0 cnt = [0] *(max(a) + 1) for i in range(n): cnt[a[i]] += 1 cnt.sort() # print(cnt) for c in cnt: if 0 < ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if len(list(set(a))) <= k: print((0)) else: ans = 0 cnt = [0] *(max(a) + 1) for i in range(n): cnt[a[i]] += 1 cnt.sort(reverse=True) tmp = 0 for c in cnt: ans += c tmp += 1 ...
23
20
444
402
n, k = list(map(int, input().split())) a = list(map(int, input().split())) K = len(list(set(a))) if K <= k: print((0)) else: rewrite = K - k ans = 0 cnt = [0] * (max(a) + 1) for i in range(n): cnt[a[i]] += 1 cnt.sort() # print(cnt) for c in cnt: if 0 < c: ans ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if len(list(set(a))) <= k: print((0)) else: ans = 0 cnt = [0] * (max(a) + 1) for i in range(n): cnt[a[i]] += 1 cnt.sort(reverse=True) tmp = 0 for c in cnt: ans += c tmp += 1 if k == tmp...
false
13.043478
[ "-K = len(list(set(a)))", "-if K <= k:", "+if len(list(set(a))) <= k:", "- rewrite = K - k", "- cnt.sort()", "- # print(cnt)", "+ cnt.sort(reverse=True)", "+ tmp = 0", "- if 0 < c:", "- ans += c", "- rewrite -= 1", "- if rewrite == 0:", ...
false
0.068648
0.064564
1.063257
[ "s271378394", "s057383492" ]
u631277801
p03837
python
s050462566
s294364273
606
98
3,572
3,692
Accepted
Accepted
83.83
class MakeGraph: # 隣接行列もしくは隣接リストの初期化 # node_num:ノード数 # isMat:隣接行列(True) / 隣接リスト(False) def __init__(self, node_num:int, isMat:bool) -> None: self.n = node_num self.isMat = isMat # 隣接行列の初期化 if self.isMat: INF = float("inf") self.gr...
from heapq import heappush, heappop def dijkstra(graph:list, node:int, start:int) -> list: # 未探索のノードは距離INF INF = float("inf") dist = [INF]*node # 始点ノードの距離を0とし、dfsのためのpriority queを作成 dist[start] = 0 heap = [(0,start)] # 未探索のノードをpriority queueに入れる while heap: ...
73
98
1,970
2,570
class MakeGraph: # 隣接行列もしくは隣接リストの初期化 # node_num:ノード数 # isMat:隣接行列(True) / 隣接リスト(False) def __init__(self, node_num: int, isMat: bool) -> None: self.n = node_num self.isMat = isMat # 隣接行列の初期化 if self.isMat: INF = float("inf") self.graph = [[INF for ...
from heapq import heappush, heappop def dijkstra(graph: list, node: int, start: int) -> list: # 未探索のノードは距離INF INF = float("inf") dist = [INF] * node # 始点ノードの距離を0とし、dfsのためのpriority queを作成 dist[start] = 0 heap = [(0, start)] # 未探索のノードをpriority queueに入れる while heap: cost, cur_node...
false
25.510204
[ "+from heapq import heappush, heappop", "+", "+", "+def dijkstra(graph: list, node: int, start: int) -> list:", "+ # 未探索のノードは距離INF", "+ INF = float(\"inf\")", "+ dist = [INF] * node", "+ # 始点ノードの距離を0とし、dfsのためのpriority queを作成", "+ dist[start] = 0", "+ heap = [(0, start)]", "+ ...
false
0.047852
0.039885
1.199742
[ "s050462566", "s294364273" ]
u761320129
p03649
python
s310386457
s428301144
510
450
3,064
3,064
Accepted
Accepted
11.76
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 while any([a>N-1 for a in A]): A.sort() d = A[-1] - (N-1) k = -(-d//N) ans += k A[-1] -= k*N for i in range(N-1): A[i] += k print(ans)
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 while any([a>N-1 for a in A]): for i in range(N): if A[i] <= N-1: continue d = A[i] - (N-1) k = -(-d//N) A[i] -= k*N ans += k for j in range(N): if j==i: continue A...
13
15
239
334
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 while any([a > N - 1 for a in A]): A.sort() d = A[-1] - (N - 1) k = -(-d // N) ans += k A[-1] -= k * N for i in range(N - 1): A[i] += k print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 while any([a > N - 1 for a in A]): for i in range(N): if A[i] <= N - 1: continue d = A[i] - (N - 1) k = -(-d // N) A[i] -= k * N ans += k for j in range(N): if j == i: ...
false
13.333333
[ "- A.sort()", "- d = A[-1] - (N - 1)", "- k = -(-d // N)", "- ans += k", "- A[-1] -= k * N", "- for i in range(N - 1):", "- A[i] += k", "+ for i in range(N):", "+ if A[i] <= N - 1:", "+ continue", "+ d = A[i] - (N - 1)", "+ k = -(-d /...
false
0.036865
0.036153
1.019687
[ "s310386457", "s428301144" ]
u028973125
p03966
python
s800096754
s806100128
177
31
38,256
9,196
Accepted
Accepted
82.49
import sys import math N = int(sys.stdin.readline().strip()) ratios = [] for _ in range(N): t, a = list(map(int, sys.stdin.readline().strip().split())) ratios.append((t, a)) ans = 0 for i in range(N-1): t1, a1 = ratios[i] t2, a2 = ratios[i+1] # math.ceilが直球だが、精度が悪い? # rate = ...
import sys input = sys.stdin.readline N = int(eval(input())) rates = [] for _ in range(N): t, a = list(map(int, input().split())) rates.append((t, a)) ans = 0 for i in range(N-1): t1, a1 = rates[i] t2, a2 = rates[i+1] rate = max((t1 - 1) // t2, (a1 - 1) // a2) + 1 rates[i+1] ...
21
19
478
358
import sys import math N = int(sys.stdin.readline().strip()) ratios = [] for _ in range(N): t, a = list(map(int, sys.stdin.readline().strip().split())) ratios.append((t, a)) ans = 0 for i in range(N - 1): t1, a1 = ratios[i] t2, a2 = ratios[i + 1] # math.ceilが直球だが、精度が悪い? # rate = max(math.ceil(t...
import sys input = sys.stdin.readline N = int(eval(input())) rates = [] for _ in range(N): t, a = list(map(int, input().split())) rates.append((t, a)) ans = 0 for i in range(N - 1): t1, a1 = rates[i] t2, a2 = rates[i + 1] rate = max((t1 - 1) // t2, (a1 - 1) // a2) + 1 rates[i + 1] = (t2 * rate,...
false
9.52381
[ "-import math", "-N = int(sys.stdin.readline().strip())", "-ratios = []", "+input = sys.stdin.readline", "+N = int(eval(input()))", "+rates = []", "- t, a = list(map(int, sys.stdin.readline().strip().split()))", "- ratios.append((t, a))", "+ t, a = list(map(int, input().split()))", "+ ...
false
0.038333
0.104971
0.365181
[ "s800096754", "s806100128" ]
u768896740
p03610
python
s154936924
s858110185
76
34
5,676
3,572
Accepted
Accepted
55.26
s = list(input()) l = [s[i] for i in range(len(s)) if i % 2 == 0] for i in l: print(i, end='')
s = eval(input()) t = [] for i in range(len(s)): if i % 2 == 0: t.append(s[i]) print((''.join(t)))
6
7
105
109
s = list(input()) l = [s[i] for i in range(len(s)) if i % 2 == 0] for i in l: print(i, end="")
s = eval(input()) t = [] for i in range(len(s)): if i % 2 == 0: t.append(s[i]) print(("".join(t)))
false
14.285714
[ "-s = list(input())", "-l = [s[i] for i in range(len(s)) if i % 2 == 0]", "-for i in l:", "- print(i, end=\"\")", "+s = eval(input())", "+t = []", "+for i in range(len(s)):", "+ if i % 2 == 0:", "+ t.append(s[i])", "+print((\"\".join(t)))" ]
false
0.040413
0.041434
0.975368
[ "s154936924", "s858110185" ]
u919730120
p02973
python
s386828027
s409409172
239
186
8,612
14,492
Accepted
Accepted
22.18
from bisect import bisect_right,bisect_left n=int(eval(input())) a=[int(eval(input())) for _ in range(n)] INF=float('INF') l=[INF]*n for i in a[::-1]: l[bisect_right(l,i)]=i print((bisect_left(l,INF)))
from bisect import bisect_left,bisect_right n=int(eval(input())) INF=float('inf') l=[INF]*n a=[int(eval(input())) for _ in range(n)] for i in a[::-1]: l[bisect_right(l,i)]=i print((bisect_left(l,INF)))
8
8
198
198
from bisect import bisect_right, bisect_left n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] INF = float("INF") l = [INF] * n for i in a[::-1]: l[bisect_right(l, i)] = i print((bisect_left(l, INF)))
from bisect import bisect_left, bisect_right n = int(eval(input())) INF = float("inf") l = [INF] * n a = [int(eval(input())) for _ in range(n)] for i in a[::-1]: l[bisect_right(l, i)] = i print((bisect_left(l, INF)))
false
0
[ "-from bisect import bisect_right, bisect_left", "+from bisect import bisect_left, bisect_right", "+INF = float(\"inf\")", "+l = [INF] * n", "-INF = float(\"INF\")", "-l = [INF] * n" ]
false
0.039637
0.040846
0.970394
[ "s386828027", "s409409172" ]
u868701750
p03478
python
s952248218
s364422771
41
34
3,060
3,060
Accepted
Accepted
17.07
# -*- coding: utf-8 -*- N, A, B = list(map(int, input().split())) def num_sum(n): p = list(map(int, str(n)[::-1])) _sum = 0 for _i in range(len(p)): _sum += p[_i] return _sum ans = 0 for i in range(N+1): if A <= num_sum(i) <= B: ans += i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(N+1): if A <= sum(list(map(int, str(i)[::]))) <= B: ans += i print(ans)
18
8
307
158
# -*- coding: utf-8 -*- N, A, B = list(map(int, input().split())) def num_sum(n): p = list(map(int, str(n)[::-1])) _sum = 0 for _i in range(len(p)): _sum += p[_i] return _sum ans = 0 for i in range(N + 1): if A <= num_sum(i) <= B: ans += i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(N + 1): if A <= sum(list(map(int, str(i)[::]))) <= B: ans += i print(ans)
false
55.555556
[ "-# -*- coding: utf-8 -*-", "-", "-", "-def num_sum(n):", "- p = list(map(int, str(n)[::-1]))", "- _sum = 0", "- for _i in range(len(p)):", "- _sum += p[_i]", "- return _sum", "-", "-", "- if A <= num_sum(i) <= B:", "+ if A <= sum(list(map(int, str(i)[::]))) <= B:" ]
false
0.162196
0.043012
3.770981
[ "s952248218", "s364422771" ]
u721316601
p03044
python
s488571183
s570708973
863
509
56,716
43,668
Accepted
Accepted
41.02
import heapq N = int(eval(input())) graph = {i:[] for i in range(1, N+1)} route = [10**20 for i in range(N+1)] visited = [False for i in range(N+1)] for i in range(N-1): u, v, w = list(map(int, input().split())) graph[u].append((v, w)) graph[v].append((u, w)) for key, value in list(graph.item...
import sys from heapq import heappush, heappop, heapify input = sys.stdin.readline def main(): INF = float('inf') N = int(eval(input())) dist = [INF] * N visited = [False] * N E = [[] for i in range(N)] V = None for i in range(N-1): u, v, w = list(map(int, ...
37
44
892
903
import heapq N = int(eval(input())) graph = {i: [] for i in range(1, N + 1)} route = [10**20 for i in range(N + 1)] visited = [False for i in range(N + 1)] for i in range(N - 1): u, v, w = list(map(int, input().split())) graph[u].append((v, w)) graph[v].append((u, w)) for key, value in list(graph.items()):...
import sys from heapq import heappush, heappop, heapify input = sys.stdin.readline def main(): INF = float("inf") N = int(eval(input())) dist = [INF] * N visited = [False] * N E = [[] for i in range(N)] V = None for i in range(N - 1): u, v, w = list(map(int, input().split())) ...
false
15.909091
[ "-import heapq", "+import sys", "+from heapq import heappush, heappop, heapify", "-N = int(eval(input()))", "-graph = {i: [] for i in range(1, N + 1)}", "-route = [10**20 for i in range(N + 1)]", "-visited = [False for i in range(N + 1)]", "-for i in range(N - 1):", "- u, v, w = list(map(int, inp...
false
0.03685
0.038078
0.967759
[ "s488571183", "s570708973" ]
u881590806
p02275
python
s268911390
s627807880
1,530
1,340
241,092
202,652
Accepted
Accepted
12.42
def counting_sort(a,k): C = [] for i in range(k): C.append(0) for ai in a: C[ai] += 1 s = 0 for i in range(k): s += C[i] C[i] = s b = [] for i in range(len(a)): b.append(None) p = 0 for i in range(k): while p < C[i]: ...
def sort(a, k): c = [0]*k for x in a: c[x] += 1 b = [] for i in range(len(c)): y = c[i] for _ in range(y): b.append(i) return b n = int(input()) a = list(map(int, input().split(' '))) b = sort(a, 10001) print(' '.join(map(str, b)))
24
16
483
305
def counting_sort(a, k): C = [] for i in range(k): C.append(0) for ai in a: C[ai] += 1 s = 0 for i in range(k): s += C[i] C[i] = s b = [] for i in range(len(a)): b.append(None) p = 0 for i in range(k): while p < C[i]: b[p] =...
def sort(a, k): c = [0] * k for x in a: c[x] += 1 b = [] for i in range(len(c)): y = c[i] for _ in range(y): b.append(i) return b n = int(input()) a = list(map(int, input().split(" "))) b = sort(a, 10001) print(" ".join(map(str, b)))
false
33.333333
[ "-def counting_sort(a, k):", "- C = []", "- for i in range(k):", "- C.append(0)", "- for ai in a:", "- C[ai] += 1", "- s = 0", "- for i in range(k):", "- s += C[i]", "- C[i] = s", "+def sort(a, k):", "+ c = [0] * k", "+ for x in a:", "+ ...
false
0.082514
0.041561
1.985358
[ "s268911390", "s627807880" ]
u600402037
p02659
python
s076494152
s471700328
25
22
10,068
9,152
Accepted
Accepted
12
# coding: utf-8 import sys import decimal sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) A, B = sr().split() A = int(A) B = decimal.Decimal(B) * 100 answer = A*B // 100 print(answer)
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) A, B = sr().split() A = int(A) B = int(float(B)*100 + 0.5) answer = A*B // 100 print(answer)
13
12
258
241
# coding: utf-8 import sys import decimal sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) A, B = sr().split() A = int(A) B = decimal.Decimal(B) * 100 answer = A * B // 100 print(answer)
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) A, B = sr().split() A = int(A) B = int(float(B) * 100 + 0.5) answer = A * B // 100 print(answer)
false
7.692308
[ "-import decimal", "-B = decimal.Decimal(B) * 100", "+B = int(float(B) * 100 + 0.5)" ]
false
0.114463
0.107299
1.06677
[ "s076494152", "s471700328" ]
u691018832
p02844
python
s252822546
s028403861
503
20
41,180
3,060
Accepted
Accepted
96.02
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) s = read().rstrip().decode() cnt = 0 for i in range(1000): num = '' if i < 100: num += '0' if i < 10: ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) s = read().rstrip().decode() cnt = 0 for i in range(1000): num = str(i).zfill(3) idx = -1 for m in num: idx = s.find(m,...
24
19
526
413
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n = int(readline()) s = read().rstrip().decode() cnt = 0 for i in range(1000): num = "" if i < 100: num += "0" if i < 10: num += "0" n...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n = int(readline()) s = read().rstrip().decode() cnt = 0 for i in range(1000): num = str(i).zfill(3) idx = -1 for m in num: idx = s.find(m, idx + 1) ...
false
20.833333
[ "- num = \"\"", "- if i < 100:", "- num += \"0\"", "- if i < 10:", "- num += \"0\"", "- num += str(i)", "- index = 0", "- for ss in s:", "- if ss == num[index]:", "- index += 1", "- if index == 3:", "- cnt += 1...
false
0.12013
0.033169
3.621794
[ "s252822546", "s028403861" ]
u488127128
p03352
python
s862734040
s839438508
29
17
3,060
2,940
Accepted
Accepted
41.38
def solve(): x = int(eval(input())) if x < 4: return 1 elif x < 8: return 4 elif x < 9: return 8 l = [i**j for i in range(1,x+1) for j in range(2,int(x**0.5)) if i**j<=x] return max(l) if __name__ == '__main__': print((solve()))
x = int(eval(input())) l = [i**j for i in range(1,33) for j in range(2,10) if i**j <= x] print((max(l)))
13
3
293
98
def solve(): x = int(eval(input())) if x < 4: return 1 elif x < 8: return 4 elif x < 9: return 8 l = [ i**j for i in range(1, x + 1) for j in range(2, int(x**0.5)) if i ** j <= x ] return max(l) if __name__ == "__main__": print((solve()))
x = int(eval(input())) l = [i**j for i in range(1, 33) for j in range(2, 10) if i ** j <= x] print((max(l)))
false
76.923077
[ "-def solve():", "- x = int(eval(input()))", "- if x < 4:", "- return 1", "- elif x < 8:", "- return 4", "- elif x < 9:", "- return 8", "- l = [", "- i**j for i in range(1, x + 1) for j in range(2, int(x**0.5)) if i ** j <= x", "- ]", "- return ...
false
0.051869
0.037189
1.394737
[ "s862734040", "s839438508" ]
u150984829
p00448
python
s324709723
s990657675
10,570
5,240
6,972
6,904
Accepted
Accepted
50.43
import sys e = sys.stdin.readlines() while 1: r=int(e[0].split()[0]) if r<1:break d=[int(''.join(x),2)for x in zip(*[x.split() for x in e[1:r+1]])] a=[] for i in range(1<<r): b=0 for j in d: c=bin(i^j).count('1') b+=c if c>r//2 else r-c a+=[b] print((max(a))) del e[:r+1]
for e in iter(input,'0 0'): r=int(e.split()[0]) d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])] a=0 b=1<<r f=[1]*b for m in range(b): if f[m]: f[~m]=0 t=0 for s in d: c=bin(m^s).count('1') t+=c if c>r//2 else r-c if a<t:a=t print(a)
15
15
306
295
import sys e = sys.stdin.readlines() while 1: r = int(e[0].split()[0]) if r < 1: break d = [int("".join(x), 2) for x in zip(*[x.split() for x in e[1 : r + 1]])] a = [] for i in range(1 << r): b = 0 for j in d: c = bin(i ^ j).count("1") b += c if c > r...
for e in iter(input, "0 0"): r = int(e.split()[0]) d = [int("".join(x), 2) for x in zip(*[input().split() for _ in [0] * r])] a = 0 b = 1 << r f = [1] * b for m in range(b): if f[m]: f[~m] = 0 t = 0 for s in d: c = bin(m ^ s).count("1")...
false
0
[ "-import sys", "-", "-e = sys.stdin.readlines()", "-while 1:", "- r = int(e[0].split()[0])", "- if r < 1:", "- break", "- d = [int(\"\".join(x), 2) for x in zip(*[x.split() for x in e[1 : r + 1]])]", "- a = []", "- for i in range(1 << r):", "- b = 0", "- for...
false
0.085943
0.046019
1.867541
[ "s324709723", "s990657675" ]
u257162238
p02838
python
s826174989
s460239160
1,878
335
42,156
48,808
Accepted
Accepted
82.16
def read(): N = int(input().strip()) A = list(map(int, input().strip().split())) return N, A def solve(N, A, L=60, MOD=10**9+7): modsum = 0 for j in range(L): count_ones = sum([1 for a in A if (a >> j) & 1]) # count_ones = sum([(A[i] >> j) & 1 for i in range(N)]) ...
import numpy as np def read(): N = int(input().strip()) A = list(map(int, input().strip().split())) return N, A def solve(N, A, L=60, MOD=10**9+7): A = np.array(A, dtype=np.int64) modsum = 0 for j in range(L): B = (A >> j) & 1 count_ones = np.count_nonzero(B) ...
21
25
554
560
def read(): N = int(input().strip()) A = list(map(int, input().strip().split())) return N, A def solve(N, A, L=60, MOD=10**9 + 7): modsum = 0 for j in range(L): count_ones = sum([1 for a in A if (a >> j) & 1]) # count_ones = sum([(A[i] >> j) & 1 for i in range(N)]) count_ze...
import numpy as np def read(): N = int(input().strip()) A = list(map(int, input().strip().split())) return N, A def solve(N, A, L=60, MOD=10**9 + 7): A = np.array(A, dtype=np.int64) modsum = 0 for j in range(L): B = (A >> j) & 1 count_ones = np.count_nonzero(B) count_...
false
16
[ "+import numpy as np", "+", "+", "+ A = np.array(A, dtype=np.int64)", "- count_ones = sum([1 for a in A if (a >> j) & 1])", "- # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])", "+ B = (A >> j) & 1", "+ count_ones = np.count_nonzero(B)" ]
false
0.036994
0.300113
0.123267
[ "s826174989", "s460239160" ]
u596536048
p03351
python
s737972591
s714676375
27
23
9,120
9,100
Accepted
Accepted
14.81
a, b, c, d = list(map(int, input().split())) print(('Yes' if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d else 'No'))
a, b, c, d = list(map(int, input().split())) if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d: print('Yes') else: print('No')
2
5
120
134
a, b, c, d = list(map(int, input().split())) print(("Yes" if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d else "No"))
a, b, c, d = list(map(int, input().split())) if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d: print("Yes") else: print("No")
false
60
[ "-print((\"Yes\" if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d else \"No\"))", "+if abs(c - a) <= d or abs(b - a) <= d and abs(c - b) <= d:", "+ print(\"Yes\")", "+else:", "+ print(\"No\")" ]
false
0.038744
0.036317
1.066836
[ "s737972591", "s714676375" ]
u379716238
p03805
python
s734935520
s766088279
31
28
3,064
3,064
Accepted
Accepted
9.68
import itertools N, M = list(map(int, input().split())) adj_matrix = [[0]*N for _ in range(N)] # 隣接行列を作る for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a-1][b-1] = 1 adj_matrix[b-1][a-1] = 1 cnt = 0 for each in itertools.permutations(list(range(N))): if each[0] !=...
N, M = list(map(int, input().split())) adj_matrix = [[0]*N for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a-1][b-1] = 1 adj_matrix[b-1][a-1] = 1 def dfs(v, used): if not False in used: return 1 ans = 0 for i in range(N): i...
22
26
463
557
import itertools N, M = list(map(int, input().split())) adj_matrix = [[0] * N for _ in range(N)] # 隣接行列を作る for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a - 1][b - 1] = 1 adj_matrix[b - 1][a - 1] = 1 cnt = 0 for each in itertools.permutations(list(range(N))): if each[0] != 0: # ...
N, M = list(map(int, input().split())) adj_matrix = [[0] * N for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) adj_matrix[a - 1][b - 1] = 1 adj_matrix[b - 1][a - 1] = 1 def dfs(v, used): if not False in used: return 1 ans = 0 for i in range(N): if not...
false
15.384615
[ "-import itertools", "-", "-# 隣接行列を作る", "-cnt = 0", "-for each in itertools.permutations(list(range(N))):", "- if each[0] != 0: # 始点は1でないといけないから", "- break", "- factor = 1", "- for i in range(N - 1):", "- factor *= adj_matrix[each[i]][each[i + 1]]", "- cnt += factor", ...
false
0.124487
0.036944
3.369622
[ "s734935520", "s766088279" ]
u509278866
p02346
python
s325215497
s256262566
1,650
750
41,568
39,128
Accepted
Accepted
54.55
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] ...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] ...
87
55
2,257
1,369
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin....
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin....
false
36.781609
[ "-class Seg:", "- def __init__(self, na, default, func):", "- if isinstance(na, list):", "- n = len(na)", "- else:", "- n = na", "+class BIT:", "+ def __init__(self, n):", "- self.D = default", "- if isinstance(na, list):", "- se...
false
0.038018
0.036775
1.033789
[ "s325215497", "s256262566" ]
u480138356
p03137
python
s660580305
s120127504
113
103
13,968
13,960
Accepted
Accepted
8.85
N, M = input().split() N = int(N) M = int(M) X = list(map(int, input().split(" "))) X = sorted(X) L = [] for i in range(1,M): L.append(X[i]-X[i-1]) L = sorted(L) if N >= M: print((0)) elif N == 1: print((sum(L))) else: print((sum(L[:-N+1])))
def main(): N, M = list(map(int, input().split())) x = sorted(list(map(int, input().split()))) sa = [] for i in range(M-1): sa.append(x[i+1] - x[i]) sa = sorted(sa, reverse=True) # print(sa) if N >= M: print((0)) else: print((sum(sa[N-1:]))) if _...
17
17
269
344
N, M = input().split() N = int(N) M = int(M) X = list(map(int, input().split(" "))) X = sorted(X) L = [] for i in range(1, M): L.append(X[i] - X[i - 1]) L = sorted(L) if N >= M: print((0)) elif N == 1: print((sum(L))) else: print((sum(L[: -N + 1])))
def main(): N, M = list(map(int, input().split())) x = sorted(list(map(int, input().split()))) sa = [] for i in range(M - 1): sa.append(x[i + 1] - x[i]) sa = sorted(sa, reverse=True) # print(sa) if N >= M: print((0)) else: print((sum(sa[N - 1 :]))) if __name__ =...
false
0
[ "-N, M = input().split()", "-N = int(N)", "-M = int(M)", "-X = list(map(int, input().split(\" \")))", "-X = sorted(X)", "-L = []", "-for i in range(1, M):", "- L.append(X[i] - X[i - 1])", "-L = sorted(L)", "-if N >= M:", "- print((0))", "-elif N == 1:", "- print((sum(L)))", "-else...
false
0.04677
0.046201
1.01231
[ "s660580305", "s120127504" ]
u483945851
p03408
python
s624227332
s772750510
20
17
3,064
3,060
Accepted
Accepted
15
N=int(eval(input())) list_s=[str(eval(input())) for s in range(N)] M=int(eval(input())) list_t=[str(eval(input())) for t in range(M)] X=0 C=0 for i in range(N): A=list_s.count(list_s[i]) B=list_t.count(list_s[i]) if (A-B)>X: X=A-B for i in range(M): A=list_s.count(list_t[i]) B=list_t.count(li...
N=int(eval(input())) wordcount={} for i in range(N): s=str(eval(input())) wordcount[s]=wordcount.get(s,0)+1 M=int(eval(input())) for i in range(M): s=str(eval(input())) wordcount[s]=wordcount.get(s,0)-1 counter=list(wordcount.values()) f=max(counter) if f>=0: print(f) else: print((0))
19
16
346
282
N = int(eval(input())) list_s = [str(eval(input())) for s in range(N)] M = int(eval(input())) list_t = [str(eval(input())) for t in range(M)] X = 0 C = 0 for i in range(N): A = list_s.count(list_s[i]) B = list_t.count(list_s[i]) if (A - B) > X: X = A - B for i in range(M): A = list_s.count(list_...
N = int(eval(input())) wordcount = {} for i in range(N): s = str(eval(input())) wordcount[s] = wordcount.get(s, 0) + 1 M = int(eval(input())) for i in range(M): s = str(eval(input())) wordcount[s] = wordcount.get(s, 0) - 1 counter = list(wordcount.values()) f = max(counter) if f >= 0: print(f) else:...
false
15.789474
[ "-list_s = [str(eval(input())) for s in range(N)]", "+wordcount = {}", "+for i in range(N):", "+ s = str(eval(input()))", "+ wordcount[s] = wordcount.get(s, 0) + 1", "-list_t = [str(eval(input())) for t in range(M)]", "-X = 0", "-C = 0", "-for i in range(N):", "- A = list_s.count(list_s[i...
false
0.041932
0.043815
0.957006
[ "s624227332", "s772750510" ]
u112629957
p02642
python
s773830699
s606960118
434
150
94,136
92,848
Accepted
Accepted
65.44
N=int(eval(input())) ls=list(map(int,input().split())) ls.sort() #定数倍のやつに+1する M=max(ls) A=[0]*(M+1) for i in range(N): a=M//ls[i] for j in range(1,a+1): A[j*ls[i]]+=1 ans=0 for i in range(len(ls)): if A[ls[i]]==1: ans+=1 print(ans)
N=int(eval(input())) ls=list(map(int,input().split())) ls.sort() #定数倍のやつに+1する M=max(ls) A=[0]*(M+1) for i in range(N): a=M//ls[i] for j in range(1,a+1): if A[ls[i]]>=2: break else: A[j*ls[i]]+=1 continue ans=0 for i in range(len(ls)): if A[ls[i]]==1: ans+=1 pri...
17
20
266
321
N = int(eval(input())) ls = list(map(int, input().split())) ls.sort() # 定数倍のやつに+1する M = max(ls) A = [0] * (M + 1) for i in range(N): a = M // ls[i] for j in range(1, a + 1): A[j * ls[i]] += 1 ans = 0 for i in range(len(ls)): if A[ls[i]] == 1: ans += 1 print(ans)
N = int(eval(input())) ls = list(map(int, input().split())) ls.sort() # 定数倍のやつに+1する M = max(ls) A = [0] * (M + 1) for i in range(N): a = M // ls[i] for j in range(1, a + 1): if A[ls[i]] >= 2: break else: A[j * ls[i]] += 1 continue ans = 0 for i in range(len(ls)): ...
false
15
[ "- A[j * ls[i]] += 1", "+ if A[ls[i]] >= 2:", "+ break", "+ else:", "+ A[j * ls[i]] += 1", "+ continue" ]
false
0.08591
0.105811
0.811924
[ "s773830699", "s606960118" ]
u353797797
p02604
python
s687190514
s128778766
2,388
1,371
88,304
77,072
Accepted
Accepted
42.59
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in ...
import sys int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): r...
48
51
1,401
1,376
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
import sys int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_numb...
false
5.882353
[ "-sys.setrecursionlimit(10**6)", "-def solve():", "- xc = [[0] * n for _ in range(1 << n)]", "- yc = [[0] * n for _ in range(1 << n)]", "- for s in range(1 << n):", "- xcs = xc[s]", "- ycs = yc[s]", "- for i, (x, y, p) in enumerate(xyp):", "- xcost = abs(x)",...
false
0.07117
0.123455
0.576486
[ "s687190514", "s128778766" ]
u377989038
p03244
python
s998464444
s959221405
105
84
20,700
20,700
Accepted
Accepted
20
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1 = sorted(list(Counter(v[::2]).items()), key=lambda x: x[1], reverse=True) v2 = sorted(list(Counter(v[1::2]).items()), key=lambda x: x[1], reverse=True) v1.append((0, 0)) v2.append((0, 0)) if v1[0][0] != v2[0][0]: ...
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1 = Counter(v[::2]).most_common() v2 = Counter(v[1::2]).most_common() v1.append((0, 0)) v2.append((0, 0)) if v1[0][0] != v2[0][0]: print((n - v1[0][1] - v2[0][1])) else: print((min(n - v1[0][1] - v2[1][1], n ...
12
12
406
334
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1 = sorted(list(Counter(v[::2]).items()), key=lambda x: x[1], reverse=True) v2 = sorted(list(Counter(v[1::2]).items()), key=lambda x: x[1], reverse=True) v1.append((0, 0)) v2.append((0, 0)) if v1[0][0] != v2[0][0]: print((n...
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1 = Counter(v[::2]).most_common() v2 = Counter(v[1::2]).most_common() v1.append((0, 0)) v2.append((0, 0)) if v1[0][0] != v2[0][0]: print((n - v1[0][1] - v2[0][1])) else: print((min(n - v1[0][1] - v2[1][1], n - v1[1][1] ...
false
0
[ "-v1 = sorted(list(Counter(v[::2]).items()), key=lambda x: x[1], reverse=True)", "-v2 = sorted(list(Counter(v[1::2]).items()), key=lambda x: x[1], reverse=True)", "+v1 = Counter(v[::2]).most_common()", "+v2 = Counter(v[1::2]).most_common()" ]
false
0.036794
0.037943
0.969734
[ "s998464444", "s959221405" ]
u498487134
p02955
python
s741116218
s271877439
240
115
41,708
74,256
Accepted
Accepted
52.08
#ある数gを用意して,最も近いgの倍数にするための手数を数える,プラマイの総和が0にならない限り,最も変更に要する手数が大きいところは逆転させる? #gはAの総和の約数 N,K=list(map(int,input().split())) A=list(map(int,input().split())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): #約数列挙 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i ==...
41
57
732
1,173
# ある数gを用意して,最も近いgの倍数にするための手数を数える,プラマイの総和が0にならない限り,最も変更に要する手数が大きいところは逆転させる? # gはAの総和の約数 N, K = list(map(int, input().split())) A = list(map(int, input().split())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): # 約数列挙 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): i...
false
28.070175
[ "-# ある数gを用意して,最も近いgの倍数にするための手数を数える,プラマイの総和が0にならない限り,最も変更に要する手数が大きいところは逆転させる?", "-# gはAの総和の約数", "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "+import sys", "+", "+input = sys.stdin.readline", "-def make_divisors(n):", "- divisors = []", "- for i in range(...
false
0.040273
0.161416
0.2495
[ "s741116218", "s271877439" ]
u424467986
p02578
python
s349130999
s582332965
161
145
32,040
32,368
Accepted
Accepted
9.94
N = int(eval(input())) A = list(map(int, input().split(' '))) ans = 0 for i in range(1,N): if A[i-1] > A[i]: ans += A[i-1] - A[i] A[i] += A[i-1] - A[i] print(ans)
N = int(eval(input())) A = list(map(int, input().split(' '))) ans = 0 gap = 0 for i in range(1,N): if ( A[i-1] + gap ) > A[i]: gap = ( A[i-1] + gap ) - A[i] else: gap = 0 ans += gap print(ans)
9
12
179
216
N = int(eval(input())) A = list(map(int, input().split(" "))) ans = 0 for i in range(1, N): if A[i - 1] > A[i]: ans += A[i - 1] - A[i] A[i] += A[i - 1] - A[i] print(ans)
N = int(eval(input())) A = list(map(int, input().split(" "))) ans = 0 gap = 0 for i in range(1, N): if (A[i - 1] + gap) > A[i]: gap = (A[i - 1] + gap) - A[i] else: gap = 0 ans += gap print(ans)
false
25
[ "+gap = 0", "- if A[i - 1] > A[i]:", "- ans += A[i - 1] - A[i]", "- A[i] += A[i - 1] - A[i]", "+ if (A[i - 1] + gap) > A[i]:", "+ gap = (A[i - 1] + gap) - A[i]", "+ else:", "+ gap = 0", "+ ans += gap" ]
false
0.036538
0.037327
0.978856
[ "s349130999", "s582332965" ]
u909601929
p03317
python
s467045505
s280373717
97
18
19,936
3,060
Accepted
Accepted
81.44
from collections import Counter from math import * N, K = [int(x) for x in input().strip().split()] A = [int(x) for x in input().strip().split()] A.sort() c = Counter(A) minc = c[A[0]] res = len(A) - minc print((ceil(res/(K-1))))
from math import * N, K = [int(x) for x in input().strip().split()] print((ceil((N-1)/(K-1))))
9
3
235
94
from collections import Counter from math import * N, K = [int(x) for x in input().strip().split()] A = [int(x) for x in input().strip().split()] A.sort() c = Counter(A) minc = c[A[0]] res = len(A) - minc print((ceil(res / (K - 1))))
from math import * N, K = [int(x) for x in input().strip().split()] print((ceil((N - 1) / (K - 1))))
false
66.666667
[ "-from collections import Counter", "-A = [int(x) for x in input().strip().split()]", "-A.sort()", "-c = Counter(A)", "-minc = c[A[0]]", "-res = len(A) - minc", "-print((ceil(res / (K - 1))))", "+print((ceil((N - 1) / (K - 1))))" ]
false
0.046219
0.047176
0.979723
[ "s467045505", "s280373717" ]
u094158322
p02713
python
s777602447
s800211009
1,345
419
82,020
78,308
Accepted
Accepted
68.85
n = int(eval(input())) def gcd(a,b): ma = max(a,b) mb = min(a,b) jy = ma % mb if jy == 0 : return mb else: return gcd(mb,jy) sum = 0 for i in range(n): for j in range(n): for k in range(n): sum += gcd(i+1,gcd(j+1,k+1)) print(sum)
n = int(eval(input())) def gcd(a,b): ma = max(a,b) mb = min(a,b) jy = ma % mb if jy == 0 : return mb else: return gcd(mb,jy) sum = 0 for i in range(1,n+1): sum += i for i in range(1,n): for j in range(i+1,n+1): sum += 6 * gcd(i,j) for i in range(1,n-1): for j in range(...
17
24
271
401
n = int(eval(input())) def gcd(a, b): ma = max(a, b) mb = min(a, b) jy = ma % mb if jy == 0: return mb else: return gcd(mb, jy) sum = 0 for i in range(n): for j in range(n): for k in range(n): sum += gcd(i + 1, gcd(j + 1, k + 1)) print(sum)
n = int(eval(input())) def gcd(a, b): ma = max(a, b) mb = min(a, b) jy = ma % mb if jy == 0: return mb else: return gcd(mb, jy) sum = 0 for i in range(1, n + 1): sum += i for i in range(1, n): for j in range(i + 1, n + 1): sum += 6 * gcd(i, j) for i in range(1, n ...
false
29.166667
[ "-for i in range(n):", "- for j in range(n):", "- for k in range(n):", "- sum += gcd(i + 1, gcd(j + 1, k + 1))", "+for i in range(1, n + 1):", "+ sum += i", "+for i in range(1, n):", "+ for j in range(i + 1, n + 1):", "+ sum += 6 * gcd(i, j)", "+for i in range(1, ...
false
0.045369
0.040583
1.117948
[ "s777602447", "s800211009" ]
u796942881
p03262
python
s307579296
s016974196
81
74
14,548
14,680
Accepted
Accepted
8.64
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, X, *x = list(map(int, open(0).read().split())) x = [abs(X - int(i)) for i in x] print((gcd_n(x))) return main()
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, X = list(map(int, input().split())) x = [abs(X - int(i)) for i in input().split()] print((gcd_n(x))) return main()
21
21
309
312
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, X, *x = list(map(int, open(0).read().split())) x = [abs(X - int(i)) for i in x] print((gcd_n(x))) return main()
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, X = list(map(int, input().split())) x = [abs(X - int(i)) for i in input().split()] print((gcd_n(x))) return main()
false
0
[ "- N, X, *x = list(map(int, open(0).read().split()))", "- x = [abs(X - int(i)) for i in x]", "+ N, X = list(map(int, input().split()))", "+ x = [abs(X - int(i)) for i in input().split()]" ]
false
0.046463
0.039373
1.180091
[ "s307579296", "s016974196" ]
u186838327
p04005
python
s584646678
s851720311
173
63
38,384
61,956
Accepted
Accepted
63.58
a, b, c = list(map(int, input().split())) l = [a, b, c] l.sort() if l[-1]%2 == 0: print((0)) else: print((l[0]*l[1]))
a, b, c = list(map(int, input().split())) L1 = a*b*(c//2)-a*b*(c-c//2) L2 = a*(b//2)*c-a*(b-b//2)*c L3 = (a//2)*b*c-(a-a//2)*b*c L = [abs(L1), abs(L2), abs(L3)] print((min(L)))
7
7
117
176
a, b, c = list(map(int, input().split())) l = [a, b, c] l.sort() if l[-1] % 2 == 0: print((0)) else: print((l[0] * l[1]))
a, b, c = list(map(int, input().split())) L1 = a * b * (c // 2) - a * b * (c - c // 2) L2 = a * (b // 2) * c - a * (b - b // 2) * c L3 = (a // 2) * b * c - (a - a // 2) * b * c L = [abs(L1), abs(L2), abs(L3)] print((min(L)))
false
0
[ "-l = [a, b, c]", "-l.sort()", "-if l[-1] % 2 == 0:", "- print((0))", "-else:", "- print((l[0] * l[1]))", "+L1 = a * b * (c // 2) - a * b * (c - c // 2)", "+L2 = a * (b // 2) * c - a * (b - b // 2) * c", "+L3 = (a // 2) * b * c - (a - a // 2) * b * c", "+L = [abs(L1), abs(L2), abs(L3)]", "...
false
0.033439
0.035701
0.93664
[ "s584646678", "s851720311" ]
u305366205
p02996
python
s514355652
s581390718
928
759
29,460
33,388
Accepted
Accepted
18.21
N = int(eval(input())) job = [] sum = 0 result = "Yes" for _ in range(N): cost, limit = list(map(int, input().split())) job.append((limit,cost)) job.sort() for i,j in job: sum += j if i < sum: result = "No" break print(result)
from operator import itemgetter n = int(eval(input())) jobs = [tuple(map(int, input().split())) for _ in range(n)] jobs = sorted(jobs, key=itemgetter(1)) total = 0 for a, b in jobs: total += a if total > b: print('No') exit() print('Yes')
16
11
264
267
N = int(eval(input())) job = [] sum = 0 result = "Yes" for _ in range(N): cost, limit = list(map(int, input().split())) job.append((limit, cost)) job.sort() for i, j in job: sum += j if i < sum: result = "No" break print(result)
from operator import itemgetter n = int(eval(input())) jobs = [tuple(map(int, input().split())) for _ in range(n)] jobs = sorted(jobs, key=itemgetter(1)) total = 0 for a, b in jobs: total += a if total > b: print("No") exit() print("Yes")
false
31.25
[ "-N = int(eval(input()))", "-job = []", "-sum = 0", "-result = \"Yes\"", "-for _ in range(N):", "- cost, limit = list(map(int, input().split()))", "- job.append((limit, cost))", "-job.sort()", "-for i, j in job:", "- sum += j", "- if i < sum:", "- result = \"No\"", "- ...
false
0.043064
0.113518
0.379359
[ "s514355652", "s581390718" ]
u116038906
p02658
python
s339528525
s476005206
140
82
40,372
21,604
Accepted
Accepted
41.43
# 初期入力 import numpy as np import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A_np =np.array(A,dtype=np.int64) ans =np.prod(A_np) #累積積 if 0 in A: print((0)) elif 0 < ans <=10**18: print(ans) else: print((-1))
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) # ans =1 if 0 in A: ans =0 else: for i in A: ans *=i if ans >10**18: ans =-1 break print(ans)
14
14
268
228
# 初期入力 import numpy as np import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A_np = np.array(A, dtype=np.int64) ans = np.prod(A_np) # 累積積 if 0 in A: print((0)) elif 0 < ans <= 10**18: print(ans) else: print((-1))
N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) # ans = 1 if 0 in A: ans = 0 else: for i in A: ans *= i if ans > 10**18: ans = -1 break print(ans)
false
0
[ "-# 初期入力", "-import numpy as np", "-import sys", "-", "-input = sys.stdin.readline", "-A_np = np.array(A, dtype=np.int64)", "-ans = np.prod(A_np) # 累積積", "+A.sort(reverse=True)", "+#", "+ans = 1", "- print((0))", "-elif 0 < ans <= 10**18:", "- print(ans)", "+ ans = 0", "- pr...
false
0.260635
0.099334
2.623828
[ "s339528525", "s476005206" ]
u968166680
p03732
python
s579855640
s057473713
194
91
9,160
9,168
Accepted
Accepted
53.09
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, W, *WV = list(map(int, read().split())) weight = WV[::2] value = WV[1::2] w_min...
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, W, *WV = list(map(int, read().split())) weight = WV[::2] value = WV[1::2] w_min...
47
50
1,000
1,080
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, W, *WV = list(map(int, read().split())) weight = WV[::2] value = WV[1::2] w_min = min(weight) ...
import sys from itertools import accumulate read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, W, *WV = list(map(int, read().split())) weight = WV[::2] value = WV[1::2] w_min = min(weight) ...
false
6
[ "- ans = max(ans, rec(i + 1, w + (w_min + i) * j, v + csums[i][j]))", "+ w_next = w + (w_min + i) * j", "+ if w_next > W:", "+ break", "+ ans = max(ans, rec(i + 1, w_next, v + csums[i][j]))" ]
false
0.040356
0.049024
0.823176
[ "s579855640", "s057473713" ]
u855831834
p03951
python
s357518651
s672134808
31
25
9,020
9,124
Accepted
Accepted
19.35
N = int(eval(input())) s = eval(input()) t = eval(input()) ans = len(s) + len(t) for i in range(len(s)): if t[:i+1] in s: ans = min(ans, len(s) + len(t) - (i+1)) print(ans)
N = int(eval(input())) s = eval(input()) t = eval(input()) ans = 2*N for i in range(N): if s[N-(i+1):] == t[:i+1]: ans = 2*N - (i+1) print(ans)
10
10
185
156
N = int(eval(input())) s = eval(input()) t = eval(input()) ans = len(s) + len(t) for i in range(len(s)): if t[: i + 1] in s: ans = min(ans, len(s) + len(t) - (i + 1)) print(ans)
N = int(eval(input())) s = eval(input()) t = eval(input()) ans = 2 * N for i in range(N): if s[N - (i + 1) :] == t[: i + 1]: ans = 2 * N - (i + 1) print(ans)
false
0
[ "-ans = len(s) + len(t)", "-for i in range(len(s)):", "- if t[: i + 1] in s:", "- ans = min(ans, len(s) + len(t) - (i + 1))", "+ans = 2 * N", "+for i in range(N):", "+ if s[N - (i + 1) :] == t[: i + 1]:", "+ ans = 2 * N - (i + 1)" ]
false
0.03967
0.039992
0.991946
[ "s357518651", "s672134808" ]
u311379832
p03363
python
s130169760
s005658937
1,546
315
48,668
48,660
Accepted
Accepted
79.62
from collections import defaultdict import math def combnations(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N = int(eval(input())) a = list(map(int, input().split())) rui = [0] * (N + 1) for i in range(N): rui[i + 1] = rui[i] + a[i] d = defaultdict(int) for key...
from collections import defaultdict N = int(eval(input())) a = list(map(int, input().split())) rui = [0] * (N + 1) for i in range(N): rui[i + 1] = rui[i] + a[i] d = defaultdict(int) for key in rui: d[key] += 1 sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True) cnt = 0 for i, j ...
25
19
521
380
from collections import defaultdict import math def combnations(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N = int(eval(input())) a = list(map(int, input().split())) rui = [0] * (N + 1) for i in range(N): rui[i + 1] = rui[i] + a[i] d = defaultdict(int) for key in rui: ...
from collections import defaultdict N = int(eval(input())) a = list(map(int, input().split())) rui = [0] * (N + 1) for i in range(N): rui[i + 1] = rui[i] + a[i] d = defaultdict(int) for key in rui: d[key] += 1 sortd = sorted(list(d.items()), key=lambda x: x[1], reverse=True) cnt = 0 for i, j in sortd: if j...
false
24
[ "-import math", "-", "-", "-def combnations(n, r):", "- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))", "-", "- cnt += combnations(j, 2)", "- else:", "- break", "+ cnt += j * (j - 1) // 2" ]
false
0.083049
0.037198
2.232609
[ "s130169760", "s005658937" ]
u540290227
p02958
python
s223714417
s370155915
31
27
9,052
9,172
Accepted
Accepted
12.9
n = int(eval(input())) p = list(map(int,input().split())) ans = [i for i in range(1,n+1)] cnt = 0 for i in range(n): if p[i] != ans[i]: cnt += 1 if cnt > 2: print('NO') exit() print('YES')
n = int(eval(input())) p = list(map(int, input().split())) error = 0 for i in range(n): if p[i] != i+1: error += 1 if error > 2: print('NO') exit() print('YES')
13
10
217
196
n = int(eval(input())) p = list(map(int, input().split())) ans = [i for i in range(1, n + 1)] cnt = 0 for i in range(n): if p[i] != ans[i]: cnt += 1 if cnt > 2: print("NO") exit() print("YES")
n = int(eval(input())) p = list(map(int, input().split())) error = 0 for i in range(n): if p[i] != i + 1: error += 1 if error > 2: print("NO") exit() print("YES")
false
23.076923
[ "-ans = [i for i in range(1, n + 1)]", "-cnt = 0", "+error = 0", "- if p[i] != ans[i]:", "- cnt += 1", "- if cnt > 2:", "+ if p[i] != i + 1:", "+ error += 1", "+ if error > 2:" ]
false
0.181917
0.046198
3.937731
[ "s223714417", "s370155915" ]
u835283937
p03048
python
s806589745
s980156393
1,965
1,317
3,060
3,060
Accepted
Accepted
32.98
def main(): R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N//R + 1): for g in range(N//G + 1): res = (N - (R*r + G*g)) if res >= 0 and res % B == 0: ans += 1 print(ans) if __name__ == "__main__": mai...
def main(): R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N//R + 1): for g in range(N//G + 1): res = (N - (R*r + G*g)) if res < 0 : break if res >= 0 and res % B == 0: ans += 1 print(an...
15
19
317
358
def main(): R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N // R + 1): for g in range(N // G + 1): res = N - (R * r + G * g) if res >= 0 and res % B == 0: ans += 1 print(ans) if __name__ == "__main__": main()
def main(): R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N // R + 1): for g in range(N // G + 1): res = N - (R * r + G * g) if res < 0: break if res >= 0 and res % B == 0: ans += 1 print(ans) if __name__...
false
21.052632
[ "+ if res < 0:", "+ break" ]
false
0.087751
0.08058
1.088992
[ "s806589745", "s980156393" ]
u761989513
p03325
python
s531774353
s958001345
113
80
4,148
4,148
Accepted
Accepted
29.2
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while i % 2 == 0: i /= 2 ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print(ans)
8
8
134
145
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while i % 2 == 0: i /= 2 ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print(ans)
false
0
[ "- i /= 2", "+ i //= 2" ]
false
0.006584
0.075394
0.087331
[ "s531774353", "s958001345" ]
u762420987
p03821
python
s895827120
s303884507
450
351
51,188
17,380
Accepted
Accepted
22
N = int(eval(input())) ablist = [] for _ in range(N): ab = list(map(int, input().split())) ablist.append(ab) ans = 0 for a, b in ablist[::-1]: a += ans if a % b == 0: continue else: ans += (b - a % b) print(ans)
N = int(eval(input())) ABlist = [tuple(map(int, input().split())) for _ in range(N)] ans = 0 for a, b in ABlist[::-1]: a += ans if a % b == 0: continue else: ans += (b - a % b) print(ans)
13
10
248
219
N = int(eval(input())) ablist = [] for _ in range(N): ab = list(map(int, input().split())) ablist.append(ab) ans = 0 for a, b in ablist[::-1]: a += ans if a % b == 0: continue else: ans += b - a % b print(ans)
N = int(eval(input())) ABlist = [tuple(map(int, input().split())) for _ in range(N)] ans = 0 for a, b in ABlist[::-1]: a += ans if a % b == 0: continue else: ans += b - a % b print(ans)
false
23.076923
[ "-ablist = []", "-for _ in range(N):", "- ab = list(map(int, input().split()))", "- ablist.append(ab)", "+ABlist = [tuple(map(int, input().split())) for _ in range(N)]", "-for a, b in ablist[::-1]:", "+for a, b in ABlist[::-1]:" ]
false
0.064
0.136512
0.468824
[ "s895827120", "s303884507" ]
u187193817
p02693
python
s273423303
s385945939
24
21
9,176
9,152
Accepted
Accepted
12.5
k = int(eval(input())) a, b = list(map(int, input().split())) judge = 0 for i in range(a, b + 1): if(i % k == 0): print("OK") judge += 1 break if(judge == 0): print("NG")
k = int(eval(input())) a, b = list(map(int, input().split())) if(a % k == 0 or a//k != b//k): print("OK") else: print("NG")
10
6
199
124
k = int(eval(input())) a, b = list(map(int, input().split())) judge = 0 for i in range(a, b + 1): if i % k == 0: print("OK") judge += 1 break if judge == 0: print("NG")
k = int(eval(input())) a, b = list(map(int, input().split())) if a % k == 0 or a // k != b // k: print("OK") else: print("NG")
false
40
[ "-judge = 0", "-for i in range(a, b + 1):", "- if i % k == 0:", "- print(\"OK\")", "- judge += 1", "- break", "-if judge == 0:", "+if a % k == 0 or a // k != b // k:", "+ print(\"OK\")", "+else:" ]
false
0.084507
0.117746
0.717713
[ "s273423303", "s385945939" ]
u514401521
p02690
python
s768676720
s168702013
1,432
306
9,176
9,116
Accepted
Accepted
78.63
X = int(eval(input())) import sys for i in range(-1000, 1000): for j in range(-1000, 1000): a = pow(i, 5) b = pow(j, 5) if a - b == X: print((i, j)) sys.exit(0)
X = int(eval(input())) import sys for i in range(-500,500): for j in range(-500, 500): if i**5 - j**5 == X: print((i, j)) sys.exit(0)
9
7
212
168
X = int(eval(input())) import sys for i in range(-1000, 1000): for j in range(-1000, 1000): a = pow(i, 5) b = pow(j, 5) if a - b == X: print((i, j)) sys.exit(0)
X = int(eval(input())) import sys for i in range(-500, 500): for j in range(-500, 500): if i**5 - j**5 == X: print((i, j)) sys.exit(0)
false
22.222222
[ "-for i in range(-1000, 1000):", "- for j in range(-1000, 1000):", "- a = pow(i, 5)", "- b = pow(j, 5)", "- if a - b == X:", "+for i in range(-500, 500):", "+ for j in range(-500, 500):", "+ if i**5 - j**5 == X:" ]
false
2.429165
0.41365
5.872517
[ "s768676720", "s168702013" ]
u562935282
p02923
python
s704639687
s149491713
94
52
14,252
11,136
Accepted
Accepted
44.68
n = int(eval(input())) h = list(map(int, input().split())) h_max = -1 ind = -1 cnt = -1 ans = -1 for i in range(n - 1, -1, -1): if h[i] >= h_max: ind = i h_max = h[i] cnt += 1 ans = max(ans, cnt) else: h_max = h[i] cnt = 0 print(ans)
def main(): N = int(eval(input())) ans = 0 t = -1 p = 1 << 30 for h in map(int, input().split()): if p >= h: t += 1 if ans < t: ans = t else: t = 0 p = h print(ans) if __name__ == '__main__': m...
17
20
301
320
n = int(eval(input())) h = list(map(int, input().split())) h_max = -1 ind = -1 cnt = -1 ans = -1 for i in range(n - 1, -1, -1): if h[i] >= h_max: ind = i h_max = h[i] cnt += 1 ans = max(ans, cnt) else: h_max = h[i] cnt = 0 print(ans)
def main(): N = int(eval(input())) ans = 0 t = -1 p = 1 << 30 for h in map(int, input().split()): if p >= h: t += 1 if ans < t: ans = t else: t = 0 p = h print(ans) if __name__ == "__main__": main()
false
15
[ "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-h_max = -1", "-ind = -1", "-cnt = -1", "-ans = -1", "-for i in range(n - 1, -1, -1):", "- if h[i] >= h_max:", "- ind = i", "- h_max = h[i]", "- cnt += 1", "- ans = max(ans, cnt)", "- else:"...
false
0.04107
0.041974
0.978474
[ "s704639687", "s149491713" ]
u596276291
p03854
python
s891851504
s953894744
79
42
3,444
4,076
Accepted
Accepted
46.84
from collections import defaultdict def main(): S = eval(input()) while len(S) != 0: change = False for s in ["dream", "dreamer", "erase", "eraser"]: if S.endswith(s): S = S[:-len(s)] change = True break if not cha...
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.se...
20
41
427
1,051
from collections import defaultdict def main(): S = eval(input()) while len(S) != 0: change = False for s in ["dream", "dreamer", "erase", "eraser"]: if S.endswith(s): S = S[: -len(s)] change = True break if not change: ...
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecurs...
false
51.219512
[ "-from collections import defaultdict", "+from collections import defaultdict, Counter", "+from itertools import product, groupby, count, permutations, combinations", "+from math import pi, sqrt", "+from collections import deque", "+from bisect import bisect, bisect_left, bisect_right", "+from string im...
false
0.036085
0.034523
1.045248
[ "s891851504", "s953894744" ]
u762420987
p02881
python
s404673088
s332324597
145
115
3,060
3,268
Accepted
Accepted
20.69
N = int(eval(input())) from math import sqrt ab_add = [] for i in range(1, int(sqrt(N)) + 1): if N % i == 0: ab_add.append(i + (N // i) - 2) print((min(ab_add)))
N = int(eval(input())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append((i + n // i) - 2) if i != n // i: divisors.append((n // i + i) - 2) divisors.sort() return divisors div = make...
7
17
172
344
N = int(eval(input())) from math import sqrt ab_add = [] for i in range(1, int(sqrt(N)) + 1): if N % i == 0: ab_add.append(i + (N // i) - 2) print((min(ab_add)))
N = int(eval(input())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append((i + n // i) - 2) if i != n // i: divisors.append((n // i + i) - 2) divisors.sort() return divisors div = make_divisors(N) pri...
false
58.823529
[ "-from math import sqrt", "-ab_add = []", "-for i in range(1, int(sqrt(N)) + 1):", "- if N % i == 0:", "- ab_add.append(i + (N // i) - 2)", "-print((min(ab_add)))", "+", "+def make_divisors(n):", "+ divisors = []", "+ for i in range(1, int(n**0.5) + 1):", "+ if n % i == 0:...
false
0.110776
0.04465
2.480985
[ "s404673088", "s332324597" ]
u681444474
p03324
python
s082662590
s231096997
19
17
3,060
2,940
Accepted
Accepted
10.53
# coding: utf-8 # Your code here! d,n=list(map(int,input().split())) if n!=100: print((100**d*n)) else: print((100**d*(n+1)))
# coding: utf-8 # Your code here! d,n=list(map(int,input().split())) if n==100: print((100**d*(n+1))) else: print((100**d*n))
7
7
129
129
# coding: utf-8 # Your code here! d, n = list(map(int, input().split())) if n != 100: print((100**d * n)) else: print((100**d * (n + 1)))
# coding: utf-8 # Your code here! d, n = list(map(int, input().split())) if n == 100: print((100**d * (n + 1))) else: print((100**d * n))
false
0
[ "-if n != 100:", "+if n == 100:", "+ print((100**d * (n + 1)))", "+else:", "-else:", "- print((100**d * (n + 1)))" ]
false
0.139274
0.109896
1.267327
[ "s082662590", "s231096997" ]
u989345508
p03252
python
s406296612
s209575876
1,638
168
3,632
23,472
Accepted
Accepted
89.74
s=eval(input()) t=eval(input()) l=len(s) c=[chr(i) for i in range(97,97+26)] for i in range(26): f=0 for j in range(l): if c[i]==s[j]: if f==0: k=t[j] f+=1 elif f==1 and t[j]!=k: f+=1 print("No") ...
d,d_=dict(),dict() s,t=eval(input()),eval(input()) l=len(s) for i in range(l): if s[i] not in d: d[s[i]]=[i] else: d[s[i]].append(i) for i in range(l): if t[i] not in d_: d_[t[i]]=[i] else: d_[t[i]].append(i) x=[sorted(i[1]) for i in list(d.items())] y=[sort...
33
18
730
395
s = eval(input()) t = eval(input()) l = len(s) c = [chr(i) for i in range(97, 97 + 26)] for i in range(26): f = 0 for j in range(l): if c[i] == s[j]: if f == 0: k = t[j] f += 1 elif f == 1 and t[j] != k: f += 1 print...
d, d_ = dict(), dict() s, t = eval(input()), eval(input()) l = len(s) for i in range(l): if s[i] not in d: d[s[i]] = [i] else: d[s[i]].append(i) for i in range(l): if t[i] not in d_: d_[t[i]] = [i] else: d_[t[i]].append(i) x = [sorted(i[1]) for i in list(d.items())] y = [...
false
45.454545
[ "-s = eval(input())", "-t = eval(input())", "+d, d_ = dict(), dict()", "+s, t = eval(input()), eval(input())", "-c = [chr(i) for i in range(97, 97 + 26)]", "-for i in range(26):", "- f = 0", "- for j in range(l):", "- if c[i] == s[j]:", "- if f == 0:", "- k...
false
0.041408
0.042155
0.982287
[ "s406296612", "s209575876" ]
u868701750
p03457
python
s809697231
s991338937
369
209
3,060
27,480
Accepted
Accepted
43.36
# -*- coding: utf-8 -*- t, x, y = 0, 0, 0 N = int(eval(input())) for _ in range(N): t_next, x_next, y_next = list(map(int, input().split())) diff_kyori = abs(x - x_next) + abs(y - y_next) diff_time = t_next - t if diff_kyori > diff_time: # 距離が時間より大きい print('No') exit(0)...
import sys _input = sys.stdin.readline def resolve(): N = int(_input()) T = [list(map(int, _input().split())) for _ in range(N)] t, x, y = 0, 0, 0 for next_t, next_x, next_y in T: diff_xy = abs(x - next_x) + abs(y - next_y) diff_t = next_t - t if diff_xy > diff_t or ...
21
19
457
459
# -*- coding: utf-8 -*- t, x, y = 0, 0, 0 N = int(eval(input())) for _ in range(N): t_next, x_next, y_next = list(map(int, input().split())) diff_kyori = abs(x - x_next) + abs(y - y_next) diff_time = t_next - t if diff_kyori > diff_time: # 距離が時間より大きい print("No") exit(0) if (diff_kyo...
import sys _input = sys.stdin.readline def resolve(): N = int(_input()) T = [list(map(int, _input().split())) for _ in range(N)] t, x, y = 0, 0, 0 for next_t, next_x, next_y in T: diff_xy = abs(x - next_x) + abs(y - next_y) diff_t = next_t - t if diff_xy > diff_t or (diff_xy %...
false
9.52381
[ "-# -*- coding: utf-8 -*-", "-t, x, y = 0, 0, 0", "-N = int(eval(input()))", "-for _ in range(N):", "- t_next, x_next, y_next = list(map(int, input().split()))", "- diff_kyori = abs(x - x_next) + abs(y - y_next)", "- diff_time = t_next - t", "- if diff_kyori > diff_time: # 距離が時間より大きい", ...
false
0.040046
0.047599
0.84133
[ "s809697231", "s991338937" ]
u971091945
p02554
python
s461782208
s078061374
584
29
10,904
9,096
Accepted
Accepted
95.03
n = int(eval(input())) mod = 10**9+7 if n==1: print((0)) else: print((((10**n)-(9**n)-(9**n)+(8**n))%mod))
n = int(eval(input())) mod = 10**9+7 print(((pow(10,n,mod)-pow(9,n,mod)*2+pow(8,n,mod))%mod))
7
3
111
87
n = int(eval(input())) mod = 10**9 + 7 if n == 1: print((0)) else: print((((10**n) - (9**n) - (9**n) + (8**n)) % mod))
n = int(eval(input())) mod = 10**9 + 7 print(((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod))
false
57.142857
[ "-if n == 1:", "- print((0))", "-else:", "- print((((10**n) - (9**n) - (9**n) + (8**n)) % mod))", "+print(((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod))" ]
false
0.208593
0.006247
33.392054
[ "s461782208", "s078061374" ]
u761989513
p03268
python
s517800668
s093365906
108
94
18,932
2,940
Accepted
Accepted
12.96
n, k = list(map(int, input().split())) s = [] for a in range(1, n + 1): if (2 * a) % k == 0: s.append(a) t = [] for a in range(1, n + 1): if a % k == 0: t.append(a) print(((len(s) - len(t)) ** 3 + len(t) ** 3))
n, k = list(map(int, input().split())) x = 0 for a in range(1, n + 1): if (2 * a) % k == 0: x += 1 y = 0 for a in range(1, n + 1): if a % k == 0: y += 1 print(((x - y) ** 3 + y ** 3))
13
13
241
215
n, k = list(map(int, input().split())) s = [] for a in range(1, n + 1): if (2 * a) % k == 0: s.append(a) t = [] for a in range(1, n + 1): if a % k == 0: t.append(a) print(((len(s) - len(t)) ** 3 + len(t) ** 3))
n, k = list(map(int, input().split())) x = 0 for a in range(1, n + 1): if (2 * a) % k == 0: x += 1 y = 0 for a in range(1, n + 1): if a % k == 0: y += 1 print(((x - y) ** 3 + y**3))
false
0
[ "-s = []", "+x = 0", "- s.append(a)", "-t = []", "+ x += 1", "+y = 0", "- t.append(a)", "-print(((len(s) - len(t)) ** 3 + len(t) ** 3))", "+ y += 1", "+print(((x - y) ** 3 + y**3))" ]
false
0.04392
0.047408
0.926425
[ "s517800668", "s093365906" ]
u566529875
p03170
python
s027918612
s878157102
1,052
190
3,828
40,432
Accepted
Accepted
81.94
n,k=list(map(int,input().split())) a=list(map(int,input().split())) ans = [False]*(k+1) for i in range(1,k+1): ok = False for j in a: if i-j<0: continue if ans[i-j] == False: ans[i] = True break print(('First' if ans[k] else 'Second'))
n,k=list(map(int,input().split())) a=list(map(int,input().split())) dp=[0]*(k+1+1234) for i in range(0,k+1): if dp[i] == 0: for x in a: dp[min(i+x,k+1)] =1 print(("First" if dp[k] else "Second"))
13
10
300
222
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ans = [False] * (k + 1) for i in range(1, k + 1): ok = False for j in a: if i - j < 0: continue if ans[i - j] == False: ans[i] = True break print(("First" if ans[k] else "Second"))
n, k = list(map(int, input().split())) a = list(map(int, input().split())) dp = [0] * (k + 1 + 1234) for i in range(0, k + 1): if dp[i] == 0: for x in a: dp[min(i + x, k + 1)] = 1 print(("First" if dp[k] else "Second"))
false
23.076923
[ "-ans = [False] * (k + 1)", "-for i in range(1, k + 1):", "- ok = False", "- for j in a:", "- if i - j < 0:", "- continue", "- if ans[i - j] == False:", "- ans[i] = True", "- break", "-print((\"First\" if ans[k] else \"Second\"))", "+dp = [0] ...
false
0.061313
0.035792
1.713035
[ "s027918612", "s878157102" ]
u863442865
p03162
python
s989503401
s831588210
420
311
47,620
27,492
Accepted
Accepted
25.95
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from bisect import bisect_left...
import sys input = sys.stdin.readline n = int(eval(input())) a = [0]*n b = [0]*n c = [0]*n for i in range(n): a[i],b[i],c[i] = list(map(int,input().split())) dpa = [a[0]]+[0]*(n-1) dpb = [b[0]]+[0]*(n-1) dpc = [c[0]]+[0]*(n-1) for i in range(1,n): dpa[i] = max(dpb[i-1],dpc[i-1]) + a[i] dpb[i]...
28
17
807
421
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations # from itertools import accumulate, product from bisect import bisect_left, b...
import sys input = sys.stdin.readline n = int(eval(input())) a = [0] * n b = [0] * n c = [0] * n for i in range(n): a[i], b[i], c[i] = list(map(int, input().split())) dpa = [a[0]] + [0] * (n - 1) dpb = [b[0]] + [0] * (n - 1) dpc = [c[0]] + [0] * (n - 1) for i in range(1, n): dpa[i] = max(dpb[i - 1], dpc[i - 1]...
false
39.285714
[ "-def main():", "- import sys", "+import sys", "- input = sys.stdin.readline", "- sys.setrecursionlimit(10000000)", "- from collections import Counter, deque", "-", "- # from collections import defaultdict", "- from itertools import combinations, permutations", "-", "- # fro...
false
0.037433
0.036764
1.018186
[ "s989503401", "s831588210" ]
u327532412
p02813
python
s744563490
s406686331
40
29
7,992
8,308
Accepted
Accepted
27.5
import itertools n = int(eval(input())) a = tuple(i for i in range(1, n+1)) x = tuple(map(int, input().split())) y = tuple(map(int, input().split())) for i, z in enumerate(tuple(itertools.permutations(a))): if z == x: x_count = i if z == y: y_count = i print((abs(x_count - y_count)))
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) comb = sorted(list(permutations([i for i in range(1, N+1)], N))) print((abs((comb.index(P) + 1) - (comb.index(Q) + 1))))
12
6
312
249
import itertools n = int(eval(input())) a = tuple(i for i in range(1, n + 1)) x = tuple(map(int, input().split())) y = tuple(map(int, input().split())) for i, z in enumerate(tuple(itertools.permutations(a))): if z == x: x_count = i if z == y: y_count = i print((abs(x_count - y_count)))
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) comb = sorted(list(permutations([i for i in range(1, N + 1)], N))) print((abs((comb.index(P) + 1) - (comb.index(Q) + 1))))
false
50
[ "-import itertools", "+from itertools import permutations", "-n = int(eval(input()))", "-a = tuple(i for i in range(1, n + 1))", "-x = tuple(map(int, input().split()))", "-y = tuple(map(int, input().split()))", "-for i, z in enumerate(tuple(itertools.permutations(a))):", "- if z == x:", "- ...
false
0.037517
0.037971
0.988037
[ "s744563490", "s406686331" ]
u786020649
p03814
python
s021153463
s221520746
68
50
10,764
10,768
Accepted
Accepted
26.47
from collections import deque s=eval(input()) ds=deque(s) flag=True while ds[0]!='A' or ds[-1]!='Z': if ds[0]!='A': ds.popleft() if ds[-1]!='Z': ds.pop() print((len(ds)))
s=eval(input()) ds=list(s) c1=0 while ds[c1]!='A': c1+=1 c2=-1 while ds[c2]!='Z': c2-=1 print((len(s[c1:c2])+1))
12
14
187
131
from collections import deque s = eval(input()) ds = deque(s) flag = True while ds[0] != "A" or ds[-1] != "Z": if ds[0] != "A": ds.popleft() if ds[-1] != "Z": ds.pop() print((len(ds)))
s = eval(input()) ds = list(s) c1 = 0 while ds[c1] != "A": c1 += 1 c2 = -1 while ds[c2] != "Z": c2 -= 1 print((len(s[c1:c2]) + 1))
false
14.285714
[ "-from collections import deque", "-", "-ds = deque(s)", "-flag = True", "-while ds[0] != \"A\" or ds[-1] != \"Z\":", "- if ds[0] != \"A\":", "- ds.popleft()", "- if ds[-1] != \"Z\":", "- ds.pop()", "-print((len(ds)))", "+ds = list(s)", "+c1 = 0", "+while ds[c1] != \"A\":...
false
0.166397
0.06064
2.744025
[ "s021153463", "s221520746" ]
u597374218
p02783
python
s069470711
s291552168
22
17
3,060
2,940
Accepted
Accepted
22.73
H,A=list(map(int,input().split())) print(((H+A-1)//A))
H,A=list(map(int,input().split())) print((-(-H//A)))
2
2
47
45
H, A = list(map(int, input().split())) print(((H + A - 1) // A))
H, A = list(map(int, input().split())) print((-(-H // A)))
false
0
[ "-print(((H + A - 1) // A))", "+print((-(-H // A)))" ]
false
0.054276
0.035529
1.527667
[ "s069470711", "s291552168" ]
u852690916
p03963
python
s077565493
s168745942
174
17
38,384
2,940
Accepted
Accepted
90.23
N,K=list(map(int, input().split())) ans=K*((K-1)**(N-1)) print(ans)
N,K=list(map(int, input().split())) ans=K for i in range(1,N): ans*=K-1 print(ans)
3
5
64
84
N, K = list(map(int, input().split())) ans = K * ((K - 1) ** (N - 1)) print(ans)
N, K = list(map(int, input().split())) ans = K for i in range(1, N): ans *= K - 1 print(ans)
false
40
[ "-ans = K * ((K - 1) ** (N - 1))", "+ans = K", "+for i in range(1, N):", "+ ans *= K - 1" ]
false
0.040849
0.038388
1.064112
[ "s077565493", "s168745942" ]
u001024152
p03476
python
s565213278
s197556232
1,996
875
9,848
9,772
Accepted
Accepted
56.16
# D N = 10**5 primes = set([]) is_prime = [True]*(N+1) is_prime[0] = False is_prime[1] = False for i in range(2, N+1): if is_prime[i]: primes.add(i) for j in range(2, N//i+1): is_prime[j*i] = False # like-2017 cnt = [0]*(int(1e5)+2) for p in primes: if (p+1)//2 in...
# D N = 10**5 primes = set([]) is_prime = [True]*(N+2) is_prime[0] = False is_prime[1] = False for i in range(2, N+2): if is_prime[i]: primes.add(i) for j in range(2, N//i+1): is_prime[j*i] = False # like-2017 cnt = [0]*(N+2) for i in range(1, N+2): cnt[i] += cnt[...
25
24
532
517
# D N = 10**5 primes = set([]) is_prime = [True] * (N + 1) is_prime[0] = False is_prime[1] = False for i in range(2, N + 1): if is_prime[i]: primes.add(i) for j in range(2, N // i + 1): is_prime[j * i] = False # like-2017 cnt = [0] * (int(1e5) + 2) for p in primes: if (p + 1) // 2 in...
# D N = 10**5 primes = set([]) is_prime = [True] * (N + 2) is_prime[0] = False is_prime[1] = False for i in range(2, N + 2): if is_prime[i]: primes.add(i) for j in range(2, N // i + 1): is_prime[j * i] = False # like-2017 cnt = [0] * (N + 2) for i in range(1, N + 2): cnt[i] += cnt[i ...
false
4
[ "-is_prime = [True] * (N + 1)", "+is_prime = [True] * (N + 2)", "-for i in range(2, N + 1):", "+for i in range(2, N + 2):", "-cnt = [0] * (int(1e5) + 2)", "-for p in primes:", "- if (p + 1) // 2 in primes:", "- cnt[p] = 1", "-for i in range(1, int(1e5) + 2):", "+cnt = [0] * (N + 2)", "...
false
0.138698
0.304229
0.455898
[ "s565213278", "s197556232" ]
u482157295
p02693
python
s780324829
s635128329
64
28
61,588
9,168
Accepted
Accepted
56.25
k = int(eval(input())) a,b = list(map(int,input().split())) flag = "ng" for i in range(a,b+1): if i % k == 0: flag = "ok" if flag == "ok": print("OK") else: print("NG")
k = int(eval(input())) a,b = list(map(int,input().split())) for i in range(a,b+1): if i%k == 0: print("OK") break else: print("NG")
10
8
185
150
k = int(eval(input())) a, b = list(map(int, input().split())) flag = "ng" for i in range(a, b + 1): if i % k == 0: flag = "ok" if flag == "ok": print("OK") else: print("NG")
k = int(eval(input())) a, b = list(map(int, input().split())) for i in range(a, b + 1): if i % k == 0: print("OK") break else: print("NG")
false
20
[ "-flag = \"ng\"", "- flag = \"ok\"", "-if flag == \"ok\":", "- print(\"OK\")", "+ print(\"OK\")", "+ break" ]
false
0.035017
0.035623
0.98298
[ "s780324829", "s635128329" ]
u201234972
p03347
python
s327334977
s263597632
392
138
11,052
17,068
Accepted
Accepted
64.8
N = int( eval(input())) A = [ int( eval(input())) for _ in range(N)] now = 0 ans = 0 if A[0] != 0: ans = -1 else: for i in range(1,N): a = A[i] # if a > i: # ans = -1 # break #el if now + 1 == a: ans += 1 now += 1 elif...
import sys input = sys.stdin.readline def main(): N = int( eval(input())) A = [ int( eval(input())) for _ in range(N)] if A[0] > 0: print((-1)) return ans = 0 for i in range(1,N): # print(i, A[i]) if A[i] == 0: continue if A[i] == 1: ...
23
27
425
589
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] now = 0 ans = 0 if A[0] != 0: ans = -1 else: for i in range(1, N): a = A[i] # if a > i: # ans = -1 # break # el if now + 1 == a: ans += 1 now += 1 elif now >=...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] if A[0] > 0: print((-1)) return ans = 0 for i in range(1, N): # print(i, A[i]) if A[i] == 0: continue if A[i] == 1: a...
false
14.814815
[ "-N = int(eval(input()))", "-A = [int(eval(input())) for _ in range(N)]", "-now = 0", "-ans = 0", "-if A[0] != 0:", "- ans = -1", "-else:", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "+def main():", "+ N = int(eval(input()))", "+ A = [int(eval(input())) for _ i...
false
0.044113
0.094407
0.467268
[ "s327334977", "s263597632" ]
u075012704
p03215
python
s751634436
s967280471
771
282
143,124
69,756
Accepted
Accepted
63.42
def main(): from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) accA = [0] + list(accumulate(A)) Bin = [] for i in range(N + 1): for j in range(i + 1, N + 1): par_sum = accA[j] - accA[i] b = bi...
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) # 連続する部分列の和を計算 A_acc = [0] + list(accumulate(A)) SubArraysSums = [] for i in range(1, N + 1): for j in range(i, N + 1): SubArraysSums.append(A_acc[j] - A_acc[i - 1]) SubArraysSums.sort() ...
27
27
605
557
def main(): from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) accA = [0] + list(accumulate(A)) Bin = [] for i in range(N + 1): for j in range(i + 1, N + 1): par_sum = accA[j] - accA[i] b = bin(par_sum) ...
from itertools import accumulate N, K = list(map(int, input().split())) A = list(map(int, input().split())) # 連続する部分列の和を計算 A_acc = [0] + list(accumulate(A)) SubArraysSums = [] for i in range(1, N + 1): for j in range(i, N + 1): SubArraysSums.append(A_acc[j] - A_acc[i - 1]) SubArraysSums.sort() ans = 0 tmp ...
false
0
[ "-def main():", "- from itertools import accumulate", "+from itertools import accumulate", "- N, K = list(map(int, input().split()))", "- A = list(map(int, input().split()))", "- accA = [0] + list(accumulate(A))", "- Bin = []", "- for i in range(N + 1):", "- for j in range(i...
false
0.044618
0.044926
0.99314
[ "s751634436", "s967280471" ]
u645250356
p03108
python
s591026174
s879065630
1,058
720
136,024
37,400
Accepted
Accepted
31.95
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.rea...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.rea...
81
78
1,904
1,852
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 mod2 = 998244353 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(in...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 mod2 = 998244353 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(in...
false
3.703704
[ "+ if uf.same(a - 1, b - 1):", "+ tt = res[-1]", "+ else:", "+ tt = res[-1] - (na * nb)", "- ns = uf.size(b - 1)", "- if na + nb == ns:", "- tt = res[-1] - (na * nb)", "- else:", "- tt = res[-1]", "- # if ns == n:", "- # tt = 0" ]
false
0.044012
0.047759
0.921531
[ "s591026174", "s879065630" ]
u606045429
p02662
python
s624814178
s760550639
222
174
139,376
132,424
Accepted
Accepted
21.62
mod = 998244353 N, S, *A = list(map(int, open(0).read().split())) dp = [[0] * (S + 1) for _ in range(N + 1)] dp[0][0] = 1 for i, a in enumerate(A): for j in range(S + 1): dp[i + 1][j] += 2 * dp[i][j] dp[i + 1][j] %= mod if j + a <= S: dp[i + 1][j + a] += dp[i][j]...
mod = 998244353 N, S, *A = list(map(int, open(0).read().split())) dp = [[0] * (S + 1) for _ in range(N + 1)] dp[0][0] = 1 for i, a in enumerate(A, 1): for j in range(S + 1): dp[i][j] = (2 * dp[i - 1][j] + (dp[i - 1][j - a] if j >= a else 0)) % mod print((dp[N][S]))
17
12
370
284
mod = 998244353 N, S, *A = list(map(int, open(0).read().split())) dp = [[0] * (S + 1) for _ in range(N + 1)] dp[0][0] = 1 for i, a in enumerate(A): for j in range(S + 1): dp[i + 1][j] += 2 * dp[i][j] dp[i + 1][j] %= mod if j + a <= S: dp[i + 1][j + a] += dp[i][j] dp[i...
mod = 998244353 N, S, *A = list(map(int, open(0).read().split())) dp = [[0] * (S + 1) for _ in range(N + 1)] dp[0][0] = 1 for i, a in enumerate(A, 1): for j in range(S + 1): dp[i][j] = (2 * dp[i - 1][j] + (dp[i - 1][j - a] if j >= a else 0)) % mod print((dp[N][S]))
false
29.411765
[ "-for i, a in enumerate(A):", "+for i, a in enumerate(A, 1):", "- dp[i + 1][j] += 2 * dp[i][j]", "- dp[i + 1][j] %= mod", "- if j + a <= S:", "- dp[i + 1][j + a] += dp[i][j]", "- dp[i + 1][j + a] %= mod", "+ dp[i][j] = (2 * dp[i - 1][j] + (dp[i - 1][j ...
false
0.096124
0.036852
2.60837
[ "s624814178", "s760550639" ]
u186838327
p03048
python
s939248702
s950571896
288
88
40,812
67,160
Accepted
Accepted
69.44
r, g, b, n = list(map(int, input().split())) ans = 0 for i in range(n+1): for j in range(n+1): s = n - r*i - g*j if s < 0: continue else: if s%b == 0: ans += 1 print(ans)
R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N+1): for g in range(N+1): res = N-R*r-G*g if res < 0: continue else: if res%B == 0: ans += 1 print(ans)
12
11
245
245
r, g, b, n = list(map(int, input().split())) ans = 0 for i in range(n + 1): for j in range(n + 1): s = n - r * i - g * j if s < 0: continue else: if s % b == 0: ans += 1 print(ans)
R, G, B, N = list(map(int, input().split())) ans = 0 for r in range(N + 1): for g in range(N + 1): res = N - R * r - G * g if res < 0: continue else: if res % B == 0: ans += 1 print(ans)
false
8.333333
[ "-r, g, b, n = list(map(int, input().split()))", "+R, G, B, N = list(map(int, input().split()))", "-for i in range(n + 1):", "- for j in range(n + 1):", "- s = n - r * i - g * j", "- if s < 0:", "+for r in range(N + 1):", "+ for g in range(N + 1):", "+ res = N - R * r - G ...
false
1.004997
1.027581
0.978023
[ "s939248702", "s950571896" ]
u644907318
p03611
python
s275118410
s359595420
272
117
52,908
92,724
Accepted
Accepted
56.99
from bisect import bisect_right N = int(eval(input())) A = sorted(list(map(int,input().split()))) cmax = 0 for i in range(N): a = A[i] ind = bisect_right(A,a+2) cmax = max(cmax,ind-i) print(cmax)
N = int(eval(input())) A = list(map(int,input().split())) C = {} for i in range(N): if A[i] not in C: C[A[i]] = 0 C[A[i]] += 1 cmax = 0 for a in A: cnt = C[a] if a-1 in C: cnt += C[a-1] if a+1 in C: cnt += C[a+1] cmax = max(cmax,cnt) print(cmax)
9
16
209
302
from bisect import bisect_right N = int(eval(input())) A = sorted(list(map(int, input().split()))) cmax = 0 for i in range(N): a = A[i] ind = bisect_right(A, a + 2) cmax = max(cmax, ind - i) print(cmax)
N = int(eval(input())) A = list(map(int, input().split())) C = {} for i in range(N): if A[i] not in C: C[A[i]] = 0 C[A[i]] += 1 cmax = 0 for a in A: cnt = C[a] if a - 1 in C: cnt += C[a - 1] if a + 1 in C: cnt += C[a + 1] cmax = max(cmax, cnt) print(cmax)
false
43.75
[ "-from bisect import bisect_right", "-", "-A = sorted(list(map(int, input().split())))", "+A = list(map(int, input().split()))", "+C = {}", "+for i in range(N):", "+ if A[i] not in C:", "+ C[A[i]] = 0", "+ C[A[i]] += 1", "-for i in range(N):", "- a = A[i]", "- ind = bisect_r...
false
0.043699
0.039359
1.110264
[ "s275118410", "s359595420" ]
u603234915
p03821
python
s849679656
s973209029
367
219
10,932
10,932
Accepted
Accepted
40.33
N = int(eval(input())) A = [None] * N B = [None] * N for i in range(1, N+1): a, b = list(map(int, input().split())) A[N-i] = a B[N-i] = b cnt = 0 for i in range(N): A_add = A[i] + cnt r = A_add % B[i] if r == 0: pass else: cnt += B[i] - r print(cnt)
import sys N = int(eval(input())) A = [None] * N B = [None] * N for i in range(1, N+1): a, b = list(map(int, sys.stdin.readline().split())) A[N-i] = a B[N-i] = b cnt = 0 for i in range(N): A_add = A[i] + cnt r = A_add % B[i] if r == 0: pass else: cnt += ...
19
20
304
329
N = int(eval(input())) A = [None] * N B = [None] * N for i in range(1, N + 1): a, b = list(map(int, input().split())) A[N - i] = a B[N - i] = b cnt = 0 for i in range(N): A_add = A[i] + cnt r = A_add % B[i] if r == 0: pass else: cnt += B[i] - r print(cnt)
import sys N = int(eval(input())) A = [None] * N B = [None] * N for i in range(1, N + 1): a, b = list(map(int, sys.stdin.readline().split())) A[N - i] = a B[N - i] = b cnt = 0 for i in range(N): A_add = A[i] + cnt r = A_add % B[i] if r == 0: pass else: cnt += B[i] - r print(...
false
5
[ "+import sys", "+", "- a, b = list(map(int, input().split()))", "+ a, b = list(map(int, sys.stdin.readline().split()))" ]
false
0.064984
0.093386
0.69586
[ "s849679656", "s973209029" ]
u047796752
p02814
python
s880907688
s605583431
482
432
60,004
60,900
Accepted
Accepted
10.37
import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a%b return a def lcm(a, b): return a*b//gcd(a, b) N, M = list(map(int, input().split())) a = list(map(int, input().split())) b = [ai//2 for ai in a] L = 1 for bi in b: L = lcm(L, bi) flag = True...
import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a%b return a def lcm(a, b): return a*b//gcd(a, b) N, M = list(map(int, input().split())) a = list(map(int, input().split())) b = [ai//2 for ai in a] cnt = [0]*N for i in range(N): tmp = b[i] w...
39
41
538
572
import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) N, M = list(map(int, input().split())) a = list(map(int, input().split())) b = [ai // 2 for ai in a] L = 1 for bi in b: L = lcm(L, bi) flag = True for i in range...
import sys input = sys.stdin.readline def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) N, M = list(map(int, input().split())) a = list(map(int, input().split())) b = [ai // 2 for ai in a] cnt = [0] * N for i in range(N): tmp = b[i] while tmp % ...
false
4.878049
[ "+cnt = [0] * N", "+for i in range(N):", "+ tmp = b[i]", "+ while tmp % 2 == 0:", "+ tmp //= 2", "+ cnt[i] += 1", "+if len(set(cnt)) != 1:", "+ print((0))", "+ exit()", "-flag = True", "-for i in range(N):", "- if (L - b[i]) % a[i] != 0:", "- flag = False"...
false
0.041698
0.046658
0.893703
[ "s880907688", "s605583431" ]
u011634450
p03078
python
s179343815
s485957448
881
768
8,708
4,460
Accepted
Accepted
12.83
# https://img.atcoder.jp/abc123/editorial.pdf # 問題D: Cake 123 解法 #2 - 「ある条件」を満たす最大106307通りを全部ソート def solve(X, Y, Z, K, A, B, C): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ABC = [] for i1, a in enumerate(A, start=1): for i2, b in enumerate(B, start=1): ...
# https://img.atcoder.jp/abc123/editorial.pdf # 問題D: Cake 123 解法 #3 - さらに高速な解法、priority-queue を用いて O(K log K) from heapq import heappush, heappop def solve(X, Y, Z, K, A, B, C): def append(cand_a, cand_b, cand_c): cand_key = (cand_a, cand_b, cand_c) if not cand_key in pushedQ \ ...
27
44
808
1,271
# https://img.atcoder.jp/abc123/editorial.pdf # 問題D: Cake 123 解法 #2 - 「ある条件」を満たす最大106307通りを全部ソート def solve(X, Y, Z, K, A, B, C): A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ABC = [] for i1, a in enumerate(A, start=1): for i2, b in enumerate(B, start=1): for i3,...
# https://img.atcoder.jp/abc123/editorial.pdf # 問題D: Cake 123 解法 #3 - さらに高速な解法、priority-queue を用いて O(K log K) from heapq import heappush, heappop def solve(X, Y, Z, K, A, B, C): def append(cand_a, cand_b, cand_c): cand_key = (cand_a, cand_b, cand_c) if ( not cand_key in pushedQ ...
false
38.636364
[ "-# 問題D: Cake 123 解法 #2 - 「ある条件」を満たす最大106307通りを全部ソート", "+# 問題D: Cake 123 解法 #3 - さらに高速な解法、priority-queue を用いて O(K log K)", "+from heapq import heappush, heappop", "+", "+", "+ def append(cand_a, cand_b, cand_c):", "+ cand_key = (cand_a, cand_b, cand_c)", "+ if (", "+ not ...
false
0.047376
0.046596
1.016742
[ "s179343815", "s485957448" ]
u022609072
p02873
python
s163638804
s976145141
289
196
4,212
4,108
Accepted
Accepted
32.18
S = eval(input()) y = 0 sum_t = 0 up = False pre = y for i in range(len(S)): if S[i] == '<': if up & (i!=(len(S))): y += 1 sum_t += y else: y = 1 sum_t += y up = True elif S[i] == '>': if up == False & (i!=(len(S))): y += 1 sum_t += y if y <= pre: sum_t -=1 else:...
S = eval(input()) y = 0 sum_t = 0 up = False pre = y for c in S: if c == '<': if up: y += 1 else: y = 1 sum_t += y up = True elif c == '>': if up: pre = y y = 1 else: y += 1 sum_t += y if y <= pre: sum_t -=1 up = False print(sum_t)
25
24
364
289
S = eval(input()) y = 0 sum_t = 0 up = False pre = y for i in range(len(S)): if S[i] == "<": if up & (i != (len(S))): y += 1 sum_t += y else: y = 1 sum_t += y up = True elif S[i] == ">": if up == False & (i != (len(S))): ...
S = eval(input()) y = 0 sum_t = 0 up = False pre = y for c in S: if c == "<": if up: y += 1 else: y = 1 sum_t += y up = True elif c == ">": if up: pre = y y = 1 else: y += 1 sum_t += y ...
false
4
[ "-for i in range(len(S)):", "- if S[i] == \"<\":", "- if up & (i != (len(S))):", "+for c in S:", "+ if c == \"<\":", "+ if up:", "- sum_t += y", "- sum_t += y", "+ sum_t += y", "- elif S[i] == \">\":", "- if up == False & (i != (len(S)))...
false
0.035073
0.176882
0.198288
[ "s163638804", "s976145141" ]
u389910364
p03008
python
s729154792
s286562022
251
26
229,020
3,192
Accepted
Accepted
89.64
import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") N = int(sys.stdin.readline()) GA, SA, BA = list(map(int, sys.stdin.readline().split())) GB, SB, BB = list(map(int, sys.stdin.readline().split())) values = [...
import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") N = int(sys.stdin.readline()) GA, SA, BA = list(map(int, sys.stdin.readline().split())) GB, SB, BB = list(map(int, sys.stdin.readline().split())) def knap...
79
63
1,901
1,731
import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") N = int(sys.stdin.readline()) GA, SA, BA = list(map(int, sys.stdin.readline().split())) GB, SB, BB = list(map(int, sys.stdin.readline().split())) values = [] weights = [] if...
import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") N = int(sys.stdin.readline()) GA, SA, BA = list(map(int, sys.stdin.readline().split())) GB, SB, BB = list(map(int, sys.stdin.readline().split())) def knapsack(n, ga, sa, b...
false
20.253165
[ "-values = []", "-weights = []", "-if GB / GA > 1:", "- values.append(GB - GA)", "- weights.append(GA)", "-if SB / SA > 1:", "- values.append(SB - SA)", "- weights.append(SA)", "-if BB / BA > 1:", "- values.append(BB - BA)", "- weights.append(BA)", "-# dp[i]: 重さ i 以下で選ぶのの価値の最...
false
0.043418
0.042288
1.026722
[ "s729154792", "s286562022" ]
u835534360
p04046
python
s194170678
s529214189
1,419
1,191
124,176
122,232
Accepted
Accepted
16.07
def combmod(n, r, p): if r < 0 or n < r: return 0 return fact[n] * finv[r] * finv[n-r] % p p = 10**9+7 N = 10**6 fact = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, N+1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) finv.append((finv[-1] *...
def combmod_pre(N, p): ''' sample usage: p = 10**9+7 N = 10**6 fact, finv = combmod_pre(N, p) combmod(n, r, p) ''' fact = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, N+1): fact.append((fact[-1] * i) % p) inv.append((-inv[p ...
22
43
503
1,020
def combmod(n, r, p): if r < 0 or n < r: return 0 return fact[n] * finv[r] * finv[n - r] % p p = 10**9 + 7 N = 10**6 fact = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, N + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) finv.append((finv[-1] * inv[-1]) ...
def combmod_pre(N, p): """ sample usage: p = 10**9+7 N = 10**6 fact, finv = combmod_pre(N, p) combmod(n, r, p) """ fact = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, N + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p /...
false
48.837209
[ "-def combmod(n, r, p):", "+def combmod_pre(N, p):", "+ \"\"\"", "+ sample usage:", "+ p = 10**9+7", "+ N = 10**6", "+ fact, finv = combmod_pre(N, p)", "+ combmod(n, r, p)", "+ \"\"\"", "+ fact = [1, 1]", "+ finv = [1, 1]", "+ inv = [0, 1]", "+ ...
false
2.391199
2.064445
1.158277
[ "s194170678", "s529214189" ]
u667084803
p02781
python
s141391405
s950941425
32
17
3,440
3,064
Accepted
Accepted
46.88
N = int(eval(input())) K = int(eval(input())) L = len(str(N)) suu = [] for i in range(L): suu.append(int(str(N)[i])) DP_1 =[[0 for k in range(L+2)] for i in range(L+1)] DP_2 =[[0 for k in range(L+2)] for i in range(L+1)] DP_2[0][0] = 1 for i in range(L): for k in range(L+1): DP_1[i+1][k] ...
N = int(eval(input())) K = int(eval(input())) L = len(str(N)) def solve(num_str, k, smaller): if num_str == "" and k > 0: return 0 if k == 0 or num_str == "": return 1 elif smaller: keta = len(num_str) if k == 1: return keta * 9 elif k == 2...
20
30
562
860
N = int(eval(input())) K = int(eval(input())) L = len(str(N)) suu = [] for i in range(L): suu.append(int(str(N)[i])) DP_1 = [[0 for k in range(L + 2)] for i in range(L + 1)] DP_2 = [[0 for k in range(L + 2)] for i in range(L + 1)] DP_2[0][0] = 1 for i in range(L): for k in range(L + 1): DP_1[i + 1][k] =...
N = int(eval(input())) K = int(eval(input())) L = len(str(N)) def solve(num_str, k, smaller): if num_str == "" and k > 0: return 0 if k == 0 or num_str == "": return 1 elif smaller: keta = len(num_str) if k == 1: return keta * 9 elif k == 2: ...
false
33.333333
[ "-suu = []", "-for i in range(L):", "- suu.append(int(str(N)[i]))", "-DP_1 = [[0 for k in range(L + 2)] for i in range(L + 1)]", "-DP_2 = [[0 for k in range(L + 2)] for i in range(L + 1)]", "-DP_2[0][0] = 1", "-for i in range(L):", "- for k in range(L + 1):", "- DP_1[i + 1][k] = DP_1[i]...
false
0.040323
0.073586
0.547968
[ "s141391405", "s950941425" ]
u077291787
p02996
python
s611344165
s890081388
831
479
33,456
33,456
Accepted
Accepted
42.36
# ABC131D - Megalomania def main(): n = int(eval(input())) arr = sorted( [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1] ) tasks = 0 for i, j in arr: tasks += i if tasks > j: print("No") break else: ...
# ABC131D - Megalomania import sys input = sys.stdin.readline def main(): n = int(eval(input())) arr = sorted( [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1] ) tasks = 0 for i, j in arr: tasks += i if tasks > j: pri...
18
21
376
418
# ABC131D - Megalomania def main(): n = int(eval(input())) arr = sorted( [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1], ) tasks = 0 for i, j in arr: tasks += i if tasks > j: print("No") break else: ...
# ABC131D - Megalomania import sys input = sys.stdin.readline def main(): n = int(eval(input())) arr = sorted( [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1], ) tasks = 0 for i, j in arr: tasks += i if tasks > j: print...
false
14.285714
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.073739
0.04472
1.648888
[ "s611344165", "s890081388" ]
u536034761
p03607
python
s641557289
s334824112
200
172
11,884
19,632
Accepted
Accepted
14
N = int(eval(input())) S = set() for i in range(N): num = int(eval(input())) if num in S: S.remove(num) else: S.add(num) print((len(S)))
from collections import Counter n = int(eval(input())) ans = 0 C = Counter(int(eval(input())) for _ in range(n)) for c in list(C.values()): if c % 2 == 1: ans += 1 print(ans)
9
8
144
176
N = int(eval(input())) S = set() for i in range(N): num = int(eval(input())) if num in S: S.remove(num) else: S.add(num) print((len(S)))
from collections import Counter n = int(eval(input())) ans = 0 C = Counter(int(eval(input())) for _ in range(n)) for c in list(C.values()): if c % 2 == 1: ans += 1 print(ans)
false
11.111111
[ "-N = int(eval(input()))", "-S = set()", "-for i in range(N):", "- num = int(eval(input()))", "- if num in S:", "- S.remove(num)", "- else:", "- S.add(num)", "-print((len(S)))", "+from collections import Counter", "+", "+n = int(eval(input()))", "+ans = 0", "+C = Cou...
false
0.007401
0.067815
0.109133
[ "s641557289", "s334824112" ]
u929569377
p02913
python
s865674207
s137599545
968
509
230,408
46,172
Accepted
Accepted
47.42
N = int(eval(input())) S = eval(input()) dp = [[0] * (N+1) for _ in range(N+1)] for i in range(N-1, -1, -1): for j in range(N-1, -1, -1): if S[i] == S[j]: dp[i][j] = dp[i+1][j+1] + 1 ans = 0 for i in range(N): for j in range(N): if i >= j: continue ...
N = int(eval(input())) S = eval(input()) ans = 0 for i in range(N-1): for j in range(i+1, N): if S[i] == S[j]: if i != 0: if S[i-1] == S[j-1]: continue equal = 1 for k in range(1, min(j-i, N-j)): if S[i+k] =...
19
19
379
449
N = int(eval(input())) S = eval(input()) dp = [[0] * (N + 1) for _ in range(N + 1)] for i in range(N - 1, -1, -1): for j in range(N - 1, -1, -1): if S[i] == S[j]: dp[i][j] = dp[i + 1][j + 1] + 1 ans = 0 for i in range(N): for j in range(N): if i >= j: continue now...
N = int(eval(input())) S = eval(input()) ans = 0 for i in range(N - 1): for j in range(i + 1, N): if S[i] == S[j]: if i != 0: if S[i - 1] == S[j - 1]: continue equal = 1 for k in range(1, min(j - i, N - j)): if S[i + k] ...
false
0
[ "-dp = [[0] * (N + 1) for _ in range(N + 1)]", "-for i in range(N - 1, -1, -1):", "- for j in range(N - 1, -1, -1):", "+ans = 0", "+for i in range(N - 1):", "+ for j in range(i + 1, N):", "- dp[i][j] = dp[i + 1][j + 1] + 1", "-ans = 0", "-for i in range(N):", "- for j in range(...
false
0.077309
0.037655
2.053119
[ "s865674207", "s137599545" ]
u576434377
p03681
python
s081892733
s439093417
716
454
13,036
12,088
Accepted
Accepted
36.59
import itertools import math N,M = list(map(int,input().strip().split(" "))) al = [i for i in range(N)] bl = [i for i in range(M)] mod = (pow(10,9) + 7) result = 0 if abs(N - M) > 1: result = 0 else: a_perm = math.factorial(N) b_perm = math.factorial(M) if abs(N - M) == 1: res...
import itertools import math N,M = list(map(int,input().strip().split(" "))) al = [i for i in range(N)] bl = [i for i in range(M)] mod = (pow(10,9) + 7) result = 0 if abs(N - M) > 1: result = 0 else: a_perm = math.factorial(N) % mod b_perm = math.factorial(M) % mod if abs(N - M) == 1: ...
22
22
438
450
import itertools import math N, M = list(map(int, input().strip().split(" "))) al = [i for i in range(N)] bl = [i for i in range(M)] mod = pow(10, 9) + 7 result = 0 if abs(N - M) > 1: result = 0 else: a_perm = math.factorial(N) b_perm = math.factorial(M) if abs(N - M) == 1: result = (a_perm * b...
import itertools import math N, M = list(map(int, input().strip().split(" "))) al = [i for i in range(N)] bl = [i for i in range(M)] mod = pow(10, 9) + 7 result = 0 if abs(N - M) > 1: result = 0 else: a_perm = math.factorial(N) % mod b_perm = math.factorial(M) % mod if abs(N - M) == 1: result =...
false
0
[ "- a_perm = math.factorial(N)", "- b_perm = math.factorial(M)", "+ a_perm = math.factorial(N) % mod", "+ b_perm = math.factorial(M) % mod" ]
false
0.041808
0.082289
0.508064
[ "s081892733", "s439093417" ]
u490642448
p03677
python
s412390321
s795239398
119
91
99,876
86,512
Accepted
Accepted
23.53
n,m = list(map(int,input().split())) a = list(map(int,input().split())) ex = [0] * m left = [0] * (2*m) right = [[0,0] for _ in range(2*m)] ans = 0 for i in range(n-1): a0 = a[i]-1 a1 = a[i+1]-1 ans += (a1-a0)%m left[a0+1] += 1 right[a1 + (a0>a1)*m][0] += 1 right[a1 + (a0>a1)*m][...
n,m = list(map(int,input().split())) a = list(map(int,input().split())) imos = [0] * (2*m+2) ans = 0 for i in range(n-1): a0 = a[i]-1 a1 = a[i+1]-1 dif = (a1-a0)%m ans += dif if(dif>=2): imos[a0+2] += 1 imos[a0+dif+1] -= dif imos[a0+dif+2] += dif-1 # print(im...
26
30
506
539
n, m = list(map(int, input().split())) a = list(map(int, input().split())) ex = [0] * m left = [0] * (2 * m) right = [[0, 0] for _ in range(2 * m)] ans = 0 for i in range(n - 1): a0 = a[i] - 1 a1 = a[i + 1] - 1 ans += (a1 - a0) % m left[a0 + 1] += 1 right[a1 + (a0 > a1) * m][0] += 1 right[a1 + (...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) imos = [0] * (2 * m + 2) ans = 0 for i in range(n - 1): a0 = a[i] - 1 a1 = a[i + 1] - 1 dif = (a1 - a0) % m ans += dif if dif >= 2: imos[a0 + 2] += 1 imos[a0 + dif + 1] -= dif imos[a0 + dif + 2] += dif...
false
13.333333
[ "-ex = [0] * m", "-left = [0] * (2 * m)", "-right = [[0, 0] for _ in range(2 * m)]", "+imos = [0] * (2 * m + 2)", "- ans += (a1 - a0) % m", "- left[a0 + 1] += 1", "- right[a1 + (a0 > a1) * m][0] += 1", "- right[a1 + (a0 > a1) * m][1] += (a1 - a0) % m - 1", "-now = left[0]", "-dif = 0",...
false
0.040582
0.045499
0.891917
[ "s412390321", "s795239398" ]
u062147869
p03295
python
s605143659
s431934619
879
711
54,572
57,944
Accepted
Accepted
19.11
N,M=list(map(int,input().split())) table=[] for i in range(M): a,b=list(map(int,input().split())) table.append((a-1,b-2)) table.sort() s=0 t=N ans=0 for a,b in table: if t<a: ans+=1 s=a t=b else: s=a t=min(t,b) #print(s,t) print((ans+1)) ...
from operator import itemgetter N,M=list(map(int,input().split())) table=[] for i in range(M): a,b=list(map(int,input().split())) table.append((a,b)) table=sorted(table, key=itemgetter(1)) ans=0 t=0 for a,b in table: if t<a: ans+=1 t=b-1 print(ans)
20
14
311
277
N, M = list(map(int, input().split())) table = [] for i in range(M): a, b = list(map(int, input().split())) table.append((a - 1, b - 2)) table.sort() s = 0 t = N ans = 0 for a, b in table: if t < a: ans += 1 s = a t = b else: s = a t = min(t, b) # print(s,...
from operator import itemgetter N, M = list(map(int, input().split())) table = [] for i in range(M): a, b = list(map(int, input().split())) table.append((a, b)) table = sorted(table, key=itemgetter(1)) ans = 0 t = 0 for a, b in table: if t < a: ans += 1 t = b - 1 print(ans)
false
30
[ "+from operator import itemgetter", "+", "- table.append((a - 1, b - 2))", "-table.sort()", "-s = 0", "-t = N", "+ table.append((a, b))", "+table = sorted(table, key=itemgetter(1))", "+t = 0", "- s = a", "- t = b", "- else:", "- s = a", "- t = min(t, b)...
false
0.07724
0.078923
0.978682
[ "s605143659", "s431934619" ]
u432551953
p03031
python
s170572297
s657427965
214
181
43,368
39,920
Accepted
Accepted
15.42
import sys input = sys.stdin.readline v = [] p = [] count = 0 m = 0 def rec(l, n): global count if len(l) == n: c = 0 st = set() for i in range(n): if l[i] == 1: st.add(i + 1) for k, sw in enumerate(v): # print(st) if len(sw.intersection(st)) % 2 != p[k]: return # print(...
import sys input = sys.stdin.readline def main(): n, m = list(map(int, input().strip().split())) A = [0] * n for i in range(m): sw = list(map(int, input().strip().split()))[1:] for e in sw: e -= 1 A[e] |= 1 << i pl = list(map(int, input().strip().split())) p = 0 for i, e in enumerate(pl)...
43
33
751
545
import sys input = sys.stdin.readline v = [] p = [] count = 0 m = 0 def rec(l, n): global count if len(l) == n: c = 0 st = set() for i in range(n): if l[i] == 1: st.add(i + 1) for k, sw in enumerate(v): # print(st) if len(sw....
import sys input = sys.stdin.readline def main(): n, m = list(map(int, input().strip().split())) A = [0] * n for i in range(m): sw = list(map(int, input().strip().split()))[1:] for e in sw: e -= 1 A[e] |= 1 << i pl = list(map(int, input().strip().split())) ...
false
23.255814
[ "-v = []", "-p = []", "-count = 0", "-m = 0", "-", "-", "-def rec(l, n):", "- global count", "- if len(l) == n:", "- c = 0", "- st = set()", "- for i in range(n):", "- if l[i] == 1:", "- st.add(i + 1)", "- for k, sw in enumerate...
false
0.043439
0.036468
1.191176
[ "s170572297", "s657427965" ]
u131638468
p03855
python
s088267348
s203105723
1,376
1,232
56,060
55,932
Accepted
Accepted
10.47
from collections import Counter n,k,l=map(int,input().split()) city1=[i for i in range(n)] city2=[i for i in range(n)] def root(c,x): if x==c[x]: return x else: return root(c,c[x]) def union(c,x,y): rx=root(c,x) ry=root(c,y) if rx>ry: c[rx]=ry else: c[ry]=rx for i in range(k)...
from collections import Counter n,k,l=map(int,input().split()) city1=[i for i in range(n)] city2=[i for i in range(n)] def root(c,x): if x==c[x]: return x else: c[x]=root(c,c[x]) return c[x] def union(c,x,y): rx=root(c,x) ry=root(c,y) if rx>ry: c[rx]=ry else: c[ry]=rx fo...
32
33
634
649
from collections import Counter n, k, l = map(int, input().split()) city1 = [i for i in range(n)] city2 = [i for i in range(n)] def root(c, x): if x == c[x]: return x else: return root(c, c[x]) def union(c, x, y): rx = root(c, x) ry = root(c, y) if rx > ry: c[rx] = ry ...
from collections import Counter n, k, l = map(int, input().split()) city1 = [i for i in range(n)] city2 = [i for i in range(n)] def root(c, x): if x == c[x]: return x else: c[x] = root(c, c[x]) return c[x] def union(c, x, y): rx = root(c, x) ry = root(c, y) if rx > ry: ...
false
3.030303
[ "- return root(c, c[x])", "+ c[x] = root(c, c[x])", "+ return c[x]" ]
false
0.088571
0.051017
1.736112
[ "s088267348", "s203105723" ]
u571524394
p02681
python
s500286345
s965619821
74
61
67,536
61,832
Accepted
Accepted
17.57
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [lis...
s = list(eval(input())) t = list(eval(input())) x = len(s) y = len(t) ans = "Yes" for i in range(x): if (s[i] == t[i]) and (x+1 == y): ans = "Yes" continue else: ans = "No" break print(ans)
47
13
1,082
209
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): r...
s = list(eval(input())) t = list(eval(input())) x = len(s) y = len(t) ans = "Yes" for i in range(x): if (s[i] == t[i]) and (x + 1 == y): ans = "Yes" continue else: ans = "No" break print(ans)
false
72.340426
[ "-#!usr/bin/env python3", "-from collections import defaultdict, deque", "-from heapq import heappush, heappop", "-from itertools import permutations, accumulate", "-import sys", "-import math", "-import bisect", "-", "-", "-def LI():", "- return [int(x) for x in sys.stdin.readline().split()]...
false
0.046368
0.074528
0.622149
[ "s500286345", "s965619821" ]