Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split(' ')))

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

def list_gcd(numbers):
    tmp=numbers[0]
    for i in range(len(numbers)-1):
        tmp=min(tmp,myGCD(numbers[i],numbers[i+1]))
    return(tmp)

#print(list_gcd(A))

candidate=[0,0]
t1 = A[0]
candidate[0]=max(A[0],A[1])
candidate[1]=myGCD(A[0],A[1])
candidate[2]=myGCD(A[0],A[1])

for i in range(2,N):
    candidate[0]=myGCD(candidate[0],A[i])
    candidate[1]=candidate[1]
    candidate[2]=myGCD(candidate[2],A[i])
    candidate[0]=min(candidate[0],candidate[1])

#print(min(candidate))

print(max(candidate))

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

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

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))

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

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

def list_gcd(numbers):
    tmp=numbers[0]
    for i in range(len(numbers)-1):
        tmp=min(tmp,math.gcd(numbers[i],numbers[i+1]))
    return(tmp)

maxgcd = 0
for i in range(N):
    Atmp=A[0:i]
    if i < N-1:
        Atmp.extend(A[i+1:N])
    #print(Atmp)
    tmpgcd=list_gcd(Atmp)
    #print(tmpgcd)
    if tmpgcd > maxgcd:
        maxgcd = tmpgcd

print(maxgcd)

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

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

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

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

maxgcd = 0
for i in range(N):
    Atmp=A[0:i]
    if i < N-1:
        Atmp.extend(A[i+1:N])
    #print(Atmp)
    tmpgcd=list_gcd(Atmp)
    #print(tmpgcd)
    if tmpgcd > maxgcd:
        maxgcd = tmpgcd

print(maxgcd)

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

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

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()) )

B=sorted(A)
#print(B[N-1]-B[0] + B[N-1]-B[0])
hN=int(N/2)
cnt=0
C=[]
if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[N-1-i])
        C.append(B[i])
    C.append(B[hN+1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[N-1-i])
        C.append(B[i])

#print(C)

for i in range(1,N):
    cnt+=abs(C[i]-C[i-1])

C=[]
cnt2=0
if N %2 == 0:
    C.append(B[hN-1])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])
    C.append(B[hN+1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])

#print(C)
for i in range(1,N):
    cnt2+=abs(C[i]-C[i-1])

print(max(cnt,cnt2))

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

B=sorted(A)
#print(B[N-1]-B[0] + B[N-1]-B[0])
hN=int(N/2)
cnt=0
C=[]
if N ==2:
    print(B[1]-B[0])
    exit()

if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[N-1-i])
        C.append(B[i])
    C.append(B[hN-1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[N-1-i])
        C.append(B[i])

#print(C)

for i in range(1,N):
    cnt+=abs(C[i]-C[i-1])

C=[]
cnt2=0
if N %2 == 0:
    C.append(B[hN])
    for i in range(hN-1):
        C.append(B[i])
        C.append(B[N-1-i])
    C.append(B[hN-1])
else:
    C.append(B[hN])
    for i in range(hN):
        C.append(B[i])
        C.append(B[N-1-i])

#print(C)
for i in range(1,N):
    cnt2+=abs(C[i]-C[i-1])

print(max(cnt,cnt2))
Buggy python submission (verdict: Time Limit Exceeded):
debug = True

def main():
    N = int(input())
    S = list(input())

    minCnt=N

    for i in range(N):
        if i==0:
            minCnt=min(minCnt,S[1:].count('E'))
        elif i == N-1:
            minCnt=min(minCnt,S[:N-2].count('W'))
        else:
            minCnt=min(minCnt,S[:i-1].count('W')+S[i+1:].count('E'))

    print(minCnt)
    return

if __name__ == "__main__":
    main()



Fixed submission:
debug = False

def main():
    N = int(input())
    S = list(input())

    tmpCnt=S.count('E')
    if S[0]=='E':
        tmpCnt-=1

    minCnt=tmpCnt

    for i in range(1,N):
        if S[i]=='E':
            tmpCnt-=1
        if S[i-1]=='W':
            tmpCnt+=1
        minCnt=min(minCnt,tmpCnt)
        if debug:
            print(i,S[i],tmpCnt,minCnt)
        
    print(minCnt)
    return

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==1 or len(ss)==2:
    ans = maxs
elif max(ss[1:len(ss)-2]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、隣の長いほうも入る。
# 但し、とろうとしている長いのが端なら、短いほうしか入れられない。
else:
    tmpmax = 0
    print(ss)
    for i in range(1,len(ss)-1 ):
        if ss[i] == maxs:
            if i == 1:
                if ss[0] > ss[2]:
                    tmp = maxs + ss[2] 
                else:
                    tmp = maxs + ss[0]
            elif i == len(ss)-2:
                if ss[len(ss)-1] > ss[len(ss)-3]:
                    tmp = maxs + ss[len(ss)-3]
                else:
                    tmp = maxs + ss[len(ss)-1]
            else:
                tmp= maxs+max(ss[i-1],ss[i+1])

            if tmp > tmpmax:
                tmpmax = tmp
        else:
            pass

    ans = tmpmax

print(ans)


Fixed submission:
import math

s = input()
minpos = len(s)

for i in range(1,len(s)):
    if s[i] != s[i-1]:
        pos = max(i,len(s)-i)

        if pos < minpos:
            minpos = pos

print(minpos)

Buggy python submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==2:
    ans = maxs
elif max(ss[1:len(ss)-1]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、隣の長いほうも入る。
else:
    tmpmax = 0
    for i in range(1,len(ss)-2 ):
        if ss[i] == maxs:
           tmp= maxs+max(ss[i-1],ss[i+1])
           if tmp > tmpmax:
               tmpmax = tmp
        else:
            pass

    ans = tmpmax

print(ans)


Fixed submission:
import math

s = input()
minpos = len(s)

for i in range(1,len(s)):
    if s[i] != s[i-1]:
        pos = max(i,len(s)-i)

        if pos < minpos:
            minpos = pos

print(minpos)

Buggy python submission (verdict: Runtime Error):
s = input()
ss = []

key = s[0]
cnt = 1
for i in range(1,len(s)):
    if key == s[i]:
        cnt += 1
    else:
        ss.append(cnt)
        key = s[i]
        cnt = 1

ss.append(cnt)

ans = 0
maxs = max(ss)
#print(ss)
# 端かどうかの判定。端ならそのまま。
if len(ss)==2:
    ans = maxs
elif max(ss[1:len(s)-1]) < maxs and ss[0] != ss[len(ss)-1]:
    ans = maxs
# 端じゃないなら、短いほうも入る
else:
    ans = maxs + min(ss[0],ss[len(ss)-1])

print(ans)


Fixed submission:
import math

s = input()
minpos = len(s)

for i in range(1,len(s)):
    if s[i] != s[i-1]:
        pos = max(i,len(s)-i)

        if pos < minpos:
            minpos = pos

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

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in prey:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")



Fixed submission:
import math

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

a = A1[0]*1.0
b = A1[1]*1.0

print(math.ceil( ( a + b ) / 2 ))
Buggy python submission (verdict: Time Limit Exceeded):
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(1,const):
    for n in range(h,const):
        tmp=4*h*n-N*n-N*h
        if tmp != 0:
            w = N*h*n/tmp
            if w == int(w) and w>0:
                print(h,n,int(w) )
                flg=True
                break
    if flg==True:
        break



Fixed submission:
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(int(N/4),const):
    for n in range(h,const):
        tmp=4*h*n-N*n-N*h
        if tmp != 0:
            w = N*h*n/tmp
            if w == int(w) and w>0:
                print(h,n,int(w) )
                flg=True
                break
    if flg==True:
        break
Buggy python submission (verdict: Runtime Error):
import math

N, K = map(int,input().split(' '))
A = list(map(int,input().split(' ')))

A.sort()
A.reverse()

t=A[0]
for i in range(1,N):
    t=math.gcd(t,A[i])

if K > A[0]:
    print("IMPOSSIBLE")
else:
    if K%t==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    

Fixed submission:
import math

N, K = map(int,input().split(' '))
A = list(map(int,input().split(' ')))

A.sort()
A.reverse()

t=A[0]

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

for i in range(1,N):
    t=myGCD(t,A[i])

if K > A[0]:
    print("IMPOSSIBLE")
else:
    if K%t==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
print(min(n*a, b))

Fixed submission:
n, a, b = map(int, input().split())
print(min(n*a, b))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
ans = []

for i in range(1, N+1):
  ans.append((A*i)//B-A*(i//B))    
  
print(max(ans))

Fixed submission:
A, B, N = map(int, input().split())
i = min(B-1, N)

print((A*i)//B-A*(i//B))
Buggy python submission (verdict: Runtime Error):
A = list(int(input()))

if A[0] == 7 or A[1] == 7 or A[2] == 7:
  print('Yes')
  
else:
  print('No')

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

if A[0] == 7 or A[1] == 7 or A[2] == 7:
  print('Yes')

else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = 0

for i in range(N-3):
  for j in range(i+1, N-1):
    if S[i] != S[j]:
      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:
N = int(input())
S = input()
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(i+1, N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)

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

for i in range(N-3):
  for j in range(i+1, N-1):
    if S[i] != S[j]:
      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:
N = int(input())
S = input()
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(i+1, N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

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

if A > N:
  print(N)
  
if A < N and A+B > N:
  print(A)
  
else:
  while len(list) <= N:
    i = 0
    for i in range(A):
      list.append('b')
      
    if len(list) <= N:
      i = 0
      for i in range(B):
        list.append('r')

  for i in range(N):
    if list[i] == 'b':
      count += 1
  print(count)
  

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

a = N // (A+B)

if N % (A+B) >= A:
  print(a*A+A)
  
else:
  print(a*A + N % (A+B))

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

if A > N:
  print(N)
  
else:
  while len(list) <= N:
    i = 0
    for i in range(A):
      list.append('b')
      
    if len(list) <= N:
      i = 0
      for i in range(B):
        list.append('r')

  for i in range(N):
    if list[i] == 'b':
      count += 1
  print(count)

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

a = N // (A+B)

if N % (A+B) >= A:
  print(a*A+A)
  
else:
  print(a*A + N % (A+B))

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

while len(list) <= N:
  i = 0
  for i in range(A):
    list.append('b')
  
  if len(list) <= N:
    i = 0
    for i in range(B):
      list.append('r')
    
for i in range(N):
  if list[i] == 'b':
    count += 1
    
print(count)
  

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

a = N // (A+B)

if N % (A+B) >= A:
  print(a*A+A)
  
else:
  print(a*A + N % (A+B))

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

while len(list) <= N:
  i = 0
  for i in range(A):
    list.append('b')
  
  i = 0
  for i in range(B):
    list.append('r')
    
for i in range(N):
  if list[i] == 'b':
    count += 1
    
print(count)
  

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

a = N // (A+B)

if N % (A+B) >= A:
  print(a*A+A)
  
else:
  print(a*A + N % (A+B))
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
i = 0
while S[i] <= X:
  if S[i]<= X:
    c += 1
    i += 1

    
print(c)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
j = 0
while j <= N:
  if S[j]<= X:
    c += 1
    j += 1
  
  else:
    j += 1

    
print(c)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
i = 0
while S[i] <= X:
  if S[i]<= X:
    c += 1
    i += 1
  else:
    print(c)
    
print(c)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
j = 0
while j <= N:
  if S[j]<= X:
    c += 1
    j += 1
  
  else:
    j += 1

    
print(c)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]

i = 0
while i <= N:
  S.append(S[i-1]+L[i])
  i += 1
  
print(S)
  

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
S = [0]
c = 0

i = 0
while i <= N-1:
  S.append(S[i]+L[i])
  i += 1
  
j = 0
while j <= N:
  if S[j]<= X:
    c += 1
    j += 1
  
  else:
    j += 1

    
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(1, N):
  for j in range(1, min(K+1, i+1)):
    dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

print(dp[N-1])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf') for i in range(N)]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(1, N):
  for j in range(1, min(K+1, i+1)):
    dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
m = 1
ans = 0
 
for i in range(N):
  m *= a[i]
  
  
while m % 2 == 0:
  m /= 2
  ans += 1
    
print(ans)

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

for i in range(N):
  while a[i] % 2 == 0:
    a[i] /= 2
    ans += 1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N[-1]==3:
  print('bon')
elif N[-1] in [0, 1, 6, 8]:
  print('pon')
else:
  print('hon')

Fixed submission:
N = str(input())

if int(N[-1])==3:
  print('bon')
elif int(N[-1]) in [0, 1, 6, 8]:
  print('pon')
else:
  print('hon')
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
A = int(X/2)
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))


Fixed submission:
X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
A = int(pow(X, 0.5))
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))


Fixed submission:
X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
A = int(pow(X, 0.2))
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))


Fixed submission:
X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
A = 0
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))

Fixed submission:
X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
# S = [s for s in S]
cnt = 0

# def my_index_multi(l, x):
#     return [i for i, _x in enumerate(l) if _x == x]
# R = my_index_multi(S, 'R')
# G = my_index_multi(S, 'G')
# B = my_index_multi(S, 'B')
R = []
G = []
B = []
for i, s in enumerate(S):
    if s=='R':
        R.append(i)
    elif s=='G':
        G.append(i)
    else:
        B.append(i)

for r in R:
    for g in G:
        for b in B:
            l = [r, g, b]
            l.sort()
            if (l[1]-l[0])!=(l[2]-l[1]):
                cnt += 1
print(cnt)


Fixed submission:
N = int(input())
S = input()
ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
    for j in range(i+1, N):
        if S[i]!=S[j]:
            k = 2*j-i
            if k < N and S[i]!=S[k] and S[j]!=S[k]:
                ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
S = [s for s in S]
cnt = 0

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
R = my_index_multi(S, 'R')
G = my_index_multi(S, 'G')
B = my_index_multi(S, 'B')
for r in R:
    for g in G:
        for b in B:
            l = [r, g, b]
            l.sort()
            if (l[1]-l[0])!=(l[2]-l[1]):
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
    for j in range(i+1, N):
        if S[i]!=S[j]:
            k = 2*j-i
            if k < N and S[i]!=S[k] and S[j]!=S[k]:
                ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
root_ab = int(math.sqrt(a)) + int(math.sqrt(b))
root_c = int(math.sqrt(c))
if root_ab < root_c:
  print('Yes')
else:
  print('No')


Fixed submission:
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])

Buggy python submission (verdict: Runtime Error):
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[int(input())])

Fixed submission:
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])

Buggy python submission (verdict: Runtime Error):
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[input()])

Fixed submission:
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

if N >= AB:
    iters, div = divmod(N, (A +B))
    print((A*iters + div))
else:
    print(A)

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

if N >= AB:
    iters, div = divmod(N, AB)
    if div <= A:
        print((A*iters + div))
    else:
        print((A*(iters + 1)))
elif N >= A:
    print(A)
else:
    print(N)

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

blue = [1 for _ in range(A)]
red = [0 for _ in range(B)]
tkhs = []
while len(tkhs) < N:
    tkhs += (blue + red)
print(sum(tkhs[: N]))

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

if N >= AB:
    iters, div = divmod(N, AB)
    if div <= A:
        print((A*iters + div))
    else:
        print((A*(iters + 1)))
elif N >= A:
    print(A)
else:
    print(N)
Buggy python submission (verdict: Runtime Error):
from collections import deque

S = input()
Q = int(input())
head = 1
d = deque([S])

for _ in range(Q):
    q = input().split()
    if q[0]=='1':
        head = head*-1
    else:
        if q[1]=='1':
            h = head*1
        else:
            h = head*-1
        
        if h==1:
            d.appendleft(q[2])
        else:
            d.append(q[2])
if head == -1:
    d.reverse()

print("".join(list(d)))

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

flg = False
for price in range(1,1010):
    if int(price*0.08)==A and int(price*0.1)==B:
        flg = True
        break

if flg:
    print(price)
else:
    print(-1)