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,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 + B)

Submission status: Wrong Answer

Solution code:
from math import floor
from sys import exit
n, a, b = map(int, input().split())
if a == 0:
    print(0)
    exit()
if n < (a + b):
    if n <= a:
        print(n)
    else:
        print(a)
    exit()
pre_a = n / (a + b)
if pre_a == int(pre_a):
    print(int(pre_a*a))
else:
    mod = n % (a + b)
    if mod >= a:
        print((floor(pre_a)*a)+a)
    else:
         print((floor(pre_a)*a)+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, r = [int(x) for x in input().split()]
if b>0:
    b+=1
    print(b)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n, a, b=map(int,input().split())
k = n / (a + b)
l = n % (a + b)
res = k * a + l
print('{:.0f}'.format(res))

Submission status: Wrong Answer

Solution code:
N,b,r = map(int,input().split())
if (b == 0 ):
	print(0)
else: 
	shou =int( N / (b +r) )
	amari = int (N % (b + r) )
	print(shou*b + amari)

Submission status: Wrong Answer

Solution code:
def main():
  n, a, b = list(map(int, input().split()))
  if a == 0:
    return 0
  if b == 0:
    return n
  if n <= a:
    return n
  if (a + b) >= n:
    return a
  
  temp = n - a
  set_count = temp // (a + b)
  mod = temp % (a + b)
  blue_in_mod = 0 if mod <= b else mod - b
  
  return a + (set_count * a) + blue_in_mod

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    for i in range(10 ** 100):
      length = (i + 1) * str_length
      if length >= n:
        blue_count = (i + 1) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        print(blue_count + add)
        break

Submission status: Wrong Answer

Solution code:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans = 0
        while n>0:
            if n < a:
                ans += a-n-1
                break
            else:
                n-=a
                if n >0:
                    ans += a
            n-=b
        print(ans)

if __name__ == "__main__":
    resolve()

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 + B)
    elif Y > B:
        print(B*Z + B)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
k=0
h=a
while a>0:
    k+=b
    a=a-b-c
j=h-b-c
if j>0 and b!=0:
    print(k+j-b)
else :
    print(k)

Submission status: Wrong Answer

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

if(N <= (A+B)):
    if(N<=A):
        print(N)
    else:
        print(A)
else:
    ans = (N//(A+B)) * A
    if((N % (A+B)) <= A):
        ans +=( N % (A+B))
    elif((N % (A+B))-A <= A):
        ans+=(N % (A+B))-A
    print(ans)

Submission status: Wrong Answer

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

mod = N%C
quo = N//C

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif quo == 0:
    if N <= A:
        print(N)
    else:
        print(N-(N%A))
elif mod == 0:
    print(quo*A)
elif mod <= A:
    print((quo)*A+mod)
else:
    print((quo)*A+(mod - mod%A))

Submission status: Wrong Answer

Solution code:
[N, A, B] = list(map(int, input().split()))
if A == 0:
  ans = 0
elif B == 0:
  ans = N
else:
  n = N // (A + B)
  yo = N % (A + B)
  if 0 < yo <= A:
    ans = A * n + yo - 1
  elif yo == 0:
    ans = A * n
  else:
    ans = A * (n+1)
print(ans)

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):

    # if A+B < N : N = A+B
    if N <= A : print(N)
    else : 
        k = N // (A+B)
        rem = N - (A+B)*k
        b_ = A - rem
        if  b_ >= 0: print(k*A+rem)
        else : print(k*A)


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

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

    print(mul*a + mod)

Submission status: Wrong Answer

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

cnt=0
ans=0

while cnt<N:
    if cnt%(A+B)<A:
        cnt+=1
        ans+=1
    else:
        cnt+=1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 何個目のボールを持ってくる？青いボールは何個？赤いボールは何個？
take_number, blue_ball, red_ball = input().split()
take_number = int(take_number)
blue_ball = int(blue_ball)
red_ball = int(red_ball)

blue_count = 0
blue_ball_num = 0
N = take_number - blue_ball
loop = 10 ** 100

for i in range(loop):
  if N < 0:
    blue_ball_num = blue_ball - N
    break
  else:
    blue_count = blue_count + 1
    N = N - red_ball
    if N <= 0:
      break
    else:
      N = N - blue_ball
  
num = (blue_ball * blue_count) + blue_ball_num
print(num)

Submission status: Wrong Answer

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

d = n % (a + b)
s = (n - d) / (a + b)

if d < a:
    ans_d = d
else:
    ans_d = a

ans = s * a + ans_d

print(int(ans))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, raw_input().split())
s=a+b
if n > s * 10**100:
    print a * 10**100
else:
    print n/s*a + n%s if n%s <= a else a

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    for i in range(10 ** 100):
      length = (i + 1) * str_length
      if length >= n:
        blue_count = (i * 1) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        print(blue_count + add)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, bu, re = list(map(int, input().split(" ")))

ttlBu, ttlRe = 0, 0
ttl = lambda: ttlBu + ttlRe

while True:
    # blue
    if ttl() + bu > n:
        ttlBu += n - ttl()
        print(ttlBu)
        exit()
    else:
        ttlBu += bu
    # red
    if ttl() + re > n:
        ttlBu += n - ttl()
        print(ttlBu)
        exit()
    else:
        ttlRe += re

Submission status: Wrong Answer

Solution code:

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

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

if N <= A:
    print(N)
    exit()

if A+B == N:
    print(A)
    exit()

print( N - B )

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):

    # if A+B < N : N = A+B
    if N <= A : print(A)
    else : 
        k = N // (A+B)
        rem = N - (A+B)*k
        b_ = A - rem
        if  b_ >= 0: print(k*A+rem)
        else : print(k*A)


    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 = map(int,input().split())
n = N -(A+B)
rb = A + B

count = 0

while n >= 0:
    if n >=0:
        count += 1
        n -= rb

blue1 = count * A
blue2 = N - count * rb

if blue2 > A:
    print(blue2-B+blue1)
else:
    print(blue2+blue1)

Submission status: Wrong Answer

Solution code:
n, an, bn = map(int, input().split())
print("0" if an == 0 else an + max(max(n - an, 0) - bn, 0))

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 or Y == B:
        print(B*Z + Y)
    elif Y > B:
        print(B*Z + B)

Submission status: Wrong Answer

Solution code:
N, A, B=map(int,input().split())
llist=[N]
r=B
b=A
for i in range(N-1 ):
    if b!=0:
       llist.append("blue")
       b=b-1
    elif r!=0:
        llist.append("red")
        r=r-1
        if r==0:
            b=A
    else : break
print(llist.count("blue"))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

    print(mul*a + mod)

Submission status: Wrong Answer

Solution code:
[N, A, B] = list(map(int, input().split()))
if A == 0:
  ans = 0
elif B == 0:
  ans = N
else:
  n = N // (A + B)
  yo = N % (A + B)
  if yo <= A:
    ans = A * n + yo - 1
  else:
    ans = A * (n+1)
print(ans)

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    print(A * s + add)
    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 = input().split()
N = int(N)
A = int(A)
B = int(B)
C = A + B

mod = N%C
quo = N//C

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif quo == 0:
    if N >= A:
        print(N)
    else:
        print(N-(N%A))
elif mod == 0:
    print(quo*A)
elif mod <= A:
    print((quo)*A+mod)
else:
    print((quo)*A+(mod - mod%A))

Submission status: Wrong Answer

Solution code:
from math import floor
from sys import exit
n, a, b = map(int, input().split())
if a == 0:
    print(0)
    exit()
pre_a = n / (a + b)
if pre_a == int(pre_a):
    print(int(pre_a*a))
else:
    mod = n % (a + b)
    if mod >= a:
        print((floor(pre_a)*a)+a)
    else:
         print((floor(pre_a)*a)+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import *
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())
    C=A+B
    if C>N:
      
      ans=A
    else:
      K=N/C
      pp=int(K)*A
      ans=pp+(N%C)
    if A>N:
      ans=N
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
N,B,R = map(int,input().split())
if B == 0:
  print(0)
if B == 0 and R != 0:
  print(N)
limit = math.floor(N/(B+R)) #genkai
blue = limit*B
N -= limit*(B+R) #15 of 100,10,7
if N-B < 0:
    print(blue+N)
    sys.exit(0)
else:
  while True:
    N-=1
    blue += 1
    if N < 0:
      print(blue)
      sys.exit(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

mod = N%C
quo = N//C

if A == 0:
    print(0)
elif quo == 0:
    if N >= A:
        print(N)
    else:
        print(N-(N%A))
elif mod == 0:
    print(quo*A)
elif mod <= A:
    print((quo)*A+mod)
else:
    print((quo)*A+(mod - mod%A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
elif b == 0:
    print(n)
elif a + b>n:
    print(a)
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:
import sys

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

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

if q == 0:
  ans = n-a
  if ans<0:
    print(n)
    sys.exit()
  else:
    print(a)
    sys.exit()

print(a*q+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    for i in range(10 ** 100):
      length = (i + 1) * str_length
      if length > n:
        blue_count = (i * 1) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        print(blue_count + add)
        break

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif a + b >= n and n > a:
    print(a)
elif a + b >= n and n < a:
    print(n)
else:
    print(d)

Submission status: Wrong Answer

Solution code:
def countballs():
  list1 = list(map(int,input().split()))
  N,A,B=list1[0],list1[1],list1[2]
  if (A>0 and A<N):
    sum1 = N-B
    return sum1
  elif (A==0):
    return A
output = countballs()
print(output)

Submission status: Wrong Answer

Solution code:
import sys
from math import *
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())
    C=A+B
    if C>N:
      if N<A:
        ans=N
      ans=A
    else:
      K=N/C
      pp=int(K)*A
      ans=pp+(N%C)
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if A == 0:
  print(0)
elif N%(A+B) == 0:
  print(int(N/(A+B)))
else:
  print(int(N/(A+B))+int(min(N%A+B,A)))

Submission status: Wrong Answer

Solution code:
N, A, S = map(int, input().split())
Blue = 0
K = 0
K = N % (A + S)
N //= (A + S)
if N != 0:
    if N >= A:
        Blue = (N*A) + A
    else:
        Blue = (N*A) + K
print(Blue)

Submission status: Wrong Answer

Solution code:
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
data2 = int(data[0]) / data1
total = data[1]*data2
tmp = data1*data2
data3 = data[0]%data1
  
if (data3 != 0) and (data3 < data[1]):
    total += data3
elif data3 > data[1]:
    total += data[1]

print(int(total))

Submission status: Wrong Answer

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

if A <= 0:
    print(0)
else:
    if N > A+B:
        print(N-B)
    else:
        if A > N:
            print(N)
        else:
            print(A)

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
ballrow = list()
outputlist = list()
outputdict = dict()
output = 0
for i in range (0,blue):
    ballrow.append('b')
for i in range (0,red):
    ballrow.append('r')
if con1 == True and con2 == True:
  if blue >= 0 and red >= 0:
      if blue == 0:
          print(0)
      elif len(ballrow) != Nball:
          diff = Nball - sumball
          for i in range (0, diff):
              ballrow.append('b')
          for i in ballrow:
              outputdict[i] = ballrow.count(i)
          for i in outputdict.values():
              output = i
              break
          print(output)
      else:
          for i in ballrow:
              outputdict[i] = ballrow.count(i)
          for i in outputdict.values():
              output = i
              break
          print(output)
  else:
       print()
else:
    print()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from math import *
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())
    C=A+B
    if C>N:
      ans=A
    else:
      K=N/C
      pp=int(K)*A
      ans=pp+(N%C)
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

g = a + b

ans1 = (n % g) * a
rem = n - ((n % g) * g)
ans2 = min(rem, a)

print(ans1 + ans2)

Submission status: Wrong Answer

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

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(A - N)
    else:
        print(A)
else:
    print(0)

Submission status: Wrong Answer

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

b = 0
r = 0

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

Submission status: Wrong Answer

Solution code:
N, A, S = map(int, input().split())
Blue = 0
K = 0
K = N % (A + S)
N //= (A + S)
print(N,K,Blue)
if N != 0:
    if N >= A:
        Blue = N + A
    else:
        Blue = N + K
print(Blue)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x=n%(a+b)
y=n//(a+b)
for i in range(1,a+1):
    if i==x:
        print(a*y+x)
        break
    elif x==0:
        print(a*y)
    else:
        print(a*(y+1))

Submission status: Wrong Answer

Solution code:
input_line = input().split(" ")
numArray = [int(i) for i in input_line]
 
if numArray[1] == 0:
  print(0)
elif numArray[2] == 0:
  print(numArray[0])
elif numArray[0] == 1:
  print(1)
elif numArray[0] == numArray[1] or numArray[0] == (numArray[1] + numArray[2]):
  print(numArray[1])
elif numArray[0] <= numArray[1]:
  print(numArray[0])
else:
  if (numArray[0] % (numArray[1] + numArray[2])) == 0:
    print(numArray[1] * (numArray[0] / (numArray[1] + numArray[2])))
  else:
    blueball = numArray[1] * (numArray[0] // (numArray[1] + numArray[2]))
    number = numArray[0] - (numArray[0] % (numArray[1] + numArray[2]))
    if number < numArray[1]:
      print(blueball + number)
    else:
      print(blueball + numArray[1])

Submission status: Wrong Answer

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

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 or Y == B:
        print(B*Z + B)

Submission status: Wrong Answer

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

b = 0
r = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, b, r = map(int, input().split())
b1 = n//(b+r)
b2 = n % (b+r)
if b == 0:
    print(0)
elif n % (b+r) != 0:
    b1 = b1*b + b
    print(b1)
elif n % (b+r) == 0:
    print(b1*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = n // d
n = n % d

if n <= a:
    print(a*c + n)
else:
    print(a*c)

Submission status: Wrong Answer

Solution code:
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
z = int(N % (A + B))
y = x * A
y = y + z
print(y)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = [int(i) for i in input().split()]
count = A + B
setCount = math.floor(N / count)
amari = N - math.floor(setCount) * count
result = setCount * A + amari
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


mod = N%C
quo = N//C

if A == 0:
    print(0)
elif mod == 0:
    print(quo*A)
elif mod <= A:
    print((quo)*A+mod)
else:
    print((quo)*A+(mod - mod%A))

Submission status: Wrong Answer

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

G=int(N-A-B)
print(A+G)

Submission status: Wrong Answer

Solution code:
N,A,B = input().split()
N = int(N)
A = int(A)
B = int(B)
C = A + B
if N % C == 0:
    T = int(N / C)
elif N / C < int(N / C):
    T = int(N / C) - 1
else:
    T = int(N / C)
if N - T * C > 0:
    count = T * A + (N - T * C)
    print(count)
else:
    count = T * A
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import *
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())
    C=A+B
    if B!=0:
      K=N/C
      pp=int(K)*A
      ans=pp+(N%C)
    else:
      ans=N
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

sho = n // (a + b)
mod = n % (a + b)
ret = sho * a + mod

print("{}".format(ret))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
l=[]
k=0
s=a-b-c+1
for i in range(s):
    for g in range(b):
        l.append("1")
    for g in range(c):
        l.append("2")
for j in range(a):
    if l==[]:
        k=0
        break
    elif l[j]== "1":
        k+=1
print(k)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if (a == 0 and b == 0) or a == 0:
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)
    print(x * a + n - (x * AB))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    (n, a, b) = [int(e) for e in input().split()]
    ans = (int(n/(a+b)))*a
    if n%(a+b) == 0:
        print(ans)
    elif n%(a+b) > a:
        print(ans + a)
    else:
        print(ans + a - n%(a+b) - 1)

Submission status: Wrong Answer

Solution code:

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

G=N-A-B
print(A+G)

Submission status: Wrong Answer

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

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 A == 0:
        print(0)
    elif N <= A:
        print(N)
    elif N <= (A + B):
        print(A)
    else:
        print(int(ans))

    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

c = n // d
n = n % d

if n <= a:
    print(a*c + n)
else:
    print(a*c)

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
R = X - Y
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y > B:
        if R == B:
            print(B*Z + B)
        elif R > B:
            print(B*Z + B)
        elif R < B:
            print(B*Z + R)

Submission status: Wrong Answer

Solution code:
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
data2 = int(data[0]) / data1
total = data[1]*data2
tmp = data1*data2
data3 = data[0]%data1
  
if (data3 != 0) and (data3 < data[1]):
  total += data3
  
print(int(total))

Submission status: Wrong Answer

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

#　商
x = n // (b + r) 

#　余り
y = n % (b + r)


if b == 0:
    print(0)
elif(n <= b):
    print(b)
elif(y == 0):
    print(x * b)
else:
    if y < b:
        print((x * b) + y)
    else:
        print((x * b) + b)