Harryxun/stf_run huggingface dataset:
n = int(input())
data = list(map(int, input.split()))
data_d = data.sort(reverse = True)
a = sum(data_d[::2])
b = sum(data_d[1::2])
print(a - b)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(a[::2])-sum(a[1::2]))
n=int(input())
A=list(map(int,input().split())
ans=1
for i in A:
  ans*=i
  if ans>10**18:
   print(-1)
   exit()

print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
x=1
A.sort()
if 0 in A:
  print(0)
  exit()

for i in range(n):
  x*=A[n-i-1]
  if x>10**18:
    print(-1)
    exit()
  else:
    continue

print(x)
N = int(input().split()[0])
words = [input() for i in range(N)]
print("".join(words.sort()))

### FIXED CODE ###

N = int(input().split()[0])
words = [input().strip() for i in range(N)]
print("".join(sorted(words)))
s = input()
k = int(input())

if sum(map(int, list(s))) == k:
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)



### FIXED CODE ###

s = input()
k = int(input())

if sum(map(int, list(s[:k]))) == len(s[:k]):
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)
N=int(input())
S=list(input())
for i in range(N-1):
    a=set(S[:i+1])
    b=set(S[i+1:])
    ans=max(ans,len(a&b))
print(ans)

### FIXED CODE ###

N=int(input())
S=list(input())
ans=0
for i in range(N-1):
    a=set(S[:i+1])
    b=set(S[i+1:])
    ans=max(ans,len(a&b))
print(ans)
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    import collections
    n, k = map(int, input().split())
    td = [list(map(int, input().split())) for _ in range(n)]
    td.sort(key=lambda x: x[1], reverse=True)
    ans_list = [0]
    reverse_td = list(zip(*td))
    c = collections.Counter(reverse_td[0][:k])
    kind = len(c)
    ans = sum(reverse_td[1][:k])+kind**2
    check = k-1
    flag=False
    for i in range(k,n):
        t = td[i][0]
        d = td[i][1]
        if t in c:
            pass
        else:
            c[t]=1
            while True:
                new_t = td[check][0]
                if c[new_t]==1:
                    check -=1
                    if check == -1:
                        flag =True
                        break
                else:
                    c[new_t]-=1
                    ans_list.append(2*kind+1+d-td[check][1])
                    kind+=1
            if flag:
                break
    print(ans+max(ans_list))


### FIXED CODE ###

if __name__ == '__main__':
    n, w, k = map(int, input().split())
    print(int(n*w/2))
X = int(input())

if X >= 0 and X <= 10 ** 9:
    while True:
        if X > 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X > 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break

total = (1000 * C) + (5 * D)

print(total)

### FIXED CODE ###

X = int(input())

C = 0
P = 0
D = 0
L = 0
total = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X >= 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X >= 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break
man = 1000 * C
t   = 5 * D

total = man + t

print(total)
#!/usr/bin/env python
# coding: utf-8

# In[13]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 for x in abcde if x%10 != 0) - 10)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 if x%10 != 0 else 10 for x in abcde ) - 10)


# In[ ]:
N = input("スライムの数 : ")
S = input("対応する文字列 : ")
result = N
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)

### FIXED CODE ###

N = input("")
S = input("")
result = int(N)
for i in range(len(S) - 1):
  if S[i] == S[i + 1]:
    result -= 1
print(result)
N,M = map(int, input().split())
A = [0]*M
for i in range(M):
    A[i] = int(input())

L = A[0]+2
if L < N - A[M-1]:
    L = N - A[M-1]
for i in range(M-1):
    L1 = A[i+1]-A[i]
    if L1 > L:
        L = L1
        
x = [0]*L
x.insert(0,0)
x.insert(1,1)
for i in range(L-2):
    x[i+2] = x[i+1] + x[i]
    
S = x[A[0]] * x[N - A[M-1]]
for i in range(M-1):
    S *= x[A[i+1]-A[i]-1]
    
print(S%1000000007)

### FIXED CODE ###

N,M = map(int, input().split())
A = [0]*M
for i in range(M):
    A[i] = int(input())
if M != 0:
    
    L = A[0]+1
    if L < N - A[M-1]:
        L = N - A[M-1]
    for i in range(M-1):
        L1 = A[i+1]-A[i]
        if L1 > L:
            L = L1
else:
    L = N +2
    
x = [0]*L
x.insert(0,0)
x.insert(1,1)
if L >2:
    for i in range(L-2):
        x[i+2] = x[i+1] + x[i]
if M != 0:
    S = x[A[0]] * x[N - A[M-1]]
    for i in range(M-1):
        S *= x[A[i+1]-A[i]-1]
else:
    S = x[N+1]
print(S%1000000007)
def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)

    for d in divs:
        diff = []
        for a in A:
            if a % d != 0:
                diff.append(a % d)
        diff.sort()
        S = list(accumulate([0] + diff))
        M = len(diff)
        if min(S[i] for i in range(1, M)
               if S[i] == (d * (M-i) - (S[M] - S[i]))) <= K:
            print(d)
            return


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.append(i)
                if i != n//i:
                    divs.append(n//i)
        return divs

    from itertools import accumulate
    divs = trial_division(sumA)
    ans = 0
    for d in divs:
        R = [a % d for a in A if a % d != 0]
        R.sort()
        S = [acc for acc in accumulate(R)]
        M = len(S)
        # print(d, R, S)
        if M == 0:
            ans = max(ans, d)
            continue
        for i in range(M-1):
            ne = S[i]
            po = d*(M-1-i) - (S[M-1] - S[i])
            if po == ne and po <= K:
                ans = max(ans, d)
    print(ans)


if __name__ == '__main__':
    main()
def fibonacci(n,memo={}):
    if n<0:
        return 0
    elif n==1 or n==0:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n]=fibonacci(n-1,memo)+fibonacci(n-2,memo)
        return memo[n]

N,M=map(int,input().split())
a=[]
for _ in range(0,M):
    a.append(int(input()))
a.append(N+1)
m=1
for i in range(0,M+1):
    if i==0:
        m=fibonacci(a[i]-1)
    else:
        m=m*fibonacci(a[i]-a[i-1]-2)

print(m%(10**9+7))

### FIXED CODE ###

def fibonacci(n):
    if n<0:
        return 0
    else:
        a=1
        b=1
        if n==0:
            return a
        elif n==1:
            return b
        else:
            i=n-2
            while i>=0:
                x=a
                a=b
                b=x+b
                i=i-1
            return b

N,M=map(int,input().split())
a=[]
for _ in range(0,M):
    a.append(int(input()))
a.append(N+1)
m=1
for i in range(0,M+1):
    if i==0:
        m=fibonacci(a[i]-1)
    else:
        m=m*fibonacci(a[i]-a[i-1]-2)

print(m%(10**9+7))
N, Q = map(int, input().split())

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

cnt_sum = [0]*(N+1)

def f(i, n):
    cnt_sum[i] = n+cnt[i]
    for t in w[i]:
        f(t, n+cnt[i])

f(1, 0)

print(" ".join([str(c) for c in cnt_sum[1:]]))

### FIXED CODE ###

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

w = [[] for _ in range(N+1)]
for _ in range(N-1):
    A, B = map(int, input().split())
    w[A].append(B)
    w[B].append(A)

cnt = [0]*(N+1)
for _ in range(Q):
    P, X = map(int, input().split())
    cnt[P] += X

flag = [False]*(N+1)

q = [1]
while q:
    n = q.pop()
    flag[n] = True
    for i in w[n]:
        if flag[i]:
            continue
        flag[i] = True
        cnt[i] += cnt[n]
        q.append(i)

print(" ".join([str(c) for c in cnt[1:]]))
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]
a=[0]*(n+1)
w=[0]*(n+1)
for i in range(m):
    if a[int(p[i][0])]==0 and p[i][1]=='AC':
        a[int(p[i][0])]+=1
    if a[int(p[i][0])]==0 and p[i][1]=='WA':
        w[int(p[i][0])]+=1
a=np.array(a)
w=np.array(w)
aw=a*w
print(sum(a),sum(aw))

### FIXED CODE ###

import numpy as np
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]
a=[0]*(n+1)
w=[0]*(n+1)
for i in range(m):
    if a[int(p[i][0])]==0 and p[i][1]=='AC':
        a[int(p[i][0])]+=1
    if a[int(p[i][0])]==0 and p[i][1]=='WA':
        w[int(p[i][0])]+=1
a=np.array(a)
w=np.array(w)
aw=a*w
print(sum(a),sum(aw))
a,b=[int(i) for i in input().split()]
if a>b:
    print('GREATER')
elif a<b:
    print('LESS')
else:
    print('EQUAL')


### FIXED CODE ###

a, b = [int(input()) for i in range(2)]
if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
#初期入力
import sys
input = sys.stdin.readline
S = input().split()
S=S[0]
Q = int(input())
FQ_dic =tuple()
rev =0
for i in range(Q):
    FQ_dic =tuple(input().split())

    if      FQ_dic[0] =="1": #逆転する
                rev +=1
    else:                   #逆転なし   
        if      FQ_dic[1]=="1":     #後ろにつける
            if rev %2 ==0:
                    S = FQ_dic[2] , *S
            else:
                    S = *S ,FQ_dic[2] 
        else: #                      #前につける
            if rev %2 ==0:
                    S = *S , FQ_dic[2]
            else:        
                    S = FQ_dic[2] , *S
if rev %2 ==0:
    print(*S,sep="")
else:
    print(*S[::-1],sep="")

### FIXED CODE ###

#前・左につける変数、後ろ・右につける変数を用意して最後に足す
#前・左は最後にひっくり返す（abc ⇒cba)

#初期入力
import sys
input = sys.stdin.readline
S = input()
S=S.strip("\n")
Q = int(input())
FQ_dic={}
for i in range(Q):
    FQ_dic[i] =input().split()

rev =0
front =""
back =""

for i in range(Q):
   # print(S) 

    if FQ_dic[i][0] =="1": #逆転する
                rev +=1
    else:                   #逆転なし  
        if FQ_dic[i][1]=="1":     #前=左につける 
            if rev %2 ==0:
                front += FQ_dic[i][2]
            else:
                back  += FQ_dic[i][2]  
        else: #                      #後ろ=右につける
            if rev %2 ==0:
                back  += FQ_dic[i][2]  
            else:        
                front += FQ_dic[i][2]
front =front[::-1]
S =front + S + back

if rev %2 ==0:
    print(*S,sep="")
else:
    print(*S[::-1],sep="")
import math

def conb(x,y):
    return (math.factorial(x) // math.factorial(x - y)) // math.factorial(y)


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

for i in range(1,k + 1):
    print(conb(n - k + 1,i) * conb(k - 1,i - 1) % 1000000007)


### FIXED CODE ###

import math

def conb(x,y):
    if x < y:
        return 0
    else:
        return (math.factorial(x) // math.factorial(x - y)) // math.factorial(y)


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

for i in range(1,k + 1):
    print(conb(n - k + 1,i) * conb(k - 1,i - 1) % 1000000007)
a,b=map(int,input())
print(['Even','Odd'][a*b%2>0])

### FIXED CODE ###

a,b=map(int,input().split())
print(['Even','Odd'][a*b%2>0])
from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));print(gcd.reduce(x-int(X)))

### FIXED CODE ###

from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));g=lambda x,y:g(y%x,x)if y%x else x;print(abs(frompyfunc(g,2,1).reduce(x-int(X))))
import sys
n,m = [int(x) for x in sys.stdin.readline().split()]
r = [0] * n
for i in range m:
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += 1
	r[b-1] += 1
for i in range n:
	print(r[i])

### FIXED CODE ###

import sys
import numpy as np
n,m = [int(x) for x in sys.stdin.readline().split()]
r = np.zeros(n)
for i in range(m):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a-1] += 1
	r[b-1] += 1
for i in range(n):
	print(int(r[i]))
import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = 0
for i in range(n-1):
    for k in range(i+1,n):
        s+=a[i]*a[j]
print(s)

### FIXED CODE ###

import copy

def j(n):
    if n:print("yes")
    else:print("no")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
s = 0
for i in range(n-1):
    for k in range(i+1,n):
        s+=a[i]*a[k]
print(s)
from itertools import combinations_with_replacement as cr
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(q)]
nl=[i for i in range(1,m+1)]
ansl=[]
for v in cr(nl,m):
  ans=0
  for a,b,c,d in l:
    if v[b-1]-v[a-1]==c:
      ans+=d
  ansl.append(ans)
print(max(ansl))

### FIXED CODE ###

from itertools import combinations_with_replacement as cr
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(q)]
nl=[i for i in range(1,m+1)]
ans=0
for v in cr(nl,n):
  s=0
  for a,b,c,d in l:
    if v[b-1]-v[a-1]==c:
      s+=d
  if ans<s:
    ans=s
print(ans)
def bubble(A):
    flag=True;
    n=len(A)
    i=0
    while flag:
        for j in range(n-1,i,-1):
            if A[j][1]<A[j-1][1]:
                A[j],A[j-1]=A[j-1],A[j]
                flag=True
        i+=1

def selection(A):
    n=len(A)
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][1]<A[minj][1]:
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]


n=int(input())
ss=[x for x in input().split()]
ss2=ss.copy()

bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=' ')
print(ss[-1])
print('Stable')

selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=' ')
print(ss2[-1])
if ss=ss2:
    print('Stable')
else:
    print('Not stable')


### FIXED CODE ###

def bubble(A):
    #标记是否需要继续冒泡
    flag =True;
    n=len(A)
    i=0
    while flag:
        flag=False
        for j in range(n-1,i,-1):
           if A[j][1]<A[j-1][1]:
               A[j],A[j-1]=A[j-1],A[j]
               flag=True
        i+=1
 
 
#选择排序法
def selection(A):
    n=len(A)
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][1]<A[minj][1]:
                minj=j
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]
             
   
           
n=int(input())
ss=[x for x in input().split()]     
ss2=ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=' ')
print(ss2[-1])
if ss==ss2:
    print('Stable')
else:
    print('Not stable')
n=list(int,input().split())
if n==[1,4,7,9]:
  print("YES")
else:
  print("NO")



### FIXED CODE ###

n= list(map(int,input().split()))
n.sort()
if 1 in n and 7 in n and 9 in n and 4 in n:
  print("YES")
else:
  print("NO")
n = int(input())

def abc(s):
  t = all('3' in s, '5' in s, '7' in s)
  if len(s) < len(n):
    return abc(s+'3') + abc(s+'5') + abc(s+'7') + t
  elif s <= n:
    return t
  else:
    return 0
print(abc(''))

### FIXED CODE ###

n = input()

def abc(s):
  t = all(('3' in s, '5' in s, '7' in s))
  if len(s) < len(n):
    return abc(s+'3') + abc(s+'5') + abc(s+'7') + t
  elif s <= n:
    return t
  else:
    return 0

print(abc(''))
S = input()

cnt = 0
for i in range(S // 2):
  if S[i] != S[len(S) - 1 - i]:
    cnt += 1
print(cnt)

### FIXED CODE ###

S = input()

cnt = 0
for i in range(len(S) // 2):
  if S[i] != S[len(S) - 1 - i]:
    cnt += 1
print(cnt)
from collections import Counter as mset

n = int(input())
intersection = input()
for i in range(n - 1):
    intersection = intersection & mset(input())

print(''.join(sorted(list(intersection.elements()))))

### FIXED CODE ###

from collections import Counter as mset

n = int(input())
inputs = []
for i in range(n):
    inputs.append(input())

intersection = mset(inputs.pop(0))

for w in inputs:
    intersection = mset(w) & intersection

print(''.join(sorted(list(intersection.elements()))))
import fractions

mod=10**9+7

n=int(input())

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

def lcm(a,b):
    return a//fractions.gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])%mod

def modpow(x,y,mod):
    res=1
    while y>0:
        if y&1:
            res=res*x%mod
        x=x*x%mod
        y>>=1
    return res

def modinv(x,mod):
    return modpow(x,mod-2,mod)

ans=0

for i in range(n):
    ans=(ans+lcma*modinv(a[i],mod)%mod)%mod

print(ans)



### FIXED CODE ###

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

if n==m:
    print('Yes')
else:
    print('No')
A = int(input())
if A % 2 == 0
   print(A)
else:
   print(A // 2 + 1)


### FIXED CODE ###

num = int(input())
if num % 2 == 0:
   print(num // 2)
else:
   print(num // 2 + 1)
from itertools import product
def solve():
    card_org = list(map(int,input().split()))
    K = int(input())
    comb = list(product(range(3), repeat=K))

    for c in comb:
        card = card_org[:]
        for i in range(3):
            card[c[i]] *= 2
        
        if card[1] > card[0] and card[2] > card[1]:
            print('Yes')
            return
    
    print('No')

if __name__ == '__main__':
    solve()

### FIXED CODE ###

from itertools import product
def solve():
    card_org = list(map(int,input().split()))
    K = int(input())
    comb = list(product(range(3), repeat=K))

    for c in comb:
        card = card_org[:]
        if card[1] > card[0] and card[2] > card[1]:
            print('Yes')
            return

        for i in range(K):
            card[c[i]] *= 2
        
            if card[1] > card[0] and card[2] > card[1]:
                print('Yes')
                return
    
    print('No')

if __name__ == '__main__':
    solve()
abk = list(map(int,input().split()))

x=[]
for i in range(1,100):
    if(abk[0]%i==0 and abk[1]%i==0):
        x.append(i)

print(x[-2])

### FIXED CODE ###

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

x=[]
for i in range(1,101):
    if(abk[0]%i==0 and abk[1]%i==0):
        x.append(i)
print(x[-abk[2]])
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

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

B = [0]*N

for i in range(N):
    B[A[i]-1] =i+1

print(B*)  


### FIXED CODE ###

from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

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

B = [0]*N

for i in range(N):
    B[A[i]-1] =i+1

print(*B)
import sympy
N = int(input())
ans = 0
for i in range(1,N+1):
  ans += i * sympy.divisor_count(i)
print(ans)

### FIXED CODE ###

# 正整数Xの正約数個数をf(X)とするときの \sum_(K=1)^N {K*f(K)}
# 正整数jの倍数でありN以下のものの総和をg(j)とするときの \sum_(j=1)^N g(j)

N = int(input())
ans = 0
for j in range(1, N+1):
  # Y = N/j とすると g(j) = j+2j+...+Yj = (1+2+...+Y)j = Y(Y+1)/2 *j
  g = (N//j)*(N//j+1)*j//2
  ans += g
print(ans)
import heapq
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

changes = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    changes[c] += b

changes = sorted(changes.items(), key = lambda x:x[0], reverse=True)

d = []
len_d = 0
for v in changes:
    d += [v[0]]*v[1]
    len_d += v[1]
    if len_d > N:
        d = d[0:N]
        break

res = 0
i = 0
while i < len(d):
    if A[i] <= d[i]:
        res += d[i]
    else:
        res += A[i]
    i += 1

if i < N:
    for j in range(i, N):
        res += A[j]

print(res)


### FIXED CODE ###

from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [(A[i], 1) for i in range(N)]

changes = [None] * M
for i in range(M):
    b, c = map(int, input().split())
    changes[i] = (c, b)

allVals = A + changes

allVals.sort(key = lambda x:x[0], reverse = True)
# print(allVals)

i = 0
j = -1
res = 0
while True:
    j += 1
    res += allVals[j][0] * allVals[j][1]
    i += allVals[j][1]

    if i >= N:
        res -= allVals[j][0] * (i - N)
        break



print(res)
def main():
    N = int(input())
    i = 0
    while N >0:
        if len(N) % 2 != 0:
            i+=1
        N -= 1
    print(i)
main()

### FIXED CODE ###

def main():
    N = input()
    i = 0
    while int(N) >0:
        if len(N) % 2 != 0:
            i+=1
        N = int(N) -1
        N = str(N)
    print(i)
main()
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

### FIXED CODE ###

N = int(input())
 
t = list(map(int, input().split()))
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = map(int, input().split())
    print(cal - t[p - 1] + x)
#124a
a, b = list(map(int, input().split()))
ans=0
if a > b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
ans+=max(a,b)
  
print(ans６)


### FIXED CODE ###

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

print(max(a+a-1,b+b-1,a+b))
import sys

n = int(input())
l = 0
r = n-1
mid = r // 2
re = [None] * n
print(0, flush=True)
re[0] = input()
if re[0] == "Vacant":
  sys.exit()
print(mid, flush=True)
re[mid] = input()
while re[mid] != "Vacant":
  if re[l] == re[mid]:
    if (mid - l) % 2:
      r = mid
    else:
      l = mid
  else:
    if (mid - l) % 2:
      l = mid
    else:
      r = mid
  mid = (l + r) // 2
  print(mid, flush=True)
  re[mid] = input()
else:
  sys.exit()


### FIXED CODE ###

x,y = map(int, input().split())
if x % y == 0:
  print(-1)
else:
  print(x)
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())

    print(int(a // 2 if a % 2 == 0 else a // 2 + 1))


if __name__ == '__main__':
    main()


### FIXED CODE ###

a = input()
n, mod = divmod(int(a), 2)
print(n if mod == 0 else n + 1)
import sys

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

number = 1
count = 0

if 1 not in nums:
    print(-1)
    sys.exit()

while len(nums) > 0:
    try:
        idx = nums.index(number)
    except ValueError:
        break
    count += idx
    nums = nums[idx+1:]
    print(nums)
    number += 1

print(count)

### FIXED CODE ###

import sys

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

number = 1
count = 0

if 1 not in nums:
    print(-1)
    sys.exit()

for num in nums:
    if num == number:
        number += 1
    else:
        count += 1
print(count)
N = 10**6
mod = 10**9 + 7
fact = [1]
for i in range(1, N+1):
    fact.append(fact[-1]*n%mod)


n, m = map(int, input())
ans = 0
if n - m > 1 or m - n > 1:
    ams = 0
elif n - m == 0:
    ans = 2 * (fact[n])**2
else:
    ans = fact[n] * fact[m)
print(ans)

### FIXED CODE ###

N = 10**6
mod = 10**9 + 7
fact = [1]
for i in range(1, N+1):
    fact.append(fact[-1]*i%mod)

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

if n - m > 1 or m - n > 1:
    ans = 0
elif n - m == 0:
    ans = 2 * fact[n] * fact[m] % mod
else:
    ans = fact[n] * fact[m] % mod
    
print(ans)