Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
if s[a] == "-" and s.count("-") == 1:
  if ｓ.replase("-", "").isdecimal():
    print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int, input().split())
s = input()
if s[a] == "-" and s.count("-") == 1:
  if ｓ.replace("-", "").isdecimal():
    print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
  if A <= sum(list(str(i))) <= B:
    cnt += 1
print(cnt)

Fixed submission:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if A <= sum(map(int, list(str(i)))) <= B:
    ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
print(math.ceil(int(input() + int(input()))))

Fixed submission:
import math
a, b = map(int, input().split())
print(math.ceil((a + b) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
x, y = map(int, input().split())

ss = s.split("T")
xmove = [i.count("F") for i in ss[::2]]
xfirst = xmove[0] # xの１回目はプラス方向固定のため切り出す
xmove = xmove[1:] # ２回目以降でリスト再作成
ymove = [i.count("F") for i in ss[1::2]]

lenx, leny = len(xmove), len(ymove)

# dp[i][p]: (x, y 各方向の)i回目の移動の後にpにいることができるか
dpx = [[False] * 8010 * 2 for _ in range(lenx+1)]
dpy = [[False] * 8010 * 2 for _ in range(leny+1)]

dpx[0][xfirst] = True
for i in range(lenx):
  for j in range(-8010, 8010):
    if j - xmove[i] > -8010:
      dpx[i+1][j] = max(dpx[i+1][j], dpx[i][j - xmove[i]])
    if j + xmove[i] < 8010: 
      dpx[i+1][j] = max(dpx[i+1][j], dpx[i][j + xmove[i]])

dpy[0][0] = True
for i in range(leny):
  for j in range(-8010, 8010):
    if j - ymove[i] > -8010:
      dpy[i+1][j] = max(dpy[i+1][j], dpy[i][j - ymove[i]])
    if j + ymove[i] < 8010:
      dpy[i+1][j] = max(dpy[i+1][j], dpy[i][j + ymove[i]])

if dpx[-1][x] and  dpy[-1][y]:
  print("Yes")
else:
  print("No")

Fixed submission:
def f(start, goal, steps):
  res = set([start])
  for s in steps:
    next_res = set()
    for r in res:
      next_res.add(r + s)
      next_res.add(r - s)
    res = next_res
  return goal in res

s = input()
x, y = map(int, input().split())

ss = s.split("T")
xmove = [i.count("F") for i in ss[::2]]
xfirst = xmove[0] # xの１回目はプラス方向固定のため切り出す
xmove = xmove[1:] # ２回目以降でリスト再作成
ymove = [i.count("F") for i in ss[1::2]]

if f(xfirst, x, xmove) and f(0, y, ymove):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
x, y = map(int, input().split())

ss = s.split("T")
xmove = [i.count("F") for i in ss[::2]]
xfirst = xmove[0] # xの１回目はプラス方向固定のため切り出す
xmove = xmove[1:] # ２回目以降でリスト再作成
ymove = [i.count("F") for i in ss[1::2]]

lenx, leny = len(xmove), len(ymove)

# dp[i][p]: (x, y 各方向の)i回目の移動の後にpにいることができるか
dpx = [[False] * 8010 * 2 for _ in range(lenx+1)]
dpy = [[False] * 8010 * 2 for _ in range(leny+1)]

dpx[0][xfirst] = True
for i in range(lenx):
  for j in range(-8010, 8010):
    if j - xmove[i] > -8010:
      dpx[i+1][j] = max(dpx[i+1][j], dpx[i][j - xmove[i]])
    if j + xmove[i] < 8010: 
      dpx[i+1][j] = max(dpx[i+1][j], dpx[i][j + xmove[i]])

dpy[0][0] = True
for i in range(leny):
  for j in range(-8010, 8010):
    if j - ymove[i] > -8010:
      dpy[i+1][j] = max(dpy[i+1][j], dpy[i][j - ymove[i]])
    if j + ymove[i] < 8010:
      dpy[i+1][j] = max(dpy[i+1][j], dpy[i][j + ymove[i]])

if dpx[-1][x] and  dpy[-1][y]:
  print("Yes")
else:
  print("No")

Fixed submission:
def f(start, goal, steps):
  res = set([start])
  for s in steps:
    next_res = set()
    for r in res:
      next_res.add(r + s)
      next_res.add(r - s)
    res = next_res
  return goal in res

s = input()
x, y = map(int, input().split())

ss = s.split("T")
xmove = [i.count("F") for i in ss[::2]]
xfirst = xmove[0] # xの１回目はプラス方向固定のため切り出す
xmove = xmove[1:] # ２回目以降でリスト再作成
ymove = [i.count("F") for i in ss[1::2]]

if f(xfirst, x, xmove) and f(0, y, ymove):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))
cnt = 0
while all(a % 2 == 0 for a in A):
    A=[a / 2 for a in A]
    ans += 1
print(ans)

Fixed submission:
n = input()
A = list(map(int, input().split()))
cnt = 0
while all(a % 2 == 0 for a in A):
    A = [a / 2 for a in A]
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import deque

h,w = map(int,input().split())
hw = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if hw[i][j] == ".":
      cnt = 0
      for x in [-1, 0, 1]:
        for y in [-1, 0, 1]:
          if i+y in range(h) and j+x in range(w):
            if hw[i+y][j+x]=="#":
              cnt += 1
      hw[i][j]=cnt

for line in hw:
  print("".join(list(map(str, line))))


Fixed submission:
A, B, C = map(int, input().split())
if A==B:
  print(C)
elif A==C:
  print(B)
else:
  print(A)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for i in range(1, 3501):
  for j in range(1, 3501):
    seed = 4 * i * j - n * i - n * j 
    if seed > 0:
      k = n * i * j / seed 
      if k % 1 == 0:
        print(i, j, int(k))
        exit()


Fixed submission:
n = int(input())
for i in range(1, 3501):
  for j in range(1, 3501):
    seed = 4 * i * j - n * i - n * j 
    if seed > 0:
      k = n * i * j / seed 
      if k % 1 == 0:
        print(i, j, int(k))
        exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
lr = [list(map(int, input().split())) for _ in range(n)]
print(sum([i[1] -1[0] + 1 for i in lr]))

Fixed submission:
n = int(input())
lr = [list(map(int, input().split())) for _ in range(n)]
print(sum([i[1] -i[0] + 1 for i in lr]))
Buggy python submission (verdict: Time Limit Exceeded):
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n, m, r = map(int,input().split()) #n:頂点数　m:辺の数 r:訪れる町の数
R = list(map(int,input().split()))

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x, y, z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
wa = warshall_floyd(d)

# 訪れる町の順番を順列で用意
from itertools import permutations
ptn = permutations(R)

ans = 10**19
for p in ptn:
  cost = 0
  roots = [(j-1, i-1) for i, j in zip(p, p[1:])]
  for i, j in roots:
    cost += wa[i][j]
  ans = min(ans, cost)
  
print(ans)

Fixed submission:
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n, m, r = map(int,input().split()) #n:頂点数　m:辺の数 r:訪れる町の数
R = list(map(int,input().split()))

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x, y, z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
wa = warshall_floyd(d)

# 訪れる町の順番を順列で用意
from itertools import permutations
ptn = permutations(R)

ans = 10**19
for p in ptn:
  cost = 0
  roots = [(j-1, i-1) for i, j in zip(p, p[1:])]
  for i, j in roots:
    cost += wa[i][j]
  ans = min(ans, cost)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
ca = Counter(a)
maxa = a[-1]
mina = a[0]
ans = 0
for i in range(mina, maxa+1):
  cnt = sum([v for k, v in ca.items() if i - 1 <= k <= i + 1])
  if ans < cnt:
    ans = cnt
print(ans)

Fixed submission:
input()
C = [0] * 100002
for i in map(int, input().split()):
  C[i - 1] += 1
  C[i] += 1
  C[i + 1] += 1
print(max(C))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
ca = Counter(a)

ans = 0
for i in ca.keys():
  cnt = sum([v for k, v in ca.items() if i-1 <= k <= i+1])
  if ans < cnt:
    ans = cnt
print(ans)


Fixed submission:
input()
C = [0] * 100002
for i in map(int, input().split()):
  C[i - 1] += 1
  C[i] += 1
  C[i + 1] += 1
print(max(C))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
ca = Counter(a)

ans = 0
for i in ca.keys():
  cnt = sum([v for k, v in ca.items() if i-1 <= k <= i+1])
  if ans < cnt:
    ans = cnt
print(ans)

Fixed submission:
input()
C = [0] * 100002
for i in map(int, input().split()):
  C[i - 1] += 1
  C[i] += 1
  C[i + 1] += 1
print(max(C))
Buggy python submission (verdict: Runtime Error):
n = int(input())
U = list(input())
input()

mod = 1000000007

idx = 0
li = []
while idx < len(U) - 1:
  if U[idx] == U[idx + 1]:
    li.append(2)
    idx += 1
  else:
    li.append(1)
  idx += 1
if U[-1] != U[-2]:
  li.append(1)

ans = 1
pre = li[0]

if pre == 1:
  ans = ans * 3 % mod
else:
  ans = ans * 6 % mod
  
for i in li[1:]:
  if pre == 1:
    ans = ans * 2 % mod
  else:
    if i == 2:
      ans = ans * 3 % mod
  pre = i

print(ans)

Fixed submission:
n = int(input())
U = list(input())
input()

mod = 1000000007

if n == 1:
  print(3)
  exit()

idx = 0
li = []
while idx < len(U) - 1:
  if U[idx] == U[idx + 1]:
    li.append(2)
    idx += 1
  else:
    li.append(1)
  idx += 1
if U[-1] != U[-2]:
  li.append(1)

ans = 1
pre = li[0]

if pre == 1:
  ans = ans * 3 % mod
else:
  ans = ans * 6 % mod
  
for i in li[1:]:
  if pre == 1:
    ans = ans * 2 % mod
  else:
    if i == 2:
      ans = ans * 3 % mod
  pre = i

print(ans)
Buggy python submission (verdict: Runtime Error):
ABCD = list(map(int,input().split()))
if ABCD[1]<=ABCD[]2 or ABCD[3]<=ABCD[0]:
  print(0)
else:
  ABCD.sort()
  print(ABCD[2]- ABCD[1])

Fixed submission:
ABCD = list(map(int,input().split()))
if ABCD[1]<=ABCD[2] or ABCD[3]<=ABCD[0]:
  print(0)
else:
  ABCD.sort()
  print(ABCD[2]- ABCD[1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

N = int(input())
abc = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
xy =  [list(map(int, input().split())) for _ in range(Q)]

li = [[0] * (N) for _ in range(N)]

for a, b, c in abc:
  li[a-1][b-1] = c
  li[b-1][a-1] = c
  
nli = np.array(li)
nnli = np.where(nli == 0, 10**12, nli)

G = csgraph_from_dense(nnli, null_value=10**12)
d = floyd_warshall(G)

for x, y in xy:
  print(int(d[x-1, K-1] + d[K-1, y-1]))

Fixed submission:
def BFS(K, edges, N):
  roots = [ [] for i in range(N)]
  for a, b, c in edges:
    roots[a-1] += [(b-1, c)]
    roots[b-1] += [(a-1, c)]
  dist = [-1] * N
  stack = []
  stack.append(K)
  dist[K] = 0
  while stack:
    label = stack.pop(-1)
    for i, c in roots[label]:
      if dist[i] == -1:
        dist[i] = dist[label] + c
        stack += [i]
  return dist

N = int(input())
abc = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())
xy =  [list(map(int, input().split())) for _ in range(Q)]

distance = BFS(K - 1, abc, N)
for x, y in xy:
  print(distance[x - 1] + distance[y - 1])
Buggy python submission (verdict: Runtime Error):
s = input()
ptint(s[0] + str(len(s)+2) + s[-1])

Fixed submission:
s = input()
print(s[0] + str(len(s)-2) + s[-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []

for i in ab:
  if i[0]==1:
    fst.append(i[1])

for i in ab:
  for j in fst:
    if set(i) == set([j, N]):
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
  


Fixed submission:
print("ABC" + input())
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []
scnd = []

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    scnd.append(i)

for i in scnd:
  for j in fst:
    if set(i) == set([j, N]):
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
  

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

fst = []
scnd = {}

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    idx = i.index(N)
    scnd[i[1-idx]] = 0

#print(scnd,fst)
    
for j in fst:
  if j in scnd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []

for i in ab:
  if i[0]==1:
    fst.append(i[1])

for i in ab:
  for j in fst:
    if set(i) == set([j, N]):
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
  

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

fst = []
scnd = {}

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    idx = i.index(N)
    scnd[i[1-idx]] = 0

#print(scnd,fst)
    
for j in fst:
  if j in scnd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]

fst = []

for i in ab:
  if i[0]==1:
    fst.append(i[1])

for i in ab:
  for j in fst:
    if set(i) == set([j, N]):
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
  

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

fst = []
scnd = {}

for i in ab:
  if i[0]==1:
    fst.append(i[1])
  if N in i:
    idx = i.index(N)
    scnd[i[1-idx]] = 0

#print(scnd,fst)
    
for j in fst:
  if j in scnd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if b − a == c − b:
  print("YES")
else:
  print("NO")
 


Fixed submission:
a,b,c = map(int, input().split())
if (b - a) == (c - b):
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if b − a == c − b:
  print("YES"):
else:
  print("NO")
 


Fixed submission:
a,b,c = map(int, input().split())
if (b - a) == (c - b):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  if i < len(o) or len(e) == len(o):
    ans.append(e[i])
print("".join(ans))


Fixed submission:
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  if i < len(o) - 1 or len(e) == len(o):
    ans.append(e[i])
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  if i < len(o) or len(e) == len(o) 
    ans.append(e[i])
print("".join(ans))

Fixed submission:
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  if i < len(o) - 1 or len(e) == len(o):
    ans.append(e[i])
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  ans.append(e[i])
print("".join(ans))

Fixed submission:
o = input()
e = input()
ans = []
for i in range(len(o)):
  ans.append(o[i])
  if i < len(o) - 1 or len(e) == len(o):
    ans.append(e[i])
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
n = input()
s = input()

ans = 0
for i in s:
  if i == "I":
    cnt += 1
  else:
    cnt -= 1
  if ans < cnt:
    ans = cnt
print(ans)

Fixed submission:
n = input()
s = input()

ans = 0
cnt = 0
for i in s:
  if i == "I":
    cnt += 1
  else:
    cnt -= 1
  if ans < cnt:
    ans = cnt
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

# print(K,S)
cnt = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
#      print(i+j+k)
      if i+j+k == S:
        cnt += 1
print(cnt)


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

# print(K,S)
cnt = 0
for i in range(K+1):
  for j in range(K+1):
    if i+j <= S and i+j+K >= S:
      cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
h, w = input().split()
for i in range(h):
  s = input()
  print(s)
  print(s)

Fixed submission:
h, w = map(int, input().split())
for i in range(h):
  s = input()
  print(s)
  print(s)
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
if n < 3:
    print(0)
    exit()

table = [[0] * 5 for i in range(11)]
for i in range(11):
    for j in range(5):
        t = 9 * (j + 2 + 7 * (i + 1))
        table[i][j] = t % 11

c = [0]
for row in table:
    c.append(c[-1] + row.count(K))

d,m = divmod(n - 2, 11)
ans = c[m] + c[-1] * d
print(ans)

Fixed submission:
n, k = map(int,input().split())
if n < 3:
    print(0)
    exit()

table = [[0] * 5 for i in range(11)]
for i in range(11):
    for j in range(5):
        t = 9 * (j + 2 + 7 * (i + 1))
        table[i][j] = t % 11

c = [0]
for row in table:
    c.append(c[-1] + row.count(k))

d, m = divmod(n - 2, 11)
ans = c[m] + c[-1] * d
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections

li = list(map(int, input().split()))
c = collections.Counter(li)

print(count(c.keys()))

Fixed submission:
import collections

li = list(map(int, input().split()))
c = collections.Counter(li)

print(len(c.keys()))
Buggy python submission (verdict: Runtime Error):
N, K, X, Y = [int(input() for _ in range(4))]
print(min(N, K) * X + max(0, N - K) * Y)

Fixed submission:
N, K, X, Y = [int(input()) for _ in range(4)]
print(min(N, K) * X + max(0, N - K) * Y)
Buggy python submission (verdict: Runtime Error):
# a*a と aaの２パターンを探せばよい？
s = input()
n = len(s)
for i in range(n-2):
  if s[i] == s[i + 1]:
  print(i, i + 1)
  exit()
  
for i in range(n-3):
  if s[i] == s[i + 2]:
  print(i, i + 2)
  exit()
  
print(-1, -1)


Fixed submission:
# a*a と aaの２パターンを探せばよい？
s = input()
n = len(s)
for i in range(n-1):
  if s[i] == s[i + 1]:
    print(i + 1, i + 2)
    exit()
  
for i in range(n-2):
  if s[i] == s[i + 2]:
    print(i + 1, i + 3)
    exit()
  
print(-1, -1)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
for i in range(len(c)-1):
  if c[i] + c[i+1] >= L:
    pos = i + 1
    break
else:
  print("Impossible")
  
for i in range(1,pos):
  print(i)
for i in range(len(c) -1, pos, -1):
  print(i)

Fixed submission:
from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
for i in range(len(c)-1):
  if c[i] + c[i+1] >= L:
    pos = i + 1
    break
else:
  print("Impossible")
  exit()

print("Possible")
for i in range(1,pos):
  print(i)
for i in range(len(c) -1, pos, -1):
  print(i)
print(pos)
Buggy python submission (verdict: Runtime Error):
n = list(int, input().split())
n.sort()
if n[0] == n[1] == 5 and n[2] == 7:
  print("YES")
else:
  print("NO")

Fixed submission:
n = list(map(int, input().split()))
n.sort()
if n[0] == n[1] == 5 and n[2] == 7:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1
 
l1 = l[1:]
l2 = l[:m - 1]
divl = []
 
for i in range(m - 1):
    divl.append(l1[i] - l2[i])
 
divl.sort(reverse = True)
 
if n == 1:
    print(max(l) - min(l))
else:
    for i in range(divcount):
        del divl[0]
    
    print (sum(divl))

Fixed submission:
# -*- coding: utf-8 -*-
 
n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1
 
l1 = l[1:]
l2 = l[:m - 1]
divl = []
 
for i in range(m - 1):
    divl.append(l1[i] - l2[i])
 
divl.sort(reverse = True)
 
if n == 1:
    print(max(l) - min(l))
else:
    if m > n:
        for i in range(divcount):
            del divl[0]
    
        print (sum(divl))
    
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from itertools import starmap

n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1

if n == 1:
    print(max(l) - min(l))
else:
    divl = sorted(list(starmap(lambda a,b: a - b, zip(l[1:], l[:m - 2])), reverse = True)
    for i in range(divcount):
        del divl[0]
    
    print (sum(divl))


Fixed submission:
# -*- coding: utf-8 -*-
 
n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1
 
l1 = l[1:]
l2 = l[:m - 1]
divl = []
 
for i in range(m - 1):
    divl.append(l1[i] - l2[i])
 
divl.sort(reverse = True)
 
if n == 1:
    print(max(l) - min(l))
else:
    if m > n:
        for i in range(divcount):
            del divl[0]
    
        print (sum(divl))
    
    else:
        print(0)

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

n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1

l1 = l[1:]
l2 = l[:m - 1]
divl = []

for i in range(m - 1):
    divl.append(l1[i] - l2[i])

divl.sort(reverse = True)

if n == 1:
    print(max(l) - min(l))
else:
    for i in range(divcount):
        del divl[0]
    
    print (sum(divl))

Fixed submission:
# -*- coding: utf-8 -*-
 
n, m = map(int, input().split())
l = sorted(list(map(int, input().split())))
divcount = n - 1
 
l1 = l[1:]
l2 = l[:m - 1]
divl = []
 
for i in range(m - 1):
    divl.append(l1[i] - l2[i])
 
divl.sort(reverse = True)
 
if n == 1:
    print(max(l) - min(l))
else:
    if m > n:
        for i in range(divcount):
            del divl[0]
    
        print (sum(divl))
    
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
ans = 0
for i in range(n):
	if s[i] is not t[i]:
		ans += 1
print(ans)

Fixed submission:
s = input()
t = input()
n = len(s)
ans = 0
for i in range(n):
	if s[i] is not t[i]:
		ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import *
from collections import *
from math import *

input = stdin.readline

n = int(input())
arr = list(map(int, input().split()))
mul = 1
for x in arr:
	mul *= x
if mul > 10 ** 18:
	mul = -1
print(mul)

Fixed submission:
from sys import *
from collections import *
from math import *

input = stdin.readline

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
mul = 1
for x in arr:
	mul *= x
	if mul > 10 ** 18:
		print(-1)
		exit(0)
print(mul)
Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split())
if w >= s:
  	print("unsafe")
else:
  	print("safe)

Fixed submission:
sheep, wolves = map(int, input().split())
print("unsafe" if wolves >= sheep else "safe")
Buggy python submission (verdict: Runtime Error):
H, A = map(int, intput().split())
res = H // A
if H % A > 0:
  	res += 1
print(res)


Fixed submission:
H, A = map(int, input().split())
res = H // A + (H % A > 0)
print(res)

Buggy python submission (verdict: Runtime Error):
H, A = map(int, intput().split())
res = H // A
if H % A > 0:
  	res += 1
print(res)

Fixed submission:
H, A = map(int, input().split())
res = H // A + (H % A > 0)
print(res)