CodeEff/ECCO huggingface dataset:
# Original solution
N, M = list(map(int, input().split()))

import math


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

ans = 0

if N >= 2:
    ans += combinations_count(N, 2)

if M >= 2:
    ans += combinations_count(M, 2)

print(ans)

# Optimized solution
N, M = list(map(int, input().split()))

print((N*(N-1)//2 + M*(M-1)//2))
# Original solution
n,m=list(map(int,input().split()))
if (n>0) and (m>0):
  print((int(n*(n-1)/2+m*(m-1)/2)))
else:
  print((int(max(n,m)*(max(n,m)-1)/2)))

# Optimized solution
n,m=list(map(int,input().split()))
print((int(n*(n-1)/2+m*(m-1)/2)))
# Original solution
import math

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

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

if not 0 <= n <= 100 and 0 <= m <= 100 and 2 <= n + m:
    print('Unsupported...')  
if n >= 2:
    n_comb = combinations_count(n, 2)
else:
    n_comb = 0
if m >= 2:
    m_comb = combinations_count(m, 2)
else:
    m_comb = 0
    
print((n_comb + m_comb))

# Optimized solution
"""
A-The Number of Even Pairs
"""

n, m = list(map(int, input().split()))
print(((n * (n-1)) // 2 + (m * (m-1)) // 2))
# Original solution
from operator import mul
from functools import reduce
N, M=list(map(int, input().split()))


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, list(range(n, n - r, -1)), 1)
    denom = reduce(mul, list(range(1, r + 1)), 1)
    return numer // denom

if N>=2 and M>=2:
    print((combinations_count(N, 2)+combinations_count(M, 2)))
elif N>=2 or M>=2:
    print((combinations_count(N, 2)+combinations_count(M, 2)-1))
else:
    print((0))


# Optimized solution
N, M = list(map(int, input().split()))

print((N * (N - 1) // 2 + M * (M - 1) // 2))
# Original solution
import math
N,M =list(map(int,input().split()))
if N==1 :
    N1=0
elif N==0:
    N1=0
else:
    N1=(math.factorial(N))//(math.factorial(N-2)*2)
    
if M==1:    
    M1=0
    
elif M ==0:
    M1=0
else:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
    
print((str(N1+M1)))

# Optimized solution
a,b =list(map(int,input().split()))
sum=a*(a-1)//2+b*(b-1)//2
print(sum)
# Original solution
N, M = list(map(int,input().split()))

print((N*(N-1)//2+M*(M-1)//2))


# Optimized solution
N, M = list(map(int,input().split()))

print(((N*(N-1)+M*(M-1))//2))
# Original solution
N, M = list(map(int, input().split()))
a = []
b = []
if M == 0:
    for i in range(1,(2*N)+1):
        if i%2==0 and i>0:
            a.append(i)
elif N == 0:
    for i in range(1,(2*M)+1):
        if i%2==1:
            b.append(i)
else:
    for i in range(1,(2**N)+1):
        if i%2==0 and i>0:
            a.append(i)
        else:
            b.append(i)
c = a[:N] + b[:M]
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[i for i in l if i%2==0]
print((len(k)))

# Optimized solution
N, M = list(map(int, input().split()))
a = []
b = []
if M == 0:
    for i in range(1,(2*N)+1):
        if i%2==0 and i>0:
            a.append(i)
elif N == 0:
    for i in range(1,(2*M)+1):
        if i%2==1:
            b.append(i)
else:
    for i in range(1,501):
        if i%2==0 and i>0:
            a.append(i)
        else:
            b.append(i)
c = a[:N] + b[:M]
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[i for i in l if i%2==0]
print((len(k)))
# Original solution
from itertools import combinations

N, M = list(map(int, input().split()))
nlist = [] 
mlist = []

for i in range(N):
  nlist.append(i)
  
for j in range(M):
  mlist.append(j)

if N == 1 and M == 1:
  print((0))
  exit()
  
if N == 1:
  print((len(list(combinations(mlist,2)))))
  exit()
  
if M == 1:
  print((len(list(combinations(nlist,2)))))
  exit()
  
print((len(list(combinations(nlist,2))) + len(list(combinations(mlist,2)))))

# Optimized solution
N, M = list(map(int, input().split()))
print((N * (N-1) // 2 + M * (M-1) // 2))
# Original solution
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,m = list(map(int,input().split()))
    ans = n*(n-1)//2
    ans += m*(m-1)//2
    print(ans)
    return

if __name__=='__main__':
    main()


# Optimized solution
n,m = list(map(int,input().split()))
ans = n*(n-1)//2
ans += m*(m-1)//2
print(ans)
# Original solution
i = list(map(int, input().split()))
N = i[0]
M = i[1]

print((((N*(N-1))//2) + ((M*(M-1))//2)))

# Optimized solution
i = list(map(int, input().split()))
N = i[0]
M = i[1]

guusuu = (N * (N-1)) // 2
kisuu = (M * (M-1)) // 2

print((guusuu + kisuu))
# Original solution
import math
n,m = list(map(int, input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = 0
b = 0
if n >=2:
    a = combinations_count(n, 2)
if m >= 2:
    b = combinations_count(m, 2)
print((a+b))

# Optimized solution
n, m = list(map(int, input().split()))
a = n*(n-1)//2
b = m*(m-1)//2
print((a+b))
# Original solution
n, m = list(map(int, input().split()))

print((m*(m-1)//2 + n*(n-1)//2))


# Optimized solution
print((sum([int(i)*(int(i)-1)//2 for i in input().split()])))
# Original solution
def nCr(n, r):
    return (fact(n) / (fact(r)
                       * fact(n - r)))


# Returns factorial of n
def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print((0))
else:
    print((int(a+b)))

# Optimized solution
def nCr(n, r):
    return (fact(n) / (fact(r)* fact(n - r)))

def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print((0))
else:
    print((int(a+b)))
# Original solution
for e in iter(input,'0 0'):
 w,h=list(map(int,e.split()))
 M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
 for i in range(1,w):
  for j in range(1,h):
   a,b,c,d=[*M[i-1][j][:2],*M[i][j-1][2:]]
   M[i][j]=[d,a+b,b,c+d]
 print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5))


# Optimized solution
def s():
 for e in iter(input,'0 0'):
  w,h=list(map(int,e.split()))
  M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
  for i in range(1,w):
   for j in range(1,h):
    a,b=M[i-1][j][:2]
    c,d=M[i][j-1][2:]
    M[i][j]=[d,a+b,b,c+d]
  print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5))
if'__main__'==__name__:s()
# Original solution
while True:
    w, h = list(map(int, input().split()))
    if w | h == 0:
        break
    dp = [[[0] * (w + 1) for _ in range(h + 1)] for _ in range(4)]    
    #0:u -> u, 1: u -> r, 2: r -> u, 3: r -> r
    dp[0][1][0] = dp[3][0][1] = 1
    for y in range(h):
        for x in range(w):
            dp[0][y + 1][x] += dp[0][y][x] + dp[2][y][x]
            dp[1][y][x + 1] += dp[0][y][x]
            dp[2][y + 1][x] += dp[3][y][x]
            dp[3][y][x + 1] += dp[1][y][x] + dp[3][y][x]
    print(sum(dp[i][h-1][w-1] for i in range(4)) % 100000)

# Optimized solution
while True:
    w, h = list(map(int, input().split()))
    if w | h == 0:
        break
    dp = [[[0] * (w + 1) for _ in range(h + 1)] for _ in range(4)]    
    dp[0][1][0] = dp[3][0][1] = 1
    for y in range(h):
        for x in range(w):
            dp[0][y + 1][x] += dp[0][y][x] + dp[2][y][x]
            dp[1][y][x + 1] += dp[0][y][x]
            dp[2][y + 1][x] += dp[3][y][x]
            dp[3][y][x + 1] += dp[1][y][x] + dp[3][y][x]
    print(sum(dp[i][h-1][w-1] for i in range(4)) % 100000)
# Original solution
a=65280; b=61680; c=52428; d=43690; e=65535
base = [a, b, c, d, e, 0]
L = {el: 1 for el in base}
for i in range(6):
    R = dict(L)
    for p in R:
        if R[p] < 16:
            L[p ^ e] = min(L.get(p ^ e, 16), R[p] + 1)
        if R[p]+3 < 16:
            for q in R:
                if R[p] + R[q] + 3 <= 16:
                    L[p & q] = min(L.get(p & q, 16), R[p] + R[q] + 3)
                    L[p ^ q] = min(L.get(p ^ q, 16), R[p] + R[q] + 3)
print(*(L[e & eval(s)] for s in open(0).read().replace("-", "~").replace("*", "&").replace("1", "e").split()[:-1]),sep="\n")


# Optimized solution
a=65280; b=61680; c=52428; d=43690; e=65535
L = {el: 1 for el in [a, b, c, d, e, 0]}
for i in range(6):
    R = sorted(L.items(), key=lambda x: x[1])
    for p, l in R:
        if l < 16:
            L[p ^ e] = min(L.get(p ^ e, 16), l+1)
            if l+3 < 16:
                for q, r in R:
                    if l+r+3 <= 16:
                        L[p & q] = min(L.get(p & q, 16), l+r+3)
                        L[p ^ q] = min(L.get(p ^ q, 16), l+r+3)
                    else: break
        else: break
print(*(L[e & eval(s)] for s in open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]),sep='\n')
# Original solution
a=65280; b=61680; c=52428; d=43690; e=65535
L = {el: 1 for el in [a, b, c, d, e, 0]}
for i in range(6):
    R = sorted(L.items(), key=lambda x: x[1])
    for p, l in R:
        if l < 16:
            L[p ^ e] = min(L.get(p ^ e, 16), l+1)
            if l+3 < 16:
                for q, r in R:
                    if l+r+3 <= 16:
                        L[p & q] = min(L.get(p & q, 16), l+r+3)
                        L[p ^ q] = min(L.get(p ^ q, 16), l+r+3)
                    else: break
        else: break
print(*(L[e & eval(s)] for s in open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]),sep='\n')


# Optimized solution
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
while Q:
    l, p = heappop(Q)
    if L[p] < l: continue
    if l+1 < L.get(p ^ e, 17):
        L[p^e] = l+1
        if l+1 < 16: heappush(Q, (l+1, p^e))
    if l+3 < 16:
        for q, r in H:
            if l+r+3 <= 16:
                if l+r+3 < L.get(p & q, 17):
                    L[p & q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p & q))
                if l+r+3 < L.get(p ^ q, 17):
                    L[p ^ q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p ^ q))
            else: break
    if l < 7: H.append((p, l))
print(*(L[e & eval(s)] for s in open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]),sep='\n')
# Original solution
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
get = L.get
push = H.append
while Q:
    l, p = heappop(Q)
    if L[p] < l: continue
    if l+1 < get(p ^ e, 17):
        L[p ^ e] = l+1
        if l+1 < 16: heappush(Q, (l+1, p ^ e))
    if l+3 < 16:
        for q, r in H:
            if l+r+3 <= 16:
                if l+r+3 < get(p & q, 17):
                    L[p & q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p & q))
                if l+r+3 < get(p ^ q, 17):
                    L[p ^ q] = l+r+3
                    if l+r+3 < 16: heappush(Q, (l+r+3, p ^ q))
            else: break
    if l < 7: push((p, l))
print(*map(L.__getitem__, eval("e&%s"%",e&".join(open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]))),sep='\n')


# Optimized solution
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
Q = [(1, a), (1, b), (1, c), (1, d)]
L = {a: 1, b: 1, c: 1, d: 1, e: 1, e: 1, 0: 1}
H = []
get = L.get
push = H.append
while Q:
    l, p = heappop(Q)
    if L[p] < l: continue
    if l+1 < get(p ^ e, 17):
        L[p ^ e] = l+1
        l < 15 and heappush(Q, (l+1, p ^ e))
    if l < 13:
        li = 13-l; l3 = 3+l
        for q, r in H:
            if r <= li:
                k = p & q
                if r < get(k, 17)-l3:
                    L[k] = l3+r
                    r < li and heappush(Q, (l3+r, k))
                k = p ^ q
                if r < get(k, 17)-l3:
                    L[k] = l3+r
                    r < li and heappush(Q, (l3+r, k))
            else: break
    if l < 7: push((p, l))
print(*map(L.__getitem__, eval("e&"+",e&".join(open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]))),sep='\n')
# Original solution
import sys
input = sys.stdin.readline
from heapq import heappush, heappop

N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}

# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく

U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
    L = 1 << (i-1)
    sp.append([x if x < y else y for x,y in zip(sp[-1][:-L], sp[-1][L:])])

def RMQ(x,y):
    # x番目から偶数番目だけ見て[x,y]での最小値を返す
    d = y - x
    if d <= 1:
        return A[x]
    n = d.bit_length()
    return min(sp[n-1][x], sp[n-1][y+2-(1<<(n-1))])

def F(x,y):
    # 辞書式で最小の2つ組をとる
    # そのあと、今後調べないといけない区間の一覧を返す
    x1 = RMQ(x,y-1)
    i1 = a_to_i[x1]
    x2 = RMQ(i1+1,y)
    i2 = a_to_i[x2]
    task = ((x,y) for x,y in ((x,i1-1), (i1+1,i2-1), (i2+1,y)) if y > x)
    return x1,x2,task

q = [(None,None,((0,N-1),))]
answer = []
while q:
    x,y,task = heappop(q)
    answer.append(x)
    answer.append(y)
    for left,right in task:
        heappush(q,F(left,right))

print((' '.join(map(str,answer[2:]))))

# Optimized solution
import sys
input = sys.stdin.readline
from heapq import heappush, heappop

N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}

# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく

U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
    L = 1 << (i-1)
    sp.append([x if x < y else y for x,y in zip(sp[-1][:-L], sp[-1][L:])])

def RMQ(x,y):
    # x番目から偶数番目だけ見て[x,y]での最小値を返す
    d = y - x
    if d <= 1:
        return A[x]
    n = d.bit_length()
    arr = sp[n-1]
    ax = arr[x]
    ay = arr[y+2-(1<<(n-1))]
    return ax if ax < ay else ay

def F(x,y):
    # 辞書式で最小の2つ組をとる
    # そのあと、今後調べないといけない区間の一覧を返す
    x1 = RMQ(x,y-1)
    i1 = a_to_i[x1]
    x2 = RMQ(i1+1,y)
    i2 = a_to_i[x2]
    task = ((x,y) for x,y in ((x,i1-1), (i1+1,i2-1), (i2+1,y)) if y > x)
    return x1,x2,task

q = [(None,None,((0,N-1),))]
answer = []
while q:
    x,y,task = heappop(q)
    answer.append(x)
    answer.append(y)
    for left,right in task:
        heappush(q,F(left,right))

print((' '.join(map(str,answer[2:]))))
# Original solution
import sys
input = sys.stdin.readline

def digit_sum(n, b):
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res

def main():
    n = int(eval(input()))
    s = int(eval(input()))
    ans = -1

    if n < s:
        ans = -1

    elif n == s:
        ans = n + 1

    else:
        key = []
        start, first = n, 1

        for i in range(1, n):
            first = digit_sum(n, start)
            end = start - n // i // (i + 1)
            if start == end+1:
                judge = start
                break

            while end > 1:
                if digit_sum(n, end) == i * (start - end) + first:
                    end -= 1
                    continue
                break
            next_start = end
            value = digit_sum(n, start)
            end = value + (start - end - 1) * i
            key.append((start, value, end, i, first))
            judge = start
            start = next_start
            if start == 1:
                break

        for i in range(2, judge + 1):
            sub = digit_sum(n, i)
            if sub == s:
                ans = i
                break
        else:
            for index, start, end, i, first in reversed(key):
                if end < s or s < start:
                    continue
                if (s - start) % i:
                    continue
                ans = index - (s - first) // i
                break

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline

def digit_sum(n, b):
    if b == 1:
        return n
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res

def main():
    n = int(eval(input()))
    s = int(eval(input()))
    
    ans = -1
    if n == s:
        ans = n + 1
    else:
        for b in range(2, int(n**0.5) + 1):
            if digit_sum(n, b) == s:
                ans = b
                break
        
        else:
            for p in range(1, int(n**0.5)+1):
                b = (n - s) // p + 1
                if b >= 2 and digit_sum(n, b) == s:
                    if ans == -1:
                        ans = b
                    else:
                        ans = min(ans, b)
                
                if b >= 1 and digit_sum(n, b+1) == s:
                    if ans == -1:
                        ans = b+1
                    else:
                        ans = min(ans, b+1)

    print(ans)



if __name__ == "__main__":
    main()
# Original solution
def digit_sum(n, s):
    if s > n:
        return -1
    if s == n:
        return n + 1

    b = 2
    while b**2 < n:
        if f(b, n) == s:
            return b

        b += 1

    p = int(n * 0.5)
    while p >= 1:
        b = (n - s) // p + 1
        if b > 1 and f(b, n) == s:
            return b
        
        p -= 1

    return -1


def f(b, n):
    if n < b:
        return n

    return f(b, n // b) + (n % b)

def solve():
    n = int(eval(input()))
    s = int(eval(input()))
    result = digit_sum(n, s)
    print(result)

solve()


# Optimized solution
def digit_sum(n, s):
    if s > n:
        return -1
    if s == n:
        return n + 1

    b = 2
    while b**2 < n:
        if f(b, n) == s:
            return b

        b += 1

    p = int(n ** 0.5)
    while p >= 1:
        b = (n - s) // p + 1
        if b > 1 and f(b, n) == s:
            return b
        
        p -= 1

    return -1


def f(b, n):
    if n < b:
        return n

    return f(b, n // b) + (n % b)

def solve():
    n = int(eval(input()))
    s = int(eval(input()))
    result = digit_sum(n, s)
    print(result)

solve()
# Original solution
import math
def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)
N=int(eval(input()))
S=int(eval(input()))
if N==S:
    print((N+1))
else:
    for b in range(2,int(math.sqrt(N))+2):
        if f(b,N)==S:
            print(b)
            exit()
    ans=10**13
    for p in range(1,int(math.sqrt(N))+2):
        if (N-S)%p!=0:
            continue
        b=(N-S)//p+1
        if b<=1:
            continue
        if f(b,N)==S:
            ans=b
    if ans==10**13:
        print((-1))
    else:
        print(ans)



# Optimized solution
import math
n=int(eval(input()))
s=int(eval(input()))

def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)


def abc(N,S):
    if N==S:
        return N+1
    else:
        for b in range(2,int(math.sqrt(N))+2):
            if f(b,N)==S:
                return b
        tmp=-1
        for p in range(1,int(math.sqrt(N))+2):
            if (N-S)%p!=0:
                continue
            b=(N-S)//p+1
            if b<=1:
                continue
            if f(b,N)==S:
                tmp=b
        return tmp
ans=abc(n,s)
print(ans)
# Original solution
from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(100000)

def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
S = int(eval(input()))

RN = int(sqrt(N))
RN += ((RN+1)**2 == N)

def func(b, N):
    if b == 0:
        return -1
    tmp = 0
    while N:
        N, d = divmod(N, b)
        tmp += d
    return tmp

for b in range(2, RN+1):
    tmp = func(b, N)
    if tmp == S:
        print(b)
        break
else:
    for x in range(RN, 0, -1):
        num = (N-S+x)//x
        b = num//x
        if func(b, N) == S:
            print(b)
            break
    else:
        print((-1))

# Optimized solution
from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(10000000)

def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
S = int(eval(input()))

RN = int(sqrt(N)) + 1
RN += ((RN+1)**2 == N)

def func(b, N):
    if b <= 1:
        return -1
    tmp = 0
    while N:
        N, d = divmod(N, b)
        tmp += d
    return tmp

for b in range(2, RN+1):
    tmp = func(b, N)
    if tmp == S:
        print(b)
        break
else:
    for x in range(RN, 0, -1):
        b = (N-S+x)//x
        if func(b, N) == S:
            print(b)
            break
    else:
        if func(S+1, N) == S:
            print((S+1))
        else:
            print((-1))
# Original solution
from collections import  deque

x = int(eval(input()))

q = deque()
q.append((0, 0)) # (t, pos)
while q:
    t, pos = q.popleft()
#     print(t, pos)
    if pos == x:
        print(t)
        break
    else:
        q.append((t+1, pos))
        q.append((t+1, pos+t+1))
        if pos-t >= 1:
            q.append((t+1, pos-t-1))

# Optimized solution
x = int(eval(input()))
s = 0
for i in range(1, x+1):
    s += i
    if s >= x:
        print(i)
        break
# Original solution
Acsum=[]
acsum=0
for i in range(10**5):
  acsum+=i
  Acsum.append(acsum)
def binarysearch(x):
  ng=-1
  ok=10**5
  while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if Acsum[mid]>=x:
      ok=mid
    else:
      ng=mid
  return ok
n=int(eval(input()))
print((binarysearch(n)))

# Optimized solution
Acsum=[]
acsum=0
for i in range(5*10**4):
  acsum+=i
  Acsum.append(acsum)
def binarysearch(x):
  ng=-1
  ok=5*10**4
  while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if Acsum[mid]>=x:
      ok=mid
    else:
      ng=mid
  return ok
n=abs(int(eval(input())))
print((binarysearch(n)))
# Original solution
x=int(eval(input()))
n=1
while 1/2*(n**2+n)<x:
  n+=1
print(n)

# Optimized solution
x=int(eval(input()))
#n=1
#while 1/2*(n**2+n)<x:
#  n+=1
#print(n)

left=0
right=x
while right-left>1:
  mid=(left+right)//2
  if (mid**2+mid)/2==x:
    right=mid
    break
  if (mid**2+mid)/2<x:
    left=mid
  else:
    right=mid
print(right)
# Original solution
n = int(eval(input()))
x,count = 1,1
while x < n:
    x += count
    count += 1
print((count if x == n else count-1))

# Optimized solution
n = int(eval(input()))
x,count = 1,1
while x <= n:
    x += count
    count += 1
print((count-1))
# Original solution
X = int(eval(input()))
dp = {}
dp[0] = 0

for i in range(1,X+1):
    dp_ = dp.copy()
    for key in list(dp.keys()):
        if not key+i in list(dp.keys()): dp_[key+i] = i
        else: dp_[key+i] = min(dp_[key+i], i)

        #if not key-i in dp.keys(): dp_[key-i] = i
        #else: dp_[key-i] = min(dp_[key-i],i)
    dp = dp_
ans = dp[X]
print(ans)



# Optimized solution
import math
X = int(eval(input()))
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)
# Original solution
import sys
input = sys.stdin.readline


def main():
    X = int(eval(input()))
    x = 0
    for i in range(1, X+1):
        x += i
        if x >= X:
            print(i)
            return


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import math
input = sys.stdin.readline


def main():
    X = int(eval(input()))
    print((math.ceil((-1 + math.sqrt(1+8*X))/2)))


if __name__ == '__main__':
    main()
# Original solution
x = int(eval(input()))
min_dt = 1001001001
min_i = 0
for i in range(1, x+1):
    dt = abs(x - (i+1)*i//2)
    if dt<min_dt:
        min_dt = dt
        min_i = i
    if min_dt == 0:
        print(i)
        break
else:
    print((min_i+min_dt))


# Optimized solution
x = int(eval(input()))
i = 1
while True:
    if (i+1)*i//2 >= x:
        print(i)
        break
    i += 1
# Original solution
import copy
X=int(eval(input()))
ava={0}
ava2={0}

for i in range(1,10**9):
  ava=copy.deepcopy(ava2)
  #print(i,ava,ava2)
  if X not in ava:
    for item in ava: 
      ava2.add(item+i)
      ava2.add(item-i)
  else:
    print((i-1))
    break

# Optimized solution
X=int(eval(input()))

for i in range(10**9):
  if (i*(i+1))//2>=X:
    print(i)
    break