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: Accepted

Solution code:

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

C=A+B
D=N//C
E=N-C*D

ans=A*D

if E>A:
    ans=ans+A
else:
    ans=ans+E


print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
n, a, b = [int(x) for x in readline().strip().split(" ")]
ans = n // (a + b) * a
amari = n % (a + b)
if amari > a:
    print(ans + a)
else:
    print(ans + amari)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor


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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
k=a+b
if n<=k and n>=a:
  print(a)
else:
  print((n//k)*a+min(n-k*(n//k),a))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# 整数の入力
#a = int(input())

# スペース区切りの文字列の入力
st = input().split()
#商
div = int(st[0]) // (int(st[1]) + int(st[2]))
#余り
rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + int(st[1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
stop,blue,red = map(int,input().split())

set = blue+red
if blue == 0:
  end = 0
else:
  end = blue*int(stop/set)+min(stop%set,blue)
print(end)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if A >= a:
    ans = A * s + a
else:
    ans = A * s + A

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

Count_Blue = 0
if 1<=N<=10**18 and A > 0 and B >= 0 and \
   0< A + B <= 10**18:
    Add_Blue = 1 * A
    Add_Both = Add_Blue + 1 * B

    q = N // Add_Both
    mod = N % Add_Both
    if mod < Add_Blue:
        Count_Blue = (q *Add_Blue) + mod
    else:
        Count_Blue = (q * Add_Blue) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))
if a != 0:
    c1 = n // (a + b)
    c2 = n - ((a + b) * c1)
    print(a * c1 + (c2 if c2 < a else a))
else:
    print("0")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

loop = n//(b+r)
mod = n%(b+r)
extra = min([b,mod])

print(loop*b+extra)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = 0

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

n += int(N/(A+B)) * A

amari = N % (A+B)
n += min(amari, A)

print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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


if __name__ == '__main__':
    main()


#

Submission status: Accepted

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

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


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

Submission status: Accepted

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

Submission status: Accepted

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

bcnt = 0
cnt = N // (A+B)

bcnt += cnt*A
rest = N - (A+B)*cnt

bcnt += min(A, rest)

print(bcnt)

Submission status: Accepted

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

Submission status: Accepted

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

r_1 = n // (a + b)
r_2 = n % (a + b)
if r_2 > a:
    r_2 = a
print(r_1*a + r_2)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
a = N // (A+B)
b = N - a*(A+B)
if b >= A:
  print(A*(a+1))
else:
  print(A*a+b)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split()
N, A, B = int(s[0]), int(s[1]), int(s[2])


def calc_rst(N, L):
    if int(N % L) > A:
        return A
    else:
        return int(N % L)


def solve(N, A, B, L=A+B):
    return (int(N / L) * A) + calc_rst(N, L)


print(solve(N, A, B))

Submission status: Accepted

Solution code:
N, Blue, Red = map(int, input().split())

if(Blue >= N):
    print(N)
elif (Blue + Red) >= N or Blue == 0:
    print(Blue)
else:
    q = N // (Blue + Red)
    mod = N % (Blue + Red)
    if Blue < mod:
        print(q * Blue  + Blue)
    else:
        print(q * Blue + mod)

Submission status: Accepted

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

print(times * a + min(r, a))

Submission status: Accepted

Solution code:
base = input().split()
n = int(base[0])
a = int(base[1])
b = int(base[2])
block = a+b
blockcnt = n//block
partx =a*blockcnt
ans = 0
if a>=(n%block):
    ans = partx+(n%block)
else:
    ans = partx+a
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    (n, a, b) = tuple(map(int, input().split()))
    ans = n // (a + b) * a
    ans += min(n % (a + b), a)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#スペース区切りの整数の入力
N, A, B = map(int, input().split())

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

amari = N % (A+B)
if(amari <= A):
  ans = ans + amari
  print(int(ans))
else:
  ans = ans + A
  print(int(ans))

Submission status: Accepted

Solution code:
n, b, r = map(int, input().split())
div = n//(b+r)
base = b*div
zan = n%(b+r)
ama = min(zan, b)
print(base+ama)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n,a,b=map(int,sys.stdin.readline().split())

c=(n//(a+b))
d=(n%(a+b))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]


ab = a + b

d = int(n / ab)
m = n % ab

if ( a > m):
	sum = a * d + m
else:
	sum = a * d + a

print sum
sys.stdout.flush()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc158/tasks/abc158_b
import sys

N, A, B = map(int, sys.stdin.read().split())

n = N // (A + B)
r = N % (A + B)
a = min(r, A)

print(n * A + a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

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

if(r <= a and a != 0):
  print("{}".format(q * a + r))
elif(r > a and a != 0):
  print("{}".format((q + 1)* a))
elif(a == 0):
  print("0")

Submission status: Accepted

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

c = n // (a+b)
d = n % (a+b)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input().split()

N = int(a[0])
A = int(a[1])
B = int(a[2])

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

cut = N - (A+B)*i

if N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*(i+1)
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Submission status: Accepted

Solution code:
tmp = input().split()
N = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])
print(A*(N//(A+B))+min(A, N%(A+B)))

Submission status: Accepted

Solution code:
n, a, b = (int(i) for i in input().split());

res = a * (n // (a + b));

curr = n % (a + b);

res += min(a, curr);

print(res);

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
q,r=divmod(n,a+b)
print(q*a+min(r,a))

Submission status: Accepted

Solution code:
N,A,B=(int(x) for x in input().split())
a=int(A+B)
b=int(N/a)
c=int(N%a)
if c<A:
  print(int(b*A+c))
else:
  print(int(b*A+A))

Submission status: Accepted

Solution code:
def main():
    n, a, b = map(int, input().split())
    
    div = n // (a+b)
    rest = n % (a+b)
    if rest >= a:
        rest = a

    print(div*a + rest)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def isneg(x):
    if x[0]=="-": return True
    else: return False


def neg(x):
    if isneg(x): return x[1:]
    else: return "-" + x

    
def zerot(x):
    rx = list(x[::-1])
    while rx[-1] == "0":
        rx.pop()
        if len(rx) == 0: 
            rx = ["0"]
            break
    return "".join(rx[::-1])


def zerocut(x):
    if isneg(x):
        ans = neg(zerot(neg(x)))
        if ans == "-0": return "0"
        return ans 
    else:
        return zerot(x)


def bigsmal(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if len(x) > len(y):
        return x,y
    elif len(x) < len(y):
        return y,x
    else: return tuple(sorted([x, y])[::-1])
    

def bigsmall(x, y):
    if (not isneg(x)) and isneg(y):
        return x,y
    elif isneg(x) and (not isneg(y)):
        return y,x
    elif (not isneg(x)) and (not isneg(y)):
        return bigsmal(x, y)
    elif isneg(x) and isneg(y):
        tmp = bigsmal(neg(x), neg(y))[::-1]
        return tuple(neg(i) for i in tmp)
    

def greater(x, y):
    if (bigsmall(x, y) == (x, y)) and x != y: return True
    else: return False
    

def ad(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    ra = [0] * (max(len(x), len(y)) + 1)
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)): ra[i] += rx[i]
    for i in range(len(ry)): ra[i] += ry[i]
    for i in range(len(ra) - 1):
        ra[i+1] += ra[i] // 10
        ra[i] = ra[i] % 10
    ans = "".join([str(i) for i in ra][::-1])
    return zerocut(ans)


def s_b(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if bigsmall(x, y) != (x, y): raise Exception("not x>=y error")
    ra = [0] * (max(len(x), len(y)))
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)): ra[i] += rx[i]
    for i in range(len(ry)): ra[i] -= ry[i]
    for i in range(len(ra) - 1):
        if ra[i] < 0:
            ra[i] = 10 + ra[i]
            ra[i+1] -= 1
    ans = "".join([str(i) for i in ra][::-1])    
    return zerocut(ans)


def sb(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    if (x, y) == bigsmall(x, y):
        return s_b(x, y)
    else:
        return neg(s_b(y, x))


def add(x, y):
    if isneg(x) and isneg(y):
        return neg(ad(neg(x), neg(y)))
    elif (not isneg(x)) and (not isneg(y)):
        return ad(x, y)
    elif (not isneg(x)) and isneg(y):
        return sb(x, neg(y))
    elif isneg(x) and (not isneg(y)):
        return sb(y, neg(x))
    

def sub(x, y):
    if isneg(x) and isneg(y):
        return sb(neg(y), neg(x))
    elif (not isneg(x)) and (not isneg(y)):
        return sb(x, y)
    elif (not isneg(x)) and isneg(y):
        return ad(x, neg(y))
    elif isneg(x) and (not isneg(y)):
        return neg(ad(neg(x), y))
        

def ml(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    ra = [0] * (len(x) + len(y))
    rx = [int(i) for i in x][::-1]
    ry = [int(i) for i in y][::-1]
    for i in range(len(rx)):
        for j in range(len(ry)):
            ra[i+j] += rx[i] * ry[j]
    for i in range(len(ra) - 1):
        ra[i+1] += ra[i] // 10
        ra[i] = ra[i] % 10
    ans = "".join([str(i) for i in ra][::-1])
    return zerocut(ans)
    

def mul(x, y):
    if isneg(x) and isneg(y):
        return ml(neg(x), neg(y))
    elif (not isneg(x)) and (not isneg(y)):
        return ml(x, y)
    elif (not isneg(x)) and isneg(y):
        return neg(ml(x, neg(y)))
    elif isneg(x) and (not isneg(y)):
        return neg(ml(neg(x), y))
        

def mod2(x):
    return int(x[-1]) % 2


def div2(x):
    if isneg(x): raise Exception("negative input")
    ans = [0] * len(x)
    xs = [int(i) for i in x]
    for i in range(len(x)-1):
        ans[i] += xs[i]
        ans[i+1] += (ans[i]%2) * 10
        ans[i] //= 2
    ans[len(x)-1] = (ans[len(x)-1] + xs[len(x)-1])//2
    ans = "".join([str(i) for i in ans])
    return zerocut(ans)
        

def isdv(x, a, b):
    if isneg(x) or isneg(a) or isneg(b): raise Exception("negative input")
    if b == "0": raise Exception("zero div error")
    ab = sub(a, b)
    bx = mul(b, x)
    cond1 = greater(bx, ab)
    cond2 = ((a, bx) == bigsmall(a, bx))
    if cond1 and cond2: 
        return True
    else: 
        return False


def dv(a, b):
    """[(str(i), dv("12", str(i))) for i in range(1, 15)]"""
    if isneg(a) or isneg(b): raise Exception("negative input")
    if b == "0": raise Exception("zero div error")
    if b == "1": return a
    left = "0"
    right = a
    while greater(right, add(left, "1")):
        x = div2(add(left, right))
        #print(x)
        if (a, mul(b, x)) == bigsmall(a, mul(b, x)):
            left = x
        else:
            right = x
    return left


def div(x, y):
    if isneg(x) and isneg(y):
        return dv(neg(x), neg(y))
    elif (not isneg(x)) and (not isneg(y)):
        return dv(x, y)
    elif (not isneg(x)) and isneg(y):
        return neg(dv(x, neg(y)))
    elif isneg(x) and (not isneg(y)):
        return neg(dv(neg(x), y))


def mod(x, y):
    if isneg(x) or isneg(y): raise Exception("negative input")
    divmul = mul(div(x, y), y)
    return sub(x, divmul)


n,a,b = input().split()
ans1 = mul(div(n, add(a, b)), a)
ans2 = bigsmall(mod(n, add(a, b)), a)[1]
print(add(ans1, ans2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
q, mod = divmod(n, a+b)
if mod > a:
    ans = a*(q+1)
else:
    ans = a*q + mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin 


N, A, B = map(int, stdin.readline().split())

n, r = divmod(N, A + B)
ans = 0
ans += n*A
ans += min(A, r)
print (ans)

Submission status: Accepted

Solution code:
nab = input().split(' ')
if len(nab) != 3:
    raise Exception

n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

loop = int(n / (a + b))
count_blue = loop * a
last = n - (a + b) * loop
if last > a:
    count_blue += a
else:
    count_blue += last

print(count_blue)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

r = N % (A + B)

ans = ans + min(r, A)

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# N, A, B
num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

numSet = num // (greenNum+redNum)
remain = num % (greenNum+redNum)
numRest = remain if (remain < greenNum) else greenNum

totalGreen = numSet * greenNum + numRest

print(totalGreen)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n,a,b=(int (x) for x in input().split())
sho=n//(a+b)
amari=n%(a+b)
pre=min(amari,a)
ans=a*sho+pre
print(ans)

Submission status: Accepted

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

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

if amari < A:
  c = amari
else:
  c = A
  
ans = A * count + c
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
q, r = divmod(N, A + B)
if r <= A:
    blues = q * A + r
else:
    blues = (q + 1) * A
print(blues)

Submission status: Accepted

Solution code:
N, blue, red = map(int,input().split())
count = min(N % (blue+red), blue)
count += int(N/(blue+red)) * blue
print(count)

Submission status: Accepted

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

q = n // (a + b)

x = a * q

w = n % (a + b)
if w >= a:
    y = a
else:
    y = w

ans = x + y

print(ans)

Submission status: Accepted

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

a = A+B

x = N//a  #繰り返し回数
y = N%a #余り

if y < A:
    b = y
else:
    b = A

blue_count = A * x + b

print(blue_count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a = int(N/(A+B))
b = N % (A+B)
if b > A :
    print(A * a + A)
else:
    print(A * a + b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(int(count))

Submission status: Accepted

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

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

Submission status: Accepted

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

def blue(n, a, b):
  res = 0
  s = n // (a+b)
  res += a*s
  n -= s*(a+b)
  if n <= a:
    res += n
  else:
    res += a
  return res

print(blue(N, A, B))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split(" "))
x = N // (A + B)
y = N % (A + B)
a = A * min([x, 10 ** 100])
if y > A:
  a += A
else:
  a += y
print(a)

Submission status: Accepted

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

t = n //(a+b)
s = min(n-(a+b)*t, a)
print(t*a+s)

Submission status: Accepted

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

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

ans = A * syou

ans += min(A, mod)

print(ans)

Submission status: Accepted

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

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

ans = A * syou

if (mod <= A):
    ans += mod
else:
    ans += A

print(ans)

Submission status: Accepted

Solution code:
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans=(n//(a+b))*a+lol
print(ans)

Submission status: Accepted

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

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

if y >= a:
    s = a
else:
    s = y

print(a*x + s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
class Solution:
    def solve(self, N: int, A: int, B: int) -> int:

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


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(N, A, B))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
range=10**100
count=N//(A+B)
amari=N%(A+B) 
add=A if A < amari else amari
print(count*A+add)

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
Q = N//(A + B)
r = N % (A + B)
if r < A+1:
    x = A * Q + r
else:
    x = A * (Q+1)
print(x)

Submission status: Accepted

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''input
6 2 4
'''
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)

ans = 0

t = n // (a + b)

ans = ans + t * a
rem = min(n - t * (a + b), a)

print(ans + rem)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = q * a + min(mod, a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = (int(x) for x in input().split())
full = n // (a+b)
rem = n - full*(a+b)
rem_a = min(a, rem)
print(full*a+rem_a)

Submission status: Accepted

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

base = A + B
count = (N // base)
remain = min(A, N % base)

print(A * count + remain)

Submission status: Accepted

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

x, y = divmod(N, A+B)
print(x * A + min(A, y))