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

Fixed submission:
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.spatial.distance import cityblock
B = []

H,W = map(int,input().split())
for row in range(H):
    Inputs = input().split()
    for column in [i for i, x in enumerate(Inputs) if x == '#']:
        B.append((column,row))
OO = [cityblock((0,0),b) for b in B]
OI = [cityblock((0,W-1),b) for b in B]
IO = [cityblock((H-1,0),b) for b in B]
II = [cityblock((H-1,W-1),b) for b in B]
print(min(min(OO),min(OI),min(IO),min(II)))

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.spatial.distance import cityblock
H,W = map(int,input().split())
for row in range(H):
    Inputs = input().split(',')
    for column in [i for i, x in enumerate(Inputs) if x == '#']:
        B.append((column,row))
for b in B:
    OO.apppend(cityblock((0,0),b))
    OI.apppend(cityblock((H-1,0),b))
    IO.apppend(cityblock((0,W-1),b))
    II.append(cityblock(H-1,W-1,b))
print(min(min(OO),min(OI),min(IO),min(II)))
Problem p03242 (python)

Fixed submission:
n = int(input())

print(1110 - n)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(input().split())
 
v_odd = []
v_even = []
 
for i in range(int(n)):
  if i % 2 == 1:
  	v_odd.append(i)
  
for i in range(int(n)):
  if i % 2 == 0:
  	v_even.append(i)
  
v_odd_counter = collections.Counter(v_odd)
a = v_odd_counter.most_common()[0][1]
 
v_even_counter = collections.Counter(v_even)
b = v_even_counter.most_common()[0][1]
 
print(n - a - b)
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())

y3 = y2 + x2- x1
y4 = x2 - x1 + y1
x3 = y1 - y2 + x2
x4 = y1 - y2 + x1

print(x3, y3, x4, y4)

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

y3 = y2 + x2- x1
y4 = x2 - x1 + y1
x3 = y1 - y2 + x2
x4 = y1 - y2 + x1

print(x3 y3 x4 y4)
Problem p03077 (python)

Fixed submission:
import math
C = []
N = int(input())
for i in range(5):
    c = int(input())
    C.append(c)
print(math.ceil(N / min(C)) + 4)

Buggy submission (verdict: Runtime Error):
ans = 5
cnt = 0
N = int(input())
for i in range(5):
    c = int(input())
    if N <= c:
        continue
    else:
        if i == 0:
            ans += N // c
            minn = c
        else:
            if minn - c > 0:
                cnt += 1
                minn = c
for i in range(cnt):
    ans += 2 ** i
print(ans)

Buggy submission (verdict: Runtime Error):
ans = 5
cnt = 0
N = int(input())
for i in range(5):
    c = int(input())
    if N < c:
        continue
    else:
        if i == 0:
            ans += N // c
            minn = c
        else:
            if minn - c > 0:
                cnt += 1
                minn = c
for i in range(cnt):
    ans += 2 ** i
print(ans)
Problem p03209 (python)

Fixed submission:
def f(N, X):
  if N == 0:
    if X >= 1:
      return 1
    return 0
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)

N, X = map(int, input().split(" "))
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)

print(f(N,X))

Buggy submission (verdict: Runtime Error):
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
print(burger)
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)
Problem p03307 (python)

Fixed submission:
import fractions
N = int(input())
print(N * 2 // fractions.gcd(2, N))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
print(N * 2 // math.gcd(2, N))
Problem p03345 (python)

Fixed submission:
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
ans = A - B
if ans >= maxL:
    print("Unfair")
else:
    if K % 2 == 0:
        print(ans)
    else:
        print(ans * (-1))

Buggy submission (verdict: Runtime Error):
import copy
A, B, C, K = map(int, input().split())
maxL = 10 ** 18
L = [A, B, C]
for i in xrange(K):
    newL = [L[1] + L[2], L[0] + L[2], L[0] + L[1]]
    L = copy.copy(newL)

ans = L[0] - L[1]
if ans >= maxL:
    print("Unfair")
else:
    print(ans)
Problem p03018 (python)

Fixed submission:
S = list(input())
S = S[::-1]

t = 0
ans = 0
bc_score = 0
flag = 1

if len(S) <= 2:
    print(0)
    exit()

while t <= len(S)-2:
    if S[t]=="C" and S[t+1] == "B":
        bc_score = 0
        bc_score += 1
        t += 2
        flag = 1
        if t == len(S)-1:
            if S[t] == "A":
                ans += 1
            t += 1
        while flag == 1 and t <= len(S) - 1:
            flag = 0
            if S[t]=="C" and S[t+1] == "B":
                bc_score += 1
                t += 2
                flag = 1
            if t <= len(S) - 1:
                if S[t] == "A":
                    ans += bc_score
                    t += 1
                    flag = 1
    else:
        t += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
S = S[::-1]

t = 0
ans = 0
bc_score = 0
flag = 1

if len(S) <= 2:
    print(0)
    exit()

while t <= len(S)-1:
    if S[t]=="C" and S[t+1] == "B":
        bc_score = 0
        bc_score += 1
        t += 2
        flag = 1
        if t == len(S)-1:
            if S[t] == "A":
                ans += 1
            t += 1
        while flag == 1 and t < len(S) - 1:
            flag = 0
            if S[t]=="C" and S[t+1] == "B":
                bc_score += 1
                t += 2
                flag = 1
            if t <= len(S) - 1:
                if S[t] == "A":
                    ans += bc_score
                    t += 1
                    flag = 1
    else:
        t += 1

print(ans)
Problem p03127 (python)

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

flag = 0
i = 1
while flag == 0:
    if A[i] % A[0] != 0:
        A[i] = A[i] % A[0]
        A[i],A[0] = A[0],A[i]
        i = 1
    else:
        i += 1
        if i == N:
            flag = 1
            print(A[0])
            exit()

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

flag = 0
i = 1
while flag == 0:
    if A[i] % A[0] != 0:
        A[i] = A[i] % A[0]
        A[i],A[0] = A[0],A[i]
        i = 1
    else:
        i += 1
    if i == N-1:
        flag = 1
        print(A[0])
        exit()

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

flag = 0
i = 1
while flag == 0:
    if A[i] % A[0] != 0:
        A[i] = A[i] % A[0]
        A.sort()
        i = 1
    else:
        i += 1
    if i == N-1:
        flag = 1
        print(A[0])
Problem p03135 (python)

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

Buggy submission (verdict: Runtime Error):
t = int(input())
x = int(input())
ans = t / x
print(ans)
Problem p03137 (python)

Fixed submission:
nm = list(map(int, input().split()))
lis = list(map(int, input().split()))

lis.sort()

sum = 0
diff = []

if nm[1] - nm[0] <= 0:
    print(0)
else:
    for i in range (nm[1] - 1):
        diff.append(lis[i + 1] - lis[i])

    diff.sort()

    if nm[0] != 1:
        for j in range (nm[0] - 2):
            diff.pop(-1)

    for k in range (nm[1] - nm [0]):
        sum = sum + diff[k]

    print(sum)

Buggy submission (verdict: Runtime Error):
nm = list(map(int, input().split()))
lis = list(map(int, input().split()))

lis.sort()

sum = 0
diff = []

if nm[1] - nm[0] <= 0:
    print(0)
else:
    for i in range (nm[1] - 1):
        diff[i] = lis[i + 1] - lis[i]

    diff.sort()

    for j in range (nm[0] - 1):
        diff.pop(-1)

    for k in range (nm[1] - nm [0] - 1):
        sum = sum + diff[k]
    
    print(sum)

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

nm = list(map(int, input().split()))
lis = list(map(int, input().split()))

lis.sort()

diff = []

for i in range (nm[1] - 1):
    diff[i] = lis[i + 1] - lis[i]

diff.sort()

for j in range (nm[0] - 1):
    diff.pop(-1)

print(np.sum(diff))
Problem p03426 (python)

Fixed submission:
h, w, d = map(int, input().split(' '))

comp = {}
for i in range(h):
    tmp = list(map(int, input().split(' ')))
    for j in range(w):
        comp[tmp[j]] = [i, j]

q = int(input())
lr = [map(int, input().split(' ')) for _ in range(q)]

dp = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    cnt = dp[i - d]
    cnt += abs(comp[i][0] - comp[i - d][0])
    cnt += abs(comp[i][1] - comp[i - d][1])    
    dp[i] = cnt
    

for l, r in lr:
    print(dp[r] - dp[l])

Buggy submission (verdict: Runtime Error):
h, w, d = map(int, input().split(' '))
q = int(input())
lr = [map(int, input().split(' ')) for _ in range(q)]

comp = {}
for i in range(h):
    tmp = list(map(int, input().split(' ')))
    for j in range(w):
        comp[tmp[j]] = [i, j]

dp = [0] * (h * w + 1)
for i in range(d + 1, h * w + 1):
    cnt = dp[i - d]
    cnt += abs(comp[i][0] - comp[i - d][0])
    cnt += abs(comp[i][1] - comp[i - d][1])    
    dp[i] = cnt
    

for l, r in lr:
    print(dp[r] - dp[l])
Problem p03036 (python)

Fixed submission:
read=input
r,d,x=map(int,read().split(' '))
for i in range(10):
  x=int(r*x-d)
  print(x)

Buggy submission (verdict: Runtime Error):
read=input
r,d,x=map(int,read()).split(' ')
for i in range(10):
  x=int(r*x-d)
  print(x)
Problem p03017 (python)

Fixed submission:
N,A,B,C,D = map(int,input().split())
S = input()
right = max(C,D)
r = min(C,D)-1

if '##' in S[A-1:C] or '##' in S[B-1:D]:
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[B-2:D+1]:
      print('Yes')
    else:
      if len(S[A-1:right])<=6:
        if S[A-1:right].count('#')==2:
          print('No')
        else:
          print('Yes')
      else:
        print('No')

Buggy submission (verdict: Runtime Error):
N,A,B,C,D = map(int,input().split())
S = input()
right = max(C,D)-1
r = min(C,D)-1

if '##' in S[A-1:C-1] or '##' in S[B-1:D-1]:
  print('No')
else:
  if C < D:
  	print('Yes')
    break
  else:
    if '...' in S[B-1:right]:
      print('Yes')
      break
    else:
      if len(S[A-1:right])<=6:
        print('Yes')
        break
      print('No')
Problem p03013 (python)

Fixed submission:
def fib(n):
    a,b = 0,1
    for i in range(n):
        a, b = b, a+b
    return int(b)

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

if M == 0:
    print(fib(N) % (10**9 + 7))
    exit()

A = [int(input()) for _ in range(M)]
L = [0] * (M+1)

ans = 1

L[0] = fib(A[0]-1) % (10**9 + 7)
L[M] = fib(N-(A[M-1]+1)) % (10**9 + 7)

for i in range(1,M):
    if A[i]-A[i-1] == 1:
        print(0)
        exit()
    L[i] = fib((A[i]-1)-(A[i-1]+1)) % (10**9 + 7)

for j in range(M+1):
    ans = (ans * L[j]) % (10**9 + 7)

print(ans)

Buggy submission (verdict: Runtime Error):
def fib(n):
    n += 1
    f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
    return int(f)

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

if M == 0:
    print(fib(N))
    exit()

A = [int(input()) for _ in range(M)]
L = [0] * (M+1)

ans = 1

L[0] = fib(A[0]-1) % (10**9 + 7)
L[M] = fib(N-(A[M-1]+1)) % (10**9 + 7)

for i in range(1,M):
    if A[i]-A[i-1] == 1:
        print(0)
        exit()
    L[i] = fib((A[i]-1)-(A[i-1]+1)) % (10**9 + 7)

for j in range(M+1):
    ans = (ans * L[j]) % (10**9 + 7)

print(ans)

Buggy submission (verdict: Runtime Error):
def fib(n):
    n += 1
    if n == 0:
        return 1
    else:
        f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
        return int(f)

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

if M == 0:
    print(fib(N))
    exit()

A = [int(input()) for _ in range(M)]
L = [0] * (M+1)

ans = 1

L[0] = fib(A[0]-1)
L[M] = fib(N-(A[M-1]+1))

for i in range(1,M):
    if A[i]-A[i-1] == 1:
        print(0)
        exit()
    L[i] = fib((A[i]-1)-(A[i-1]+1))

for j in range(M+1):
    ans = (ans * L[j]) % (10**9 + 7)

print(ans)
Problem p03107 (python)

Fixed submission:
s = input()
count_0 = s.count('0')
count_1 = s.count('1')
print(2*min(count_0,count_1))

Buggy submission (verdict: Runtime Error):
s = str(input())

num_moto = int(len(s))

for ctr in range(500)
    if int(len(s)) == 0:
        break
    s = s.replace('10','')
    s = s.replace('01','')
    
num_kekka = int(len(s))
print(num_moto - num_kekka)
Problem p03108 (python)

Fixed submission:
import math


def find_root(ele):
    root = node_list[ele]['root']
    if root is not None:
        return find_root(root)
    return ele


N, M = list(map(int, input().split()))
bridge_list = list()
for _ in range(M):
    bridge_list.append(list(map(int, input().split())))

answer_list = [math.factorial(N) // math.factorial(2) // math.factorial(N - 2)]
node_list = [{'root': None, 'child_count': 0} for i in range(N)]

for bridge_list in bridge_list[:0:-1]:
    a = bridge_list[0] - 1
    b = bridge_list[1] - 1
    a_root = find_root(a)
    b_root = find_root(b)
    if a_root != b_root:
        answer_list.append(answer_list[-1] - (node_list[a_root]['child_count'] + 1) * (node_list[b_root]['child_count'] + 1))
        next_root = min(a_root, b_root)
        old_root = max(a_root, b_root)
        node_list[next_root]['child_count'] += node_list[old_root]['child_count'] + 1
        node_list[old_root]['root'] = next_root
    else:
        answer_list.append(answer_list[-1])

for answer in answer_list[::-1]:
    print(answer)

Buggy submission (verdict: Runtime Error):
import math


def find_root(ele):
    root = node_list[ele]['root']
    if root is not None:
        return find_root(root)
    return ele


N, M = list(map(int, input().split()))
bridge_list = list()
for _ in range(M):
    bridge_list.append(list(map(int, input().split())))

answer_list = [math.factorial(N) // math.factorial(2) // math.factorial(N - 2)]
node_list = [{'root': None, 'child_count': 0} for i in range(N)]

for bridge_list in bridge_list[:0:-1]:
    a = bridge_list[0] - 1
    b = bridge_list[1] - 1
    a_root = find_root(a)
    b_root = find_root(b)
    if a_root == a and b_root == b:
        answer_list.append(answer_list[-1] - (node_list[a]['child_count'] + 1) * (node_list[b]['child_count'] + 1))
        next_root = min(a, b)
        old_root = max(a, b)
        node_list[next_root]['child_count'] += node_list[old_root]['child_count'] + 1
        node_list[old_root]['root'] = next_root
    elif a_root == a and b_root != b:
        answer_list.append(answer_list[-1] - (node_list[a]['child_count'] + 1) * (node_list[b_root]['child_count'] + 1))
        node_list[a]['child_count'] += node_list[b_root]['child_count'] + 1
        node_list[b_root]['root'] = a
    elif a_root != a and b_root == b:
        answer_list.append(answer_list[-1] - (node_list[a_root]['child_count'] + 1) * (node_list[b]['child_count'] + 1))
        node_list[b]['child_count'] += node_list[a_root]['child_count'] + 1
        node_list[a_root]['root'] = b
    else:
        answer_list.append(answer_list[-1])

for answer in answer_list[::-1]:
    print(answer)
Problem p03745 (python)

Fixed submission:
import math

N = int(input())
A_list = list(map(int, input().split()))

num_split = 1
sign = None
len_A_list = len(A_list)

for i in range(len_A_list-1):
    if sign == None:
        if A_list[i+1] - A_list[i] == 0:
            continue
        sign = (A_list[i+1] - A_list[i]) / math.fabs(A_list[i+1] - A_list[i])

    if (A_list[i+1] - A_list[i]) *  sign >= 0:
        continue

    num_split += 1
    sign = None

print(num_split)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
line_list = list()
for _ in range(M):
    a, b = list(map(int, input().split()))
    line_list.append((a, b))

path_points = [ line_list[0][0], line_list[0][1] ]

for i in range(1, M):
    if line_list[i][0] not in path_points and line_list[i][1] not in path_points:
        break

    if   line_list[i][0] in path_points and line_list[i][1] not in path_points:
        path_points.append(line_list[i][1])
    elif line_list[i][1] in path_points and line_list[i][0] not in path_points:
        path_points.insert(0, line_list[i][0])

for point in path_points:
    print(point)

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

X = []
W = []
X_after = []
for _ in range(N):
    x, w = list(map(int, input().split()))
    if w == 1:
        x_after = (x + T) % L
    else:
        x_after = (x - T) % L
        x_after = x_after if x_after >= 0 else L + x_after
    X.append(x)
    W.append(w)
    X_after.append(x_after)

n_colide = 0
for i in range(1, N):
    if W[0] == 1 and W[i] == 2:
        dist = X[i] - X[0]
        n_colide += 2 * (T - (dist / 2)) // L + 1
    elif W[0] == 2 and W[i] == 1:
        dist = (L + X[0]) - X[i]
        n_colide += 2 * (T - (dist / 2)) // L + 1

if W[0] == 1:
    num_after = n_colide % N
else:
    num_after = N - (n_colide % N)

num_after = int(num_after)

x_after_first = X_after[0]
X_after = sorted(X_after)
i = X_after.index(x_after_first)
X_after = X_after[i-num_after:] + X_after[:i-num_after]

for x_after in X_after:
    print(x_after)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A_list = list(map(int, input().split()))

num_split = 1
sign = None
len_A_list = len(A_list)

for i in range(len_A_list-1):
    if sign == None:
        sign = (A_list[i+1] - A_list[i]) / math.fabs(A_list[i+1] - A_list[i])

    if (A_list[i+1] - A_list[i]) *  sign >= 0:
        continue

    num_split += 1
    sign = None

print(num_split)
Problem p03767 (python)

Fixed submission:

def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

    sum_second_a = 0
    
    a_list = a_list[:2*N]
    for i in range(1, 2*N, 2):
        sum_second_a += a_list[i]

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

    sum_second_a = 0
    
    import pdb; pdb.set_trace()
    while len(a_list) > 0:
        a_list.pop(0)
        sum_second_a += a_list.pop(0)
        a_list.pop(-1)

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


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

Fixed submission:


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

if k % 2 == 0:
    if a - b > pow(10,18):
        print("Unfair")
    else:
        print(a - b)
else:
    if b - a > pow(10,18):
        print("Unfair")
    else:
        print(b - a)

Buggy submission (verdict: Runtime Error):

n = int(input())
p = [int(input()) for _ in range(n)]


lsi = list(0 for _ in range(n+1))

for i in range(n):
    num = p[i]
    lsi[num] = 1

    for j in range(num):
        if j + lsi[j] == num:
            lsi[j] += 1

print(n - max(lsi))
Problem p03272 (python)

Fixed submission:
def main():
    # parse
    N, i = parse()
    # compute
    result = compute(N, i)
    # show result
    print(result)

def compute(N, i):
    return N + 1 - i

def parse():
    vars = split_stdin(get_stdin())
    return int(vars[0]), int(vars[1])

def get_stdin():
    return input()

def split_stdin(stdin_val, delim = ' '):
    return [x for x in stdin_val.split(delim) if x != '']

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def main():
    # parse
    N, i = parse() 
    # compute
    result = compute(N, i)
    # show result
    print(result)

def compute(N, i):
    return N + 1 - i

def parse():
    vars = split_stdin(get_stdin())
    return vars[0], vars[1] 

def get_stdin():
    return input()

def split_stdin(stdin_val, delim = ' '):
    return [x for x in stdin_val.split(delim) if x != '']

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

def main():
    # parse
    N, i = parse() 
    # compute
    result = compute(N, i)
    # show result
    print(result)

def compute(N, i):
    return N + 1 - i

def parse():
    vars = split_stdin(get_stdin())
    return vars[0], vars[1] 

def get_stdin():
    return input()

def split_stdin(stdin_val, delim = ' '):
    return [x for x in stdin_val.split(delim) if x != '']

if __name__ == "__main__":
    main()
Problem p03011 (python)

Fixed submission:
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
print(a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a = input().split()
a = [int(i) for i in a]
a = sort(a)
print(a[0]+a[1])
Problem p03137 (python)

Fixed submission:
import sys
# メタデータ入力
n, m = map(int,input().split())

if n >= m:
  print(0)
  sys.exit()
# 座標入力
pos = list(map(int,input().split()))
# ソート
pos.sort()

# 差分計算
distances = []
for i, x in enumerate(pos):
  if i == 0:
    continue
  distances.append(abs(pos[i] - pos[i-1]))

distances.sort()
for i in range(n-1):
	distances.pop()
print(sum(distances))

Buggy submission (verdict: Runtime Error):
# メタデータ入力
n, m = map(int,input().split())

# 座標入力
pos = list(map(int,input().split()))
# ソート
pos.sort()

# 差分計算
distances = []
for i, x in enumerate(pos):
  if i == 0:
    continue
  distances.append(abs(pos[i] - pos[i-1]))

distances.sort()
for i in range(n-1):
	distances.pop()
print(sum(distances))
Problem p03013 (python)

Fixed submission:
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 1000000007

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(100010)]
dp[0] = 0
for i in a: dp[i] = 0
def rec(i):
    if dp[i] > -1:
        return dp[i]
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%MOD
    return dp[i]
    
print(rec(N))

Buggy submission (verdict: Runtime Error):
MOD=10**9+7

N,_,*a = map(int, open(0).read().split())
A=set(a)
dp = [0 for _ in range(N+1)]
for i in range(1,3):
    if i not in A:
        dp[i]=dp[i-1]+1
for i in range(3,N+1):
    if i not in A:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
    
print(dp[N])

Buggy submission (verdict: Runtime Error):
MOD=10**9+7

N,_,*a = map(int, open(0).read().split())
A=set(a)
dp = [0 for _ in range(N+1)]
for i in range(1,3):
    if i not in A: dp[i]=dp[i-1]+1
for i in range(3,N+1):
    if i not in A: dp[i]=(dp[i-1]+dp[i-2])%MOD
    
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3000)

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(150000)]
dp[0] = 0
def rec(i):
    if dp[i] >= 0:
        return dp[i]
    if i in a:
        dp[i] = 0
        return 0
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%1000000007
    return dp[i]
    
print(rec(N))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(150000)]
dp[0] = 0
def rec(i):
    if dp[i] >= 0:
        return dp[i]
    if i in a:
        dp[i] = 0
        return 0
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%1000000007
    return dp[i]
    
print(rec(N))
Problem p03011 (python)

Fixed submission:
data = list(map(int, input().split()))
time = sorted(data)
answer = time[0] + time[1]
print(answer)

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

time = time.sort()

print(time[0] + time[1])