Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(max(a[:n].extend(a[n+1:])))

Fixed submission:
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
a_=sorted(a)
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(a_[-2])

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  print(max(a[:n]+a[n+1:])

Fixed submission:
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
a_=sorted(a)
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(a_[-2])
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,d=map(int,input().split())
arr=np.array((n,d))
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)

Fixed submission:
import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      ans +=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n,d=map(int,input().split())
arr=np.array(n)
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)

Fixed submission:
import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      ans +=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
i = int(input())
i = list(i)
for k in range(3):
  if i[k] == i[k+1]:
    print("Bad")
    sys.exit()
print("Good")

Fixed submission:
import sys
i = input()
i = list(map(int,list(i)))
for k in range(3):
  if i[k] == i[k+1]:
    print("Bad")
    sys.exit()
print("Good")
Buggy python submission (verdict: Runtime Error):
S = input()
ans = [0, 0]
if check(S[0], S[1]):
    ans[0] += 1
if check(S[2], S[3]):
    ans[1] += 1

if ans == [0, 0]:
    print("NA")
elif ans == [0, 1]:
    print("YYMM")
elif ans == [1, 0]:
    print("MMYY")
elif ans == [1, 1]:
    print("AMBIGIOUS")

Fixed submission:
def check(M_1, M_2):
    M_1 = int(M_1)
    M_2 = int(M_2)
    MM = M_1 * 10 + M_2
    if 1 <= MM <= 12:
        return True
    else:
        return False


S = input()
ans = [0, 0]
if check(S[0], S[1]):
    ans[0] += 1
if check(S[2], S[3]):
    ans[1] += 1

if ans == [0, 0]:
    print("NA")
elif ans == [0, 1]:
    print("YYMM")
elif ans == [1, 0]:
    print("MMYY")
elif ans == [1, 1]:
    print("AMBIGUOUS")
Buggy python submission (verdict: Time Limit Exceeded):
# import time
R, G, B, N = map(int, input().split())
# print(R, G, B)
i = 0
# r, g = 0, 0
# s = time.time()
for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) >= 0:
            b = int((N - r * R - g * G) / B)
            if N - (r * R + g * G + b * B) == 0:
                # print(r, g, b)
                i += 1
print(i)
# print(time.time()-s)


Fixed submission:
R, G, B, N = map(int, input().split())
i = 0
for r in range(N // R + 1):
    Rr = r * R
    for g in range(N // G + 1):
        Gg = g * G
        Bb = N-Rr-Gg
        if Bb < 0:
            break
        if Bb % B == 0:
            i += 1
print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
V = [int(input()) for i in range(N)]
C = [int(input()) for i in range(N)]
_ = 0
for j in range(N):
  if V[j] > C[j]:
    _ += V[j] - C[j]
print(_)

Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
_ = 0
for j in range(N):
  if V[j] > C[j]:
    _ += V[j] - C[j]
print(_)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
black = 0
white = 0
black2 = 0
white2 = 0
k = 0
ans = 0
for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == ".":
        if k == 0:
            black = S[:i + 1].count("#")
            white = S[i + 1:].count(".")
            ans += min(black, white)
            k = 1
        elif k == 1:
            black2 = S[:i + 1].count("#")
            white2 = S[i + 1:].count(".")
            ans += min(black2 - black, white - white2)
            black = black2
            white = white2
print(ans)

Fixed submission:
N = int(input())
S = list(input())
S.insert(0,0)
# b = S.count("#")
w = S.count(".")
black = 0
white = w
ans = 2e5
for i in range(N+1):
    if S[i] == "#":
        black += 1
    elif S[i] == ".":
        white -= 1
    # print(black,white)
    ans = min(black + white, ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
n_sharp = S.count("#")
n_period = S.count(".")
temp = [[], []]
k = 0
for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == ".":
        temp[0].append(S[:i + 1].count("#"))
        # print(S[:i + 1], S[i + 1:])
        temp[1].append(S[i + 1:].count("."))
        k += 1
        if k == 1:
            ans = min(temp[0], temp[1])[0]
            # print((ans))
        elif k > 1:
            ans += min(abs(temp[0][k-1] - temp[0][k - 2]), abs(temp[1][k-1] - temp[1][k - 2]))

print(ans)

Fixed submission:
N = int(input())
S = list(input())
S.insert(0,0)
# b = S.count("#")
w = S.count(".")
black = 0
white = w
ans = 2e5
for i in range(N+1):
    if S[i] == "#":
        black += 1
    elif S[i] == ".":
        white -= 1
    # print(black,white)
    ans = min(black + white, ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
n_sharp = S.count("#")
n_period = S.count(".")
temp = [[], []]

for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == ".":
        temp[0].append(S[:i + 1].count("#"))
        temp[1].append(S[i + 1:].count("."))
_ = len(temp[0])
ans = min(temp[0])
for i in range(_ -1):
    ans += min(abs(temp[0][i + 1] - temp[0][i]), abs(temp[1][i + 1] - temp[1][i]))
print(ans)

Fixed submission:
N = int(input())
S = list(input())
S.insert(0,0)
# b = S.count("#")
w = S.count(".")
black = 0
white = w
ans = 2e5
for i in range(N+1):
    if S[i] == "#":
        black += 1
    elif S[i] == ".":
        white -= 1
    # print(black,white)
    ans = min(black + white, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,j] = array[:,i] * 0
print(array[array==1].sum())

Fixed submission:
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
print((ipt[0]-cr[0])*(ipt[1]-cr[1]))

Buggy python submission (verdict: Runtime Error):
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,i] = array[:,i] * 0
print(array[array==1].sum())

Fixed submission:
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
print((ipt[0]-cr[0])*(ipt[1]-cr[1]))
Buggy python submission (verdict: Runtime Error):

def factorization(n):
    arr = []
    temp = n
    for i in range(2,3):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)


    return arr

n=int(input())
num=list(map(factorization,list(map(int,input().split()))))
print(min(num)[0])

Fixed submission:
n = int(input())
a_n = list(map(int,input().split(" ")))
k = 0
t = 0
while True:
  for i in range(len(a_n)):
    if a_n[i] % 2 == 0:
      a_n[i] = a_n[i] / 2
    else:
      t = -1
      break
  if t == -1:
    break
  k += 1
print(k)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_s = list(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += a_s[i] * a_s[j]

print(int(ans % (1e9 + 7)))


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

sum_a = 0
mul_a = 0
mod = 1000000007

for a in a_s:
    sum_a += a
    mul_a += a*a
    sum_a %= mod
    mul_a %= mod

ans = sum_a * sum_a
ans %= mod
ans -= mul_a
ans %= mod

n = mod-2
inv = 1
base = 2

while n:
    if n & 1:
        inv = inv*base % mod
    base = base*base % mod
    n >>= 1

ans *= inv
ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
# f = open('test.txt')
f = open('b11.txt')
n, m, k = map(int, f.readline().split())
a = list(map(int, f.readline().split()))
b = list(map(int, f.readline().split()))

a_sum = [0]
b_sum = [0]
cnt = 0
best_b = m
confirm = ()

for i in a:
    a_sum.append(i + a_sum[-1])

for i in b:
    b_sum.append(i + b_sum[-1])

for a_idx in range(n + 1):
    if a_sum[a_idx] > k:
        break
    for b_idx in reversed(range(best_b + 1)):
        if b_sum[b_idx] + a_sum[a_idx] <= k:
            # if cnt < a_idx + b_idx:
            cnt = max(cnt, a_idx + b_idx)
            best_b = b_idx
            break

print(cnt)


Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
cnt = 0
best_b = m
confirm = ()

for i in a:
    a_sum.append(i + a_sum[-1])

for i in b:
    b_sum.append(i + b_sum[-1])

for a_idx in range(n + 1):
    if a_sum[a_idx] > k:
        break
    for b_idx in reversed(range(best_b + 1)):
        if b_sum[b_idx] + a_sum[a_idx] <= k:
            # if cnt < a_idx + b_idx:
            cnt = max(cnt, a_idx + b_idx)
            best_b = b_idx
            break

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

k = 1
summed = 0

for i in range(1, n + 1):
    if i != 1:
        while k * i <= n:
            ints[k * i - 1] += 1
            k += 1
        k = 1
    summed += (ints[i-1]+1) * i

print(summed)


Fixed submission:
n = int(input())

ans = 0
for i in range(1, n + 1):
    ans += i * (n // i) * (n // i + 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int, input().split())))

for i in range(q):
    a = [bc[i][1] if bc[i][0] == j else j for j in a]
    print(sum(a))



Fixed submission:
n = int(input())
a_series = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int, input().split())))

summed = sum(a_series)
num = [0 for i in range(100005)]

for a in a_series:
    num[a] += 1

for i in range(q):
    summed += ((bc[i][1] - bc[i][0]) * num[bc[i][0]])
    num[bc[i][1]] += num[bc[i][0]]
    num[bc[i][0]] = 0
    print(summed)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ints = list(map(int, input().split()))
m = max(ints)
x = [0] * m
cnt = 0

for i in ints:
    for j in range(m):
        if (j + 1) % i == 0:
            x[j] += 1

for i in ints:
    if x[i-1] == 1:
        cnt += 1

print(cnt)


Fixed submission:
n = int(input())
ints = list(map(int, input().split()))
m = max(ints)
x = [0] * m
cnt = 0

for i in ints:
    if x[i-1] >= 2:
        continue
    for j in range(m // i):

        x[i * (j + 1) - 1] += 1

for i in ints:
    if x[i - 1] == 1:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ints = list(map(int, input().split()))

cnt = 0
div_times = 0

for i in ints:
    for j in ints:
        if i % j == 0:
            div_times += 1
        if div_times == 2:
            break
    if div_times == 1:
        cnt += 1
    div_times = 0

print(cnt)


Fixed submission:
n = int(input())
ints = list(map(int, input().split()))
m = max(ints)
x = [0] * m
cnt = 0

for i in ints:
    if x[i-1] >= 2:
        continue
    for j in range(m // i):

        x[i * (j + 1) - 1] += 1

for i in ints:
    if x[i - 1] == 1:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ints = list(map(int, input().split()))

cnt = 0

for i in ints:
    clr = [i % j == 0 for j in ints]
    if clr.count(True) == 1:
        cnt += 1

print(cnt)



Fixed submission:
n = int(input())
ints = list(map(int, input().split()))
m = max(ints)
x = [0] * m
cnt = 0

for i in ints:
    if x[i-1] >= 2:
        continue
    for j in range(m // i):

        x[i * (j + 1) - 1] += 1

for i in ints:
    if x[i - 1] == 1:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int,input().split()))
k = 10**9+7
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        count += arr[i]*arr[j]
        count = count%k
print(count)


Fixed submission:
N = int(input())
arr1 = list(map(int,input().split()))
arr2 = [0 for _ in range(N)]
sum = 0
for i in range(N):
    arr2[i] = sum+arr1[i]
    sum = arr2[i]

k = 10**9+7

count = 0
for i in range(N-1):
    count += arr2[i]*arr1[i+1]
    count %= k

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M = map(int,input().split())
Hinx = [0 for _ in range(H+1)]
Winx = [0 for _ in range(W+1)]
Hexist = [0 for _ in range(M)]
Wexist = [0 for _ in range(M)]
for i in range(M):
    h,w = map(int,input().split())
    Hinx[h] += 1
    Winx[w] += 1
    Hexist[i] = h
    Wexist[i] = w

HMinx = []
WMinx = []

Hmax = max(Hinx)
Wmax = max(Winx)
ans = Hmax+Wmax-1
for i in range(1,H+1):
    if Hinx[i] == Hmax:
        HMinx.append(i)
for i in range(1,W+1):
    if Winx[i] == Wmax:
        WMinx.append(i)

flag = False
for i in HMinx:
    for j in WMinx:
        flag2 = False
        for k in range(M):
            if Hexist[k] == i and Wexist[k] == j:
                flag2 = True
                break
        if flag2 == False:
            flag = True
            ans += 1
            break
    if flag == True:
        break
print(ans)


Fixed submission:
H,W,M = map(int,input().split())
Hinx = [0 for _ in range(H+1)]
Winx = [0 for _ in range(W+1)]
isExist = []
for i in range(M):
    h,w = map(int,input().split())
    Hinx[h] += 1
    Winx[w] += 1
    isExist.append((h,w))

HMinx = []
WMinx = []
Hmax = max(Hinx)
Wmax = max(Winx)
ans = Hmax + Wmax

isExist = set(isExist)
for i in range(1,H+1):
    if Hinx[i] == Hmax:
        HMinx.append(i)
for i in range(1,W+1):
    if Winx[i] == Wmax:
        WMinx.append(i)

cross = 0
not_cross = 0

flag = True
for i in HMinx:
    for j in WMinx:
        if (i,j) not in isExist:
            flag = False
            break
    if flag == False:
        break
if flag == False:
    print(ans)
else:
    print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
H,W,M = map(int,input().split())
Hinx = [0 for _ in range(H+1)]
Winx = [0 for _ in range(W+1)]
isExist = [0 for _ in range(M)]
for i in range(M):
    h,w = map(int,input().split())
    Hinx[h] += 1
    Winx[w] += 1
    isExist[i] = (h,w)

HMinx = []
WMinx = []

Hmax = max(Hinx)
Wmax = max(Winx)
ans = Hmax+Wmax
for i in range(1,H+1):
    if Hinx[i] == Hmax:
        HMinx.append(i)
for i in range(1,W+1):
    if Winx[i] == Wmax:
        WMinx.append(i)

flag = False
for i in HMinx:
    for j in WMinx:
        flag2 = False
        for k in isExist:
            if k == (i,j):
                flag2 = True
                break
        if flag2 == False:
            flag = True
            break
    if flag == True:
        break
if flag == True:
    print(ans)
else:
    print(ans-1)


Fixed submission:
H,W,M = map(int,input().split())
Hinx = [0 for _ in range(H+1)]
Winx = [0 for _ in range(W+1)]
isExist = []
for i in range(M):
    h,w = map(int,input().split())
    Hinx[h] += 1
    Winx[w] += 1
    isExist.append((h,w))

HMinx = []
WMinx = []
Hmax = max(Hinx)
Wmax = max(Winx)
ans = Hmax + Wmax

isExist = set(isExist)
for i in range(1,H+1):
    if Hinx[i] == Hmax:
        HMinx.append(i)
for i in range(1,W+1):
    if Winx[i] == Wmax:
        WMinx.append(i)

cross = 0
not_cross = 0

flag = True
for i in HMinx:
    for j in WMinx:
        if (i,j) not in isExist:
            flag = False
            break
    if flag == False:
        break
if flag == False:
    print(ans)
else:
    print(ans-1)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
arr = list(map(int,input().split()))
denominator = sum(arr)

import copy
value = copy.deepcopy(arr)
piece = [1 for i in range(N)]
left = K+N-sum(piece)
for i in range(left):
    j = value.index(max(value))
    piece[j] += 1
    value[j] = arr[j]/piece[j]

import math
print(round(round(max(value)*10)/10))

Fixed submission:
if int(input()) >= 30:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = input()
arr = []
for i in range(N):
    arr.append(l[i])

c = 0
left = 0
right = N-1
while True:
    while True:
        if arr[left] == 'R':
            left += 1
        else:
            break
    while True:
        if arr[right] == 'W':
            right -= 1
        else:
            break
    arr[left] = 'R'
    arr[right] = 'W'
    if left >= right:
        break
    else:
        c += 1

print(c)


Fixed submission:
N = int(input())
l = input()
arr = []
for i in range(N):
    arr.append(l[i])

c = 0
left = 0
right = N-1

T = False
for i in arr:
    if i == 'R':
        T = True
if T == False:
    print(c)
else:
    T = False
    for i in arr:
        if i == 'W':
            T = True
    if T == False:
        print(c)
    else:
        while True:
            while True:
                if arr[left] == 'R':
                    left += 1
                else:
                    break
            while True:
                if arr[right] == 'W':
                    right -= 1
                else:
                    break
            arr[left] = 'R'
            arr[right] = 'W'
            if left >= right:
                break
            else:
                c += 1
        print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

arr = [0 for _ in range(N+1)]
def DFS(x,y,z):
    n = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
    if n <= N:
        if x == y and y == z:
            arr[n] += 1
        elif (x == y) or (y == z) or (z == x):
            arr[n] += 3
        else:
            arr[n] += 6
        if x+1<=y:
            DFS(x+1,y,z)
        if y+1<=z:
            DFS(x,y+1,z)
        DFS(x,y,z+1)
    return(0)

DFS(1,1,1)
for i in arr[1:]:
    print(i)


Fixed submission:
N = int(input())

arr = [0 for _ in range(N+1)]
for x in range(1,N+1):
    F1 = True
    for y in range(x,N+1):
        F2 = True
        for z in range(y,N+1):
            n = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
            if n > N:
                if y == z:
                    F2 = False
                break
            else:
                if x == y and y == z:
                    arr[n] += 1
                elif (x == y) or (y == z) or (z == x):
                    arr[n] += 3
                else:
                    arr[n] += 6
        if F2 == False:
            if x == y:
                F1 = False
            break
    if F1 == False:
        break

for i in arr[1:]:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())

s = input()
count = 0
for i in range(n):
    if (s[i] == 'A' and s[i + 1] == 'B' and s[i+2] == 'C'):
        count += 1

print(count)


Fixed submission:
import math

n = int(input())

s = input()
count = 0
for i in range(2, n):
    if (s[i-2] == 'A' and s[i - 1] == 'B' and s[i] == 'C'):
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(k):
  if sum(s[i])==0:
    r=r+1
print(r)


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s=[[0] * k for i in range(n)]
for i in range(k):
  input()
  l=list(map(int, input().split()))
  for j in range(len(l)):
    s[l[j]-1][i]=1

r=0
for i in range(n):
  if sum(s[i])==0:
    r=r+1
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s=input()
sl=len(s)
if len(s)>1:
  while True:
    ll=len(s)
    s=s.replace('01','')
    s=s.replace('10','')
    if ll==len(s):
      break

print(sl-len(s))



Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s=input()
sl=len(s)
l=list(s)
nl=[l.pop(0)]
si=0
while len(l)>0:
  c=l.pop(0)
  if len(nl)>0:
    if nl[si]!=c:
      nl.pop(si)
      si=si-1
    else:
      nl.append(c)
      si=si+1
  else:
    nl=[c]
    si=0

print(sl-len(nl))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
k,a,b = map(int, input().split())

if a >= b:
  print(k+1)
elif k==1:
  print(b)
elif k==2:
  print(b)
elif k<=a:
  print(k+1)
else:
  t=((k+1)//(a+2))
  r=(k+1)-t*(a+2)
  if a < (b-a):
    nn = (k+1)-a
    print(nn//2*(b-a)+a+((k+1)-a)%2) 
  else:
    print(max(t*b+r,k+1))


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
if n==1 and k==1:
  print('YES')
elif n <= k:
  print('NO')
elif n < ((k-1)*2+1) :
  print('NO')
else:
  print('YES')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

def lcm(x, y):
  return (x * y) // math.gcd(x, y)

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)



Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
l = []
for i in range(0,n):
  l.append(int(input()))
  

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x
def lcm(x, y):
  return (x * y) // gcd(x, y)

res=l[0]
for i in range(1,n):
  res=lcm(res,l[i])
print(res)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み
x = int(input())
y = int(intpu())

res = 0
if x < 0:
    res = res + 1
if y < 0:
    res = res + 1

res = res + (abs(y)-abs(x))

print(res)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 数値の読み込み
x,y = [int(i) for i in input().split()]

res = 0


if abs(y) > abs(x):
    # |x| < |y|
    if x < 0:
        res = res + 1
    if y < 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))
else :
    # x > y
    if x > 0:
        res = res + 1
    if y > 0:
        res = res + 1
    res = res + abs(abs(y)-abs(x))


print(res)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

c = 0
t = int(sum(a)//n)
for i in range(0,N):
  if a[i]!=t:
    c=abs(t-a[i])

print(c)


Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))

c1 = 0
c2 = 0
t1 = int(math.ceil(sum(a)/n))
t2 = int(sum(a)//n)
for i in range(0,n):
  if a[i]!=t1:
    c1=c1+(t1-a[i])*(t1-a[i])
  if a[i]!=t2:
    c2=c2+(t2-a[i])*(t2-a[i])

print(min(c1,c2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int,input().split()))

sum = 0

for i in range(n):
  for j in range(i+1,n):
    sum += a_list[i] * a_list[j]
    sum = sum%(10**9+7)

print(sum)

Fixed submission:
n = int(input())
a_list = list(map(int,input().split()))
sum_a = sum(a_list)

sum = 0
for i in range(n):
  sum += a_list[i] * (sum_a-a_list[i])
  sum = sum%(10**9+7)
  sum_a -= a_list[i]
print(sum)