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 = [int(n) for n in input().split(" ")]

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

a = A
if t < A:
    a = t

print(s * A + a)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-08-30 14:36:32 +0900
# LastModified: 2020-08-30 14:45:15 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

C = A + B

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

Submission status: Accepted

Solution code:
r=input().split()
N=int(r[0])
A=int(r[1])
B=int(r[2])
x=N//(A+B)
y=N%(A+B)
if y<=A:
    print(A*x+y)
else:
    print(A*(x+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 高橋くんが根性ありすぎるので, ループではTLE
# 単純に商と剰余の和と思いがちだが, そうでないことに注意
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
# 剰余がaを超えていた場合, aにする
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

Submission status: Accepted

Solution code:
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,a,b=map(int,input().split())
ans=(n//(a+b))*a
r=n%(a+b)
if r<=a:
    print(ans+r)
else:
    print(ans+a)

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,A,B = MI()
q = N // (A+B)
r = N % (A+B)
print(q*A+min(r,A))

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())
ans = N//(A+B) * A
ans += min(A, N%(A+B))
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, open(0).read().split())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N,A,B = map(int,input().split())
    syo = N//(A+B)
    amari = N%(A+B)
    ans = syo*A
    if amari < A:
        ans += amari
    else:
        ans += A

    return ans

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

loop = a+b
l_cnt = n//loop
rem = n%loop

ans = l_cnt*a
if rem < a:
    ans += rem
else:
    ans += a

print(ans)

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


N, A, B = LI()
x = N//(A+B)
y = N-A*x-B*x
if y >= A:
    ans = (x+1)*A
else:
    ans = x*A+y
print(ans)

Submission status: Accepted

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

term = A + B
blue = (N // term) * A

if N - ((N // term) * term) <= A:
    blue += (N - ((N // term) * term))
else:
    blue += A

print(blue)

Submission status: Accepted

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

AB = A+B

shou = N//AB

amari = N%AB

ans = shou*A+min(A,amari)

print(ans)

Submission status: Accepted

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

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

print(div * a + min(a, mod))

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N, A, B = map(int, input().split())
    if A == 0:
        print(0)
        exit()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
a = 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())
x=n//(a+b)
y=n%(a+b)
if y<=a:
    print(a*x+y)
else:
    print(a*x+a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
d,m = divmod(N,A+B)
print(d*A + min(A,m))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

input = sys.stdin.readline


def ST():
    return input().rstrip()


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


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


def LI():
    return list(MI())


N, A, B = MI()

q, r = divmod(N, A + B)

if r > A:
    print(q * A + A)
else:
    print(q * A + r)

Submission status: Accepted

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

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

    if d > a:
        ans = a * c + a
    else:
        ans = a * c + d

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

else:
  if m2 >= a:
    print((m1 + 1) * a )
  else:
    print(m1 * a + m2)

Submission status: Accepted

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

s = N // (A+B)

t = N % (A+B)

k = 0

if t <= A:
  k = t
else:
  k = A

print(s*A+k)

Submission status: Accepted

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

a = N//(A+B)
b = N%(A+B)
if b > A:
    b = A
ans = a*A + b

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:
  print(A*X+Y)
else:
  print(A*(X+1))

Submission status: Accepted

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

Submission status: Accepted

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

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: #nokoriが全てAの場合
	print((number_turn * A) + nokori)
else: #nokoriがAとBの両方の場合
	print((number_turn * A) + A)

Submission status: Accepted

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

sets = N // (A+B)
N = N % (A+B)
print(sets*A + min(N,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=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())
k=n//(a+b)
print(k*a+min(a, n%(a+b)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
import sys
N,A,B=map(int,input().split())

count=int(N/(A+B))
s=N%(A+B)

if s<=A:
    print(A*count+s)
else:
    print(A*count+A)

Submission status: Accepted

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

Submission status: Accepted

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

ans = N // (blue + red) * blue
rem = N % (blue + red)
ans += min(rem, blue)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math as mt

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, a, b = map(int, readline().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:
#!/usr/bin/env python3
def main():
    N, A, B = map(int, input().split())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ablen = A + B
n = int(N / int(ablen))
num = A * n
m = N % int(ablen)
num += min(m, A)
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    N, A, B = list(map(int, input().split()))
    base = (N // (A+B)) * A
    rem = N - (N//(A+B))*(A+B)
    ans = base
    ans += A if rem >= A else rem
    print(ans)


if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

x = N//(A+B)
y = (N - x*(A+B))
blue=x*A + (A if y>=A else y%A)
print(blue)

Submission status: Accepted

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

Submission status: Accepted

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

pair = N // (A + B)
remain = N % (A + B)

print(A * pair + min(remain, A))

Submission status: Accepted

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

pair = N // (A + B)
remain = N % (A + B)

if remain > A:
    print(A * pair + A)
else:
    print(A * pair + remain)

Submission status: Accepted

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

chunk = n // (a + b) * a
rest = a if n % (a + b) > a else n % (a + b)
print(chunk + rest)

Submission status: Accepted

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

Submission status: Accepted

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

n = N%(A+B)

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n, a, b = [int(x) for x in input().split()]
print(a * (n // (a + b)) + min(a, n % (a + b)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

kotae= N//(A+B)*A
am = N%(A+B)

if am>A:
	am=A

print(kotae+am)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, 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:
n, a, b = map(int,input().split())
a_b = n//(a+b)*a
if n%(a+b) < a:
    print(a_b + n%(a+b))
else:
    print(a_b + a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

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

Submission status: Accepted

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

# 周期
# 青 A個, 赤 B個

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

before_count  = loop * a
after_count = min(r,a)
ans = before_count + after_count

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if N%(A+B)>=A:
  print(r*A+A)

else:
  print(r*A+(N-r*(A+B)))

Submission status: Accepted

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

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:
import math
N, A, B = map(int, input().split())
if math.log10(N)>math.log10(A+B)+100:
    print(A*(10**100))
elif N % (A+B) <= A:
    print((N//(A+B)*A)+(N%(A+B)))
else:
    print((N//(A+B)*A)+A)

Submission status: Accepted

Solution code:
a = [int(s) for s in input().split()]
b = int(a[0] // (a[1] + a[2]))
c = int(a[0] % (a[1] + a[2]))
d = b * a[1]
if c >= a[1]:
  d = d + a[1]
else:
  d = d + c

print(d)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if c <= a:
    ans = d * a + c
else:
    ans = d * a + a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

rep=n//(a+b)
rep2=n%(a+b)
ans=rep*a
if rep2>=a:
  ans+=a
  print(ans)
else:
  ans+=rep2
  print(ans)

Submission status: Accepted

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

C = A+B
q=N//C
r=N%C

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
c=10**100
if N<c:
    if N%(A+B)<=A:
        print((N//(A+B))*A+(N%(A+B)))
    elif N%(A+B)>A:
        print((N//(A+B))*A+A)
elif N>=c:
    if c%(A+B)<=A:
        print((c//(A+B))*A+(c%(A+B)))
    elif c%(A+B)<=A:
        print((c//(A+B))*A+A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Count Balls
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=list(map(int, input().split()))
ct=N//(A+B)
res=N%(A+B)
print(A*ct + min(A,res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B - Count Balls
N,A,B = map(int,input().split())

balls = N - (A+B)*(N//(A+B))#最後の一回の操作で加えることのできるボールの個数
if balls <= A:
    ans = A * (N//(A+B)) + balls
else:
    ans = A * (N//(A+B)) + A
print(ans)

Submission status: Accepted

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

ab=a+b
num=n//ab
n-=ab*num

if n>=a:
  ans=a
  
else:
  ans=n
  
print(ans+num*a)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, A, B = map(int, input().split())
    base = pow(10, 100)
    C = A+B
    mod = N%C
    n = N//C
    if mod>A:
        print(A*n+A)
    else:
        print(A*n+mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,R=list(map(int,input().split()))
K=B+R
ans=B*(A//K)
S=A%K
if S<=B:
  ans+=S
else:
  ans+=B
print(ans)

Submission status: Accepted

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

if a >= n:
    ans = n
elif a+b >= n:
    ans = a
else:
    set_ab = n//(a+b)
    ans += set_ab*a
    n -= set_ab*(a+b)
    if n < a:
        ans += n
    else:
        ans += a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(A * M + min(N - M * (A + B), A))

Submission status: Accepted

Solution code:
def solve():
    N,A,B = [int(i) for i in input().split()]
    blue_red = A + B
    ans = N // blue_red * A + min(A, N % blue_red)
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import os, sys
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    nab = [int(x) for x in input().rstrip().split(" ")]
    n = nab[0]
    a = nab[1]
    b = nab[2]

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

    ans = kurikaesi * a
    ans += amari if amari < a else a
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if a>=mod:
  print((div*a)+mod)
else:
  print((div*a)+a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
  n,a,b = list(map(int,input().split()))
  ans=0
  count=int(n/(a+b))
  ans+=count*a
  amari=n-count*(a+b)
  if amari <= a:
    ans+=amari
  else:
    ans+=a
  print(ans)
main()

Submission status: Accepted

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

n = N//(A+B)

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

# print(f'{N=} {A=} {B=}')
div, mod = divmod(N, A + B)
# print(f'{div=} {mod=}')
ans = div * A + min(mod, A)
print(ans)

Submission status: Accepted

Solution code:
score = list(map(int,input().split()))
gokei = score[1] + score[2]
shou,amari = score[0]//gokei,score[0] % gokei
if amari > score[1]:
    print((shou+1)*score[1])
else:
    print(shou*score[1]+amari)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N % (A+B) > A:
  C = A
elif N % (A+B) <= A:
  C = N % (A+B)
  
print((N//(A+B))*A + C)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NN =input().split()
N =int(NN[0])
A = int(NN[1])
B = int(NN[2])
X =A+B
Y =N//X
Z = N%X

if Z >=A:
  ans = A
else:
  ans = Z
ans1 = Y*A + ans
print(ans1)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N, B, R = list(map(lambda x: int(x), input().split(" ")))

print((N // (B + R)) * B + min([N % (B + R), B]))

Submission status: Accepted

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

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())

N_syo = N//(A+B)
N_amari = N%(A+B)
ans = 0

if B == 0:
    print(N)

elif N_amari == 0:
    print(N_syo*A)
else:
    ans += N_syo*A
    N -= N_syo*(A+B)
    if N <= A:
        ans += N
        print(ans)
    else:
        ans += A
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if N - N // (A + B) * (A + B) > A:
    tail = A
else:
    tail = N - N // (A + B) * (A + B)

print(N // (A + B) * A + tail)

Submission status: Accepted

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

Submission status: Accepted

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

x, y = divmod(n, a + b)
print(a * x + y if y <= a else a * (x + 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ab = A + B

r1 = N // ab * A
r2 = min(A, N % ab)

print(r1 + r2)

Submission status: Accepted

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

s, e = divmod(n, (a + b))

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

Submission status: Accepted

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

cont_num = A+B

k = N // cont_num
# print(k)

adjust_num = N - k*cont_num
add_blue = 0
if adjust_num >= A:
    add_blue = A
else:
    add_blue = adjust_num

print(k*A + add_blue)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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

    N -= n * (A + B)
    ans += min(A, N)

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()

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

if list[0]%(list[1]+list[2])==0:
	print((list[0]//(list[1]+list[2]))*list[1])
elif list[0]%(list[1]+list[2])<=list[1]:
	print((list[0]//(list[1]+list[2]))*list[1]+list[0]%(list[1]+list[2]))
else:
	print(list[0]//(list[1]+list[2])*list[1]+list[1])

Submission status: Accepted

Solution code:
import numpy as np

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

C = A+B
set = N // C

ans = A if (N-C*set) >= A else N-C*set

ans += set*A

print(ans)

Submission status: Accepted

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

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

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 = [int(a) for a in input().split()]

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

lastseq = N%(A+B)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

AB = A + B
NumABalls = 0

NumABalls = N//AB * A
M = N%AB

if A - M >= 0:
  NumABalls += M
else:
  NumABalls += A

print(NumABalls)

Submission status: Accepted

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

g = n // (b+r)
i = n % (b+r)

if b == 0:
    print(0)
elif i > b:
    print(g*b + b)
else: #i <= b
    print(g*b + i)