Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, H, M = map(int, input().rstrip().split())
if H == 0 and M == 0:
    print(0)
else:
    aH = H * 5 + (float(M) / 60 * 5)
    kakudo = abs(aH - M)
    kakudo *= 6
    decimal.getcontext().prec = 5
    val =  math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo)))
    val = decimal.Decimal(val)
    print(val)
    # print(math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo))))


Fixed submission:
import math

a, b, H, M = map(int, input().rstrip().split())
if H == 0 and M == 0:
    print(abs(a-b))
else:
    H = H * 5 + (float(M) / 12)
    kakudo = abs(H - M)
    kakudo *= 6
    print(math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo))))

Buggy python submission (verdict: Runtime Error):
a, b, H, M = map(int, input().rstrip().split())
if H == 0 and M == 0:
    print(0)
else:
    aH = H * 5 + (float(M) / 60 * 5)
    kakudo = abs(aH - M)
    kakudo *= 6
    decimal.getcontext().prec = 30
    val =  math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo)))
    val = decimal.Decimal(val)
    print(val)
    # print(math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo))))


Fixed submission:
import math

a, b, H, M = map(int, input().rstrip().split())
if H == 0 and M == 0:
    print(abs(a-b))
else:
    H = H * 5 + (float(M) / 12)
    kakudo = abs(H - M)
    kakudo *= 6
    print(math.sqrt(float(a * a) + float(b * b) - 2 * a * b * math.cos(math.radians(kakudo))))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().rstrip().split())
from decimal import *
getcontext().prec = 100000
if (Decimal(a).sqrt() + Decimal(b).sqrt()) < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')


Fixed submission:
a, b, c = map(int, input().rstrip().split())
from decimal import *
getcontext().prec = 500
if (Decimal(a).sqrt() + Decimal(b).sqrt()) < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = int(N / (A + B)) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b')
print(ret)


Fixed submission:
N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = (N // (A + B) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b'))
print(ret)


Fixed submission:
N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
if A == B == 0:
    print(0)
else:
    print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))


Fixed submission:
N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().rstrip().split())
print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))


Fixed submission:
N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

max_val = 0
d = deque(maxlen=K)
for n in Ps:
    d.append(n)
    val = sum(d)
    if max_val < val:
        max_val = val
print((max_val+K)/2)


Fixed submission:
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if K == 1:
    max_val = max(Ps)
    print((max_val + 1) / 2)
elif N == K:
    max_val = Ps_sum_list[-1]
    print((max_val + K) / 2)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]
base_i = 0
max_val = 0
for i in range(len(Ps)-K+1):
    sum_val = sum(Ps[i:i+K])
    if max_val < sum_val:
        max_val = sum_val
        base_i = i
print((sum(Ps[base_i:base_i+K])+K)/2)


Fixed submission:
N, K = map(int, input().rstrip().split())
Ps = [int(x) for x in input().rstrip().split()]

Ps_sum_list = []
Ps_sum = 0
for x in Ps:
    Ps_sum += x
    Ps_sum_list.append(Ps_sum)

max_val = 0
if K == 1:
    max_val = max(Ps)
    print((max_val + 1) / 2)
elif N == K:
    max_val = Ps_sum_list[-1]
    print((max_val + K) / 2)
else:
    for i in range(N - K):
        val = Ps_sum_list[i + K] - Ps_sum_list[i]
        if val > max_val:
            max_val = val
    print((max_val + K) / 2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, stdin.readline().rstrip().split())
AC = 0
WA = 0
data = {}
for _ in range(M):
    tmp = stdin.readline().rstrip().split()
    p, S =  int(tmp[0]), tmp[1]
    if p not in data.keys():
        if S == 'AC':
            data[p] = {'AC': True, 'WA': 0}
            AC += 1
        elif S == 'WA':
            data[p] = {'AC': False, 'WA': 1}
    else:
        if S == 'AC':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['AC'] = True
                WA += data[p]['WA']
                AC += 1
        elif S == 'WA':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['WA'] += 1
print('{} {}'.format(AC, WA))



Fixed submission:
N, M = map(int, input().rstrip().split())
AC = 0
WA = 0
data = {}
for _ in range(M):
    tmp = input().rstrip().split()
    p, S =  int(tmp[0]), tmp[1]
    if p not in data.keys():
        if S == 'AC':
            data[p] = {'AC': True, 'WA': 0}
            AC += 1
        elif S == 'WA':
            data[p] = {'AC': False, 'WA': 1}
    else:
        if S == 'AC':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['AC'] = True
                WA += data[p]['WA']
                AC += 1
        elif S == 'WA':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['WA'] += 1
print('{} {}'.format(AC, WA))
Buggy python submission (verdict: Runtime Error):
abc = 'ABC'
N = int(input().rstrip())
S = input().rstrip()
ret = 0
if N == 3 and S == abc:
    ret = 1
else:
    for i in range(N - len(abc)):
        if abc == S[i:i+3]:
            ret += 1
print(ret)


Fixed submission:
K, X = map(int, input().rstrip().split())
ret = 'Yes' if  K*500 >= X else 'No'
print(ret)

Buggy python submission (verdict: Runtime Error):
abc = 'ABC'
N = int(input().rstrip())
S = input().rstrip()
ret = 0
if len(S) == 3 and S == 'ABC':
    ret = 1
else:
    for i in range(N - len(abc)):
        if 'ABC' == S[i:i + 3]:
            ret += 1
print(ret)


Fixed submission:
K, X = map(int, input().rstrip().split())
ret = 'Yes' if  K*500 >= X else 'No'
print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(stdin.readline().rstrip())
P = map(int, input().rstrip().split())
Q = map(int, input().rstrip().split())

import itertools
l = list(itertools.permutations(list(range(1, N+1))))
a = l.index(tuple(P))
b = l.index(tuple(Q))
print(abs(a-b))



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

import itertools
l = list(itertools.permutations(list(range(1, N+1))))
a = l.index(tuple(P))
b = l.index(tuple(Q))
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
l = [1, 2, 3]
A = int(stdin.readline().rstrip())
B = int(stdin.readline().rstrip())
l.remove(A)
l.remove(B)
print(l[0])

Fixed submission:
l = [1, 2, 3]
A = int(input().rstrip())
B = int(input().rstrip())
l.remove(A)
l.remove(B)
print(l[0])
Buggy python submission (verdict: Runtime Error):
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
return count


Fixed submission:
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)

Buggy python submission (verdict: Runtime Error):
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in len(predict_weather):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)

Fixed submission:
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)

Buggy python submission (verdict: Runtime Error):
predict_weather = list(input())
actual_weather = list(input())

count = 0
for i in len(predict_weather):
  if predict_weather[i] == actual_weather[i]:
    count += 1

return count

Fixed submission:
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(stdin.readline().rstrip())
Hs = list(map(int, stdin.readline().rstrip().split()))

# print(Hs)

count = 0
ret_count = 0
prev_val = Hs[-1]

for H in Hs[:-1][::-1]:
    # print('prev_val: ' + str(prev_val))
    # print('H: ' + str(H))
    # print('ret_count: ' + str(ret_count))
    if prev_val <= H:
        count += 1
    else:
        if ret_count < count:
            ret_count = count
        count = 0
    prev_val = H

if ret_count < count:
    ret_count = count

print(ret_count)


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

# print(Hs)

count = 0
ret_count = 0
prev_val = Hs[-1]

for H in Hs[:-1][::-1]:
    # print('prev_val: ' + str(prev_val))
    # print('H: ' + str(H))
    # print('ret_count: ' + str(ret_count))
    if prev_val <= H:
        count += 1
    else:
        if ret_count < count:
            ret_count = count
        count = 0
    prev_val = H

if ret_count < count:
    ret_count = count

print(ret_count)

Buggy python submission (verdict: Runtime Error):
    N = int(stdin.readline().rstrip())
    Hs = list(map(int, stdin.readline().rstrip().split()))

    # print(Hs)

    count = 0
    ret_count = 0
    prev_val = Hs[-1]

    for H in Hs[:-1][::-1]:
        # print('prev_val: ' + str(prev_val))
        # print('H: ' + str(H))
        # print('ret_count: ' + str(ret_count))
        if prev_val <= H:
            count += 1
        else:
            if ret_count < count:
                ret_count = count
            count = 0
        prev_val = H

    if ret_count < count:
        ret_count = count

    print(ret_count)


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

# print(Hs)

count = 0
ret_count = 0
prev_val = Hs[-1]

for H in Hs[:-1][::-1]:
    # print('prev_val: ' + str(prev_val))
    # print('H: ' + str(H))
    # print('ret_count: ' + str(ret_count))
    if prev_val <= H:
        count += 1
    else:
        if ret_count < count:
            ret_count = count
        count = 0
    prev_val = H

if ret_count < count:
    ret_count = count

print(ret_count)
Buggy python submission (verdict: Runtime Error):
a, loop = input().split()
string = input()

for i in range(int(loop)):
  j, k = input().split()
  print(string[int(j)-1:int(k)].count('AC'))

Fixed submission:
b = input().strip()
d = {"A": "T", "C": "G", "T": "A", "G": "C"}
print(d[b])

Buggy python submission (verdict: Runtime Error):
d = {'A': 'C', 'G': 'T', 'C': 'A', 'T': 'G'}
print(d[b])

Fixed submission:
b = input().strip()
d = {"A": "T", "C": "G", "T": "A", "G": "C"}
print(d[b])
Buggy python submission (verdict: Time Limit Exceeded):
a, loop = input().split()
string = input()

import re
for i in range(int(loop)):
  j, k = input().split()
  #print(string[int(j)-1:int(k)].count('AC'))  # TLE
  print(len(re.findall('AC', string[int(j)-1:int(k)])))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Runtime Error):
a, loop = input().split()
string = input()

import re
for i in range(int(loop)):
  j, k = input().split()
  #print(string[int(j)-1:int(k)].count('AC'))  # TLE
  print(re.findall('AC', string[int(j)-1:int(k)])

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
a, loop = input().split()
string = input()

for i in range(int(loop)):
  j, k = input().split()
  print(string[int(j)-1:int(k)].count('AC'))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

if __name__ == '__main__':
  import sys
  argvs = sys.argv
  input = eval(argvs[1])
  if not isinstance(input, int):
    print 'not int'

  print (48 - input)

Fixed submission:
input = eval(raw_input())
if not isinstance(input, int):
  print 'not int'
print (48 - input)
Buggy python submission (verdict: Runtime Error):
a = str(raw_input())
b = str(raw_input())
c = str(raw_input())

if len(a) == 1:
    print 'a'
    return

s = a[0]
a = a[1:]
while True:
    if s == 'a':
        if len(a) == 1:
            print 'a'
            break
        s = a[0]
        a = a[1:]
    elif s == 'b':
        if len(b) == 1:
            print 'b'
            break
        s = b[0]
        b = b[1:]
    elif s == 'c':
        if len(c) == 1:
            print 'c'
            break
        s = c[0]
        c = c[1:]


Fixed submission:
a = int(raw_input())
b = int(raw_input())
h = int(raw_input())
print "{}".format(int((a+b)*h/2))

Buggy python submission (verdict: Time Limit Exceeded):
a = str(raw_input())
b = str(raw_input())
c = str(raw_input())
s = a[0]
a = a[1:]
while True:
    if s == 'a':
        if len(a) == 1:
            print 'a'
            break
        s = a[0]
        a = a[1:]
    elif s == 'b':
        if len(b) == 1:
            print 'b'
            break
        s = b[0]
        b = b[1:]
    elif s == 'c':
        if len(c) == 1:
            print 'c'
            break
        s = c[0]
        c = c[1:]

Fixed submission:
a = int(raw_input())
b = int(raw_input())
h = int(raw_input())
print "{}".format(int((a+b)*h/2))

Buggy python submission (verdict: Runtime Error):
    a = int(raw_input())
    b = int(raw_input())
    h = int(raw_input())
    print "{}".format(int((a+b)*h/2))


Fixed submission:
a = int(raw_input())
b = int(raw_input())
h = int(raw_input())
print "{}".format(int((a+b)*h/2))
Buggy python submission (verdict: Runtime Error):
s = []
s = map(int, input().split())
print(s[0]*s[1])


Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
s = map(int, input().split())
print(s[0]*s[1])

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split()))
print(a*b)


Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
a*b


Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print(a*b)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
X = int(a)*int(b)
print(X)


Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(1,101):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(-200,200):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print("0")
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(1,101):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(-200,200):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9":
  print("hon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
  print("pon")
elif N[-1]=="3":
  print("bon")


Fixed submission:
N=input()
if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9":
  print("hon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
  print("pon")
elif N[-1]=="3":
  print("bon")
Buggy python submission (verdict: Runtime Error):
,B,C,K=map(int,input().split())
ans=0
if A>=K:
  ans=K
elif A<K and K<=A+B:
  ans=A
else :
  ans=A-(K-A-B)
print(ans)

Fixed submission:
A,B,C,K=map(int,input().split())
ans=0
if A>=K:
  ans=K
elif A<K and K<=A+B:
  ans=A
else :
  ans=A-(K-A-B)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=0
cnt=0
anlist=[]
while True:
  if A[A[a]-1]==1:
    break
  else:
    anlist.append(A[A[a]-1])
    a=A[a]-1
    cnt+=1
res=N%cnt
ans=anlist[res]
print(ans)  

Fixed submission:
N,K,*A=map(int, open(0).read().split())
x=1
C=[None]*N
C[0]=0
c=0
while c<K:
    x=A[x-1]
    c+=1
    if C[x-1] is None:
        C[x-1]=c
    else:
        a=C[x-1]
        b=c-a
        K=(K-a)%b+a+b
        while c<K:
            x=A[x-1]
            c+=1
        break
print(x)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=0
cnt=0
anlist=[0]*K
while True:
  if A[A[a]-1]==1:
    break
  else:
    anlist[cnt]=A[A[a]-1]
    a=A[a]-1
    cnt+=1
res=N%cnt
ans=anlist[res]
print(ans)  

Fixed submission:
N,K,*A=map(int, open(0).read().split())
x=1
C=[None]*N
C[0]=0
c=0
while c<K:
    x=A[x-1]
    c+=1
    if C[x-1] is None:
        C[x-1]=c
    else:
        a=C[x-1]
        b=c-a
        K=(K-a)%b+a+b
        while c<K:
            x=A[x-1]
            c+=1
        break
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
max=0
if N<B:
  print(math.floor(A*N/B)-A*math.floor(N/B))
  exit()
for i in range(1,B):
  tmp=math.floor(A*i/B)-A*math.floor(i/B)
  if tmp>max:
    max=tmp
print(max)

Fixed submission:
import math
A,B,N=map(int,input().split())
max=0
if N<B:
  print(math.floor(A*N/B)-A*math.floor(N/B))
  exit()
tmp=math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)
K=int(input())
ans=0
x=[]
for i in range(1,K+1):
  for j in range(1,K+1):
    x.append(math.gcd(i,j))
for i in x:
  for j in range(1,K+1):
    ans+=gcd(i,j)
print(ans)

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

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
from functools import reduce
import collections
def gcd_list(numbers):
    return reduce(math.gcd,numbers)
K=int(input())
ans=0
x=list(itertools.combinations_with_replacement(range(1,K+1),3))
for i in x:
  c=collections.Counter(i)
  if max(c.values())==1:
    ans+=6*gcd_list(i)
  elif max(c.values())==2:
    ans+=3*gcd_list(i)
  else:
    ans+=gcd_list(i)
print(ans)
  

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

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)
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+=gcd(i,j,k)
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd,numbers)

ans=0
K=int(input())
x=list(itertools.product(range(1,K+1),repeat=3))
for i in x:
    ans+=gcd_list(i)
print(ans)

Fixed submission:
import itertools
import math
from functools import reduce
K=int(input())
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    t=math.gcd(i,j)
    for k in range(1,K+1):
      ans+=math.gcd(t,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
tmp=0
for k in range(N):
  for j in range(k):
    i=int(2*j-k)
    if i>=0:
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
        tmp+=1
ans=S.count("R")*S.count("G")*S.count("B")-tmp
print(ans)

      
      
    

Fixed submission:
n=int(input())
s=input()
sum=0
r=int(s.count('R'))
g=int(s.count('G'))
b=int(s.count('B'))
for k in range(n):
    for j in range(k):
        i=2*j-k
        if i+1>0:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                sum=sum+1
print(r*g*b-sum)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
tmp=0
for k in range(2,N):
  for j in range(1,k):
    i=int(2*j-k)
    if i>=0:
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
        tmp+=1
ans=S.count("R")*S.count("G")*S.count("B")-tmp
print(ans)

Fixed submission:
n=int(input())
s=input()
sum=0
r=int(s.count('R'))
g=int(s.count('G'))
b=int(s.count('B'))
for k in range(n):
    for j in range(k):
        i=2*j-k
        if i+1>0:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                sum=sum+1
print(r*g*b-sum)