Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
if(str[0] != str[1] and str[n-1] != str[n-2] and k >= 2):
  print(happy + 2 * k - 2)
elif(str[n-1] != str[n-2] or str[0] != str[1]):
  print(happy + 2 * k - 1)
else:
  print(happy + 2 * k )

Fixed submission:
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
print( min(n-1,(happy + 2 * k )))

# 10 1
# LLLLLRRRRRの時、happy + 2 * kだけやったら10になるけど、幸福になる人数は最高でも9人(n-1人)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
 
str = input()
print(str[0])
happy = 0
unhappy = 0
hashi = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
if(str[0] != str[1] and str[n-1] != str[n-2]):
  hashi = 2
if(str[n-1] != str[n-2] or str[0] != str[1]):
  hashi = 1
if(k >= 2):
  print(happy + 2 * k - hashi)
if(k == 1):
  print(happy + 2 * k - hashi * k)

Fixed submission:
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
print( min(n-1,(happy + 2 * k )))

# 10 1
# LLLLLRRRRRの時、happy + 2 * kだけやったら10になるけど、幸福になる人数は最高でも9人(n-1人)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
 
str = input()
print(str[0])
happy = 0
unhappy = 0
hashi = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
if(str[0] != str[1]):
  hashi += 1
if(str[n-1] != str[n-2]):
  hashi += 1
if(k == 1):
  hashi = 1
print(happy + 2 * k - hashi)

Fixed submission:
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
print( min(n-1,(happy + 2 * k )))

# 10 1
# LLLLLRRRRRの時、happy + 2 * kだけやったら10になるけど、幸福になる人数は最高でも9人(n-1人)

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

str = input().split()

happy = 0
unhappy = 0

for i in range(n):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
    
print(happy + 2 * k)


Fixed submission:
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
print( min(n-1,(happy + 2 * k )))

# 10 1
# LLLLLRRRRRの時、happy + 2 * kだけやったら10になるけど、幸福になる人数は最高でも9人(n-1人)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
l = [0,0,0]


for i in range(n-1):
  if h[i] >= h[i + 1]:
    l.insert(i, 1)
 
con = 0
max = 0
for i in range(n + 1):
  if l[i] == 1:
    con += 1
  else:
    if con > max:
      max = con
      con = 0
print(max)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
l = [0,0,0]
for i in range(n-1):
  if h[i] >= h[i + 1]:
    l.insert(i, 1)
  else:
    l.insert(i,0)

con = 0
max = 0
for i in range(n + 1):
  if l[i] == 1:
    con = con + 1
  else:
    if con > max:
      max = con
    con = 0
print(max)

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split())
l = [0,0,0]

for i in range(n):
  if h[i] > h[i + 1]:
    l.insert(i, 1)

con = 0
max = 0
for i in range(n + 1):
  if l[i] == 1:
    con += 1
  else:
    if con > max:
      max = con
      con = 0
print(max)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
l = [0,0,0]
for i in range(n-1):
  if h[i] >= h[i + 1]:
    l.insert(i, 1)
  else:
    l.insert(i,0)

con = 0
max = 0
for i in range(n + 1):
  if l[i] == 1:
    con = con + 1
  else:
    if con > max:
      max = con
    con = 0
print(max)
Buggy python submission (verdict: Runtime Error):
n =  int(input())
a = int(input())
b = int(input())

if n * a < b:
  print(n * a)
else:
  print(b)

Fixed submission:
str = input().split()
n = int(str[0])
a = int(str[1])
b = int(str[2])

if n * a < b:
  print(n * a)
else :
  print(b)
Buggy python submission (verdict: Runtime Error):
s = int(input())

n = len(s)

for i in range(n-1):
  if s[i] == s[i+1]:
    if s[i] == 0:
      s[i+1] = 1
    else:
      [i] = 0

print(s)

Fixed submission:
s = list(map(int,input()))

n = len(s)
 
ans_l = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    ans_l += 1
    if s[i] == 0:
      s[i+1] = 1
    else:
      s[i+1] = 0
print(ans_l)
Buggy python submission (verdict: Runtime Error):
str = input()
n = lent(str)
counter = []
max = 0
for i in range(n):
  counter[i] = 0

for i in range(n):
  if str[i] == "A" or "T" or "C" or "G":
    counter[i] ++
  
  
for i in range(n):
  if counter[i] > max:
    max = counter[i]
    
print(max)

Fixed submission:
str = list(input())
n = len(str)
max = 0
counter = [0,0,0]
for i in range(n):
  if 'A' in str[i] or 'T'in str[i] or 'C' in str[i]or 'G'in str[i]:
    counter.insert(i, counter[i] + 1)
  else:
    counter.append(0)
  

con = 0;    
for i in range(n+1):
  if counter[i] == 1:
    con += 1
    continue
  else :
    if con > max :
      max = con
      con = 0
    
print(max)
Buggy python submission (verdict: Runtime Error):
str = int(input()).split()
a = str[0]
b = str[1]
c = str[2]

if b / a > c:
	print(c)

else:
	print(int(b / a))

Fixed submission:
str = input().split()
a = int(str[0])
b = int(str[1])
c = int(str[2])
 
if b // a > c:
	print(c)
else:
	print(b // a)
Buggy python submission (verdict: Runtime Error):
a = []
A,B,K  = map(int, input().split())

if A > B:
	min = B
else:
  min = A

for i in B:
  if(A % i == 0 && B % i == 0):
    a.append(i)

print(a.get(K-1))

Fixed submission:
a = []
A,B,K  = map(int, input().split())
min = 0
 
if A > B:
	min = B
else:
  min = A
for i in range(1, min + 1):
  if(A % i == 0 and B % i == 0):
    a.append(i)
    
print(a[len(a) - K])

#no 1 is a(len-1)
# no k is a(lent-K)
Buggy python submission (verdict: Runtime Error):
str = input()
n = len(str)

ls = []

for i in range(n):
  ls.append(str[i])


for i in range(len(ls)):
  if (ls[i] == ls[i+1]) or (len(ls) == 1):
    break
  if (ls[i] == 0 and ls[i + 1] == 1) or (ls[i] == 1 and ls[i + 1] == 0):
    del ls[i]
    del ls[i]

nokori = len(ls)
print(n - nokori)
  


Fixed submission:
str = input()

count1 = str.count('1')
count0 = str.count('0')
print(2 * min(count1, count0))
Buggy python submission (verdict: Runtime Error):
def exchange(btc):
  return 380000.0 / btc

n = int(input())
sum = 0.0
for i in range(n):
  a, b = input().split()
  if "JPY" in b:
    sum += float(a)
  else:
    sum += exchange(int(a))

print(sum)

Fixed submission:
def exchange(btc):
  return 380000.0 * btc
 
n = int(input())
sum = 0.0
for i in range(n):
  a, b = input().split()
  if "JPY" in b:
    sum += float(a)
  else:
    sum += exchange(float(a))
 
print(sum)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split()) #n person, m pieces

counter = []
ans = 0
for i in range(m):
  counter.apeend(0)

for i in range(n):
  ls = [map(int, input().split())]
  for i in range(1, ls[0]+1):
    num = counter[ls[i] - 1]
    counter.insert(ls[i]-1, num + 1)
for i in range(m):
  if counter[i] == n:
    ans += 1
print(ans)



Fixed submission:
n,m = map(int, input().split()) #n person, m pieces
 
counter = []
ans = 0
for i in range(m):
  counter.append(0)
 
for i in range(n):
  ls = list(map(int, input().split()))
  kazu = ls[0]
  for i in range(1, kazu+1):
    num = counter[ls[i] - 1]
    counter[ls[i]-1] = num + 1
for i in range(m):
  if counter[i] == n:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input()) # the num of monster
 
ls = list(map(int, input().split()))
n = len(ls)
ans = math.gcd(ls[0], ls[1])

for i in range(n):
    ans = math.gcd(ans, ls[i])
    
print(ans)

Fixed submission:
n = int(input()) # the num of monster
 
ls = list(map(int, input().split()))
n = len(ls)

def gcd(a,b):
  while b != 0:
    a,b = b, a % b
  return a

ans = gcd(ls[0], ls[1])
 
for i in range(n):
    ans = gcd(ans, ls[i])
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input()) # the num of monster

ls = list(map(int, input().split()))

ls.sort()

for i in range(len(ls)-1):
  if(len(ls)==1):
    print(len[0])
  for j in range(1, len(ls)):
    if(ls[j] % ls[i] == 0):
      ls.remove(ls[j])



Fixed submission:
n = int(input()) # the num of monster
 
ls = list(map(int, input().split()))
n = len(ls)

def gcd(a,b):
  while b != 0:
    a,b = b, a % b
  return a

ans = gcd(ls[0], ls[1])
 
for i in range(n):
    ans = gcd(ans, ls[i])
    
print(ans)
Buggy python submission (verdict: Runtime Error):

# Python 3 program to implement 
# the above approach 
from math import pow
  
# Function to calculate number of characters 
# in corresponding string of 'A' and 'B' 
def no_of_characters(M): 
      
    # Since the minimum number 
    # of characters will be 1 
    k = 1
  
    # Calculating number of characters 
    while (True): 
          
        # Since k length string can 
        # represent at most pow(2, k+1)-2 
        # that is if k = 4, it can 
        # represent at most pow(2, 4+1)-2 = 30 
        # so we have to calculate the 
        # length of the corresponding string 
        if (pow(2, k + 1) - 2 < M): 
            k += 1
        else: 
            break
  
    # return the length of 
    # the corresponding string 
    return k 
  
# Function to print corresponding 
# string of 'A' and 'B' 
def print_string(M): 
      
    # Find length of string 
    k = no_of_characters(M) 
  
    # Since the first number that can be  
    # represented by k length string will  
    # be (pow(2, k)-2)+1 and it will be  
    # AAA...A, k times, therefore, N will  
    # store that how much we have to print 
    N = M - (pow(2, k) - 2) 
  
    # At a particular time, 
    # we have to decide whether 
    # we have to print 'A' or 'B', 
    # this can be check by calculating 
    # the value of pow(2, k - 1) 
    while (k > 0): 
        num = pow(2, k - 1) 
  
        if (num >= N): 
            print("A", end = "") 
        else: 
            print("B", end = "") 
            N -= num 
        k -= 1
          
    print("\n", end = "") 
  

M=input()
print_string(M)

Fixed submission:
n = int(input())
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
s = ''
while n>0:
    n -= 1
    i = n % 26
    s += ascii_lowercase[i]
    n = n // 26
out = s[::-1]
print(out)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(n):
    d[arr[i]]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]*a
    e2=d[b]*b
    sumi=sumi+e2-e1
    print(sumi)
    d[b]=d[b]+d[a]
    d[a]=0
    
    

    

Fixed submission:
n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(10**5+1):
    d[i]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]
    d[b]=d[b]+e1
    sumi=sumi+(e1)*(b-a)
    print(sumi)
    d[a]=0

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
for i in range(k):
    sumi=0
    a,b=[int(a) for a in input().split()]
    for j in range(n):
        if(arr[j]==a):
            arr[j]=b
    for i in range(n):
        sumi=sumi+arr[i]
    print(sumi)    
        
    

Fixed submission:
n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(10**5+1):
    d[i]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]
    d[b]=d[b]+e1
    sumi=sumi+(e1)*(b-a)
    print(sumi)
    d[a]=0
Buggy python submission (verdict: Runtime Error):
n,m=[int(n) for n in input().split()]
if(m>(n*4) or m<(n*2)):
  print("No")
else:
  if(m%2==0):
    print("Yes"):
  else:
    print("No")

Fixed submission:
n,m=[int(n) for n in input().split()]
if(m>(n*4) or m<(n*2)):
  print("No")
else:
  if(m%2==0):
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m=[int(n) for n in input().split()]
arr=list(map(int,input().strip().split()))
if(m==0):
    print(n)
else:
    j=n
    while(j>=1):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j-1
        else:
            s1=j
            break
    j=n
    while(j<101):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j+1
        else:
            s2=j
            break
    a=abs(n-s1)
    b=abs(n-s2)
    if(a<=b):
        print(s1)
    else:
        print(s2)
        

Fixed submission:
x, n = (int(x) for x in input().split())
p_list = list(map(int, input().split()))
 
ans = 0
 
max_ = 0
min_ = 0

for i in range(x, 102, 1) :
 
    if i not in p_list:
        max_ = i
        break
for j in reversed(range(x + 1)) :

 
    if j not in p_list:
        min_ = j
        break
 
if abs (min_ - x) <= abs(max_ - x) :
    ans = min_
else : 
    ans = max_
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().strip().split()))
arr.append(0)
arr.sort()
arr.append(0)
count=0
s=set()
for i in range(1,n+1):
    if(arr[i]==arr[i-1] or arr[i]==arr[i+1]):
        s.add(arr[i])
    else:
        if(len(s)):
            crr=list(s)
            flag=0
            for j in range(len(s)):
                if(arr[i]%crr[j]==0):
                    flag=1
                    break
            if(flag==0):
                count=count+1
            s.add(arr[i])
        else:
            s.add(arr[i])
            count=count+1
print(count)            
                
            
            
        

            
        
    


Fixed submission:
n=int(input())
arr=list(map(int,input().strip().split()))
arr.sort()
maxi=arr[-1]
booll=[True]*(maxi+1)
r=0
for i in range(n-1):
    a=arr[i]
    if(booll[a]==True):
        for j in range(a,maxi+1,a):
            booll[j]=False
        if(a<arr[i+1]):
            r=r+1
if(booll[arr[n-1]]==True):
    r=r+1
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# 約数を求める時間はない！

n = int(input())
ans = 0

for i in range(1, n + 1):
    for j in range(1, n + 1):
        if i % j == 0:
            ans += i
print(ans)

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

# 約数を求める時間はない！

N = int(input())

ans = 0
for i in range(1, N + 1):
    n = N // i
    ans += i * (n * (n + 1)) // 2

print(ans)

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

# 約数を求める時間はない！

n = int(input())
ans = 0

for i in range(1, n + 1):
    for j in range(1, (i // 2) +1):
        if i % j == 0:
            ans += i
    ans += i
print(ans)

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

# 約数を求める時間はない！

N = int(input())

ans = 0
for i in range(1, N + 1):
    n = N // i
    ans += i * (n * (n + 1)) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a, b = map(int, input().split())

if a > (b * 2):
    print(a - (b * 2))
else:
    print(0)

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

n = int(input())

print((n - (n // 2)) / n)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())

if (n / 1000) == 0:
    print('ABC' + n % 1000)
else:
    print('ABD' + (n % 1000) + 1)

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

n = int(input())

if (n // 1000) == 0:
    print('ABC')
else:
    print('ABD')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())

a = []

for i in range(N):
    a.append(int(input()))

ans = 0
b_now = 1
loop = []

if 2 in a:
    for i in range(1, N + 1):
        loop.append(b_now)
        b_now = a[b_now - 1]
        ans += 1
        if b_now == 2:
            print(ans)
            exit()
        elif b_now in loop:
            print(-1)
            exit()
else:
    print(-1)

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

N = int(input())

a = []

for i in range(N):
    a.append(int(input()))

ans = 0
b_now = 1
loop = []

for i in range(N):
    b_now = a[b_now - 1]
    ans += 1
    if b_now == 2:
        print(ans)
        exit()

print(-1)

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

N = int(input())

a = []

for i in range(N):
    a.append(int(input()))

ans = 0
b_now = 1
loop = []

for i in range(1, N + 1):
    loop.append(b_now)
    b_now = a[b_now - 1]
    ans += 1
    if b_now == 2:
        print(ans)
        exit()
    elif b_now in loop:
        print(-1)
        exit()

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

N = int(input())

a = []

for i in range(N):
    a.append(int(input()))

ans = 0
b_now = 1
loop = []

for i in range(N):
    b_now = a[b_now - 1]
    ans += 1
    if b_now == 2:
        print(ans)
        exit()

print(-1)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

for i in range(1, B + 1)
    if (A * i) % B == C:
        print('YES')
        exit()
        
print('NO')

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

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

for i in range(1, B + 1):
    if (A * i) % B == C:
        print('YES')
        exit()

print('NO')
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int,input().split()))
a = Collections.Counter(A)

for i in range(N):
  print(a[i])

Fixed submission:
import collections
 
N = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)
 
for i in range(N):
  print(a[i+1])
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())
lis = list(itertools.product(range(1, K+1), repeat=3))

ans=0
for x, y, z in lis:
    ans += gcd(x, y, z)

print(ans)


Fixed submission:


import itertools
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
lis = list(itertools.combinations_with_replacement(range(1, K+1), 3))

ans=0
for i, j, k in lis:
    if i==j and j==k and i==k:
        ans+=gcd(i, j, k)
    elif i!=j and j!=k and i!=k:
        ans+=6*gcd(i, j, k)
    else:
        ans+=3*gcd(i, j, k)

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

R = [i for i, x in enumerate(S) if x == 'R']
G = [j for j, y in enumerate(S) if y == 'G']
B = [k for k, z in enumerate(S) if z == 'B']

cnt=0
for r in R:
    for g in G:
        for b in B:
            if abs(g-r) != abs(b-g) and \
                abs(b-r) != abs(g-b) and \
                abs(r-b) != abs(g-r):
                cnt+=1

print(cnt)

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

R = [X for X, x in enumerate(S) if x == 'R']
G = [Y for Y, y in enumerate(S) if y == 'G']
B = [Z for Z, z in enumerate(S) if z == 'B']

mae = len(R)*len(G)*len(B)

cnt=0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >=N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(mae-cnt)

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

N = int(input())
S = input()

lis = list(itertools.combinations(range(0, N), 3))

cnt=0
for i, j, k in lis:
    if j-i != k-j:
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(cnt)


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

R = [X for X, x in enumerate(S) if x == 'R']
G = [Y for Y, y in enumerate(S) if y == 'G']
B = [Z for Z, z in enumerate(S) if z == 'B']

mae = len(R)*len(G)*len(B)

cnt=0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >=N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(mae-cnt)

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

N = int(input())
S = input()

lis = list(itertools.combinations(range(0, N), 3))

cnt=0
for i, j, k in lis:
    if j-i != k-j:
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(cnt)


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

R = [X for X, x in enumerate(S) if x == 'R']
G = [Y for Y, y in enumerate(S) if y == 'G']
B = [Z for Z, z in enumerate(S) if z == 'B']

mae = len(R)*len(G)*len(B)

cnt=0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >=N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(mae-cnt)

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

N = int(input())
S = input()

lis = list(itertools.combinations(range(0, N), 3))

cnt=0
for i, j, k in lis:
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        if j-i != k-j:
            cnt+=1

print(cnt)


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

R = [X for X, x in enumerate(S) if x == 'R']
G = [Y for Y, y in enumerate(S) if y == 'G']
B = [Z for Z, z in enumerate(S) if z == 'B']

mae = len(R)*len(G)*len(B)

cnt=0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >=N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(mae-cnt)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
ansli=[]

for i in range(1, 10**9):
    if len(ansli)==K:
        print(ansli[K-1])
        exit()

    if 1<= i <=9:
        ansli.append(i)
        continue

    stri = str(i)
    leni = len(stri)

    for ii in range(leni-1):
        if int(stri[ii]) == int(stri[ii+1])-1 or \
            int(stri[ii]) == int(stri[ii+1]) or \
            int(stri[ii]) == int(stri[ii+1])+1:
            pass

        else:
            break

        if ii==leni-2:
            ansli.append(i)


Fixed submission:
from collections import deque

K = int(input())
d = deque([1,2,3,4,5,6,7,8,9])
ansq = deque([1,2,3,4,5,6,7,8,9])

while len(ansq)<=K:
    num = d.popleft()

    if str(num)[-1] == "0":
        d.append(num*10)
        d.append(num*10+1)
        ansq.append(num*10)
        ansq.append(num*10+1)
        continue

    if str(num)[-1] == "9":
        d.append(num*10+8)
        d.append(num*10+9)
        ansq.append(num*10+8)
        ansq.append(num*10+9)
        continue

    d.append(num*10+int(str(num)[-1])-1)
    d.append(num*10+int(str(num)[-1]))
    d.append(num*10+int(str(num)[-1])+1)
    ansq.append(num*10+int(str(num)[-1])-1)
    ansq.append(num*10+int(str(num)[-1]))
    ansq.append(num*10+int(str(num)[-1])+1)
    
print(ansq[K-1])
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = list(map(int, input().split()))

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

shoku=[]

for i in range(X):
    shoku.append(p[i])

for j in range(Y):
    shoku.append(q[j])

shoku.sort()

r_num=0
for k in range(C):
    if r_num == C:
        break

    if shoku[k] < r[r_num]:
        shoku[k] = r[r_num]
        r_num+=1

print(sum(shoku))


Fixed submission:
X, Y, A, B, C = list(map(int, input().split()))

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

shoku=[]

for i in range(X):
    shoku.append(p[i])

for j in range(Y):
    shoku.append(q[j])

shoku.sort()

r_num=0
for k in range(len(shoku)):
    if r_num == C:
        break

    if shoku[k] < r[r_num]:
        shoku[k] = r[r_num]
        r_num+=1

print(sum(shoku))