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

n = int(input())

def div_num(x):
  num = 0
  for i in range(1,x+1):
    if x % i == 0:
      num += 1
  return num

ans = 0
for i in range(1,n+1):
  ans += i * div_num(i)
print(ans)

### FIXED CODE ###

n = int(input())

ans = 0
for i in range(1,n+1):
  k = n//i
  ans += i*(k*(k+1)//2)
print(ans)
### BUGGY CODE ###

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


def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p

    if n != 1: ret[n] = 1

    return ret


a, b = map(int, input().split())
g = gcd(a, b)

print( len(prime_factor(g)) + 1)


### FIXED CODE ###

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


def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p
        p += 1

    if n != 1: ret[n] = 1

    return ret


a, b = map(int, input().split())
g = gcd(a, b)

print( len(prime_factor(g)) + 1)
### BUGGY CODE ###

N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  for i in range(K):
    
    list_monster.pop(0)
 
  print(sum(list_monster))

### FIXED CODE ###

N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  print(sum(list_monster[K:]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
matrix = [[0]*N for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    matrix[x][y] = 1

dp = [-1]*N

def rec(nodes):
    if dp[nodes] != -1:
        return dp[nodes]
    res = 0
    for ne,bit in enumerate(matrix[nodes]):
        if bit == 0:continue
        option = rec(ne)+1
        if res < option:
            res = option
    dp[nodes] = res
    return dp[nodes]

ans = 0
for i in range(N):
    res = rec(i)
    if ans < res:
        ans = res
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
ad = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    ad[x].append(y)

dp = [-1]*N

def rec(nodes):
    if dp[nodes] != -1:
        return dp[nodes]
    res = 0
    for ne in ad[nodes]:
        option = rec(ne)+1
        if res < option:
            res = option
    dp[nodes] = res
    return dp[nodes]

ans = 0
for i in range(N):
    res = rec(i)
    if ans < res:
        ans = res
print(ans)
### BUGGY CODE ###

H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [10**9 for _ in range(H+10**4+1)]
dp[0] = 0

for a, b in magic:
    for j in range(H+1):
        if dp[j+a] > dp[j] + b:
            dp[j+a] = dp[j] + b

print(min(dp[H:]))

### FIXED CODE ###



H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

dp = [10**9 for _ in range(H+10**4+1)]
dp[0] = 0

for a, b in magic:
    for j in range(H+1):
        if dp[j+a] > dp[j] + b:
            dp[j+a] = dp[j] + b

print(min(dp[H:]))
### BUGGY CODE ###

import itertools
import numpy as np
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    Aindex = np.array(list(itertools.combinations(range(N),2)))
    count = 0
    for i in range(len(Aindex)):
        if A[Aindex[i,0]] + A[Aindex[i,1]] == abs(Aindex[i,0] - Aindex[i,1]):
            count += 1
    print(count)
resolve()

### FIXED CODE ###

from collections import defaultdict
iim = lambda: map(int, input().rstrip().split())
 
def resolve():
    N = int(input())
    A = list(iim())
    ans = 0
    dp = [0]*N
    for i, ai in enumerate(A):
        x = i + ai
        if x < N:
            dp[x] += 1
        x = i - ai
        if x >= 0:
            ans += dp[x]
    print(ans)
resolve()
### BUGGY CODE ###

def count1(n):
    nx=bin(n)
    return nx.count('1')

N=int(input())
X=input()
'''for i in range(N):
    Ni2=X
    if X[i]=='0':
        Ni2=X[:i]+'1'+X[(i+1):] #文字列は変更できない
    else:
        Ni2=X[:i]+'0'+X[(i+1):]
    Ni=int(Ni2,2)
    ans=0
    #print(Ni)
    while Ni!=0:
        Ni=Ni%count1(Ni)
        ans+=1
    print(ans)'''

Nx=int(X,2)
for i in range(N):
    if X[i]=='0':
        Ni=Nx+2**(len(X)-i-1) #文字列は変更できない
    else:
        Ni=Nx-2**(len(X)-i-1)
    ans=0
    #print(Ni)
    while Ni!=0:
        Ni=Ni%count1(Ni)
        ans+=1
    print(ans)

### FIXED CODE ###

N = int(input())
X = input()
popcount_X = X.count('1')
numX = int(X, 2)
a = numX % (popcount_X + 1)
b = numX % (popcount_X - 1) if popcount_X != 1 else 0
for i, x in enumerate(X, 1): #リストのインデクス，要素，第二引数に開始位置
    if x == '1' and popcount_X == 1:
        print(0)
        continue
    ans = 1
    if x == '1':
        temp = (b - pow(2, N - i, popcount_X - 1)) % (popcount_X - 1)
    else:
        temp = (a + pow(2, N - i, popcount_X + 1)) % (popcount_X + 1)
    while temp:
        p = format(temp, 'b').count('1') #2進数，1の個数
        temp %= p
        ans += 1
    print(ans)
### BUGGY CODE ###

import numpy as np
 
n,X = map(int,input().split())
xs = np.array(list(map(int,input().split())))
cumsumx =np.insert(np.cumsum(xs),0,0)
 
cut = np.int_(100000000000000000)
 
def cutsum(array):
    acm = np.int_(0)
    for i in array:
        if acm <= cut:
            acm += i
        else:
            acm = cut
            break
    return(acm)
 
def energy(k):
    nok = n//k
    offset = (n+k)*X
    acm = (n+k)*X + 3*cumsumx[-1] - 2*cumsumx[-k-1]
    acm += 2*cutsum(cumsumx[::-k])
    return(acm)
 
ans = (n+1)*X+2*cutsum(cumsumx)+3*cumsumx[-1]-2*cumsumx[-2]
for j in range (2,min(n//2+4,n+1)):
    tmp = energy(j)
    if tmp < ans:
        ans =tmp
 
print(ans)
 
 
 

### FIXED CODE ###

import numpy as np
 
n,X = map(int,input().split())
xs = np.array(list(map(int,input().split())))
cumsumx =np.insert(np.cumsum(xs),0,0)
 
cut = np.int_(3000000000000000000)
 
def cutsum(array):
    acm = np.int_(0)
    for i in array:
        if acm <= cut:
            acm += i
        else:
            acm = cut
            break
    return(acm)
 
def energy(k):
    nok = n//k
    offset = (n+k)*X
    acm = (n+k)*X + 3*cumsumx[-1] - 2*cumsumx[-k-1]
    acm += 2*cutsum(cumsumx[::-k])
    return(acm)
 
ans = (n+1)*X+2*cutsum(cumsumx)+3*cumsumx[-1]-2*cumsumx[-2]
for j in range (2,min(n//2+4,n+1)):
    tmp = energy(j)
    if tmp < ans:
        ans =tmp
 
print(ans)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    L=[int(_) for _ in input().split()]
    L.sort()
    ans=0
    for a in range(n-2):
        for b in range(a+1,n-1):
            flag=L[a]+L[b]
            for c in range(b+1,n):
                if L[c]>=flag:
                    break
                ans+=1
    print(ans)


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left
def main():
    n=int(input())
    L=[int(_) for _ in input().split()]
    L.sort()
    ans=0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans+=bisect_left(L,L[a]+L[b])-b-1
    print(ans)


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

import numpy as np

s = np.array(list(input("")))
Q = int(input())
c = 0
for i in range(Q):
    t = input()
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c%2 == 0:
            s = np.insert(s,0,t[4])
        else:
            s = np.append(s,t[4])
    else:
        if c%2 == 0:
            s = np.append(s,t[4])
        else:
            s = np.insert(s,0,t[4])

if c%2 == 0:
    for i in range(len(s)):
        print(s[i],end="")
else:
    k = s[::-1]
    for i in range(len(s)):
        print(k[i],end="")

### FIXED CODE ###

s = input("")
Q = int(input())
c = 0
before = []
after = []
for i in range(Q):
    t = input()
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c%2 == 0:
            before.append(t[4])
        else:
            after.append(t[4])
    else:
        if c%2 == 0:
            after.append(t[4])
        else:
            before.append(t[4])

if c%2 == 0:
    print("".join(before[::-1]),end="")
    print(s,end="")
    print("".join(after),end="")
else:
    print("".join(after[::-1]),end="")
    print(s[::-1],end="")
    print("".join(before),end="")
### BUGGY CODE ###

import itertools
def main():
    N = int(input().strip())
    S = [input().strip() for _ in range(N)]
    MARCH_S = [x[0] for x in S if x[0] in ['M','A','R','C','H']]
    if not MARCH_S:
        return 0

    pat = list(itertools.combinations(MARCH_S, 3));
    pat_len = len(pat)
    
    for x in ['M','A','R','C','H']:
        pat_len -= len([p for p in pat if p.count(x) > 1])

    return pat_len
    
if __name__ == '__main__':
    print(main())

### FIXED CODE ###

import math
def kumi(s, n):
    count = 1
    for x in range(s, s - n, -1):
        count *= x
    ret = count // math.factorial(n)
    return ret

def main():
    N = int(input().strip())
    S = []
    D = {}
    for _ in range(N):
        in_s = (input().strip())[0]
        if in_s in ['M','A','R','C','H']:
            S.append(in_s)
            D[in_s] = D.get(in_s, 0) + 1

    if not S or len(D.keys()) < 3:
        return 0

    
    # 組み合わせ数
    count = kumi(len(S), 3)
    # 重複削除
    for v in D.values():
        if v < 2:
            continue
        elif v == 2:
            count -= len(S) - v
        else:
            count -= kumi(v, 2) * (len(S) - v)
            count -= kumi(v, 3)
    return count

if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
	a.append(int(input()))

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

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)

k = [i for i, x in enumerate(a) if x == m]

if len(k)>=2:
	for i in a:
		print(m)
else:
	b = []
	b += a
	mi = b.index(m)
	b.pop(mi) 
	m2 = max(b)
	for i in a:
		if i != m:
			print(m)
		else:
			print(m2)
### BUGGY CODE ###

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)


# にぶたん := N人のメンバーそれぞれが完食にかかる時間のうち最大値をxに以下にできるか？
ok, ng = 10 ** 18, -1
while ok - ng > 1:
    x = (ok + ng) // 2

    need_training = 0
    for a, f in zip(A, F):
        need_training += max(0, a - x // f)

    if need_training <= K:
        ok = x
    else:
        ng = x

print(ok)


### FIXED CODE ###

from math import ceil
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)

K = min(K, sum(A))
X = [[a, f] for a, f in zip(A, F)]

ok, ng = 10 ** 12 + 1, -1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    k_cost = 0
    for a, f in X:
        if a * f <= m:
            continue
        else:
            k_cost += max(0, ceil(-(m / f - a)))

    if k_cost <= K:
        ok = m
    else:
        ng = m

print(ok)
### BUGGY CODE ###

l = list(map(int, input().split(' ')))

#num = int(input())
#S = str(input())

r=l[0]
g=l[1]
b=l[2]
N=l[3]
sum = 0
for i in range(int(N/r)+1):
    for j in range(int(N/g)+1):
        for k in range(int(N/b)+1):
            if(i*r+j*g+k*b==N):
                sum+=1
print(sum)


### FIXED CODE ###

l = list(map(int, input().split(' ')))

#num = int(input())
#S = str(input())

r=l[0]
g=l[1]
b=l[2]
N=l[3]

Num=3000

sum = 0
for i in range(N//r+1):
    for j in range(N//g+1):
        _b=N-i*r-j*g
        if _b<0:
            break
        if _b%b==0:
            sum+=1
print(sum)
### BUGGY CODE ###

n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        

### FIXED CODE ###

n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
### BUGGY CODE ###

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

num = 0
max_num = 0

for i in range(1, n+1):
    num = math.floor(a*i/b) - a * math.floor(i / b)
    max_num = max(max_num, num)
print(max_num)

### FIXED CODE ###

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

if b > n:
    ans = math.floor(a*n/b) - a*math.floor(n/b)
else:
    num = b - 1
    ans = math.floor(a*num/b) - a*math.floor(num/b)
print(ans)
### BUGGY CODE ###

L, R = map(int, input().split())

if L - R >= 2019:
    ans = 0
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            a = (i * j) % 2019
            if a < ans:
                ans = a

print(ans)


### FIXED CODE ###

import sys

L, R = list(map(int, input().split()))

yy = 2019

d = 2019

if R > L+2019:
    R = L+2019

for i in range(L,R):
    im = i % yy

    for j in range(i+1, R+1):
        jm = j % yy

        if im * jm % yy <= d:
            d = im * jm % yy

print(d)
### BUGGY CODE ###

def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

n,m,k = mp()

def combination(n, r, mod):
    np1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (np1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


mod = 998244353
now_comb = 1
now_pow = pow(m-1, n-1, mod)
ans = now_pow*m
for i in range(1, k+1):
    # u1 = (now_comb * (n-i) * pow(i, mod-2, mod)) % mod
    u1 = combination(n-1, i, mod)
    u2 = (now_pow * pow(m-1, mod-2, mod)) % mod
    now_comb = u1
    now_pow = u2
    ans += u1*u2*m
    ans %= mod
print(ans%mod)


### FIXED CODE ###

def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
n,m,k = mp()
mod = 998244353
conb = [1]
pows = [pow(m-1, n-1-k, mod)]
for i in range(1,k+1):
    conb.append(conb[i-1]*(n-i)*pow(i,mod-2,mod) % mod)
    pows.append(pows[i-1]*(m-1) % mod)
pows.reverse()
# print(conb, pows)
ans = 0
for i in range(k+1):
    ans += m * conb[i] * pows[i]
    ans %= mod
print(ans)

# print(conb)
# print(pows)
# exit()
# now_comb = 1
# now_pow = pow(m-1, n-1, mod)
# ans = now_pow*m
# for i in range(1, k+1):
#     u1 = (now_comb * (n-i) * pow(i, mod-2, mod)) % mod
#     u2 = (now_pow * pow(m-1, mod-2, mod)) % mod
#     now_comb = u1
#     now_pow = u2
#     ans += u1*u2*m
#     ans %= mod
# print(ans%mod)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())
e = [[] for _ in range(n)]

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

c = [0] * n
def search_path(p, temp):
    c[p] = 1
    for x in e[p]:
        if x in temp:
            ans = [] + temp[temp.index(x):]
            check = 1
            while check == 1:
                check = 0
                #print(ans)
                for i in range(len(ans)-1):
                    for z in e[ans[i]]:
                        if z == ans[i+1]:
                            continue
                        elif z in ans:
                            t = ans.index(z)
                            if t < i:
                                ans = [] + ans[t:i+1]
                            else:
                                ans = [] + ans[i:t+1]
                            #print(ans, z)
                            check = 1
                            break
                    if check == 1:
                        break
                if check == 1:
                    continue
                for z in e[ans[-1]]:
                    if z in ans[1:]:
                        ans = [] + ans[ans.index(z):]
                        check = 1
                        #print(z, ans)
                        break
            print(len(ans))
            for z in ans:
                print(z+1)
            exit()
        else:
            search_path(x, temp + [x])


t = 1
for i in range(n):
    if c[i] == 0:
        ans = search_path(i, [i])

print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())
e = [[] for _ in range(n)]

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

c = [0] * n
ans = []
def search_path(p, temp):
    c[p] = 1
    for x in e[p]:
        if x in temp:
            print(-99999)
            exit()
        else:
            search_path(x, temp + [x])


t = 1
for i in range(n):
    if c[i] == 0:
        ans = search_path(i, [i])

print(-1)
### BUGGY CODE ###

#B
n,a,b=map(int,input().split())
i=0
aa=[]
bb=[]
while n>0:
    if n<a:
        aa.append(n)
        break
    else:
        aa.append(a)
    n-=a
    if n<b:
        bb.append(n)
        break
    else:
        bb.append(b)
    n-=b
print(sum(aa))

### FIXED CODE ###

#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    if s==0:
        m=n
    else:
        absum=(a+b)*s
        m=n%(absum)#余り
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)
### BUGGY CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)

sum_a = [0]
for i in range(1,len(a)):
    sum_a.append(sum_a[i-1] + a[i])
    if sum_a[i] > k:
        break

sum_b = [0]
for i in range(1,len(b)):
    sum_b.append(sum_b[i-1] + b[i])
    if sum_b[i] > k:
        break

ans = 0
for i in range(len(sum_a)):
    if sum_a[i] > k:
        break
    for j in range(len(sum_b)-1,-1,-1):
        if sum_a[i] + sum_b[j] <= k:
            ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)

sum_a = [0]
for i in range(1,n+1):
    sum_a.append(sum_a[i-1] + a[i])

sum_b = [0]
for i in range(1,m+1):
    sum_b.append(sum_b[i-1] + b[i])

ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        break
    for j in range(m,-1,-1):
        if sum_a[i] + sum_b[j] <= k:
            ans = max(ans, i+j)
            m = j
            break
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
ans =[0]*N
tmp = 0
ans[0] = N-1-S.count('E')
ans[-1] = N-S.count('W')
for i in range(1,N-1):
    A = S[:i]
    B = S[i+1:]
    tmp = (i-A.count('E'))+(N-(i+1)-B.count('W'))
    ans[i] = tmp
    tmp = 0
print(min(ans))

### FIXED CODE ###

n = int(input())
s = input()
lstW = [0]
c = 0
#累積和
for i in range(1,len(s)):
    if s[i-1] == "W":
        c += 1
    lstW.append(c)
    
lstE = [0]
c = 0
for i in range(len(s)-2,-1,-1):
    if s[i+1] == "E":
        c += 1 
    lstE.append(c)
lst = []
for i in range(len(lstW)):
    lst.append(lstW[i] + lstE[n-i-1])
lst.sort()
print(lst[0])
### BUGGY CODE ###

n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = [0]*(n+1)
for i in range(1,n+1):
  d[i] = i
  
s = [0] + [1]*n

#print(d)

c = n*(n-1)//2
ans = []
ans.append(c)

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  if x == y:
    ans.append(c)
    continue
  c -= s[x]*s[y]
  #print(c, "x")
  ans.append(c)
  s[x] += s[y]
  s[y] = 0
  for i in range(1,n+1):
    if d[i] == y:
      d[i] = x
for t in ans[::-1]:
  print(t)
  

### FIXED CODE ###

n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = [0]*(n+1)
for i in range(1,n+1):
  d[i] = i
  
s = [0] + [1]*n

g=[ [0] ]*(n+1)
for i in range(1,n+1):
  g[i] = [i]
g[0] = []
#print(g)
#quit()

c = n*(n-1)//2
ans = []
ans.append(c)

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x == y:
    ans.append(c)
    continue
  c -= s[x]*s[y]
  #print(c, "x")
  ans.append(c)
  s[x] += s[y]
  #s[y] = 0
  for i in g[y]:
    d[i] = x
  g[x] += g[y]
  #g[y] = []
for t in ans[::-1]:
  print(t)
### BUGGY CODE ###

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

for i in range(N)[::-1]:
    for j in range(i)[::-1]:
        if n[i]-n[j]<-1:
            print("No")
            exit()
print("Yes")

### FIXED CODE ###

n=int(input())
h=[int(i) for i in input().split()]
f=1
h[0]-=1
for i in range(1,n):
    if h[i]-h[i-1]>=1:h[i]+=-1
    elif h[i]-h[i-1]==0:h[i]+=0
    else:
        f=0
        print("No")
        break
if f==1:print("Yes")
### BUGGY CODE ###

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

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))


### FIXED CODE ###

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

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(sum(t[i][q] - t[i][i - 1] for i in range(p, q + 1)))
print('\n'.join(str(v) for v in result))
### BUGGY CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

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

count = 0
while M > 0:
    A.sort(reverse=True)
    A[0] = A[0]//2
    M -= 1

print(sum(A))


### FIXED CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

import heapq

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

if N == 1:
    A[0] //= (2**M)
    print(A[0])
    exit()

hq = []
for a in A:
    heapq.heappush(hq, -a)

while M > 0:
    high = -1 * heapq.heappop(hq)
    high //= 2
    M -= 1
    heapq.heappush(hq, -high)

ans = 0
for i in range(N):
    ans += heapq.heappop(hq)

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

X = int(input())
 
now = 0
cnt = 0
while now < X:
  cnt += 1
  now + int(now*0.01)
print(cnt)

### FIXED CODE ###

X = int(input())
 
now = 100
cnt = 0
while now < X:
  cnt += 1
  now += int(now*0.01)
print(cnt)
### BUGGY CODE ###

import sys
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))

dp = [sys.maxsize] * n


dp[0] = 0
i = 0
j = 0
while i < n:
    j = 1
    while j <= k:
        if (i+j >= n):
            break
        dp[i+j] = min(dp[i+j], abs(h[i] - h[i+j]) + dp[i])
        j += 1
    i += 1


print(dp[n-1])


### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))
h = np.array(h)

dp = np.zeros(n, dtype=int)


dp[0] = 0
i = 0
j = 0
for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))


print(dp[n-1])