Problem:


Score : 200 points

Problem Statement

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

Initially, there is no ball placed.

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

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

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

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

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

Sample Input 1

8 3 4

Sample Output 1

4

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

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Wrong Answer

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

all = a + b

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

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

# a > 0
c = round(N / all)
d = N % all

roundCnt = a * c
amariCnt = 0

if d != 0:
    if d <= a :
        amariCnt = d
    else:
        amariCnt = a

print(roundCnt + amariCnt)


#a = 0 print 0
#a > 0
# N <= a print N
# N > a
#  N/(a+b)=c     が割り切れる  a * c
#  N/(a+b)=c...d が余りが出る  a * c
#    d <= a のとき a * c + d
#    d >  a のとき a * c + a
#

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().strip().split()]
if A+B > N and A < N:
  print(A)
else:
  q, r = divmod(N, A+B)
  print(A*q + r)

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
n = nums[0]
a = nums[1]
b = nums[2]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print(n)
		# elif a<=n:
			# print(a)
		else:
			for i in range(1,10**100):
				if n < (a+b)*i and (a+b)*(i-1)<=n:
						if n-(a+b)*(i-1)<a:
							print(a*(i-1)+n-(a+b)*(i-1))
						else:
							print(a*i)
						break
				break
main()

Submission status: Wrong Answer

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

if a + b == 0:
    b = 1

x = n // (a + b) * a
# print(x)
y = n % (a + b)
# print(y)
ans = x + y 


print(ans)

Submission status: Wrong Answer

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

if a == 0:
    print("0")
if b == 0:
    print(int(n))
else:
    cnt = 0
    for j in range(0, a):
        box.append("b")
        cnt += 1
    for k in range(0, b):
        box.append("r")
        cnt += 1
    if cnt < n:
        ap = n - cnt
        for l in range(0, ap):
            box.append("b")
    
    print(box.count("b"))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
lst = []
for i in range(A):
    lst.append(0)
for i in range(B):
    lst.append(1)

if len(lst) >= N:
    lst = lst[:N]
else:
    lst2 = []
    while len(lst2) < N:
        lst2 += lst
    lst2 = lst2[:N]
    print(lst2.count(0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n <= blue:
    print(n)
    exit()

if n <= blue + red:
    print(blue)
    exit()

q = n // (blue + red)
r = n % (blue + red)

cnt = q * blue + r % blue

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * max(count, 1) + min(A, amari)
if N == 0: sum_blue = 0
print(sum_blue)

Submission status: Wrong Answer

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

a = N // (A+B)

if A == 0:
  ans = 0
elif B == 0:
  ans = N
elif a > 1:
  ans = A*a + A
else:
  ans = A + (N-(A+B))

print(ans)

Submission status: Wrong Answer

Solution code:
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
ans = 0

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

if n > (a + b) * t:
    ans += n - (a + b) * t

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

result = 0

a = math.floor(N / (A + B))
r = N % (A + B)

if r > A:
    ad = A
else:
    ad = A - r

result = A * a + r

print(result)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().strip().split()]
if A < N:
  print(A)
else:
  q, r = divmod(N, A+B)
  print(A*q + r)

Submission status: Wrong Answer

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

ans = (N // (B+R)) * B
print(ans)


rest = N % (B+R)

print(rest)

if rest < B:
  print(ans+rest)
else:
  print(ans+B)

Submission status: Wrong Answer

Solution code:

def main():
    N,A,B = map(int, input().split())
    if A == 0:
        print(0)
        return
    if B == 0:
        print(N)
        return
    
    count=0

    sho1 = N // (A+B)
    amari1 = N % (A+B)
    
    if sho1 ==0:
        sho2=amari1 // A
        amari2=amari1 % A
        if sho2 == 0:
            count += amari2
        
        elif sho2 == 1:
            count += A
    else:
        count += sho1*A
        
        sho2=amari1 // A
        amari2=amari1 % A
        
        if sho2 == 0:
            count += amari2
        
        elif sho2 == 1:
            count += A
            

    print(count)
    
    
main()

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
count=0
flag=True
pattern=True
ans=0
num=A+B
while flag:
    x=N%num
    if x==0:
        if A>0:
            ans=A
        else:
            ans=(A*x)+x
    elif x==N:
        ans=A

    else:
        ans=(A*x)+x

    flag=False


print(ans)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:

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

    span_len = A+B
    # span中に何回繰り返しがあるか
    span_count = N // span_len

    span_remain = N % span_len
    print(span_count, span_remain)
    if (span_remain == 0) :
        ans = span_count * A
        print(ans)
    elif (span_remain < A) :
        ans = span_count * A + span_remain
        print(ans)
    else :
        ans = span_count * A + A
        print(ans)


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
List = [int(i) for i in input().split()]
if List[1] != 0:
    add = 0
    if List[0] % (List[1] + List[2]) > List[1]:
        add = List[1]
    else:
        add = List[0] % (List[1] + List[2]) > List[1]
    print(math.floor(List[0] / (List[1] + List[2])) * List[1] + add)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
co=0
i=0
while (A+B)*i<N:
    co=co+A
    i+=1
print(co)

Submission status: Wrong Answer

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

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

t=A*r+s

print(t)

Submission status: Wrong Answer

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

#Process
nokori = 0
na = int(N / (A + B))
if((A+B)*na + A > N):
    nokori = N % (A + B)
Ans = A * na + nokori

#Output
print(Ans)

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif n <= a:
    print(n)
elif a < n and n <= a+b:
    print(a)
else:
    mul = n // (a+b)
    mod = max(n - mul*a - mul*b, 0)
    print(mul*a + mod)

Submission status: Wrong Answer

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

if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n < a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
i_str = input()
N,A,B = map(int,i_str.split())

AB = A+B

waru = (N // AB)
amari = N % AB
answer = waru * A + amari
print(answer)

Submission status: Wrong Answer

Solution code:
import math

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


def func():
    if A==0 and B == 0:
        return 0
    
    AB = A+B
    div = math.ceil(N/AB)
    blue = A*div
    count= AB*div
    
    if count>N:
        remain = count - N - B
        if remain > 0:
            blue = blue - remain
    return blue

print(func())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - b * x) <= a:
            print(n - b * x)
        else:
            print(a * x + a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n < a+b:
    if n <= a:
        print(n)
    else:
        print(a)
else:
    print(a*m+s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A == 0:
    print(0)

amari = N % (A + B)

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

Submission status: Wrong Answer

Solution code:
# Author: cr4zjh0bp
# Created: Sat Mar  7 12:01:50 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
 
from math import ceil
 
N, A, B = na()
C = N % (A + B)
if C == N:
    print(A)
else:
    print(A * (N // (A + B)) + (C if C <= A else A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

balls= 0
blue = 0

for i in range(10**18):
  if i % 2 == 0:
    balls = balls + a
    blue = blue + a
  else:
    balls = balls + b
  if balls >= n:
    break

print(blue)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
lst = []
for i in range(A):
    lst.append("b")
for i in range(B):
    lst.append("r")
# print("lst:", lst)

if len(lst) >= N:
    lst = lst[:N]
    print(lst.count('b'))
else:
    lst2 = []
    while len(lst2) < N:
        lst2 += lst
    lst = lst[:N]
    print(lst.count('b'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

ss = s.split(" ")

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

if A == 0:
  print(0)
else:
  if N <= A + B :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) # A > 0
    mod = N % ( A + B )
    ans = div * A

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif n <= a:
    print(n)
elif a < n and n <= a+b:
    print(a)
else:
    mul = n // (a+b)
    mod = (n - mul*a - mul*b)
    print(mul*a + mod)

Submission status: Wrong Answer

Solution code:
#AtCoder

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

sm = A + B
n = N // sm
amari = N % sm

blue = n*A + amari
print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
count = 0
while True:
  n %= (a+b)
  count += 1
  if n < (a + b):
    break
if n <= a:
  print(a * count + n)
else:
  print(a * count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
List = [int(i) for i in input().split()]
if List[1] != 0:
    print(math.floor(List[0] / (List[1] + List[2])) * List[1] + List[0] % (List[1]+List[2]))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, a, b = map(int, input().split())

m = n % (a + b)

if (m <= a):
    v = m
elif m >= a:
    v = a

print(int((n * a) / (a + b)) + v)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
Sum = A + B
if A == 0:
    print('0')
    exit()
if B == 0:
    print(N)
    exit()
ans = (N // Sum) * A
if N >= Sum:
    ans += N - Sum
if N < Sum:
    ans += A
    if N < A:
        ans=N
print(ans)

Submission status: Wrong Answer

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

c=a+b
if c==0:
    print(0)
if a==0:
    print(0)
if c!=0 and a!=0:
    d=n//c
    num=a*d
    if n%a<=b:
        print(num)
    else:
        print(num+n%a-b)

Submission status: Wrong Answer

Solution code:
ballinput = input().split(" ")
Nball = int(ballinput[0])
blue = int(ballinput[1])
red = int(ballinput[2])
diff = 0
sumball = blue + red
con1 = Nball >= 1 and Nball <= 10^18
con2 = sumball > 0 and sumball <= 10^18
if con1 == True and con2 == True:
  if blue >= 0 and red >= 0:
    if sumball == Nball:
      print(blue)
    elif blue == 0:
      print(0)
    elif red == 0:
      print(blue)
    else:
      diff = Nball - sumball
      blue = blue + diff
      print(blue)
  else:
    print()
else:
  print()

Submission status: Wrong Answer

Solution code:
N,A,B = (int(x) for x in input().split())
S =  N % (A+B) - A
Acount = N % (A+B)
Ansn = int(N / (A + B) * A)
if S <= 0:
    print(Ansn + Acount)
else:
    print(Ansn + A)

Submission status: Wrong Answer

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

nokori = N - result
if N % (A+B):
    if nokori - A <= 0:
        result += nokori
    else:
        result += A

print(result)

Submission status: Wrong Answer

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

all = a + b

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

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

# a > 0
c = round(N / all)
d = N % all

roundCnt = a * c

if d <= a :
    amariCnt = d
else:
    amariCnt = a

print(roundCnt + amariCnt)


#a = 0 print 0
#a > 0
# N <= a print N
# N > a
#  N/(a+b)=c     が割り切れる  a * c
#  N/(a+b)=c...d が余りが出る  a * c
#    d <= a のとき a * c + d
#    d >  a のとき a * c + a
#

Submission status: Wrong Answer

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

i = 0
i = int(n / (a + b)) + 1
print(i)
if ((a + b)*i) - n <= b:
    print(a * i)
else:
    num1 = ((a + b)* i) - n
    num2 = a * i
    num3 = num1 - b
    print(num2 - num3)

Submission status: Wrong Answer

Solution code:
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
count=0

if a==0:
  print('0')
  exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    else:
      break

ball=a*count+n

print(ball)

Submission status: Wrong Answer

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

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


if A == 0 :
    print(0)

elif N >A+B :
    if mod <= A :
        print(q*A+mod)
    if mod > A :
        print(q*A+A)
    
elif N == A+B :
    print(q*A)

elif N < A+B :
    print(N)

Submission status: Wrong Answer

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

balls= 0
blue = 0

for i in range(10**18):
  if i % 2 == 0:
    balls = balls + a
    blue = blue + a
  else:
    balls = balls + b
  if balls > n:
    break

print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
List = [int(i) for i in input().split()]
print(math.floor(List[0] / (List[1] + List[2])) * List[1] + List[0] % (List[1]+List[2]))

Submission status: Wrong Answer

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

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

print(A*q + r)

Submission status: Wrong Answer

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

if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n <= a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)

Submission status: Wrong Answer

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

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * max(count, 1) + min(A, amari)

print(sum_blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = []
i = 0
j = 0
while i+j < n:
    i += a
    if i+j < n:
        j += b


if i < j:
    print(i)
else:
    print(i-(i+j-n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
count=0
flag=True
pattern=True
ans=0
num=A+B
while flag:
    x=N%num
    if x==0:
        if A>0:
            ans=A
        else:
            ans=(A*x)+x
    else:
        ans=(A*x)+x

    flag=False
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
d = 0
l = a // (b+c)
k = a % (b+c)
if b == 0:
    print('0')
    
elif b + c >= a:
    if b < a:
        print(b)
    elif b > a:
        print(a)
    
elif b + c < a:
    if a % (b + c) == 0:
        print(int(l))
    elif a % (b + c) != 0:
        print(int(l*b + k))

Submission status: Wrong Answer

Solution code:
N ,b_int ,r_int = map(int, input().split())

b_count = 0
total_count =0

while True:
 
  i = 0
  while i < b_int:
    b_count += 1
    total_count +=1
    i += 1
    if total_count >= N:
      break
    total_count += r_int
  if total_count >= N:
    break

    
print(b_count)

Submission status: Wrong Answer

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

if a + b == 0:
    x = 1
else:
    x = a + b

c = n // x
if c == 0:
    d = a + b
else:
    d = n - (c * (a+b))

if d > a:
    ans = (c*a) + a
else:
    ans = (c*a) + d
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,B,R = input().split()
N = int(N)
B = int(B)
R = int(R)
X = B + R
Z = N // X
Y = N % X
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y > B:
        print(B*Z + Y-B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a != 0:
    rem = n % (a+b)
    quo = n // (a+b)

    print(quo*a + rem)
    
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n, a ,b = list(map(int,(input().split())))
k = n//(a+b)
am = n%(a+b)

print(a*k+am)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()
if a == 0 and b == 0:
    print(0)
elif a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n // (a+b)
    c = n % (a+b)
    if c <= a:
        print(a*cnt+c)
    else:
        print(a*cnt+c-b)

Submission status: Wrong Answer

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

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

flg = True
if A == 0:
    print(0)
    flg = False

if B == 0:
    print(N)
    flg = False

if flg:

    zentai_num = N // (A + B)
    zentai_b = zentai_num * A

    amari_num = N % (A + B)

    amari_b = 0
    if amari_num >= B:
        amari_b = B
    else:
        amari_b = amari_num

    # amari_b = max(amari_num - B,0)

    # print(amari_num,amari_b)

    print(zentai_b + amari_b)

Submission status: Wrong Answer

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


print(int(x + y))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if (rest > A):
    result = A*num_move
else:
    result = A*(num_move-1)+rest

print(result)

Submission status: Wrong Answer

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

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

if n <= blue:
    print(n)
    exit()

if n <= blue + red:
    print(blue)
    exit()

temp = n // (blue + red)
cnt = temp * blue
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()

ss = s.split(" ")

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

if A == 0:
  print(0)
else:
  if N <= A + B :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) # A > 0
    mod = N % ( A + B )
    ans = div * A

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

Submission status: Wrong Answer

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

count = -(-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)

print(sum_blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = (int(x) for x in input().split())
S =  N % (A+B) - A
Acount = N % (A+B)
Ansn = N / (A + B) * A
if S <= 0:
    print(int(Ansn + Acount))
else:
    print(int(Ansn + A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, A, B = map(int, input().split())

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

s = A + B

a = N // s

ans = A*a
nokori = N-s*a

if nokori <= A:ans += nokori

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0:
    print(0)
else:
    num = int(N / (A + B)) * A
    # print("num:", num)
    num += N % (A + B)
    # print("num:", num)
    print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x1=n//(a+b)
x2=(-(-n//(a+b)))
if x1 == 0:
  x = x2
else:
  x = x1

y = n % (a+b)

print((a*x)+y)

Submission status: Wrong Answer

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

s = 0
t = 0
while True:
  n -= (a+b)
  s += 1
  if n < (a+b):
    break
if n < a:
  print(s*a + n)
else:
  print(s*a + a)

Submission status: Wrong Answer

Solution code:
[N, A, B] = list(map(int, input().split()))
b_f = (A + B + N -1) // (A + B)
b_l = (A + B) * b_f - B

if N > b_l:
  ans = A * b_f
else:
  ans = A * (b_f - 1) + b_l - (N + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
lst = [int(i) for i in input().split()]

ball = lst[0]
blue = lst[1]
red = lst[2]

red_blue = int(ball / (red + blue))
shokichi = red_blue * red
amari = ball - (red_blue * (red + blue))

if amari > blue:
    nokori = amari - blue
else:
    nokori = 0

if blue == 0:
    print(0)
else:
    print(shokichi + nokori)

Submission status: Wrong Answer

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

count = -(-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)
print(A * count)
print(amari)
print(sum_blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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