Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def solve(N):
  A, B = map(int, input().split())
  return A / B

print(solve())


Fixed submission:
def solve():
  A, B = map(int, input().split())
  return A / B

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

xors = lambda x, y: sum([(a & x) ^ y for a in A])

def dp(flag, k):
  if k < 0: return 0

  x = 1 << k

  if flag and not(K & x):
    return xors(x, 0) + dp(True, k-1)
  else:
    return max(xors(x, x) + dp(flag, k-1), xors(x, 0) + dp(False, k-1))

print(dp(True, 40))


Fixed submission:
def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  B = [0] * 40
  for i in range(40):
    for a in A:
      if a & (1 << i): B[i] += 1

  X = 0
  for i in range(39, -1, -1):
    if X + (1 << i) > K: continue
    if B[i] < N - B[i]: X += 1 << i

  ans = 0
  for a in A:
    ans += a ^ X

  return ans

print(solve())

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from operator import xor
from math import log

def solve():
  N, K = map(int, input().split())
  X = [int(i) for i in input().split()]
  x = reduce(xor, X)
  maxNum = max(X)
  d = int(log(maxNum, 2))
  D = int(log(K, 2))
  while D > d:
    x |= 1 << D
    D -= 1
  ans = 0
  for a in X:
    ans += a ^ x
  return ans

print(solve())


Fixed submission:
def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  B = [0] * 40
  for i in range(40):
    for a in A:
      if a & (1 << i): B[i] += 1

  X = 0
  for i in range(39, -1, -1):
    if X + (1 << i) > K: continue
    if B[i] < N - B[i]: X += 1 << i

  ans = 0
  for a in A:
    ans += a ^ X

  return ans

print(solve())
Buggy python submission (verdict: Runtime Error):
import reduce from functools
import mul from operator

def solve():
	L = [int(i) for i in input().split()]
	return reduce(mul, L) // (2 * max(L))

print(solve())


Fixed submission:
from functools import reduce
from operator import mul

def solve():
	L = [int(i) for i in input().split()]
	return reduce(mul, L) // (2 * max(L))

print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
	N = int(input())
	h = [int(i) for i in input().split()]
    ans = 0
	for i in range(1, N):
		ans += max(h[i] - (0 if i - 1 < 0 else h[i - 1]), 0)
	return ans

print(solve())

Fixed submission:
def solve():
	N = int(input())
	h = [int(i) for i in input().split()]
	ans = 0
	for i in range(0, N):
		ans += max(h[i] - (0 if i - 1 < 0 else h[i - 1]), 0)
	return ans

print(solve())

Buggy python submission (verdict: Runtime Error):
def solve():
	N = int(input())
	h = [int(i) for i in input().split()]
    return N * max(h) - sum(h)

print(solve())

Fixed submission:
def solve():
	N = int(input())
	h = [int(i) for i in input().split()]
	ans = 0
	for i in range(0, N):
		ans += max(h[i] - (0 if i - 1 < 0 else h[i - 1]), 0)
	return ans

print(solve())
Buggy python submission (verdict: Runtime Error):
import operator

def solve(A, B):
  diff = list(map(operator.sub, A, B))
  shortage  = list(filter(lambda d: d < 0, diff))
  remainder = list(filter(lambda d: d > 0, diff))
  remainder.sort(reverse=True)
  short_sum = sum(shortage)
  if short_sum == 0: return 0
  counter = len(shortage)
  for r in remainder:
    short_sum += r
    counter += 1
    if short_sum >= 0: return counter
  return -1

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

print(solve(A, B))

Fixed submission:
def solve(arr):
  flag = [ False ] * 10
  for value in arr:
    flag[value] = True
  return 'YES' if flag[1] and flag[9] and flag[7] and flag[4] else 'NO'


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

print(solve(arr))
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0

for i in range(N):
  if i + 1 < N: dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
  if i + 2 < N: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        # wi = weight[i]
        # vi = value[i]
        for w in range(W, -1, -1):
            _w = w + weight[i]
            # _v = dp[w] + value[i]
            if _w > W: continue
            # if _v <= dp[_w]: continue
            dp[_w] = max(dp[_w], dp[w] + value[i])
    return dp[-1]

print(solve())


Fixed submission:
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for w in range(W, -1, -1):
            _w = w + wi
            _v = dp[w] + vi
            if _w > W: continue
            if _v <= dp[_w]: continue
            dp[_w] = _v
    return dp[-1]

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  N, W = map(int, input().split())
  weight = [0 for i in range(N)]
  value = [0 for i in range(N)]
  for i in range(N):
    weight[i], value[i] = map(int, input().split())
  dp = [[0 for w in range(100100)] for i in range(110)]

  for i in range(N):
    for w in range(W + 1):
      if w - weight[i] >= 0:
        dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - weight[i]] + value[i])
      dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])

  return dp[N][W]

print(solve())


Fixed submission:
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [0 for w in range(W + 1)]

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for w in range(W, -1, -1):
            _w = w + wi
            _v = dp[w] + vi
            if _w > W: continue
            if _v <= dp[_w]: continue
            dp[_w] = _v
    return dp[-1]

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    MAX_VALUE = sum(value)
    dp = [float('inf') for i in range(MAX_VALUE + 1)]
    dp[0] = 0

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for v in range(MAX_VALUE, -1, -1):
            _v = v + vi
            _w = dp[v] + wi
            if _v > MAX_VALUE: continue
            if _w > W: continue
            if dp[_v] <= _w: continue
            dp[_v] = _w
    for i in range(MAX_VALUE, -1, -1):
      if dp[i] <= W: return i
    return 0

print(solve())


Fixed submission:
def solve():
    N, W = map(int, input().split())
    weight = [0 for i in range(N)]
    value = [0 for i in range(N)]
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    dp = [W + 1 for i in range(N * 1000 + 1)]
    dp[0] = 0
    V = 0

    for i in range(N):
        wi = weight[i]
        vi = value[i]
        for v in range(V, -1, -1):
            w = dp[v] + wi
            if dp[v + vi] <= w: continue
            dp[v + vi] = w
        V += vi

    for i in range(V, -1, -1):
      if dp[i] <= W: return i
    return 0

print(solve())
Buggy python submission (verdict: Runtime Error):
def solve(X, Y):
	ans = []


	# append output array
    ans.append(str(X + Y // 2))

    # Output according to format
    ans = '\n'.join(ans)
    return ans

# receive inputs
X, Y = list(map(int, input().split()))

# print outputs
print(solve(X, Y))


Fixed submission:
def solve(X, Y):
	ans = []
	
	ans.append(str(X + Y // 2))
	
    # Output according to format
	ans = '\n'.join(ans)
	return ans

# receive inputs
X, Y = list(map(int, input().split()))

# print outputs
print(solve(X, Y))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

d = gcd(N, M)
n = N // d
m = M // d
f = True

for i in range(d):
    if S[n*i] != T[m*i]:
        f = false
        break

print(n * m * d if f else -1)

Fixed submission:
from fractions import gcd
 
 
def solve(n, m, s, t):
    g = gcd(n, m)
    ng = n // g
    mg = m // g
 
    for h in range(g):
        if s[ng * h] != t[mg * h]:
            return -1
    return ng * mg * g
 
 
n, m = list(map(int, input().split()))
s = input()
t = input()
print(solve(n, m, s, t))

Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N, M = list(map(int, input().split()))
S = input()
T = input()

d = gcd(N, M)
n = N // d
m = M // d
f = True

for i in range(d):
    if S[n*i] != T[m*i]:
        f = false
        break

print(N * M // d if f else -1)

Fixed submission:
from fractions import gcd
 
 
def solve(n, m, s, t):
    g = gcd(n, m)
    ng = n // g
    mg = m // g
 
    for h in range(g):
        if s[ng * h] != t[mg * h]:
            return -1
    return ng * mg * g
 
 
n, m = list(map(int, input().split()))
s = input()
t = input()
print(solve(n, m, s, t))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

N, M = list(map(int, input().split()))
S = input()
T = input()

d = gcd(N, M)
n = N // d
m = M // d
f = True

for i in range(1, d):
    if S[n*i] != T[m*i]:
        f = false
        break

print(N * M // d if f else -1)

Fixed submission:
from fractions import gcd
 
 
def solve(n, m, s, t):
    g = gcd(n, m)
    ng = n // g
    mg = m // g
 
    for h in range(g):
        if s[ng * h] != t[mg * h]:
            return -1
    return ng * mg * g
 
 
n, m = list(map(int, input().split()))
s = input()
t = input()
print(solve(n, m, s, t))
Buggy python submission (verdict: Runtime Error):
print(1110-input())

Fixed submission:
print(1110-int(input()))
Buggy python submission (verdict: Runtime Error):
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  print(_input)
  array.append((int(_input[0]), int(_input[1], int(_input[2]))))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

Fixed submission:
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
array = []

for i in range(N-1):
  _input = str(input()).split(' ')
  array.append((int(_input[0]), int(_input[1], int(_input[2]))))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

Fixed submission:
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
array = []

for i in N-1:
  input = input().split(' ')
  array.append((input[0], input[1]))

for i in N-1:
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    time = time + array[j][0]
  print(time)


print(0)

Fixed submission:
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = map(int, input().split())
count = [0] * N
for a in A:
  count[a] += 1

count.sort(reverse=True)
print(sum(count[K:]))


Fixed submission:
N,K = map(int,input().split())
A = [int(j) for j in input().split()]
count = [0] * N
for a in A:
  count[a - 1] += 1

count.sort(reverse=True)
print(sum(count[K:]))
Buggy python submission (verdict: Runtime Error):
from functools import reduce; from operator import add; print((lambda T, L: reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L), initializer=T))(int(input().split()[1]), list(map(int, input().split()))))


Fixed submission:
from functools import reduce; from operator import add; print((lambda T, L: (reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)) + T) if len(L) > 1 else T)(int(input().split()[1]), list(map(int, input().split()))))

Buggy python submission (verdict: Runtime Error):
from functools import reduce; from operator import add; print((lambda T, L: T + reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)))(int(input().split()[1]), list(map(int, input().split()))))


Fixed submission:
from functools import reduce; from operator import add; print((lambda T, L: (reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)) + T) if len(L) > 1 else T)(int(input().split()[1]), list(map(int, input().split()))))

Buggy python submission (verdict: Runtime Error):
from functools import reduce; from operator import add; print((lambda T, L: T + reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)))(int(input().split()[1]), list(map(int, input().split()))))


Fixed submission:
from functools import reduce; from operator import add; print((lambda T, L: (reduce(add, (lambda t, l: [min(i - j, t) for i, j in zip(l[1:], l[:-1])])(T, L)) + T) if len(L) > 1 else T)(int(input().split()[1]), list(map(int, input().split()))))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

A, B, K = [int(num) for num in input().split()]

if A + B == K:
    print(0, 0)
    sys.exit(0)

if K > A:
    K = K - A
    A = 0

while K:
    if A > 0:
        A -= 1
        K -= 1
        continue
    if B > 0:
        B -= 1
        K -= 1
        continue
print(A, B)


Fixed submission:
import sys

A, B, K = [int(num) for num in input().split()]

if A + B <= K:
    A = 0
    B = 0
    print(A, B)
    sys.exit(0)

if A > K:
    A = A - K
    print(A, B)
    sys.exit(0)
else:
    K = K - A
    A = 0

if B > K:
    B = B - K
    print(A, B)
    sys.exit(0)
else:
    B = 0
    print(A, B)
Buggy python submission (verdict: Runtime Error):
num = int(input())
if num >= 2:
  input_list = [int(i) for i in input().split()] 
  sorted_list = sorted(input_list)

  count = 0
  for input, sort in zip(input_list, sorted_list):
    if input != sort:
      count += 1

  if count < 2:
    print('YES')
  else:
    print('NO')
print('NO')


Fixed submission:
a, b = (int(i) for i in input().split()) 
if a == 0 or b > 10**9 or b == 0 or a == b:
  print('IMPOSSIBLE')
  
elif (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  x = (a + b) / 2
  print(int(x))

Buggy python submission (verdict: Runtime Error):
num = int(input())
if num > 2:
  input_list = [int(i) for i in input().split()] 
  sorted_list = sorted(input_list)

  count = 0
  for input, sort in zip(input_list, sorted_list):
    if input != sort:
      count += 1

  if count < 2:
    print('YES')
  else:
    print('NO')
print('NO')

Fixed submission:
a, b = (int(i) for i in input().split()) 
if a == 0 or b > 10**9 or b == 0 or a == b:
  print('IMPOSSIBLE')
  
elif (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  x = (a + b) / 2
  print(int(x))
Buggy python submission (verdict: Runtime Error):
inputs = [int(x) for x in input().split()]

N = inputs[0]
D = inputs[1]
answer = 0
if N > (D*2) + 1:
  check = N % ((D*2) + 1)
  answer = N / ((D*2) + 1) 
  answer = int(answer)
  if check != 0:
    answer += 1
  
else:
  answer = 1
  
print(answer)

Fixed submission:
r = int(input())
x = 3*(r**2)
print(x)
Buggy python submission (verdict: Runtime Error):
inputs = [int(x) for x in input().split()]

N = inputs[0]
D = inputs[1]
answer = 0
if N < (D*2) + 1:
  answer = 1
else:
  check = N % ((D*2) + 1)
  answer = N / ((D*2) + 1) 
  answer = int(answer)
if check != 0:
  answer += 1
  
print(answer)

Fixed submission:
inputs = [int(x) for x in input().split()]

N = inputs[0]
D = inputs[1]
answer = 0
if N > (D*2) + 1:
  check = N % ((D*2) + 1)
  answer = N / ((D*2) + 1) 
  answer = int(answer)
  if check != 0:
    answer += 1
  
else:
  answer = 1
  
print(answer)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

N += 1

sum = 0
count = 1

for i in range(N):
  sum = sum + L[i]
  count += 1
  if sum > X:
    count -= 1
    break
  if sum >= X:
    break
print(count)

Fixed submission:
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

sum = 0
count = 1

for i in range(N):
  sum = sum + L[i]
  count += 1
  if sum > X:
    count -= 1
    break
  if sum >= X:
    break
print(count)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

N += 1

sum = 0
count = 1

for i in range(N):
  sum = sum + L[i]
  count += 1
  if sum > X:
    count -= 1
    break
  if sum >= X:
    break
print(count)

Fixed submission:
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

sum = 0
count = 1

for i in range(N):
  sum = sum + L[i]
  count += 1
  if sum > X:
    count -= 1
    break
  if sum >= X:
    break
print(count)
Buggy python submission (verdict: Runtime Error):
a, b = tuple(int(num) for input().split())
ab = a * b

if ab % 2:
  print('Odd')
else:
  print('Even')

Fixed submission:
num1, num2 = map(int,input().split())

if num1 * num2 % 2 ==0:
  	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
gd = math.gcd(A,B)
hf = A*B//gd
print(hf)

Fixed submission:
def gcd(x,y):
  while y:
    x,y = y,x%y
  return x

A,B = map(int,input().split())
gd = gcd(A,B)
hf = A*B//gd
print(hf)
Buggy python submission (verdict: Runtime Error):
N=int(input())
edges = [0 for i in range(N)]
edge_l = [[] for i in range(N)]
cols = [0 for i in range(N)]
out = 0
seen = [False for i in range(N)]

def paint(cur, parC):
  curC = 1
  seen[cur] = True
  for e in edge_l[cur]:
    if not seen[e[0]]:
      if curC == parC:
        curC+=1
      cols[e[1]] = curC
      paint(e[0], cols[cur])
      curC+=1

for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edges[a]+=1
  edges[b]+=1
  edge_l[a].append([b,i])
  edge_l[b].append([a,i])
  out = max(out,edges[a],edges[b])
print(out)
paint(0,0)
for i in range(N-1):
  print(cols[i])

Fixed submission:
import sys
sys.setrecursionlimit(200000)

N=int(input())
edges = [0 for i in range(N)]
edge_l = [[] for i in range(N)]
cols = [0 for i in range(N)]
out = 0
seen = [False for i in range(N)]
seen2 = [False for i in range(N)]

def paint(cur, parC):
  if seen[cur]:
    return
  curC = 1
  seen[cur] = True
  for e in edge_l[cur]:
    if not seen2[e[1]]:
      seen2[e[1]] = True
      if curC == parC:
        curC+=1
      cols[e[1]] = curC
      paint(e[0], curC)
      curC+=1
  return

for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edges[a]+=1
  edges[b]+=1
  edge_l[a].append([b,i])
  edge_l[b].append([a,i])
  out = max(out,edges[a],edges[b])
print(out)
paint(0,0)
for i in range(N-1):
  print(cols[i])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i] -= 1
  A[i] %= K

hm = {}
hm[A[0]] = 1
out = 0
for i in range(1,N):
  A[i] += A[i-1]
  A[i] %= K

for i in range(K-1):
  if A[i]==0:
    out+=1
    
for i in range(1,K-1):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  out += hm[A[i]]-1
  
for i in range(K-1,N):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  hm[A[i-K+1]] -= 1
  out += hm[A[i]]-1

print(int(out))

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i] -= 1
  A[i] %= K

hm = {}
hm[A[0]] = 1
out = 0
for i in range(1,N):
  A[i] += A[i-1]
  A[i] %= K

for i in range(min(K-1,N)):
  if A[i]==0 and K != 1:
    out+=1
    
for i in range(1,min(N,K)):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  out += hm[A[i]]-1
  
for i in range(min(K,N),N):
  if A[i] in hm:
    hm[A[i]]+=1
  else:
    hm[A[i]]=1
  hm[A[i-K]] -= 1
  out += hm[A[i]]-1

print(int(out))
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

if A <= K:
    print(0, max(B - (K - A), 0)
else:
    print(A - K, B)


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

if A <= K:
    print(0, max(B - (K - A), 0))
else:
    print(A - K, B)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

X = M // N
for x in range(X, 1, -1):
    r = M - x * (N - 1)
    if r % x == 0:
        print(x)
        exit()
print(1)

Fixed submission:
N, M = map(int, input().split())

X = M // N
for x in range(X, 1, -1):
    r = M - x * (N - 1)
    if r % x == 0:
        print(x)
        exit()
print(1)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N = int(input())
a = [int(ai) for ai in input().split()]

def f(m):
    answer = 0
    for ai in a:
        answer += m % ai
    return answer

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

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

m = lcm(a) - 1
print(f(m))


Fixed submission:
import fractions
from functools import reduce
N = int(input())
a = [int(ai) for ai in input().split()]

def f(m):
    answer = 0
    for ai in a:
        answer += m % ai
    return answer

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

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

m = lcm(a) - 1
print(f(m))