Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[float]"):
    dp = []
    for _ in range(0, N + 1):
        L = [0.0] * (N + 1)
        dp.append(L)
    
    dp[1][0] = 1 - p[0]
    dp[1][1] = p[0]

    for i in range(2, N + 1):
        for j in range(0, i + 1):
            if j == 0:
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1])

    res = 0
    for j in range(0, N + 1):
        if j < N / 2:
            continue
        res += dp[N][j]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[float]"):
    dp = []
    for _ in range(0, N + 1):
        L = [0.0] * (N + 1)
        dp.append(L)
    
    dp[1][0] = 1 - p[0]
    dp[1][1] = p[0]

    for i in range(2, N + 1):
        for j in range(0, i + 1):
            if j == 0:
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1])

    res = 0
    for j in range(0, N + 1):
        if j < N / 2:
            continue
        res += dp[N][j]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
func chatInACircle(a []int) int {
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})
	if len(a) == 2 {
		return a[0]
	}

	m := a[0]
	a = a[1:]

	for i := 0; i < len(a) - 1; i++ {
		m += a[i/2]
	}

	return m
}

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

a=sorted(a,reverse=True)
if n==2:
    print(max(a))
    exit(0)

ans=a[0]
a=a[1:]
from math import floor

for i in range(n-2):
    index=floor(i/2)
    ans+=a[index]

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(r ** 2 * 3)

Fixed submission:
n = int(input())
print(n ** 2 * 3)
Buggy python submission (verdict: Runtime Error):

L, R = map(int, input().split())
# 2019 = 3*673
p = 673
if R-L>=p:
    print(0)
else:
    ans = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min((i*j)%2019, ans)
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

x = 0
for i,a in enumerate(A):
    if i%2==0:
        x += a
    else:
        x -= a
ans = [str(x)]
for i in range(1,N):
    x = 2*A[i-1] - x
    ans.append(str(x))

print(' '.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
def serch(s, index, li):
    h = []
    x = len(s) - 4
    for i in li:
        if s[i] + s[i+1] + s[i+2] == 'ABC':
            if 0 < i:
                if s[i-1] == 'A':
                    h.append(i-1)
            if i < x:
                h.append(i+2)
            s = s[0:i] + 'BCA' + s[i+3:]
            index += 1
    h = list(set(h))

    return s, index, h

S = input()

li = []

for i in range(len(S) - 2):
    if S[i] == 'A':
        li.append(i)

ans = 0

while len(li):
    S, ans, li = serch(S, ans, li)

print(ans)

Fixed submission:
S = input()
S = S.replace('BC', 'X')

ans = 0
acc_A = 0
for s in S:
    if s=='A':
        acc_A += 1
    elif s=='X':
        ans += acc_A
    else:
        acc_A = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def serch(s, index, li):
    h = []
    x = len(s) - 4
    for i in li:
        if s[i] + s[i+1] + s[i+2] == 'ABC':
            if 0 < i:
                if s[i-1] == 'A':
                    h.append(i-1)
            if i < x:
                h.append(i+2)
            s = s[0:i] + 'BCA' + s[i+3:]
            index += 1
    h = list(set(h))

    return s, index, h

S = input()

li = []

for i in range(len(S) - 2):
    if S[i] == 'A':
        li.append(i)

ans = 0

while len(li):
    S, ans, li = serch(S, ans, li)

print(ans)

Fixed submission:
S = input()
S = S.replace('BC', 'X')

ans = 0
acc_A = 0
for s in S:
    if s=='A':
        acc_A += 1
    elif s=='X':
        ans += acc_A
    else:
        acc_A = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input())
print(x + y // 2)

Fixed submission:
x, y = map(int, input().split())
print(x + y // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, m, q = map(int, input().split())
abcd_lis = []
for i in range(q):
    abcd = list(map(int, input().split()))
    abcd_lis.append(abcd)
L = []
for i in range(1, m+1):
    L.append(i)
H = list(itertools.combinations_with_replacement(L, n))
max_score = 0
for h in H:
    score = 0
    for j in range(q):
        if list(h)[abcd_lis[j][1]-1]-list(h)[abcd_lis[j][0]-1] == abcd_lis[j][2]:
            score += abcd_lis[j][3]
    if score > max_score:
        max_score = score
print(max_score)

Fixed submission:
import itertools

n, m, q = map(int, input().split())
abcd_lis = []
for i in range(q):
    abcd = list(map(int, input().split()))
    abcd_lis.append(abcd)
L = []
for i in range(1, m+1):
    L.append(i)
H = list(itertools.combinations_with_replacement(L, n))
max_score = 0
for h in H:
    score = 0
    for j in range(q):
        if list(h)[abcd_lis[j][1]-1]-list(h)[abcd_lis[j][0]-1] == abcd_lis[j][2]:
            score += abcd_lis[j][3]
    if score > max_score:
        max_score = score
print(max_score)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    prize = str(input())
    if not(prize in s):
        s.append(prize)
print(len(s))

Fixed submission:
n = int(input())
s = set()
for i in range(n):
    prize = str(input())
    s.add(prize)
print(len(s))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    prize = str(input())
    if not(prize in s):
        s.append(prize)
print(len(s))

Fixed submission:
n = int(input())
s = set()
for i in range(n):
    prize = str(input())
    s.add(prize)
print(len(s))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
prize = []
for  j in range(n):
    if not(s[j] in prize):
        prize.append(s[j])
print(len(prize))

Fixed submission:
n = int(input())
s = set()
for i in range(n):
    prize = str(input())
    s.add(prize)
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
count = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            x = math.gcd(a,b)
            count += math.gcd(x,c)
print(count)

Fixed submission:
import math

k = int(input())
count = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        x = math.gcd(a,b)
        for c in range(1, k+1):
            count += math.gcd(x,c)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
r = s.count("R")
g = s.count("G")
b = s.count("B")
total = r * g * b
for i in range(2001):
    for j in range(n-2):
        if j + (2*i) <= n-1:
            if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j+(2*i)] != s[j]:
                total -= 1
print(total)

Fixed submission:
n = int(input())
s = str(input())
r = s.count("R")
g = s.count("G")
b = s.count("B")
total = r * g * b
for i in range(2000):
    for j in range(n-2*i):
        if j + (2*i) <= n-1:
            if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j+(2*i)] != s[j]:
                total -= 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] and j -i != k-j:
                count += 1
print(count)

Fixed submission:
n = int(input())
s = str(input())
r = s.count("R")
g = s.count("G")
b = s.count("B")
total = r * g * b
for i in range(2000):
    for j in range(n-2*i):
        if j + (2*i) <= n-1:
            if s[j] != s[j+i] and s[j+i] != s[j+(2*i)] and s[j+(2*i)] != s[j]:
                total -= 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
saidai = 0
for i in range(n-k+1):
    wa = 0
    for j in range(i, i+k):
        wa += p[j]
    if wa > saidai:
        saidai = wa
kitai = (1/2)*(k+saidai)
print(str(kitai))

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
saidai = 0
wa =[None]*n
wa_2 = 0
gokei = 0
for i in range(n):
    gokei += p[i]
    wa[i] = gokei
saidai = wa[k-1]
for j in range(n-k):
    wa_2 = wa[j+k]-wa[j]
    if wa_2 > saidai:
        saidai = wa_2
kitai = (1/2)*(k+saidai)
print(str(kitai))
Buggy python submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[[moji[0]+moji[-1]] == "":
    f_dict[moji[0]+moji[-1]] = 0
  else:
    f_dict[[moji[0]+moji[-1]]+= 1 
  if s_dict[[moji[-1]+moji[0]] == "":
    f_dict[[moji[-1]+moji[0]] = 0
  else:
    f_dict[[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Fixed submission:
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if not moji[0]+moji[-1] in f_dict:
    f_dict[moji[0]+moji[-1]] = 1
  else:
    f_dict[moji[0]+moji[-1]] += 1 
  if not moji[-1]+moji[0] in s_dict:
    s_dict[moji[-1]+moji[0]] = 1
  else:
    s_dict[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  if mykey in s_dict:
      cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Buggy python submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[[moji[0], moji[-1]] == "":
    f_dict[moji[0], moji[-1]] = 0
  else:
    f_dict[[moji[0], moji[-1]]+= 1 
  if s_dict[[moji[-1], moji[0]] == "":
    f_dict[[moji[-1], moji[0]] = 0
  else:
    f_dict[[moji[-1], moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Fixed submission:
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if not moji[0]+moji[-1] in f_dict:
    f_dict[moji[0]+moji[-1]] = 1
  else:
    f_dict[moji[0]+moji[-1]] += 1 
  if not moji[-1]+moji[0] in s_dict:
    s_dict[moji[-1]+moji[0]] = 1
  else:
    s_dict[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  if mykey in s_dict:
      cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Buggy python submission (verdict: Runtime Error):
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if f_dict[moji[0], moji[-1]] == "":
    f_dict[moji[0], moji[-1]] = 0
  else:
  	f_dict[moji[0], moji[-1]] += 1 
  if s_dict[moji[-1], moji[0]] == "":
    f_dict[moji[-1], moji[0]] = 0
  else:
  	f_dict[moji[-1], moji[0]] += 1
for mykey in f_dict.keys():
  cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)

Fixed submission:
n = int(input())
f_dict = {}
s_dict = {}
cnt_all = 0
for i in range(n):
  moji = str(i+1)
  if not moji[0]+moji[-1] in f_dict:
    f_dict[moji[0]+moji[-1]] = 1
  else:
    f_dict[moji[0]+moji[-1]] += 1 
  if not moji[-1]+moji[0] in s_dict:
    s_dict[moji[-1]+moji[0]] = 1
  else:
    s_dict[moji[-1]+moji[0]] += 1
for mykey in f_dict.keys():
  if mykey in s_dict:
      cnt_all += f_dict[mykey] * s_dict[mykey]
print(cnt_all)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
for j in range(n):
    list0.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])] = 1
        else:
            pen += 1
    else:
        if lis[1] == "AC":
            pass
        else:
            pen += 1
print(str(sei)+" "+str(pen))



Fixed submission:
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
listpen = []
for j in range(n):
    list0.append(0)
for k in range(n):
    listpen.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])-1] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])-1] = 1
        else:
            listpen[int(lis[0])-1] += 1
    else:
        pass
for l in range(n):
    if list0[l] == 1:
        pen += listpen[l]
print(str(sei)+" "+str(pen))
Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())
while x > 0:
  for i in range(2, math.floor(x**(1/2))):
    if x % i == 0:
      print(x)
      break
  else:
    x += 1

Fixed submission:
import math

x = int(input())
while x > 0:
  for i in range(2, math.floor(x**(1/2))):
    if x % i == 0:
      x += 1
      break
  else:
    print(x)
    break

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
while x > 0:
  for i in range(2, x):
    if x % i == 0:
      print(x)
      break
  else:
    x += 1

Fixed submission:
import math

x = int(input())
while x > 0:
  for i in range(2, math.floor(x**(1/2))):
    if x % i == 0:
      x += 1
      break
  else:
    print(x)
    break
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
syo = n//k 
total = 0
for i in range(k):
  for j in range(i, n, k):
    if j == i or score == 0 or t[j] ?= te:
      if t[j] = 'r'
      	score = p
      	total += p
        te = 'p'
      elif t[j] = 's'
      	score = r
      	total += r
        te = 'r'
      else:
        score = s
        total += s
        te = 's'
    else:
      score = 0
      
  
print(total)

Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
syo = n//k 
total = 0
for i in range(k):
  te = ''
  score = 0
  for j in range(i, n, k):
    if score == 0 or t[j] != te:
      if t[j] == 'r':
        score = p
        total += p
        te = 'r'
      elif t[j] == 's':
        score = r
        total += r
        te = 's'
      else:
        score = s
        total += s
        te = 'p'
    else:
      score = 0
      
  
print(total)
Buggy python submission (verdict: Runtime Error):
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m = int(input())
list = str(input())
n = len(list)
for i in range(n):
	if int(alpha.index(list[i])) + m < 26:
		list[i] = alpha[int(alpha.index(list[i])) + m]
	else:
		list[i] = alpha[int(alpha.index(list[i])) + m -26] 
print(list)

Fixed submission:
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m = int(input())
list = input()
newlist = []
n = len(list)
for i in range(n):
	if int(alpha.find(list[i])) + m < 26:
		newlist.append(alpha[int(alpha.find(list[i])) + m])
	else:
		newlist.append(alpha[int(alpha.find(list[i])) + m -26]) 
moji = ''.join(newlist)
print(moji)

Buggy python submission (verdict: Runtime Error):
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m = int(input())
list = str(input())
n = len(list)
for i in range(n):
	if alpha.index(list[i]) + m < 26:
		list[i] = alpha[alpha.index(list[i]) + m]
	else:
		list[i] = alpha[alpha.index(list[i]) + m -26] 
print(list)

Fixed submission:
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m = int(input())
list = input()
newlist = []
n = len(list)
for i in range(n):
	if int(alpha.find(list[i])) + m < 26:
		newlist.append(alpha[int(alpha.find(list[i])) + m])
	else:
		newlist.append(alpha[int(alpha.find(list[i])) + m -26]) 
moji = ''.join(newlist)
print(moji)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
alis.sort()
blis.sort()
for i in range(n):
    if alis[i] > blis[i]:
        print("No")
        sys.exit()


for i in range(n-1):
    if alis[i+1] > blis[i]:
        pass
    else:
        print("Yes")
        sys.exit()
print("No")


Fixed submission:
n = int(input())
print((n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(a.index(i+1)+1)
print(" ".join(map(str, b)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [None] * n 
for i in range(n):
  b[a[i]-1] = i+1
print(" ".join(map(str, b)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(a.index(i+1)+1)
print(" ".join(map(str, b)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [None] * n 
for i in range(n):
  b[a[i]-1] = i+1
print(" ".join(map(str, b)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(a.index(i+1)+1)
for i in range(n):
  print(i+" ")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [None] * n 
for i in range(n):
  b[a[i]-1] = i+1
print(" ".join(map(str, b)))
Buggy python submission (verdict: Runtime Error):
s = str(input())
if s = "Sunny":
	print("Cloudy")
elif s = "Cloudy":
	print("Rainy")
else:
	print("Sunny")

Fixed submission:
s = str(input())
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy python submission (verdict: Runtime Error):
s = str(input())
if s = "Sunny":
  print("Cloudy")
elif s = "Cloudy":
  print("Rainy")
else:
  print("Sunny")


Fixed submission:
s = str(input())
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
bridge = [1]*(n-1)
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if sum(bridge[a-1:b-1])/len(bridge[a-1:b-1]) == 1 and b >= 2:
        bridge[b-2] = 0
        count += 1
print(count)

Fixed submission:
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
x = 0
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if a <= x:
        continue
    x = b-1
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
bridge = [1]*(n-1)
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if sum(bridge[a:b])/len(bridge[a:b]) == 1 and b >= 2:
        bridge[b-2] = 0
        count += 1
print(count)

Fixed submission:
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
x = 0
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if a <= x:
        continue
    x = b-1
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
bridge = [1]*(n-1)
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if sum(bridge[a:b])/len(bridge[a:b]) == 1:
        bridge[b-2] = 0
        count += 1
print(count)

Fixed submission:
n, m = map(int, input().split())
ab_lis =[]
for i in range(m):
    a,b = map(int, input().split())
    ab_lis.append([b,a])
ab_lis.sort()
count = 0
x = 0
for lis in ab_lis:
    b = lis[0]
    a = lis[1]
    if a <= x:
        continue
    x = b-1
    count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      if a + b + c == s:
        count += 1
      else:
        pass
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for a in range(k+1):
  for b in range(k+1):
      if s-k <= a + b <= s:
        count += 1
      else:
        pass
print(count)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, M, K = map(int, input().split())
    A = deque(list(map(int, input().split())))
    B = deque(list(map(int, input().split())))

    time = 0
    res = 0
    same_flag = False

    while True:
        if len(A) != 0:
            tmp1 = A[0]
        else:
            tmp1 = 10 ** 10
        
        if len(B) != 0:
            tmp2 = B[0]
        else:
            tmp2 = 10 ** 10
        
        if time + tmp1 > K and time + tmp2 > K:
            break

        if tmp1 == 10 ** 10 and tmp2 == 10 ** 10:
            break
        elif tmp1 < tmp2:
            tmp_time = A.popleft()
            time += tmp_time
            res += 1
        elif tmp1 == tmp2:
            sumA = sum(A[1:])
            sumB = sum(B[1:])

            if same_flag:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
            elif sumA < sumB:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
            elif sumA > sumB:
                tmp_time = B.popleft()
                time += tmp_time
                res += 1
            else:
                tmp_time = A.popleft()
                time += tmp_time
                res += 1
                same_flag = True
        else:
            tmp_time = B.popleft()
            time += tmp_time
            res += 1
        
        if time > K:
            time -= tmp_time
            res -= 1
            break
    
    print(res)

if __name__ == '__main__':
    main()

Fixed submission:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    cumsumA = [0] + list(accumulate(A))
    cumsumB = [0] + list(accumulate(B))

    res = 0

    for i in range(N+1):
        if i == 0:
            for j in range(M, -1, -1):
                if cumsumB[j] <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
        else:
            for j in range(max_j, -1, -1):
                time = cumsumA[i] + cumsumB[j]
                if  time <= K:
                    max_j = j
                    res = max(res, i + j)
                    break
    
    print(res)

if __name__ == '__main__':
    main()