Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
i = list(map(int, input().split()))
c=math.gcd(i[0],i[1])
print(i[0]*i[1]/c)

Fixed submission:
import fractions
i=list(map(int, input().split()))
a=i[0]
b=i[1]
c=fractions.gcd(a,b)
print(i[0]*i[1]//c)

Buggy python submission (verdict: Runtime Error):
import math
i = list(map(int, input().split()))
c=math.gcd(i[0],i[1])
print(i[0]*i[1]/c)

Fixed submission:
import fractions
i=list(map(int, input().split()))
a=i[0]
b=i[1]
c=fractions.gcd(a,b)
print(i[0]*i[1]//c)
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
n=len(s)
for i in range(n):
    z=ord(s[i]+k)
    if z>123:
        z-=27
    s[i]=chr(z)
print(s)

Fixed submission:
k=int(input())
s=input()
n=len(s)
temp=""
for i in range(n):
    z=ord(s[i])+k
    if z>90:
        z-=26
    temp+=chr(z)
print(temp)
Buggy python submission (verdict: Runtime Error):
n,k,q= list(map(int, input().split()))
lis=[k]*n
for i in range(q):
    a=int(input())
    a-=1
    lis=map(lambda x: x-1, lis)
    lis[a]+=1
for i in range(n):
    if lis[i]>0:
        print("Yes")
    else:
        print("No")


Fixed submission:
n,k,q= list(map(int, input().split()))
lis=[k-q]*n
for i in range(q):
    a=int(input())
    a-=1
    lis[a]+=1
    
for i in range(n):
    if lis[i]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
x,y= list(map(int, input().split()))
n=input()
for k in range(y):
    i,j= list(map(int, input().split()))
    i-=1
    ans=n.count('AC', i, j)
    print(ans)

Fixed submission:
x,y= list(map(int, input().split()))
s=input()
anslis=[0]*x
ans=0
for k in range(1,x):
    if s[k-1:k+1]=="AC":
        ans+=1
    anslis[k]+=ans

for k in  range(y):
    i,j= list(map(int, input().split()))
    i-=1
    j-=1
    print(anslis[j]-anslis[i])
Buggy python submission (verdict: Runtime Error):
import math
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=math.gcd(ans,l[k]-l[k-1])
print(ans)

Fixed submission:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(0,a):
    if k==0:
        ans=l[0]
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())
k=[]
for i in range(s):
    j=input()
    if j in k:
        k.remove(j)
    else:
        k.append(j)
print(len(k))

Fixed submission:
import collections
s=int(input())
k = [input() for i in range(s)]
c = collections.Counter(k)
z=c.values()
lst=[ e for e in z if e%2==1]
print(len(lst))

Buggy python submission (verdict: Runtime Error):
s=int(input())
k=[]
for i in range(s):
    j=int(input())
    if j in k:
        k=k-j
    else:
        k.append(j)
print(len(k))
    

Fixed submission:
import collections
s=int(input())
k = [input() for i in range(s)]
c = collections.Counter(k)
z=c.values()
lst=[ e for e in z if e%2==1]
print(len(lst))
Buggy python submission (verdict: Runtime Error):
count=0
n=int(input())
while n%2=!1:
  n=n/2
  count+=1
print(count)

Fixed submission:
n=int(input())
i=1
if n==1:
  print(1)
else:
  while n>=2**i:
  	i+=1
  print(2**(i-1))

Buggy python submission (verdict: Runtime Error):
count=0
n=int(input())
while n%2=!1:
  n=n/2
  count+=1
  

Fixed submission:
n=int(input())
i=1
if n==1:
  print(1)
else:
  while n>=2**i:
  	i+=1
  print(2**(i-1))
Buggy python submission (verdict: Runtime Error):
s=int(input())
i= list(map(int, input().split()))
 
i.sort(reverse=True)
sum=0
ks=0
for j in range(s):
    sum+=i[j+1]
for j in range(n,2*n):
  ks+=i[j]
print(max(sum,ks))

Fixed submission:
s=int(input())
i= list(map(int, input().split()))
i.sort(reverse=True)
sum=0
for j in range(s):
    sum+=i[(2*j)+1]
print(sum)
Buggy python submission (verdict: Runtime Error):
x,y = list(map(int, input().split()))
count=0
for i in range(x+1):
    for j in range(x+1):
        k=y-i-j
        if k=<x and 0=<k:
          count+=1
print(count)

Fixed submission:
x,y = list(map(int, input().split()))
count=0
for i in range(x+1):
    for j in range(x+1):
        k=y-i-j
        if k<=x and 0<=k:
          count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
x,y = list(map(int, input().split()))
count=0
for i in range(x):
	for j in range(x):
      for k in range(x):
        a=i+j+K
        if y==a:
          count+=1
print(count)

Fixed submission:
x,y = list(map(int, input().split()))
count=0
for i in range(x+1):
    for j in range(x+1):
        k=y-i-j
        if k<=x and 0<=k:
          count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        d = abs(n-k)
        r = n % d
        if abs(r-d) < r:
            r = abs(r-d)

    print(r)

__main__()

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        r = n % k
        if abs(r-k) < r:
            r = abs(r-k)

    print(r)
    
__main__()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
A = [int(i) for i in input().split()]
d = {}

As = set(A)
for x in As:
    d.update({x: A.count(x)})

summ = 0
for x in As:
    y = d.get(x)
    summ += y*(y-1) // 2

for a0 in A:
    print(summ - (d.get(a0)-1))

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
A = [int(i) for i in input().split()]
d = {}

As = set(A)

for a in A:
    if a in d:
        d.update({a: d.get(a) + 1})
    else:
        d.update({a: 1})

summ = 0
for x in As:
    y = d.get(x)
    summ += y*(y-1) // 2

for a0 in A:
    print(summ - (d.get(a0)-1))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
A = [int(i) for i in input().split()]
d = {}
for a in A:
    if a in d:
        d.update({a: d.get(a) + 1})
    else:
        d.update({a: 1})

dr = {}
for x in A:
    if x not in dr:
        res = 0
        for item in d:
            y = d.get(item)
            if item == x:
                res += (y-1)*(y-2) // 2
            else:
                res += y*(y-1) // 2
        dr.update({x: res})

    print(dr.get(x))

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
A = [int(i) for i in input().split()]
d = {}

As = set(A)

for a in A:
    if a in d:
        d.update({a: d.get(a) + 1})
    else:
        d.update({a: 1})

summ = 0
for x in As:
    y = d.get(x)
    summ += y*(y-1) // 2

for a0 in A:
    print(summ - (d.get(a0)-1))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

s = list(input())
q = int(input())
reverse_counter = 0
for q0 in range(q):
    A = [i for i in input().split()]
    if len(A) == 1:
        reverse_counter += 1
    else:
        if A[1] == '1':
            if reverse_counter % 2 == 0:
                s.insert(0, A[2])
            else:
                s.append(A[2])
        else:
            if reverse_counter % 2 == 0:
                s.append(A[2])
            else:
                s.insert(0, A[2])

if reverse_counter % 2 == 1:
    s.reverse()

print(''.join(s))

Fixed submission:
# -*- coding: utf-8 -*-

s = list(input())
q = int(input())
reverse_counter = 0
left = []
for q0 in range(q):
    A = [i for i in input().split()]
    if len(A) == 1:
        reverse_counter += 1
    else:
        if A[1] == '1':
            if reverse_counter % 2 == 0:
                left.append(A[2])
            else:
                s.append(A[2])
        else:
            if reverse_counter % 2 == 0:
                s.append(A[2])
            else:
                left.append(A[2])

left.reverse()

res = left + s

if reverse_counter % 2 == 1:
    res.reverse()

print(''.join(res))
Buggy python submission (verdict: Runtime Error):
a = int(input().strip())
print a*a

Fixed submission:
# -*- coding: utf-8 -*-

r = int(input().strip())
print(r*r)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1
        import math
        for h in range(len(v)):
            if hh == 1:
                pass
            elif v[h] == 1:
                num *= hh
            elif h < hh:
                num *= hh * (v[h] + 1)
            else:
                cnk = 0
                for i in range(hh):
                    cnk += math.factorial(hh)/math.factorial(h)/math.factorial(hh - h)

                num *= int(cnk)

            hh = v[h]

            num = num % mod

        print(num)

    else:
        print(0)


Fixed submission:
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0 or 0 in d[1:]:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1

        for h in v:
            num *= hh ** h
            num = num % mod
            hh = h

        print(num)

    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
a = int(input())
b = round(math.sqrt(a))
while a % b != 0:
    b+=1
c = int(a / b)
print(b+c-2)

Fixed submission:
# -*- coding: utf-8 -*-
import math
a = int(input())
b = round(math.sqrt(a))
while a % b != 0:
    b -= 1
c = int(a / b)
print(b + c - 2)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
a, b, x = map(int, input().split())
if x <= a*a*b/2: print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else: print(90 - math.degrees(math.atan(a**3/(2*(a*a*b-x)))))

Fixed submission:
# -*- coding: utf-8 -*-
import math
a, b, x = map(int, input().split())
if x <= a*a*b/2: print(90 - math.degrees(math.atan(2*x/(a*b*b))))
elif x == a*a*b: print('0')
else: print(90 - math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
import numpy as np

string = input().split()
A = float(string[0])
B = float(string[1])

keta = np.log10(float(math.floor(A*B)))


def mypow(nuko):
    pai = 1
    for i in range(int(nuko)):
        pai = pai * 10
    return pai
    

hoge = np.log10(B)
neko = mypow(keta-(hoge+2)) 

print(int( math.floor(A*B) - (math.floor(A*B) % neko) ) )



Fixed submission:
# coding: utf-8
# Your code here!
import math
import numpy as np


string = input().split()
A = int(string[0]) 
B = int (round(float(string[1]) * 100))

print(int(int( (A*B) )//int(100)))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
import numpy as np

string = input().split()
A = float(string[0])
B = float(string[1])

keta = np.log10(A)


def mypow(nuko):
    pai = 1
    for i in range(int(nuko)):
        pai = pai * 10
    return pai
    

hoge = np.log10(B)
neko = mypow(keta-(hoge+2)) 

print(int( math.floor(A*B) - (math.floor(A*B) % neko) ) )



Fixed submission:
# coding: utf-8
# Your code here!
import math
import numpy as np


string = input().split()
A = int(string[0]) 
B = int (round(float(string[1]) * 100))

print(int(int( (A*B) )//int(100)))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math
import numpy as np

string = input().split()
A = float(string[0])
B = float(string[1])

keta = np.log10(A)


def mypow(nuko):
    pai = 1
    for i in range(int(nuko)):
        pai = pai * 10
    return pai
    
    
hoge = np.log10(B)

neko = mypow(keta-(hoge+2)) 

print(int( math.floor(A*B) - (math.floor(A*B) % neko) ) )



Fixed submission:
# coding: utf-8
# Your code here!
import math
import numpy as np


string = input().split()
A = int(string[0]) 
B = int (round(float(string[1]) * 100))

print(int(int( (A*B) )//int(100)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

A.sort()

ans = 0

if A[0]!=A[1]:
    ans += 1

for i in range(1, N):
    flag = True
    for j in range(0, i):
        if i==j:
            continue
        if A[i] % A[j] == 0:
            flag = False
            break
    
    if flag:
        # print(i)
        ans += 1

print(ans)


Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

K = 10**6+1
num = [0] * K
l = [False] * K
for i in range(N):
    num[A[i]]+=1
    l[A[i]] = True

for i in range(1, K):
    if num[i]>0:
        if num[i]>1:
            l[i] = False
        j = 2
        while i*j < K:
            l[i*j] = False
            j += 1

ans = 0
for i in range(N):
    if l[A[i]]:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
p[N] = int(input().split())

ans = 0
e_sum = 0

for j in range(K):
  e_sum = e_sum + (p[j]+1)/2

ans = e_sum
for i in range(K,N):
  e_sum = e_sum + (p[i]+1)/2
  e_sum = e_sum - (p[i-K]+1)/2
  if ans<e_sum:
    ans=e_sum

print(ans)

Fixed submission:
str_N = input().split()
N = int(str_N[0])
K = int(str_N[1])
str_p = input().split()
p = [float(str_p[i]) for i in range(N)]

ans = 0
e_sum = 0

for j in range(K):
  e_sum = e_sum + (p[j]+1)/2

ans = e_sum
for i in range(K,N):
  e_sum = e_sum + (p[i]+1)/2
  e_sum = e_sum - (p[i-K]+1)/2
  if ans<e_sum:
    ans=e_sum

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=int(1e9)+7
l=[int(x) for x in input().split()]
sum1=0
for i in range(n-1):
    for j in range(i+1,n,1):
        prod=(l[i]*l[j])%mod
        sum1=(sum1%mod+prod%mod)%mod
print(sum1)


Fixed submission:
n=int(input())
mod=int(1e9)+7
l=[int(x) for x in input().split()]
sum1=0
sum2=0
for i in range(n):
    sum2=(sum2%mod+l[i]%mod)%mod
for i in range(n-1):
    sum2=sum2-l[i]
    x=(sum2%mod*(l[i]%mod))%mod
    sum1=(sum1%mod+(x%mod))%mod
print(sum1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
while n:
    a += n % 10
    n //= 10
if a % 9 == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
n = list(input())
a = 0
for i in range(len(n)):
    a += int(n[i])
if a % 9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

a = sorted(a)
#print(a)
count = 0
while len(a)>=1:
    aa = a.pop(0)
    if len(a)>=1 and a[0] == aa:
        while a[0] == aa:
            a.pop(0)
            if len(a) == 0:
                break
        continue
    #print("after popped aa: ",a)
    #print("aa: ",aa)
    count += 1
    i = 0
    num = 0
    a_len = len(a)
    while num < a_len:
        if a[i] % aa == 0:
            #print("remove: ",a[i])
            a.remove(a[i])
            #print("a -> ",a)
            num += 1
        else:
            i += 1
            num += 1
        #print("i, num == ",i, num)
print(count)


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
count = 0

a = sorted(a)

max = a[len(a)-1]
line = [0]*(max+1)

for x in a:
    line[x] += 1
    
for x in a:
    if line[x] == 0:
        continue
    xx = x * 2
    j = 3
    while xx <= max:
        if line[xx] != 0:
            line[xx] = 0
        xx = x * j
        j += 1
for i in range(max+1):
    if line[i] == 1:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
mult = 1
for i in range(n):
    mult *= a[i]
    if mult == 0:
        print(0)
        break
if mult > 1e+18:
    print(-1)
elif mult != 0:
    print(mult)


Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 1
 
for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break
 
for n in range(N):
 if L[n] == 0: ans = 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
mult = 1
for i in range(n):
    mult *= a[i]
    if mult == 0:
        print(0)
        break
if mult > 1e+18:
    print(-1)
elif mult != 0:
    print(mult)


Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 1
 
for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break
 
for n in range(N):
 if L[n] == 0: ans = 0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
mult = 1
for i in range(n):
    mult *= a[i]
if mult > 1e+18:
    print(-1)
else:
    print(mult)


Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 1
 
for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break
 
for n in range(N):
 if L[n] == 0: ans = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
a = []
b = []
for i in range(m):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

path = [[] for i in range(n)]
for i in range(m):
    for j in range(1, n+1):
        if a[i] == j:
            path[j-1].append(b[i])
        if b[i] == j:
            path[j-1].append(a[i])

#print('h: ', h)
#print(path)

total = 0
for i in range(n):
    flag = 1
    #print('len(path[i]): ', len(path[i]))
    for j in range(len(path[i])):
        idx = path[i][j]
        #print('idx: ',idx)
        #print('h[idx]:',h[idx])
        #print('h[i]:', h[i])
        if h[idx-1] >= h[i]:
            flag = 0
    total += flag

print(total)


Fixed submission:
n, m = map(int, input().split())
h = [int(x) for x in input().split()]

ans = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans[b-1] = 0
    if h[b-1] >= h[a-1]:
        ans[a-1] = 0

count = ans.count(1)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
a = []
b = []
for i in range(m):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

path = [[] for i in range(n)]
for i in range(m):
    for j in range(1, n+1):
        if a[i] == j:
            path[j-1].append(b[i])
        if b[i] == j:
            path[j-1].append(a[i])

#print('h: ', h)
#print(path)

total = 0
for i in range(n):
    flag = 1
    #print('len(path[i]): ', len(path[i]))
    for j in range(len(path[i])):
        idx = path[i][j]
        #print('idx: ',idx)
        #print('h[idx]:',h[idx])
        #print('h[i]:', h[i])
        if h[idx-1] >= h[i]:
            flag = 0
    total += flag

print(total)


Fixed submission:
n, m = map(int, input().split())
h = [int(x) for x in input().split()]

ans = [1 for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans[b-1] = 0
    if h[b-1] >= h[a-1]:
        ans[a-1] = 0

count = ans.count(1)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
total = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            total += math.gcd( math.gcd(i,j), m)
print(total)


Fixed submission:
import math
k = int(input())
total = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ab = math.gcd(a,b)
            total += math.gcd(ab, c)
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

for i in range(len(r)):
    for j in range(len(g)):
        for k in range(len(b)):
            rgb = sorted([r[i],g[j],b[k]])
            if rgb[2]-rgb[1] != rgb[1]-rgb[0]:
                count += 1
print(count)


Fixed submission:
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

count += len(r)*len(g)*len(b)

for i in range(n-2):
    for j in range(i+1,n):
        if j+(j-i) >= n:
            continue
        k = j + (j-i)
        if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            count -= 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if k-j == j-i:
                continue
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
                count += 1
print(count)


Fixed submission:
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

count += len(r)*len(g)*len(b)

for i in range(n-2):
    for j in range(i+1,n):
        if j+(j-i) >= n:
            continue
        k = j + (j-i)
        if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            count -= 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if k-j == j-i:
                continue
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
                count += 1
print(count)


Fixed submission:
n = int(input())
s = input()

count = 0
r = []
g = []
b = []

for i in range(n):
    if s[i] == 'R':
        r.append(i)
    if s[i] == 'G':
        g.append(i)
    if s[i] == 'B':
        b.append(i)

count += len(r)*len(g)*len(b)

for i in range(n-2):
    for j in range(i+1,n):
        if j+(j-i) >= n:
            continue
        k = j + (j-i)
        if (s[i] != s[j]) and (s[j] != s[k]) and (s[k] != s[i]):
            count -= 1

print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
lcm = a * b // gcd(a, b)
print(lcm)


Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
lcm = a * b // gcd(a, b)
print(lcm)
Buggy python submission (verdict: Runtime Error):
[N, X, Y] = input().split()
N = int(N)
X = int(X)
Y = int(Y)
dist_list = []

for i in range(N):
    for j in range(i+1, N):
        a = j - i
        b = abs(i+1 - X) + abs(j+1 -Y) + 1
        if a > b:
            dist_list.append(b)
        else:
            dist_list.append(a)

for k in range(N-1):
    print(dist_list.count(k+1))



Fixed submission:
S = input()

if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if S[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)


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

a = N * (N-1) / 2
b = M * (M-1) / 2

print(int(a+b))