Harryxun/stf_run huggingface dataset:
import itertools


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

a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]

A_pattern = list(itertools.combinations_with_replacement(A, M)) # 10^5

ans = 0

for a_pattern in A_pattern: # 数列全部調べる
    ansi = 0
    for i in range(Q): # 得点になるかどうか調べる

        if a_pattern[b[i]-1] - a_pattern[a[i]-1] == c[i]: # A[bi] - A[ai] == ci -> ansi += di
            ansi += d[i]

    ans = max(ans, ansi)


print(ans)


### FIXED CODE ###

import itertools


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

a = []
b = []
c = []
d = []

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]

A_pattern = list(itertools.combinations_with_replacement(A, N))

ans = 0

for a_pattern in A_pattern: # 数列全部調べる
    ansi = 0
    for i in range(Q): # 得点になるかどうか調べる
        if a_pattern[b[i]-1] - a_pattern[a[i]-1] == c[i]: # A[bi] - A[ai] == ci -> ansi += di
            ansi += d[i]

    ans = max(ans, ansi)


print(ans)
am,n = list(map(int,input().split()))
arr = list(map(int,input().split()))
got = 0
for i in range(am):
	if arr[i]>=1/(4*am):
      got+=1
if got >=n:
	print("YES")
else:
  print("NO")

### FIXED CODE ###

am,n = list(map(int,input().split()))
arr = list(map(int,input().split()))
got = 0
s = sum(arr)
for i in range(am):
    if arr[i]>=s*(1/(4*n)):
        got+=1
if got >=n:
    print("Yes")
else:
    print("No")
S, T = map(str, input().split())

print("{}{}",format(T, S))

### FIXED CODE ###

S, T = map(str, input().split())

print("{}{}".format(T, S))
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
lis = list(range(1,n+1))
a,b = None,None
P = readInts()
Q = readInts()
i = 0
for A in permutations(lis,n):
    if list(A) == P:
        a = i
    elif list(A) == Q:
        b = i
    i += 1
print(abs(a-b))


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import itertools
    n = int(input())
    # indexの中身 を 使うときは, list じゃなくて、 tuple じゃないとだめええ
    p = tuple(map(int,input().split()))
    q = tuple(map(int,input().split()))
    # 初期リスト
    num = [i + 1 for i in range(n)]
    per = list(itertools.permutations(num))
    # permutations 全て tuple だから 合わせろ!
    print(abs(per.index(q) - per.index(p)))



if __name__ == '__main__':
  main()
oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
newMoney = 0
for i in range(10):
    if str(i) not in hateLines and str(i) > oldMoney[0]:
        okLines.append(i)
for index,m in enumerate(oldMoney):
    if m in hateLines and okLines is not None:
        oldMoney[index] = okLines[0]
print("".join(oldMoney))

### FIXED CODE ###

oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
FirstBigList = []
newMoney = list(oldMoney)


def FindFirstBig(okLines, m, FirstBig):
    for i in okLines:
        if i > m:
            FirstBig.append(i)
    return FirstBig


for i in range(10):
    if str(i) not in hateLines:
        okLines.append(str(i))

FirstFlag = -1
ProblemFlag = -1
for index, m in enumerate(oldMoney):
    if FirstFlag == -1:
        if m in hateLines:
            FirstBigList = FindFirstBig(okLines, m, FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[index] = FirstBigList[0]
                FirstFlag = index
            ProblemFlag = index
    elif FirstFlag != -1:
        newMoney[index] = okLines[0]

if oldMoney == newMoney:
    if ProblemFlag is not 0 and ProblemFlag is not -1:
        FirstBigList.clear()
        while ProblemFlag:
            FirstBigList = FindFirstBig(okLines, newMoney[ProblemFlag - 1], FirstBigList)
            if len(FirstBigList) > 0:
                newMoney[ProblemFlag - 1] = FirstBigList[0]
                for i in range(ProblemFlag, len(newMoney), 1):
                    newMoney[i] = okLines[0]
            if oldMoney == newMoney:
                ProblemFlag -= 1
    if ProblemFlag is 0:
        if okLines[0] != '0':
            newMoney.insert(0, okLines[0])
        else:
            newMoney.insert(0, okLines[1])
        for i in range(ProblemFlag + 1, len(newMoney), 1):
            newMoney[i] = okLines[0]
resultnew = "".join(newMoney)
print(resultnew)
import copy
def func(n):
    result = []
    result.append([1,2])
    result.append([2,1])
    if n == 2:
        return result
    else:
        #for i in range(3,n+1):
        res_list = func(n-1)
        res = []
        for j in range(n):
            for s in res_list:
                st = copy.copy(s)
                st.insert(j,n)
                res.append(st)
        return res

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

s = func(n)
s.sort()
p_i = 0
q_i = 0
for i in range(n):
    #print(s[i])
    if s[i]==p:
        p_i = i
    if s[i]==q:
        q_i = i
print(abs(p_i,q_i))


### FIXED CODE ###

import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

l = [int(x) for x in range(1,n+1)]
i = 0
p_i = 0
q_i = 0
for v in itertools.permutations(l, len(l)):
    i += 1
    if p==list(v):
        p_i = i
        #print(list(v))
    if q==list(v):
        q_i = i
        #print(i,list(v))
print(abs(p_i-q_i))
n, p = map(int, input().split())
s = list(map(int, input()))
ans = 0

if p == 2 or p == 5:
    for i, x in enumerate(s):
        if (p == 2 and not x % 2) or (p == 5 and (x == 0 or x == 5)):
            ans += i+1
    print(ans)
    exit()

s.reverse()
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = (cum[i] + s[i] * pow(10, i, p)) % p
t = [0] * 10
for x in cum: t[x] += 1

for x in t:
    ans += x * (x-1) // 2
print(ans)


### FIXED CODE ###

n, p = map(int, input().split())
s = list(map(int, input()))
ans = 0

if p == 2 or p == 5:
    for i, x in enumerate(s):
        if (p == 2 and not x % 2) or (p == 5 and (x == 0 or x == 5)):
            ans += i+1
    print(ans)
    exit()

s.reverse()
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = (cum[i] + s[i] * pow(10, i, p)) % p
t = [0] * p
for x in cum: t[x] += 1

for x in t:
    ans += x * (x-1) // 2
print(ans)
N,K = map(int, input().split())
p = list(map(int, input().split()))
sump0=0
for i in range(N-2):
 
  sump=p[i]+p[i+1]+p[i+2]
  if sump>sump0:
		sum0=sump
    
print(sum0/2+K/2)

### FIXED CODE ###

import itertools
 
n, k = map(int, input().split())
p = list(map(int, input().split()))
acc = [0] + list(itertools.accumulate([(x+1)/2 for x in p])) # 累積和を計算
 
ans = max(acc[i]-acc[i-k] for i in range(k, n+1)) # k番目からn番目まで計算
print(ans)
N = int(input())
A = list(map(int,input().split()))
A_oddList = A[::2]
A_evenList = A[1::2]
A_oddList = A_oddList[::-1]
A_evenList = A_evenList[::-1]

if N % 2 == 1:
    print(*A_oddList ,*A_evenList)
else:
    A_oddList = A_oddList[::-1]
    print(*A_evenList , *A_oddList)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A_oddList = A[::2]
A_evenList = A[1::2]
A_oddList = A_oddList[::-1]
A_evenList = A_evenList[::-1]

if N % 2 == 1:
    A_evenList = A_evenList[::-1]
    print(*A_oddList , end = " ")
    print(*A_evenList)
else:
    A_oddList = A_oddList[::-1]
    print(*A_evenList , end = " ")
    print(*A_oddList)
N=int(input())
list = []
flg = True
for A in range(1,int((N+1)**0.5)):
    for B in range(1,N+1):
        if A*B==N:
            if len(str(A)) > len(str(B)):
                list.append(len(str(A)))
                print(list)
            else:
                list.append(len(str(B)))

        #print(list)
list.sort()
print((list[0]))


### FIXED CODE ###

N = int(input())
ans = len(str(N))
for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        #print(i)
        #print("leng",len(str(N/i)))
        #print(ans,len(str(i)),len(str(N//i)),len(str(int(N/i))))
        ans = min(ans,max(len(str(i)),len(str(N//i))))
print(ans)
N, M = map(int, input().split())
F = [list(map(int, input().split())) for i in range(M)]

G = []

for i, f in enumerate(F):
    new_grp = True
    for j, g in enumerate(G):
        if f[0] in g:
            if f[1] not in g:
                G[j].append(f[1])
                new_grp = False
        if f[1] in g:
            if f[0] not in g:
                G[j].append(f[0])
                new_grp = False
    if new_grp:
        G.append(f)

print(max(map(len, G)))


### FIXED CODE ###

N, M = map(int, input().split())
F = [list(map(int, input().split())) for i in range(M)]

d = [-1]*N


def find(x):
    if d[x] < 0:
        return x
    d[x] = find(d[x])
    return d[x]


def union(x, y):
    x, y = find(x), find(y)
    if x == y:
        return
    if (d[x] > d[y]):
        x, y = y, x
    d[x] += d[y]
    d[y] = x


for f in F:
    union(f[0]-1, f[1]-1)
print(-min(d))
n,a,b = map(int, input().split())

shou = n // (a+b)
amari = n % (a+b)

print(shou * a + a) if amari >= a

print(shou * a + amari) if amari < a

### FIXED CODE ###

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

shou = n // (a+b)
amari = n % (a+b)

if amari >= a:
    print(shou * a + a)

else: print(shou * a + amari)
m,n=input().slide()
x=(m-1)n
print(x)

### FIXED CODE ###

m,n=map(int,input().split())
print((m-1)*(n-1))
N,X=map(int, raw_input().split())

p=[1]
a=[1]
for i in range(N):
	p.append( p[-1]*2+1 )
	a.append( a[-1]*2+3 )

#print "p:::",p
#print "a::::",a

X-=1

ans=0
def f(N,X):
	global ans
#	print "f (",N ," , ", X ," ) " ,ans

	if N==0:
		if X>=-1:
			return 1
		else:
			return 0
	elif X>=a[N]/2:
		X-=(a[N-1]+2)
		ans+=p[N-1]+1
		f(N-1,X)
	elif X<a[N]/2:
		X-=(a[N-1]+2)
		ans+=f(N-1,X)

	X-=(a[1]+2)

f(N,X)

print ans


### FIXED CODE ###

N,X=map(int, raw_input().split())

a,p=[1], [1]
for i in range(N):
	a.append(a[-1]*2+3)
	p.append(p[-1]*2+1)

def f(N,X):
	if N==0:
		return 0 if X<=0 else 1
	elif X<=1 + a[N-1]:
		return f(N-1,X-1)
	else:
		return p[N-1]+1+f(N-1, X-2-a[N-1])

print f(N,X)
if N%1000==0:
  return (0)
else:
  return (1000-N%1000)

### FIXED CODE ###

N = int(input())
if N%1000==0:
  print(0)
else:
  print(1000-N%1000)
N,K = map(int,input().split())

s = [t for t in range(1,N+1)]
for i in range(K):
    d = int(input())
    A = list(map(input().split()))
    if A[i] in s:
        s.remove(A[i])
    K -= 1
print(lne(s))

### FIXED CODE ###

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

s = [t for t in range(1,N+1)]
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for i in range(len(A)):
        if A[i] in s:
            s.remove(A[i])
print(len(s))
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
print(ans)

### FIXED CODE ###

import math
import copy
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
if N > 2:
    print(ans)
else:
    print(1)
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[n,m] = inpl()
fibsec = [0]*n
fibsec[0] = 1
fibsec[1] = 1
fibsec[-1] = 0
for i in range(2,n-1):
    fibsec[i] = fibsec[i-1]+fibsec[i-2]

firsta = -1
for k in range(m):
    seconda = inp()
    ans = ans*(fibsec[seconda-firsta -2 ])%mod
    firsta = seconda

ans = ans*(fibsec[n-firsta-1])%mod
    
print(ans)

### FIXED CODE ###

from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[n,m] = inpl()
fibsec = [0]*(n+2)
fibsec[0] = 1
fibsec[1] = 1
fibsec[-1] = 0
for i in range(2,n+1):
    fibsec[i] = fibsec[i-1]+fibsec[i-2]

firsta = -1
for k in range(m):
    seconda = inp()
    ans = ans*(fibsec[seconda-firsta -2 ])%mod
    firsta = seconda

ans = ans*(fibsec[n-firsta-1])%mod
    

print(ans)
a = int(input())
x  = 0
lists = []
ass =[]
#bが気温c、standardが平均気温の基準
b,standard = map(int,input().split())
#標高
elev = list(map(int,input().split()))

for i in range(a):
    lists.append(abs(b - elev[i] * 0.006 - standard))

m = min(lists)
mindex = lists.index(1.0)
print(mindex + 1)


### FIXED CODE ###

a = int(input())
x  = 0
lists = []
ass =[]
#bが気温c、standardが平均気温の基準
b,standard = map(int,input().split())
#標高
elev = list(map(int,input().split()))

for i in range(a):
    lists.append(abs(b - elev[i] * 0.006 - standard))

m = min(lists)
mindex = lists.index(m)
print(mindex + 1)
def solve():
    from sys import stdin
    #f_i = stdin
    f_i = open('test_in_3')#
    
    N = f_i.readline().rstrip()
    N = N[::-1] + '0'
    
    INF = 10 ** 32
    
    import numpy as np
    dp = np.full((len(N), 2), INF)
    dp[0][0] = 0
    
    for i, x in enumerate(int(n) for n in N[:-1]):
        ni = i + 1
        dp[ni][0] = min(dp[i] + x)
        dp[ni][1] = min(dp[i][0] + 11 - x, dp[i][1] + 9 - x)
    
    ans = min(dp[-1])
    
    print(ans)

solve()

### FIXED CODE ###

def solve():
    N = input()
    
    INF = 10 ** 32
    
    dp = [[INF, INF] for i in range(len(N) + 1)]
    dp[0][0] = 0
    
    for i, x in enumerate(int(n) for n in N[::-1]):
        ni = i + 1
        dp[ni][0] = min(dp[i][0] + x, dp[i][1] + x)
        dp[ni][1] = min(dp[i][0] + 11 - x, dp[i][1] + 9 - x)
    
    ans = min(dp[-1])
    
    print(ans)

solve()
O = input()
E = input()
s = ''
while O or E:
    if len(E) >= len(O):
        s = E.pop() + s
    else:
        s = O.pop() + s
print(s)

### FIXED CODE ###

O = list(input())
E = list(input())
s = ''
while O or E:
    if len(E) >= len(O):
        s = E.pop() + s
    else:
        s = O.pop() + s
print(s)
import numpy as np
c=list(map(int, input().split()))
print(np.gcd.reduce(c))

### FIXED CODE ###

import fractions as f
n=int(input())
c=list(map(int, input().split()))
for i in range(1,n):
    c[i]=f.gcd(c[i-1],c[i])
ans=0
while True:
    if c[n-1]/2==c[n-1]//2:
        ans+=1
        c[n-1]/=2
    else:
        break
print(ans)
import math
from functools import reduce

# 最小公倍数を求める関数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm = lcm_list(a)

ans = 0
for i in range(n):
    ans += (lcm-1) % a[i]

print(ans)

### FIXED CODE ###

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

ans = sum(a)-n

print(ans)
k = int(input())
a,b = map(int,input().split())
for i in range(a,b):
  if i % k == 0:
    ans = 'OK'
  else:
    ans = 'No'
print(ans)

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
p = a % k
q = k - p
if (p == 0) or ((a + q) <= b):
    print('OK')
else:
    print('NG')
import sys
input = sys.stdin.readlinefrom collections
import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))

if __name__ == '__main__':
    main()


### FIXED CODE ###

#import sys
#input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    d = deque()
    for a in A:
        t = bisect_right(d, a)
        if t == 0:
            d.appendleft(a)
            continue
        if d[t-1] == a:
            t = bisect_left(d, a)
        if t == 0:
            d.appendleft(a)
        else:
            d[t-1] = a
    print(len(d))
if __name__ == '__main__':
    main()
A,B,C = map(int,input().split())
#B＋CがAより少ないなら０
if B+C =< A:
    print(0)
else:
    print(C+B-A)

### FIXED CODE ###

A,B,C=map(int,input().split())
if B+C <= A:
    print(0)
else:
    print(C+B-A)
l = list(map(int, input().split()))

if l[0]<2 or l[0]>20 or l[1]<1 or l[1]>20:
	sys.exit()

a = 0
while l[0] <= l[1]:
	l[1] = l[1] - l[0]
	a += 1
print(a)

### FIXED CODE ###

S=input()
T=input()
if len(S)>3 or len(S) < 1 or len(T)>3 or len(T) < 1:
  sys.exit()

a = 0
if S[0] == T[0]:
  a += 1
if S[1] == T[1]:
  a += 1
if S[2] == T[2]:
  a += 1

print(a)
import fractions

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

total=0
left=[0]*(N+1)
right=[0]*(N+1)

for i in range(N):
    left[i+1]=(fractions.gcd(left[i]),A[i])
    left[i + 1] = (fractions.gcd(left[N-1]), A[N-1-i])

for i in range[N]:
    total=max(total,fractions.gcd(left[i]),right[N+1])
    
print(total)

### FIXED CODE ###

from fractions import gcd


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

total=0
left=[0]*(N+1)
right=[0]*(N+1)

for i in range(N):
    left[i+1]=gcd(left[i],A[i])
    right[N -i - 1] = gcd(right[N-i], A[N-1-i])

for i in range(N):
    total=max(total,gcd(left[i],right[i+1]))

print(total)
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

from fractions import gcd
from math import floor

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  max_n = floor(n ** 0.5) + 1
  is_prime = [True for x in range(max_n)]
  
  for cursor in two_and_odds(max_n):
    if n == 1: break
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

def two_and_odds(max_n):
  yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()


### FIXED CODE ###

# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

import itertools
from fractions import gcd
from math import ceil

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  if n == 1:
    return [1]
  elif n % 2 == 0:
    fac = [1, 2]
    while n % 2 == 0:
      n = n // 2
  
  max_n = ceil(n ** 0.5) + 1
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

if __name__ == "__main__":
  main()
r=map(int,raw_input().split())
print ('%f %f' (float2*M_PI*r,floatr*r*M_PI)

### FIXED CODE ###

import math
r = float(raw_input())
print "%f %f" % (math.pi* r*r, math.pi*r*2)
D = sorted(list(map(int,input().split())))
A,B,C = D
if (C-B)%2==0 and (B-A)%2==0:
    n = (C-B)//2+(C-A)//2
elif (C-B)%2==1 and (B-A)%2==0:
    n = (B-A)//2+(C-B)
elif (C-B)%2==0 and (B-A)%2==1:
    n = (C-B)//2+1 +(C+1-A)//2
elif (C-B)%2==1 and (B-A%2==1):
    n = 1+(C-B-1)//2+(C-A-1)//2
print(n)

### FIXED CODE ###

A = sorted(list(map(int,input().split())))
a,b,c = A[0],A[1],A[2]
if (b-a)%2==0:
    cnt = (b-a)//2+c-b
else:
    cnt = 1+(b+1-a)//2+c-b
print(cnt)
a = input()
a[3]=8
print(a)

### FIXED CODE ###

a = input().split("/")
a[0]="2018"
print(a[0]+"/"+a[1]+"/"+a[2])
[int(i) for i in input().join(' ')]
N = input()
M = input()

items = [int(i) for i in input().join(' ')]
items.sort()
total = sum(items)

flag = 1
for i in range(M):
  if 1 // (4 * M) >= items[i]:
    pass
  else:
    flag = 0
if not flag:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N,M = [int(i) for i in input().split()]

items = [int(i) for i in input().split()]
items.sort(reverse=True)
total = sum(items)

flag = 1
for i in range(M):
  if total / (4 * M) <= items[i]:
    pass
  else:
    flag = 0
if flag:
  print('Yes')
else:
  print('No')
nums = input().split()
a = int(nums[0])
b = int(nums[1])
print(a * b,(a + b) * 2)

### FIXED CODE ###

x = int(input())
print( x ** 3)
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if pair < 1:
      continue
    #print(pair)
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

print(pairCounter)

### FIXED CODE ###

from sys import stdin

def main():
    A=stdin.readline().replace('B', '0').replace('W', '1')
    #A=list(map(int,bw))
    #A = list(map(int,stdin.readline().replace('B', '0').replace('W', '1')))

    wc = A.count('1')
    indices = [i for i, x in enumerate(A) if x == '1']
    if wc > 0:
      print(sum(indices) - 1*wc*(wc-1) //2 )
    else:
      print(sum(indices))

input = lambda: stdin.readline()
main()