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

# -*- coding: utf-8 -*-
#文字列と文字列の長さ取得、文字列をリスト化
S = input()
N = len(S)
S = list(S)

#文字列に"BW"が含まれていないかのチェック
i=0
count = 0
while(i<N):
	#iがリストの最後に到達するとbreak
	if(i==N-1):
		break
	else:
		#i番目が"B"でi+1番目が"W"のとき置き換え、置き換えた回数を数える。
		if(S[i] == 'B' and S[i+1] == 'W'):
			S[i] = 'W'
			S[i+1] = 'B'
			count = count + 1
			i = -1
	i = i + 1
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
S = input()
N = len(S)
S = list(S)

count = 0
count2 = 0
kekka = 0
for i in range(len(S)):
	if(S[i] == 'B'):
		count = count + 1
		count2 = count2 + i
for j in range(count):
	kekka = kekka + N - j-1

print(kekka-count2)
### BUGGY CODE ###

N,C=map(int, raw_input().split())
X=[ tuple( map(int, raw_input().split()) ) for i in range(N)]
T=[]
R=[]

a=[]
for i in range(N):
	temp=[]
	for j in range(i+1):
		temp.append(X[j])

	back=X[i][0]

	for j in range(N-1,i,-1):
		x=C-X[j][0]
		v=X[j][1]
		temp.append( (x+back*2,v) )
	val=0
	for x,y in temp:
		val+=y
		a.append(val-x)


for i in range(N):
	
	temp=[]
	for j in range(N-1,N-i-2,-1):
		x=C-X[j][0]
		v=X[j][1]
		temp.append( (x,v) )
	back=C-X[N-1-i][0]

	for j in range(N-i-1):
		x=X[j][0]
		v=X[j][1]
		temp.append( (x+back*2,v) )
	val=0
	for x,y in temp:
		val+=y
		a.append(val-x)


print max(0,max(a))

### FIXED CODE ###

N,C=map(int, raw_input().split())
X=[ tuple( map(int, raw_input().split()) ) for i in range(N)]
T=[]
R=[]

a=[]

v_sum=0
for x,v in X:
	v_sum+=v
	T.append(v_sum-x)

a+=T

v_sum=0
for x,v in X[::-1]:
	v_sum+=v
	R.append(v_sum-(C-x))

a+=R



T_MAX=[]
val=float("-inf")
for i in T:
	val=max(val,i)
	T_MAX.append(val)


R_MAX=[]
val=float("-inf")
for i in R:
	val=max(val,i)
	R_MAX.append(val)


for i in range(N):
	extra_x=X[i][0]
	if N-i-2>=0:
		val=T[i]+R_MAX[N-i-2]-extra_x
		a.append(val)


for i in range(N):
	extra_x=C-X[N-i-1][0]
	if N-i-2>=0:
		val=R[i]+T_MAX[N-i-2]-extra_x
		a.append(val)


print max(0,max(a))
### BUGGY CODE ###

l = input().split(" ")
w = int(l[0])
h = int(l[1])
n = int(l[2])

array = [[0 for i in range(h)] for j in range(w)]

for i in range(n):
	l = input().split(" ")
	x = int(l[0]) - 1
	y = int(l[1]) - 1
	array[x][y] = 1

ans = [0 for i in range(10)]

for i in range(h-2):
	for j in range(w-2):
		a = 0
		for y in range(3):
			for x in range(3):
				a += array[j+x][i+y]

		ans[a] += 1

for a in ans:
	print(a)

### FIXED CODE ###

"""
l = input().split(" ")
w = int(l[0])
h = int(l[1])
n = int(l[2])

array = [[0 for i in range(h)] for j in range(w)]

for i in range(n):
	l = input().split(" ")
	x = int(l[0]) - 1
	y = int(l[1]) - 1
	for i in range(3):
		for j in range(3):
			if x+j-1 >=0 and x+j-1<w and y+i-1 >=0 and y+i-1<h:
				array[x+j-1][y+i-1] += 1

ans = [0 for i in range(10)]

for i in range(h-2):
	for j in range(w-2):
		ans[array[j+1][i+1]] += 1

for a in ans:
	print(a)

"""

l = input().split(" ")
w = int(l[0])
h = int(l[1])
n = int(l[2])

array = dict()

for i in range(n):
	l = input().split(" ")
	x = int(l[0])
	y = int(l[1])
	for i in range(3):
		if y-i < 1 or y-i > h-2:
			continue
		for j in range(3):
			if x-j < 1 or x-j > w-2:
				continue
			if (x-j, y-i) in array:
				array[(x-j, y-i)] +=1
			else:
				array[(x-j, y-i)] = 1

ans = [0] * 10
ans[0] = (h-2) * (w-2)
 
for i in array:
    ans[array[i]] += 1
    ans[0] -= 1

for i in range(10):
    print(ans[i])
### BUGGY CODE ###

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return y


def gcd_3(x, y, z):
    x_y = gcd(x, y)
    return gcd(x_y, z)


K = int(input())
ans = 0

sum_list = []


for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            ans += gcd(gcd(i, j), k)

print(ans)

### FIXED CODE ###


import math
k = int(input())
s = 0
box = [0]*(k+1)
for l in range (1,k+1):
     for m in range (1, k+1):
          box[math.gcd(l,m)] += 1
for l in range (1,k+1):
     for n in range (1, k+1):
          s += math.gcd(l,n)*box[l]
print(s)
### BUGGY CODE ###

N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
start = 0
queue = [start]
pre = [None]*N
pre[0] = 0
while queue:
    v = queue.pop(0)
    for i in adj[v]:
        if pre[i] is None:
            pre[i] = v
            queue.append(i)
if None in pre:
    print("No")
else:
    print("Yes")
    for p in pre[1:]:
        print(p+1)

### FIXED CODE ###

N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
start = 0
queue = [start]
pre = [None]*N
pre[0] = 0
while queue:
    v = queue.pop(0)
    for i in adj[v]:
        if pre[i] is None:
            pre[i] = v
            queue.append(i)
if None in pre:
    print("No")
else:
    print("Yes")
    for p in pre[1:]:
        print(p+1)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        a[i] = 1

for i in range(q):
    l, r = map(int, input().split())
    lr = s[l-1:r]
    print(sum(a[l-1:r-1]))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        a[i+1] = 1
    if i > 0:
        a[i] += a[i-1]
a[n-1] += a[n-2]

for i in range(q):
    l, r = map(int, input().split())
    t = a[r-1]-a[l-1]
    print(t)
### BUGGY CODE ###

from sys import stdin
from itertools import repeat
def main():
    r, c = map(int, stdin.readline().split())
    n = int(stdin.readline())
    a = map(int, stdin.read().split(), repeat(10, 3 * n))
    rs = [[] for i in xrange(c)]
    cs = [[] for i in xrange(r)]
    for i in xrange(n):
        a[i*3] -= 1
        y = a[i*3]
        a[i*3+1] -= 1
        x = a[i*3+1]
        rs[x].append((y, a[i*3+2]))
        cs[y].append((x, a[i*3+2]))
    v = [None] * c
    rd = [None] * r
    st = []
    pu = st.append
    po = st.pop
    for i in xrange(c):
        if v[i] is not None:
            continue
        if not rs[i]:
            continue
        mnc = v[i] = rs[i][0][1]
        pu((rs[i][0][0], rs[i][0][1], i, 0))
        mnr = 0
        while st:
            y, base, x, dr = po()
            for nx, val in cs[y]:
                tmp = val - dr
                if v[nx] is None:
                    v[nx] = tmp
                    if mnc > tmp:
                           mnc = tmp
                elif v[nx] != tmp:
                    print "No"
                    return
                for ny, nval in rs[nx]:
                    if not rd[ny]:
                        rd[ny] = 1
                        if 0 > nval - tmp < -mnr:
                            mnr = tmp - nval
                        pu((ny, nval, nx, nval - tmp))
        if mnc < mnr:
            print "No"
            return
    print "Yes"
main()

### FIXED CODE ###

from sys import stdin
from itertools import repeat
def main():
    r, c = map(int, stdin.readline().split())
    n = int(stdin.readline())
    a = map(int, stdin.read().split(), repeat(10, 3 * n))
    rs = [[] for i in xrange(c)]
    cs = [[] for i in xrange(r)]
    for i in xrange(n):
        a[i*3] -= 1
        y = a[i*3]
        a[i*3+1] -= 1
        x = a[i*3+1]
        rs[x].append((y, a[i*3+2]))
        cs[y].append((x, a[i*3+2]))
    v = [None] * c
    rd = [None] * r
    st = []
    pu = st.append
    po = st.pop
    for i in xrange(c):
        if v[i] is not None:
            continue
        if not rs[i]:
            continue
        mnc = rs[i][0][1]
        pu((rs[i][0][0], rs[i][0][1], i, 0))
        mnr = 0
        while st:
            y, base, x, dr = po()
            for nx, val in cs[y]:
                tmp = val - dr
                if v[nx] is None:
                    v[nx] = tmp
                    if mnc > tmp:
                           mnc = tmp
                    for ny, nval in rs[nx]:
                        if not rd[ny]:
                            rd[ny] = 1
                            if 0 > nval - tmp < -mnr:
                                mnr = tmp - nval
                            pu((ny, nval, nx, nval - tmp))
                elif v[nx] != tmp:
                    print "No"
                    return
        if mnc < mnr:
            print "No"
            return
    print "Yes"
main()
### BUGGY CODE ###

def is_prime(n, cf):
    for i in cf:
        if i * i > n:
            return 1  # False
        if n % i == 0:
            return 0  # True
    else:
        return 1


def cf(a, b):
    return [i for i in range(2, (min(a, b)) + 1) if a % i == 0 and b % i == 0]


a, b = map(int, input().split())
# a, b = 12, 18
data = cf(a, b)
ans = 0
for n in data:
    ans += is_prime(n, data)
print(ans + 1)
# def sieve(n):
#     is_prime = list(repeat(True, len(n)))
#     prime = []
#     p = 0
#     for i in range(len(n)):
#         if is_prime[i]:
#             p += 1
#             prime.append(n[i])
#             for j in range(2 * n[i], n, i):
#                 is_prime[j] = False
#     return p, prime

# def sieve(n):
#     is_prime = list(repeat(True, n))
#     prime = []
#     p = 0
#     for i in range(2, n):
#         if is_prime[i]:
#             p += 1
#             prime.append(i)
#             for j in range(2 * i, n, i):
#                 is_prime[j] = False
#     return p, prime

# print(sieve(n))
# print(sieve(10000))


### FIXED CODE ###

from collections import defaultdict

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


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


d = gcd(A, B)
# print(d)


def f(v):
    dic = defaultdict(int)
    if v == 1:
        dic[1] = 1
        return dic
    for i in range(2, v):
        if i * i > v:
            break
        while v % i == 0:
            v //= i
            dic[i] += 1
    if v != 1:
        dic[v] += 1
    dic[1] = 1
    return dic


divisor = f(d)
# print(divisor)
print(len(divisor))
### BUGGY CODE ###

s = input()
q = int(input())
counter = 1
lista = [list(input().split()) for i in range(q)]

def rever(i):
    if i == '1':
        return 1
    else:
        return -1
for i in lista:
    if i[0] == '1':
        counter = -1 * counter
    else:
        if counter * rever(i[1]) > 0:
            s = i[2] + s
        else:
            s = s + i[2]
if counter > 0:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

from collections import deque

s = deque(input())
q = int(input())
counter = 1
lista = [list(input().split()) for i in range(q)]

def rever(i):
    if i == '1':
        return 1
    else:
        return -1
for i in lista:
    if i[0] == '1':
        counter = -1 * counter
    else:
        if counter * rever(i[1]) > 0:
            s.appendleft(i[2])
        else:
            s.append(i[2])
s = "".join(list(s))
if counter > 0:
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
a.sort()
ans=0
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
MOD=10**9+7
def comb(n, k):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % MOD        
        ret = ret * pow(i, MOD - 2, MOD) % MOD
        
    return ret
for i in range(n-k+1):
    ans-=a[i]*comb(n-i-1,k-1)
    ans%=mod
a.sort(reverse=True)
for i in range(n-k+1):
    ans+=a[i]*comb(n-i-1,k-1)
    ans%=mod

print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
mod=10**9+7
ans=0
MOD=10**9+7

factorial = [1]
inverse = [1]
for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))
 
 
# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD
for i in range(n-k+1):
    ans-=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod
a=a[::-1]
for i in range(n-k+1):
    ans+=a[i]*nCr(n-i-1,k-1)%mod
    ans%=mod

print(ans%mod)
### BUGGY CODE ###

s = input()
q = int(input())
q_datas = [input().split() for _ in range(q)]

output_string = s

for query in q_datas :
    if query[0] == '1':
        output_string = output_string[::-1]
    else:
        if query[1] == '1':
            output_string = query[2] + output_string
        else:
            output_string = output_string + query[2]

print(output_string)

### FIXED CODE ###

s = input()
q = int(input())
q_datas = [input().split() for _ in range(q)]

direction = 1  # 操作を始める前の向きを1、逆を-1とする
output_string = s
string1 = ''
string2 = ''

change_direction_count = 0
for query in q_datas :
    if query[0] == '1':
        direction *= -1
        change_direction_count += 1
    else:
        if query[1] == '1' and direction == 1:
            string1 = query[2] + string1
        elif  query[1] == '1' and direction == -1:
            string2 = string2 + query[2]
        elif  query[1] == '2' and direction == 1:
            string2 = string2 + query[2]
        else: # query[1] == '2' and direction == -1
            string1 = query[2] + string1

if change_direction_count % 2 == 0:
    print(string1 + s + string2)
else:
    print(string2[::-1] + s[::-1] + string1[::-1])
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import factorial 
def main():
    x, y = map(int, readline().split())
    if ((2*y-x)%3) or ((2*x-y)%3):
        print(0)
        return
    a = (2*y-x)//3
    b = (2*x-y)//3
    if a < 0:
        print(0)
        return
    if b < 0:
        print(0)
        return
    P = int(1e9)+7
    def c(n, m):
        ch = 1
        for i in range(m):
            ch *= (n-i)
            ch %= P
        b = factorial(m) 
        b = pow(b, P-2, P)
        return ch*b%P
    print(c(a+b, a)) 
if __name__ == '__main__':
    main()


### FIXED CODE ###

#python3
from math import factorial
from math import floor
MOD = int(1e9+7)

def comb(n, m, mod):
    comb_a = 1
    for i in range(m): 
        comb_a *= (n-i)
        comb_a %= mod
    comb_tmp = factorial(m) 
    comb_b = pow(comb_tmp, mod-2, mod)
    return (comb_a * comb_b)%mod
def main():
    x, y = map(int, input().split())
    k = (2*x-y)/3
    l = (2*y-x)/3

    if floor(k) - k != 0:
        print(0)
        return
    if floor(l) - l != 0:
        print(0)
        return 
    if k<0:
        print(0)
        return
    if l<0:
        print(0)
        return
    k = int(k)
    l = int(l)
    print(comb(k+l, k, MOD)%MOD) 

main()
### BUGGY CODE ###

import itertools

def warshall_floyd(D, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                D[i][j] = min(D[i][j], D[i][k]+D[k][j])


N, M, R = map(int, input().split())
r = list(map(int, input().split()))
D = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    D[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    D[a-1][b-1] = c
    D[b-1][a-1] = c

warshall_floyd(D, N)

ans = float('inf')
for P in itertools.permutations(r):
    cost = 0
    for i in range(R-1):
        cost += D[P[i]-1][P[i+1]-1]
    ans = min(ans, cost)

print(ans)

### FIXED CODE ###

import itertools

def warshall_floyd(D, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                D[i][j] = min(D[i][j], D[i][k]+D[k][j])


N, M, R = map(int, input().split())
r = list(map(int, input().split()))
D = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    D[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    D[a-1][b-1] = c
    D[b-1][a-1] = c

warshall_floyd(D, N)

ans = float('inf')
for P in itertools.permutations(r):
    cost = 0
    for i in range(R-1):
        cost += D[P[i]-1][P[i+1]-1]
    ans = min(ans, cost)

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

def solve(N,x):
    ans = []
    cnt = 0
    for i in range(N):
        if 2**i & x != 0:
            cnt += 1

    ans_dict = {}
    for i in range(10**3):
        ans_dict[i] = cal(i,0,{})

    for i in range(N):
        x ^= 2**(N-i-1)
        ans.append(cal(x,0,ans_dict))
        x ^= 2**(N-i-1)
    return ans

def cal(x,rec,ans_dict):
    if x in ans_dict:
        return ans_dict[x] + rec
    else:
        cnt,dig = 0,0
        while 2**dig <= x:
            if 2**dig & x != 0:
                cnt += 1
            dig += 1

        if cnt == 0:
            return rec
        else:
            amari = 0
            for i in range(dig):
                if x & 2**i != 0:
                    amari += pow(2,i,cnt)
                    amari %= cnt
            return cal(amari,rec+1,ans_dict)

def main():
    N = int(input())
    X = input()

    x = 0
    for i in range(N):
        if X[i] == "1":
            x += pow(2,N-i-1)

    ans = solve(N,x)
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def solve(N,X):
    ans = []
    cnt = X.count("1")
    rem_ori = [0,0]
    for i in range(N):
        if X[i] == "1":
            if cnt != 1:
                rem_ori[0] += pow(2,N-i-1,cnt-1)
                rem_ori[0] %= (cnt-1)
            else:
                rem_ori[0] = 0
            rem_ori[1] += pow(2,N-i-1,cnt+1)
            rem_ori[1] %= (cnt+1)

    rem = [(rem_ori[0] if X[i] == "1" else rem_ori[1]) for i in range(N)]
    for i in range(N):
        if X[i] == "1":
            if cnt != 1:
                rem[i] -= pow(2,N-i-1,cnt-1)
                rem[i] %= (cnt-1)
                ans.append(cal(rem[i],1))
            else:
                ans.append(0)
        else:
            rem[i] += pow(2,N-i-1,cnt+1)
            rem[i] %= (cnt+1)
            ans.append(cal(rem[i],1))

    return ans

def cal(rem,rec):
    if rem == 0:
        return rec
    else:
        b = bin(rem)[2:]
        cnt = b.count("1")
        rem %= cnt
        return cal(rem,rec+1)

def main():
    N = int(input())
    X = input()

    ans = solve(N,X)
    for i in range(N):
        print(ans[i])

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

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

m = 10 ** 9 + 7

def comb(n, r, m):
  ans = 1
  for i in range(r):
    ans *= (n-i) * pow(i+1, m-2, m) % m
  return ans
  
print((pow(2,n,m)-1-comb(n,a,m)-comb(n,b,m))%m)


### FIXED CODE ###

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

m = 10 ** 9 + 7

def comb(n, r, m):
  ans = 1
  for i in range(r):
    #ans = ans * (n-i) * pow(i+1, m-2, m) % m
    ans *= (n-i) * pow(i+1, m-2, m) % m
    ans %= m
    # *= で書いてしまうとans自体にmod計算されないので
    # 大きな数が発生して遅くなる．
    # ans %= mを追加すれば早い？
    
  return ans
  
print((pow(2,n,m)-1-comb(n,a,m)-comb(n,b,m))%m)
### BUGGY CODE ###

num=raw_input()
out=0
for i in range(len(num)):
    #out+=num[i:].count(num(i))
    #print len(num[i:])-num[i:].count(num[i])
    out+=len(num[i:])-num[i:].count(num[i])

print out+1

### FIXED CODE ###

num=raw_input()
out=0
d={}
for i in set(num):
    d[i]=num.count(i)
#print d
#aaa
for i in range(len(num)):
    #out+=num[i:].count(num(i))
    #print len(num[i:])-num[i:].count(num[i])
    #out+=len(num[i:])-num[i:].count(num[i])
    out+=len(num[i:])-d[num[i]]
    d[num[i]]-=1

print out+1
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
B = []
C = 0
for i in range(N + 1):
  B.append(A.count(i))
  C += int(B[i] * (B[i] - 1) / 2)
for j in range(N):
  print(0 if B[A[j]] < 2 else C + 1 - B[A[j]])

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
L = {key:(B[key] * (B[key] - 1) // 2) for key in B}
total = sum(L.values())
#print(f"A = {A}\nB = {B}\nL = {L}\ntotal = {total}")
[print(total if L[i] == 0 else total - L[i] + ((B[i] - 1) * (B[i] - 2) // 2)) for i in A]
### BUGGY CODE ###

import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split())) #A[0]〜A[N-1]

m = min(A)
answer = N

for i in range(N-K+1): #A[i:i+K]〜A[N-K:N]
  if not m in A[i:i+K]:
    continue
  answer = min(answer,
              (1 + math.ceil(i/(K-1)) + math.ceil((N-K-i)/(K-1))))
print(answer)

### FIXED CODE ###

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

print((N-1)//(K-1) + bool((N-1)%(K-1)))
### BUGGY CODE ###

import math

# 入力の取得(1行目。数値)
i = list(map(int, input().split()))

# 変数セット
# 1.購入する品物の数
itemCount = i[0]
# 2.割引券の数
discountTicketsCount = i[1]

# 入力の取得(2行目。数値)
priceList = list(map(int, input().split()))

# 割引件数分ループ
for i in  range(discountTicketsCount):

    # 全アイテムに対して、割引券を使った場合の試算を行う
    discountPrice = 0
    shouldUseItem = 0
    for idx , price in enumerate(priceList):

        # 割引券使用による割引金額を取得
        workDiscountPrice = math.ceil(price - (price / 2))

        # 最も割引金額が多い場合、候補として変数に格納
        if workDiscountPrice > discountPrice:
            discountPrice = workDiscountPrice
            shouldUseItem = idx

    # 割引金額が最大の品物に割引券を使用
    priceList[shouldUseItem] -= discountPrice

# 合計金額を出力
print(sum(priceList))


### FIXED CODE ###

import math
import heapq

# 入力の取得(1行目。数値)
i = list(map(int, input().split()))

# 変数セット
# 1.購入する品物の数
itemCount = i[0]
# 2.割引券の数
discountTicketsCount = i[1]

# 入力の取得(2行目。数値)
priceList = list(map(int, input().split()))

# 「符号反転した」リストを優先度付きキューに変換
# ★ポイント★
# heapqは最小値しか取り出せないため、
# 符号反転してからキューに変換=>最小値を取る、という手法を行う。
priceList = [ n * -1 for n in priceList]
heapq.heapify(priceList)

# 割引件数分ループ
for i in  range(discountTicketsCount):

    # キューから最小値の取り出し(ここで符号反転も行っておく)
    target = abs(heapq.heappop(priceList))

    # 2で割る。(小数点切り下げ)
    target = math.floor(target / 2)

    # 割引券利用後の金額をキューに格納(ここで符号反転する)
    heapq.heappush(priceList, target * -1)

# 合計金額を出力
print(abs(sum(priceList)))
### BUGGY CODE ###

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

for i in range(1,n+1): #1~nについて
    b[i-1] = a.index(i) + 1

print(' '.join(map(str, b)))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0 for j in range(n)]

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

print(*b)
### BUGGY CODE ###

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

bar.sort(reverse=True)
ans = 0

while len(bar) > 1:
    a = bar.pop()
    cnt = 0
    for i in range(len(bar)-1,-1,-1):
        b = bar[i]
        cnt += 1
        for j in range(len(bar)-1-cnt,-1,-1):
            c = bar[j]
            if c < (a+b):
                ans += 1
            else:
                break
print(ans)

### FIXED CODE ###

import bisect

n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0

for i in range(n):
    for j in range(i+1,n):
        T=bisect.bisect_left(L,L[i]+L[j])
        count += T-j-1

print(count)