Problem:


Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
l = []

def append():
    for i in range(a):
        l.append("b")
        if len(l)==n:
            return
    for k in range(b):
        l.append("r")
        if len(l)==n:
            return

append()
if len(l)<n:
    append()


#print(l)
print(l[:n].count('b'))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
l = []

def append():
    for i in range(a):
        l.append("b")
        if len(l)==n:
            return
    for k in range(b):
        l.append("r")
        if len(l)==n:
            return

append()
if len(l)<n:
    append()


#print(l)
print(l.count('b'))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a == 0:
  print(0)
elif a+b <= n:
  print((n//(a+b))*a + n%(a+b))
elif n < a+b and n < a:
  print(n)
elif n < a+b and a <= n:
  print(a)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = n // (a + b)
d = n % (a + b)
if d - a < 0:
    print((c * a) + d)
else:
    print((c * a) + (d - a))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int, input().split())
if A == 0:
    print(0)
else:
    print(N-B)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a == 0:
    print(0)
else:
    print(n - b)

Submission status: Wrong Answer

Solution code:
#26
N,A,B = map(int,input().split())
num = int(N/(A+B))
blue = 0

blue = num*A
blue +=(N-num*(A+B))

print(blue)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = 0
q = n // (a+b)
print(q)
ans += q*a
q = n - (a+b)*q
print(q)
if q - a >= 0:
    ans += a
if q - a < 0:
    ans = ans + a +(q-a)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = 0
q = n // (a+b)
ans += q*a
q = n - (a+b)*q
if q - a >= 0:
    ans += a

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
ans = math.ceil(N * A / (A+B))
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
t=N//(A+B)
s=N%(A+B)
ans = t*A + s
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
n, a, b = map(int, input().split())

cnt = math.ceil(n / (a + b))
cnt2 = cnt * (a + b)
r = cnt2 - n - b

if r < 0:
    print(cnt * a)
else:
    print(cnt * a - r)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x=n//(a+b)
y=n-(a+b)*x
ans=a*x
if y>=(a+b):
    ans+=a
else:
    ans+=y
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print(a*(n//(a+b)))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
#n blue red
#8 3 4
#bbbrrrrb
#4
ans = 0
x = N // (A+B)
ans += (x * A)
N -= x * (A+B)
if N <= A:
  ans += N
else:
  ans += A

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
#n blue red
#8 3 4
#bbbrrrrb
#4
ans = 0
y = A + B
x = N // y
ans += (x * A)
N -= x * y
ans += N
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
#n blue red
#8 3 4
#bbbrrrrb
#4
ans = 0
x = N // (A+B)
ans += (x * A)
N -= x * (A+B)
ans += N
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
#n blue red
#8 3 4
#bbbrrrrb
#4
ans = 0
while N > 0:
  if N >= A:
    ans += A
    N -= (A + B)
  if N < A:
    ans += N
    break
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
#N 13
ball=A+B #3+4=7 BBBRRRR BBBRRR
s=N//ball #1
y=N%ball #1
print(s*A+A)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ball=A+B #3+4=7
s=N//ball #1
y=N%ball #1
print(s*A+y)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
print(A*N//(A+B) + min(A,N%(A+B)))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if(a==0):
  print(0)
  exit()

c = n//(a+b)
d = n%(a+b)
if(c==0):
  print()
elif(d==0):
  print(a*c)
elif(d%a==0):
  print(a*c+(d%a)+a)
else:
  print(a*c+(d%a))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if(a==0):
  print(0)
  exit()

c = n//(a+b)
d = n%(a+b)
if(c==0):
  print()
elif(d==0):
  print(a*c)
else:
  print(a*c+((d+a)%a))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

a = N // (A + B)
mod = N % (A + B)

ans = ( a * A ) + mod
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

a = N // (A + B)
if N % (A+B) != 0:
    a_cnt = ( a * A ) + ( N % (A+B) )
else:
    a_cnt = a * A

print(a_cnt)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

s = a + b
t = n // s
u = n - s
if a < u:
    u = a
print(t * a + u)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
print((N // (A + B)) * A + N - (A + B) * (N // (A + B)))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if a == 0:
    print(0)
elif n >= a + b:
    print(a * (n // (a + b)) + n % (a + b))
else:
    if n < a:
        print(n)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if a == 0:
    print(0)
elif n >= a + b:
    print(a * n // (a + b) + n % (a + b))
else:
    if n < a:
        print(n)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if a == 0:
    print(0)
elif n >= a + b:
    print(a + n // (a + b))
else:
    if n < a:
        print(n)
    else:
        print(a)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())

S = A+B

x = N//S
y = N%S

print(x*A+y)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())

if n%(a + b) == 0:
  ans = (n//(a + b)) * a 
else:
  ans = (n//(a + b)) * a + n % (a + b)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

x, mod = divmod(n, a + b)

if x == 0:
    print(min(a, n))
else:
    print(a * x + mod)

Submission status: Wrong Answer

Solution code:
import math

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

x, mod = divmod(n, a + b)

print(a * x + mod)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())

loop = N//(A+B)

remain = N - loop*(A+B)

if remain <= A:
    remain = remain
else:
    remain = A

print("loop=",loop)
print("remain=",remain)

print(loop*A+remain)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
count = 0
total = 0
while total+(A+B) <= N:
  total += (A+B)
  count += A

if total<N:
  count += (N-total)
print(count)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())

if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print(answer*a+remainder)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int, input().split())
if A == 0:
    print(0)
    exit

c = A+B
size = N//c
least = N%c
ans = size * A + min(A, least)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(n):
 for b in range(a):
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
lis=""
ans=0
for i in range(n):
 for b in range(a):
  lis+='b'
  ans+=1
 for r in range(b+1):
  lis+='r'
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
lis=""
for i in range(n):
 for b in range(a):
  lis+='b'
 for r in range(b+1):
  lis+='r'
print(lis.count('b'))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
lis=[]
for i in range(n):
 for b in range(a):
  lis.append('b')
 for r in range(b+1):
  lis.append('r')
print(lis.count('b'))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())

if N<A:
    balls=N
elif N<A+B:
    balls=A
else:
    div=N%(A+B)
    if div==0:
        balls=N*(A/(A+B))
    else:
        if div>A:
            balls=(N-div)*(A/(A+B))+A
        else:
            balls=(N-div)*(A/(A+B))+div

print(int(balls))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a + b == n:
  print(a)
elif a == 0:
  print(0)
elif (n - b) >= a:
  print(a)
else:
  print(n - b)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a + b == n:
  print(a)
elif a == 0:
  print(0)
else:
  print(n - b)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

total = N//(A + B)*B + max(0, N%(A+B)-A)
print(total)

Submission status: Wrong Answer

Solution code:
n, b, r = map(int, input().split())
s = 0
while(n != 0):
    if n >=b:
        n -= b
        s += b
    else:
        s += n
    if n >= r:
        n -= r
    else:
        break
print(s)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=a+b
print(n//c*a+n%c)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=a+b
print(n*a//c+n%c)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
tmp = 0
tmp = N // (A + B) * A
print(tmp + min(N - (A + B), A))

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B = [int(i) for i in input().split()]
    d, m = divmod(N, (A + B))
    print(d * A + m)


resolve()

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
print(N//(A+B)+min(N%(A+B), A))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())

if n >= (a + b):
    print(a + min(n%(a + b),a))
else:
    n -= (a + b)
    print(a + n//(a + b)*a + min(n%(a + b),a))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())

cnt_blue = 0

try:
    pre_loop_cnt = N // (A+B)
    totol_pre_A = sum([A] * pre_loop_cnt)
    totol_pre_B = sum([B] * pre_loop_cnt)

    total_tmp = totol_pre_A + totol_pre_B
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  totol_pre_B
    else:
        cnt_blue = totol_pre_A + A
    print(cnt_blue)
except:
    print(0)

Submission status: Wrong Answer

Solution code:
import math
def main():
  n, a, b = map(int, input().split())
  total = 0
  
  if n <= a + b:
    print(int(n - b))
  else:
    x = math.floor(n / (a+b))
    total = a * x
    y = n % (a+b)
    if y >= a:
      total += a
    else:
      total += y
      
      
  print(total)
  
  
main()

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if A !=0:
    print(N-B)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys

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

if a == 0:
  print(0)
  sys.exit()

set_n = int(n / (a + b))
amari_n = int(n % (a + b))

ans = set_n * a + amari_n

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = a+b
if n%c <= a:
    ans = a * (n//c) + n%c
else:
    ans = a *(n//c)
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
sho = N //(A+B)
amari = N % (A+B)
print(sho*A+amari)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
q = n // (a + b)
r = n % (a + b)

print(q*a + r)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int,input().split())
ans = math.ceil(n*(a/(a+b)))
print(ans)

Submission status: Wrong Answer

Solution code:
N, b, r = map(int, input().split())

s = 0
t = 0
for i in range(1000):
    t = t+b+r
    s += 1
    if N<=t:
        if (t-N)<r:
            print(s*b)
            exit()
        else:
            print((s-1)*b+N-t+b+r)
            exit()

Submission status: Wrong Answer

Solution code:
N,A,B = (int(a) for a in input().split())
ans = 0
while N > 0 :
    if N > A :
        ans += A
        N -= A
    else : 
        ans += N
    if N > B :
        N -= B
    else :
        N = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
p = n // (a+b)
ans = a*b + min(a,(n%(a + b)))
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = n//(a+b)
if n%(a+b) >= b:
    print((c*a)+a)
else:
    print((c*a)+n%(a+b))

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))

blue=True
s=''
length = N
while length>0:
    if blue:
        for i in range(A):
            if len(s)<N:
                s+='b'
        length = length - A
        blue = False
    else:
        for i in range(B):
            if len(s)<N:
                s+='r'
        length = length - B
        blue = True
print(s)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
C = A+B

if N%C==0:
    ans = int((N/C)*A)
    print(ans)

else:
    tmp = (N//C)*A
    add = 0
    if N%C<A:
        add = int(N%C)
    else:
        add = A
    ans = tmp+add
    print(ans)

Submission status: Wrong Answer

Solution code:
#inport
import sys
import numpy as np
#import itertools as itlt
#from collections import deque

#input 
N,A,B = [int(x) for x in sys.stdin.readline().split()]

num = np.floor(N/(A+B))*A
if N%(A+B)>=A:
    num = num + A
else:
    num = num + N%(A+B)

print(int(num))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
count=N//(A+B)
print(A*count+N-(A*count+B*count))

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())

t = n % (b + r)

if t >= b: print(b)
else: print(t)

Submission status: Wrong Answer

Solution code:
n,b,r= map(int,input().split())
if b==0 and r==0:
  print(n)
elif b==0:
  print(0)
else:
  print(n-r)

Submission status: Wrong Answer

Solution code:
n,b,r= map(int,input().split())
if b==0:
  print(0)
else:
  print(n-r)

Submission status: Wrong Answer

Solution code:
R=[]
cont=0
n,a,b= map(int,input().split())
for i in range(a):
  R.append('b')
for i in range(b):
  R.append('r')
while len(R)<n:
  R.append('b')
for i in range(n):
  if R[i]=='b':
    cont+=1
print(cont)

Submission status: Wrong Answer

Solution code:
n,a,b= map(int,input().split())
if a!=0:
  print(a+(n-a-b))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
A=n//(a+b)
print(a*A+min(a,A))

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < n else a
    print(q*a+x)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < n else n
    print(q*a+x)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
#x=n//(a+b)
#y=n%(a+b)
if n%(a+b) < a: print(a*n//(a+b)+n%(a+b))
else: print(a*(n//(a+b)+1))

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
#if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
#else: print((n//(b+r))*(b+1))
ans = n//(b+r)*b
re = n%(b+r)
ans += min(re, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
#if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
#else: print((n//(b+r))*(b+1))
ans = (n//(b+r))*b
re = n%(b+r)
ans += min(re, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
#if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
#else: print((n//(b+r))*(b+1))
ans = n//(b+r)+b
re = n%(b+r)
ans += min(re, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
else: print((n//(b+r))*(b+1))

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
if (n%(b+r))==0: print((n//(b+r))*b)
elif (n%(b+r)) <= b: print((n//(b+r))*b+(n%(b+r)))
else: print((n//(b+r))*(b+1))

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
if (n%(b+r))==0: print((n//(b+r))*b)
elif (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
else: print((n//(b+r))*(b+1))

Submission status: Wrong Answer

Solution code:
z=[]
n, a, b= map(int,input().split())
for i in range(0,a):
    z.append('b')
for i in range(0,b):
    z.append('r')
if len(z)<n:
    for i in range(0,(n-len(z))):
        z.append('b')
    
print(z.count('b'))

Submission status: Wrong Answer

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n, a, b = map(int, input().split())

amari = n%(a+b)
if (amari > a) :
    amari = a

b = int(a*n/(a+b))

print(b+amari)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

cnt = 0
ans = 0
while cnt+A < N:
  cnt += A+B
  ans += A
  
if A == 0:
  ans = 0
  
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

ans = (N//(A+B)) * A + (N%(A+B))
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
print(a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
s = a + b
ans = 0

if a == 0:
    print(ans)
    exit()
elif b == 0:
    print(n)
    exit()

if n <= s:
    ans = a
else:
    d = n % s
    if d == 0:
        ans += n // s * a
    elif d >= a:
        ans += (n // s * a) + a
    else:
        ans += (n // s * a) + d

print(ans)

Submission status: Wrong Answer

Solution code:

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

num1 = n // (a + b) * a
num2 = n % (a + b)

if num2 < a:
    print(num1 + num2)
else:
    print(num1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

num1 = n // (a + b) * a
num2 = n % (a + b)

if num2 <= a:
    print(num1 + num2)
else:
    print(num1)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())


a=(N//(A+B))
b=N%(A+B)
print(a*A+b)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
print((n//(a+b))*a + n%(a+b))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
print((n//(a+b))*a + max(0,n%(a+b)-b))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if A > 0 and B > 0:
    A = A * (N // (A + B)) + N % (A + B)
    print(A)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
A = A * (N // (A + B)) + N % (A + B)
print(A)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if A > 0:
    if N - A <= 0:
        print(N)
    elif N - (A + B) <= 0:
        print(A)
    else:
        C = N // (A + B)
        C = C * A + N % (A + B)
        print(C) 
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if N - (A + B) <= 0:
    print(A)
else:
    C = N // (A + B)
    if A > 0:
        C = C * A + N % (A + B)
        print(C) 
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
C = 0
while True:
    if N <= 0:
        break
    if A > 0:
        if N - A <= 0:
            print(N)
            break
        else:
            C = C + A
            N = N - A  
    else:
        print(0)
        break
    N = N - B
print(C)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
N = N - B
if N - A >= 0 and A > 0:
    print(N)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#

import sys
from decimal import Decimal
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    N=Decimal(N)
    A=Decimal(A)
    B=Decimal(B)
    if N%(A+B)<=A:
        print(A*N//(A+B)+N%(A+B))
    else:
        print(A*N//(A+B)+A)
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    if N%(A+B)<=A:
        print(int(A*N//(A+B)+N%(A+B)))
    else:
        print(int(A*N//(A+B)+A))
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    if N%(A+B)<=A:
        print(A*N//(A+B)+N%(A+B))
    else:
        print(A*N//(A+B)+A)
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
hoge = n // (a+b)
hoge1 = n % (a+b)
if hoge1 <= 4:
    print(hoge*a + hoge1)
else:
    print(hoge*a + 4)

Submission status: Wrong Answer

Solution code:
n,b,r = map(int,input().split())

if b == 0:
    print(0)
elif r == 0:
    print(n)
else:
    d = b + r
    c = d // n * b
    if d % n == 0:
        print(c)
    else:
        if d % n < b:
            print(c + (d % n))
        else:
            print(c + b)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
k=0
l=0

if a <= 0 and b <= 0:
    print("0")
    exit()

if a >= n:
    k = a - (a - n)
elif a < n:
    k = a * (n // (a+b))
    l = n % (a + b)

print(k + l)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
k=0
l=0

if a >= n:
    k = a - (a - n)
elif a < n:
    k = a * (n // (a+b))
    l = n % (a + b)

print(k + l)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())

if a >= n:
    k = a -n
elif a < n:
    k = a * (n // (a+b))

l = n % (a+b)

print(k + l)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())

k = a * (n // (a+b))
l = n % (a+b)

print(k + l)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n//(a+b)<=a:
  print((n//(a+b))*a+ n % (a+b))
else:
  print((n//(a+b))*a+ a)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())

ans=0

times=N//(A+B)
rest=N%(A+B)

ans=times*A
if rest>A:
  a=A
else:
  a=rest

print(ans+rest)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
tmp = n // (a+b)
print((tmp*a)+(n-(tmp*(a+b))))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = n // (a+b)
ans = a * c
d = n % (a+b)
if 0 < d <= a:
    print(ans+d)
else:
    print(ans+a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

ans = 0

x = n % (a + b)
y = n - (a + b) * x

ans = x * a + min(y, a)

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

b_count = n // (a+b) 
print('b_count', b_count)
if (n-(a+b)*b_count) <= a:
    print(n-b*b_count)
else:
    print(a*b_count + a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

b_count = n // (a+b) 

if (n-(a+b)*b_count) <= a:
    print(n-b*b_count)
else:
    print(n-b*b_count + a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

b_count = n // (a+b) 

print(n-b*b_count)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

b_count = n // (a+b) 
print('b_count', b_count)
print('answer',n-b*b_count)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

b_count = n // (a+b) 
print(n-(a+b)*b_count + a*b_count)

Submission status: Wrong Answer

Solution code:
import math


def actual(n, a, b):
    x, y = divmod(n, (a + b))
    return a * x + y

n, a, b = map(int, input().split())
print(actual(n, a, b))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*b + [b,q][q<b])

Submission status: Wrong Answer

Solution code:
def solve():
    N,A,B = map(int, input().split())
    x,y = divmod(N, A+B)
    if y>B:
        y = A
    print(A*x + y)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

ans=n//(a+n)*a
rem=n%(a+b)
ans+=min(rem,a)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
if a==0:
  print(0)
if b==0:
  print(n)
  
sum=0
L=n//(a+b)
M=n%(a+b)

if a<=M:
  print(a*L+a)
else:
  print(a*L+M)

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
if a==0:
  print(0)
if b==0:
  print(n)
  
sum=0
ball=[]
r_ball=["r" for i in range(a)]
b_ball=["b" for i in range(b)]
while sum<n:
  ball=ball+r_ball
  ball=ball+b_ball
  sum=sum+a+b
print(ball[:n].count("b"))

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
sum=0
ball=[]
while sum<n:
  ball=ball+["r" for i in range(a)]
  ball=ball+["b" for i in range(b)]
  sum=sum+a+b
print(ball[:n].count("b"))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=[]
for i in range(A):
    a.append("x")
for j in range(B):
    a.append("y")
    if len(a) >= N:
        ans=a[:N]
        print(ans.count("x"))
        exit()

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=[]
while len(a) < N:
    for i in range(A):
        a.append("x")
    for j in range(B):
        a.append("y")
        break
ans=a[:N]
print(ans.count("x"))

Submission status: Wrong Answer

Solution code:
import math
N, a, b = map(int, input().split())

if N < b:
    print(N)
elif N < a + b:
    print(b)
else:
    times = math.floor(N / (a + b))
    amari = N % (a + b)
    no_blue = a * times + amari
    print(no_blue)

Submission status: Wrong Answer

Solution code:
N, a, b = map(int, input().split())

times = int(N / (a + b))
amari = N % (a + b)

no_blue = a * times + amari

print(no_blue)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

x = n // (a + b) * a
k = n % (a + b)
if k <= a:
    print(n + k)
else:
    print(n + a)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A == 0:
        print(0)
        return

    ans = 0
    times = N // (A + B)
    if times >= 1:
        ans += times * A
        ans += N - (times * (A + B))
    else:
        ans = A
    print(ans)
    return


# Generated by 1.1.7.1 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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())

t = N%(A+B)

if t > A:
    print(N//(A+B)*A)
else:
    print(N//(A+B)*A+t)

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int, input().split()))
print(N//(A+B)*A + min(N%(A+B), B))

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())
    AB = A + B

    q, r = divmod(N, AB)
    print(A * q + r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print((n//(a+b))*a+(n%(a+b)))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
print(min((N//(A+B))*A + N-(N//(A+B)), (N//(A+B))*A + A))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
x = n // (a+b)
y = n % (a+b)
if n < a+b:
    if n < a:
        print(n)
    else:
        print(a)
else:
    print(a*x + y)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
x = n // (a+b)
y = n % (a+b)
print(a*x + y)

Submission status: Wrong Answer

Solution code:
N, A, B = (int(x) for x in input().split())

X = A * (N // (A+B))
Y = N % (A+B)

print(X + Y)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
M = int(N / (A + B))
L = N % (A + B)
print(A * M + L)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=a+b
print((n//c)*a+n%c)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=0
while n>=a and n>0:
    c+=a
    n=n-a-b
    if n<a:
        break
    else:
        continue
print(c)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=0
while n>=a:
    n-=a
    c+=a
    n-=b
    if n<=0:
        break
    else:
        continue
print(n+c)

Submission status: Wrong Answer

Solution code:
N, A, B=map(int, input().split())
ans=(N//(A+B))*B
if N%(A+B)>A:
  ans+=N%(A+B)-A
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B=map(int, input().split())
ans=(N//(A+B))*B+N%(A+B)-A
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B=map(int, input().split())
ans=N//(A+B)+N%(A+B)-A
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input(). split())
blue = 0
red = 0
s = 0
while s < n:
  blue += a
  s += a
  if s < n:
    red += b
    s += b
if s%(a+b) == 0:
  ans = blue 
else:
  ans = blue - (s - n)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,A,B=pin()
    C=A+B
    n=N%C
    m=N//C
    ans=A*m
    if n<=B:
        ans+=n
    else:
        ans+=A
    print(ans)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if a == 0:
    print(0)
    exit()

ans = a*n//(a+b) + min(a, n%(a+b))
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
n = N//(A+B)
m = N%(A+B)
k = max(0,m-A)
print(n*B+k)

Submission status: Wrong Answer

Solution code:
def resolve():
  n, a, b = map(int, input().split())
  ans = (n // (a + b)) * a
  ans += min(b, n % (a+b))
  print(ans)
  return

if __name__ == "__main__":
  resolve()