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

#!/usr/bin/env python3
N, x = map(int, input().split())
if 1 < x < 2 * N - 1:
    print('Yes')
    for i in range(2 * N - 1):
        order = (1, -1)[x > N]
        print(list(range(1, 2 * N)[::order])[i - abs(x - N)])
else:
    print('No')


### FIXED CODE ###

#!/usr/bin/env python3
N, x = map(int, input().split())
if 1 < x < 2 * N - 1:
    print('Yes')
    order = (1, -1)[x > N]
    l = list(range(1, 2 * N)[::order])
    for i in range(2 * N - 1):
        print(l[i - abs(x - N)])
else:
    print('No')
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().rstrip().split(" ")))

t = list(0 for i in range(n+1))
for i in range(1, n+1):
    t[i] = t[i-1] + a[i-1]

def sum_a(i, j):
    return t[j]-t[i]

min_dif = sum_a(0, n)

for i in range(2, n-1):
    j0 = 0
    j1 = i
    u = sum_a(0, i) // 2
    while j1 - j0 > 1:
        j = (j0+j1) // 2
        if sum_a(0, j) <= u: 
            j0 = j
        else:
            j1 = j
    if abs(sum_a(0, j0)-sum_a(j0, i)) < abs(sum_a(0, j1) - sum_a(j1, i)): 
        p = sum_a(0, j0)
        q = sum_a(j0, i)
    else:
        p = sum_a(0, j1)
        q = sum_a(j1, i)

    j0 = i
    j1 = n
    u = sum_a(i, n) // 2
    while j1 - j0 > 1:
        j = (j0+j1) // 2
        if sum_a(i, j) <= u: 
            j0 = j
        else:
            j1 = j
    if abs(sum_a(i, j0)-sum_a(j0, n)) < abs(sum_a(i, j1) - sum_a(j1, n)): 
        r = sum_a(i, j0)
        s = sum_a(j0, n)
    else:
        r = sum_a(i, j1)
        s = sum_a(j1, n)

    min_dif = min(min_dif, max(p, q, r, s)-min(p, q, r, s))

print(min_dif)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().rstrip().split(" ")))

t = list(0 for i in range(n+1))
for i in range(1, n+1):
    t[i] = t[i-1] + a[i-1]

def sum_a(i, j):
    return t[j]-t[i]

min_dif = sum_a(0, n)

i = 0
k = 2
for j in range(2, n-1):
    u = sum_a(0, j) // 2
    while sum_a(0, i) < u:
        i = i + 1
    if abs(sum_a(0, i-1)-sum_a(i-1, j)) < abs(sum_a(0, i) - sum_a(i, j)): 
        i = i - 1
    p = sum_a(0, i)
    q = sum_a(i, j)

    u = sum_a(j, n) // 2
    while sum_a(j, k) < u:
        k = k + 1
    if abs(sum_a(j, k-1)-sum_a(k-1, n)) < abs(sum_a(j, k) - sum_a(k, n)): 
        k = k - 1
    r = sum_a(j, k)
    s = sum_a(k, n)

    min_dif = min(min_dif, max(p, q, r, s)-min(p, q, r, s))

print(min_dif)
### BUGGY CODE ###

def nCr(n, r):
    mod=10**9+7
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

nn,k=map(int,input().split())
*A,=sorted(map(int,input().split()))
B=sorted(A,reverse=True)
mod=10**9+7


mi,ma=0,0
for i in range(k-1,nn):
    L=nCr(i,k-1)    
    ma+=L*A[i]
    mi+=L*B[i]
    
print((ma-mi)%mod)


### FIXED CODE ###

M,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
ANS = 0
 
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
for j in range(M-K+1):
    ANS += (L[K-1+j] - L[M-K-j])*cmb(K-1+j,K-1,mod)
 
print(ANS % mod)
### BUGGY CODE ###

a,b,c,k=map(int, input().split())
ans =0
for i in range(k):
    if a>0:
        a-=1
        ans+=1
    elif b>0:
        b-=1
    else:
        ans-=1
print(ans)

### FIXED CODE ###

a,b,c,k=map(int, input().split())
ans =0
if a>=k:
	ans+=k
else:
	ans+=a
if k-a-b>=1:
	ans+=-(k-a-b)
print(ans)
### BUGGY CODE ###

from operator import itemgetter

h, w, m = (int(x) for x in input().split())
H = [0] * h
W = [0] * w
HW = []
for _ in range(m):
    h_, w_ = (int(x) - 1 for x in input().split())
    HW.append((h_, w_))
    H[h_] += 1
    W[w_] += 1
hmax = max(H)
wmax = max(W)
hindex = []
windex = []
ans = hmax + wmax - 1

HW.sort(key=itemgetter(0, 1))
for y in range(h):
    if H[y] == hmax:
        hindex.append(y)
for x in range(w):
    if W[x] == wmax:
        windex.append(x)

HW_set = set(HW)
for y in hindex:
    for x in windex:
        if not (y, x) in HW_set:
            ans = hmax + wmax

print(ans)


### FIXED CODE ###

from operator import itemgetter

h, w, m = (int(x) for x in input().split())
H = [0] * h
W = [0] * w
HW = []
for _ in range(m):
    h_, w_ = (int(x) - 1 for x in input().split())
    HW.append((h_, w_))
    H[h_] += 1
    W[w_] += 1
hmax = max(H)
wmax = max(W)
hindex = set()
windex = set()

HW.sort(key=itemgetter(0, 1))
for y in range(h):
    if H[y] == hmax:
        hindex.add(y)
for x in range(w):
    if W[x] == wmax:
        windex.add(x)

count = 0
for h, w in HW:
    if h in hindex and w in windex:
        count += 1

if count == len(hindex)*len(windex):
    ans = hmax + wmax - 1
else:
    ans = hmax + wmax

print(ans)
### BUGGY CODE ###

k,s=map(int,input().split())
cnt=0
for i in range(s+1):
	for j in range(i,s+1):
		if i<=k and j-i<=k and s-j<=k:
			cnt+=1
print(cnt)
		

### FIXED CODE ###

k,s=map(int,input().split())
cnt=0
for i in range(s+1):
    if i>k:
        break
    cnt+= max(0,min(i+k,s)-max(s-k,i)+1)
print(cnt)
### BUGGY CODE ###

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

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

k = n * m // gcd(n, m)


for i in range(k, n * m + 1, k):
    ss = {a*(i//n) for a in range(n)}
    tt = {a*(i//m) for a in range(m)}
    st = ss & tt
    x = ''.join(S[c//(i//n)]for c in st)
    y = ''.join(T[c//(i//m)]for c in st)
    if x == y:
        print(i)
        exit()
print(-1)

### FIXED CODE ###

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


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


k = n * m // gcd(n, m)


for i in range(k, n * m + 1, k):
    g = i * i // n // m // gcd(i // n, i // m)
    flag = True
    for c in range(0, i, g):
        if S[c * n // i] != T[c * m // i]:
            flag = False
            break
    if flag:
        print(i)
        exit()
print(-1)
### BUGGY CODE ###

import bisect

N,D,A = map(int,input().split())
mons = []
X = []; H = []
need = [0]*N

for _ in range(N):
    x,h = map(int,input().split())
    mons.append([x,h])
mons = sorted(mons)

for i in range(N):
    X.append(mons[i][0]); H.append(mons[i][1])
    need[i] = mons[i][1] // A
    if mons[i][1] % A != 0: need[i] += 1

eliminated = 0
target = 0
ans = 0
while eliminated < N:
    for i in range(target,N):
        if need[i] > 0:
            target = i
            break
        else:
            eliminated += 1
    need_bomb = need[target]
    bomb_range = bisect.bisect_right(X,X[target] + 2*D)
    for i in range(target,bomb_range):
        need[i] -= need_bomb
    ans += need_bomb
print(ans)

### FIXED CODE ###

import bisect

N,D,A = map(int,input().split())
mons = []; X = []; need = [0]*N; bomb_range = []

for _ in range(N):
    x,h = map(int,input().split())
    mons.append([x,h])
mons = sorted(mons)

for i in range(N):
    X.append(mons[i][0])
    need[i] = mons[i][1] // A
    if mons[i][1] % A != 0: need[i] += 1

for i in range(N):
    bomb_range.append(bisect.bisect_right(X,X[i] + 2*D))

if N == 1:
    ans = need[0]
else:
    # imos setting
    imos = [0]*(N+1)
    imos[0] = need[0]
    imos[bomb_range[0]] = - need[0]
    #
    ans = need[0]
    for i in range(1,N):
        imos[i] += imos[i-1]
        bomb = need[i] - imos[i]
        if bomb > 0:
            ans += bomb
            imos[i] += bomb
            imos[bomb_range[i]] -= bomb
        else:
            continue

print(ans)
### BUGGY CODE ###

N = int(input())
A = map(int,input().split())
c =1
for i in A:
  c *= i
if c <= 10**18:
  print(c)
else:
  print(-1)

### FIXED CODE ###

def main():
  N = int(input())
  A = [int(i) for i in input().split()]
  
  if 0 in A:
    print(0)
    return
  
  c = 1
  for i in A:
    c *= i
    
    if c > 10**18:
      print(-1)
      return
  print(c)
  
main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque
H,W=map(int, sys.stdin.readline().split())

A=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]
B=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]

for h in range(H):
    for w in range(W):
        A[h][w]=abs(A[h][w]-B[h][w])

dp=[ [ 0 for _ in range(W) ] for __ in range(H) ]

Center=80*80      #中心地のセット マイナスの値もセットできるようにbitsetのゼロを80*80+1桁目に置く

#初期化
r,c=0,0
val=A[r][c]
dp[r][c]=1<<val+Center

q=deque()
q.append((0,0))
D=[(1,0),(0,1)]
Visit={}    #訪問済みの頂点にフラグ1を立てる
Visit[(0,0)]=1

while q:
    r,c=q.popleft()
    for dr,dc in D:
        if r+dr<H and c+dc<W:
            next_r=r+dr
            next_c=c+dc
            next_val=A[next_r][next_c]
            dp[next_r][next_c]|=dp[r][c]<<next_val
            dp[next_r][next_c]|=dp[r][c]>>next_val
            Visit[(next_r,next_c)]=1    #次の頂点をキューに入れたら、訪問済みに印をつける
            q.append((next_r,next_c))

ans=float("inf")
for i in range(80*80*2):
    bit=dp[H-1][W-1]>>i&1
    if bit==1:
        ans=min(ans,abs(i-Center))

print ans


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque,defaultdict

H,W=map(int, sys.stdin.readline().split())
A=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]
B=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]

for h in range(H):
    for w in range(W):
        A[h][w]=abs(A[h][w]-B[h][w])

dp=[ [ 0 for _ in range(W) ] for __ in range(H) ]

Center=80*80      #中心地のセット マイナスの値もセットできるようにbitsetのゼロを80*80+1桁目に置く

#初期化
r,c=0,0
val=A[r][c]
dp[r][c]=1<<val+Center

q=deque()
q.append((0,0))
D=[(1,0),(0,1)]
Visit=defaultdict(lambda: 0)     #訪問済みの頂点にフラグ1を立てる
Visit[(0,0)]=1
D=[(1,0),(0,1)]

for r in range(H):
    for c in range(W):
        for dr,dc in D: #横に1つ移動か、下に1つ移動
            if r+dr<H and c+dc<W:   #移動しようとするマスが存在するならばif文内の処理を行う
                next_r=r+dr
                next_c=c+dc
                next_val=A[next_r][next_c]
                dp[next_r][next_c]|=dp[r][c]<<next_val  #次のマスの値が+の場合は、bitshift全体を左にシフト
                dp[next_r][next_c]|=dp[r][c]>>next_val  #次のマスの値が-の場合は、bitshift全体を右にシフト
                q.append((next_r,next_c))

ans=float("inf")
for i in range(Center*2):
    bit=dp[H-1][W-1]>>i&1
    if bit==1:
        ans=min(ans,abs(i-Center))

print ans
### BUGGY CODE ###

X = int(input())
 
ans = 0
p = 2
A = set()
for i in range(X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

### FIXED CODE ###

X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)
### BUGGY CODE ###

import math

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
hb = n * (n - 1) // 2
result = [hb]
leder = [i for i in range(1, n + 1)]
size = [1 for i in range(n)]
for brk in ab[:0:-1]:
    if size[leder[brk[0] - 1] - 1] < size[leder[brk[1] - 1] - 1]:
        brk = brk[::-1]
    if leder[brk[0] - 1] != leder[brk[1] - 1]:
        hb -= size[leder[brk[0] - 1] - 1] * size[leder[brk[1] - 1] - 1]
        size[leder[brk[0] - 1] - 1] += size[leder[brk[1] - 1] - 1]
        size[leder[brk[1] - 1] - 1] = 0
    result.append(hb)
    # leder[leder[brk[1]-1]-1]=leder[brk[0]-1]
    leder = [i if i != leder[brk[1] - 1] else leder[brk[0] - 1] for i in leder]
for i in result[::-1]:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n


def leader_check(i):
    if leader[i] == -1:
        return i
    ln = leader_check(leader[i])
    leader[i] = ln
    return ln

for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la = leader_check(a)
    lb = leader_check(b)
    if la != lb:
        leader[la] = lb
        ans -= size[la] * size[lb]
        size[lb] += size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)
### BUGGY CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N=I()
  A=LI()

  l=[0]*1000100
  for x in A:
    l[x]+=1

  pairwise=True
  for i in range(2,1000100):
    cnt=0
    for j in range(i+1,1000100):
      cnt+=l[j]
    if cnt>1:
      pairwise=False

  if pairwise:
    return 'pairwise coprime'

  g=0
  for x in A:
    g=math.gcd(g,x)

  if g==1:
    return 'setwise coprime'

  return 'not coprime'

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N=I()
  A=LI()

  g=0
  for x in A:
    g=math.gcd(g,x)
  if g>1:
    return 'not coprime'

  sosu=[0]*1000100
  for x in A:
    if x==1:
      continue
    sosu[x]+=1
    if sosu[x]>1:
      return 'setwise coprime'
    for y in range(2,int(math.sqrt(x))+1):
      if x%y!=0:
        continue
      z=x//y
      if y==z:
        sosu[y]+=1
        if sosu[y]>1:
          return 'setwise coprime'
      else:
        sosu[y]+=1
        if sosu[y]>1:
          return 'setwise coprime'
        sosu[z]+=1
        if sosu[z]>1:
          return 'setwise coprime'

  return 'pairwise coprime'

# main()
print(main())
### BUGGY CODE ###

def MergeSort(num_list):
  n = len(num_list)
  
  if len(num_list) == 1:
    return num_list
  
  #1. 整列されていないリストを２つのサブリストに分割する
  mid = int(round(n/2))
  
  left = num_list[:mid]
  right = num_list[mid:]
  

  
  #2. 分割したリスト（サブリスト）を整列する。サブリストもマージソートを使って整列させる。（再帰関数）
  l = MergeSort(left)
  r = MergeSort(right)
  
  #3. 2つのサブリストをマージして１つの整列済みリストにする
  return Merge(l,r)
  
# 整列済みリストA、Bを使って、整列済みリストCを作成する
def Merge(A,B):
  C = []
#   print("A",A)
#   print("B",B)
  
  # 1. AとBの先頭の数字を比較し、小さい方をCに追加し追加した値はリストから削除する
  # 2. 手順1をどちらか一方のリストが空になるまで繰り返す。
  while (len(A) > 0) and (len(B) > 0):
    if A[0] < B[0]:
      C.append(A[0])
      del A[0]
    else:
      C.append(B[0])
      del B[0]
  
  # 3. 残った要素をCの末尾に追加する
  if len(A) > 0:
    C.extend(A)
  else:
    C.extend(B)
 
#   print("C",C)
  return C

n = int(input())
array =list(map(int, input().split()))

list = MergeSort(array)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[-i-1]
  ans -= list[-1]
else:
  for i in range((n-1)//2):
   ans += 2*list[-i-1]
  ans += list[-(n-1)//2-1]
  ans -= list[-1]
print(ans)




### FIXED CODE ###

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

list.sort(reverse=True)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[i]
  ans -= list[0]
else:
  for i in range((n-1)//2):
    ans += 2*list[i]
  ans += list[(n-1)//2]
  ans -= list[0]
print(ans)
### BUGGY CODE ###

import sys
import math
import itertools
import collections

def solve(N,M,X,C,A):
    lis = [i for i in range(N)]
    ans = []
    for c in itertools.combinations_with_replacement(lis,N):
        tmp = 0
        dic = {key:0 for key in range(M)}
        for i in set(c):
            tmp += C[i]
            for n,a in enumerate(A[i]):
                dic[n] += a
        for m in range(M):
            if(dic[m] < X):
                break
        else:
            ans.append(tmp)
    return min(ans) if(ans != []) else -1
def main():
    N,M,X = map(int,input().split())
    C = []
    A = []
    for _ in range(N):
        tmp = list(map(int,input().split()))
        C.append(tmp.pop(0))
        A.append(tmp)
    # solve()
    print(solve(N,M,X,C,A))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import itertools
import collections

def solve(N,M,X,C,A):
    lis = [i for i in range(N)]
    ans = []
    for k,_ in enumerate(lis,1):
        for c in itertools.combinations(lis,r=k):
            tmp = 0
            dic = {key:0 for key in range(M)}
            for i in set(c):
                tmp += C[i]
                for n,a in enumerate(A[i]):
                    dic[n] += a
            for m in range(M):
                if(dic[m] < X):
                    break
            else:
                ans.append(tmp)
    return min(ans) if(ans != []) else -1
def main():
    N,M,X = map(int,input().split())
    C = []
    A = []
    for _ in range(N):
        tmp = list(map(int,input().split()))
        C.append(tmp.pop(0))
        A.append(tmp)
    # solve()
    print(solve(N,M,X,C,A))

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

N = int(input())
S = input()
stack = []
ans = []

for s in S:
    for i in range(len(stack)):
        if len(stack[i]) <= 2:
            new = s + stack[i]
            if new not in stack:
                stack.append(new)
    if s not in stack:
        stack.append(s)
        
cnt = 0
for w_ in stack:
    if len(w_) == 3:
        cnt += 1
print(cnt)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)
### BUGGY CODE ###

import math
import sys
x = int(input())

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-100000, 100000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                sys.exit(0)
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                sys.exit(0)


### FIXED CODE ###

import math
import sys
x = int(input())

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-1000, 1000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                sys.exit(0)
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                sys.exit(0)
### BUGGY CODE ###

import numpy as np
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

p = np.array(p)
p1 = sum((p[0:0+k] + 1)/2)

ansum = np.array([p1])
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum = np.append(ansum, p1)

print(max(ansum))

### FIXED CODE ###

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

p1 = (sum(p[:k]) + k)/2

ansum = [p1]
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum.append(p1)

print(max(ansum))
### BUGGY CODE ###

s = list(input())

ans = 0
n = len(s)
for i in range(n):
    if s[i] == 'W':
        ans += s[:i].count('B')

print(ans)

### FIXED CODE ###

s = list(input())

ans = 0
count_b = 0
n = len(s)
for i in range(n):
    if s[i] == 'B':
        count_b += 1
    if s[i] == 'W':
        ans += count_b

print(ans)
### BUGGY CODE ###

import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import combinations
input = lambda: sys.stdin.readline().rstrip()


def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def check(a,b,c):
    if a < b + c and b < c + a and c < a + b:
        return True
    else:
        return False


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

    c = list(combinations(Ls, 3))

    cnt = 0
    for i in range(len(c)):
        cnt += check(*c[i])
    print(cnt)
    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from bisect import bisect_right
input = lambda: sys.stdin.readline().rstrip()


def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()
    cnt = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            #k以下なら良い
            k =  Ls[i] + Ls[j] -1
            # bisect_right(Ls, k)個の要素が左にある
            # 答え: bisect_right(Ls, k) - j
            cnt += max(bisect_right(Ls, k) - j-1, 0)
            # print(Ls, Ls[i],Ls[j],k, bisect_right(Ls,k)-j-1)
    print(cnt)
            

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

n = int(input())
point_list = []
for i in range(n):
  line = list(map(int, input().split()))
  point_list.append(line)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    x = abs(point_list[i][0] - point_list[j][0]) + abs(point_list[i][1] - point_list[j][1])
    if x > ans:
      ans = x
print(ans)
              

### FIXED CODE ###

n = int(input())
x = []
y = []
z = []
for i in range(n):
  a,b = map(int, input().split())
  x.append(a+b)
  y.append(a-b)
  z.append(b-a)
print(max(max(x) - min(x),max(y) - min(y),max(z) - min(z)))
### BUGGY CODE ###

n,k,q=map(int,input().split())
lst=[k]*n
for i in range(q):
  person=int(input())
  for j in range(n):
    if j!=person-1:
      lst[j]-=1
for p in range(n):
  if lst[p]<=0:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

n,k,q=map(int,input().split())
lst=[0]*n
for i in range(q):
  person=int(input())
  lst[person-1]+=1
for p in range(n):
  temp=k-q+lst[p]
  if temp<=0:
    print("No")
  else:
    print("Yes")
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

for i, num in enumerate(a):
#    print(i, num)
    cnt = 0
    for j in range(i, len(a)):
        if a[j] == i+1:
            cnt += 1
    print(cnt)
print('0')


### FIXED CODE ###

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

for i, value in enumerate(a):
    b[value-1] += 1

for j in b:
    print(j) 

print('0')
### BUGGY CODE ###

#-*- coding: utf-8 -*-
import math
a,b,n = map(int,input().split())
ma = 0
for i in range(1,n+1):
    ans = math.floor(a*i/b) - (a * math.floor(i/b))
    ma = max(ma,ans)

print(ma)


### FIXED CODE ###

#-*- coding: utf-8 -*-
import math
a,b,n = map(int,input().split())
x = min(b-1,n)
ans = math.floor(a*x//b)-a*math.floor(x/b)
print(ans)
### BUGGY CODE ###

import sys
n = int(input())
a = list(input().split())
b =list(map(int,a))
aa = list(set(b))
x = []
y = []
c = 1
for i in range(1,n+1):
    x.append(i)
for j in aa:
    if j in x and 1 in aa:
        pass
    else:
        print("-1")
        sys.exit()
for k in a:
    if int(k) == c:
        y.append(k)
        c = c + 1
print(len(a)-len(y))


### FIXED CODE ###

import sys
n = int(input())
a = list(map(int, input().split()))

num =  1
ans = 0
if 1 not in a:
    print(-1)
    sys.exit()
for i in a:
    if i == num:
        num += 1
    else:
        ans += 1
print(ans)