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
u609061751
p03043
python
s962392740
s277119351
183
44
38,896
2,940
Accepted
Accepted
75.96
import sys input = sys.stdin.readline n, k = [int(x) for x in input().split()] ans = 0 for i in range(1, n + 1): score = i cnt = 0 while score < k: cnt += 1 score *= 2 ans += (1/n) * (1/2)**cnt print(ans)
import sys input = lambda : sys.stdin.readline().rstrip() n, k = list(map(int, input().split())) p = 0 for i in range(1, n + 1): cnt = 0 while 1 <= i <= k - 1: cnt += 1 i *= 2 p += 0.5**cnt print((p / n))
16
15
255
242
import sys input = sys.stdin.readline n, k = [int(x) for x in input().split()] ans = 0 for i in range(1, n + 1): score = i cnt = 0 while score < k: cnt += 1 score *= 2 ans += (1 / n) * (1 / 2) ** cnt print(ans)
import sys input = lambda: sys.stdin.readline().rstrip() n, k = list(map(int, input().split())) p = 0 for i in range(1, n + 1): cnt = 0 while 1 <= i <= k - 1: cnt += 1 i *= 2 p += 0.5**cnt print((p / n))
false
6.25
[ "-input = sys.stdin.readline", "-n, k = [int(x) for x in input().split()]", "-ans = 0", "+input = lambda: sys.stdin.readline().rstrip()", "+n, k = list(map(int, input().split()))", "+p = 0", "- score = i", "- while score < k:", "+ while 1 <= i <= k - 1:", "- score *= 2", "- an...
false
0.056269
0.185439
0.303438
[ "s962392740", "s277119351" ]
u896741788
p03295
python
s637253885
s385421020
486
344
29,848
32,724
Accepted
Accepted
29.22
n,m=list(map(int,input().split())) l=[] l=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1]) ans=1 now=l[0][1]-1 for x,y in l[1:]: if x<=now<=y-1:continue ans+=1 now=y-1 print(ans)
n,m=list(map(int,input().split())) ans=0 head=1 from operator import itemgetter as it for x,y in sorted([list(map(int,input().split()))for i in range(m)],reverse=0,key=lambda x:(it(1)(x)*(n+1)*10-it(0)(x))): if not(x<head <=y): head=y ans+=1 print(ans)
11
9
223
274
n, m = list(map(int, input().split())) l = [] l = sorted([list(map(int, input().split())) for i in range(m)], key=lambda x: x[1]) ans = 1 now = l[0][1] - 1 for x, y in l[1:]: if x <= now <= y - 1: continue ans += 1 now = y - 1 print(ans)
n, m = list(map(int, input().split())) ans = 0 head = 1 from operator import itemgetter as it for x, y in sorted( [list(map(int, input().split())) for i in range(m)], reverse=0, key=lambda x: (it(1)(x) * (n + 1) * 10 - it(0)(x)), ): if not (x < head <= y): head = y ans += 1 print(ans)
false
18.181818
[ "-l = []", "-l = sorted([list(map(int, input().split())) for i in range(m)], key=lambda x: x[1])", "-ans = 1", "-now = l[0][1] - 1", "-for x, y in l[1:]:", "- if x <= now <= y - 1:", "- continue", "- ans += 1", "- now = y - 1", "+ans = 0", "+head = 1", "+from operator import it...
false
0.096222
0.036161
2.660913
[ "s637253885", "s385421020" ]
u799215419
p02659
python
s019802173
s423483798
37
34
10,084
10,052
Accepted
Accepted
8.11
import math from decimal import * A, B = list(map(str, input().split())) print((math.floor(Decimal(A) * Decimal(B))))
import math from decimal import Decimal A, B = list(map(str, input().split())) print((math.floor(Decimal(A) * Decimal(B))))
4
4
118
124
import math from decimal import * A, B = list(map(str, input().split())) print((math.floor(Decimal(A) * Decimal(B))))
import math from decimal import Decimal A, B = list(map(str, input().split())) print((math.floor(Decimal(A) * Decimal(B))))
false
0
[ "-from decimal import *", "+from decimal import Decimal" ]
false
0.035159
0.034486
1.019511
[ "s019802173", "s423483798" ]
u516554284
p03557
python
s490403754
s829701447
624
256
29,216
29,792
Accepted
Accepted
58.97
def bs_left(list, target): low = 0 high = len(list) while low < high: mid = (low + high) // 2 if target > list[mid]: low = mid + 1 else: high = mid return low def bs_right(list, target): low = 0 high = len(list) while low < hig...
import bisect import sys stdin=sys.stdin ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() yp=lambda:print('Yes') np=lambda:print('No') n=ip() a=lp() b=lp() c=lp() a.sort() b.sort() c.sort() ans=0 for i in range(n...
35
30
710
424
def bs_left(list, target): low = 0 high = len(list) while low < high: mid = (low + high) // 2 if target > list[mid]: low = mid + 1 else: high = mid return low def bs_right(list, target): low = 0 high = len(list) while low < high: mid ...
import bisect import sys stdin = sys.stdin ip = lambda: int(sp()) fp = lambda: float(sp()) lp = lambda: list(map(int, stdin.readline().split())) sp = lambda: stdin.readline().rstrip() yp = lambda: print("Yes") np = lambda: print("No") n = ip() a = lp() b = lp() c = lp() a.sort() b.sort() c.sort() ans = 0 for i in rang...
false
14.285714
[ "-def bs_left(list, target):", "- low = 0", "- high = len(list)", "- while low < high:", "- mid = (low + high) // 2", "- if target > list[mid]:", "- low = mid + 1", "- else:", "- high = mid", "- return low", "+import bisect", "+import sys"...
false
0.039369
0.048212
0.816583
[ "s490403754", "s829701447" ]
u461454424
p02689
python
s224368147
s322377174
249
230
20,120
20,116
Accepted
Accepted
7.63
#input N, M = list(map(int, input().split())) H = list(map(int, input().split())) dp = [1] * N for _ in range(M): A, B = list(map(int, input().split())) if H[A-1] > H[B-1]: dp[B-1] = 0 elif H[A-1] < H[B-1]: dp[A-1] = 0 elif H[A-1] == H[B-1]: dp[A-1] = 0 dp[B-1...
#input def main(): N, M = list(map(int, input().split())) H = list(map(int, input().split())) dp = [1] * N for _ in range(M): A, B = list(map(int, input().split())) if H[A-1] > H[B-1]: dp[B-1] = 0 elif H[A-1] < H[B-1]: dp[A-1] = 0 elif H...
16
20
340
447
# input N, M = list(map(int, input().split())) H = list(map(int, input().split())) dp = [1] * N for _ in range(M): A, B = list(map(int, input().split())) if H[A - 1] > H[B - 1]: dp[B - 1] = 0 elif H[A - 1] < H[B - 1]: dp[A - 1] = 0 elif H[A - 1] == H[B - 1]: dp[A - 1] = 0 ...
# input def main(): N, M = list(map(int, input().split())) H = list(map(int, input().split())) dp = [1] * N for _ in range(M): A, B = list(map(int, input().split())) if H[A - 1] > H[B - 1]: dp[B - 1] = 0 elif H[A - 1] < H[B - 1]: dp[A - 1] = 0 elif...
false
20
[ "-N, M = list(map(int, input().split()))", "-H = list(map(int, input().split()))", "-dp = [1] * N", "-for _ in range(M):", "- A, B = list(map(int, input().split()))", "- if H[A - 1] > H[B - 1]:", "- dp[B - 1] = 0", "- elif H[A - 1] < H[B - 1]:", "- dp[A - 1] = 0", "- elif...
false
0.038374
0.039846
0.963055
[ "s224368147", "s322377174" ]
u766407523
p03545
python
s605845793
s129032415
19
17
3,060
3,060
Accepted
Accepted
10.53
flag = False s = list(eval(input())) candidate = [] op = '+-' for i in op: for j in op: for k in op: candidate = s[0]+i+s[1]+j+s[2]+k+s[3] if eval(candidate)==7: print((candidate+'=7')) flag = True break if flag: ...
flag = False s = list(eval(input())) candidate = [] op = '+-' for i in op: for j in op: for k in op: candidate = s[0]+i+s[1]+j+s[2]+k+s[3] if eval(candidate)==7: print((candidate+'=7')) exit()
16
11
359
262
flag = False s = list(eval(input())) candidate = [] op = "+-" for i in op: for j in op: for k in op: candidate = s[0] + i + s[1] + j + s[2] + k + s[3] if eval(candidate) == 7: print((candidate + "=7")) flag = True break if flag:...
flag = False s = list(eval(input())) candidate = [] op = "+-" for i in op: for j in op: for k in op: candidate = s[0] + i + s[1] + j + s[2] + k + s[3] if eval(candidate) == 7: print((candidate + "=7")) exit()
false
31.25
[ "- flag = True", "- break", "- if flag:", "- break", "- if flag:", "- break", "+ exit()" ]
false
0.077885
0.081981
0.95004
[ "s605845793", "s129032415" ]
u076917070
p03607
python
s175822687
s404162501
172
64
18,012
17,888
Accepted
Accepted
62.79
N = int(eval(input())) a = {} for i in range(N): x = eval(input()) if x in a: del a[x] else: a[x] = 0 print((len(a)))
import sys input=sys.stdin.readline N = int(eval(input())) a = {} for i in range(N): x = eval(input()) if x in a: del a[x] else: a[x] = 0 print((len(a)))
10
13
142
183
N = int(eval(input())) a = {} for i in range(N): x = eval(input()) if x in a: del a[x] else: a[x] = 0 print((len(a)))
import sys input = sys.stdin.readline N = int(eval(input())) a = {} for i in range(N): x = eval(input()) if x in a: del a[x] else: a[x] = 0 print((len(a)))
false
23.076923
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.08689
0.036558
2.376794
[ "s175822687", "s404162501" ]
u347600233
p02681
python
s648731084
s385667532
24
22
9,032
9,092
Accepted
Accepted
8.33
s = eval(input()) t = eval(input()) print(('Yes' if s == t[:len(t) - 1] else 'No'))
s = eval(input()) t = eval(input()) print(('Yes' if s == t[:-1] else 'No'))
3
3
71
63
s = eval(input()) t = eval(input()) print(("Yes" if s == t[: len(t) - 1] else "No"))
s = eval(input()) t = eval(input()) print(("Yes" if s == t[:-1] else "No"))
false
0
[ "-print((\"Yes\" if s == t[: len(t) - 1] else \"No\"))", "+print((\"Yes\" if s == t[:-1] else \"No\"))" ]
false
0.032803
0.036637
0.895336
[ "s648731084", "s385667532" ]
u040442732
p02820
python
s059351034
s552433959
423
65
8,556
4,084
Accepted
Accepted
84.63
n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) T = eval(input()) hand = ('r', 's', 'p') def rps(hero, villain): hero = hand.index(hero) villain = hand.index(villain) result = hero - villain if result % 3 == 0 or result % 3 == 1: return 0 else: ...
n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) T = list(eval(input())) for i in range(k, n): if T[i] == T[i-k]: T[i] = 'x' points = 0 for i in range(n): if T[i] == 'r': points += p elif T[i] == 's': points += r elif T[i] == 'p': ...
27
18
829
338
n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) T = eval(input()) hand = ("r", "s", "p") def rps(hero, villain): hero = hand.index(hero) villain = hand.index(villain) result = hero - villain if result % 3 == 0 or result % 3 == 1: return 0 else: retu...
n, k = list(map(int, input().split())) r, s, p = list(map(int, input().split())) T = list(eval(input())) for i in range(k, n): if T[i] == T[i - k]: T[i] = "x" points = 0 for i in range(n): if T[i] == "r": points += p elif T[i] == "s": points += r elif T[i] == "p": points ...
false
33.333333
[ "-T = eval(input())", "-hand = (\"r\", \"s\", \"p\")", "-", "-", "-def rps(hero, villain):", "- hero = hand.index(hero)", "- villain = hand.index(villain)", "- result = hero - villain", "- if result % 3 == 0 or result % 3 == 1:", "- return 0", "- else:", "- return ...
false
0.036961
0.167233
0.221016
[ "s059351034", "s552433959" ]
u970197315
p03700
python
s561255567
s254840380
1,228
834
11,080
16,936
Accepted
Accepted
32.08
from math import ceil def f(x,hp): hp=[hh-(b*x) for hh in hp] c=0 for p in hp: if p<=0:continue c+=ceil(p/(a-b)) return c<=x n,a,b=list(map(int,input().split())) h=[int(eval(input())) for i in range(n)] ng=0 ok=10**9 while ok-ng>1: mid=(ok+ng)//2 if f(mid,h): ok=mid else: ...
from math import ceil def f(x,h): hp = h hp = [hh-(b*x) for hh in hp] count = 0 for hh in hp: if hh <=0: continue count += ceil(hh/(a-b)) return x >= count n,a,b = list(map(int,input().split())) h = [int(eval(input())) for i in range(n)] ng = 0 ok = 10**9 while ab...
24
24
336
411
from math import ceil def f(x, hp): hp = [hh - (b * x) for hh in hp] c = 0 for p in hp: if p <= 0: continue c += ceil(p / (a - b)) return c <= x n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] ng = 0 ok = 10**9 while ok - ng > 1: m...
from math import ceil def f(x, h): hp = h hp = [hh - (b * x) for hh in hp] count = 0 for hh in hp: if hh <= 0: continue count += ceil(hh / (a - b)) return x >= count n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] ng = 0 ok = 10**9...
false
0
[ "-def f(x, hp):", "+def f(x, h):", "+ hp = h", "- c = 0", "- for p in hp:", "- if p <= 0:", "+ count = 0", "+ for hh in hp:", "+ if hh <= 0:", "- c += ceil(p / (a - b))", "- return c <= x", "+ count += ceil(hh / (a - b))", "+ return x >= count...
false
0.036249
0.03533
1.026009
[ "s561255567", "s254840380" ]
u792670114
p02913
python
s424442665
s610002550
1,128
101
3,060
9,504
Accepted
Accepted
91.05
N = int(eval(input())) S = eval(input()) r = 0 i = j = 0 while j < N: t = S[i:j] if t in S[j:]: r = max(r, j-i) j += 1 else: i += 1 print(r)
N = int(eval(input())) S = eval(input()) def check(l): D = {} for i in range(N-l+1): s = S[i:i+l] if s not in D: D[s] = i continue if D[s]+l <= i: return True return False a = 1 b = N while a < b: i = (a + b)//2 if not check(i): b = i else: if a == i:...
12
24
160
352
N = int(eval(input())) S = eval(input()) r = 0 i = j = 0 while j < N: t = S[i:j] if t in S[j:]: r = max(r, j - i) j += 1 else: i += 1 print(r)
N = int(eval(input())) S = eval(input()) def check(l): D = {} for i in range(N - l + 1): s = S[i : i + l] if s not in D: D[s] = i continue if D[s] + l <= i: return True return False a = 1 b = N while a < b: i = (a + b) // 2 if not check...
false
50
[ "-r = 0", "-i = j = 0", "-while j < N:", "- t = S[i:j]", "- if t in S[j:]:", "- r = max(r, j - i)", "- j += 1", "+", "+", "+def check(l):", "+ D = {}", "+ for i in range(N - l + 1):", "+ s = S[i : i + l]", "+ if s not in D:", "+ D[s] = i...
false
0.094174
0.034907
2.697864
[ "s424442665", "s610002550" ]
u102461423
p02624
python
s462424414
s575776489
1,860
1,604
183,252
105,124
Accepted
Accepted
13.76
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): div = np.zeros(N+1, np.int64) for n in range(1, N+1): for m in range(n, N+1, n): div[m] += 1 div *= np.arange(N + 1) return div...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): div = np.zeros(N+1, np.int64) for n in range(1, N+1): for m in range(n, N+1, n): div[m] += m return div.sum() if sys.argv[-1] == ...
32
31
694
665
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): div = np.zeros(N + 1, np.int64) for n in range(1, N + 1): for m in range(n, N + 1, n): div[m] += 1 div *= np.arange(N + 1) return div...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): div = np.zeros(N + 1, np.int64) for n in range(1, N + 1): for m in range(n, N + 1, n): div[m] += m return div.sum() if sys.argv[-1] == ...
false
3.125
[ "- div[m] += 1", "- div *= np.arange(N + 1)", "+ div[m] += m" ]
false
0.296426
0.593586
0.499382
[ "s462424414", "s575776489" ]
u623231048
p03958
python
s110561876
s940244838
75
31
12,724
9,024
Accepted
Accepted
58.67
k,t = list(map(int,input().split())) a = list(map(int,input().split())) dp = [[False] * (k//2+1) for _ in range(t+1)] dp[0][0] = True for i in range(t): for j in range(k//2+1): if dp[i][j]: dp[i+1][j] = True if j + a[i] < k//2+1: dp[i+1][j + a[i]] = Tru...
k,t = list(map(int,input().split())) a = list(map(int,input().split())) a.sort() print((max(0, a[-1] - sum(a[:-1]) - 1)))
22
6
435
121
k, t = list(map(int, input().split())) a = list(map(int, input().split())) dp = [[False] * (k // 2 + 1) for _ in range(t + 1)] dp[0][0] = True for i in range(t): for j in range(k // 2 + 1): if dp[i][j]: dp[i + 1][j] = True if j + a[i] < k // 2 + 1: dp[i + 1][j + a[i]]...
k, t = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() print((max(0, a[-1] - sum(a[:-1]) - 1)))
false
72.727273
[ "-dp = [[False] * (k // 2 + 1) for _ in range(t + 1)]", "-dp[0][0] = True", "-for i in range(t):", "- for j in range(k // 2 + 1):", "- if dp[i][j]:", "- dp[i + 1][j] = True", "- if j + a[i] < k // 2 + 1:", "- dp[i + 1][j + a[i]] = True", "-cnt = 0", "...
false
0.034931
0.035561
0.982294
[ "s110561876", "s940244838" ]
u102242691
p02754
python
s557794104
s030852100
26
18
3,060
2,940
Accepted
Accepted
30.77
n,a,b = list(map(int,input().split())) ans = 0 c = n % (a + b) if a == 0 and b == 0: print((0)) else: ans = int(n / (a + b)) * a if 0 <= c <= a: print((ans + c)) elif a <= c <= a + b: print((ans + a)) else: print("What??")
n,a,b = list(map(int,input().split())) x = n // (a+b) y = n % (a+b) if y <= a: print(((x*a) + y)) else: print(((x*a) + a))
15
10
271
133
n, a, b = list(map(int, input().split())) ans = 0 c = n % (a + b) if a == 0 and b == 0: print((0)) else: ans = int(n / (a + b)) * a if 0 <= c <= a: print((ans + c)) elif a <= c <= a + b: print((ans + a)) else: print("What??")
n, a, b = list(map(int, input().split())) x = n // (a + b) y = n % (a + b) if y <= a: print(((x * a) + y)) else: print(((x * a) + a))
false
33.333333
[ "-ans = 0", "-c = n % (a + b)", "-if a == 0 and b == 0:", "- print((0))", "+x = n // (a + b)", "+y = n % (a + b)", "+if y <= a:", "+ print(((x * a) + y))", "- ans = int(n / (a + b)) * a", "- if 0 <= c <= a:", "- print((ans + c))", "- elif a <= c <= a + b:", "- pr...
false
0.040313
0.035567
1.133436
[ "s557794104", "s030852100" ]
u357751375
p02779
python
s889394408
s495983696
184
96
25,172
31,076
Accepted
Accepted
47.83
n = int(eval(input())) a = list(map(int,input().split())) list.sort(a) y = True for i in range(n - 1): if a[i] == a[i + 1]: y = False break if y: print('YES') else: print('NO')
n = int(eval(input())) a = list(map(int,input().split())) b = list(set(a)) m = len(b) if n == m: print('YES') else: print('NO')
14
8
221
136
n = int(eval(input())) a = list(map(int, input().split())) list.sort(a) y = True for i in range(n - 1): if a[i] == a[i + 1]: y = False break if y: print("YES") else: print("NO")
n = int(eval(input())) a = list(map(int, input().split())) b = list(set(a)) m = len(b) if n == m: print("YES") else: print("NO")
false
42.857143
[ "-list.sort(a)", "-y = True", "-for i in range(n - 1):", "- if a[i] == a[i + 1]:", "- y = False", "- break", "-if y:", "+b = list(set(a))", "+m = len(b)", "+if n == m:" ]
false
0.083049
0.043969
1.888821
[ "s889394408", "s495983696" ]
u571969099
p02537
python
s092486151
s028433645
881
803
148,592
148,576
Accepted
Accepted
8.85
from typing import Callable, TypeVar, List T = TypeVar('T') class SegTree: def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None: self._n = len(v) self.log = (self._n - 1).bit_length() self.size = 1 << self.log self.d = [e() for _ in range(2...
from typing import Callable, TypeVar, List T = TypeVar('T') class SegTree: def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None: self._n = len(v) self.log = (self._n - 1).bit_length() self.size = 1 << self.log self.d = [e for _ in range(2 *...
104
109
3,108
3,268
from typing import Callable, TypeVar, List T = TypeVar("T") class SegTree: def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None: self._n = len(v) self.log = (self._n - 1).bit_length() self.size = 1 << self.log self.d = [e() for _ in range(2 * self.si...
from typing import Callable, TypeVar, List T = TypeVar("T") class SegTree: def __init__(self, v: List[T], op: Callable[[T, T], T], e: Callable[[], T]) -> None: self._n = len(v) self.log = (self._n - 1).bit_length() self.size = 1 << self.log self.d = [e for _ in range(2 * self.size...
false
4.587156
[ "- self.d = [e() for _ in range(2 * self.size)]", "+ self.d = [e for _ in range(2 * self.size)]", "- return cls([e() for _ in range(n)], op, e)", "+ return cls([e for _ in range(n)], op, e)", "+ assert 0 <= p < self._n", "+ assert 0 <= p < self._n", "- sm...
false
1.249282
1.022489
1.221805
[ "s092486151", "s028433645" ]
u621935300
p02579
python
s131771303
s565106990
1,789
1,104
183,980
215,404
Accepted
Accepted
38.29
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque H,W=list(map(int, sys.stdin.readline().split())) CH,CW=list(map(int, sys.stdin.readline().split())) CH-=1 CW-=1 DH,DW=list(map(int, sys.stdin.readline().split())) DH-=1 DW-=1 S=[ sys.stdin.readline().strip() for _ in range(H) ] ...
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque H,W=list(map(int, sys.stdin.readline().split())) CH,CW=list(map(int, sys.stdin.readline().split())) CH-=1 CW-=1 DH,DW=list(map(int, sys.stdin.readline().split())) DH-=1 DW-=1 S=[ sys.stdin.readline().strip() for _ in range(H) ] ...
43
48
1,197
1,265
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque H, W = list(map(int, sys.stdin.readline().split())) CH, CW = list(map(int, sys.stdin.readline().split())) CH -= 1 CW -= 1 DH, DW = list(map(int, sys.stdin.readline().split())) DH -= 1 DW -= 1 S = [sys.stdin.readline().strip() for _ in range(...
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque H, W = list(map(int, sys.stdin.readline().split())) CH, CW = list(map(int, sys.stdin.readline().split())) CH -= 1 CW -= 1 DH, DW = list(map(int, sys.stdin.readline().split())) DH -= 1 DW -= 1 S = [sys.stdin.readline().strip() for _ in range(...
false
10.416667
[ "-q.append((CH, CW))", "+q.append((0, CH, CW))", "- fro_h, fro_w = q.popleft()", "- if (fro_h, fro_w) == (DH, DW):", "- print(d[(fro_h, fro_w)])", "- quit()", "+ kyori, fro_h, fro_w = q.popleft()", "+ if d[(fro_h, fro_w)] < kyori:", "+ continue", "+ # 歩いて移動", ...
false
0.064213
0.155037
0.414177
[ "s131771303", "s565106990" ]
u729133443
p03283
python
s961851321
s283006740
1,933
1,775
13,316
15,188
Accepted
Accepted
8.17
I=lambda:list(map(int,input().split())) n,m,q=I() k=n+2 l=[0]*k**2 for _ in range(m): s,g=I() l[s*k+g]+=1 for i in range(1,n+1): for j in range(1,n+1): l[i*k+j]+=l[i*k+j-1] for i in range(1,n+1): for j in range(1,n+1): l[i*k+j]+=l[(i-1)*k+j] for _ in range(q): s,g=I() print((l[g*k+g]-...
I=lambda:list(map(int,input().split())) n,m,q=I() l=[[0]*-~n for _ in range(n+1)] for _ in range(m): s,g=I() l[s][g]+=1 for i in range(1,n+1): for j in range(1,n+1): l[i][j]+=l[i][j-1] for j in range(1,n+1): l[i][j]+=l[i-1][j] for _ in range(q): s,g=I() print((l[g][g]-l[s-1][g]-l[g][s-1...
16
14
358
333
I = lambda: list(map(int, input().split())) n, m, q = I() k = n + 2 l = [0] * k**2 for _ in range(m): s, g = I() l[s * k + g] += 1 for i in range(1, n + 1): for j in range(1, n + 1): l[i * k + j] += l[i * k + j - 1] for i in range(1, n + 1): for j in range(1, n + 1): l[i * k + j] += l[(i...
I = lambda: list(map(int, input().split())) n, m, q = I() l = [[0] * -~n for _ in range(n + 1)] for _ in range(m): s, g = I() l[s][g] += 1 for i in range(1, n + 1): for j in range(1, n + 1): l[i][j] += l[i][j - 1] for j in range(1, n + 1): l[i][j] += l[i - 1][j] for _ in range(q): s,...
false
12.5
[ "-k = n + 2", "-l = [0] * k**2", "+l = [[0] * -~n for _ in range(n + 1)]", "- l[s * k + g] += 1", "+ l[s][g] += 1", "- l[i * k + j] += l[i * k + j - 1]", "-for i in range(1, n + 1):", "+ l[i][j] += l[i][j - 1]", "- l[i * k + j] += l[(i - 1) * k + j]", "+ l[i][j] +...
false
0.105653
0.115798
0.912389
[ "s961851321", "s283006740" ]
u790710233
p03229
python
s050405796
s194225006
371
222
8,888
7,776
Accepted
Accepted
40.16
from collections import deque n = int(eval(input())) A = sorted(int(eval(input()))for _ in range(n)) L = 1 R = n-1 B = deque([A[0]]) prev_L = A[0] prev_R = A[0] while L <= R: x, y = A[L], A[R] if abs(min(prev_L, prev_R)-y) < abs(max(prev_L, prev_R)-x): if prev_L < prev_R: B.appen...
n = int(eval(input())) A = sorted(int(eval(input()))for _ in range(n)) if n % 2 == 0: low = A[:n//2] high = A[n//2:] ans = abs(2*sum(high)-high[0]-(2*sum(low)-low[-1])) else: low = A[:n//2] high = A[n//2+1:] mid = A[n//2] ans = abs(2*sum(high)-high[0]-(2*sum(low)-low[-1])) a...
32
14
678
355
from collections import deque n = int(eval(input())) A = sorted(int(eval(input())) for _ in range(n)) L = 1 R = n - 1 B = deque([A[0]]) prev_L = A[0] prev_R = A[0] while L <= R: x, y = A[L], A[R] if abs(min(prev_L, prev_R) - y) < abs(max(prev_L, prev_R) - x): if prev_L < prev_R: B.append(x)...
n = int(eval(input())) A = sorted(int(eval(input())) for _ in range(n)) if n % 2 == 0: low = A[: n // 2] high = A[n // 2 :] ans = abs(2 * sum(high) - high[0] - (2 * sum(low) - low[-1])) else: low = A[: n // 2] high = A[n // 2 + 1 :] mid = A[n // 2] ans = abs(2 * sum(high) - high[0] - (2 * su...
false
56.25
[ "-from collections import deque", "-", "-L = 1", "-R = n - 1", "-B = deque([A[0]])", "-prev_L = A[0]", "-prev_R = A[0]", "-while L <= R:", "- x, y = A[L], A[R]", "- if abs(min(prev_L, prev_R) - y) < abs(max(prev_L, prev_R) - x):", "- if prev_L < prev_R:", "- B.append(x)...
false
0.041622
0.046706
0.891142
[ "s050405796", "s194225006" ]
u793868662
p02753
python
s512586522
s176226501
190
163
38,256
38,384
Accepted
Accepted
14.21
def resolve(): a = eval(input()) if a =="AAA" or a == "BBB": print("No") else: print("Yes") resolve()
s = eval(input()) if s == "AAA" or s == "BBB": print("No") else: print("Yes")
7
5
129
77
def resolve(): a = eval(input()) if a == "AAA" or a == "BBB": print("No") else: print("Yes") resolve()
s = eval(input()) if s == "AAA" or s == "BBB": print("No") else: print("Yes")
false
28.571429
[ "-def resolve():", "- a = eval(input())", "- if a == \"AAA\" or a == \"BBB\":", "- print(\"No\")", "- else:", "- print(\"Yes\")", "-", "-", "-resolve()", "+s = eval(input())", "+if s == \"AAA\" or s == \"BBB\":", "+ print(\"No\")", "+else:", "+ print(\"Yes\")" ...
false
0.139506
0.089013
1.567242
[ "s512586522", "s176226501" ]
u009348313
p02609
python
s805257110
s442061328
1,231
200
412,060
118,952
Accepted
Accepted
83.75
import sys sys.setrecursionlimit(10 ** 9) n = int(eval(input())) x = eval(input()) p = [-1 for _ in range(2*(10**7)+1)] cnt = x.count('1') def calc(a): #print('a=',a) if 0 <= a <= 2*(10**7) and p[a] != -1: return p[a] else: if a == 0: ret = 0 else: b = bin(a).count('1'...
import sys sys.setrecursionlimit(10 ** 9) n = int(eval(input())) x = eval(input()) p = [-1 for _ in range(2*(10**5)+1)] cnt = x.count('1') def calc(a): #print('a=',a) if p[a] != -1: return p[a] else: if a == 0: ret = 0 else: b = bin(a).count('1') ret = 1+calc(a%b...
44
43
830
770
import sys sys.setrecursionlimit(10**9) n = int(eval(input())) x = eval(input()) p = [-1 for _ in range(2 * (10**7) + 1)] cnt = x.count("1") def calc(a): # print('a=',a) if 0 <= a <= 2 * (10**7) and p[a] != -1: return p[a] else: if a == 0: ret = 0 else: b =...
import sys sys.setrecursionlimit(10**9) n = int(eval(input())) x = eval(input()) p = [-1 for _ in range(2 * (10**5) + 1)] cnt = x.count("1") def calc(a): # print('a=',a) if p[a] != -1: return p[a] else: if a == 0: ret = 0 else: b = bin(a).count("1") ...
false
2.272727
[ "-p = [-1 for _ in range(2 * (10**7) + 1)]", "+p = [-1 for _ in range(2 * (10**5) + 1)]", "- if 0 <= a <= 2 * (10**7) and p[a] != -1:", "+ if p[a] != -1:", "- if 0 <= a <= 2 * (10**7):", "- p[a] = ret", "+ p[a] = ret", "- for i in range(n + 1):", "+ for i in rang...
false
0.337344
0.038704
8.715972
[ "s805257110", "s442061328" ]
u947883560
p02644
python
s782687711
s116143268
306
280
156,184
156,228
Accepted
Accepted
8.5
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from collections import deque def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() for _...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from collections import deque def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() for _...
59
58
1,622
1,616
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from collections import deque def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) from collections import deque def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) def ZIP(n): ...
false
1.694915
[ "+ append, popleft = stack.append, stack.popleft", "- head = 0", "- b = stack.popleft()", "- head += 1", "+ b = popleft()", "- stack.append(((xx * KETA + yy) << 2) + (d - 1) % 4)", "- stack.append(((xx * KETA + yy) << 2) + (d + 1) % 4)", "+ ...
false
0.048695
0.050073
0.97247
[ "s782687711", "s116143268" ]
u073549161
p03574
python
s861480528
s812452588
264
184
45,804
40,048
Accepted
Accepted
30.3
global h, w, dat h, w = map(int, input().split()) dat = [] for i in range(h): dat.append(input()) for y in range(h): for x in range(w): c = 0 if dat[y][x] == "#": print("#", end="") continue if 0 < y: if dat[y - 1][x] == "#": # 2 ...
h, w = list(map(int,input().split())) maze = [] for _ in range(h): maze.append(list(eval(input()))) dx = [-1, 0, 1, -1, 1, -1, 0, 1] dy = [-1, -1, -1, 0, 0, 1, 1, 1] for hh in range(h): for ww in range(w): if maze[hh][ww] == "#": continue cnt = 0 for di in range(le...
40
23
1,067
645
global h, w, dat h, w = map(int, input().split()) dat = [] for i in range(h): dat.append(input()) for y in range(h): for x in range(w): c = 0 if dat[y][x] == "#": print("#", end="") continue if 0 < y: if dat[y - 1][x] == "#": # 2 c += ...
h, w = list(map(int, input().split())) maze = [] for _ in range(h): maze.append(list(eval(input()))) dx = [-1, 0, 1, -1, 1, -1, 0, 1] dy = [-1, -1, -1, 0, 0, 1, 1, 1] for hh in range(h): for ww in range(w): if maze[hh][ww] == "#": continue cnt = 0 for di in range(len(dx)): ...
false
42.5
[ "-global h, w, dat", "-h, w = map(int, input().split())", "-dat = []", "+h, w = list(map(int, input().split()))", "+maze = []", "+for _ in range(h):", "+ maze.append(list(eval(input())))", "+dx = [-1, 0, 1, -1, 1, -1, 0, 1]", "+dy = [-1, -1, -1, 0, 0, 1, 1, 1]", "+for hh in range(h):", "+ ...
false
0.033756
0.033794
0.998889
[ "s861480528", "s812452588" ]
u066253157
p02947
python
s660484717
s388874149
325
296
31,260
19,852
Accepted
Accepted
8.92
N = int(eval(input())) lst = [eval(input()) for _ in range(N)] lst = [sorted(i) for i in lst] lst = ["".join(i) for i in lst] cnt = 0 dic = {} for i in lst: if i in dic: cnt += dic[i] dic[i] += 1 else: dic[i] = 1 print(cnt)
N = int(eval(input())) S = [eval(input()) for _ in range(N)] S = ["".join(sorted(s)) for s in S] cnt = 0 dic = {} for w in S: if w in dic: cnt += dic[w] dic[w] += 1 else: dic[w] = 1 print(cnt)
16
15
261
237
N = int(eval(input())) lst = [eval(input()) for _ in range(N)] lst = [sorted(i) for i in lst] lst = ["".join(i) for i in lst] cnt = 0 dic = {} for i in lst: if i in dic: cnt += dic[i] dic[i] += 1 else: dic[i] = 1 print(cnt)
N = int(eval(input())) S = [eval(input()) for _ in range(N)] S = ["".join(sorted(s)) for s in S] cnt = 0 dic = {} for w in S: if w in dic: cnt += dic[w] dic[w] += 1 else: dic[w] = 1 print(cnt)
false
6.25
[ "-lst = [eval(input()) for _ in range(N)]", "-lst = [sorted(i) for i in lst]", "-lst = [\"\".join(i) for i in lst]", "+S = [eval(input()) for _ in range(N)]", "+S = [\"\".join(sorted(s)) for s in S]", "-for i in lst:", "- if i in dic:", "- cnt += dic[i]", "- dic[i] += 1", "+for w ...
false
0.036572
0.066662
0.548629
[ "s660484717", "s388874149" ]
u033606236
p03339
python
s888147277
s061849516
311
178
19,840
15,516
Accepted
Accepted
42.77
nums = int(eval(input())) direct = list(eval(input())) ary_w = [0 for i in range(nums)] ary_e = [0 for i in range(nums)] count_w = 0 count_e = 0 count = 0 result = 100000000 for i in range(nums): if direct[i] == "W": count_w += 1 elif direct[i] == "E": count_e += 1 ary_w[i] ...
n = int(eval(input())) s = eval(input()) dp = [0]*n dp[0] = s[1:].count("E") a = s[0] for i in range(1,n): dp[i] = dp[i-1] if s[i] == "E":dp[i] -= 1 if a == "W":dp[i] += 1 a = s[i] print((min(dp)))
28
11
550
209
nums = int(eval(input())) direct = list(eval(input())) ary_w = [0 for i in range(nums)] ary_e = [0 for i in range(nums)] count_w = 0 count_e = 0 count = 0 result = 100000000 for i in range(nums): if direct[i] == "W": count_w += 1 elif direct[i] == "E": count_e += 1 ary_w[i] = count_w ary...
n = int(eval(input())) s = eval(input()) dp = [0] * n dp[0] = s[1:].count("E") a = s[0] for i in range(1, n): dp[i] = dp[i - 1] if s[i] == "E": dp[i] -= 1 if a == "W": dp[i] += 1 a = s[i] print((min(dp)))
false
60.714286
[ "-nums = int(eval(input()))", "-direct = list(eval(input()))", "-ary_w = [0 for i in range(nums)]", "-ary_e = [0 for i in range(nums)]", "-count_w = 0", "-count_e = 0", "-count = 0", "-result = 100000000", "-for i in range(nums):", "- if direct[i] == \"W\":", "- count_w += 1", "- ...
false
0.154748
0.03932
3.935634
[ "s888147277", "s061849516" ]
u075012704
p03142
python
s850836801
s661052268
1,127
872
90,800
90,800
Accepted
Accepted
22.63
import sys sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(N - 1 + M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 G[a].append(b) def topological_sort(g): topological_list = [] visited = set() def d...
import sys sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(N - 1 + M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 G[a].append(b) def topological_sort(g): topological_list = [] visited = set() def d...
50
48
1,064
954
import sys sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(N - 1 + M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 G[a].append(b) def topological_sort(g): topological_list = [] visited = set() def dfs(n): fo...
import sys sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(N - 1 + M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 G[a].append(b) def topological_sort(g): topological_list = [] visited = set() def dfs(n): fo...
false
4
[ "-node_depth = sorted(list(enumerate(dist)), key=lambda x: x[1])", "-ans = [[node_depth[0][0], -1]]", "-for n, depth in node_depth:", "+ans = [-1] * N", "+for n in range(N):", "- if dist[to] == depth + 1:", "- ans.append([to, n])", "-ans.sort()", "-for i, p in ans:", "+ if...
false
0.007998
0.093748
0.085317
[ "s850836801", "s661052268" ]
u506287026
p03308
python
s344193062
s927443356
19
17
2,940
2,940
Accepted
Accepted
10.53
N = int(eval(input())) As = [int(i) for i in input().split()] m = -1 for i in range(N-1): for j in range(i+1, N): m = max(abs(As[i] - As[j]), m) print(m)
N = int(eval(input())) As = [int(i) for i in input().split()] # m = -1 # for i in range(N-1): # for j in range(i+1, N): # m = max(abs(As[i] - As[j]), m) # print(m) print((max(As) - min(As)))
8
10
168
206
N = int(eval(input())) As = [int(i) for i in input().split()] m = -1 for i in range(N - 1): for j in range(i + 1, N): m = max(abs(As[i] - As[j]), m) print(m)
N = int(eval(input())) As = [int(i) for i in input().split()] # m = -1 # for i in range(N-1): # for j in range(i+1, N): # m = max(abs(As[i] - As[j]), m) # print(m) print((max(As) - min(As)))
false
20
[ "-m = -1", "-for i in range(N - 1):", "- for j in range(i + 1, N):", "- m = max(abs(As[i] - As[j]), m)", "-print(m)", "+# m = -1", "+# for i in range(N-1):", "+# for j in range(i+1, N):", "+# m = max(abs(As[i] - As[j]), m)", "+# print(m)", "+print((max(As) - min(As)))" ]
false
0.086562
0.047616
1.817926
[ "s344193062", "s927443356" ]
u524534026
p02681
python
s142115278
s897769508
22
20
8,964
9,096
Accepted
Accepted
9.09
s=eval(input()) t=eval(input()) if s+t[-1]==t: print('Yes') else: print('No')
s=eval(input()) t=eval(input()) if s==t[:-1]: print('Yes') else: print('No')
6
6
78
77
s = eval(input()) t = eval(input()) if s + t[-1] == t: print("Yes") else: print("No")
s = eval(input()) t = eval(input()) if s == t[:-1]: print("Yes") else: print("No")
false
0
[ "-if s + t[-1] == t:", "+if s == t[:-1]:" ]
false
0.116584
0.008567
13.60823
[ "s142115278", "s897769508" ]
u330039499
p03328
python
s728095095
s029113666
11
10
2,692
2,568
Accepted
Accepted
9.09
a, b = list(map(int, input().split())) towers = [0] * 1000 for i in range(999): towers[i + 1] = towers[i] + 1 + i diffs = [0] * 1000 for i in reversed(list(range(999))): diffs[i] = towers[i + 1] - towers[i] target_idx = diffs.index(b - a) print(towers[target_idx] - a)
a, b = list(map(int, input().split())) print((b - a) * (b - a + 1) / 2 - b)
11
3
274
76
a, b = list(map(int, input().split())) towers = [0] * 1000 for i in range(999): towers[i + 1] = towers[i] + 1 + i diffs = [0] * 1000 for i in reversed(list(range(999))): diffs[i] = towers[i + 1] - towers[i] target_idx = diffs.index(b - a) print(towers[target_idx] - a)
a, b = list(map(int, input().split())) print((b - a) * (b - a + 1) / 2 - b)
false
72.727273
[ "-towers = [0] * 1000", "-for i in range(999):", "- towers[i + 1] = towers[i] + 1 + i", "-diffs = [0] * 1000", "-for i in reversed(list(range(999))):", "- diffs[i] = towers[i + 1] - towers[i]", "-target_idx = diffs.index(b - a)", "-print(towers[target_idx] - a)", "+print((b - a) * (b - a + 1) ...
false
0.041477
0.040026
1.03624
[ "s728095095", "s029113666" ]
u959225525
p03212
python
s347917788
s940168634
102
67
3,188
2,940
Accepted
Accepted
34.31
import itertools n=eval(input()) ans=0 for i in range(3,len(n)+1): li=itertools.product([3,5,7],repeat=i) for j in li: t=''.join(map(str,j)) if int(t)<=int(n): if t.count("3")>=1 and t.count("5")>=1 and t.count("7")>=1: ans+=1 print(ans)
n=int(eval(input())) def dfs(num): if int(num)>n: return 0 else: if num.count("3")>=1 and num.count("5")>=1 and num.count("7")>=1: ans=1 else: ans=0 for i in "753": ans=ans+dfs(num+i) return ans print...
15
17
314
325
import itertools n = eval(input()) ans = 0 for i in range(3, len(n) + 1): li = itertools.product([3, 5, 7], repeat=i) for j in li: t = "".join(map(str, j)) if int(t) <= int(n): if t.count("3") >= 1 and t.count("5") >= 1 and t.count("7") >= 1: ans += 1 print(ans)
n = int(eval(input())) def dfs(num): if int(num) > n: return 0 else: if num.count("3") >= 1 and num.count("5") >= 1 and num.count("7") >= 1: ans = 1 else: ans = 0 for i in "753": ans = ans + dfs(num + i) return ans print((dfs("0")))...
false
11.764706
[ "-import itertools", "+n = int(eval(input()))", "-n = eval(input())", "-ans = 0", "-for i in range(3, len(n) + 1):", "- li = itertools.product([3, 5, 7], repeat=i)", "- for j in li:", "- t = \"\".join(map(str, j))", "- if int(t) <= int(n):", "- if t.count(\"3\") >= 1...
false
0.09649
0.054205
1.7801
[ "s347917788", "s940168634" ]
u179169725
p02762
python
s051026806
s520179747
1,233
965
121,108
95,576
Accepted
Accepted
21.74
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): ''' H is number of rows ''' return [list(map(int, read().split())) for _ in range(H)] def read_map(H): ''' H i...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ...
129
128
2,840
2,986
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): """ H is number of rows """ return [list(map(int, read().split())) for _ in range(H)] def read_map(H): """ H is number of rows ...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tupl...
false
0.775194
[ "+sys.setrecursionlimit(1 << 25)", "+ra = range", "+enu = enumerate", "-", "-", "-def read_matrix(H):", "- \"\"\"", "- H is number of rows", "- \"\"\"", "- return [list(map(int, read().split())) for _ in range(H)]", "-", "-", "-def read_map(H):", "- \"\"\"", "- H is num...
false
0.068814
0.047738
1.441498
[ "s051026806", "s520179747" ]
u899909022
p02900
python
s623124905
s071015759
200
181
3,060
2,940
Accepted
Accepted
9.5
def factorization(n): res = set() tmp = n for i in range(2, int(n ** 0.5) // 1): if tmp % i == 0: while tmp % i == 0: tmp //= i res.add(i) res.add(tmp) return res a, b = list(map(int,input().split())) ans = factorization(a) & factorization...
def f(n): res = set() for i in range(2, int(n ** 0.5) // 1): if n % i: continue while not n % i: n //= i res.add(i) return res | {n} a, b = list(map(int,input().split())) print((len(f(a) & f(b) | {1})))
14
10
341
241
def factorization(n): res = set() tmp = n for i in range(2, int(n**0.5) // 1): if tmp % i == 0: while tmp % i == 0: tmp //= i res.add(i) res.add(tmp) return res a, b = list(map(int, input().split())) ans = factorization(a) & factorization(b) | {1} pr...
def f(n): res = set() for i in range(2, int(n**0.5) // 1): if n % i: continue while not n % i: n //= i res.add(i) return res | {n} a, b = list(map(int, input().split())) print((len(f(a) & f(b) | {1})))
false
28.571429
[ "-def factorization(n):", "+def f(n):", "- tmp = n", "- if tmp % i == 0:", "- while tmp % i == 0:", "- tmp //= i", "- res.add(i)", "- res.add(tmp)", "- return res", "+ if n % i:", "+ continue", "+ while not n % i:", ...
false
0.04232
0.039767
1.064194
[ "s623124905", "s071015759" ]
u951401193
p02819
python
s872863989
s755783053
366
70
83,932
21,732
Accepted
Accepted
80.87
m = int(eval(input())) if m <= 2 : print('2') else: n = 10**6 primes = set(range(2, n+1)) for i in range(2, int(n**0.5+1)): primes.difference_update(list(range(i*2, n+1, i))) primes=list(primes) for i in range(len(primes)-1): if primes[i] < m and m <= primes[i+1]: print((primes[...
m = int(eval(input())) if m <= 2 : print('2') else: n = 2*10**5 primes = set(range(2, n+1)) for i in range(2, int(n**0.5+1)): primes.difference_update(list(range(i*2, n+1, i))) primes=list(primes) for i in range(len(primes)-1): if primes[i] < m and m <= primes[i+1]: print((prime...
13
14
312
317
m = int(eval(input())) if m <= 2: print("2") else: n = 10**6 primes = set(range(2, n + 1)) for i in range(2, int(n**0.5 + 1)): primes.difference_update(list(range(i * 2, n + 1, i))) primes = list(primes) for i in range(len(primes) - 1): if primes[i] < m and m <= primes[i + 1]: ...
m = int(eval(input())) if m <= 2: print("2") else: n = 2 * 10**5 primes = set(range(2, n + 1)) for i in range(2, int(n**0.5 + 1)): primes.difference_update(list(range(i * 2, n + 1, i))) primes = list(primes) for i in range(len(primes) - 1): if primes[i] < m and m <= primes[i + 1]...
false
7.142857
[ "- n = 10**6", "+ n = 2 * 10**5" ]
false
0.006603
0.123355
0.05353
[ "s872863989", "s755783053" ]
u537782349
p03078
python
s974551732
s116360798
1,757
856
5,232
4,980
Accepted
Accepted
51.28
a, b, c, d = list(map(int, input().split())) al = list(map(int, input().split())) bl = list(map(int, input().split())) cl = list(map(int, input().split())) al = sorted(al, reverse=True) bl = sorted(bl, reverse=True) cl = sorted(cl, reverse=True) q = [[al[0] + bl[0] + cl[0], 0, 0, 0]] ans = [[al[0] + bl[0] + cl[...
import heapq a, b, c, d = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A, reverse=True) B = list(map(int, input().split())) B = sorted(B, reverse=True) C = list(map(int, input().split())) C = sorted(C, reverse=True) ans = [] q_list = [] n_q = [] heapq.heappush(n_q, [-(A[0]...
41
29
1,365
951
a, b, c, d = list(map(int, input().split())) al = list(map(int, input().split())) bl = list(map(int, input().split())) cl = list(map(int, input().split())) al = sorted(al, reverse=True) bl = sorted(bl, reverse=True) cl = sorted(cl, reverse=True) q = [[al[0] + bl[0] + cl[0], 0, 0, 0]] ans = [[al[0] + bl[0] + cl[0], 0, 0...
import heapq a, b, c, d = list(map(int, input().split())) A = list(map(int, input().split())) A = sorted(A, reverse=True) B = list(map(int, input().split())) B = sorted(B, reverse=True) C = list(map(int, input().split())) C = sorted(C, reverse=True) ans = [] q_list = [] n_q = [] heapq.heappush(n_q, [-(A[0] + B[0] + C[...
false
29.268293
[ "+import heapq", "+", "-al = list(map(int, input().split()))", "-bl = list(map(int, input().split()))", "-cl = list(map(int, input().split()))", "-al = sorted(al, reverse=True)", "-bl = sorted(bl, reverse=True)", "-cl = sorted(cl, reverse=True)", "-q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]", "-ans = ...
false
0.037116
0.033531
1.106923
[ "s974551732", "s116360798" ]
u249218427
p02679
python
s722064604
s272984214
895
746
68,032
93,236
Accepted
Accepted
16.65
# -*- coding: utf-8 -*- from math import gcd N = int(eval(input())) dict_F = {} count_0 = 0 def insert(A,B,s): # A>=0, B>0, s=0or1 if (A,B) not in list(dict_F.keys()): dict_F[(A,B)] = [0,0] dict_F[(A,B)][s] += 1 def make_power2(N): result = 1 list_result = [1] for _ in range(N): r...
# -*- coding: utf-8 -*- import sys from math import gcd N, *AB = list(map(int, sys.stdin.read().split())) dict_F = {} count_0 = 0 def insert(A,B,s): # A>=0, B>0, s=0or1 if (A,B) not in list(dict_F.keys()): dict_F[(A,B)] = [0,0] dict_F[(A,B)][s] += 1 def make_power2(N): result = 1 list_re...
47
48
885
918
# -*- coding: utf-8 -*- from math import gcd N = int(eval(input())) dict_F = {} count_0 = 0 def insert(A, B, s): # A>=0, B>0, s=0or1 if (A, B) not in list(dict_F.keys()): dict_F[(A, B)] = [0, 0] dict_F[(A, B)][s] += 1 def make_power2(N): result = 1 list_result = [1] for _ in range(N): ...
# -*- coding: utf-8 -*- import sys from math import gcd N, *AB = list(map(int, sys.stdin.read().split())) dict_F = {} count_0 = 0 def insert(A, B, s): # A>=0, B>0, s=0or1 if (A, B) not in list(dict_F.keys()): dict_F[(A, B)] = [0, 0] dict_F[(A, B)][s] += 1 def make_power2(N): result = 1 lis...
false
2.083333
[ "+import sys", "-N = int(eval(input()))", "+N, *AB = list(map(int, sys.stdin.read().split()))", "- A, B = list(map(int, input().split()))", "+ A, B = AB[2 * i], AB[2 * i + 1]" ]
false
0.036748
0.037377
0.983171
[ "s722064604", "s272984214" ]
u761529120
p02850
python
s251293029
s546775256
775
456
112,028
148,876
Accepted
Accepted
41.16
import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) def main(): N = int(eval(input())) edges = [[] for _ in range(N)] ans = [] for i in range(N-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edges[a].append((b,i)) edges[b].ap...
import sys sys.setrecursionlimit(1000000) def main(): N = int(eval(input())) edge = [[] for _ in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append([b,i]) edge[b].append([a,i]) color = [0] * (N-1) def...
40
30
820
684
import sys input = sys.stdin.readline sys.setrecursionlimit(10**5) def main(): N = int(eval(input())) edges = [[] for _ in range(N)] ans = [] for i in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edges[a].append((b, i)) edges[b].append((a,...
import sys sys.setrecursionlimit(1000000) def main(): N = int(eval(input())) edge = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge[a].append([b, i]) edge[b].append([a, i]) color = [0] * (N - 1) def d...
false
25
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**5)", "+sys.setrecursionlimit(1000000)", "- edges = [[] for _ in range(N)]", "- ans = []", "+ edge = [[] for _ in range(N)]", "- edges[a].append((b, i))", "- edges[b].append((a, i))", "- K = 0", "- for i in rang...
false
0.037316
0.074868
0.498424
[ "s251293029", "s546775256" ]
u067299340
p00017
python
s692813466
s897946889
20
10
4,328
4,200
Accepted
Accepted
50
import sys from functools import reduce c=lambda w,n:reduce(lambda a,b:a+b,[chr((ord(x)-97+n)%26+97)if x.isalpha() else x for x in w]) for i in sys.stdin: n=0 for s in i.replace(".","").split(): r=c(s,116-ord(s[0])) m=len(s) if m==3 and"the"==r or m==4 and r in["this","that"]:n=116-ord(s[0]) print(c(i,...
import sys,re c=lambda w,n:"".join([chr((ord(x)-97+n)%26+97)if x.isalpha()else x for x in w]) for i in sys.stdin: n=0 while not re.search("th(e|is|at)",c(i,n)):n+=1 print(c(i,n).strip())
9
6
310
193
import sys from functools import reduce c = lambda w, n: reduce( lambda a, b: a + b, [chr((ord(x) - 97 + n) % 26 + 97) if x.isalpha() else x for x in w], ) for i in sys.stdin: n = 0 for s in i.replace(".", "").split(): r = c(s, 116 - ord(s[0])) m = len(s) if m == 3 and "the" == ...
import sys, re c = lambda w, n: "".join( [chr((ord(x) - 97 + n) % 26 + 97) if x.isalpha() else x for x in w] ) for i in sys.stdin: n = 0 while not re.search("th(e|is|at)", c(i, n)): n += 1 print(c(i, n).strip())
false
33.333333
[ "-import sys", "-from functools import reduce", "+import sys, re", "-c = lambda w, n: reduce(", "- lambda a, b: a + b,", "- [chr((ord(x) - 97 + n) % 26 + 97) if x.isalpha() else x for x in w],", "+c = lambda w, n: \"\".join(", "+ [chr((ord(x) - 97 + n) % 26 + 97) if x.isalpha() else x for x i...
false
0.071929
0.042192
1.704806
[ "s692813466", "s897946889" ]
u227082700
p03426
python
s238290789
s725843730
940
667
15,980
56,524
Accepted
Accepted
29.04
h,w,d=list(map(int,input().split())) p=[0]*(h*w) for i in range(h): a=list(map(int,input().split())) for j in range(w):p[a[j]-1]=(i,j) x=[0]*d calc=lambda x1,y1,x2,y2:abs(x1-x2)+abs(y1-y2) for i in range(d,h*w): x.append(x[i-d]+calc(p[i][0],p[i][1],p[i-d][0],p[i-d][1])) for i in range(int(eval(input())))...
h,w,d=list(map(int,input().split())) b=[(0--(h*w-i)//d)*[0]for i in range(d)] a=[list(map(int,input().split()))for _ in range(h)] for i in range(h): for j in range(w): a[i][j]-=1 b[a[i][j]%d][a[i][j]//d]=(i,j) bb=[[0]for _ in range(d)] for i in range(d): for j in range(1,len(b[i])): bb[i].appe...
12
15
365
521
h, w, d = list(map(int, input().split())) p = [0] * (h * w) for i in range(h): a = list(map(int, input().split())) for j in range(w): p[a[j] - 1] = (i, j) x = [0] * d calc = lambda x1, y1, x2, y2: abs(x1 - x2) + abs(y1 - y2) for i in range(d, h * w): x.append(x[i - d] + calc(p[i][0], p[i][1], p[i - ...
h, w, d = list(map(int, input().split())) b = [(0 - -(h * w - i) // d) * [0] for i in range(d)] a = [list(map(int, input().split())) for _ in range(h)] for i in range(h): for j in range(w): a[i][j] -= 1 b[a[i][j] % d][a[i][j] // d] = (i, j) bb = [[0] for _ in range(d)] for i in range(d): for j i...
false
20
[ "-p = [0] * (h * w)", "+b = [(0 - -(h * w - i) // d) * [0] for i in range(d)]", "+a = [list(map(int, input().split())) for _ in range(h)]", "- a = list(map(int, input().split()))", "- p[a[j] - 1] = (i, j)", "-x = [0] * d", "-calc = lambda x1, y1, x2, y2: abs(x1 - x2) + abs(y1 - y2)", "-for i...
false
0.113712
0.068872
1.651064
[ "s238290789", "s725843730" ]
u517910772
p03163
python
s784346646
s172182180
1,860
171
7,736
14,580
Accepted
Accepted
90.81
def main(): def solve(N, W, wv): dp = [-1] * (W+1) dp[0] = 0 for i in range(N): wi = wv[i][0] vi = wv[i][1] for j in range(W-wi, -1, -1): if dp[j] == -1: continue if dp[j+wi] < dp[j] + vi: ...
def e(): import numpy as np N, W = list(map(int, input().split())) dp = np.zeros(W+1, dtype=np.int64) for _ in range(N): w, v = list(map(int, input().split())) np.maximum(dp[:-w]+v, dp[w:], out=dp[w:]) print((dp[-1])) ########## if __name__ == "__main__": e(...
24
17
578
308
def main(): def solve(N, W, wv): dp = [-1] * (W + 1) dp[0] = 0 for i in range(N): wi = wv[i][0] vi = wv[i][1] for j in range(W - wi, -1, -1): if dp[j] == -1: continue if dp[j + wi] < dp[j] + vi: ...
def e(): import numpy as np N, W = list(map(int, input().split())) dp = np.zeros(W + 1, dtype=np.int64) for _ in range(N): w, v = list(map(int, input().split())) np.maximum(dp[:-w] + v, dp[w:], out=dp[w:]) print((dp[-1])) ########## if __name__ == "__main__": e()
false
29.166667
[ "-def main():", "- def solve(N, W, wv):", "- dp = [-1] * (W + 1)", "- dp[0] = 0", "- for i in range(N):", "- wi = wv[i][0]", "- vi = wv[i][1]", "- for j in range(W - wi, -1, -1):", "- if dp[j] == -1:", "- co...
false
0.041586
0.188794
0.220273
[ "s784346646", "s172182180" ]
u046187684
p03476
python
s987518497
s125303514
1,066
898
15,996
17,996
Accepted
Accepted
15.76
#!/usr/bin/env python3 # coding=utf-8 import sys import numpy as np num_max = 100000 primes = np.asarray([True for _ in range(num_max + 1)]) for i in range(num_max + 1): if i == 0 or i == 1: primes[i] = False else: primes[i * 2::i] = False primes = set(np.arange(num_max + 1)[pri...
#!/usr/bin/env python3 # coding=utf-8 import sys import numpy as np num_max = 100000 primes = np.asarray([True for _ in range(num_max + 1)]) for i in range(num_max + 1): if i == 0 or i == 1: primes[i] = False elif primes[i]: primes[i * 2::i] = False primes = set(np.arange(num_ma...
24
24
632
642
#!/usr/bin/env python3 # coding=utf-8 import sys import numpy as np num_max = 100000 primes = np.asarray([True for _ in range(num_max + 1)]) for i in range(num_max + 1): if i == 0 or i == 1: primes[i] = False else: primes[i * 2 :: i] = False primes = set(np.arange(num_max + 1)[primes]) like2017...
#!/usr/bin/env python3 # coding=utf-8 import sys import numpy as np num_max = 100000 primes = np.asarray([True for _ in range(num_max + 1)]) for i in range(num_max + 1): if i == 0 or i == 1: primes[i] = False elif primes[i]: primes[i * 2 :: i] = False primes = set(np.arange(num_max + 1)[primes]...
false
0
[ "- else:", "+ elif primes[i]:" ]
false
0.291465
0.397384
0.733461
[ "s987518497", "s125303514" ]
u687343821
p03074
python
s468659511
s599311447
87
62
8,120
5,568
Accepted
Accepted
28.74
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(int, s...
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() def Solve(): N,K=na() S=[int(d) for d in eval(input())] l=[] N=len(S) if(S[0]==0): l.append(0) b=S[0] ct=1 for i in S[1:]: ...
56
43
1,382
851
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI...
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() def Solve(): N, K = na() S = [int(d) for d in eval(input())] l = [] N = len(S) if S[0] == 0: l.append(0) b = S[0] ct = 1 for i in S[1:]: ...
false
23.214286
[ "-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools", "-import random", "+import sys", "-sys.setrecursionlimit(10**7)", "-inf = 10**20", "-eps = 1.0 / 10**10", "-mod = 10**9 + 7", "-dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]", "-ddn = [(-1, 0), (-1, ...
false
0.037117
0.037369
0.993266
[ "s468659511", "s599311447" ]
u682467216
p02726
python
s469852297
s715525689
1,209
854
27,384
27,284
Accepted
Accepted
29.36
from math import floor, ceil, sqrt, factorial, log, gcd from itertools import accumulate, permutations, combinations, product, combinations_with_replacement from bisect import bisect_left, bisect_right from collections import Counter, defaultdict from heapq import heappop, heappush, heappushpop import copy import...
from math import floor, ceil, sqrt, factorial, log, gcd from itertools import accumulate, permutations, combinations, product, combinations_with_replacement from bisect import bisect_left, bisect_right from collections import Counter, defaultdict from heapq import heappop, heappush, heappushpop import copy import...
90
89
1,574
1,526
from math import floor, ceil, sqrt, factorial, log, gcd from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from collections import Counter, defaultdict from heapq import heappop, heappush, heappushpop...
from math import floor, ceil, sqrt, factorial, log, gcd from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from collections import Counter, defaultdict from heapq import heappop, heappush, heappushpop...
false
1.111111
[ "- d[", "- min(j - i, abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x)) - 1", "- ] += 1", "+ d[min(j - i, abs(x - i) + 1 + abs(j - y)) - 1] += 1" ]
false
0.036383
0.164765
0.220814
[ "s469852297", "s715525689" ]
u546285759
p00836
python
s247660772
s922721140
260
230
7,716
7,728
Accepted
Accepted
11.54
primes = [0, 0] + [1]*9999 for i in range(2, 101): if primes[i]: for j in range(i*i, 10001, i): primes[j] = 0 while True: n = int(eval(input())) if n == 0: break m = n while not primes[m]: m -= 1 pnum = [i for i in range(m+1) if primes[i]] ans...
primes = [0, 0] + [1]*9999 for i in range(2, 101): if primes[i]: for j in range(i*i, 10001, i): primes[j] = 0 pnums = [i for i in range(10001) if primes[i]] while True: n = int(eval(input())) if n == 0: break m = n while not primes[m]: m -= 1 ans ...
24
25
573
589
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i * i, 10001, i): primes[j] = 0 while True: n = int(eval(input())) if n == 0: break m = n while not primes[m]: m -= 1 pnum = [i for i in range(m + 1) if primes[i]] ans = 0 ...
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i * i, 10001, i): primes[j] = 0 pnums = [i for i in range(10001) if primes[i]] while True: n = int(eval(input())) if n == 0: break m = n while not primes[m]: m -= 1 ans = 0 e...
false
4
[ "+pnums = [i for i in range(10001) if primes[i]]", "- pnum = [i for i in range(m + 1) if primes[i]]", "- for i in range(len(pnum)):", "+ end = pnums.index(m) + 1", "+ for i in range(end):", "- for j in range(i, len(pnum)):", "- tmp += pnum[j]", "+ for j in range(i,...
false
0.038236
0.050881
0.751477
[ "s247660772", "s922721140" ]
u469254913
p02642
python
s558813912
s261081581
1,804
847
51,420
113,564
Accepted
Accepted
53.05
import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) # from numba import njit,i8 def sieve(N,A,dp): for i in range(N): now = A[i] M = A[-1] // now for j in range(2,M+1): ...
import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) from numba import njit,i8,b1 # @njit(b1[:](i8,i8,b1[:])) @njit def sieve(N,A,dp): for i in range(N): now = A[i] M = A[-1] // now ...
54
58
954
1,024
import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) # from numba import njit,i8 def sieve(N, A, dp): for i in range(N): now = A[i] M = A[-1] // now for j in range(2, M + 1): dp[now *...
import numpy as np # import math # import copy # from collections import deque import sys input = sys.stdin.readline # sys.setrecursionlimit(10000) from numba import njit, i8, b1 # @njit(b1[:](i8,i8,b1[:])) @njit def sieve(N, A, dp): for i in range(N): now = A[i] M = A[-1] // now for j in...
false
6.896552
[ "-# from numba import njit,i8", "+from numba import njit, i8, b1", "+", "+# @njit(b1[:](i8,i8,b1[:]))", "+@njit", "+# @njit(i8(i8,i8,b1[:]))", "+@njit" ]
false
0.172465
0.19354
0.891108
[ "s558813912", "s261081581" ]
u707808519
p02623
python
s091229049
s603617896
364
327
47,300
48,592
Accepted
Accepted
10.16
import bisect N, M, K = list(map(int, input().split())) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] da = [0 for _ in range(N+1)] for i in range(N): da[i+1] = da[i] + a[i] db = [0 for _ in range(M+1)] for i in range(M): db[i+1] = db[i] + b[i] ans = 0 for i in rang...
N, M, K = list(map(int, input().split())) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] da = [0 for _ in range(N+1)] for i in range(N): da[i+1] = da[i] + a[i] db = [0 for _ in range(M+1)] for i in range(M): db[i+1] = db[i] + b[i] ans = 0; j = M for i in range(N+1): ...
19
19
429
430
import bisect N, M, K = list(map(int, input().split())) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] da = [0 for _ in range(N + 1)] for i in range(N): da[i + 1] = da[i] + a[i] db = [0 for _ in range(M + 1)] for i in range(M): db[i + 1] = db[i] + b[i] ans = 0 for i in range(N + 1)...
N, M, K = list(map(int, input().split())) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] da = [0 for _ in range(N + 1)] for i in range(N): da[i + 1] = da[i] + a[i] db = [0 for _ in range(M + 1)] for i in range(M): db[i + 1] = db[i] + b[i] ans = 0 j = M for i in range(N + 1): if ...
false
0
[ "-import bisect", "-", "+j = M", "- ans = max(ans, i + bisect.bisect_right(db, K - da[i]) - 1)", "+ while db[j] > K - da[i]:", "+ j -= 1", "+ ans = max(ans, i + j)" ]
false
0.042759
0.042128
1.014972
[ "s091229049", "s603617896" ]
u254871849
p02771
python
s515492332
s469337289
20
17
2,940
2,940
Accepted
Accepted
15
import sys *a, = list(map(int, sys.stdin.readline().split())) a.sort() a, b, c = a def main(): if a == b != c or a != b == c: return 'Yes' return 'No' if __name__ == '__main__': ans = main() print(ans)
import sys *a, = list(map(int, sys.stdin.readline().split())) def main(): ans = 'Yes' if len(set(a)) == 2 else 'No' print(ans) if __name__ == '__main__': main()
14
10
235
179
import sys (*a,) = list(map(int, sys.stdin.readline().split())) a.sort() a, b, c = a def main(): if a == b != c or a != b == c: return "Yes" return "No" if __name__ == "__main__": ans = main() print(ans)
import sys (*a,) = list(map(int, sys.stdin.readline().split())) def main(): ans = "Yes" if len(set(a)) == 2 else "No" print(ans) if __name__ == "__main__": main()
false
28.571429
[ "-a.sort()", "-a, b, c = a", "- if a == b != c or a != b == c:", "- return \"Yes\"", "- return \"No\"", "+ ans = \"Yes\" if len(set(a)) == 2 else \"No\"", "+ print(ans)", "- ans = main()", "- print(ans)", "+ main()" ]
false
0.042299
0.043008
0.983506
[ "s515492332", "s469337289" ]
u018679195
p03162
python
s331987225
s500242565
711
645
47,384
74,348
Accepted
Accepted
9.28
N = int(eval(input())) vacation = [] for i in range(N): vacation.append(list(map(int, input().split()))) activities = 3 schedules = [[None for _ in range(activities)] for _ in range(N)] schedules[0] = vacation[0] for i in range(1, N): for j in range(activities): schedules[i][j] = max(schedu...
def main(): n = int(eval(input())) matrix = [] tb = [[0] * 4 for _ in range(n + 1)] for _ in range(n): matrix.append([int(e) for e in input().split()]) for i in range(1, n + 1): for j in range(1, 4): for l in range(1, 4): if j == l: continue...
14
18
418
478
N = int(eval(input())) vacation = [] for i in range(N): vacation.append(list(map(int, input().split()))) activities = 3 schedules = [[None for _ in range(activities)] for _ in range(N)] schedules[0] = vacation[0] for i in range(1, N): for j in range(activities): schedules[i][j] = ( max(sched...
def main(): n = int(eval(input())) matrix = [] tb = [[0] * 4 for _ in range(n + 1)] for _ in range(n): matrix.append([int(e) for e in input().split()]) for i in range(1, n + 1): for j in range(1, 4): for l in range(1, 4): if j == l: con...
false
22.222222
[ "-N = int(eval(input()))", "-vacation = []", "-for i in range(N):", "- vacation.append(list(map(int, input().split())))", "-activities = 3", "-schedules = [[None for _ in range(activities)] for _ in range(N)]", "-schedules[0] = vacation[0]", "-for i in range(1, N):", "- for j in range(activiti...
false
0.048928
0.035796
1.366875
[ "s331987225", "s500242565" ]
u796942881
p03127
python
s876916622
s699481542
66
52
14,652
14,052
Accepted
Accepted
21.21
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, *A = list(map(int, open(0).read().split())) print((gcd_n(A))) return main()
def main(): N, *A = list(map(int, open(0).read().split())) b = None for a in A: if b is None: b = a continue while b: a, b = b, a % b b = a print(a) return main()
20
15
268
253
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, *A = list(map(int, open(0).read().split())) print((gcd_n(A))) return main()
def main(): N, *A = list(map(int, open(0).read().split())) b = None for a in A: if b is None: b = a continue while b: a, b = b, a % b b = a print(a) return main()
false
25
[ "-from functools import reduce", "-", "-", "-def gcd(a, b):", "- while b:", "- a, b = b, a % b", "- return a", "-", "-", "-def gcd_n(numbers):", "- return reduce(gcd, numbers)", "-", "-", "- print((gcd_n(A)))", "+ b = None", "+ for a in A:", "+ if b is...
false
0.057187
0.04755
1.202671
[ "s876916622", "s699481542" ]
u781758937
p02888
python
s393628643
s050872793
1,892
1,728
3,188
3,316
Accepted
Accepted
8.67
N = int(eval(input())) L = list(map(int, input().split())) L.sort() from bisect import bisect_left cnt = 0 for i in range(0,N-2): for j in range(i+1,N-1): t = L[i]+L[j] idx = bisect_left(L,t) cnt += max(0,idx-j-1) print(cnt)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() from bisect import bisect_left cnt = 0 for i in range(0,N-2): for j in range(i+1,N-1): t = L[i]+L[j] idx = bisect_left(L,t,j+1) cnt += max(0,idx-j-1) print(cnt)
12
12
246
250
N = int(eval(input())) L = list(map(int, input().split())) L.sort() from bisect import bisect_left cnt = 0 for i in range(0, N - 2): for j in range(i + 1, N - 1): t = L[i] + L[j] idx = bisect_left(L, t) cnt += max(0, idx - j - 1) print(cnt)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() from bisect import bisect_left cnt = 0 for i in range(0, N - 2): for j in range(i + 1, N - 1): t = L[i] + L[j] idx = bisect_left(L, t, j + 1) cnt += max(0, idx - j - 1) print(cnt)
false
0
[ "- idx = bisect_left(L, t)", "+ idx = bisect_left(L, t, j + 1)" ]
false
0.04789
0.040277
1.189017
[ "s393628643", "s050872793" ]
u347600233
p02682
python
s021774636
s921490275
30
26
8,992
9,144
Accepted
Accepted
13.33
a, b, c, k = list(map(int, input().split())) if k <= a: print(k) elif k <= a + b: print(a) else: print((a - (k - (a + b))))
a, b, c, k = list(map(int, input().split())) print((k if k <= a else a if k <= a + b else a - (k - a - b)))
7
2
133
100
a, b, c, k = list(map(int, input().split())) if k <= a: print(k) elif k <= a + b: print(a) else: print((a - (k - (a + b))))
a, b, c, k = list(map(int, input().split())) print((k if k <= a else a if k <= a + b else a - (k - a - b)))
false
71.428571
[ "-if k <= a:", "- print(k)", "-elif k <= a + b:", "- print(a)", "-else:", "- print((a - (k - (a + b))))", "+print((k if k <= a else a if k <= a + b else a - (k - a - b)))" ]
false
0.03836
0.0372
1.031188
[ "s021774636", "s921490275" ]
u608088992
p03262
python
s628129297
s170867721
118
104
14,252
14,168
Accepted
Accepted
11.86
N, X = list(map(int, input().split())) P = [int(_) for _ in input().split()] def gcd(a, b): a, b = max(a, b), min(a, b) while b: a, b = b, a%b return a D = abs(P[0]-X) for i in range(N): D = gcd(D, abs(P[i]-X)) print(D)
import sys def gcd(a,b): a, b = max(a,b), min(a,b) while a % b > 0: a, b = b, a % b return b def solve(): input = sys.stdin.readline N, X = list(map(int, input().split())) A = [int(a) for a in input().split()] Ans = abs(A[0] - X) for a in A: Ans = gcd(Ans,...
14
20
253
399
N, X = list(map(int, input().split())) P = [int(_) for _ in input().split()] def gcd(a, b): a, b = max(a, b), min(a, b) while b: a, b = b, a % b return a D = abs(P[0] - X) for i in range(N): D = gcd(D, abs(P[i] - X)) print(D)
import sys def gcd(a, b): a, b = max(a, b), min(a, b) while a % b > 0: a, b = b, a % b return b def solve(): input = sys.stdin.readline N, X = list(map(int, input().split())) A = [int(a) for a in input().split()] Ans = abs(A[0] - X) for a in A: Ans = gcd(Ans, abs(a - ...
false
30
[ "-N, X = list(map(int, input().split()))", "-P = [int(_) for _ in input().split()]", "+import sys", "- while b:", "+ while a % b > 0:", "- return a", "+ return b", "-D = abs(P[0] - X)", "-for i in range(N):", "- D = gcd(D, abs(P[i] - X))", "-print(D)", "+def solve():", "+ i...
false
0.080675
0.078884
1.022698
[ "s628129297", "s170867721" ]
u347640436
p03160
python
s428119606
s248530518
174
128
14,356
13,928
Accepted
Accepted
26.44
# DP(配るDP) N = int(eval(input())) h = list(map(int, input().split())) dp = [float('inf')] * N dp[0] = 0 for i in range(N - 2): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) dp[N - 1] = min(dp[N - 1], dp[N - 2] + abs(h[N - 1] - h[N - 2...
# DP(貰うDP) N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = dp[0] + abs(h[1] - h[0]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[N - 1]))
11
10
336
259
# DP(配るDP) N = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf")] * N dp[0] = 0 for i in range(N - 2): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) dp[N - 1] = min(dp[N - 1], dp[N - 2] + abs(h[N - 1] - h[N - 2])) print(...
# DP(貰うDP) N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = dp[0] + abs(h[1] - h[0]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[N - 1]))
false
9.090909
[ "-# DP(配るDP)", "+# DP(貰うDP)", "-dp = [float(\"inf\")] * N", "-dp[0] = 0", "-for i in range(N - 2):", "- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))", "- dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))", "-dp[N - 1] = min(dp[N - 1], dp[N - 2] + abs(h[N - 1] - h[N - 2]))", ...
false
0.083287
0.061245
1.359898
[ "s428119606", "s248530518" ]
u263830634
p02831
python
s756689751
s506754851
52
36
5,600
5,048
Accepted
Accepted
30.77
from fractions import gcd A, B = list(map(int, input().split())) lcm = (A * B) // gcd(A, B) print (lcm)
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 from fractions import gcd A, B = list(map(int, input().split())) print((A * B // gcd(A, B)))
7
10
106
184
from fractions import gcd A, B = list(map(int, input().split())) lcm = (A * B) // gcd(A, B) print(lcm)
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) MOD = 10**9 + 7 from fractions import gcd A, B = list(map(int, input().split())) print((A * B // gcd(A, B)))
false
30
[ "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**9)", "+MOD = 10**9 + 7", "-lcm = (A * B) // gcd(A, B)", "-print(lcm)", "+print((A * B // gcd(A, B)))" ]
false
0.100618
0.044177
2.27761
[ "s756689751", "s506754851" ]
u604839890
p02612
python
s233060286
s739788258
68
26
61,568
9,088
Accepted
Accepted
61.76
n = int(eval(input())) print((1000 - n%1000 if n%1000 != 0 else 0))
print(((1000-int(eval(input()))%1000)%1000))
2
1
60
36
n = int(eval(input())) print((1000 - n % 1000 if n % 1000 != 0 else 0))
print(((1000 - int(eval(input())) % 1000) % 1000))
false
50
[ "-n = int(eval(input()))", "-print((1000 - n % 1000 if n % 1000 != 0 else 0))", "+print(((1000 - int(eval(input())) % 1000) % 1000))" ]
false
0.037567
0.036613
1.026056
[ "s233060286", "s739788258" ]
u334712262
p03287
python
s876813602
s812576658
192
157
110,432
99,768
Accepted
Accepted
18.23
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with...
80
76
1,550
1,504
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import ( combinations, combinations_wit...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import ( combinations, combinations_wit...
false
5
[ "- sa = [0] + list(accumulate(A))", "- sam = [a % M for a in sa]", "- ans = 0", "- for n in Counter(sam).values():", "- ans += n * (n - 1) // 2", "- return ans", "+ return reduce(", "+ lambda x, y: x + y * (y - 1) // 2,", "+ Counter(accumulate([0] + A, lambda x...
false
0.045826
0.040646
1.127436
[ "s876813602", "s812576658" ]
u440566786
p03768
python
s238919224
s230298039
1,981
1,006
170,972
119,440
Accepted
Accepted
49.22
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() from collections import deque def resolve(): n,m=map(int,input().split()) E=[[] for _ in range(n)] for _ in range(m): u,v=map(int,input().split()) u-=1; v-=1 ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() from collections import deque def resolve(): n,m=map(int,input().split()) E=[[] for _ in range(n)] for _ in range(m): u,v=map(int,input().split()) u-=1; v-=1 ...
42
44
998
1,073
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() from collections import deque def resolve(): n, m = map(int, input().split()) E = [[] for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) u -= 1...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() from collections import deque def resolve(): n, m = map(int, input().split()) E = [[] for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) u -= 1...
false
4.545455
[ "- Q.append((v, d - 1))", "+ if not dp[v][d - 1]:", "+ dp[v][d - 1] = 1", "+ Q.append((v, d - 1))" ]
false
0.209422
0.107894
1.940999
[ "s238919224", "s230298039" ]
u171276253
p03478
python
s363526832
s312328393
32
29
3,060
2,940
Accepted
Accepted
9.38
x, min, max = input().rstrip().split() ans = 0 for i in range(int(x) + 1): if int(min) <= sum(map(int, str(i))) <=int(max): ans += i print(ans)
x, min, max = list(map(int, input().split())) ans = 0 for i in range(x+1): if min <= sum(map(int, str(i))) <= max: ans += i print(ans)
6
6
161
146
x, min, max = input().rstrip().split() ans = 0 for i in range(int(x) + 1): if int(min) <= sum(map(int, str(i))) <= int(max): ans += i print(ans)
x, min, max = list(map(int, input().split())) ans = 0 for i in range(x + 1): if min <= sum(map(int, str(i))) <= max: ans += i print(ans)
false
0
[ "-x, min, max = input().rstrip().split()", "+x, min, max = list(map(int, input().split()))", "-for i in range(int(x) + 1):", "- if int(min) <= sum(map(int, str(i))) <= int(max):", "+for i in range(x + 1):", "+ if min <= sum(map(int, str(i))) <= max:" ]
false
0.046759
0.112032
0.417371
[ "s363526832", "s312328393" ]
u866769581
p03127
python
s676161719
s388012132
173
142
14,224
14,224
Accepted
Accepted
17.92
N = int(eval(input())) A = list(map(int,input().split())) while len(A) > 1: a_ = A[0] for x in range(1,len(A)): A[x] %= a_ A = [ans for ans in A if ans > 0] A.sort() print((A[0]))
N = int(eval(input())) A = list(map(int,input().split())) while len(A) > 1: A.sort() devided_num = int(A[0]) devi_lis = [devided_num] As = A As.pop(0) A =[_%devided_num for _ in As if _%devided_num > 0] A += devi_lis print((A[0]))
9
11
203
260
N = int(eval(input())) A = list(map(int, input().split())) while len(A) > 1: a_ = A[0] for x in range(1, len(A)): A[x] %= a_ A = [ans for ans in A if ans > 0] A.sort() print((A[0]))
N = int(eval(input())) A = list(map(int, input().split())) while len(A) > 1: A.sort() devided_num = int(A[0]) devi_lis = [devided_num] As = A As.pop(0) A = [_ % devided_num for _ in As if _ % devided_num > 0] A += devi_lis print((A[0]))
false
18.181818
[ "- a_ = A[0]", "- for x in range(1, len(A)):", "- A[x] %= a_", "- A = [ans for ans in A if ans > 0]", "+ devided_num = int(A[0])", "+ devi_lis = [devided_num]", "+ As = A", "+ As.pop(0)", "+ A = [_ % devided_num for _ in As if _ % devided_num > 0]", "+ A += devi_l...
false
0.035958
0.077313
0.465094
[ "s676161719", "s388012132" ]
u864197622
p03248
python
s495071992
s810576783
235
160
21,624
4,556
Accepted
Accepted
31.91
x = [c for c in eval(input())] n = len(x) ret=[] for i in range(n-1): ret.append([0,0]) if x[n-1] == "1": print((-1)) elif x[0] == "0": print((-1)) else: flg = 1 for i in range(n-1): if x[i] != x[n-1-i-1]: flg = 0 if flg == 0: print((-1)) else...
x = eval(input()) n = len(x) ret=[] if x[n-1]=="1" or x[0]=="0" or x[:-1]!=x[-2::-1]: print((-1)) else: a=1 for i in range(n-1): print(("{0} {1}".format(a, i+2))) if x[i] == "1": a=i+2
29
11
594
226
x = [c for c in eval(input())] n = len(x) ret = [] for i in range(n - 1): ret.append([0, 0]) if x[n - 1] == "1": print((-1)) elif x[0] == "0": print((-1)) else: flg = 1 for i in range(n - 1): if x[i] != x[n - 1 - i - 1]: flg = 0 if flg == 0: print((-1)) else: ...
x = eval(input()) n = len(x) ret = [] if x[n - 1] == "1" or x[0] == "0" or x[:-1] != x[-2::-1]: print((-1)) else: a = 1 for i in range(n - 1): print(("{0} {1}".format(a, i + 2))) if x[i] == "1": a = i + 2
false
62.068966
[ "-x = [c for c in eval(input())]", "+x = eval(input())", "-for i in range(n - 1):", "- ret.append([0, 0])", "-if x[n - 1] == \"1\":", "- print((-1))", "-elif x[0] == \"0\":", "+if x[n - 1] == \"1\" or x[0] == \"0\" or x[:-1] != x[-2::-1]:", "- flg = 1", "+ a = 1", "- if x[i] !...
false
0.038721
0.037464
1.033563
[ "s495071992", "s810576783" ]
u089230684
p03163
python
s086232468
s601195394
1,968
1,191
7,832
130,652
Accepted
Accepted
39.48
def woo(n, w): res = [0 for i in range(0, w+1)] for i in range(0, n): ww, vv = list(map(int, input().split())) for j in range(w, ww-1, -1): wtotal = j + ww vtotal = res[j-ww] + vv if vtotal > res[j]: res[j] = vtotal return res if __name__ == '__main__': n, w = list(map(int, input()...
def main(): n, w = tuple([int(e) for e in input().split()]) items = [] for i in range(n): items.append(tuple([int(e) for e in input().split()])) t = [[0] * (n + 1) for _ in range(w + 1)] for i in range(1, w + 1): for j in range(1, n + 1): if i - items[j - 1]...
17
17
350
559
def woo(n, w): res = [0 for i in range(0, w + 1)] for i in range(0, n): ww, vv = list(map(int, input().split())) for j in range(w, ww - 1, -1): wtotal = j + ww vtotal = res[j - ww] + vv if vtotal > res[j]: res[j] = vtotal return res if __...
def main(): n, w = tuple([int(e) for e in input().split()]) items = [] for i in range(n): items.append(tuple([int(e) for e in input().split()])) t = [[0] * (n + 1) for _ in range(w + 1)] for i in range(1, w + 1): for j in range(1, n + 1): if i - items[j - 1][0] >= 0: ...
false
0
[ "-def woo(n, w):", "- res = [0 for i in range(0, w + 1)]", "- for i in range(0, n):", "- ww, vv = list(map(int, input().split()))", "- for j in range(w, ww - 1, -1):", "- wtotal = j + ww", "- vtotal = res[j - ww] + vv", "- if vtotal > res[j]:", "-...
false
0.047876
0.081484
0.587554
[ "s086232468", "s601195394" ]
u248364740
p02621
python
s689783886
s332057232
26
24
9,144
9,056
Accepted
Accepted
7.69
a = int(eval(input())) result = a + a * a + a * a * a print(result)
#!/usr/bin/env python # -*- coding: utf-8 -*- a = int(eval(input())) result = a + a ** 2 + a ** 3 print(result)
3
7
63
114
a = int(eval(input())) result = a + a * a + a * a * a print(result)
#!/usr/bin/env python # -*- coding: utf-8 -*- a = int(eval(input())) result = a + a**2 + a**3 print(result)
false
57.142857
[ "+#!/usr/bin/env python", "+# -*- coding: utf-8 -*-", "-result = a + a * a + a * a * a", "+result = a + a**2 + a**3" ]
false
0.088073
0.040316
2.18456
[ "s689783886", "s332057232" ]
u225388820
p03739
python
s646541652
s451097517
100
91
86,252
86,024
Accepted
Accepted
9
n = int(eval(input())) a = list(map(int, input().split())) cost = (a[0] == 0) c = a[0] + (a[0] == 0) for i in a[1:]: if c > 0: if c + i >= 0: cost += c + i + 1 c = -1 else: c += i else: if c + i <= 0: cost += 1 - c - i c = 1 else: c += i tmp = cos...
def f(c, cost): for i in a[1:]: if c > 0: if c + i >= 0: cost += c + i + 1 c = -1 else: c += i else: if c + i <= 0: cost += 1 - c - i c = 1 else: ...
39
32
640
635
n = int(eval(input())) a = list(map(int, input().split())) cost = a[0] == 0 c = a[0] + (a[0] == 0) for i in a[1:]: if c > 0: if c + i >= 0: cost += c + i + 1 c = -1 else: c += i else: if c + i <= 0: cost += 1 - c - i c = 1 ...
def f(c, cost): for i in a[1:]: if c > 0: if c + i >= 0: cost += c + i + 1 c = -1 else: c += i else: if c + i <= 0: cost += 1 - c - i c = 1 else: c += i ...
false
17.948718
[ "+def f(c, cost):", "+ for i in a[1:]:", "+ if c > 0:", "+ if c + i >= 0:", "+ cost += c + i + 1", "+ c = -1", "+ else:", "+ c += i", "+ else:", "+ if c + i <= 0:", "+ cost += 1 - c - i"...
false
0.046805
0.047194
0.991759
[ "s646541652", "s451097517" ]
u968846084
p02863
python
s033272022
s953577504
950
426
182,020
47,064
Accepted
Accepted
55.16
n,t=list(map(int,input().split())) F=[list(map(int,input().split())) for i in range(n)] dp1=[[0]*(t+1) for i in range(n)] for i in range(1,n): for j in range(1,t+1): if j-F[i-1][0]>=0: dp1[i][j]=max(dp1[i-1][j],dp1[i][j-1],dp1[i-1][j-F[i-1][0]]+F[i-1][1]) else: dp1[i][j]=max(dp1[i-1][j],dp...
n,t=list(map(int,input().split())) l=[list(map(int,input().split())) for _ in range(n)] l.sort() dp=[0]*(t+max(l)[0]) for a,b in l: for i in range(0,t+a)[::-1]: if i-a>=0: dp[i]=max(dp[i],dp[i-a]+b) print((max(dp[t:])))
23
9
700
232
n, t = list(map(int, input().split())) F = [list(map(int, input().split())) for i in range(n)] dp1 = [[0] * (t + 1) for i in range(n)] for i in range(1, n): for j in range(1, t + 1): if j - F[i - 1][0] >= 0: dp1[i][j] = max( dp1[i - 1][j], dp1[i][j - 1], dp1[i - 1][j - F[i - 1][0...
n, t = list(map(int, input().split())) l = [list(map(int, input().split())) for _ in range(n)] l.sort() dp = [0] * (t + max(l)[0]) for a, b in l: for i in range(0, t + a)[::-1]: if i - a >= 0: dp[i] = max(dp[i], dp[i - a] + b) print((max(dp[t:])))
false
60.869565
[ "-F = [list(map(int, input().split())) for i in range(n)]", "-dp1 = [[0] * (t + 1) for i in range(n)]", "-for i in range(1, n):", "- for j in range(1, t + 1):", "- if j - F[i - 1][0] >= 0:", "- dp1[i][j] = max(", "- dp1[i - 1][j], dp1[i][j - 1], dp1[i - 1][j - F[i - 1...
false
0.0422
0.146828
0.287413
[ "s033272022", "s953577504" ]
u102461423
p03216
python
s030024409
s210542854
1,237
1,040
55,512
58,428
Accepted
Accepted
15.93
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) S = np.empty(N+1,'S1') S[1:] = np.frombuffer(readline(),dtype='S1')[:N] Q = int(readline()) query = list(map(int,readline().split())) isD = S == b'D' ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) S = np.zeros(N+1,'U1') S[1:] = list(readline().rstrip().decode('utf-8')) Q = int(readline()) query = list(map(int,readline().split())) isD = S == 'D' ...
24
24
585
583
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) S = np.empty(N + 1, "S1") S[1:] = np.frombuffer(readline(), dtype="S1")[:N] Q = int(readline()) query = list(map(int, readline().split())) isD = S == b"D" isM = S ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) S = np.zeros(N + 1, "U1") S[1:] = list(readline().rstrip().decode("utf-8")) Q = int(readline()) query = list(map(int, readline().split())) isD = S == "D" isM = S =...
false
0
[ "-S = np.empty(N + 1, \"S1\")", "-S[1:] = np.frombuffer(readline(), dtype=\"S1\")[:N]", "+S = np.zeros(N + 1, \"U1\")", "+S[1:] = list(readline().rstrip().decode(\"utf-8\"))", "-isD = S == b\"D\"", "-isM = S == b\"M\"", "-isC = S == b\"C\"", "+isD = S == \"D\"", "+isM = S == \"M\"", "+isC = S == \...
false
0.261123
0.264481
0.987303
[ "s030024409", "s210542854" ]
u450956662
p02984
python
s276046757
s883810164
122
100
14,028
20,480
Accepted
Accepted
18.03
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] * N ans[0] = sum(A) - 2 * sum(A[1:N-1:2]) for i in range(N-1): ans[i+1] = 2 * A[i] - ans[i] print((*ans))
N = int(eval(input())) A = list(map(int, input().split())) S = sum(A) X = [0] * N X[0] = S - 2 * sum(A[1::2]) for i in range(1, N): X[i] = 2 * A[i-1] - X[i-1] print((*X))
8
8
179
174
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] * N ans[0] = sum(A) - 2 * sum(A[1 : N - 1 : 2]) for i in range(N - 1): ans[i + 1] = 2 * A[i] - ans[i] print((*ans))
N = int(eval(input())) A = list(map(int, input().split())) S = sum(A) X = [0] * N X[0] = S - 2 * sum(A[1::2]) for i in range(1, N): X[i] = 2 * A[i - 1] - X[i - 1] print((*X))
false
0
[ "-ans = [0] * N", "-ans[0] = sum(A) - 2 * sum(A[1 : N - 1 : 2])", "-for i in range(N - 1):", "- ans[i + 1] = 2 * A[i] - ans[i]", "-print((*ans))", "+S = sum(A)", "+X = [0] * N", "+X[0] = S - 2 * sum(A[1::2])", "+for i in range(1, N):", "+ X[i] = 2 * A[i - 1] - X[i - 1]", "+print((*X))" ]
false
0.071048
0.034127
2.081837
[ "s276046757", "s883810164" ]
u460386402
p02713
python
s444485123
s743495735
1,382
488
68,692
68,868
Accepted
Accepted
64.69
k=int(eval(input())) sum=0 def gcd(x,y): while y!=0: x,y=y,x%y return x for i in range(1,k+1): for j in range(1,k+1): for z in range(1,k+1): sum+=gcd(i,gcd(j,z)) print(sum)
import math k=int(eval(input())) sum=0 for i in range(1,k+1): for j in range(1,k+1): for z in range(1,k+1): sum+=math.gcd(i,math.gcd(j,z)) print(sum)
14
10
212
176
k = int(eval(input())) sum = 0 def gcd(x, y): while y != 0: x, y = y, x % y return x for i in range(1, k + 1): for j in range(1, k + 1): for z in range(1, k + 1): sum += gcd(i, gcd(j, z)) print(sum)
import math k = int(eval(input())) sum = 0 for i in range(1, k + 1): for j in range(1, k + 1): for z in range(1, k + 1): sum += math.gcd(i, math.gcd(j, z)) print(sum)
false
28.571429
[ "+import math", "+", "-", "-", "-def gcd(x, y):", "- while y != 0:", "- x, y = y, x % y", "- return x", "-", "-", "- sum += gcd(i, gcd(j, z))", "+ sum += math.gcd(i, math.gcd(j, z))" ]
false
0.061591
0.059827
1.029488
[ "s444485123", "s743495735" ]
u981931040
p02755
python
s966150152
s144317054
180
18
2,940
2,940
Accepted
Accepted
90
A, B = list(map(int,input().split())) for i in range(10 ** 6 + 1): if i * 8 // 100 == A and i // 10 == B: print(i) exit() print("-1")
A, B = list(map(int, input().split())) for ans in range(1, 1001): tmp_A = ans * 8 // 100 tmp_B = ans // 10 if tmp_A == A and tmp_B == B: print(ans) exit() print('-1')
6
8
152
195
A, B = list(map(int, input().split())) for i in range(10**6 + 1): if i * 8 // 100 == A and i // 10 == B: print(i) exit() print("-1")
A, B = list(map(int, input().split())) for ans in range(1, 1001): tmp_A = ans * 8 // 100 tmp_B = ans // 10 if tmp_A == A and tmp_B == B: print(ans) exit() print("-1")
false
25
[ "-for i in range(10**6 + 1):", "- if i * 8 // 100 == A and i // 10 == B:", "- print(i)", "+for ans in range(1, 1001):", "+ tmp_A = ans * 8 // 100", "+ tmp_B = ans // 10", "+ if tmp_A == A and tmp_B == B:", "+ print(ans)" ]
false
0.376672
0.041921
8.985348
[ "s966150152", "s144317054" ]
u056544471
p03076
python
s054713420
s956369970
158
17
12,508
3,064
Accepted
Accepted
89.24
#マックスから引くやり方 import numpy as np A=int(eval(input())) B=int(eval(input())) C=int(eval(input())) D=int(eval(input())) E=int(eval(input())) # 届く時間を1の位で切り上げたとき、届く時間の和 Menu = [A,B,C,D,E] L1=[0] L2=[] time_max=0 extra=[] """ 解答1 """ for i in Menu: if i%10==0: L1.append(i) else: L2....
A=int(eval(input())) B=int(eval(input())) C=int(eval(input())) D=int(eval(input())) E=int(eval(input())) # 届く時間を1の位で切り上げたとき、届く時間の和 Menu = [A,B,C,D,E] L1=[0] L2=[] time_max=0 extra=[] """ 解答1 """ for i in Menu: if i%10==0: L1.append(i) else: L2.append(i + 10 - int(i%10)) ...
32
27
488
445
# マックスから引くやり方 import numpy as np A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input())) E = int(eval(input())) # 届く時間を1の位で切り上げたとき、届く時間の和 Menu = [A, B, C, D, E] L1 = [0] L2 = [] time_max = 0 extra = [] """ 解答1 """ for i in Menu: if i % 10 == 0: L1.append(i) else: ...
A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) D = int(eval(input())) E = int(eval(input())) # 届く時間を1の位で切り上げたとき、届く時間の和 Menu = [A, B, C, D, E] L1 = [0] L2 = [] time_max = 0 extra = [] """ 解答1 """ for i in Menu: if i % 10 == 0: L1.append(i) else: L2.append(i + 10 - int(i % 10...
false
15.625
[ "-# マックスから引くやり方", "-import numpy as np", "-" ]
false
0.170519
0.043935
3.881207
[ "s054713420", "s956369970" ]
u423665486
p03317
python
s835389688
s877621732
224
197
52,476
52,780
Accepted
Accepted
12.05
import math def resolve(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) i = a.index(min(a)) + 1 if k - 1 > i: v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1 else: v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1)) print(v) resolve()
import math # def resolve(): # n, k = map(int, input().split()) # a = list(map(int, input().split())) # i = a.index(min(a)) + 1 # if k - 1 > i: # v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1 # else: # v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1)) # print(v) def resolve(): n, ...
11
17
289
446
import math def resolve(): n, k = list(map(int, input().split())) a = list(map(int, input().split())) i = a.index(min(a)) + 1 if k - 1 > i: v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1 else: v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1)) print(v) resolve()
import math # def resolve(): # n, k = map(int, input().split()) # a = list(map(int, input().split())) # i = a.index(min(a)) + 1 # if k - 1 > i: # v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1 # else: # v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1)) # print(v) def resolve(): n, k = list(...
false
35.294118
[ "-", "+# def resolve():", "+# \tn, k = map(int, input().split())", "+# \ta = list(map(int, input().split()))", "+# \ti = a.index(min(a)) + 1", "+# \tif k - 1 > i:", "+# \t\tv = max(0, math.ceil((n - k - 2) / (k - 1))) + 1", "+# \telse:", "+# \t\tv = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (...
false
0.049559
0.04855
1.020793
[ "s835389688", "s877621732" ]
u107639613
p03732
python
s546295688
s381576434
254
84
92,492
73,008
Accepted
Accepted
66.93
import sys def input(): return sys.stdin.readline().strip() offset = 10**10 def main(): N, W = list(map(int, input().split())) w0, v0 = list(map(int, input().split())) item = [0, w0 * offset + v0] weight_sum, value_sum = w0, v0 for _ in range(1, N): w, v = list(map(int, input().sp...
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() offset = 10**10 def main(): """ ナップサックで重さを飛び飛びにしてdpを軽くしなくても、 そもそも重さが4パターンだから全探索で解けたのか。。。。。。 """ N, W = list(map(int, input().split())) item = [[] for _ in range(4)] length = [1, 0, 0, 0]...
53
39
1,791
1,109
import sys def input(): return sys.stdin.readline().strip() offset = 10**10 def main(): N, W = list(map(int, input().split())) w0, v0 = list(map(int, input().split())) item = [0, w0 * offset + v0] weight_sum, value_sum = w0, v0 for _ in range(1, N): w, v = list(map(int, input().spl...
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() offset = 10**10 def main(): """ ナップサックで重さを飛び飛びにしてdpを軽くしなくても、 そもそも重さが4パターンだから全探索で解けたのか。。。。。。 """ N, W = list(map(int, input().split())) item = [[] for _ in range(4)] length = [1, 0, 0, 0] ...
false
26.415094
[ "+from itertools import accumulate", "+ \"\"\"", "+ ナップサックで重さを飛び飛びにしてdpを軽くしなくても、", "+ そもそも重さが4パターンだから全探索で解けたのか。。。。。。", "+ \"\"\"", "+ item = [[] for _ in range(4)]", "+ length = [1, 0, 0, 0]", "- item = [0, w0 * offset + v0]", "- weight_sum, value_sum = w0, v0", "- for _...
false
0.082827
0.043298
1.912939
[ "s546295688", "s381576434" ]
u424768586
p02986
python
s061147404
s905441372
3,346
3,008
215,276
215,352
Accepted
Accepted
10.1
import sys sys.setrecursionlimit(10**6+1) #再帰関数の上限,10**5以上の場合python def input(): x=sys.stdin.readline() return x[:-1] if x[-1]=="\n" else x def printe(*x):print("## ",*x,file=sys.stderr) def printl(li): _=print(*li, sep="\n") if li else None #N, Q = map(int, input().split()) N, Q = map(int, inp...
import sys sys.setrecursionlimit(10**6+1) #再帰関数の上限,10**5以上の場合python def input(): x=sys.stdin.readline() return x[:-1] if x[-1]=="\n" else x def printe(*x):print("## ",*x,file=sys.stderr) def printl(li): _=print(*li, sep="\n") if li else None #N, Q = map(int, input().split()) N, Q = map(int, inp...
125
126
2,979
2,977
import sys sys.setrecursionlimit(10**6 + 1) # 再帰関数の上限,10**5以上の場合python def input(): x = sys.stdin.readline() return x[:-1] if x[-1] == "\n" else x def printe(*x): print("## ", *x, file=sys.stderr) def printl(li): _ = print(*li, sep="\n") if li else None # N, Q = map(int, input().split()) N, Q ...
import sys sys.setrecursionlimit(10**6 + 1) # 再帰関数の上限,10**5以上の場合python def input(): x = sys.stdin.readline() return x[:-1] if x[-1] == "\n" else x def printe(*x): print("## ", *x, file=sys.stderr) def printl(li): _ = print(*li, sep="\n") if li else None # N, Q = map(int, input().split()) N, Q ...
false
0.793651
[ "- ans[i] = dist[u - 1] + dist[v - 1] - 2 * dist[lca(u - 1, v - 1)]", "+ a = lca(u - 1, v - 1)", "+ ans[i] = dist[u - 1] + dist[v - 1] - 2 * dist[a]", "- qn[lca(u - 1, v - 1)].append((i, x - 1, y, -2))", "+ qn[a].append((i, x - 1, y, -2))" ]
false
0.040431
0.049292
0.820232
[ "s061147404", "s905441372" ]
u542932305
p03944
python
s654546775
s162452929
72
17
3,188
3,064
Accepted
Accepted
76.39
W, H, N = list(map(int, input().split())) cells = [[0 for _ in range(W)] for _ in range(H)] lists = [list(map(int, input().split())) for _ in range(N)] for ls in lists: x, y, a = ls[0], ls[1], ls[2] if a == 1: # xi の左側を塗りつぶす for h in range(H): for w in range(x): ...
W, H, N = list(map(int, input().split())) w, h = 0, 0 for _ in range(N): x, y, a = list(map(int, input().split())) if a == 1: # 黒の領域(x軸)を増やす w = max(w, x) elif a == 2: # 白の領域(x軸)を削る W = min(W, x) elif a == 3: # 黒の領域(y軸)を増やす h = max(h, y) ...
32
22
820
427
W, H, N = list(map(int, input().split())) cells = [[0 for _ in range(W)] for _ in range(H)] lists = [list(map(int, input().split())) for _ in range(N)] for ls in lists: x, y, a = ls[0], ls[1], ls[2] if a == 1: # xi の左側を塗りつぶす for h in range(H): for w in range(x): cells...
W, H, N = list(map(int, input().split())) w, h = 0, 0 for _ in range(N): x, y, a = list(map(int, input().split())) if a == 1: # 黒の領域(x軸)を増やす w = max(w, x) elif a == 2: # 白の領域(x軸)を削る W = min(W, x) elif a == 3: # 黒の領域(y軸)を増やす h = max(h, y) else: ...
false
31.25
[ "-cells = [[0 for _ in range(W)] for _ in range(H)]", "-lists = [list(map(int, input().split())) for _ in range(N)]", "-for ls in lists:", "- x, y, a = ls[0], ls[1], ls[2]", "+w, h = 0, 0", "+for _ in range(N):", "+ x, y, a = list(map(int, input().split()))", "- # xi の左側を塗りつぶす", "- ...
false
0.06604
0.041961
1.573848
[ "s654546775", "s162452929" ]
u616719454
p02576
python
s976931590
s345349621
34
26
9,052
8,944
Accepted
Accepted
23.53
N,X,T = list(map(int,input().split())) #print(N // X) if N % X == 0: cou = N // X print((cou * T)) else: cou = N // X print(((cou + 1) * T ))
#176A N,X,T = list(map(int,input().split())) if N % X == 0: a= N // X print((a*T)) else: a = N// X print(((a+1)* T))
13
11
176
136
N, X, T = list(map(int, input().split())) # print(N // X) if N % X == 0: cou = N // X print((cou * T)) else: cou = N // X print(((cou + 1) * T))
# 176A N, X, T = list(map(int, input().split())) if N % X == 0: a = N // X print((a * T)) else: a = N // X print(((a + 1) * T))
false
15.384615
[ "+# 176A", "-# print(N // X)", "- cou = N // X", "- print((cou * T))", "+ a = N // X", "+ print((a * T))", "- cou = N // X", "- print(((cou + 1) * T))", "+ a = N // X", "+ print(((a + 1) * T))" ]
false
0.045856
0.04583
1.000572
[ "s976931590", "s345349621" ]
u535803878
p02642
python
s805933743
s276725703
471
230
183,600
126,612
Accepted
Accepted
51.17
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())) from collections import Counter a = list(map(int, input().split())) c = Counter(a) s = set() for k,v in list(c.items()): if v>=2: ...
n = int(eval(input())) a = list(map(int, input().split())) from collections import Counter c = Counter(a) vals = [True]*(max(a)+1) ans = 0 m = max(a)+1 for i in range(1, m): if i not in c: continue if c[i]>=2: vals[i] = False for j in range(2*i, m, i): vals[j] = False a...
31
20
622
404
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())) from collections import Counter a = list(map(int, input().split())) c = Counter(a) s = set() for k, v in list(c.items()): if v >= 2: s.add(k)...
n = int(eval(input())) a = list(map(int, input().split())) from collections import Counter c = Counter(a) vals = [True] * (max(a) + 1) ans = 0 m = max(a) + 1 for i in range(1, m): if i not in c: continue if c[i] >= 2: vals[i] = False for j in range(2 * i, m, i): vals[j] = False ans ...
false
35.483871
[ "-import sys", "-", "-input = lambda: sys.stdin.readline().rstrip()", "-sys.setrecursionlimit(max(1000, 10**9))", "-write = lambda x: sys.stdout.write(x + \"\\n\")", "+a = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-s = set()", "-for k, v in list(c.items()):", "- ...
false
1.105054
0.036149
30.569056
[ "s805933743", "s276725703" ]
u645250356
p02863
python
s412773859
s678496174
917
514
187,768
137,688
Accepted
Accepted
43.95
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
44
25
1,176
700
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.read...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.read...
false
43.181818
[ "-wv = [None] * n", "-for i in range(n):", "- a, b = inpl()", "- wv[i] = (a, b)", "-rwv = wv[::-1]", "-udp = [[0] * t for _ in range(n)]", "-ddp = [[0] * t for _ in range(n)]", "+wv = sorted([inpl() for _ in range(n)])", "+dp = [[0] * t for _ in range(n + 1)]", "- udp[i + 1][j] = ...
false
0.036492
0.038341
0.951752
[ "s412773859", "s678496174" ]
u498531348
p03814
python
s878352615
s904692720
72
66
74,596
74,680
Accepted
Accepted
8.33
s = list(eval(input())) A = s.index("A") S = list(reversed(s)) Z = S.index("Z") print((len(s) - Z - A))
s = list(eval(input())) for i in range(len(s)): if s[i] == "A": A = i break for i in range(len(s)): if s[i] == "Z" and i > A: B = i print((B - A + 1))
8
12
106
192
s = list(eval(input())) A = s.index("A") S = list(reversed(s)) Z = S.index("Z") print((len(s) - Z - A))
s = list(eval(input())) for i in range(len(s)): if s[i] == "A": A = i break for i in range(len(s)): if s[i] == "Z" and i > A: B = i print((B - A + 1))
false
33.333333
[ "-A = s.index(\"A\")", "-S = list(reversed(s))", "-Z = S.index(\"Z\")", "-print((len(s) - Z - A))", "+for i in range(len(s)):", "+ if s[i] == \"A\":", "+ A = i", "+ break", "+for i in range(len(s)):", "+ if s[i] == \"Z\" and i > A:", "+ B = i", "+print((B - A + 1))" ...
false
0.049228
0.056534
0.870766
[ "s878352615", "s904692720" ]
u941438707
p02681
python
s607484594
s075920235
24
21
9,024
9,088
Accepted
Accepted
12.5
a=eval(input()) b=eval(input()) print(("Yes" if a==b[:-1] and len(a)+1==len(b) else "No"))
print(("Yes" if eval(input())==input()[:-1] else "No"))
3
1
79
47
a = eval(input()) b = eval(input()) print(("Yes" if a == b[:-1] and len(a) + 1 == len(b) else "No"))
print(("Yes" if eval(input()) == input()[:-1] else "No"))
false
66.666667
[ "-a = eval(input())", "-b = eval(input())", "-print((\"Yes\" if a == b[:-1] and len(a) + 1 == len(b) else \"No\"))", "+print((\"Yes\" if eval(input()) == input()[:-1] else \"No\"))" ]
false
0.034574
0.032814
1.05362
[ "s607484594", "s075920235" ]
u596276291
p03997
python
s655648220
s995411955
23
20
3,192
3,316
Accepted
Accepted
13.04
def main(): a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) print(((a + b) * h // 2)) if __name__ == '__main__': main()
from collections import defaultdict def main(): a, b, h = int(eval(input())), int(eval(input())), int(eval(input())) print(((a + b) * h // 2)) if __name__ == '__main__': main()
9
10
151
182
def main(): a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) print(((a + b) * h // 2)) if __name__ == "__main__": main()
from collections import defaultdict def main(): a, b, h = int(eval(input())), int(eval(input())), int(eval(input())) print(((a + b) * h // 2)) if __name__ == "__main__": main()
false
10
[ "+from collections import defaultdict", "+", "+", "- a = int(eval(input()))", "- b = int(eval(input()))", "- h = int(eval(input()))", "+ a, b, h = int(eval(input())), int(eval(input())), int(eval(input()))" ]
false
0.038457
0.038697
0.993779
[ "s655648220", "s995411955" ]
u324314500
p03038
python
s939311967
s283798442
505
459
88,404
88,148
Accepted
Accepted
9.11
import sys #import numpy as np s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for ...
import sys s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2sss ...
33
37
784
924
import sys # import numpy as np s2nn = lambda s: [int(c) for c in s.split(" ")] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in ran...
import sys s2nn = lambda s: [int(c) for c in s.split(" ")] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2sss = lambd...
false
10.810811
[ "-# import numpy as np", "+ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]", "+ # 元のカード列Aを単調増加にする", "- BC.sort(key=lambda x: x[1])", "+ # 書き換え後の値C[1:M]を単調減少にする", "+ BC.sort(key=lambda v: v[1])", "- # print(A)", "- # print(BC)", "+ # 貪欲法的に書き換える", "- ...
false
0.038199
0.038264
0.998307
[ "s939311967", "s283798442" ]
u600402037
p03287
python
s462239069
s883747271
510
218
23,100
62,576
Accepted
Accepted
57.25
import sys import numpy as np from collections import Counter from math import factorial stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces N, M = rl() A = np.array(rl()) A_cum = A.cumsum() A_c...
# coding: utf-8 import sys from collections import defaultdict sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 左から累積和のリストを持ちながらApplePen N, M = lr() A = lr() dic = defaultdict(int) dic[0] = 1 answer = 0 cur = 0 for a in A: cur += a ...
27
22
551
389
import sys import numpy as np from collections import Counter from math import factorial stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) rs = lambda: stdin.readline().rstrip() # ignore trailing spaces N, M = rl() A = np.array(rl()) A_cum = A.cumsum() A_cum %= M A_cum = A...
# coding: utf-8 import sys from collections import defaultdict sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # 左から累積和のリストを持ちながらApplePen N, M = lr() A = lr() dic = defaultdict(int) dic[0] = 1 answer = 0 cur = 0 for a in A: cur += a cur %= M answe...
false
18.518519
[ "+# coding: utf-8", "-import numpy as np", "-from collections import Counter", "-from math import factorial", "+from collections import defaultdict", "-stdin = sys.stdin", "-ri = lambda: int(rs())", "-rl = lambda: list(map(int, stdin.readline().split()))", "-rs = lambda: stdin.readline().rstrip() #...
false
0.213397
0.088663
2.406836
[ "s462239069", "s883747271" ]
u125545880
p02720
python
s390727933
s731778711
110
101
3,188
9,204
Accepted
Accepted
8.18
import sys sys.setrecursionlimit(10**6) def dfs(n, before): global cnt, K, ans, flag ints = int(before[-1]) int1s = ints - 1; ints1 = ints + 1 if int1s >= 0: after1s = before + str(int1s) if n == 1: cnt += 1 if cnt == K and flag == 0: ans...
import sys sys.setrecursionlimit(10**6) def dfs(base, n): global K, cnt, ans, flag if flag: return if n == 0: cnt += 1 if cnt == K: ans = int(base) flag = True return else: last = int(base[-1]) for l in range(m...
57
37
1,218
762
import sys sys.setrecursionlimit(10**6) def dfs(n, before): global cnt, K, ans, flag ints = int(before[-1]) int1s = ints - 1 ints1 = ints + 1 if int1s >= 0: after1s = before + str(int1s) if n == 1: cnt += 1 if cnt == K and flag == 0: ans = after1s ...
import sys sys.setrecursionlimit(10**6) def dfs(base, n): global K, cnt, ans, flag if flag: return if n == 0: cnt += 1 if cnt == K: ans = int(base) flag = True return else: last = int(base[-1]) for l in range(max(0, last - 1)...
false
35.087719
[ "-def dfs(n, before):", "- global cnt, K, ans, flag", "- ints = int(before[-1])", "- int1s = ints - 1", "- ints1 = ints + 1", "- if int1s >= 0:", "- after1s = before + str(int1s)", "- if n == 1:", "- cnt += 1", "- if cnt == K and flag == 0:", "- ...
false
0.044275
0.084366
0.524795
[ "s390727933", "s731778711" ]
u708255304
p03252
python
s498313893
s298856477
155
108
4,016
3,632
Accepted
Accepted
30.32
from collections import Counter S = str(eval(input())) T = str(eval(input())) s_counter = Counter(S) t_counter = Counter(T) # print(s_counter) # print(t_counter) dict_S_to_T = {} dict_T_to_S = {} for s, t in zip(S, T): if s not in list(dict_S_to_T.keys()): dict_S_to_T[s] = t else: ...
S = str(eval(input())) T = str(eval(input())) dict_S_to_T = {} dict_T_to_S = {} for s, t in zip(S, T): if s not in list(dict_S_to_T.keys()): dict_S_to_T[s] = t else: if dict_S_to_T[s] != t: print('No') exit() if t not in list(dict_T_to_S.keys()): ...
29
21
550
423
from collections import Counter S = str(eval(input())) T = str(eval(input())) s_counter = Counter(S) t_counter = Counter(T) # print(s_counter) # print(t_counter) dict_S_to_T = {} dict_T_to_S = {} for s, t in zip(S, T): if s not in list(dict_S_to_T.keys()): dict_S_to_T[s] = t else: if dict_S_to_...
S = str(eval(input())) T = str(eval(input())) dict_S_to_T = {} dict_T_to_S = {} for s, t in zip(S, T): if s not in list(dict_S_to_T.keys()): dict_S_to_T[s] = t else: if dict_S_to_T[s] != t: print("No") exit() if t not in list(dict_T_to_S.keys()): dict_T_to_S[t...
false
27.586207
[ "-from collections import Counter", "-", "-s_counter = Counter(S)", "-t_counter = Counter(T)", "-# print(s_counter)", "-# print(t_counter)" ]
false
0.035558
0.037858
0.939246
[ "s498313893", "s298856477" ]
u285891772
p04001
python
s266320197
s048842846
342
171
22,660
13,760
Accepted
Accepted
50
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lower...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lower...
40
40
1,149
1,117
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
false
0
[ "-anss = []", "+ans = []", "- ans = []", "+ anss = []", "- # print(i)", "- S_ = S.copy()", "- ans.append(S_.pop(0))", "- while S_ != []:", "+ SS = S.copy()", "+ anss.append(SS.pop(0))", "+ while SS != []:", "- ans.append(\"+\")", "- ans.append(S_....
false
0.047309
0.092053
0.513935
[ "s266320197", "s048842846" ]
u204260373
p02753
python
s828522114
s226423766
20
17
2,940
2,940
Accepted
Accepted
15
def yesno(S): if S=="AAA" or S=="BBB": return "No" else: return "Yes" S=eval(input()) print((yesno(S)))
s=eval(input()) if s=="AAA" or s=="BBB": print("No") else: print("Yes")
7
5
114
73
def yesno(S): if S == "AAA" or S == "BBB": return "No" else: return "Yes" S = eval(input()) print((yesno(S)))
s = eval(input()) if s == "AAA" or s == "BBB": print("No") else: print("Yes")
false
28.571429
[ "-def yesno(S):", "- if S == \"AAA\" or S == \"BBB\":", "- return \"No\"", "- else:", "- return \"Yes\"", "-", "-", "-S = eval(input())", "-print((yesno(S)))", "+s = eval(input())", "+if s == \"AAA\" or s == \"BBB\":", "+ print(\"No\")", "+else:", "+ print(\"Yes\"...
false
0.04158
0.106076
0.391988
[ "s828522114", "s226423766" ]
u962718741
p03644
python
s215308098
s358383912
174
33
38,256
9,060
Accepted
Accepted
81.03
def resolve(): N = int(eval(input())) for i in range(1,9): if 2**i > N: ans = 2**(i-1) break print(ans) resolve()
#!/usr/bin/env python3 def main(): n = int(eval(input())) i = 0 while 2 ** i <= n: i += 1 print((2 ** (i - 1))) if __name__ == "__main__": main()
8
12
159
180
def resolve(): N = int(eval(input())) for i in range(1, 9): if 2**i > N: ans = 2 ** (i - 1) break print(ans) resolve()
#!/usr/bin/env python3 def main(): n = int(eval(input())) i = 0 while 2**i <= n: i += 1 print((2 ** (i - 1))) if __name__ == "__main__": main()
false
33.333333
[ "-def resolve():", "- N = int(eval(input()))", "- for i in range(1, 9):", "- if 2**i > N:", "- ans = 2 ** (i - 1)", "- break", "- print(ans)", "+#!/usr/bin/env python3", "+def main():", "+ n = int(eval(input()))", "+ i = 0", "+ while 2**i <= n:", ...
false
0.040353
0.036119
1.117222
[ "s215308098", "s358383912" ]
u583507988
p03611
python
s591032431
s617673695
118
79
20,724
20,672
Accepted
Accepted
33.05
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) c = Counter(a) ans = 0 for x in range(min(a), max(a)+1): res = c[x] + c[x+1] + c[x-1] ans = max(ans, res) print(ans)
n=int(eval(input())) a=list(map(int,input().split())) data=[0]*(10**5+2) for i in a: data[i]+=1 data[i+1]+=1 data[i+2]+=1 print((max(data)))
9
8
213
145
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) c = Counter(a) ans = 0 for x in range(min(a), max(a) + 1): res = c[x] + c[x + 1] + c[x - 1] ans = max(ans, res) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) data = [0] * (10**5 + 2) for i in a: data[i] += 1 data[i + 1] += 1 data[i + 2] += 1 print((max(data)))
false
11.111111
[ "-from collections import Counter", "-", "-c = Counter(a)", "-ans = 0", "-for x in range(min(a), max(a) + 1):", "- res = c[x] + c[x + 1] + c[x - 1]", "- ans = max(ans, res)", "-print(ans)", "+data = [0] * (10**5 + 2)", "+for i in a:", "+ data[i] += 1", "+ data[i + 1] += 1", "+ ...
false
0.046205
0.050966
0.90657
[ "s591032431", "s617673695" ]
u861141787
p04001
python
s685509621
s609435461
190
19
39,152
3,060
Accepted
Accepted
90
s = eval(input()) n = len(s) ans = 0 for i in range(2**(n - 1)): a = "" for j in range(n-1): if (i >> j)& 1 == 1: a += s[j] + '+' else: a += s[j] a += s[-1] ans += eval(a) print(ans)
S = eval(input()) N = len(S) ans = 0 for i in range(1<<N-1): p = 0 for j in range(N-1): if i >> j & 1: ans += int(S[p:j+1]) p = j + 1 ans += int(S[p:]) print(ans)
17
12
252
212
s = eval(input()) n = len(s) ans = 0 for i in range(2 ** (n - 1)): a = "" for j in range(n - 1): if (i >> j) & 1 == 1: a += s[j] + "+" else: a += s[j] a += s[-1] ans += eval(a) print(ans)
S = eval(input()) N = len(S) ans = 0 for i in range(1 << N - 1): p = 0 for j in range(N - 1): if i >> j & 1: ans += int(S[p : j + 1]) p = j + 1 ans += int(S[p:]) print(ans)
false
29.411765
[ "-s = eval(input())", "-n = len(s)", "+S = eval(input())", "+N = len(S)", "-for i in range(2 ** (n - 1)):", "- a = \"\"", "- for j in range(n - 1):", "- if (i >> j) & 1 == 1:", "- a += s[j] + \"+\"", "- else:", "- a += s[j]", "- a += s[-1]", "- ...
false
0.051639
0.038654
1.335947
[ "s685509621", "s609435461" ]
u353797797
p03176
python
s079963158
s427516092
1,077
444
35,972
121,168
Accepted
Accepted
58.77
def get(i): mx = 0 while i > 0: if bit[i] > mx: mx = bit[i] i -= i & -i return mx def update(i, x): while i < n + 1: if x > bit[i]: bit[i] = x i += i & -i def f(n, hs, a_s): for h, a in zip(hs, a_s): update(h, get(...
def get(i): mx = 0 while i > 0: if bit[i] > mx: mx = bit[i] i -= i & -i return mx def update(i, x): while i < n + 1: if x > bit[i]: bit[i] = x i += i & -i def f(hs, a_s): for h, a in zip(hs, a_s): update(h, get(h -...
27
27
488
482
def get(i): mx = 0 while i > 0: if bit[i] > mx: mx = bit[i] i -= i & -i return mx def update(i, x): while i < n + 1: if x > bit[i]: bit[i] = x i += i & -i def f(n, hs, a_s): for h, a in zip(hs, a_s): update(h, get(h - 1) + a) pr...
def get(i): mx = 0 while i > 0: if bit[i] > mx: mx = bit[i] i -= i & -i return mx def update(i, x): while i < n + 1: if x > bit[i]: bit[i] = x i += i & -i def f(hs, a_s): for h, a in zip(hs, a_s): update(h, get(h - 1) + a) print...
false
0
[ "-def f(n, hs, a_s):", "+def f(hs, a_s):", "-f(n, hs, a_s)", "+f(hs, a_s)" ]
false
0.046425
0.112295
0.41342
[ "s079963158", "s427516092" ]
u893063840
p02863
python
s973576687
s729303099
237
214
14,276
14,436
Accepted
Accepted
9.7
import numpy as np n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() dp = np.zeros(t, dtype=np.int64) ans = 0 for a, b in ab: ans = max(ans, dp[-a:].max() + b) np.maximum(dp[a:], dp[:-a] + b, out=dp[a:]) print(ans)
import numpy as np n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() dp = np.zeros(t, dtype=np.int64) ans = 0 for a, b in ab: ans = max(ans, dp[-1] + b) np.maximum(dp[a:], dp[:-a] + b, out=dp[a:]) print(ans)
16
16
294
287
import numpy as np n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() dp = np.zeros(t, dtype=np.int64) ans = 0 for a, b in ab: ans = max(ans, dp[-a:].max() + b) np.maximum(dp[a:], dp[:-a] + b, out=dp[a:]) print(ans)
import numpy as np n, t = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() dp = np.zeros(t, dtype=np.int64) ans = 0 for a, b in ab: ans = max(ans, dp[-1] + b) np.maximum(dp[a:], dp[:-a] + b, out=dp[a:]) print(ans)
false
0
[ "- ans = max(ans, dp[-a:].max() + b)", "+ ans = max(ans, dp[-1] + b)" ]
false
0.007644
0.248524
0.030757
[ "s973576687", "s729303099" ]
u004423772
p02683
python
s129369653
s923108056
80
33
68,384
9,168
Accepted
Accepted
58.75
import sys input = sys.stdin.readline def main(): N, M, X = list(map(int, input().split())) ans = 10 ** 9 C_list = [] A_list = [] for _ in range(N): CA = list(map(int, input().split())) C_list.append(CA[0]) A_list.append(CA[1:]) for bit in range(2**N): ...
# DFS import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF = 10 ** 9 + 100 ans = INF def dfs(i, S, cost, C_list, A_list, N, M, X): global ans # print(i, buy, cost, S) if i == N: ok = True for j in range(M): if S[j] < X: ok = Fal...
29
41
771
1,065
import sys input = sys.stdin.readline def main(): N, M, X = list(map(int, input().split())) ans = 10**9 C_list = [] A_list = [] for _ in range(N): CA = list(map(int, input().split())) C_list.append(CA[0]) A_list.append(CA[1:]) for bit in range(2**N): cost = 0 ...
# DFS import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF = 10**9 + 100 ans = INF def dfs(i, S, cost, C_list, A_list, N, M, X): global ans # print(i, buy, cost, S) if i == N: ok = True for j in range(M): if S[j] < X: ok = False ...
false
29.268293
[ "+# DFS", "+sys.setrecursionlimit(2147483647)", "+INF = 10**9 + 100", "+ans = INF", "+", "+", "+def dfs(i, S, cost, C_list, A_list, N, M, X):", "+ global ans", "+ # print(i, buy, cost, S)", "+ if i == N:", "+ ok = True", "+ for j in range(M):", "+ if S[j] < ...
false
0.038631
0.079158
0.488024
[ "s129369653", "s923108056" ]
u001024152
p03699
python
s854399917
s285713094
20
18
3,316
3,060
Accepted
Accepted
10
N = int(eval(input())) a = list(int(eval(input())) for _ in range(N)) a.sort() ans = sum(a) if ans%10 > 0: print(ans) exit() for ai in a: if ai%10 > 0: print((ans - ai)) break else: print((0))
import sys N = int(eval(input())) S = [int(eval(input())) for _ in range(N)] ans = sum(S) if ans % 10 > 0: print(ans) sys.exit() S.sort() for si in S: if si % 10 > 0: print((ans - si)) sys.exit() print((0))
14
15
223
235
N = int(eval(input())) a = list(int(eval(input())) for _ in range(N)) a.sort() ans = sum(a) if ans % 10 > 0: print(ans) exit() for ai in a: if ai % 10 > 0: print((ans - ai)) break else: print((0))
import sys N = int(eval(input())) S = [int(eval(input())) for _ in range(N)] ans = sum(S) if ans % 10 > 0: print(ans) sys.exit() S.sort() for si in S: if si % 10 > 0: print((ans - si)) sys.exit() print((0))
false
6.666667
[ "+import sys", "+", "-a = list(int(eval(input())) for _ in range(N))", "-a.sort()", "-ans = sum(a)", "+S = [int(eval(input())) for _ in range(N)]", "+ans = sum(S)", "- exit()", "-for ai in a:", "- if ai % 10 > 0:", "- print((ans - ai))", "- break", "-else:", "- print...
false
0.033206
0.036246
0.916132
[ "s854399917", "s285713094" ]
u641406334
p03371
python
s059887265
s439802693
29
19
3,064
3,064
Accepted
Accepted
34.48
a,b,c,x,y = list(map(int,input().split())) ab = min(a+b, c*2) if x>y: tmp, tmp2, tmp3 = y, (x-y)*a, (x-y)*ab else: tmp, tmp2, tmp3 = x, (y-x)*b, (y-x)*ab ans = 0 for i in range(tmp): ans += ab print((ans+min(tmp2, tmp3)))
a, b, c, x, y = list(map(int, input().split())) ab = c*2 if a+b > ab: t = ab*min(x,y) d = max(x,y)-min(x,y) if x>y: dd = a*d else: dd = b*d print((t+ab*d if dd>ab*d else t+dd)) else: print((a*x+b*y))
10
10
235
222
a, b, c, x, y = list(map(int, input().split())) ab = min(a + b, c * 2) if x > y: tmp, tmp2, tmp3 = y, (x - y) * a, (x - y) * ab else: tmp, tmp2, tmp3 = x, (y - x) * b, (y - x) * ab ans = 0 for i in range(tmp): ans += ab print((ans + min(tmp2, tmp3)))
a, b, c, x, y = list(map(int, input().split())) ab = c * 2 if a + b > ab: t = ab * min(x, y) d = max(x, y) - min(x, y) if x > y: dd = a * d else: dd = b * d print((t + ab * d if dd > ab * d else t + dd)) else: print((a * x + b * y))
false
0
[ "-ab = min(a + b, c * 2)", "-if x > y:", "- tmp, tmp2, tmp3 = y, (x - y) * a, (x - y) * ab", "+ab = c * 2", "+if a + b > ab:", "+ t = ab * min(x, y)", "+ d = max(x, y) - min(x, y)", "+ if x > y:", "+ dd = a * d", "+ else:", "+ dd = b * d", "+ print((t + ab * d i...
false
0.039407
0.03757
1.048888
[ "s059887265", "s439802693" ]
u620084012
p02699
python
s770248660
s562605773
26
20
9,152
9,064
Accepted
Accepted
23.08
S, W = list(map(int,input().split())) if S <= W: print("unsafe") else: print("safe")
import sys def input(): return sys.stdin.readline()[:-1] def main(): # N = int(input()) S, W = list(map(int,input().split())) # S = input() print(("safe" if S > W else "unsafe")) if __name__ == '__main__': main()
5
10
91
236
S, W = list(map(int, input().split())) if S <= W: print("unsafe") else: print("safe")
import sys def input(): return sys.stdin.readline()[:-1] def main(): # N = int(input()) S, W = list(map(int, input().split())) # S = input() print(("safe" if S > W else "unsafe")) if __name__ == "__main__": main()
false
50
[ "-S, W = list(map(int, input().split()))", "-if S <= W:", "- print(\"unsafe\")", "-else:", "- print(\"safe\")", "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", "+", "+def main():", "+ # N = int(input())", "+ S, W = list(map(int, inpu...
false
0.038624
0.042917
0.899969
[ "s770248660", "s562605773" ]
u225388820
p03173
python
s166045273
s998952851
450
366
43,244
43,244
Accepted
Accepted
18.67
# dp[l][r]=min(区間[l,r]を合成するための最小コスト) n=int(eval(input())) a=list(map(int,input().split())) INF=10**15 dp=[[0]*n for i in range(n)] for i in range(n): dp[i][i]=a[i] # 合成するときの必要経費を構成 for i in range(n-1): for j in range(i+1,n): dp[i][j]=dp[i][j-1]+a[j] dp[0][-1]=0 # dp[i][j]=min(dp[i][k]+dp[k+1...
# 大きさがsum(a)のスライムが1匹いる # dp[l][r]=min(区間[l,r]を分解するための最小コスト) import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline INF=10**15 n=int(eval(input())) a=list(map(int,input().split())) b=[0]*(n+1) for i in range(n): b[i+1]=b[i]+a[i] dp=[[-1]*n for i in range(n)] for i in range(n): dp[i]...
21
23
567
535
# dp[l][r]=min(区間[l,r]を合成するための最小コスト) n = int(eval(input())) a = list(map(int, input().split())) INF = 10**15 dp = [[0] * n for i in range(n)] for i in range(n): dp[i][i] = a[i] # 合成するときの必要経費を構成 for i in range(n - 1): for j in range(i + 1, n): dp[i][j] = dp[i][j - 1] + a[j] dp[0][-1] = 0 # dp[i][j]=min(d...
# 大きさがsum(a)のスライムが1匹いる # dp[l][r]=min(区間[l,r]を分解するための最小コスト) import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline INF = 10**15 n = int(eval(input())) a = list(map(int, input().split())) b = [0] * (n + 1) for i in range(n): b[i + 1] = b[i] + a[i] dp = [[-1] * n for i in range(n)] for i in range(n)...
false
8.695652
[ "-# dp[l][r]=min(区間[l,r]を合成するための最小コスト)", "+# 大きさがsum(a)のスライムが1匹いる", "+# dp[l][r]=min(区間[l,r]を分解するための最小コスト)", "+import sys", "+", "+sys.setrecursionlimit(1000000000)", "+input = sys.stdin.readline", "+INF = 10**15", "-INF = 10**15", "-dp = [[0] * n for i in range(n)]", "+b = [0] * (n + 1)", "- ...
false
0.087606
0.079827
1.097452
[ "s166045273", "s998952851" ]
u358254559
p02983
python
s618961857
s168760910
379
48
3,060
3,060
Accepted
Accepted
87.34
L, R = list(map(int, input().split())) new_L = L % 2019 new_R = R % 2019 if R - L >= 2019: print((0)) else: mi=10**10 for l in range(new_L,new_R+1): for r in range(l+1,new_R+1): mod = (l*r) % 2019 if mod < mi: mi=mod print(mi)
L, R = list(map(int, input().split())) import sys mi=10**10 for l in range(L,R+1): for r in range(l+1,R+1): mod = (l*r) % 2019 if mod < mi: mi=mod if mi==0: print(mi) sys.exit() print(mi)
16
14
300
260
L, R = list(map(int, input().split())) new_L = L % 2019 new_R = R % 2019 if R - L >= 2019: print((0)) else: mi = 10**10 for l in range(new_L, new_R + 1): for r in range(l + 1, new_R + 1): mod = (l * r) % 2019 if mod < mi: mi = mod print(mi)
L, R = list(map(int, input().split())) import sys mi = 10**10 for l in range(L, R + 1): for r in range(l + 1, R + 1): mod = (l * r) % 2019 if mod < mi: mi = mod if mi == 0: print(mi) sys.exit() print(mi)
false
12.5
[ "-new_L = L % 2019", "-new_R = R % 2019", "-if R - L >= 2019:", "- print((0))", "-else:", "- mi = 10**10", "- for l in range(new_L, new_R + 1):", "- for r in range(l + 1, new_R + 1):", "- mod = (l * r) % 2019", "- if mod < mi:", "- mi = mod", ...
false
0.042255
0.041325
1.022499
[ "s618961857", "s168760910" ]
u150984829
p00514
python
s190580688
s637361848
330
80
5,632
5,632
Accepted
Accepted
75.76
n,m,r=list(map(int,input().split())) r-=m*n if r<0:print((0)) else: a=1 for i in range(r):a*=i+n for i in range(r):a//=i+1 print(a)
n,m,r=list(map(int,input().split())) r-=m*n if r<0:print((0)) else: d=1 for i in range(r):d*=i+1 u=1 for i in range(r):u*=i+n print((u//d))
8
9
135
143
n, m, r = list(map(int, input().split())) r -= m * n if r < 0: print((0)) else: a = 1 for i in range(r): a *= i + n for i in range(r): a //= i + 1 print(a)
n, m, r = list(map(int, input().split())) r -= m * n if r < 0: print((0)) else: d = 1 for i in range(r): d *= i + 1 u = 1 for i in range(r): u *= i + n print((u // d))
false
11.111111
[ "- a = 1", "+ d = 1", "- a *= i + n", "+ d *= i + 1", "+ u = 1", "- a //= i + 1", "- print(a)", "+ u *= i + n", "+ print((u // d))" ]
false
0.067121
0.041347
1.62335
[ "s190580688", "s637361848" ]
u843175622
p04000
python
s179859680
s003069138
2,238
1,663
191,308
178,444
Accepted
Accepted
25.69
from collections import defaultdict H, W, N = list(map(int, input().split())) YX = [list(map(int, input().split())) for _ in range(N)] memo = defaultdict(int) for y, x in YX: y -= 1; x -= 1 for i in range(9): memo[y - 1 + i//3, x - 1 + i%3] += 1 ans = [0] * 10 for y, x in memo: if 0 ...
from collections import defaultdict 縦, 横, _, *点 = list(map(int, open(0).read().split())) あー = defaultdict(int) for y, x in zip(*[iter(点)]*2): y -= 1; x -= 1 for i in range(9): あー[y - 1 + i//3, x - 1 + i%3] += 1 答 = [0] * 10 for [y, x], c in list(あー.items()): 答[c] += 横 - 1 > x > 0 < y ...
17
15
428
361
from collections import defaultdict H, W, N = list(map(int, input().split())) YX = [list(map(int, input().split())) for _ in range(N)] memo = defaultdict(int) for y, x in YX: y -= 1 x -= 1 for i in range(9): memo[y - 1 + i // 3, x - 1 + i % 3] += 1 ans = [0] * 10 for y, x in memo: if 0 < x < W ...
from collections import defaultdict 縦, 横, _, *点 = list(map(int, open(0).read().split())) あー = defaultdict(int) for y, x in zip(*[iter(点)] * 2): y -= 1 x -= 1 for i in range(9): あー[y - 1 + i // 3, x - 1 + i % 3] += 1 答 = [0] * 10 for [y, x], c in list(あー.items()): 答[c] += 横 - 1 > x > 0 < y < 縦 -...
false
11.764706
[ "-H, W, N = list(map(int, input().split()))", "-YX = [list(map(int, input().split())) for _ in range(N)]", "-memo = defaultdict(int)", "-for y, x in YX:", "+縦, 横, _, *点 = list(map(int, open(0).read().split()))", "+あー = defaultdict(int)", "+for y, x in zip(*[iter(点)] * 2):", "- memo[y - 1 + i //...
false
0.045145
0.084732
0.532794
[ "s179859680", "s003069138" ]
u119148115
p03474
python
s436982485
s970311640
71
64
61,900
61,936
Accepted
Accepted
9.86
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし A,B = MI() S = LS2() for i in range(A+B+1): if i == A: if S[i] != '-': print('No') break else: if S[i] == '-': ...
26
19
730
381
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
import sys def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LS2(): return list(sys.stdin.readline().rstrip()) # 空白なし A, B = MI() S = LS2() for i in range(A + B + 1): if i == A: if S[i] != "-": print("No") break else: if S[i] == "-"...
false
26.923077
[ "-", "-sys.setrecursionlimit(10**7)", "-", "-", "-def I():", "- return int(sys.stdin.readline().rstrip())", "-", "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline().rstri...
false
0.046029
0.038532
1.194576
[ "s436982485", "s970311640" ]
u911153222
p03013
python
s921779412
s437045608
73
52
11,884
14,180
Accepted
Accepted
28.77
import sys input = sys.stdin.readline def typical_stairs(): n, m = list(map(int, input().split())) dangerous = set(int(eval(input())) for _ in range(m)) mod = 1000000007 dp = [0] * (n + 1) dp[0] = 1 if 1 not in dangerous: dp[1] = 1 for i in range(2, n + 1): if ...
def typical_stairs(): n, m, *dangerous = list(map(int, open(0).read().split())) dangerous = set(dangerous) mod = 1000000007 dp = [0] * (n + 1) dp[0] = 1 if 1 not in dangerous: dp[1] = 1 for i in range(2, n + 1): if i not in dangerous: dp[i] = (dp[i - 2] ...
20
16
452
406
import sys input = sys.stdin.readline def typical_stairs(): n, m = list(map(int, input().split())) dangerous = set(int(eval(input())) for _ in range(m)) mod = 1000000007 dp = [0] * (n + 1) dp[0] = 1 if 1 not in dangerous: dp[1] = 1 for i in range(2, n + 1): if i not in dan...
def typical_stairs(): n, m, *dangerous = list(map(int, open(0).read().split())) dangerous = set(dangerous) mod = 1000000007 dp = [0] * (n + 1) dp[0] = 1 if 1 not in dangerous: dp[1] = 1 for i in range(2, n + 1): if i not in dangerous: dp[i] = (dp[i - 2] + dp[i - 1...
false
20
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "- n, m = list(map(int, input().split()))", "- dangerous = set(int(eval(input())) for _ in range(m))", "+ n, m, *dangerous = list(map(int, open(0).read().split()))", "+ dangerous = set(dangerous)" ]
false
0.037411
0.08995
0.415912
[ "s921779412", "s437045608" ]
u312025627
p02762
python
s588889122
s748391627
1,720
1,112
122,348
129,628
Accepted
Accepted
35.35
def main(): N, M, K = (int(i) for i in input().split()) par = [i for i in range(N)] rank = [1 for i in range(N)] def find_root(x): if par[x] == x: return x else: par[x] = find_root(par[x]) return par[x] def is_same_group(x, y): ...
def main(): import sys input = sys.stdin.buffer.readline N, M, K = (int(i) for i in input().split()) AB = [[int(i)-1 for i in input().split()] for j in range(M)] CD = [[int(i)-1 for i in input().split()] for j in range(K)] par = [i for i in range(N)] rank = [1 for i in range(N)] ...
50
50
1,252
1,303
def main(): N, M, K = (int(i) for i in input().split()) par = [i for i in range(N)] rank = [1 for i in range(N)] def find_root(x): if par[x] == x: return x else: par[x] = find_root(par[x]) return par[x] def is_same_group(x, y): return fin...
def main(): import sys input = sys.stdin.buffer.readline N, M, K = (int(i) for i in input().split()) AB = [[int(i) - 1 for i in input().split()] for j in range(M)] CD = [[int(i) - 1 for i in input().split()] for j in range(K)] par = [i for i in range(N)] rank = [1 for i in range(N)] de...
false
0
[ "+ import sys", "+", "+ input = sys.stdin.buffer.readline", "+ AB = [[int(i) - 1 for i in input().split()] for j in range(M)]", "+ CD = [[int(i) - 1 for i in input().split()] for j in range(K)]", "- # 連結成分のサイズを返す", "- fri = [[] for _ in range(N)]", "- for _ in range(M):", "-...
false
0.116057
0.083396
1.391644
[ "s588889122", "s748391627" ]