Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, X = map(int, input().split())
x = [int(i) for i in input().split()]

y = [abs(X-i) for i in x]
D = min(y)
f = True
for i in range(D, 0, -1):
    f = True
    for j in range(0, N):
        if y[j]%D != 0:
            f = False
            break
    if f:
        break
    D = i
print(D)

Fixed submission:
import collections

N, X = map(int, input().split())
x = [int(i) for i in input().split()]

y = [abs(X-i) for i in x]
y.append(0)
y.sort()
z = [(y[i+1] - y[i]) for i in range(0, N)]
zz = []
for i in range(0, N):
    if z[i] != 0 and not(z[i] in zz):
        zz.append(z[i])
a = collections.Counter(zz).keys()
D = min(a)
f = True
for i in range(D, 0, -1):
    f = True
    for j in range(0, N):
        if y[j]%D != 0:
            f = False
            break
    if f:
        break
    D = i
print(D)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = []
for i in range(H):
    a.append(list(map(int, input().split())))

ans = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
       operate(h-1, j, h-1, j+1)

print(len(ans))
for i in ans:
    print("{} {} {} {}".format(i[0], i[1], i[2], i[3]))

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = []
ope = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
        operate(h-1, j, h-1, j+1)

print(len(ans))
for i in range(0, len(ans)):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3],end="")
    print()

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
ans = []
for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            a[i][j] -= 1
            a[i+1][j] += 1
            ans.append([i+1, j+1, k+1, l+1])
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
        a[h-1][j] -= 1
        a[h-1][j+1] += 1
        ans.append([h-1, j, h-1, j+1])
print(len(ans))
for i in range(0, len(ans)):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3],end="")
    print()

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]

ans = []
ope = []
def operate(i, j, k, l):
    a[i][j] -= 1
    a[k][l] += 1
    ans.append([i+1, j+1, k+1, l+1])

for j in range(0, w):
    for i in range(0, h-1):
        if a[i][j]%2 == 1:
            operate(i, j, i+1, j)
for j in range(0, w-1):
    if a[h-1][j]%2 == 1:
        operate(h-1, j, h-1, j+1)

print(len(ans))
for i in range(0, len(ans)):
    print(ans[i][0],ans[i][1],ans[i][2],ans[i][3],end="")
    print()
Buggy python submission (verdict: Runtime Error):
print((int(input()) - 1) * (int(input()) - 1))

Fixed submission:
n, m = map(int, input().split())
print((n - 1) * (m - 1))
Buggy python submission (verdict: Runtime Error):
import sys
num = [int(s) for s in sys.stdin.readline().split()]
d = {}
for line in sys.stdin.readlines():
  n = [int(s) for s in line.split()]
  print n
  for s in range(1,n[0]+1):
    if s in d :
      d[n[s]] = d[n[s]]+1
    else :
      d[n[s]] = 1
keys = [k for k, v in d.items() if v == num[0]]
print(len(keys))

Fixed submission:
import sys
num = sys.stdin.readline().split()
d = {}
for line in sys.stdin.readlines():
  n = line.split()
  n.pop(0)
  for s in n:
    if s in d :
      d[s] = d[s]+1
    else :
      d[s] = 1
keys = [k for k, v in d.items() if v == int(num[0])]
print(len(keys))
Buggy python submission (verdict: Runtime Error):
from datetime.datetime import datetime
S=datetime.strptime(S,'%Y/%m/%d')
x=datetime.datetime(2019, 4, 30, 0, 0)
if x>S:
     print('TBD')
else:
     print("Heisei")

Fixed submission:
Y,M,D=map(int,input().split("/"))
if (Y,M,D)>(2019,4,30):
  print("TBD")
else:
   print("Heisei")

Buggy python submission (verdict: Runtime Error):
from datetime.datetime import datetime
datetime.datetime(2019, 4, 30, 0, 0)
S=datetime.strptime(S,'%Y/%m/%d')
x=datetime.datetime(2019, 4, 30, 0, 0)
if x>S:
     print('TBD')
else:
     print("Heisei")

Fixed submission:
Y,M,D=map(int,input().split("/"))
if (Y,M,D)>(2019,4,30):
  print("TBD")
else:
   print("Heisei")

Buggy python submission (verdict: Runtime Error):
S = input()
if S =< 2019/04/30:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
S = input()

if S <= "2019/04/30":
    print("Heisei")
else:
    print("TBD")

Buggy python submission (verdict: Runtime Error):
if S >= 2019/04/30:
  print("Heisei")
  
else:
  print("TBD")

Fixed submission:
S = input()

if S <= "2019/04/30":
    print("Heisei")
else:
    print("TBD")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,raw_input().split())
l = []
s = list()
for i in range(n):
    v,count = map(int,raw_input().split())
    l.append((count,v))

sorted(l, key=lambda x: x[1])

countTmp = 0
for count,v in l:
    count >= k:
        print v
        break
    countTmp = countTmp + count
    if k <= countTmp:
       print v
       break;

Fixed submission:
n,k = map(int,raw_input().split())
l = []
s = list()
for i in range(n):
    v,count = map(int,raw_input().split())
    l.append((count,v))

l = sorted(l, key=lambda x: x[1])

countTmp = 0
for count,v in l:
    countTmp = countTmp + count
    if k <= countTmp:
       print v
       break
Buggy python submission (verdict: Runtime Error):
def solve(t,a,tp,ap):

    if t/a == tp/ap:
        return t,a
    
    next_t=0
    next_a=0
    
    num_a = max( int(a/ap)  , int(t/tp) )
    next_t = num_a*tp
    next_a = num_a*ap

    while not(next_t > t and next_a > a):
        next_t += tp
        next_a += ap
    return next_t,next_a


N = int(raw_input())
l = []
for i in range(N):
    l.append( map(float,raw_input().split()) )

t = 1.0
a = 1.0

while len(l):
    tp,ap = l.pop(0)
    t,a = solve(t,a,tp,ap)

print int(t+a)




Fixed submission:
l =  map(int,raw_input().split())
print len(set(l))
Buggy python submission (verdict: Runtime Error):
N = int(input())
SUM = 0
for i in range(N):
    ODM = input().split()
    if ODM[1] == "JPY":
        SUM = SUM + float(ODM[0])
    else:
        SUM = SUM + float(ODM[0])*380000
print(SUM)

Fixed submission:
import datetime
date = list(map(int,input().split("/")))
date2 = datetime.datetime(date[0],date[1],date[2])
date3 = datetime.datetime(2019,4,30)
if date2 > date3:
    print("TBD")
else:
    print("Heisei")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L_max = max(L)

L_sum = sum(L)

if L_sum - L_max > L_max:
    print("Yes")
else:
    print("No")

Fixed submission:
input_data = input().split()
input_int = list(map(int,input_data))
T = input_int[0]
X = input_int[1]

A = T / X
print(A)
Buggy python submission (verdict: Runtime Error):
import stdin

year, month, date = stdin.readline().rstrip().split('/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 1

if y < heisei_y:
  print('Heisei')
elif  m < heisei_m:
  print('Heisei')
elif  d < heisei_d:
  print('Heisei')
else:
  print('TBD')



Fixed submission:
from sys import stdin


year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 30

if y < heisei_y:
  print('Heisei')
elif  (y == heisei_y) and (m < heisei_m):
  print('Heisei')
elif  ((y == heisei_y) and m == heisei_m) and (d <= heisei_d):
  print('Heisei')
else:
  print('TBD')

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

year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 1

if y < heisei_y:
  print('Heisei');
elif  m < heisei_m:
  print('Heisei');
elif  d < heisei_d:
  print('Heisei');
else:
  print('TBD');



Fixed submission:
from sys import stdin


year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 30

if y < heisei_y:
  print('Heisei')
elif  (y == heisei_y) and (m < heisei_m):
  print('Heisei')
elif  ((y == heisei_y) and m == heisei_m) and (d <= heisei_d):
  print('Heisei')
else:
  print('TBD')

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

year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 1

if (y < heisei_y):
  print('Heisei');
  else if ( m < heisei_m):
    print('Heisei');
    else if ( d < heisei_d):
      print('Heisei');
      else:
        print('TBD');



Fixed submission:
from sys import stdin


year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 30

if y < heisei_y:
  print('Heisei')
elif  (y == heisei_y) and (m < heisei_m):
  print('Heisei')
elif  ((y == heisei_y) and m == heisei_m) and (d <= heisei_d):
  print('Heisei')
else:
  print('TBD')
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    u[i],x[i] = map(str, input().split())
    x[i] = float(x[i])

sum = 0

for i in range(N):
    if (u[i] == 'JPY'):
        sum += x[i]
    elif (u[i] == 'BTC'):
        sum += x[i] * 380000
    else:
        break
print(sum)

Fixed submission:
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    x[i],u[i] = map(str, input().split())
    x[i] = float(x[i])

sum = 0

for i in range(N):
    if (u[i] == 'JPY'):
        sum += x[i]
    elif (u[i] == 'BTC'):
        sum += x[i] * 380000
    else:
        break
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    x[i],u[i] = map(int, input().split())
sum = 0
for i in range(N):
    if (u[i] == 'JPY'):
        sum += x[i]
    elif (u[i] == 'BTC'):
        sum += x[i] * 380000
    else:
        break


Fixed submission:
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    x[i],u[i] = map(str, input().split())
    x[i] = float(x[i])

sum = 0

for i in range(N):
    if (u[i] == 'JPY'):
        sum += x[i]
    elif (u[i] == 'BTC'):
        sum += x[i] * 380000
    else:
        break
print(sum)
Buggy python submission (verdict: Runtime Error):
def solver():
  a = input().rstrip('\n').split('/')
  if int(a[0]) >= 2019:
  	if int(a[1]) >= 4:
  		if int(a[2]) >= 30:
          print('TBD')
  else:
    print('Heisei')
    
solver()

Fixed submission:
def solver():
	a = input().rstrip('\n').split('/')
	if int(a[0]) > 2019:
		print('TBD')
	elif int(a[0]) < 2019:
		print('Heisei')
	else:
		if int(a[1]) > 4:
			print('TBD')
		elif int(a[1]) < 4:
			print('Heisei')
		else:
			if int(a[2]) > 30:
				print('TBD')
			elif int(a[2]) < 30:
				print('Heisei')
			else:
				print('Heisei')

solver()
Buggy python submission (verdict: Runtime Error):
def calc(val, unit):
	if unit == 'BTC':
		val *= 380000
	return val

sum41 = 0
n = int(input())
for _ in range(n):
	tmp = input().rstrip('\n').split(' ')
	sum41 += calc(int(tmp[0]), tmp[1])

print(1.0 * sum41)

Fixed submission:
sum41 = 0
n = int(input())
for _ in range(n):
	tmp = input().split(' ')
	sum41 += float(tmp[0]) if tmp[1] == 'JPY' else float(tmp[0]) * 380000

print(1.0 * sum41)

Buggy python submission (verdict: Runtime Error):
def calc(val, unit):
	if unit == 'BTC':
		val *= 380000
	return val

sum41 = 0
n = int(input())
for i in range(n):
	tmp = input().rstrip('\n').split(' ')
	sum41 += calc(tmp[0], tmp[1])

print(1.0 * sum41)

Fixed submission:
sum41 = 0
n = int(input())
for _ in range(n):
	tmp = input().split(' ')
	sum41 += float(tmp[0]) if tmp[1] == 'JPY' else float(tmp[0]) * 380000

print(1.0 * sum41)
Buggy python submission (verdict: Runtime Error):
import sys
import datetime

lines = sys.stdin.readlines()
X = lines[0]

d = datetime.datetime.strptime(X, '%Y/%m/%d')

if d > datetime.datetime(2019,4,30):
  print('TBD')
else:
  print('Heisei')


Fixed submission:
import sys

lines = sys.stdin.readlines()
S = lines[0]

Ss = S.split('/')

if int(Ss[0]) >= 2019:
  if int(Ss[1]) >= 5:
    print('TBD')
    exit(0)
print('Heisei')

Buggy python submission (verdict: Runtime Error):
import sys
import datetime

lines = sys.stdin.readlines()
X = lines[0]

d = datetime.datetime.strptime(X, '%Y/%m/%d')

if d > datetime.datetime(2019,4,30):
  print('TBD')
else:
  print('Heisei')



Fixed submission:
import sys

lines = sys.stdin.readlines()
S = lines[0]

Ss = S.split('/')

if int(Ss[0]) >= 2019:
  if int(Ss[1]) >= 5:
    print('TBD')
    exit(0)
print('Heisei')
Buggy python submission (verdict: Runtime Error):
import sys

lines = sys.stdin.readlines()

N = lines[0]
H = lines[1]
W = lines[2]

p_row = H - N + 1
p_column = W - N + 1

ans = p_row * p_column
print(ans)



Fixed submission:
import sys

lines = sys.stdin.readlines()

N = int(lines[0])
H = int(lines[1])
W = int(lines[2])

p_row = N - H + 1
p_column = N - W + 1

ans = p_row * p_column
print(ans)

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

lines = sys.stdin.readlines()

N = lines[0]
H = lines[1]
W = lines[2]

p_row = H - N + 1
p_column = W - N + 1

ans = p_row * p_column
print(ans)



Fixed submission:
import sys

lines = sys.stdin.readlines()

N = int(lines[0])
H = int(lines[1])
W = int(lines[2])

p_row = N - H + 1
p_column = N - W + 1

ans = p_row * p_column
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
[Alice, Bob] = sys.argv[1].split()
if Alice == Bob:
	print 'Draw'
	return 0
if Alice == '1':
	print 'Alice'
	return 0
if Bob == '1':
	print 'Bob'
	return 0
if int(Alice) < int(Bob):
	print 'Bob'
else:
	print 'Alice'

Fixed submission:
import sys
[Alice, Bob] = sys.stdin.readline().split()
if Alice == Bob:
	print('Draw')
	sys.exit()
if Alice == '1':
	print('Alice')
	sys.exit()
if Bob == '1':
	print('Bob')
	sys.exit()
if int(Alice) < int(Bob):
	print('Bob')
else:
	print('Alice')
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
X_list = sorted(list(map(int, input().split())))
result_list =[]
for i in range(M):
    result = 0
    for x in X_list:
        result += i ^ x
    result_list.append(result)
if len(result_list)==0:
    print(X_list[0])
else:
    print(max(result_list))

Fixed submission:
T, X = list(map(int, input().split()))
print(T/X)
Buggy python submission (verdict: Runtime Error):
x, y = list(map(int, input().split()))

a = int(x)
b = int(y)

product = a*b

if product % 2 = 0:
	print("Even")
else:
	print("Odd")


Fixed submission:
x, y = list(map(int, input().split()))
 
a = int(x)
b = int(y)
 
product = a*b
 
if product % 2 == 0:
	print("Even")
else:
	print("Odd")
Buggy python submission (verdict: Runtime Error):
year, month, day = [int(item) for item in S.split('/')]

if (int(year) >= 2019) & (int(month) >= 5):
	print('TBD')
else:
	print('Heisei')

Fixed submission:
S = input()

year, month, day = [int(item) for item in S.split('/')]

if (int(year) >= 2019) & (int(month) >= 5):
	print('TBD')
else:
	print('Heisei')
Buggy python submission (verdict: Runtime Error):
N = input()

yen = 0.
for i in range(N):
	x, u = input().split(' ')
	if u == 'JPY':
		yen += float(x)
	elif u == 'BTC':
		yen += 380000.0*float(x)

print(yen)

Fixed submission:
N = int(input())

yen = 0.
for i in range(N):
	x, u = input().split(' ')
	if u == 'JPY':
		yen += float(x)
	elif u == 'BTC':
		yen += 380000.0*float(x)

print(yen)
Buggy python submission (verdict: Runtime Error):
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)
 
def lcm(A, B):
  return (A * // gcd(A, B)) * b

print(functools.reduce(lcm, sorted(T, reverse=True)))

Fixed submission:
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)

def lcm(A, B):
  return (A // gcd(A, B)) * B

print(functools.reduce(lcm, sorted(T, reverse=True)))
Buggy python submission (verdict: Runtime Error):
N, t = map(int, raw_input().split())
n = map(int, raw_input().split())
total = 0
next = t
for i in range(N-1):
	if(next < n[i+1]):
		total += t
		next = n[i+1]
	else:
		total += n[i+1]-n[i]
		next = n[i+1] +t
total += t
print(total)

Fixed submission:
str = raw_input().split()
if (str[0][-1:] == str[1][0] and str[1][-1:] == str[2][0]):
	print ("YES")
else :
	print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
HPs = list(map(int, input().split()))

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    while 0 in HPs:
        HPs.remove(0)

print(HPs[0])

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

Q = B/A

if Q.is_integer():
    print(A+B)
else:
    print(B-A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
HPs = list(map(int, input().split()))

print(N)
print(HPs)

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    if 0 in HPs: 
        HPs.remove(0)

print(HPs[0])

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

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    while 0 in HPs:
        HPs.remove(0)

print(HPs[0])

Buggy python submission (verdict: Runtime Error):
N = int(input())
HPs = list(map(int, input().split()))

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    HPs.remove(0)

print(HPs[0])

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

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    while 0 in HPs:
        HPs.remove(0)

print(HPs[0])

Buggy python submission (verdict: Runtime Error):
N = int(input())
HPs = list(map(int, input().split()))

while len(HPs) > 1:
    HPs.sort()
    for i in len(HPs):
        HPs[i+1] = HPs[i+1] % HPs[0]
    HPs.remove(0)

print(HPs[0])

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

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    while 0 in HPs:
        HPs.remove(0)

print(HPs[0])
Buggy python submission (verdict: Runtime Error):
M, N = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
else:
    distance = []
    X.sort()
    for i in range(M-1):
        distance = distance.append(X[i+1]-X[i])
    distance.sort(reverse=True)
    print(sum(distance[N:]))

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

if N >= M:
    print(0)
else:
    distance = []
    X.sort()
    for i in range(M-1):
        distance.append(X[i+1]-X[i])
    distance.sort(reverse=True)
    print(sum(distance[N-1:]))
Buggy python submission (verdict: Runtime Error):
N = map(int, input().split())
h = list(map(int, input().split()))

loc_max = h[0]
count = 0

for i in range(1, N):
    if h[i] >= loc_max:
        loc_max = h[i]
    if h[i] < h[i-1]:
        count = count + loc_max - h[i]
        loc_max = 0
    if i == N-1:
        count = count + h[i]

print(count)

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

count = 0

for i in range(N-1):
    if h[i] > h[i+1]:
        count = count + h[i] - h[i+1]

count = count + h[N-1]

print(count)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-K+1):
    ans = min(ans, h[i+K]-h[i])

print(ans)

Fixed submission:
N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-K+1):
    ans = min(ans, h[i+K-1]-h[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-K+1):
    ans = min(ans, max(h[i:i+K])-min(h[i:i+K]))

print(ans)


Fixed submission:
N, K = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

ans = 10 ** 9
for i in range(N-K+1):
    ans = min(ans, h[i+K-1]-h[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
n, k = map(int, input().split())
A = list(map(int, input().split()))

ones = [0] * 40 # 各桁で1が立っている数
for a in A:
    for i in range(40):
        if a & (1 << k):
            ones[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << k) > K:
        continue
    if ones[k] < n - ones[k]: # 1が立っている数 < 0が立っている数 -> 1を立てる
        x += (1 << k)

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

print(ans)

Fixed submission:
# input
n, k = map(int, input().split())
A = list(map(int, input().split()))

ones = [0] * 40 # 各桁で1が立っている数
for a in A:
    for i in range(40):
        if a & (1 << i):
            ones[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << i) > k:
        continue
    if ones[i] < n - ones[i]: # 1が立っている数 < 0が立っている数 -> 1を立てる
        x += (1 << i)

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

print(ans)

Buggy python submission (verdict: Runtime Error):
# input
n, k = map(int, input().split())
A = sorted(list(map(int, input().split())))

x = A[0]
for i in range(1, n):
    x = x ^ A[i]

ans1 = 0
for i in range(n):
    ans += x ^ A[i]

ans2 = 0
for i in range(n):
    ans += k ^ A[i]

ans = max(ans1, ans2)
print(ans)

Fixed submission:
# input
n, k = map(int, input().split())
A = list(map(int, input().split()))

ones = [0] * 40 # 各桁で1が立っている数
for a in A:
    for i in range(40):
        if a & (1 << i):
            ones[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << i) > k:
        continue
    if ones[i] < n - ones[i]: # 1が立っている数 < 0が立っている数 -> 1を立てる
        x += (1 << i)

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

print(ans)
Buggy python submission (verdict: Runtime Error):
# input
A = int(input())
B = int(input())

ans = (A - 1) * (B - 1)
print(ans)

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

ans = (A - 1) * (B - 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
# input
N = int(input())
A = list(map(int, input().split()))

i = 0
ans = 0

while i < N - 1:
    if A[i + 1] == A[i]:
        A[i + 1] == A[i] + A[i + 2]
        i += 1
        ans += 1
    i += 1

print(ans)
        


Fixed submission:
# input
N = int(input())
A = list(map(int, input().split()))

i = 0
ans = 0

while i < N - 1:
    if A[i + 1] == A[i]:
        if i < N - 2:
            A[i + 1] == A[i] + A[i + 2]
        if i == N - 1:
            A[i + 1] += 1
        i += 1
        ans += 1
    i += 1

print(ans)