Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))

d.sort()
c = [0]
j = 0
for i in range(1, max(d)):
	tmp = 0
	 while d[j] == i:
	 	tmp += 1
	 	j += 1
	 c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)

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

dd = sorted(d)
c = []
j = 0
for i in range(max(d)+1):
	tmp = 0
	while dd[j] == i:
		tmp += 1
		j += 1
		if j == n:
			break
	c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))

x = []
for i in range(max(d)+1):
	x.append(d.count(i))
ans = 1
if d[0] == 0 and x[0] == 1:
	for i in range(1, len(x)-1):
		ans = ans * (x[i]**x[i+1])
else:
	ans = 0

print(ans%998244353)

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

dd = sorted(d)
c = []
j = 0
for i in range(max(d)+1):
	tmp = 0
	while dd[j] == i:
		tmp += 1
		j += 1
		if j == n:
			break
	c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))

for i in range(max(d)+1):
	x.append(d.count(i))
ans = 1
if d[0] == 0 and x[0] == 1:
	for i in range(1, len(x)):
		ans = ans * (x[i]**x[i+1])
else:
	ans = 0

print(ans%998244353)

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

dd = sorted(d)
c = []
j = 0
for i in range(max(d)+1):
	tmp = 0
	while dd[j] == i:
		tmp += 1
		j += 1
		if j == n:
			break
	c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))


ans = 1
if d[0] == 0 and d.count(0) == 1:
	for i in range(1, max(d)):
		x = d.count(i)
		ans = ans * (x**(d.count(i+1)))
else:
	ans = 0

print(ans%998244353)

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

dd = sorted(d)
c = []
j = 0
for i in range(max(d)+1):
	tmp = 0
	while dd[j] == i:
		tmp += 1
		j += 1
		if j == n:
			break
	c.append(tmp)

ans = 1
if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0:
	for i in range(1, max(d)):
		ans = ans * (c[i]**c[i+1])
else:
	ans = 0

print(ans%998244353)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

ans = ""
for i in range(1, n+1):
	ans = ans + str(a.index(i)+1) + " "

print(ans.rstrip())


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

ans = []
for i in range(1, n+1):
	ans.append("")

for i in range(n):
	tmp = i + 1
	ans[a[i]-1] = str(tmp)
	
print(' '.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

ans = []
for i in range(1, n+1):
	ans.append(str(a.index(i)+1))
	
print(' '.join(ans))


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

ans = []
for i in range(1, n+1):
	ans.append("")

for i in range(n):
	tmp = i + 1
	ans[a[i]-1] = str(tmp)
	
print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = []
while m <= n - 2:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))


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

m = 0
ans  = [0]
while m <= n - 3:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = []
while m < n - 2:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))


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

m = 0
ans  = [0]
while m <= n - 3:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = []
while m < n - 1:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))


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

m = 0
ans  = [0]
while m <= n - 3:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
	s.append(sorted(input()))
	

ans = 0
for i in range(n-1):
	for j in range(i+1, n):
		if s[i] == s[j]:
			ans += 1

print(ans)

Fixed submission:
n = int(input())
st = {}
sv = {}
for i in range(n):
	tmp = "".join(sorted(input()))
	if tmp in st.keys():
		sv[tmp] += st[tmp]
		st[tmp] += 1
	else:
		st[tmp] = 1
		sv[tmp] = 0


print(sum(sv.values()))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
	s.append("".join(sorted(input())))
	

ans = 0
for i in range(n-1):
	for j in range(i+1, n):
		if s[i] == s[j]:
			ans += 1

print(ans)


Fixed submission:
n = int(input())
st = {}
sv = {}
for i in range(n):
	tmp = "".join(sorted(input()))
	if tmp in st.keys():
		sv[tmp] += st[tmp]
		st[tmp] += 1
	else:
		st[tmp] = 1
		sv[tmp] = 0


print(sum(sv.values()))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()

a = a.split()


for i in range(n):
	a[i] = int(a[i])
	
a = a.reverse()

alice = int(a[0])
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + int(a[i])
	else:
		bob = bob + int(a[i])
	
print(alice - bob)


Fixed submission:
n = int(input())
a = input()

a = a.split()


for i in range(n):
	a[i] = int(a[i])

a	= sorted(a)
a.reverse()

alice = a[0]
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + a[i]
	else:
		bob = bob + a[i]
	
print(alice - bob)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()

a = a.split()

alice = 0
bob = 0
ans = 0

for i in range(n):
	a[i] = int(a[i])

a = a.reverse()

for i in range(n):
	if i%2 == 0:
		alice = alice + int(a[i])
	else:
		bob = bob + int(a[i])
	
print(alice - bob)

Fixed submission:
n = int(input())
a = input()

a = a.split()


for i in range(n):
	a[i] = int(a[i])

a	= sorted(a)
a.reverse()

alice = a[0]
bob = 0
for i in range(1, n):
	if i%2 == 0:
		alice = alice + a[i]
	else:
		bob = bob + a[i]
	
print(alice - bob)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())


if a*b%2 == 0:
	print('Even')
else:
	print('Odd')

Fixed submission:
ab = input()
ab = ab.split()

a = int(ab[0])
b = int(ab[1])



if a*b%2 == 0:
	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
nk = list(map(int,input().split()))
a = list(map(int,input().split()))

sa = list(set(a))

if len(sa) > nk[1]:
	c = []
	for i in range(len(sa)):
		c.append(a.count(sa[i]))
		
	sortc = sorted(c, reverse = True)
	m = 0
	for i in range(nk[1]):
		m += sortc[i]
	ans = nk[0] - m
else:
	ans = 0

print(ans)


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

cli = []
for i in range(nk[0]+1):
	cli.append(0)

for i in range(nk[0]):
	cli[a[i]] += 1

c = sorted(cli, reverse = True)

m = 0
for i in range(nk[1]):
	m += c[i]

ans = nk[0] - m
if ans < 0:
	ans = 0
	
print(ans)

Buggy python submission (verdict: Runtime Error):
nk = list(map(int,input().split()))
a = list(map(int,input().split()))


sa = list(set(a))

if len(sa) > nk[1]:
	c = []
	for i in range(len(sa)):
		c.append(a.count(sa[i]))
		
	sortc = sorted(c, reverse = True)
	for i in range(nk[1]):
		m += sc[i]
	ans = n - m
else:
	ans = 0

print(ans)


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

cli = []
for i in range(nk[0]+1):
	cli.append(0)

for i in range(nk[0]):
	cli[a[i]] += 1

c = sorted(cli, reverse = True)

m = 0
for i in range(nk[1]):
	m += c[i]

ans = nk[0] - m
if ans < 0:
	ans = 0
	
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
nk = list(map(int,input().split()))
a = list(map(int,input().split()))

sa = list(set(a))

if len(sa) > nk[1]:
	c = []
	for i in range(len(sa)):
		c.append(a.count(sa[i]))
		
	sc = sorted(c)
	ans = 0
	for i in range(len(sa)-nk[1]):
		ans += sc[i]
else:
	ans = 0

print(ans)


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

cli = []
for i in range(nk[0]+1):
	cli.append(0)

for i in range(nk[0]):
	cli[a[i]] += 1

c = sorted(cli, reverse = True)

m = 0
for i in range(nk[1]):
	m += c[i]

ans = nk[0] - m
if ans < 0:
	ans = 0
	
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ab = []
ans = []
for i in range(1, int(n**(0.5))):
	ab.clear()
	if n%i == 0:
		ab.append(i)
		ab.append(int(n/i))
		ans.append(len(str(max(ab))))
			

print(min(ans))


Fixed submission:
n = int(input())

ab = []
ans = []
for i in range(1, int(n**(0.5))+1):
	ab.clear()
	if n%i == 0:
		ab.append(i)
		ab.append(int(n/i))
		ans.append(len(str(max(ab))))
			
if len(ans) == 0:
	ans.append(1)

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):	
			if x + y + z == s:
				ans += 1
				break
		
print(ans)

Fixed submission:
ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
			tmp = s - (x + y)
			if tmp  <= k and tmp >= 0:
				ans += 1
		
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):	
			if x + y + z == s:
				ans += 1
		
print(ans)

Fixed submission:
ks = input().split()

k = int(ks[0])
s = int(ks[1])

ans = 0

for x in range(k+1):
	for y in range(k+1):
			tmp = s - (x + y)
			if tmp  <= k and tmp >= 0:
				ans += 1
		
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_counter < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_counter < counter:
  max_count = counter

print(max_counter)


Fixed submission:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)

Buggy python submission (verdict: Runtime Error):
S = input()
counter = 0
for i in S:
  if i == 'S':
    counter = 0
  elif i == 'R':
    counter += 1

return counter


Fixed submission:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)

Buggy python submission (verdict: Runtime Error):
counter = 0
for i in S:
  if i == 'S':
    counter = 0
  elif i == 'R':
    counter += 1

return counter


Fixed submission:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)

Buggy python submission (verdict: Runtime Error):
counter = 0
for i in S:
	if i == 'S':
		counter = 0
	elif i == 'R':
      	counter += 1

return counter


Fixed submission:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)

Buggy python submission (verdict: Runtime Error):
counter = 0
for i in S:
	if i == 'S':
		counter = 0
	elif i == 'R':
      	counter += 1

print(counter)

Fixed submission:
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = str(input())
red = 0
blue = 0
if "R" in s:
    red += 1
elif "B" in s:
    blue += 1

if red > blue:
    print("Yes")
elif red == blue or red < blue:
    print("No")


Fixed submission:
A,B,C = map(int, input().split())
if A == B == C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

a,b,h,m = map(int,input().split())

hangle = float((h/12)*360)
hangle += float((m/60)*30)
mangle = float((m/60)*360)

if hangle > 180 and mangle > 180:
    angle = abs(hangle-mangle)
elif hangle > 180:
    hangle = 360-hangle
    angle = abs(hangle-mangle)
elif mangle > 180:
    mangle = 360-mangle
    angle = abs(hangle-mangle)
else:
    angle = abs(hangle-mangle)

if hangle > 180:
    hangle = 360-hangle
if mangle > 180:
    mangle = 360-mangle

angle = abs(hangle-mangle)
rad = math.radians(angle)

ans = float(math.sqrt(a*a + b*b - float(2*a*b*math.cos(rad))))

if m != 0 and h != 0:
    print('{:.10f}'.format(ans))
else :
    print(0)

Fixed submission:
n = int(input())

if n >= 100:
    n = n%100
    if n >= 10:
        n = n%10
    if n == 3:
        print("bon")
    elif n == 0 or n == 1 or n == 6 or n == 8:
        print("pon")
    else:
        print("hon")
elif n <= 99 and n >= 10:
    n = n%10
    if n == 3:
        print("bon")
    elif n == 0 or n == 1 or n == 6 or n == 8:
        print("pon")
    else:
        print("hon")
else:
    if n == 3:
        print("bon")
    elif n == 0 or n == 1 or n == 6 or n == 8:
        print("pon")
    else:
        print("hon")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))

a = [list(map(int,input().split())) for i in range(m)]

ans = []

for i in range(m):
    if h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(h[a[i][1]-1])
    else:
        if ans.index(h[a[i][0]-1]):
            ans.remove(h[a[i][0]-1])
        ans.append(h[a[i][0]-1])
    
ans = set(ans)

print(len(ans))

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

a = [list(map(int,input().split())) for i in range(m)]

ans = []

for i in range(m):
    if h[a[i][0]-1] > h[a[i][1]-1]:
        ans.append(a[i][1])
    elif h[a[i][0]-1] < h[a[i][1]-1]:
        ans.append(a[i][0])
    if h[a[i][0]-1] == h[a[i][1]-1]:
        ans.append(a[i][0])
        ans.append(a[i][1])
        

ans = set(ans)

print(int(len(h)) - int(len(ans)))
#2,3,5

1,4,4
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())

max1 = (a*2)//b - a*(2//b)
max2 = (a*(n//2))//b - a*((n//2)//b)


for i in range(2,n//2):
    if (a*i)//b - a*(i//b) >= max1:
        max1 = (a*i)//b - a*(i//b)

for i in range(n//2,n+1):
    if (a*i)//b - a*(i//b) >= max2:
        max2 = (a*i)//b - a*(i//b)

if max1 > max2:
    print(max1)
else:
    print(max2)

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

if n >= b-1:
    x = b-1
else:
    x = n

ans = (a*x)//b - a*(x//b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())

max = (a*2)//b - a*(2//b)

for i in range(2,n+1):
    if (a*i)//b - a*(i//b) >= max:
        max = (a*i)//b - a*(i//b)

print(max)

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

if n >= b-1:
    x = b-1
else:
    x = n

ans = (a*x)//b - a*(x//b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

s = list(s)

count = 0

for i in range(0,len(s)):
    for j in range(i,len(s)):
        for k in range(j,len(s)):
            if(j-i != k-j) and (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]):
                count += 1


print(count)


Fixed submission:
n = int(input())
s = input()

s = list(s)

k = r = b = g = count = 0

for i in range(len(s)):
    for j in range(i+1,len(s)):
        k = 2*j-i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            count += 1    

rbg = s.count("R")*s.count("B")*s.count("G")

print(rbg-count)

Buggy python submission (verdict: Runtime Error):
n,s = input().split()
s = list(s)

count = 0

for i in range(0,len(s)):
    for j in range(i,len(s)):
        for k in range(j,len(s)):
            if(j-i != k-j) and (s[i] != s[j] and s[i] != s[k] and s[j] != s[k]):
                count += 1


print(count)


Fixed submission:
n = int(input())
s = input()

s = list(s)

k = r = b = g = count = 0

for i in range(len(s)):
    for j in range(i+1,len(s)):
        k = 2*j-i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            count += 1    

rbg = s.count("R")*s.count("B")*s.count("G")

print(rbg-count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

b = []
total = 0

for i in range(n):
    b.append(0)

for i in range(n):
    b[a[i]-1] += 1

for i in range(n):
    b[a[i]-1] -= 1
    for j in range(n):
        if b[j] >= 2:
            total += b[j]*(b[j]-1)//2
    print(total)
    total = 0
    b[a[i]-1] += 1


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

b = []
total = 0

for i in range(n):
    b.append(0)

for i in range(n):
    b[a[i]-1] += 1
for i in range(n):
    if b[i] >= 2:   
        total += b[i]*(b[i]-1)//2



for i in range(n):
    ans = total
    ans -= b[a[i]-1]*(b[a[i]-1]-1)//2
    b[a[i]-1] -= 1
    ans += b[a[i]-1]*(b[a[i]-1]-1)//2
    print(ans)
    b[a[i]-1] += 1

Buggy python submission (verdict: Runtime Error):
import math

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

b = []
total = 0

for i in range(n):
    b.append(0)

for i in range(n):
    b[a[i]] += 1

for i in range(n):
    b[a[i]] -=1
    for j in range(n):
        if b[j] >= 2:
            total += b[j]*(b[j]-1)//2
    print(total)
    total = 0
    b[a[i]] += 1

#for i in range(n):
 #   print(b[i])


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

b = []
total = 0

for i in range(n):
    b.append(0)

for i in range(n):
    b[a[i]-1] += 1
for i in range(n):
    if b[i] >= 2:   
        total += b[i]*(b[i]-1)//2



for i in range(n):
    ans = total
    ans -= b[a[i]-1]*(b[a[i]-1]-1)//2
    b[a[i]-1] -= 1
    ans += b[a[i]-1]*(b[a[i]-1]-1)//2
    print(ans)
    b[a[i]-1] += 1
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

sum = n//(a+b)*a
res = n%(a*b)
sum += min(res,a)

print(sum)

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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())


sum = 0
while(n > a):
    n = n-a-b
    sum += a
if n < 0:
    print(sum)
else:    
    print(sum+n)


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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

 n//(a+b)

sum = 0
if n >= a:
    while(n > a):
        n = n-a-b
        sum += a
    print(sum+n)
else:
    print(n)

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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

sum = 0
if n >= a:
    while(n > a):
        n = n-a-b
        sum += a
print(sum+n)
else:
    print(a)

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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())

sum = 0

while(n > a):
    n = n-a-b
    sum += a

print(sum+n)

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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())

inn = []
jun = 0

for i in range(q):
    inn = list(input().split())
    if inn[0] == "1":
        if jun == 0:
            jun = 1
        else:
            jun = 0#jun = 0はそのまま　jun = 1は逆をする
    elif inn[0] == "2":
        if inn[1] == "1" and jun == 0:
            s.insert(0,inn[2])
        elif inn[1] == "2" and jun == 0:
            s.append(inn[2])
        if inn[1] == "1" and jun == 1:
            s.append(inn[2])
        elif inn[1] == "2" and jun == 1:
            s.insert(0,inn[2])
        
if jun == 0:
    news = ''.join(s)
else:
    s = s[::-1]
    news = ''.join(s)

print(news)
               

Fixed submission:
import collections

s = list(input())
q = int(input())

s2 = collections.deque(s)

inn = []
jun = 0

for i in range(q):
    inn = list(input().split())
    if inn[0] == "1":
        if jun == 0:
            jun = 1
        else:
            jun = 0#jun = 0はそのまま　jun = 1は逆をする
    elif inn[0] == "2":
        if inn[1] == "1" and jun == 0:
            s2.appendleft(inn[2])
        elif inn[1] == "2" and jun == 0:
            s2.append(inn[2])
        if inn[1] == "1" and jun == 1:
            s2.append(inn[2])
        elif inn[1] == "2" and jun == 1:
            s2.appendleft(inn[2])
    
if jun == 0:
    news = ''.join(s2)
else:
    s2.reverse()
    news = ''.join(s2)

print(news)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())

inn = []

for i in range(q):
    inn = list(input().split())
    if inn[0] == "1":
        s = s[::-1]
    elif inn[0] == "2":
        if inn[1] == "1":
            s.insert(0,inn[2])
        elif inn[1] == "2":
            s.append(inn[2])

news = ''.join(s)
    
print(news)
               

Fixed submission:
import collections

s = list(input())
q = int(input())

s2 = collections.deque(s)

inn = []
jun = 0

for i in range(q):
    inn = list(input().split())
    if inn[0] == "1":
        if jun == 0:
            jun = 1
        else:
            jun = 0#jun = 0はそのまま　jun = 1は逆をする
    elif inn[0] == "2":
        if inn[1] == "1" and jun == 0:
            s2.appendleft(inn[2])
        elif inn[1] == "2" and jun == 0:
            s2.append(inn[2])
        if inn[1] == "1" and jun == 1:
            s2.append(inn[2])
        elif inn[1] == "2" and jun == 1:
            s2.appendleft(inn[2])
    
if jun == 0:
    news = ''.join(s2)
else:
    s2.reverse()
    news = ''.join(s2)

print(news)