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

def insertionSortForShell(lst, n, g):
    cnt = 0
    for i in range(g, n):
        v = lst[i]
        j = i - g
        while j >= 0 and lst[j] > v:
            lst[j+g] = lst[j]
            j = j - g
            cnt += 1
        lst[j+g] = v
    return cnt


def shellSort(lst, n):
    cnt = 0
    G = [1000000, 500000, 100000, 50000, 10000, 5000, 2500, 1000, 600, 400,
         200, 100, 80, 50, 30, 10, 5, 3, 1]
    G2 = []
    for i in range(0, len(G)):
        if G[i] < n:
            tmp = insertionSortForShell(lst, n, G[i])
            if tmp != 0:
                G2.append(G[i])
            cnt += tmp

    if len(G2) == 0:
        print(1)
        print(1)
    else:
        print(len(G2))
        print(" ".join([str(g) for g in G2]))
    print(cnt)
    for n in lst:
        print(n)


if __name__ == "__main__":
    n = int(input())
    lst = []
    for i in range(0, n):
        lst.append(int(input()))
    shellSort(lst, n)

### FIXED CODE ###

def insertionSortForShell(lst, n, g):
    cnt = 0
    for i in range(g, n):
        v = lst[i]
        j = i - g
        while j >= 0 and lst[j] > v:
            lst[j+g] = lst[j]
            j = j - g
            cnt += 1
        lst[j+g] = v
    return cnt


def cleate_split_lst(n):
    lst = []
    while 1:
        n = int(n/2)
        if n <= 1:
                lst.append(1)
                break
        else:
                lst.append(n)
    return lst


def shellSort(lst, n):
    cnt = 0
    G = cleate_split_lst(n)

    for i in range(0, len(G)):
        cnt += insertionSortForShell(lst, n, G[i])

    print(len(G))
    print(" ".join([str(g) for g in G]))
    print(cnt)
    for n in lst:
        print(n)


if __name__ == "__main__":
    n = int(input())
    lst = []
    for i in range(0, n):
        lst.append(int(input()))
    shellSort(lst, n)
### BUGGY CODE ###

lis=list(map(int,input().split()))
A=lis[0]
B=lis[1]
C=lis[2]
D=lis[3]
sum=B-A+1
gcd=1
for x in range(C):
  if D%(1+x)==0 and C%(1+x)==0:
    gcd=1+x
times=C*D//gcd
restac=A%C
restbc=B%C
restad=A%D
restbd=B%D
restat=A%times
restbt=B%times
x=int((B-restbc)//C)-int((A-restac)//C)
y=int((B-restbd)//D)-int((A-restad)//D)
z=int((B-restbt)//times)-int((A-restat)//times)
if restac==0:
  x+=1
if restad==0:
  y+=1
if(restat==0):
  z+=1
print(sum-x-y+z)

### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
lis=list(map(int,input().split()))
A=lis[0]
B=lis[1]
C=lis[2]
D=lis[3]
sum=B-A+1

times=C*D//gcd(C,D)
restac=A%C
restbc=B%C
restad=A%D
restbd=B%D
restat=A%times
restbt=B%times
x=int((B-restbc)//C)-int((A-restac)//C)
y=int((B-restbd)//D)-int((A-restad)//D)
z=int((B-restbt)//times)-int((A-restat)//times)
if restac==0:
  x+=1
if restad==0:
  y+=1
if(restat==0):
  z+=1
print(sum-x-y+z)
### BUGGY CODE ###

import math
import sys


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


input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
LCM = 1
ans = 0
MOD = 1000000007
for x in A:
  LCM = lcm(LCM, x)
for x in A:
  ans += LCM // x
  ans %= MOD

print(ans)

### FIXED CODE ###

import math
import sys


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


input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
LCM = 1
ans = 0
MOD = 1000000007
for x in A:
  LCM = lcm(LCM, x)
for x in A:
  ans += LCM // x

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

# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    while link[x] >= 0:
        x = link[x]
    return x


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    a = find(i)
    b = find(p[i - 1])
    if a == b:
        cnt += 1
print(cnt)


### FIXED CODE ###

# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    if link[x] < 0:
        return x
    else:
        # 経路の圧縮
        link[x] = find(link[x])
        return link[x]


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    if find(i) == find(p[i - 1]):
        cnt += 1
print(cnt)
### BUGGY CODE ###

def resolve():
    N, K = map(int, input().split())
    targets = list(map(str, input().split()))
    targets_dict = {}

    for i in range(N):
        if targets[i] not in targets_dict:
            targets_dict[targets[i]] = 1
        else:
            targets_dict[targets[i]] += 1

    need_reduce = len(targets_dict) - K

    if need_reduce <= 0:
        print(0)
    else:
        ans = 0
        for _ in range(need_reduce):
            min_kv = min(targets_dict.items(), key=lambda x: x[1])
            ans += min_kv[1]
            del targets_dict[min_kv[0]]

        print(ans)
        
resolve()

### FIXED CODE ###

def resolve():
    N, K = map(int, input().split())
    targets = list(map(str, input().split()))
    targets_dict = {}

    for i in range(N):
        if targets[i] not in targets_dict:
            targets_dict[targets[i]] = 1
        else:
            targets_dict[targets[i]] += 1

    need_reduce = len(targets_dict) - K

    if need_reduce <= 0:
        print(0)
    else:
        ans = 0
        targets_dict = sorted(targets_dict.items(), key=lambda x: x[1])
        for i in range(need_reduce):
            ans += targets_dict[i][1]
        print(ans)
       
resolve()
### BUGGY CODE ###

K=int(input())

queue = list(range(1,10))

i = 0
while i!=K:
  lunlun = queue.pop(0)
  #print(lunlun)
  last = lunlun%10
  if last!=0:
    queue.append(10*lunlun+last-1)
  queue.append(10*lunlun+last)
  if last!=9:
    queue.append(10*lunlun+last+1)

  i += 1

print(lunlun)

### FIXED CODE ###

K=int(input())
from collections import deque

#queue = list(range(1,10))
queue = deque(list(range(1,10)))

for i in range(K):
  lunlun = queue.popleft()
  #print(lunlun)
  last = lunlun%10
  if last!=0:
    queue.append(10*lunlun+last-1)
  queue.append(10*lunlun+last)
  if last!=9:
    queue.append(10*lunlun+last+1)

print(lunlun)
### BUGGY CODE ###

import math


def main():
    s1 = input()   
    s2 = input()
    
    dp = [[0]*(len(s2)+1) for x in range(len(s1)+1)]
    for x in range(len(s1)):
        dp[x][0] = 0
    for x in range(len(s2)):
        dp[0][x] = 0
    
    for x in range(1,len(s1)+1):
        for y in range(1,len(s2)+1):
            if s1[x-1]==s2[y-1]:
                dp[x][y] = dp[x-1][y-1]+1
            else:
                dp[x][y] = max(dp[x][y-1],dp[x-1][y])
    x = len(s1)
    y = len(s2)
    s = ""
    while x > 0 and y > 0:
        if(s1[x-1]==s2[y-1]):
            s+=s1[x-1]
            x-=1
            y-=1
        elif dp[x-1][y] > dp[x][y-1]:
            x-=1
        else:
            y-=1
    print(s[::-1])
    
main()

### FIXED CODE ###

import math


def main():
    s1 = input()   
    s2 = input()
    
    dp = [[0]*(len(s2)+1) for x in range(len(s1)+1)]
    for x in range(len(s1)):
        dp[x][0] = 0
    for x in range(len(s2)):
        dp[0][x] = 0
    
    for x in range(1,len(s1)+1):
        for y in range(1,len(s2)+1):
            if s1[x-1]==s2[y-1]:
                dp[x][y] = dp[x-1][y-1]+1
            else:
                dp[x][y] = max(dp[x][y-1],dp[x-1][y])
    x = len(s1)
    y = len(s2)
    s = ""
    while x > 0 and y > 0:
        if(s1[x-1]==s2[y-1]):
            s+=s1[x-1]
            x-=1
            y-=1
        elif dp[x-1][y] > dp[x][y-1]:
            x-=1
        else:
            y-=1
    print(s[::-1])
    
main()
### BUGGY CODE ###

n=int(input())
A=[0]+list(map(int,input().split()))+[0]
diff=[abs(A[i]-A[i-1]) for i in range(1,len(A))]



for i in range(1,n+1):
  if i==n:
    print(sum(diff)-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
    exit()
  elif A[i]<=A[i+1] and ((A[i]>0 and A[i+1]<0) or (A[i]<0 and A[i+1]>0)):
    print(sum(diff)-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
  elif A[i]<=A[i+1]:
    print(sum(diff))
  else:
    print(sum(diff)-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))



### FIXED CODE ###

n=int(input())
A=[0]+list(map(int,input().split()))+[0]
diff=[abs(A[i]-A[i-1]) for i in range(1,len(A))]
sums=sum(diff)

for i in range(1,n+1):
  # if i==n:
  #   print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
  #   exit()
  # elif A[i]<=A[i+1] and ((A[i]>0 and A[i+1]<0) or (A[i]<0 and A[i+1]>0)):
  #   print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
  # elif A[i]<=A[i+1]:
  #   print(sums)
  # else:
    print(sums-abs(A[i]-A[i+1])-abs(A[i-1]-A[i])+abs(A[i-1]-A[i+1]))
### BUGGY CODE ###

N, M, K = map(int, input().split())
A = input().split()
B = input().split()
for n in range(N):
    A[n] = int(A[n])
for m in range(M):
    B[m] = int(B[m])
Ka = 0
ca = 0
for a in range (N):
    if Ka + A[a] <= K:
        Ka += A[a]
        ca += 1
    else:
        break
Kb = 0
cb= 0
for b in range (M):
    if Kb + B[b] <= K:
        Kb += B[b]
        cb += 1
    else:
        break
list_c = [ca, cb]
for i in range (1, ca+1):
    for j in range (1, cb+1):
        c = i + j
        s = 0
        for a in range (i):
            s += A[a]
        for b in range (j):
            s += B[b]
        if s <= K:
            list_c.append(c)
list_c.sort()
print(list_c[len(list_c) - 1])


### FIXED CODE ###

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

sum_A = [0]
for  i in range(N):
    sum_A.append(sum_A[i] + A[i])

sum_B = [0]
for  i in range(M):
    sum_B.append(sum_B[i] + B[i])

ans = 0
j = M

for i in range (N+1):
    if sum_A[i] > K:
        break
    while sum_B[j] > K - sum_A[i]:
        j -= 1
    ans = max(ans, i+j)

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

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

for i in range(m):
    max_tmp = max(list_A)
    for j in range(len(list_A)):
        if list_A[j] == max_tmp:
            list_A[j] = int(list_A[j]/2)
            break

            # print(i, j, list_A[j])

print(sum(list_A))

### FIXED CODE ###

import heapq as hp
n, m = map(int, input().split())
list_A = list(map(int, input().split()))
# list_A = sorted(list_A)

a_q = []
for i in list_A:
    hp.heappush(a_q, -1*i)

for i in range(m):
    tmp = hp.heappop(a_q)
    tmp = hp.heappush(a_q, int(tmp/2))

print(-sum(a_q))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, d, a = MAP()
monster = {}
x = []
for i in range(n):
    xx, hh = MAP()
    monster[xx] = hh
    x.append(xx)
x.sort()
cnt = 0
for i in range(n):
    cx, ch = x[i], monster[x[i]]
    if ch <= 0:
        continue
    cn = (ch + a - 1) // a
    cnt += cn
    tmp = []
    j = i + 1
    while j < n:
        nx = x[j]
        if nx <= cx + 2*d:
            monster[nx] -= cn * a
            j += 1
        else:
            break
    
print(cnt)


### FIXED CODE ###

from collections import deque
import sys

input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, d, a = MAP()
xh = [LIST() for i in range(n)]

xh = sorted(xh, key=lambda x:(x[0]))
q = deque()
ca = 0
cnt = 0
for i in range(n):
    cx, ch = xh[i][0], xh[i][1]
    
    while q and q[0][0] < cx:
        qx, qa = q.popleft()
        ca -= qa
    
    if ch - ca <= 0:
        continue
    
    cn = (ch - ca + a - 1) // a
    cnt += cn
    ca += cn * a
    q.append([cx+2*d, cn*a])
    
print(cnt)
### BUGGY CODE ###

def abs(n, k):
    if n - k >= 0:
        return n-k
    else:
        return k-n

N, K = map(int, input().split())
while N > abs(N, K):
    N, K = abs(N, K), K
print(N)


### FIXED CODE ###

N, K = map(int, input().split())
r = N % K
print(min(r, K-r))
### BUGGY CODE ###

import itertools
from fractions import gcd

K = int(input())
l = range(1, K+1)
ans = 0

for a, b, c in itertools.product(l, repeat=3):
    ans += gcd(gcd(a, b), c)

print(ans)


### FIXED CODE ###

import itertools
import math
 
K = int(input())
l = range(1, K+1)
ans = sum(l)
 
for a, b in itertools.combinations(l, 2):
    ans += math.gcd(a, b) * 6
 
for a, b, c in itertools.combinations(l, 3):
    ans += math.gcd(math.gcd(a,b), c)*6
    
        
print(ans)
### BUGGY CODE ###

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

check = True
for i in range(0,N-1):
  if H[i] - min(H[i+1:]) >= 2:
    check = False

if check:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
H.reverse()

check = True

for i in range(N-1):
  if H[i] >= H[i+1]:
    continue
  else:
    if H[i+1] - H[i] > 1:
      check = False
      break
    else:
      H[i+1] -= 1
      
if check:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

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

f_inf = float('infinity')
dp = [f_inf] * N
dp[0] = 0

for i in range(1, N):
    for j in range(1, min(i,K)+1):
        dp[i] = min(dp[i], dp[i-j] + abs(H[i] - H[i-j]))

print(dp[N-1])


### FIXED CODE ###

import numpy as np

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

dp = np.full(N, np.inf)
dp[0] = 0
H = np.array(H)

for i in range(1, N):
    j = max(0,i-K)
    dp[i] = min(dp[j:i] + np.abs(H[i] - H[j:i]))

print(int(dp[N-1]))
### BUGGY CODE ###


def main():
    s, c = list(map(int, input().split()))
    count = 0
    while True:
        if c < 2 or (s < 1 and c < 4):
            break
        if s > 1:
            s -= 1
            c -= 2
        else:
            c -= 4
        count += 1
    print(count)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s, c = list(map(int, input().split()))
    count = 0
    if s <= c//2:
        count = s
    else:
        print(c//2)
        exit()
    c -= s*2
    print(count+c//4)


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

#AC済み
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ab=[-a[i]-b[j] for j in range(y) for i in range(x)]
ab.sort()
ab=ab[:k]
l=len(ab)
abc=[ab[i]-c[j] for j in range(z) for i in range(l)]
abc.sort()
for i in range(k):
    print(-abc[i])


### FIXED CODE ###

import heapq
x,y,z,k=map(int,input().split())
#heapqは小さい順にしか並べられないので、-をつければ大きい順になる
a=sorted([-int(i) for i in input().split()])
b=sorted([-int(i) for i in input().split()])
c=sorted([-int(i) for i in input().split()])
check=set()
ans=[]
heapq.heappush(ans,(a[0]+b[0]+c[0],0,0,0))
check.add((0,0,0))
for i in range(k):
    h=heapq.heappop(ans)
    print(-h[0])
    if h[1]+1<x:
        if (h[1]+1,h[2],h[3]) not in check:
            heapq.heappush(ans,(a[h[1]+1]+b[h[2]]+c[h[3]],h[1]+1,h[2],h[3]))
            check.add((h[1]+1,h[2],h[3]))
    if h[2]+1<y:
        if (h[1],h[2]+1,h[3]) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]+1]+c[h[3]],h[1],h[2]+1,h[3]))
            check.add((h[1],h[2]+1,h[3]))
    if h[3]+1<z:
        if (h[1],h[2],h[3]+1) not in check:
            heapq.heappush(ans,(a[h[1]]+b[h[2]]+c[h[3]+1],h[1],h[2],h[3]+1))
            check.add((h[1],h[2],h[3]+1))
'''
while len(ans)!=0:
    print(heapq.heappop(ans)[0])
'''
### BUGGY CODE ###

N, *a = map(int, open(0).read().split())
b = []
for i, v in enumerate(a):
    if i % 2 == 0:
        b.append(v)
    else:
        b.insert(0, v)
        
if N % 2 == 0:
    print(*b)
else:
    print(*b[::-1])

### FIXED CODE ###

N, *a = map(int, open(0).read().split())
b = a[1::2][::-1] + a[::2]
if N % 2 == 0:
    print(*b)
else:
    print(*b[::-1])
### BUGGY CODE ###

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

dp = [float('inf') for _ in range(n)]
dp[0] = 0

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


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        a = h[i]
        for j in range(1, min(k+1, n-i)):
            num = dp[i]+abs(a-h[i+j])
            if num < dp[i+j]:
                dp[i+j] = num
    print(dp[-1])

main()
### BUGGY CODE ###

import sys
import math

n = int(sys.stdin.readline())

power = math.factorial(n)

print power % (long(1e+9) + 7)


### FIXED CODE ###

import sys
import math

n = int(sys.stdin.readline())

power = math.factorial(n)

print(power % (int(1e+9) + 7))
### BUGGY CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    A.sort()

    l = 1
    res = 0
    for a in A:
        l2 = gm(a, l)
        res = (res * l2 // l) % mod
        res = (res + l2 // a) % mod
        l = l2
    print(res)


if __name__ == "__main__":
    main()



### FIXED CODE ###

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


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

# 解説放送の解法

INF = 1001001001

N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    s = 0
    for c in C:
        c -= 1
        s |= 1 << c
    key.append((s, a))

dp = [INF] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

ans = dp[-1]
if ans == INF:
    ans = -1

print(ans)


### FIXED CODE ###

# 解説放送の解法

INF = 1001001001

N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        c -= 1
        s |= 1 << c
    key.append((s, a))

dp = [INF] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)

ans = dp[-1]
if ans == INF:
    ans = -1

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

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a
cost = sum(s_cost)
orig_list = list(range(N))
for k in range(1,N):
    s_cost = [min(s_cost[x],a[y]) for (x,y) in zip( orig_list, list(range(N-k,N))+list(range(N-k)) )]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)


### FIXED CODE ###

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
s_cost = a.copy()
cost = sum(s_cost)
for k in range(1,N):
    for i in range(N):
        if s_cost[i] > a[(i-k)%N] :
            s_cost[i] = a[(i-k)%N]
    if cost > k*x + sum(s_cost):
        cost = k*x + sum(s_cost)
    else:
        break

print(cost)
### BUGGY CODE ###

n, m, *a = map(int, open(0).read().split())

a.sort(reverse=True)

a0 = 0
a1 = 0

if n == 1:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] == 0:
      break
else:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] < a[1]:
      if a[0] < a[2]:
        a.sort(reverse=True)
      else:
        a0 = a[0]
        a1 = a[1]
        a[0] = a1
        a[1] = a0

print(sum(a))

### FIXED CODE ###

n, m, *a = map(int, open(0).read().split())

a.sort(reverse=True)

if n == 1:
  for i in range (0,m):
    a[0] = a[0]//2
    if a[0] == 0:
      break
else:
  a.append(0)
  biggest = a[0]
  now = 0
  while m > 0:
    a[now] = a[now]//2
    m = m - 1
    biggest = a[0]
    for i in range (n-1):
      if a [i+1] >= biggest and m>0:
        a[i+1] = a[i+1]//2
        m = m -1
      else:
        a.sort(reverse = True)
        break

print(sum(a))
### BUGGY CODE ###

from bisect import *
from heapq import *

md = 998244353
n = int(input())
hp = []
for _ in range(n):
    heappush(hp, list(map(int, input().split())))
cy = [[0] * 4 for _ in range(n)]
xy = []
ys = []
for i in range(n):
    x, y = heappop(hp)
    s = bisect(ys, y)
    cy[i][3] = pow(2, s, md)
    cy[i][2] = pow(2, i - s, md)
    ys.insert(s, y)
    xy.append([x, y])
ys = []
for i in range(n - 1, -1, -1):
    x, y = xy[i]
    s = bisect(ys, y)
    cy[i][0] = pow(2, s, md)
    cy[i][1] = pow(2, n - 1 - i - s, md)
    ys.insert(s, y)
ans = pow(2, n - 1, md) * n % md
for i in range(n):
    c0, c1, c2, c3 = cy[i]
    ans = (ans + (c0 - 1) * (c2 - 1) * c1 * c3 + (c1 - 1) * (c3 - 1) * c0 * c2
           - (c0 - 1) * (c1 - 1) * (c2 - 1) * (c3 - 1)) % md
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class BitSum:
    def __init__(self, n):
        self.n = n + 1
        self.table = [0] * self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    md=998244353
    n=II()
    xy=LLI(n)
    yy=set()
    for x,y in xy:yy.add(y)
    ytoj={y:j for j,y in enumerate(sorted(yy))}

    ans=n*(pow(2,n,md)-1)-4*(pow(2,n,md)-1-n)
    ans%=md

    xy.sort()
    bit=BitSum(200005)
    for i,[x,y] in enumerate(xy):
        j=ytoj[y]
        c=bit.sum(j-1)
        ans+=pow(2,c,md)-1
        ans+=pow(2,i-c,md)-1
        ans%=md
        bit.add(j,1)

    bit=BitSum(200005)
    for i,[x,y] in enumerate(xy[::-1]):
        j=ytoj[y]
        c=bit.sum(j-1)
        ans+=pow(2,c,md)-1
        ans+=pow(2,i-c,md)-1
        ans%=md
        bit.add(j,1)

    print(ans)

main()
### BUGGY CODE ###

N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
A = 1
if a[0] == 0:
    print(0)
else: 
    for i in range(N):
        A = A * a[i]
if A > 1000000000000000000:
    print(-1)
else:
    print(A)

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
  print(0)
  exit()
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    exit()
print(A)