Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
 
for q in range(1, Q + 1):
    inp = input().split(" ")
    if (int(inp[0]) == 1):
        S.reverse()
    else:
        if (int(inp[1]) == 1):
            S.insert(0, inp[2])
        elif (int(inp[1]) == 2):
            S.append(inp[2])
 
print("".join(S))

Fixed submission:
S = input()
a = 0
b = 0
for s in S:
    if s == "A":
        a += 1
    elif s == "B":
        b += 1
if a == 0 or b == 0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k] = 0

res = 'NO'
for l in range(3):
    if sum(a[l]) == 0:
        res = 'Yes'

nl = []

for m in range(3):
    nl.append(a[m][l])

if sum(nl) == 0:
    res = 'Yes'
if sum([a[0][0],a[1][1],a[2][2]]) == 0:
    res = 'Yes'
if sum([a[2][2], a[1][1], a[2][1]]) == 0:
    res = 'Yes'
print res


a,b = map(int,raw_input().split())


Fixed submission:
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

diag1 = [a[0][0],a[1][1],a[2][2]]
diag2 = [a[0][2],a[1][1],a[2][0]]
res = 'No'
if sum(diag1) ==0 or sum(diag2) ==0:
    res ='Yes'

rowsum = [sum(a[i]) for i in range(3) ]
if 0 in rowsum:
    res = 'Yes'

colSum = [sum([a[j][i] for j in range(3)]) for i in range(3)]
if 0 in colSum:
    res = 'Yes'

print res

Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k] = 0

res = 'NO'
for l in range(3):
    if sum(a[l]) == 0:
        res = 'Yes'
    else:
        nl = []

        for m in range(3):
            nl.append(a[m][l])

        if sum(nl) == 0:
            res = 'Yes'
if sum([a[0][0],a[1][1],a[2][2]]) == 0:
    res = 'Yes'
if sum([a[2][2], a[1][1], a[3][1]]) == 0:
    res = 'Yes'
print res


Fixed submission:
a = []
for i in range(3):
    a.append(map(int,raw_input().split()))
n = input()
for j in range(n):
    b = input()
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                a[j][k] = 0

diag1 = [a[0][0],a[1][1],a[2][2]]
diag2 = [a[0][2],a[1][1],a[2][0]]
res = 'No'
if sum(diag1) ==0 or sum(diag2) ==0:
    res ='Yes'

rowsum = [sum(a[i]) for i in range(3) ]
if 0 in rowsum:
    res = 'Yes'

colSum = [sum([a[j][i] for j in range(3)]) for i in range(3)]
if 0 in colSum:
    res = 'Yes'

print res
Buggy python submission (verdict: Runtime Error):
 r= input()
 nr = 2*3.14*(r**2)
 ar = 2*3.14
 print int(nr/ar)

# l = []
# for i in xrange(41):
#     l.append(map(int,raw_input().split()))
# print l


Fixed submission:
r= input()

print r**2
Buggy python submission (verdict: Runtime Error):
import math
n=int(raw_input())
sq=math.sqrt(n)
ans=None



if str(sq)[-2]=='.':
    print len(str(sq))-2
else:
    nu=[]
    while sq>1:
        sq=int(sq)
        if n%sq==0:
            nu.append(str(sq))
            nu.append(str(n/sq))
            sq-=1
            break
        else:
            sq-=1
    if len(nu)!=0:
        nu.sort()
        print len((nu[1]))
    else:
        print len(str(n))

Fixed submission:
a,b=map(int,raw_input().split())
print (a+b)%24
Buggy python submission (verdict: Runtime Error):
n,m=map(int,raw_input().split())
st=[]
ch=[]
l=[]
for i in range(n):
    g=map(int,raw_input().split())
    st.append(g)
for y in range(n):
    r=map(int,raw_input().split())
    ch.append(r)





def dis(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])

for stu in st:
    ctr=0
    gh=10**9+7
    new={}
    for che in ch:
        # print stu,che,dis(stu,che)
        if dis(stu,che)<gh:
            gh=dis(stu,che)
            ctr+=1
            if gh not in new:
                new[gh]=[ctr]
            else:
                new[gh].append(ctr)


        else:
            ctr+=1
    # print new
    po=new.keys()
    # print po
    po.sort()
    poi=new[po[0]]
    # print poi
    poi.sort()
    l.append(poi[0])
for numb in l:
    print numb


Fixed submission:
n,m=map(int,raw_input().split())
stu=[]
point=[]


for i in xrange(n):
    stu.append(map(int,raw_input().split()))
for j in xrange(m):
    point.append(map(int,raw_input().split()))


def dis(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])



for co in stu:
    ctr=1
    l=[]
    for po in point:
        l.append((dis(po,co),ctr))
        ctr+=1
    l.sort()
    print l[0][1]
Buggy python submission (verdict: Time Limit Exceeded):
import math
print math.factorial(int(raw_input()))%(10**9+7)

Fixed submission:
mod=10**9+7
ans=1
for i in xrange(int(raw_input())):
    ans*=i+1
    ans%=mod
print ans

Buggy python submission (verdict: Time Limit Exceeded):
import math
print math.factorial(int(raw_input()))%(10**9+7)

Fixed submission:
mod=10**9+7
ans=1
for i in xrange(int(raw_input())):
    ans*=i+1
    ans%=mod
print ans
Buggy python submission (verdict: Runtime Error):
l=map(int,raw_input().split())
c=3
for i in l:
    if l.count(i)==3:
        c= 1
        break
    elif l.count(i)==2:
        c= 2
        break
print c
vvvvv

Fixed submission:
l=map(int,raw_input().split())
c=3
for i in l:
    if l.count(i)==3:
        c= 1
        break
    elif l.count(i)==2:
        c= 2
        break
print c
Buggy python submission (verdict: Runtime Error):
n,l=map(int,raw_input().split())
l=[]
for i in range(n):
    l.append(raw_input())
l.sort()
print ''.join(l)

Fixed submission:
l=map(int,raw_input().split())
if l.count(5)==2 and l.count(7)==1  :
    print 'YES'
else:
    print 'NO'
Buggy python submission (verdict: Runtime Error):
from collections import deque


def main():
    X, Y, A, B, C = map(int, input().split(' '))
    a_list = list(map(int, input().split(' ')))
    b_list = list(map(int, input().split(' ')))
    c_list = list(map(int, input().split(' ')))
    a_deq = deque(sorted(a_list, reverse=True)[:X])
    b_deq = deque(sorted(b_list, reverse=True)[:Y])
    c_deq = deque(sorted(c_list, reverse=True))
    result = sum(a_deq) + sum(b_deq)
    while len(c_deq) != 0:
        min_ab = 0
        if a_deq[-1] < b_deq[-1]:
            min_ab = a_deq.pop()
        else:
            min_ab = b_deq.pop()
        if min_ab >= c_deq[0]:
            break
        result += c_deq.popleft() - min_ab

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import deque


def main():
    X, Y, A, B, C = map(int, input().split(' '))
    a_list = list(map(int, input().split(' ')))
    b_list = list(map(int, input().split(' ')))
    c_list = list(map(int, input().split(' ')))
    a_deq = deque(sorted(a_list, reverse=True)[:X])
    b_deq = deque(sorted(b_list, reverse=True)[:Y])
    c_deq = deque(sorted(c_list, reverse=True))
    result = sum(a_deq) + sum(b_deq)
    while len(c_deq) > 0:
        try:
            if a_deq[-1] < b_deq[-1]:
                min_ab = a_deq.pop()
            else:
                min_ab = b_deq.pop()
        except IndexError:
            if len(a_deq) > 0:
                min_ab = a_deq.pop()
            elif len(b_deq) > 0:
                min_ab = b_deq.pop()
            else:
                break

        if min_ab >= c_deq[0]:
            break
        result += c_deq.popleft() - min_ab

    print(result)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def cycle(x):
    result = 0
    for y in range(int(x), 0, -1):
        result += y - 1
    return result


def main():
    input()
    a_list = list(map(int, input().split()))
    dict_a_list = dict()
    dict_result = dict()
    for a in a_list:
        if a in dict_a_list:
            dict_a_list[a] += 1
            continue
        dict_a_list[a] = 1
    for a in a_list:
        result = 0
        if a in dict_result:
            print(dict_result[a])
            continue
        dict_a_list[a] -= 1
        for v in dict_a_list.values():
            result += cycle(v)
        print(result)
        dict_result[a] = result
        dict_a_list[a] += 1


if __name__ == '__main__':
    main()


Fixed submission:
def cycle(x):
    result = 0
    for y in range(int(x), 0, -1):
        result += y - 1
    return result


def main():
    input()
    a_list = list(map(int, input().split(' ')))
    dict_a_list = dict()
    dict_result = dict()
    for a in a_list:
        if a in dict_a_list:
            dict_a_list[a] += 1
            continue
        dict_a_list[a] = 1
    for a in a_list:
        result = 0
        if dict_a_list[a] in dict_result:
            print(dict_result[dict_a_list[a]])
            continue
        dict_a_list[a] -= 1
        for v in dict_a_list.values():
            result += cycle(v)
        print(result)
        dict_a_list[a] += 1
        dict_result[dict_a_list[a]] = result


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def cycle(x):
    result = 0
    for y in range(int(x), 0, -1):
        result += y - 1
    return result


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    dict_a_list = dict()
    for a in a_list:
        if a in dict_a_list:
            dict_a_list[a] += 1
            continue
        dict_a_list[a] = 1
    for a in a_list:
        result = 0
        dict_a_list[a] -= 1
        for v in dict_a_list.values():
            result += cycle(v)
        print(result)
        dict_a_list[a] += 1


if __name__ == '__main__':
    main()


Fixed submission:
def cycle(x):
    result = 0
    for y in range(int(x), 0, -1):
        result += y - 1
    return result


def main():
    input()
    a_list = list(map(int, input().split(' ')))
    dict_a_list = dict()
    dict_result = dict()
    for a in a_list:
        if a in dict_a_list:
            dict_a_list[a] += 1
            continue
        dict_a_list[a] = 1
    for a in a_list:
        result = 0
        if dict_a_list[a] in dict_result:
            print(dict_result[dict_a_list[a]])
            continue
        dict_a_list[a] -= 1
        for v in dict_a_list.values():
            result += cycle(v)
        print(result)
        dict_a_list[a] += 1
        dict_result[dict_a_list[a]] = result


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    hash_max = 0
    for i in range(0, N - K + 1):
        if sum(p_list[i:i + K]) > hash_max:
            hash_max = sum(p_list[i:i + K])
    print(hash_max)


if __name__ == '__main__':
    main()


Fixed submission:
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(int, input().split(' ')))
    max_p_sum = 0
    sum_list = list()
    for n in range(0, N - K + 1, 1):
        hash_sum = sum(p_list[n: n + K])
        if max_p_sum < hash_sum:
            max_p_sum = hash_sum
            sum_list = p_list[n: n + K]
    expected_value = [(1 + s) / 2 for s in sum_list]
    print(sum(expected_value))


if __name__ == '__main__':
    main()


Fixed submission:
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(int, input().split(' ')))
    max_p_sum = 0
    sum_list = list()
    for n in range(0, N - K + 1, 1):
        if max_p_sum < sum(p_list[n: n + K]):
            max_p_sum = sum(p_list[n: n + K])
            sum_list = p_list[n: n + K]
    expected_value = [(1 + s) / 2 for s in sum_list]
    print(sum(expected_value))


if __name__ == '__main__':
    main()


Fixed submission:
def expected_value(x):
    x = int(x)
    return (x + 1) / 2


def main():
    N, K = map(int, input().split(' '))
    p_list = list(map(expected_value, input().split(' ')))
    cumulative_list = [0]
    for p in p_list:
        cumulative_list.append(cumulative_list[-1] + p)
    max_len = 0
    for i in range(0, N - K + 1):
        if max_len < cumulative_list[i + K] - cumulative_list[i]: max_len = cumulative_list[i + K] - cumulative_list[i]
    print(max_len)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, S = open(0).read().split('\n')
    print(S.count('ABC'))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = input()
    S = input()
    print(S.count('ABC'))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
c = np.lcm(a, b)
print(str(c))

Fixed submission:
result_list = [1, 2, 3]
for i in range(2):
    item = int(input())
    result_list.remove(item)
print(result_list[0])
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
c = np.lcm(a, b)
print(str(c))

Fixed submission:
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b = list(map(int, input().split()))
print(lcm(a, b))

Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
print(np.lcm(a, b))

Fixed submission:
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b = list(map(int, input().split()))
print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
i= int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list)

Fixed submission:
i= int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list))

Buggy python submission (verdict: Runtime Error):
#i = int(input())
#s = input()
i = 13
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list)

Fixed submission:
i= int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list))

Buggy python submission (verdict: Runtime Error):
i = int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans = [en[(en.index(x) + 26) % 26 + i] for x in s]
print(ans.join(''))

Fixed submission:
i= int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list))
Buggy python submission (verdict: Runtime Error):
def main():
    N = input()
    cnt = 9
    len_n = len(N)
    if len_n == 1:
        cnt = int(N)
    elif len_n % 2 == 0:
        len_n -= 1
    else:
        cnt += int(N[1:]) + 1
        len_n -= 2
    while len_n > 1:
        print(f'len_n {len_n} , cnt {cnt}')
        cnt += 10 ** (len_n - 1) * 9
        len_n -= 2
    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = input()
    cnt = 9
    len_n = len(N)
    if len_n == 1:
        cnt = int(N)
    elif len_n % 2 == 0:
        len_n -= 1
    else:
        cnt += int(N[1:]) + 1
        if int(N[0]) > 1:
            cnt += (int(N[0])-1) * 10 ** (len_n-1)
        len_n -= 2
    while len_n > 1:
        cnt += 10 ** (len_n - 1) * 9
        len_n -= 2
    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split(' '))
cnt_pattern = 0
for a in range(k+1):
  for b in range(k+1):
    for c in range(k+1):
      if s == a + b + c:
        cnt_pattern += 1
        if s < a + b + c:
          break
print(cnt_pattern)

Fixed submission:
k, s = map(int, input().split(' '))
cnt_pattern = 0
for a in range(k + 1):
  for b in range(k + 1):
    if 0 <= s - a - b <= k:
      cnt_pattern += 1
print(cnt_pattern)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
c = 0

print({}.format(N*3))

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

print(N*N*N)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())
tempM = 0
M = []

for i in range(N):
    for p in range(i+1):
        temp = p % (i+1)
        if temp > tempM:
            tempM = temp
    M.append(tempM)

print(sum(M))

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

print(int(N*(N-1)//2))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())
tempM = 0
M = []

for i in range(N):
    for p in range(N):
        temp = p % (i+1)
        if temp > tempM:
            tempM = temp
    M.append(tempM)

print(sum(M))

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

print(int(N*(N-1)//2))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())
tempM = 0
M = []

for i in range(N):
    for p in range(N):
        temp = p % (i+1)
        if temp > tempM:
            tempM = temp
    M.append(tempM)

print(sum(M))

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

print(int(N*(N-1)//2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
A,B,C = map(int,input().split())

if C>(A=B):
  print(C-(A-B))
else:
  print(0)

Fixed submission:
# -*- coding: utf-8 -*-
 
A,B,C = map(int,input().split())
 
if C>(A-B):
    print(C-(A-B))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

if N == 2:
    if H[0]>H[1]:
    H[0] -= 1
else:
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]:
            H[i] -= 1

for i in range(N-1):
    if H[i]>H[i+1]:
        flag = 0

print(H)

if flag == 1:
    print('Yes')
else:
    print('No')

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

if N == 2:
    if H[0]>H[1]:
        H[0] -= 1
else:
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]:
            H[i] -= 1

for i in range(N-1):
    if H[i]>H[i+1]:
        flag = 0

if flag == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N+1):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

print(count)


Fixed submission:
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

if (A[N] > 0) and (B[N-1] > 0):
    tmp = min(A[N],B[N-1])
    count += tmp
    A[N] -= tmp
    B[N-1] -= tmp 

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans = 0
        while n>0:
            for i in range(a):
                n -=1
                if n >= 0:
                    ans+=1
                else:
                    break
            for j in range(b):
                n -=1
        print(ans)

if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans=0
        tmp = n //(a+b)
        ans += a*tmp
        if n - (a+b)*tmp >a :
            ans +=a
        else:
            ans += n - (a+b)*tmp
        
        print(ans)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    n, a, b = map(int, input().split())
    arr = ""
    while True:
        arr += "b"*a
        if len(arr) >= n:
            break
        arr+= "r"*b
        if len(arr) >= n:
            break
    print(arr[0:n].count("b"))


if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans=0
        tmp = n //(a+b)
        ans += a*tmp
        if n - (a+b)*tmp >a :
            ans +=a
        else:
            ans += n - (a+b)*tmp
        
        print(ans)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, a, b = map(int, input().split())
    lis = []
    while True:
        for i in range(a):
            lis.append("b")
        if len(lis) >= n:
            break
        for j in range(b):
            lis.append("r")
        if len(lis) >= n:
            break
    print(lis[0:n].count("b"))


if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans=0
        tmp = n //(a+b)
        ans += a*tmp
        if n - (a+b)*tmp >a :
            ans +=a
        else:
            ans += n - (a+b)*tmp
        
        print(ans)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():

    n,a,b =map(int, input().split())
    lis = []
    while True:
        for i in range(a):
            lis.append("b")
        for j in range(b):
            lis.append("r")
        if len(lis)>= n:
            break
    print(lis[0:n].count("b"))
    
    
    
if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans=0
        tmp = n //(a+b)
        ans += a*tmp
        if n - (a+b)*tmp >a :
            ans +=a
        else:
            ans += n - (a+b)*tmp
        
        print(ans)

if __name__ == "__main__":
    resolve()