Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03426 (python)

Fixed submission:
H, W, D = map(int, input().split())
A = [0] * H * W
for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
        A[temp[j] - 1] = (i + 1, j + 1)

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def consumption(point_A, point_B):
    return abs(point_A[0] - point_B[0]) + abs(point_A[1] - point_B[1])


X = []
for i in [D] + list(range(1, D)):
    power = 0
    x = [0]
    for j in range(int((H * W - i) / D)):
        power += consumption(A[i - 1 + j * D], A[i - 1 + (j + 1) * D])
        x.append(power)
        #print("{}->{}".format(A[i - 1], A[i - 1 + (j + 1) * D]))
    X.append(x)
# print(X)
for i in range(Q):
    k = L[i] % D
    if k == 0:
        l = int((L[i] - D) / D)
        r = int((R[i] - D) / D)
    else:
        l = int((L[i] - k) / D)
        r = int((R[i] - k) / D)
    #print(X[k], l, r)
    print(X[k][r] - X[k][l])

Buggy submission (verdict: Runtime Error):
H, W, D = map(int, input().split())
A = [0] * H * W
for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
        A[temp[j] - 1] = (i + 1, j + 1)

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def consumption(point_A, point_B):
    return abs(point_A[0] - point_B[0]) + abs(point_A[1] - point_B[1])


X = []
for i in [D] + list(range(1, D)):
    power = 0
    x = [0]
    for j in range(int((H * W - i) / D)):
        power += consumption(A[i - 1 + j * D], A[i - 1 + (j + 1) * D])
        x.append(power)
        #print("{}->{}".format(A[i - 1], A[i - 1 + (j + 1) * D]))
    X.append(x)
# print(X)
for i in range(Q):
    l = int(L[i] / D)
    r = int(R[i] / D)
    #print(X[L[i] % D], l, r)
    print(X[L[i] % D][r] - X[L[i] % D][l])

Buggy submission (verdict: Runtime Error):
H, W, D = map(int, input().split())
A = [0] * H * W
for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
        A[temp[j] - 1] = (i + 1, j + 1)

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def consumption(point_A, point_B):
    return abs(point_A[0] - point_B[0]) + abs(point_A[1] - point_B[1])


X = []
for i in [D] + list(range(1, D)):
    power = 0
    x = []
    for j in range(int((H * W - i) / D)):
        power += consumption(A[i - 1 + j * D], A[i - 1 + (j + 1) * D])
        x.append(power)
    X.append(x)
for i in range(Q):
    l = int(L[i] / D) - 2
    r = int(R[i] / D) - 2
    print(X[L[i] % D][r] - X[L[i] % D][l])
Problem p03075 (python)

Fixed submission:
c = list()
for i in range(6):
  c.append(int(input()))
if c[4] - c[0] > c[5]:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
c = list()
for i in range(6):
  c.append(int(input()))
if coo[4] - coo[0] > coo[5]:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
C = list()
for i in range(6):
    coo.append(int(input()))
  if coo[4] - coo[0] > coo[5]:
    print(":(")
  else:
    print("Yay!")
Problem p03075 (python)

Fixed submission:
import sys

nums = []

for i in range(5):
  nums.append(int(input()))

k = int(input())

for i in range(5):
  for j in range(5-i)[1:]:
    if nums[j] - nums[i] > k:
      print(":(")
      sys.exit()

print("Yay!")

Buggy submission (verdict: Runtime Error):
nums = []

for i in range(5):
  nums.append(input())

k = input()

for i in range(5):
  for j in range(5-i)[1:]:
    if nums[j] - nums[i] > k:
      print ":("
      return

print "Yay!"
return
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a<=k and e-b<=k and e-c<=k and e-d<=k:
 print('Yay!')
else:
 print(':(')

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = map(int, input().split())
if e-a<=k and e-b<=k and e-c<=k and e-d<=k:
 print(':(')
else:
 print('Yay!')
Problem p03272 (python)

Fixed submission:
N,i=map(int, input().split())
print(N-i+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
i=int(input())
print(N-i+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
i=int(input())
print(N-i+1)
Problem p03307 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N * 2)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N % 2 = 0:
 print(N)
else:
 print(N*2)
Problem p03315 (python)

Fixed submission:
S=input()
if S.count('+') == 0:
 print(-4)
elif S.count('+') == 1:
 print(-2)
elif S.count('+') == 2:
 print(0)
elif S.count('+') == 3:
 print(2)
else:
 print(4)

Buggy submission (verdict: Runtime Error):
S=input()
if S.count('+') = 0:
 print(-4)
elif S.count('+') = 1:
 print(-2)
elif S.count('+') = 2:
 print(0)
elif S.count('+') = 3:
 print(2)
else:
 print(4)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if( e - a > k):
	print(":(")
else:
	print("Yay!")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = int(input()) for i in range(6)
print("Yay!" if (e - a <= k) else ":(")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if( e - a > k):
	print(':)')
else:
	print('Yay'")
Problem p03242 (python)

Fixed submission:
print(1110 - int(input()))

Buggy submission (verdict: Runtime Error):
print(1100 - int(input())
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a<=k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
x,y,z,k = [int(num) for num in input().split()]
#入力して降順ソートしてｋ個分にスライス
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True)[:k] for _ in range(3)]

#リストの最初の値(max値)との差分をリスト化
diff_list = list()
for cake in [a_cake,b_cake,c_cake]:
        diff_list.extend(list(map(lambda x:cake[0]-x,cake)))

diff_list.sort()
cake_max = a_cake[0]+b_cake[0]+c_cake[0]
for diff in diff_list[:k]:
    print(cake_max-diff)

Buggy submission (verdict: Runtime Error):
x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True) for _ in range(3)]

sum_cake = sorted([a+b+c for a in a_cake for b in b_cake for c in c_cake],reverse=True)[:k]
print(sum_cake)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = [int(input()) for _ in range(6)]
 
result = "Yey!" if e-a<=k else ":("
println(result)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = [int(input()) for _ in range(6)]

if e-a > k:
	print(":(")
else
	print("Yey!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

println(e - a <= k ? "Yay!" : ":(")
Problem p03250 (python)

Fixed submission:
# coding: utf-8

nums = input().split(" ")
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
num_list = [a, b, c]

max_num = max(num_list)
min_num = min(num_list)

if max_num == a:
	max_index = 0
elif max_num == b:
	max_index = 1
else:
	max_index = 2

if min_num == a and max_index != 0:
	min_index = 0
elif min_num == b and max_index != 1:
	min_index = 1
else:
	min_index = 2

index_list = [0, 1, 2]
index_list[max_index] = "abc"
index_list[min_index] = "abc"
if index_list[0] == 0:
	middle_index = 0
elif index_list[1] == 1:
	middle_index = 1
else:
	middle_index = 2

answer = int( str(num_list[max_index]) + str(num_list[middle_index]) ) + num_list[min_index]

print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

nums = input().split(" ")
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
num_list = [a, b, c]

max_num = max(num_list)
min_num = min(num_list)

if max_num == a:
	max_index = 0
elif max_num == b:
	max_index = 1
else:
	max_index = 2

if min_num == a and max_index != 0:
	min_index = 0
elif min_num == b and max_index != 1:
	min_index = 1
else:
	min_index = 2

index_list = [0, 1, 2]
del index_list[max_index]
del index_list[min_index]
middle_index = index_list[0]

answer = int( str(num_list[max_index]) + str(num_list[middle_index]) ) + num_list[min_index]

print(answer)
Problem p03317 (python)

Fixed submission:
import math
N , K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
print(math.ceil((N-1)/(K-1)))

Buggy submission (verdict: Runtime Error):
N , K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
print(ceil((N-1)/(K-1)))
Problem p03307 (python)

Fixed submission:
n=int(input())
if n%2==0:
	print(n)
else:
	print(n*2)

Buggy submission (verdict: Runtime Error):
n=int(input())
if(n%2==0)
	print(n)
else
	print(n*2)
Problem p03104 (python)

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

def xors(X):
  res = 0
  x = 2
  while True:
    if x > X:
      break
    if (X % (x*2)) >= x and (X % (x*2)) % 2 == 0:
      res = res + x
    x = x*2
  if X % 4 <= 2 and X % 4 >= 1:
    res = res + 1
  return res
print(xors(B) ^ xors(A-1))

Buggy submission (verdict: Runtime Error):
123456789012 123456789012
Problem p03075 (python)

Fixed submission:
a = int(input())
_ = int(input())
_ = int(input())
_ = int(input())
e = int(input())
k = int(input())

if e - a <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
_ = int(input())
_ = int(input())
_ = int(input())
e = int(input())
k = int(input())

if e - a =< k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
d = int(input())
f = int(input())
h = int(input())
e = int(input())
k = int(input())

if e - a =< k:
  print("Yay!")
else:
  print(":(")
Problem p03135 (python)

Fixed submission:
t,x = map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = [x[i+1]-x[i] for i in range(m-1)]
def dp(n):
    if n == 1:
        return max(x) - min(x)
    else:
        if len(gap) > 0:
            maxGap = max(gap)
            gap.remove(maxGap)
        else:
            maxGap = 0
        return dp(n-1) - maxGap
if n < m:
    print(dp(n))
else:
    print(0)
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = sorted([x[i+1]-x[i] for i in range(m-1)])
if n < m:
    print(sum(gap[:m-n]))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = sorted([x[i+1]-x[i] for i in range(m-1)])
length = len(gap)
def dp(n):
    global gap
    global length
    if n == 1:
        return max(x) - min(x)
    else:
        if length > 0:
            maxGap = gap[length - 1]
            gap = gap[:length-1]
        else:
            maxGap = 0
        return dp(n-1) - maxGap
if n < m:
    print(dp(n))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = [x[i+1]-x[i] for i in range(m-1)]
def dp(n):
    if n == 1:
        return max(x) - min(x)
    else:
        if len(gap) > 0:
            maxGap = max(gap)
            gap.remove(maxGap)
        else:
            maxGap = 0
        return dp(n-1) - maxGap
if n < m:
    print(dp(n))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
gap = [x[i+1]-x[i] for i in range(m-1)]
def dp(n):
    if n == 1:
        return max(x) - min(x)
    else:
        if len(gap) > 0:
            maxGap = max(gap)
            gap.remove(maxGap)
        else:
            maxGap = 0
        return dp(n-1) - maxGap
print(dp(n))
Problem p03327 (python)

Fixed submission:
N = int(input())
if N <1000:
	print("ABC")
else:
	print("ABD")

Buggy submission (verdict: Runtime Error):
N = int(input())　
if N <1000:
	print('ABC') 
else:
	print('ABD')

Buggy submission (verdict: Runtime Error):
N = int(input())　
if N <1000:
	print("ABC") 
else:
	print("ABD")

Buggy submission (verdict: Runtime Error):
N = int(input())　#int=整数
if N <1000:
	print("ABC") #"文字列"
else:
	print("ABD") #else=if以外
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b-a=<k and c-a=<k and d-a=<k and e-a=<k and c-b=<k and d-b=<k and e-b=<k and d-c=<k and e-c=<k and e-d=<k:
  print('Yay!')
else:
  print(':(')
Problem p03307 (python)

Fixed submission:
N = int(input())

if N%2 == 0:
	print(N)
else:
	print(N*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
if n%2 == 0:
  print(N)
else:
  print(N*2)
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x=map(int(),input().split())
print(t/x)
Problem p03250 (python)

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[2]*10+a[1]+a[0])

Buggy submission (verdict: Runtime Error):
a=sort(list(int,input(),split())
b=str(a[2]+a[1])
print(int(b)+a[0])
Problem p03208 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(N)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(n)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()
Problem p03137 (python)

Fixed submission:
num, num_of_coordinates = map(int, input().split(" "))
if num >= num_of_coordinates:
  print ("0")
else:
  coordinates = list(map(int, input().split(" ")))
  total = 0
  abs_distance = []
  coordinates.sort()
  for i in range(0, len(coordinates)-1):
    dist = abs(coordinates[i] - coordinates[i+1])
    total += dist
    abs_distance.append(dist)  

  #でかいやつ順に並べる
  abs_distance.sort()
  abs_distance.reverse()
  for i in range(num-1):
    total -= abs_distance[i]

  print(total)

Buggy submission (verdict: Runtime Error):
num, num_of_coordinates = map(int, input().split(" "))
coordinates = list(map(int, input().split(" ")))
total = 0
abs_distance = []
coordinates.sort()
for i in range(0, len(coordinates)-1):
  dist = abs(coordinates[i] - coordinates[i+1])
  total += dist
  abs_distance.append(dist)  

#でかいやつ順に並べる
abs_distance.sort()
abs_distance.reverse()
for i in range(num-1):
  total -= abs_distance[i]

print(total)
Problem p03104 (python)

Fixed submission:
import itertools


def count_ones(n):
  res = []
  length = n.bit_length()
  power = 1
  while len(res) < length:
    d, m = divmod(n, 2**power)
    num_ones = 2**(power-1) * d + max(0, m + 1 - 2**(power-1))
    res.append(num_ones)
    power += 1
  return res

A, B = map(int, input().split())
if B == 0:
  print(0)
else:
  ones_A = count_ones(A)
  ones_B = count_ones(B)

  ones = [nb - na for nb, na in itertools.zip_longest(ones_B, ones_A, fillvalue=0)]

  change = [x % 2 for x in ones[::-1]]
  change = int(''.join(map(str, change)), 2)
  print(A ^ change)

Buggy submission (verdict: Runtime Error):
import itertools


def count_ones(n):
  res = []
  length = n.bit_length()
  power = 1
  while len(res) < length:
    d, m = divmod(n, 2**power)
    num_ones = 2**(power-1) * d + max(0, m + 1 - 2**(power-1))
    res.append(num_ones)
    power += 1
  return res

A, B = map(int, input().split())
ones_A = count_ones(A)
ones_B = count_ones(B)

ones = [nb - na for nb, na in itertools.zip_longest(ones_B, ones_A, fillvalue=0)]

change = [x % 2 for x in ones[::-1]]
change = int(''.join(map(str, change)), 2)
print(A ^ change)
Problem p03207 (python)

Fixed submission:
N = int(input())
S = [int(input()) for _ in range(N)]

A = sorted(S, reverse=True)

A[0] = A[0]/2

print(int(sum(A)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]

A = sorted(S, reverse=True)

S[0] = S[0]/2

print(sum(int(S))
Problem p03252 (python)

Fixed submission:
s = list(input())
t = list(input())

#print(s)
#print(t)

sset = list(set(s))
tset = list(set(t))

#print(sset)
#print(tset)

s_getindex = []
t_getindex = []

for j in range(len(sset)):
    s_getindex.append([i for i, x in enumerate(s) if x == sset[j]])

for jj in range(len(tset)):
    t_getindex.append([ii for ii, y in enumerate(t) if y == tset[jj]])

#print(s_getindex)
#print(t_getindex)

check_s = []
check_t = []
ans = 0

for k in range(len(sset)):
    if len(s_getindex[k]) != 1:
        for m in s_getindex[k]:
            check_s.append(t[m])
#        print(check_s)
#        print(len(set(check_s)))
        if len(set(check_s)) != 1:
            ans = ans + 1
#            print(s[m])
        check_s.clear()

for kk in range(len(tset)):
    if len(t_getindex[kk]) != 1:
        for mm in t_getindex[kk]:
            check_t.append(s[mm])
        if len(set(check_t)) != 1:
            ans = ans + 1
#            print(t[mm])
        check_t.clear()

#print(ans)

if ans == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())

#print(s)
#print(t)

sset = list(set(s))
tset = list(set(t))

#print(sset)
#print(tset)

s_getindex = []
t_getindex = []

for j in range(len(sset)):
    s_getindex.append([i for i, x in enumerate(s) if x == sset[j]])

for jj in range(len(tset)):
    t_getindex.append([ii for ii, y in enumerate(t) if y == tset[jj]])

#print(s_getindex)
#print(t_getindex)

check_s = []
check_t = []
ans = 0

for k in range(len(sset)):
    if len(s_getindex[k]) != 1:
        for m in s_getindex[k]:
            check_s.append(t[m])
        if len(set(check_s)) != 1:
            ans = ans + 1

for kk in range(len(tset)):
    if len(t_getindex[kk]) != 1:
        for mm in s_getindex[kk]:
            check_t.append(s[mm])
        if len(set(check_t)) != 1:
            ans = ans + 1

#print(ans)

if ans == 0:
    print("Yes")
else:
    print("No")
Problem p03104 (python)

Fixed submission:
def calculate(A):
  c=(int((A+1)/2))%2
  if A%2==0:
    c=c^A
  return c

A,B=map(int,input().split())
print(calculate(A-1)^calculate(B))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input()split())
g=b
while a<b:
  g^=a
  a+=1
print(g)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input()split())
g=b
while a<b:
  g=g^a
  a+=1
print(g)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input()split())
g=b
while a<b:
  g=g*a
  a+=1
print(g)
Problem p03107 (python)

Fixed submission:
S=input()
if S.count("1")>=S.count("0"):
  print(S.count("0")*2)
else:
  print(S.count("1")*2)

Buggy submission (verdict: Runtime Error):
S=input()
if S.count(1)>=S.count(0):
  print(S.count("0")*2)
else:
  print(S.count("1")*2)

Buggy submission (verdict: Runtime Error):
S=input()
if S.count(1)>=S.count(0):
  print(S.count(0)*2)
else:
  print(S.count(1)*2)

Buggy submission (verdict: Runtime Error):
S=input()
res1,res2=0
for i in range(1000):
  S=S.replace("10","3")
  S=S.replace("01","3")
  res1+=S.count("3")*2
  S=S.replace("3","")
for j in range(1000):
  S=S.replace("10","3")
  S=S.replace("01","3")
  res2+=S.count("3")*2
  S=S.replace("3","")
if res1>res2:
  print(res2)
else:
  print(res1)

Buggy submission (verdict: Runtime Error):
S=input()
S=S.replace("10","3")
S=S.replace("01","3")
res=0
res+=S.count(3)
print(S.replace("3",""))
Problem p03137 (python)

Fixed submission:
N,M=map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
if N<M:
  for i in range(M):
    if i != 0:
      count.append(X[i]-get)
      sum+=count[i-1]
    get=X[i]
  count.sort(reverse=True)
  if count != []:
    for i in range(N-1):
      sum-=count[i]
print(sum)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
if n<m:
  for i in range(M):
    if i != 0:
      count.append(X[i]-get)
      sum+=count[i-1]
    get=X[i]
  count.sort(reverse=True)
  if count != []:
    for i in range(N-1):
      sum-=count[i]
print(sum)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
if n<=m:
  for i in range(M):
    if i != 0:
      count.append(X[i]-get)
      sum+=count[i-1]
    get=X[i]
  count.sort(reverse=True)
  if count != []:
    for i in range(N-1):
      sum-=count[i]
print(sum)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
for i in range(M):
  if i != 0:
    count.append(X[i]-get)
    sum+=count[i-1]
  get=X[i]
count.sort(reverse=True)
if count != []:
  for i in range(N-1):
    sum-=count[i]
print(sum)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()
count=[]
sum=0
for i in range(M):
  if i != 0:
    count.append(X[i]-get)
    sum+=count[i-1]
  get=X[i]
count.sort(reverse=True)
for i in range(N-1):
  sum-=count[i]
print(sum)
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
res=[]
for i in range(N-K+1):
  res.append(h[K+i-1]-h[i])
print(min(res))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
res=[]
for i in range(N-K-1):
  res.append(h[K+i-1]-h[i])
print(min(res))
Problem p03242 (python)

Fixed submission:
S=input()
A=""
for i in range(len(S)):
  if S[i]=="1":
    A+="9"
  else:
    A+="1"
print(int(A))

Buggy submission (verdict: Runtime Error):
S=input()
for i in range(len(S)):
  if S[i]=="1":
    S[i]="9"
  else:
    S[i]="1"
print(S)
Problem p03252 (python)

Fixed submission:
S = input()
T = input()

Skey = sorted(set(S),key=S.index)
Tkey = sorted(set(T),key=T.index)

for idx,i in enumerate(Skey):
  S = S.replace(i,str(idx))
for idx,i in enumerate(Tkey):
  T = T.replace(i,str(idx))

if S==T:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
Skey=sorted(S,key=S.index)
Tkey=sorted(t,ket=T.index)

for index,i in enumerate(Skey):
  S=S.replace(i,str(index))
for index,i in enumerate(Tkey):
  T=T.replace(i,str(index))

if S==T:
  print("Yes")
else:
  print("No")
Problem p03307 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 = 0:
  print(N)
else:
  print(N*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 = 0:
  print(N)
else print(N*2)
Problem p03631 (python)

Fixed submission:
N=input()
if N[0]==N[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=input()
if N(0)==N(2):
  print("Yes")
else:
  print("No")
Problem p03834 (python)

Fixed submission:
print(input().replace(',', ' '))

Buggy submission (verdict: Runtime Error):
a=input().split()
print(a[0:4]+" "+a[6:12]+" "+a[13:17])
Problem p03307 (python)

Fixed submission:
n = int(input())
if n%2==0:
  print(n)
else:
  print(2*n)

Buggy submission (verdict: Runtime Error):
n = input()
i = 2
while True:
  if i%2==0 and i%n==0:
    print(i)
    break
  i +=1
Problem p03127 (python)

Fixed submission:
def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  if x % y == 0:
    return y
  else:
    while x % y != 0:
      z = x % y
      x = y
      y = z
    else:
      return z
n = int(input())
a = list(map(int, input().split()))
lsize = len(a)
bef = a[0]
for i in range(1, lsize):
  bef = gcd(bef,a[i])
hp = bef
print(hp)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))
lsize = len(a)
bef = a[0]
for i in range(1, lsize):
  bef = math.gcd(bef,a[i])
print(bef)