Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')]

dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    for x in range(1, min(i, k) + 1):
        z = abs(a[i - x] - a[i]) + dp[i - x]
        if dp[i] > z:
            dp[i] = z
print(dp[-1])

Fixed submission:
n, k = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')]

dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    for x in range(1, min(i, k) + 1):
        z = abs(a[i - x] - a[i]) + dp[i - x]
        if dp[i] > z:
            dp[i] = z
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')]

dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    for x in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], abs(a[i - x] - a[i]) + dp[i - x])
print(dp[-1])

Fixed submission:
n, k = map(int, input().split(' '))
a = [int(i) for i in input().split(' ')]

dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    for x in range(1, min(i, k) + 1):
        z = abs(a[i - x] - a[i]) + dp[i - x]
        if dp[i] > z:
            dp[i] = z
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
X=input()
if X >=30:
    print("Yes")
else:
    print("No")

Fixed submission:
x=int(input())
if x >=30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
R = int(input())
print(R*pi*2)

Fixed submission:
R =int(input())
import math
RU=2*math.pi*R
print(RU)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
total = 0
for i in range(n):
    for j in range(i+1, n):
        temp = a[i]*a[j]
        total = (total + temp)%mod
print(total)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
total = 0
sum_sqr = 0
sqr_sum = 0
for i in range(n):
    sum_sqr = (sum_sqr + a[i])
sum_sqr = (sum_sqr * sum_sqr)
for i in range(n):
    sqr_sum = (sqr_sum + ((a[i] * a[i])))
# print(sqr_sum, sum_sqr)
total = (sum_sqr - sqr_sum) // 2
print(total%mod)
Buggy python submission (verdict: Time Limit Exceeded):
# cook your dish here
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
scores = []
start = k-1
kk = k
i = k-1
while i<n:
    cnt = kk
    temp = 0
    ans = 1
    while cnt>0:
        ans = ans*l[i-temp]
        temp=temp+1
        cnt=cnt-1
    scores.append(ans)
    i=i+1
if len(scores)==1:
    print("Yes")
else:
    i = 1
    while i<len(scores):
        if scores[i]>scores[i-1]:
            print("Yes")
        else:
            print("No")
        i = i+1

Fixed submission:
# cook your dish here
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(k, n):
    if l[i-k] < l[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
p = map(int,input().split())
newlist = sorted(p, reverse=False)
ans_list=[]
for i in range(1,K+1):
    ans.append(newlist[i-1])
print(sum(ans_list))


Fixed submission:
N, K = map(int,input().split())
p = map(int,input().split())
newlist = sorted(p, reverse=False)
ans_list=[]
for i in range(1,K+1):
    ans_list.append(newlist[i-1])
print(sum(ans_list))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print(A*B)

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

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

if 0 in A:
    print(0)

else:
    total = 1
    for i in range(N):
        total *= A[i]

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


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

if 0 in A:
    print(0)

else:
    total = 1
    for i in range(N):
        total *= A[i]
        if total > 10**18:
            total = -1
            break
    print(total)
Buggy python submission (verdict: Runtime Error):
import math
A,B,H,M = map(float, input().split())
rate = M / 60.0
HM = H*5.0 + 10.0*rate
theta = abs(HM-M) * 6.0
if theta > 180:
    theta = 360-theta
#rad = math.radians(theta)
#cos = abs(math.cos(rad))
L = math.sqrt(A**2 + B**2 - 2*A*B*abs(math.cos(math.radians(theta))))
if H==0 and M ==0:
    L = 0
print("{:.19f}".format(L))

Fixed submission:
N = int(input())
if (N % 10 == 3):
	print("bon")
elif (N % 10 ==0 or N % 10 ==1 or N % 10 ==6 or N % 10 ==8):
	print("pon")
else:
	print("hon")

Buggy python submission (verdict: Runtime Error):
N = map(int, input().split())
if (N % 10 == 3):
	print("bon")
elif (N % 10 ==0 or N % 10 ==1 or N % 10 ==6 or N % 10 ==8):
	print("pon")
else:
	print("hon)


Fixed submission:
N = int(input())
if (N % 10 == 3):
	print("bon")
elif (N % 10 ==0 or N % 10 ==1 or N % 10 ==6 or N % 10 ==8):
	print("pon")
else:
	print("hon")
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if (len(S) > K):
    print(S[:K]+"...")
else:
    print(S)

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

if (len(S) > K):
    print(S[:K]+"...")
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = list(map(int, input().split()))

if (A >= K):
  print(K*1)

else:
  if (A + B >= K):
    print(A*1 + 0)
  else:
    print(A*1 + 0 + (K-A-B)*(-1))


Fixed submission:
id1 = input()
id2 = input()

if (id1 == id2[:-1]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools
 
N, M, X = list(map(int, input().split()))
Arr = np.zeros((N,M+1))
List = np.zeros(M)
 
for i in range(N):
    Arr[i] = list(map(int, input().split()))
    
for j in range(M):
    List[j] = np.sum(Arr[:,j])

if np.any(List<10):
    print(-1)

else:
    List = sorted(List)
    for i in range(N+1):
        for team in itertools.combinations(List,i):
            Sum = np.sum(Arr[team,:])
            if np.all(Sum>=10):
                break

Fixed submission:
N,M,X = map(int,input().split())
B = [list(map(int,input().split())) for i in range(N)]
ANS = 10**5 * 12 + 1
for i in range(1<<N):
    SCORE=[0]*M
    MONEY=0
    for j in range(N):
        if (1<<j) & i != 0:
            MONEY+=B[j][0]
            for k in range(M):
                SCORE[k]+=B[j][k+1]
    if min(SCORE)>=X:
        ANS=min(ANS,MONEY)
if ANS == 10**5 * 12 + 1:
    print(-1)
else:
    print(ANS)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools

N, M, X = list(map(int, input().split()))
Arr = np.zeros((N,M+1))
List = np.zeros(M)

for i in range(N):
  Arr[i] = list(map(int, input().split()))
  
for j in range(M):
  List[j] = np.sum(Arr[:,j])

if np.any(List<10):
  print(-1)
  
else:
  List = sorted(List)
  for i in range(N+1):
    for team in itertools.combinations(List,i):
      Sum = np.sum(Arr[team,:])
      if np.all(Sum>=10):
        break
    
  


Fixed submission:
N,M,X = map(int,input().split())
B = [list(map(int,input().split())) for i in range(N)]
ANS = 10**5 * 12 + 1
for i in range(1<<N):
    SCORE=[0]*M
    MONEY=0
    for j in range(N):
        if (1<<j) & i != 0:
            MONEY+=B[j][0]
            for k in range(M):
                SCORE[k]+=B[j][k+1]
    if min(SCORE)>=X:
        ANS=min(ANS,MONEY)
if ANS == 10**5 * 12 + 1:
    print(-1)
else:
    print(ANS)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt
 
for i in range(N):
    for j in range(i,N):
        k = 2*j - i
        if k > N:
            break
        elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1

print(ans)

Fixed submission:
N = int(input())
S = input()
 
r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt
 
for i in range(N):
    for j in range(i,N):
        k = 2*j - i
        if k >= N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
#         print(i,j,k)

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt
 
for i in range(N):
    for j in range(i,N):
        k = 2*j - i
        if k >= N:
            break
        elif S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1

print(ans)

Fixed submission:
N = int(input())
S = input()
 
r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt
 
for i in range(N):
    for j in range(i,N):
        k = 2*j - i
        if k >= N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
#         print(i,j,k)

print(ans)
Buggy python submission (verdict: Runtime Error):
d,t,s=map(int,input()).split())
if s == 0:
    print("No")
elif d/s => t :
    print("Yes")
else:
    print("No")

Fixed submission:
d,t,s=map(int,input().split())
if s == 0:
    print("No")
elif d/s <= t :
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#/usr/bin/python3
n = int(input())
list_a = list(map(int, input().split()))
result = 1
#if 0 in list_a:
#        print(0)
#        exit()
  
for i in range(n):
    result *= int(list_a[i])
if result > 10**18:
	print("-1")
else:
  print(result)

Fixed submission:
#/usr/bin/python3
n = int(input())
list_a = list(map(int, input().split()))
result = 1
if 0 in list_a:
        print(0)
        exit()
  
for i in range(n):
    result *= int(list_a[i])
    if result > 10**18:
        print("-1")
        exit()
print(result)
Buggy python submission (verdict: Runtime Error):
import math
 
A, B, H, M = map(int, input().split())
 
deg_long = M * 6
deg_short = 30 * H + M / 2
    
rad = math.radians( min(deg_long - deg_short, 360-(deg_long-deg_short)))
print( math.sqrt(A **2 + B ** 2 - 2*A*B*cos(rad)) )

Fixed submission:
import math
 
A, B, H, M = map(int, input().split())
 
deg_long = M * 6
deg_short = 30 * H + M / 2
    
rad = math.radians( min(deg_long - deg_short, 360-(deg_long-deg_short)))
print( math.sqrt(A **2 + B ** 2 - 2* A * B* math.cos(rad)) )
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
K = int(input())
sum_gcd = 0
gcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            i = 1
            while i <= min(a,b,c):
                if a % i == 0 and b % i == 0 and c % i == 0:
                   gcd = i  
                i += 1
            sum_gcd += gcd
print(sum_gcd)       

Fixed submission:
#!/usr/bin/python3
import math
K = int(input())
sum_gcd = 0
for a in range(1,K+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if a == b and b == c :
                sum_gcd += math.gcd(math.gcd(a,b),c)
            elif a == b or b == c or c == a:
                sum_gcd += 3 * math.gcd(math.gcd(a,b),c)
            else:
                sum_gcd += 6 * math.gcd(math.gcd(a,b),c)
print(sum_gcd)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = list(input().split())
sum = 0
for i in range(len(b)):
  for j in range(i,len(b)):
    sum += b[i] * b[j]
print(sum)

Fixed submission:
a = int(input())
b = list(input().split())
sum = 0
for i in range(len(b)):
  for j in range(i,len(b)):
    if i != j:
        sum += int(b[i]) * int(b[j])
print(sum)
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=str(input())
if a=>3200:
  print(s)
else:
  print("red")

Fixed submission:
a=int(input())
s=str(input())
if a>=3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [] * N
List = input().split(" ")
List.sort()
for i in range(N-1):
    List[i+1] = (int(List[i]) + int(List[i+1]) / 2
print(List[N])

Fixed submission:
N = int(input())
List = [] * N
List = input().split(" ")
for i in range(N):
    List[i] = float(List[i]) 
List.sort()
for i in range(N-1):
    List[i+1] = ( List[i] + List[i+1] ) / 2
print(List[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [] * N
List = input().split(" ")
List.sort()
for i in range(N-1):
    List[i+1] = (int(List[i]) + int(List[i+1]) / 2
print(List[N])

Fixed submission:
N = int(input())
List = [] * N
List = input().split(" ")
for i in range(N):
    List[i] = float(List[i]) 
List.sort()
for i in range(N-1):
    List[i+1] = ( List[i] + List[i+1] ) / 2
print(List[N-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = numpy.array(list(map(int, input().split())))

ans = 0

for i in range(N):
	ans = (ans +  A[i] * numpy.sum(A[i+1:N])) % (10**9+7)

print(ans)

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

for i in range(N):
	ans += A[i]**2

res = (Asum_sq-ans)//2
print(res%DIV)

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

ans = 0

for i in range(N):
	ans = (ans +  A[i] * sum(A[i+1:N])) % (10**9+7)

print(ans)

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

for i in range(N):
	ans += A[i]**2

res = (Asum_sq-ans)//2
print(res%DIV)

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

ans = 0

for i in range(N):
	for j in range(i+1,N):
		ans = (ans +  A[i]*A[j]) % (10**9+7)

print(ans)

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

DIV = 10**9+7
ans = 0
Asum = sum(A)
Asum_sq = Asum**2

for i in range(N):
	ans += A[i]**2

res = (Asum_sq-ans)//2
print(res%DIV)
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
A = list(map(int, input().split()))

now = 1
toLoop = 0 #1の町からループに入るまでのワープ数
towns = list()
townList = list()
for i in range(1,K+1):
	now = A[now-1]
	loop_num = i
	if not now in towns:
		towns.append(now)
	else:
		start = now
		count = 1
		now = A[now-1]
		while start != now:
			count += 1
			now = A[now-1]
		toLoop = loop_num - count
		loop_num = count
		break

if K <= loop_num:
	print(now)
else:
	warp_num = (K-toLoop)%loop_num
	for _ in range(warp_num): now = A[now-1]
	print(now)

Fixed submission:
S = input()
T = input()

if S == T[:-1] and len(S) == len(T)-1:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
H = list(map(int, input().split()))
michi = [[False] * N for i in range(N)]

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

count = 0
for n in range(N):
	goodFlag = True
	for i in range(N):
		if michi[n][i]:
			if H[n] <= H[i]:
				goodFlag = False
				break
	if goodFlag: count += 1

print(count)

Fixed submission:
N,M = map(int, input().split())
H = list(map(int, input().split()))
goodTowerFlag = [True] * N

for _ in range(M):
	a,b = map(int, input().split())
	if H[a-1] <= H[b-1]:
		goodTowerFlag[a-1] = False
	if H[b-1] <= H[a-1]:
		goodTowerFlag[b-1] = False

print(goodTowerFlag.count(True))
Buggy python submission (verdict: Time Limit Exceeded):
import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		for c in range(1, K+1):
			ans += math.gcd(math.gcd(a,b), c)
 
print(ans)

Fixed submission:
import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		tmp = math.gcd(a,b)
		for c in range(1, K+1):
			ans += math.gcd(tmp,c)
 
print(ans)

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

K = int(input())
gcd_map = [[[0] * K for i in range(K)] for j in range(K)]

ans = 0

for a in range(1, K+1):
	for b in range(1, K+1):
		for c in range(1, K+1):
				if gcd_map[a-1][b-1][c-1] == 0:
					gcd = math.gcd(math.gcd(a,b), c)
					gcd_map[a-1][b-1][c-1] = gcd
					gcd_map[a-1][c-1][b-1] = gcd
					gcd_map[b-1][a-1][c-1] = gcd
					gcd_map[b-1][c-1][a-1] = gcd
					gcd_map[c-1][a-1][b-1] = gcd
					gcd_map[c-1][b-1][a-1] = gcd
					ans += gcd
				else:
					ans += gcd_map[a-1][b-1][c-1]

print(ans)

Fixed submission:
import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		tmp = math.gcd(a,b)
		for c in range(1, K+1):
			ans += math.gcd(tmp,c)
 
print(ans)

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

K = int(input())

ans = 0

for a in range(1, K+1):
	for b in range(1, K+1):
		for c in range(1, K+1):
			ans += math.gcd(math.gcd(a,b), c)

print(ans)

Fixed submission:
import math
 
K = int(input())
 
ans = 0
 
for a in range(1, K+1):
	for b in range(1, K+1):
		tmp = math.gcd(a,b)
		for c in range(1, K+1):
			ans += math.gcd(tmp,c)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

S = list()
counter = list()

for _ in range(N):
	s = input()
	if s in S:
		index = S.index(s)
		counter[index] += 1
	else:
		S.append(s)
		counter.append(1)

# print(counter)
max_value = max(counter)

ans = list()
for i,x in enumerate(counter):
	if x == max_value:
		ans.append(S[i])

ans.sort()
for a in ans:
	print(a)

Fixed submission:
import collections

N = int(input())

S = list()
for i in range(N): S.append(input())

c = collections.Counter(S)
max_value = c.most_common()[0][1]

ans = list()
for s in c.most_common():
	if s[1] == max_value:
		ans.append(s[0])
	else:
		break

ans.sort()
for a in ans:
	print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 0
isBigger = True

for i in range(len(P)):
	for j in range(i):
		isBigger = True
		if not (P[i] <= P[j]):
			isBigger = False
			break
	if isBigger:
		count += 1

print(count)

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

count = 0
min_value = 2e5+1

for p in P:
	if p <= min_value:
		min_value = p
		count += 1

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

X,Y = map(int, input().split())

movableFlag = False

for x in range(X):
	y = X-x*2
	if x*2+y*1==X and x*1+y*2==Y:
		movableFlag = True
		break
	
if movableFlag:
	if x==0 or y==0:
		print(1)
	else:
		print(math.factorial(X-1) // (math.factorial(x) // math.factorial((X-1)-x)))
else:
	print(0)

Fixed submission:
# (+1,+2)をn回，(+2,+1)をm回とすると
#  n + 2m = X
# 2n +  m = Y でn,mが求まる．
# このとき答えは(n+m)Cn通り

def combination(n,r):
	"""
    高速な組み合わせの計算．
	nCrは必ず整数になるため分母を全部約分で1にしてから残った分子の積を求める．
	[参考]https://kadzus.hatenadiary.org/entry/20081211/1229023326
    """

	if n-r < r: r = n-r
	if r == 0: return 1
	if r == 1: return int(n)

	numerator = [i+1 for i in range(n-r, n)]
	denominator = [i+1 for i in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p-1]
		if pivot > 1:
			offset = (n-r)%p
			for k in range(p-1, r, p):
				numerator[k-offset] /= pivot
				denominator[k] /= pivot
	
	ans = 1
	for i in range(r):
		if numerator[i] > 1:
			ans *= numerator[i]
			ans %= 1e9+7
	
	return int(ans)

X,Y = map(int, input().split())

if (X+Y)%3 != 0:
	ans = 0
else:
	n = int((2*Y-X)/3)
	m = int(Y-2*n)
	if n<0 or m<0:
		ans = 0
	else:
		ans = combination(n+m, n)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count = 0

for i in range((N+2)//2):
    if A[2*i ] % 2 == 1:
        count += 1

print(count)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
count = 0

if N % 2 ==0:
    for i in range((N+2)//2 - 1):
        if A[2*i ] % 2 == 1:
            count += 1
else:
    for i in range((N+2)//2):
        if A[2*i ] % 2 == 1:
            count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count = 0

for i in range((N+2)//2):
    if A[2*i ] % 2 == 1:
        count += 1

print(count)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
count = 0

if N % 2 ==0:
    for i in range((N+2)//2 - 1):
        if A[2*i ] % 2 == 1:
            count += 1
else:
    for i in range((N+2)//2):
        if A[2*i ] % 2 == 1:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    ans = ans * A[i]
    
if ans > 10**18:
    ans = -1
    
print(ans)
    
    
    

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


if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            ans = -1
            break

    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int,input().split())

ans = 0

for i in range(K):
    if i+1 <= A:
        ans += 1
    if A < i+1 <= A + B:
        ans +=0
    if A + B < i+1 <= A + B + C:
        ans = ans - 1
        
print(ans)

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

if K < A:
    print(K)
if A <= K < A + B:
    print(A)
if A + B <= K <= A + B + C:
    print(2*A + B - K)
Buggy python submission (verdict: Runtime Error):
A, B, N = map(int,input().split())
ans = []

if N >= 100000:
    for i in range(N-200,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

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

for i in range(A,B+1):
    if i % K ==0:
        print("OK")
        break
    if i == B:
        print("NG")
    else:
        i = i + 1

Buggy python submission (verdict: Runtime Error):
A, B, N = map(int,input().split())
ans = []
for i in range(N//2,N+1):
    k = (A*i)//B - A*(i//B)
    ans.append(k)
    i = i + 1
    
print(max(ans))

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

for i in range(A,B+1):
    if i % K ==0:
        print("OK")
        break
    if i == B:
        print("NG")
    else:
        i = i + 1
Buggy python submission (verdict: Runtime Error):
K = int(input())
ans = 0

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




Fixed submission:
K = int(input())
ans = 0
from math import gcd
for i in range(1,K+1):
    for k in range(1,K+1):
        for j in range(1,K+1):
            ans += gcd(gcd(i, k),j)
            
print(ans)

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

K = int(input())
ans = 0

for i in range(K):
    i = i + 1
    for k in range(K):
        k = k + 1
        for j in range(K):
            j = j + 1
            def gcd(*numbers):
                return reduce(math.gcd, numbers)
            ans += gcd(i, k, j)
            j = j + 1
        k = k + 1
    i = i + 1
            
print(ans)

Fixed submission:
K = int(input())
ans = 0
from math import gcd
for i in range(1,K+1):
    for k in range(1,K+1):
        for j in range(1,K+1):
            ans += gcd(gcd(i, k),j)
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
youso = 0

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

print(youso)



Fixed submission:
K = int(input())
ans = 0
from math import gcd
for i in range(1,K+1):
    for k in range(1,K+1):
        for j in range(1,K+1):
            ans += gcd(gcd(i, k),j)
            
print(ans)