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

N,K = map(int,input().split())
H = list(map(int,input().split()))
for i in range(K):
  max_value = max(H)
  max_index = H.index(max_value)
  H[max_index] = 0
count = sum(H)
print(count)

### FIXED CODE ###

N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
if N>K:
  for i in range(K):
    H[i]=0
  count = sum(H)
  print(count)
else:
  print(0)
### BUGGY CODE ###

n, a = int(input()), list(map(int, input().split()))
for i in range(int(input())):
    b, c = map(int, input().split())
    a = [c if i == b else i for i in a]
    print(sum(a))

### FIXED CODE ###

n, a = int(input()), list(map(int, input().split()))
s = sum(a)
d = [0] * (10 ** 5 + 1)
for i in a:
    d[i] += 1
for i in range(int(input())):
    b, c = map(int, input().split())
    d[c] += d[b]
    s += (c - b) * d[b]
    print(s)
    d[b] = 0
### BUGGY CODE ###

import heapq
from sys import stdin
h,w = map(int,input().split())
si,sj = map(int,input().split())
gi,gj = map(int,input().split())
si,sj,gi,gj = si-1,sj-1,gi-1,gj-1
grid = []
for _ in [0]*h:
    grid.append(stdin.readline())
INF = float("inf")
dist = [[INF]*w for _ in range(h)]
dist[si][sj] = 0
heap = [(0,si,sj)]
while heap:
    mindist,i,j = heapq.heappop(heap)
    if (i,j) == (gi,gj):
        print(mindist)
        break
    if mindist > dist[i][j]: continue
    for ni,nj in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
        if 0 <= ni and ni < h and 0 <= nj and nj < w and grid[ni][nj] == ".":
            if dist[ni][nj] > dist[i][j]:
                dist[ni][nj] = dist[i][j]
                heapq.heappush(heap,(dist[ni][nj],ni,nj))
    for ni in range(i-2,i+3):
        if not (0 <= ni and ni < h): continue
        for nj in range(j-2,j+3):
            if not (0 <= nj and nj < w): continue
            if (ni,nj) not in [(i,j),(i+1,j),(i-1,j),(i,j+1),(i,j-1)] and grid[ni][nj] == ".":
                if dist[ni][nj] > dist[i][j] + 1:
                    dist[ni][nj] = dist[i][j] + 1
                    heapq.heappush(heap,(dist[ni][nj],ni,nj))
 
else:
    print(-1)

### FIXED CODE ###

from sys import stdin
def solve():
    import collections
    readline = stdin.readline
    h,w = map(int,readline().split())
    si,sj = map(int,readline().split())
    gi,gj = map(int,readline().split())
    si,sj,gi,gj = si-1,sj-1,gi-1,gj-1
    grid = []
    for _ in [0]*h:
        grid.append(readline()[:-1])
    INF = float("inf")
    dist = [[INF]*w for _ in range(h)]
    q = collections.deque([(si,sj)])
    dist[si][sj] = 0
    while q:
        i,j = q.popleft()
        if (i,j) == (gi,gj):
            return dist[i][j]
        for ni,nj in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
            if 0 <= ni and ni < h and 0 <= nj and nj < w and grid[ni][nj] == ".":
                if dist[ni][nj] > dist[i][j]:
                    dist[ni][nj] = dist[i][j]
                    q.appendleft((ni,nj))
        listj = range(j-2,j+3)
        for ni in range(i-2,i+3):
            if not (0 <= ni and ni < h): continue
            for nj in listj:
                if not (0 <= nj and nj < w): continue
                if grid[ni][nj] == "." and dist[ni][nj] > dist[i][j] + 1:
                    dist[ni][nj] = dist[i][j] + 1
                    q.append((ni,nj))

    return -1

print(solve())
### BUGGY CODE ###

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
T
answer = 0
while len(T) >0:
    limit = T[0] + K
    counter = 0
    while counter < C:
        if len(T) == 0:
            break
        t = T.pop(0)
        if t > limit:
            T = [t] + T
            break
        counter += 1
    answer += 1
print(answer)

### FIXED CODE ###

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 0
while len(T) > 0:
    limit = T[0] + K
    counter = 0
    while counter < C:
        if len(T) == 0:
            break
        if T[0] > limit:
            break
        del T[0]
        counter += 1
    answer += 1
print(answer)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
import collections
def count_ident(v):
    c = collections.Counter(v)
    val_list=list(c.values())
    v_count=map(lambda x: x * (x-1), val_list)
    print(int(sum(v_count)/2))

for i in range(len(a)):
    tmp = list(a)    
    tmp.pop(i)
    count_ident(tmp)
    

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
import collections
c = collections.Counter(a)
val_list=list(c.values())
v_count=map(lambda x: x * (x-1), val_list)
total_count=int(sum(v_count)/2)

for i in a:
    print(total_count-(c[i]-1))
### BUGGY CODE ###

from collections import deque

n, m = map(int, input().split())
G = [list() for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1; b -= 1
  G[a].append(b)
  G[b].append(a)
Q = int(input())
queries = [tuple(map(int, input().split())) for _ in range(Q)][::-1]
dp = [[Q]*11 for _ in range(n)]
for i, (v, d, _) in enumerate(queries):
  if dp[v-1][d] == Q:
    dp[v-1][d] = i
for d in range(10, 0, -1):
  for v in range(n):
    if dp[v][d] < Q:
      dp[v][d-1] = min(dp[v][d-1], dp[v][d])
      for x in G[v]:
        dp[x][d-1] = min(dp[x][d-1], dp[v][d])
queries.append((-1, -1, 0))
color = [queries[dp[v][0]][2] for v in range(n)]
print(*color, sep='\n')

### FIXED CODE ###

import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
  n, m = nm()
  G = [list() for _ in range(n)]
  for _ in range(m):
    a, b = nm()
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
  Q = int(input())
  queries = [tuple(nm()) for _ in range(Q)][::-1]
  dp = [[Q]*11 for _ in range(n)]
  for i in range(Q-1, -1, -1):
    v, d, _ = queries[i]
    dp[v-1][d] = i
    
  for d in range(10, 0, -1):
    for v in range(n):
      for x in G[v] + [v]:
        if dp[x][d-1] > dp[v][d]:
          dp[x][d-1] = dp[v][d]
          
  queries.append((-1, -1, 0))
  color = [queries[dp[v][0]][2] for v in range(n)]
  print(*color, sep='\n')
  return

solve()
### BUGGY CODE ###

import sys
import bisect

N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]

G.sort(key = lambda x : -x[2])
T.sort()

A = [0] * (4 * Q + 5)

def update(A, i, l, r, ll, rr, val) :
    if r <= ll or rr <= l :
        return
    if ll <= l and r <= rr :
        A[i] = val
        return

    if A[i] != 0 :
        A[i * 2] = A[i * 2 + 1] = A[i]
        A[i] = 0

    m = (l + r) // 2
    update(A, i * 2, l, m, ll, rr, val)
    update(A, i * 2 + 1, m, r, ll, rr, val)

def get(A, i, l, r, p) :
    if A[i] != 0 or l + 1 == r :
        return A[i]
    m = (l+r) // 2
    if p < m :
        return get(A, i * 2, l, m, p)
    else :
        return get(A, i * 2 + 1, m, r, p)

for g in G :
    s = max(0, g[0] - g[2])
    e = g[1] - g[2]
    if e <= 0 :
        continue

    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)

    if ll == rr :
        continue

    update(A, 1, 0, Q, ll, rr, g[2])

for i in range(Q) :
    ans = get(A, 1, 0, Q, i)
    if ans == 0 :
        print(-1)
    else :
        print(ans)


### FIXED CODE ###

import sys
import bisect
 
N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]

class SegTree :
    def __init__(self, n) :
        self.n = n
        self.A = [10**15] * (2 << (n + 1).bit_length())
 
    def update(self, l, r, val) :
      l += len(self.A) // 2
      r += len(self.A) // 2
      while l < r:
          if l & 1 :
              self.A[l] = min(self.A[l], val)
              l += 1
          if r & 1:
              self.A[r-1] = min(self.A[r-1], val)
              r -= 1
          l //= 2
          r //= 2

    def get(self, i) :
      i += len(self.A) // 2
      ret = self.A[i]
      while i > 0 :
          i //= 2
          ret = min(ret, self.A[i])
      return ret if ret < 10**15 else -1

ST = SegTree(Q)
for g in G :
    s = g[0] - g[2]
    e = g[1] - g[2]
 
    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)
 
    if ll == rr :
        continue
 
    ST.update(ll, rr, g[2])
 
for i in range(Q) :
    ans = ST.get(i)
    print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
count = 0
def findb(ind,checker):
    b = S[ind:].count("B")
    if b > 0:
        if ind + checker < N:
            if S[ind+checker] == "B":
                return b - 1
            else:
                return b
        else:
            return b
    return 0
def findg(ind,checker):
    g = S[ind:].count("G")
    if g > 0:
        if ind + checker < N:
            if S[ind+checker] == "G":
                return g - 1
            else:
                return g
        else:
            return g
    return 0
def findr(ind,checker):
    r = S[ind:].count("R")
    if r > 0:
        if ind + checker < N:
            if S[ind+checker] == "R":
                return r - 1
            else:
                return r
        else:
            return r
    return 0
for i in range(N):
    if S[i] == "R":
        for j in [x for x, y in enumerate(S[i:]) if y == 'G']:
            count += findb(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'B']:
            count += findg(i+j,j)
    elif S[i] == "G":
        for j in [x for x, y in enumerate(S[i:]) if y == 'B']:
            count += findr(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'R']:
            count += findb(i+j,j)
    else:
        for j in [x for x, y in enumerate(S[i:]) if y == 'R']:
            count += findg(i+j,j)
        for j in [x for x, y in enumerate(S[i:]) if y == 'G']:
            count += findr(i+j,j)
print(count)

### FIXED CODE ###

N = int(input())
S = input()
r = S.count('R')
g = S.count('G')
b = S.count('B')
count = r * g * b
for i in range(N):
    for j in range(i+1,N-1):
        if 2*j - i <= N-1:
            l = set([S[i],S[j],S[2*j-i]])
            if len(l) == 3:
                count -= 1
print(count)
### BUGGY CODE ###

import math
import collections
import numpy as np

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

for i in range(N):
    result = 0
    ind = np.ones(N, dtype=bool)
    ind[i] = False
    # pop = A.pop(i)
    c = collections.Counter(A[ind])
    values, counts = zip(*c.most_common())
    for v in counts:
        if v > 1:
            result = result + combinations_count(v, 2)
        else:
            break
        
    # A.insert(i, pop)
    print(result)

### FIXED CODE ###

import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)
### BUGGY CODE ###

# D - Dice in Line

N, K = map(int, input().split())
P = list(int(x) for x in input().split())

A = [0] * K

for i in range(K-1, N):
    if sum(P[i-(K-1):i+1])>sum(A):
        A = P[i-(K-1):i+1]

ans = 0

for a in A:
    ans += 0.5*(1+a)

print(ans)

### FIXED CODE ###

# D - Dice in Line

N, K = map(int, input().split())
P = list(int(x) for x in input().split())

S = [0] * (N+1)

for i in range(N):
    S[i+1] = S[i] + P[i]

ans = 0

for j in range(K, N+1):
    if S[j]-S[j-K]>ans:
        ans = S[j]-S[j-K]

print(0.5*(K+ans))
### BUGGY CODE ###

from collections import deque
n = int(input())
dList = deque()

for _ in range(n):
  op = list(map(str,input().split()))
  if(op[0] == "insert"):
    dList.appendleft(op[1])
  elif(op[0] == "delete"):
    try:
        dList.remove(op[1])
    except:
        pass
  elif(op[0] == "deleteFirst"):
    dList.popleft()
  elif(op[0] == "deleteLast") :
    dList.pop()

print(*dList)



### FIXED CODE ###


import collections,sys
def s():
  d = collections.deque()
  input()
  for e in sys.stdin:
    if "i"==e[0]: d.appendleft(e[7:-1])
    else:
      if " "==e[6]:
        m = e[7:0-1]
        if m in d: d.remove(m)
      elif "i"==e[7]: d.popleft()
      else: d.pop()
  print(*d)

s()
### BUGGY CODE ###

def binsearch(left=-1, right=float("inf"), evaluate=lambda: True):
    while left + 1 < right:
        mid = (left + right) // 2
        if evaluate(mid):
            right = mid
        else:
            left = mid
    return left


def binsearch_arr(target, arr):
    return binsearch(evaluate=lambda x: target <= arr[x], left=-1, right=len(arr))


def main():
    A, B, Q = map(int, input().split())
    S = [int(input()) for _ in range(A)]
    T = [int(input()) for _ in range(B)]
    for i in range(Q):
        x = int(input())
        l1 = binsearch_arr(x, S)
        l2 = binsearch_arr(x, T)
        tmp = float("inf")
        if l1 >= 0 and l2 >= 0:
            tmp = min(tmp, x - min(S[l1], T[l2]))
        if l1+1 < len(S) and l2 >= 0:
            tmp = min(tmp, S[l1+1] - T[l2] + min(S[l1+1]-x, x-T[l2]))
        if l1 >= 0 and l2+1 < len(T):
            tmp = min(tmp, T[l2+1] - S[l1] + min(T[l2+1]-x, x-S[l1]))
        if l1+1 < len(S) and l2+1 < len(T):
            tmp = min(tmp, max(S[l1+1], T[l2+1]) - x)
        print(tmp)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from bisect import bisect_left

INF = 10**12


def main():
    A, B, Q = map(int, input().split())
    S = [-INF] + [int(input()) for _ in range(A)] + [INF]
    T = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(Q):
        x = int(input())
        l1 = bisect_left(S, x)
        l2 = bisect_left(T, x)
        tmp = INF
        for s in (S[l1-1], S[l1]):
            for t in (T[l2-1], T[l2]):
                tmp = min(tmp, abs(s-t) + abs(x-s))
                tmp = min(tmp, abs(s-t) + abs(x-t))
        print(tmp)


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

n = int(input())
V = list(map(int,input().split()))
L1 = []
L2 = []
for i in range(n) :
    if i % 2 == 0 :
        L1.append(V[i])
    else :
        L2.append(V[i])
T1 = list(set(L1))
T2 = list(set(L2))
X1 = []
X2 = []
for j in range(len(T1)) :
    X1.append(L1.count(T1[j]))
for k in range(len(T2)) :
    X2.append(L2.count(T2[k]))

p = len(T1)
q = len(T2)
if p == 1 and q == 1 :
    if L1[0] != L2[0] :
        print(0)
    else :
        print(len(L2))
elif p != 1 and q == 1 :
    print(sum(X1)-max(X1))
elif p == 1 and q != 1 :
    print(sum(X2)-max(X2))
else :
    print(sum(X1)-max(X1)+sum(X2)-max(X2))


### FIXED CODE ###

#input phase
N = int(input())
V = list(map(int,input().split()))
#make dictionary
D1 = {}
D2 = {}
#append element to dictionary
for i in range(N):
    if i % 2 == 0 :
        if V[i] in D1 :
            D1[V[i]] += 1
        else:
            D1[V[i]] = 1
    else:
        if V[i] in D2 :
            D2[V[i]] += 1
        else:
            D2[V[i]] = 1
#define max-value of each dictionary
maxD1 = max(D1.values())
maxD2 = max(D2.values())
# I haven't appreciated dictionary method well...
if max(D1, key=D1.get) != max(D2, key=D2.get):
    print(N-maxD1-maxD2)
else:
    D1[max(D1, key=D1.get)] = 0
    D2[max(D2, key=D2.get)] = 0
    maxD12 = max(D1.values())
    maxD22 = max(D2.values())
    if maxD12 >= maxD22 :
        if len(D1) > 1 :
            print(N-maxD12-maxD2)
        else :
            print(N-maxD2)
    else :
        if len(D2) > 1 :
            print(N-maxD1-maxD22)
        else :
            print(N-maxD2)
### BUGGY CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
A.sort()

for B,C in BC:
  if min(A) >= C:
    break
  else:
    for i in range(B):
      if min(A) >= C:
        break
      else:
        A.append(C)
        A.pop(0)

ans = sum(A)

print(ans)


### FIXED CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
min_A = min(A)

for B,C in BC:
  if min_A >= C and count > N:
    break
  else:
    l = min(B, N-count)
    for i in range(l):
      count+=1
      A.append(C)

A.sort()

ans = sum(A[count:len(A)])

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

n=int(input())

if n==1:
    print("Yes")
    print(2)
    print(1,1)
    print(1,1)
    exit()
a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set(range(1,1+n))
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    print(n*2//a,*ll)

### FIXED CODE ###

def main():
    n=int(input())
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        print("Yes")
        m+=1
        print(m)
    else:
        print("No")
        exit()
    
    ans=[[m-1] for i in range(m)]
    c=1
    for i in range(m):
        for j in range(i+1,m):
            ans[i].append(c)
            ans[j].append(c)
            c+=1
    for i in ans:
        print(*i)


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

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

tree = dict()
for i in range(n-1):
  a,b = map(int, input().split())
  if a in tree: tree[a].add(b)
  else: tree[a] = {b}
  if b in tree: tree[b].add(a)
  else: tree[b] = {a}

opr = {i+1:0 for i in range(n)}
for i in range(q):
  p,x = map(int, input().split())
  opr[p] += x

stack = [1]
parent = [0] * (n+1)
ans = [0]*n
while stack:
  x = stack.pop()
  ans[x-1] += opr[x]
  for y in tree[x]:
    if y == parent[x]: continue
    parent[y] = x
    stack.append(y)
    ans[y-1] += ans[x-1]

print(*ans)

### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,q = map(int, input().split())
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:n+n-2])
PX = iter(ABPX[n+n-2:])

tree = dict()
for a,b in zip(AB,AB):
  if a in tree: tree[a].add(b)
  else: tree[a] = {b}
  if b in tree: tree[b].add(a)
  else: tree[b] = {a}

opr = {i+1:0 for i in range(n)}
for p,x in zip(PX,PX):
  opr[p] += x

stack = [1]
parent = [0] * (n+1)
ans = [0]*n
while stack:
  x = stack.pop()
  ans[x-1] += opr[x]
  for y in tree[x]:
    if y == parent[x]: continue
    parent[y] = x
    stack.append(y)
    ans[y-1] += ans[x-1]

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

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0]
bb = [0]
for i in a:
    aa.append(aa[-1]+i)
for i in b:
    bb.append(bb[-1]+i)
sub = []
for i in range(len(aa)):
    if aa[i] > k:
        break
    for j in range(len(bb)):
        if aa[i]+bb[j] <= k:
            tmp = i+j
        else:
            break
    sub.append(tmp)
print(max(sub))


### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0]
for i in a:
    aa.append(aa[-1]+i)
bb = [0]
for i in b:
    bb.append(bb[-1]+i)
ans = 0
j = m
for i in range(n+1):
    if aa[i] > k:
        break
    while aa[i] + bb[j] > k and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)
### BUGGY 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 math
from collections import defaultdict

# 組み合わせ
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

A.sort(reverse=True)

max_v = 0
ans = 0
for i in range(N-1):
    memo = defaultdict(int)
    for j in range(i+1, N):
        if memo[A[j]] > 0:
            continue

        x = combinations_count(A[i], A[j])
        memo[A[j]] = x
#        print(x, A[i], A[j])
        if x > max_v:
            max_v = x
            ans = (A[i], A[j])

print(*ans)

### 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) ]
##############################

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

left = max(A)
center = left // 2

right = 0
diff = INF
for i in range(N):
    if A[i] == left:
        continue

    x = abs(center-A[i])
    if diff > x:
        diff = x
        right = A[i]

print(left, right)
### BUGGY CODE ###

from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    S.reverse()
  else:
    if A[1]=="1":
      S.appendleft(A[2])
    else:
      S.append(A[2])
ans="".join(S)
print(ans)

### FIXED CODE ###

from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    count=(count+1)%2
  else:
    if A[1]=="1":
      if count==0:
        S.appendleft(A[2])
      else:
        S.append(A[2])
    else:
      if count==0:
        S.append(A[2])
      else:
        S.appendleft(A[2])
if count==1:
  S.reverse()
ans="".join(S)
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
p=[(i+1)/2 for i in p]
a=0
for i in range(n-k+1):
  a=max(a,sum(p[i:i+k]))
print(a)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
p=[(i+1)/2 for i in p]
a=sum(p[0:k])
b=a
for i in range(0,n-k):
  a=a-p[i]+p[i+k]
  b=max(a,b)
print(b)
### BUGGY CODE ###

def main():
    N,M,K=map(int,input().split())
    MOD=998244353
    E=0

    n_=1
    for i in range(1,N):
        n_=(n_*i)%MOD

    nr_ = 1
    nr_array=[]
    for i in range(1,N-1):
        nr_ = (nr_ * i) % MOD
        nr_array.append(nr_)

    r_=1
    for i in range(0,K+1):
        if i!=0 and i!=N-1:
            r_ = (r_ * i) % MOD
            nr_=nr_array.pop()
            power_r=pow(r_,MOD-2,MOD)
            power_nr=pow(nr_,MOD-2,MOD)
        Mk=pow(M-1,N-1-i,MOD)

        if i!=0 and i!=N-1:
            E+=(n_*power_r*power_nr*Mk)%MOD
        else:
            E+=Mk%MOD

    res=(M*E)%MOD
    print(res)

if __name__=="__main__":
    main()



### FIXED CODE ###

def main():
    N,M,K=map(int,input().split())
    MOD=998244353
    E=0

    n_=1
    for i in range(1,N):
        n_=(n_*i)%MOD

    nr_ = 1
    nr_array=[]
    for i in range(1,N-1):
        nr_ = (nr_ * i) % MOD
        nr_array.append(nr_)
    m=1
    Mk_array=[1]
    for i in range(1,N):
        m=(m*(M-1))%MOD
        Mk_array.append(m)
    r_=1
    for i in range(0,K+1):
        if i!=0 and i!=N-1:
            r_ = (r_ * i) % MOD
            nr_=nr_array.pop()
            power_r=pow(r_,MOD-2,MOD)
            power_nr=pow(nr_,MOD-2,MOD)
        Mk=Mk_array.pop()

        if i!=0 and i!=N-1:
            E+=(n_*power_r*power_nr*Mk)%MOD
        else:
            E+=Mk%MOD

    res=(M*E)%MOD
    print(res)

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

N = int(input())

lst = list()
count = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        ahead = int(str(i)[0])
        atail = i % 10
        bhead = int(str(j)[0])
        btail = j % 10
        if ahead == btail and atail == bhead:
            count += 1
print(count)


### FIXED CODE ###

def main3(N):
    lst = list()
    for i in range(1, 10):
        lst.append([0]*9)

    for n in range(1, N+1):
        head = int(str(n)[0])
        tail = int(str(n)[-1])
        #末尾が0はNG
        if tail != 0:
            lst[head-1][tail-1] += 1
        
    #for i in range(0, len(lst)):
    #    print(lst[i])
    
    count = 0
    for i in range(0, len(lst)):
        for j in range(0, len(lst[i])):
            count += lst[i][j] * lst[j][i]

    print(count)

N = int(input())
main3(N)