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
u150984829
p00436
python
s170025453
s994146885
40
30
5,620
5,684
Accepted
Accepted
25
n=int(eval(input())) c=list(range(1,1+2*n)) for _ in[0]*int(eval(input())): k=int(eval(input())) if k:c=c[k:]+c[:k] else: for a,b in zip(c[:n],c[n:]): c+=[a,b] c=c[2*n:] for x in c:print(x)
from itertools import chain n=int(eval(input())) c=list(range(1,1+2*n)) for _ in[0]*int(eval(input())): k=int(eval(input())) c=c[k:]+c[:k]if k else list(chain.from_iterable(x for x in zip(c[:n],c[n:]))) for x in c:print(x)
10
7
221
219
n = int(eval(input())) c = list(range(1, 1 + 2 * n)) for _ in [0] * int(eval(input())): k = int(eval(input())) if k: c = c[k:] + c[:k] else: for a, b in zip(c[:n], c[n:]): c += [a, b] c = c[2 * n :] for x in c: print(x)
from itertools import chain n = int(eval(input())) c = list(range(1, 1 + 2 * n)) for _ in [0] * int(eval(input())): k = int(eval(input())) c = c[k:] + c[:k] if k else list(chain.from_iterable(x for x in zip(c[:n], c[n:]))) for x in c: print(x)
false
30
[ "+from itertools import chain", "+", "- if k:", "- c = c[k:] + c[:k]", "- else:", "- for a, b in zip(c[:n], c[n:]):", "- c += [a, b]", "- c = c[2 * n :]", "+ c = c[k:] + c[:k] if k else list(chain.from_iterable(x for x in zip(c[:n], c[n:])))" ]
false
0.040087
0.040553
0.988496
[ "s170025453", "s994146885" ]
u133936772
p03611
python
s995021794
s508144978
205
93
13,964
20,032
Accepted
Accepted
54.63
eval(input()) l=sorted(map(int,input().split())) from bisect import * a=0 for i in range(l[0],l[-1]+1): a=max(a,bisect(l,i+1)-bisect_left(l,i-1)) print(a)
n,*l=list(map(int,open(0).read().split())) c=[0]*(10**5+3) for i in l: for j in (-1,0,1): c[i+j]+=1 print((max(c)))
7
5
156
113
eval(input()) l = sorted(map(int, input().split())) from bisect import * a = 0 for i in range(l[0], l[-1] + 1): a = max(a, bisect(l, i + 1) - bisect_left(l, i - 1)) print(a)
n, *l = list(map(int, open(0).read().split())) c = [0] * (10**5 + 3) for i in l: for j in (-1, 0, 1): c[i + j] += 1 print((max(c)))
false
28.571429
[ "-eval(input())", "-l = sorted(map(int, input().split()))", "-from bisect import *", "-", "-a = 0", "-for i in range(l[0], l[-1] + 1):", "- a = max(a, bisect(l, i + 1) - bisect_left(l, i - 1))", "-print(a)", "+n, *l = list(map(int, open(0).read().split()))", "+c = [0] * (10**5 + 3)", "+for i ...
false
0.040084
0.041414
0.967895
[ "s995021794", "s508144978" ]
u738898077
p02768
python
s530279292
s683851388
271
142
12,796
3,064
Accepted
Accepted
47.6
import numpy as np mod = (10**9)+7 def modpow(x, n): ans = 1 mod = (10**9)+7 while(n > 0): if(bin(n & 1) == bin(1)): ans = ans*x ans %= mod x = x*x x %= mod n = n >> 1 #ビットシフト return ans def nCr(n,r): mod = (10**9)+7 r = min(n,r) bunsi = bunbo = 1 ...
mod = (10**9)+7 def modpow(x, n): ans = 1 mod = (10**9)+7 while(n > 0): if(bin(n & 1) == bin(1)): ans = ans*x ans %= mod x = x*x x %= mod n = n >> 1 #ビットシフト return ans def nCr(n,r): mod = (10**9)+7 r = min(n,r) bunsi = bunbo = 1 for i in range(1,r+...
27
26
567
547
import numpy as np mod = (10**9) + 7 def modpow(x, n): ans = 1 mod = (10**9) + 7 while n > 0: if bin(n & 1) == bin(1): ans = ans * x ans %= mod x = x * x x %= mod n = n >> 1 # ビットシフト return ans def nCr(n, r): mod = (10**9) + 7 r = min...
mod = (10**9) + 7 def modpow(x, n): ans = 1 mod = (10**9) + 7 while n > 0: if bin(n & 1) == bin(1): ans = ans * x ans %= mod x = x * x x %= mod n = n >> 1 # ビットシフト return ans def nCr(n, r): mod = (10**9) + 7 r = min(n, r) bunsi = b...
false
3.703704
[ "-import numpy as np", "-" ]
false
0.167378
0.088325
1.895038
[ "s530279292", "s683851388" ]
u888092736
p03209
python
s977776461
s695021844
30
27
9,112
9,140
Accepted
Accepted
10
def count_patties(L, x): if L == 0: return 0 if x <= 0 else 1 if x <= total_layers[L - 1] + 1: return count_patties(L - 1, x - 1) else: return ( count_patties(L - 1, x - total_layers[L - 1] - 2) + 1 + total_patties[L - 1] ) N, X = list(map(int, input(...
def f(L, x): if L == 0: return 0 if x <= 0 else 1 if x <= total[L - 1] + 1: return f(L - 1, x - 1) else: return patties[L - 1] + 1 + f(L - 1, x - total[L - 1] - 2) N, X = list(map(int, input().split())) total = [1] patties = [1] for i in range(50): total.append(tot...
15
16
463
387
def count_patties(L, x): if L == 0: return 0 if x <= 0 else 1 if x <= total_layers[L - 1] + 1: return count_patties(L - 1, x - 1) else: return ( count_patties(L - 1, x - total_layers[L - 1] - 2) + 1 + total_patties[L - 1] ) N, X = list(map(int, input().split()))...
def f(L, x): if L == 0: return 0 if x <= 0 else 1 if x <= total[L - 1] + 1: return f(L - 1, x - 1) else: return patties[L - 1] + 1 + f(L - 1, x - total[L - 1] - 2) N, X = list(map(int, input().split())) total = [1] patties = [1] for i in range(50): total.append(total[-1] * 2 + ...
false
6.25
[ "-def count_patties(L, x):", "+def f(L, x):", "- if x <= total_layers[L - 1] + 1:", "- return count_patties(L - 1, x - 1)", "+ if x <= total[L - 1] + 1:", "+ return f(L - 1, x - 1)", "- return (", "- count_patties(L - 1, x - total_layers[L - 1] - 2) + 1 + total_pa...
false
0.072844
0.037901
1.921952
[ "s977776461", "s695021844" ]
u546285759
p00340
python
s926446228
s917763981
30
20
7,672
7,644
Accepted
Accepted
33.33
rec = sorted(list(map(int, input().split()))) print(("yes" if rec[0]==rec[1] and rec[2]==rec[3] else "no"))
e = sorted(map(int, input().split())) print(("yes" if e[0] == e[1] and e[2] == e[3] else "no"))
2
2
106
94
rec = sorted(list(map(int, input().split()))) print(("yes" if rec[0] == rec[1] and rec[2] == rec[3] else "no"))
e = sorted(map(int, input().split())) print(("yes" if e[0] == e[1] and e[2] == e[3] else "no"))
false
0
[ "-rec = sorted(list(map(int, input().split())))", "-print((\"yes\" if rec[0] == rec[1] and rec[2] == rec[3] else \"no\"))", "+e = sorted(map(int, input().split()))", "+print((\"yes\" if e[0] == e[1] and e[2] == e[3] else \"no\"))" ]
false
0.04924
0.11901
0.413746
[ "s926446228", "s917763981" ]
u172748267
p03434
python
s201105037
s091293110
32
27
9,080
9,112
Accepted
Accepted
15.62
n=int(eval(input())) a=[int(i)for i in input().split()] a.sort() alice=0 bob=0 for i in range(n): if i%2==0: alice+=a.pop(-1) else: bob+=a.pop(-1) print((alice-bob))
n=int(eval(input())) a=sorted([int(i)for i in input().split()]) res=0 for i in range(n): tmp=a.pop(-1) if i%2==0: res+=tmp else: res-=tmp print(res)
11
10
191
179
n = int(eval(input())) a = [int(i) for i in input().split()] a.sort() alice = 0 bob = 0 for i in range(n): if i % 2 == 0: alice += a.pop(-1) else: bob += a.pop(-1) print((alice - bob))
n = int(eval(input())) a = sorted([int(i) for i in input().split()]) res = 0 for i in range(n): tmp = a.pop(-1) if i % 2 == 0: res += tmp else: res -= tmp print(res)
false
9.090909
[ "-a = [int(i) for i in input().split()]", "-a.sort()", "-alice = 0", "-bob = 0", "+a = sorted([int(i) for i in input().split()])", "+res = 0", "+ tmp = a.pop(-1)", "- alice += a.pop(-1)", "+ res += tmp", "- bob += a.pop(-1)", "-print((alice - bob))", "+ res -= tm...
false
0.086552
0.046852
1.847335
[ "s201105037", "s091293110" ]
u185034753
p03731
python
s583161288
s377401629
129
119
25,836
25,200
Accepted
Accepted
7.75
def solve(): [N, T] = [int(x) for x in input().split()] ts = [int(x) for x in input().split()] import collections stack = collections.deque() for t in ts: if not stack: stack.append((t, t+T)) continue last = stack.pop() if last[1] >= t:...
def solve(): [N, T] = [int(x) for x in input().split()] ts = [int(x) for x in input().split()] return sum([ min(T, t2-t1) for t2, t1 in zip(ts[1:], ts[:-1]) ]) + T def main(): print((solve())) if __name__ == '__main__': main()
32
15
611
275
def solve(): [N, T] = [int(x) for x in input().split()] ts = [int(x) for x in input().split()] import collections stack = collections.deque() for t in ts: if not stack: stack.append((t, t + T)) continue last = stack.pop() if last[1] >= t: ...
def solve(): [N, T] = [int(x) for x in input().split()] ts = [int(x) for x in input().split()] return sum([min(T, t2 - t1) for t2, t1 in zip(ts[1:], ts[:-1])]) + T def main(): print((solve())) if __name__ == "__main__": main()
false
53.125
[ "- import collections", "-", "- stack = collections.deque()", "- for t in ts:", "- if not stack:", "- stack.append((t, t + T))", "- continue", "- last = stack.pop()", "- if last[1] >= t:", "- stack.append((last[0], t + T))", "- ...
false
0.069515
0.054703
1.270781
[ "s583161288", "s377401629" ]
u761320129
p04006
python
s305446853
s399267584
784
319
3,188
42,220
Accepted
Accepted
59.31
N,X = list(map(int,input().split())) src = list(map(int,input().split())) dp = src[:] ans = float('inf') for n in range(N): for m in range(N): if dp[m] > src[m-n]: dp[m] = src[m-n] ans = min(ans, sum(dp)+n*X) print(ans)
N,X = list(map(int,input().split())) A = list(map(int,input().split())) ans = sum(A) costs = A[:] for i in range(1,N): cost = i*X if cost >= ans: break for j in range(N): costs[j] = min(costs[j], A[(j-i)%N]) cost += costs[j] ans = min(ans, cost) print(ans)
10
14
248
297
N, X = list(map(int, input().split())) src = list(map(int, input().split())) dp = src[:] ans = float("inf") for n in range(N): for m in range(N): if dp[m] > src[m - n]: dp[m] = src[m - n] ans = min(ans, sum(dp) + n * X) print(ans)
N, X = list(map(int, input().split())) A = list(map(int, input().split())) ans = sum(A) costs = A[:] for i in range(1, N): cost = i * X if cost >= ans: break for j in range(N): costs[j] = min(costs[j], A[(j - i) % N]) cost += costs[j] ans = min(ans, cost) print(ans)
false
28.571429
[ "-src = list(map(int, input().split()))", "-dp = src[:]", "-ans = float(\"inf\")", "-for n in range(N):", "- for m in range(N):", "- if dp[m] > src[m - n]:", "- dp[m] = src[m - n]", "- ans = min(ans, sum(dp) + n * X)", "+A = list(map(int, input().split()))", "+ans = sum(A)"...
false
0.033498
0.035529
0.942852
[ "s305446853", "s399267584" ]
u884087839
p02954
python
s849219837
s759889753
632
359
39,932
28,156
Accepted
Accepted
43.2
#!/usr/bin/env python3 import sys from math import log2 ROUND = 10 ** 5 LOG = 33#int(log2(ROUND)) def main(): S = eval(input()) N = len(S) to = [] for _ in range(LOG): l = [0] * N to.append(l) for i in range(N): to[0][i] = i + 1 if S[i] == "R" else i - ...
#!/usr/bin/env python3 import sys from math import log2 ROUND = 10 ** 5 LOG = 18#int(log2(ROUND)) def test(): print((len(format(ROUND, "b")))) def main(): #test() #return S = eval(input()) #S = "R" * (10 ** 5 - 1) + "L" N = len(S) to = [] for _ in range(LOG): ...
40
41
764
736
#!/usr/bin/env python3 import sys from math import log2 ROUND = 10**5 LOG = 33 # int(log2(ROUND)) def main(): S = eval(input()) N = len(S) to = [] for _ in range(LOG): l = [0] * N to.append(l) for i in range(N): to[0][i] = i + 1 if S[i] == "R" else i - 1 for i in rang...
#!/usr/bin/env python3 import sys from math import log2 ROUND = 10**5 LOG = 18 # int(log2(ROUND)) def test(): print((len(format(ROUND, "b")))) def main(): # test() # return S = eval(input()) # S = "R" * (10 ** 5 - 1) + "L" N = len(S) to = [] for _ in range(LOG): l = [0] * N...
false
2.439024
[ "-LOG = 33 # int(log2(ROUND))", "+LOG = 18 # int(log2(ROUND))", "+", "+", "+def test():", "+ print((len(format(ROUND, \"b\"))))", "+ # test()", "+ # return", "+ # S = \"R\" * (10 ** 5 - 1) + \"L\"", "- a = []", "- for i in range(LOG):", "- if ROUND >> i & 1:", "- ...
false
0.036743
0.036537
1.005661
[ "s849219837", "s759889753" ]
u170201762
p03732
python
s998781914
s485041530
538
482
21,500
28,244
Accepted
Accepted
10.41
N,W = list(map(int,input().split())) l0=[] l1=[] l2=[] l3=[] for i in range(N): w,v = list(map(int,input().split())) if i == 0: w1 = w if w == w1: l0.append(v) elif w == w1+1: l1.append(v) elif w == w1+2: l2.append(v) elif w == w1+3: l3.app...
from collections import defaultdict N,W = list(map(int,input().split())) wv = [list(map(int,input().split())) for _ in range(N)] w1 = wv[0][0] ws = [] ijkl = [0,0,0,0] for i in range(N): w = wv[i][0] ijkl[w-w1] += 1 for i in range(ijkl[0]+1): for j in range(ijkl[1]+1): for k in range(ijkl...
46
25
928
719
N, W = list(map(int, input().split())) l0 = [] l1 = [] l2 = [] l3 = [] for i in range(N): w, v = list(map(int, input().split())) if i == 0: w1 = w if w == w1: l0.append(v) elif w == w1 + 1: l1.append(v) elif w == w1 + 2: l2.append(v) elif w == w1 + 3: l3.a...
from collections import defaultdict N, W = list(map(int, input().split())) wv = [list(map(int, input().split())) for _ in range(N)] w1 = wv[0][0] ws = [] ijkl = [0, 0, 0, 0] for i in range(N): w = wv[i][0] ijkl[w - w1] += 1 for i in range(ijkl[0] + 1): for j in range(ijkl[1] + 1): for k in range(ij...
false
45.652174
[ "+from collections import defaultdict", "+", "-l0 = []", "-l1 = []", "-l2 = []", "-l3 = []", "+wv = [list(map(int, input().split())) for _ in range(N)]", "+w1 = wv[0][0]", "+ws = []", "+ijkl = [0, 0, 0, 0]", "- w, v = list(map(int, input().split()))", "- if i == 0:", "- w1 = w",...
false
0.443062
0.049437
8.962206
[ "s998781914", "s485041530" ]
u883621917
p03044
python
s958614863
s412030603
743
239
90,320
94,016
Accepted
Accepted
67.83
import sys sys.setrecursionlimit(10**6) n = int(eval(input())) edges = [[int(i) for i in input().split()] for _ in range(n - 1)] BLACK = 1 WHITE = 0 UNKNOWN = -1 import sys if n == 1: print(BLACK) sys.exit(0) colors = [UNKNOWN] * (n + 1) graph = [[] for _ in range(n + 1)] for e in edges: ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n = int(eval(input())) graph = [0] + [[] for _ in range(n)] for _ in range(n - 1): u, v, w = list(map(int, input().split())) graph[u].append((v, w)) graph[v].append((u, w)) def dfs(graph, queue, color): is_bigraph = True ...
37
36
885
898
import sys sys.setrecursionlimit(10**6) n = int(eval(input())) edges = [[int(i) for i in input().split()] for _ in range(n - 1)] BLACK = 1 WHITE = 0 UNKNOWN = -1 import sys if n == 1: print(BLACK) sys.exit(0) colors = [UNKNOWN] * (n + 1) graph = [[] for _ in range(n + 1)] for e in edges: graph[e[0]].appen...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n = int(eval(input())) graph = [0] + [[] for _ in range(n)] for _ in range(n - 1): u, v, w = list(map(int, input().split())) graph[u].append((v, w)) graph[v].append((u, w)) def dfs(graph, queue, color): is_bigraph = True while que...
false
2.702703
[ "-sys.setrecursionlimit(10**6)", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**7)", "-edges = [[int(i) for i in input().split()] for _ in range(n - 1)]", "-BLACK = 1", "-WHITE = 0", "-UNKNOWN = -1", "-import sys", "-", "-if n == 1:", "- print(BLACK)", "- sys.exit(0)", "-co...
false
0.03817
0.044263
0.862342
[ "s958614863", "s412030603" ]
u550061714
p03003
python
s205847751
s955514025
354
264
73,436
16,460
Accepted
Accepted
25.42
N, M = list(map(int, input().split())) S = tuple(map(int, input().split())) T = tuple(map(int, input().split())) MOD = 10 ** 9 + 7 dp = [[1] * (M + 1) for _ in range(N + 1)] for i in range(N): for j in range(M): dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] if S[i] != T[j]: d...
import numpy as np N, M = list(map(int, input().split())) S = np.array(list(map(int, input().split()))) T = np.array(list(map(int, input().split()))) MOD = 10 ** 9 + 7 neq = (S[:, None] != T[None, :]) dp = np.ones(M + 1, dtype=np.int64) for i in range(N): new_dp = dp.copy() new_dp[1:] -= dp[:-1] * ...
13
15
392
393
N, M = list(map(int, input().split())) S = tuple(map(int, input().split())) T = tuple(map(int, input().split())) MOD = 10**9 + 7 dp = [[1] * (M + 1) for _ in range(N + 1)] for i in range(N): for j in range(M): dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] if S[i] != T[j]: dp[i + 1][j + ...
import numpy as np N, M = list(map(int, input().split())) S = np.array(list(map(int, input().split()))) T = np.array(list(map(int, input().split()))) MOD = 10**9 + 7 neq = S[:, None] != T[None, :] dp = np.ones(M + 1, dtype=np.int64) for i in range(N): new_dp = dp.copy() new_dp[1:] -= dp[:-1] * neq[i] np.cu...
false
13.333333
[ "+import numpy as np", "+", "-S = tuple(map(int, input().split()))", "-T = tuple(map(int, input().split()))", "+S = np.array(list(map(int, input().split())))", "+T = np.array(list(map(int, input().split())))", "-dp = [[1] * (M + 1) for _ in range(N + 1)]", "+neq = S[:, None] != T[None, :]", "+dp = n...
false
0.073498
0.426474
0.172339
[ "s205847751", "s955514025" ]
u606045429
p03297
python
s154514849
s617953938
20
18
3,064
3,188
Accepted
Accepted
10
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c ...
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T, *L = list(map(int, open(0).read().split())) for a, b, c, d in zip(*[iter(L)] * 4): if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c i...
20
19
376
376
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T = int(eval(input())) for _ in range(T): a, b, c, d = list(map(int, input().split())) if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c if flag: ...
def gcd(a, b): return a if b == 0 else gcd(b, a % b) T, *L = list(map(int, open(0).read().split())) for a, b, c, d in zip(*[iter(L)] * 4): if a < b or d < b: flag = False elif c >= b - 1: flag = True else: g = gcd(b, d) flag = (b + a % g - g) <= c if flag: p...
false
5
[ "-T = int(eval(input()))", "-for _ in range(T):", "- a, b, c, d = list(map(int, input().split()))", "+T, *L = list(map(int, open(0).read().split()))", "+for a, b, c, d in zip(*[iter(L)] * 4):" ]
false
0.036388
0.041117
0.884986
[ "s154514849", "s617953938" ]
u054514819
p02912
python
s849954841
s537245444
265
148
98,164
90,908
Accepted
Accepted
44.15
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M = mapint() As = list(mapint()) Q = [] from heapq import heappop, heappush for a in As: heappush(Q, -a) for i in range(M): v = heappop(Q) heappush(Q...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M = mapint() As = list(mapint()) from heapq import heappush, heappop Q = [] for a in As: heappush(Q, -a) for i in range(M): a = -heappop(Q) heapp...
16
18
365
347
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M = mapint() As = list(mapint()) Q = [] from heapq import heappop, heappush for a in As: heappush(Q, -a) for i in range(M): v = heappop(Q) heappush(...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N, M = mapint() As = list(mapint()) from heapq import heappush, heappop Q = [] for a in As: heappush(Q, -a) for i in range(M): a = -heappop(Q) heappush...
false
11.111111
[ "+from heapq import heappush, heappop", "+", "-from heapq import heappop, heappush", "-", "- v = heappop(Q)", "- heappush(Q, v / 2)", "-lis = [-int(x) for x in Q]", "-print((sum(lis)))", "+ a = -heappop(Q)", "+ heappush(Q, -(a // 2))", "+print((-sum(Q)))" ]
false
0.03643
0.048582
0.749867
[ "s849954841", "s537245444" ]
u124498235
p03408
python
s866249607
s261859844
21
18
3,316
3,064
Accepted
Accepted
14.29
from collections import Counter n = int(eval(input())) s = [eval(input()) for _ in range(n)] m = int(eval(input())) t = [eval(input()) for _ in range(m)] a = Counter(s) b = Counter(t) a.subtract(b) print((max(0,a.most_common(1)[0][1])))
n = int(eval(input())) s = [eval(input()) for i in range(n)] m = int(eval(input())) t = [eval(input()) for i in range(m)] dics = {} for i in s: if i in dics: dics[i] += 1 else: dics[i] = 1 dict = {} for j in t: if j in dict: dict[j] += 1 else: dict[j] = 1 ans = 0 for i in list(dics.keys()):...
11
23
224
389
from collections import Counter n = int(eval(input())) s = [eval(input()) for _ in range(n)] m = int(eval(input())) t = [eval(input()) for _ in range(m)] a = Counter(s) b = Counter(t) a.subtract(b) print((max(0, a.most_common(1)[0][1])))
n = int(eval(input())) s = [eval(input()) for i in range(n)] m = int(eval(input())) t = [eval(input()) for i in range(m)] dics = {} for i in s: if i in dics: dics[i] += 1 else: dics[i] = 1 dict = {} for j in t: if j in dict: dict[j] += 1 else: dict[j] = 1 ans = 0 for i in...
false
52.173913
[ "-from collections import Counter", "-", "-s = [eval(input()) for _ in range(n)]", "+s = [eval(input()) for i in range(n)]", "-t = [eval(input()) for _ in range(m)]", "-a = Counter(s)", "-b = Counter(t)", "-a.subtract(b)", "-print((max(0, a.most_common(1)[0][1])))", "+t = [eval(input()) for i in r...
false
0.044893
0.043214
1.038857
[ "s866249607", "s261859844" ]
u672220554
p03274
python
s716771161
s182346351
830
86
14,252
14,392
Accepted
Accepted
89.64
n,k = list(map(int,input().split())) x = list(map(int,input().split())) kx = x[0:k] l=kx[0] r = kx[-1] lrsmall = min(abs(l),abs(r)) res = r-l+lrsmall for i in range(1,n-k+1): del kx[0] kx.append(x[i+k-1]) l=kx[0] r = kx[-1] lrsmall = min(abs(l),abs(r)) res = min(r-l+lrsmall,res) pr...
n,k = list(map(int,input().split())) x = list(map(int,input().split())) res = 10**10 for i in range(0,n-k+1): l = x[i] r = x[i+k-1] lrsmall = min(abs(l),abs(r)) res = min(r-l+lrsmall,res) print(res)
15
9
322
216
n, k = list(map(int, input().split())) x = list(map(int, input().split())) kx = x[0:k] l = kx[0] r = kx[-1] lrsmall = min(abs(l), abs(r)) res = r - l + lrsmall for i in range(1, n - k + 1): del kx[0] kx.append(x[i + k - 1]) l = kx[0] r = kx[-1] lrsmall = min(abs(l), abs(r)) res = min(r - l + lrs...
n, k = list(map(int, input().split())) x = list(map(int, input().split())) res = 10**10 for i in range(0, n - k + 1): l = x[i] r = x[i + k - 1] lrsmall = min(abs(l), abs(r)) res = min(r - l + lrsmall, res) print(res)
false
40
[ "-kx = x[0:k]", "-l = kx[0]", "-r = kx[-1]", "-lrsmall = min(abs(l), abs(r))", "-res = r - l + lrsmall", "-for i in range(1, n - k + 1):", "- del kx[0]", "- kx.append(x[i + k - 1])", "- l = kx[0]", "- r = kx[-1]", "+res = 10**10", "+for i in range(0, n - k + 1):", "+ l = x[i]"...
false
0.047268
0.038446
1.229465
[ "s716771161", "s182346351" ]
u072949274
p02552
python
s050211199
s117103516
92
63
61,552
61,788
Accepted
Accepted
31.52
n = int(eval(input())) if n == 0: print((1)) elif n == 1: print((0))
n = int(eval(input())) print((0 if n == 1 else 1))
6
3
73
46
n = int(eval(input())) if n == 0: print((1)) elif n == 1: print((0))
n = int(eval(input())) print((0 if n == 1 else 1))
false
50
[ "-if n == 0:", "- print((1))", "-elif n == 1:", "- print((0))", "+print((0 if n == 1 else 1))" ]
false
0.04405
0.044502
0.989841
[ "s050211199", "s117103516" ]
u562935282
p03040
python
s838134379
s658947051
1,704
856
11,184
11,284
Accepted
Accepted
49.77
from heapq import heappush, heappop Q = int(eval(input())) update_count = 0 al = [] sl = 0 ar = [] sr = 0 b = 0 for _ in range(Q): # print(f'al:{al}, sl:{sl}') # print(f'ar:{ar},sr:{sr}') # print(f'b:{b}') # print() s = tuple(map(int, input().split())) if s[0] == 1: # ...
from heapq import heappush, heappop import sys input = sys.stdin.readline Q = int(eval(input())) update_count = 0 al = [] sl = 0 ar = [] sr = 0 b = 0 for _ in range(Q): # print(f'al:{al}, sl:{sl}') # print(f'ar:{ar},sr:{sr}') # print(f'b:{b}') # print() s = tuple(map(int, input(...
46
49
1,160
1,202
from heapq import heappush, heappop Q = int(eval(input())) update_count = 0 al = [] sl = 0 ar = [] sr = 0 b = 0 for _ in range(Q): # print(f'al:{al}, sl:{sl}') # print(f'ar:{ar},sr:{sr}') # print(f'b:{b}') # print() s = tuple(map(int, input().split())) if s[0] == 1: # 更新クエリ b +=...
from heapq import heappush, heappop import sys input = sys.stdin.readline Q = int(eval(input())) update_count = 0 al = [] sl = 0 ar = [] sr = 0 b = 0 for _ in range(Q): # print(f'al:{al}, sl:{sl}') # print(f'ar:{ar},sr:{sr}') # print(f'b:{b}') # print() s = tuple(map(int, input().split())) if s...
false
6.122449
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.038948
0.038014
1.024585
[ "s838134379", "s658947051" ]
u926412290
p02954
python
s542262305
s392047509
380
158
101,252
92,036
Accepted
Accepted
58.42
S = input() T = S.replace("RL", "$$") devided_S = [] ans = [-1 if T[i] == "$" else 0 for i in range(len(S))] while True: index = S.find("LR") if index == -1: devided_S.append(S) break devided_S.append(S[:index+1]) S = S[index+1:] more_than_0 = [] for block in devided_S: ...
import re S = input() T = S.replace("RL", "$$") devided_S = re.findall("R+L+", S) ans = [-1 if T[i] == "$" else 0 for i in range(len(S))] more_than_0 = [] for block in devided_S: count = len(block) r = block.count("R") l = count - r if count % 2 == 0: for _ in range(2): ...
35
32
889
778
S = input() T = S.replace("RL", "$$") devided_S = [] ans = [-1 if T[i] == "$" else 0 for i in range(len(S))] while True: index = S.find("LR") if index == -1: devided_S.append(S) break devided_S.append(S[: index + 1]) S = S[index + 1 :] more_than_0 = [] for block in devided_S: r, l = ...
import re S = input() T = S.replace("RL", "$$") devided_S = re.findall("R+L+", S) ans = [-1 if T[i] == "$" else 0 for i in range(len(S))] more_than_0 = [] for block in devided_S: count = len(block) r = block.count("R") l = count - r if count % 2 == 0: for _ in range(2): more_than_0....
false
8.571429
[ "+import re", "+", "-devided_S = []", "+devided_S = re.findall(\"R+L+\", S)", "-while True:", "- index = S.find(\"LR\")", "- if index == -1:", "- devided_S.append(S)", "- break", "- devided_S.append(S[: index + 1])", "- S = S[index + 1 :]", "- r, l = block.count(\"...
false
0.035564
0.040135
0.8861
[ "s542262305", "s392047509" ]
u973013625
p03416
python
s177642933
s859708304
62
41
2,940
3,060
Accepted
Accepted
33.87
a, b = list(map(int, input().split())) x = 0 for i in range(a, b+1): if str(i)==str(i)[::-1]: x+=1 print(x)
a,b=list(map(int,input().split())) print((len([i for i in map(str, list(range(a, b+1))) if i==i[::-1]])))
8
2
122
92
a, b = list(map(int, input().split())) x = 0 for i in range(a, b + 1): if str(i) == str(i)[::-1]: x += 1 print(x)
a, b = list(map(int, input().split())) print((len([i for i in map(str, list(range(a, b + 1))) if i == i[::-1]])))
false
75
[ "-x = 0", "-for i in range(a, b + 1):", "- if str(i) == str(i)[::-1]:", "- x += 1", "-print(x)", "+print((len([i for i in map(str, list(range(a, b + 1))) if i == i[::-1]])))" ]
false
0.04937
0.111376
0.44327
[ "s177642933", "s859708304" ]
u600402037
p03208
python
s492878497
s772980196
359
310
17,528
20,572
Accepted
Accepted
13.65
import numpy as np N, K = list(map(int, input().split())) H = np.array(sorted([int(eval(input())) for _ in range(N)])) diff = H[K-1:] - H[:-K+1] print((diff.min()))
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() H = np.array([ir() for _ in range(N)]) H.sort() Hdiff = H[K-1:] - H[:-(K-1)] answer = Hdiff.min() print(answer)
8
14
161
293
import numpy as np N, K = list(map(int, input().split())) H = np.array(sorted([int(eval(input())) for _ in range(N)])) diff = H[K - 1 :] - H[: -K + 1] print((diff.min()))
# coding: utf-8 import sys import numpy as np sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() H = np.array([ir() for _ in range(N)]) H.sort() Hdiff = H[K - 1 :] - H[: -(K - 1)] answer = Hdiff.min() print(answer)
false
42.857143
[ "+# coding: utf-8", "+import sys", "-N, K = list(map(int, input().split()))", "-H = np.array(sorted([int(eval(input())) for _ in range(N)]))", "-diff = H[K - 1 :] - H[: -K + 1]", "-print((diff.min()))", "+sr = lambda: sys.stdin.readline().rstrip()", "+ir = lambda: int(sr())", "+lr = lambda: list(map...
false
0.292831
0.31074
0.942367
[ "s492878497", "s772980196" ]
u148423304
p03338
python
s978092967
s443077466
41
19
3,956
3,064
Accepted
Accepted
53.66
n = int(eval(input())) s = list(eval(input())) import copy M = 0 for i in range(n): count = 0 l1 = copy.copy(s[0 : i + 1]) l2 = copy.copy(s[i + 1 : n]) l1 = list(set(l1)) l2 = list(set(l2)) for j in range(len(l1)): if l1[j] in l2: count += 1 if count > M: ...
n = int(eval(input())) s = eval(input()) l = list(s) m = 0 for i in range(n - 1): l1 = l[:i+1] l2 = l[i+1:] l1 = list(set(l1)) l2 = list(set(l2)) l1.sort() l2.sort() x = 0 for j in range(len(l1)): if l1[j] in l2: x += 1 if x > m: m = x pri...
16
18
338
314
n = int(eval(input())) s = list(eval(input())) import copy M = 0 for i in range(n): count = 0 l1 = copy.copy(s[0 : i + 1]) l2 = copy.copy(s[i + 1 : n]) l1 = list(set(l1)) l2 = list(set(l2)) for j in range(len(l1)): if l1[j] in l2: count += 1 if count > M: M = cou...
n = int(eval(input())) s = eval(input()) l = list(s) m = 0 for i in range(n - 1): l1 = l[: i + 1] l2 = l[i + 1 :] l1 = list(set(l1)) l2 = list(set(l2)) l1.sort() l2.sort() x = 0 for j in range(len(l1)): if l1[j] in l2: x += 1 if x > m: m = x print(m)
false
11.111111
[ "-s = list(eval(input()))", "-import copy", "-", "-M = 0", "-for i in range(n):", "- count = 0", "- l1 = copy.copy(s[0 : i + 1])", "- l2 = copy.copy(s[i + 1 : n])", "+s = eval(input())", "+l = list(s)", "+m = 0", "+for i in range(n - 1):", "+ l1 = l[: i + 1]", "+ l2 = l[i + ...
false
0.109508
0.078261
1.399264
[ "s978092967", "s443077466" ]
u690037900
p02947
python
s767509866
s427110293
609
295
73,048
28,720
Accepted
Accepted
51.56
n = int(eval(input())) s = [eval(input()) for _ in range(n)] for i in range(n): s[i] = ''.join(sorted(s[i])) t = {} for i in range(n): if s[i] in t: t[s[i]] += 1 else: t[s[i]] = 1 print((sum(t[k] * (t[k] -1) // 2 for k in t)))
import collections N=int(eval(input())) s=[str(sorted(eval(input()))) for i in range(N)] c=collections.Counter(s) print((sum((v*(v-1))//2 for v in list(c.values()))))
11
5
237
150
n = int(eval(input())) s = [eval(input()) for _ in range(n)] for i in range(n): s[i] = "".join(sorted(s[i])) t = {} for i in range(n): if s[i] in t: t[s[i]] += 1 else: t[s[i]] = 1 print((sum(t[k] * (t[k] - 1) // 2 for k in t)))
import collections N = int(eval(input())) s = [str(sorted(eval(input()))) for i in range(N)] c = collections.Counter(s) print((sum((v * (v - 1)) // 2 for v in list(c.values()))))
false
54.545455
[ "-n = int(eval(input()))", "-s = [eval(input()) for _ in range(n)]", "-for i in range(n):", "- s[i] = \"\".join(sorted(s[i]))", "-t = {}", "-for i in range(n):", "- if s[i] in t:", "- t[s[i]] += 1", "- else:", "- t[s[i]] = 1", "-print((sum(t[k] * (t[k] - 1) // 2 for k in t...
false
0.038316
0.056665
0.676184
[ "s767509866", "s427110293" ]
u452512115
p02732
python
s411520843
s592198837
1,049
680
26,896
106,444
Accepted
Accepted
35.18
from operator import mul from functools import reduce def ncr(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1,r + 1))) return over // under a = int(eval(input())) A = list(map(int, input().split())) d = {} for k...
from operator import mul from functools import reduce def ncr(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1,r + 1))) return over // under a = int(eval(input())) A = list(map(int, input().split())) d = {} for k...
35
35
596
599
from operator import mul from functools import reduce def ncr(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under a = int(eval(input())) A = list(map(int, input().split())) d = {} for k...
from operator import mul from functools import reduce def ncr(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under a = int(eval(input())) A = list(map(int, input().split())) d = {} for k...
false
0
[ "-for k in d:", "- if d[k] >= 2:", "- res += ncr(d[k], 2)", "+for k in list(d.values()):", "+ if k >= 2:", "+ res += ncr(k, 2)", "- d[k] -= 1", "+ d[k] -= 1" ]
false
0.036718
0.043225
0.849479
[ "s411520843", "s592198837" ]
u814986259
p03733
python
s663302958
s813704576
114
89
25,708
30,796
Accepted
Accepted
21.93
N,T = list(map(int, input().split())) prev = 0 ans = 0 tt = list(map(int, input().split())) for t in tt: if prev+T <= t: ans += T else: ans += (t - prev) prev = t print((ans + T))
N, T = list(map(int, input().split())) t = list(map(int, input().split())) ans = 0 end = -1 start = -1 for x in t: if end < x: ans += (end - start) start = x end = x + T else: end = x + T ans += (end - start) print(ans)
13
17
204
273
N, T = list(map(int, input().split())) prev = 0 ans = 0 tt = list(map(int, input().split())) for t in tt: if prev + T <= t: ans += T else: ans += t - prev prev = t print((ans + T))
N, T = list(map(int, input().split())) t = list(map(int, input().split())) ans = 0 end = -1 start = -1 for x in t: if end < x: ans += end - start start = x end = x + T else: end = x + T ans += end - start print(ans)
false
23.529412
[ "-prev = 0", "+t = list(map(int, input().split()))", "-tt = list(map(int, input().split()))", "-for t in tt:", "- if prev + T <= t:", "- ans += T", "+end = -1", "+start = -1", "+for x in t:", "+ if end < x:", "+ ans += end - start", "+ start = x", "+ end = x...
false
0.093076
0.044673
2.083511
[ "s663302958", "s813704576" ]
u422104747
p02918
python
s332033803
s306998347
202
183
46,064
40,048
Accepted
Accepted
9.41
n,k=list(map(int,input().split())) s="R"+eval(input())+"L" now="X" l=[] le=None for i in range(n+2): if now!=s[i]: l.append(le) now=s[i] le=1 else: le+=1 l.append(le) l=l[1:] nn=len(l) lr=[] ll=[] su=0 for i in range(0,nn,2): lr.append(l[i]) su+=l[i]-1...
n,k=list(map(int,input().split())) s=eval(input()) rl=s.count("RL") lr=s.count("LR") cnt=0 for i in range(n): if (i>0 and s[i]=="L" and s[i-1]=="L") or (i<n-1 and s[i]=="R" and s[i+1]=="R"): cnt+=1 for i in range(k): if min(rl,lr)>0: cnt+=2 rl-=1 lr-=1 elif rl>0:...
33
22
502
424
n, k = list(map(int, input().split())) s = "R" + eval(input()) + "L" now = "X" l = [] le = None for i in range(n + 2): if now != s[i]: l.append(le) now = s[i] le = 1 else: le += 1 l.append(le) l = l[1:] nn = len(l) lr = [] ll = [] su = 0 for i in range(0, nn, 2): lr.append(l[...
n, k = list(map(int, input().split())) s = eval(input()) rl = s.count("RL") lr = s.count("LR") cnt = 0 for i in range(n): if (i > 0 and s[i] == "L" and s[i - 1] == "L") or ( i < n - 1 and s[i] == "R" and s[i + 1] == "R" ): cnt += 1 for i in range(k): if min(rl, lr) > 0: cnt += 2 ...
false
33.333333
[ "-s = \"R\" + eval(input()) + \"L\"", "-now = \"X\"", "-l = []", "-le = None", "-for i in range(n + 2):", "- if now != s[i]:", "- l.append(le)", "- now = s[i]", "- le = 1", "+s = eval(input())", "+rl = s.count(\"RL\")", "+lr = s.count(\"LR\")", "+cnt = 0", "+for i i...
false
0.045117
0.048862
0.92337
[ "s332033803", "s306998347" ]
u230621983
p03208
python
s601944128
s574881084
240
116
7,384
14,092
Accepted
Accepted
51.67
n, k = list(map(int, input().split())) height = [int(eval(input())) for _ in range(n)] height.sort() ans = height[-1] for i in range(n-k+1): ans = min(ans, height[i+k-1]-height[i]) print(ans)
n, k, *height = list(map(int, open(0).read().split())) height.sort() ans = height[-1] for i in range(n-k+1): ans = min(ans, height[i+k-1]-height[i]) print(ans)
7
6
189
162
n, k = list(map(int, input().split())) height = [int(eval(input())) for _ in range(n)] height.sort() ans = height[-1] for i in range(n - k + 1): ans = min(ans, height[i + k - 1] - height[i]) print(ans)
n, k, *height = list(map(int, open(0).read().split())) height.sort() ans = height[-1] for i in range(n - k + 1): ans = min(ans, height[i + k - 1] - height[i]) print(ans)
false
14.285714
[ "-n, k = list(map(int, input().split()))", "-height = [int(eval(input())) for _ in range(n)]", "+n, k, *height = list(map(int, open(0).read().split()))" ]
false
0.064091
0.063116
1.015439
[ "s601944128", "s574881084" ]
u596276291
p03816
python
s014731908
s057596639
81
47
20,188
14,948
Accepted
Accepted
41.98
from collections import defaultdict def main(): n = int(eval(input())) card_list = list(map(int, input().split())) ans = len(set(card_list)) d = defaultdict(int) for card in card_list: d[card] += 1 one, two = 0, 0 for card, num in list(d.items()): if num %...
from collections import defaultdict def main(): n = int(eval(input())) a_list = list(map(int, input().split())) s = len(set(a_list)) if (len(a_list) - s) % 2 != 0: print((s - 1)) else: print(s) if __name__ == '__main__': main()
25
15
448
278
from collections import defaultdict def main(): n = int(eval(input())) card_list = list(map(int, input().split())) ans = len(set(card_list)) d = defaultdict(int) for card in card_list: d[card] += 1 one, two = 0, 0 for card, num in list(d.items()): if num % 2 == 1: ...
from collections import defaultdict def main(): n = int(eval(input())) a_list = list(map(int, input().split())) s = len(set(a_list)) if (len(a_list) - s) % 2 != 0: print((s - 1)) else: print(s) if __name__ == "__main__": main()
false
40
[ "- card_list = list(map(int, input().split()))", "- ans = len(set(card_list))", "- d = defaultdict(int)", "- for card in card_list:", "- d[card] += 1", "- one, two = 0, 0", "- for card, num in list(d.items()):", "- if num % 2 == 1:", "- one += 1", "- ...
false
0.037567
0.044957
0.835617
[ "s014731908", "s057596639" ]
u352394527
p00067
python
s372930552
s442033793
30
20
5,624
5,576
Accepted
Accepted
33.33
while True: lst = [] for i in range(12): ls = [] s = eval(input()) for j in range(12): ls.append(int(s[j])) lst.append(ls) xd = [0,1,0,-1] yd = [1,0,-1,0] count = 0 def check(pt): if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0: return False elif(lst[p...
direct = ((0, -1), (0, 1), (-1, 0), (1, 0)) #移動方向 def search(x, y, mp): if mp[x][y] == "1": #1を見つけたら0に書き換える mp[x][y] = "0" for dx, dy in direct: #4方向について繰り返す search(x + dx, y + dy, mp) while True: #mp...全体のマップ、上下左右を0で囲っておく mp = [list("0" + eval(input()) + "0") for _ in range(12)] mp...
39
28
831
569
while True: lst = [] for i in range(12): ls = [] s = eval(input()) for j in range(12): ls.append(int(s[j])) lst.append(ls) xd = [0, 1, 0, -1] yd = [1, 0, -1, 0] count = 0 def check(pt): if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0: ...
direct = ((0, -1), (0, 1), (-1, 0), (1, 0)) # 移動方向 def search(x, y, mp): if mp[x][y] == "1": # 1を見つけたら0に書き換える mp[x][y] = "0" for dx, dy in direct: # 4方向について繰り返す search(x + dx, y + dy, mp) while True: # mp...全体のマップ、上下左右を0で囲っておく mp = [list("0" + eval(input()) + "0") for _ in...
false
28.205128
[ "+direct = ((0, -1), (0, 1), (-1, 0), (1, 0)) # 移動方向", "+", "+", "+def search(x, y, mp):", "+ if mp[x][y] == \"1\": # 1を見つけたら0に書き換える", "+ mp[x][y] = \"0\"", "+ for dx, dy in direct: # 4方向について繰り返す", "+ search(x + dx, y + dy, mp)", "+", "+", "- lst = []", "- ...
false
0.066353
0.069062
0.960773
[ "s372930552", "s442033793" ]
u368796742
p03822
python
s289414839
s149359280
495
346
159,372
117,560
Accepted
Accepted
30.1
import sys sys.setrecursionlimit(10**5) from collections import defaultdict n = int(eval(input())) e = [[] for i in range(n)] for i in range(1,n): x = int(eval(input())) e[x-1].append(i) def dfs(x): count = len(e[x]) if count == 0: return 0 d = defaultdict(int) ma = 0 ...
import sys sys.setrecursionlimit(10**5) n = int(eval(input())) e = [[] for i in range(n)] for i in range(1,n): x = int(eval(input())) e[x-1].append(i) def dfs(x): count = len(e[x]) if count == 0: return 0 l = [] for nex in e[x]: l.append(dfs(nex)) l.sort(rev...
31
22
585
427
import sys sys.setrecursionlimit(10**5) from collections import defaultdict n = int(eval(input())) e = [[] for i in range(n)] for i in range(1, n): x = int(eval(input())) e[x - 1].append(i) def dfs(x): count = len(e[x]) if count == 0: return 0 d = defaultdict(int) ma = 0 s = set(...
import sys sys.setrecursionlimit(10**5) n = int(eval(input())) e = [[] for i in range(n)] for i in range(1, n): x = int(eval(input())) e[x - 1].append(i) def dfs(x): count = len(e[x]) if count == 0: return 0 l = [] for nex in e[x]: l.append(dfs(nex)) l.sort(reverse=True) ...
false
29.032258
[ "-from collections import defaultdict", "-", "- d = defaultdict(int)", "- ma = 0", "- s = set()", "+ l = []", "- v = dfs(nex)", "- d[v] += 1", "- s.add(v)", "- ma = max(ma, v)", "+ l.append(dfs(nex))", "+ l.sort(reverse=True)", "- bef = 0"...
false
0.063669
0.091955
0.692391
[ "s289414839", "s149359280" ]
u708217907
p00121
python
s332254415
s427559469
1,580
120
5,884
6,076
Accepted
Accepted
92.41
def to_xyi(str, target): index = 0 for s in list(str): if target == int(s): x = index%4 if index < 4: y = 0 else: y = 1 return (x, y, index) index += 1 def zero_swap(str, mx, my): zx, zy, zi = to_xyi(str, 0) for index in range(len(list(str))): ...
MOVE = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]] answers = {"01234567": 0} def swap(field, a, b): tmp = list(field) tmp[a], tmp[b] = tmp[b], tmp[a] return "".join(tmp) def breadth_first_search(answers): q = [[0, "01234567"]] while len(q) != 0: g, field = q...
56
31
1,391
655
def to_xyi(str, target): index = 0 for s in list(str): if target == int(s): x = index % 4 if index < 4: y = 0 else: y = 1 return (x, y, index) index += 1 def zero_swap(str, mx, my): zx, zy, zi = to_xyi(str, 0) ...
MOVE = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]] answers = {"01234567": 0} def swap(field, a, b): tmp = list(field) tmp[a], tmp[b] = tmp[b], tmp[a] return "".join(tmp) def breadth_first_search(answers): q = [[0, "01234567"]] while len(q) != 0: g, field ...
false
44.642857
[ "-def to_xyi(str, target):", "- index = 0", "- for s in list(str):", "- if target == int(s):", "- x = index % 4", "- if index < 4:", "- y = 0", "- else:", "- y = 1", "- return (x, y, index)", "- index +...
false
1.680866
0.007314
229.822108
[ "s332254415", "s427559469" ]
u222668979
p03096
python
s074557381
s087792721
1,064
266
789,364
90,776
Accepted
Accepted
75
n = int(eval(input())) c = [int(eval(input())) for _ in range(n)] mod = 10 ** 9 + 7 # 解説AC dp = [1] * n color = [-1] * max(c) for i, ci in enumerate(c): dp[i] = dp[i - 1] if 0 <= color[ci - 1] < i - 1: dp[i] += dp[color[ci - 1]] color[ci - 1] = i print((dp[-1] % mod))
n = int(eval(input())) c = [int(eval(input())) for _ in range(n)] mod = 10 ** 9 + 7 # 解説AC dp = [1] * n color = [-1] * max(c) for i, ci in enumerate(c): dp[i] = dp[i - 1] if 0 <= color[ci - 1] < i - 1: dp[i] += dp[color[ci - 1]] dp[i] %= mod color[ci - 1] = i print((dp[-1]))
13
14
288
304
n = int(eval(input())) c = [int(eval(input())) for _ in range(n)] mod = 10**9 + 7 # 解説AC dp = [1] * n color = [-1] * max(c) for i, ci in enumerate(c): dp[i] = dp[i - 1] if 0 <= color[ci - 1] < i - 1: dp[i] += dp[color[ci - 1]] color[ci - 1] = i print((dp[-1] % mod))
n = int(eval(input())) c = [int(eval(input())) for _ in range(n)] mod = 10**9 + 7 # 解説AC dp = [1] * n color = [-1] * max(c) for i, ci in enumerate(c): dp[i] = dp[i - 1] if 0 <= color[ci - 1] < i - 1: dp[i] += dp[color[ci - 1]] dp[i] %= mod color[ci - 1] = i print((dp[-1]))
false
7.142857
[ "+ dp[i] %= mod", "-print((dp[-1] % mod))", "+print((dp[-1]))" ]
false
0.045528
0.044974
1.012334
[ "s074557381", "s087792721" ]
u603958124
p03006
python
s769909742
s770247514
1,091
43
10,200
10,492
Accepted
Accepted
96.06
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator i...
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator i...
35
43
1,163
1,124
from math import ( ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf, ) from itertools import ( accumulate, groupby, permutations, combinations, product, combinations_with_replacemen...
from math import ( ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf, ) from itertools import ( accumulate, groupby, permutations, combinations, product, combinations_with_replacemen...
false
18.604651
[ "-reg = 0", "+a = []", "- p = x[j][0] - x[i][0]", "- q = x[j][1] - x[i][1]", "- count = 0", "- for k in range(n):", "- for l in range(n):", "- if x[l][0] - x[k][0] == p and x[l][1] - x[k][1] == q:", "- ...
false
0.085706
0.035121
2.440324
[ "s769909742", "s770247514" ]
u285891772
p03107
python
s682376713
s354381280
35
22
3,956
3,956
Accepted
Accepted
37.14
S = list(eval(input())) count_0 = 0 count_1 = 0 for i in S: if i == "0": count_0 += 1 if i == "1": count_1 += 1 print((min(count_0, count_1)*2))
S = list(eval(input())) cnt0 = S.count("0") cnt1 = S.count("1") print((min(cnt0, cnt1) * 2))
12
6
156
93
S = list(eval(input())) count_0 = 0 count_1 = 0 for i in S: if i == "0": count_0 += 1 if i == "1": count_1 += 1 print((min(count_0, count_1) * 2))
S = list(eval(input())) cnt0 = S.count("0") cnt1 = S.count("1") print((min(cnt0, cnt1) * 2))
false
50
[ "-count_0 = 0", "-count_1 = 0", "-for i in S:", "- if i == \"0\":", "- count_0 += 1", "- if i == \"1\":", "- count_1 += 1", "-print((min(count_0, count_1) * 2))", "+cnt0 = S.count(\"0\")", "+cnt1 = S.count(\"1\")", "+print((min(cnt0, cnt1) * 2))" ]
false
0.034377
0.103236
0.332995
[ "s682376713", "s354381280" ]
u476604182
p03290
python
s940041399
s529427416
52
29
3,064
3,444
Accepted
Accepted
44.23
D, G = list(map(int, input().split())) dic = [0]*(D+1) for i in range(D): p, c = list(map(int, input().split())) dic[i+1] = (p,c) ans = 10**9 for i in range(2**D): ls = [] x = i v = 0 count = 0 for j in range(D): if x%2==1: ls += [j+1] x = x>>1 for h in ls: p, c = dic[h...
D, G, *L = list(map(int, open(0).read().split())) inf = [] for m in zip(*[iter(L)]*2): inf.append(m) ans = float('inf') for i in range(2**D): m = 0 cnt = 0 log = [] for j in range(D): if i%2==0: m += 100*(j+1)*inf[j][0]+inf[j][1] cnt += inf[j][0] else: log.append(j) ...
37
29
643
555
D, G = list(map(int, input().split())) dic = [0] * (D + 1) for i in range(D): p, c = list(map(int, input().split())) dic[i + 1] = (p, c) ans = 10**9 for i in range(2**D): ls = [] x = i v = 0 count = 0 for j in range(D): if x % 2 == 1: ls += [j + 1] x = x >> 1 ...
D, G, *L = list(map(int, open(0).read().split())) inf = [] for m in zip(*[iter(L)] * 2): inf.append(m) ans = float("inf") for i in range(2**D): m = 0 cnt = 0 log = [] for j in range(D): if i % 2 == 0: m += 100 * (j + 1) * inf[j][0] + inf[j][1] cnt += inf[j][0] ...
false
21.621622
[ "-D, G = list(map(int, input().split()))", "-dic = [0] * (D + 1)", "-for i in range(D):", "- p, c = list(map(int, input().split()))", "- dic[i + 1] = (p, c)", "-ans = 10**9", "+D, G, *L = list(map(int, open(0).read().split()))", "+inf = []", "+for m in zip(*[iter(L)] * 2):", "+ inf.append...
false
0.049169
0.083721
0.587293
[ "s940041399", "s529427416" ]
u102461423
p03162
python
s243570341
s461916847
172
155
20,192
28,132
Accepted
Accepted
9.88
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int,read().split())) ABC = list(zip(m,m,m)) x,y,z = 0,0,0 # 最後の活動 -> 幸福度のmax for a,b,c in ABC: x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c answer = max(x,...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) dp = [0, 0, 0] for a, b, c in zip(m, m, m): dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c] print((max(...
15
13
327
317
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) ABC = list(zip(m, m, m)) x, y, z = 0, 0, 0 # 最後の活動 -> 幸福度のmax for a, b, c in ABC: x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c answer ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) dp = [0, 0, 0] for a, b, c in zip(m, m, m): dp = [max(dp[1], dp[2]) + a, max(dp[0], dp[2]) + b, max(dp[0], dp[1]) + c] print((max(dp)))
false
13.333333
[ "-ABC = list(zip(m, m, m))", "-x, y, z = 0, 0, 0 # 最後の活動 -> 幸福度のmax", "-for a, b, c in ABC:", "- x, y, z = max(y, z) + a, max(x, z) + b, max(x, y) + c", "-answer = max(x, y, z)", "-print(answer)", "+dp = [0, 0, 0]", "+for a, b, c in zip(m, m, m):", "+ dp = [max(dp[1], dp[2]) + a, max(dp[0], d...
false
0.041264
0.049248
0.837873
[ "s243570341", "s461916847" ]
u659302753
p02684
python
s927743146
s575314866
211
179
37,496
37,400
Accepted
Accepted
15.17
from sys import stdin def get_result(data): N, K = data[0] A = data[1] trans_num = [0] * N curr_pos = 1 arrival_pos = set() for i in range(N): trans_num[curr_pos-1] = i arrival_pos.add(curr_pos) # see next next_pos = A[curr_pos-1] if next...
from sys import stdin def get_result(data): N, K = data[0] A = data[1] trans_num = [0] * N curr_pos = 1 arrival_pos = set() for i in range(N): trans_num[curr_pos-1] = i arrival_pos.add(curr_pos) # see next next_pos = A[curr_pos-1] if next...
41
38
1,013
978
from sys import stdin def get_result(data): N, K = data[0] A = data[1] trans_num = [0] * N curr_pos = 1 arrival_pos = set() for i in range(N): trans_num[curr_pos - 1] = i arrival_pos.add(curr_pos) # see next next_pos = A[curr_pos - 1] if next_pos in arri...
from sys import stdin def get_result(data): N, K = data[0] A = data[1] trans_num = [0] * N curr_pos = 1 arrival_pos = set() for i in range(N): trans_num[curr_pos - 1] = i arrival_pos.add(curr_pos) # see next next_pos = A[curr_pos - 1] if next_pos in arri...
false
7.317073
[ "- loop = 0", "- if (K - loop_start) > 0:", "- loop = loop_start + (K - loop_start) % loop_trans_num", "- else:", "- loop = K", "+ loop = K if (K - loop_start) < 0 else loop_start + (K - loop_start) % loop_trans_num" ]
false
0.038422
0.085361
0.450111
[ "s927743146", "s575314866" ]
u191874006
p02608
python
s682047503
s943649298
153
99
69,072
75,100
Accepted
Accepted
35.29
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
#!/usr/bin/env python3 n = int(eval(input())) ans = [0] * (n+1) m = int(n**(1/2)) + 1 for x in range(1, m): for y in range(1, m): for z in range(1, m): res = x**2 + y**2 + z**2 + x*y + y*z + z*x if res <= n: ans[res] += 1 for i in ans[1:]: print(i)
28
13
855
311
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
#!/usr/bin/env python3 n = int(eval(input())) ans = [0] * (n + 1) m = int(n ** (1 / 2)) + 1 for x in range(1, m): for y in range(1, m): for z in range(1, m): res = x**2 + y**2 + z**2 + x * y + y * z + z * x if res <= n: ans[res] += 1 for i in ans[1:]: print(i)
false
53.571429
[ "-import sys", "-import math", "-from bisect import bisect_right as br", "-from bisect import bisect_left as bl", "-", "-sys.setrecursionlimit(2147483647)", "-from heapq import heappush, heappop, heappushpop", "-from collections import defaultdict", "-from itertools import accumulate", "-from coll...
false
1.278976
0.086567
14.774337
[ "s682047503", "s943649298" ]
u426534722
p02270
python
s504437802
s104950230
280
230
9,588
16,492
Accepted
Accepted
17.86
import sys readline = sys.stdin.readline N, K = list(map(int, input().split())) W = tuple(int(readline()) for _ in range(N)) ma = max(W) def check(x): if x < ma: return False use = 1 rest = x for w in W: if rest >= w: rest -= w else: rest = x...
import sys readline = sys.stdin.readline N, K = list(map(int, input().split())) W = tuple(map(int, sys.stdin.read().splitlines())) ma = max(W) def check(x): if x < ma: return False use = 1 rest = x for w in W: if rest >= w: rest -= w else: re...
26
26
490
496
import sys readline = sys.stdin.readline N, K = list(map(int, input().split())) W = tuple(int(readline()) for _ in range(N)) ma = max(W) def check(x): if x < ma: return False use = 1 rest = x for w in W: if rest >= w: rest -= w else: rest = x - w ...
import sys readline = sys.stdin.readline N, K = list(map(int, input().split())) W = tuple(map(int, sys.stdin.read().splitlines())) ma = max(W) def check(x): if x < ma: return False use = 1 rest = x for w in W: if rest >= w: rest -= w else: rest = x - w ...
false
0
[ "-W = tuple(int(readline()) for _ in range(N))", "+W = tuple(map(int, sys.stdin.read().splitlines()))" ]
false
0.083786
0.050303
1.665623
[ "s504437802", "s104950230" ]
u104922648
p03493
python
s802497638
s924809182
20
17
3,316
2,940
Accepted
Accepted
15
n = eval(input()) print((sum([int(i) for i in n])))
n = eval(input()) result = 0 if n[0] == '1': result += 1 if n[1] == '1': result += 1 if n[2] == '1': result += 1 print(result)
2
9
44
134
n = eval(input()) print((sum([int(i) for i in n])))
n = eval(input()) result = 0 if n[0] == "1": result += 1 if n[1] == "1": result += 1 if n[2] == "1": result += 1 print(result)
false
77.777778
[ "-print((sum([int(i) for i in n])))", "+result = 0", "+if n[0] == \"1\":", "+ result += 1", "+if n[1] == \"1\":", "+ result += 1", "+if n[2] == \"1\":", "+ result += 1", "+print(result)" ]
false
0.043224
0.042439
1.018493
[ "s802497638", "s924809182" ]
u339199690
p02837
python
s848010959
s925408897
206
176
3,064
5,068
Accepted
Accepted
14.56
N = int(eval(input())) xy = [[] for i in range(N)] for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split())) xy[i].append([x, y]) res = 0 for i in range(2 ** N): cnt = 0 for j in range(N): ok = True if i >> j & 1: ...
import sys, heapq, bisect, math, fractions from collections import deque N = int(eval(input())) xy = [[] for _ in range(N)] for i in range(N): a = int(eval(input())) for _ in range(a): xy[i].append(tuple(map(int, input().split()))) def ok(i: int, j: int): for x, y in xy[j]: ...
25
30
591
699
N = int(eval(input())) xy = [[] for i in range(N)] for i in range(N): A = int(eval(input())) for j in range(A): x, y = list(map(int, input().split())) xy[i].append([x, y]) res = 0 for i in range(2**N): cnt = 0 for j in range(N): ok = True if i >> j & 1: cnt +=...
import sys, heapq, bisect, math, fractions from collections import deque N = int(eval(input())) xy = [[] for _ in range(N)] for i in range(N): a = int(eval(input())) for _ in range(a): xy[i].append(tuple(map(int, input().split()))) def ok(i: int, j: int): for x, y in xy[j]: if y == 0 and ...
false
16.666667
[ "+import sys, heapq, bisect, math, fractions", "+from collections import deque", "+", "-xy = [[] for i in range(N)]", "+xy = [[] for _ in range(N)]", "- A = int(eval(input()))", "- for j in range(A):", "- x, y = list(map(int, input().split()))", "- xy[i].append([x, y])", "+ ...
false
0.046093
0.046035
1.001263
[ "s848010959", "s925408897" ]
u471214054
p02837
python
s337042213
s954939566
1,526
1,357
3,064
3,064
Accepted
Accepted
11.07
def counter(x): if x == 0: return 0 return counter(x >> 1) + (x & 1) N = int(eval(input())) A = [0 for i in range(20)] x = [[0 for i in range(20)] for j in range(20)] y = [[0 for i in range(20)] for j in range(20)] for i in range(1, N + 1): A[i] = int(eval(input())) for j in rang...
def counter(x): if x == 0: return 0 return counter(x >> 1) + (x & 1) N = int(eval(input())) A = [0 for i in range(20)] x = [[0 for i in range(20)] for j in range(20)] y = [[0 for i in range(20)] for j in range(20)] for i in range(1, N + 1): A[i] = int(eval(input())) for j in rang...
33
33
844
846
def counter(x): if x == 0: return 0 return counter(x >> 1) + (x & 1) N = int(eval(input())) A = [0 for i in range(20)] x = [[0 for i in range(20)] for j in range(20)] y = [[0 for i in range(20)] for j in range(20)] for i in range(1, N + 1): A[i] = int(eval(input())) for j in range(1, A[i] + 1)...
def counter(x): if x == 0: return 0 return counter(x >> 1) + (x & 1) N = int(eval(input())) A = [0 for i in range(20)] x = [[0 for i in range(20)] for j in range(20)] y = [[0 for i in range(20)] for j in range(20)] for i in range(1, N + 1): A[i] = int(eval(input())) for j in range(1, A[i] + 1)...
false
0
[ "- # 不親切な人の意見は無視", "- if not ((bits >> (i - 1)) & 1):", "+ # 不親切な人の証言は無視", "+ if ((bits >> (i - 1)) & 1) == 0:", "- if ((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]:", "+ if ((bits >> (x[i][j] - 1)) & 1) != y[i][j]:" ]
false
0.047503
0.047642
0.997086
[ "s337042213", "s954939566" ]
u059210959
p02996
python
s276740695
s039808932
988
813
47,280
40,412
Accepted
Accepted
17.71
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 def LI(): return list(map(int, sys.stdin.readline().split())) N = int(eval(input())) BA = [[] for i ...
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 def LI(): return list(map(int, sys.stdin.readline().split())) N = int(eval(input())) BA = [[] for i ...
35
32
651
624
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import sys mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 def LI(): return list(map(int, sys.stdin.readline().split())) N = int(eval(input())) BA = [[] for i i...
# encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import sys mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 def LI(): return list(map(int, sys.stdin.readline().split())) N = int(eval(input())) BA = [[] for i i...
false
8.571429
[ "- A, B = LI()", "- BA[i] = [B, A]", "+ a, b = LI()", "+ BA[i] = (b, a)", "- if B - part_A[i] >= 0:", "- pass", "- else:", "+ if B - part_A[i] < 0:" ]
false
0.061713
0.05941
1.038765
[ "s276740695", "s039808932" ]
u057993957
p03592
python
s134849787
s138800140
253
29
9,072
9,132
Accepted
Accepted
88.54
n, m, k = list(map(int, input().split())) flag = False for y in range(m+1): for x in range(n + 1): if n * y + m * x - 2 * x * y == k: flag = True break print(("Yes" if flag else "No"))
n, m, k = list(map(int, input().split())) flag = False for y in range(n+1): if n - 2 * y == 0: continue x = (k - m * y) / (n - 2 * y) if (k - m * y) % (n - 2 * y) == 0 and (0 <= x and x <= m): flag = True break print(("Yes" if flag else "No"))
9
13
227
304
n, m, k = list(map(int, input().split())) flag = False for y in range(m + 1): for x in range(n + 1): if n * y + m * x - 2 * x * y == k: flag = True break print(("Yes" if flag else "No"))
n, m, k = list(map(int, input().split())) flag = False for y in range(n + 1): if n - 2 * y == 0: continue x = (k - m * y) / (n - 2 * y) if (k - m * y) % (n - 2 * y) == 0 and (0 <= x and x <= m): flag = True break print(("Yes" if flag else "No"))
false
30.769231
[ "-for y in range(m + 1):", "- for x in range(n + 1):", "- if n * y + m * x - 2 * x * y == k:", "- flag = True", "- break", "+for y in range(n + 1):", "+ if n - 2 * y == 0:", "+ continue", "+ x = (k - m * y) / (n - 2 * y)", "+ if (k - m * y) % (n - 2 ...
false
0.074719
0.036434
2.050818
[ "s134849787", "s138800140" ]
u512007680
p02722
python
s847870822
s030378617
917
297
10,868
47,852
Accepted
Accepted
67.61
###草 import math N = int(eval(input())) Klist = [0]*(int(N**(1/2))+1) count = 1###int(N**(1/2))+1以上についてカウント ###あらかじめK=Nはカウント for i in range(1,int((N-1)**(1/2))+1): if (N-1) % i == 0: Klist[i] = 1 count += 1 ### #print(i,(N-1)//i) ### if (N-1)**(1/2) - ...
N = int(eval(input())) ans = 0 L = [0]*(int((N-1)**(1/2))+1) for i in range(1,int((N-1)**(1/2))+1): if (N-1)%i == 0: ans += 2 L[i] = 1 ### #print(i,(N-1)//i) ### if i**2 == N-1: ans -= 1 for i in range(1,int(N**(1/2))+1): if i < int((N-1)**(...
34
38
803
790
###草 import math N = int(eval(input())) Klist = [0] * (int(N ** (1 / 2)) + 1) count = 1 ###int(N**(1/2))+1以上についてカウント ###あらかじめK=Nはカウント for i in range(1, int((N - 1) ** (1 / 2)) + 1): if (N - 1) % i == 0: Klist[i] = 1 count += 1 ### # print(i,(N-1)//i) ### if (N - 1) ** (1 / ...
N = int(eval(input())) ans = 0 L = [0] * (int((N - 1) ** (1 / 2)) + 1) for i in range(1, int((N - 1) ** (1 / 2)) + 1): if (N - 1) % i == 0: ans += 2 L[i] = 1 ### # print(i,(N-1)//i) ### if i**2 == N - 1: ans -= 1 for i in range(1, int(N ** (1 / 2)) + 1): if i ...
false
10.526316
[ "-###草", "-import math", "-", "-Klist = [0] * (int(N ** (1 / 2)) + 1)", "-count = 1 ###int(N**(1/2))+1以上についてカウント", "-###あらかじめK=Nはカウント", "+ans = 0", "+L = [0] * (int((N - 1) ** (1 / 2)) + 1)", "- Klist[i] = 1", "- count += 1", "+ ans += 2", "+ L[i] = 1", "-if (N -...
false
0.391011
0.15263
2.561823
[ "s847870822", "s030378617" ]
u476199965
p03355
python
s428557574
s457499879
109
89
7,232
6,972
Accepted
Accepted
18.35
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**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in...
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**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in...
40
36
1,058
1,041
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**10 mod = 998244353 dd = [(0, -1), (1, 0), (0, 1), (-1, 0)] ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)] def LI...
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**10 mod = 998244353 dd = [(0, -1), (1, 0), (0, 1), (-1, 0)] ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)] def LI...
false
10
[ "-", "-", "-def push(res, s):", "- if s not in res:", "- for i in range(len(res)):", "- if s < res[i]:", "- res.insert(i, s)", "- break", "- res.append(s)", "- return res[0:k]", "-", "-", "- res = push(res, s1)", "+ ...
false
0.080305
0.04081
1.967764
[ "s428557574", "s457499879" ]
u075303794
p02659
python
s711064010
s478712157
27
21
10,000
9,164
Accepted
Accepted
22.22
from decimal import Decimal a, b = input().split() print((int(Decimal(a) * Decimal(b))))
a,b = input().split() a = int(a) b = int(float(b)*100+0.5) print((a*b//100))
5
6
92
81
from decimal import Decimal a, b = input().split() print((int(Decimal(a) * Decimal(b))))
a, b = input().split() a = int(a) b = int(float(b) * 100 + 0.5) print((a * b // 100))
false
16.666667
[ "-from decimal import Decimal", "-", "-print((int(Decimal(a) * Decimal(b))))", "+a = int(a)", "+b = int(float(b) * 100 + 0.5)", "+print((a * b // 100))" ]
false
0.037471
0.034976
1.071332
[ "s711064010", "s478712157" ]
u540761833
p02695
python
s940466138
s281645785
1,068
576
9,152
9,168
Accepted
Accepted
46.07
N,M,Q = list(map(int,input().split())) abcd = [list(map(int,input().split())) for i in range(Q)] ans = 0 for a in range(1,M+1): for b in range(a,M+1): for c in range(b,M+1): for d in range(c,M+1): for e in range(d,M+1): for f in range(e,M+1): ...
N,M,Q = list(map(int,input().split())) abcd = [list(map(int,input().split())) for i in range(Q)] ans = 0 def dfs(n,A,now): global ans if n == 0: ansi = 0 for a,b,c,d in abcd: if A[b-1]-A[a-1]==c: ansi+=d ans = max(ans,ansi) else: for i ...
20
18
912
396
N, M, Q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for i in range(Q)] ans = 0 for a in range(1, M + 1): for b in range(a, M + 1): for c in range(b, M + 1): for d in range(c, M + 1): for e in range(d, M + 1): for f in range(e, M +...
N, M, Q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for i in range(Q)] ans = 0 def dfs(n, A, now): global ans if n == 0: ansi = 0 for a, b, c, d in abcd: if A[b - 1] - A[a - 1] == c: ansi += d ans = max(ans, ansi) else: ...
false
10
[ "-for a in range(1, M + 1):", "- for b in range(a, M + 1):", "- for c in range(b, M + 1):", "- for d in range(c, M + 1):", "- for e in range(d, M + 1):", "- for f in range(e, M + 1):", "- for g in range(f, M + 1):", "- ...
false
0.061823
0.068503
0.902486
[ "s940466138", "s281645785" ]
u450956662
p03450
python
s301218266
s775993786
1,112
939
129,664
69,912
Accepted
Accepted
15.56
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline def dfs(v, d): if visited[v] and X[v] != d: return False if visited[v] and X[v] == d: return True visited[v] = True X[v] = d for u, c in E[v]: if not dfs(u, d + c): return False ...
from collections import deque def dfs(s): stack = deque([s]) dist[s] = 0 while stack: v = stack.pop() for d, u in E[v]: if dist[u] is None: dist[u] = dist[v] + d stack.append(u) else: if dist[u] != dist[v] +...
32
31
703
729
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def dfs(v, d): if visited[v] and X[v] != d: return False if visited[v] and X[v] == d: return True visited[v] = True X[v] = d for u, c in E[v]: if not dfs(u, d + c): return False return True ...
from collections import deque def dfs(s): stack = deque([s]) dist[s] = 0 while stack: v = stack.pop() for d, u in E[v]: if dist[u] is None: dist[u] = dist[v] + d stack.append(u) else: if dist[u] != dist[v] + d: ...
false
3.125
[ "-import sys", "-", "-sys.setrecursionlimit(10**6)", "-input = sys.stdin.readline", "+from collections import deque", "-def dfs(v, d):", "- if visited[v] and X[v] != d:", "- return False", "- if visited[v] and X[v] == d:", "- return True", "- visited[v] = True", "- X[...
false
0.133739
0.053335
2.507506
[ "s301218266", "s775993786" ]
u440566786
p02850
python
s572771815
s080564834
603
452
80,628
70,816
Accepted
Accepted
25.04
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): n=int(eval(input())) E=[[] for _ in range(n)] idx={} for i in range(n-1): a,b=list(map(int,input().split())) a-=1; b-=1 E[a].append(b) ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): n=int(input()) E=[[] for _ in range(n)] idx={} for i in range(n-1): a,b=map(int,input().split()) a-=1; b-=1 E[a].append(b) idx...
44
30
981
650
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n = int(eval(input())) E = [[] for _ in range(n)] idx = {} for i in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 ...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n = int(input()) E = [[] for _ in range(n)] idx = {} for i in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 E[a]....
false
31.818182
[ "- n = int(eval(input()))", "+ n = int(input())", "- a, b = list(map(int, input().split()))", "+ a, b = map(int, input().split())", "- E[b].append(a)", "- k = max(len(E[v]) for v in range(n))", "- # DFSで辺に色付け", "- Q = [0]", "+ # coloring", "+ Q = [(0, 0)]"...
false
0.142026
0.044841
3.167349
[ "s572771815", "s080564834" ]
u729133443
p02902
python
s689690256
s175927918
277
23
45,400
3,828
Accepted
Accepted
91.7
from collections import* n,m=list(map(int,input().split())) outs=defaultdict(list) ins=defaultdict(int) for _ in range(m): a,b=list(map(int,input().split())) outs[a-1]+=b-1, ins[b-1]+=1 q=deque(i for i in range(n)if ins[i]==0) res=[] while q: v=q.popleft() res+=v, for w in outs[v]: ...
from collections import* n,m,*t=list(map(int,open(0).read().split())) i,o=[0]*n,[[]for _ in range(n)] for a,b in zip(*[iter(t)]*2): o[a-1]+=b-1, i[b-1]+=1 q=deque(v for v in range(n)if i[v]<1) r=[] while q: v=q.popleft() r+=v, for w in o[v]: i[w]-=1 if i[w]==0:q+=w, print((-(len(r)==n)))
18
15
397
312
from collections import * n, m = list(map(int, input().split())) outs = defaultdict(list) ins = defaultdict(int) for _ in range(m): a, b = list(map(int, input().split())) outs[a - 1] += (b - 1,) ins[b - 1] += 1 q = deque(i for i in range(n) if ins[i] == 0) res = [] while q: v = q.popleft() res += (...
from collections import * n, m, *t = list(map(int, open(0).read().split())) i, o = [0] * n, [[] for _ in range(n)] for a, b in zip(*[iter(t)] * 2): o[a - 1] += (b - 1,) i[b - 1] += 1 q = deque(v for v in range(n) if i[v] < 1) r = [] while q: v = q.popleft() r += (v,) for w in o[v]: i[w] -= ...
false
16.666667
[ "-n, m = list(map(int, input().split()))", "-outs = defaultdict(list)", "-ins = defaultdict(int)", "-for _ in range(m):", "- a, b = list(map(int, input().split()))", "- outs[a - 1] += (b - 1,)", "- ins[b - 1] += 1", "-q = deque(i for i in range(n) if ins[i] == 0)", "-res = []", "+n, m, *t...
false
0.069209
0.035539
1.947411
[ "s689690256", "s175927918" ]
u606045429
p02904
python
s676688686
s760928847
404
372
39,772
40,772
Accepted
Accepted
7.92
from itertools import accumulate from collections import deque N, K, *P = list(map(int, open(0).read().split())) def slide(A, K, cmp=lambda a, b: a > b): res = [] Q = deque() for i, a in enumerate(A): while Q and cmp(A[Q[-1]], a): Q.pop() Q.append(i) if Q[0]...
from collections import deque from itertools import accumulate def slide_min(A, K): res = [] Q = deque() for i, a in enumerate(A): while Q and A[Q[-1]] > a: Q.pop() Q.append(i) if Q[0] == i - K: Q.popleft() res.append(Q[0]) return res...
29
29
752
730
from itertools import accumulate from collections import deque N, K, *P = list(map(int, open(0).read().split())) def slide(A, K, cmp=lambda a, b: a > b): res = [] Q = deque() for i, a in enumerate(A): while Q and cmp(A[Q[-1]], a): Q.pop() Q.append(i) if Q[0] == i - K: ...
from collections import deque from itertools import accumulate def slide_min(A, K): res = [] Q = deque() for i, a in enumerate(A): while Q and A[Q[-1]] > a: Q.pop() Q.append(i) if Q[0] == i - K: Q.popleft() res.append(Q[0]) return res[K - 1 :] ...
false
0
[ "+from collections import deque", "-from collections import deque", "-", "-N, K, *P = list(map(int, open(0).read().split()))", "-def slide(A, K, cmp=lambda a, b: a > b):", "+def slide_min(A, K):", "- while Q and cmp(A[Q[-1]], a):", "+ while Q and A[Q[-1]] > a:", "-mi = slide(P, K)", ...
false
0.037817
0.041148
0.919051
[ "s676688686", "s760928847" ]
u411203878
p03074
python
s023521813
s591644667
230
199
48,860
49,804
Accepted
Accepted
13.48
n,k = list(map(int,input().split())) s=eval(input()) s = list(map(int,s)) memo = [0] for i in range(1,n): if s[i-1] != s[i]: memo.append(i) ans = 0 for i in range(len(memo)): start = memo[i] if (s[start] == 1): end = i + 2*k +1 else: end = i + 2*k if end...
n,k = list(map(int,input().split())) s=list(eval(input())) memo = [0] for i in range(1,n): if s[i] != s[i-1]: memo.append(i) ans = 0 kyoukai_math = len(memo) for i in range(kyoukai_math): if s[memo[i]] == '1': hasi = i+k*2+1 else: hasi = i+k*2 if hasi < kyoukai_math: ...
24
25
422
396
n, k = list(map(int, input().split())) s = eval(input()) s = list(map(int, s)) memo = [0] for i in range(1, n): if s[i - 1] != s[i]: memo.append(i) ans = 0 for i in range(len(memo)): start = memo[i] if s[start] == 1: end = i + 2 * k + 1 else: end = i + 2 * k if end < len(memo...
n, k = list(map(int, input().split())) s = list(eval(input())) memo = [0] for i in range(1, n): if s[i] != s[i - 1]: memo.append(i) ans = 0 kyoukai_math = len(memo) for i in range(kyoukai_math): if s[memo[i]] == "1": hasi = i + k * 2 + 1 else: hasi = i + k * 2 if hasi < kyoukai_m...
false
4
[ "-s = eval(input())", "-s = list(map(int, s))", "+s = list(eval(input()))", "- if s[i - 1] != s[i]:", "+ if s[i] != s[i - 1]:", "-for i in range(len(memo)):", "- start = memo[i]", "- if s[start] == 1:", "- end = i + 2 * k + 1", "+kyoukai_math = len(memo)", "+for i in range(kyo...
false
0.0425
0.047046
0.903373
[ "s023521813", "s591644667" ]
u796942881
p03109
python
s920067412
s873946092
199
17
5,096
2,940
Accepted
Accepted
91.46
import datetime S = datetime.datetime.strptime(eval(input()), "%Y/%m/%d") T = datetime.datetime.strptime("2019/05/01", "%Y/%m/%d") print(("Heisei" if S < T else "TBD"))
S = eval(input()) T = "2019/05/01" print(("Heisei" if S < T else "TBD"))
7
5
170
71
import datetime S = datetime.datetime.strptime(eval(input()), "%Y/%m/%d") T = datetime.datetime.strptime("2019/05/01", "%Y/%m/%d") print(("Heisei" if S < T else "TBD"))
S = eval(input()) T = "2019/05/01" print(("Heisei" if S < T else "TBD"))
false
28.571429
[ "-import datetime", "-", "-S = datetime.datetime.strptime(eval(input()), \"%Y/%m/%d\")", "-T = datetime.datetime.strptime(\"2019/05/01\", \"%Y/%m/%d\")", "+S = eval(input())", "+T = \"2019/05/01\"" ]
false
0.064204
0.05731
1.120305
[ "s920067412", "s873946092" ]
u886633618
p02763
python
s478251152
s980119167
1,972
1,306
106,328
116,696
Accepted
Accepted
33.77
import bisect N = int(eval(input())) S = eval(input()) Q = int(eval(input())) alphabet_dic = {} alphabet_array = [] for i,s in enumerate(S): alphabet_array.append(s) if s in alphabet_dic: alphabet_dic[s].append(i) else: alphabet_dic[s] = [i] # print(alphabet_dic) for _ in ra...
class SegmentTree(object): # 1-indexed def __init__(self, size, S): self.len = 1 << size.bit_length() self.array = [0] * (2 * self.len) for i, s in enumerate(S): self.array[i + self.len] = 1 << (ord(s) - ord('a')) for i in range(self.len - 1, 0, -1): ...
38
51
1,038
1,508
import bisect N = int(eval(input())) S = eval(input()) Q = int(eval(input())) alphabet_dic = {} alphabet_array = [] for i, s in enumerate(S): alphabet_array.append(s) if s in alphabet_dic: alphabet_dic[s].append(i) else: alphabet_dic[s] = [i] # print(alphabet_dic) for _ in range(Q): a, ...
class SegmentTree(object): # 1-indexed def __init__(self, size, S): self.len = 1 << size.bit_length() self.array = [0] * (2 * self.len) for i, s in enumerate(S): self.array[i + self.len] = 1 << (ord(s) - ord("a")) for i in range(self.len - 1, 0, -1): self.arr...
false
25.490196
[ "-import bisect", "+class SegmentTree(object): # 1-indexed", "+ def __init__(self, size, S):", "+ self.len = 1 << size.bit_length()", "+ self.array = [0] * (2 * self.len)", "+ for i, s in enumerate(S):", "+ self.array[i + self.len] = 1 << (ord(s) - ord(\"a\"))", "+ ...
false
0.081246
0.091032
0.892502
[ "s478251152", "s980119167" ]
u780962115
p02769
python
s144414526
s889484431
313
170
85,272
124,176
Accepted
Accepted
45.69
n,k=list(map(int,input().split())) def find_power(n,mod): # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである) powlist=[0]*(n+1) powlist[0]=1 powlist[1]=1 for i in range(2,n+1): powlist[i]=powlist[i-1]*i%(mod) return powlist def find_inv_power(n): #0!からn!までの逆元を素数10**9+7で割ったあまりリス...
class Combi(): def __init__(self, N, mod): self.power = [1 for _ in range(N+1)] self.rev = [1 for _ in range(N+1)] self.mod = mod for i in range(2, N+1): self.power[i] = (self.power[i-1]*i) % self.mod self.rev[N] = pow(self.power[N], self.mod-2, self.mod) ...
48
34
1,202
976
n, k = list(map(int, input().split())) def find_power(n, mod): # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである) powlist = [0] * (n + 1) powlist[0] = 1 powlist[1] = 1 for i in range(2, n + 1): powlist[i] = powlist[i - 1] * i % (mod) return powlist def find_inv_power(n): # 0!からn!までの逆元...
class Combi: def __init__(self, N, mod): self.power = [1 for _ in range(N + 1)] self.rev = [1 for _ in range(N + 1)] self.mod = mod for i in range(2, N + 1): self.power[i] = (self.power[i - 1] * i) % self.mod self.rev[N] = pow(self.power[N], self.mod - 2, self.mod...
false
29.166667
[ "-n, k = list(map(int, input().split()))", "+class Combi:", "+ def __init__(self, N, mod):", "+ self.power = [1 for _ in range(N + 1)]", "+ self.rev = [1 for _ in range(N + 1)]", "+ self.mod = mod", "+ for i in range(2, N + 1):", "+ self.power[i] = (self.power...
false
1.918015
0.742265
2.584003
[ "s144414526", "s889484431" ]
u347640436
p02936
python
s458937733
s287349003
1,361
1,237
33,412
31,856
Accepted
Accepted
9.11
n, q = list(map(int, input().split())) values = [0] * (n + 1) parents = [0] * (n + 1) results = [0] * (n + 1) for i in range(n - 1): a, b = list(map(int, input().split())) parents[b] = a for _ in range(q): p, x = list(map(int, input().split())) values[p] += x for i in range(1, n + 1): results[i] = ...
def main(): _map = map _range = range _int = int n, q = _map(_int, input().split()) values = [0] * (n + 1) parents = [0] * (n + 1) results = [0] * (n + 1) for i in _range(n - 1): a, b = _map(_int, input().split()) parents[b] = a for _ in _range(q): p, x = _map(_int, input().spl...
15
20
421
527
n, q = list(map(int, input().split())) values = [0] * (n + 1) parents = [0] * (n + 1) results = [0] * (n + 1) for i in range(n - 1): a, b = list(map(int, input().split())) parents[b] = a for _ in range(q): p, x = list(map(int, input().split())) values[p] += x for i in range(1, n + 1): results[i] = v...
def main(): _map = map _range = range _int = int n, q = _map(_int, input().split()) values = [0] * (n + 1) parents = [0] * (n + 1) results = [0] * (n + 1) for i in _range(n - 1): a, b = _map(_int, input().split()) parents[b] = a for _ in _range(q): p, x = _map...
false
25
[ "-n, q = list(map(int, input().split()))", "-values = [0] * (n + 1)", "-parents = [0] * (n + 1)", "-results = [0] * (n + 1)", "-for i in range(n - 1):", "- a, b = list(map(int, input().split()))", "- parents[b] = a", "-for _ in range(q):", "- p, x = list(map(int, input().split()))", "- ...
false
0.047738
0.03676
1.298665
[ "s458937733", "s287349003" ]
u604839890
p04044
python
s064637175
s856302481
28
24
9,108
9,104
Accepted
Accepted
14.29
n, l = map(int, input().split()) s = sorted([input() for _ in range(n)]) print(*s, sep='')
n, l = map(int, input().split()) print(*sorted([input() for _ in range(n)]), sep='')
3
2
92
85
n, l = map(int, input().split()) s = sorted([input() for _ in range(n)]) print(*s, sep="")
n, l = map(int, input().split()) print(*sorted([input() for _ in range(n)]), sep="")
false
33.333333
[ "-s = sorted([input() for _ in range(n)])", "-print(*s, sep=\"\")", "+print(*sorted([input() for _ in range(n)]), sep=\"\")" ]
false
0.041343
0.040193
1.028619
[ "s064637175", "s856302481" ]
u163783894
p03078
python
s459533116
s669402486
689
89
139,440
9,532
Accepted
Accepted
87.08
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readline_s = sys.stdin.readline readlines = sys.stdin.buffer.readlines INF = 10 ** 10 + 7 def main(): X, Y, Z, K = list(map(int, readline().split())) A = sorted(list(map(int, readline().split())), reverse=True) B =...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readline_s = sys.stdin.readline readlines = sys.stdin.buffer.readlines INF = 10 ** 10 + 7 def main(): X, Y, Z, K = list(map(int, readline().split())) A = sorted(list(map(int, readline().split())), reverse=True) B =...
42
60
923
1,366
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readline_s = sys.stdin.readline readlines = sys.stdin.buffer.readlines INF = 10**10 + 7 def main(): X, Y, Z, K = list(map(int, readline().split())) A = sorted(list(map(int, readline().split())), reverse=True) B = sorted(list(map...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readline_s = sys.stdin.readline readlines = sys.stdin.buffer.readlines INF = 10**10 + 7 def main(): X, Y, Z, K = list(map(int, readline().split())) A = sorted(list(map(int, readline().split())), reverse=True) B = sorted(list(map...
false
30
[ "- ans = solve1(X, Y, Z, K, A, B, C)", "+ ans = solve2(X, Y, Z, K, A, B, C)", "+", "+", "+def solve2(X, Y, Z, K, A, B, C):", "+ ABC = []", "+ for i in range(X):", "+ if (i + 1) > K:", "+ break", "+ for j in range(Y):", "+ if (i + 1) * (j + 1) > K:"...
false
0.078193
0.03606
2.168443
[ "s459533116", "s669402486" ]
u474925961
p02696
python
s935555993
s497808442
61
21
61,928
9,096
Accepted
Accepted
65.57
import sys import itertools if sys.platform =='ios': sys.stdin=open('input_file.txt') a,b,n=list(map(int,input().split())) cnt=0 if n//b>0: print((a*(b-1)//b-a*((b-1)//b))) else: print((a*(n)//b-a*((n)//b)))
a,b,n=list(map(int,input().split())) if n>=b-1: print(((a*(b-1))//b-a*((b-1)//b))) else: print(((a*n)//b-a*(n//b)))
12
5
220
117
import sys import itertools if sys.platform == "ios": sys.stdin = open("input_file.txt") a, b, n = list(map(int, input().split())) cnt = 0 if n // b > 0: print((a * (b - 1) // b - a * ((b - 1) // b))) else: print((a * (n) // b - a * ((n) // b)))
a, b, n = list(map(int, input().split())) if n >= b - 1: print(((a * (b - 1)) // b - a * ((b - 1) // b))) else: print(((a * n) // b - a * (n // b)))
false
58.333333
[ "-import sys", "-import itertools", "-", "-if sys.platform == \"ios\":", "- sys.stdin = open(\"input_file.txt\")", "-cnt = 0", "-if n // b > 0:", "- print((a * (b - 1) // b - a * ((b - 1) // b)))", "+if n >= b - 1:", "+ print(((a * (b - 1)) // b - a * ((b - 1) // b)))", "- print((a *...
false
0.039671
0.038467
1.031296
[ "s935555993", "s497808442" ]
u150984829
p00425
python
s589972882
s096232831
40
30
5,660
5,716
Accepted
Accepted
25
import sys d=sys.stdin.readline p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)} while 1: n=int(d()) if n==0:break a=1;s='123456' for _ in[0]*n: s=[s[e]for e in p[d()[0]]] a+=int(s[0]) print(a)
import sys d=sys.stdin.readline p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)} while 1: n=int(d()) if n==0:break a=[1];s='123456' for _ in[0]*n: s=[s[e]for e in p[d()[0]]] a+=[s[0]] print((sum(map(int,a))))
12
12
281
294
import sys d = sys.stdin.readline p = { "N": (1, 5, 2, 3, 0, 4), "E": (3, 1, 0, 5, 4, 2), "W": (2, 1, 5, 0, 4, 3), "S": (4, 0, 2, 3, 5, 1), "R": (0, 2, 4, 1, 3, 5), "L": (0, 3, 1, 4, 2, 5), } while 1: n = int(d()) if n == 0: break a = 1 s = "123456" for _ in [0] * n:...
import sys d = sys.stdin.readline p = { "N": (1, 5, 2, 3, 0, 4), "E": (3, 1, 0, 5, 4, 2), "W": (2, 1, 5, 0, 4, 3), "S": (4, 0, 2, 3, 5, 1), "R": (0, 2, 4, 1, 3, 5), "L": (0, 3, 1, 4, 2, 5), } while 1: n = int(d()) if n == 0: break a = [1] s = "123456" for _ in [0] * ...
false
0
[ "- a = 1", "+ a = [1]", "- a += int(s[0])", "- print(a)", "+ a += [s[0]]", "+ print((sum(map(int, a))))" ]
false
0.044548
0.043412
1.026165
[ "s589972882", "s096232831" ]
u977389981
p03352
python
s573758383
s445349653
21
17
3,060
3,060
Accepted
Accepted
19.05
x = int(eval(input())) ans = 0 for i in range(1, 1000): for j in range(2, 10): if i ** j <= x: ans = max(i ** j, ans) print(ans)
x = int(eval(input())) ans = 0 if x == 1: ans = 1 else: for i in range(2, 100): n = 2 while i ** n <= x: ans = max(ans , i ** n) n += 1 print(ans)
9
13
168
214
x = int(eval(input())) ans = 0 for i in range(1, 1000): for j in range(2, 10): if i**j <= x: ans = max(i**j, ans) print(ans)
x = int(eval(input())) ans = 0 if x == 1: ans = 1 else: for i in range(2, 100): n = 2 while i**n <= x: ans = max(ans, i**n) n += 1 print(ans)
false
30.769231
[ "-for i in range(1, 1000):", "- for j in range(2, 10):", "- if i**j <= x:", "- ans = max(i**j, ans)", "+if x == 1:", "+ ans = 1", "+else:", "+ for i in range(2, 100):", "+ n = 2", "+ while i**n <= x:", "+ ans = max(ans, i**n)", "+ ...
false
0.049549
0.043405
1.141534
[ "s573758383", "s445349653" ]
u714300041
p03835
python
s325487707
s859897716
1,630
324
2,940
40,684
Accepted
Accepted
80.12
K, S = list(map(int, input().split())) number = 0 for x in range(K+1): for y in range(K+1): z = S - (x + y) if 0 <= z <= K: number += 1 print(number)
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) K, S = list(map(int, input().split())) ans = 0 for z in range(K+1): for y in range(K+1): x = S - (z + y) if x >= 0 and x <= K: ans += 1 print(ans)
8
13
167
255
K, S = list(map(int, input().split())) number = 0 for x in range(K + 1): for y in range(K + 1): z = S - (x + y) if 0 <= z <= K: number += 1 print(number)
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) K, S = list(map(int, input().split())) ans = 0 for z in range(K + 1): for y in range(K + 1): x = S - (z + y) if x >= 0 and x <= K: ans += 1 print(ans)
false
38.461538
[ "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**7)", "-number = 0", "-for x in range(K + 1):", "+ans = 0", "+for z in range(K + 1):", "- z = S - (x + y)", "- if 0 <= z <= K:", "- number += 1", "-print(number)", "+ x = S - (z + y)...
false
0.055536
0.075109
0.739408
[ "s325487707", "s859897716" ]
u818318325
p02659
python
s202040819
s509121276
23
20
9,160
9,164
Accepted
Accepted
13.04
s,t =input().split() a = int(s) b = int(float(t)*1000) ans = a*b print((ans//1000))
#import math #from decimal import * #getcontext().prec = 28 a,b=input().split() #a_ = Decimal(a) #b_ = Decimal(b) a = int(a) b = int(float(b)*1000) #print(round(Decimal(Decimal(a)*Decimal(b)))) ans = a*b print((ans//1000)) #print(math.floor(Decimal(a)*Decimal(b)/Decimal(100.0)))
5
12
86
288
s, t = input().split() a = int(s) b = int(float(t) * 1000) ans = a * b print((ans // 1000))
# import math # from decimal import * # getcontext().prec = 28 a, b = input().split() # a_ = Decimal(a) # b_ = Decimal(b) a = int(a) b = int(float(b) * 1000) # print(round(Decimal(Decimal(a)*Decimal(b)))) ans = a * b print((ans // 1000)) # print(math.floor(Decimal(a)*Decimal(b)/Decimal(100.0)))
false
58.333333
[ "-s, t = input().split()", "-a = int(s)", "-b = int(float(t) * 1000)", "+# import math", "+# from decimal import *", "+# getcontext().prec = 28", "+a, b = input().split()", "+# a_ = Decimal(a)", "+# b_ = Decimal(b)", "+a = int(a)", "+b = int(float(b) * 1000)", "+# print(round(Decimal(Decimal(a...
false
0.072191
0.115466
0.625214
[ "s202040819", "s509121276" ]
u954774382
p03162
python
s050358764
s591360250
694
348
49,520
51,760
Accepted
Accepted
49.86
import math import operator as op from functools import reduce from fractions import Fraction as frac def ncr(n, r): r = min(r, n-r) numer = reduce(op.mul, list(range(n, n-r, -1)), 1) denom = reduce(op.mul, list(range(1, r+1)), 1) return numer / denom """ int(input()) map(int,input().split(...
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bi...
27
45
722
1,431
import math import operator as op from functools import reduce from fractions import Fraction as frac def ncr(n, r): r = min(r, n - r) numer = reduce(op.mul, list(range(n, n - r, -1)), 1) denom = reduce(op.mul, list(range(1, r + 1)), 1) return numer / denom """ int(input()) map(int,input().split()) ...
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect f...
false
40
[ "-import math", "-import operator as op", "-from functools import reduce", "-from fractions import Fraction as frac", "+import sys", "+from functools import lru_cache, cmp_to_key", "+from heapq import merge, heapify, heappop, heappush", "+from math import *", "+from collections import defaultdict as...
false
0.039929
0.039477
1.011449
[ "s050358764", "s591360250" ]
u526094365
p02713
python
s011941091
s636948339
727
488
111,316
79,492
Accepted
Accepted
32.87
import math from numba import jit K = int(eval(input())) @jit def apt(N): cnt = 0 for i in range(1, K+1): for j in range(1, K + 1): for k in range(1, K + 1): cnt += math.gcd(k, math.gcd(i, j)) return cnt print((apt(K)))
import math K = int(eval(input())) cnt = 0 for i in range(1, K+1): for j in range(1, K + 1): for k in range(1, K + 1): cnt += math.gcd(k, math.gcd(i, j)) print(cnt)
17
11
281
196
import math from numba import jit K = int(eval(input())) @jit def apt(N): cnt = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): cnt += math.gcd(k, math.gcd(i, j)) return cnt print((apt(K)))
import math K = int(eval(input())) cnt = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): cnt += math.gcd(k, math.gcd(i, j)) print(cnt)
false
35.294118
[ "-from numba import jit", "-", "-", "-@jit", "-def apt(N):", "- cnt = 0", "- for i in range(1, K + 1):", "- for j in range(1, K + 1):", "- for k in range(1, K + 1):", "- cnt += math.gcd(k, math.gcd(i, j))", "- return cnt", "-", "-", "-print((apt(K)...
false
0.042169
0.044444
0.948823
[ "s011941091", "s636948339" ]
u644907318
p03945
python
s982445344
s828611879
171
67
39,536
67,688
Accepted
Accepted
60.82
S = input().strip() N = len(S) cur = 0 cnt = 0 for i in range(1,N): if S[i]!=S[cur]: cnt += 1 cur = i print(cnt)
S = input().strip() cnt = 0 for i in range(1,len(S)): if S[i]!=S[i-1]: cnt += 1 print(cnt)
9
6
140
107
S = input().strip() N = len(S) cur = 0 cnt = 0 for i in range(1, N): if S[i] != S[cur]: cnt += 1 cur = i print(cnt)
S = input().strip() cnt = 0 for i in range(1, len(S)): if S[i] != S[i - 1]: cnt += 1 print(cnt)
false
33.333333
[ "-N = len(S)", "-cur = 0", "-for i in range(1, N):", "- if S[i] != S[cur]:", "+for i in range(1, len(S)):", "+ if S[i] != S[i - 1]:", "- cur = i" ]
false
0.131066
0.190055
0.689621
[ "s982445344", "s828611879" ]
u100641536
p02623
python
s536801575
s945377615
673
531
58,456
58,028
Accepted
Accepted
21.1
import sys import numpy as np input = lambda: sys.stdin.readline().rstrip() def main(): n,m,k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = np.cumsum([0]+a) sb = np.cumsum([0]+b) for i in range(n): sa[i+1] = sa[i] + a[i] for...
import sys import numpy as np input = lambda: sys.stdin.readline().rstrip() def main(): n,m,k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = np.cumsum([0]+a) sb = np.cumsum([0]+b) rx = 0 rb = m for ra in range(0,n+1): whi...
25
21
575
475
import sys import numpy as np input = lambda: sys.stdin.readline().rstrip() def main(): n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = np.cumsum([0] + a) sb = np.cumsum([0] + b) for i in range(n): sa[i + 1] = sa[i...
import sys import numpy as np input = lambda: sys.stdin.readline().rstrip() def main(): n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) sa = np.cumsum([0] + a) sb = np.cumsum([0] + b) rx = 0 rb = m for ra in range(0, n ...
false
16
[ "- for i in range(n):", "- sa[i + 1] = sa[i] + a[i]", "- for i in range(m):", "- sb[i + 1] = sb[i] + b[i]" ]
false
0.756818
0.357279
2.118283
[ "s536801575", "s945377615" ]
u028973125
p03645
python
s906415908
s463454855
627
530
51,416
38,424
Accepted
Accepted
15.47
import sys from collections import deque N, M = list(map(int, sys.stdin.readline().strip().split())) paths = [[] for _ in range(N+1)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().strip().split())) paths[a].append(b) paths[b].append(a) q = deque([(1, 0)]) visited = set() while...
import sys N, M = list(map(int, sys.stdin.readline().strip().split())) paths = [[] for _ in range(N+1)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().strip().split())) paths[a].append(b) paths[b].append(a) for i in paths[1]: for j in paths[i]: if j == N: ...
27
16
576
372
import sys from collections import deque N, M = list(map(int, sys.stdin.readline().strip().split())) paths = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().strip().split())) paths[a].append(b) paths[b].append(a) q = deque([(1, 0)]) visited = set() while q: p, c ...
import sys N, M = list(map(int, sys.stdin.readline().strip().split())) paths = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, sys.stdin.readline().strip().split())) paths[a].append(b) paths[b].append(a) for i in paths[1]: for j in paths[i]: if j == N: print("POSS...
false
40.740741
[ "-from collections import deque", "-q = deque([(1, 0)])", "-visited = set()", "-while q:", "- p, c = q.popleft()", "- if p in visited:", "- continue", "- visited.add(p)", "- if c > 2:", "- continue", "- if p == N:", "- print(\"POSSIBLE\")", "- sys.e...
false
0.133968
0.037397
3.582358
[ "s906415908", "s463454855" ]
u941407962
p03112
python
s820984254
s343634922
1,456
815
68,312
74,460
Accepted
Accepted
44.02
x=[] for i,j in enumerate(map(int,input().split())): c=[] for l in range(j): t=int(eval(input())) x.append((i,l,t)) c.append([t]) x.sort(key=lambda x:x[2]) l=[-10**20]*2 for y in x: if y[0] != 2: l[y[0]]=y[2] else: c[y[1]]+=l[:] l=[10**20]*2 for y ...
import sys input = sys.stdin.readline A, B, Q = list(map(int, input().split())) inf = 10**18 S = [-inf] for _ in range(A): S.append(int(eval(input()))) S.append(inf) T = [-inf] for _ in range(B): T.append(int(eval(input()))) T.append(inf) def f_s(x, l): mn, mx = -1, len(l) idx = mx//2 ...
25
38
592
841
x = [] for i, j in enumerate(map(int, input().split())): c = [] for l in range(j): t = int(eval(input())) x.append((i, l, t)) c.append([t]) x.sort(key=lambda x: x[2]) l = [-(10**20)] * 2 for y in x: if y[0] != 2: l[y[0]] = y[2] else: c[y[1]] += l[:] l = [10**20] *...
import sys input = sys.stdin.readline A, B, Q = list(map(int, input().split())) inf = 10**18 S = [-inf] for _ in range(A): S.append(int(eval(input()))) S.append(inf) T = [-inf] for _ in range(B): T.append(int(eval(input()))) T.append(inf) def f_s(x, l): mn, mx = -1, len(l) idx = mx // 2 while mx ...
false
34.210526
[ "-x = []", "-for i, j in enumerate(map(int, input().split())):", "- c = []", "- for l in range(j):", "- t = int(eval(input()))", "- x.append((i, l, t))", "- c.append([t])", "-x.sort(key=lambda x: x[2])", "-l = [-(10**20)] * 2", "-for y in x:", "- if y[0] != 2:", "...
false
0.041844
0.037026
1.130132
[ "s820984254", "s343634922" ]
u225388820
p02702
python
s594088354
s396935357
1,916
183
75,928
25,440
Accepted
Accepted
90.45
f=[0]*22209 def main(): a=list(map(int,eval(input()))) n=len(a) ans=0 d=[0]*2019 d2=[0]*2019 d2[a[0]]+=1 for i in range(11): for j in range(2019): f[2019*i+j]=j for i in range(1,n): d[a[i]]+=1 for j in range(2019): d[f[10*j+a[...
""" s=1817181712114 なら 4 10 100 2000 10000 700000 1000000 80000000 100000000 7000000000 10000000000 800000000000 1000000000000 の数列とみて, 各々%2019を取ってzero sum range """ from collections import Counter def make_modlist(Len,mod): modlist=[0]*Len modlist[0]=1 for i in range(1,Len): mo...
21
38
443
630
f = [0] * 22209 def main(): a = list(map(int, eval(input()))) n = len(a) ans = 0 d = [0] * 2019 d2 = [0] * 2019 d2[a[0]] += 1 for i in range(11): for j in range(2019): f[2019 * i + j] = j for i in range(1, n): d[a[i]] += 1 for j in range(2019): ...
""" s=1817181712114 なら 4 10 100 2000 10000 700000 1000000 80000000 100000000 7000000000 10000000000 800000000000 1000000000000 の数列とみて, 各々%2019を取ってzero sum range """ from collections import Counter def make_modlist(Len, mod): modlist = [0] * Len modlist[0] = 1 for i in range(1, Len): modlist[i] = 1...
false
44.736842
[ "-f = [0] * 22209", "+\"\"\"", "+s=1817181712114 なら", "+4", "+10", "+100", "+2000", "+10000", "+700000", "+1000000", "+80000000", "+100000000", "+7000000000", "+10000000000", "+800000000000", "+1000000000000", "+の数列とみて, 各々%2019を取ってzero sum range", "+\"\"\"", "+from collections im...
false
0.040619
0.008542
4.755323
[ "s594088354", "s396935357" ]
u995102075
p03031
python
s855076725
s208155138
67
51
3,064
3,064
Accepted
Accepted
23.88
import itertools N, M = list(map(int, input().split())) lights = [] for i in range(M): lights.append([int(x) for x in input().split()]) p = [int(x) for x in input().split()] ans = 0 switches = 0b1111111111 >> (10 - N) for _ in range(0, switches + 1): flag = True for i in range(M): s =...
N, M = list(map(int, input().split())) lights = [] for _ in range(M): lights.append([int(i) for i in input().split()]) p = [int(i) for i in input().split()] ans = 0 for switch in range(0, 2**N): flag = True for i in range(M): s = 0 for j in range(lights[i][0]): s += ...
22
19
536
454
import itertools N, M = list(map(int, input().split())) lights = [] for i in range(M): lights.append([int(x) for x in input().split()]) p = [int(x) for x in input().split()] ans = 0 switches = 0b1111111111 >> (10 - N) for _ in range(0, switches + 1): flag = True for i in range(M): s = 0 for...
N, M = list(map(int, input().split())) lights = [] for _ in range(M): lights.append([int(i) for i in input().split()]) p = [int(i) for i in input().split()] ans = 0 for switch in range(0, 2**N): flag = True for i in range(M): s = 0 for j in range(lights[i][0]): s += (switch >> (l...
false
13.636364
[ "-import itertools", "-", "-for i in range(M):", "- lights.append([int(x) for x in input().split()])", "-p = [int(x) for x in input().split()]", "+for _ in range(M):", "+ lights.append([int(i) for i in input().split()])", "+p = [int(i) for i in input().split()]", "-switches = 0b1111111111 >> (...
false
0.038324
0.038098
1.005922
[ "s855076725", "s208155138" ]
u046187684
p03032
python
s743627507
s138318717
62
21
3,064
3,064
Accepted
Accepted
66.13
def solve(string): n, k, *v = list(map(int, string.split())) ans = 0 for i in range(k + 1): for j in range(k - i + 1): base = sorted(v[:i] + v[max(n - k + i + j, i):]) ans = max(ans, sum([b for l, b in enumerate(base) if b >= 0 or j <= l])) return str(ans) if ...
from itertools import accumulate def solve(string): n, k, *v = list(map(int, string.split())) r = min(n, k) """ for i in range(k + 1): for j in range(k - i + 1): base = sorted(v[:i] + v[max(n - k + i + j, i):]) ans = max(ans, sum([b for l, b in enumerate(base) if ...
12
33
387
1,014
def solve(string): n, k, *v = list(map(int, string.split())) ans = 0 for i in range(k + 1): for j in range(k - i + 1): base = sorted(v[:i] + v[max(n - k + i + j, i) :]) ans = max(ans, sum([b for l, b in enumerate(base) if b >= 0 or j <= l])) return str(ans) if __name__ ...
from itertools import accumulate def solve(string): n, k, *v = list(map(int, string.split())) r = min(n, k) """ for i in range(k + 1): for j in range(k - i + 1): base = sorted(v[:i] + v[max(n - k + i + j, i):]) ans = max(ans, sum([b for l, b in enumerate(base) if b >= 0...
false
63.636364
[ "+from itertools import accumulate", "+", "+", "- ans = 0", "+ r = min(n, k)", "+ \"\"\"", "- base = sorted(v[:i] + v[max(n - k + i + j, i) :])", "+ base = sorted(v[:i] + v[max(n - k + i + j, i):])", "+ \"\"\"", "+", "+ def s(w):", "+ l = [0] * (k + ...
false
0.007395
0.038351
0.192825
[ "s743627507", "s138318717" ]
u599547273
p03485
python
s573604043
s062586660
19
17
3,060
2,940
Accepted
Accepted
10.53
ab=list(map(int,input().split()));print(((sum(ab)-1)//2+1))
print((~-sum(map(int,input().split()))//2+1))
2
1
54
43
ab = list(map(int, input().split())) print(((sum(ab) - 1) // 2 + 1))
print((~-sum(map(int, input().split())) // 2 + 1))
false
50
[ "-ab = list(map(int, input().split()))", "-print(((sum(ab) - 1) // 2 + 1))", "+print((~-sum(map(int, input().split())) // 2 + 1))" ]
false
0.041649
0.045763
0.910109
[ "s573604043", "s062586660" ]
u708255304
p03038
python
s787435202
s999875685
554
478
27,980
36,856
Accepted
Accepted
13.72
N, M = list(map(int, input().split())) A = list(map(int, input().split())) # 二次元配列を作る BC = [] for i in range(M): b, c = list(map(int, input().split())) BC.append([b, c]) BC = sorted(BC, reverse=True, key=lambda x: x[1]) # Cの値で降順にソートされる cnt = 0 com = [] for b, c in BC: cnt += b if cn...
N, M = list(map(int, input().split())) A = list(map(int, input().split())) magic = [list(map(int, input().split())) for _ in range(M)] magic = sorted(magic, key=lambda x: -x[1]) hold = [] now = 0 for k, v in magic: hold.extend([v]*k) now += k if now >= N: break A.extend(hold) A.sort(re...
27
15
529
345
N, M = list(map(int, input().split())) A = list(map(int, input().split())) # 二次元配列を作る BC = [] for i in range(M): b, c = list(map(int, input().split())) BC.append([b, c]) BC = sorted(BC, reverse=True, key=lambda x: x[1]) # Cの値で降順にソートされる cnt = 0 com = [] for b, c in BC: cnt += b if cnt > N: # 操作を加える回数がN...
N, M = list(map(int, input().split())) A = list(map(int, input().split())) magic = [list(map(int, input().split())) for _ in range(M)] magic = sorted(magic, key=lambda x: -x[1]) hold = [] now = 0 for k, v in magic: hold.extend([v] * k) now += k if now >= N: break A.extend(hold) A.sort(reverse=True) ...
false
44.444444
[ "-# 二次元配列を作る", "-BC = []", "-for i in range(M):", "- b, c = list(map(int, input().split()))", "- BC.append([b, c])", "-BC = sorted(BC, reverse=True, key=lambda x: x[1]) # Cの値で降順にソートされる", "-cnt = 0", "-com = []", "-for b, c in BC:", "- cnt += b", "- if cnt > N: # 操作を加える回数がNを超えることはない...
false
0.063563
0.037071
1.714659
[ "s787435202", "s999875685" ]
u389910364
p03283
python
s291491362
s223537877
1,540
1,405
81,332
103,076
Accepted
Accepted
8.77
import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 N, M, Q = list(map(int, sys.stdin.buffer.readline().split())) LR = [list(map(int, sys.stdin.buffe...
import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 N, M, Q = list(map(int, sys.stdin.buffer.readline().split())) LR = [list(map(int, sys.stdin.buffe...
27
29
680
732
import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 N, M, Q = list(map(int, sys.stdin.buffer.readline().split())) LR = [list(map(int, sys.stdin.buffer.readline().split())) for...
import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 N, M, Q = list(map(int, sys.stdin.buffer.readline().split())) LR = [list(map(int, sys.stdin.buffer.readline().split())) for...
false
6.896552
[ "-PQ = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(Q)]", "+P, Q = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(Q)]))", "+P = np.array(P, dtype=int)", "+Q = np.array(Q, dtype=int)", "-for p, q in PQ:", "- ans = cum[q, q] - cum[p - 1, q] - cum[q, p - 1] ...
false
0.236328
0.312441
0.756392
[ "s291491362", "s223537877" ]
u550061714
p03161
python
s130182448
s485625974
1,496
500
22,812
56,416
Accepted
Accepted
66.58
import numpy as np N, K = list(map(int, input().split())) H = np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64) table = np.full(N + K, 10 ** 10, dtype=np.int64) table[0] = 0 for i in range(1, N): table[i:i + K] = np.minimum(table[i:i + K], np.abs(H[i:i + K] - H[i - 1]) + table[i - 1]) ...
N, K = list(map(int, input().split())) H = tuple(map(int, input().split())) table = [0] * N for i in range(1, N): table[i] = min(abs(H[i] - H[j]) + table[j] for j in range(max(0, i - K), i)) print((table[N-1]))
12
8
337
216
import numpy as np N, K = list(map(int, input().split())) H = np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64) table = np.full(N + K, 10**10, dtype=np.int64) table[0] = 0 for i in range(1, N): table[i : i + K] = np.minimum( table[i : i + K], np.abs(H[i : i + K] - H[i - 1]) + table[i - 1]...
N, K = list(map(int, input().split())) H = tuple(map(int, input().split())) table = [0] * N for i in range(1, N): table[i] = min(abs(H[i] - H[j]) + table[j] for j in range(max(0, i - K), i)) print((table[N - 1]))
false
33.333333
[ "-import numpy as np", "-", "-H = np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64)", "-table = np.full(N + K, 10**10, dtype=np.int64)", "-table[0] = 0", "+H = tuple(map(int, input().split()))", "+table = [0] * N", "- table[i : i + K] = np.minimum(", "- table[i : i + K], ...
false
0.180532
0.03524
5.122983
[ "s130182448", "s485625974" ]
u392029857
p03854
python
s310689915
s198309035
69
19
3,316
3,188
Accepted
Accepted
72.46
S = eval(input()) while len(S) > 0: if 'dream' in S[-5:]: S = S[:-5] continue if 'dreamer' in S[-7:]: S = S[:-7] continue if 'erase' in S[-5:]: S = S[:-5] continue if 'eraser' in S[-6:]: S = S[:-6] continue break if S == ...
S = eval(input()) T = S.replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '') if T == '': print('YES') else: print('NO')
19
6
359
160
S = eval(input()) while len(S) > 0: if "dream" in S[-5:]: S = S[:-5] continue if "dreamer" in S[-7:]: S = S[:-7] continue if "erase" in S[-5:]: S = S[:-5] continue if "eraser" in S[-6:]: S = S[:-6] continue break if S == "": print("...
S = eval(input()) T = ( S.replace("eraser", "") .replace("erase", "") .replace("dreamer", "") .replace("dream", "") ) if T == "": print("YES") else: print("NO")
false
68.421053
[ "-while len(S) > 0:", "- if \"dream\" in S[-5:]:", "- S = S[:-5]", "- continue", "- if \"dreamer\" in S[-7:]:", "- S = S[:-7]", "- continue", "- if \"erase\" in S[-5:]:", "- S = S[:-5]", "- continue", "- if \"eraser\" in S[-6:]:", "- ...
false
0.037423
0.035761
1.046495
[ "s310689915", "s198309035" ]
u960783046
p03073
python
s847425604
s630724344
97
80
3,188
3,188
Accepted
Accepted
17.53
Tiles=eval(input()) N_len=len(Tiles) type1 = 0 # 1スタート for i in range(N_len): if Tiles[i] == str(i%2): type1 += 1 # 0スタート type2=0 for i in range(N_len): if Tiles[i] != str(i%2): type2 += 1 print((min(type1,type2)))
Tiles=eval(input()) N_len=len(Tiles) type1 = sum( 1 if Tiles[i] == str(i%2) else 0 for i in range(N_len)) type2 = sum( 0 if Tiles[i] == str(i%2) else 1 for i in range(N_len)) print((min(type1,type2)))
18
6
268
198
Tiles = eval(input()) N_len = len(Tiles) type1 = 0 # 1スタート for i in range(N_len): if Tiles[i] == str(i % 2): type1 += 1 # 0スタート type2 = 0 for i in range(N_len): if Tiles[i] != str(i % 2): type2 += 1 print((min(type1, type2)))
Tiles = eval(input()) N_len = len(Tiles) type1 = sum(1 if Tiles[i] == str(i % 2) else 0 for i in range(N_len)) type2 = sum(0 if Tiles[i] == str(i % 2) else 1 for i in range(N_len)) print((min(type1, type2)))
false
66.666667
[ "-type1 = 0", "-# 1スタート", "-for i in range(N_len):", "- if Tiles[i] == str(i % 2):", "- type1 += 1", "-# 0スタート", "-type2 = 0", "-for i in range(N_len):", "- if Tiles[i] != str(i % 2):", "- type2 += 1", "+type1 = sum(1 if Tiles[i] == str(i % 2) else 0 for i in range(N_len))", ...
false
0.04418
0.090254
0.489509
[ "s847425604", "s630724344" ]
u764600134
p02996
python
s318186689
s425266892
1,058
800
52,348
41,356
Accepted
Accepted
24.39
# -*- coding: utf-8 -*- """ D - Megalomania https://atcoder.jp/contests/abc131/tasks/abc131_d """ import sys from heapq import heappop, heappush def solve(N, tasks): ct = 0 hq = [] for a, b in tasks: heappush(hq, (b, a)) while hq: b, a = heappop(hq) ct += ...
# -*- coding: utf-8 -*- """ D - Megalomania https://atcoder.jp/contests/abc131/tasks/abc131_d """ import sys def solve(N, tasks): ct = 0 tasks.sort(key=lambda x: x[1], reverse=True) while tasks: a, b = tasks.pop() ct += a if ct > b: return 'No' r...
34
30
594
541
# -*- coding: utf-8 -*- """ D - Megalomania https://atcoder.jp/contests/abc131/tasks/abc131_d """ import sys from heapq import heappop, heappush def solve(N, tasks): ct = 0 hq = [] for a, b in tasks: heappush(hq, (b, a)) while hq: b, a = heappop(hq) ct += a if ct > b: ...
# -*- coding: utf-8 -*- """ D - Megalomania https://atcoder.jp/contests/abc131/tasks/abc131_d """ import sys def solve(N, tasks): ct = 0 tasks.sort(key=lambda x: x[1], reverse=True) while tasks: a, b = tasks.pop() ct += a if ct > b: return "No" return "Yes" def ma...
false
11.764706
[ "-from heapq import heappop, heappush", "- hq = []", "- for a, b in tasks:", "- heappush(hq, (b, a))", "- while hq:", "- b, a = heappop(hq)", "+ tasks.sort(key=lambda x: x[1], reverse=True)", "+ while tasks:", "+ a, b = tasks.pop()" ]
false
0.046071
0.03682
1.251231
[ "s318186689", "s425266892" ]
u145950990
p03239
python
s813961136
s387122231
171
17
38,256
2,940
Accepted
Accepted
90.06
n,T = list(map(int,input().split())) min_c = 10**4 for i in range(n): c,t = list(map(int,input().split())) if t<=T and min_c>c: min_c = c print(('TLE' if min_c==10**4 else min_c))
ans = 10**10 n,time = list(map(int,input().split())) for i in range(n): c,t = list(map(int,input().split())) if t<=time and c<ans: ans = c print(('TLE' if ans==10**10 else ans))
7
7
187
185
n, T = list(map(int, input().split())) min_c = 10**4 for i in range(n): c, t = list(map(int, input().split())) if t <= T and min_c > c: min_c = c print(("TLE" if min_c == 10**4 else min_c))
ans = 10**10 n, time = list(map(int, input().split())) for i in range(n): c, t = list(map(int, input().split())) if t <= time and c < ans: ans = c print(("TLE" if ans == 10**10 else ans))
false
0
[ "-n, T = list(map(int, input().split()))", "-min_c = 10**4", "+ans = 10**10", "+n, time = list(map(int, input().split()))", "- if t <= T and min_c > c:", "- min_c = c", "-print((\"TLE\" if min_c == 10**4 else min_c))", "+ if t <= time and c < ans:", "+ ans = c", "+print((\"TLE\...
false
0.095222
0.037871
2.514359
[ "s813961136", "s387122231" ]
u347640436
p03013
python
s285149655
s257842076
192
156
11,884
17,304
Accepted
Accepted
18.75
n, m = [int(e) for e in input().split()] a = set(int(eval(input())) for i in range(m)) t = [0] * (n + 2) t[0] = 1 for i in range(n): if i in a: t[i] = 0 else: t[i + 1] = (t[i + 1] + t[i]) % 1000000007 t[i + 2] = (t[i + 2] + t[i]) % 1000000007 print((t[n]))
# DP(動的計画法) N, M = list(map(int, input().split())) A = set(int(eval(input())) for _ in range(M)) m = 1000000007 t = [0] * (N + 2) t[0] = 1 for i in range(N): if i in A: t[i] = 0 else: t[i + 1] = (t[i + 1] + t[i]) % m t[i + 2] = (t[i + 2] + t[i]) % m print((t[N]))
11
15
275
298
n, m = [int(e) for e in input().split()] a = set(int(eval(input())) for i in range(m)) t = [0] * (n + 2) t[0] = 1 for i in range(n): if i in a: t[i] = 0 else: t[i + 1] = (t[i + 1] + t[i]) % 1000000007 t[i + 2] = (t[i + 2] + t[i]) % 1000000007 print((t[n]))
# DP(動的計画法) N, M = list(map(int, input().split())) A = set(int(eval(input())) for _ in range(M)) m = 1000000007 t = [0] * (N + 2) t[0] = 1 for i in range(N): if i in A: t[i] = 0 else: t[i + 1] = (t[i + 1] + t[i]) % m t[i + 2] = (t[i + 2] + t[i]) % m print((t[N]))
false
26.666667
[ "-n, m = [int(e) for e in input().split()]", "-a = set(int(eval(input())) for i in range(m))", "-t = [0] * (n + 2)", "+# DP(動的計画法)", "+N, M = list(map(int, input().split()))", "+A = set(int(eval(input())) for _ in range(M))", "+m = 1000000007", "+t = [0] * (N + 2)", "-for i in range(n):", "- if...
false
0.043853
0.046659
0.939867
[ "s285149655", "s257842076" ]
u318233626
p02762
python
s158291506
s836059453
1,359
1,138
36,628
44,820
Accepted
Accepted
16.26
import sys sys.setrecursionlimit(4100000) #Union Findデータ構造 class UnionFind: def __init__(self, n): #Data: 正:親要素のノード番号, 負:サイズ self.D = [-1 for i in range(n)] def find(self, x:int)->int: if self.D[x] < 0: return x else: self.D[x] = self.fi...
import sys sys.setrecursionlimit(4100000) n, m, k = map(int, input().split()) F = [[] for i in range(n)] #Friend list for i in range(m): a, b = map(int, input().split()) a, b = a-1, b-1 F[a].append(b) F[b].append(a) gnum = 1 #group number #DFS def DFS_func(a:int, gnum:int): #Ta...
64
49
1,457
1,113
import sys sys.setrecursionlimit(4100000) # Union Findデータ構造 class UnionFind: def __init__(self, n): # Data: 正:親要素のノード番号, 負:サイズ self.D = [-1 for i in range(n)] def find(self, x: int) -> int: if self.D[x] < 0: return x else: self.D[x] = self.find(self.D[x]...
import sys sys.setrecursionlimit(4100000) n, m, k = map(int, input().split()) F = [[] for i in range(n)] # Friend list for i in range(m): a, b = map(int, input().split()) a, b = a - 1, b - 1 F[a].append(b) F[b].append(a) gnum = 1 # group number # DFS def DFS_func(a: int, gnum: int): # Target, Data ...
false
23.4375
[ "-# Union Findデータ構造", "-class UnionFind:", "- def __init__(self, n):", "- # Data: 正:親要素のノード番号, 負:サイズ", "- self.D = [-1 for i in range(n)]", "-", "- def find(self, x: int) -> int:", "- if self.D[x] < 0:", "- return x", "- else:", "- self.D[x...
false
0.077698
0.047394
1.639411
[ "s158291506", "s836059453" ]
u906428167
p02803
python
s449861524
s508742279
305
266
46,316
44,268
Accepted
Accepted
12.79
from collections import deque def solve(S, s): if S[s[0]][s[1]] != ".": return -1 queue = deque([s]) visited = [[-1 for _ in range(W)] for _ in range(H)] visited[s[0]][s[1]] = 0 while queue: y, x = queue.popleft() for j, k in ([1,0], [-1,0], [0,1], [0,-1]): ...
from collections import deque h, w = list(map(int, input().split())) s = [[x for x in eval(input())] for _ in range(h)] delta = [(-1, 0), (1, 0), (0, 1), (0, -1)] def bfs(i, j): if s[i][j] == '#': return -1 q = deque([(i, j)]) visited = [[-1 for _ in range(w)] for __ in range(h)] ...
28
31
829
800
from collections import deque def solve(S, s): if S[s[0]][s[1]] != ".": return -1 queue = deque([s]) visited = [[-1 for _ in range(W)] for _ in range(H)] visited[s[0]][s[1]] = 0 while queue: y, x = queue.popleft() for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]): ...
from collections import deque h, w = list(map(int, input().split())) s = [[x for x in eval(input())] for _ in range(h)] delta = [(-1, 0), (1, 0), (0, 1), (0, -1)] def bfs(i, j): if s[i][j] == "#": return -1 q = deque([(i, j)]) visited = [[-1 for _ in range(w)] for __ in range(h)] visited[i][j...
false
9.677419
[ "+h, w = list(map(int, input().split()))", "+s = [[x for x in eval(input())] for _ in range(h)]", "+delta = [(-1, 0), (1, 0), (0, 1), (0, -1)]", "-def solve(S, s):", "- if S[s[0]][s[1]] != \".\":", "+", "+def bfs(i, j):", "+ if s[i][j] == \"#\":", "- queue = deque([s])", "- visited = [...
false
0.040737
0.03875
1.05127
[ "s449861524", "s508742279" ]
u747602774
p02928
python
s495288497
s993539181
1,382
920
3,188
3,188
Accepted
Accepted
33.43
N,K = list(map(int,input().split())) A = list(map(int,input().split())) P = 10**9+7 ans1 = 0 ans2 = 0 for i in range(N): for j in range(N): if i == j: continue if A[i] > A[j]: if i < j: ans1 += 1 else: ans2 += 1 ...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) P = 10**9+7 ans1 = 0 ans2 = 0 for i in range(N): for j in range(N): if A[i] > A[j]: if i < j: ans1 += 1 elif i > j: ans2 += 1 K1 = (K*(K+1)//2)%P K2 = (K*(K-1)//...
23
21
398
362
N, K = list(map(int, input().split())) A = list(map(int, input().split())) P = 10**9 + 7 ans1 = 0 ans2 = 0 for i in range(N): for j in range(N): if i == j: continue if A[i] > A[j]: if i < j: ans1 += 1 else: ans2 += 1 K1 = (K * (K + ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) P = 10**9 + 7 ans1 = 0 ans2 = 0 for i in range(N): for j in range(N): if A[i] > A[j]: if i < j: ans1 += 1 elif i > j: ans2 += 1 K1 = (K * (K + 1) // 2) % P K2 = (K * (K - 1) // ...
false
8.695652
[ "- if i == j:", "- continue", "- else:", "+ elif i > j:" ]
false
0.035103
0.034235
1.025376
[ "s495288497", "s993539181" ]
u050641473
p02725
python
s952716901
s718274050
125
110
26,060
26,596
Accepted
Accepted
12
K, N = list(map(int, input().split())) house = list(map(int,input().split())) house = house + house min = house[N - 1] - house[0] for i in range(N - 1): if K - (house[N + 1 + i] - house[i]) < min: min = K - (house[N + 1 + i] - house[i]) print(min)
K, N = list(map(int, input().split())) house = list(map(int,input().split())) min = house[N - 1] - house[0] for i in range(N - 1): if K - (house[i + 1] - house[i]) < min: min = K - (house[i + 1] - house[i]) print(min)
10
9
260
229
K, N = list(map(int, input().split())) house = list(map(int, input().split())) house = house + house min = house[N - 1] - house[0] for i in range(N - 1): if K - (house[N + 1 + i] - house[i]) < min: min = K - (house[N + 1 + i] - house[i]) print(min)
K, N = list(map(int, input().split())) house = list(map(int, input().split())) min = house[N - 1] - house[0] for i in range(N - 1): if K - (house[i + 1] - house[i]) < min: min = K - (house[i + 1] - house[i]) print(min)
false
10
[ "-house = house + house", "- if K - (house[N + 1 + i] - house[i]) < min:", "- min = K - (house[N + 1 + i] - house[i])", "+ if K - (house[i + 1] - house[i]) < min:", "+ min = K - (house[i + 1] - house[i])" ]
false
0.049467
0.046371
1.06675
[ "s952716901", "s718274050" ]
u130900604
p02820
python
s693535526
s168158659
68
46
4,084
4,084
Accepted
Accepted
32.35
n,k=list(map(int,input().split())) r,s,p=list(map(int,input().split())) t=list(eval(input())) point=dict() point["p"]=s #s wins p point["s"]=r #r wins s point["r"]=p #p wins r point["checked"]=0 ans=0 for i in range(n): tmp=i-k if tmp>=0 and t[tmp]==t[i]: ans+=0 t[i]="checked" else: ...
def main(): n,k=list(map(int,input().split())) r,s,p=list(map(int,input().split())) t=list(eval(input())) point=dict() point["p"]=s #s wins p point["s"]=r #r wins s point["r"]=p #p wins r point["checked"]=0 ans=0 for i in range(n): tmp=i-k if tmp>=0 and t[tmp]==t[i]: ...
19
23
335
393
n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = list(eval(input())) point = dict() point["p"] = s # s wins p point["s"] = r # r wins s point["r"] = p # p wins r point["checked"] = 0 ans = 0 for i in range(n): tmp = i - k if tmp >= 0 and t[tmp] == t[i]: ans += 0 ...
def main(): n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = list(eval(input())) point = dict() point["p"] = s # s wins p point["s"] = r # r wins s point["r"] = p # p wins r point["checked"] = 0 ans = 0 for i in range(n): tmp = i - k...
false
17.391304
[ "-n, k = list(map(int, input().split()))", "-r, s, p = list(map(int, input().split()))", "-t = list(eval(input()))", "-point = dict()", "-point[\"p\"] = s # s wins p", "-point[\"s\"] = r # r wins s", "-point[\"r\"] = p # p wins r", "-point[\"checked\"] = 0", "-ans = 0", "-for i in range(n):", ...
false
0.071828
0.04119
1.743827
[ "s693535526", "s168158659" ]
u434630332
p03597
python
s342000183
s404764613
31
25
9,024
9,084
Accepted
Accepted
19.35
n = int(eval(input())) a = int(eval(input())) y = n * n x = y - a print(x)
n = int(eval(input())) a = int(eval(input())) print((n * n - a))
7
4
70
54
n = int(eval(input())) a = int(eval(input())) y = n * n x = y - a print(x)
n = int(eval(input())) a = int(eval(input())) print((n * n - a))
false
42.857143
[ "-y = n * n", "-x = y - a", "-print(x)", "+print((n * n - a))" ]
false
0.038174
0.045176
0.84501
[ "s342000183", "s404764613" ]
u745087332
p03291
python
s557421710
s126195892
259
106
27,636
3,188
Accepted
Accepted
59.07
# coding:utf-8 import sys input = sys.stdin.readline INF = float('inf') MOD = 10 ** 9 + 7 def inpl(): return list(map(int, input().split())) S = input().rstrip() dp = [[0] * 4 for _ in range(len(S) + 1)] dp[0][0] = 1 for i in range(len(S)): if S[i] == '?': dp[i + 1][0] = (dp[i][0]...
# coding:utf-8 import sys input = sys.stdin.readline INF = float('inf') MOD = 10 ** 9 + 7 def inpl(): return list(map(int, input().split())) S = input().rstrip() na, a, ab, abc = 1, 0, 0, 0 for s in S: if s == 'A': a = (a + na) % MOD if s == 'B': ab = (ab + a) % MOD ...
35
31
854
574
# coding:utf-8 import sys input = sys.stdin.readline INF = float("inf") MOD = 10**9 + 7 def inpl(): return list(map(int, input().split())) S = input().rstrip() dp = [[0] * 4 for _ in range(len(S) + 1)] dp[0][0] = 1 for i in range(len(S)): if S[i] == "?": dp[i + 1][0] = (dp[i][0] * 3) % MOD ...
# coding:utf-8 import sys input = sys.stdin.readline INF = float("inf") MOD = 10**9 + 7 def inpl(): return list(map(int, input().split())) S = input().rstrip() na, a, ab, abc = 1, 0, 0, 0 for s in S: if s == "A": a = (a + na) % MOD if s == "B": ab = (ab + a) % MOD if s == "C": ...
false
11.428571
[ "-dp = [[0] * 4 for _ in range(len(S) + 1)]", "-dp[0][0] = 1", "-for i in range(len(S)):", "- if S[i] == \"?\":", "- dp[i + 1][0] = (dp[i][0] * 3) % MOD", "- dp[i + 1][1] = (dp[i][1] * 3 + dp[i][0]) % MOD", "- dp[i + 1][2] = (dp[i][2] * 3 + dp[i][1]) % MOD", "- dp[i + 1]...
false
0.088672
0.095344
0.930024
[ "s557421710", "s126195892" ]
u285681431
p02972
python
s405471990
s194125834
430
177
17,496
92,272
Accepted
Accepted
58.84
N = int(eval(input())) a = list(map(int, input().split())) box = [-1] * (N + 1) ball_in_list = [] # 箱について(i = N, N-1, ..., 1) for i in range(N, 0, -1): cnt = 0 # (N//i)*i, ..., 3*i, 2*i for j in range((N // i) * i, 2 * i - 1, -i): cnt += box[j] # 偶奇が同じならボールは入れない if cnt % 2 == ...
N = int(eval(input())) a = [0] + list(map(int, input().split())) box = [0] * (N + 1) ans = [] # ex. 3の倍数は 3*1, 3*2, ..., 3*(N//3 - 1), 3*(N//3) # 箱Nから確定させていく (箱番号が大きいものほど、考慮すべき箱の数が少ない) # 箱iについて for i in range(N, 0, -1): cnt = 0 # 2*i, 3*i, ..., N//i * i について、現在のボールの総和 for j in range(N // i, ...
22
27
488
562
N = int(eval(input())) a = list(map(int, input().split())) box = [-1] * (N + 1) ball_in_list = [] # 箱について(i = N, N-1, ..., 1) for i in range(N, 0, -1): cnt = 0 # (N//i)*i, ..., 3*i, 2*i for j in range((N // i) * i, 2 * i - 1, -i): cnt += box[j] # 偶奇が同じならボールは入れない if cnt % 2 == a[i - 1]: ...
N = int(eval(input())) a = [0] + list(map(int, input().split())) box = [0] * (N + 1) ans = [] # ex. 3の倍数は 3*1, 3*2, ..., 3*(N//3 - 1), 3*(N//3) # 箱Nから確定させていく (箱番号が大きいものほど、考慮すべき箱の数が少ない) # 箱iについて for i in range(N, 0, -1): cnt = 0 # 2*i, 3*i, ..., N//i * i について、現在のボールの総和 for j in range(N // i, 1, -1): ...
false
18.518519
[ "-a = list(map(int, input().split()))", "-box = [-1] * (N + 1)", "-ball_in_list = []", "-# 箱について(i = N, N-1, ..., 1)", "+a = [0] + list(map(int, input().split()))", "+box = [0] * (N + 1)", "+ans = []", "+# ex. 3の倍数は 3*1, 3*2, ..., 3*(N//3 - 1), 3*(N//3)", "+# 箱Nから確定させていく (箱番号が大きいものほど、考慮すべき箱の数が少ない)",...
false
0.040845
0.034492
1.184194
[ "s405471990", "s194125834" ]
u022407960
p02367
python
s795289253
s315473573
210
190
23,916
23,908
Accepted
Accepted
9.52
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 0 1 1 2 2 3 3 4 """ import sys from operator import itemgetter sys.setrecursionlimit(int(3e6)) def generate_adj_table(_v_info): for v_detail in _v_info: v_from, v_to = list(map(int, v_detail)...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 0 1 1 2 2 3 3 4 """ import sys sys.setrecursionlimit(int(3e6)) def generate_adj_table(_v_info): for v_detail in _v_info: v_from, v_to = list(map(int, v_detail)) init_adj_table[v_from].a...
96
94
2,286
2,251
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 0 1 1 2 2 3 3 4 """ import sys from operator import itemgetter sys.setrecursionlimit(int(3e6)) def generate_adj_table(_v_info): for v_detail in _v_info: v_from, v_to = list(map(int, v_detail)) init_adj_table[v_fr...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 0 1 1 2 2 3 3 4 """ import sys sys.setrecursionlimit(int(3e6)) def generate_adj_table(_v_info): for v_detail in _v_info: v_from, v_to = list(map(int, v_detail)) init_adj_table[v_from].append(v_to) # undir...
false
2.083333
[ "-from operator import itemgetter" ]
false
0.008595
0.041061
0.209333
[ "s795289253", "s315473573" ]
u525065967
p02598
python
s185894527
s606368536
1,356
541
30,916
30,812
Accepted
Accepted
60.1
n, k = list(map(int, input().split())) A = [*list(map(int, input().split()))] A.sort(reverse=True) ng, ok = 0, 1<<30 while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: d = (a - 1) // m if d == 0: break c += d if c <= k: ok = m else: ng = m print(ok)
_, k = list(map(int, input().split())) A = [*list(map(int, input().split()))] ng, ok = 0, 1<<30 while ok - ng > 1: m = (ng + ok) // 2 if k < sum([(a-1)//m for a in A]): ng = m else: ok = m print(ok)
14
8
300
206
n, k = list(map(int, input().split())) A = [*list(map(int, input().split()))] A.sort(reverse=True) ng, ok = 0, 1 << 30 while ok - ng > 1: m = (ng + ok) // 2 c = 0 for a in A: d = (a - 1) // m if d == 0: break c += d if c <= k: ok = m else: ng = m p...
_, k = list(map(int, input().split())) A = [*list(map(int, input().split()))] ng, ok = 0, 1 << 30 while ok - ng > 1: m = (ng + ok) // 2 if k < sum([(a - 1) // m for a in A]): ng = m else: ok = m print(ok)
false
42.857143
[ "-n, k = list(map(int, input().split()))", "+_, k = list(map(int, input().split()))", "-A.sort(reverse=True)", "- c = 0", "- for a in A:", "- d = (a - 1) // m", "- if d == 0:", "- break", "- c += d", "- if c <= k:", "+ if k < sum([(a - 1) // m for a in...
false
0.043053
0.07816
0.55083
[ "s185894527", "s606368536" ]
u054825571
p02633
python
s764863257
s468889748
30
27
9,044
9,072
Accepted
Accepted
10
import math n=int(eval(input())) print((360//math.gcd(n,360)))
import math print((360//math.gcd(int(eval(input())),360)))
3
2
56
51
import math n = int(eval(input())) print((360 // math.gcd(n, 360)))
import math print((360 // math.gcd(int(eval(input())), 360)))
false
33.333333
[ "-n = int(eval(input()))", "-print((360 // math.gcd(n, 360)))", "+print((360 // math.gcd(int(eval(input())), 360)))" ]
false
0.0373
0.036977
1.008735
[ "s764863257", "s468889748" ]
u197615397
p02235
python
s071258484
s588737907
1,360
1,070
123,684
5,660
Accepted
Accepted
21.32
def lcs_hs(s1, s2): from bisect import bisect_left p = [] append_p = p.append for i, c in enumerate(s1): j = s2.find(c)+1 while j: append_p((i, -j)) j = s2.find(c, j)+1 lis, result = [], 0 append_lis = lis.append for _, y in sorted(p): ...
def lcs_hs(s1, s2): from bisect import bisect_left s2 = s2[::-1] lis, result = [], 0 append = lis.append for c in s1: i = s2.find(c)+1 while i: j = bisect_left(lis, -i) if j >= result: append(-i) result += 1 ...
25
23
568
495
def lcs_hs(s1, s2): from bisect import bisect_left p = [] append_p = p.append for i, c in enumerate(s1): j = s2.find(c) + 1 while j: append_p((i, -j)) j = s2.find(c, j) + 1 lis, result = [], 0 append_lis = lis.append for _, y in sorted(p): i =...
def lcs_hs(s1, s2): from bisect import bisect_left s2 = s2[::-1] lis, result = [], 0 append = lis.append for c in s1: i = s2.find(c) + 1 while i: j = bisect_left(lis, -i) if j >= result: append(-i) result += 1 else:...
false
8
[ "- p = []", "- append_p = p.append", "- for i, c in enumerate(s1):", "- j = s2.find(c) + 1", "- while j:", "- append_p((i, -j))", "- j = s2.find(c, j) + 1", "+ s2 = s2[::-1]", "- append_lis = lis.append", "- for _, y in sorted(p):", "- ...
false
0.126717
0.056551
2.240737
[ "s071258484", "s588737907" ]
u254871849
p03240
python
s344021281
s594815435
31
28
3,064
3,064
Accepted
Accepted
9.68
# 2019-11-10 20:23:41(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # from scipy.misc import comb # float ...
import sys n, *xyh = map(int, sys.stdin.read().split()) xyh = list(zip(*[iter(xyh)] * 3)) def conflict(cx, cy, ch, x, y, h): return h != max(ch - abs(x - cx) - abs(y - cy), 0) def main(): for x, y, h in xyh: if h >= 1: xt, yt, ht = x, y, h break for cx i...
41
26
1,319
654
# 2019-11-10 20:23:41(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce # import operator as op # from scipy.misc import comb # float # import ...
import sys n, *xyh = map(int, sys.stdin.read().split()) xyh = list(zip(*[iter(xyh)] * 3)) def conflict(cx, cy, ch, x, y, h): return h != max(ch - abs(x - cx) - abs(y - cy), 0) def main(): for x, y, h in xyh: if h >= 1: xt, yt, ht = x, y, h break for cx in range(101): ...
false
36.585366
[ "-# 2019-11-10 20:23:41(JST)", "-# import collections", "-# import math", "-# from string import ascii_lowercase, ascii_uppercase, digits", "-# from bisect import bisect_left as bi_l, bisect_right as bi_r", "-# import itertools", "-# from functools import reduce", "-# import operator as op", "-# fro...
false
0.040486
0.095045
0.425962
[ "s344021281", "s594815435" ]
u977349332
p03835
python
s233828148
s092113659
1,890
1,437
2,940
2,940
Accepted
Accepted
23.97
K, S = list(map(int, input().split())) answer = 0 for x in range(K+1): for y in range(K+1): if S - x - y <= K and S -x-y >=0: answer += 1 print(answer)
k, s = list(map(int, input().split())) count = 0 for x in range(k+1): for y in range(k+1): if 0 <= s - x - y <= k: count += 1 print(count)
9
9
168
149
K, S = list(map(int, input().split())) answer = 0 for x in range(K + 1): for y in range(K + 1): if S - x - y <= K and S - x - y >= 0: answer += 1 print(answer)
k, s = list(map(int, input().split())) count = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y <= k: count += 1 print(count)
false
0
[ "-K, S = list(map(int, input().split()))", "-answer = 0", "-for x in range(K + 1):", "- for y in range(K + 1):", "- if S - x - y <= K and S - x - y >= 0:", "- answer += 1", "-print(answer)", "+k, s = list(map(int, input().split()))", "+count = 0", "+for x in range(k + 1):", ...
false
0.042166
0.040507
1.040954
[ "s233828148", "s092113659" ]
u684120680
p03061
python
s302867531
s905033929
221
200
16,144
16,124
Accepted
Accepted
9.5
import fractions import functools import sys n=int(eval(input())) a = [int(i) for i in input().split()] a.sort() if len(a) == 2: print((max(a))) sys.exit() gcd_a = functools.reduce(fractions.gcd, a) a=[i//gcd_a for i in a] so = 0 cnt = 0 gcd_0 = functools.reduce(fractions.gcd, a[1:]) for i i...
from fractions import gcd import functools import sys n=int(eval(input())) a = [int(i) for i in input().split()] left_gcd = [a[0]] for i in range(1,len(a)): left_gcd.append(gcd(left_gcd[-1],a[i])) #print(left_gcd) right_gcd = [a[-1]] for i in range(len(a)-1)[::-1]: right_gcd.append(gcd(right_gcd[...
31
26
587
572
import fractions import functools import sys n = int(eval(input())) a = [int(i) for i in input().split()] a.sort() if len(a) == 2: print((max(a))) sys.exit() gcd_a = functools.reduce(fractions.gcd, a) a = [i // gcd_a for i in a] so = 0 cnt = 0 gcd_0 = functools.reduce(fractions.gcd, a[1:]) for i in range(1, le...
from fractions import gcd import functools import sys n = int(eval(input())) a = [int(i) for i in input().split()] left_gcd = [a[0]] for i in range(1, len(a)): left_gcd.append(gcd(left_gcd[-1], a[i])) # print(left_gcd) right_gcd = [a[-1]] for i in range(len(a) - 1)[::-1]: right_gcd.append(gcd(right_gcd[-1], a[...
false
16.129032
[ "-import fractions", "+from fractions import gcd", "-a.sort()", "-if len(a) == 2:", "- print((max(a)))", "- sys.exit()", "-gcd_a = functools.reduce(fractions.gcd, a)", "-a = [i // gcd_a for i in a]", "-so = 0", "-cnt = 0", "-gcd_0 = functools.reduce(fractions.gcd, a[1:])", "+left_gcd = [...
false
0.050793
0.059302
0.856517
[ "s302867531", "s905033929" ]
u170839742
p02695
python
s801736654
s097935827
1,031
690
9,184
140,708
Accepted
Accepted
33.07
from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) A, B, C, D = [], [], [], [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) A.append(a - 1) B.append(b - 1) C.append(c) D.append(d) res = 0 for p in combinations_with_replacement...
def dfs(n, lower): if n == N: return [[]] else: res = [] for i in range(lower, M + 1): for p in dfs(n + 1, i): res.append([i] + p) return res N, M, Q = list(map(int, input().split())) A, B, C, D = [], [], [], [] for _ in range(Q): a...
18
27
477
599
from itertools import combinations_with_replacement N, M, Q = list(map(int, input().split())) A, B, C, D = [], [], [], [] for _ in range(Q): a, b, c, d = list(map(int, input().split())) A.append(a - 1) B.append(b - 1) C.append(c) D.append(d) res = 0 for p in combinations_with_replacement(list(range...
def dfs(n, lower): if n == N: return [[]] else: res = [] for i in range(lower, M + 1): for p in dfs(n + 1, i): res.append([i] + p) return res N, M, Q = list(map(int, input().split())) A, B, C, D = [], [], [], [] for _ in range(Q): a, b, c, d = li...
false
33.333333
[ "-from itertools import combinations_with_replacement", "+def dfs(n, lower):", "+ if n == N:", "+ return [[]]", "+ else:", "+ res = []", "+ for i in range(lower, M + 1):", "+ for p in dfs(n + 1, i):", "+ res.append([i] + p)", "+ return re...
false
0.064314
0.272275
0.236209
[ "s801736654", "s097935827" ]
u597374218
p03089
python
s844289421
s305240843
27
17
3,060
3,060
Accepted
Accepted
37.04
n=int(eval(input())) b=list(map(int,input().split())) a=[0]*(n+1) a[0]=0 for i in b:a.insert(int(i)-1,i) if sum(a[:n])==sum(b): for i in range(n): print((a[i])) else:print((-1))
n=int(eval(input())) B=list(map(int,input().split())) a=[0] for b in B:a.insert(b-1,b) if sum(a[:n])==sum(B): for i in range(n):print((a[i])) else:print((-1))
9
7
187
158
n = int(eval(input())) b = list(map(int, input().split())) a = [0] * (n + 1) a[0] = 0 for i in b: a.insert(int(i) - 1, i) if sum(a[:n]) == sum(b): for i in range(n): print((a[i])) else: print((-1))
n = int(eval(input())) B = list(map(int, input().split())) a = [0] for b in B: a.insert(b - 1, b) if sum(a[:n]) == sum(B): for i in range(n): print((a[i])) else: print((-1))
false
22.222222
[ "-b = list(map(int, input().split()))", "-a = [0] * (n + 1)", "-a[0] = 0", "-for i in b:", "- a.insert(int(i) - 1, i)", "-if sum(a[:n]) == sum(b):", "+B = list(map(int, input().split()))", "+a = [0]", "+for b in B:", "+ a.insert(b - 1, b)", "+if sum(a[:n]) == sum(B):" ]
false
0.039849
0.073584
0.541542
[ "s844289421", "s305240843" ]
u533039576
p03229
python
s679769911
s610761405
297
225
13,884
14,972
Accepted
Accepted
24.24
from collections import deque n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] a.sort() a = deque(a) b = deque([a.pop()]) ans = 0 for _ in range(n - 1): x = max( abs(a[0] - b[0]), abs(a[0] - b[-1]), abs(a[-1] - b[0]), abs(a[-1] - b[-1]), ) ...
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] cand1 = [0] * n cand2 = [0] * n for i in range(n - 1): if i % 2 == 0: cand1[i] -= 1 cand1[i + 1] += 1 cand2[i] += 1 cand2[i + 1] -= 1 else: cand1[i] += 1 cand1[i + 1] -= 1 can...
28
26
594
505
from collections import deque n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] a.sort() a = deque(a) b = deque([a.pop()]) ans = 0 for _ in range(n - 1): x = max( abs(a[0] - b[0]), abs(a[0] - b[-1]), abs(a[-1] - b[0]), abs(a[-1] - b[-1]), ) if x == abs(a[0] -...
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] cand1 = [0] * n cand2 = [0] * n for i in range(n - 1): if i % 2 == 0: cand1[i] -= 1 cand1[i + 1] += 1 cand2[i] += 1 cand2[i + 1] -= 1 else: cand1[i] += 1 cand1[i + 1] -= 1 cand2[i] -= 1 ...
false
7.142857
[ "-from collections import deque", "-", "+cand1 = [0] * n", "+cand2 = [0] * n", "+for i in range(n - 1):", "+ if i % 2 == 0:", "+ cand1[i] -= 1", "+ cand1[i + 1] += 1", "+ cand2[i] += 1", "+ cand2[i + 1] -= 1", "+ else:", "+ cand1[i] += 1", "+ c...
false
0.06929
0.037786
1.83377
[ "s679769911", "s610761405" ]