Harryxun/stf_run huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ca = [0]*(n+1)
cb = [0]*(n+1)
for i in a:
    ca[i] += 1
for i in b:
    cb[i] += 1
ma = 0
ind = -1
for i in range(n+1):

    if ca[i]+cb[i]> ma:
        ma = ca[i]+cb[i]
        ind = i
    if ma > n:
        print("No")
        exit()

print("Yes")
ans = [-1]*n
l = a.index(ind)+ca[ind]
s = b.index(ind)
for i in range(s,s+n):
    ans[(l+i)%n] = b[i%n]
print(*ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b = b[::-1]

l = []
num = -1
for i in range(n):
    if a[i] == b[i]:
        l.append(i)
        num = a[i]

ind = 0
for i in range(n):
    if b[i] != num and a[i] != num and ind < len(l):
        b[i],b[l[ind]] = b[l[ind]],b[i]
        ind += 1
if ind < len(l):
    print("No")
else:
    print("Yes")
    print(*b)
#!/usr/bin/env python3
import sys

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [[int()] * (M+1) for _ in range(N)] # type: "List[int]"

    for i in range(N):
        A[i] = [int(next(tokens)) for _ in range(M+1)]
    
    # print(A)

    import numpy as np
    A = np.array(A)
    min_c = [10000000]

    def dfs(k, dep):
        if dep == N-1:
            if (k[1:]>=X).all():
                min_c[0] = min(min_c[0], k[0])
            elif (k[1:]+A[dep][1:]>=X).all():
                min_c[0] = min(min_c[0], k[0]+A[dep][0])
        else:
            dfs(k+A[dep],dep+1)
            dfs(k,dep+1)

    dfs(A[0], 1)          
    dfs(np.zeros(M+1,dtype=int), 1)
    
    if min_c[0] != 10000000:
        print(min_c[0])
    else:
        print(-1)




if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = np.zeros((N,M+1))
    for i in range(N):
        A[i] = [int(next(tokens)) for _ in range(M+1)]
    
    min_c = [10000000]

    def dfs(k, dep):
        if dep == N-1:
            if (k[1:]>=X).all():
                min_c[0] = min(min_c[0], k[0])
            elif ((k+A[dep])[1:]>=X).all():
                min_c[0] = min(min_c[0], k[0]+A[dep][0])
        else:
            dfs(k+A[dep],dep+1)
            dfs(k,dep+1)
    
    dfs(np.zeros(M+1), 0)
    
    if min_c[0] != 10000000:
        print(int(min_c[0]))
    else:
        print(-1)




if __name__ == '__main__':
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []

now = a[0]
path.append(now)

for i in range(1, k+1):
    now = a[now-1]
    if now in path:
        now = a[a.index(now) + (k-i)%(len(path) - a.index(now) - 1)]
        break
    path.append(now)

print(now)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
alr = [0 for i in range(n)]
now = 1
path = [now]

for i in range(k):
    now = a[now-1]
    # if now in path:
    #     now = path[path.index(now) + (k-i-1)%(len(path) - path.index(now))]
    #     break
    if alr[now-1] != 0:
        now = path[path.index(now) + (k-i-1)%(len(path) - path.index(now))]
        break
    path.append(now)
    alr[now-1] += 1

print(now)
inp = str(input())
n, m = tuple(inp.split())
m_calculation = math.factorial(m)/2**(m/2)*math.factorial(m/2)
n_calculation = math.factorial(n)/2**(n/2)*math.factorial(n/2)
print(n_calculation + m_calculation)

### FIXED CODE ###

n,m = map(int,input().split())
 
print(n*(n-1)//2+m*(m-1)//2)
import math

a, b = map(int, input().split())
print((a * b) // math.gcd(a, b))

### FIXED CODE ###

def gcd(n, m):
    r = n % m
    if r == 0:
        return m
    else:
        return gcd(m, r)


a, b = map(int, input().split())
print((a * b) // gcd(a, b))
N, P = map(int, input().split())

d = int(pow(P, 1/N))
for i in range(int(pow(P, 1/N))+1, 0, -1):
  if P % i**N == 0:
    d = i
    break
print(d)

### FIXED CODE ###

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

if N == 1:
  d = P
else:
  d = 1
  i = 2
  while i <= round(pow(P, 1/N)):
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  k=str(i)
  keta=0
  for j in range(len(k)):
    keta+=k[j]
  if k>=a and k<=b:
    ans+=i
print(ans)

### FIXED CODE ###

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  k=str(i)
  keta=0
  for j in range(len(k)):
    keta+=int(k[j])
  if keta>=a and keta<=b:
    ans+=i
print(ans)
N=int(input())
A=list(map(int,input().split()))
ans=[]
for i in A:
    ans[i-1]+=1
for j in ans:
    print(j)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=[0]*N
for i in A:
    ans[i-1]+=1
for j in ans:
    print(j)
(a, b) = map(int, raw_input().split())
print("%d %d" % (a * b, 2 * (a + b)))

### FIXED CODE ###

a, b = map(int, raw_input().split())
print ("%d %d" % (a * b, 2 * (a + b)))
import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

i = 0
total_cost = 0
 
a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

for i in range(2, N):
    #a[i] = min(a[max(i-2,0)] + abs(hs[i] - hs[max(i-2,0)]),
    #           a[max(i-1,0)] + abs(hs[i] - hs[max(i-1,0)]))
    
    b = np.zeros(K, int)
    for j in range(K):
        b[j] = a[max(i-(j+1),0)] + abs(hs[i] - hs[max(i-(j+1),0)])
    a[i] = np.min(b)    
print(a[-1])

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
hs = np.array(list(map(int, input().split())))

a = np.zeros(N, int)
a[0] = 0
a[1] = abs(hs[1] - hs[0])

if N == 2:
    print(a[-1])
else:
    for i in range(2, N):
        b = a[max(i-K,0):i] + np.abs(hs[i] - hs[max(i-K,0):i])
        a[i] = np.min(b)
    print(a[-1])
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

s.sort()
t.sort()

i = 0
cnt = 0

for x in t:
	if i < n:
		while s[i] <= x:
			if s[i] == x:
				cnt += 1
			i += 1
	else:
		break

print(cnt)

### FIXED CODE ###

n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]

cnt = 0

for x in t:
	if x in s:
		cnt += 1

print(cnt)
M = int(input())
N = []

ans = 0
prev_d = 0
for i in range(M):
    d, c = map(int, input().split())
    N += [d] * c
    ans += c
    if prev_d + d > 9:
        ans += 1
    prev_d = d

print(ans-1)


### FIXED CODE ###

M = int(input())

s = 0
dig = 0
for i in range(M):
    d, c = map(int, input().split())
    s += d * c
    dig += c

print(dig - 1 + (s - 1) // 9)
import itertools
n = int(input())
s = tuple(map(int, input()))
a = tuple(set(itertools.combinations(s, 3)))
ans = len(a)
print(ans)


### FIXED CODE ###

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 + 1 == m2 and d2 == 1:
    print(1)
else:
    print(0)
k,a,b=map(int,input().split());print(-1if a<b else 2*((k-1)//(a-b))+1)

### FIXED CODE ###

k,a,b=map(int,input().split());print(1+2*((k-a-1)//(a-b)+1)if a-b>0 else(1 if k<=a else -1))
a, b = map(int, input().split())
if a>b:
    print(a>b)
else if a<b:
    print(a<b)
else
    print(a=b)

### FIXED CODE ###

a,b = map(int, input().split(' '))
if a>b:
    print('a > b')
elif a<b:
    print('a < b')
else:
    print('a == b')
from collections import deque
N, D, A = map(int, input().split())

ys = []
hs = []
for i in range(N):
    X, H = map(int, input().split())
    ys.append((X,i))
    hs.append(-(-H//A))

ys = sorted(ys, key=lambda x : x[0])
l = ys[0][0] + 2*D
li = 0
dmg = 0
r = 0
for y, i in ys:
    while l <= y:
        li += 1
        l = ys[li][0] + 2*D
        dmg -= hs[ys[li][1]]
    tr = max(0, hs[i]-dmg)
    hs[i] = tr
    dmg += tr
    r += tr
print(r)


### FIXED CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
N, D, A = map(int, input().split())

ys = []
for _ in range(N):
    X, H = map(int, input().split())
    ys.append((2*X, -(-H//A)))
    ys.append((2*X+4*D+1, -(-H//A)))

ys = sorted(ys, key=lambda x : x[0])
d1 = dict()
d2 = dict()
ls = []
c = 0
hs = [0]
for i, (y, h) in enumerate(ys):
    if y%2:
        d1[y-1-4*D] = c
    else:
        c += 1
        d2[y] = c
        ls.append(y)
        hs.append(h)

lls = []
for i in range(N):
    lls.append(d1[ls[i]]-d2[ls[i]]+1)

X = Bit(N+1)

r = 0
for i in range(N):
    n = lls[i]
    x = hs[i+1] + X.sum(i+1)
    if x <=0:
        continue
    r += x
    X.add(i+1, -x)
    X.add(i+1+n, x)
print(r)
#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_3
from  itertools import accumulate
mod=1000000007
n=int(input())
s=input()
dp=[1]*n
for i in range(n-1):
    if s[i]==">":
        dp.reverese()
        dp=list(accumulate(dp[:-1]))
        dp.reverse()
    else:
        dp=list(accumulate(dp[:-1]))
    for j in range(len(dp)):
        dp[j]%=mod
print(dp[0])

### FIXED CODE ###

#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_3
from  itertools import accumulate
mod=1000000007
n=int(input())
s=input()
dp=[1]*n
for i in range(n-1):
    if s[i]==">":
        dp.reverse()
        dp=list(accumulate(dp[:-1]))
        dp.reverse()
    else:
        dp=list(accumulate(dp[:-1]))
    for j in range(len(dp)):
        dp[j]%=mod
print(dp[0])
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    t =     _in[1]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    s_arr = [_s for _s in s]
    t_arr = [_t for _t in t]
    s_arr.sort()
    t_arr.sort(reverse=True)
    s = ''.join(s_arr)
    t = ''.join(t_arr)
    if s==t:
        TF = 'Yes' if len(s)<len(t) else 'No'
    else:
        for i in range(min(len(s),len(t))):
            if s[i] != t[i]:
                TF = 'Yes' if s[i]<t[i] else 'No'
                break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


### FIXED CODE ###

from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    t =     _in[1]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    s_arr = [_s for _s in s]
    t_arr = [_t for _t in t]
    s_arr.sort()
    t_arr.sort(reverse=True)
    s = ''.join(s_arr)
    t = ''.join(t_arr)
    if s==t:
        TF = 'Yes' if len(s)<len(t) else 'No'
    else:
        TF = 'Yes' if s<t else 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)
n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z'))]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)


### FIXED CODE ###

#171C
##One Quadrillion and One Dalmatians

n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z')+1)]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)
def solver(a, b, c, d, e, f):
    answer = []

    m = a / d

    d = d * m
    e = e * m
    f = f * m

    y = (c - f)/(b - e)

    x = (c - b * y)/a
    answer.append(x)
    answer.append(y)

    return answer




while 1:
    try:
        p_1, p_2, p_3, p_4, p_5, p_6 = map(float, raw_input().split())

        ans = []
        ans = solver(p_1, p_2, p_3, p_4, p_5, p_6)

        print "%.3f %.3f" % (ans[0], ans[1])


    except:

### FIXED CODE ###

while 1:
    def solver(a, b, c, d, e, f):
        answer = []

        if d == 0:
            y = f / e
            x = (c - b * y)/a

        else:
            m = a / d

            d = d * m
            e = e * m
            f = f * m

            y = (c - f)/(b - e)

            x = (c - b * y)/a

            if x == -0:
                x = 0
            if y == -0:
                y = 0

        answer.append(x)
        answer.append(y)
        return answer

    try:
        p_1, p_2, p_3, p_4, p_5, p_6 = map(float, raw_input().split())

        ans = []
        ans = solver(p_1, p_2, p_3, p_4, p_5, p_6)

        print "%.3f %.3f" % (ans[0], ans[1])

    except:
        break
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    x, y, z, w = ns()
    size = [[0, x], [1, y], [2, z]]
    size.sort(key=lambda x: x[1])
    d = []
    for _ in range(3):
        tmp = na()
        tmp.sort(reverse=True)
        d.append(tmp)

    d2 = []
    for i, s in size:
        d2.append(d[i])

    lima = min(size[0][1], 15)
    limb = min(size[1][1], int((3375 / lima) ** (1 / 2)) + 1)
    limc = min(size[2][1], int((3375 / lima / limb) ** (1 / 2)) + 2)

    ans = []
    for i in range(lima):
        for j in range(limb):
            for k in range(limc):
                ans.append(d2[0][i] + d2[1][j] + d2[2][k])
    ans.sort(reverse=True)

    for i in range(w):
        print(ans[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    x, y, z, w = ns()
    a = na()
    b = na()
    c = na()

    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)

    ans = []
    for ai in a:
        for bi in b:
            ans.append(ai + bi)

    ans.sort(reverse=True)
    ans = ans[:3010]

    res = []
    for ci in c:
        for i in range(len(ans)):
            res.append(ci + ans[i])
    res.sort(reverse=True)

    for i in range(w):
        print(res[i])


if __name__ == '__main__':
    main()
K,A,B = map(int,input().split())
if A <= B % K == 0 and A or B % K == 0:
	print("OK")
else:
    print("NG")


### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
ans="NG"

for i in range(1001):
  if A<=i*K and i*K<=B:
    ans="OK"
    break

print(ans)
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

for k in range(N):
    A[k] -= k

A.sort()


def get_pity_sum(x):
    pity_sum = 0
    for l in A:
        if A[x] - l >= 0:
            pity_sum += A[x] - l
        else:
            pity_sum += l - A[x]
    return pity_sum


if N % 2 == 1:
    c = get_pity_sum(int((N - 1) / 2))
    print(min(c, get_pity_sum(int((N - 1) / 2 - 1)), c + (A[int((N - 1) / 2) + 1] - A[int((N - 1) / 2)]) * 2, c + (A[int((N - 1) / 2)] - A[int((N - 1) / 2 - 1)]) * 2))
else:
    d = get_pity_sum(int(N / 2))
    print(min(get_pity_sum(int(N / 2)), d + (A[int(N / 2) + 1] - A[int(N / 2)]) * 2))

### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

for k in range(N):
    A[k] -= k

A.sort()


def get_pity_sum(x):
    pity_sum = 0
    for l in A:
        if A[x] - l >= 0:
            pity_sum += A[x] - l
        else:
            pity_sum += l - A[x]
    return pity_sum


if N % 2 == 1:
    c = get_pity_sum(int((N - 1) / 2))
    if N == 1:
        print(c)
    else:
        print(min(c, get_pity_sum(int((N - 1) / 2 - 1)), c + (A[int((N - 1) / 2) + 1] - A[int((N - 1) / 2)]) * 2, c + (A[int((N - 1) / 2)] - A[int((N - 1) / 2 - 1)]) * 2))
else:
    d = get_pity_sum(int(N / 2))
    print(min(get_pity_sum(int(N / 2)), d + (A[int(N / 2) + 1] - A[int(N / 2)]) * 2))
n = int(input())
arr = list(map(int,input().split()))

arr.sort()

prev = arr[0]

for i in range(n-1)
  prev = (prev+arr[i+1])/2
  
print(prev)



### FIXED CODE ###

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

arr.sort()

prev = arr[0]

for i in range(n-1):
  prev = (prev+arr[i+1])/2
  
print(prev)
n,m = map(int.input().split())
if n < 10:
    print(m+(100*(10-n)))
else:
   print(m)

### FIXED CODE ###

n,m = map(int,input().split())
if n < 10:
    print(m+(100*(10-n)))
else:
   print(m)
"""
import sys
sys.setrecursionlimit(10 ** 6)
"""
n, q = map(int, input().split())
cnt = [0] * n
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

def dfs(cur, par):
    for chi in tree[cur]:
        if chi == par:
            continue
        cnt[chi] += cnt[cur]
        dfs(chi, cur)
dfs(0, -1)
print(*cnt)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, q = map(int, input().split())
cnt = [0] * n
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

for i in range(q):
    p, x = map(int, input().split())
    cnt[p - 1] += x

def dfs(cur, par):
    for chi in tree[cur]:
        if chi == par:
            continue
        cnt[chi] += cnt[cur]
        dfs(chi, cur)
dfs(0, -1)
print(*cnt)
S = list(input())

if S[0] == "Y" and S[1] == "A" and S[2] == "K" and S[3] == "I":
    print("Yes")
else:
    print("No")


 
    

### FIXED CODE ###

S = input()

if S[:4] == "YAKI":
    print("Yes")
else:
    print("No")
n= int(input())
a=list(map(int, input().split()))
b = [0]*(n+1)
c = [0]*(n+1)
su = 0

for x in range(n):
    b[a[x]] += 1

for y in range(len(b)):
    if b[y] >=2:
        c[y]=combinations_count(b[y], 2)
    else:
        c[y]=0
    su += c[y]

for z in range(n):
    if c[a[z]] > 0:
        ans = su - (b[a[z]] - 1)
    else:
        ans = su

    print(str(ans))

### FIXED CODE ###

import math

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

n= int(input())
a=list(map(int, input().split()))
b = [0]*(n+1)
c = [0]*(n+1)
su = 0

for x in range(n):
    b[a[x]] += 1

for y in range(len(b)):
    if b[y] >=2:
        c[y]=combinations_count(b[y], 2)
    else:
        c[y]=0
    su += c[y]

for z in range(n):
    if c[a[z]] > 0:
        ans = su - (b[a[z]] - 1)
    else:
        ans = su

    print(str(ans))
n = int(input())
a = list(map(int, input().split()))
for  i in range(1,n+1):
    v  = a[i]
    j = i-1
    while a[j]>v and j>=0:
        a[j] = v
        j -=1
    print(*a)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
for  i in range(n):
    v  = a[i]
    j = i-1
    while a[j]>v and j>=0:
        a[j+1] = a[j]
        j -=1

    a[j+1] = v
    print(*a)
S, T = map(input().split())
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        C+=1
print cnt

### FIXED CODE ###

S = input()
T = input()
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        cnt+=1
print(cnt)
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
answer= 1
if n!=1: np.sign(a[1]-a[0])
for i in range(1,n-1):
	num = np.sign(a[i+1]-a[i])
	if flag==0:
		flag = num
	elif num==-flag:
		answer += 1
		flag = 0
print(answer)

### FIXED CODE ###

import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
answer = 1
if n!=1: flag = np.sign(a[1]-a[0])
for i in range(1,n-1):
	num = np.sign(a[i+1]-a[i])
	if flag==0:
		flag = num
	elif num==-flag:
		answer += 1
		flag = 0
print(answer)
import math

x1, y1, x2, y2 = map(int, input().split())

dx = x1 - x2
dy = y1 - y2

d = math.hypot(dx, dy)

print(d)

### FIXED CODE ###

import math

x1, y1, x2, y2 = map(float, input().split())

dx = x1 - x2
dy = y1 - y2

d = math.hypot(dx, dy)

print(d)
N, MOD = int(input()), 10**9+7
count = 0
def dfs(index,last3):
	if index == N:
		return 1
	c_next = 'AT'
	if 'AC' in last3[1:]:
		c_next + 'G'
	if 'AG' in last3 == False:
		if  last3[1:] != 'GA':
			if last3[0]+last3[2] != 'AG':
				c_next + 'C'

	for c in c_next:
		count += dfs(index+1,last3[1:]+c)

print(dfs(0,'TTT'))

### FIXED CODE ###

N, MOD = int(input()), 10**9+7
memo = [{} for i in range(N+1)]
# Keyが直前の三文字、Valueが作れる文字列の数
# ↑これを文字列の今の長さごとにメモする
# memo[6]['TTT']には直前の三文字がTTTで、
# 6文字目以降の条件に合う文字列の総数が入ってる


# めも化再帰
def dfs(index,last3):
	if last3 in memo[index]:
		return memo[index][last3]
	if index == N:
		return 1
	c_next = 'AT'
	if last3[1:] != 'AC':
		c_next += 'G'
	if ('AG' in last3) == False:
		if  last3[1:] != 'GA':
			if last3[0]+last3[2] != 'AG':
				c_next += 'C'
	count = 0
	for c in c_next:
		count += dfs(index+1,last3[1:]+c)
		count %= MOD

	memo[index][last3] = count
	return count

print(dfs(0,'TTT'))
a,b = map(int,input())
if a>b:
    print("a > b")
elif a<b:
    print("a < b")
else:
    print("a == b")

### FIXED CODE ###

a,b = map(int,input().split())
if a>b:
    print("a > b")
elif a<b:
    print("a < b")
else:
    print("a == b")
n = 0
X = 0
while X<1:
	# print(L)
	K = len(L)-1
	# print(K)
	for i in range(K):
		if L[i]+L[i+1]==1:
			L.pop(i)
			L.pop(i)
			n=n+1
			break
		elif i == K-1:
			X=1

# print(L)
print(n*2)


### FIXED CODE ###

A,B,C = map(int,input().split())

print(min(int(B/A), C))
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def calc_rle(s):
    tmp, count, ans = s[0], 1, ""
    for i in range(1, len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans += tmp + str(count)
            tmp = s[i]
            count = 1
    ans += tmp + str(count)
    return ans


s = S()
rle = calc_rle(s)
print(rle)
if rle[0] == 'W':
    rle = rle[2:]
if rle[-2] == 'B':
    rle = rle[:-2]
# print(rle)
rle = [[rle[i], eval(rle[i+1])] for i in range(0, len(rle), 2)]
# print(rle)
ans = 0
for i in range(0, len(rle), 2):
    # print(rle[i], rle[i+1])
    ans += rle[i][1] * rle[i + 1][1]
    if i + 2 < len(rle):
        rle[i + 2][1] += rle[i][1]
    # print(f'{ans=}')
print(ans)


### FIXED CODE ###

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
ans = 0
w_cnt = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - w_cnt  # その W の場所までにあった B の数
        w_cnt += 1

print(ans)