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

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

if A>=N:
    print(N)
else:
    s, a = divmod(N, A+B)
    print(s*A+a)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
xx=min(a,b)
if xx==0:
    if a==0:
        print(0)
    else:
        print(n)
    exit()
yy=n//xx
baaki=n-(a*(yy-1))-(b*(yy-1))
ans=a*(yy-1)
if baaki<=a:
    print(ans+baaki)
else:
    ans+=a 
    baaki-=a
    baaki-=b 
    if baaki<=0:
        print(ans)
    else:
        print(ans+baaki)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

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

    # k = n // (a+b): 完璧にループがおわったぶん
    # ここにあるBlueはa*k
    # n -( k*(a+b)) : 端数
    # ここにあるBlueはn-(k*(a+b))
    k = n // (a+b)
    print(a*k + n -(k*(a+b)))
    return 

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
N, A, B = map(int, input().split())

AB = A+B
if AB == 0:
    print(0)
    exit()

if A >= N:
    print(N)
elif AB >= N:
    print(A)
else:
    cnt = A * (N//AB)
    cnt += N % AB
    print(cnt)

Submission status: Wrong Answer

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

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(A * int(N / (A + B)) + amari)
else:
    print(A * int(N / (A + B)) + A)

Submission status: Wrong Answer

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

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

N = N - (A + B) * x
result += N
print(result)

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:
  C=A+B
  cnt=0
  while N>=A:
    N -= C
    cnt+=1
  
  print(A*cnt+N)

Submission status: Wrong Answer

Solution code:
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

d,m = divmod(n,a+b)

print(d*a+m if m<=a else d*a+m-b)

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 + mod) * d
    print(c)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
number = input().split(" ")
N = int(number[0])
B = int(number[1])
R = int(number[2])

a = int(N/(B+R))
b = int(N%(B+R))

if R == 0:
    print(N)
elif B == 0:
    print(0)
else:
    print(a*B+b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
z=0
x=n
if a==0:
    print(0)
    sys.exit()
while 1:
    z+=a
    n-=(a+b)
    if n<=a:
        break
print(z+x-(a+b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A == 0:
    print(0)

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

    elif N > A + B:
        print(A+N-(A+B))

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int,input().split())
print (math.ceil(N*A/(A+B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
ans = kurikaeshi * a
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
for i in range(1,kurikaeshi+2):
    for j in range(1,a+1):
        ball_list.append('b')
    for k in range(1,b+1):
        ball_list.append('r')
for l in range(0,a+1):
    if(ball_list[amari] == 'b'):
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0 :
  print("0")
elif a==n or (a+b)==n :
  print(a)
elif (a+b)<n :
  print(a+(n-(a+b)))
elif (a+b)>n :
  print(n)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = N % S if S != 0 else 0
print(A*count + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def answer(N, A, B):

    if N > A:
        return A
    else:
        return N

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a!=0:
    if n<a+b:
        print(a)
    else:
        res = n - (a+b)
        num = (res+1)//2
        print(a+num)
else:
    print(0)

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
    if (span_remain == 0) :
        ans = span_count * A
        print(ans)
    elif (span_remain < A) :
        ans = span_count * A + (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())

#print(n)
if((a+b) != 0):
    s = n//(a+b)*a
    l = n - n//(a+b)*(a+b)
    print(s+l)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b
    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

if doTest==0:
    resolve()
    sys.exit()

Submission status: Wrong Answer

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

wa = a+b
print(n // wa * a + n % wa)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = N // (A+B)
b = N % (A+B)
print(A*a + b)

Submission status: Wrong Answer

Solution code:
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
m=n%(a+b)
l=(n-m)/(a+b)
if m>a:
  y=a
else:
  y=m
x=a*l+y
x=round(x)
print(x)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
count = 0
c = n // (a+b)
c2 = n % (a+b)

ans = c*a + c2
        
print(ans)

Submission status: Wrong Answer

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

while total < n:
  i += 1
  blue = a*i
  total = a*i + b*i

num = total - a - b
num2 = blue - a

if total == n:
  print(blue)
else:
  print(num2 + (n - num))

Submission status: Wrong Answer

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

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


n,a,b = list(map(int,input().split()))
"""
if n<a+b:
    l = (a+b)//n
    p = min((a+b)%n,a)

    print((l*a)+p)
else:
    ans = (n//(a+b))*a
    ans += min(n%(a+b),a)
    print(ans)
"""
tmp = 0
ans = 0
while 1:
    if tmp+(a+b)>n:
        ans += n%(a+b)
        break
    tmp+=n
    ans += a
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)

    ans = (k * A) + g
    if N <= (A + B):
        print(A)
    elif A == 0:
        print(0)
    else:
        print(ans)

    return 0
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(A)

Submission status: Wrong Answer

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


if N>=(A+B):
    amari = N%(A+B)
    syou  = N//(A+B)
    sum = 0
    if syou>=1:
        syou = syou * A
        sum = sum + syou
    sum = sum + amari
    print(sum)
else:
    if N>=A:
        print(A)     
    else:
        print(N)

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 + m)
else:
    print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    if A != 0:
        print(N-pow(10, 100, A+B))
    else:
        print(0)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n, a, b = map(int, input().split())
if (a + b) * (10**100) <= n:
    print(a * (10**100))
    sys.exit()
else:
    for i in range(n):
        if (a + b) * i <= n < (a + b) * (i + 1):
            if n - (a + b) * i >= a:
                print(a * i + a)
                sys.exit()
            else:
                print(a * i +n-(a + b)*i )
                sys.exit()

Submission status: Wrong Answer

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

    ao_count = 0

    count_num = N / (A + B)
    amari_num = N % (A + B)

    ao_count = count_num * A
    if amari_num <= A:
        ao_count += A


    print(ao_count)



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

if(irest>B):
    print((i+1)*A)
else:
    print(i*A+irest)

Submission status: Wrong Answer

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

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

ans = 0

num_rb = n//(a+b)

if num_rb == 0:
    if n >= a:
        print(a)
        exit(0)
    else:
        print(n)
        exit(0)

ans += (num_rb)*a
ans += n - num_rb*(a+b)

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
sho = N//(A+B)
zantei = sho*A
amari = N%(A+B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif zantei == 0:
    print(A)
else:
    print(zantei+amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data = input()

b, r, N = [int(i) for i in data.split()]

total = b + r

def count():
    remain = N%total
    if remain < b:
        return remain
    else:
        return b
      
ball = int(N/total) * b + count()
print(ball)

Submission status: Wrong Answer

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

print(x*A + add)

Submission status: Wrong Answer

Solution code:
li = list(map(int,input().split()))
a = 0
b = 0
out = 0
isA = True
for i in range(li[0]):
    if(isA):
        a += 1
        out += 1
        if(a >= li[1]):
            isA = False
            a = 0
    else:
        b += 1
        if(b >= li[2]):
            isA = True
            b = 0
print(out)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if (n % (a+b)) <= a:
    res += n % (a+b)
else:
    res += a

print(int(res))

Submission status: Wrong Answer

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B >= N:
    print(A)
else:
    r = int(N / (A+B))
    q = N % (A+B)
    print(r * A + q)

# -----
# 8 4 2

# bbbbrrbb bb

# 13 4 2
# bbbb rr bbbb rr b

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

# r * A + q

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):
    x = N // (A+B)
    r = N % (A+B)

    ans = A * x + r
    if r >= B:
        ans -= B

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

NAB=np.array(input().split(" "),dtype=np.int32)

N=NAB[0]
A=NAB[1]
B=NAB[2]

out=[]
blue_flag=True
blue_count=0
red_count=0
for i in range(N):
    if(blue_count<A):
        red_count=0
        blue_count+=1
        out.append("b")
    else:
        if(red_count<B):
            red_count+=1
            out.append("r")
        else:
            blue_count=0
            if(blue_count<A):
                out.append("b")
            else:
                red_count=0
                if(red_count<B):
                    out.append("r")

print(out.count("b"))

Submission status: Wrong Answer

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

bl = int(n / (a + b))
m = n % (a + b)

r = (bl * a) + m
print(r)

Submission status: Wrong Answer

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

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

print(p*(a+b)-p*b+ (q if q <= a else 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    N,A,B = map(int,input().split())
    k = math.floor(N/(A+B))
    if N-(A+B) * k <= A:
        print(N-B*k)
    else:
        print(2*A*k)



if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):
    dev = N // (A+B)
    rem = N % (A+B)
    return A*dev + rem


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(N, A, B))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main(N, A, B):

    if A == 0:
        return 0
    if A == 0 and B == 0:
        return 0
    
    # main
    sumBlue = A * N // (A + B)

    # amari
    sumBlue += min(B, N % (A + B))

    return sumBlue

if __name__ == "__main__":

    answer = main(N, A, B)
    print(answer)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

s = n // (blue + red)
a = n % (blue + red)

ans = 0
if blue > 0:
    ans += a
print(ans + s * blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if b==0:
    print(0)
else:
    sets=n//(a+b)
    res=n%(a+b)

    resa=min(res,a)

    print(sets*a+resa)

Submission status: Wrong Answer

Solution code:
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n/(a+b)
print(math.ceil(ans*a))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
try:
    ans = math.ceil(n / (a + b) * a)
except Exception as e:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while 1:
  n -= a + b
  count += a
  if n < a:
    count += n
    print(count)
    exit()
    
  elif n <= 0:
    print(count)
    exit()

Submission status: Wrong Answer

Solution code:
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

d,m = divmod(n,a+b)

print(d*a+m if m<a else d*a+m-b)

Submission status: Wrong Answer

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

each=a+b

baisu=n//each
amari=n%each

ans+=(a*baisu)

if amari<=a:
    ans+=amari
    
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
if a == 0:
  print(0)
elif n <= a:
  print(n)
elif int(n / (a + b)) == 0:
  print(a)
else:
  nn = int(n / (a + b))
  na = n // (a + b)
  sum = nn * a + min(na,a) 
  print(sum)

Submission status: Wrong Answer

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

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

ans = 0

num_rb = n//(a+b)

if num_rb ==0:
    if n >= a:
        print(a)
    else:
        print(n)

ans += (num_rb)*a
ans += n - num_rb*(a+b)

print(ans)

Submission status: Wrong Answer

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

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

amari = N%(A+B)

if amari > A:
    print(A*div + amari + A)
else:
    print(A*div + amari)

Submission status: Wrong Answer

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

a = N % (A+B)

M = N - (A+B)*a

if M >= A:
    print(a*A+A)

else :
    print(a*A+M)

Submission status: Wrong Answer

Solution code:
number = input().split(" ")
N = int(number[0])
B = int(number[1])
R = int(number[2])

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

box = []
counter = 0
while True:
    for i in range(a):
        box.append("b")
    
    for i in range(b):
        box.append("r")
    if(counter == n or counter == a+b):
        break

    counter += 1

ans = 0
counter = 1
for j in box:
    if(j == "b"):
        ans += 1
    if(counter == n or counter == a+b+1):
        print(ans)
        break
    counter += 1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):
    x = N // (A+B)
    r = N % (A+B)

    ans = A * x + r
    if r >= B:
        ans -= r

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
C = A + B
result = 0
if A < N:
    result = int(N / C) * A + N % C
else:
    result = N

print(result)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a>n:
    print(n)
else:
    for i in range(pow(10,18)):
        if i*(a+b)>n:
            print(n-(i-1)*b)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
count = 0
while(n>0 and count<=10000):
    n -= a
    if n >= 0:
        ans += a
    else:
        ans += a + n
    n -= b
    count += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = (int(x) for x in input().split())
M = N//(A+B)
L = N%(A+B)
print(M*A + L)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
c = n - a
s = c - b
if a == 0:
  print(0)
else:
  print(s+a)

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()
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:
import math
n , a , b  = map(int, input().split())
if a >- n : exit(print(n))
ans = n/(a+b)
print(math.ceil(ans*a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
sum_num = a + b
iter_num = int(n/sum_num)
rest = n - iter_num * sum_num
print(a * iter_num + rest)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    c , d = divmod(N, A+B)
    print(A*c+d)

Submission status: Wrong Answer

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

if A==0:
    print(0)
else:
    b=N//(A+B)
    x=N%(A+B)
    print(b*A+x)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
xx=min(a,b)
if xx==0:
    if a==0:
        print(0)
    else:
        print(n)
    exit()
yy=n//xx
baaki=n-(yy*xx)
# print(baaki)
baaki-=(max(a,b)-xx)
# print(baaki,yy)
print(((yy-1)*a)+baaki)

Submission status: Wrong Answer

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

answer =0

if A==0:
    answer = 0
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

Submission status: Wrong Answer

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

if c > 0:
    print(a*c + (n - (a+b)*c))
else:
    print(min(a,n))

Submission status: Wrong Answer

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

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

    print(blue)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

print((A * q) + max((mod - B), mod))

Submission status: Wrong Answer

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

if a == 0:
    print(0)
else:
    rest = n - a + b
    res = a + rest
    print(res)

Submission status: Wrong Answer

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