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

Fixed submission:
n = int(input())
s = input()
if n%2:
    print('No')
else:
    n //= 2
    if s[:n]==s[n:]:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2:
  print('No')
else:
  n /= 2
  if s[:n]==s[n:]:
    print('Yes')
  else:
    print('No')
Problem p02912 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n):
        a[i] = -a[i]
    heapify(a)
    for _ in range(m):
        b = heappop(a)
        b = -(-b // 2)
        heappush(a, b)
    print(-sum(a))




if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    while 1:
        a[-1] = a[-1] / 2
        m -= 1
        if m==0:
            res = 0
            for j in a:
                res += int(i)
            print(res)
            exit()
        p = bisect_right(a, a[-1])
        for i in range(p, n-1):
            a[i] = a[i] / 2
            m -= 1
            if m==0:
                res = 0
                for j in a:
                    res += int(i)
                print(res)
                exit()
        a.sort()



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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from fractions import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2
        # 約数のリストを返す

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    
    kouho = yakusuu(sum(a))

    for i in kouho[::-1]:
        nega = [0]*n
        posi = [0]*n
        for j in range(n):
            posi[j] = a[j] % i
        posi.sort()
        for j in range(n):
            nega[j] = posi[j] - i
        posi = [0] + posi
        nega = [0] + nega
        posi = list(accumulate(posi))
        nega = list(accumulate(nega))
        total = 10**10
        for j in range(1, n+1):
            total = min(total, max(posi[j], -(nega[-1]-nega[j])))
        if total <= k:
            print(i)
            break
        
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2
        # 約数のリストを返す

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    
    kouho = yakusuu(sum(a))

    for i in kouho[::-1]:
        nega = [0]*n
        posi = [0]*n
        for j in range(n):
            posi[j] = a[j] % i
        posi.sort()
        for j in range(n):
            nega[j] = posi[j] - i
        posi = [0] + posi
        nega = [0] + nega
        posi = list(accumulate(posi))
        nega = list(accumulate(nega))
        total = 10**10
        for j in range(1, n+1):
            total = min(total, max(posi[j], -(nega[-1]-nega[j])))
        if total <= k:
            print(i)
            break
        
if __name__ == '__main__':
    main()
Problem p02959 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    res = 0
    n = 0
    for i in range(N):
        res += min(a[i], b[i]+n)
        c = max(a[i]-n, 0)
        n = max(b[i]-c, 0)
    res += min(n, a[-1])
    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    res = 0
    n = 0
    for i in range(N):
        if a[i]<b[i]+n:
            res += a[i]
        else:
            res += b[i]+n
        if a[i]-n>0:
            c = a[i]-n
        else:
            c = 0
        if b[i]-c>0:
            n = b[i]-c
        else:
            b = 0
    res += min(n, a[-1])
    print(res)

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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    a = list(set(s))
    if len(a) <2:
        print('No')
        exit()
    if s.count(a[0]) == s.count(a[1]) == 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    a = list(set(s))
    if s.count(a[0]) == s.count(a[1]) == 2:
        print('Yes')
    else:
        print('No')

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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math

#inf = 10**17
#mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(n, 3*n, 2):
    res += a[i]
print(res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd

#inf = 10**17
#mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(n, 3*n, 2):
    res += a[i]
print(res)
Problem p03805 (python)

Fixed submission:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,m = map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(m)]
    res = []
    visited = [0]*n

    def dfs(node):
        visited[node-1]=1
        if sum(visited)==n:
            res.append(1)
            return
        for x,y in edge:
            if x == node:
                if not visited[y-1]:
                    dfs(y)
                    visited[y-1] = 0
            if y == node:
                if not visited[x-1]:
                    dfs(x)
                    visited[x-1] = 0

    for a,b in edge:
        if a==1:
            dfs(a)
            print(len(res))
            exit()

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
res = 0
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007


    N,M = map(int, input().split())
    g = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int, input().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)

    visited = [0]*N

    def dfs(node):
      	global res
        visited[node]=1
        if all(visited):
            res += 1
            return
        for n_node in g[node]:
                if not visited[n_node]:
                    dfs(n_node)
                    visited[n_node] = 0
    dfs(0)
    print(res)

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

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

Buggy submission (verdict: Runtime Error):
k, s = list(map(int, input().split()))
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            total = i+j+k
            if total==s:
                cnt += 1
print(cnt)
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
A = set()
for _ in range(K):
  d = int(input())
  A.update(list(map(int, input().split())))
print(N - len(A))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = set()
for _ in range(K):
  d = int(input())
  A.add(list(input().split()))
print(N - len(A))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = set()
for _ in rnage(K):
  d = int(input())
  A.add(list(input().split()))
print(N - len(A))
Problem p02862 (python)

Fixed submission:
X, Y = map(int, input().split())
n = (2 * X - Y) / 3
m = (2 * Y - X) / 3

if n < 0 or m < 0 or not n.is_integer() or not m.is_integer():
    print(0)
    exit()

n, m = map(int, [n, m])
mod = 10**9 + 7
fact = [1]
inv = [1]
for i in range(1, X + Y + 1):
    fact.append((fact[i-1] * i) % mod)
    inv.append(pow(fact[-1], mod-2, mod))

def cmb(n, r):
    return fact[n] * inv[n-r] * inv[r]

print(cmb(n+m, min(n, m)) % mod)

Buggy submission (verdict: Runtime Error):
from math import factorial

X, Y = [int(i) for i in input().split()]
n = 2 * X - Y
m = 2 * Y - X

if (X + Y) % 3 != 0 or n % 3 != 0 or m % 3 != 0:
    print(0)
    exit()

def comb(a, b):
    return factorial(a) // (factorial(a - b) * factorial(b))

n, m = n / 3, m / 3

print(comb(n + m, n) % (10**9 + 7))
Problem p02912 (python)

Fixed submission:
import heapq
if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(A)
    for _ in range(M):
        tmp = heapq.heappop(A)
        heapq.heappush(A, -(-tmp // 2))
    print(-sum(A))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N, M = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    p = 0
    while 0 < M:
        if N == 1:
            p = 0
        elif N == 2:
            p = A.index(max(A[0], A[1]))
        else:
            p = A.index(max(A[p - 1], A[p], A[p + 1])) if p != 0 else A.index(max(A[p], A[p + 1], A[p + 2]))

        A[p] //= 2
        M -= 1

    ret = 0
    for a in A:
        ret += a
    print(ret)
Problem p03038 (python)

Fixed submission:
import numpy as np
N , M = map(int,input().split())
A = list(map(int,input().split()))
B_C = []
C = []
for i in range(M):
	B_C.append(list(map(int,input().split())))
B_C =np.array(B_C,dtype = np.int64)
B_C = B_C[np.argsort(B_C[:,1])]
not_change = N
A.sort()
A = np.array(A,dtype = np.int64)
k = M - 1
sum_num = 0
judge = 0 
while judge == 0:
	if not_change > B_C[k][0]:
		if A[N - not_change] < B_C[k][1]:
			if A[N - not_change  + B_C[k][0]] < B_C[k][1]:
				sum_num += B_C[k][1] * B_C[k][0]
				not_change -= B_C[k][0]
				if not_change == 0:
					judge = 1
			else:
				while A[N - not_change] < B_C[k][1]:
					sum_num += B_C[k][1]
					not_change -= 1
				judge = 1
		else:
			judge = 1
	else:
		if A[N - not_change] < B_C[k][1]:
			if A[N-1] < B_C[k][1]:
				sum_num += B_C[k][1] * not_change
				not_change = 0
				judge = 1
			else:
				while A[N - not_change] < B_C[k][1]:
					sum_num += B_C[k][1]
					not_change -= 1
				judge = 1
		else:
			judge = 1
	k -= 1
	if k == -1:
		judge = 1


if not_change == 0:
	print(sum_num)
else:
	print(A[N-not_change:N].sum() + sum_num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N , M = map(int,input().split())
A = list(map(int,input().split()))
B_C = []
C = []
for i in range(M):
	B_C.append(list(map(int,input().split())))
B_C =np.array(B_C,dtype = np.int64)
B_C = B_C[np.argsort(B_C[:,1])]
not_change = N
A.sort()
A = np.array(A,dtype = np.int64)
k = M - 1
sum_num = 0
judge = 0 
while judge == 0:
	if not_change >= B_C[k][0]:
		if A[N - not_change] < B_C[k][1]:
			if A[N - not_change  + B_C[k][0]] < B_C[k][1]:
				sum_num += B_C[k][1] * B_C[k][0]
				not_change -= B_C[k][0]
				if not_change == 0:
					judge = 1
			else:
				while A[N - not_change] < B_C[k][1]:
					sum_num += B_C[k][1]
					not_change -= 1
				judge = 1
		else:
			judge = 1
	else:
		if A[N - not_change] < B_C[k][1]:
			if A[N-1] < B_C[k][1]:
				sum_num += B_C[k][1] * not_change
				not_change = 0
				judge = 1
			else:
				while A[N - not_change] < B_C[k][1]:
					sum_num += B_C[k][1]
					not_change -= 1
				judge = 1
		else:
			judge = 1
	k -= 1
	if k == -1:
		judge = 1


if not_change == 0:
	print(sum_num)
else:
	print(A[N-not_change:N].sum() + sum_num)
Problem p02792 (python)

Fixed submission:
import numpy as np
N = int(input())

c = np.zeros((10,10),dtype = int)

for k in range(1,N+1):
	c[int(str(k)[0])][int(str(k)[-1])] += 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += c[i][j]*c[j][i]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())

c = np.zeros((10,10),dtype = int)

for k in range(1,N+1):
	c[int(str(k)[0])][int(str(k)[-1])] += 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += c[i][j]*c[j][i]
print(ans)
Problem p02793 (python)

Fixed submission:
import fractions
N = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,N):
	lcm = lcm*a[i]//fractions.gcd(lcm,a[i])

b = [0]*N

ans = 0
for i in range(N):
	ans += lcm//a[i]
print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,N):
	lcm = lcm*a[i]//fractions.gcd(lcm,a[i])

b = [0]*N

ans = 0
for i in range(N):
	ans += lcm/a[i]
	
print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,N):
	lcm = lcm*a[i]//math.fractions(lcm,a[i])

b = [0]*N

ans = 0
for i in range(N):
	ans += lcm/a[i]
	
print(int(ans%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int,input().split()))
lcm = a[0]
for i in range(1,N):
	lcm = lcm*a[i]//math.gcd(lcm,a[i])

b = [0]*N

ans = 0
for i in range(N):
	ans += lcm/a[i]
	
print(int(ans%(10**9+7)))
Problem p03745 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 1

if N < 3:
	print(ans)
	exit()

if a[0] < a[1]:
	flag = 1
if a[0] > a[1]:
	flag = -1
if a[0] == a[1]:
	flag = 0


for i in range(2,N):
	if flag == 1 and a[i-1] > a[i]:
		ans += 1
		flag = 0
	elif flag == -1 and a[i-1] < a[i]:
		ans += 1
		flag = 0
	elif flag == 0 and a[i-1] < a[i]:
		flag = 1
	elif flag == 0 and a[i-1] > a[i]:
		flag = -1
	
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 1

if a[0] < a[1]:
	flag = 1
if a[0] > a[1]:
	flag = -1
if a[0] == a[1]:
	flag = 0


for i in range(2,N):
	if flag == 1 and a[i-1] > a[i]:
		ans += 1
		flag = 0
	elif flag == -1 and a[i-1] < a[i]:
		ans += 1
		flag = 0
	elif flag == 0 and a[i-1] < a[i]:
		flag = 1
	elif flag == 0 and a[i-1] > a[i]:
		flag = -1
	
print(ans)
Problem p03013 (python)

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

mod = int(1e9+7)

if N == 1:
  print(1)
  exit()

solver = [0]*(N+1)
solver[0] = 1

## 調べるべき階段のみ取り出す
stairs = set(range(2,N+1)) - set(A)

## 1段目の処理
if len(A) > 0 and A[0] == 1:
  solver[1] = 0
else:
  solver[1] = 1

for i in stairs: ## i段目の処理
    var = (solver[i-2] + solver[i-1]) % mod
    solver[i] = var
    
print(solver[-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

mod = int(1e9+7)

if N == 1:
  print(1)
  exit()

solver = [1]

## 1段目の処理
if A[0] == 1:
  solver.append(0)
else:
  solver.append(1)

for i in range(2,N+1): ## i段目の処理
  if i in A:
    solver.append(0)
  else:
    var = (solver[i-2] + solver[i-1]) % mod
    solver.append(var)
    
print(solver[-1])
Problem p02676 (python)

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

if len(s) <= n:
  print(s)
else :
  print(s[:n] + "...")

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

if len(s) <= n:
  print(s)
else :
  print(s[:n] + "...")
Problem p02682 (python)

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

ans=0

if a>= k:
  print(k)

elif a+b >= k:
  print(a)
  
else:
  print(a-((k-a-b)))

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())

ans=0

if a>= k:
  print(k)

elif a+b >= k:
  print(a)
  
else:
  print(a-((k-a-b))
Problem p02711 (python)

Fixed submission:
n = int(input())
 
n = str(n)
 
flag = 0
 
for i in n:
  if(i != '7'):
    flag = 0
  else:
    flag = 1
    break
 
    
if flag == 0:
  print('No')
else :
  print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
 
n = str(n)
 
flag = 0
 
for i in n:
  if(i != '7'):
    flag = 0
  else:
    flag = 1
 
    
if flag = 0:
  print('No')
else :
  print('Yes')
Problem p02712 (python)

Fixed submission:
n = int(input())

a = 0


for i in range(1,n+1):
  
  if(i%3 == 0 or i%5 == 0):
    pass
  else:
    a += i
print(a)

Buggy submission (verdict: Runtime Error):
n = longlong(input())

a = 0


for i in n:
	if(n%i*3 == 0 and n%i*5 == 0):
      a += i
    elif(n%i*3 == 0):
      a += i
    elif(n%i*5 == 0):
      a += i
print(i)
Problem p02835 (python)

Fixed submission:
x , y, z = map(int,input().split(" "))

point = x + y + z

if point <= 21:print("win")

else: print("bust")

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())
z = int(input())
point = x + y + z

if point <= 21:
  print("win")

else:
  print("bust")
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(int((a * b) / gcd(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd

a, b = map(int, input().split())
print(int((a * b) / gcd(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd

a, b = map(int, input().split())
print((a * b) // gcd(a, b))
Problem p02771 (python)

Fixed submission:
A,B,C = map(int,input().split())
if (A==B and B==C and A==C) or (A!=B and B!=C and A!=C):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if A==B and B==C:
    print("No")
else:
print("Yes")
Problem p02835 (python)

Fixed submission:
A1,A2,A3 = map(int,input().split())
if A1+A2+A3>21:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
A1,A2,A3 = map(int,input().split())
if sum(A1,A2,A3)>21:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
A1,A2,A3 = map(int,input().split())
if sum(A1,A2,A3)>21:
    print("bust")
else:
    ("win")
Problem p03137 (python)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
li = [0]*(M-1)
X.sort()
for i in range(M-1):
    li[i] = abs(X[i+1]-X[i])
li.sort()
print(sum(li[:max(0,M-N)]))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = list(map(int,input().split()))
li = []
i = j = ans = 0
X.sort()

for i in range(M-1):
  a = abs(int(X[i+1])-int(X[i]))
  li.append(a)
  i += 1
  
li.sort(reverse=True)
del li[0:N-1]

for j in range(N+1):
  if int(len(li)) == 0:
    break
  ans = ans + int(li[j])
  j += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
X = list(map(int,input().split()))
li = []
i = j = ans = 0
X.sort()
for i in range(M-1):
  a = abs(int(X[i+1])-int(X[i]))
  li.append(a)
  i += 1
li.sort(reverse=True)
del li[0:N-1]
for j in range(N+1):
  ans = ans + int(li[j])
  j += 1
print(ans)
Problem p03775 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

N = int(input())
list =  make_divisors(N)
ans = 10**9
if len(list)%2==1:
    list.append(list[-1])
for i in range(0,len(list),2):
    tmp1 = len(str(list[i]))
    tmp2 = len(str(list[i+1]))
    ans = min(ans,max(tmp1,tmp2))
print(ans)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

N = int(input())
list =  make_divisors(N)
ans = 10**9
for i in range(0,len(list),2):
  tmp1 = len(str(list[i]))
  tmp2 = len(str(list[i+1]))
  ans = min(ans,max(tmp1,tmp2))
print(ans)