Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
l_n = list(input())
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + 1 if l_n[i] == "A" and l_n[i+1] == "C" else l_a[i]
for i in range(M):
    l,r = list(map(int,input().split()))
    print(l_a[r-1]-l_a[l-1])

Fixed submission:
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
l_n = list(input())
for i in range(N-1):
    if l_n[i] == "A" and l_n[i+1] == "C":
        l_n[i] = "a"
for i in range(M):
    B = list(map(int,input().split()))
    C = l_n[B[0]-1:B[1]-1].count("a")
    print(C)

Fixed submission:
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
A,B = list(map(int,input().split()))
C = input()
for i in range(B):
    M,R = list(map(int,input().split()))
    print(C[M-1:R].count("AC"))

Fixed submission:
N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])
Buggy python submission (verdict: Runtime Error):
3 2
2 1

Fixed submission:
H,W=list(map(int,input().split()))
h,w=list(map(int,input().split()))
print(H*W-h*W-w*H+h*w)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
dp=[0]*(N+1)
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Fixed submission:
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
dict={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]*(N+1)
for j in l:
   nu,val=j,dict[j]
   dp[val]=max(dp[val],int(nu))
for i in range(N):
   if dp[i]!=0:
      for j in l:
         nu,val=j,dict[j]
         if i+val<=N:
            dp[i+val]=max(dp[i+val],int(str(dp[i])+str(nu)))
print(dp[N])

Fixed submission:
N,M=map(int,input().split())
l=list(map(int,input().split()))
w=[2,5,5,4,5,6,3,7,6]
l.sort()
dp=[0]*(max(N+1,8))
for j in l:
   dp[w[j-1]]=j
for i in range(N):
   if dp[i]!=0:
      for j in l:
         if w[j-1]+i<=N:
            dp[i+w[j-1]]=max(dp[i+w[j-1]],dp[i]*10+j)
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N,A = list(map(int,input().split()))
listA = list(map(int,input().split()))
listA.sort()
listB = []
ans = 0
if N >= len(listA):
    print(0)
    exit()
for i in range(A-1):
    listB.append(listA[i+1]-listA[i])
ans = sum(listB)
for i in range(N-1):
    M = max(listB)
    ans -= M
    listB.remove(M)
print(ans)

Fixed submission:
N,A = list(map(int,input().split()))
listA = list(map(int,input().split()))
listB = []
if N >= len(listA):
    print(0)
    exit()
listA.sort()
max_n = listA[-1] - listA[0]
for i in range(A-1):
    listB.append(listA[i+1]-listA[i])
listB.sort(reverse=True)
max_n -= sum(listB[:N-1])
print(max_n)

Buggy python submission (verdict: Time Limit Exceeded):
N,A = list(map(int,input().split()))
listA = list(map(int,input().split()))
listA.sort()
listB = []
if N >= len(listA):
    print(0)
    exit()
for i in range(A-1):
    listB.append(listA[i+1]-listA[i])
for i in range(N-1):
    listB.remove(max(listB))
print(sum(listB))

Fixed submission:
N,A = list(map(int,input().split()))
listA = list(map(int,input().split()))
listB = []
if N >= len(listA):
    print(0)
    exit()
listA.sort()
max_n = listA[-1] - listA[0]
for i in range(A-1):
    listB.append(listA[i+1]-listA[i])
listB.sort(reverse=True)
max_n -= sum(listB[:N-1])
print(max_n)
Buggy python submission (verdict: Runtime Error):
N,M=list(map(int,input().split()))
import sys
l=[list(map(int,_.rstrip().split())) for _ in sys.stdin.readlines()]
n=sorted(l,key=lambda x:x[1])
dic={}
mem=[0]*M
for i,j in n:
   mem[i-1]+=1
   dic[i,j]=str(i).zfill(6)+str(mem[i-1]).zfill(6)
for i,j in l:
   print(dic[i,j])

Fixed submission:
N,M=list(map(int,input().split()))
import sys
l=[list(map(int,_.rstrip().split())) for _ in sys.stdin.readlines()]
n=sorted(l,key=lambda x:x[1])
dic={}
mem=[0]*N
for i,j in n:
   mem[i-1]+=1
   dic[i,j]=str(i).zfill(6)+str(mem[i-1]).zfill(6)
for i,j in l:
   print(dic[i,j])
Buggy python submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
	B = A - 1 + B
print(str(B))

Fixed submission:
I = int(input())
B = 0
count = 0
A = list(map(int,input().split()))
for i in range(I):
    B += A[count] - 1
    count += 1
print(str(B))

Buggy python submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(str(B))

Fixed submission:
I = int(input())
B = 0
count = 0
A = list(map(int,input().split()))
for i in range(I):
    B += A[count] - 1
    count += 1
print(str(B))

Buggy python submission (verdict: Runtime Error):
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(B)

Fixed submission:
I = int(input())
B = 0
count = 0
A = list(map(int,input().split()))
for i in range(I):
    B += A[count] - 1
    count += 1
print(str(B))
Buggy python submission (verdict: Runtime Error):
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   l=[chr(ord('a') + i) for i in range(26)]
   A=A[::-1]
   for i in range(1,26):
      if A[i-1] < A[i]:
         pass
      else:
         if A[i-1] == "z":
            S=l[-1*i:]
            S.sort()
            A=A[::-1]
            print(A[:-1*i-1]+S[0])
            exit()
         else:
            A[i-1],A[i]=A[i],A[i-1]
            print(A[::-1])
            exit()

Fixed submission:
A=input()
l=set(chr(ord('a') + i) for i in range(26))
l2=list(l-set(A))
l2.sort()
if len(A)!=26:
   print(A+l2[0])
else:
   for i in reversed(range(25)):
      for j in reversed(range(i+1,26)):
         if A[i] < A[j]:
            print(A[:i]+A[j])
            exit()
   else:
      print(-1)
Buggy python submission (verdict: Runtime Error):
A= input()
length=len(A)
B = "9" * (length-1)
A=int(A)
C=A-int(B)
B=str(int(C/10**(length-1)))+B
B=int(B)
B=list(str(B))
B=list(map(int,B))
print(sum(B))

Fixed submission:
A= input()
if len(A)== 1:
	print(A)
	exit()
length=len(A)
B = "9" * (length-1)
A=int(A)
C=A-int(B)
B=str(int(C/10**(length-1)))+B
B=int(B)
B=list(str(B))
B=list(map(int,B))
print(sum(B))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A= list(map(int,input().split()))
l=[0]*N
for i in range(N):
   if A[i] == i+1:
      l[i]=1
ans=0
for i in range(N):
   if l[i] == 1:
      if l[i+1] == 1:
         l[i+1]=0
         ans+=1
      else:
         ans+=1
print(ans)

Fixed submission:
N=int(input())
A= list(map(int,input().split()))
l=[0]*N
for i in range(N):
   if A[i] == i+1:
      l[i]=1
ans=0
for i in range(N):
   if l[i] == 1:
      try:
         if l[i+1] == 1:
            l[i+1]=0
            ans+=1
         else:
            ans+=1
      except IndexError:
         ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
A=int(input())
n_l=list(map(int,input().split()))
n_l.sort()
n_l_s=deque()
for i in range(A-1):
   n_l_s.append(n_l[i+1]-n_l[i])
ans=1
n_l_s=list(n_l_s)
for i in range(A-1):
   c=0
   n=0
   for j in range(i,A-1):
      c+=n_l_s[j]
      if c < 3:
         n+=1
      else:
         ans=max(ans,n+1)
         break
print(ans)

Fixed submission:
A=int(input())
n_l=list(map(int,input().split()))
import collections
ans=0
n_l=collections.Counter(n_l)
for i in range(0,100001):
   ans=max(ans,n_l[i]+n_l[i+1]+n_l[i+2])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A=int(input())
n_l=list(map(int,input().split()))
n_l.sort()
n_l_s=[]
for i in range(A-1):
   n_l_s.append(n_l[i+1]-n_l[i])
ans=1
for i in range(A-1):
   c=0
   n=0
   for j in range(i,A-1):
      c+=n_l_s[j]
      if c < 3:
         n+=1
      else:
         ans=max(ans,n+1)
         break
print(ans)

Fixed submission:
A=int(input())
n_l=list(map(int,input().split()))
import collections
ans=0
n_l=collections.Counter(n_l)
for i in range(0,100001):
   ans=max(ans,n_l[i]+n_l[i+1]+n_l[i+2])
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A = int(input())
ans = int(input())
for i in range(A-1):
    B = int(input())
    ans = B * ans // math.gcd(ans,B)
print(ans)

Fixed submission:
import fractions
A = int(input())
ans = int(input())
for i in range(A-1):
    B = int(input())
    ans = B * ans // fractions.gcd(ans,B)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=list(map(int,input().split()))
import math
A=math.gcd(l[0],l[1])
if K<=max(l):
   for i in range(max(0,N-2)):
      A=math.gcd(A,l[i+2])
   if K%A==0:
      print("POSSIBLE")
   else:
      print("IMPOSSIBLE")
else:
   print("IMPOSSIBLE")

Fixed submission:
N,K=list(map(int,input().split()))
l=list(map(int,input().split()))
import math
if N==1:
   if l[0]==K:
      print("POSSIBLE")
      exit()
   else:
      print("IMPOSSIBLE")
      exit()
A=math.gcd(l[0],l[1])
if K<=max(l):
   for i in range(max(0,N-2)):
      A=math.gcd(A,l[i+2])
   if K%A==0:
      print("POSSIBLE")
   else:
      print("IMPOSSIBLE")
else:
   print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
A,B,C = list(map(int,input().split()))
if abs(A-B) == abs(B-C):
	print("YES")
    exit()
else:
	print("NO")
    exit()

Fixed submission:
a,b,c=map(int,input().split())
if b-a==c-b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N,K =  list(map(int,input().split()))
listA = []
for i in range(K):listA.append(input())
listA.sort()
print("".join(listA))

Fixed submission:
N,L =  list(map(int,input().split()))
listA = []
for i in range(N):listA.append(input())
listA.sort()
print("".join(listA))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

def DFS(i):
    if done[i]:
        ans[-1]+=1
        done[i]=False
        for g in G[i]:
            if done[g]:
                DFS(g)
    else:
        return p

N,M=map(int,input().split())
G=[[] for _ in range(N)]
done=[True for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=[]
for j in range(N):
    ans.append(0)
    if done[j]:
        DFS(j)
print(max(ans))


Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def DFS(i):
    if done[i]:
        ans[-1]+=1
        done[i]=False
        for g in G[i]:
            if done[g]:
                DFS(g)
    else:
        return p

N,M=map(int,input().split())
G=[[] for _ in range(N)]
done=[True for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
ans=[]
for j in range(N):
    ans.append(0)
    if done[j]:
        DFS(j)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M=map(int,input().split())
L=[0 for _ in range(H)]
C=[0 for _ in range(W)]
B=[list(map(int,input().split())) for _ in range(M)]

for i in range(M):
    L[B[i][0]-1]+=1
    C[B[i][1]-1]+=1

LM=max(L)
CM=max(C)

l=[]
c=[]
for j in range(H):
    if L[j]==LM:
        l.append(j)

for k in range(W):
    if C[k]==CM:
        c.append(k)

ans=LM+CM-1
for a in l:
    for b in c:
        if [a+1,b+1] not in B:
            ans=LM+CM
            break
    if ans==LM+CM:
        break
print(ans)

Fixed submission:
H,W,M=map(int,input().split())
L=[0 for _ in range(H)]
C=[0 for _ in range(W)]
B={}
for _ in range(M):
    a,b=map(int,input().split())
    B[str(a)+","+str(b)]=0
    L[a-1]+=1
    C[b-1]+=1

LM=max(L)
CM=max(C)

l=[]
c=[]
for j in range(H):
    if L[j]==LM:
        l.append(j)

for k in range(W):
    if C[k]==CM:
        c.append(k)

ans=LM+CM-1

for a in l:
    for b in c:
        if str(a+1)+","+str(b+1) not in B:
            ans=LM+CM
            break
    if ans==LM+CM:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)

Fixed submission:
K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0 or K%5==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)
    

Fixed submission:
K=int(input())
n=len(str(K))
N=int("7"*n)
if K%2==0 or K%5==0:
    print(-1)
else:
    while N%K!=0:
        n+=1
        N=N*10+7
        N%=K
    print(n)
Buggy python submission (verdict: Runtime Error):
from math import ceil

def check(A,N,i,K):
    cnt=0
    for j in range(N):
        cnt+=ceil(A[j]/i)-1
    if cnt<=K:
        return 1
    else:
        return -1

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
M=A[-1]
res=[0 for _ in range(M+1)]
i=M//2
d=M//2
if K==0:
    print(M)
else:
    while True:
        d//=2
        res[i]=check(A,N,i,K)
        if i>0 and res[i-1]*res[i]==-1:
            ans=i
            break
        elif i<M and res[i]*res[i+1]==-1:
            ans=i+1
            break
        if res[i]==1:
            i-=d
        else:
            i+=d
    print(ans)
    print(res)

Fixed submission:
from math import ceil

def check(x):
    cnt = 0
    for a in A:
        cnt += ceil(a/x)-1
    return cnt <= K

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

left = 0
right = max(A)
while left < right-1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
M=int(N**0.5)+1

for i in range(1,1+N):
    ans=0
    for x in range(1,M):
        for y in range(1,x+1):
            if x**2+y**2+x*y<N:
                for z in range(1,y+1):
                    if x**2+y**2+z**2+x*y+y*z+z*x==i:
                        if x==y==z:
                            ans+=1
                        elif x!=y and y!=z and z!=x:
                            ans+=6
                        else:
                            ans+=3
    print(ans)

Fixed submission:
N=int(input())

for i in range(1,1+N):
    ans=0
    M=int(i**0.5)+1
    for x in range(1,M):
        if x**2<i:
            for y in range(1,x+1):
                if x**2+y**2+x*y<i:
                    for z in range(1,y+1):
                        if x**2+y**2+z**2+x*y+y*z+z*x==i:
                            if x==y==z:
                                ans+=1
                            elif x!=y and y!=z and z!=x:
                                ans+=6
                            else:
                                ans+=3
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=0
for i in range(1,1+N):
    m=N-N%i
    n=N//i
    ans+=(i+m)*n//2
print(ans)

Fixed submission:
N=int(input())
ans=0
for i in range(1,1+N):
    m=N-N%i
    n=N//i
    ans+=(i+m)*n//2
print(ans)

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

def div(n):
    res=0
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            res+=2
        if i**2==n:
            res-=1
    return res

ans=0
for i in range(1,N+1):
    ans+=i*div(i)
print(ans)

Fixed submission:
N=int(input())
ans=0
for i in range(1,1+N):
    m=N-N%i
    n=N//i
    ans+=(i+m)*n//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = ''
while N > 0:
N -= 1
ans += chr(ord('a') + N % 26)
N //= 26
print(ans[::-1])

Fixed submission:
N = int(input())
ans = ''
while N > 0:
    N -= 1
    ans += chr(ord('a') + N % 26)
    N //= 26
print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
from copy import copy

for k in range(K):
    left={}
    right={}
    for i in range(N):
        l=max(0,i-A[i])
        r=min(N-1,i+A[i])
        if l in left:
            left[l]+=1
        else:
            left[l]=1
        if r in right:
            right[r]+=1
        else:
            right[r]=1

    br=[]
    b=0
    m=N
    for i in range(N):
        if i in left:
            b+=left[i]
        br.append(b)
        m=min(m,b)
        if i in right:
            b-=right[i]
    if m==N:
        break
    A=copy(br)
print(*br)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
from copy import copy

for k in range(K):
    left={}
    right={}
    for i in range(N):
        l=max(0,i-A[i])
        r=min(N-1,i+A[i])
        if l in left:
            left[l]+=1
        else:
            left[l]=1
        if r in right:
            right[r]+=1
        else:
            right[r]=1

    br=[]
    b=0
    m=N
    for i in range(N):
        if i in left:
            b+=left[i]
        br.append(b)
        m=min(m,b)
        if i in right:
            b-=right[i]
    if m==N:
        break
    A=copy(br)
print(*br)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N,M=map(int,input().split())

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w]!=-1:
            continue
        dist[w] = v
        que.append(w)

print("Yes")
for j in range(1,N):
    print(ans[j])

Fixed submission:
from collections import deque

N,M=map(int,input().split())

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
ans=[0 for _ in range(N)]
for i in range(1,N):
    for t in tree[i]:
        if dist[t]==dist[i]-1:
            ans[i]=t+1
            break

print("Yes")
for j in range(1,N):
    print(ans[j])
Buggy python submission (verdict: Runtime Error):
X=int(input())

for i in range(-100,100):
    for j in range(-100,100):
        if i**5==j**5+X:
            A=i
            B=j
            break
print(A,B)

Fixed submission:
X=int(input())

for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5==j**5+X:
            A=i
            B=j
            break
print(A,B)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
AA=[]
M=0
for i in range(N):
    if A[i]<N:
        M=max(A[i],M)

m=min(A)
cnt=0
for i in range(N):
    LM=min(i+M+A[i]+1,N)
    lm=max(i+m+A[i],i+1)
    for j in range(lm,LM):
        cnt+=1
        if j-i==abs(A[i]+A[j]):
            ans+=1
print(ans)

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

L={}
R={}
ans=0
for i in range(N):
    if i+A[i] in L:
        L[i+A[i]]+=1
    else:
        L[i+A[i]]=1
    if A[i]<=i:
        if i-A[i] in R:
            R[i-A[i]]+=1
        else:
            R[i-A[i]]=1
for r in R:
    if r in L:
        ans+=L[r]*R[r]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        if j-i==abs(A[i]+A[j]):
            ans+=1
print(ans)

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

L={}
R={}
ans=0
for i in range(N):
    if i+A[i] in L:
        L[i+A[i]]+=1
    else:
        L[i+A[i]]=1
    if A[i]<=i:
        if i-A[i] in R:
            R[i-A[i]]+=1
        else:
            R[i-A[i]]=1
for r in R:
    if r in L:
        ans+=L[r]*R[r]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def check(r,g,b):
    ans=0
    for i in range(len(r)):
        G=bisect.bisect_left(g,r[i])
        for j in range(G,len(g)):
            B=bisect.bisect_left(b,g[j])
            ans+=len(b)-B
            if 2*g[j]-r[i] in b:
                ans-=1
    return ans

N=int(input())
S=input()
ans=0
r=[]
g=[]
b=[]

for h in range(N):
    if S[h]=="R":
        r.append(h)
    elif S[h]=="G":
        g.append(h)
    else:
        b.append(h)

ans=check(r,g,b)+check(g,b,r)+check(b,r,g)+check(b,g,r)+check(g,r,b)+check(r,b,g)
print(ans)

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):
        k=2*j-i
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[j]!=S[i]:
            ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
#import time
#start = time.time()

def check(r,g,b):
    ans=0
    for i in range(len(r)):
        G=bisect.bisect_left(g,r[i])
        for j in range(G,len(g)):
            B=bisect.bisect_left(b,g[j])
            ans+=len(b)-B
            if 2*g[j]-r[i] in b:
                ans-=1
    return ans

N=int(input())
S=input()
ans=0
r=[]
g=[]
b=[]

for h in range(N):
    if S[h]=="R":
        r.append(h)
    elif S[h]=="G":
        g.append(h)
    else:
        b.append(h)

ans=check(r,g,b)+check(g,b,r)+check(b,r,g)+check(b,g,r)+check(g,r,b)+check(r,b,g)


print(ans)
#process_time = time.time() - start
#print(process_time)

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):
        k=2*j-i
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[j]!=S[i]:
            ans-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
K=int(input())
if K<10:
    print(K)
else:
    n=10
    i=9
while i<K:
    S=str(n)
    cond=True
    for j in range(len(S)-1):
        if abs(int(S[j])-int(S[j+1]))>1:
            cond=False
            break
    if cond:
        i+=1
#        print(n)
        n+=1
    else:
        n+=10**(len(S)-j-2)
#        print(n,10**(len(S)-j-2))
        
print(n-1)

Fixed submission:
K=int(input())
if K<10:
    n=2
    i=1
else:
    n=10
    i=9
while i<K:
    S=str(n)
    cond=True
    for j in range(len(S)-1):
        if abs(int(S[j])-int(S[j+1]))>1:
            cond=False
            break
    if cond:
        i+=1
#        print(n)
        n+=1
    else:
        n+=10**(len(S)-j-2)
#        print(n,10**(len(S)-j-2))
print(n-1)