Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import time

MOD = 10 ** 9 + 7

K = int(input())
S = input()
l = len(S)

fac = [1] * (K + l + 1)
invfac = [1] * (K + l + 1)
for i in range(1, K + l + 1):
	fac[i] = (fac[i - 1] * i) % MOD
	invfac[i] = pow(fac[i], MOD - 2, MOD)

p25 = [1] * (K + 1)
p26 = [1] * (K + 1)
for i in range(1, K + 1):
	p25[i] = (p25[i - 1] * 25) % MOD
	p26[i] = (p26[i - 1] * 26) % MOD

ans = 0
for en in range(l - 1, l + K):
	t = (fac[en] * invfac[en - l + 1]) % MOD
	t = (t * invfac[l - 1]) % MOD
	t = (t * p25[en - l + 1]) % MOD
	t = (t * p26[l + K - 1 - en]) % MOD
	ans = (ans + t) % MOD
print(ans)

Fixed submission:
MOD = 10 ** 9 + 7

K = int(input())
S = input()
l = len(S)

fac = [1] * (K + l + 1)
for i in range(1, K + l + 1):
	fac[i] = (fac[i - 1] * i) % MOD

p25 = [1] * (K + 1)
p26 = [1] * (K + 1)
for i in range(1, K + 1):
	p25[i] = (p25[i - 1] * 25) % MOD
	p26[i] = (p26[i - 1] * 26) % MOD

ans = 0
for en in range(l - 1, l + K):
	t = (fac[en] * pow(fac[en - l + 1], MOD - 2, MOD) * pow(fac[l - 1], MOD - 2, MOD)) % MOD
	t = (t * p25[en - l + 1]) % MOD
	t = (t * p26[l + K - 1 - en]) % MOD
	ans = (ans + t) % MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    print(min(ans))
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    if len(ans)==0:
        print(0)
    else:
        print(min(ans))
    
if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    p.sort()
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    print(min(ans))
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    X,N=map(int,input().split())
    p=list(map(int,input().split()))
    ans=[]
    for i in range(max(X,100-X)):
        if not X+i in p:
            ans+=[X+i]
        if not X-i in p:
            ans+=[X-i]
        if len(ans)>0:
            break
    if len(ans)==0:
        print(0)
    else:
        print(min(ans))
    
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=list(b)
b=[b[0],b[2],b[3]]
c=a*b[0]+a*b[1]//10+a*b[2]//100
print(c)

Fixed submission:
a,b=map(int,input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
N=int(input())
Nk=N
rootN=int(N**0.5)
p=[1]*(rootN+1)
p[0]=0
p[1]=0
for i in range(2,rootN+1):
    for j in range(i*2,rootN,i):
        p[j]=0
ps=[i for i in range(1,rootN+1) if p[i]==1]
pq=[]
for i in ps:
    d=i
    c=0
    for j in range(1,10):
        if (N/i).is_integer():
            c+=1
            N/=(i)
        else:
            break
        d*=i
    if c!=0:
        pq.append(c)

res=0
for j in pq:
    res+=int(((8*j+1)**0.5-1)/2)


if N > rootN:
    res+=1
if N==Nk:
    res+=1
    
print(res)

Fixed submission:
a,b=map(int,input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))

f=1
c=0
for i in l:
    f*=i
    
if f > 10**18:
    print(-1)
else:
    print(f)

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

f=1
c=0
for i in l:
    f*=i
    if f > 10**18:
        c=1
        break
    
if 0 in l:
    print(0)
elif c==1:
    print(-1)
else:
    print(f)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Fixed submission:
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=(a*b[0]*100+a*b[1]*10+a*b[2])//100
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=list(b)
b=[b[0],b[2],b[3]]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Fixed submission:
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=(a*b[0]*100+a*b[1]*10+a*b[2])//100
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=map(input().split())
a=int(a)
b=list(b)
b=[b[0],b[2],b[3]]
c=a*b[0]+a*b[2]//10+a*b[3]//100
print(c)

Fixed submission:
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=(a*b[0]*100+a*b[1]*10+a*b[2])//100
print(c)

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a0=a//(10**9)
a1=a-a0*10**9
b*=100
print((a0*b*10**9+a1*b)//100)

Fixed submission:
a,b=input().split()
a=int(a)
b=list(b)
b=[int(b[0]),int(b[2]),int(b[3])]
c=(a*b[0]*100+a*b[1]*10+a*b[2])//100
print(c)
Buggy python submission (verdict: Runtime Error):
if N > rootN:
    res*=2

Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    ps=[]
    for i in range(2,int((N**0.5))+1):
        if N%i==0:
            cnt=0
            for j in range(40):
                if N%i==0:
                    N//=i
                    cnt+=1
            ps.append([i,cnt])
    if N!=1:
        ps.append([N,1])
        
    ans=0
    for p in ps:
        ans+=int(((8*p[1]+1)**0.5-1)/2)
    print(ans)
    
    
if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353

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

dp = [[0] * (S + 1) for i in range(N)]
dp[0][0] = 2
if A[0] < S + 1:
	dp[0][A[0]] = 1

for i in range(1, N):
	for j in range(S + 1):
		dp[i][j] = (2 * dp[i - 1][j]) % MOD
		if 0 <= j - A[i] <= S:
			dp[i][j] = (dp[i][j] + dp[i - 1][j - A[i]]) % MOD
print(dp[-1][-1])


Fixed submission:
MOD = 998244353

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

dp = [[0] * (S + 1) for i in range(N)]
dp[0][0] = 2
if A[0] < S + 1:
	dp[0][A[0]] = 1

for i in range(1, N):
	for j in range(S + 1):
		dp[i][j] = (2 * dp[i - 1][j]) % MOD
		if 0 <= j - A[i] <= S:
			dp[i][j] = (dp[i][j] + dp[i - 1][j - A[i]]) % MOD
print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
import cmath
a,b,h,m=map(int, input().split(" "))

print(abs(a*cmath.exp(j*(h+m/60)*cmath.pi/6)-b*cmath.exp(j*m*2*cmath.pi/60)))

Fixed submission:
import cmath
a,b,h,m=map(int, input().split(" "))

print(abs(a*cmath.exp(1j*(h+m/60)*cmath.pi/6)-b*cmath.exp(1j*m*2*cmath.pi/60)))
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split(" "))
l=[]
for i in range(m):
  l.append(list(map(int,input().split(" "))))


d=[n+1 for i in range(n)]
d[0]=0

an,m=map(int, input().split(" "))
l=[]
for i in range(m):
  l.append(list(map(int,input().split(" "))))


d=[n+3 for i in range(n)]
d[0]=0

for i in range(n):
    for j in l:
        if j[0]-1==i:
            d[j[1]-1]=min(d[j[1]-1], d[i]+1)
            l.remove(j)
        elif j[1]-1==i:
            d[j[0]-1]=min(d[j[0]-1],d[i]+1)
            l.remove(j)
            
            
j="Yes"
for i in range(n):
    if d[i]==n+3:
        j="No"
print(j)
for i in range(1,n):
    print(d[i])

Fixed submission:
#

import sys
from collections import deque
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    adj=[[] for i in range(N)]
    for i in range(M):
        A,B=map(int,input().split())
        adj[A-1]+=[B-1]
        adj[B-1]+=[A-1]
    parent=[-1]*N
    qu=deque([0])
    qup=qu.popleft
    qua=qu.append
    parent[0]=0
    while(len(qu)>0):
        v=qup()
        for nv in adj[v]:
            if parent[nv]!=-1:
                continue
            else:
                parent[nv]=v
                qua(nv)
    print("Yes")
    for i in range(1,N):
        print(parent[i]+1)
        
    
    
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import gcd
from bisect import bisect_left, bisect_right

MOD = 10 ** 9 + 7
pow2 = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
	pow2[i] = (pow2[i - 1] * 2) % MOD

N = int(input())

iwasies = []
for i in range(N):
	A, B = map(int, input().split())
	if A == 0 and B == 0:
		continue
	elif A == 0:
		iwasies.append((0, 1))
	elif B == 0:
		iwasies.append((1, 0))
	else:
		g = gcd(A, B)
		A //= g
		B //= g
		if A < 0:
			iwasies.append((-A, -B))
		else:
			iwasies.append((A, B))

iwasies.sort()
badpairs = set()
for i in range(N):
	A, B = iwasies[i]
	abcount = bisect_right(iwasies, (A, B)) - bisect_left(iwasies, (A, B))
	
	Ao, Bo = B, -A
	if Ao < 0:
		Ao, Bo = -Ao, -Bo
	
	aobocount = bisect_right(iwasies, (Ao, Bo)) - bisect_left(iwasies, (Ao, Bo))
	
	if aobocount > 0:
		if (A, B) < (Ao, Bo):
			badpairs.add(((A, B, abcount), (Ao, Bo, aobocount)))
		else:
			badpairs.add(((Ao, Bo, aobocount), (A, B, abcount)))

numiwasi = len(iwasies)
sociable = numiwasi
ans = 1

for bp in badpairs:
	count1 = bp[0][2]
	count2 = bp[1][2]
	sociable -= (count1 + count2)
	ans = (ans * (pow2[count1] + pow2[count2] - 1)) % MOD
ans = (ans * pow2[sociable]) % MOD

print(ans - 1)	

Fixed submission:
from math import gcd
from bisect import bisect_left, bisect_right

MOD = 10 ** 9 + 7
pow2 = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
	pow2[i] = (pow2[i - 1] * 2) % MOD

N = int(input())
zero = 0
iwasies = []
for i in range(N):
	A, B = map(int, input().split())
	if A == 0 and B == 0:
		zero += 1
	elif A == 0:
		iwasies.append((0, 1))
	elif B == 0:
		iwasies.append((1, 0))
	else:
		g = gcd(A, B)
		A //= g
		B //= g
		if A < 0:
			iwasies.append((-A, -B))
		else:
			iwasies.append((A, B))

numiwasi = len(iwasies)
iwasies.sort()
badpairs = set()
for i in range(numiwasi):
	A, B = iwasies[i]
	abcount = bisect_right(iwasies, (A, B)) - bisect_left(iwasies, (A, B))
	
	Ao, Bo = B, -A
	if Ao < 0:
		Ao, Bo = -Ao, -Bo
	
	aobocount = bisect_right(iwasies, (Ao, Bo)) - bisect_left(iwasies, (Ao, Bo))
	
	if aobocount > 0:
		if (A, B) < (Ao, Bo):
			badpairs.add(((A, B, abcount), (Ao, Bo, aobocount)))
		else:
			badpairs.add(((Ao, Bo, aobocount), (A, B, abcount)))

sociable = numiwasi
ans = 1

for bp in badpairs:
	count1 = bp[0][2]
	count2 = bp[1][2]
	sociable -= (count1 + count2)
	ans = (ans * (pow2[count1] + pow2[count2] - 1)) % MOD
ans = (ans * pow2[sociable]) % MOD

print((ans + zero - 1) % MOD)
Buggy python submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]


cmin=12*10**5+1
for bit in range(2**N):
    A=[0]*M
    c=0
    for j in range(N):
        if (bit>>j)&1:
            c+=l[j][0]
            A=[x+y for (x,y) in zip(A, l[j][1:])]
    if min(A) >= X:
        cmin=min(cmin,c)

if cmin!=12*10**5+1:
    print(cmin)
else:
    print(-1)

Fixed submission:
N,M,X=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]


cmin=12*10**5+1
for bit in range(2**N):
    A=[0]*M
    c=0
    for j in range(N):
        if (bit>>j)&1:
            c+=l[j][0]
            A=[x+y for (x,y) in zip(A, l[j][1:])]
    if min(A) >= X:
        cmin=min(cmin,c)

if cmin!=12*10**5+1:
    print(cmin)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split(" "))
for i in range(n):
  A[i]=list(map(int,input().split(" ")))

minprice=[-1]
for i in range(m):
  for j in range(n):
    maxi = j
    for k in range(j,n):
      if A[maxi][i] < A[k][i]:
        maxi = k
    temp = A[maxi][i]
    A[maxi][i] = A[j][i]
    A[j][i] = temp
  x_m=0
  p_m
  for j in range(n):
    if x_m < x:
      x_m += A[j][i]
      p_m += A[j][0]
  minprice.append(p_m)
  
print(min(minprice))

Fixed submission:
N,M,X=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]


cmin=12*10**5+1
for bit in range(2**N):
    A=[0]*M
    c=0
    for j in range(N):
        if (bit>>j)&1:
            c+=l[j][0]
            A=[x+y for (x,y) in zip(A, l[j][1:])]
    if min(A) >= X:
        cmin=min(cmin,c)

if cmin!=12*10**5+1:
    print(cmin)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lremain = []
rremain = []

for i in range(N):
	S = input()
	left = 0
	right = 0
	for c in S:
		if c == ".":
			left += 1
		else:
			if left == 0:
				right += 1
			else:
				left -= 1
	if left == 0 and right == 0:
		continue
	lremain.append(left)
	rremain.append(right)

N = len(lremain)

if sum(lremain) != sum(rremain):
	print("No")
	exit()

head = 0
tail = 0
removei = []
for i in range(N):
	if rremain[i] == 0:
		head += lremain[i]
		removei.append(i)
	if lremain[i] == 0:
		tail += rremain[i]
		removei.append(i)

lnr = []
for i in range(N):
	if not i in removei:
		lnr.append((lremain[i], rremain[i]))

N = len(lnr)
lnr.sort(key = lambda x: (x[1], -x[0]))

for i in range(N):
	if head < lnr[i][1]:
		print("No")
		exit()
	head -= lnr[i][1]
	head += lnr[i][0]

if head == tail:
	print("Yes")
else:
	print("No")
	
	
23, 31, 41, 43 wa
1, 2, 3, 4, tle

Fixed submission:
N = int(input())
lremain = []
rremain = []

for i in range(N):
	S = input()
	left = 0
	right = 0
	for c in S:
		if c == "(":
			left += 1
		else:
			if left == 0:
				right += 1
			else:
				left -= 1
	if left == 0 and right == 0:
		continue
	lremain.append(left)
	rremain.append(right)

N = len(lremain)

if sum(lremain) != sum(rremain):
	print("No")
	exit()

head = 0
tail = 0
removei = set()
for i in range(N):
	if rremain[i] == 0:
		head += lremain[i]
		removei.add(i)
	if lremain[i] == 0:
		tail += rremain[i]
		removei.add(i)

lnr = []
for i in range(N):
	if not i in removei:
		lnr.append((lremain[i], rremain[i]))

N = len(lnr)
lnr.sort(key = lambda x: (x[1]-x[0]))

for i in range(N):
	if head < lnr[i][1]:
		print("No")
		exit()
	head -= lnr[i][1]
	head += lnr[i][0]

if head == tail:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split(" ")))
c=0
for i in range(n):
  if l[i]>n-1-i:
    continue
  for j in range(i+1,n):
    if l[i]+l[j]==j-i:
      c+=1
      
print(c)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()

ans = 0
for i in range(N):
	ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split(" ")))
c=0
for i in range(n):
  for j in range(i+1,n):
    if l[i]+l[j]==j-i:
      c+=1
      
print(c)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()

ans = 0
for i in range(N):
	ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split(" ")))
c=0
for i in range(n):
  for j in range(i+1,n):
    if l[i]+l[j]=j-i:
      c+=1
      
print(c)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())

A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()

ans = 0
for i in range(N):
	ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
from collections import deque
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))
adj = [[] for i in range(N)]
for i in range(N - 1):
	u, v = map(int, input().split())
	adj[u - 1].append(v - 1)
	adj[v - 1].append(u - 1)


INF = 10 ** 10
done = [False] * N
done[0] = True
lisdp = [INF] * N
lisdp[0] = A[0]
change = [[-1, INF] for i in range(N)] #index, original
change[0] = [0, INF]
lisl = [0] * N
lisl[0] = 1

def dfs(v):
	for nv in adj[v]:
		if done[nv]:
			continue
		done[nv] = True
		ind = bisect_left(lisdp, A[nv])
		ori = lisdp[ind]
		change[nv] = [ind, ori]
		if ori == INF:
			lisl[nv] = lisl[v] + 1
		else:
			lisl[nv] = lisl[v]
		lisdp[ind] = A[nv]
		dfs(nv)
	lisdp[change[v][0]] = change[v][1]

dfs(0)
for i in range(N):
	print(lisl[i])	

Fixed submission:
import sys
sys.setrecursionlimit(200000)
from collections import deque
from bisect import bisect_left

N = int(input())
A = list(map(int, input().split()))
adj = [[] for i in range(N)]
for i in range(N - 1):
	u, v = map(int, input().split())
	adj[u - 1].append(v - 1)
	adj[v - 1].append(u - 1)


INF = 10 ** 10
done = [False] * N
done[0] = True
lisdp = [INF] * N
lisdp[0] = A[0]
change = [[-1, INF] for i in range(N)] #index, original
change[0] = [0, INF]
lisl = [0] * N
lisl[0] = 1

def dfs(v):
	for nv in adj[v]:
		if done[nv]:
			continue
		done[nv] = True
		ind = bisect_left(lisdp, A[nv])
		ori = lisdp[ind]
		change[nv] = [ind, ori]
		if ori == INF:
			lisl[nv] = lisl[v] + 1
		else:
			lisl[nv] = lisl[v]
		lisdp[ind] = A[nv]
		dfs(nv)
	lisdp[change[v][0]] = change[v][1]

dfs(0)
for i in range(N):
	print(lisl[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split(" ")))
for i in range(1,n+1):
    c=0
    for j in range(len(l)):
        if l[j]==i:
            l[j]=0
            c+=1
    print(c)
    for j in range(c):
        l.remove(0)

Fixed submission:
n=int(input())
l=list(map(int,input().split(" ")))
s=[0]*n
for i in range(len(l)):
    s[l.pop()-1]+=1
    
for i in range(n):
    print(s[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split(" ")))
for i in range(1,n+1):
  print(l.count(i))

Fixed submission:
n=int(input())
l=list(map(int,input().split(" ")))
s=[0]*n
for i in range(len(l)):
    s[l.pop()-1]+=1
    
for i in range(n):
    print(s[i])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)

cnt0=len(B)
cnt=0
for i in R:
    for j in G:
        cnt+=cnt0
        koho=set()
        if (j+i)%2==0:
            koho.add((j+i)//2)
        if 0<=2*i-j<N:
            koho.add(2*i-j)
        if 0<=2*j-i<N:
            koho.add(2*j-i)
        for k in koho:
            if k in B:
                cnt-=1
            
                
print(cnt)

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

R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)

cnt=len(R)*len(G)*len(B)
for i in R:
    for j in G:
        koho=set()
        if (j+i)%2==0:
            koho.add((j+i)//2)
        if 0<=2*i-j<N:
            koho.add(2*i-j)
        if 0<=2*j-i<N:
            koho.add(2*j-i)
        for k in koho:
            if k in B:
                cnt-=1
            
                
print(cnt)

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

R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)
    
cnt=0
for i in R:
    for j in G:
        for k in B:
            mini=min(i,j,k)
            maxi=max(i,j,k)
            if i != mini and i !=maxi:
                mid=i
            if j != mini and j !=maxi:
                mid=j
            if k != mini and k !=maxi:
                mid=k
            if maxi-mid!=mid-mini:
                cnt+=1
                
print(cnt)

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

R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)

cnt=len(R)*len(G)*len(B)
for i in R:
    for j in G:
        koho=set()
        if (j+i)%2==0:
            koho.add((j+i)//2)
        if 0<=2*i-j<N:
            koho.add(2*i-j)
        if 0<=2*j-i<N:
            koho.add(2*j-i)
        for k in koho:
            if k in B:
                cnt-=1
            
                
print(cnt)
Buggy python submission (verdict: Runtime Error):
#

import sys
input=sys.stdin.readline

def main():
    x,y,z=map(int.input().split())
    print(z,x,y)
    
    
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    x,y,z=map(int,input().split())
    print(z,x,y)
    
    
    
if __name__=="__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import ceil
H,W=map(int,input().split())

if H==1 and W==1:
  print(1)
else:
  print(int(ceil(h*w/2)))


Fixed submission:
import math
H, W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(int(math.ceil(H*W/2)))

Buggy python submission (verdict: Runtime Error):
import decimal
H,W=input().split()
h=decimal.Decimal(H)
w=decimal.Decimal(W)

if h%2==0 or W%2==0:
  print(h*w/2)
else:
  print(h*w/2+1)

Fixed submission:
import math
H, W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(int(math.ceil(H*W/2)))

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
print(H*int(ceil(W/2)))

Fixed submission:
import math
H, W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(int(math.ceil(H*W/2)))

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input())
cnt=0
for i in range(H):
    for j in range(W):
        if i+j % 2 ==0:
            cnt+=1
print(cnt)

Fixed submission:
import math
H, W = map(int,input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(int(math.ceil(H*W/2)))
Buggy python submission (verdict: Runtime Error):
A=[list(map(int,input().split())) for i in range(3)]
AB=[[0 for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
    x=input()
    for j in range(3):
        for k in range(3):
            if A[i][j]==x:
                AB[i][j]=1
c=1
for i in range(3):
    if A[i][0]*A[i][1]*A[i][2]==1:
        c=0
        print("Yes")
        break
    if A[0][i]*A[1][i]*A[2][i]==1:
        c=0
        print("Yes")
        break
    if A[0][0]*A[1][1]*A[2][2]==1:
        c=0
        print("Yes")
        break
    if A[0][2]*A[1][1]*A[2][0]==1:
        c=0
        print("Yes")
        
if c==1:
    print("No")

Fixed submission:
A=[list(map(int,input().split())) for i in range(3)]
AB=[[0 for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
    x=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==x:
                AB[j][k]=1
c=1
for i in range(3):
    if AB[i][0]*AB[i][1]*AB[i][2]==1:
        c=0
        break
    if AB[0][i]*AB[1][i]*AB[2][i]==1:
        c=0
        break
    if AB[0][0]*AB[1][1]*AB[2][2]==1:
        c=0
        break
    if AB[0][2]*AB[1][1]*AB[2][0]==1:
        c=0
        break
        

if c==1:
    print("No")
else:
  	print("Yes")