Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S) + 1

vA = [0,] * N
vZ = []
p = ">"
for i,s in enumerate(S):
    if p+s == "><":
        vZ.append(i)
    p = s
if S[-1] == ">":
    vZ.append(N-1)

# print(vZ)##
####
for z in vZ:
    if z == N-1:
        break
    t = z
    while t<N-1 and S[t] == "<":
        vA[t+1] = vA[t] + 1
        t += 1

# print(vA)##

for z in vZ:
    if z == 0:
        continue
    t = z
    while S[t-1] == ">":
        vA[t-1] = max(vA[t] + 1, vA[t-1])
        t -= 1

# print(vA)###
print(sum(vA))


Fixed submission:
S = input()
N = len(S) + 1

vA = [0,] * N
vZ = []
p = ">"
for i,s in enumerate(S):
    if p+s == "><":
        vZ.append(i)
    p = s
if S[-1] == ">":
    vZ.append(N-1)

# print(vZ)##
####
for z in vZ:
    if z == N-1:
        break
    t = z
    while t<N-1 and S[t] == "<":
        vA[t+1] = vA[t] + 1
        t += 1

# print(vA)##

for z in vZ:
    if z == 0:
        continue
    t = z
    while t>0 and S[t-1] == ">":
        vA[t-1] = max(vA[t] + 1, vA[t-1])
        t -= 1

# print(vA)###
print(sum(vA))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(i for i in range(N)))


Fixed submission:
N = int(input())
print((N-1)*N//2)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
vH = list(map(int, input().split()))

INF = float("inf")
head = [INF,] * (K-1)
vH = head + vH
dp = head + [0,]

for i in range(K, N+K-1):
    dp.append(min(dp[-k] + abs(vH[i] - vH[i-k]) for k in range(1,K+1)))

print(dp[-1])


Fixed submission:
N, K = map(int, input().split())
vH = list(map(int, input().split()))

INF = float("inf")
head = [INF,] * (K-1)
vH = head + vH
dp = head + [0,]

for i in range(K, N+K-1):
    dp.append(min(dp[-k] + abs(vH[i] - vH[i-k]) for k in range(1,K+1)))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
    N = int(input())
	#N, M = map(int, input().split())
    #print(lcm(N, M))
	print("ABC" if N<1000 else "ABD")

if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
    N = int(input())
    #N, M = map(int, input().split())
    #print(lcm(N, M))
    print("ABC" if N<1000 else "ABD")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

n = int(input())
A = [None]*n
A = map(int, input().split())
T = reduce((lambda x, y: x * y), A)
if T > pow(10,18):
    print(-1)
else:
    print(T)



Fixed submission:
n = int(input())
res = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        res *= a[i]
        if res > 10**18:
            print(-1)
            quit()
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
A = [None]*n
A = map(int, input().split())
T = math.prod(A)
if T > pow(10,18):
    print(-1)
else:
    print(T)



Fixed submission:
n = int(input())
res = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        res *= a[i]
        if res > 10**18:
            print(-1)
            quit()
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
A = [None]*n
A = input().split()
T = 1
for i in A:
    T *= int(i)
if T > pow(10,18):
    print(-1)
else:
    print(T)

Fixed submission:
n = int(input())
res = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        res *= a[i]
        if res > 10**18:
            print(-1)
            quit()
    print(res)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
half = k//2
while c > half:
    c = abs(c-k)
l.append(c)
print(min(l))

Fixed submission:
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
half = k//2
while c > half:
    c = abs(c-k)
    l.append(c)
print(min(l))

Fixed submission:
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
if n % k ==0:
print(0)
else:
l = [n]
p = n//k
c = n-(p*k)
half = k//2
while c > half:
c = abs(c-k)
l.append(c)
print(min(l))

Fixed submission:
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))

Buggy python submission (verdict: Runtime Error):
x,y,z = list(map(int,input().split()))
def swap(a,b):
tmp = a
a = b
b = tmp
return (a,b)
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)
n,k = map(int,input().split())
if n % k ==0:
print(0)
else:
l = [n]
p = n//k
c = n-(p*k)
half = k//2
while c > half:
c = abs(c-k)
l.append(c)
print(min(l))

Fixed submission:
n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))
Buggy python submission (verdict: Runtime Error):
N = int(input())
R = int(input())
if N >= 10:
  print(R)
else:
  print(R + 100*(10-N))

Fixed submission:
n = input().split()
if int(n[0]) >= 10:
  print(n[1])
else:
  print(int(n[1]) + 100*(10-int(n[0])))
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
print(s.count('ABC'))

Fixed submission:
N = input()
S = input()
print(S.count('ABC'))

Buggy python submission (verdict: Runtime Error):
int N = input()
String S = input()
print(s.count('ABC'))

Fixed submission:
N = input()
S = input()
print(S.count('ABC'))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
lst = []
while num > 0:
    lst.append(num%10)
    num //= 10
if sum(lst) % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
lst = list(input())
total = sum([int(i) for i in lst])
if total % 9 == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import sys 
input =sys.stdin.readline 
from deciaml import Decimal 

def main():
	a,b= list(map(Decimal,input().strip().split()))
	print(int(a*b))

main()

Fixed submission:
import sys 
input =sys.stdin.readline 
from decimal import Decimal 

def main():
	a,b= list(map(Decimal,input().strip().split()))
	print(int(a*b))

main()
Buggy python submission (verdict: Runtime Error):
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int N = scan.nextInt();
		Integer p[] = new Integer[N];
		//int min = Math.abs(100 - X);
		int min = 100;
        int result = X;

		for (int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}

		for (int i = 0; i <= 200; i++) {
			if (Math.abs(X - i) < min && !Arrays.asList(p).contains(i)) {
				min = Math.abs(X - i);
				result = i;
			}
		}

		System.out.println(result);

	}

}

Fixed submission:
X, N = map(int, input().split(' '))
P = []
if N > 0:
  P = sorted(list(map(int, input().split(' '))))
  ans = 0
  i = 0
  while True:
    if (X-i) not in P:
      ans = (X-i)
      break
    elif (X+i) not in P:
      ans = (X+i)
      break
    else:
      i += 1

if N > 0:
  print(ans)
else:
  print(X)
Buggy python submission (verdict: Time Limit Exceeded):
# 最小公倍数(ユーグリッド互除法)
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd( b, a % b)


K = int(input()) +1
mydict = {}

# データパターンを求める式
ans = 0
for h in range(1, K):
  for i in range(1, K):
    for j in range(1, K):
      
      tmp = ''.join(map(str, sorted([h,i,j])))
      if tmp in mydict:
        ans += mydict[tmp]
      else:
        val = gcd(h,gcd(i,j))
        ans += val
        mydict[tmp] = val 

print(ans)


Fixed submission:
# 最小公倍数(ユーグリッド互除法)
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd( b, a % b)

K = int(input()) + 1
mydict = {}

# データパターンを求める式
ans = 0
for h in range(1, K):
  ans += gcd(h,gcd(h,h))

  for i in range(h+1, K):
    ans += (gcd(h,gcd(h,i)) * 3)
    ans += (gcd(h,gcd(i,i)) * 3)

    for j in range(i+1, K):
      ans += (gcd(h,gcd(i,j)) * 6)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# 最小公倍数(ユーグリッド互除法)
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd( b, a % b)

K = int(input()) +1

# データパターンを求める式
ans = 0
for h in range(1, K):
  for i in range(1, K):
    for j in range(1, K):
      # 最小公倍数算出
      ans += gcd(h,gcd(i,j))

print(ans)

Fixed submission:
# 最小公倍数(ユーグリッド互除法)
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd( b, a % b)

K = int(input()) + 1
mydict = {}

# データパターンを求める式
ans = 0
for h in range(1, K):
  ans += gcd(h,gcd(h,h))

  for i in range(h+1, K):
    ans += (gcd(h,gcd(h,i)) * 3)
    ans += (gcd(h,gcd(i,i)) * 3)

    for j in range(i+1, K):
      ans += (gcd(h,gcd(i,j)) * 6)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

# 全探索
cnt = 0
for i in range(0, N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      # 条件1(全要素が異なる文字判定)
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        # 条件2判定
        if j - i != k - j:
          cnt += 1

print(cnt)


Fixed submission:
N = int(input())
S = input()

# RGBそれぞれの字数カウント
R = S.count('R')
G = S.count('G')
B = S.count('B')

# 条件２の対象数カウント
ad = R * G * B
ed = 0

for i in range(0, N-1):
  for j in range(i+1, N):
    # 判定
    P = j+(j-i)
    if P < N:
      if S[i] != S[j] and S[j] != S[P] and S[P] != S[i]:
        ed += 1

print(ad-ed)
Buggy python submission (verdict: Runtime Error):
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(ans+A) 
else:
  print(ans+( N % (A+B)))
 

Fixed submission:
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(tmp+A) 
else:
  print(tmp+( N % (A+B)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
N, A, B = (int(x) for x in input().split(' '))
ans = 0
#
for i in range(N):
  if i % (A+B) < A:
    ans += 1
#結果出力
print(ans)

Fixed submission:
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(tmp+A) 
else:
  print(tmp+( N % (A+B)))
Buggy python submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split(' '))
TMP = [0 for _ in range(M)]
ans = 0

#ループで探しながら処理 
for _ in range(M):
  s, c = (int(x) for x in input().split(' '))

  #前回値判定
  if TMP[s-1] == 0 or TMP[s-1] == c:
    TMP[s-1] = c
  else:
    ans = -1
    break

if ans != -1:
	ans = int(''.join(map(str, TMP)))

print(ans if ans != 0 else -1)

Fixed submission:
N, M = (int(x) for x in input().split(' '))
TMP = ['*'] * N
ans = 0

#ループで探しながら置き換え処理 
for i in range(M):
  s, c = (int(x) for x in input().split(' '))

  #既に異なる値が指定されている場合はエラー(-1)とする
  if TMP[s-1] == '*' or TMP[s-1] == c:
    TMP[s-1] = c
  else:
    ans = -1
    break    

# 例外判定。桁数が2桁以上で先頭桁に0が指定された場合。0で始まる2桁以上数は-1とする。
if N > 1 and TMP[0] == 0:
  ans = -1

#未指定文字の置き換え。最上位桁は"1"に、以外は"0"に置き換える。
if ans != -1:
  for x in range(N):
    #先頭の未指定文字は1に置き換え
    if TMP[x] == '*' and x == 0:
      if N == 1 and M == 0: 
        TMP[x] = 0
      else:
      	TMP[x] = 1

    #以外の未指定文字は0に置き換え
    if TMP[x] == '*' and x > 0:
      TMP[x] = 0


if ans != -1:
  ans = int(''.join(map(str, TMP)))
  print(ans)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = (int(x) for x in input().split(' '))
H    = [int(x) for x in input().split(' ')]
#ソート処理
list.sort(H, reverse=True)
#K回最大値をHから消す
while N > 0 and K > 0:
  del H[0]
  N -= 1
  K -= 1
#総和を出力
print(sum(H))

Fixed submission:
N, K = (int(x) for x in input().split(' '))
H    = [int(x) for x in input().split(' ')]
#ソート処理
list.sort(H, reverse=True)
#K回最大値をHから消す
if N >= K:
  del H[0:K]
else:
  H.clear()
#総和を出力
print(sum(H))

Buggy python submission (verdict: Time Limit Exceeded):
import math

class Culuculation():
  H = 0
  K = 0
  H = []
  
  def __init__(self):
    self.N, self.K = (int(x) for x in input().split(' '))
    self.H = [int(x) for x in input().split(' ')]
    
  def culuculation(self):
    #Hを降順にソートしてK回POPし、母数を減らす
    list.sort(self.H, reverse=True)
    for i in range(self.K):
      self.H.pop(0)
      if len(self.H) == 0:
        break
    #残ったリストHを合算して出力
    print(sum(self.H))
    
def main():
  tmp = Culuculation()
  tmp.culuculation()

if __name__=='__main__':
  main()

Fixed submission:
N, K = (int(x) for x in input().split(' '))
H    = [int(x) for x in input().split(' ')]
#ソート処理
list.sort(H, reverse=True)
#K回最大値をHから消す
if N >= K:
  del H[0:K]
else:
  H.clear()
#総和を出力
print(sum(H))
Buggy python submission (verdict: Runtime Error):
import math
import sys
from collections import deque

N, M , K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))


count = 0
time = 0
#もし先にどっちかの玉が尽きた時の問題。
for i in range(400001):
    #本が尽きていない。
    if len(A) != 0 and len(B) != 0:

        if A[0] < B[0]:
            time = time + A[0]
            if time <= K:
                count = count + 1
                A.popleft()

        elif A[0] > B[0]:
            time = time + B[0]
            if time <= K:
                count = count + 1
                B.popleft()
        else:
            time = time + A[0]
            if time <= K:
                count = count + 1
                A.popleft()
    else:
        #どっかの本が尽きている。
        if len(A) == 0 and len(B) != 0:
            time = time + B[0]
            if time <= K:
                count = count + 1
                B.popleft()
        elif len(A) != 0 and len(B) == 0:
            time = time +A[0]
            if time <= K:
                count = count + 1
                A.popleft()
        elif len(A) == 0 and len(B) == 0:
            print(count)
            sys.exit()
               


print(count)


Fixed submission:
import math
import sys

S = int(input())
print(S+(S**2)+(S**3))
Buggy python submission (verdict: Runtime Error):
import sys
X, N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()
  
if X == 100 and N == 100:
  print(-100)
  sys.exit()
  
  
P = list(map(int, input().split()))

lis = []
for i in range (-100,102,1):
    if i not in P:
        lis.append(i)


        
        
        
ans = 10**18
suzi = 0
lis2 = []
for j in lis:
    num = abs(X-j)
    if num < ans:
        ans = num
        suzi = j

print(suzi)

    


Fixed submission:
X1,X2,X3,X4,X5 = map(int, input().split())
lis = [X1,X2,X3,X4,X5]

for i in range(len(lis)):
    if lis[i] == 0:
        print(i+1)
Buggy python submission (verdict: Runtime Error):
X,Y = map(int, input().split())

for i in range(X+1):
    for j in range(X+1):
        if int(i) + int(j) < X+1:
            if (((2*i) + (3*j)) == Y) or (((2*j) + (3*i)) == Y):
                print("Yes")
                sys.exit()

print("No")

Fixed submission:
import sys 
X,Y = map(int, input().split())
for i in range(X+1):
    for j in range(X+1):
        if (((2*i) + (4*j)) == Y) or (((2*j) + (4*i)) == Y):
            if (i+j == X):
                print("Yes")
                sys.exit()
print("No")
Buggy python submission (verdict: Runtime Error):
import sys
A,V = map(int(input()))
B,W = map(int(input()))
T = int(input())

#これO(1)で解けそう。

# スピードが同じ or 逃げる方のスピードが速いと無理
if V == W:
    print("NO")
    sys.exit()
elif W < V:
    print("YES")
    sys.exit()


# 鬼の方がスピードが速い場合で場合訳
distance_AB = abs(A-B)
speed_AB = abs(V-W)

if speed_AB * T < distance_AB:
    print("YES")
else:
    print("NO")




Fixed submission:
import sys
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())

#これO(1)で解けそう。

# スピードが同じ or 逃げる方のスピードが速いと無理
if V <= W:
    print("NO")
    sys.exit()



# 鬼の方がスピードが速い場合で場合訳
distance_AB = abs(A-B)
speed_AB = abs(V-W)

if speed_AB * T >= distance_AB:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

Fixed submission:
N, M = map(int, input().split())
print(N*M)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
 
for i in A:
    ans = ans*i
    if ans > int(10**18) and A.count(0) == 0:
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

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

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

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

ans = 1

for i in A:
    ans = ans*i

if ans > int(10**18):
    print(-1)
else:
    print(ans)

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

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
from decimal import *
A,B = map(int, input().split())
A = Decimal(A)
B = Decimal(B)

print(Decimal((A*B)/1))

Fixed submission:
import sys
S, T = map(str, input().split())
 
S1 = int(S)
T1 = T.replace(".", "")


print(S1*int(T1)//100)

Buggy python submission (verdict: Runtime Error):
import math
decimal.getcontext().prec = 6
S = input().split()
A = int(S[0])
B = float(S[1])


print(int(math.floor(A*B)))

Fixed submission:
import sys
S, T = map(str, input().split())
 
S1 = int(S)
T1 = T.replace(".", "")


print(S1*int(T1)//100)

Buggy python submission (verdict: Runtime Error):
import math

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

print(int(math.floor(A*B)))


Fixed submission:
import sys
S, T = map(str, input().split())
 
S1 = int(S)
T1 = T.replace(".", "")


print(S1*int(T1)//100)

Buggy python submission (verdict: Runtime Error):
import math

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

print(math.floor(A*B))


Fixed submission:
import sys
S, T = map(str, input().split())
 
S1 = int(S)
T1 = T.replace(".", "")


print(S1*int(T1)//100)

Buggy python submission (verdict: Runtime Error):
import math

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

print(math.floor(A*B))


Fixed submission:
import sys
S, T = map(str, input().split())
 
S1 = int(S)
T1 = T.replace(".", "")


print(S1*int(T1)//100)
Buggy python submission (verdict: Runtime Error):
時針と分針の回り方も存じ上げないカス。

Fixed submission:
a,b,h,m=map(int,input().split())
import math
mm=m*6
hh=(h*60+m)/2
ans=a**2+b**2-2*a*b*math.cos(math.radians(abs(hh-mm)))
print(math.sqrt(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)


Fixed submission:
from math import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)

Fixed submission:
from math import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(i,j,k)

print(ans)


Fixed submission:
from math import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(gcd(i,j),k)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N,M = map(int, input().split())
A = list(map(int, input().split()))
sorted_A = sorted(A, reverse=True) 
all_A = sum(A)

rule = (1/(4*M))

ans = 0

for i in A:
    if (i / all_A) > rule:
        ans = ans + 1
    else:
        pass

if ans >= M:
    print("Yes")
else:
    print("No")


Fixed submission:
X,Y,Z = map(int, input().split())

print(str(Z) + " " + str(X) + " " + str(Y))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K, N = map(int, input().split())
A = list(map(int, input().split()))

A_list = list(itertools.permutations(A, N))
ans = 10**8
for i in A_list:
    tmp = 0
    
    if (i[0] == min(A) and i[2] == max(A)) or  (i[0] == max(A) and i[2] == min(A)):
        for j in range(N-1):
            if abs((i[j+1]) - (i[j])) <= abs(K-i[j+1]):
                tmp = tmp +  abs((i[j+1]) - (i[j]))
            else:
                tmp = tmp + abs(K-i[j+1])
        
        if tmp <= ans:
            ans = tmp
    else:
        pass
print(ans)

Fixed submission:
K,N = map(int, input().split())
A = [int(a) for a in input().split()]

ans = A[-1]-A[0]
for i in range(N-1):
    ans = min(ans, K-A[i+1]+A[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K, N = map(int, input().split())
A = list(map(int, input().split()))

A_list = list(itertools.permutations(A, N))
ans = 10**8
for i in A_list:
    tmp = 0
    
    if i[0] == min(A) and i[2] == max(A):
        pass
    else:
        for j in range(N-1):
            if abs((i[j+1]) - (i[j])) <= abs(K-i[j+1]):
                tmp = tmp +  abs((i[j+1]) - (i[j]))
            else:
                tmp = tmp + abs(K-i[j+1])
        
        if tmp <= ans:
            ans = tmp
print(ans)


Fixed submission:
K,N = map(int, input().split())
A = [int(a) for a in input().split()]

ans = A[-1]-A[0]
for i in range(N-1):
    ans = min(ans, K-A[i+1]+A[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools
K, N = map(int, input().split())
A = list(map(int, input().split()))

A_list = list(itertools.permutations(l, N))
ans = 10**8
for i in A_list:
    tmp = 0
    
    if i[0] == min(A) and i[2] == max(A):
        pass
    else:
        for j in range(N-1):
            if abs((i[j+1]) - (i[j])) <= abs(K-i[j+1]):
                tmp = tmp +  abs((i[j+1]) - (i[j]))
            else:
                tmp = tmp + abs(K-i[j+1])
        
        if tmp <= ans:
            ans = tmp
print(ans)

Fixed submission:
K,N = map(int, input().split())
A = [int(a) for a in input().split()]

ans = A[-1]-A[0]
for i in range(N-1):
    ans = min(ans, K-A[i+1]+A[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools
K, N = map(int, input().split())
A = list(map(int, input().split()))

A_list = list(itertools.permutations(l, N))

print(A_list)

Fixed submission:
K,N = map(int, input().split())
A = [int(a) for a in input().split()]

ans = A[-1]-A[0]
for i in range(N-1):
    ans = min(ans, K-A[i+1]+A[i])
print(ans)