Harryxun/stf_run huggingface dataset:
N = int(input())
l = []
sumB = 0
for i in range(N):
    tmp = map(int, input().split())
    l.append(tmp[0] + tmp[1])
    sumB += tmp[1]
l.sort(reverse=True)
A = 0
for i in range(0, N, 2):
        A += l[i]
print(A - sumB)

### FIXED CODE ###

N = int(input())
l = []
sumB = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    l.append(tmp[0] + tmp[1])
    sumB += tmp[1]
l.sort(reverse=True)
A = 0
for i in range(N):
    if i % 2 ==0:
        A += l[i]
print(A - sumB)
def create_array(n: int, r: int, mod, mod2):
    m_ls = [1] * (r + 1)

    for i, j in zip(range(n, 0, -1), range(1, r + 1)):
        m_ls[j] = (m_ls[j - 1] * i * pow(j, mod2, mod)) % mod
    return m_ls


def main():
    n, a, b = map(int, input().split())
    _mod = 1_000_000_007
    _mod2 = 1_000_000_005

    m_ls = create_array(n, b, _mod, _mod2)

    _all_cnts = pow(2, n, _mod) - 1
    ans = _all_cnts + (_mod - m_ls[a]) + (_mod - m_ls[b])
    ans %= _mod

    print(ans)


main()


### FIXED CODE ###


def create_array(n: int, r: int, mod, mod2):
    m_ls = [1] * (r + 1)

    for i, j in zip(range(n, 0, -1), range(1, r + 1)):
        m_ls[j] = (m_ls[j - 1] * i * pow(j, mod2, mod)) % mod
    return m_ls


def main():
    n, a, b = map(int, input().split())
    _mod = 1000000007
    _mod2 = 1000000005

    m_ls = create_array(n, b, _mod, _mod2)

    _all_cnts = pow(2, n, _mod) - 1
    ans = _all_cnts + (_mod - m_ls[a]) + (_mod - m_ls[b])
    ans %= _mod

    print(ans)


main()
n, x = map(int, input().split())
l = list(map(int, input().split()))

d = [0]*(n+1)
for i in range(n):
    d[i+1] = d[i] + l[i]
    
ans = 0
for j in range(n+2):
    if d[j] <= x:
        ans += 1
    else:
        break

print(ans)

### FIXED CODE ###

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

d = [0]*(n+1)
for i in range(n):
    d[i+1] = d[i] + l[i]
    
ans = 0
for j in range(n+1):
    if d[j] <= x:
        ans += 1
    else:
        break

print(ans)
from math import log2

N, K = map(int, input().split())
A = [int(a) for a in input().split()]

if K == 0:
    n = 0
else:
    n = int(log2(K)) + 1


def f(X):
    return sum(map(lambda a: X ^ a, A))


B = [0 for _ in range(n)]
result = [0 for _ in range(n)]

for a in A:
    for i in range(n):
        B[i] += (a >> i) & 1

#print(B)

for i in range(n):
    if B[i] * 2 < N and (K > (1 << i)):
        result[i] = 1

#print(result)

x = eval('0b' + ''.join(map(str, result[::-1])))

#print(x)

print(f(x))


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(a) for a in input().split()]

n = 41

B = [0 for _ in range(n)]
result = [0 for _ in range(n)]

for a in A:
    for i in range(n):
        B[i] += (a >> i) & 1

#print(B)

result = 0
k_rest = K

for i in list(range(n))[::-1]:
    if B[i] * 2 < N and (k_rest >= (1 << i)):
        k_rest = k_rest - (1 << i)
        result += (1 << i) * (N - B[i])
    else:
        result += (1 << i) * B[i]

print(result)
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
S.replace('dream','')
S.replace('dreamer','')
S.replace('erase','')
S.replace('eraser','')

if len(S) = 0:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

# -*- coding: utf-8 -*-

import re
# 整数の入力
S = input()
S=re.sub('dreamer(?!ase)','',S)
S=re.sub('eraser(?!ase)','',S)
S=S.replace('dream','')
S=S.replace('erase','')
 
if len(S) == 0:
  print('YES')
else:
  print('NO')
counter = 1
while true:
    x = int(input())
    if x == 0 : 
        break
    else :
        print("Case {}: {}".format(counter,x))
        counter = counter + 1



### FIXED CODE ###

ans = []
for i, x in enumerate(open(0).readlines()):
    ans.append("Case %d: %s" % (i+1, x))
open(1,'w').writelines(ans[:-1])
a = input()
s = input()

if a >= 3200:
  print(s)
else:
  print('Red')

### FIXED CODE ###

a = input()
s = input()
 
if int(a) >= 3200:
  print(s)
else:
  print('red')
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    C=list(map(int,input().split()))
    
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N,MOD)
    
    def COM(n, k, MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    C.sort(reverse=1)
    ans=0
    for i in range(N):
        ans+=(pow(2,i,MOD)+i*pow(2,i-1,MOD))*2*pow(2,N-(i+1),MOD)*C[i]
        ans%=MOD
    ans*=pow(2,N-1,MOD)
    ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    C=list(map(int,input().split()))
    
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N,MOD)
    
    def COM(n, k, MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    def modinv(a, mod):
        b,u,v = mod,1,0
        while b:
            t=a//b
            a-=t*b
            a,b=b,a
            u-=t*v
            u,v=v,u
        u%=mod
        if u < 0:
            u+=mod
        return u

    def modpow(n,k,MOD):
        if k<0:
            return pow(modinv(n,MOD),-k,MOD)
        else:
            return pow(n,k,MOD)
    
    C.sort(reverse=1)
    ans=0
    for i in range(N):
        ans+=(modpow(2,i,MOD)+i*modpow(2,i-1,MOD))*2*modpow(2,N-(i+1),MOD)*C[i]
        ans%=MOD
    ans*=pow(2,N-1,MOD)
    ans%=MOD
    print(ans)

if __name__ == '__main__':
    main()
K=int('K')
if K==1:
 print('ACL')
elif K==2:
 print('ACL'*2)
elif K==3:
 print('ACL'*3)
elif K==4:
 print('ACL'*4)
else:
 print('ACL'*5)


### FIXED CODE ###

print('ACL'*int(input()))
A,B = int(input().split())
if A <= 5:
  price = B
elif A >=6 and A <= 12:
  price = B/2
else:
  price = B
print(B)

### FIXED CODE ###

A,B = map(int,input().split())
if A <= 5:
  price = 0
elif A >=6 and A <= 12:
  price = B/2
else:
  price = B
print(int(price))
l=int(input())
v=float((l/3)**3)
print(f'{v:.15e}')

### FIXED CODE ###

l=int(input())
v=float((l/3)**3)
print(v)
import sys
sys.setrecursionlimit(100000000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("$" * (2 + h)))
	for i in range(0, w) : array.append(list("$" + raw_input().replace(" ", "") + "$"))
	array.append(list("$" * (2 + h)))
	
	count = 0
	for i in range(1, h + 1):
		for j in range(1, w + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("0" * (2 + h)))
	for i in range(0, w) : array.append(list("0" + raw_input().replace(" ", "") + "0"))
	array.append(list("0" * (2 + h)))
	
	count = 0
	for i in range(1, w + 1):
		for j in range(1, h + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count
d = int( input() )
c = [ int( val ) for val in input().split( " " ) ]
f = int( input() )
b = [ int( val ) for val in input().split( " " ) ]
for i in range( 0, 3 ):
	print( "yes" )

### FIXED CODE ###

def solve( p, t ):
	global isExist, n, A
	isExist[ t ] = True
	if p < n:
		solve( p+1, t-A[p] )
		solve( p+1, t )
	else:
		return

isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )
n=list(int(input().split()))
if n[0]==n[1]:
    print(n[0]*2)
else:
    print(max(n)*2-1)

### FIXED CODE ###

n=list(map(int,input().split()))
if n[0]==n[1]:
    print(n[0]*2)
else:
    print(max(n)*2-1)
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()


slen = len(S)
if(slen < K):
    print(S)
else: 
    pr = S[:K]
    #
    change = S[K:]
    #print(change)
    for i in range(3):
        change = change.replace(change[i], ".")
    print(pr + change[:3])



### FIXED CODE ###

#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()



if(len(S) <= K):
    print(S)
else:
    print(S[:K] + '.' * 3)
    #for i in range(3):
    #    change = change.replace(change[i], '.')
    #print(S[:K] + change[:3])
N,K=map(int,input().split())
ls=list(map(int,input().split()))
ls_p=[(ls[i]+1)/2 for i in range(N)]
a=0
for i in range(K):
  a+=ls_p[i]
for i in range(N-K):
  c=a+ls_p[i+K]-ls_p[i]
  b=max([a,c])
  a=c
print(b)

### FIXED CODE ###

N,K=map(int,input().split())
ls=list(map(int,input().split()))
ls_p=[(ls[i]+1)/2 for i in range(N)]
a=0
for i in range(K):
  a+=ls_p[i]
b=a  
for i in range(N-K):
  c=a+ls_p[i+K]-ls_p[i]
  b=max([b,c])
  a=c
print(b)
import sys
sys.setrecursionlimit(3000)
def main():
    N, M = map(int, input().split())
    d = {}
    for _ in range(M):
        x, y = map(int, input().split())
        if x in d:
            d[x].append(y)
        else:
            d[x] = [y]
    l = {}
    m = 0
    for i in d:
        m = max(m, dfs(i, d, l))
    print(m)
def dfs(node, d, l):
    if node in l:
        return l[node]
    if node not in d:
        return 0
    a = 1 + max(dfs(i, d, l) for i in d[node])
    l[node] = a
    return a

main()





### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
    N, M = map(int, input().split())
    d = {}
    for _ in range(M):
        x, y = map(int, input().split())
        if x in d:
            d[x].append(y)
        else:
            d[x] = [y]
    l = {}
    m = 0
    for i in d:
        m = max(m, dfs(i, d, l))
    print(m)
def dfs(node, d, l):
    if node in l:
        return l[node]
    if node not in d:
        return 0
    a = 1 + max(dfs(i, d, l) for i in d[node])
    l[node] = a
    return a

main()
n = int(input())
a = list(map(int, input().split()))
import collections
l1 = collections.Counter(a).most_common()
l1.sort()
if len(l1) > 2　or l1[1][0] - l1[0][0] > 1:
    print("No")
elif len(l1) == 1:#発言が１種類の場合
    if l1[0][0] * 2 <= n or l1[0][0] == n - 1:
        print("Yes")
    else:
        print("No")
else:
    if l1[1][1] >= (l1[1][0] - l1[0][1]) * 2 and l1[1][0] > l1[0][1]:
        print("Yes")#多い発言の人数が残りの色数かけ２より多い、全体色数が少ない発言の人数より多い
    else:
        print("No")

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
import collections
l1 = collections.Counter(a).most_common()
l1.sort()
if len(l1) > 2:
    print("No")
elif len(l1) == 1:#発言が１種類の場合
    if l1[0][0] * 2 <= n or l1[0][0] == n - 1:
        print("Yes")
    else:
        print("No")
else:
    if l1[1][0] - l1[0][0] > 1:
        print("No")
    elif l1[1][1] >= (l1[1][0] - l1[0][1]) * 2 and l1[1][0] > l1[0][1]:
        print("Yes")#多い発言の人数が残りの色数かけ２より多い、全体色数が少ない発言の人数より多い
    else:
        print("No")
from collections import Counter
n=int(input())
D=list(map(int,input().split()))
D_count=sorted(Counter(D).items())
if D_count[0][0]!=0 or D_count[0][1]!=1:print(0);exit()
ans=1
for i in range(1,max(D)+1):
    ans *=D_count[i-1][1]**D_count[i][1]
    ans %=998244353
print(ans)

### FIXED CODE ###

from collections import Counter
mod=998244353
n=int(input())
D=list(map(int,input().split()))
Count=Counter(D)
if Count[0]!=1 or D[0]!=0:print(0);exit()
ans=1
for i in range(1,max(Count)+1):
    ans *=Count[i-1]**Count[i]
    ans %=mod
print(ans)
N = int(input())
print(sum(list(map(int,input().split())))-N)

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
print(A[2] - A[0])
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0

print(max(ans))



### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int, input().split()))
ans = []
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0

ans.append(cnt)
print(max(ans))
a, b = input().split()
a = int(ab[0])
b = int(ab[1])
print(a*b, (a+b)*2)

### FIXED CODE ###

ab = input().split()
a = int(ab[0])
b = int(ab[1])
print(a*b, (a+b)*2)
import math
n = int(input())

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

sq = math.sqrt(n)
if sq.is_integer():
    ansInt = sq

if is_prime(n):
    ansInt = n
else:
    ansInt = prime_decomposition(n)
print(len(str(int(max(ansInt)))))

### FIXED CODE ###

n = int(input())
ans = len(str(n))
a = 0
while a**2 <= n:
    a += 1
    if n % a != 0:
        continue
    b = n // a
    cur = max(len(str(a)), len(str(b)))
    if ans > cur:
        ans = cur
print(ans)
n = int(input())
import math
ans = 0
n = int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        t = math.gcd(i,j)
        for k in range(1,k+1):
            ans += math.gcd(t,k)
print(ans)

### FIXED CODE ###

k = int(input())
li=[1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(li[k-1])
N,W=map(int,input().split())
taple=[]
for i in range(N):
    a,b=map(int,input().split())
    taple.append((a,b))
dp=[[10**22]*(N*(10**3)+1) for i in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
    w,v=taple[i-1]
    for j in range(N*(10**3)+1):
        if j>=v[i]:
            dp[i][j]=min(dp[i-1][j-v]+w,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(N*(10**3),-1,-1):
    if dp[N][i]<=W:
        print(i)
        break


### FIXED CODE ###

N,W=map(int,input().split())
taple=[]
for i in range(N):
    w,v=map(int,input().split())
    taple.append((w,v))
dp=[[10**22]*(N*(10**3)+1) for i in range(N+1)]
dp[0][0]=0
for i in range(1,N+1):
    w,v=taple[i-1]
    for j in range(N*(10**3)+1):
        if j>=v:
            dp[i][j]=min(dp[i-1][j-v]+w,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(N*(10**3),-1,-1):
    if dp[N][i]<=W:
        print(i)
        break
N = input()
N = int(N)
 
allsum = (N+1)*int(N/2)
 
fum = int(N / 3)
bsum = int(N / 5)
fbsum = int(N / 15)
 
print(allsum-fsum*3-bsum*5+fbsum*15)

### FIXED CODE ###

N = input()
N = int(N)

allsum = int( (N + 1) * N / 2 )
#print(allsum)

f = int(N / 3)
b = int(N / 5)
fb = int(N / 15)


#print(f)
#print(b)
#print(fb)

fsum = int((f+1)*f/2)*3
bsum = int((b+1)*b/2)*5
fbsum = int((fb+1)*fb/2)*15

print(allsum - fsum - bsum + fbsum)
N, M = map(int, input().split())
ab = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

count = 0

def dfs(i, now, done):
    global count
    if i == N-1:
        count += 1
        return

    for j in ab[now]:
        if j not in done:
            dfs(i+1, j, done + [j])
    return

dfs(0, 0, [0])
print(count)


### FIXED CODE ###

A, B = map(int, input().split())
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')
K = int(input())
A, B = map(int, input())
c = 0

for i in range(A, B+1):
    if i % K == 0:
       c += 1
if c > 0:
    print("OK")
else:
    print("NG")

### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())
c = 0

for i in range(A, B+1):
    if i % K == 0:
       c += 1
if c > 0:
    print("OK")
else:
    print("NG")
N = int(input())

ef num_withdraw_ll(N):
    dp = [N] * (N + 1)
    dp[0] = 0
    for n in range(0, N):
        dp[n + 1] = min(dp[n + 1], dp[n] + 1)
        coin = 6
        while n + coin <= N:
            dp[n + coin] = min(dp[n + coin], dp[n] + 1)
            coin *= 6
        coin = 9
        while n + coin <= N:
            dp[n + coin] = min(dp[n + coin], dp[n] + 1)
            coin *= 9
    return dp[N]

print(num_withdraw_ll(N))

### FIXED CODE ###

N = int(input())

def num_withdraw_l(N):
    dp = [N] * (N + 1)
    dp[0] = 0
    for n in range(1, N+1):
        dp[n] = min(dp[n], dp[n - 1] + 1)
        coin = 6
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 6
        coin = 9
        while coin <= N:
            dp[n] = min(dp[n], dp[n - coin] + 1)
            coin *= 9
    return dp[N]

print(num_withdraw_l(N))
N = int(input())
S = input()

c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']

ans = 0
for a, b in zip(S, S_target):
    if b == 'W':
        break
    if a != b:
        ans += 1
print(ans)


### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()

c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']

ans = 0
for a, b in zip(S, S_target):
    if b == 'W':
        break
    if a != b:
        ans += 1
print(ans)
s = input()
ans = []
for i in s:
    if i =='0' or i == '1':
        ans.append(i)
    elif i == 'B':
        ans.pop(-1)
print(''.join(ans))

### FIXED CODE ###

string = []
S = input()
for i in S:
    if i == '0':
        string += '0'
    elif i == '1':
        string += '1'
    elif i == 'B':
        if len(string) == 0:
            pass
        else:
            del string[-1]
print(''.join(string))
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def main():
    n = ri()
    x = rs()

    k = int(x, 2)
    d = x.count('1')
    if d > 0:
        k0 = k % (d-1)
    k1 = k % (d+1)

    f = [0] * (n + 1)
    for i in range(1, n+1):
        f[i] = f[i % bin(i).count('1')] + 1

    for i in range(n):
        if x[i] == '1':
            dd = d - 1
            if dd == 0:
                wi(0)
                continue
            wi(f[(k0 - pow(2, n - i - 1, dd)) % dd] + 1)
        else:
            dd = d + 1
            wi(f[(k1 + pow(2, n - i - 1, dd)) % dd] + 1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def main():
    n = ri()
    x = rs()

    k = int(x, 2)
    d = x.count('1')
    
    if d > 1:
        k0 = k % (d-1)
    k1 = k % (d+1)

    f = [0] * (n + 1)
    for i in range(1, n+1):
        f[i] = f[i % bin(i).count('1')] + 1

    for i in range(n):
        cnt = 0
        if x[i] == '1' and d - 1 > 0:
            cnt += f[(k0 - pow(2, n - i - 1, d - 1)) % (d - 1)] + 1
        elif x[i] == '0':
            cnt += f[(k1 + pow(2, n - i - 1, d + 1)) % (d + 1)] + 1
        wi(cnt)


if __name__ == '__main__':
    main()
n = int(input())
a = []
nowmin = a[0]
for i in range(n):
  a.append(int(input()))
ans = a[1]-a[0]
for i in range(n-1):
  if a[i] < nowmin:
    k = max(a[i+1:]) - a[i]
    if k > ans:
      ans =  k
    
print(ans)



### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)
N,M = map(int,input().split())
A,B = [],[]
for i in range(N):
  a,b = map(int,input().split())
  A += [a]
  B += [b]
AA = []
BB = []
while True:
  if len(A) == 0:
    break
  else:
    for i in range(len(A)):
      if A[i] == min(A):
        AA += [A[i]]
        BB += [B[i]]
        del A[i]
        del B[i]
rest = M
cost = 0
while True:
  if rest - BB[0] <= 0:
    cost += rest * AA[0]
    break
  else:
    rest -= BB[0]
    cost += AA[0] * BB[0]
    del AA[0]
    del BB[0]
print(cost)

### FIXED CODE ###

N,M = map(int,input().split())
ab = []
for i in range(N):
  ab += [list(map(int,input().split()))]
ab.sort()
rest = M
cost = 0
while True:
  if rest - ab[0][1] <= 0:
    cost += rest * ab[0][0]
    break
  else:
    rest -= ab[0][1]
    cost += ab[0][0] * ab[0][1]
    del ab[0]
print(cost)