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
u875541136
p02689
python
s442494595
s225612469
330
255
25,452
20,084
Accepted
Accepted
22.73
N, M = list(map(int, input().split())) H = list(map(int, input().split())) better = [[] for _ in H] for _ in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 if H[A] >= H[B]: better[B].append(A) if H[A] <= H[B]: better[A].append(B) print((sum([1 for b in better if not b]...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) good = [True] * N for _ in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 if H[A] >= H[B]: good[B] = False if H[A] <= H[B]: good[A] = False print((sum(good)))
15
15
309
270
N, M = list(map(int, input().split())) H = list(map(int, input().split())) better = [[] for _ in H] for _ in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 if H[A] >= H[B]: better[B].append(A) if H[A] <= H[B]: better[A].append(B) print((sum([1 for b in better if not b...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) good = [True] * N for _ in range(M): A, B = list(map(int, input().split())) A -= 1 B -= 1 if H[A] >= H[B]: good[B] = False if H[A] <= H[B]: good[A] = False print((sum(good)))
false
0
[ "-better = [[] for _ in H]", "+good = [True] * N", "- better[B].append(A)", "+ good[B] = False", "- better[A].append(B)", "-print((sum([1 for b in better if not b])))", "+ good[A] = False", "+print((sum(good)))" ]
false
0.04616
0.150081
0.307564
[ "s442494595", "s225612469" ]
u533039576
p02936
python
s040176907
s709546087
1,835
761
124,748
117,452
Accepted
Accepted
58.53
from collections import deque n, q = list(map(int, input().split())) edge = [[] for _ in range(n)] for i in range(n-1): a, b = list(map(int, input().split())) a, b = a-1, b-1 edge[a].append(b) edge[b].append(a) imos = [0] * n for i in range(q): p, x = list(map(int, input().split())) ...
import sys from collections import deque input = sys.stdin.readline n, q = list(map(int, input().split())) edge = [[] for _ in range(n)] for i in range(n-1): a, b = list(map(int, input().split())) a, b = a-1, b-1 edge[a].append(b) edge[b].append(a) imos = [0] * n for i in range(q): p...
26
28
546
586
from collections import deque n, q = list(map(int, input().split())) edge = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 edge[a].append(b) edge[b].append(a) imos = [0] * n for i in range(q): p, x = list(map(int, input().split())) p -= ...
import sys from collections import deque input = sys.stdin.readline n, q = list(map(int, input().split())) edge = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 edge[a].append(b) edge[b].append(a) imos = [0] * n for i in range(q): p, x = lis...
false
7.142857
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.038668
0.037949
1.01896
[ "s040176907", "s709546087" ]
u966508131
p03494
python
s956717581
s644807285
190
19
39,920
3,060
Accepted
Accepted
90
eval(input()) A=list(map(int,input().split())) ans=0 while all(a%2==0 for a in A): A=[a/2 for a in A] ans+=1 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 100000 for i in range(len(A)): cnt = 0 while A[i] % 2 == 0: A[i] /= 2 cnt += 1 # print(cnt) ans = min(ans, cnt) print(ans)
7
11
127
224
eval(input()) A = list(map(int, input().split())) ans = 0 while all(a % 2 == 0 for a in A): A = [a / 2 for a in A] ans += 1 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 100000 for i in range(len(A)): cnt = 0 while A[i] % 2 == 0: A[i] /= 2 cnt += 1 # print(cnt) ans = min(ans, cnt) print(ans)
false
36.363636
[ "-eval(input())", "+N = int(eval(input()))", "-ans = 0", "-while all(a % 2 == 0 for a in A):", "- A = [a / 2 for a in A]", "- ans += 1", "+ans = 100000", "+for i in range(len(A)):", "+ cnt = 0", "+ while A[i] % 2 == 0:", "+ A[i] /= 2", "+ cnt += 1", "+ # print(cn...
false
0.033479
0.071472
0.46842
[ "s956717581", "s644807285" ]
u046187684
p02641
python
s218691798
s384382555
33
26
9,460
9,112
Accepted
Accepted
21.21
import bisect import collections x, n = list(map(int, input().split())) p = list(map(int, input().split())) def calc(a): return abs(a - x) if not n: print(x) exit() l = [i for i in range(102) if i not in set(p)] print((min(l, key=calc)))
x, n = list(map(int, input().split())) p = list(map(int, input().split())) def calc(a): return abs(a - x) if not n: print(x) exit() l = [i for i in range(102) if i not in set(p)] print((min(l, key=calc)))
15
12
259
223
import bisect import collections x, n = list(map(int, input().split())) p = list(map(int, input().split())) def calc(a): return abs(a - x) if not n: print(x) exit() l = [i for i in range(102) if i not in set(p)] print((min(l, key=calc)))
x, n = list(map(int, input().split())) p = list(map(int, input().split())) def calc(a): return abs(a - x) if not n: print(x) exit() l = [i for i in range(102) if i not in set(p)] print((min(l, key=calc)))
false
20
[ "-import bisect", "-import collections", "-" ]
false
0.04241
0.104519
0.405767
[ "s218691798", "s384382555" ]
u912237403
p00004
python
s525547073
s139495287
20
10
4,232
4,232
Accepted
Accepted
50
import sys for s in sys.stdin: a,b,c,d,e,f=list(map(float,s.split())) x=c*e-b*f y=a*f-c*d z=a*e-b*d def f(x,z): if x==0: return 0 else: return x/z print("%.3f %.3f" %(f(x,z),f(y,z)))
import sys for s in sys.stdin: a,b,c,d,e,f=list(map(int,s.split())) x=c*e-b*f y=a*f-c*d z=a*e-b*d def f(x,z): if x==0: return 0 else: return 1.0*x/z print("%.3f %.3f" %(f(x,z),f(y,z)))
10
10
224
226
import sys for s in sys.stdin: a, b, c, d, e, f = list(map(float, s.split())) x = c * e - b * f y = a * f - c * d z = a * e - b * d def f(x, z): if x == 0: return 0 else: return x / z print("%.3f %.3f" % (f(x, z), f(y, z)))
import sys for s in sys.stdin: a, b, c, d, e, f = list(map(int, s.split())) x = c * e - b * f y = a * f - c * d z = a * e - b * d def f(x, z): if x == 0: return 0 else: return 1.0 * x / z print("%.3f %.3f" % (f(x, z), f(y, z)))
false
0
[ "- a, b, c, d, e, f = list(map(float, s.split()))", "+ a, b, c, d, e, f = list(map(int, s.split()))", "- return x / z", "+ return 1.0 * x / z" ]
false
0.08911
0.036747
2.424938
[ "s525547073", "s139495287" ]
u344959886
p02786
python
s246819354
s714383037
173
17
38,384
3,060
Accepted
Accepted
90.17
import sys h=int(eval(input())) n=0 while h>1: h=h // 2 n+=1 a=1 for i in range(n): a=a*2+1 print(a)
h=int(eval(input())) def aaa(i): if i == 1: return(1) else: return 2*aaa(i//2)+1 print((aaa(h)))
12
8
123
120
import sys h = int(eval(input())) n = 0 while h > 1: h = h // 2 n += 1 a = 1 for i in range(n): a = a * 2 + 1 print(a)
h = int(eval(input())) def aaa(i): if i == 1: return 1 else: return 2 * aaa(i // 2) + 1 print((aaa(h)))
false
33.333333
[ "-import sys", "+h = int(eval(input()))", "-h = int(eval(input()))", "-n = 0", "-while h > 1:", "- h = h // 2", "- n += 1", "-a = 1", "-for i in range(n):", "- a = a * 2 + 1", "-print(a)", "+", "+def aaa(i):", "+ if i == 1:", "+ return 1", "+ else:", "+ r...
false
0.039149
0.036368
1.076469
[ "s246819354", "s714383037" ]
u254871849
p03078
python
s805563618
s496494572
753
313
90,668
19,892
Accepted
Accepted
58.43
import sys import numpy as np def main(): x, y, z, K = list(map(int, sys.stdin.readline().split())) abc = np.array(sys.stdin.read().split(), dtype=np.int64) a = abc[:x] b = abc[x:x + y] c = abc[x + y:x + y+ z] ab = np.sort(np.array([a[i] + b for i in range(x)]).reshape(-1))[::-1][:K]...
import sys import numpy as np INF = 10 ** 18 def main(): x, y, z, K = list(map(int, sys.stdin.readline().split())) abc = np.array(sys.stdin.read().split(), dtype=np.int64) a = np.append(abc[:x], INF) b = np.append(abc[x:x + y], INF) c = np.append(abc[x + y:x + y+ z], INF) a = np.sor...
17
26
477
708
import sys import numpy as np def main(): x, y, z, K = list(map(int, sys.stdin.readline().split())) abc = np.array(sys.stdin.read().split(), dtype=np.int64) a = abc[:x] b = abc[x : x + y] c = abc[x + y : x + y + z] ab = np.sort(np.array([a[i] + b for i in range(x)]).reshape(-1))[::-1][:K] ...
import sys import numpy as np INF = 10**18 def main(): x, y, z, K = list(map(int, sys.stdin.readline().split())) abc = np.array(sys.stdin.read().split(), dtype=np.int64) a = np.append(abc[:x], INF) b = np.append(abc[x : x + y], INF) c = np.append(abc[x + y : x + y + z], INF) a = np.sort(a)[::...
false
34.615385
[ "+", "+INF = 10**18", "- a = abc[:x]", "- b = abc[x : x + y]", "- c = abc[x + y : x + y + z]", "- ab = np.sort(np.array([a[i] + b for i in range(x)]).reshape(-1))[::-1][:K]", "- res = np.sort(np.array([c[i] + ab for i in range(z)]).reshape(-1))[::-1][:K]", "+ a = np.append(abc[:x], I...
false
0.29759
0.284033
1.047731
[ "s805563618", "s496494572" ]
u941753895
p03478
python
s591582769
s349108904
44
37
2,940
2,940
Accepted
Accepted
15.91
n,a,b=list(map(int,input().split())) c=0 for i in range(1,n+1): x=0 y=list(str(i)) for j in range(len(y)): x+=int(y[j]) if a<=x and x<=b: c+=i print(c)
# 入力 N,A,B=list(map(int,input().split())) c=0 for x in range(1,N+1): y=list(str(x)) # 各桁の和を求める z=sum([int(a) for a in y]) # 各桁の和がA以上B以下なら加算 if A<=z and z<=B: c+=x # 出力 print(c)
10
16
170
203
n, a, b = list(map(int, input().split())) c = 0 for i in range(1, n + 1): x = 0 y = list(str(i)) for j in range(len(y)): x += int(y[j]) if a <= x and x <= b: c += i print(c)
# 入力 N, A, B = list(map(int, input().split())) c = 0 for x in range(1, N + 1): y = list(str(x)) # 各桁の和を求める z = sum([int(a) for a in y]) # 各桁の和がA以上B以下なら加算 if A <= z and z <= B: c += x # 出力 print(c)
false
37.5
[ "-n, a, b = list(map(int, input().split()))", "+# 入力", "+N, A, B = list(map(int, input().split()))", "-for i in range(1, n + 1):", "- x = 0", "- y = list(str(i))", "- for j in range(len(y)):", "- x += int(y[j])", "- if a <= x and x <= b:", "- c += i", "+for x in range(1...
false
0.04534
0.045086
1.005631
[ "s591582769", "s349108904" ]
u761320129
p03659
python
s086144488
s154747833
197
178
24,816
24,172
Accepted
Accepted
9.64
N = int(eval(input())) src = list(map(int,input().split())) s = sum(src) ans = float('inf') tmp = 0 for i in range(N-1): tmp += src[i] rem = s - tmp ans = min(ans, abs(tmp - rem)) print(ans)
from itertools import accumulate as ac N = int(eval(input())) src = list(map(int,input().split())) acum = list(ac(src)) ans = float('inf') for i in range(N-1): ans = min(ans, abs(acum[i] - (acum[-1]-acum[i]))) print(ans)
10
8
206
225
N = int(eval(input())) src = list(map(int, input().split())) s = sum(src) ans = float("inf") tmp = 0 for i in range(N - 1): tmp += src[i] rem = s - tmp ans = min(ans, abs(tmp - rem)) print(ans)
from itertools import accumulate as ac N = int(eval(input())) src = list(map(int, input().split())) acum = list(ac(src)) ans = float("inf") for i in range(N - 1): ans = min(ans, abs(acum[i] - (acum[-1] - acum[i]))) print(ans)
false
20
[ "+from itertools import accumulate as ac", "+", "-s = sum(src)", "+acum = list(ac(src))", "-tmp = 0", "- tmp += src[i]", "- rem = s - tmp", "- ans = min(ans, abs(tmp - rem))", "+ ans = min(ans, abs(acum[i] - (acum[-1] - acum[i])))" ]
false
0.046025
0.050016
0.920203
[ "s086144488", "s154747833" ]
u678167152
p03761
python
s392065030
s695003661
21
19
3,316
3,060
Accepted
Accepted
9.52
from itertools import groupby, accumulate, product, permutations, combinations from collections import Counter def solve(): N = int(eval(input())) dics = [[0]*N for _ in range(26)] S = [eval(input()) for _ in range(N)] for i in range(N): for s in S[i]: dics[ord(s)-ord('a')][i...
from itertools import groupby, accumulate, product, permutations, combinations N = int(eval(input())) dics = [[0]*N for _ in range(26)] for i in range(N): S = eval(input()) for s in S: dics[ord(s)-ord('a')][i]+=1 ans = '' for i in range(26): ans += chr(i+ord('a'))*min(dics[i]) print(ans)
14
11
429
306
from itertools import groupby, accumulate, product, permutations, combinations from collections import Counter def solve(): N = int(eval(input())) dics = [[0] * N for _ in range(26)] S = [eval(input()) for _ in range(N)] for i in range(N): for s in S[i]: dics[ord(s) - ord("a")][i] ...
from itertools import groupby, accumulate, product, permutations, combinations N = int(eval(input())) dics = [[0] * N for _ in range(26)] for i in range(N): S = eval(input()) for s in S: dics[ord(s) - ord("a")][i] += 1 ans = "" for i in range(26): ans += chr(i + ord("a")) * min(dics[i]) print(ans)
false
21.428571
[ "-from collections import Counter", "-", "-def solve():", "- N = int(eval(input()))", "- dics = [[0] * N for _ in range(26)]", "- S = [eval(input()) for _ in range(N)]", "- for i in range(N):", "- for s in S[i]:", "- dics[ord(s) - ord(\"a\")][i] += 1", "- ans = \"\...
false
0.036809
0.03419
1.076593
[ "s392065030", "s695003661" ]
u426649993
p03013
python
s690412898
s992542174
198
146
7,852
14,448
Accepted
Accepted
26.26
if __name__ == "__main__": mod = 10 ** 9 + 7 n, m = list(map(int, input().split())) a = list() for i in range(m): a.append(int(eval(input()))) dp = [0] * (n + 1) for aa in a: dp[aa] = -1 if dp[1] != -1: dp[1] = 1 else: dp[1] = 0 if...
def solve(N, a): mod = 10**9 + 7 dp = [0] * (N+1) step = [0] * (N+1) for aa in a: step[aa] = 1 dp[0] = 1 if step[1] == 0: dp[1] = 1 for i in range(2, N+1): if step[i] == 0: dp[i] = dp[i-1] + dp[i-2] dp[i] %= mod return dp...
30
24
591
462
if __name__ == "__main__": mod = 10**9 + 7 n, m = list(map(int, input().split())) a = list() for i in range(m): a.append(int(eval(input()))) dp = [0] * (n + 1) for aa in a: dp[aa] = -1 if dp[1] != -1: dp[1] = 1 else: dp[1] = 0 if n > 1: if dp[2...
def solve(N, a): mod = 10**9 + 7 dp = [0] * (N + 1) step = [0] * (N + 1) for aa in a: step[aa] = 1 dp[0] = 1 if step[1] == 0: dp[1] = 1 for i in range(2, N + 1): if step[i] == 0: dp[i] = dp[i - 1] + dp[i - 2] dp[i] %= mod return dp[N] if ...
false
20
[ "+def solve(N, a):", "+ mod = 10**9 + 7", "+ dp = [0] * (N + 1)", "+ step = [0] * (N + 1)", "+ for aa in a:", "+ step[aa] = 1", "+ dp[0] = 1", "+ if step[1] == 0:", "+ dp[1] = 1", "+ for i in range(2, N + 1):", "+ if step[i] == 0:", "+ dp[i]...
false
0.076116
0.040945
1.858975
[ "s690412898", "s992542174" ]
u747602774
p03806
python
s470458930
s793926844
618
395
4,872
59,356
Accepted
Accepted
36.08
N,Ma,Mb = list(map(int,input().split())) INF = float('inf') dp = [[INF for b in range(401)] for a in range(401)] dp[0][0] = 0 sa = 0 sb = 0 for i in range(1,N+1): ai,bi,ci = list(map(int,input().split())) sa += ai sb += bi for a in range(sa+1,-1,-1): for b in range(sb+1,-1,-...
N,Ma,Mb = list(map(int,input().split())) INF = float('inf') dp = [[INF for b in range(401)] for a in range(401)] dp[0][0] = 0 for i in range(1,N+1): ai,bi,ci = list(map(int,input().split())) for a in range(400,-1,-1): for b in range(400,-1,-1): if a-ai >= 0 and b-bi >= 0:...
28
22
572
527
N, Ma, Mb = list(map(int, input().split())) INF = float("inf") dp = [[INF for b in range(401)] for a in range(401)] dp[0][0] = 0 sa = 0 sb = 0 for i in range(1, N + 1): ai, bi, ci = list(map(int, input().split())) sa += ai sb += bi for a in range(sa + 1, -1, -1): for b in range(sb + 1, -1, -1): ...
N, Ma, Mb = list(map(int, input().split())) INF = float("inf") dp = [[INF for b in range(401)] for a in range(401)] dp[0][0] = 0 for i in range(1, N + 1): ai, bi, ci = list(map(int, input().split())) for a in range(400, -1, -1): for b in range(400, -1, -1): if a - ai >= 0 and b - bi >= 0: ...
false
21.428571
[ "-sa = 0", "-sb = 0", "- sa += ai", "- sb += bi", "- for a in range(sa + 1, -1, -1):", "- for b in range(sb + 1, -1, -1):", "+ for a in range(400, -1, -1):", "+ for b in range(400, -1, -1):" ]
false
0.119499
1.030154
0.116001
[ "s470458930", "s793926844" ]
u374802266
p02615
python
s215279951
s625246577
146
134
31,588
31,660
Accepted
Accepted
8.22
n=int(eval(input())) a=sorted(list(map(int,input().split())),reverse=True) ans=0 for i in range(n-1): ans+=a[(i+1)//2] print(ans)
n=int(eval(input())) a=sorted(list(map(int,input().split())),reverse=1) b=0 for i in range(n-1): b+=a[(i+1)//2] print(b)
6
6
132
123
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 for i in range(n - 1): ans += a[(i + 1) // 2] print(ans)
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=1) b = 0 for i in range(n - 1): b += a[(i + 1) // 2] print(b)
false
0
[ "-a = sorted(list(map(int, input().split())), reverse=True)", "-ans = 0", "+a = sorted(list(map(int, input().split())), reverse=1)", "+b = 0", "- ans += a[(i + 1) // 2]", "-print(ans)", "+ b += a[(i + 1) // 2]", "+print(b)" ]
false
0.034453
0.035944
0.95852
[ "s215279951", "s625246577" ]
u758738963
p03108
python
s567889899
s642022231
645
398
40,028
85,268
Accepted
Accepted
38.29
import numpy as np class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] ...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y)...
82
80
1,814
1,792
import numpy as np class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, ...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
false
2.439024
[ "-import numpy as np", "-", "-" ]
false
0.03462
0.038167
0.907082
[ "s567889899", "s642022231" ]
u562935282
p03294
python
s222069577
s405937414
95
19
3,316
3,316
Accepted
Accepted
80
n = int(eval(input())) a = list(map(int, input().split())) x = 1 for i in a: x *= i ans = 0 for i in a: ans += (x - 1) % i print(ans)
n = int(eval(input())) a = list(map(int, input().split())) print((sum(a) - len(a)))
12
4
149
79
n = int(eval(input())) a = list(map(int, input().split())) x = 1 for i in a: x *= i ans = 0 for i in a: ans += (x - 1) % i print(ans)
n = int(eval(input())) a = list(map(int, input().split())) print((sum(a) - len(a)))
false
66.666667
[ "-x = 1", "-for i in a:", "- x *= i", "-ans = 0", "-for i in a:", "- ans += (x - 1) % i", "-print(ans)", "+print((sum(a) - len(a)))" ]
false
0.047222
0.047022
1.004247
[ "s222069577", "s405937414" ]
u440566786
p02868
python
s887732752
s475376325
1,599
1,315
263,108
271,424
Accepted
Accepted
17.76
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) N = 1 << (n - 1).bit_length() N2, now = N * 2, N * 3 E = [[] for _ in ra...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) N = 1 << (n - 1).bit_length() N2, N3 = N * 2, N * 3 E = [[] for _ in ran...
67
66
1,801
1,799
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) N = 1 << (n - 1).bit_length() N2, now = N * 2, N * 3 E = [[] for _ in range(N...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m = list(map(int, input().split())) N = 1 << (n - 1).bit_length() N2, N3 = N * 2, N * 3 E = [[] for _ in range(N ...
false
1.492537
[ "- N2, now = N * 2, N * 3", "+ N2, N3 = N * 2, N * 3", "- for _ in range(m):", "+ for i in range(m):", "- E[ref(l + N2)].append((now, w))", "+ E[ref(l + N2)].append((N3 + i, w))", "- E[ref(r + N2)].append((now, w))", "+ E[ref(r + ...
false
0.039437
0.037979
1.038408
[ "s887732752", "s475376325" ]
u375695365
p02996
python
s605668546
s782867514
1,748
824
91,412
67,444
Accepted
Accepted
52.86
n=int(eval(input())) ab=[list(map(int,input().split())) for _ in range(n)] sort_ab = sorted(ab, key=lambda x:(x[1], x[0])) #print(sort_ab) count=0 for i in range(n): count+=sort_ab[i][0] if sort_ab[i][1]<count: print("No") break else: print("Yes")
n = int(eval(input())) ab = [list(map(int,input().split())) for i in range(n)] ab = sorted(ab, key=lambda x:(x[1], -x[0])) count = 0 for i in range(n): count += ab[i][0] if count > ab[i][1]: print("No") break else: print("Yes")
15
12
286
265
n = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(n)] sort_ab = sorted(ab, key=lambda x: (x[1], x[0])) # print(sort_ab) count = 0 for i in range(n): count += sort_ab[i][0] if sort_ab[i][1] < count: print("No") break else: print("Yes")
n = int(eval(input())) ab = [list(map(int, input().split())) for i in range(n)] ab = sorted(ab, key=lambda x: (x[1], -x[0])) count = 0 for i in range(n): count += ab[i][0] if count > ab[i][1]: print("No") break else: print("Yes")
false
20
[ "-ab = [list(map(int, input().split())) for _ in range(n)]", "-sort_ab = sorted(ab, key=lambda x: (x[1], x[0]))", "-# print(sort_ab)", "+ab = [list(map(int, input().split())) for i in range(n)]", "+ab = sorted(ab, key=lambda x: (x[1], -x[0]))", "- count += sort_ab[i][0]", "- if sort_ab[i][1] < cou...
false
0.082646
0.044628
1.851876
[ "s605668546", "s782867514" ]
u747602774
p03611
python
s817168194
s230743278
305
178
68,800
14,564
Accepted
Accepted
41.64
import collections N=int(eval(input())) li=list(map(int,input().split())) for n in range(N): plus=li[n]+1 minus=li[n]-1 li.append(plus) li.append(minus) ans=collections.Counter(li) print((ans.most_common()[0][1]))
from collections import Counter n = int(eval(input())) a = list(map(int,input().split())) ac = Counter(a) ans = 0 for i in range(1,10**5): ans = max(ans, ac[i-1]+ac[i]+ac[i+1]) print(ans)
12
11
227
198
import collections N = int(eval(input())) li = list(map(int, input().split())) for n in range(N): plus = li[n] + 1 minus = li[n] - 1 li.append(plus) li.append(minus) ans = collections.Counter(li) print((ans.most_common()[0][1]))
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) ac = Counter(a) ans = 0 for i in range(1, 10**5): ans = max(ans, ac[i - 1] + ac[i] + ac[i + 1]) print(ans)
false
8.333333
[ "-import collections", "+from collections import Counter", "-N = int(eval(input()))", "-li = list(map(int, input().split()))", "-for n in range(N):", "- plus = li[n] + 1", "- minus = li[n] - 1", "- li.append(plus)", "- li.append(minus)", "-ans = collections.Counter(li)", "-print((ans...
false
0.039618
0.140382
0.282214
[ "s817168194", "s230743278" ]
u318427318
p02881
python
s596574453
s620951244
425
298
3,512
9,172
Accepted
Accepted
29.88
import math def dictcheck(dict): min = 0 for k,v in list(dict.items()): if k == 1: min = v break elif min == 0: min=(int(k)-1)+(int(v)-1) elif min > (int(k)-1)+(int(v)-1): min = (int(k)-1)+(int(v)-1) else: ...
#-*-coding:utf-8-*- import sys input=sys.stdin.readline def main(): n = int(eval(input())) ans=10**12 for a in range(1,10**6+1): if n%a==0: b=n//a ans=min(ans,a+b-2) print(ans) if __name__=="__main__": main()
35
15
748
266
import math def dictcheck(dict): min = 0 for k, v in list(dict.items()): if k == 1: min = v break elif min == 0: min = (int(k) - 1) + (int(v) - 1) elif min > (int(k) - 1) + (int(v) - 1): min = (int(k) - 1) + (int(v) - 1) else: ...
# -*-coding:utf-8-*- import sys input = sys.stdin.readline def main(): n = int(eval(input())) ans = 10**12 for a in range(1, 10**6 + 1): if n % a == 0: b = n // a ans = min(ans, a + b - 2) print(ans) if __name__ == "__main__": main()
false
57.142857
[ "-import math", "+# -*-coding:utf-8-*-", "+import sys", "-", "-def dictcheck(dict):", "- min = 0", "- for k, v in list(dict.items()):", "- if k == 1:", "- min = v", "- break", "- elif min == 0:", "- min = (int(k) - 1) + (int(v) - 1)", "- ...
false
0.007348
0.9246
0.007947
[ "s596574453", "s620951244" ]
u226108478
p02861
python
s120887159
s208352332
420
199
8,052
13,708
Accepted
Accepted
52.62
# -*- coding: utf-8 -*- def calc_dist(x1, x2, y1, y2): return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 def main(): from itertools import permutations n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] total = 0 m = len(list(permutations(list(range...
# -*- coding: utf-8 -*- def main(): from itertools import permutations from math import sqrt n = int(eval(input())) x = [0 for _ in range(n)] y = [0 for _ in range(n)] for i in range(n): xi, yi = list(map(int, input().split())) x[i] = xi y[i] = yi ...
27
29
581
594
# -*- coding: utf-8 -*- def calc_dist(x1, x2, y1, y2): return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 def main(): from itertools import permutations n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] total = 0 m = len(list(permutations(list(range(n))))) for p...
# -*- coding: utf-8 -*- def main(): from itertools import permutations from math import sqrt n = int(eval(input())) x = [0 for _ in range(n)] y = [0 for _ in range(n)] for i in range(n): xi, yi = list(map(int, input().split())) x[i] = xi y[i] = yi path = list(permuta...
false
6.896552
[ "-def calc_dist(x1, x2, y1, y2):", "- return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5", "-", "-", "+ from math import sqrt", "- xy = [list(map(int, input().split())) for _ in range(n)]", "- total = 0", "- m = len(list(permutations(list(range(n)))))", "- for p in permutations(list(r...
false
0.074944
0.07775
0.963902
[ "s120887159", "s208352332" ]
u079022693
p02900
python
s635444366
s791890179
322
200
5,180
16,140
Accepted
Accepted
37.89
from fractions import gcd A,B=list(map(int,input().split())) C=gcd(A,B) if C==1: print((1)) else: count=1 C_copy=C n=2 while n**2<=C: flag=False while C_copy%n==0: C_copy//=n flag=True if flag: count+=1 n=n+1 if n==2 else n+2 ...
def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if is_prime[i]] from fractions...
25
40
408
785
from fractions import gcd A, B = list(map(int, input().split())) C = gcd(A, B) if C == 1: print((1)) else: count = 1 C_copy = C n = 2 while n**2 <= C: flag = False while C_copy % n == 0: C_copy //= n flag = True if flag: count += 1 ...
def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if is_prime[i]] from frac...
false
37.5
[ "+def primes(n):", "+ is_prime = [True] * (n + 1)", "+ is_prime[0] = False", "+ is_prime[1] = False", "+ for i in range(2, int(n**0.5) + 1):", "+ if not is_prime[i]:", "+ continue", "+ for j in range(i * 2, n + 1, i):", "+ is_prime[j] = False", "+ ...
false
0.224651
0.053788
4.176644
[ "s635444366", "s791890179" ]
u873190923
p03244
python
s213659512
s373378256
348
234
80,216
57,324
Accepted
Accepted
32.76
# input() # int(input()) # map(int, input().split()) # list(map(int, input().split())) import itertools import math import fractions import functools l = [0]*(10**5+1) r = [0]*(10**5+1) n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: l[v[i]] +...
# input() # int(input()) # map(int, input().split()) # list(map(int, input().split())) import math import sys import bisect import heapq # 優先度付きキュー(最小値取り出し) inf = 10 ** 15 mod = 10 ** 9 + 7 n = int(eval(input())) v = list(map(int, input().split())) # 偶数番目の要素において、iの数が何個あったか even = [0 for i in range(100...
41
67
809
1,338
# input() # int(input()) # map(int, input().split()) # list(map(int, input().split())) import itertools import math import fractions import functools l = [0] * (10**5 + 1) r = [0] * (10**5 + 1) n = int(eval(input())) v = list(map(int, input().split())) for i in range(n): if i % 2 == 0: l[v[i]] += 1 els...
# input() # int(input()) # map(int, input().split()) # list(map(int, input().split())) import math import sys import bisect import heapq # 優先度付きキュー(最小値取り出し) inf = 10**15 mod = 10**9 + 7 n = int(eval(input())) v = list(map(int, input().split())) # 偶数番目の要素において、iの数が何個あったか even = [0 for i in range(100001)] # 奇数番目の要素において、...
false
38.80597
[ "-import itertools", "-import fractions", "-import functools", "+import sys", "+import bisect", "+import heapq # 優先度付きキュー(最小値取り出し)", "-l = [0] * (10**5 + 1)", "-r = [0] * (10**5 + 1)", "+inf = 10**15", "+mod = 10**9 + 7", "-for i in range(n):", "- if i % 2 == 0:", "- l[v[i]] += 1"...
false
0.055925
0.103621
0.539704
[ "s213659512", "s373378256" ]
u171366497
p03574
python
s310752504
s164503330
35
24
3,700
3,188
Accepted
Accepted
31.43
h,w=list(map(int,input().split())) from collections import defaultdict data=defaultdict(int) for y in range(h): line=eval(input()) for x in range(w): if line[x]=='#': data[(y,x)]=-1 for i in range(-1,2): for j in range(-1,2): if data[...
H,W=list(map(int,input().split())) Map=['.'*(W+2)] for i in range(H): line='.'+eval(input())+'.' x=[] for j in range(W+2): x.append(line[j]) Map.append(x) Map.append('.'*(W+2)) for h in range(1,1+H): for w in range(1,1+W): if Map[h][w]=='.': cnt=0 ...
18
18
504
512
h, w = list(map(int, input().split())) from collections import defaultdict data = defaultdict(int) for y in range(h): line = eval(input()) for x in range(w): if line[x] == "#": data[(y, x)] = -1 for i in range(-1, 2): for j in range(-1, 2): if...
H, W = list(map(int, input().split())) Map = ["." * (W + 2)] for i in range(H): line = "." + eval(input()) + "." x = [] for j in range(W + 2): x.append(line[j]) Map.append(x) Map.append("." * (W + 2)) for h in range(1, 1 + H): for w in range(1, 1 + W): if Map[h][w] == ".": ...
false
0
[ "-h, w = list(map(int, input().split()))", "-from collections import defaultdict", "-", "-data = defaultdict(int)", "-for y in range(h):", "- line = eval(input())", "- for x in range(w):", "- if line[x] == \"#\":", "- data[(y, x)] = -1", "- for i in range(-1, 2):...
false
0.040635
0.040317
1.007878
[ "s310752504", "s164503330" ]
u691018832
p02681
python
s435733520
s002890425
64
22
61,616
9,100
Accepted
Accepted
65.62
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) s = readline().rstrip().decode() t = readline().rstrip().decode() if s == t[:len(t) - 1]: print('Yes') else: print('No')
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) s = readline().rstrip().decode() t = read().rstrip().decode() print(('Yes' if s == t[:-1] else 'No'))
12
9
288
256
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) s = readline().rstrip().decode() t = readline().rstrip().decode() if s == t[: len(t) - 1]: print("Yes") else: print("No")
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) s = readline().rstrip().decode() t = read().rstrip().decode() print(("Yes" if s == t[:-1] else "No"))
false
25
[ "-t = readline().rstrip().decode()", "-if s == t[: len(t) - 1]:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+t = read().rstrip().decode()", "+print((\"Yes\" if s == t[:-1] else \"No\"))" ]
false
0.125354
0.047934
2.615151
[ "s435733520", "s002890425" ]
u047796752
p02711
python
s666176497
s465065460
73
65
64,612
61,856
Accepted
Accepted
10.96
from collections import * N = eval(input()) if '7' in N: print('Yes') else: print('No')
N = eval(input()) if '7' in N: print('Yes') else: print('No')
8
6
98
69
from collections import * N = eval(input()) if "7" in N: print("Yes") else: print("No")
N = eval(input()) if "7" in N: print("Yes") else: print("No")
false
25
[ "-from collections import *", "-" ]
false
0.039231
0.065052
0.603074
[ "s666176497", "s465065460" ]
u636683284
p03546
python
s273197359
s137821377
429
82
76,968
73,908
Accepted
Accepted
80.89
import heapq def dijkstra(s): hq = [(0, s)] heapq.heapify(hq) # リストを優先度付きキューに変換 cost = [float('inf')] * 10 # 行ったことのないところはinf cost[s] = 0 # 開始地点は0 while hq: c, v = heapq.heappop(hq) if c > cost[v]: # コストが現在のコストよりも高ければスルー continue for d, u in e[v]: ...
def floyd_warshall(dist): v = len(dist) for k in range(v): for i in range(v): for j in range(v): dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]) h,w = list(map(int,input().split())) c = [list(map(int,input().split())) for _ in range(10)] floyd_warshall(c) A = [l...
37
17
870
488
import heapq def dijkstra(s): hq = [(0, s)] heapq.heapify(hq) # リストを優先度付きキューに変換 cost = [float("inf")] * 10 # 行ったことのないところはinf cost[s] = 0 # 開始地点は0 while hq: c, v = heapq.heappop(hq) if c > cost[v]: # コストが現在のコストよりも高ければスルー continue for d, u in e[v]: ...
def floyd_warshall(dist): v = len(dist) for k in range(v): for i in range(v): for j in range(v): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) h, w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] floyd_warshall(c) A = [list...
false
54.054054
[ "-import heapq", "-", "-", "-def dijkstra(s):", "- hq = [(0, s)]", "- heapq.heapify(hq) # リストを優先度付きキューに変換", "- cost = [float(\"inf\")] * 10 # 行ったことのないところはinf", "- cost[s] = 0 # 開始地点は0", "- while hq:", "- c, v = heapq.heappop(hq)", "- if c > cost[v]: # コストが現在のコストよ...
false
0.055664
0.04819
1.155082
[ "s273197359", "s137821377" ]
u077291787
p02925
python
s334218393
s729281713
906
698
80,220
146,352
Accepted
Accepted
22.96
# ABC139E - League from collections import deque def main(): N = int(eval(input())) A = [0] + list(deque(list(map(int, input().split()))) for _ in range(N)) cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1) q = deque(list(range(1, N + 1))) while q: x = q.popleft() if not ...
# ABC139E - League from collections import deque def main(): N, *A = list(map(int, open(0).read().split())) B = {} for i in range(N): x = i * (N - 1) B[i + 1] = deque(A[x : x + N - 1]) cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1) q = deque(list(range(1, N + 1))) ...
27
30
970
943
# ABC139E - League from collections import deque def main(): N = int(eval(input())) A = [0] + list(deque(list(map(int, input().split()))) for _ in range(N)) cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1) q = deque(list(range(1, N + 1))) while q: x = q.popleft() if not A[x]: # pl...
# ABC139E - League from collections import deque def main(): N, *A = list(map(int, open(0).read().split())) B = {} for i in range(N): x = i * (N - 1) B[i + 1] = deque(A[x : x + N - 1]) cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1) q = deque(list(range(1, N + 1))) while q: ...
false
10
[ "- N = int(eval(input()))", "- A = [0] + list(deque(list(map(int, input().split()))) for _ in range(N))", "+ N, *A = list(map(int, open(0).read().split()))", "+ B = {}", "+ for i in range(N):", "+ x = i * (N - 1)", "+ B[i + 1] = deque(A[x : x + N - 1])", "- if not A...
false
0.037534
0.033509
1.120121
[ "s334218393", "s729281713" ]
u759934006
p00114
python
s652401934
s911909158
560
300
6,740
6,744
Accepted
Accepted
46.43
# 0114 def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) while True: try: x, y, z = 1, 1, 1 c1, c2 ,c3 = 0, 0, 0 a1, m1, a2, m2, a3, m3 = list(map(int, input().split())) if sum([a1, m1, a2, m2, a3, m3]) == 0: break while True: x...
# 0114 def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) def times(a, m): c = 1 x = a * 1 % m while x != 1: x = a * x % m c += 1 return c while True: try: x, y, z = 1, 1, 1 c1, c2 ,c3 = 0, 0, 0 a1, m1, a2, m2, a3, m3 = list(map(int...
40
34
584
525
# 0114 def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) while True: try: x, y, z = 1, 1, 1 c1, c2, c3 = 0, 0, 0 a1, m1, a2, m2, a3, m3 = list(map(int, input().split())) if sum([a1, m1, a2, m2, a3, m3]) == 0: ...
# 0114 def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) def times(a, m): c = 1 x = a * 1 % m while x != 1: x = a * x % m c += 1 return c while True: try: x, y, z = 1, 1, 1 c1, c2, c3 = 0, 0, 0 ...
false
15
[ "+def times(a, m):", "+ c = 1", "+ x = a * 1 % m", "+ while x != 1:", "+ x = a * x % m", "+ c += 1", "+ return c", "+", "+", "- while True:", "- x = a1 * x % m1", "- c1 += 1", "- if x == 1:", "- break", "- ...
false
0.085938
0.038854
2.21182
[ "s652401934", "s911909158" ]
u931636178
p03448
python
s058785516
s101146388
57
51
3,060
3,060
Accepted
Accepted
10.53
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for count_500 in range(A+1): for count_100 in range(B+1): for count_50 in range(C+1): sum_money = 500*count_500 + 100*count_100 + 50*count_50 if sum_money == X: ...
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) count = 0 for i1 in range(A+1): for i2 in range(B+1): for i3 in range(C+1): if (i1*500 + i2*100 + i3 *50) == X: count += 1 print(count)
13
11
321
253
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for count_500 in range(A + 1): for count_100 in range(B + 1): for count_50 in range(C + 1): sum_money = 500 * count_500 + 100 * count_100 + 50 * count_50 if sum_money == X: ...
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) count = 0 for i1 in range(A + 1): for i2 in range(B + 1): for i3 in range(C + 1): if (i1 * 500 + i2 * 100 + i3 * 50) == X: count += 1 print(count)
false
15.384615
[ "-ans = 0", "-for count_500 in range(A + 1):", "- for count_100 in range(B + 1):", "- for count_50 in range(C + 1):", "- sum_money = 500 * count_500 + 100 * count_100 + 50 * count_50", "- if sum_money == X:", "- ans += 1", "-print(ans)", "+count = 0", ...
false
0.139624
0.121641
1.147834
[ "s058785516", "s101146388" ]
u325282913
p03476
python
s982446981
s319415554
836
721
4,980
94,380
Accepted
Accepted
13.76
def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return is_prime Q = int(eval(input())) ans = [0]...
import math def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True Q = int(eval(input())) cnt = [0]*(10**5+1) for i in range(1,10**5+1): if i % 2 == 0: cnt[i] = cnt[i-1] continue if i...
21
20
583
503
def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return is_prime Q = int(eval(input())) ans = [0] * (10**5...
import math def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True Q = int(eval(input())) cnt = [0] * (10**5 + 1) for i in range(1, 10**5 + 1): if i % 2 == 0: cnt[i] = cnt[i - 1] continue ...
false
4.761905
[ "-def primes(n):", "- is_prime = [True] * (n + 1)", "- is_prime[0] = False", "- is_prime[1] = False", "- for i in range(2, int(n**0.5) + 1):", "- if not is_prime[i]:", "- continue", "- for j in range(i * 2, n + 1, i):", "- is_prime[j] = False", "- ...
false
0.132478
0.488168
0.271378
[ "s982446981", "s319415554" ]
u802234509
p02824
python
s044417257
s954825517
312
241
62,576
62,576
Accepted
Accepted
22.76
import bisect n, m, v, p = list(map(int, input().split())) ls = list(map(int, input().split())) ls.sort() total=m*v for i in range(min(v-1,p-1)): ls[-i-1]+=m total-=m ac = [0]*n for i in range(n-1): ac[i+1] = ac[i]+(ls[i+1]-ls[i])*(i+1) ans=p for i in range(n-p): idx=bisect.bisect_rig...
import bisect n, m, v, p = list(map(int, input().split())) ls = list(map(int, input().split())) ls.sort() total=m*v for i in range(min(v-1,p-1)): ls[-i-1]+=m total-=m ac = [0]*n for i in range(n-1): ac[i+1] = ac[i]+(ls[i+1]-ls[i])*(i+1) l=-1 r=n while l+1<r: i=(l+r)//2 idx=bisec...
30
34
589
617
import bisect n, m, v, p = list(map(int, input().split())) ls = list(map(int, input().split())) ls.sort() total = m * v for i in range(min(v - 1, p - 1)): ls[-i - 1] += m total -= m ac = [0] * n for i in range(n - 1): ac[i + 1] = ac[i] + (ls[i + 1] - ls[i]) * (i + 1) ans = p for i in range(n - p): idx ...
import bisect n, m, v, p = list(map(int, input().split())) ls = list(map(int, input().split())) ls.sort() total = m * v for i in range(min(v - 1, p - 1)): ls[-i - 1] += m total -= m ac = [0] * n for i in range(n - 1): ac[i + 1] = ac[i] + (ls[i + 1] - ls[i]) * (i + 1) l = -1 r = n while l + 1 < r: i = (...
false
11.764706
[ "-ans = p", "-for i in range(n - p):", "+l = -1", "+r = n", "+while l + 1 < r:", "+ i = (l + r) // 2", "+ l = i", "- ans += 1", "+ r = i", "+ l = i", "- ans += 1", "-print(ans)", "+ r = i", "+print((n - r))" ]
false
0.047522
0.040536
1.172343
[ "s044417257", "s954825517" ]
u761320129
p03998
python
s904479124
s391902035
27
17
3,060
3,064
Accepted
Accepted
37.04
sa = eval(input()) sb = eval(input()) sc = eval(input()) ai = bi = ci = -1 turn = 'a' while True: exec(turn + 'i += 1') turn = eval('s' + turn + '[' + turn + 'i-1]') if eval(turn + 'i == len(s' + turn + ')'): print((turn.upper())) exit()
A = eval(input()) B = eval(input()) C = eval(input()) ai = bi = ci = 0 turn = 'a' while 1: if turn == 'a': if ai >= len(A): print('A') exit() turn = A[ai] ai += 1 elif turn == 'b': if bi >= len(B): print('B') exit()...
12
25
257
461
sa = eval(input()) sb = eval(input()) sc = eval(input()) ai = bi = ci = -1 turn = "a" while True: exec(turn + "i += 1") turn = eval("s" + turn + "[" + turn + "i-1]") if eval(turn + "i == len(s" + turn + ")"): print((turn.upper())) exit()
A = eval(input()) B = eval(input()) C = eval(input()) ai = bi = ci = 0 turn = "a" while 1: if turn == "a": if ai >= len(A): print("A") exit() turn = A[ai] ai += 1 elif turn == "b": if bi >= len(B): print("B") exit() turn = B...
false
52
[ "-sa = eval(input())", "-sb = eval(input())", "-sc = eval(input())", "-ai = bi = ci = -1", "+A = eval(input())", "+B = eval(input())", "+C = eval(input())", "+ai = bi = ci = 0", "-while True:", "- exec(turn + \"i += 1\")", "- turn = eval(\"s\" + turn + \"[\" + turn + \"i-1]\")", "- if...
false
0.07829
0.0648
1.208174
[ "s904479124", "s391902035" ]
u332385682
p03805
python
s153977246
s160774470
26
21
3,192
3,064
Accepted
Accepted
19.23
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def do_dp(N, Adj): univ = 2**(N-1) - 1 dp = [[0]*(N-1) for i in range(univ + 1)] for u in range(N - 1): ...
def bit_dp(N, Adj): dp = [[0]*N for i in range(1 << N)] # dp({0], 0) = 1 と初期化する dp[1][0] = 1 for S in range(1 << N): for v in range(N): # v が S に含まれていないときはパスする if (S & (1 << v)) == 0: continue # sub = S - {v} sub = S ^...
45
39
1,025
895
import sys def debug(x, table): for name, val in table.items(): if x is val: print("DEBUG:{} -> {}".format(name, val), file=sys.stderr) return None def do_dp(N, Adj): univ = 2 ** (N - 1) - 1 dp = [[0] * (N - 1) for i in range(univ + 1)] for u in range(N - 1): ...
def bit_dp(N, Adj): dp = [[0] * N for i in range(1 << N)] # dp({0], 0) = 1 と初期化する dp[1][0] = 1 for S in range(1 << N): for v in range(N): # v が S に含まれていないときはパスする if (S & (1 << v)) == 0: continue # sub = S - {v} sub = S ^ (1 << v) ...
false
13.333333
[ "-import sys", "-", "-", "-def debug(x, table):", "- for name, val in table.items():", "- if x is val:", "- print(\"DEBUG:{} -> {}\".format(name, val), file=sys.stderr)", "- return None", "-", "-", "-def do_dp(N, Adj):", "- univ = 2 ** (N - 1) - 1", "- d...
false
0.105329
0.168737
0.624218
[ "s153977246", "s160774470" ]
u047023156
p02862
python
s658312625
s579991650
180
166
38,640
3,696
Accepted
Accepted
7.78
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 1...
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 1...
40
37
974
854
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 10**9 + ...
import math, sys from bisect import bisect_left, bisect_right from collections import Counter, defaultdict, deque from copy import deepcopy from functools import lru_cache from heapq import heapify, heappop, heappush from itertools import accumulate, combinations, permutations input = sys.stdin.readline mod = 10**9 + ...
false
7.5
[ "-def main():", "- def fur(n, r):", "- p, q = 1, 1", "- for i in range(r):", "- p = p * (n - i) % mod", "- q = q * (i + 1) % mod", "- return p * pow(q, mod - 2, mod) % mod", "-", "- x, y = nm()", "- if (x + y) % 3 != 0:", "- print((0))",...
false
0.074435
0.086378
0.861745
[ "s658312625", "s579991650" ]
u454524105
p03147
python
s387782526
s480774136
485
264
3,060
3,060
Accepted
Accepted
45.57
n = int(eval(input())) h = [int(i) for i in input().split()] r = i = 0 while max(h) != 0: if h[i] == 0: i += 1 else: r += 1 while i < n and h[i] > 0: h[i] -= 1 i += 1 i = 0 print(r)
n = int(eval(input())) h = [int(i) for i in input().split()] r = i = 0 while sum(h) != 0: if h[i] == 0: i += 1 else: r += 1 while i < n and h[i] > 0: h[i] -= 1 i += 1 i = 0 print(r)
13
13
251
251
n = int(eval(input())) h = [int(i) for i in input().split()] r = i = 0 while max(h) != 0: if h[i] == 0: i += 1 else: r += 1 while i < n and h[i] > 0: h[i] -= 1 i += 1 i = 0 print(r)
n = int(eval(input())) h = [int(i) for i in input().split()] r = i = 0 while sum(h) != 0: if h[i] == 0: i += 1 else: r += 1 while i < n and h[i] > 0: h[i] -= 1 i += 1 i = 0 print(r)
false
0
[ "-while max(h) != 0:", "+while sum(h) != 0:" ]
false
0.044962
0.082352
0.545977
[ "s387782526", "s480774136" ]
u435480265
p02727
python
s173486227
s693592139
345
237
23,328
23,328
Accepted
Accepted
31.3
x,y,a,b,c = list(map(int,input().split())) lst_r = list(map(int,input().split())) lst_g = list(map(int,input().split())) lst_n = list([int(x)*(-1) for x in input().split()]) from heapq import * heapify(lst_r) for i in range(a-x): _ = heappop(lst_r) heapify(lst_g) for i in range(b-y): _ = heappop(l...
x,y,a,b,c = list(map(int,input().split())) lst_r = list(map(int,input().split())) lst_g = list(map(int,input().split())) lst_n = list(map(int,input().split())) lst_r = sorted(lst_r, reverse=True)[:x] lst_g = sorted(lst_g, reverse=True)[:y] lst_all = sorted(lst_r + lst_g + lst_n, reverse=True)[:x+y] print((sum(ls...
26
8
623
320
x, y, a, b, c = list(map(int, input().split())) lst_r = list(map(int, input().split())) lst_g = list(map(int, input().split())) lst_n = list([int(x) * (-1) for x in input().split()]) from heapq import * heapify(lst_r) for i in range(a - x): _ = heappop(lst_r) heapify(lst_g) for i in range(b - y): _ = heappop(l...
x, y, a, b, c = list(map(int, input().split())) lst_r = list(map(int, input().split())) lst_g = list(map(int, input().split())) lst_n = list(map(int, input().split())) lst_r = sorted(lst_r, reverse=True)[:x] lst_g = sorted(lst_g, reverse=True)[:y] lst_all = sorted(lst_r + lst_g + lst_n, reverse=True)[: x + y] print((su...
false
69.230769
[ "-lst_n = list([int(x) * (-1) for x in input().split()])", "-from heapq import *", "-", "-heapify(lst_r)", "-for i in range(a - x):", "- _ = heappop(lst_r)", "-heapify(lst_g)", "-for i in range(b - y):", "- _ = heappop(lst_g)", "-heapify(lst_n)", "-while len(lst_n) > 0:", "- flg = lst...
false
0.037707
0.037055
1.017585
[ "s173486227", "s693592139" ]
u047796752
p02665
python
s453749322
s235603483
132
81
89,740
82,892
Accepted
Accepted
38.64
import sys input = sys.stdin.readline from collections import * N = int(eval(input())) A = list(map(int, input().split())) low = [0]*(N+1) high = [0]*(N+1) low[N] = A[N] high[N] = A[N] if A[N]>2**N: print((-1)) exit() for i in range(N-1, -1, -1): low[i] = (low[i+1]+1)//2+A[i] high[i]...
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) low = [0]*(N+1) high = [0]*(N+1) low[N] = A[N] high[N] = A[N] for i in range(N-1, -1, -1): low[i] = (low[i+1]+1)//2+A[i] high[i] = high[i+1]+A[i] if not low[0]<=1<=high[0]: print((-1)) exi...
38
26
604
427
import sys input = sys.stdin.readline from collections import * N = int(eval(input())) A = list(map(int, input().split())) low = [0] * (N + 1) high = [0] * (N + 1) low[N] = A[N] high[N] = A[N] if A[N] > 2**N: print((-1)) exit() for i in range(N - 1, -1, -1): low[i] = (low[i + 1] + 1) // 2 + A[i] high[...
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) low = [0] * (N + 1) high = [0] * (N + 1) low[N] = A[N] high[N] = A[N] for i in range(N - 1, -1, -1): low[i] = (low[i + 1] + 1) // 2 + A[i] high[i] = high[i + 1] + A[i] if not low[0] <= 1 <= high[0]: print((-1))...
false
31.578947
[ "-from collections import *", "-", "-if A[N] > 2**N:", "- print((-1))", "- exit()", "- lim = 2**i", "- if low[i] > lim:", "- print((-1))", "- exit()", "- high[i] = min(high[i], lim)", "+if not low[0] <= 1 <= high[0]:", "+ print((-1))", "+ exit()", "+ans =...
false
0.039559
0.03964
0.997967
[ "s453749322", "s235603483" ]
u761320129
p04046
python
s320667884
s875460692
1,130
440
18,564
28,376
Accepted
Accepted
61.06
MOD = 10**9+7 def add(a,b): return (a+b) % MOD def mul(a,b): return (a*b) % MOD def pow(a,n): ans = 1 mag = a for b in reversed(str(bin(n))): if b == 'b': break if b == '1': ans = mul(ans, mag) mag = mul(mag, mag) return ans def inv(a): return pow(a, MOD-2) H,W,...
H,W,A,B = list(map(int,input().split())) N = H+W+10 MOD = 10**9+7 fac = [1,1] + [0]*N finv = [1,1] + [0]*N inv = [0,1] + [0]*N for i in range(2,N+2): fac[i] = fac[i-1] * i % MOD inv[i] = -inv[MOD%i] * (MOD // i) % MOD finv[i] = finv[i-1] * inv[i] % MOD def ncr(n,r): if n < r: return 0 ...
42
23
782
519
MOD = 10**9 + 7 def add(a, b): return (a + b) % MOD def mul(a, b): return (a * b) % MOD def pow(a, n): ans = 1 mag = a for b in reversed(str(bin(n))): if b == "b": break if b == "1": ans = mul(ans, mag) mag = mul(mag, mag) return ans def in...
H, W, A, B = list(map(int, input().split())) N = H + W + 10 MOD = 10**9 + 7 fac = [1, 1] + [0] * N finv = [1, 1] + [0] * N inv = [0, 1] + [0] * N for i in range(2, N + 2): fac[i] = fac[i - 1] * i % MOD inv[i] = -inv[MOD % i] * (MOD // i) % MOD finv[i] = finv[i - 1] * inv[i] % MOD def ncr(n, r): if n <...
false
45.238095
[ "+H, W, A, B = list(map(int, input().split()))", "+N = H + W + 10", "-", "-", "-def add(a, b):", "- return (a + b) % MOD", "-", "-", "-def mul(a, b):", "- return (a * b) % MOD", "-", "-", "-def pow(a, n):", "- ans = 1", "- mag = a", "- for b in reversed(str(bin(n))):", ...
false
0.044049
0.044225
0.996041
[ "s320667884", "s875460692" ]
u644907318
p02834
python
s347127992
s768820313
742
380
76,260
103,724
Accepted
Accepted
48.79
from collections import deque INFTY = 10**6 N,u,v = list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for _ in range(N-1): a,b = list(map(int,input().split())) G[a].append(b) G[b].append(a) du = [INFTY for _ in range(N+1)] du[u] = 0 que = deque([(0,u)]) hist = [0 for _ in range(N+1)...
from collections import deque N,u,v = list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for _ in range(N-1): a,b = list(map(int,input().split())) G[a].append(b) G[b].append(a) distT = [0 for _ in range(N+1)] heap = deque([(u,0)]) distT[u] = 0 hist = [0 for _ in range(N+1)] hist[u] =...
37
37
864
904
from collections import deque INFTY = 10**6 N, u, v = list(map(int, input().split())) G = {i: [] for i in range(1, N + 1)} for _ in range(N - 1): a, b = list(map(int, input().split())) G[a].append(b) G[b].append(a) du = [INFTY for _ in range(N + 1)] du[u] = 0 que = deque([(0, u)]) hist = [0 for _ in range(...
from collections import deque N, u, v = list(map(int, input().split())) G = {i: [] for i in range(1, N + 1)} for _ in range(N - 1): a, b = list(map(int, input().split())) G[a].append(b) G[b].append(a) distT = [0 for _ in range(N + 1)] heap = deque([(u, 0)]) distT[u] = 0 hist = [0 for _ in range(N + 1)] his...
false
0
[ "-INFTY = 10**6", "-du = [INFTY for _ in range(N + 1)]", "-du[u] = 0", "-que = deque([(0, u)])", "+distT = [0 for _ in range(N + 1)]", "+heap = deque([(u, 0)])", "+distT[u] = 0", "-while que:", "- c, i = que.popleft()", "- for j in G[i]:", "- if hist[j] == 0:", "- que.a...
false
0.036516
0.03268
1.117379
[ "s347127992", "s768820313" ]
u145035045
p03354
python
s892372555
s386524614
549
496
38,240
14,008
Accepted
Accepted
9.65
def solve(): n, m = list(map(int,input().split())) plst = list(map(int,input().split())) pare_inds = [i for i in range(n)] belongs = [[] for i in range(n)] def get_root(x): p = pare_inds[x] if p == x: return x a = get_root(p) pare_inds[x] = a return a for i in r...
def solve(): n, m = list(map(int,input().split())) plst = list(map(int,input().split())) pare_inds = [i for i in range(n)] def find(x): p = pare_inds[x] if p == x: return x a = find(p) pare_inds[x] = a return a for i in range(m): x, y = list(map(int,input().sp...
52
27
1,113
540
def solve(): n, m = list(map(int, input().split())) plst = list(map(int, input().split())) pare_inds = [i for i in range(n)] belongs = [[] for i in range(n)] def get_root(x): p = pare_inds[x] if p == x: return x a = get_root(p) pare_inds[x] = a re...
def solve(): n, m = list(map(int, input().split())) plst = list(map(int, input().split())) pare_inds = [i for i in range(n)] def find(x): p = pare_inds[x] if p == x: return x a = find(p) pare_inds[x] = a return a for i in range(m): x, y =...
false
48.076923
[ "- belongs = [[] for i in range(n)]", "- def get_root(x):", "+ def find(x):", "- a = get_root(p)", "+ a = find(p)", "- r_x, r_y = get_root(x), get_root(y)", "- if r_x < r_y:", "- pare_inds[y] = r_x", "- pare_inds[r_y] = r_x", "- els...
false
0.042546
0.03772
1.127951
[ "s892372555", "s386524614" ]
u576432509
p03779
python
s032259035
s640545734
28
17
3,060
2,940
Accepted
Accepted
39.29
x=int(eval(input())) i=0 isum=0 while isum<x: i=i+1 isum=isum+i print(i)
x=int(eval(input())) t=int(((-1+(8*x+1)**0.5)-10**(-10))/2)+1 print(t)
9
4
84
69
x = int(eval(input())) i = 0 isum = 0 while isum < x: i = i + 1 isum = isum + i print(i)
x = int(eval(input())) t = int(((-1 + (8 * x + 1) ** 0.5) - 10 ** (-10)) / 2) + 1 print(t)
false
55.555556
[ "-i = 0", "-isum = 0", "-while isum < x:", "- i = i + 1", "- isum = isum + i", "-print(i)", "+t = int(((-1 + (8 * x + 1) ** 0.5) - 10 ** (-10)) / 2) + 1", "+print(t)" ]
false
0.053128
0.039699
1.33827
[ "s032259035", "s640545734" ]
u986014912
p02787
python
s504424073
s112081737
346
306
16,092
33,004
Accepted
Accepted
11.56
import sys import numpy as np h, n = list(map(int, input().split())) ab = np.array(sys.stdin.read().split(), dtype=np.int64) aaa = ab[0::2] bbb = ab[1::2] dp = np.zeros(10001, dtype=np.int64) for i in range(1, h + 1): dp[i] = (dp[i - aaa] + bbb).min() print((dp[h])) # https://atcoder.jp/contests/a...
# coding=utf-8 # Date: 2020-01-08 # Author: lee215 get = lambda: int(input().strip()) getl = lambda: input().strip() gets = lambda: list(map(int, input().strip().split())) getss = lambda n: [gets() for _ in range(n)] h, N = gets() AB = getss(N) dp = [0] + [float('inf')] * h for a, b in AB: for i in...
15
18
342
422
import sys import numpy as np h, n = list(map(int, input().split())) ab = np.array(sys.stdin.read().split(), dtype=np.int64) aaa = ab[0::2] bbb = ab[1::2] dp = np.zeros(10001, dtype=np.int64) for i in range(1, h + 1): dp[i] = (dp[i - aaa] + bbb).min() print((dp[h])) # https://atcoder.jp/contests/abc153/submissions...
# coding=utf-8 # Date: 2020-01-08 # Author: lee215 get = lambda: int(input().strip()) getl = lambda: input().strip() gets = lambda: list(map(int, input().strip().split())) getss = lambda n: [gets() for _ in range(n)] h, N = gets() AB = getss(N) dp = [0] + [float("inf")] * h for a, b in AB: for i in range(h): ...
false
16.666667
[ "-import sys", "-import numpy as np", "-", "-h, n = list(map(int, input().split()))", "-ab = np.array(sys.stdin.read().split(), dtype=np.int64)", "-aaa = ab[0::2]", "-bbb = ab[1::2]", "-dp = np.zeros(10001, dtype=np.int64)", "-for i in range(1, h + 1):", "- dp[i] = (dp[i - aaa] + bbb).min()", ...
false
0.296169
0.124308
2.382539
[ "s504424073", "s112081737" ]
u262597910
p02936
python
s727046810
s072257957
1,989
1,421
74,756
73,732
Accepted
Accepted
28.56
n,q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n-1): a,b = list(map(int, input().split())) way[a-1].append(b-1) way[b-1].append(a-1) add = [0]*n for i in range(q): a,b = list(map(int, input().split())) add[a-1] += b ans = [-1]*n ans[0] = add[0] st...
import sys input = sys.stdin.readline n,q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n-1): a,b = list(map(int, input().split())) way[a-1].append(b-1) way[b-1].append(a-1) add = [0]*n for i in range(q): a,b = list(map(int, input().split())) add[a-1] += ...
21
25
541
589
n, q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) way[a - 1].append(b - 1) way[b - 1].append(a - 1) add = [0] * n for i in range(q): a, b = list(map(int, input().split())) add[a - 1] += b ans = [-1] * n ans[0] = add[0] s...
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) way = [[] for _ in range(n)] for i in range(n - 1): a, b = list(map(int, input().split())) way[a - 1].append(b - 1) way[b - 1].append(a - 1) add = [0] * n for i in range(q): a, b = list(map(int, input().split())) add[a - 1...
false
16
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.050867
0.077302
0.658036
[ "s727046810", "s072257957" ]
u912237403
p00096
python
s347870681
s871361941
1,150
170
4,492
4,316
Accepted
Accepted
85.22
import sys a=[0]*2001 b=[0]*4001 n=1001 for i in range(n): for j in range(n): a[i+j]+=1 n=2001 for i in range(n): for j in range(n): b[i+j]+=a[i]*a[j] for i in sys.stdin: print(b[int(i)])
import sys n=1001 a=[0]*2001 for i in range(n): for j in range(n): a[i+j]+=1 for n in map(int,sys.stdin): x=0 for i in range(max(0,n-2000),min(n,2000)+1): x+=a[i]*a[n-i] print(x)
13
12
212
205
import sys a = [0] * 2001 b = [0] * 4001 n = 1001 for i in range(n): for j in range(n): a[i + j] += 1 n = 2001 for i in range(n): for j in range(n): b[i + j] += a[i] * a[j] for i in sys.stdin: print(b[int(i)])
import sys n = 1001 a = [0] * 2001 for i in range(n): for j in range(n): a[i + j] += 1 for n in map(int, sys.stdin): x = 0 for i in range(max(0, n - 2000), min(n, 2000) + 1): x += a[i] * a[n - i] print(x)
false
7.692308
[ "+n = 1001", "-b = [0] * 4001", "-n = 1001", "-n = 2001", "-for i in range(n):", "- for j in range(n):", "- b[i + j] += a[i] * a[j]", "-for i in sys.stdin:", "- print(b[int(i)])", "+for n in map(int, sys.stdin):", "+ x = 0", "+ for i in range(max(0, n - 2000), min(n, 2000) +...
false
3.181013
0.326481
9.743321
[ "s347870681", "s871361941" ]
u780475861
p02803
python
s515235307
s977262527
1,962
327
12,420
3,064
Accepted
Accepted
83.33
import sys import numpy as np from heapq import heappop, heappush read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H,W = list(map(int,readline().split())) grid = np.full((H+2,W+2),b'#',dtype='S1') grid[1:-1,1:-1] = np.frombuffer(read(),'S1').reshap...
import sys from heapq import heappop, heappush readline = sys.stdin.readline H, W = list(map(int, readline().split())) grid = '#' * (W + 2) + ''.join('#' + readline().strip() + '#' for _ in range(H)) + '#' * (W + 2) INF = 400 def shortest(grid, start, cost=0): dist = [...
42
39
1,120
940
import sys import numpy as np from heapq import heappop, heappush read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W = list(map(int, readline().split())) grid = np.full((H + 2, W + 2), b"#", dtype="S1") grid[1:-1, 1:-1] = np.frombuffer(read(), "S1").reshape(H,...
import sys from heapq import heappop, heappush readline = sys.stdin.readline H, W = list(map(int, readline().split())) grid = ( "#" * (W + 2) + "".join("#" + readline().strip() + "#" for _ in range(H)) + "#" * (W + 2) ) INF = 400 def shortest(grid, start, cost=0): dist = [INF] * (H + 2) * (W + 2) ...
false
7.142857
[ "-import numpy as np", "-read = sys.stdin.buffer.read", "-readline = sys.stdin.buffer.readline", "-readlines = sys.stdin.buffer.readlines", "+readline = sys.stdin.readline", "-grid = np.full((H + 2, W + 2), b\"#\", dtype=\"S1\")", "-grid[1:-1, 1:-1] = np.frombuffer(read(), \"S1\").reshape(H, -1)[:, :W]"...
false
0.192002
0.064731
2.966131
[ "s515235307", "s977262527" ]
u729133443
p03564
python
s625577165
s623426299
167
17
38,256
2,940
Accepted
Accepted
89.82
n=int(eval(input()));k=int(eval(input()));r=1 for _ in[0]*n:r+=min(r,k) print(r)
n,k=eval('int(input()),'*2);r=1 for _ in[0]*n:r+=min(r,k) print(r)
3
3
70
68
n = int(eval(input())) k = int(eval(input())) r = 1 for _ in [0] * n: r += min(r, k) print(r)
n, k = eval("int(input())," * 2) r = 1 for _ in [0] * n: r += min(r, k) print(r)
false
0
[ "-n = int(eval(input()))", "-k = int(eval(input()))", "+n, k = eval(\"int(input()),\" * 2)" ]
false
0.13665
0.04455
3.067311
[ "s625577165", "s623426299" ]
u163320134
p02949
python
s721634035
s390285762
1,489
962
52,696
64,472
Accepted
Accepted
35.39
def BF(edges,n,s): inf=float("inf") d=[inf for i in range(n+1)] d[s]=0 flag=False for i in range(n+1): for v,u,cost in edges: if d[v]!=inf and d[u]>d[v]+cost: d[u]=d[v]+cost ans1=d[-1] for i in range(n+1): for v,u,cost in edges: if d[v]!=inf ...
import sys sys.setrecursionlimit(10**9) def BF(edges,n,s): inf=float("inf") d=[inf for i in range(n+1)] d[s]=0 update=True cnt=0 while 1: update=False for v,u,cost in edges: if cand[v]!=1 or cand[u]!=1: continue if d[v]!=inf and d[u]>d[v]+cost...
27
59
602
1,142
def BF(edges, n, s): inf = float("inf") d = [inf for i in range(n + 1)] d[s] = 0 flag = False for i in range(n + 1): for v, u, cost in edges: if d[v] != inf and d[u] > d[v] + cost: d[u] = d[v] + cost ans1 = d[-1] for i in range(n + 1): for v, u, co...
import sys sys.setrecursionlimit(10**9) def BF(edges, n, s): inf = float("inf") d = [inf for i in range(n + 1)] d[s] = 0 update = True cnt = 0 while 1: update = False for v, u, cost in edges: if cand[v] != 1 or cand[u] != 1: continue if ...
false
54.237288
[ "+import sys", "+", "+sys.setrecursionlimit(10**9)", "+", "+", "- flag = False", "- for i in range(n + 1):", "+ update = True", "+ cnt = 0", "+ while 1:", "+ update = False", "+ if cand[v] != 1 or cand[u] != 1:", "+ continue", "- ans1 = d[...
false
0.043433
0.035924
1.209035
[ "s721634035", "s390285762" ]
u119148115
p02804
python
s147519623
s144767484
304
152
64,168
91,388
Accepted
Accepted
50
N,K = list(map(int,input().split())) A = list(map(int,input().split())) A = sorted(A) mod = 10**9+7 def p(m,n): a = 1 for i in range(n): a = a*(m-i) return a def p_mod(m,n,mod): a = 1 for i in range(n): a = a*(m-i) % mod return a def c(m,n): return p(...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N,K = MI() A = [-10**10] + LI() A.sort() mod = 10**9+7 B = [0]*(K-1) + [1] # B[i] = i_C_(K-1) for i in range(K,N): B.append((B[-1]*i*pow(i-(K-...
43
19
803
432
N, K = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A) mod = 10**9 + 7 def p(m, n): a = 1 for i in range(n): a = a * (m - i) return a def p_mod(m, n, mod): a = 1 for i in range(n): a = a * (m - i) % mod return a def c(m, n): return p(m,...
import sys def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり N, K = MI() A = [-(10**10)] + LI() A.sort() mod = 10**9 + 7 B = [0] * (K - 1) + [1] # B[i] = i_C_(K-1) for i in range(K, N): B.append((B[-1]...
false
55.813953
[ "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-A = sorted(A)", "-mod = 10**9 + 7", "+import sys", "-def p(m, n):", "- a = 1", "- for i in range(n):", "- a = a * (m - i)", "- return a", "+def MI():", "+ return list(map(int, sys.stdin.read...
false
0.177546
0.04161
4.266879
[ "s147519623", "s144767484" ]
u670180528
p03006
python
s576156366
s785940767
196
105
3,316
3,188
Accepted
Accepted
46.43
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] pq = [] for i in range(n): for j in range(n): if i==j: continue xi, yi = xy[i] xj, yj = xy[j] pq.append((xi - xj, yi - yj)) ans = 1e9 if n>1 else 1 for p, q in pq: cost = 0 for x, y in xy: if (x + p, y + q) in...
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] pq = [] for i in range(n): for j in range(i+1,n): if i==j: continue xi, yi = xy[i] xj, yj = xy[j] pq.append((xi - xj, yi - yj)) ans = n for p, q in pq: cost = 0 for x, y in xy: if (x + p, y + q) in xy: pas...
20
20
386
373
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] pq = [] for i in range(n): for j in range(n): if i == j: continue xi, yi = xy[i] xj, yj = xy[j] pq.append((xi - xj, yi - yj)) ans = 1e9 if n > 1 else 1 for p, q in pq: cost = 0 for x,...
n = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(n)] pq = [] for i in range(n): for j in range(i + 1, n): if i == j: continue xi, yi = xy[i] xj, yj = xy[j] pq.append((xi - xj, yi - yj)) ans = n for p, q in pq: cost = 0 for x, y in xy: ...
false
0
[ "- for j in range(n):", "+ for j in range(i + 1, n):", "-ans = 1e9 if n > 1 else 1", "+ans = n" ]
false
0.063639
0.064515
0.986421
[ "s576156366", "s785940767" ]
u037430802
p02973
python
s346260183
s297405371
550
241
56,536
8,604
Accepted
Accepted
56.18
import bisect N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] colors = [] #後ろから見ていく for i,n in enumerate(list(reversed(A))): # 一つ目はとりあえずなんか一色ぬる if i == 0: colors.append(n) else: #二つ目以降は、各色の最小値のなかで、今見ているのより小さいものがあればそれを置き換える #ここをbisect_leftにすると、colo...
import bisect N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] colors = [] #後ろから見ていく for i,n in enumerate(list(reversed(A))): # 一つ目はとりあえずなんか一色ぬる if i == 0: colors.append(n) else: #二つ目以降は、各色の最小値のなかで、今見ているのより小さいものがあればそれを置き換える # 「各色の最小値集合の最小値と置き換える」を繰...
24
24
572
538
import bisect N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] colors = [] # 後ろから見ていく for i, n in enumerate(list(reversed(A))): # 一つ目はとりあえずなんか一色ぬる if i == 0: colors.append(n) else: # 二つ目以降は、各色の最小値のなかで、今見ているのより小さいものがあればそれを置き換える # ここをbisect_leftにすると、colorsの中で同じ最小値があると...
import bisect N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] colors = [] # 後ろから見ていく for i, n in enumerate(list(reversed(A))): # 一つ目はとりあえずなんか一色ぬる if i == 0: colors.append(n) else: # 二つ目以降は、各色の最小値のなかで、今見ているのより小さいものがあればそれを置き換える # 「各色の最小値集合の最小値と置き換える」を繰り返すので、最小値集合の最大よ...
false
0
[ "- # ここをbisect_leftにすると、colorsの中で同じ最小値があるときにinsertが必要なので遅い", "- if idx == len(colors):", "+ # if idx == len(colors):", "+ if colors[-1] <= n:" ]
false
0.06782
0.037364
1.815125
[ "s346260183", "s297405371" ]
u654470292
p03161
python
s929571442
s432902085
490
207
55,392
81,012
Accepted
Accepted
57.76
import sys def input(): return sys.stdin.readline()[:-1] n,k=list(map(int,input().split())) h=list(map(int,input().split())) cost=[float("inf")]*n cost[0]=0 for i in range(n-1): now=h[i] for j in range(k): if i+j+1>=n: break cost[i+j+1]=min(abs(now-h[i+j+1])+cost[i]...
import bisect import copy import heapq import math import sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) sys.setrecurs...
17
29
369
708
import sys def input(): return sys.stdin.readline()[:-1] n, k = list(map(int, input().split())) h = list(map(int, input().split())) cost = [float("inf")] * n cost[0] = 0 for i in range(n - 1): now = h[i] for j in range(k): if i + j + 1 >= n: break cost[i + j + 1] = min(abs(no...
import bisect import copy import heapq import math import sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) sys.setrecursionl...
false
41.37931
[ "+import bisect", "+import copy", "+import heapq", "+import math", "+from collections import *", "+from functools import lru_cache", "+from itertools import accumulate, combinations, permutations, product", "+def ruiseki(lst):", "+ return [0] + list(accumulate(lst))", "+", "+", "+sys.setrec...
false
0.093774
0.040758
2.30074
[ "s929571442", "s432902085" ]
u392319141
p03346
python
s246215614
s594127705
218
167
35,312
21,224
Accepted
Accepted
23.39
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9 + 7 INF = float('inf') def sol(): N = int(eval(input())) P = [0] * N ...
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9 + 7 INF = float('inf') def sol(): N = int(eval(input())) P = [0] * N in...
31
33
660
685
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10**7) MOD = 10**9 + 7 INF = float("inf") def sol(): N = int(eval(input())) P = [0] * N for i in range(...
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10**7) MOD = 10**9 + 7 INF = float("inf") def sol(): N = int(eval(input())) P = [0] * N index = [0] * (...
false
6.060606
[ "+ index = [0] * (N + 1)", "- pToIndex = {p: i for i, p in enumerate(P)}", "- maxLeng = 1", "+ index[P[i]] = i", "- for n in range(1, N):", "- if pToIndex[n] < pToIndex[n + 1]:", "- length += 1", "- maxLeng = max(maxLeng, length)", "+ seq = 1", "+...
false
0.037314
0.079939
0.466778
[ "s246215614", "s594127705" ]
u787562674
p03487
python
s730273464
s598730290
99
85
18,168
18,676
Accepted
Accepted
14.14
N = int(eval(input())) S = list(int(i) for i in input().split()) dict = {} count = 0 for i in range(N): if S[i] not in dict: dict[S[i]] = 1 else: dict[S[i]] += 1 for key, value in list(dict.items()): if key < value: count += (value-key) elif key > value: ...
from collections import Counter as C N = int(eval(input())) S = list(int(i) for i in input().split()) count = 0 for key, value in list(C(S).items()): if key < value: count += (value-key) elif key > value: count += value print(count)
18
13
340
259
N = int(eval(input())) S = list(int(i) for i in input().split()) dict = {} count = 0 for i in range(N): if S[i] not in dict: dict[S[i]] = 1 else: dict[S[i]] += 1 for key, value in list(dict.items()): if key < value: count += value - key elif key > value: count += value pr...
from collections import Counter as C N = int(eval(input())) S = list(int(i) for i in input().split()) count = 0 for key, value in list(C(S).items()): if key < value: count += value - key elif key > value: count += value print(count)
false
27.777778
[ "+from collections import Counter as C", "+", "-dict = {}", "-for i in range(N):", "- if S[i] not in dict:", "- dict[S[i]] = 1", "- else:", "- dict[S[i]] += 1", "-for key, value in list(dict.items()):", "+for key, value in list(C(S).items()):" ]
false
0.043243
0.040464
1.068687
[ "s730273464", "s598730290" ]
u279266699
p02820
python
s586933116
s319702781
158
47
4,340
9,868
Accepted
Accepted
70.25
from collections import Counter, deque n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = eval(input()) con = Counter(t) ans = con['r'] * p + con['s'] * r + con['p'] * s dic = {'r': p, 's': r, 'p': s} for i in range(k): target = list(t[i::k]) hp = 0 count = 1 ...
def main(): n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = eval(input()) hand = ['r', 's', 'p'] score = [p, r, s] dic_score = dict(list(zip(hand, score))) win = [0] * n ans = 0 for i in range(k): ans += dic_score[t[i]] ...
23
22
570
513
from collections import Counter, deque n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = eval(input()) con = Counter(t) ans = con["r"] * p + con["s"] * r + con["p"] * s dic = {"r": p, "s": r, "p": s} for i in range(k): target = list(t[i::k]) hp = 0 count = 1 for j in ...
def main(): n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) t = eval(input()) hand = ["r", "s", "p"] score = [p, r, s] dic_score = dict(list(zip(hand, score))) win = [0] * n ans = 0 for i in range(k): ans += dic_score[t[i]] win[i] = 1 ...
false
4.347826
[ "-from collections import Counter, deque", "+def main():", "+ n, k = list(map(int, input().split()))", "+ r, s, p = list(map(int, input().split()))", "+ t = eval(input())", "+ hand = [\"r\", \"s\", \"p\"]", "+ score = [p, r, s]", "+ dic_score = dict(list(zip(hand, score)))", "+ ...
false
0.063524
0.064628
0.98292
[ "s586933116", "s319702781" ]
u145950990
p03672
python
s380657572
s053749083
174
17
38,384
2,940
Accepted
Accepted
90.23
s = input()[:-1] for i in range(len(s)): x = s[:i] n = len(s[:i]) if n%2==0 and x[:i//2]==x[i//2:]: ans = n print(ans)
s = input()[:-1] while s[:len(s)//2]*2 != s: s = s[:-1] print((len(s)))
7
6
144
80
s = input()[:-1] for i in range(len(s)): x = s[:i] n = len(s[:i]) if n % 2 == 0 and x[: i // 2] == x[i // 2 :]: ans = n print(ans)
s = input()[:-1] while s[: len(s) // 2] * 2 != s: s = s[:-1] print((len(s)))
false
14.285714
[ "-for i in range(len(s)):", "- x = s[:i]", "- n = len(s[:i])", "- if n % 2 == 0 and x[: i // 2] == x[i // 2 :]:", "- ans = n", "-print(ans)", "+while s[: len(s) // 2] * 2 != s:", "+ s = s[:-1]", "+print((len(s)))" ]
false
0.042732
0.040749
1.048657
[ "s380657572", "s053749083" ]
u352394527
p00481
python
s979908485
s680559711
3,890
3,370
18,152
22,960
Accepted
Accepted
13.37
from collections import deque h,w,n = list(map(int,input().split())) factrys = [None] * (n + 1) ss = ["X" * (w + 2)] append = ss.append for i in range(h): s = "X" + eval(input()) + "X" if "S" in s: factrys[0] = (i + 1, s.index("S")) for j in range(len(s)): if s[j] != 'S' and s[j] != '.' and s[j]...
from collections import deque def main(): h, w, n = list(map(int, input().split())) mp = ["X" + eval(input()) + "X" for _ in range(h)] mp.insert(0, "X" * (w + 2)) mp.append("X" * (w + 2)) poss = [None] * (n + 1) for y in range(1, h + 1): for x in range(1, w + 1): if mp[y][x] == "S":...
44
42
1,033
1,023
from collections import deque h, w, n = list(map(int, input().split())) factrys = [None] * (n + 1) ss = ["X" * (w + 2)] append = ss.append for i in range(h): s = "X" + eval(input()) + "X" if "S" in s: factrys[0] = (i + 1, s.index("S")) for j in range(len(s)): if s[j] != "S" and s[j] != "." ...
from collections import deque def main(): h, w, n = list(map(int, input().split())) mp = ["X" + eval(input()) + "X" for _ in range(h)] mp.insert(0, "X" * (w + 2)) mp.append("X" * (w + 2)) poss = [None] * (n + 1) for y in range(1, h + 1): for x in range(1, w + 1): if mp[y][x...
false
4.545455
[ "-h, w, n = list(map(int, input().split()))", "-factrys = [None] * (n + 1)", "-ss = [\"X\" * (w + 2)]", "-append = ss.append", "-for i in range(h):", "- s = \"X\" + eval(input()) + \"X\"", "- if \"S\" in s:", "- factrys[0] = (i + 1, s.index(\"S\"))", "- for j in range(len(s)):", "-...
false
0.125589
0.042217
2.974863
[ "s979908485", "s680559711" ]
u179169725
p02959
python
s992255106
s194175804
281
196
82,020
18,476
Accepted
Accepted
30.25
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 l = A[0] for i in range(N): r = A[i + 1] cur = B[i] # print(l, r, cur) ans += min(l + r, cur) l = max(r - max(cur - l, 0), 0) # めちゃくちゃ整理するとこの形の式になる print(ans)
# https://atcoder.jp/contests/abc135/tasks/abc135_c N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 l = A[0] for i in range(N): r = A[i + 1] cur = B[i] # print(l, r, cur) # ans += min(l + r, cur) # l = max(r - max(cur - l, 0), 0) #...
12
21
287
501
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 l = A[0] for i in range(N): r = A[i + 1] cur = B[i] # print(l, r, cur) ans += min(l + r, cur) l = max(r - max(cur - l, 0), 0) # めちゃくちゃ整理するとこの形の式になる print(ans)
# https://atcoder.jp/contests/abc135/tasks/abc135_c N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 l = A[0] for i in range(N): r = A[i + 1] cur = B[i] # print(l, r, cur) # ans += min(l + r, cur) # l = max(r - max(cur - l, 0), 0) # めちゃくちゃ整理するとこ...
false
42.857143
[ "+# https://atcoder.jp/contests/abc135/tasks/abc135_c", "- ans += min(l + r, cur)", "- l = max(r - max(cur - l, 0), 0) # めちゃくちゃ整理するとこの形の式になる", "+ # ans += min(l + r, cur)", "+ # l = max(r - max(cur - l, 0), 0) # めちゃくちゃ整理するとこの形の式になる", "+ # わかりやすくかきなおす", "+ ans += min(l, cur)", "+ ...
false
0.036832
0.082936
0.444101
[ "s992255106", "s194175804" ]
u773265208
p02785
python
s251150981
s182036770
173
154
26,180
26,764
Accepted
Accepted
10.98
n,k = list(map(int,input().split())) h = list(map(int,input().split())) if n <= k: print((0)) else: h.sort() ans = 0 for i in range(n-k): ans += h[i] print(ans)
import sys n,k = list(map(int,input().split())) h = list(map(int,input().split())) h.sort() if k >= n: print((0)) sys.exit() h = h[:n-k] print((sum(h)))
11
15
178
167
n, k = list(map(int, input().split())) h = list(map(int, input().split())) if n <= k: print((0)) else: h.sort() ans = 0 for i in range(n - k): ans += h[i] print(ans)
import sys n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort() if k >= n: print((0)) sys.exit() h = h[: n - k] print((sum(h)))
false
26.666667
[ "+import sys", "+", "-if n <= k:", "+h.sort()", "+if k >= n:", "-else:", "- h.sort()", "- ans = 0", "- for i in range(n - k):", "- ans += h[i]", "- print(ans)", "+ sys.exit()", "+h = h[: n - k]", "+print((sum(h)))" ]
false
0.039506
0.046025
0.858355
[ "s251150981", "s182036770" ]
u893307213
p03329
python
s108577452
s231367987
610
212
15,072
27,744
Accepted
Accepted
65.25
N = int(eval(input())) dp = dict() dp[0] = 0 # 貰う DP --- dp[n] に遷移を集める for n in range(1, N+1): dp[n] = dp[n-1] + 1 # メモ化 x = 6 while x <= n: dp[n] = min(dp[n], dp[n-x]+1) x *= 6 x = 9 while x <= n: dp[n] = min(dp[n], dp[n-x]+1) x *= 9 # dp[n] = ans print...
n = int(eval(input())) max_N = 1000000 memo = [False]*max_N import sys import threading sys.setrecursionlimit(100000) threading.stack_size(128*1024*1024) # 貰う DPではなく、再帰を使ったメモ化再帰 from functools import lru_cache lru_cache(maxsize=100000) def f(n): if n < 6: return n if memo[n]: # print(f"at n:...
22
40
321
608
N = int(eval(input())) dp = dict() dp[0] = 0 # 貰う DP --- dp[n] に遷移を集める for n in range(1, N + 1): dp[n] = dp[n - 1] + 1 # メモ化 x = 6 while x <= n: dp[n] = min(dp[n], dp[n - x] + 1) x *= 6 x = 9 while x <= n: dp[n] = min(dp[n], dp[n - x] + 1) x *= 9 # dp[n] = ans...
n = int(eval(input())) max_N = 1000000 memo = [False] * max_N import sys import threading sys.setrecursionlimit(100000) threading.stack_size(128 * 1024 * 1024) # 貰う DPではなく、再帰を使ったメモ化再帰 from functools import lru_cache lru_cache(maxsize=100000) def f(n): if n < 6: return n if memo[n]: # print(f...
false
45
[ "-N = int(eval(input()))", "-dp = dict()", "-dp[0] = 0", "-for n in range(1, N + 1):", "- dp[n] = dp[n - 1] + 1", "+n = int(eval(input()))", "+max_N = 1000000", "+memo = [False] * max_N", "+import sys", "+import threading", "+", "+sys.setrecursionlimit(100000)", "+threading.stack_size(128...
false
0.094177
0.169012
0.557222
[ "s108577452", "s231367987" ]
u102461423
p03037
python
s295583664
s464903585
317
188
3,060
23,212
Accepted
Accepted
40.69
N,M = list(map(int,input().split())) l = -1 r = N+1 for _ in range(M): L,R = list(map(int,input().split())) l = max(l,L) r = min(r,R) answer = max(0,r - l + 1) print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,M = list(map(int,readline().split())) LR = np.array(read().split(),np.int32) L = LR[::2]; R = LR[1::2] x = R.min() - L.max() + 1 if x < 0: x = 0 print(x)
11
15
179
302
N, M = list(map(int, input().split())) l = -1 r = N + 1 for _ in range(M): L, R = list(map(int, input().split())) l = max(l, L) r = min(r, R) answer = max(0, r - l + 1) print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, M = list(map(int, readline().split())) LR = np.array(read().split(), np.int32) L = LR[::2] R = LR[1::2] x = R.min() - L.max() + 1 if x < 0: x = 0 print(x)
false
26.666667
[ "-N, M = list(map(int, input().split()))", "-l = -1", "-r = N + 1", "-for _ in range(M):", "- L, R = list(map(int, input().split()))", "- l = max(l, L)", "- r = min(r, R)", "-answer = max(0, r - l + 1)", "-print(answer)", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readli...
false
0.036673
0.225436
0.162676
[ "s295583664", "s464903585" ]
u535803878
p03822
python
s193564335
s408734462
368
239
156,072
115,712
Accepted
Accepted
35.05
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(eval(input())) a = [None]*(n-1) from collections import defaultdict c = defaultdict(list) for i in range(n-1): num = int(eval(input())) c[num].append...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(eval(input())) a = [None]*(n-1) from collections import defaultdict c = defaultdict(list) for i in range(n-1): num = int(eval(input())) c[num].append(i...
24
40
536
870
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n = int(eval(input())) a = [None] * (n - 1) from collections import defaultdict c = defaultdict(list) for i in range(n - 1): num = int(eval(input())) c[num].append(i + ...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n = int(eval(input())) a = [None] * (n - 1) from collections import defaultdict c = defaultdict(list) for i in range(n - 1): num = int(eval(input())) c[num].append(i + ...
false
40
[ "+### 行きがけ順DFS", "+def dfs(start):", "+ q = [start] # now, prev", "+ us = []", "+ seen = set([start])", "+ while q:", "+ u = q.pop()", "+ us.append(u)", "+ for v in c[u]:", "+ if v in seen:", "+ continue", "+ q.append(v)", ...
false
0.043483
0.072603
0.598913
[ "s193564335", "s408734462" ]
u761320129
p03216
python
s100975117
s281816639
2,491
1,498
54,364
74,840
Accepted
Accepted
39.86
import sys rl = sys.stdin.readline N = int(rl()) S = rl() Q = int(rl()) ks = list(map(int,rl().split())) ans = [] for k in ks: d = m = 0 dm = dmc = 0 for i in range(N): if i >= k: if S[i-k] == 'D': d -= 1 dm -= m elif S[i-k] ==...
import sys input = sys.stdin.readline N = int(input()) S = input() Q = int(input()) K = list(map(int,input().split())) ans = [] for k in K: d = m = dm = dmc = 0 for i in range(N): if i >= k: if S[i-k] == 'D': d -= 1 dm -= m elif S[i...
28
26
557
562
import sys rl = sys.stdin.readline N = int(rl()) S = rl() Q = int(rl()) ks = list(map(int, rl().split())) ans = [] for k in ks: d = m = 0 dm = dmc = 0 for i in range(N): if i >= k: if S[i - k] == "D": d -= 1 dm -= m elif S[i - k] == "M": ...
import sys input = sys.stdin.readline N = int(input()) S = input() Q = int(input()) K = list(map(int, input().split())) ans = [] for k in K: d = m = dm = dmc = 0 for i in range(N): if i >= k: if S[i - k] == "D": d -= 1 dm -= m elif S[i - k] == "M"...
false
7.142857
[ "-rl = sys.stdin.readline", "-N = int(rl())", "-S = rl()", "-Q = int(rl())", "-ks = list(map(int, rl().split()))", "+input = sys.stdin.readline", "+N = int(input())", "+S = input()", "+Q = int(input())", "+K = list(map(int, input().split()))", "-for k in ks:", "- d = m = 0", "- dm = dm...
false
0.04155
0.040964
1.014303
[ "s100975117", "s281816639" ]
u887207211
p03266
python
s646038481
s069576169
85
17
3,060
2,940
Accepted
Accepted
80
N, K = list(map(int,input().split())) a, b = 0, 0 for i in range(1, N+1): if(i%K == 0): a += 1 if(K%2 == 0): for i in range(1, N+1): if(i%K == K//2): b += 1 print((a**3 + b**3))
N, K = list(map(int,input().split())) k = N//K ans = k**3 if(K%2 == 0): if(K*k+K//2 <= N): ans += (k+1)**3 else: ans *= 2 print(ans)
10
9
196
146
N, K = list(map(int, input().split())) a, b = 0, 0 for i in range(1, N + 1): if i % K == 0: a += 1 if K % 2 == 0: for i in range(1, N + 1): if i % K == K // 2: b += 1 print((a**3 + b**3))
N, K = list(map(int, input().split())) k = N // K ans = k**3 if K % 2 == 0: if K * k + K // 2 <= N: ans += (k + 1) ** 3 else: ans *= 2 print(ans)
false
10
[ "-a, b = 0, 0", "-for i in range(1, N + 1):", "- if i % K == 0:", "- a += 1", "+k = N // K", "+ans = k**3", "- for i in range(1, N + 1):", "- if i % K == K // 2:", "- b += 1", "-print((a**3 + b**3))", "+ if K * k + K // 2 <= N:", "+ ans += (k + 1) ** 3"...
false
0.045988
0.126148
0.364558
[ "s646038481", "s069576169" ]
u785989355
p03715
python
s126049618
s661659063
208
189
3,188
40,304
Accepted
Accepted
9.13
H,W = list(map(int,input().split())) min_score = 10**27 for i in range(1,H): if W%2==0: S1 = i*W/2 S2 = (H-i)*W min_score = min(abs(S1-S2),min_score) else: S1 = i*(W-1)/2 S2 = i*(W+1)/2 S3 = (H-i)*W S4 = max(S1,S2,S3) S5 = min(S1,...
H,W=list(map(int,input().split())) min_d=10**27 if H%3==0 or W%3==0: print((0)) else: min_d=min(H,W) for i in range(H+1): a=i*W b=(H-i)*(W//2) c=(H-i)*W - b min_d = min(max(a,b,c)-min(a,b,c),min_d) for i in range(W+1): a=i*H b=(W-i)*(H//2)...
46
19
963
409
H, W = list(map(int, input().split())) min_score = 10**27 for i in range(1, H): if W % 2 == 0: S1 = i * W / 2 S2 = (H - i) * W min_score = min(abs(S1 - S2), min_score) else: S1 = i * (W - 1) / 2 S2 = i * (W + 1) / 2 S3 = (H - i) * W S4 = max(S1, S2, S3) ...
H, W = list(map(int, input().split())) min_d = 10**27 if H % 3 == 0 or W % 3 == 0: print((0)) else: min_d = min(H, W) for i in range(H + 1): a = i * W b = (H - i) * (W // 2) c = (H - i) * W - b min_d = min(max(a, b, c) - min(a, b, c), min_d) for i in range(W + 1): ...
false
58.695652
[ "-min_score = 10**27", "-for i in range(1, H):", "- if W % 2 == 0:", "- S1 = i * W / 2", "- S2 = (H - i) * W", "- min_score = min(abs(S1 - S2), min_score)", "- else:", "- S1 = i * (W - 1) / 2", "- S2 = i * (W + 1) / 2", "- S3 = (H - i) * W", "- ...
false
0.047842
0.047162
1.014414
[ "s126049618", "s661659063" ]
u263753244
p02777
python
s199518380
s388718060
171
27
38,384
9,156
Accepted
Accepted
84.21
s,t=input().split() a,b=list(map(int,input().split())) u=eval(input()) if u==s: a-=1 else: b-=1 print((a,b))
s,t=input().split() a,b=list(map(int,input().split())) u=eval(input()) if u==s: print((a-1,b)) else: print((a,b-1))
8
7
109
113
s, t = input().split() a, b = list(map(int, input().split())) u = eval(input()) if u == s: a -= 1 else: b -= 1 print((a, b))
s, t = input().split() a, b = list(map(int, input().split())) u = eval(input()) if u == s: print((a - 1, b)) else: print((a, b - 1))
false
12.5
[ "- a -= 1", "+ print((a - 1, b))", "- b -= 1", "-print((a, b))", "+ print((a, b - 1))" ]
false
0.03562
0.040097
0.888336
[ "s199518380", "s388718060" ]
u184817817
p03160
python
s806333046
s784820161
184
140
50,960
13,928
Accepted
Accepted
23.91
import sys sys.setrecursionlimit(100000) n = int(eval(input())) h = list(map(int,input().split())) dp_ = [-1]*n def dp(i): if dp_[i]!=-1: return dp_[i] if i == 0: dp_[i] = 0 elif i == 1: dp_[i] = abs(h[1]-h[0]) else: dp_[i] = min(dp(i-2)+abs(h[i]-h[i-2])...
#A n = int(eval(input())) h = list(map(int,input().split())) cost = [0]*n for i in range(n): if i == 0: continue if i == 1: cost[i] = abs(h[i]-h[i-1]) continue cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2])) print((cost[n-1]))
19
13
377
288
import sys sys.setrecursionlimit(100000) n = int(eval(input())) h = list(map(int, input().split())) dp_ = [-1] * n def dp(i): if dp_[i] != -1: return dp_[i] if i == 0: dp_[i] = 0 elif i == 1: dp_[i] = abs(h[1] - h[0]) else: dp_[i] = min(dp(i - 2) + abs(h[i] - h[i - 2])...
# A n = int(eval(input())) h = list(map(int, input().split())) cost = [0] * n for i in range(n): if i == 0: continue if i == 1: cost[i] = abs(h[i] - h[i - 1]) continue cost[i] = min( cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]) ) print((cost[n - ...
false
31.578947
[ "-import sys", "-", "-sys.setrecursionlimit(100000)", "+# A", "-dp_ = [-1] * n", "-", "-", "-def dp(i):", "- if dp_[i] != -1:", "- return dp_[i]", "+cost = [0] * n", "+for i in range(n):", "- dp_[i] = 0", "- elif i == 1:", "- dp_[i] = abs(h[1] - h[0])", "- ...
false
0.046778
0.046399
1.008177
[ "s806333046", "s784820161" ]
u729133443
p02913
python
s670167160
s451546894
49
39
4,196
4,092
Accepted
Accepted
20.41
def main(): import sys input=sys.stdin.buffer.readline n=int(eval(input())) b=129 M=2**61-1 x,y=1,0 f=[x]*(n+2) h=[y]*(n+2) for i,c in enumerate(eval(input())): f[i+1]=x=x*b%M h[i+1]=y=(y*b+c)%M ok,ng=0,n//2+1 while ng-ok>1: mid=ok+ng>>1 ...
def main(): import sys input=sys.stdin.buffer.readline n=int(eval(input())) b=37 M=998244353 x,y=1,0 f=[x]*(n+2) h=[y]*(n+2) for i,c in enumerate(eval(input())): f[i+1]=x=x*b%M h[i+1]=y=(y*b+c)%M ok,ng=0,n//2+1 while ng-ok>1: mid=ok+ng>>1...
28
28
610
611
def main(): import sys input = sys.stdin.buffer.readline n = int(eval(input())) b = 129 M = 2**61 - 1 x, y = 1, 0 f = [x] * (n + 2) h = [y] * (n + 2) for i, c in enumerate(eval(input())): f[i + 1] = x = x * b % M h[i + 1] = y = (y * b + c) % M ok, ng = 0, n // 2 ...
def main(): import sys input = sys.stdin.buffer.readline n = int(eval(input())) b = 37 M = 998244353 x, y = 1, 0 f = [x] * (n + 2) h = [y] * (n + 2) for i, c in enumerate(eval(input())): f[i + 1] = x = x * b % M h[i + 1] = y = (y * b + c) % M ok, ng = 0, n // 2 +...
false
0
[ "- b = 129", "- M = 2**61 - 1", "+ b = 37", "+ M = 998244353" ]
false
0.114268
0.0418
2.733675
[ "s670167160", "s451546894" ]
u072717685
p03162
python
s333845569
s159538953
481
201
40,224
3,060
Accepted
Accepted
58.21
def main(): n = int(eval(input())) abc = [] for _ in range(n): abc.append(tuple(map(int, input().split()))) dp = [[0,0,0] for _ in range(n)] dp[0][0] = abc[0][0] dp[0][1] = abc[0][1] dp[0][2] = abc[0][2] for i in range(1, n): dp[i][0] = max(dp[i - 1][1], dp[i ...
import sys input = sys.stdin.readline def main(): n = int(eval(input())) colA, colB, colC = list(map(int, input().split())) for i1 in range(1, n): a, b, c = list(map(int, input().split())) colA, colB, colC = a + max(colB, colC), b + max(colA, colC), c + max(colA, colB) print((m...
18
13
529
365
def main(): n = int(eval(input())) abc = [] for _ in range(n): abc.append(tuple(map(int, input().split()))) dp = [[0, 0, 0] for _ in range(n)] dp[0][0] = abc[0][0] dp[0][1] = abc[0][1] dp[0][2] = abc[0][2] for i in range(1, n): dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) +...
import sys input = sys.stdin.readline def main(): n = int(eval(input())) colA, colB, colC = list(map(int, input().split())) for i1 in range(1, n): a, b, c = list(map(int, input().split())) colA, colB, colC = a + max(colB, colC), b + max(colA, colC), c + max(colA, colB) print((max(colA...
false
27.777778
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "- abc = []", "- for _ in range(n):", "- abc.append(tuple(map(int, input().split())))", "- dp = [[0, 0, 0] for _ in range(n)]", "- dp[0][0] = abc[0][0]", "- dp[0][1] = abc[0][1]", "- dp[0][2] = abc[0][2]", ...
false
0.06377
0.03411
1.869539
[ "s333845569", "s159538953" ]
u926678805
p03856
python
s605668330
s015948965
82
75
3,188
3,188
Accepted
Accepted
8.54
s=input()[::-1] d=['maerd','remaerd','esare','resare'] while s: for i in range(4): if s.startswith(d[i]): s=s[len(d[i]):] break else: print('NO') exit() print('YES')
s=eval(input()) d=['dream','dreamer','erase','eraser'] while s: for m in d: if s.endswith(m): s=s[:-len(m)] break else: print('NO') exit() print('YES')
11
11
232
212
s = input()[::-1] d = ["maerd", "remaerd", "esare", "resare"] while s: for i in range(4): if s.startswith(d[i]): s = s[len(d[i]) :] break else: print("NO") exit() print("YES")
s = eval(input()) d = ["dream", "dreamer", "erase", "eraser"] while s: for m in d: if s.endswith(m): s = s[: -len(m)] break else: print("NO") exit() print("YES")
false
0
[ "-s = input()[::-1]", "-d = [\"maerd\", \"remaerd\", \"esare\", \"resare\"]", "+s = eval(input())", "+d = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "- for i in range(4):", "- if s.startswith(d[i]):", "- s = s[len(d[i]) :]", "+ for m in d:", "+ if s.endswith(m):...
false
0.06967
0.042737
1.630218
[ "s605668330", "s015948965" ]
u326609687
p02574
python
s686965304
s016048345
626
240
119,728
42,584
Accepted
Accepted
61.66
import numpy as np from numba import njit i4 = np.int32 i8 = np.int64 u4 = np.uint32 @njit def get_factorization(n): """ nまでの割り切れる最小の素数を返す。 """ sieve_size = (n - 1) // 2 sieve = np.zeros(sieve_size, u4) for i in range(sieve_size): if sieve[i] == 0: value_at_...
import sys import numpy as np i4 = np.int32 i8 = np.int64 u4 = np.uint32 if sys.argv[-1] == 'ONLINE_JUDGE': from numba.pycc import CC from numba import njit from numba.types import Array, int32, int64, uint32 cc = CC('my_module') @njit def get_factorization(n): """ ...
79
90
1,770
2,219
import numpy as np from numba import njit i4 = np.int32 i8 = np.int64 u4 = np.uint32 @njit def get_factorization(n): """ nまでの割り切れる最小の素数を返す。 """ sieve_size = (n - 1) // 2 sieve = np.zeros(sieve_size, u4) for i in range(sieve_size): if sieve[i] == 0: value_at_i = i * 2 + 3 ...
import sys import numpy as np i4 = np.int32 i8 = np.int64 u4 = np.uint32 if sys.argv[-1] == "ONLINE_JUDGE": from numba.pycc import CC from numba import njit from numba.types import Array, int32, int64, uint32 cc = CC("my_module") @njit def get_factorization(n): """ nまでの割り切れる最小...
false
12.222222
[ "+import sys", "-from numba import njit", "+if sys.argv[-1] == \"ONLINE_JUDGE\":", "+ from numba.pycc import CC", "+ from numba import njit", "+ from numba.types import Array, int32, int64, uint32", "+ cc = CC(\"my_module\")", "-@njit", "-def get_factorization(n):", "- \"\"\"", "-...
false
0.172163
0.197752
0.870602
[ "s686965304", "s016048345" ]
u102461423
p03248
python
s336734346
s249142210
171
91
16,592
14,232
Accepted
Accepted
46.78
import sys input = sys.stdin.readline S = '-' + input().rstrip() N = len(S) - 1 def solve(S): if S[1] == '0': return None if S[N] == '1': return None prev = 1 graph = [] for n in range(1,N//2 + 1): if S[n] != S[N-n]: return None if S[n] =...
import sys input = sys.stdin.readline S = '-' + input().rstrip() N = len(S) - 1 def solve(S): if S[1] == '0': return None if S[N] == '1': return None prev = 1 graph = [] for n in range(1,N//2 + 1): if S[n] != S[N-n]: return None if S[n] =...
32
31
614
629
import sys input = sys.stdin.readline S = "-" + input().rstrip() N = len(S) - 1 def solve(S): if S[1] == "0": return None if S[N] == "1": return None prev = 1 graph = [] for n in range(1, N // 2 + 1): if S[n] != S[N - n]: return None if S[n] == "0": ...
import sys input = sys.stdin.readline S = "-" + input().rstrip() N = len(S) - 1 def solve(S): if S[1] == "0": return None if S[N] == "1": return None prev = 1 graph = [] for n in range(1, N // 2 + 1): if S[n] != S[N - n]: return None if S[n] == "0": ...
false
3.125
[ "- graph.append((i, n))", "+ graph.append(\"{} {}\".format(i, n))", "- graph.append((i, N))", "+ graph.append(\"{} {}\".format(i, N))", "- for x, y in graph:", "- print((x, y))", "+ print((\"\\n\".join(graph)))" ]
false
0.036177
0.035935
1.006745
[ "s336734346", "s249142210" ]
u134302690
p03308
python
s827363892
s320630441
166
18
38,512
2,940
Accepted
Accepted
89.16
n = int(eval(input())) a = list(map(int,input().split())) a.sort(reverse=True) print((a[0]-a[-1]))
N = int(eval(input())) A = list(map(int,input().split())) A.sort() print((A[-1]-A[0]))
4
4
93
81
n = int(eval(input())) a = list(map(int, input().split())) a.sort(reverse=True) print((a[0] - a[-1]))
N = int(eval(input())) A = list(map(int, input().split())) A.sort() print((A[-1] - A[0]))
false
0
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-a.sort(reverse=True)", "-print((a[0] - a[-1]))", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+A.sort()", "+print((A[-1] - A[0]))" ]
false
0.039377
0.038414
1.025056
[ "s827363892", "s320630441" ]
u636683284
p02837
python
s147650733
s524104905
166
134
74,892
74,436
Accepted
Accepted
19.28
from collections import defaultdict,deque n = int(eval(input())) d = defaultdict(list) for i in range(n): a = int(eval(input())) for j in range(a): x,y = list(map(int,input().split())) d[i].append((x-1,bool(y))) maxi = 0 for i in range(2 ** n): honest = [-1]*n que = ...
def judge(bit): global l for i in range(n): if (bit>>i)&1 == 0: continue for x,y in l[i]: if y==1 and (bit>>x)&1==0: return False if y==0 and (bit>>x)&1==1: return False return True n = int(eval(input())) l = [...
31
24
808
590
from collections import defaultdict, deque n = int(eval(input())) d = defaultdict(list) for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) d[i].append((x - 1, bool(y))) maxi = 0 for i in range(2**n): honest = [-1] * n que = deque([]) ...
def judge(bit): global l for i in range(n): if (bit >> i) & 1 == 0: continue for x, y in l[i]: if y == 1 and (bit >> x) & 1 == 0: return False if y == 0 and (bit >> x) & 1 == 1: return False return True n = int(eval(input(...
false
22.580645
[ "-from collections import defaultdict, deque", "+def judge(bit):", "+ global l", "+ for i in range(n):", "+ if (bit >> i) & 1 == 0:", "+ continue", "+ for x, y in l[i]:", "+ if y == 1 and (bit >> x) & 1 == 0:", "+ return False", "+ ...
false
0.105589
0.036927
2.859386
[ "s147650733", "s524104905" ]
u684120680
p02948
python
s997081043
s256147643
1,697
191
26,692
31,508
Accepted
Accepted
88.74
from bisect import bisect_left as bisect def main(): n, m, *ab = list(map(int, open(0).read().split())) rate = [] for a, b in zip(*[iter(ab)] * 2): if a > m: continue rate.append([a, b]) rate = sorted(rate, key=lambda x: -x[1]) day = list(range(1, m + 1))...
import heapq def main(): n, m, *ab = list(map(int, open(0).read().split())) ab_dict = {} for a, b in zip(*[iter(ab)] * 2): if a > m: continue if a in ab_dict: ab_dict[a].append(-b) else: ab_dict[a] = [-b] cand = [] ans = 0...
30
28
640
594
from bisect import bisect_left as bisect def main(): n, m, *ab = list(map(int, open(0).read().split())) rate = [] for a, b in zip(*[iter(ab)] * 2): if a > m: continue rate.append([a, b]) rate = sorted(rate, key=lambda x: -x[1]) day = list(range(1, m + 1)) day_len = ...
import heapq def main(): n, m, *ab = list(map(int, open(0).read().split())) ab_dict = {} for a, b in zip(*[iter(ab)] * 2): if a > m: continue if a in ab_dict: ab_dict[a].append(-b) else: ab_dict[a] = [-b] cand = [] ans = 0 for day in ...
false
6.666667
[ "-from bisect import bisect_left as bisect", "+import heapq", "- rate = []", "+ ab_dict = {}", "- rate.append([a, b])", "- rate = sorted(rate, key=lambda x: -x[1])", "- day = list(range(1, m + 1))", "- day_len = m", "+ if a in ab_dict:", "+ ab_dict[a].append...
false
0.03845
0.084496
0.455054
[ "s997081043", "s256147643" ]
u555767343
p02786
python
s730326600
s767421888
164
66
38,256
61,772
Accepted
Accepted
59.76
h = int(eval(input())) def attack(h): count = 0 if h == 1: count += 1 return count else: count += 1 count += 2*attack(h//2) return count print((attack(h)))
h = int(eval(input())) num = 1 count = 0 while h > 0: h = h//2 count += num num = num*2 print(count)
12
9
211
115
h = int(eval(input())) def attack(h): count = 0 if h == 1: count += 1 return count else: count += 1 count += 2 * attack(h // 2) return count print((attack(h)))
h = int(eval(input())) num = 1 count = 0 while h > 0: h = h // 2 count += num num = num * 2 print(count)
false
25
[ "-", "-", "-def attack(h):", "- count = 0", "- if h == 1:", "- count += 1", "- return count", "- else:", "- count += 1", "- count += 2 * attack(h // 2)", "- return count", "-", "-", "-print((attack(h)))", "+num = 1", "+count = 0", "+while h...
false
0.069372
0.069357
1.000214
[ "s730326600", "s767421888" ]
u971811058
p03502
python
s986651017
s007526651
31
25
9,104
9,112
Accepted
Accepted
19.35
n = int(eval(input())) s = str(n) sum = 0 for i in range(len(s)): sum+=(ord(s[i])-ord('0')) if n%sum == 0: print("Yes") else: print("No")
s = eval(input()) sum = 0 for i in s: sum+=int(i) if int(s)%sum == 0: print("Yes") else: print("No")
9
6
151
103
n = int(eval(input())) s = str(n) sum = 0 for i in range(len(s)): sum += ord(s[i]) - ord("0") if n % sum == 0: print("Yes") else: print("No")
s = eval(input()) sum = 0 for i in s: sum += int(i) if int(s) % sum == 0: print("Yes") else: print("No")
false
33.333333
[ "-n = int(eval(input()))", "-s = str(n)", "+s = eval(input())", "-for i in range(len(s)):", "- sum += ord(s[i]) - ord(\"0\")", "-if n % sum == 0:", "+for i in s:", "+ sum += int(i)", "+if int(s) % sum == 0:" ]
false
0.038215
0.101535
0.376375
[ "s986651017", "s007526651" ]
u972658925
p02572
python
s093829731
s502539661
276
242
50,036
49,740
Accepted
Accepted
12.32
import numpy as np n = int(eval(input())) a = list(map(int,input().split())) a_sum = sum(a) aa = np.array(np.cumsum(a),dtype="object") all_a = sum(a) mod = 1000000007 ans = 0 for i in range(n-1): ans += (a[i]%mod * (all_a - aa[i])%mod) print((ans%mod))
import numpy as np n = int(eval(input())) a = list(map(int,input().split())) a_sum = sum(a) aa = np.array(np.cumsum(a),dtype="object") all_a = sum(a) mod = 1000000007 ans = 0 for i in range(n-1): ans += (a[i] * (all_a - aa[i])) print((ans%mod))
14
14
264
256
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) a_sum = sum(a) aa = np.array(np.cumsum(a), dtype="object") all_a = sum(a) mod = 1000000007 ans = 0 for i in range(n - 1): ans += a[i] % mod * (all_a - aa[i]) % mod print((ans % mod))
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) a_sum = sum(a) aa = np.array(np.cumsum(a), dtype="object") all_a = sum(a) mod = 1000000007 ans = 0 for i in range(n - 1): ans += a[i] * (all_a - aa[i]) print((ans % mod))
false
0
[ "- ans += a[i] % mod * (all_a - aa[i]) % mod", "+ ans += a[i] * (all_a - aa[i])" ]
false
0.236717
0.231004
1.024731
[ "s093829731", "s502539661" ]
u525065967
p02658
python
s034433713
s532485109
87
72
21,640
21,420
Accepted
Accepted
17.24
n = int(eval(input())) A = [*list(map(int,input().split()))] A.sort() ans = 1 for a in A: ans *= a if ans > 10**18: ans = -1 break print(ans)
n = int(eval(input())) A = [*list(map(int,input().split()))] inf = 10**18 + 1 ans = 1 for a in A: ans = min(ans*a, inf) if ans == inf: ans = -1 print(ans)
10
7
163
149
n = int(eval(input())) A = [*list(map(int, input().split()))] A.sort() ans = 1 for a in A: ans *= a if ans > 10**18: ans = -1 break print(ans)
n = int(eval(input())) A = [*list(map(int, input().split()))] inf = 10**18 + 1 ans = 1 for a in A: ans = min(ans * a, inf) if ans == inf: ans = -1 print(ans)
false
30
[ "-A.sort()", "+inf = 10**18 + 1", "- ans *= a", "- if ans > 10**18:", "- ans = -1", "- break", "+ ans = min(ans * a, inf)", "+if ans == inf:", "+ ans = -1" ]
false
0.103593
0.10522
0.984536
[ "s034433713", "s532485109" ]
u309120194
p02829
python
s420633921
s012439445
28
25
9,168
9,128
Accepted
Accepted
10.71
A = int(eval(input())) B = int(eval(input())) l = [1,2,3] l.remove(A) l.remove(B) print((l[0]))
A = int(eval(input())) B = int(eval(input())) # 頭いい方法! print((6-A-B))
8
5
92
61
A = int(eval(input())) B = int(eval(input())) l = [1, 2, 3] l.remove(A) l.remove(B) print((l[0]))
A = int(eval(input())) B = int(eval(input())) # 頭いい方法! print((6 - A - B))
false
37.5
[ "-l = [1, 2, 3]", "-l.remove(A)", "-l.remove(B)", "-print((l[0]))", "+# 頭いい方法!", "+print((6 - A - B))" ]
false
0.081599
0.044331
1.840687
[ "s420633921", "s012439445" ]
u189487046
p03273
python
s827112964
s851058332
23
20
3,188
3,316
Accepted
Accepted
13.04
H, W = list(map(int, input().split())) a = [] for i in range(H): tmp = list(eval(input())) if "#" in tmp: a.append(tmp) w_check = [True] * W for i in range(len(a)): for j in range(W): if a[i][j] == "#": w_check[j] = False ans = [[] for i in range(len(a))] for i in...
# zipを使用する版 H, W = list(map(int, input().split())) a = [] for _ in range(H): tmp = list(eval(input())) if "#" in tmp: a.append(tmp) a_reverse = list(map(list, list(zip(*a)))) ans = [] for tmp in a_reverse: if "#" in tmp: ans.append(tmp) ans_list = list(map(list, list(zip(*a...
24
22
503
416
H, W = list(map(int, input().split())) a = [] for i in range(H): tmp = list(eval(input())) if "#" in tmp: a.append(tmp) w_check = [True] * W for i in range(len(a)): for j in range(W): if a[i][j] == "#": w_check[j] = False ans = [[] for i in range(len(a))] for i in range(len(a)): ...
# zipを使用する版 H, W = list(map(int, input().split())) a = [] for _ in range(H): tmp = list(eval(input())) if "#" in tmp: a.append(tmp) a_reverse = list(map(list, list(zip(*a)))) ans = [] for tmp in a_reverse: if "#" in tmp: ans.append(tmp) ans_list = list(map(list, list(zip(*ans)))) for tmp_lis...
false
8.333333
[ "+# zipを使用する版", "-for i in range(H):", "+for _ in range(H):", "-w_check = [True] * W", "-for i in range(len(a)):", "- for j in range(W):", "- if a[i][j] == \"#\":", "- w_check[j] = False", "-ans = [[] for i in range(len(a))]", "-for i in range(len(a)):", "- for j in range...
false
0.035195
0.037191
0.946329
[ "s827112964", "s851058332" ]
u581187895
p02888
python
s846156040
s804134227
1,402
817
3,188
3,316
Accepted
Accepted
41.73
import bisect # 三角形の条件: c < a+b N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 # a と b を固定 for a in range(N): for b in range((a+1), N): # c の動ける範囲の右端を求める c = L[a]+L[b] k = bisect.bisect_left(L, c) # c の動ける範囲は、[j+1, k) ans += k - b - 1 print(ans)
import bisect # 三角形の条件: c < a+b N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N-1, 1, -1): a = 0 b = i-1 while a<b: if L[a]+L[b] > L[i]: ans += b-a b -= 1 else: a += 1 print(ans)
17
19
313
285
import bisect # 三角形の条件: c < a+b N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 # a と b を固定 for a in range(N): for b in range((a + 1), N): # c の動ける範囲の右端を求める c = L[a] + L[b] k = bisect.bisect_left(L, c) # c の動ける範囲は、[j+1, k) ans += k - b - 1 print(a...
import bisect # 三角形の条件: c < a+b N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 1, 1, -1): a = 0 b = i - 1 while a < b: if L[a] + L[b] > L[i]: ans += b - a b -= 1 else: a += 1 print(ans)
false
10.526316
[ "-# a と b を固定", "-for a in range(N):", "- for b in range((a + 1), N):", "- # c の動ける範囲の右端を求める", "- c = L[a] + L[b]", "- k = bisect.bisect_left(L, c)", "- # c の動ける範囲は、[j+1, k)", "- ans += k - b - 1", "+for i in range(N - 1, 1, -1):", "+ a = 0", "+ b = i ...
false
0.039461
0.04661
0.846631
[ "s846156040", "s804134227" ]
u678167152
p02844
python
s244817804
s620181490
405
18
71,132
3,060
Accepted
Accepted
95.56
from collections import deque,defaultdict def solve(): N = int(eval(input())) S = list(eval(input())) dic = defaultdict(lambda: False) ans = 0 d = deque() for s in S: for _ in range(len(d)): t = d.popleft() d.append(t) if len(t)==1: ...
n=int(eval(input())) s=eval(input()) ans=0 for i in range(10): x=s.find(str(i)) if x!=-1: for j in range(10): y=s.find(str(j),x+1) if y!=-1: for k in range(10): z=s.find(str(k),y+1) if z!=-1: ...
26
15
690
334
from collections import deque, defaultdict def solve(): N = int(eval(input())) S = list(eval(input())) dic = defaultdict(lambda: False) ans = 0 d = deque() for s in S: for _ in range(len(d)): t = d.popleft() d.append(t) if len(t) == 1: ...
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(10): x = s.find(str(i)) if x != -1: for j in range(10): y = s.find(str(j), x + 1) if y != -1: for k in range(10): z = s.find(str(k), y + 1) if z != -1: ...
false
42.307692
[ "-from collections import deque, defaultdict", "-", "-", "-def solve():", "- N = int(eval(input()))", "- S = list(eval(input()))", "- dic = defaultdict(lambda: False)", "- ans = 0", "- d = deque()", "- for s in S:", "- for _ in range(len(d)):", "- t = d.popl...
false
0.083311
0.035161
2.369405
[ "s244817804", "s620181490" ]
u183200783
p02785
python
s091235035
s023672763
213
186
26,180
26,024
Accepted
Accepted
12.68
N, K = list(map(int, input().split())) H = sorted(list(map(int, input().split())), reverse=True) cnt = 0 atk = 0 while True: for i in range(N): if H[i] <= 0: continue else: if K > 0: K -= 1 H[i] = 0 cnt += 1 ...
N, K = list(map(int, input().split())) H = sorted(list(map(int, input().split())), reverse=True) atk = 0 for i in range(N): if K > 0: K -= 1 else: atk += H[i] print(atk)
22
11
430
199
N, K = list(map(int, input().split())) H = sorted(list(map(int, input().split())), reverse=True) cnt = 0 atk = 0 while True: for i in range(N): if H[i] <= 0: continue else: if K > 0: K -= 1 H[i] = 0 cnt += 1 else: ...
N, K = list(map(int, input().split())) H = sorted(list(map(int, input().split())), reverse=True) atk = 0 for i in range(N): if K > 0: K -= 1 else: atk += H[i] print(atk)
false
50
[ "-cnt = 0", "-while True:", "- for i in range(N):", "- if H[i] <= 0:", "- continue", "- else:", "- if K > 0:", "- K -= 1", "- H[i] = 0", "- cnt += 1", "- else:", "- atk += H[i]", "- ...
false
0.039298
0.037495
1.048072
[ "s091235035", "s023672763" ]
u948524308
p03013
python
s933373515
s249567187
357
154
460,020
3,064
Accepted
Accepted
56.86
def fib(n): if n==1: ans=[1] return ans ans=[1,1] cnt=2 while cnt <n: ans.append(ans[-2]+ans[-1]) cnt+=1 return ans N,M=list(map(int,input().split())) mod=10**9+7 if N==1: print((1)) exit() a0=-1 ans=1 for i in range(M): a=int(e...
def fib(n): if n==1: a=1 return a if n==2: a=1 return a a0=1 a1=1 cnt=2 while cnt <n: a=a0+a1 cnt+=1 a0=a1 a1=a return a N,M=list(map(int,input().split())) mod=10**9+7 if N==1: print((1)) exit...
40
46
530
573
def fib(n): if n == 1: ans = [1] return ans ans = [1, 1] cnt = 2 while cnt < n: ans.append(ans[-2] + ans[-1]) cnt += 1 return ans N, M = list(map(int, input().split())) mod = 10**9 + 7 if N == 1: print((1)) exit() a0 = -1 ans = 1 for i in range(M): a = i...
def fib(n): if n == 1: a = 1 return a if n == 2: a = 1 return a a0 = 1 a1 = 1 cnt = 2 while cnt < n: a = a0 + a1 cnt += 1 a0 = a1 a1 = a return a N, M = list(map(int, input().split())) mod = 10**9 + 7 if N == 1: print((1))...
false
13.043478
[ "- ans = [1]", "- return ans", "- ans = [1, 1]", "+ a = 1", "+ return a", "+ if n == 2:", "+ a = 1", "+ return a", "+ a0 = 1", "+ a1 = 1", "- ans.append(ans[-2] + ans[-1])", "+ a = a0 + a1", "- return ans", "+ a0...
false
0.052728
0.041976
1.256153
[ "s933373515", "s249567187" ]
u727717182
p02713
python
s607559181
s808074269
929
509
9,636
67,720
Accepted
Accepted
45.21
from sys import stdin import math from functools import reduce def main(): input = stdin.readline K = int(eval(input())) ans_sum = 0 for i in range(1,K+1): for j in range(i,K+1): for k in range(j,K+1): check = [i,j,k] sum_type = ...
import math K = int(eval(input())) ans = 0 for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): ans += math.gcd(math.gcd(a,b),c) print(ans)
34
9
689
183
from sys import stdin import math from functools import reduce def main(): input = stdin.readline K = int(eval(input())) ans_sum = 0 for i in range(1, K + 1): for j in range(i, K + 1): for k in range(j, K + 1): check = [i, j, k] sum_type = len(set(ch...
import math K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): for c in range(1, K + 1): ans += math.gcd(math.gcd(a, b), c) print(ans)
false
73.529412
[ "-from sys import stdin", "-from functools import reduce", "-", "-def main():", "- input = stdin.readline", "- K = int(eval(input()))", "- ans_sum = 0", "- for i in range(1, K + 1):", "- for j in range(i, K + 1):", "- for k in range(j, K + 1):", "- ch...
false
0.16054
0.041718
3.848186
[ "s607559181", "s808074269" ]
u634079249
p03352
python
s603009630
s543579821
1,333
35
2,940
10,248
Accepted
Accepted
97.37
import sys import os def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") N = int(sys.stdin.readline().rstrip()) ret = 1 for b in range(1, N): for p in range(2, N//2): if b ** p <= N: ret = max(ret, b ** p) print(ret) ...
import sys, os, math, bisect, itertools, collections, heapq, queue # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) ...
20
50
362
1,337
import sys import os def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") N = int(sys.stdin.readline().rstrip()) ret = 1 for b in range(1, N): for p in range(2, N // 2): if b**p <= N: ret = max(ret, b**p) print(ret) if __name__ == "__m...
import sys, os, math, bisect, itertools, collections, heapq, queue # from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda...
false
60
[ "-import sys", "-import os", "+import sys, os, math, bisect, itertools, collections, heapq, queue", "+", "+# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall", "+from decimal import Decimal", "+from collections import defaultdict", "+", "+# import fractions", "+sys.setrecursionl...
false
0.665237
0.006788
98.00178
[ "s603009630", "s543579821" ]
u030090262
p03495
python
s877901405
s839834860
221
102
39,344
32,568
Accepted
Accepted
53.85
from collections import Counter N,K=list(map(int,input().split())) a = list(map(int,input().split())) d=Counter(a) d=sorted(list(d.items()),key=lambda x:x[1]) ans=0 for i in range(len(d)-K): ans+=d[i][1] print(ans)
from collections import Counter N,K=list(map(int,input().split())) a = list(map(int,input().split())) d=Counter(a) ans=sum(sorted(list(d.values()),reverse=1)[:K]) print((N-ans))
9
6
218
168
from collections import Counter N, K = list(map(int, input().split())) a = list(map(int, input().split())) d = Counter(a) d = sorted(list(d.items()), key=lambda x: x[1]) ans = 0 for i in range(len(d) - K): ans += d[i][1] print(ans)
from collections import Counter N, K = list(map(int, input().split())) a = list(map(int, input().split())) d = Counter(a) ans = sum(sorted(list(d.values()), reverse=1)[:K]) print((N - ans))
false
33.333333
[ "-d = sorted(list(d.items()), key=lambda x: x[1])", "-ans = 0", "-for i in range(len(d) - K):", "- ans += d[i][1]", "-print(ans)", "+ans = sum(sorted(list(d.values()), reverse=1)[:K])", "+print((N - ans))" ]
false
0.033622
0.042034
0.79989
[ "s877901405", "s839834860" ]
u993435350
p03147
python
s537462678
s465929643
59
19
3,188
3,060
Accepted
Accepted
67.8
N = int(eval(input())) H = list(map(int,input().split())) flowers = [0] * N start = 0 end = 0 con = 0 while flowers != H: for i in range(0,N): if H[i] > flowers[i]: start = i for j in range(i,N): if H[j] == flowers[j]: end = j break else: end = N break ...
N = int(eval(input())) L = list(map(int,input().split())) s = L[0] ans = s for i in range(0,N): if s <= L[i]: ans += L[i] - s s = L[i] print(ans)
34
10
414
157
N = int(eval(input())) H = list(map(int, input().split())) flowers = [0] * N start = 0 end = 0 con = 0 while flowers != H: for i in range(0, N): if H[i] > flowers[i]: start = i for j in range(i, N): if H[j] == flowers[j]: end = j ...
N = int(eval(input())) L = list(map(int, input().split())) s = L[0] ans = s for i in range(0, N): if s <= L[i]: ans += L[i] - s s = L[i] print(ans)
false
70.588235
[ "-H = list(map(int, input().split()))", "-flowers = [0] * N", "-start = 0", "-end = 0", "-con = 0", "-while flowers != H:", "- for i in range(0, N):", "- if H[i] > flowers[i]:", "- start = i", "- for j in range(i, N):", "- if H[j] == flowers[j]:", ...
false
0.076832
0.036834
2.085917
[ "s537462678", "s465929643" ]
u345389118
p02571
python
s632183244
s537519365
72
65
9,104
9,148
Accepted
Accepted
9.72
S = eval(input()) T = eval(input()) res = 0 for i in range(len(S) - len(T) + 1): tmp = 0 for j in range(len(T)): if S[i+j] == T[j]: tmp += 1 res = max(res, tmp) print((len(T) - res))
S = eval(input()) T = eval(input()) if len(S) == 1: if S == T: print((0)) else: print((1)) else: l = [] for i in range(len(S) - len(T) + 1): A = S[i:i + (len(T))] # print(A) count = 0 for j in range(len(A)): if A[j] == T[j]: ...
12
28
214
517
S = eval(input()) T = eval(input()) res = 0 for i in range(len(S) - len(T) + 1): tmp = 0 for j in range(len(T)): if S[i + j] == T[j]: tmp += 1 res = max(res, tmp) print((len(T) - res))
S = eval(input()) T = eval(input()) if len(S) == 1: if S == T: print((0)) else: print((1)) else: l = [] for i in range(len(S) - len(T) + 1): A = S[i : i + (len(T))] # print(A) count = 0 for j in range(len(A)): if A[j] == T[j]: c...
false
57.142857
[ "-res = 0", "-for i in range(len(S) - len(T) + 1):", "- tmp = 0", "- for j in range(len(T)):", "- if S[i + j] == T[j]:", "- tmp += 1", "- res = max(res, tmp)", "-print((len(T) - res))", "+if len(S) == 1:", "+ if S == T:", "+ print((0))", "+ else:", "+ ...
false
0.037487
0.04951
0.757155
[ "s632183244", "s537519365" ]
u427344224
p03713
python
s713634872
s576275340
455
235
18,968
11,032
Accepted
Accepted
48.35
H, W = list(map(int, input().split())) result = [] for h in range(1, H): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * remai...
H, W = list(map(int, input().split())) result = [] for h in range(1, H//2+1): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * ...
32
32
724
734
H, W = list(map(int, input().split())) result = [] for h in range(1, H): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * remain result.appe...
H, W = list(map(int, input().split())) result = [] for h in range(1, H // 2 + 1): Sa = W * h remain = H - h h2 = (remain + 1) // 2 Sb1 = W * h2 Sc1 = W * (remain - h2) result.append(max(Sa, Sb1, Sc1) - min(Sa, Sb1, Sc1)) w = (W + 1) // 2 Sb2 = w * remain Sc2 = (W - w) * remain re...
false
0
[ "-for h in range(1, H):", "+for h in range(1, H // 2 + 1):", "-for w in range(1, W):", "+for w in range(1, W // 2 + 1):" ]
false
0.896158
0.286843
3.124216
[ "s713634872", "s576275340" ]
u577170763
p02923
python
s209985194
s747794476
199
66
58,224
12,776
Accepted
Accepted
66.83
import sys from math import pi, cos, sqrt from collections import defaultdict readline = sys.stdin.buffer.readline #sys.setrecursionlimit(10**8) def geta(fn=lambda s: s.decode()): return list(map(fn, readline().split())) def gete(fn=lambda s: s.decode()): return fn(readline().rstrip()) def ...
import sys from math import pi, cos, sqrt from collections import defaultdict readline = sys.stdin.buffer.readline #sys.setrecursionlimit(10**8) def geta(fn=lambda s: s.decode()): return list(map(fn, readline().split())) def gete(fn=lambda s: s.decode()): return fn(readline().rstrip()) def ...
35
35
628
664
import sys from math import pi, cos, sqrt from collections import defaultdict readline = sys.stdin.buffer.readline # sys.setrecursionlimit(10**8) def geta(fn=lambda s: s.decode()): return list(map(fn, readline().split())) def gete(fn=lambda s: s.decode()): return fn(readline().rstrip()) def main(): n =...
import sys from math import pi, cos, sqrt from collections import defaultdict readline = sys.stdin.buffer.readline # sys.setrecursionlimit(10**8) def geta(fn=lambda s: s.decode()): return list(map(fn, readline().split())) def gete(fn=lambda s: s.decode()): return fn(readline().rstrip()) def main(): n =...
false
0
[ "- h = tuple(geta(int))", "- ans = 0", "+ h = list(geta(int))", "+ h += [10**10]", "- for i in range(n - 1):", "- if h[i] >= h[i + 1]:", "- cur += 1", "- if cur > ans:", "- ans = cur", "+ ans, tmp = 0, 0", "+ while cur < n:", "+ ...
false
0.034387
0.037079
0.927408
[ "s209985194", "s747794476" ]
u368780724
p03662
python
s995516323
s319322510
903
808
35,544
34,776
Accepted
Accepted
10.52
from collections import defaultdict def inpl(): return [int(i) for i in input().split()] path = defaultdict(lambda: []) N = int(eval(input())) for _ in range(N-1): a, b = inpl() path[a].append(b) path[b].append(a) inf = float('inf') ctr = 1 now = {1} distF = [inf for _ in range(N+1)] distF[1...
from collections import defaultdict def inpl(): return [int(i) for i in input().split()] path = defaultdict(lambda: []) N = int(eval(input())) for _ in range(N-1): a, b = inpl() path[a].append(b) path[b].append(a) inf = float('inf') ctr = 1 now = {1} distF = [inf for _ in range(N+1)] distF[1...
66
47
1,553
1,073
from collections import defaultdict def inpl(): return [int(i) for i in input().split()] path = defaultdict(lambda: []) N = int(eval(input())) for _ in range(N - 1): a, b = inpl() path[a].append(b) path[b].append(a) inf = float("inf") ctr = 1 now = {1} distF = [inf for _ in range(N + 1)] distF[1] = ...
from collections import defaultdict def inpl(): return [int(i) for i in input().split()] path = defaultdict(lambda: []) N = int(eval(input())) for _ in range(N - 1): a, b = inpl() path[a].append(b) path[b].append(a) inf = float("inf") ctr = 1 now = {1} distF = [inf for _ in range(N + 1)] distF[1] = ...
false
28.787879
[ "-D = distF[N]", "+ctr = 0", "- if distF[i] == D // 2 and distF[i] + distS[i] == D:", "- St = i", "- if distF[i] == D // 2 + 1 and distF[i] + distS[i] == D:", "- En = i", "-path[St].remove(En)", "-path[En].remove(St)", "-ctr = 1", "-now = {1}", "-distF = [inf for _ in range(N...
false
0.091896
0.085609
1.073437
[ "s995516323", "s319322510" ]
u706330549
p02754
python
s905585905
s519947502
19
17
3,060
3,060
Accepted
Accepted
10.53
n, a, b = [int(x) for x in input().split()] if a == 0 and b == 0: print("0") elif a >= n: print(n) else: x = n // (a + b) if x == 0: print(a) else: if (n - ((a + b) * x)) >= a: print((a * x + a)) else: print((a * x + (n - (a + b) * x)))
n, a, b = [int(x) for x in input().split()] if a == 0 and b == 0: print("0") elif a >= n: print(n) else: x = n // (a + b) if x == 0: print(a) else: if (n - ((a + b) * x)) >= a: print((a * x + a)) else: print((n - b * x))
15
15
318
300
n, a, b = [int(x) for x in input().split()] if a == 0 and b == 0: print("0") elif a >= n: print(n) else: x = n // (a + b) if x == 0: print(a) else: if (n - ((a + b) * x)) >= a: print((a * x + a)) else: print((a * x + (n - (a + b) * x)))
n, a, b = [int(x) for x in input().split()] if a == 0 and b == 0: print("0") elif a >= n: print(n) else: x = n // (a + b) if x == 0: print(a) else: if (n - ((a + b) * x)) >= a: print((a * x + a)) else: print((n - b * x))
false
0
[ "- print((a * x + (n - (a + b) * x)))", "+ print((n - b * x))" ]
false
0.042877
0.041465
1.034065
[ "s905585905", "s519947502" ]
u497596438
p03681
python
s523609463
s683379842
206
99
41,968
14,816
Accepted
Accepted
51.94
N,M=list(map(int,input().split())) if abs(N-M)>1: print((0)) quit() if abs(N-M)==1: a=1 else: a=2 MOD=10**9+7 def factorials(M):#M!までのリストxと其の逆元のリストyを返すmod INF INF=int(1e9+7) fac=[0]*(M+1) finv=[0]*(M+1) inv=[0]*(M+1) fac[0]=fac[1]=1 finv[0]=finv[1]=1 inv[1]=1 ...
N,M=list(map(int,input().split())) MOD=10**9+7 if abs(N-M)>=2: print((0)) quit() if abs(N-M)==1: a=1 else: a=2 def factorials(M):#M!までのリストxと其の逆元のリストyを返すmod INF INF=int(1e9+7) fac=[0]*(M+1) finv=[0]*(M+1) inv=[0]*(M+1) fac[0]=fac[1]=1 finv[0]=finv[1]=1 inv[1]=1...
31
24
671
540
N, M = list(map(int, input().split())) if abs(N - M) > 1: print((0)) quit() if abs(N - M) == 1: a = 1 else: a = 2 MOD = 10**9 + 7 def factorials(M): # M!までのリストxと其の逆元のリストyを返すmod INF INF = int(1e9 + 7) fac = [0] * (M + 1) finv = [0] * (M + 1) inv = [0] * (M + 1) fac[0] = fac[1] = 1 ...
N, M = list(map(int, input().split())) MOD = 10**9 + 7 if abs(N - M) >= 2: print((0)) quit() if abs(N - M) == 1: a = 1 else: a = 2 def factorials(M): # M!までのリストxと其の逆元のリストyを返すmod INF INF = int(1e9 + 7) fac = [0] * (M + 1) finv = [0] * (M + 1) inv = [0] * (M + 1) fac[0] = fac[1] = 1...
false
22.580645
[ "-if abs(N - M) > 1:", "+MOD = 10**9 + 7", "+if abs(N - M) >= 2:", "-MOD = 10**9 + 7", "-def nCr(n, r):", "- INF = int(1e9 + 7)", "- if n < r or r < 0 or n < 0:", "- return 0", "- return fac[n] * (finv[r] * finv[n - r] % INF) % INF", "-", "-" ]
false
0.04112
0.200348
0.205244
[ "s523609463", "s683379842" ]
u747602774
p02659
python
s401326721
s442955833
27
22
9,880
9,060
Accepted
Accepted
18.52
A,B = input().split() from decimal import Decimal,ROUND_DOWN A = Decimal(A) B = Decimal(B) N = A*B print((N.quantize(Decimal('1'),rounding=ROUND_DOWN)))
A,B = input().split() A = int(A) B = B.replace('.','') B = int(B) print((A*B//100))
6
7
155
91
A, B = input().split() from decimal import Decimal, ROUND_DOWN A = Decimal(A) B = Decimal(B) N = A * B print((N.quantize(Decimal("1"), rounding=ROUND_DOWN)))
A, B = input().split() A = int(A) B = B.replace(".", "") B = int(B) print((A * B // 100))
false
14.285714
[ "-from decimal import Decimal, ROUND_DOWN", "-", "-A = Decimal(A)", "-B = Decimal(B)", "-N = A * B", "-print((N.quantize(Decimal(\"1\"), rounding=ROUND_DOWN)))", "+A = int(A)", "+B = B.replace(\".\", \"\")", "+B = int(B)", "+print((A * B // 100))" ]
false
0.052058
0.046853
1.111082
[ "s401326721", "s442955833" ]
u046187684
p03472
python
s377776590
s709017728
363
229
36,256
27,268
Accepted
Accepted
36.91
from math import ceil from numpy import cumsum def solve(string): n, h, *ab = list(map(int, string.split())) max_a = max(ab[::2]) cnt = 0 b = sorted([b for b in ab[1::2] if b > max_a], reverse=True) if sum(b) < h: cnt = len(b) + ceil((h - sum(b)) / max_a) else: cn...
from math import ceil def solve(string): n, h, *ab = list(map(int, string.split())) max_a = max(ab[::2]) b = sorted([b for b in ab[1::2] if b > max_a], reverse=True) if sum(b) < h: cnt = len(b) + ceil((h - sum(b)) / max_a) else: for i, _b in enumerate(b): cnt...
27
21
660
565
from math import ceil from numpy import cumsum def solve(string): n, h, *ab = list(map(int, string.split())) max_a = max(ab[::2]) cnt = 0 b = sorted([b for b in ab[1::2] if b > max_a], reverse=True) if sum(b) < h: cnt = len(b) + ceil((h - sum(b)) / max_a) else: cnt = (cumsum(b)...
from math import ceil def solve(string): n, h, *ab = list(map(int, string.split())) max_a = max(ab[::2]) b = sorted([b for b in ab[1::2] if b > max_a], reverse=True) if sum(b) < h: cnt = len(b) + ceil((h - sum(b)) / max_a) else: for i, _b in enumerate(b): cnt = i + 1 ...
false
22.222222
[ "-from numpy import cumsum", "- cnt = 0", "- cnt = (cumsum(b) >= h).argmax() + 1", "- \"\"\"", "- for _b in b:", "- cnt += 1", "+ for i, _b in enumerate(b):", "+ cnt = i + 1", "- \"\"\"" ]
false
0.42521
0.040333
10.542587
[ "s377776590", "s709017728" ]
u151005508
p03665
python
s184517530
s880658752
185
17
39,408
2,940
Accepted
Accepted
90.81
import math N, P = map(int, input().split()) A = list(map(int, input().split())) odd = list(filter(lambda x:(x % 2 == 1), A)) even = list(filter(lambda x:(x % 2 == 0), A)) #print(odd) #print(even) odd_num = len(odd) even_num = len(even) ans = 0 def comb(n, r ): return math.factorial(n) //\ ...
N, P = list(map(int, input().split())) A = list(map(int, input().split())) if list([x for x in A if (x % 2 == 1)]): print((2 ** (N -1))) else: if P == 0: print((2 ** N)) else: print((0))
32
10
769
214
import math N, P = map(int, input().split()) A = list(map(int, input().split())) odd = list(filter(lambda x: (x % 2 == 1), A)) even = list(filter(lambda x: (x % 2 == 0), A)) # print(odd) # print(even) odd_num = len(odd) even_num = len(even) ans = 0 def comb(n, r): return math.factorial(n) // (math.factorial(r) *...
N, P = list(map(int, input().split())) A = list(map(int, input().split())) if list([x for x in A if (x % 2 == 1)]): print((2 ** (N - 1))) else: if P == 0: print((2**N)) else: print((0))
false
68.75
[ "-import math", "-", "-N, P = map(int, input().split())", "+N, P = list(map(int, input().split()))", "-odd = list(filter(lambda x: (x % 2 == 1), A))", "-even = list(filter(lambda x: (x % 2 == 0), A))", "-# print(odd)", "-# print(even)", "-odd_num = len(odd)", "-even_num = len(even)", "-ans = 0",...
false
0.08294
0.035848
2.313655
[ "s184517530", "s880658752" ]
u200887663
p02754
python
s379256293
s483662257
24
17
3,060
2,940
Accepted
Accepted
29.17
#n=int(input()) n,a,b=list(map(int,input().split())) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] v=n//(a+b) ans=v*a mod=n%(a+b) temp=min(mod,a) ans+=temp print(ans)
#k=int(input()) n,a,b=list(map(int,input().split())) #hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] total=a+b ans=(n//total)*a print((ans+min(a,n%total)))
12
9
217
199
# n=int(input()) n, a, b = list(map(int, input().split())) # l=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] v = n // (a + b) ans = v * a mod = n % (a + b) temp = min(mod, a) ans += temp print(ans)
# k=int(input()) n, a, b = list(map(int, input().split())) # hl=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] total = a + b ans = (n // total) * a print((ans + min(a, n % total)))
false
25
[ "-# n=int(input())", "+# k=int(input())", "-# l=list(map(int,input().split()))", "+# hl=list(map(int,input().split()))", "-v = n // (a + b)", "-ans = v * a", "-mod = n % (a + b)", "-temp = min(mod, a)", "-ans += temp", "-print(ans)", "+total = a + b", "+ans = (n // total) * a", "+print((ans ...
false
0.037752
0.036128
1.044934
[ "s379256293", "s483662257" ]
u497952650
p02793
python
s528114389
s628030308
1,874
1,573
4,084
75,188
Accepted
Accepted
16.06
def gcd(a,b): while b!=0: a,b=b,a%b return a def lcm(a, b): return (a * b)//gcd(a,b) N = int(eval(input())) A = list(map(int,input().split())) lcm_a = 1 for i in A: lcm_a = lcm(lcm_a,i) ans = 0 for i in A: ans +=lcm_a//i print((ans%int(1e9+7)))
N = int(eval(input())) A = list(map(int,input().split())) def gcd(a,b): while b!=0: a,b=b,a%b return a def lcm(a, b): return (a * b)//gcd(a,b) lcm_a = 1 for i in range(N): lcm_a = lcm(lcm_a,A[i]) ans = 0 for i in range(N): ans += lcm_a//A[i] mod = int(1e9+7) ...
21
23
295
331
def gcd(a, b): while b != 0: a, b = b, a % b return a def lcm(a, b): return (a * b) // gcd(a, b) N = int(eval(input())) A = list(map(int, input().split())) lcm_a = 1 for i in A: lcm_a = lcm(lcm_a, i) ans = 0 for i in A: ans += lcm_a // i print((ans % int(1e9 + 7)))
N = int(eval(input())) A = list(map(int, input().split())) def gcd(a, b): while b != 0: a, b = b, a % b return a def lcm(a, b): return (a * b) // gcd(a, b) lcm_a = 1 for i in range(N): lcm_a = lcm(lcm_a, A[i]) ans = 0 for i in range(N): ans += lcm_a // A[i] mod = int(1e9 + 7) print((an...
false
8.695652
[ "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+", "+", "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-for i in A:", "- lcm_a = lcm(lcm_a, i)", "+for i in range(N):", "+ lcm_a = lcm(lcm_a, A[i])", "-for i in A:", "- ans += lcm_a // i", "-pr...
false
0.105355
0.035567
2.962173
[ "s528114389", "s628030308" ]
u475503988
p02623
python
s886495034
s802199061
842
186
44,616
44,624
Accepted
Accepted
77.91
import numpy as np import sys input = sys.stdin.buffer.readline N, M, K = list(map(int, input().split())) cumA = np.zeros(N+1, dtype=np.int64) cumA[1:] = np.array(input().split(), dtype=np.int64).cumsum() cumB = np.zeros(M+1, dtype=np.int64) cumB[1:] = np.array(input().split(), dtype=np.int64).cumsum() # prin...
import numpy as np import sys input = sys.stdin.buffer.readline N, M, K = list(map(int, input().split())) cumA = np.zeros(N+1, dtype=np.int64) cumA[1:] = np.array(input().split(), dtype=np.int64).cumsum() cumB = np.zeros(M+1, dtype=np.int64) cumB[1:] = np.array(input().split(), dtype=np.int64).cumsum() # prin...
18
17
500
490
import numpy as np import sys input = sys.stdin.buffer.readline N, M, K = list(map(int, input().split())) cumA = np.zeros(N + 1, dtype=np.int64) cumA[1:] = np.array(input().split(), dtype=np.int64).cumsum() cumB = np.zeros(M + 1, dtype=np.int64) cumB[1:] = np.array(input().split(), dtype=np.int64).cumsum() # print(cum...
import numpy as np import sys input = sys.stdin.buffer.readline N, M, K = list(map(int, input().split())) cumA = np.zeros(N + 1, dtype=np.int64) cumA[1:] = np.array(input().split(), dtype=np.int64).cumsum() cumB = np.zeros(M + 1, dtype=np.int64) cumB[1:] = np.array(input().split(), dtype=np.int64).cumsum() # print(cum...
false
5.555556
[ "-ans = 0", "-for i in range(N, -1, -1):", "- if cumA[i] > K:", "- continue", "- j = np.searchsorted(cumB, K - cumA[i], side=\"right\")", "- ans = max(ans, i + j - 1)", "-print(ans)", "+cumA = cumA[cumA <= K]", "+cumB = cumB[cumB <= K]", "+ans = np.searchsorted(cumA, K - cumB, side...
false
0.404396
0.34614
1.168299
[ "s886495034", "s802199061" ]