Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int, input().split())
c = 0
d = 0
for i in range(1,N+1):
	if B > N:
		d = (math.floor(A * N / B))-(A * (math.floor(N / B)))
		break
	c = (math.floor(A * i / B))-(A * (math.floor(i / B)))
	if c>d:
		d=c
print(d)

Fixed submission:
import math
A,B,N = map(int, input().split())
c = 0
if B > N:
	c = (math.floor(A * N / B))-(A * (math.floor(N / B)))
elif B <= N:
	c = (math.floor(A * (B-1) / B))-(A * (math.floor((B - 1) / B)))
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int, input().split())
c = 0
d = 0
for i in range(1,N+1):
	if B > N:
		d = (math.floor(A * N / B))-(A * (math.floor(N / B)))
		break
	c = (math.floor(A * i / B))-(A * (math.floor(i / B)))
	if c>d:
		d=c
print(d)

Fixed submission:
import math
A,B,N = map(int, input().split())
c = 0
if B > N:
	c = (math.floor(A * N / B))-(A * (math.floor(N / B)))
elif B <= N:
	c = (math.floor(A * (B-1) / B))-(A * (math.floor((B - 1) / B)))
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N = map(int, input().split())
c = 0
d = 0
for i in range(1,N+1):
	c = (math.floor(A * i / B))-(A * (math.floor(i / B)))
	if c>d:
		d=c
print(d)

Fixed submission:
import math
A,B,N = map(int, input().split())
c = 0
if B > N:
	c = (math.floor(A * N / B))-(A * (math.floor(N / B)))
elif B <= N:
	c = (math.floor(A * (B-1) / B))-(A * (math.floor((B - 1) / B)))
print(c)
Buggy python submission (verdict: Runtime Error):
import math
s = str(input())
m = (len(s) - 1) / 2
c = True
for i in range(math.floor(m / 2)):
    if s[i] != s[int(m-1-i)]:
        c = False
for i in range(math.floor(m / 2)):
    if s[int(m+1+i)] != s[int(len(s)-1-i)]:
        c = False
for i in range(math.floor(m)):
    if s[i] != s[int(math.floor(len(s)-i))]:
        c = False
if c:
    print("Yes")
else:
    print("No")

Fixed submission:
import math
s = str(input())
m = (len(s) - 1) / 2
c = True
for i in range(math.floor(m / 2)):
    if s[i] != s[int(m-1-i)]:
        c = False
for i in range(math.floor(m / 2)):
    if s[int(m+1+i)] != s[int(len(s)-1-i)]:
        c = False
for i in range(math.floor(m)):
    if s[i] != s[int(math.floor(len(s)-1-i))]:
        c = False
if c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for i in range(k):
    if a == 0:
        b += -1
    if a:
        a += -1
print(a,b)

Fixed submission:
a,b,k = map(int,input().split())
if a >= k:
    print(a-k,b)
else:
    print(0,max(0,b-k+a))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(6-a-b)

Fixed submission:
a = int(input())
b = int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
list = ["Sunny","Cloudy","Rainy"]
s = str(input())
a = list.index(s)
if a == 2:
    a == -1
print(list[a+1])

Fixed submission:
list = ["Sunny","Cloudy","Rainy"]
s = str(input())
a = list.index(s)
if a == 2:
    a = -1
print(list[a+1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
data = []
count = 0
for i in range(n):
    s = sorted(str(input()))
    if s in data:
        count += data.count(s)
    data.append(s)
print(count)

Fixed submission:
from collections import Counter
n = int(input())
m = []
count = 0
for i in range(n):
    m.append("".join(sorted(str(input()))))
m = Counter(m)
ans = 0
for j in m.values():
    ans += j * (j-1) / 2
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
maxa = max(a)
if a.count(maxa) > 1:
    for i in range(n):
        print(max(a))
else:
    for j in range(n):
        if a[j] == maxa:
            sorta = sorted(a)
            print(sorta[-2])
        else:
            print(maxa)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
aa = sorted(a)[:n-1]
maxa = max(a)
b = a.index(maxa)
for i in range(n):
	if i == b:
		print(max(aa))
	else:
		print(maxa)
Buggy python submission (verdict: Runtime Error):
s = input()
if len(set(s.sort())) == 4:
    print("Good")
else:
    print("No")

Fixed submission:
s = input()
if s[0] != s[1] != s[2] != s[3]:
    print("Good")
else:
    print("Bad")

Buggy python submission (verdict: Runtime Error):
s = input()
if len(set(sort(s))) == 4:
    print("Good")
else:
    print("No")

Fixed submission:
s = input()
if s[0] != s[1] != s[2] != s[3]:
    print("Good")
else:
    print("Bad")
Buggy python submission (verdict: Runtime Error):
x,a = map(int,input.split())
if x < a:
    print("0")
else:
    print("10")

Fixed submission:
x,a = map(int,input().split())
if x < a:
    print("0")
else:
    print("10")
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = step[i-1] + step[i-2]
step[-1] %= 1000000007
print(step[-1])

Fixed submission:
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])

Fixed submission:
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for j in range(2,n+1):
    if j not in a:
        step[j] = (step[j-1] + step[j-2]) % 1000000007
print(step[-1])

Fixed submission:
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for j in range(2,n+1):
    if j not in a:
        step[j] = step[j-1] + step[j-2]
print(step[n] % 1000000007)

Fixed submission:
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
step = [0] * (n+1)
step[0] = 1
if 1 not in a:
    step[1] = 1
else:
    step[1] = 0
for i in range(2,n+1):
    if i in a:
        continue
    step[i] = (step[i-1] + step[i-2]) % 1000000007
print(step[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
l,r = [],[]
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
count = 0
for i in range(1,n+1):
    for j in range(m):
        if i < l[j] or i > r[j]:
            count -= 1
            break
print(n + count) 

Fixed submission:
n,m = map(int,input().split())
l,r = [],[]
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
num = list(range(1,n+1))
lmax = max(l)
rmin = min(r)
if lmax > rmin:
    print(0)
else:
    gate = set(range(lmax,rmin+1))
    ans = list(set(num) & gate)
    print(len(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a,b = 0,0
for _ in range(m):
  a,b = map(int,input().split())
  print(sum(t) - t[a] + b)

Fixed submission:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a,b = 0,0
for _ in range(m):
  a,b = map(int,input().split())
  print(sum(t) - t[a-1] + b)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
turn = 0
while a > 0 or c > 0:
  if turn%2 == 0:
    c -= b
  else:
    a -= d
print('Yes' if a > 0 else 'No')

Fixed submission:
a,b,c,d = map(int,input().split())
turn = 0
while a > 0 and c > 0:
  if turn%2 == 0:
    c -= b
  else:
    a -= d
  turn += 1
print('Yes' if a > 0 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
inp = list(map(int,input().split()))
d = {}
for x in inp:
    d[x] = d.get(x, 0) + 1
v = [0 for _ in range(n+1)]
for x, y in d.items():
    v[x] = (y)*(y-1)//2
for i in range(n):
    print(sum(v)-v[inp[i]]+((d[inp[i]]-1)*(d[inp[i]]-2)//2))

Fixed submission:
n = int(input())
inp = list(map(int,input().split()))
d = {}
for x in inp:
    d[x] = d.get(x, 0) + 1
v = [0 for _ in range(n+1)]
for x, y in d.items():
    v[x] = (y)*(y-1)//2
tot = sum(v)
for i in range(n):
    print(tot-v[inp[i]]+((d[inp[i]]-1)*(d[inp[i]]-2)//2))
Buggy python submission (verdict: Runtime Error):
print('Yes' if all(input().count(c) > 0 for c in 'AB') else 'No')

Fixed submission:
s = input()
print('No' if (s == 'AAA' or s == 'BBB') else 'Yes')
Buggy python submission (verdict: Runtime Error):
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or 
  (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")

Fixed submission:
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")
Buggy python submission (verdict: Runtime Error):
import math
print(math.ceil(math.log(int(input()), int(input()))))

Fixed submission:
n, k = map(int,input().split())
ans = 0
while (n > 0):
    ans += 1
    n //= k
print(ans + n%k)
Buggy python submission (verdict: Runtime Error):
s = input()
for _ in range(len(s)):
  print(x,end='')

Fixed submission:
s = input()
for _ in range(len(s)):
  print('x',end='')
Buggy python submission (verdict: Runtime Error):
print('win' if sum(map(int,input())) == 21 else 'bust')

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')

Buggy python submission (verdict: Runtime Error):
print('win' if sum(list(map(int,input())))) == 21 else 'bust')

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')

Buggy python submission (verdict: Runtime Error):
print "bust" if sum([int(x) for x in input().split()]) > 21 else "win"

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')

Buggy python submission (verdict: Runtime Error):
a, b, c = [int(x) for x in input().split()]
print(a+b+c > 21 ? 'bust' : 'win')

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')

Buggy python submission (verdict: Runtime Error):
print(sum([int(x) for x in input().split()]) > 21 ? "bust":"win")

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(max([a+b,a*b,a-b])

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a*b,a-b))
Buggy python submission (verdict: Runtime Error):
s = input()
a = set(s)
print('Yes' if len(a) == 2 and s.count(a[0]) == 2 and s.count(a[1]) == 2 else 'No')

Fixed submission:
s = input()
a = list(set(s))
print('Yes' if len(a) == 2 and s.count(a[0]) == 2 and s.count(a[1]) == 2 else 'No')
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input())
s = input()
k -= 1
print(s[:k]+s[k].lower()+s[k+1:])

Fixed submission:
n, k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
for c in s:
  print(c, end='')
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = sorted([tuple(input().split()) for i in range(n)])
ans = 0
for x in a:
  temp = min(x[1],k)
  ans += temp*x[0]
  k = max(0,k-temp)
print(ans)

Fixed submission:
n,k = map(int, input().split())
a = sorted(tuple(map(int,input().split())) for i in range(n))
ans = 0
for x in a:
  temp = min(x[1],k)
  ans += temp*x[0]
  k = max(0,k-temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
y,m,d = input().split()
print("Heisei" if int(y+m+d) <= 20190430 else "TBD")

Fixed submission:
y,m,d = input().split('/')
print("Heisei" if int(y+m+d) <= 20190430 else "TBD")

Buggy python submission (verdict: Runtime Error):
s = tuple(map(int,input().split('/')))
t = tuple(2019,4,30)
print("Heisei" if s <= t else "TBD")

Fixed submission:
y,m,d = input().split('/')
print("Heisei" if int(y+m+d) <= 20190430 else "TBD")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(n):
  x,y = input().split()
  ans += (int(x) if y == "JPY" else int(x)*48000)
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
  x,y = input().split()
  ans += (float(x) if y == "JPY" else float(x)*380000)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 104206969
for i in range(len(s)-2):
  ans = min(ans, abs(753-int(s[i:i+2])))
print ans


Fixed submission:
s = input()
ans = 104206969
for i in range(len(s)-2):
  ans = min(ans, abs(753-int(s[i:i+3])))
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = 104206969
for i in range(len(s)-2):
  ans = min(ans, abs(753-int(s[i:i+3])))
print ans


Fixed submission:
s = input()
ans = 104206969
for i in range(len(s)-2):
  ans = min(ans, abs(753-int(s[i:i+3])))
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = 104206969
for i in range(len(s)-3):
  ans = min(ans, abs(753-int(s[i:i+3])))
print ans

Fixed submission:
s = input()
ans = 104206969
for i in range(len(s)-2):
  ans = min(ans, abs(753-int(s[i:i+3])))
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(a,b):
  return a//math.gcd(a,b)*b

n = int(input())
v = [int(x) for x in input().split()]
running = 1
for x in v:
  running = lcm(running,x)
print(x-1)

Fixed submission:
n = int(input())
v = [int(x) for x in input().split()]
running = 0
for x in v:
  running += x-1
print(running)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(max([a+b,a-b,a*b])

Fixed submission:
a,b = map(int,input().split())
print(max([a+b,a-b,a*b]))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
vis = [False for _ in range(1001)]
for i in range(1,1001):
  tmp = i
  while (tmp < 1001):
    vis[tmp] = True
    tmp *= i
best = 0
for i in range(x+1):
  if vis[i] and i > best:
    best = i
print(i)

Fixed submission:
x = int(input())
vis = [False for _ in range(x+1)]
vis[1] = True
for i in range(2,x+1):
  tmp = i*i
  while tmp < x+1:
    vis[tmp] = True
    tmp *= i
best = 1
for i in range(1,x+1):
  if vis[i]:
    best = i
print(best)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
vis = [False for _ in range(1001)]
for i in range(1,1001):
  tmp = i
  while (tmp < 1001):
    vis[tmp] = True
    tmp *= i
best = 0
for i in range(x+1):
  if vis[i] and i > best:
    best = i
print(i)

Fixed submission:
x = int(input())
vis = [False for _ in range(x+1)]
vis[1] = True
for i in range(2,x+1):
  tmp = i*i
  while tmp < x+1:
    vis[tmp] = True
    tmp *= i
best = 1
for i in range(1,x+1):
  if vis[i]:
    best = i
print(best)
Buggy python submission (verdict: Runtime Error):
a,b = [int(x) for x in input().split()]
print('Possible' (a+b)%3 == 0 else 'Impossible')

Fixed submission:
a,b = [int(x) for x in input().split()]
print('Possible' if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0 else 'Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
def main():

    n = int(input())
    a = list(map(int,input().split()))

    import collections

    c = collections.Counter(a).most_common()

    m = 10**9 + 7
    ans = 0
    for i in range(0,len(c)):
        num1 = c[i][0]
        cnt1 = c[i][1]
        if cnt1 != 1:
            tmp = (num1**2) % m
            ans +=  tmp * ((cnt1 * (cnt1 - 1) ) // 2)
        for j in range(i+1, len(c)):
            num2 = c[j][0]
            cnt2 = c[j][1]
            tmp = (num1 * num2) % m
            ans += tmp * (cnt1 * cnt2)

    print(ans%m)

if __name__=='__main__':
    main()


Fixed submission:
def main():

    n = int(input())
    a = list(map(int,input().split()))


    m = 10**9 + 7
    ans = 0
    s = []
    total = sum(a)
    s.append(total-a[0])
    for i in range(1,n):
        s.append(s[i-1] - a[i])
    for i in range(n):
        tmp = s[i] % m
        ans += tmp * a[i]
    # ans //= 2
    print(ans%m)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():

    n,m = map(int,input().split())
    ary = []
    for i in range(m):
        aa, bb = map(int,input().split())
        l = min(aa,bb)
        r = max(aa,bb)
        ary.append((l,r))
    ary_s = list(set(ary))
    a = []
    # b = []
    for i in range(len(ary_s)):
        a.append(ary_s[i][0])
        a.append(ary_s[i][1])

    import collections
    c_a = collections.Counter(a).most_common()[0][1]
    print(c_a+1)
if __name__=='__main__':
    main()


Fixed submission:
def main():

    n,m = map(int,input().split())
    ary = []
    for i in range(m):
        aa, bb = map(int,input().split())

        ary.append((aa-1,bb-1))
    ary_s = list(set(ary))
    a = []
    # b = []
    # Union-Find作る
    uf = UnionFind(n)

    for i in range(len(ary_s)):
        a.append(ary_s[i][0])
        a.append(ary_s[i][1])
        uf.union(ary_s[i][0], ary_s[i][1])
    ans = 1
    for i in a:
        ans = max(ans, uf.size(i))
    print(ans)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    zero = [0]
    sum_a = zero + list(itertools.accumulate(a))
    sum_b = zero + list(itertools.accumulate(b))

    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[1] > k and b[1] > k:
        print(0)
        return

    for i in range(n+1):
        if sum_a[i] > k:
            break
    start_a = i - 1

    for i in range(m+1):
        if sum_b[i] + sum_a[start_a] > k:
            break
    start_b = i - 1

    ans = start_a + start_b
    for a_i in range(start_a-1, -1, -1):
        for b_i in range(start_b, m+1):
            now_sum_time = sum_a[a_i] + sum_b[b_i]
            if now_sum_time > k:
                cnt_b = b_i - 1
                break
            if b_i == m:
                cnt_b = b_i
        ans = max(ans, a_i + cnt_b)
    print(ans)
if __name__=='__main__':
    main()


Fixed submission:
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    sum_a = list(itertools.accumulate(a))
    sum_b = list(itertools.accumulate(b))
    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[0] > k and b[0] > k:
        print(0)
        return

    for i in range(n):
        if sum_a[i] > k:
            break

    s_a = i - 1
    if sum_a[-1] <= k:
        s_a = n-1
    now_sum = 0
    if s_a >= 0:
        now_sum = sum_a[s_a]
    for i in range(m):
        if now_sum + sum_b[i] > k:
            break
    s_b = i - 1
    ans = s_a + 1 + s_b + 1
    now_sum = 0
    for a_i in range(s_a-1, -2, -1):
        for b_i in range(s_b+1,m):
            if a_i < 0:
                now_sumtime = sum_b[b_i]
            else:
                now_sumtime = sum_a[a_i] + sum_b[b_i]

            if b_i == m-1 and now_sumtime <= k:
                now_sum = a_i + m + 1
                break
            if now_sumtime > k:
                now_sum = a_i + b_i + 1
                break
        s_b = b_i-1
        ans = max(ans, now_sum)
    print(ans)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    s = list(input())
    now = 0
    for i in range(len(s)):
        if s[i] == '?':
            if i == 0 or s[i-1] == 'P' or s[i-1] == '?':
                s[i] = 'D'
                continue
            if i != len(s) -1 or s[i+1] == 'D' or s[i+1] == '?':
                s[i] ='P'
                continue
    print(''.join(s))

if __name__=='__main__':
    main()


Fixed submission:
def main():
    s = list(input())
    now = 0
    for i in range(len(s)):
        if s[i] == '?':
            if i == 0 or s[i-1] == 'P' or s[i-1] == '?':
                s[i] = 'D'
                continue
            if i+1 < len(s)  and( s[i+1] == 'D' or s[i+1] == '?'):
                s[i] ='P'
                continue
            s[i] = 'D'
    print(''.join(s))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    x = int(input())
    tmp = [0] * 100
    for i in range(100):
        tmp[i] = i**5
    for i in range(100):
        a = x-tmp[i]
        if abs(a) in tmp:
            print(int(a**0.2),i*(a//abs(a)))
            return
if __name__=='__main__':
    main()


Fixed submission:
import math
def main():
    x = int(input())
    tmp = [0] * 1000
    for i in range(1000):
        tmp[i] = i**5
    for i in range(1000):
        a = x+tmp[i]
        if abs(a) in tmp:

            print(int(a**0.2),i)
            return

        a = x - tmp[i]
        if abs(a) in tmp:

            print(int(a**0.2),-i)
            return

if __name__=='__main__':
    main()