Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
S = input()
Q = int(input())
querys = [list(map(str, input().split())) for i in range(Q)]
for i in range(Q):
    query = querys[i]
    if query[0] == "1":
        qi = int(query[1])
        S = S[:qi-1] + query[2] + S[qi:]
    else:
        c = collections.Counter(S[int(query[1]) - 1:int(query[2])])
        print(len(c))

Fixed submission:
N = int(input()) 
if N % 2 == 1:
    print((N//2) + 1)
else:
    print(N//2)

Buggy python submission (verdict: Runtime Error):
N = input()

if N%2 == 1:
  print(int(N/2)+1)
else:
  print(N/2)

Fixed submission:
N = int(input()) 
if N % 2 == 1:
    print((N//2) + 1)
else:
    print(N//2)

Buggy python submission (verdict: Runtime Error):
N = input()
x = int(N/2)
print(x)

Fixed submission:
N = int(input()) 
if N % 2 == 1:
    print((N//2) + 1)
else:
    print(N//2)
Buggy python submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
k = {}
j = True
ans = []

for i in range(M):
    a, b = input().split()
    a = int(a)
    ans.append("0")
    if a not in k.keys():
        k[a] = b
    else:
        if k[a] != b:
            j = False
            break

for n in range(N):
    if n + 1 in k.keys():
        ans[n] = k[n + 1]

if j:
    f = int("".join(ans))
    print(f)
else:
    print(-1)

Fixed submission:
def main():
    N, M = (int(x) for x in input().split())
    SC = [list(map(int, input().split())) for _ in range(M)]
    for i in range(10 ** N):
        _str = str(i)
        k = True
        if len(_str) == N:
            for j in range(M):
                if _str[SC[j][0]-1] != str(SC[j][1]):
                    k = False
            if k:
                return print(i)
    return print('-1')

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
k = {}
j = True
ans = []

for i in range(M):
    ans.append("0")
    a, b = input().split()
    a = int(a)
    if a not in k.keys():
        k[a] = b
    else:
        if k[a] != b:
            j = False
            break

for n in range(N):
    if n + 1 in k.keys():
        ans[n] = k[n + 1]

if j:
    f = "".join(ans)
    print(int(f))
else:
    print(-1)

Fixed submission:
def main():
    N, M = (int(x) for x in input().split())
    SC = [list(map(int, input().split())) for _ in range(M)]
    for i in range(10 ** N):
        _str = str(i)
        k = True
        if len(_str) == N:
            for j in range(M):
                if _str[SC[j][0]-1] != str(SC[j][1]):
                    k = False
            if k:
                return print(i)
    return print('-1')

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    X = [int(x) for x in input().split()]
    ans = []
    for i in range(min(X), max(X)):
        a = map(lambda x: (x-i)**2, X)
        ans.append(sum(a))
    return print(min(ans))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    X = [int(x) for x in input().split()]
    ans = []
    mini = min(X)
    maxi = max(X)
    if mini != maxi:
        for i in range(mini, maxi):
            a = map(lambda x: (x-i)**2, X)
            ans.append(sum(a))
    else:
        ans.append(0)
    return print(min(ans))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1, len(A)):
    if A[i - 1] != A[i]:
        continue
        k = True
    else:
        k = False
        break

if k:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1, len(A)):
    if A[i - 1] != A[i]:
        k = True
    else:
        k = False
        break

if k:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1,len(A)):
    if A[i - 1] != A[i]:
        continue
        k = True
    else:
        k = False
        break

if k:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1, len(A)):
    if A[i - 1] != A[i]:
        k = True
    else:
        k = False
        break

if k:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 0
    for i in range(N):
        M = min(P[:i+1])
        if M >= P[i]:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 1
    num = P[0]
    for i in range(1, N):
        if num >= P[i]:
            count += 1
            num = P[i]
    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 0
    for i in range(N):
        k = True
        for j in range(i):
            if P[i] > P[j]:
                k = False
                break
        if k:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 1
    num = P[0]
    for i in range(1, N):
        if num >= P[i]:
            count += 1
            num = P[i]
    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 0
    for i in range(N):
        k = True
        for j in range(i):
            if P[i] > P[j]:
                k = False
                break
        if k:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    count = 1
    num = P[0]
    for i in range(1, N):
        if num >= P[i]:
            count += 1
            num = P[i]
    print(count)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = (int(x) for x in input().split())

for i in range(K):
    if A > 0:
        A -= 1
    elif B > 0:
        B -= 1
    else:
        pass

print(A, B)


Fixed submission:
A, B, K = (int(x) for x in input().split())

M = A + B
if K >= M:
    A = 0
    B = 0
else:
    if K >= A:
        B = B - (K - A)
        A = 0
    else:
        A = A - K

print(A, B)
Buggy python submission (verdict: Runtime Error):
import math
x, y = (int(x) for x in input().split())

print((x * y) / math.gcd(x, y))

Fixed submission:
import fractions
x, y = (int(x) for x in input().split())

print(int((x * y) / fractions.gcd(x, y)))

Buggy python submission (verdict: Runtime Error):
import math
x, y = (int(x) for x in input().split())

print((x * y) // math.gcd(x, y))

Fixed submission:
import fractions
x, y = (int(x) for x in input().split())

print(int((x * y) / fractions.gcd(x, y)))

Buggy python submission (verdict: Runtime Error):
import math
x, y = (int(x) for x in input().split())

print((x * y) // math.gcd(x, y))

Fixed submission:
import fractions
x, y = (int(x) for x in input().split())

print(int((x * y) / fractions.gcd(x, y)))

Buggy python submission (verdict: Runtime Error):
import math
A, B = (int(x) for x in input().split())


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


print(lcm(A, B))

Fixed submission:
import fractions
x, y = (int(x) for x in input().split())

print(int((x * y) / fractions.gcd(x, y)))
Buggy python submission (verdict: Runtime Error):
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K-Q for i in range(N)]

for a in A:
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K for i in range(N)]

for a in A:
    ans = list(map(lambda x: x-1, ans))
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K-Q for i in range(N)]

for a in A:
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K for i in range(N)]

for a in A:
    ans = list(map(lambda x: x-1, ans))
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K-Q for i in range(N)]

for a in A:
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    B = [int(x) for x in input().split()]
    A = [0] * N
    A[0] = B[0]
    A[N-1] = B[-1]
    for i in range(1, N-1):
        if B[i - 1] <= B[i]:
            A[i] = B[i - 1]
        else:
            A[i] = B[i]
    print(sum(A))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    S = input()
    T = input()
    ans = 0
    for i in range(3):
        if S[i] == T[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def main():
    N = int(input())
    s = [Counter(input()) for _ in range(N)]
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if s[i] == s[j]:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter


def main():
    N = int(input())
    s = ["".join(sorted(input())) for _ in range(N)]
    S = Counter(s)
    ans = 0
    for a in S.values():
        ans += sigma(a)
    print(ans)


def sigma(x):
    sum = 0
    for i in range(1, x):
        sum += i
    return sum


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    k = True
    for i in range(1, N):
        if H[i] >= max(H[:i]):
            if H[i] - 1 >= H[i - 1]:
                H[i] = H[i] - 1
        else:
            k = False
            break
    if k:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    k = True
    for i in range(1, N):
        if H[i] >= H[i-1]:
            if H[i] - 1 >= H[i - 1]:
                H[i] = H[i] - 1
        else:
            k = False
            break
    if k:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    S = sorted(int(input()))
    if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
        print("Bad")
    else:
        print("Good")


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    S = input()
    if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
        print("Bad")
    else:
        print("Good")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math


def main():
    A, B, C, D = [int(x) for x in input().split()]
    N = B - A + 1
    g = math.gcd(C, D)
    l = (C * D) / g
    b = anti(B, C, D, l)
    a = anti((A-1), C, D, l)
    print(N - (b - a))


def anti(x, y, z, l):
    return int(x / y) + int(x / z) - int(x / l)


if __name__ == "__main__":
    main()


Fixed submission:
from fractions import gcd


def main():
    A, B, C, D = [int(x) for x in input().split()]
    l = (C * D) // gcd(C, D)
    b = B - anti(B, C, D, l)
    a = (A - 1) - anti((A - 1), C, D, l)
    print(int(b - a))


def anti(x, y, z, l):
    return (x // y) + (x // z) - (x // l)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter


def main():
    N, M = map(int, input().split())
    LR = []
    for _ in range(M):
        L, R = map(int, input().split())
        LR.append(list(range(L, R + 1)))
    LR = list(itertools.chain.from_iterable(LR))
    C = Counter(LR)

    ans = 0
    for c in C.values():
        if c == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    L = 0
    R = N
    for _ in range(M):
        l, r = map(int, input().split())
        if L < l:
            L = l
        if R > r:
            R = r
    ans = 0
    if L <= R:
        ans = R - L + 1
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter


def main():
    N, M = map(int, input().split())
    LR = []
    for _ in range(M):
        L, R = map(int, input().split())
        LR.append(list(range(L, R + 1)))
    LR = list(itertools.chain.from_iterable(LR))
    C = Counter(LR)

    ans = 0
    for c in C.values():
        if c == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, M = map(int, input().split())
    L = 0
    R = N
    for _ in range(M):
        l, r = map(int, input().split())
        if L < l:
            L = l
        if R > r:
            R = r
    ans = 0
    if L <= R:
        ans = R - L + 1
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    maxi = 0
    for i in range(2 ** N):
        binary = list(map(int, format(i, 'b').zfill(N)))
        ans = 0
        for j, k in enumerate(binary):
            if k == 1:
                ans += V[j] - C[j]
        if ans > maxi:
            maxi = ans

    print(maxi)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    K = [V[i] - C[i] for i in range(N)]
    ans = 0
    for k in K:
        if k > 0:
            ans += k
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    K = [int(input()) for _ in range(5)]
    ans = []
    A = []
    for k in K:
        a = k % 10
        if a == 0:
            ans.append(k)
        else:
            ans.append(k + (10 - a))
            A.append(a)
    print(sum(ans) - (10 - min(A)))


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    K = [int(input()) for _ in range(5)]
    ans = []
    A = [0]
    for k in K:
        a = k % 10
        if a == 0:
            ans.append(k)
        else:
            ans.append(k + (10 - a))
            A.append(10 - a)
    print(sum(ans) - max(A))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1]>H[B-1]):l.append(B-1)
    elif(H[A-1]==H[B-1]):
      l.append(A-1)
      l.append(B-1)
    else:l.append(A-1)
l = list(set(l))
dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
print(len(dellist(H,l)))

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1]>H[B-1]):l.append(B-1)
    elif(H[A-1]==H[B-1]):
      l.append(A-1)
      l.append(B-1)
    else:l.append(A-1)
l = list(set(l))
print(len(H)-len(l))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1]>H[B-1]):l.append(B-1)
    elif(H[A-1]==H[B-1]):
      l.append(A-1)
      l.append(B-1)
    else:l.append(A-1)
l = list(set(l))
dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
print(len(dellist(H,l)))

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1]>H[B-1]):l.append(B-1)
    elif(H[A-1]==H[B-1]):
      l.append(A-1)
      l.append(B-1)
    else:l.append(A-1)
l = list(set(l))
print(len(H)-len(l))
Buggy python submission (verdict: Runtime Error):
N = int(input())
lis = str(input())
a = []
b = []
for pair in itertools.combinations(lis, 3):
    a.append(list(pair))

lis_num = range(len(lis))
for i in itertools.combinations(lis_num, 3):
    b.append(list(i))

count = 0
for i in range(len(a)):
    if (a[i][0]!=a[i][1] and a[i][1]!=a[i][2] and a[i][2] != a[i][0] and b[i][0]!=b[i][1] and b[i][1] != b[i][2]):
        count += 1
print(count)

Fixed submission:
s = str(input())

if(s[0]=='7'): print('Yes')
elif(s[1]=='7'): print('Yes')
elif(s[2]=='7'): print('Yes')
else: print('No')
Buggy python submission (verdict: Runtime Error):
total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            print(total)
            if(total==X): count += 1
                
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            if(total==X): count += 1
                
print(count)
Buggy python submission (verdict: Runtime Error):
def calc_sum_digits(n):
    sumd = 0
    while(n > 1):
        sumd += int(n%10)
        n /= 10
        
    return sumd

N = int(input())
sumd = 0
sumd = calc_sum_digits(N)
if(N%sumd == 0):
     print('yes')
else:
     print('No')

Fixed submission:
def calc_sum_digits(n):
    sumd = 0
    while(int(n) > 0):
        sumd += int(n%10)
        n /= 10
    return sumd

N = int(input())
sumd = calc_sum_digits(N)
if(N%sumd == 0):
     print('Yes')
else:
     print('No')

Buggy python submission (verdict: Runtime Error):
def calc_sum_digits(n):
    sumd = 0
    while(n > 1):
        sumd += int(n%10)
        n /= 10
        
    return sumd
 

 N = int(input())
sumd = 0
 
sumd = calc_sum_digits(N)
if(N%sumd == 0): print('yes')
else: print('No')

Fixed submission:
def calc_sum_digits(n):
    sumd = 0
    while(int(n) > 0):
        sumd += int(n%10)
        n /= 10
    return sumd

N = int(input())
sumd = calc_sum_digits(N)
if(N%sumd == 0):
     print('Yes')
else:
     print('No')

Buggy python submission (verdict: Runtime Error):
def calc_sum_digits(n):
    sumd = 0
    while(n > 1):
        sumd += int(n%10)
        n /= 10
        
    return sumd

N = int(input())
sumd = 0

sumd = calc_sum_digits(N)
if(N%sumd == 0): print('yes')
else: print('No')

Fixed submission:
def calc_sum_digits(n):
    sumd = 0
    while(int(n) > 0):
        sumd += int(n%10)
        n /= 10
    return sumd

N = int(input())
sumd = calc_sum_digits(N)
if(N%sumd == 0):
     print('Yes')
else:
     print('No')
Buggy python submission (verdict: Runtime Error):
lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
k = int(input())
index = 0
while True:
	if len(lun_luns) >= k:
		break
	num = lun_luns.pop(index)
	lun_luns.insert(index, num)
	mod = num % 10
	n = num * 10
	if mod == 9:
		lun_luns.extend([n+mod-1, n+mod])
	else:
		lun_luns.extend([n+mod-1, n+mod, n+mod+1])
	index += 1
print(lun_luns[k-1])

Fixed submission:
x, y, z = map(int, input().split())
a = y
b = x
c = z
a = c
c = y
print(a, b, c)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
x = n
r = 0
pre_x = x
while True:
	if k == 1 or n == 0:
		break
	pre_x = x
	x = abs(x - k)
	if pre_x < x:
		r = pre_x
		break
print(r)

Fixed submission:
n, k = map(int, input().split())
x = n
r = 0
x = n - (n // k) * k
pre_x = x
while True:
	if k == 1 or n == 0:
		break
	pre_x = x
	x = abs(x - k)
	if pre_x < x:
		r = pre_x
		break
print(r)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) if (len(t) > 0) else 0
if count == 0:
	t = ''
else:
	count = count + 1
	t=(t*count)[0:n]
print(t.count('b'))


Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) + 1
t=(t*count)[0:n]
print(t.count('b'))

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'b' * a + 'r' * b
count = int(n/len(t)) + 1 
t=(t*count)[0:n]
print(t.count('r'))

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
t = 'r' * a + 'b' * b
t=(t*n)[0:n]
print(t.count('r'))

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
r = 0
n2 = 0
if n < a:
	r = n
elif a == 0:
	r = 0
else:
	n2 = n
while n2 > 0:
	if (n2 - a < 1):
		r = r + n2
		n2 = 0
		break
	r = r + a
	n2 = n2 - a - b
print(r)

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
r = 0
n2 = 0
if n < a:
	r = n
elif a == 0:
	r = 0
else:
	n2 = n 
while n2 > 0:
	if (n2 - a < 1):
		r = r + n2
		n2 = 0
		break
	else:
		r = r + a
		n2 = n2 - a
	n2 = n2 - b
print(r)

Fixed submission:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)