Harryxun/stf_run huggingface dataset:
n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)

### FIXED CODE ###

import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)
n = int(input())
h = list(map(int,input().split()))
memo = [-1 for i in range(n)]

def dp(i):
    if i == 0:
        return 0
    elif i >= 2:
        if memo[i] != -1:
            return memo[i]
        else:
            memo[i] = min(dp(i-2) + abs(h[i]-h[i-2]), dp(i-1) + abs(h[i]-h[i-1]))
            return memo[i]
    else:
        return abs(h[1]-h[0])

print(dp(n-1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
h = list(map(int,input().split()))
memo = [-1 for i in range(n)]

def dp(i):
    if i == 0:
        return 0
    elif i >= 2:
        if memo[i] != -1:
            return memo[i]
        else:
            memo[i] = min(dp(i-2) + abs(h[i]-h[i-2]), dp(i-1) + abs(h[i]-h[i-1]))
            return memo[i]
    else:
        return abs(h[1]-h[0])

print(dp(n-1))
n=int(input())
s=input()
k=[i for i in range(1,n+1)]
from itertools import combinations
c=list(combinations(k,3))
ans=0
for i in range(len(c)):
  p=c[i][0]
  q=c[i][1]
  r=c[i][2]
  if s[p]!=s[q] and s[q]!=s[r] and s[p]!=s[r] and q-p!=r-q:
    ans=ans+1
print(ans)  

### FIXED CODE ###

n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 
      ans=ans+1
print(a*b*c-ans)
A=input()
B=input()
C=input()
D=[]
E=[]
F=[]
s=a
x=len(A)
y=len(B)
z=len(C)
for i in range(len(A)):
    D.append(A[i])
for i in range(len(B)):
    E.append(B[i]) 
for i in range(len(C)):
    F.append(C[i])
while x>=0 and y>=0 and z>=0:
    if s==a:
        if x==0:
            print("A")
            break
        else:
            count=D[0]
            D.pop(0)
            x-=1
    elif s==b:
        if y==0:
            print("B")
            break
        else:
            count=E[0]
            E.pop(0)
            y-=1
    else:
        if z==0:
            print("C")
            break
        else:
            count=F[0]
            F.pop(0)
            z-=1
 
    

### FIXED CODE ###

sa = input()
sb = input()
sc = input()
turn = sa[0]
sa = sa[1:]
while True:
    if turn == 'a':
        if not sa:
            win = 'A'
            break
        else:
            turn = sa[0]
            sa = sa[1:]
    if turn == 'b':
        if not sb:
            win = 'B'
            break
        else:
            turn = sb[0]
            sb = sb[1:]
    if turn == 'c':
        if not sc:
            win = 'C'
            break
        else:
            turn = sc[0]
            sc = sc[1:]
print(win)
w = raw_input()

i = 0
count = 0

S = raw_input().split(" ")

while S[i] != "END_OF_TEXT":
    if S[i] == w:
        count += 1
    i += 1
    
print count

### FIXED CODE ###

w = raw_input()

i = 0
count = 0

while True:
    S = raw_input().split(" ")

    for s in S:
        if s.upper() == w.upper():
            count += 1

    if S[-1] == "END_OF_TEXT":
        break    
print count
import sys
a, b, c, d = map(int, sys.stdin.readline().split())
li = [1]*a + [0]*b + [-1]*c
print(sum(li[0:d]))


### FIXED CODE ###

a, b, c, k = map(int,input().split())
if a > k:
  print(k)
elif a+b >= k:
  print(a)
else:
  print(a-(k-a-b))
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tmp = 1000000
ans = 0
for i in range(n):
  c = t - h[i] * 0.006
  d = a - c
  if d < 0:
    d = -d
  if d < tmp:
    tmp = d
    ans = i + 1
print(ans)


### FIXED CODE ###

X,Y = map(int, input().split())
print(int (X + Y/2))
from collections import Counter

cnt = Counter(a)
b = set(a)
c = 0
for i in b:
    c += cnt[i]*(cnt[i]-1)//2

for i in a:
    print(c-cnt[i]+1)

### FIXED CODE ###

n = int(input())
a = tuple(map(int, input().split()))

from collections import Counter

cnt = Counter(a)
b = set(a)
c = 0
for i in b:
    c += cnt[i]*(cnt[i]-1)//2

for i in a:
    print(c-cnt[i]+1)
import numpy as np
import math
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7

N = int(readline())
x = np.array(readline().split(), dtype=np.int64)
# print(N, x)

# dif = np.zeros((N-1,N-1), dtype=np.int64)
dif = np.fmax(x[1:].reshape(-1, N-1) - x[:N-1].reshape(N-1, -1), 0)
# print(dif)

cnt = np.zeros((N-1,N-1), dtype=np.int64)
for i in range(N-1):
    for j in range(i+1):
        if i == 0:
            cnt[N-2-i, N-2-j] = math.factorial(N-1)
        elif j == 1:
            cnt[N-2-i, N-2-j] = cnt[N-2-i+1, N-2-j+1] // (i+1)
        elif j == 0:
            cnt[N-2-i, N-2-j] = cnt[N-2-i+1, N-2-j] * i // (i+1)
        else:
            cnt[N-2-i, N-2-j] = cnt[N-2-i+1, N-2-j+1]
# print(cnt)

ans = (dif * cnt) % MOD
# print(ans)
ans = ans.sum()
print(ans)


### FIXED CODE ###

MOD = 10**9+7

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

ans = 0
mul = 0
for i in range(N-1):
    mul += pow(i+1, MOD-2, MOD)
    ans += (x[i+1] - x[i]) * mul % MOD
    ans %= MOD
for i in range(2, N):
    ans *= i
    ans %= MOD
print(ans)
import bisect
import numpy as np
import scipy as sp
from sys import stdin

r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)


### FIXED CODE ###



r, g, b, n = map(int, input().split())
count = 0

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)
#この解答を自分で写経してみる
N,M=map(int,input().split())
AB=[map(int,input().split()) for _ in range(M)]
#map関数を格納したリストを作る
#この_表記で繰り返すという文化に慣れよう

links=[[] for _ in range(N+1)]
#移動先を出力する
#リストの入れ子にしたかったら、最初から入れ子として定義しないといけない
#何か + for _ in range(M)　で、何かをM回繰り返す
for a,b in AB:
#map関数それぞれに対して、値を抽出する
    links[a].append(b)
    links[b].append(a)

from collections import deque
result=[-1]*(N+1)
#これで[-1,-1,,,]のリストは作れる
#各部屋ごとの出力先

q=deque([1])
#始点の定義
while len(q)>0:
    i=q.popleft()
    for j in links[i]:
        if result[j] ==-1:
            result[j] = i
            #新しいものをどんどん加えていくことで、層がどんどん深くなっていく
            q.append(j)
print("yes")
print("\n".join(str(i) for i in result[2:] ))

### FIXED CODE ###

N=int(input())

def yomikata(N):
    N_firstdigit=N%10
    if N_firstdigit==3:
        print("bon")
    #elif N_firstdigit==0 or 1 or 6 or 8: このように条件は省略して書いてはだめらしい!
    elif N_firstdigit==0 or N_firstdigit==1 or N_firstdigit==6 or N_firstdigit==8:
        print("pon")
    else:
        print("hon")
        
yomikata(N)
a,b,c = map(int, input().split())

print(a+b+c)

### FIXED CODE ###

s=input()
a,b,c=s[0],s[1],s[2]

print(int(a)+int(b)+int(c))
n,m = input().split()
n = int(n)
m = int(m)

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

import itertools
l = A
p = itertools.permutations(A,2)

permlist = []
for perm in p:
    permlist.append(perm)

permsumlist = []

for perm in permlist:
    permsumlist.append(sum(perm))

new_list_reverse = sorted(permsumlist, reverse=True)

answer = max(A) + max(A)

for i in range(m-1):
    answer += new_list_reverse[i]

print(answer)

### FIXED CODE ###

import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A.sort()
A = np.array(A, dtype=int)
cs = A[::-1].cumsum()[::-1]


def test(k):
    # 幸福度が k 以上になる握手を採用する
    counts = N - np.searchsorted(A, k - A)
    return counts.sum() >= M


def count(k):
    counts = N - np.searchsorted(A, k - A)
    cnt = counts.sum()

    pos = np.searchsorted(A, k - A)
    ret = ((A * counts)[pos < N] + cs[pos[pos < N]]).sum()
    ret -= abs(M - cnt) * k
    return ret


ok = 0
ng = max(A) * 2 + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid

ans = count(ok)
print(ans)
#!python3

class Node:

    def __init__(self, num):
        self.num = num
        self.v = 1
        self.parent = 0
        self.deep = None


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

# input
N = int(input())
AB = [LI() for _ in range(N - 1)]

# link
link = [[] for _ in range(N + 1)]
for a, b in AB:
    link[a].append(b)
    link[b].append(a)

# nodes
nodes = [Node(i) for i in range(N + 1)]


def create_tree(parent):
    for child in link[parent.num]:
        if child == parent.parent:
            continue
        node = nodes[child]
        node.parent = parent.num
        node.deep = parent.deep + 1
        create_tree(node)
        parent.v += node.v


def main():
    nodes[1].deep = 1
    create_tree(nodes[1])

    x = (nodes[N].deep - nodes[1].deep - 1) // 2
    v = nodes[N]
    for _ in range(x):
        v = nodes[v.parent]
    
    snuke = v.v
    fennec = N - snuke
    ans = "Fennec" if fennec > snuke else "Snuke"
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!python3

import sys
sys.setrecursionlimit(10 ** 6)


class Node:

    def __init__(self, num):
        self.num = num
        self.v = 1
        self.parent = 0
        self.deep = None


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

# input
N = int(input())
AB = [LI() for _ in range(N - 1)]

# link
link = [[] for _ in range(N + 1)]
for a, b in AB:
    link[a].append(b)
    link[b].append(a)

# nodes
nodes = [Node(i) for i in range(N + 1)]


def create_tree(parent):
    for child in link[parent.num]:
        if child == parent.parent:
            continue
        node = nodes[child]
        node.parent = parent.num
        node.deep = parent.deep + 1
        create_tree(node)
        parent.v += node.v


def main():
    nodes[1].deep = 1
    create_tree(nodes[1])

    x = (nodes[N].deep - nodes[1].deep - 1) // 2
    v = nodes[N]
    for _ in range(x):
        v = nodes[v.parent]
    
    snuke = v.v
    fennec = N - snuke
    ans = "Fennec" if fennec > snuke else "Snuke"
    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
S = str(input())

count = 0

for i in range(1, N):
    if S[i-1] == 'A' and S[i] =='B' and S[i+1] == 'C':
        count += 1

print(count)

### FIXED CODE ###

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

count = 0

for i in range(1, N-1):
    if S[i-1] == 'A' and S[i] =='B' and S[i+1] == 'C':
        count += 1

print(count)
N = int(input())
ans = 3 ** N
num = 1

for i in range(N):
    A = int(input())
    num *= (2-(A%2))

print(ans-num)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 3**N
num = 1
for i in A:
    if i%2 == 0:
        num *= 2
print( ans-num )
N = int(input())
A = int(input())

if(n%500 <= A):
    print("Yes")
else:
    print ("No")

### FIXED CODE ###

N = int(input())
A = int(input())

if(N%500 <= A):
    print("Yes")
else:
    print ("No")
#A問題
N,M = map(int,input().split())
A = []
mod = 1000000007
for i in range(M):
    A.append(int(input()))

sta = []
for i in range(N):
    if i == 0:
        sta.append(1)
    elif i == 1:
        sta.append(1)
    elif i == 2:
        sta.append(2)
    else:
        sta.append(sta[i-1]+sta[i-2])

row = []
now = 1
flag = 0
for i in range(N):
    I = i+1
    if i == 0:
        if I in A:
            now = 0
            flag = 1
        else:
            now+=1
    else:
        if I in A:
            if flag == 1:
                flag = 2
                break
            else:
                row.append(now)
                now = 0
                flag = 1
        else:
            flag = 0
            now+=1

if flag == 2:
    print(0)
else:
    row.append(now)
    ans = 1
    for r in row:
        ans = (ans*sta[r-1])%mod
    print(ans)

### FIXED CODE ###

#C問題
mod = 10**9+7
N,M = map(int,input().split())

step = []
for i in range(N+2):
    if i <= 1:
        step.append(1)
    elif i == 2:
        step.append(1)
    else:
        step.append(step[i-1]+step[i-2])
    
A = []
for j in range(M):
    A.append(int(input()))

stairs = []
flag = 0
old = -1
for a in A:
    if a-old == 1:
        flag = 1
        break
    else:
        stairs.append(a-old-1)
        old = a
stairs.append(N-old)

if flag == 1:
    print(0)
else:
    #print(stairs)
    ans = 1
    for s in stairs:
        ans*=step[s]
        
    print(ans%mod)
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array([[int(j) for j in list(format(i,'b').zfill(60))] for i in a]).T
mod = 10**9+7

"""
#2^iをmodで割った余りを出しておく
twos = [1]
for i in range(1,60):
    twos.append((twos[i-1]*2)%mod)

#各baのbitごとに0の個数を求める
c0 = np.sum(ba, axis=1)
"""

#答えは各bitごとの(0の数)*(1の数)より求まる
ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
mod = 10**9+7

twos = 1
ans = 0
for i in range(0,60):
    cou1 = np.count_nonzero((a >> i) & 1)
    ans += (cou1*(n-cou1)*twos)%mod
    twos = (twos*2)%mod

ans %= mod
print(ans)
n,m = map(int,input().split())
d = {}
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
memo = {}
def dp(i):
    if i not in d:
        return 0
    if i not in memo:
        memo[i] = 0
        for nei in d.get(i,[]):
            memo[i] = max(memo[i],dp(nei)+1)
    return memo[i]
ans = 0
for i in range(n):
    ans = max(ans,dp(i))
print(ans)

### FIXED CODE ###

from collections import deque
 
N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1
 
dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)
 
print(max(dp))
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r ~ list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
p = p[::-1]
p = p[:x]
q = q[::-1]
q = q[:y]
r = r[::-1]
ans = p + q + r
ans.sort()
print(sum(ans[:x+y]))


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
p = p[::-1]
q = q[::-1]
r = r[::-1]

ir = 0
ig = 0

red = 0
for i in range(x):
    red += p[i]
    ir = i
green = 0
for i in range(y):
    green += q[i]
    ig = i

ino = 0
while (0 <= ir or 0 <= ig) and ino < c:
    iir = ir
    iig = ig
    iino = ino

    if ig < 0:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    elif ir < 0:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1
    elif p[ir] < q[ig]:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    else:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1

    if iir == ir and iig == ig and iino == ino:
        break

print(green + red)
import numpy as np
N,K = map(int,input().split())
a = np.array(input().split(),np.int64)
a = np.sort(a)
zero = a[a==0]
pos = a[a>0]
neg = a[a<0]

def f(x):
    count = 0
    c = x // pos
    count += np.searchsorted(a, c, side='right').sum()
    count += N*len(zero) if x >= 0 else 0
    c = -(-x // neg)
    count += (N - np.searchsorted(a, c, side='left')).sum()
    count -= a[a*a <= x].size
    count //= 2
    return count

right = 10**18
left = -10**18
while right-left>1:
    mid = (right + left)//2
    if f(mid)<K:
        left = mid
    else:
        right = mid
        
print(int(right))

### FIXED CODE ###

A, B, C = map(int, input().split())

if A == B:
  if A == C:
    print('No')
  else:
    print('Yes')
elif A == C:
  print('Yes')
elif B == C:
  print('Yes')
else:
  print('No')
import math

A = int(input())
B = int(input())

X = B / A
XX = B // A

if XX == 0:
    print(X)
else:
    print(math.ceil(X))

### FIXED CODE ###

A, B = map(int, input().split())
 
X = ((B-2) // (A-1)) + 1

print(X)
H, W = map(int, input().split())
picture = [input() for _ in range(H)]

for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H or picture[i+1][j] == '.':
						if j == W or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')


### FIXED CODE ###

H, W = map(int, input().split())
picture = [input() for _ in range(H)]

for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H-1 or picture[i+1][j] == '.':
						if j == W-1 or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')
x1, y1, x2, y2 = map(int, input().split())
import math
d12 = math.sqrt((x1-x2)**2 + (y1-y2)**2)
  
for x in range(-100, x1):
  for y in range(-100, 100):
    d14 = math.sqrt((x1-x)**2 + (y1-y)**2)
    if d12 == d14:
      y4 = y
      break
  if d12 == d14:
    x4 = x
    break
      
for x in range(-100, x2):
  for y in range(-100, 100):
    d23 = math.sqrt((x2-x)**2 + (y2-y)**2)
    if d12 == d23:
      y3 = y
      break
  if d12 == d23:
    x3 = x
    break

print(x3, y3, x4, y4)

### FIXED CODE ###

x1, y1, x2, y2 = map(int, input().split())
print(x2-y2+y1, y2+x2-x1, x1+y1-y2, y1-x1+x2)
N, S = map(int, input().split())
x = [int(x) for x in input().split()]
x = 0, *x
 
# 状態リストを作成
m = [[[0 for _ in range(3)] for _ in range(S+1)] for _ in range(N+1)]
m[0][0][0] = 1
 
for i in range(1,N+1):
    
    for k in range(S+1):

        # x を含めない
        m[i][k][0] += m[i-1][k][0] # まだ開始しない
        m[i][k][1] += m[i-1][k][0] + m[i-1][k][1]  # 今回から開始して加えない、もしくは既に開始しているが、加えない
        m[i][k][2] += m[i-1][k][0] + m[i-1][k][1] + m[i-1][k][2]  # 今回、開始・終了して加えない、今回開始して加えず終了。

        # x を含める場合
        if k - x[i] >= 0:
            m[i][k][1] += m[i-1][k - x[i]][0] + m[i-1][k - x[i]][1]
            m[i][k][2] += m[i-1][k - x[i]][0] + m[i-1][k - x[i]][1]
        
        m[i][k][0] = m[i][k][0] % 998244353
        m[i][k][1] = m[i][k][1] % 998244353
        m[i][k][2] = m[i][k][2] % 998244353
            
print(m[N][S][2])

### FIXED CODE ###

import numpy as np

N, S = map(int, input().split())
x = [int(x) for x in input().split()]
 
# 状態リストを作成
m = np.zeros((S+1,3))
p = np.zeros((S+1,3))
p[0,0] = 1

# 前状態から次状態の場合数を計算
for i in range(1,N+1):
    
    # x[i] を加えない場合
    m[:,0] = p[:,0]
    m[:,1] = p[:,0] + p[:,1]  # 今回から開始して加えない、もしくは既に開始しているが、加えない
    m[:,2] = p[:,0] + p[:,1] + p[:,2]  # 今回、開始・終了して加えない、今回開始して加えず終了。

    # x[i] を加える場合
    m[x[i-1]:,1] += p[:-x[i-1],0] + p[:-x[i-1],1]
    m[x[i-1]:,2] += p[:-x[i-1],0] + p[:-x[i-1],1]

    p[:,0] = m[:,0] % 998244353
    p[:,1] = m[:,1] % 998244353
    p[:,2] = m[:,2] % 998244353
            
print(int(p[S,2]))
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
chk = []
for i in range(n):
  a,b =  map(int,input().split())
  if a <= m:
    chk.append((-b,a))

from heapq import heapify, heappop, heappush
from operator import itemgetter
chk = sorted(chk,key=itemgetter(1))
print(chk)
s = []
heapify(s)
ans = 0
cnt = chk[0][1]
for i in chk:
  a,b = i
  if b == cnt:
    heappush(s,i)
  if b > cnt:
    r,t = heappop(s)
    ans -= r
    heappush(s,i)
    cnt = b
    
r,t = heappop(s)
ans -= r    
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
chk = []
for i in range(n):
  a,b =  map(int,input().split())
  if a <= m:
    chk.append((a,b))

from heapq import heappop, heappush
from operator import itemgetter
chk = sorted(chk,key=itemgetter(0),reverse=True)

q = []
ans = 0
for i in range(1, m + 1):
    while chk and chk[-1][0] <= i:
        a,b = chk.pop()
        heappush(q,-b)
    if q:
        ans -= heappop(q)
print(ans)
def dfs(now_node,parent_node,dist):
  depth[now_node]=dist
  for next_node,w in graph[now_node]:
    if next_node==parent_node:
      continue
    dfs(next_node,now_node,dist+w)

n=int(input())
graph=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b,c=map(int,input().split())
  graph[a].append((b,c))
  graph[b].append((a,c))
  
q,k=map(int,input().split())
depth=[-1]*(n+1)
dfs(k,0,0)
for _ in range(q):
  x,y=map(int,input().split())
  print(depth[x]+depth[y])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def dfs(now_node,parent_node,dist):
  depth[now_node]=dist
  for next_node,w in graph[now_node]:
    if next_node==parent_node:
      continue
    dfs(next_node,now_node,dist+w)

n=int(input())
graph=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b,c=map(int,input().split())
  graph[a].append((b,c))
  graph[b].append((a,c))
  
q,k=map(int,input().split())
depth=[-1]*(n+1)
dfs(k,0,0)
for _ in range(q):
  x,y=map(int,input().split())
  print(depth[x]+depth[y])
n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-1]
r = y[n//2]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)
k = int(input())
s = str(input())

if int(len(s)) < k:
    print(s)
else:
    print(s[:k],"...")

### FIXED CODE ###

n = input()
sn = str(n)
snr = int(sn[::-1][:1])

if snr == 3:
    print("bon")
elif snr == 0 or snr ==1 or snr == 6 or snr == 8:
    print("pon")
else:
    print("hon")
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(1,n+1):
    b.append(a[i-1] - i)
b.sort
if n % 2 != 0:
    B = b[int((n-1)/2)]
    ans = 0
    for i in range(n):
        ans += abs(a[i]-i-1-B)
    print(ans)
else:
    big = b[int((n)/2)]
    smo = b[int(n-2/2)]
    smoB = int((big+smo)/2)
    bigB = smoB + 1
    big = smo = 0
    for i in range(n):
        big += abs(a[i]-i-1-bigB)
    for i in range(n):
        smo += abs(a[i]-i-1-smoB)
    print(min(big,smo))

### FIXED CODE ###

n = int(input())
def get_gcd(a, b): #最大公約数を求める関数
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return get_gcd(b, a % b)
def get_lcm(a, b, gcd): #みたまんまそういうやつです
    lcm = a * b // gcd
    return lcm
print(int((2 * n) / get_gcd(2,n)))