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.

Solution (Python):
import sys
n, a, b = map(int, input().split())

if n < a:
  print(n)
  sys.exit()

c = n // (a+b)
n -= c * (a + b)

print(a * c + min(n, a))

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

Solution (Python):
def main():
    n,a,b=map(int,input().split())
    k=n//(a+b)
    print(a*k+min(n%(a+b),a))
main()

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

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

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

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

if N % (A+B) > A:
    left = A
else:
    left = N % (A+B)
ans = (N // (A+B)) * A + left
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,A,B = MI()
	ans = (N//(A+B))*A
	tmp = N%(A+B)
	if(tmp>A):
		ans += A
	else:
		ans+= tmp

	print(ans)

if __name__ == '__main__':
	main()

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

set_num = n // (a + b)
amari = n % (a + b)

if amari > a:
    ans = set_num * a + a
else:
    ans = set_num * a + amari

print(ans)

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

x=N//(A+B)
y=N%(A+B)

if y<=A:
    ans=x*A+y
else:
    ans=x*A+A

print(ans)

Solution (Python):

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

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

grouped = n // (a + b)
ungrouped = n % (a + b)

ans = grouped * a

if ungrouped <= a:
    ans += ungrouped
else:
    ans += a

print(ans)

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

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

ans = N // (A + B) * A
if N % (A + B) != 0:
  if N % (A + B) < A:
    ans += N % (A + B)
  else:
    ans += A

print(ans)

Solution (Python):
def Main(N, A, B):
    div = N // (A + B)
    res = N % (A + B)
    res2 = min(res, A)
    return div*A + res2
                     

def main():
    N, A, B = map(int, input().split())
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

Solution (Python):
n, a, b = map(int, input().split())
ab = a+b
syou = n//ab
amari = n%ab

base = syou*a
if amari<a:
    plus = amari
elif amari>=a:
    plus = a
print(base+plus)

Solution (Python):



import math

n,a,b=[int(i) for i in input().split()]
cnt=0
print((n//(a+b))*a+min(n%(a+b),a))

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

Solution (Python):
s=list(map(int,input().split()))
a=s[1]+s[2]
b=int(s[0]//a)
c=s[0]%a
if c==0:
  print(b*s[1])
else:
  if c<=s[1]:
    print(b*s[1]+c)
  else:
    print(b*s[1]+s[1])

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

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

if N % (A + B) > A:
    ans = ans + A
else:
    ans = ans + (N % (A + B))

print(ans)

Solution (Python):
n,a,b=map(int,input().split())
x=a+b
p=n//x
ans=p*a
r=n%x
if r>=a:
  ans+=a
else:
  ans+=r
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
s=n//(a+b)
if n-(a+b)*s-a>0:
	unchi=a
else:
	unchi=n-(a+b)*s
print(s*a+unchi)

Solution (Python):
def resolve():
    n, a, b = map(int, input().split())
    if a==0:
        print(0)
    else:
        i = n//(a+b)
        if (n-(a+b)*i) >= a:
            print(i*a+a)
        else:
            print(i*a+(n-(a+b)*i))
resolve()

Solution (Python):
n, a, b = map(int, input().split())
m = n//(a+b)
r = n % (a+b)
print(a*m + min(a, r))

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





SUM = A + B

LOOP_SUM = int(N / SUM) * A
REST = N % SUM

if REST > A:
	LOOP_SUM += A
else:
	LOOP_SUM += REST

print(LOOP_SUM)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

def main():
    N,A,B=mis()
    S = N // (A+B)
    ans = S*A
    rem = N-S*(A+B)
    if rem > A:
        ans += A
    else:
        ans += rem
    print(ans)

main()

Solution (Python):
import math
N, A, B = map(int, input().split(' '))
r = math.floor(N / (A + B))
ans = r * A + min(N - r * (A + B), A)
print(ans)

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

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

q, r = divmod(n, (a+b))
ans = q * a
if r < a:
    ans += r
else:
    ans += a

print(ans)

Solution (Python):
N,A,B=map(int, raw_input().split())
x=N/(A+B)
y=N%(A+B)
print A*x+min(A,y)

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

if N < A:
  print(N)

elif A <= N <= A + B:
  print(A)
  
else:
  count = N // (A+B)
  amari = N % (A + B)
  if amari < A:
    print(A*count + amari)
  else:
    print(A*count + A)

Solution (Python):
import sys
input = sys.stdin.readline

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


if A == 0:
    print(0)

elif N % (A + B) == 0:
    print(N // (A + B) * A)

else:
    count = N // (A + B) * A
    rem = min(A, N % (A + B))
    print(count + rem)

Solution (Python):
n,a,b=map(int,input().split())
s=(n-1)//(a+b)
ans=s*a
p=n-(a+b)*s
if p<=a:
    ans+=p
else:
    ans+=a
print(ans)

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,A,B = map(int, readline().split())

    if A == 0:
        print(0)
        exit()
        
    m = N // (A + B)
    ans = m * A

    N -= m * (A + B)

    if N >= A:
        ans += A
    else:
        ans += N
    
    print(ans)

if __name__ == "__main__":
    main()

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

cnt = A * (N//(A+B))
x =  N % (A+B)
if x > A:
    cnt += A
else:
    cnt += x
    
print(cnt)

Solution (Python):
N, A, B=(int(i) for i in input().split())

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

Solution (Python):
import sys
range = xrange
input = raw_input

n,a,b = [int(x) for x in input().split()]

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

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

x = n // (a + b)
y = n % (a + b)

if (y <= a):
   print(a * x + y)
else:
   print(a * x + a)

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

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

a = N % (A+B)

if a >= A:
    print(ans + A)
else:
    print(ans + a)

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

P = N // (A+B)
Q = N % (A+B)

if Q > A:
    Q = A

ans = P*A + Q
print(ans)

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

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

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

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

Solution (Python):
import numpy as np

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

per = int(N//(A+B))

last = int(N%(A+B))

if last <=A:
    add_ = last
else:
    add_=A
    
ans =int(A*per+add_)
print(ans)

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

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

C=A+B

ans=(N//C)*A

if N%C!=0:
    if N%C<A:
        ans+=N%C
    else:
        ans+=A
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n,a,b=mii()

x=n//(a+b)
y=n%(a+b)
if y>a:
    print(x*a+a)
else:
    print(x*a+y)

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

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

q, mod = divmod(n, r+b)
if b > mod:
    ans = q*b + mod
else:
    ans = q*b + b
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,a,b = [int(i) for i in read().split()]

m = a+b

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

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

ans = 0
s = N//(A+B)
ans = s * A
if N%(A+B) > A:
    ans += A
else:
    ans += (N%(A+B))
print(ans)

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

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

number = n // (a+b)

if n%(a+b) >= a:
    print(number*a+a)
else:
    print(number*a+n%(a+b))

Solution (Python):
import sys
import math
import copy
import queue
input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]
INF = 10**15
DD = ((1,0),(0,1),(-1,0),(0,-1))

n,a,b = LI()

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

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

Solution (Python):
n, a, b = map(int, open(0).read().split())
q, r = divmod(n, a+b)
print(q*a + min(r, a))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, a, b = map(int, input().split())
    c = n // (a+b)
    m = n % (a+b)
    ans = c*a+min(m, a)
    print(ans)


main()

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

n = N//(A+B)
if N-n*(A+B) > A:
    print((n+1)*A)
else:
    print(n*A+N-n*(A+B))

Solution (Python):
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split(' '))
q, mod = divmod(N, A+B)
rest = min(mod, A)
ans = A * q + rest
print(ans)

Solution (Python):

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs


def main(inputs):
	n,blue,red=getIntList(inputs[0])
	s=blue+red
	ans=(n//s)*blue+min(n%s, blue)
	print(ans)

if __name__=="__main__":
	inputs=getInputs()

	main(inputs)

Solution (Python):
N, A, B = map(int, input().split())
q, r = divmod(N, A+B)
print(q * A + min(A, r))

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

rep = n//(a+b)

ans = 0

ans += rep * a

m = n%(a+b)

ans += min(m, a)

print(ans)

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        







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

temp = N%(A+B)
ans = 0

ans += math.floor(N/(A+B))*A
ans += min(A,temp)


print(int(ans))

Solution (Python):
i=list(map(int, input().split()))
n=i[0]
a=i[1]
b=i[2]
x=n//(a+b)
y=n%(a+b)
if y<=a:
    print(x*a+y)
else:
    print(x*a+a)

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

x, y = N//(A+B), N%(A+B)

print(A * x + min(y,A))

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

k = int(n//(a+b))
s = n % (a+b)

if s>=a:
    print(a*k+a)
else:
    print(a*k+s)

Solution (Python):
N, A, B = [int(x) for x in input().split()]
res = N//(A + B) * A + (N%(A + B) <= A) * (N%(A + B)) + (N%(A + B) > A) * A
print(res)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    res = N // (A + B) * A
    res += min(N % (A + B), A)
    print(res)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)


if __name__ == '__main__':
    main()

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

c = A+B

ans = N//(c)*A

if N%c > A:
    ans += A
else:
    ans += N%c

print(ans)

Solution (Python):
N, A, B = map(int, input().split())
cnt = 0
cnt += N // (A + B) * A
mod = N % (A + B)
if mod <= A:
    cnt += mod
else:
    cnt += A
print(cnt)

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

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

Solution (Python):
N,A,B=map(int,input().split())
c = N//(A+B) 
d = N%(A+B)
if d < A:
    print(c*A+d)
else:
    print(c*A+A)

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,a,b = l_in()
p,q = divmod(n, a+b)
print(p*a + min(q, a))

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

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

print(x * a + min(n - x*(a+b), a))

Solution (Python):
N,A,B = map(int,input().split())
i = 1
k = N//(A+B)
if N >= (A+B) * k + A:
    print(A*(k+1))
else:
    print(A*k + (N - (A+B)*k))

Solution (Python):
n,a,b = [int(i)for i in input().split()]
cycles = n//(a+b)
remain = n%(a+b)
ans = cycles*a+min(remain,a)
print(ans)

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

C = A + B

if N - (N//C)*C >= A:
  D = (N//C)*A + A
else:
  D = (N//C)*A + N - (N//C)*C
print(D)

Solution (Python):
N, A, B = map(int, input().split())
Q = N // (A + B)
R = N % (A + B)
if R > A:
    R = A

print(Q * A + R)

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

Solution (Python):
n,a,b=map(int,input().split())
sum_=a+b
num=n//sum_
zan=n%sum_
ans=num*a
if zan<a:
    ans+=zan
else:
    ans+=a
print(ans)

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    n = N // (A + B)
    m = N % (A + B)
    if m > A:
        print(A * n + A)
    else:
        print(A * n + m)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, a, b = rli()
    p = n // (a+b)
    ans = p*a+min(n%(a+b), a)
    print(ans)


if __name__ == '__main__':
    main()

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

m = n//(a+b)
amari = n%(a+b)


print(m*a+min(amari,a))

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

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

if n%(a+b) > a:
    print(a + (n//(a+b)) * a)
else:
    print(n%(a+b) + (n//(a+b)) * a)

Solution (Python):
n, blue, red = map(int, input().split())

total= n//(blue+red)*blue

if n%(blue+red)>=blue:
  total+= blue
else:
  total+= n%(blue+red)

print(total)

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

div = N//(A+B)
mod_val = N % (A+B)

res = div * A
if mod_val <= A:
    res += mod_val
else:
    res += A

print(res)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    count = N // (A + B)
    print(A * count + min(N - (A+B)*count, A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

n, a, b = input_nums()

r = n // (a + b)
q = n % (a + b)

ans = r * a
if q >= a:
    ans += a
else:
    ans += q
print(ans)

Solution (Python):
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd

mod=10**9+7

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



print(N//(A+B)*A+min(N%(A+B),A)*bool(N%(A+B)))

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

tmp1 = (N // (A+B))
tmp2 = min(A,(N - tmp1 * (A+B)))
ans = tmp1 * A + tmp2

print(ans)

Solution (Python):



'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''




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

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

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

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

num = A + B
q, mod = divmod(N, num)
print(A * q + mod if mod <= A else A * (q + 1))

Solution (Python):
N,A,B = map(int,input().split())
q = N // (A+B)
mod = N % (A+B)

ans = q * A
if mod <= A:
  ans += mod
else:
  ans += A
  
print(ans)

Solution (Python):
N, A, B = list(map(int, input().split(" ")))
blue = 0
pair = N // (A+B)
blue += pair * A
mod = N % (A+B)
blue += min(mod, A)
print(blue)

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

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

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

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

if mod > A:
    print(shou*A+A)
else:
    print(shou*A+mod)

Solution (Python):
from sys import stdin

n, a, b = (int(x) for x in stdin.readline().rstrip().split())
c = a + b
if n % c <= a:
    print((n//c)*a + n%c)
else:
    print((n//c)*a + a)

Solution (Python):
N,A,B=map(int,input().split())
S=A+B
p=N//S
q=N%S
if q<=A:
  print(A*p+q)
else:
  print(A*(p+1))

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

val =  N // (A+B)
left = N % (A+B)

ans = val * A

if left < A:
    ans += left
else:
    ans += A

print(ans)

Solution (Python):
N, A, B = map(int, input().split())
count = N // (A+B)
mod = N % (A+B)
if mod < A:
    print(A*count + mod)
else:
    print(A*count + A)

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

res = 0

res += N // (A+B) * A

x = N % (A+B)

res += min(x, A)

print(res)

Solution (Python):
N,A,B = map(int,input().split())
k = N//(A+B)
m = N%(A+B)
if m>=A:
    n = A
else:
    n = m
print(k*A+n)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
res = a * (n // (a+b)) + min(a, n % (a+b))
print(res)

Solution (Python):
from sys import stdin
n,a,b = map(int,stdin.readline().rstrip().split())
c = n//(a+b)
d = n%(a+b)
if d > a:
    print(a*(c+1))
else:
    print(a*c+d)

Solution (Python):
n,a,b=map(int,input().split())
total=a+b
loop=n//total
leave=n-loop*total
if leave <= a:
    print(a*loop+leave)
else:
    print(a*loop+a)

Solution (Python):
n, b, r = map(int, input().split())
print(n // (b+r) * b + min(b, n%(b+r)))

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



Sum = A+B

rep = N//Sum

remain = N%Sum





ad = 0
if A <= remain:
    ad = A
else: ad = remain

result = rep*A + ad
print(result)

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

if B == 0:
	print(N)
else:
	n = N//(A+B)
	ans = A*n
	ans += min(N%(A+B),A)
	print(ans)

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

ans = 0

C = A + B
D = N // C
E = N % C

ans += D * A

if E >= A:
    print(ans + A)
else:
    print(ans + E)

Solution (Python):
n,a,b= map(int,input().split())
t1 = (n // (a+b)) * a
t2 = min(a, n % (a+b))
print(t1+t2)

Solution (Python):
def main():
    N, A, B = map(int, input().split(' '))

    div = int(N / (A+B))
    sub = N - (A+B)*div

    ans = div*A
    if sub <= A:
        ans += sub
    else:
        ans += A
    
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):


import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, a, b = MAP()

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

Solution (Python):
N, A, B = map(int, input().split())
s = int(N/(A+B))*A
a = N%(A+B)
if a >= A:
    a = A
print(s + a)

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

units = n//(a+b)
unitsblue = units*a
amari = min(n%(a+b), a)

print(unitsblue+amari)

Solution (Python):
n,a,b = map(int, input().split())
x = 10**100
balls = (n//(a+b))*a
if n%(a+b) > a:
    balls += a
else:
    balls += (n%(a+b))
print(balls)

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

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

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

resolve()

Solution (Python):





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

syou = N // (A + B)
ans = 0
ans += syou * A

ans += min(N % (A + B), A)

print(ans)

Solution (Python):
import numpy as np
import math as m

def main(**kwargs):
    q = n // (a + b) 
    r = n % (a + b)

    if r < a:
        res = q * a + r

    else:
        res = q * a + a
        
    return res

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, a, b, *_ = cin

    cout = main(n=n, a=a, b=b)
    print(cout)

Solution (Python):


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

Solution (Python):
A,B,C = list(map(int,input().split()))
D = B+C
E = A // D
amari = A % D
if amari >= B:
    print(E * B + B)
else:
    print(E * B + amari)

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

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

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

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

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

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

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



times = A + B

quo = N // times
rem = N % times

if rem >= A:
    print(quo*A + A)
else:
    print(quo*A + rem)

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

ans = int(n / (b + r)) * b
if n % (b + r) < b:
    ans += n % (b + r)
else:
    ans += b
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
c = n // (a+b)
r = n % (a+b)
ans = a * c + min(a, r)

print(ans)

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

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

answer=N//(A+B)
answer*=A

if N%(A+B)>=A:
    answer+=A
    print(answer)
else:
    print(answer+N%(A+B))

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

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

ans = A * (N//(A+B)) + min(A, N%(A+B))

print(ans)

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

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

print(A*(N//(A+B)) + min(A, N % (A+B)))

Solution (Python):




a=[]
def myin(fun=int):
    global a
    a=list(map(fun,input().split()))

myin()
print(a[0]//(a[1]+a[2])*a[1]+min(a[0]%(a[1]+a[2]),a[1]))

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

Solution (Python):
def main():
    N, A, B = (int(i) for i in input().split())
    ans = (N//(A+B)) * A
    less = N - (N//(A+B)) * (A+B)
    print(ans + min(less, A))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())
div, mod = divmod(N, (A + B))
print(div * A + min(mod, A))

Solution (Python):



def main():
  n, a, b = map(int, input().strip().split())
  ans = a * (n // (a+b)) + min(n%(a+b), a)
  print(ans)
 

if __name__=='__main__':
  main()

Solution (Python):
n, a, b = [int(i) for i in input().split()]

c = a + b

s = n // c
s *= a

_s = n % c
if _s >= a:
    s += a
else:
    s += _s

print(s)

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

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

if y > a:
    print(a*x + a)
else:
    print(a*x + y)

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

ab = a + b

cnt = n // ab
r = n % ab

if a < r:
    r = a

ans = a * cnt + r
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
e = N // (A+B)
i = N % (A+B)
i = A if i > A else i
print(e*A + i)

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

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

m = N // (A + B)
l = N % (A + B)


if l >= A:
    t = A
else:
    t = l

print(m * A + t)

Solution (Python):



def input_multiple_number():
    return map(int, input().split())

n,a,b = input_multiple_number()

pattern = n //(a+b)
blue = pattern*a
red = pattern*b

rest = n%(a+b)

if rest <= a:
    blue += rest
else:
    blue += a
    red += (rest-a)

print(blue)

Solution (Python):
n,a,b = map(int,input().split())
c,d = divmod(n,a+b)
print(a*c + min(a,d))

Solution (Python):
n,a,b= map(int,input().split())
if b==0:
  print(n)
  exit()
ans=n//(a+b)
n%=a+b
ans*=a
ans+=min(a,n)






print(ans)

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