Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
INF = int(1e9)
N, M, K = list(map(int, input().split()))
R = list(map(lambda x: int(x) - 1, input().split()))

G = [[INF] * N for i in range(N)]
for i in range(N):
    G[i][i] = 0
            
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    G[a][b] = G[b][a] = c
    
ls = range(N)
for k in ls:
    for i in ls:
        for j in ls:
            x = G[i][k] + G[k][j]
            if x < G[i][j]:
                G[i][j] = G[j][i] = x

dp = [[INF] * (1<<K) for i in range(K)]
for i in range(K):
    dp[i][1<<i] = 0

for bit in range(1<<K):
    for pre in range(K):
        if (bit >> pre) & 1 == 0:
            continue
        for to in range(K):
            if (bit >> to) & 1 == 1:
                continue
            cost = dp[pre][bit] + G[R[pre]][R[to]]
            nbit = bit | (1<<to)
            if dp[to][nbit] > cost:
                dp[to][nbit] = cost

ans = INF     
for pre in range(K):
    ans = min(ans, dp[pre][(1<<K) - 1])
print (ans)
              


Fixed submission:
INF = int(1e9)
N, M, K = list(map(int, input().split()))
R = list(map(lambda x: int(x) - 1, input().split()))

G = [[INF] * N for i in range(N)]
for i in range(N):
    G[i][i] = 0
            
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    G[a][b] = G[b][a] = c
    
ls = range(N)
for k in ls:
    for i in ls:
        for j in range(i+1,N):
            x = G[i][k] + G[k][j]
            if x < G[i][j]:
                G[i][j] = G[j][i] = x

dp = [[INF] * (1<<K) for i in range(K)]
for i in range(K):
    dp[i][1<<i] = 0

for bit in range(1<<K):
    for pre in range(K):
        if (bit >> pre) & 1 == 0:
            continue
        for to in range(K):
            if (bit >> to) & 1 == 1:
                continue
            cost = dp[pre][bit] + G[R[pre]][R[to]]
            nbit = bit | (1<<to)
            if dp[to][nbit] > cost:
                dp[to][nbit] = cost

ans = INF     
for pre in range(K):
    ans = min(ans, dp[pre][(1<<K) - 1])
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = [int(i) for i in input().split()]

INF = int(1e18)
G = np.full((N, N), INF)
for i in range(N):
    G[i][i] = 0

edge = []
for i in range(M):
    a, b, c = [int(i) for i in input().split()]
    a, b = a - 1, b - 1
    G[a][b] = G[b][a] = c
    edge.append((a, b, c))


rng = range(N)
for k in rng:
    for i in rng:
        for j in range(i + 1, N):
            x = G[i][k] + G[k][j]
            if G[i][j] > x:
                G[i][j] = G[j][i] = x;
                
ans = 0
for (a, b, c) in edge:
    flag = False
    for s in rng:
        if flag:
            break;
        for t in rng:
            flag = flag | (G[s][t] == G[s][a] + c + G[b][t])

    ans = ans + (flag == False)
print(ans)
    
        
    



Fixed submission:
import numpy as np
N, M = [int(i) for i in input().split()]

INF = int(1e18)
G = np.full((N, N), INF)
for i in range(N):
    G[i][i] = 0

edge = []
for i in range(M):
    a, b, c = [int(i) for i in input().split()]
    a, b = a - 1, b - 1
    G[a][b] = G[b][a] = c
    edge.append((a, b, c))


rng = range(N)
for k in rng:
    for i in rng:
        for j in range(i + 1, N):
            x = G[i][k] + G[k][j]
            if G[i][j] > x:
                G[i][j] = G[j][i] = x;
                
ans = 0
for (a, b, c) in edge:
    ans = ans + (G[a][b] != c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = [int(i) for i in input().split()]

INF = int(1e18)
G = np.full((N, N), INF)
for i in range(N):
    G[i][i] = 0

edge = []
for i in range(M):
    a, b, c = [int(i) for i in input().split()]
    a, b = a - 1, b - 1
    G[a][b] = G[b][a] = c
    edge.append((a, b, c))


for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j]);

ans = 0
for (a, b, c) in edge:
    flag = False
    for s in range(N):
        for t in range(N):
            flag = flag | (G[s][t] == G[s][a] + c + G[b][t])

    ans = ans + (flag == False)
print(ans)
    
        
    



Fixed submission:
import numpy as np
N, M = [int(i) for i in input().split()]

INF = int(1e18)
G = np.full((N, N), INF)
for i in range(N):
    G[i][i] = 0

edge = []
for i in range(M):
    a, b, c = [int(i) for i in input().split()]
    a, b = a - 1, b - 1
    G[a][b] = G[b][a] = c
    edge.append((a, b, c))


rng = range(N)
for k in rng:
    for i in rng:
        for j in range(i + 1, N):
            x = G[i][k] + G[k][j]
            if G[i][j] > x:
                G[i][j] = G[j][i] = x;
                
ans = 0
for (a, b, c) in edge:
    ans = ans + (G[a][b] != c)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import floor, gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    mods = []
    # print([A * x % B for x in range(B)])
    for x in range(B):
        m = A * x % B
        if m >= 1:
            mods.append(m)
    
    # print(mods)
    if A <= B:
        index = mods.index(min(mods))
    else:
        index = mods.index(max(mods))
    print(index+1)

    # for x in range(1, N+1):
    #     out = floor(A * x / B) - floor(x / B)
    #     tmp = max(tmp, out)
    # print(tmp)
    
    
main()

Fixed submission:
from math import floor, gcd

def f(x, A, B):
    return floor(A * x / B) - A * floor(x / B)

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    # mods = []
    
    a = f(min(B-1, N), A, B)
    print(a)
    
    
main()
Buggy python submission (verdict: Runtime Error):
def main():
    A, B, C = map(int, input().split(' '))
    A, B = B, A
    A, C = C, A
    pritn(A, B, C)
    
    
main()

Fixed submission:
def main():
    A, B, C = map(int, input().split(' '))
    A, B = B, A
    A, C = C, A
    print(A, B, C)
    
    
main()
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N, K = map(int, input().split(' '))
    
    # out = min(float('inf'), N)
    prev = N
    
    isFinish = False
    
    if N % K == 0:
        print(0)
        return
    
    while not isFinish:
        next = abs(prev - K)
        
        if next >= prev:
            isFinish = True
        else:
            prev = next
            
    print(prev)

main()

Fixed submission:

def main():
    N, K = map(int, input().split(' '))
    
    # out = min(float('inf'), N)
    prev = N % K
    
    isFinish = False
    
    if prev == 0:
        print(0)
        return
    
    while not isFinish:
        next = abs(prev - K)
        
        if next >= prev:
            isFinish = True
        else:
            prev = next
            
    print(prev)

main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    N, K = map(int, input().split(' '))
    
    # out = min(float('inf'), N)
    prev = N
    
    isFinish = False
    
    if N % K == 0:
        print(0)
        return
    
    while not isFinish:
        next = abs(prev - K)
        
        if next > prev:
            isFinish = True
        else:
            prev = next
            
    print(prev)
        
        
    
    
    
    
main()

Fixed submission:

def main():
    N, K = map(int, input().split(' '))
    
    # out = min(float('inf'), N)
    prev = N % K
    
    isFinish = False
    
    if prev == 0:
        print(0)
        return
    
    while not isFinish:
        next = abs(prev - K)
        
        if next >= prev:
            isFinish = True
        else:
            prev = next
            
    print(prev)

main()
Buggy python submission (verdict: Runtime Error):
def main():
    H, W = map(int, input().split(" "))
    # r1 + c1 = r2 + c2
    # r1 - c1 = r2 - c2

    if H == 1 or W == 1:
        print('1')

    c = H * W
    if c % 2 == 0:
        print(c // w)
    else:
        MAX = max(H, W)
        MIN = min(H, W)

        out = MIN * (MIN - 1) + MAX % MIN
        


main()

Fixed submission:
def main():
    H, W = map(int, input().split(" "))
    # r1 + c1 = r2 + c2
    # r1 - c1 = r2 - c2
    c = H * W
    if H == 1 or W == 1:
        print('1')
        return

    if c % 2 == 0: # OK
        print(c // 2)
    else:
        print((c // 2) + 1)


# def main():
#     H, W = map(int, input().split(" "))
#     # r1 + c1 = r2 + c2
#     # r1 - c1 = r2 - c2

#     if H == 1 or W == 1:
#         print('1')

#     c = H * W
#     if c % 2 == 0:
#         print(c // w)
#     else:
#         MAX = max(H, W)
#         MIN = min(H, W)

#         out = MIN * (MIN - 1) + MAX % MIN
        


main()
Buggy python submission (verdict: Runtime Error):
def main():
    a,b,c = map(int, input().split(" "))

    if (4 * a * b) < (c - a - b) * (c - a - b) 2 and (c - a - b) > 0:
        print('Yes')
    else:
        print('No')
main()

Fixed submission:
from decimal import Decimal

def main():
    a,b,c = map(int, input().split(" "))

    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print('Yes')
    else:
        print('No')
main()

Buggy python submission (verdict: Runtime Error):
def main():
    a,b,c = map(int, input().split(" "))

    if (4 * a * b) < (c - a - b) * (c - a - b) 2 and (c - a - b) > 0:
        print('Yes')
    else:
        print('No')
main()

Fixed submission:
from decimal import Decimal

def main():
    a,b,c = map(int, input().split(" "))

    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print('Yes')
    else:
        print('No')
main()

Buggy python submission (verdict: Runtime Error):
def main():
    a,b,c = map(int, input().split(" "))

    if 4 * a * b < (c - a - b) * (c - a - b) 2 and (c - a - b) > 0:
        print('Yes')
    else:
        print('No')
main()

Fixed submission:
from decimal import Decimal

def main():
    a,b,c = map(int, input().split(" "))

    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print('Yes')
    else:
        print('No')
main()
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split(" "))


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]

# print(bakks)
count = 0
for x in balls:
    if x == 'b':
        count += 1
print(count)

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split(" "))


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split(" "))


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split(" "))


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls)
print(balls.count('b'))

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split(" "))


balls = ''
for i in range(1000):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
# print(balls)
print(balls.count('b'))

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split(" "))


balls = []
isFinish = True
count = 0
while isFinish:
    if len(balls) >= N:
        isFinish = False
    
    for i in range(A):

        if len(balls) >= N:
            isFinish = False
            break
        balls.append('b')
        count += 1
        

    for i in range(B):
        if len(balls) >= N:
            isFinish = False
            break
        balls.append('r')
        

print(count)

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()
Buggy python submission (verdict: Time Limit Exceeded):
takahashi, aoki, K = list(map(int, input().split(" ")))

for _ in range(K):
    if takahashi >= 1:
        takahashi -= 1
    elif takahashi == 0 and aoki == 0:
        continue
    elif takahashi < 1 and aoki >= 1:
        aoki -= 1

print(takahashi, aoki)

Fixed submission:
A, B, K = list(map(int, input().split(" ")))
times = min(A, K)
K -= times
print(A-times, max(B-K, 0))
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = map(int, input().split(" "))

print(lcm(A, B))

Fixed submission:
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B = map(int, input().split(" "))

print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n-2)

N = int(input())
result = str(f(N))[::-1]
print(result)

count = 0
for n in result:
    if n != 0:
        break
    else:
        count += 1
print(count)

Fixed submission:
def main():
    I = int(input())

    if not I % 2 == 0:
        return 0
    
    I //= 2

    counter = 0
    while I > 0:
        I //= 5
        counter += I
    return counter

print(str(main()))
Buggy python submission (verdict: Runtime Error):
import numpy as np

from sys import exit

def main():
  A, B = map(int, input().split(' '))
  values = range(A, B+1)
  # values = []

  # for n in N:
  #   values.append('{:043b}'.format(n))

  values = np.array(values)
  for i, value in enumerate(values):
    if i == 0:
      result = value
    else:
      result = np.bitwise_xor(result, value)
  print(int(result))
    
  # if len(values) == 1:
  #   print(int(values[0], 2))
  #   return

  # result = ''

  # if len(values) % 2 == 1:
  #   for n in range(43):
  #     num_zero = 0
  #     for value in values:
  #       if value[n] == '0':
  #         num_zero += 1

  #     if num_zero % 2 == 0:
  #       result += '1'
  #     else:
  #       result += '0'

  # else:
  #   for n in range(43):
  #     num_zero = 0

  #     for value in values:
  #       if value[n] == '0':
  #         num_zero += 1

  #     if num_zero % 2 == 0:
  #       result += '0'
  #     else:
  #       result += '1'
  # print(int(result, 2))
  
main()



Fixed submission:
def main():
  H, W = map(int, input().split(' '))
  h, w = map(int, input().split(' '))
  
  a = H*W
  b = (h * W) + (w * H) - h * w
  print(a - b)
  


main()
Buggy python submission (verdict: Runtime Error):

def is_include_0(x):
  if 0 in x:
    x.remove(0)


  if 0 in x:
    return is_include_0(x)
  else:
    return x
  

def main():
  N = int(input())
  monsters = list(map(int, input().split()))

  monsters = sorted(monsters)
  # print(monsters)

  last = 10000
  while True:
    # print('==============================')
    # print(monsters)
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    # print(monsters)
    if 0 in monsters:
      # monsters.remove(0)
      monsters = is_include_0(monsters)
      monsters = sorted(monsters)

    # print(monsters)
    if len(monsters) == 2:
      # print('a')
      last = int(abs(monsters[1] - monsters[0]))
      monsters[0] = last
      monsters.remove(monsters[1])
      # print(monsters)

    if len(monsters) == 1:
      break
  print(monsters[0])

main()


Fixed submission:
from fractions import gcd
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

a = A[0]
for b in A[1:]:
  # print(a)
  a = gcd(a, b)

print(a)

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

  monsters = sorted(monsters)
  # print(monsters)

  last = 10000
  while True:
    # print('==============================')
    # print(monsters)
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    # print(monsters)
    if 0 in monsters:
      monsters.remove(0)
      monsters = sorted(monsters)

    # print(monsters)
    if len(monsters) == 2:
      last = int(abs(monsters[1] - monsters[0]))
      monsters.remove(monsters[1])

    if len(monsters) == 1:
      break
  print(last)

  

main()


Fixed submission:
from fractions import gcd
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

a = A[0]
for b in A[1:]:
  # print(a)
  a = gcd(a, b)

print(a)
Buggy python submission (verdict: Runtime Error):
def main():
  t, x = map(int, input())
  print(float(t) / float(x))


main()

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


main()
Buggy python submission (verdict: Runtime Error):
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  MIN = 100000000000000
  # print(trees)
  for n in range(K):
    t = trees[n+K-1] - trees[n]
    MIN = min(t, MIN)
  print(MIN)
main()

Fixed submission:
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  # MIN = 100000000000000
  # print(trees)
  # for n in range(K):
  # for n in range(N - K + 1):
  #   t = trees[n+K-1] - trees[n]
  #   MIN = min(t, MIN)
  MIN = min([trees[n+K-1] - trees[n] for n in range(N-K+1)])
  print(MIN)

main()

Buggy python submission (verdict: Runtime Error):
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  MIN = 100000000000000
  # print(trees)
  for n in range(K):
    t = trees[n+K-1] - trees[n]
    print(trees[n], trees[n+K-1])
    MIN = min(t, MIN)
  print(MIN)
main()

Fixed submission:
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  # MIN = 100000000000000
  # print(trees)
  # for n in range(K):
  # for n in range(N - K + 1):
  #   t = trees[n+K-1] - trees[n]
  #   MIN = min(t, MIN)
  MIN = min([trees[n+K-1] - trees[n] for n in range(N-K+1)])
  print(MIN)

main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    guusuu = Counter(v_n[::2])
    kisuu = Counter(v_n[1::2])

    guusuu = guusuu.most_common()
    kisuu = kisuu.most_common()


    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            print(guusuu)
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n- guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])
        
main()

Fixed submission:
n = list(input())

result = ""

for a in n:
  if a == '1':
    result += '9'
  else:
    result += '1'


print(result)
Buggy python submission (verdict: Runtime Error):
from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()
    
    if guusuu[0][0]==kisuu[0][0]:
        print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()

Fixed submission:
from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()

    # print(guusuu, len(guusuu))
    # print(kisuu, len(kisuu))
    
    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            # n=4, `4 4 4 4`
            # print('----------')
            print(guusuu[0][1])
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
  return reduce(math.gcd, numbers)

def solve():
  n, start = map(int, input().split())
  cities = input().split(" ")
  # Startを0からに変更
  cities = [int(i) - start for i in cities]
  print(gcd(*cities))

solve()

Fixed submission:
from functools import reduce

def gcds(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd(*numbers):
  return reduce(gcds, numbers)

def solve():
  n, start = map(int, input().split())
  cities = input().split(" ")
  # Startを0からに変更
  cities = [int(i) - start for i in cities]
  print(abs(gcd(*cities)))

solve()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

def solve():
  n, k = map(int, input().split())
  count = 0
  # # A解法
  # for a in range(1, n+1):
  #   for b in range(1, n+1):
  #     # for c in range(1, n+1):
  #     count += min(a, cal(a, b, 3, n, k))

  # B解法
  ary = [(a, b, c)
    for a in range(1, n+1)
    for b in range(1, n+1)
    for c in range(1, n+1)]
  # print(ary)

  for i in range(len(ary)):
    A = ary[i][0] + ary[i][1]
    B = ary[i][1] + ary[i][2]
    C = ary[i][0] + ary[i][2]

    if A%k ==0 and B%k ==0 and C%k ==0:
      count += 1


  
  # for a, b, c in ary:
  #   if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
  #     count += 1

  # C解法
  # a = range(1, n+1)
  # for i in range(1, n+1):
  #   b = i


  
  print(count)


solve()


Fixed submission:
def solve():
  n, k = map(int, input().split())
  
  divList = [0 for _ in range(k)]
  for i in range(1, n+1):
    divList[i % k] += 1
  
  count = 0
  for i in range(k):
    if (i*2) % k ==0:
      count += divList[i] ** 3
  print(count)
solve()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

def solve():
  n, k = map(int, input().split())
  count = 0
  # A解法
  for a in range(n):
    a += 1
    for b in range(n):
      b += 1
      for c in range(n):
        c += 1
        if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
          count += 1

  # B解法
  # ary = [(a, b, c)
  #   for a in range(n)
  #   for b in range(n)
  #   for c in range(n)]
  
  # for a, b, c in ary:
  #   if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
  #     count += 1

  # C解法
  # a = range(1, n+1)
  # for i in range(1, n+1):
  #   b = i


  
  print(count)


solve()

Fixed submission:
def solve():
  n, k = map(int, input().split())
  
  divList = [0 for _ in range(k)]
  for i in range(1, n+1):
    divList[i % k] += 1
  
  count = 0
  for i in range(k):
    if (i*2) % k ==0:
      count += divList[i] ** 3
  print(count)
solve()