Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x + y + z == S:
                    count += 1
                    
    print(count)

if __name__ == '__main__':
    K, S = map(int, input().split())
    solve(K, S)

Fixed submission:
K, S = map(int, input().split())
res = 0

for i in range(K+1):
    for j in range(K+1):
            if 0 <= S - (i + j) <= K:
                res += 1
                
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
res = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                res += 1
                
print(res)

Fixed submission:
K, S = map(int, input().split())
res = 0

for i in range(K+1):
    for j in range(K+1):
            if 0 <= S - (i + j) <= K:
                res += 1
                
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())

tmp = x
count = 0
if x < 0:
    count += 1
    x = x * (-1)
    
while True:
    if x == y or x == -y:
        break
    x += 1
    count += 1
    
if x != y:
    count += 1
print(count)
    

Fixed submission:
x, y = map(int, input().split())

if x == 0 and y < 0:
  print(abs(y) + 1)

elif x < 0 and y == 0:
  print(abs(x))

elif x > 0 and y == 0:
  print(x+1)

elif x >= 0 or y >= 0:
  if x == y:
    print(0)

  elif x == -y:
    print(1)

  elif x > y:
    # (11, 7)
    if y >= 0:
      ans = 2
      ans += x - y
      print(ans)

    # (11, -7)
    else:
      print(1 + abs(abs(x) + y))

  else:
    # (7, 11)
    if x >= 0:
      print(y - x)

    # (-7, 11)
    else:
      print(1 + abs(abs(y) + x))

else:
  if x == y:
    print(0)


  else:
    if x > y:
      print(abs(y) - abs(x) + 2)
    else:
      print(abs(x) - abs(y))
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

def f(n, x):
    if n >= 0:
        return int(n/x) + 1
    else:
        return 0

print(f(b, x) - f(a, n))

Fixed submission:
a, b, x = map(int, input().split())

def f(n, x):
    if n >= 0:
        return (n//x) + 1
    else:
        return 0

print(f(b, x) - f(a-1, x))

Buggy python submission (verdict: Runtime Error):
import math
import numpy
a, b, x = map(uint64, input().split())

res = 0    
res += math.floor((b-a)/x)

if a%x == 0:
    res += 1

if b%x == 0:
    res += 1


print(res)

Fixed submission:
a, b, x = map(int, input().split())

def f(n, x):
    if n >= 0:
        return (n//x) + 1
    else:
        return 0

print(f(b, x) - f(a-1, x))
Buggy python submission (verdict: Runtime Error):
W, H = map(int, input().split())
L = [input() for _ in range(H)]

count = 0
for i in range(H):
  for j in range(W):
    if L[i][j] == '#':
      count += 1
      
if count == W + H - 1:
  print('Possible')
else:
  print('Impossible')

Fixed submission:
H, W = map(int, input().split())
L = [input() for _ in range(H)]

count = 0
for i in range(H):
  for j in range(W):
    if L[i][j] == '#':
      count += 1
      
if count == W + H - 1:
  print('Possible')
else:
  print('Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

tmp1 = 1
tmp2 = 1

res = 2
for l in L:
    i = 1
    while True:
        if i * l[0] >= tmp1 and i * l[1] >= tmp2:
            res += (i * l[0] - tmp1) + (i * l[1] - tmp2)
            tmp1 = i * l[0] 
            tmp2 = i * l[1] 
            break
        i += 1
            
print(res)

Fixed submission:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

tmp1 = 1
tmp2 = 1

for l in L:
    i = max(1, tmp1//l[0] if tmp1%l[0] == 0 else tmp1//l[0] + 1, tmp2//l[1] if tmp2%l[1] == 0 else tmp2//l[1] + 1)
    tmp1 = i * l[0] 
    tmp2 = i * l[1] 
            
print(tmp1 + tmp2)
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()

now = A [0]
a = 1
b = 0
c = 0
while True:
    if now == 'a':
        if a + 1 == len(A):
            res = 'A'
            break
        now = A[a+1]
        a = a + 1
        
    if now == 'b':
        if b + 1 == len(B):
            res = 'B'
            break
        now = B[b+1]
        b = b + 1
        
    if now == 'c':
        if c + 1 == len(C):
            res = 'C'
            break
        now = C[c+1]
        c = c + 1

print(res)

Fixed submission:
A = input()
B = input()
C = input()

now = 'a'
a = 0
b = 0
c = 0

while True:
    if now == 'a':
        if a  == len(A):
            res = 'A'
            break
        now = A[a]
        a = a + 1
        
    elif now == 'b':
        if b  == len(B):
            res = 'B'
            break
        now = B[b]
        b = b + 1
        
    elif now == 'c':
        if c  == len(C):
            res = 'C'
            break
        now = C[c]
        c = c + 1

print(res)
Buggy python submission (verdict: Runtime Error):
import itertools

def solve(S):
    '''
    数字の間に+を入れるパターンと入れないパターンを全てチェックする
    125であれば、 125, 1+25, 12+5, 1+2+5
    +が入る可能性のある場所は右の通り、 1  |ここ!| 2  |ここ!| 5
    よって、組み合わせは 2 ** (文字列数 - 1)
    '''
    count = 0
    bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
    for pattern in bit_list:
            '''
            ビットの値が1の時に+が入ると考えて、0の時は入らない
            文字列を先頭から調べていき、次の文字との間に+が入る場合、そこまでの文字列をint型に変換して変数「count」に加算する
            
            '''
        start = 0
        for end in range(len(pattern)):
            if pattern[end] == 1:
                count += int(S[start:end+1])
                start = end + 1
                
            if end == len(bit) - 1:
                count += int(S[start:])
                
    print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

Fixed submission:
s = input()
n = len(s)
res = 0
for i in range(2**(n-1)):
    k = 0
    b = bin(i)[2:]
    for j in range(len(b)):
        if b[-(j+1)] == '1':
            res += int(s[k:j+1])
            k = j+1
    res += int(s[k:])

            
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
X = list(map(int, input().split()))
X.insert(0, 0)
dp = [[[0 for _ in range(N+1)] for _ in range(N+1)] for _ in range(sum(X)+1)]

dp[0][0][0] = 1
for i in range(sum(X) + 1):
    for j in range(1, N + 1):
        for k in range(N + 1):
            if i - X[j] >= 0 and k >= 1:
                dp[i][j][k] = dp[i][j - 1][k] + dp[i - X[j]][j - 1][k - 1]
            else:
                dp[i][j][k] = dp[i][j - 1][k]
                
res = 0

for k in range(1, N + 1):
    if A * k <= sum(X):
        res += dp[A*k][N][k]
                
print(res)

Fixed submission:
N, A = map(int, input().split())
X = list(map(int, input().split()))
X.insert(0, 0)
dp = [[[0 for _ in range(N+1)] for _ in range(N+1)] for _ in range(sum(X)+1)]

dp[0][0][0] = 1
for i in range(sum(X) + 1):
    for j in range(1, N + 1):
        for k in range(N + 1):
            if i - X[j] >= 0 and k >= 1:
                dp[i][j][k] = dp[i][j - 1][k] + dp[i - X[j]][j - 1][k - 1]
            else:
                dp[i][j][k] = dp[i][j - 1][k]
                
res = 0

for k in range(1, N + 1):
    if A * k <= sum(X):
        res += dp[A*k][N][k]
                
print(res)
Buggy python submission (verdict: Runtime Error):
N = input()
print((N-2)*180)

Fixed submission:
N = (int)(input())
print((N-2)*180)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

a = 7

for i in range(K):
    if(a % K == 0):
        print(i + 1)
        break
    a = a * 10 + 7

else:
    print(-1)

Fixed submission:
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

if(K % 2 == 0):
    print(-1)
else:
    seven_num = ''
    flg = True
    n = 0
    while(flg):
        seven_num += '7'
        n += 1
        if(int(seven_num) % K == 0):
            print(n)
            flg = False

Fixed submission:
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split)
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(i + j, ans)

print(ans)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(i + j, ans)

print(ans)

Buggy python submission (verdict: Runtime Error):
n_m_k = input().split()
n = int(n_m_k[0])
m = int(n_m_k[1])
k = int(n_m_k[2])

a_str_list = input().split()
a_int_list = [int(x) for x in a_str_list]

b_str_list = input().split()
b_int_list = [int(x) for x in b_str_list]

sum_t = 0
cnt_a = 0
cnt_b = 0

len_a = len(a_int_list)
len_b = len(b_int_list)
while(1):
    if((cnt_a != len_a) and (cnt_b != len_b)):
        if(a_int_list[cnt_a] < b_int_list[cnt_b]):
            sum_t += a_int_list[cnt_a]
            if(sum_t <= k):
                cnt_a += 1
            else:
                break
        elif(a_int_list[cnt_a] > b_int_list[cnt_b]):
            sum_t += b_int_list[cnt_b]
            if(sum_t <= k):
                cnt_b += 1
            else:
                break
        #
        elif(a_int_list[cnt_a] == b_int_list[cnt_b]):
            if(a_int_list[cnt_a + 1] < b_int_list[cnt_b + 1]):
                sum_t += a_int_list[cnt_a]
                if(sum_t <= k):
                    cnt_a += 1
                else:
                    break
            elif(a_int_list[cnt_a + 1] > b_int_list[cnt_b + 1]):
                sum_t += b_int_list[cnt_b]
                if(sum_t <= k):
                    cnt_b += 1
                else:
                    break
        #

    elif(cnt_a < len_a):
        sum_t += a_int_list[cnt_a]
        if(sum_t <= k):
            cnt_a += 1
        else:
            break
    elif(cnt_b < len_b):
        sum_t += b_int_list[cnt_b]
        if(sum_t <= k):
            cnt_b += 1
        else:
            break
    else:
        break

print(cnt_a + cnt_b)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(i + j, ans)

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

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

abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

#print(abcd_list)
list_tmp = []
for i in range(1, M + 1):
    list_tmp.append(i)

comb_A = list(itertools.combinations_with_replacement(list_tmp, N))


max_score = 0
for A in comb_A:
    tmp_score = 0
    #print(A)
    for q in range(Q):
        #print(A)
        a = abcd_list[q][0]
        b = abcd_list[q][1]
        c = abcd_list[q][2]
        d = abcd_list[q][3]

        A_a = A[a - 1]
        A_b = A[b - 1]

        if(A_b - A_a == c):
            tmp_score += d
        
    max_score = max(max_score, tmp_score)

print(max_score)

Fixed submission:
import itertools

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

abcd_list = []
for q in range(Q):
    abcd_list.append(list(map(int, input().split())))

#print(abcd_list)
list_tmp = []
for i in range(1, M + 1):
    list_tmp.append(i)

comb_A = list(itertools.combinations_with_replacement(list_tmp, N))


max_score = 0
for A in comb_A:
    tmp_score = 0
    for q in range(Q):
        A_a = A[abcd_list[q][0] - 1]
        A_b = A[abcd_list[q][1] - 1]

        if(A_b - A_a == abcd_list[q][2]):
            tmp_score += abcd_list[q][3]
        
    max_score = max(max_score, tmp_score)

print(max_score)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S_list = []
str_cnt = 0
for n in range(N):
    tmp = input()
    if((tmp in S_list) == False):
        str_cnt += 1
        S_list.append(tmp)

print(str_cnt)

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

print(len(set(S_list)))
Buggy python submission (verdict: Time Limit Exceeded):
from math import log
mod = int(1e9) + 7
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
m, ok = 0, 0

def sign(v):
    if v == 0:
        return 0
    return 1 if v > 0 else -1

for i in range(k + 1):
    c = 1
    sm = 0
    sgn = 1
    for j in range(i):
        c = c * a[j] % mod
        sgn *= sign(a[j])
        if a[j] != 0:
            sm += log(abs(a[j]))
    for j in range(k - i):
        c = c * a[n - j - 1] % mod
        sgn *= sign(a[n - j - 1])
        if a[n - j - 1] != 0:
            sm += log(abs(a[n - j - 1]))
    if not ok:
        m = (sgn * sm, c)
        ok = 1
    else:
        m = max(m, (sgn * sm, c))
    
print(m[1])

Fixed submission:
from math import log
mod = int(1e9) + 7
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

def sign(v):
    if v == 0:
        return 0
    return 1 if v > 0 else -1

pref = [(0, 1)] * (n + 1)
suf = [(0, 1)] * (n + 1)

c = 1
sm = 0
sgn = 1
for j in range(n):
    c = c * a[j] % mod
    sgn *= sign(a[j])
    if a[j] != 0:
        sm += log(abs(a[j]))
    pref[j + 1] = (sgn * sm, c, sgn)

c = 1
sm = 0
sgn = 1
for j in range(n):
    c = c * a[n - j - 1] % mod
    sgn *= sign(a[n - j - 1])
    if a[n - j - 1] != 0:
        sm += log(abs(a[n - j - 1]))
    suf[j + 1] = (sgn * sm, c, sgn)

m = max(pref[k], suf[k])
for i in range(1, k):
    sgn = pref[i][2] * suf[k - i][2]
    pm = pref[i][1] * suf[k - i][1] % mod
    sm = abs(pref[i][0]) + abs(suf[k - i][0])
    m = max(m, (sgn * sm, pm, sgn))

    
print(m[1])
Buggy python submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
const = 1000000007

arr = list(sorted(map(int, input().split())))

def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

result = 0
for i, e in enumerate(arr):
    result += e * (comb(i, k - 1) - comb(n - i - 1, k - 1))
    result %= const

print(result)


Fixed submission:
print(chr(ord(input()) + 1))
Buggy python submission (verdict: Runtime Error):
x = int(input())

res = [False for i in range(x + 1)]
res[0] = True
for i in range(100, 106):
    res[i] = True

for i in range(106, x + 1):
    res[i] = res[i-100] or res[i-101] or res[i-102] or res[i-103] or res[i-104] or res[i-105]

if res[x]:
    print(1)
else:
    print(0)


Fixed submission:
x = int(input())

res = [False for i in range(x + 1)]
res[0] = True
for i in range(100, 106):
    if x < i:
        break
    res[i] = True

for i in range(106, x + 1):
    res[i] = res[i-100] or res[i-101] or res[i-102] or res[i-103] or res[i-104] or res[i-105]

if res[x]:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
tmpA = max(a, b)
tmpB = min(a, b)
 
while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB
 
tmp = tmpA

ass = []
for i in range(2,int(tmp**0.5)+1):
    while tmp % i==0:
        ass.append(i)
        tmp = tmp//i
if tmp != 1:
    ass.append(n)

print(len(set(ass)) + 1)


Fixed submission:
import math

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

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

tmp = tmpA
res = 1

for i in range(2, int(math.sqrt(tmp)) + 1):
    if tmp % i == 0:
        res += 1
        tmp //= i
    else:
        continue

    while tmp % i == 0:
        tmp = tmp//i


if tmp != 1:
    res += 1

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
 
tmpA = max(a, b)
tmpB = min(a, b)
 
while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB
 
already = [0 for i in range(tmpA)]
already[0] = 1
pointer = 1
tmp = tmpA
 
while tmp != 1:
    for i in range(2, tmp // already[pointer - 1]):
        if tmp % i == 0:
            already[pointer] = i
            pointer += 1
            tmp = tmp // i
            break
    else:
        already[pointer] = tmp
        break

print(max(len(set(already)) - 1, 1))


Fixed submission:
import math

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

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

tmp = tmpA
res = 1

for i in range(2, int(math.sqrt(tmp)) + 1):
    if tmp % i == 0:
        res += 1
        tmp //= i
    else:
        continue

    while tmp % i == 0:
        tmp = tmp//i


if tmp != 1:
    res += 1

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

already = [1]
tmp = tmpA

while True:
    if tmp == 1:
        break
    
    for i in range(2, tmp):
        if tmp % i == 0:
            already.append(i)
            tmp = tmp // i
            break
    else:
        already.append(tmp)
        break

print(len(set(already)))


Fixed submission:
import math

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

tmpA = max(a, b)
tmpB = min(a, b)

while tmpB != 0:
    newB = tmpA % tmpB
    tmpA = tmpB
    tmpB = newB

tmp = tmpA
res = 1

for i in range(2, int(math.sqrt(tmp)) + 1):
    if tmp % i == 0:
        res += 1
        tmp //= i
    else:
        continue

    while tmp % i == 0:
        tmp = tmp//i


if tmp != 1:
    res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
def mapping(string):
    return 1 if string == "L" else -1


n, k = map(int, input().split())
s = list(map(mapping, input()))

left = 0
right = n - 1


for loop in range(k):
    for i in range(left, n - 1):
        if s[i] != s[i+1]:
            left = i + 1
            break

    else:
        break

    for i in range(right - 1, left, -1):
        if s[i] != s[i+1]:
            right = i + 1
            break
    else:
        right = n

    for i in range(left, right):
        s[i] *= -1

tmp = 0
for i in range(n - 1):
    if s[i] != s[i+1]:
        tmp += 1

print(n - tmp - 1)


Fixed submission:
def mapping(string):
    return 1 if string == "L" else -1


n, k = map(int, input().split())
s = list(map(mapping, input()))

flips = []
for i in range(n - 1):
    if s[i] != s[i + 1]:
        flips.append(i + 1)

print(min(n - 1, n - 1 - len(flips) + 2 * k))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = tuple(map(int, input().split()))
arr = [0 for i in range(n)]
sums = 0
for i in range(n):
    inp = int(input())
    arr[i] = inp

arr.sort()

sa = 1000000000
for i in range(n-k+1):
    newsa = max(arr[i:i+k]) - min(arr[i:i+k])
    if newsa < sa:
        sa = newsa

print(sa)


Fixed submission:
n, k = tuple(map(int, input().split()))
arr = [0 for i in range(n)]
sums = 0
for i in range(n):
    inp = int(input())
    arr[i] = inp

arr.sort()

sa = 1000000000
for i in range(n-k+1):
    newsa = arr[i+k-1] - arr[i]
    if newsa < sa:
        sa = newsa

print(sa)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
odd = []
even = []
arr = list(map(int, input().split()))
for i, e in enumerate(arr):
    if i % 2 == 0:
        # odd
        res = False
        for x in odd:
            if x[0] == e:
                x[1] += 1
                res = True
                break
        if not res:
            odd.append([e, 1])
    else:
        # even
        res = False
        for x in even:
            if x[0] == e:
                x[1] += 1
                res = True
                break
        if not res:
            even.append([e, 1])
odd.sort(key=lambda x: x[1])
even.sort(key=lambda x: x[1])
if odd[-1][0] == even[-1][0]:
    if len(odd) == 1:
        ans = n - even[-1][1]
    elif len(even) == 1:
        ans = n - odd[-1][1]
    elif odd[-2][1] > even[-2][1]:
        ans = n - even[-1][1] - odd[-2][1]
    else:
        ans = n - even[-2][1] - odd[-1][1]
else:
    ans = n - odd[-1][1] - even[-1][1]
print(ans)


Fixed submission:
n = int(input())
odd = [[i, 0] for i in range(100000)]
even = [[i, 0] for i in range(100000)]
arr = list(map(int, input().split()))
odd_e = True
even_e = True
for i, e in enumerate(arr):
    if i % 2 == 0:
        odd[e - 1][1] += 1
        if odd_e and arr[0] != e:
            odd_e = False
    else:
        even[e - 1][1] += 1
        if even_e and arr[1] != e:
            even_e = False
odd.sort(key=lambda z: z[1])
even.sort(key=lambda z: z[1])
if odd[-1][0] == even[-1][0]:
    if odd_e or even_e:
        ans = n - even[-1][1]
    elif odd[-2][1] > even[-2][1]:
        ans = n - even[-1][1] - odd[-2][1]
    else:
        ans = n - even[-2][1] - odd[-1][1]
else:
    ans = n - odd[-1][1] - even[-1][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


n = int(input())
arr = list(map(int, input().split()))
lcm = 1
for e in arr:
    lcm = int(lcm * e / gcd(lcm, e))
lcm -= 1
res = 0
for e in arr:
    res += lcm % e
print(res)


Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
lcm = 0
for e in arr:
    lcm += e - 1
print(lcm)

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
arr = list(map(int, input().split()))
lcm = 1
for e in arr:
    lcm = int(lcm * e / math.gcd(lcm, e))
lcm -= 1
res = 0
for e in arr:
    res += lcm % e
print(res)


Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
lcm = 0
for e in arr:
    lcm += e - 1
print(lcm)
Buggy python submission (verdict: Runtime Error):
l = input().split()
N = int(l[0])
M = int(l[1])
X = int(l[2])
cost1 = 0
cost2 = 0
j = 0
k = input().split()
for (e in k):
    if int(e) >= X:
        j = k.index(e)
    cost1 = cost1 + 1

for (i in range(j, M)):
    cost2 = cost2 + 1
if cost1 > cost2:
    print(cost1)
else:
    print(cost2)


Fixed submission:
l = input().split()
N = int(l[0])
M = int(l[1])
X = int(l[2])
cost1 = 0
cost2 = 0
j = 0
k = input().split()
for e in k:
    if int(e) >= X:
        j = k.index(e)
        break
    cost1 = cost1 + 1

for i in range(j, M):
    cost2 = cost2 + 1
if cost1 > cost2:
    print(cost2)
else:
    print(cost1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
array = list(map(int, input().split()))
for i in range(0, N):
    konichiwa = list(array)
    konichiwa.pop(i)
    konichiwa.sort()
    print(konichiwa[int(N / 2) - 1])


Fixed submission:
N = int(input())
array = list(map(int, input().split()))
test = list(array)
test.sort()
wow = test[int(N / 2) - 1: int(N / 2) + 1]
for i in range(0, N):
    if array[i] > wow[0]:
        print(wow[0])
    else:
        print(wow[1])
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
arr = list(map(int, input().split()))
ar = [0 for i in range(max(arr))]
for i in arr:
    ar[i - 1] += 1
res = 0
for i in range(len(ar)):
    if ar[i] > i + 1:
        res += ar[i] - i - 1
    if ar[i] < i + 1:
        res += ar[i]
print(res)


Fixed submission:
n = input()
arr = list(map(int, input().split()))
ar = [0 for i in range(100001)]
res = 0
for i in arr:
    if i > 100000:
        res += 1
    else:
        ar[i] += 1
for i in range(len(ar)):
    if ar[i] > i:
        res += ar[i] - i
    if ar[i] < i:
        res += ar[i]
print(res)