Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

class grid:
    def __init__(self, word):
        self.word = word
        self.has_golem = 1
        self.will_move_golem = 0


def move_golem(text, dir):
    for i in range(n):
        if grids[i].word == text and grids[i].has_golem != 0:
            move_golem = grids[i].has_golem
            grids[i].has_golem = 0
            if(dir == 'L' and i != 0):
                grids[i-1].will_move_golem += move_golem
            if(dir == 'R' and i != n-1):
                grids[i+1].will_move_golem += move_golem
        else:
            continue
    for g in grids:
        g.has_golem += g.will_move_golem
        g.will_move_golem = 0

def answer():
    sum_golem = 0
    for g in grids:
        sum_golem += g.has_golem

    return sum_golem

n, q = map(int, input().split())
s = input()

grids = []
for i in range(n):
    grids.append(grid(s[i]))

for i in range(q):
    text, dir = input().split()
    move_golem(text, dir)

print(answer())


### FIXED CODE ###

class spell:
    def __init__(self, text, dir):
        self.text = text
        self.dir = dir

def isRange(a):
    if(0 <= a < n):
        return True
    else:
        return False

n, q = map(int, input().split())
s = input()

spells = []
for i in range(q):
    text, dir = input().split()
    spells.append(spell(text, dir))


l = -1
r = n

for sp in reversed(spells):
    if(isRange(l+1) and s[l+1] == sp.text and sp.dir == 'L'):
        l += 1
    elif(isRange(l) and s[l] == sp.text and sp.dir == 'R'):
        l -= 1
    if(isRange(r-1) and s[r-1] == sp.text and sp.dir == 'R'):
        r -= 1
    elif(isRange(r) and s[r] == sp.text and sp.dir == 'L'):
        r += 1

print(n-(l+1)-(n-r))
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
for i in range(N - 1):
  for j in range(i+1, N):
    a = (A[i] * A[j]) % mod
    ans += a
    ans = ans % mod

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
#TLE
'''
for i in range(N - 1):
  for j in range(i+1, N):
    a = A[i] % mod
    b = A[j] % mod
    ans += (a * b) % mod
    ans = ans % mod
'''
tot = 0
for i in range(N):
  A[i] %= mod
  tot += A[i]
  tot %= mod
for i in range(N-1):
  tot -= A[i]
  ans += (A[i] * tot) % mod
  ans %= mod
print(ans)
### BUGGY CODE ###

N=int(input())
s=[]
for i in range(N):
	s.append(str(input()))
ans=0
dic={}
for i in range(N):
	a=sorted(s[i])
	a=''.join(a)
	if a in list(dic.keys()):
		ans+=dic[a]
		dic[a]+=1
	else:
		dic[a] = 1
print(ans)


### FIXED CODE ###

N=int(input())
ans=0
dic={}
for i in range(N):
	a=sorted(str(input()))
	a=''.join(a)
	if a in dic.keys():
		ans+=dic[a]
		dic[a]+=1
	else:
		dic[a]=1
print(ans)
### BUGGY CODE ###

def ACcount(l,r):
    count = 0
    for i in range(l-1,r-1): #最後にAが出ても意味ないのでr-1でカット
        if(S[i]=='A'):
            if(S[i+1]=='C'):
                count += 1
    return count

n,q = map(int,input().split())
S = list(input())
l = [0]*q
r = [0]*q
for i in range(q):
    l[i],r[i] = map(int,input().split())

for i in range(q):
    print(ACcount(l[i],r[i]))


### FIXED CODE ###

n,q = map(int,input().split())
S = list(input())
a = [0]*n

for i in range(1,n):
    a[i] = a[i-1]
    if (S[i-1]=='A')and(S[i]=='C'):
        a[i] += 1 
for i in range(q):
    l,r = map(int,input().split())
    print(a[r-1]-a[l-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(1,n+1):
  print(a.index(i)+1, end = " ")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0 for _ in range(n)]
for i, A in enumerate(a):
  ans[A-1] = str(i+1)
print(' '.join(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def main():
    s = input().rstrip()
    K = int(input())

    N = len(s)
    sub = set()
    for i in range(N):
        t = s[i]
        sub.add(t)
        for j in range(i+1, N):
            t = "".join([t, s[j]])
            sub.add(t)
    sub = sorted(sub)
    ans = sub[K-1]
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from string import ascii_lowercase as AL

input = sys.stdin.readline


def main():
    s = input().rstrip()
    K = int(input())

    N = len(s)
    total = 0
    for al in AL:
        induces = []
        for i in range(N):
            if al == s[i]:
                induces.append(i)
        if not induces:
            continue
        match = [al]
        for i in range(1, 5):
            for idx in induces:
                if idx + i < N:
                    match.append(s[idx:idx + i + 1])
        match = set(match)
        match = sorted(match)
        if total + len(match) >= K:
            ans = match[K - 1 - total]
            break
        else:
            total += len(match)
    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###


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

C = [float('inf')] * (1 << N)
C[0] = 0

for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + a

        ex_status = 0
        for j in box:
            ex_status += 1 << (j-1)
        now_status = i | ex_status

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])



### FIXED CODE ###


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

C = [float('inf')] * (1 << N)
C[0] = 0
key_v = [float('inf')] * (1 << N)
for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    ex_status = 0
    for j in box:
        ex_status += 1 << (j-1)
    key_v[ex_status] = min(a, key_v[ex_status])

for key, val in enumerate(key_v):
    if val == float('inf'):
        continue
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + val
        if score == float("inf"):
            continue

        now_status = i | key

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])
### BUGGY CODE ###

# coding: utf-8
# Your code here!

from collections import deque
from pprint import pprint
moves=[(0,1),(1,0),(0,-1),(-1,0)]
pp=pprint
# INF=float("inf")

h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
maze=[list(input()) for _ in range(h)]
cost=[[-1]*w for _ in range(h)]

todo=deque()
todo.append((x1,y1))
cost[x1][y1]=0

while todo:
    x,y=todo.popleft()
    for vx,vy in moves:
        for kk in range(1,k+1):
            nx=x+vx*kk
            ny=y+vy*kk
            if not(0<=nx<h) or not(0<=ny<w):
                continue
            if maze[nx][ny]=="@":
                break
            if cost[nx][ny]!=-1 and cost[nx][ny]<=cost[x][y]:
                continue
            if cost[nx][ny]!=-1:
                continue
            cost[nx][ny]=cost[x][y]+1
            todo.append((nx,ny))


# pp(cost)
ans=cost[x2][y2]
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!

from collections import deque
from pprint import pprint
moves=[(0,1),(1,0),(0,-1),(-1,0)]
pp=pprint
# INF=float("inf")

h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
maze=[list(input()) for _ in range(h)]
cost=[[-1]*w for _ in range(h)]

todo=deque()
todo.append((x1,y1))
cost[x1][y1]=0

while todo:
    x,y=todo.popleft()
    for vx,vy in moves:
        for kk in range(1,k+1):
            nx=x+vx*kk
            ny=y+vy*kk
            if not(0<=nx<h) or not(0<=ny<w):
                continue
            if maze[nx][ny]=="@":
                break
            if cost[nx][ny]!=-1 and cost[nx][ny]<=cost[x][y]:
                break
            if cost[nx][ny]!=-1:
                continue
            cost[nx][ny]=cost[x][y]+1
            todo.append((nx,ny))


# pp(cost)
ans=cost[x2][y2]
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
key = [i+1 for i in range(n)]
for i in range(m):
  l,r = map(int,input().split())
  new_key = [i for i in range(l,r+1)]
  key = list(set(new_key) & set(key))
  
print(len(key))
  

### FIXED CODE ###

n,m = map(int,input().split())
key = [i+1 for i in range(n)]
lmax = 0
rmin = 10**5
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)

num = rmin-lmax+1
print(num if num>0 else 0)
### BUGGY CODE ###

import copy

s = input()
s_sub = copy.deepcopy(s)
# 
tar1 = "01"
tar2 = "10"
# tar3 = ["1010","1001","0101","0110"]

while((tar1 in s )or(tar2 in s)):
    
    
    # for i in range(4):
    #     if tar3[i] in s:
    #         s = s.replace(tar3[i],"")
    

    if tar1 in s:
        s = s.replace(tar1,"",1)
    if tar2 in s:
        s = s.replace(tar2,"",1)



print(len(s_sub)-len(s))

### FIXED CODE ###

import copy

s = input()
s_sub = copy.deepcopy(s)
# # 
# tar1 = "01"
# tar2 = "10"
# tar3 = ["1010","1001","0101","0110","1100","0011",""]
# 
# while((tar1 in s )or(tar2 in s)):
# 
# 
#     # for i in range(4):
#     #     if tar3[i] in s:
#     #         s = s.replace(tar3[i],"")
# 
# 
#     if tar1 in s:
#         s = s.replace(tar1,"",1)
#     if tar2 in s:
#         s = s.replace(tar2,"",1)
# 
# 
# 
# print(len(s_sub)-len(s))

#0と1の数数えて差分が残るのでは？
l1 = s.count("0")
l2 = s.count("1")
l3 = abs(l1-l2)

print(len(s_sub)-l3)
### BUGGY CODE ###

#E
H,N=map(int,input().split())

A=[]
B=[]
DP=[0]+[float('Inf')]*(2*10**4)

for i in range(N): 
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

for j in range(10**4):
  for i in range(N):
    DP[j+A[i]]=min(B[i]+DP[j],DP[j+A[i]])

print(min(DP[H:]))

### FIXED CODE ###

#E
H,N=map(int,input().split())

A=[]
B=[]
DP=[0]+[float('Inf')]*(2*10**4)

for i in range(N): 
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

for j in range(10**4):
  for i in range(N):
    DP[j+A[i]]=min(B[i]+DP[j],DP[j+A[i]])

print(min(DP[H:]))
### BUGGY CODE ###

n = int(input())
s = input()

ans = 300001
for i in range(n):
    people = s[:i].count('W') + s[i+1:].count('E')
    if ans > people:
        ans = people

print(ans)


### FIXED CODE ###

'''
制約
2 ≤ N ≤ 3×10^5(300,000)

入力例 3
8
WWWWWEEE

出力例 3
3

考え方：
Eを0, Wを1と置くと、
0000000X11111111 と並ぶようにすればよい。
そのために、値を変える数が最小になるリーダーの位置を調べればよい

-> 左端のW(West), 右端のE(East)はほぼ必ず向きを変える必要がある。


A. 全パターン試す
ある地点より左のWの数 + 右のEの数　の合計が最小になるパターンを求める（文字一致でカウント）
-> TLE

B. 全パターン
str.count('W')でやる
-> TLE

C. 「累積和」(cumulative sum)というアルゴリズムを使わないと解けない問題。学習して、使う！


'''

# from collections import deque # キュー、スタックに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

is_debug = False


def main():
    '''メイン処理'''
    n = int(input())
    sss = input()

    s_list = list(sss)

    W_sums = [0] * n # 累積和を入れるリスト
    E_sums = [0] * n # 累積和を入れるリスト
    W_sum = 0 # 左端から数えて、向きを変える必要のあるWの数
    E_sum = 0 # 右端から数えて、向きを変える必要のあるWの数
    
    if is_debug:
        print(W_sums)
    
    for i in range(n):
        if s_list[i] == 'W':
            W_sum += 1
        W_sums[i] = W_sum
        if s_list[n-i] == 'E':
            E_sum += 1
        E_sums[(n-1)-i] = E_sum

    if is_debug:
        print(W_sums)
        print(E_sums)
    
    # W_sums, E_sumsを用いて、向きを変える人数が最小となる値を見つける
    min_cost = float('inf')
    for i in range(n):
        # Wを振り向かせる人数
        if i == 0:
            W_cost = 0
        else:
            W_cost = W_sums[i-1]
        # Eを振り向かせる人数
        if i == n-1:
            E_cost = 0
        else:
            E_cost = E_sums[(i-1)+1]

        if is_debug:
            print(i, W_cost, E_cost)

        cost = W_cost+E_cost
        if cost < min_cost:
            min_cost = cost
    
    print(min_cost)

if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()
### BUGGY CODE ###

#ALDS1_4-D Allocation
from collections import deque

def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    while(w):
        tmp = w.popleft()
        if(tmp > p):return False
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:return False
    return True
    
n,k = [int(x) for x in input().split()]
w = []
for i in range(n):
    w.append(int(input()))

p = int(sum(w)/k)+1
if(sum(w)%k==0):p-=1
while(1):
    x=deque(w)
    if(pIsAccptbl(x,k,p)):
        print(p)
        break
    else:
        p+=1

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
### BUGGY CODE ###

n, m = map(int, input().split())

l_first, r_first = map(int, input().split())

answer_set = {value for value in range(l_first, r_first + 1)}

for _ in range(m - 1):
    l_current, r_current = map(int, input().split())
    current_set = {value for value in range(l_current, r_current + 1)}
    answer_set.intersection_update(current_set)

print(len(answer_set))


### FIXED CODE ###

import sys

input = sys.stdin.readline

n, m = map(int, input().split())

l_list = []
r_list = []

for _ in range(m):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)

l_maybe_answer = max(l_list)
r_maybe_answer = min(r_list)

if l_maybe_answer <= r_maybe_answer:
    print(min(r_list) - max(l_list) + 1)
else:
    print(0)
### BUGGY CODE ###

N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
while M>0:
    B=max(A)
    A[A.index(B)]=A[A.index(B)]//2
    M-=1
print(sum(A))

### FIXED CODE ###

import heapq
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
A=[-A[i] for i in range(N)]
heapq.heapify(A)
for i in range(M):
    a=A[0]
    heapq.heappop(A)
    heapq.heappush(A,-(a//-2))
print(-sum(A))
### BUGGY CODE ###

N = int(input())
l = list(map(int,input().split()))


def gcd(l):
    flag = {'gcd':True}
    g = 0
    m = min(l)
    for i in range(1,m+1):
        flag['gcd'] = True
        for j in l:
            if j % i != 0:
                flag['gcd'] = False
                break

        if flag['gcd']:
            g = i
    return g

memo = 1
for i in range(N):
    g = gcd(l[:i]+l[i+1:])
    if g > memo:
        memo = g

print(memo)



### FIXED CODE ###

import fractions

N = int(input())
l = list(map(int,input().split()))

L = [0]
R = [0]

gl = 0
gr = 0
for i in range(N):
    gl = fractions.gcd(gl,l[i])
    L.append(gl)
    gr = fractions.gcd(gr,l[N-1-i])
    R.append(gr)

M = []
for i in range(N+1):
    M.append(fractions.gcd(L[i-1],R[N-i]))

print(max(M))
### BUGGY CODE ###

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
S = ["".join(sorted(input())) for i in range(N)]

S_ = set(S)

a = [combinations_count(S.count(i), 2) for i in S_ if not S.count(i) == 1]

print(int(sum(a)))

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
existed = {}
c = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))

  if sorted_s in existed:
    c += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(c)
### BUGGY CODE ###

class UFT(object):
  def __init__(self,N):
    self.par={i:i for i in range(1,N+1)}
    self.h={i:0 for i in range(1,N+1)}
  def find(self,n):
    if self.par[n]==n:
      return n
    else:
      self.par[n]=self.find(self.par[n])
      return self.par[n]
  def unite(self,a,b):
    a=self.find(a)
    b=self.find(b)
    if self.h[a]>self.h[b]:
      self.par[b]=a
    else:
      self.par[a]=b
      if self.h[a]==self.h[b]:
        self.h[b]+=1
  def issame(self,a,b):
    return self.find(a)==self.find(b)

N=int(input())
obj=UFT(N)
d={i:0 for i in range(1,N+1)}
for i in range(N):
  b=int(input())
  d[i+1]=b
  obj.unite(i+1,b)

if obj.issame(2,1):
  c=1
  e=d[1]
  while e!=2:
    c+=1
    e=d[e]
  print(c)
else:
  print("-1")

### FIXED CODE ###

n=int(input())
d={i:int(input()) for i in range(1,n+1)}

f=True
s=1
for i in range(n):
  if s==2:
    print(i)
    f=False
    break
  s=d[s]
if f:
  print(-1)
### BUGGY CODE ###

H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
x=max(a for a,b in ab)
dp=[0]*(H+1)
for i in range (1,H+1):
    dp[i]=min(dp[max(i-a,0)]+b for a,b in ab)
print(dp[H])

### FIXED CODE ###

H,N=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(N)]
x=max(a for a,b in ab)
dp=[0]*(H+x)
for i in range (1,H+x):
    dp[i]=min(dp[i-a]+b for a,b in ab)
print(dp[H])
### BUGGY CODE ###

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

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

t = 0
A = []

for i in range(n-k+1):
    s = sum(P[i:i+k])
    if s > t:
        A = P[i:i+k]
        t = s
ans = 0
def f(x):
    y = 0
    for i in range(x+1):
        y += i
    return y / x

B = []
C = []
for i in A:
    if i not in B:
        temp = f(i)
        B.append(i)
        C.append(temp)
    else:
        temp = C[B.index(i)]
    ans += temp
print(ans)

### FIXED CODE ###

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

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

B = []
t = -1
init_sum = sum(A[0:k])

for i in range(n - k+1):
    if t < init_sum:
        B = A[i:i+k]
        t = init_sum
    if i != n - k:
        init_sum = init_sum - A[i] + A[i+k]


import collections
B = sorted(B)
C = collections.Counter(B)

D = list(C.keys())
E = list(C.values())
F = zip(D, E)
F = sorted(F)
D, E = zip(*F)

G = []
j = 0
total = 0
for i in range(max(D) + 1):
    total += i
    if D[j] == i:
        G.append(total)
        j += 1
ans = 0
k = 0
for i, j in zip(D, G):
    ans += (j/i) * E[k]
    k += 1
print(ans)
### BUGGY CODE ###

def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))

    score = 1
    for _a in a[:k]:
        score *= _a

    for i, _a in enumerate(a[k:]):
        if score < (score * _a / a[i]):
            print("Yes")
        else:
            print("No")
        score = score * _a / a[i]
    
    return


if __name__ == "__main__":
    main()



### FIXED CODE ###

def main():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))

    for i, _a in enumerate(a[k:]):
        if a[i] < _a:
            print("Yes")
        else:
            print("No")
    
    return


if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import deque

X, Y, A, B, C = map(int, input().split())
P = [int(n) for n in input().split()]
Q = [int(n) for n in input().split()]
R = [int(n) for n in input().split()]

P.sort()
Q.sort()
R.sort(reverse=True)

PQ = deque(sorted(P[-X:] + Q[-Y:]))
R = deque(R)

while True:
    if not R or R[0] <= PQ[0]:
        break
    if P[0] > PQ[0]:
        PQ.append(R.popleft())
        PQ.popleft()

print(sum(PQ))

### FIXED CODE ###

from collections import deque
from itertools import count

X, Y, A, B, C = map(int, input().split())
P = [int(n) for n in input().split()]
Q = [int(n) for n in input().split()]
R = [int(n) for n in input().split()]


P.sort()
Q.sort()
R.sort(reverse=True)

P = deque(P[-X:])
Q = deque(Q[-Y:])
R = deque(R)

for i in count():
    if not R or P[0] >= R[0] <= Q[0]:
        break
    if R[0] >= P[0] <= Q[0]:
        P.append(R.popleft())
        P.popleft()
    elif R[0] >= Q[0] <= P[0]:
        Q.append(R.popleft())
        Q.popleft()

print(sum(P) + sum(Q))
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
l =sorted(L)
t = 0
for i in range(N-2):
  for k in range(i+1,N-1):
    for m in range(k+1, N):
      if l[m] < l[k] + l[i]:
        t += 1
      else:
        break
print(t)
      

### FIXED CODE ###

import bisect
n =int(input())
l =list(map(int, input().split()))
l.sort()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    tmp = bisect.bisect_left(l,l[i]+l[j])
    total += tmp - j - 1
print(total)
### BUGGY CODE ###

n= int(input())
s = str(input())

r = []
g = []
b = []
for i in range(n):
    if s[i]=="R":
        r.append(i)
    elif(s[i]=="G"):
        g.append(i)
    elif(s[i]=="B"):
        b.append(i)
score = len(r)*len(g)*len(b)

for i in r:
    for j in g:
        if (i>j)and(2*i-j in b):
            score-=1
        if (i>j)and(2*j-i in b):
            score-=1
        if(j>i)and(2*j-i in b):
            score-=1
        if(j>i)and(2*i-j in b):
            score-=1
        if((i+j)/2 in b):
            score-=1
# print(count_)
print(score)

### FIXED CODE ###

n= int(input())
s = str(input())

r=set()
g=set()
b=set()
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)
score = len(r)*len(g)*len(b)
for i in r:
    for j in g:
        dist=abs(j-i)
        if (i>j):
            bi = i+dist
            if bi in b:
                score -=1
            bi = j-dist
            if bi in b:
                score -=1
        else:
            bi = j+dist
            if bi in b:
                score-=1
            bi = i-dist
            if bi in b:
                score-=1
        if((i+j)%2==0 and (i+j)/2 in b):
            score-=1
# print(count_)
print(score)
### BUGGY CODE ###

def cutw(s,n):
    t = 0
    for i in range(n):
        if s[i] == '#':
            break
        else:
            t += 1
    s = s[t:]
    n = len(s)
    return s,n

def cutb(s,n):
    t = n
    for i in range(n-1, -1,-1):
        if s[i] == '.':
            break
        else:
            t -= 1
    s = s[:t]
    n = len(s)
    return s,n


if __name__ == '__main__':
    n = int(input())
    s = input()
    res = 0
    s1 = s
    n1 = n
    res1 = 0
    while True:
        s,n = cutw(s,n)
        s,n = cutb(s,n)
        if n>0:
            s = '.'+s[1:]
            res += 1
        else:
            break
    while True:
        s1,n1 = cutw(s1,n1)
        s1,n1 = cutb(s1,n1)
        if n1>0:
            s1 = s1[:n1-1] + '#'
            res1 += 1
        else:
            break
    print(min(res,res1))

### FIXED CODE ###

def main():
    n = int(input())
    s = input()
    res = w = s.count('.')
    b = 0
    for i in range(n):
        if s[i] == '#':
            b += 1
        else:
            w -= 1
        res = min(res,b+w)

    print(res)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = input()
MOD = 10 ** 9 + 7
dp = 1

n = 1
for c in reversed(S):
  if c == '1':
    dp = (2 * dp + n) % MOD
  n *= 3
print(dp)

### FIXED CODE ###

S = input()
MOD = 10 ** 9 + 7
dp = 1

n = 1
for c in reversed(S):
  if c == '1':
    dp = 2 * dp + n
  n *= 3
print(dp % MOD)