Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
max_renzoku=[]
for i in range(0,num-renzoku+1):
  max_renzoku.append(sum(dices[i:i+renzoku]))
print((max(max_renzoku)+renzoku)/2)


Fixed submission:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Buggy python submission (verdict: Runtime Error):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
max_renzoku=[]
for i in range(0,num-renzoku):
  max_renzoku.append(sum(dices[i:i+renzoku]))
print((max(max_renzoku)+renzoku)/2)

Fixed submission:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Buggy python submission (verdict: Time Limit Exceeded):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
expects_list=[]
for i in range(0,num-renzoku+1):
  expects_list.append(sum(expects[i:i+renzoku]))
print(max(expects_list))

Fixed submission:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)

Buggy python submission (verdict: Time Limit Exceeded):
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
expects_list=[]
for i in range(0,num-renzoku+1):
  expects_list.append(sum(expects[i:i+renzoku]))
print(max(expects_list))

Fixed submission:
num,renzoku=map(int,input().split())
dices=list(map(int,input().split()))
expects=[0]*num
for i in range(num):
  pi=dices[i]
  expects[i]=(1+pi)/2
Si=[0]*(num+1)
for i in range(1,num+1):
  Si[i]=Si[i-1]+expects[i-1]
max_Si=0
for i in range(0,num-renzoku+1):
  if max_Si<Si[i+renzoku]-Si[i]:
    max_Si=Si[i+renzoku]-Si[i]
print(max_Si)
Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    min_ij = 2018 ** 2
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            min_ij = min(min_ij, (i % 2019) * (j % 2019))

print(min_ij)

Fixed submission:
l, r = map(int, input().split())
if r - l >= 2018:
    print(0)
else:
    min_ij = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            min_ij = min(min_ij, ((i % 2019) * (j % 2019)) % 2019)
    print(min_ij)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

stairs = []
is_continuous = False
for i in range(m):
    stairs.append(int(input()))
    if i > 0 and stairs[i] - 1 == stairs[i - 1]:
        is_continuous = True
        break

if is_continuous:
    print(0)
else:
    countup_num = [0] * (n + 1)
    countup_num[0] = 1
    countup_num[1] = 1
    for i in range(2, n + 1):
        countup_num[i] = (countup_num[i - 1] + countup_num[i - 2]) % 1000000007
    res = 1
    diff = 0
    now = 0
    for i in range(m):
        diff = stairs[i] - now - 1
        now = stairs[i] + 1
        res *= (countup_num[diff]) % 1000000007
        # print(res, now)
    diff = n - stairs[-1] - 1
    res *= (countup_num[diff]) % 1000000007

    res %= 1000000007
    # print(countup_num)
    print(res)


Fixed submission:
n, m = map(int, input().split())

stairs = []
is_continuous = False
for i in range(m):
    stairs.append(int(input()))
    if i > 0 and stairs[i] - 1 == stairs[i - 1]:
        is_continuous = True
        break

if is_continuous:
    print(0)
else:
    countup_num = [0] * (n + 1)
    countup_num[0] = 1
    countup_num[1] = 1
    for i in range(2, n + 1):
        countup_num[i] = (countup_num[i - 1] + countup_num[i - 2]) % 1000000007
    res = 1
    diff = 0
    now = 0
    for i in range(m):
        diff = stairs[i] - now - 1
        now = stairs[i] + 1
        res *= (countup_num[diff]) % 1000000007
        # print(res, now)
    if m == 0:
        res = countup_num[n]
    else:
        diff = n - stairs[-1] - 1
        res *= (countup_num[diff]) % 1000000007

    res %= 1000000007
    # print(countup_num)
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
line = set(range(1, n + 1))
for i in range(m):
    l, r = map(int, input().split())
    line &= set(range(l, r + 1))

print(len(line))


Fixed submission:
n, m = map(int, input().split())
l_max = 1
r_min = 10 ** 5
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l, l_max)
    r_min = min(r, r_min)

print(max(0, r_min - l_max + 1))
Buggy python submission (verdict: Time Limit Exceeded):
num,jump=map(int,input().split())
height=list(map(int,input().split()))

dp=[10**9]*(num)
dp[0]=0
# dp[1]=abs(height[1]-height[0])
# for i in range(2,num):
#   dp[i]=min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]))

for i in range(1,num):
    for j in range(1,min(i,jump)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]))

print(dp[-1])

Fixed submission:
num,jump=map(int,input().split())
height=list(map(int,input().split()))

dp=[10**9]*(num)
dp[0]=0

for i in range(1,num):
    for j in range(1,min(i,jump)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
seat = [0] * 10 ** 5
for i in range(n):
    l, r = map(int, input().split())
    seat[l - 1] += 1
    seat[r] -= 1

for i in range(1, 10 ** 5):
    seat[i] += seat[i - 1]

res = 0
for i in range(10 ** 5):
    if seat[i] == 1:
        res += 1
print(res)


Fixed submission:
n = int(input())
seat = [0] * 10 ** 6
for i in range(n):
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        seat[j - 1] = 1

res = 0
for i in range(10 ** 6):
    if seat[i] == 1:
        res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(input()) for i in range(n)]
sum_list = [0]

for i in range(n):
    for j in range(len(sum_list)):
        sum_list.append(sum_list[j] + s[i])

sum_list.sort(reverse=True)
for i in sum_list:
    if i % 10 != 0:
        print(i)
        break
    else:
        pass
else:
    print(0)


Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i in range(n):
        if s[i] % 10 == 0:
            pass
        else:
            print(sum(s) - s[i])
            break
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(input()) for i in range(n)]
sum_list = [0]

for i in range(n):
    for j in range(len(sum_list)):
        sum_list.append(sum_list[j] + s[i])

sum_list.sort(reverse=True)
for i in sum_list:
    if i % 10 != 0:
        print(i)
        break
    else:
        pass
else:
    print(0)


Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i in range(n):
        if s[i] % 10 == 0:
            pass
        else:
            print(sum(s) - s[i])
            break
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
x = int(input())
print(x^^2)

Fixed submission:
x = int(input())
print(x**2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

tmp = 7
ans = 1
p = 1
mo = tmp % K
checked = [0] *  (10 ** 6 + 1)
checked[mo] = 1

while mo != 0:
    mo = mo + 7 * pow(10, p, K)
    mo %= K
    p += 1
    if checked[mo]:
        # 0には一生辿り着かない
        print(-1)
        break
    checked[mo] = 1
else:
    print(p)


Fixed submission:
import sys, 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

tmp = 7
ans = 1
p = 1
mo = tmp % K
checked = [0] *  (10 ** 6 + 1)
checked[mo] = 1

while mo != 0:
    mo = mo + 7 * pow(10, p, K)
    mo %= K
    p += 1
    if checked[mo]:
        # 0には一生辿り着かない
        print(-1)
        break
    checked[mo] = 1
else:
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# b = A[K:]

B = []
tmp = 1
for a in A[:K]:
    tmp *= a
for i in range(N - K):
    tmp2 = tmp / A[i] * A[K + i]
    if tmp < tmp2:
        print("Yes")
    else:
        print("No")
    # print(tmp, tmp2)
    tmp = tmp2


Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# b = A[K:]

B = []
tmp = 1
# for a in A[:K]:
#     tmp *= a
tmp = 1
for i in range(N - K):
    tmp2 = tmp / A[i] * A[K + i]
    if tmp < tmp2:
        print("Yes")
    else:
        print("No")
    # print(tmp, tmp2)
    tmp = 1
Buggy python submission (verdict: Time Limit Exceeded):
import sys, 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 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
for a in A:
    ans *= a
if ans > 10 ** 18:
    print(-1)
else:
    
    print(ans)

Fixed submission:
import sys, 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 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
# exit()
A.sort()
# print(A)
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
else:

    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, 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 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N
ans = (A * x//B) - A * (x // B)

memo = [0] * (B+1)
for x in range(1, B+1):
    memo[x] = (A * (x)//B) - A * ((x)  // B)
# print(memo[N-1])
# print(memo)
# print(N)

# exit()
if N >= B:
    ans = memo[-2]
else:
    ans = memo[N]
print(ans)


Fixed submission:
import sys, 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 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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N

ans1 = (A * (B-1)//B) - A * ((B-1) // B)
ans2 = ((A * N)//B) - A * (N // B)
# print(ans2)
# ans = max(A-1, ans2)

if N < B:
    print(ans2)
else:
    
    print(ans1)

# exit()

exit()
# exit()
memo = [0] * (B+1)
ma = 0
for x in range(1, B+1):
    memo[x] = int((A * (x)/B)) - A * ((x)  // B)
    ma = max(memo[x], ma)
# print(memo[N-1])
print(memo)
# print(N)

# exit()
if N >= B:
    ans = ma
else:
    ans = memo[N]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(input())
N = len(S)
 
 
l = [0] * 2019
index = 0
temp = 0
for i in range(N-1, -1, -1):
    temp += int(S[i]) * 10**index
    l[temp%2019] += 1
    index += 1
 
ans = l[0]
 
for i in range(1, 2019):
    v = l[i]
    ans += v * (v-1) // 2
 
print(ans)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s, w = MAP()


if s <= w:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

# 和があればTrue
# dp = [False] * ((N + 1) * N // 2 + 1)
dp = defaultdict(int)

# for k in range(N + 1, K - 1, -1):
q = [[10 ** 10 + i for i in range(0, N + 1)]]
# print(q)
while q:
    a = q.pop()
    # print(a)
    s = sum(a)
    # print(a)
    # print(s)
    dp[s] = True
    if len(a) > K:
        # K より大きければ続ける
        for i in range(len(a)):
            b = deepcopy(a)
            b.pop(i)
            q.append(b)
# print(sum(dp) % mod)
print(len(dp) % mod)


    






Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = 0
for i in range(K, N + 2):
    B = N * (N + 1) // 2 - (N - i) * (N - i + 1) // 2
    A = (i - 1) * i // 2
    ans += (B - A + 1)
print(ans % mod)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

a = N // K
b = ceil(N / K)
# print(a, b)
c,d = N-a, N-b
# print(c,d)
# print(N-c,N-d)

#
x = N // (N - K)
y = x+1
# print(x, y)
a = N - x * (N-K)
b = N - y * (N-K)
# print(a, b)

# print(min(abs(a), abs(b)))

if N < K:
    print(min(K-N, N))
elif K == 1:
    print(0)
else:
    ans = min(abs(a), abs(b))
    print(ans)

# if N >= K:
#     ans = min(abs(a), abs(b))
# # K > N:
# else:
#     ans = min(K-N, N)
# print(ans)


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

N, K = MAP()

if N <= K:
    print(min(K-N, N))
# elif K == 1:
#     print(0)
else:
    print(min(N % K, K - N % K))
    # a = N // K
    # b = ceil(N / K)
    # c = N % K
    # print(a, b, c)
    # print(abs(c-K), abs(c))

    # x = N // (N - K)
    # y = x + 1
    # z = x - 1
    # print(x, y, z)
    # a = N - x * (N-K)
    # b = N - y * (N-K)
    # c = N - z * (N-K)
    # print(a, b, c)
    # ans = min(abs(a), abs(b), abs(c))
    # print(ans)

# if N >= K:
#     ans = min(abs(a), abs(b))
# # K > N:
# else:
#     ans = min(K-N, N)
# print(ans)
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

# x = n // (a + b)
# pr/int(x)
x = 0
x += (n // (a + b)) * a
x += (n % (a+b)) % b
print(x)

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

n, a, b = MAP()

# x = n // (a + b)
# pr/int(x)
x = 0
x = (n // (a + b)) * a
y = 0
if a != 0:
    y = n % (a+b)
    if not 0 <= y <= a:
        y = a

print(x + y)