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):
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math

def fast_comb(a,b,mod):
    up = reduce(lambda x,y: x*y%mod, range(a,a-b,-1))
    down = reduce(lambda x,y: x*y%mod, range(1,b+1))
    return (up * pow(down, mod-2, mod)) % mod

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def readlines(n):
    for _ in range(n):
        map(int, input().split())
        yield

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

    base = (n//(a+b)) * a
    plus = min(n % (a+b), a)

    print(base + plus)

main()

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

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

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

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

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

s=N%(A+B)
if s<=A and s!=0:
  print(s+A*(N//(A+B)))
elif s!=0:
  print(A*(1+N//(A+B)))
else:
  print(A*(N//(A+B)))

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

sho = N // (A + B)
amari = N % (A + B)

if A == 0:
    print(0)
elif amari >= A :
    print(sho*A + A)
else:
    print(sho*A + amari)

Solution (Python):





def solv(N, A, B):
    m = N // (A+B)
    n = N % (A+B)
    if n < A:
        return A * m + n
    return A * m + A


if __name__ == "__main__":

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

    print(ans)

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

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

if m > a:
    i = a
else:
    i = m

print(q*a+i)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, A, B = LI()
    cnt = 0
    cnt += (N // (A+B)) * A
    rem = N - (A+B) * (N//(A+B))
    if rem >= A:
        cnt += A
    else:
        cnt += rem
    print(cnt)

main()

Solution (Python):



import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B = i2nn()
    q, mod = divmod(N, A+B)
    blue_sum = q * A + min(mod, A)
    print(blue_sum)
    return

main()

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

d, m = divmod(N, A+B)
ans = 0
if m == 0:
  ans = A * d
else:
  if A <= m:
    ans = A * (d + 1)
  else:
    ans = A * d + m

print(ans)

Solution (Python):

import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s


N,A,B=map(int,input().split())
C=A+B
ans=N//(A+B)
ans=ans*A
N%=(A+B)
if N<=A:
    ans+=N
else:
    ans+=A
print(ans)

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

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

q = N // (A + B)
r = N % (A + B)

if r >= A:
    ans = q * A + A
else:
    ans = q * A + r

print(ans)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    print(A * (N // (A+B)) + min(A, N % (A+B)))
    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):
length, blue, red = [int(x) for x in input().split(' ')]

pair_count = int(length / (red + blue))

print(pair_count * blue + min(blue, length - pair_count * (red + blue)))

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

ab = A + B
num = N//ab
r = N - num*ab

if(r <= A):
  print(A*num + r)
else:
  print(A*num + 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):
N,A,B = map(int,input().split())
if A == 0:
    print(0)
else:
    ans = A*(N//(A+B))
    rem = N%(A+B)
    ans += min(rem,A)
    print(ans)

Solution (Python):
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]



def A():
    S = input()
    if S == 'AAA' or S == 'BBB':
        print('No')
    else:
        print('Yes')
    return



def B():
    N, A, B = LI()
    ans = N // (A + B) * A + min(N % (A + B), A)
    print(ans)
    return



def C():

    return



def D():
    return



def E():
    return



def F():
    return



if __name__ == "__main__":
    B()

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

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

print(ans)

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

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):
n, a, b = map(int, input().split())

c = a + b
c_count = n // c
rest = n - c_count * c

print(c_count * a + min(rest, a))

Solution (Python):
def main():
  import sys
  input = sys.stdin.readline
  n,a,b=map(int,input().split())
  print(a*(n//(a+b))+min(n%(a+b),a))
  
if __name__=='__main__':
  main()

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

syo, amari = n // (a+b), n % (a+b),

plus = min(amari, a)

print(syo*a + plus)

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

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

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

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

if __name__ == "__main__":
    main()

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

Solution (Python):


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

ans = int(N // (A + B)) * A
mod = N % (A + B)

ans += min(A, mod)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
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())

one_set = a + b
amari = n % one_set
ans = (n // one_set) * a

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

print(ans)

Solution (Python):
n,a,b = map(int,input().split())
c = n//(a+b)
d = n - (a+b)*c

if 0<=d<=a:
    res = a*c+d
else:
    res = a*c+a
print(res)

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

C = N // (A + B)
D = N % (A + B)

CB = C * A
DB = min(D, A)

print(CB+DB)

Solution (Python):
def main(n,a,b):
    x = a+b
    q,mod = divmod(n,x)
    res = (q*a) + (a if a<=mod else mod)
    return res

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

Solution (Python):
import math
N,A,B= list(map(int,input().split(" ")))
ans = 0
d = N //(A + B)
amari = N % (A + B)
ans += d * A
ans += min(amari,A)
print(ans)

Solution (Python):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop
import sys
stdin = sys.stdin
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

n, a, b = na()

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

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

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

Solution (Python):
n, a, b = [int(v) for v in input().split()]
c = n // (a + b)
d = n % (a + b)

ans = a * c + min(a, d)
print(ans)

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

d, rem = divmod(n, a + b)
ans = d * a + min(rem, a)
print(ans)

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

Solution (Python):
from sys import stdin
n,a,b = map(int, stdin.readline().rstrip().split())

ab = a+b
amari = n%ab
ans = a*(n // ab)
if amari <= a:
    ans += amari
else:
    ans += 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())

n = N // (A + B)
k = N % (A + B)

if k < A:
    print(n * A + k)
else:
    print(n * A + A)

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

Solution (Python):
N, Nb, Nr = map(int, input().split())

batch_total = Nb + Nr
remain = min(Nb, N%batch_total)
iterate_num = N // batch_total

sum_num = iterate_num * Nb + remain
print(sum_num)

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())
    full = N // (A+B)
    ans = full * A
    N -= full * (A+B)
    if N >= A:
        ans += A
    else:
        ans += N
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
if __name__ == '__main__':
    n, a, b = list(map(int, input().split(" ")))
    c = n // (a + b)
    if (n - c * (a + b)) <= a:
        d = n - c * (a + b)
    else:
        d = a

    print(c * a + d)

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

at = int(N/(A+B))
bt = int(N % (A+B))

if bt > A:
    print(A*at + A)
else:
    print(A*at + bt)

Solution (Python):
if __name__ == "__main__":
    n, a, b = map(int, input().split())

    tmp = n // (a + b)
    ans = tmp * a

    tmp = n % (a + b)

    if tmp > a:
        ans += a
    else:
        ans += tmp

    print(ans)

Solution (Python):
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

Solution (Python):
N,A,B=map(int,input().split())
t=N//(A+B)
nokori=N-(A+B)*t
if nokori<A:
  print(A*t+nokori)
else:
  print(A*(t+1))

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

tmp = n // (a+b)
tmpamari = n % (a+b)

ans = tmp * a
ans += min(tmpamari, a)

print(ans)

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

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

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

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


if __name__ == '__main__':
    main()

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

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

ans = n // (a+b) * a
delta = n % (a + b)
if delta >= a:
    delta = a
ans += delta
print(ans)

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, A, B = map(int, input().split())

    d, m = divmod(N, A + B)
    ans = d * A + min(m, A)
    print(ans)


main()

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

    d = N // (A + B)
    r = N % (A + B)

    print(d * A + min(r, A))


if __name__ == "__main__":
    resolve()

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

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

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


y=N-N//(A+B)*(A+B)

z=min(A,y)

print(x+z)

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

Solution (Python):
input = raw_input
N, a, b = map(int, input().split(" "))

unit = a+b
r = N // unit 
q = N % unit
nokori = min(q, a)
out = r*a + nokori
print(out)

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

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

print(ans)

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

Solution (Python):
n,a,b = map(int,input().split())
buf = a+b
tmp1 = n%buf
if tmp1 > a:
    tmp1 = a
tmp2 = n//buf
print(tmp2 * a + tmp1)

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

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

print(ans)

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

sum = A + B

q, mod = divmod(N, sum)

if mod > A:
    mod = A

print(q * A +mod)

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

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

print(ans)

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

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

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

C = A + B
a = N // C
b = N % C
c = a * A + min(b, A)
print(c)

Solution (Python):
N, A, B = [int(i) for i in input().split()]
count, r = divmod(N, A + B)
ans = A * count + min(A, r)
print(ans)

Solution (Python):

import sys
import math
import numpy as np
import itertools


n, a, b = (int(i) for i in input().split())  


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

print(answer)

Solution (Python):


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

if A == 0:
    print(0)
else:
    if N <= A:
        print(N)
    else:
        ans, rem = divmod(N, A+B)
        ans *= A
        if rem >= A:
            ans += A
        else:
            ans += rem
        print(ans)

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


t = A + B
tn = N // t
ta = N % t
res = tn * A

if ta > A:
    print(res + A)
else:
    print(res + ta)

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

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

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

if int(N) <= int(A):
  print(int(N))
elif int(N) <= int(A + B):
  print(int(A))
else:
  a = int(N//(A+B))
  b = int(N - (A+B)*a)
  c = min(b,A)
  print(a*A+c)

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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,a,b = mi()
ans = 0
ans += (n//(a+b)) * a
tmp = n % (a+b)
tmp2 = min(a,tmp)
ans += tmp2
print(ans)

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

if (r > a):
    r = a

z = t * a + r

print(z)

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

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

if k <=a:
    print(l*a+k)
else:
    print(l*a+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())
print(A * (N // (A + B)) + min(A, N % (A + B)))

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

def pin(type=int):
    return map(type,input().split())
     


def resolve():
    N,A,B=pin()
    ans=0
    cycle=A+B
    ans+=A*(N//cycle)
    t=N%cycle
    if t <= A:
        ans+=t
    else:
        ans+=A
    print(ans)
    
    
    


"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """8 3 4"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8 0 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)




from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

def pin(type=int):
    return map(type,input().split())
     


def resolve():
    N,A,B=pin()
    ans=0
    cycle=A+B
    ans+=A*(N//cycle)
    t=N%cycle
    if t <= A:
        ans+=t
    else:
        ans+=A
    print(ans)
    
    
    


"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """8 3 4"""
        output = """4"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """8 0 4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Solution (Python):
N, A, B = map(int, input().split())
sets = N // (A + B)
rem = N - sets * (A + B)


if rem <= A:
    print(sets * A + rem)
else:
    print(sets * A + A)

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

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

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

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

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

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

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

print(x + min(A, y))

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N, A, B = MI()
    a = N % (A + B)
    b = N // (A + B)

    print(b * A + min(a, A))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys









mod = int(1e9+7)
INF = 1<<29

def main():
    n,a,b = map(int,input().split())
    x = n // (a + b)
    ans = a * x
    if n-(a+b)*x<=a:
        ans += n - (a + b) * x
    else:
        ans += a
    print(ans)
    return

if __name__=='__main__':
    main()

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

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

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

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

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

c = n // (a+b)
d = c * a
e = min(a, n%(a+b))

print(d + e)

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B = imn()

ans1 = (N //(A+B))*A
mod = (N%(A+B))
ans2 = min(mod, A)

print(ans1+ans2)

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

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

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

ans=q*a

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

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

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

q = N // (A+B)
r = N % (A+B)
if r <= A:
    print(q*A+r)
else:
    print(q*A+A)

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 = map(int,input().split())
    ab =A + B
    div = N // ab
    remain = N % ab

    ans = div*A + min(remain,A)
    print(ans)
    return

if __name__ == "__main__":
    main()

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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B):
    m = N // (A + B)
    x = m * A
    return x + min((N-(A+B)*m), A)


def main():
    N, A, B = read_int_n()
    print(slv(N, A, B))


if __name__ == '__main__':
    main()

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

group = N // (A + B)
print(group*A + min(A, (N-group*(A+B))))

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

c = a + b

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

Solution (Python):
def solve(n, a, b):
    res = n // (a + b) * a
    res += min(n % (a + b), a)
    return res


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(8, 3, 4) == 4
    assert solve(8, 0, 4) == 0
    assert solve(6, 2, 4) == 2


if __name__ == "__main__":
    test()
    main()

Solution (Python):

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

C = (A + B)
n = N // C
m = min(N - C * n, A)

print(n * A + m)

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

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

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

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