Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
l = sorted(list(map(int,input().split())))
c = 0
b = {}
for i in range(len(l)):
    if l[i] in b:
        b[l[i]] += 1
    else:
        b[l[i]] = 1

for i in range(len(l) - 1, -1, -1):
    if  b[l[i]] == 0:
        continue
    t = l[i]
    b[l[i]] -= 1
    s = 2 ** math.floor(math.log2(temp))
    st = 2*s - t 
    if l == []:
        break
    if st in b and b[st] > 0:
        b[2 * s - t] -= 1
        c += 1
print(c)

Fixed submission:
import math
n = int(input())
l = sorted(list(map(int,input().split())))
c = 0
b = {}
for i in range(len(l)):
    if l[i] in b:
        b[l[i]] += 1
    else:
        b[l[i]] = 1

for i in range(len(l) - 1, -1, -1):
    if  b[l[i]] == 0:
        continue
    t = l[i]
    b[l[i]] -= 1
    s = 2 ** math.floor(math.log2(t))
    st = 2*s - t 
    if l == []:
        break
    if st in b and b[st] > 0:
        b[2 * s - t] -= 1
        c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(m)]
count = 0
for i in range(m):
    ab[i].sort()
while len(ab) > 0:
    ab = sorted(ab, key = lambda x: x[1])
    end = ab[0]
    list.sort(ab, reverse=True)
    remove = ab.index(end)
    if remove >= 1:
        while ab[remove - 1][0] < end[1]:
            remove -= 1
            if remove == 0:
                break
    del ab[(remove):]
    count += 1
print(int(count))

Fixed submission:
n, m = map(int, input().split())
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append((b, a))
l.sort()
answer = 0
last = 0
for b, a in l:
    if a >= last:
        answer += 1
        last = b
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(m)]
count = 0
for i in range(m):
    ab[i].sort()
while len(ab) > 0:
    ab = sorted(ab, key = lambda x: x[1])
    end = ab[0]
    list.sort(ab, reverse=True)
    remove = ab.index(end)
    if remove >= 1:
        while ab[remove - 1][0] < end[1]:
            remove -= 1
            if remove == 0:
                break
    del ab[(remove):]
    count += 1
print(int(count))


Fixed submission:
n, m = map(int, input().split())
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append((b, a))
l.sort()
answer = 0
last = 0
for b, a in l:
    if a >= last:
        answer += 1
        last = b
print(answer)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(m)]
count = 0
while len(ab) > 0:
    ab = sorted(ab, key = lambda x: x[1])
    end = ab[0]
    list.sort(ab, reverse=True)
    remove = ab.index(end)
    while ab[remove][0] == end[0]:
        remove += 1
    del ab[(remove - 1):]
    count += 1
print(int(count))


Fixed submission:
n, m = map(int, input().split())
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append((b, a))
l.sort()
answer = 0
last = 0
for b, a in l:
    if a >= last:
        answer += 1
        last = b
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(m)]
count = 0
while len(ab) != 0:
    ab = sorted(ab, key = lambda x: x[1])
    end = ab[0][1]
    ab.sort()
    while ab[0][0] < end:
        ab.pop(0)
        if len(ab) == 0:
            break
    count += 1
print(int(count))


Fixed submission:
n, m = map(int, input().split())
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append((b, a))
l.sort()
answer = 0
last = 0
for b, a in l:
    if a >= last:
        answer += 1
        last = b
print(answer)
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
M = a[0]
m = a[0]
for i in range(1, n):
  if a[i] > M:
    M = a[i]
  if a[i] < m:
    m = a[i]
print(int(M - m))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
M = a[0]
m = a[0]
for i in range(1, n):
  if a[i] > M:
    M = a[i]
  if a[i] < m:
    m = a[i]
print(int(M - m))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
for i in range(n):
    place = l1.index(x[i])
    l1.remove(x[i])
    print(l1[int((n / 2) - 1)])
    l1.insert(place, x[i])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
median1 = l1[int(n / 2) - 1]
median2 = l1[int(n / 2)]
if median1 == median2:
    for i in range(n):
        print(median1)
else:
    for i in range(n):
        if x[i] <= median1:
            print(median2)
        else:
            print(median1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
import copy
for i in range(n):
    l1 = copy.copy(x)
    l1.sort()
    l1.remove(x[i])
    print(l1[int((n / 2) - 1)])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
median1 = l1[int(n / 2) - 1]
median2 = l1[int(n / 2)]
if median1 == median2:
    for i in range(n):
        print(median1)
else:
    for i in range(n):
        if x[i] <= median1:
            print(median2)
        else:
            print(median1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
import collections
l1 = collections.Counter(a).most_common()
l1.sort()
if len(l1) > 2　or l1[1][0] - l1[0][0] > 1:
    print("No")
elif len(l1) == 1:#発言が１種類の場合
    if l1[0][0] * 2 <= n or l1[0][0] == n - 1:
        print("Yes")
    else:
        print("No")
else:
    if l1[1][1] >= (l1[1][0] - l1[0][1]) * 2 and l1[1][0] > l1[0][1]:
        print("Yes")#多い発言の人数が残りの色数かけ２より多い、全体色数が少ない発言の人数より多い
    else:
        print("No")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
import collections
l1 = collections.Counter(a).most_common()
l1.sort()
if len(l1) > 2:
    print("No")
elif len(l1) == 1:#発言が１種類の場合
    if l1[0][0] * 2 <= n or l1[0][0] == n - 1:
        print("Yes")
    else:
        print("No")
else:
    if l1[1][0] - l1[0][0] > 1:
        print("No")
    elif l1[1][1] >= (l1[1][0] - l1[0][1]) * 2 and l1[1][0] > l1[0][1]:
        print("Yes")#多い発言の人数が残りの色数かけ２より多い、全体色数が少ない発言の人数より多い
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        a[i + 1] = x - a[i]
if a[n - 1] + a[n] > x:
    count += a[n - 1] + a[n] - x
print(int(count))


Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        if a[i + 1] >= a[i] + a[i + 1] - x:
            a[i + 1] = x - a[i]
        else:
            a[i + 1] = 0
            a[i] = x
print(int(count))
Buggy python submission (verdict: Runtime Error):
A,V=map(int, input().split())
B,W=map(int, input().split())
T=int(input())

if A>B and A-V*T=<B-W*T:
  print("YES")
elif  A<B and A+V*T>=B+W*T:
  print("YES")
else:
  print("NO")

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

if A>B and A-V*T<=B-W*T:
  print("YES")
elif  A<B and A+V*T>=B+W*T:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
l.append(input())
for i in range(1,N):
  s=input()
  if s not in l:
    l.append(s)
  
print(len(l))

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  l.append(input())

print(len(set(l)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=[]
l.append(input())
for i in range(1,N):
  s=input()
  for j in range(len(l)):
    if s==l[j]:
      break
    if j == len(l)-1:
      l.append(s)
  
print(len(l))

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  l.append(input())

print(len(set(l)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[]
l=[]
for i in range(N):
  s.append(input())
  if len(l)==0:
    l.append(s[i])
  if len(l)>0:
    for j in range(len(l)):
      #print(s[i])
      if s[i]==l[j]:
        break
      if j==len(l)-1:
        l.append(s[i])
  
#print(l)
print(len(l))

Fixed submission:
N=int(input())
l=[]
for i in range(N):
  l.append(input())

print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
m=list(map(int, input().split()))
m.sort(reverse=True)
a=0
for i in range(n):
  m.pop(0)
  if len(m)==0:
  	break
  
for i in range(len(m)):
  a=a+m[i]
  
print(a)

Fixed submission:
h,n=map(int,input().split())
m=list(map(int, input().split()))
m.sort(reverse=True)
del m[:n]
a=0

for i in range(len(m)):
  a=a+m[i]
  
print(a)
Buggy python submission (verdict: Runtime Error):
s, t = input(), input()

ans = 0

for i in range(len(s) - len(t) + 1):
  count = 0
  for j in range(len(t)):
    if s[i][j] == t[j]:
      count += 1

if ans <= count:
  ans = count
print(len(t) - count)

Fixed submission:
s = input()
t = input()
 
ans = 0
 
for i in range(len(s) - len(t) + 1):
  count = 0
  for j in range(len(t)):
    if s[i + j] == t[j]:
      count += 1
 
  if ans <= count:
    ans = count
print(len(t) - ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
 
ans = 0
 
for i in range(n):
  for j in range(n):
    for k in range(n):
      if l[i] == l[j] and l[j] == l[k] and l[i] == l[k]:
        coutinue
      if (l[i]+l[j]>l[k]) and (l[j]+l[k]>l[i]) and (l[i]+l[k]>l[j]):
        ans += 1
        
print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))
 
ans = 0
 
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
        if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]:
          ans += 1
        
print(ans)

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

ans = 0

for i in range(n):
  for j in range(n):
    for k in range(n):
      if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
        coutinue
      if (l[i]+l[j]>l[k]) or (l[j]+l[k]>l[i]) or (l[i]+l[k]>l[j]):
        ans += 1
        
print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))
 
ans = 0
 
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
        if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]:
          ans += 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
 
count = 0
 
for i in range(len(s))
if s[i] != t[i]:
  count += 1

print(count)

Fixed submission:
s = input()
t = input()
 
count = 0
 
for i in range(len(s)):
	if s[i] != t[i]:
		count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

count = 0

for i in range(len(s))
if s[i] == t[i]:
  count += 1

print(count)


Fixed submission:
s = input()
t = input()
 
count = 0
 
for i in range(len(s)):
	if s[i] != t[i]:
		count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a = map(int,input().split())

for i in range(len(a)):
  if a[i] == 0:
    print(i+1)
    break

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

for i in range(len(a)):
  if a[i] == 0:
    print(i+1)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans = False

for i in range(101):
  for j in range(101):
    if i+j == x and 2*i + 4*j == y:
		ans = True

if ans:
  print("Yes")
else:
  print("No")

Fixed submission:
x, y = map(int, input().split())
ans = False
 
for i in range(101):
	for j in range(101):
		if i+j == x and 2*i+4*j == y:
			ans = True
if ans:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
count = 1
if 0 in a:
  print(0)
else:
  for i in range(N):
    count *= a[i]
    if ans > 10 ** 18:
      print(-1)
      break
  else:
    print(count)

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int,input().split()))
num = 10**18
count = 1
if 0 in nums:
	print(0)
else:
	for i in range(n):
		count *= nums[i]
		if count < num:
			print(-1)
            break
		else:
			print(count)

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = map(int,input().split())
num = 10**18
count = 1
for i in range(n):
	count *= nums[i]

if count < num:
	print(-1)
else:
	print(count)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(N):
    ans *= a[i]
    if ans > 10 ** 18:
      print(-1)
      break
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
word = input()
ans = ""
if len(word) <= n:
	print(word)
else:
	for i in range(n):
    	ans += word[i]
	ans +=("...")
	print(ans)

Fixed submission:
k = int(input())
s = input()
if len(s)<=k:
	print(s)
else:
    print(s[:k]+"...")

Buggy python submission (verdict: Runtime Error):
n = int(input())
word = input()
ans = ""
if len(word) < n:
	print(word)
else:
	for i in range(n):
    	ans += word[i]
print(ans + "...")

Fixed submission:
k = int(input())
s = input()
if len(s)<=k:
	print(s)
else:
    print(s[:k]+"...")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
used = []
ans = 0
for i in range(N):
  b = input()
  a.append(b)
  for j in a:
    if not j in used:
      ans += 1
      used.append(j)
print(ans)

Fixed submission:
N = int(input())
ans = set()
for i in range(N):
  ans.add(input())
print(len(ans))
Buggy python submission (verdict: Runtime Error):
map_list = [int,input().split() for x in range(3)]

n = int(input())
for i in range(n):
  a = int(input())
  

Fixed submission:
map_list = [list(map(int,input().split())) for x in range(3)]
 
n = int(input())
for i in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if map_list[i][j] == a:
        map_list[i][j] = 0

ans = "No"
for k in range(3):
  if map_list[0][k] == map_list[1][k] == map_list[2][k] or \
     map_list[k][0] == map_list[k][1] == map_list[k][2]:
      ans = "Yes"
      break
  if map_list[0][0] == map_list[1][1] == map_list[2][2] or \
	 map_list[0][2] == map_list[1][1] == map_list[2][0]:
      ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
a = ("".join(a))*b

Fixed submission:
a, b = map(int,input().split())
a1, b1 = str(a) * b, str(b) * a
ans = min(a1[0],b1[0])
if int(ans) == b:
  print(b1)
else:
  print(a1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i+1][0]:
    ans = "No"
print(ans)

Fixed submission:
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n-1): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i+1][0]:
    ans = "No"
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)):
  cnt=0
  for j in range(i,len(t)+i):
    if s[j]!=t[j-i]:
      cnt+=1
  ans.append(cnt)
print(min(ans))


Fixed submission:
s=list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)+1):
  cnt=0
  for j in range(i,len(t)+i):
    if s[j]!=t[j-i]:
      cnt+=1
  ans.append(cnt)
print(min(ans))

Buggy python submission (verdict: Runtime Error):
s=list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)):
  cnt=0
  for j in range(i,len(t)+i):
    if s[j]!=t[j]:
      cnt+=1
  ans.append(cnt)
print(min(ans))

Fixed submission:
s=list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)+1):
  cnt=0
  for j in range(i,len(t)+i):
    if s[j]!=t[j-i]:
      cnt+=1
  ans.append(cnt)
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n,x,t=map(int,input().split())
print(((n+x-1)//x)+*t)

Fixed submission:
n,x,t=map(int,input().split())
print(((n+x-1)//x)*t)
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
ans=0
for i in range(n):
  a.append(list(map(int,input().split())))
a=list(set(a))
for i in range(n):
  if a[i][0]^2+a[i][1]^2<=d^2:
    ans+=1
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
n,d=map(int,input().split())
ans=0
a=[]
for i in range(n):
  e=list(map(int,input().split()))
  a.append(e)
a.sort()
for i in range(n):
  #print(a[i][0]**2+a[i][1]**2)
  if a[i][0]**2+a[i][1]**2<=d**2:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
cnt=[0]*500000
print(2*10**2)
for i in range(1,2*10**2+1):
    for j in range(1,2*10**2+1):
        for k in range(1,2*10**2+1):
            cnt[((i+j)**2+(j+k)**2+(k+i)**2)//2-1]+=1
for i in range(n):
    print(cnt[i])


Fixed submission:
l,r,d=map(int,input().split())
ans=0
for i in range(l,r+1):
  if i%d==0:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

a,b=input().split()
b=list(b)
if a=="0" or b=="0":
    print(0)
else:
    b.remove('.')
    b=''.join(b)
    a=int(a)
    b=int(b)
    c=str(a*b)
    c=list(c)
    del c[-1]
    del c[-1]
    c=''.join(c)
    print(c)


Fixed submission:
# coding: utf-8
# Your code here!

a,b=input().split()
b=list(b)
if a=="0" or b=="0":
    print(0)
else:
    b.remove('.')
    b=''.join(b)
    a=int(a)
    b=int(b)
    c=str(a*b)
    if a*b<100:
        print(0)
    else:
        c=list(c)
        del c[-1]
        del c[-1]
        c=''.join(c)
        print(c)

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
b=list(b)
b.remove('.')
b=''.join(b)
a=int(a)
b=int(b)
c=a*b
c=list(str(c))
c.insert('.',len(c)-3)
print(''.join(c))


Fixed submission:
# coding: utf-8
# Your code here!

a,b=input().split()
b=list(b)
if a=="0" or b=="0":
    print(0)
else:
    b.remove('.')
    b=''.join(b)
    a=int(a)
    b=int(b)
    c=str(a*b)
    if a*b<100:
        print(0)
    else:
        c=list(c)
        del c[-1]
        del c[-1]
        c=''.join(c)
        print(c)
Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
print(min(k,a)+min(max(k-a,0),abs(k-a-b))+min(max(k-a-b,0),abs(k-a-b-c))

Fixed submission:
a,b,c,k=map(int,input().split())
d=k-a
if d<0:
  print(k)
else:
  ans=a
  d-=b
  if d<0:
    print(ans)
  else:
    print(ans-d)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
print(2*n*pi)

Fixed submission:
import math
n=int(input())
print(2*n*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
import math as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)

Fixed submission:
import math as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)

Fixed submission:
import math as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   ans+=f.gcd(f.gcd(i,j),k)
print(ans)


Fixed submission:
import math as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   ans+=f.gcd(f.gcd(i,j),k)
print(ans)

Fixed submission:
import math as f 
a=int(input())
ans=0
for i in range(1,a+1):
 for j in range(1,a+1):
  for k in range(1,a+1):
   b=f.gcd(i,j)
   ans+=f.gcd(b,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
for i in range(n):
    for j in range(i+1,n):
        if s[i]==s[j]:
            continue
        for k in range(j+1,n):
            if s[j]!=s[k]and s[k]!=s[i] and j-i!=k-j:
                ans+=1
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
t=[]
ss=[]
for i in range(n):
    t.append(s[i:])
    ss.append(t[i].count('R'))
    ss.append(t[i].count('G'))
    ss.append(t[i].count('B'))
#print(t)
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]==s[j]:
            continue
        else:
            if s[i]=='R' and s[j]=='G'or s[i]=='G'and s[j]=='R':
                ans+=ss[3*(j+1)+2]
                if 2*j-i<n:
                    if s[2*j-i]=='B':
                        ans-=1
            if s[i]=='B' and s[j]=='R'or s[i]=='R'and s[j]=='B':
                ans+=ss[3*(1+j)+1]
                if 2*j-i<n:
                    if s[2*j-i]=='G':
                        ans-=1
            if s[i]=='B' and s[j]=='G'or s[i]=='G'and s[j]=='B':
                ans+=ss[3*j+3]
                if 2*j-i<n:
                    if s[2*j-i]=='R':
                        ans-=1
        #print(ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if s[i]!=s[j] and s[j]!=s[k]and s[k]!=s[i] and j-i!=k-j:
                ans+=1
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
t=[]
ss=[]
for i in range(n):
    t.append(s[i:])
    ss.append(t[i].count('R'))
    ss.append(t[i].count('G'))
    ss.append(t[i].count('B'))
#print(t)
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]==s[j]:
            continue
        else:
            if s[i]=='R' and s[j]=='G'or s[i]=='G'and s[j]=='R':
                ans+=ss[3*(j+1)+2]
                if 2*j-i<n:
                    if s[2*j-i]=='B':
                        ans-=1
            if s[i]=='B' and s[j]=='R'or s[i]=='R'and s[j]=='B':
                ans+=ss[3*(1+j)+1]
                if 2*j-i<n:
                    if s[2*j-i]=='G':
                        ans-=1
            if s[i]=='B' and s[j]=='G'or s[i]=='G'and s[j]=='B':
                ans+=ss[3*j+3]
                if 2*j-i<n:
                    if s[2*j-i]=='R':
                        ans-=1
        #print(ans)
print(ans)