Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

ARGS=input().split()
N=int(ARGS[0])
M=int(ARGS[1])

COMB=int(comb(N, 2) + comb(M, 2))

print(str(COMB))

Fixed submission:
import math

ARGS=input().split()
N=int(ARGS[0])
M=int(ARGS[1])
R=2

COMB=0
if N >= R:
    COMB=math.factorial(N) // math.factorial(N - R) // math.factorial(R)
if M >= R:
    COMB+=math.factorial(M) // math.factorial(M - R) // math.factorial(R)

print(str(COMB))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

if N == M:
    print('Yes')
else
    print('No')

Fixed submission:
N, M = map(int, input().split())

if N == M:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = s.count('B') * s.coufnt('G') * s.count('R')
for i in range(n):
  for j in range(i, n-1):
    k = 2*j - i
    if k >= n:
      continue
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1

print(ans)


Fixed submission:
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
  for j in range(i, n-1):
    k = 2*j - i
    if k >= n:
      continue
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = input().split()
A, B, C, K = int(A), int(B), int(C), int(K)

if K >= A:
    Anum = A
    N = K - A
else:
    Anum = K

if N >= B:
    Bnum = B
    N = N - B
else:
    Bnum = N

Cnum = N

Total = Anum * 1 + Bnum * 0 + Cnum * (-1)

print(Total)

Fixed submission:
A, B, C, K = input().split()
A, B, C, K = int(A), int(B), int(C), int(K)

if K >= A:
    Anum = A
    N = K - A
else:
    Anum = K
    N = 0

if N >= B:
    Bnum = B
    N = N - B
else:
    Bnum = N
    N = 0

Cnum = N

Total = Anum * 1 + Bnum * 0 + Cnum * (-1)

print(Total)
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
#
C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

# N, M, X = 3, 3, 10
# C = [60,70,50]
# A = [[2,2,4],[8,7,9],[2,3,9]]

alist = []

for i in range(1 << N):
    mlist = []
    slist = []
    plist = [0] * M # 0要素の数M個のリスト

    for j in range(N):

        if (i >> j) & 1 == 1:
            mlist.append(C[j])
            slist.append(A[j])
    # print(i,mlist,slist,len(slist))

    for j in range(len(slist)):
        if len(slist)==1:
            plist = slist[j]
        else:
            plist = [a + b for a, b in zip(plist, slist[j])]

    if all((x >= X for x in plist)) == True:
        alist.append(sum(mlist))
        # print(i,plist)

print(min(alist))


Fixed submission:
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

alist = []

for i in range(1 << N):
    mlist = []
    slist = []
    plist = [0] * M # 0要素の数M個のリスト

    for j in range(N):

        if (i >> j) & 1 == 1:
            mlist.append(C[j])
            slist.append(A[j])

    for j in range(len(slist)):
        if len(slist)==1:
            plist = slist[j]
        else:
            plist = [a + b for a, b in zip(plist, slist[j])]

    if all((x >= X for x in plist)) == True:
        alist.append(sum(mlist))

if len(alist) != 0:
    print(min(alist))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))[::-1]

x = list(range(1, n+1))

cnt = 0
for i in p:
    if x.index(i) == 0:
        cnt += 1
    x.remove(i)

print(cnt)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 1
mi = p[0]
for i in range(1, n):
    if mi > p[i]:
        mi = p[i]
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = [[] for i in range(n)]    


for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    d[p].append(s)

ac_cnt, w_cnt = 0, 0
for l in d:
    if len(l) != 0:
        w_cnt += l.index("AC")

    if "AC" in l:
        ac_cnt += 1

print(ac_cnt, w_cnt)


Fixed submission:
n, m = map(int, input().split())
d = [[] for i in range(n)]    


for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    d[p].append(s)

ac_cnt, w_cnt = 0, 0
for l in d:
    if len(l) != 0 and "AC" in l:
        w_cnt += l.index("AC")

    if "AC" in l:
        ac_cnt += 1

print(ac_cnt, w_cnt)
Buggy python submission (verdict: Runtime Error):
from functools import reduce

n, m = map(int, input().split())
A =[i//2 for i in list(map(int, input().split()))]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b / gcd(a, b)


def cntTwo(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

if len(set(map(cntTwo, A))) != 1:
    print(0)
    exit()

def merge(a, b):
    l = lcm(a, b)
    if l > 10 ** 9:
        return 0
    return l

x = int(reduce(merge, A))
print(m//x - m//(x*2))

Fixed submission:
from functools import reduce

n, m = map(int, input().split())
A =[i//2 for i in list(map(int, input().split()))]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)


def cntTwo(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

if len(set(map(cntTwo, A))) != 1:
    print(0)
    exit()

def merge(a, b):
    l = lcm(a, b)
    if l > 10 ** 9:
        return 0
    return l

x = reduce(merge, A)
if x == 0:
    print(0)
else:
    print(m//x - m//(x*2))
Buggy python submission (verdict: Runtime Error):
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    for j in range(a):
        xy.append([tuple(map(int, input().split()))])

ans = 0

for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)


Fixed submission:
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product([1,0], repeat=N):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)

Buggy python submission (verdict: Runtime Error):
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    for j in range(a):
        xy.append([tuple(map(int, input().split()))])

ans = 0

for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)


Fixed submission:
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product([1,0], repeat=N):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
arr = np.array(map(int, input().split()))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

Fixed submission:
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    from itertools import combinations

    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    ans = 0
    for i in combinations(a, 2):
        ans += i[0] ^ i[1]
        ans %= mod

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)

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

n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in combinations(a, 2):
    ans += i[0] ^ i[1]
    ans %= mod

print(ans)

Fixed submission:
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

i, s = 0, 0
while True:
	s += a[i]
	i += 1
	if s >= sum(a) // 2:
		break

b = a[::-1]
j, t = 0, 0
while True:
	t += b[j]
	j += 1
	if t >= sum(a) // 2:
		break
 
print(min(s-(sum(a)-s), t-(sum(a)-t)))

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

total = sum(A)

s = 0
for a in A:
	s += a
	if 2 * s >= total:
		break

B = A[::-1]
t = 0
for b in B:
	t += b
	if 2 * t >= total:
		break

print(min(2*s-total, 2*t-total))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

i, s = 0, 0
while True:
	s += a[i]
	i += 1
	if s >= sum(a) // 2:
		break

b = a[::-1]
j, t = 0, 0
while True:
	t += b[j]
	j += 1
	if t >= sum(a) // 2:
		break
 
print(min(s-(sum(a)-s), t-(sum(a)-t)))

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

total = sum(A)

s = 0
for a in A:
	s += a
	if 2 * s >= total:
		break

B = A[::-1]
t = 0
for b in B:
	t += b
	if 2 * t >= total:
		break

print(min(2*s-total, 2*t-total))

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

i, s = 0, 0
while True:
	s += a[i]
	i += 1
	if s >= sum(a) // 2:
		break

b = a[::-1]
j, t = 0, 0
while True:
	t += b[j]
	j += 1
	if t >= sum(a) // 2:
 
print(min(s-(sum(a)-s), t-(sum(a)-t)))

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

total = sum(A)

s = 0
for a in A:
	s += a
	if 2 * s >= total:
		break

B = A[::-1]
t = 0
for b in B:
	t += b
	if 2 * t >= total:
		break

print(min(2*s-total, 2*t-total))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s) + 1
al, ar = [0] * n, [0] * n

for i in range(len(s)):
    if s[i] == "<":
        al[i+1] = al[i] + 1

for i in range(len(s)):
    if s[-(i+1)] == ">":
        ar[i+1] = ar[i] + 1

ans = 0
for i in range(len(al)):
    if al[i] >= ar[::-1][i]:
        ans += al[i]
    else:
        ans += ar[::-1][i]

print(ans)

Fixed submission:
s = list(input())
n = len(s) + 1
al, ar = [0] * n, [0] * n

for i in range(len(s)):
    if s[i] == "<":
        al[i+1] = al[i] + 1

for i in range(len(s)):
    if s[-(i+1)] == ">":
        ar[i+1] = ar[i] + 1

ans = 0
ar = ar[::-1]

for i in range(len(al)):
    if al[i] >= ar[i]:
        ans += al[i]
    else:
        ans += ar[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def d(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)

    return divisors

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

ad = set(d(a))
bd = set(d(b))

cd = ad & bd

cnt = 0

for i in cd:
    if len(d(i)) == 2:
        cnt += 1

print(cnt+1)

Fixed submission:
def d(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)

    return divisors

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

ad = set(d(a))
bd = set(d(b))

cd = ad & bd

cnt = 0

for i in cd:
    if len(d(i)) == 2:
        cnt += 1

print(cnt+1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))

if n == 1:
    for _ in range(m):
        a[0] //=2
    print(a[0])
    exit()

temp = []
temp.append(a.pop())

while m > 0:
    if temp[-1] < a[-1]:
        temp.append(a.pop())
    else:
        temp = sorted(temp)
        temp[-1] //= 2
        m -= 1

print(sum(temp)+sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
    temp = heapq.heappop(a)
    temp = -(-temp//2)
    heapq.heappush(a, temp)

print(-sum(a))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))

if n == 1:
    for _ in range(m):
        a[0] //=2
    print(a[0])
    exit()

temp = []
temp.append(a.pop())

while m > 0:
    if sorted(temp)[-1] < a[-1]:
        temp.append(a.pop())
    else:
        temp = sorted(temp)
        temp[-1] //= 2
        m -= 1

print(sum(temp)+sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
    temp = heapq.heappop(a)
    temp = -(-temp//2)
    heapq.heappush(a, temp)

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))

for _ in range(m):
    a[-1] //= 2
    a = sorted(a)

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
    temp = heapq.heappop(a)
    temp = -(-temp//2)
    heapq.heappush(a, temp)

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
import java.util.Scanner;

public class Main<i> {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int s = x - (k - 1);
        int e = x + (k - 1);

        for (int i = s; i <= e; i++) {
            System.out.println(i);
        }
    }
}

Fixed submission:
k, x = map(int, input().split())

for i in range(x-(k-1), x + (k-1)+1):
  print(i, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))

for i in range(len(h)-1):
    if h[i] - min(h[i+1:]) > 1:
        print("No")
        exit()

print("Yes")

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

h = h[::-1]

for i in range(len(h)-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
        if not  h[i] == h[i+1]:
            print("No")
            exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(A)[-2]

for i in range(n):
  if a[i] != a:
    print(ma)
  else:
    print(sma)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(sma)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)

for i in range(n):
  if a[i] != ma:
    print(ma)
  elif a.count(ma) > 1:
    print(ma)
  else:
    temp = a[:]
    del temp[i]
    print(max(temp))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(sma)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    temp = a[:]
    del temp[i]
    print(max(temp))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(sma)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
  temp = a[:]
  del temp[i]
  print(max(temp))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(sma)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int,input().split())

ans = 0

for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    ans += 1

print(ans)

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

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def f(b, c, d):
  return b - ((b // c) + (b // d)) + b // ((c * d) // gcd(c,d))

print(f(b, c, d) - f(a-1, c, d))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = [0] + [int(i) for i in input().split()]

c = 0

for i in range(len(l)):
    if sum(L[:i+1]) <= x:
        c += 1
print(c)

Fixed submission:
n, x = input().split()
l = [0] + [int(i) for i in input().split()]
x = int(x)

c = 0

for i in range(len(l)):
    if sum(l[:i+1]) <= x:
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1; b -= 1; c -= 1; d -= 1

#ABCD
if c < d:
    for i in range(a, d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    print("Yes")

#ABDC
elif d < c:
    flag_a = False
    for i in range(b, c+1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag_a = True

    flag_b = True
    for i in range(a, d-1):
            if s[i] == "#" and s[i+1] == "#":
                flag_b = False

    if flag_a and flag_b:
        print("Yes")
    else:
        print("No")                


Fixed submission:
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1; b -= 1; c -= 1; d -= 1

#ABCD
if c < d:
    for i in range(a, d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    print("Yes")

#ABDC
elif d < c:
    flag_a = False
    for i in range(b, d+1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag_a = True

    flag_b = True
    for i in range(a, d-1):
            if s[i] == "#" and s[i+1] == "#":
                flag_b = False

    if flag_a and flag_b:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if N-R*r-G*g >= 0 and (N-R*r-G*g) % B == 0:
            ans += 1
print(ans)


Fixed submission:
def main():

    R, G, B, N = map(int, input().split())

    ans = 0

    for i in range((N//R)+1):
        r = i
        for j in range(((N-R*r)//G)+1):
            g = j
            if (N-R*r-G*g) % B == 0 and N-R*r-G*g >= 0:
                ans += 1

    print(ans)

if __name__=='__main__':
    main()

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

ans = 0

for i in range((N//R)+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if (N-R*r-G*g) % B == 0 and N-R*r-G*g >= 0:
            ans += 1

print(ans)

Fixed submission:
def main():

    R, G, B, N = map(int, input().split())

    ans = 0

    for i in range((N//R)+1):
        r = i
        for j in range(((N-R*r)//G)+1):
            g = j
            if (N-R*r-G*g) % B == 0 and N-R*r-G*g >= 0:
                ans += 1

    print(ans)

if __name__=='__main__':
    main()

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

ans = 0

for i in range((N//R)+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if (N-R*r-G*g) % B == 0:
            b = N-R*r-G*g
            if b >= 0:
                ans += 1

print(ans)

Fixed submission:
def main():

    R, G, B, N = map(int, input().split())

    ans = 0

    for i in range((N//R)+1):
        r = i
        for j in range(((N-R*r)//G)+1):
            g = j
            if (N-R*r-G*g) % B == 0 and N-R*r-G*g >= 0:
                ans += 1

    print(ans)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

for _ in range(q):
  l, r = map(int, input().split())
  l = l-1
  r = r-1
  temp = s[l:r+1]
  c = 0
  for i in range(len(temp)-1):
    if temp[i] == "A" and temp[i+1] == "C":
      c += 1

  print(c)

Fixed submission:
n, q = map(int, input().split())
s = input()

t = [0] * (n+1)

for i in range(n):
  if s[i:i+2] == "AC":
    t[i+1] = t[i] + 1
  else:
    t[i+1] = t[i]

for i in range(q):
  l, r = map(int, input().split())
  l = l-1
  r = r-1
  print(t[r] - t[l])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))

while len(a) > 1:
    mina = min(a)
    for i in a:
        if i == mina:
            continue
        elif i % mina == 0:
            a.remove(i)
        else:
            a[a.index(i)] = i % mina
            
print(a[0])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

g = a[0]

for i in a:
    g = gcd(g, i)

print(g)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
    s = max(i-k, 0)
    dp[i] = min(dp[j] + abs(h[i]-h[j]) for j in range(s, i))

print(dp[-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(max(i-k, 0), i))

print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
  s = max(i-k, 0)
  dp[i] = min(dp[j] + abs(h[j]-h[i]) for j in range(s, i))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])

h_dif = []
ans = 10 ** 9 + 1

for i in range(1, n):
    h_dif.append(h[i]-h[i-1])
    if i >= k-1:
        ans = min(ans, sum(h_dif[i-k+1:i]))

print(ans)

Fixed submission:
n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])

mind = 10 ** 9 + 1

for i in range(n-k+1):
    mind = min(mind, h[i+k-1] - h[i])

print(mind)