Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# def check(place, List):
#     flag = 0
#     for i in range(len(List)):
#         distance = abs(i - place)
#         if distance > len(List):
#             distance = len(List) - distance
#         if distance < List[i]:
#             flag = 1
#     return flag
# def getDistance(Now,Next,C):
#     dst = abs(Next - Now)
#     if(dst > C/2):
#         dst = C - dst
#     return dst
#
#
#
# N, C = map(int, input().split())
# # Counter = [0 for i in range(C)]
# X_V = []
# #V = []
# for i in range(N):
#      #x,v = map(int, input().split()))
#      X_V.append(tuple(map(int, input().split())))
# nowPlace = 0
# while(1):
#     getCal = list(map(lambda x:x[1] - getDistance(nowPlace, x[0], C), X_V))
#     nextPlace = X_V[getCal.index(max(getCal))][0]

N, C = map(int, input().split())
X = [0]
V = [0]
for i in range(N):
    x,v = map(int, input().split())
    X.append(x)
    V.append(v)
#print(-X[1])
inv_X = [C-X[i] for i in range(N+1)][::-1]
inv_X.pop()
inv_X.insert(0,0)
#累積和の計算
right = [0]
left = [0]
#print(V)
for i in range(1,N+1):
    right.append(right[i-1]+V[i])
    left.append(left[i-1]+V[N+1-i])
#print('right:', right, 'left:', left)
Rtemp_max = 0
#right -> left pattern
for i in range(N+1):
    for j in range(N+1-i):
        OA = X[i]
        OB = inv_X[j]
        RightMovingDistance = 2 * OA + OB
        getCal = right[i] + left[j] - RightMovingDistance
        #print(i, j,right[i], left[j], RightMovingDistance)
        #print('Right_i:',i,'Right_getCal:',getCal)
        Rtemp_max = max(Rtemp_max, getCal)
#left -> right pattern
Ltemp_max = 0
for i in range(N+1):
    for j in range(N+1-i):
        OA = X[i]
        OB = inv_X[j]
        LeftMovingDistance = OA + 2 * OB
        getCal = right[i] + left[j] - LeftMovingDistance
        #print(i, j,right[i], left[j], LeftMovingDistance)
        #print('Right_i:',i,'Right_getCal:',getCal)
        Ltemp_max = max(Ltemp_max, getCal)
ans = max(Rtemp_max, Ltemp_max)
print(ans)


Fixed submission:
import numpy as np
N, C = map(int, input().split())
X,V = [],[]
for _ in range(N):
    x,v = map(int, input().split())
    X.append(x)
    V.append(v)

r1,r2,l1,l2 = [0],[0],[0],[0]
sum = 0
#原点から時計回りに行ってくる、行って戻ってくるパターン。前の奴と比較して、それより小さかったら無視
for i in range(N):
    sum += V[i]
    #print(r1, r2)
    r1.append(max(r1[i], sum-X[i]))
    r2.append(max(r2[i], sum-2*X[i]))
sum = 0
for i in range(N,0,-1):
    #print('hogehoge',i,V[i-1],X[i-1])
    sum += V[i-1]
    #print(l1, l2)
    l1.append(max(l1[-1], sum-(C-X[i-1])))
    l2.append(max(l2[-1], sum-2*(C-X[i-1])))
#print(l1, l2)
a = max(np.array(r1) + np.array(l2)[::-1])
b = max(np.array(r2) + np.array(l1)[::-1])
print(max(a,b))
Buggy python submission (verdict: Runtime Error):
Q = int(input())
for i in range(Q):
    a,b = (map(int, input().split()))
    if(a == b or a+1 == b):
        print(2*a -2)
    else:
        c = int(sqrt(a*b))
        if(c*(c+1) > a*b):
            print(2*c-2)
        else:
            print(2*c-1)


Fixed submission:
Q = int(input())
for i in range(Q):
    a,b = (map(int, input().split()))
    if(a == b):
        print(2*a -2)
    elif(abs(a-b) == 1):
        print(2 * min(a,b) -2)
    else:
        c = int((a*b) ** 0.5)
        if c == (a*b) ** 0.5:
            c -= 1
        if(c*(c+1) >= a*b):
            print(2*c-2)
        else:
            print(2*c-1)
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = [input() for i in range(H)]
queue = [(0,0,1)]
shape = sum(row.count("#") for row in List)
used ={(0,0)}

def check(x,y,c):
    if(x>W-1 or y>H-1 or x<0 or y<0):
        return
    if(List[y][x] == '#'):
        return
    if(x,y) in used:
        return
    queue.append((x,y,c+1))
    used.add((x,y))

f= -1
while queue:
    x,y,c = queue[0]
    if x==W-1 and y==H-1:
        f=1
        break
    queue.pop(0)
    check(x+1,y,c)
    check(x, y+1,c)
    check(x-1,y,c)
    check(x, y-1,c)
print(f if f == -1 else(H*W-c-shape))


Fixed submission:
N = int(input())
A = int(input())
mod = N % 500
if mod <= A:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from collections import deque

#幅優先探索でラベリング
def bfs(x, graph, people):
    #people[x] is None -> まだ訪問していない．訪問していたらなラベルがつくので，
    if people[x] is not None:
        return
    unvisited = deque([x])
    people[x] = 0
    while unvisited:
        now = unvisited.popleft()
        for Next, d in graph:
            if people[Next] is None:
                people[Next] = people[now] + d
                unvisited.append(Next)

def main():
    N, M = list(map(int, input().split()))
    graph = [ [] for i in range(N)]
    people = [None] * N

    #グラフの作成
    for i in range(M):
        L, R, D = list(map(int, input().split()))
        graph[L].append((R, D))
        graph[R].append((L, -D))
    #全ての頂点でサーチ ->ラベリングを行う
    for i in range(N):
        bfs(i, graph, people)

    for i in range(N):
        for j,d in graph[i]:
            if people[j] - people[i] != d:
                print("No")
                exit()
    print("Yes")
if __name__ == '__main__':
    main()


Fixed submission:
from collections import deque

#幅優先探索でラベリング
def bfs(x, graph, people):
    #people[x] is None -> まだ訪問していない．訪問していたらなラベルがつくので，
    if people[x] is not None:
        return
    unvisited = deque([x])
    people[x] = 0
    while unvisited:
        now = unvisited.popleft()
        for Next, d in graph[now]:
            if people[Next] is None:
                people[Next] = people[now] + d
                unvisited.append(Next)

def main():
    N, M = list(map(int, input().split()))
    graph = [ [] for i in range(N+1)]
    people = [None] * (N+1)

    #グラフの作成
    for i in range(M):
        L, R, D = list(map(int, input().split()))
        graph[L].append((R, D))
        graph[R].append((L, -D))
    #全ての頂点でサーチ ->ラベリングを行う
    for i in range(1,N+1):
        bfs(i, graph, people)

    for i in range(1,N+1):
        for j,d in graph[i]:
            if people[j] - people[i] != d:
                print("No")
                exit()
    print("Yes")
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
S = input()

# s = S[0]
temp_T = 100000
for i in range(len(S)-1):
    if(S[i+1] != s[i]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)


Fixed submission:
S = input()

# s = S[0]
temp_T = len(S)
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)

print(temp_T)

Buggy python submission (verdict: Runtime Error):
S = input()

s = S[0]
temp_T = 100000
for i in range(1, len(S)+1):
    if(S[i] != s):
        judge = max(i,len(S)-i)
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)


Fixed submission:
S = input()

# s = S[0]
temp_T = len(S)
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)

print(temp_T)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def main():
    n = int(input())
    sumv = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                sumv += gcd(i, j, k)
                #print(i,j,k)
    print(sumv)
  
if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def main():
    n = int(input())
    sumv = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                sumv += gcd(i, j, k)
                #print(i,j,k)
    print(sumv)
  
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
from copy import copy

MOD = 1000000007

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2, mod))

f = [1]
for i in range(10**5+5):
    f.append(f[-1]*(i+1)%MOD)
    
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % MOD

def nCr(n, r):
    return f[n] // (f[r] * f[n-r])
  
def main():
    n = int(input())
    li = list(map(int, input().split()))
    nums = [0] * n
    for num in li:
        nums[num - 1] += 1
        
    sumv = 0
    for num in nums:
        if num == 0:
            continue
        sumv += nCr(num, 2)
    
    for num in li:
        cnt = nums[num - 1]
        if cnt == 1:
            print(sumv)
            continue
        v = sumv + nCr(cnt-1, 2) - nCr(cnt, 2)
        print(v)
        
  
if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8


def nC2(n):
    return n * (n-1) // 2
  
def main():
    n = int(input())
    li = list(map(int, input().split()))
    nums = [0] * n
    for num in li:
        nums[num - 1] += 1
        
    sumv = 0
    for num in nums:
        if num == 0:
            continue
        sumv += nC2(num)
    
    for num in li:
        cnt = nums[num - 1]
        v = sumv + nC2(cnt-1) - nC2(cnt)
        print(v)
        
  
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

n = int(input())
nums = map(int, input().split(' '))

if a >= b:
    print(''.join([str(b)] * a))
else:
    print(''.join([str(a)] * b))

Fixed submission:
#coding:utf-8

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


print(''.join([str(min(a, b))] * max(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import queue

row, col = map(int, input().split(' '))
maze = [list(input()) for _ in range(row)]

                
def BPS(si, sj, gi, gj):
    global done
    done = [[0 for _ in range(col)] for _ in range(row)]
    q = queue.Queue()
    q.put((si, sj, 0))
    around = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    while not q.empty():
        i, j, cnt = q.get()
        done[i][j] = 1
        for ar in around:
            di, dj = ar[0], ar[1]
            i_n, j_n = i + di, j + dj
            if (i_n >= 0 and i_n < row and j_n >= 0 and j_n < col) == False:
                continue
            if maze[i_n][j_n] == '#':
                continue
            if done[i_n][j_n] == 1:
                continue
            if done[i_n][j_n] == 2:
                continue
            q.put((i_n, j_n, cnt + 1))
            done[i_n][j_n] = 2
        if i == gi and j == gj:
            return cnt
    return 0
            
            
def main():        
    maxv = 0
    for i in range(row):
        for j in range(col):
            for k in range(row):
                for l in range(col):
                    if i == k and j == l:
                        continue
                    maxv = max(maxv, BPS(i,j,k,l))
    print(maxv)
                    
                
                    
    
main()


Fixed submission:
# coding: utf-8
import queue

row, col = map(int, input().split(' '))
maze = [list(input()) for _ in range(row)]

                
def BPS(si, sj):
    done = [[0 for _ in range(col)] for _ in range(row)]
    q = queue.Queue()
    q.put((si, sj, 0))
    around = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    maxv = 0
    while not q.empty():
        i, j, cnt = q.get()
        done[i][j] = 1
        for ar in around:
            di, dj = ar[0], ar[1]
            i_n, j_n = i + di, j + dj
            if (i_n >= 0 and i_n < row and j_n >= 0 and j_n < col) == False:
                continue
            if maze[i_n][j_n] == '#':
                continue
            if done[i_n][j_n] == 1:
                continue
            if done[i_n][j_n] == 2:
                continue
            maxv = max(maxv, cnt + 1)
            q.put((i_n, j_n, cnt + 1))
            done[i_n][j_n] = 2
        
    return maxv
            
            
def main():        
    maxv = 0
    for i in range(row):
        for j in range(col):
            if maze[i][j] == '#':
                continue
            maxv = max(maxv, BPS(i,j))
    print(maxv)
                    
                
                    
    
main()
Buggy python submission (verdict: Runtime Error):

#coding:utf-8

from functools import reduce
import fractions

n, x = map(int, input().split(' '))
nums = list(map(int, input().split(' ')))

def devide_cnt(num):
    cnt = 0
    while num % 2 == 0:
        cnt += 1
        num //= 2
    return cnt, num

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    odd_nums = []
    cnt = -1
    for num in nums:
        tmp, num = devide_cnt(num)
        if cnt == -1:
            cnt = tmp
        if cnt != tmp:
            print(0)
            return
        odd_nums.append(num)
        
    minv = 2 ** cnt * lcm_list(odd_nums)

    
    l = 1
    r = 10000000001
    tmp = -1
    while l < r + 1:
        m = l + (r - l) // 2
        p = m * minv + 0.5 * minv
        if p > x:
            r = m
        else:
            l = m
        
        if tmp == p:
            break
        tmp = p
        
            
    print(l+1)
    
    
    

main()

Fixed submission:
#coding:utf-8

k, x = map(int, input().split(' '))
if k * 500 >= x:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

import math

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

print(int(a * b / math.gcd(a, b)))

Fixed submission:
#coding:utf-8

import fractions

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

print(int(a * b / fractions.gcd(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
x, y = map(int, input().split())

mod = 10**9 + 7
f = [1]
for i in range(10**6):
    f.append(f[-1] * (i+1) % mod)
    
def nCr(n, r):
    return f[n] * pow(f[r], f[r] ** (mod-2), mod) * pow(f[n-r] ** (mod-2), mod) % mod

def main():
    if (x + y) % 3 != 0 or (x + y) // 3 < abs(x - y):
        print(0)
        return

    n = (x + y) // 3
    r = n - abs(x - y)
    print(nCr(n, r))
    return
    
main()

Fixed submission:
#coding:utf-8
x, y = map(int, input().split())

mod = 10**9 + 7
f = [1]
for i in range(10**6):
    f.append(f[-1] * (i+1) % mod)
    
def nCr(n, r):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

def main():
    if (x + y) % 3 != 0 or (x + y) // 3 < abs(x - y):
        print(0)
        return
    
    n = (x + y) // 3
    r = n // 2 - abs(x-y) // 2
    print(nCr(n, r))
    return
    
main()
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

N,M = map(int,input().split())

start,left = map(int,input().split())
right = left
cnt = 0
for i in range(M-1):
    data = list(map(int,input().split()))
    if data[0] != start:
        start = data[0]
        if data[1] >= left:
            cnt += 1
            left = data[1]
            right = left
    else:
        right = data[1]
    
if data[1] >= right:
    cnt += 1

print(cnt)


Fixed submission:
#coding:utf-8

N,M = map(int,input().split())
List = sorted([list(map(int,input().split())) for i in range(M)], key=lambda x:x[1])

cnt = 1
maxa = 0
b = List[0][1]
for i in range(1,M):
    newB = List[i][1]
    maxa = max(maxa,List[i][0])
    if newB > b:
        if maxa >= b:
            cnt += 1
            b = newB
        maxa = 0
        
print(cnt)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
from bisect import bisect_right

N,M = map(int,input().split())

start,left = map(int,input().split())
right = left
cnt = 0
for i in range(M-1):
    data = list(map(int,input().split()))
    if data[0] != start:
        start = data[0]
        if data[1] >= left:
            cnt += 1
            left = data[1]
            right = left
    else:
        right = data[1]
    
if data[1] >= right:
    cnt += 1

print(cnt)


Fixed submission:
#coding:utf-8

N,M = map(int,input().split())
List = sorted([list(map(int,input().split())) for i in range(M)], key=lambda x:x[1])

cnt = 1
maxa = 0
b = List[0][1]
for i in range(1,M):
    newB = List[i][1]
    maxa = max(maxa,List[i][0])
    if newB > b:
        if maxa >= b:
            cnt += 1
            b = newB
        maxa = 0
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
nums = list(map(int,input().split()))

nums = [num - i for i,num in enumerate(nums,1)]
nums.sort()

sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)
minv = nums[0] * (1 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    for b in range(nums[i], nums[i+1]+1):
        p = b * (2*(i+1) - n) -2 * sums[i] + allv
        minv = min(minv,p)

print(minv)


Fixed submission:
#coding:utf-8
a = int(input())

def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

g = gcd(a,2)
l = a * 2 // g
print(l)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import math
a = int(input())

gcd = math.gcd
g = gcd(a,2)
l = a * 2 // g
print(l)


Fixed submission:
#coding:utf-8
a = int(input())

def gcd(a, b):

	while b:

		a, b = b, a % b

	return a

g = gcd(a,2)
l = a * 2 // g
print(l)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = sum[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)

Fixed submission:
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = nums[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    for b in range(nums[i], nums[i+1]+1):
        p = b * (2*(i+1) - n) -2 * sums[i] + allv
        minv = min(minv,p)

print(minv)

Fixed submission:
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = nums[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
K = int(input())
ten = K // 10
sur = K % 10
for i in range(ten+1):
    K += 1
    ten = K // 10
    sur = K % 10
    if i == ten:
        for j in range(1, sur+1):
            moji = "{}".format(j) + "9" * i
            print(moji)
    else:
        for j in range(1,10):
            moji = "{}".format(j) + "9" * i
            print(moji)


Fixed submission:
#coding:utf-8

s = input()
num = 0
for i in s:
    if i == "+":
        num += 1
    else:
        num -= 1
print(num)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)
numList = [i for i in range(N)]


maxv = 0
if M < N/2:
    combi = list(itertools.combinations(numList,M))
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(total,maxv)
    print(maxv)


else:
    M = N - M
    combi = list(itertools.combinations(numList,M))
    BDP = [np.sum(cakeList[:,i]) for i in range(3)]
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(BDP[i] - np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(maxv,total)
    print(maxv)


Fixed submission:
#coding:utf-8
A,B = map(int, input().split())

if A <= 8 and B <= 8:
    print("Yay!")

else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

a,b,m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(m)]
x = []
y = []
#普通に足算する
p = itertools.product(A, B)
for v in p:
    x.append(sum(v))
#min出す
xx = min(x)    
#割引券使う
for i in range(m):
  y.append(A[P[i][0]-1] + B[P[i][1]-1] - P[i][2])
#min出す
yy = min(y)
print(min(xx,yy))



Fixed submission:
import itertools

a,b,m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(m)]
y = []
#普通に足算する
aa = min(A)
bb = min(B)
xx =aa+bb

#割引券使う
for i in range(m):
  y.append(A[P[i][0]-1] + B[P[i][1]-1] - P[i][2])
#min出す
yy = min(y)

print(min(xx,yy))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int, input().split())

x = ''
y = ''
z = ''
zz =''
for i in range(a):
  x = x + '0'

for i in range(b):
  y = y + '1'

zz = x + y

for i in range(int(n/len(zz))+1):
  z = z + x + y

print(z[:n].count('0')) 

Fixed submission:
n,a,b = map(int, input().split())
 
x = n//(a+b)
y = n%(a+b)
z = 0
if y <= a :
  z = y
else :
  z = a
  
print(x*a+z)
Buggy python submission (verdict: Runtime Error):
a,b= map(int, input().split())
aa = a + 0.9
bb = b + 0.9

if int(bb/0.1) > 1000:
bb = 1000

aaa = set(range(int(a/0.08),int(aa/0.08)))
bbb = set(range(int(b/0.1), int(bb/0.1)))

x = list(aaa.intersection(bbb))

if len(x) == 0:
  print('-1')
else:
  print(min(x))


Fixed submission:
a,b=map(int,input().split())
for i in  range(1,1300):
  if int(i*0.08)==a and int(i*0.1)==b:
    print(i)
    exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
x = 0
 
if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:
      print('DENIED')

Fixed submission:
a,b,c = map(int, input().split())
 
if (a == b) and (b !=c):
	print('Yes')
elif (a == c) and (b !=c):
	print('Yes')
elif (b == c) and (a !=c):
	print('Yes')
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input()
x = 0

if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:
      print('DENIED')


Fixed submission:
a,b,c = map(int, input().split())
 
if (a == b) and (b !=c):
	print('Yes')
elif (a == c) and (b !=c):
	print('Yes')
elif (b == c) and (a !=c):
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = b = list(map(int, input().split()))

ans = 0
for i in range(N):
    P_i = P[i] 
    if P_i == min(P[:i + 1]):
        ans += 1

print(ans)


Fixed submission:
N = int(input())
P = b = list(map(int, input().split()))

ans = 0
P_min = P[0]
for i in range(N):
    if P[i] <= P_min:
        P_min = P[i]
        ans += 1

print(ans)