CodeEff/ECCO huggingface dataset:
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を返す関数
    def f(sub):
        if len(sub) > K: 
            return 
        #sのsubstringか確認 
        if sub in s:
            cnd.append(sub)
        #lから選んでsubに一文字追加する
        for i in l:
            nx = sub+i
            f(nx)
    f('')
    print((cnd[K]))
if __name__ == '__main__':
    main()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print((cnd[K-1]))
if __name__ == '__main__':
    main()
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print((cnd[K-1]))
if __name__ == '__main__':
    main()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    return f(nx)
    for i in l:
        f(i) 
    print((cnd[K-1]))
if __name__ == '__main__':
    main()
# Original solution
s = list(input().rstrip())
k = int(eval(input()))
ans_list = []

for i in range(len(s)):
    for j in range(i,len(s)+1):
        a = s[i:j]
        a = "".join(a)
        ans_list.append(a)
        
ans_list = list(set(ans_list))
ans_list.sort()

print((ans_list[k]))


# Optimized solution
s = list(input().rstrip())
k = int(eval(input()))
ans_list = []

for i in range(len(s)):
    for j in range(i,len(s)+1):
        a = s[i:j]
        if len(a) > k:
            break
        a = "".join(a)
        ans_list.append(a)
        
ans_list = list(set(ans_list))
ans_list.sort()

print((ans_list[k]))
# Original solution
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
N = len(S)
K = INT()

min_s = min(S)
B = [s for s in S]
B.sort()
# print(B)

cursol = 0
min_s = 'ATCODER'
cand = []
while len(cand) < K:
	# print(cursol)
	if min_s == B[cursol]:
		cursol += 1
		continue
	else:
		min_s = B[cursol]
	for i,s in enumerate(S):
		if s == min_s:
			for j in range(i+1, N+1):
				if not cand.count(S[i:j]): cand.append(S[i:j])
	cursol += 1

cand.sort()
# print(cand)

s = min(S)
cnt = 0
for c in cand:
	cnt += 1
	if cnt == K:
		print(c)
		break

# Optimized solution
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
N = len(S)
K = INT()

min_s = min(S)
B = [s for s in S]
B.sort()
# print(B)

cursol = 0
min_s = 'ATCODER'
cand = []
while len(cand) < K:
	# print(cursol)
	if min_s == B[cursol]:
		cursol += 1
		continue
	else:
		min_s = B[cursol]
	for i,s in enumerate(S):
		if s == min_s:
			for j in range(i+1, i+1+K):
				if not cand.count(S[i:j]): cand.append(S[i:j])
	cursol += 1

cand.sort()
# print(cand)

s = min(S)
cnt = 0
for c in cand:
	cnt += 1
	if cnt == K:
		print(c)
		break
# Original solution
s= str(input().strip())
K= int(input().strip())
parts = []
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        flg = 0
        if j-i > K:
            break
        for k in parts:
            if s[i:j] == k:
                flg = 1
        if flg == 0:
            parts.append(s[i:j])
        
v = sorted(parts)
print((v[K-1]))

# Optimized solution
s= str(input().strip())
K= int(input().strip())
parts = []
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        flg = 0
        if j-i > K:
            break
        parts.append(s[i:j])
v = sorted(parts)
vv = [v[0]]
tmp = v[0]
for k in range(1,len(v)):
    if v[k]!=tmp:
        vv.append(v[k])
        tmp = v[k]
    if len(vv)==K:
        break
        
print((vv[K-1]))
# Original solution
def 解():
    sS = input().rstrip()
    dsS = set()
    for s in sS:
        if s not in dsS:
            dsS.add(s)
    iK = int(eval(input()))
    iL = len(sS)
    iC = 0
    for s in sorted(list(dsS)):
        sDic = set()
        indexes = []
        for i in range(iL):
            if sS[i] == s :
                if i != 0 and i != iL-1:
                    if sS[i-1] != s or sS[i+1] != s:
                        indexes.append(i)
                else:
                    indexes.append(i)
        if iK < iL :
            for i in indexes:
                for j in range(1,iK+1):
                    if i+j <= iL:
                        sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            if iK <= len(aS) :
                print((aS[iK - iC -1]))
                exit()
            else:
                iC += len(aS)
        else:
            for i in indexes:
                for j in range(1,iL -i+1):
                    sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            iLS = len(aS)
            if iC + iLS < iK:
                iC += iLS
                continue
            else:
                print((aS[iK -iC-1]))
                exit()
解()


# Optimized solution
def 解():
    sS = input().rstrip()
#   dsS = set()
#   for s in sS:
#       if s not in dsS:
#           dsS.add(s)
    iK = int(eval(input()))
    iL = len(sS)
    iC = 0
#   for s in sorted(list(dsS)):
    for s in sorted(set(sS)):
        d = set()
        indexes = []
        for i in range(iL):
            if sS[i] == s :
                if i != 0 and i != iL-1:
                    if sS[i-1] != s or sS[i+1] != s:
                        indexes.append(i)
                else:
                    indexes.append(i)
        if iK < iL :
            for i in indexes:
                for j in range(1,iK+1):
                    if i+j <= iL:
                        d.add(sS[i:i+j])
            aS = sorted(d)
            if iK <= len(aS) :
                print((aS[iK - iC -1]))
                exit()
            else:
                iC += len(aS)
        else:
            for i in indexes:
                for j in range(1,iL -i+1):
                    d.add(sS[i:i+j])
            aS = sorted(d)
            iLS = len(aS)
            if iC + iLS < iK:
                iC += iLS
                continue
            else:
                print((aS[iK -iC-1]))
                exit()
解()
# Original solution
s = input().strip()
k = int(eval(input()))
ss = []
for i in range(1, len(s) + 1):
    for j in range(len(s) + 1 - i):
        ss.append(s[j:j + i])
ss = list(set(ss))
ss.sort()
print((ss[k - 1]))

# Optimized solution
s = input().strip()
k = int(eval(input()))
ss = []
n = len(s)
for i in range(n):
    for j in range(1, 6):
        if i + j <= n:
            ss.append(s[i:i + j])
ss = list(set(ss))
ss.sort()
print((ss[k - 1]))
# Original solution
s = input().strip()
k = int(eval(input()))
ss = []
n = len(s)
for i in range(n):
    for j in range(1, 6):
        if i + j <= n:
            ss.append(s[i:i + j])
ss = list(set(ss))
ss.sort()
print((ss[k - 1]))

# Optimized solution
import sys

input = sys.stdin.readline

ri = lambda: int(eval(input()))
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

s = rs()
k = ri()
ss = set()
n = len(s)
for i in range(n):
    for j in range(1, 6):
        ss.add(s[i:i + j])
print((sorted(ss)[k - 1]))
# Original solution
s = input().strip()
K = int(eval(input()))

S = set()
for i in range(len(s)):
    for w in range(1, K+1):
        S.add(s[i:i+w])

print((sorted(S)[K-1]))



# Optimized solution
s = input().strip()
K = int(eval(input()))

substr = set()

for i in range(len(s)):
    for j in range(1, K+1):
        substr.add(s[i:i+j])

print((sorted(substr)[K-1]))
# Original solution
s = input()
K = int(input())
subs = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    subs.add(s[i:j+1])
subs = list(subs)
subs.sort()
print(subs[K-1])


# Optimized solution
s = input()
K = int(input())
subs = set()
for i in range(len(s)):
  for j in range(i, i+K+1):
    subs.add(s[i:j+1])
subs = list(subs)
subs.sort()
print(subs[K-1])
# Original solution
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print((li[n-1]))

# Optimized solution
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,6):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print((li[n-1]))
# Original solution
n=1000000
p=[1]*(n+1)
pr=[]
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n,i):
            p[j]=0
for i in range(2,n):
    if p[i]:
        pr.append(int(i))
while 1:
    l=int(eval(input()))
    if l==0:break
    ans=-l
    while l:
        l-=1
        a,m=list(map(int,input().split()))
        j=0
        while j<len(pr) and pr[j]<=a+m:
            if(pr[j]>=a-m):ans+=1
            j+=1
    print(ans)

# Optimized solution
import bisect
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(eval(input()))
    ans=-n
    if n==0:break
    while n:
        n-=1
        a,m=list(map(int,input().split()))
        ans+=bisect.bisect_left(p,a+m+1)-bisect.bisect_left(p,a-m)
    print(ans)
# Original solution
import math
N=1000000
prime=[1]*(N+1)
prime[0]=0
prime[1]=0
for i in range(2,int(math.sqrt(N))):
    if prime[i]==1:
        j=i
        while i*j<=N:
            prime[i*j]=0
            j+=1
prime=[i for i in range(N+1) if prime[i]==1]

while True:
    n=eval(input())
    if n==0:break
    cnt=0
    for i in range(n):
        p,m=list(map(int,input().split()))
        for j in range(len(prime)):
            if p-m<=prime[j]<=p+m:
                cnt+=1
            if p+m<=prime[j]:
                break
    print(cnt-n)

# Optimized solution
import math
import bisect
N=1000000
prime=[1]*(N+1)
prime[0]=0
prime[1]=0
for i in range(2,int(math.sqrt(N))):
    if prime[i]==1:
        j=i
        while i*j<=N:
            prime[i*j]=0
            j+=1
prime=[i for i in range(N+1) if prime[i]==1]

while True:
    n=eval(input())
    if n==0:break
    cnt=0
    for i in range(n):
        p,m=list(map(int,input().split()))
        l=bisect.bisect_left(prime,p-m)
        u=bisect.bisect_left(prime,p+m+1)
        cnt+=u-l
    print(cnt-n)
# Original solution
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def solve(n, a, b, c, d, MOD):
    facts, invs = prepare(n, MOD)
    dp = [0] * (n + 1)
    dp[n] = 1
    for i in range(a, b + 1):
        iv = invs[i]
        for j in range(i * c, n + 1):
            base = dp[j] * facts[j] % MOD
            for k in range(c, d + 1):
                ik = i * k
                if ik > j:
                    break
                pat = base * invs[j - ik] % MOD
                pat = pat * pow(iv, k, MOD) * invs[k]
                dp[j - ik] = (dp[j - ik] + pat) % MOD
    return dp[0]


n, a, b, c, d = list(map(int, input().split()))
MOD = 10 ** 9 + 7
print((solve(n, a, b, c, d, MOD)))


# Optimized solution
def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def solve(n, a, b, c, d, MOD):
    facts, invs = prepare(n, MOD)

    pre = {}
    for i in range(a, b + 1):
        iv = invs[i]
        for k in range(c, d + 1):
            if i * k > n:
                break
            pre[i, k] = pow(iv, k, MOD) * invs[k] % MOD

    dp = [0] * (n + 1)
    dp[n] = 1
    for i in range(a, b + 1):
        iv = invs[i]
        for j in range(i * c, n + 1):
            base = dp[j]
            for k in range(c, d + 1):
                ik = i * k
                if ik > j:
                    break
                dp[j - ik] = (dp[j - ik] + base * pre[i, k]) % MOD
    return dp[0] * facts[n] % MOD


n, a, b, c, d = list(map(int, input().split()))
MOD = 10 ** 9 + 7
print((solve(n, a, b, c, d, MOD)))
# Original solution
def main():
    mod = 10**9+7
    inv_n = [0]*1001
    nCr = [[1]*(i+1) for i in range(1001)]
    for i in range(1001):
        inv_n[i] = pow(i, mod-2, mod)
    for i in range(2, 1001):
        for j in range(1, i):
            nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j]) % mod
    n, a, b, c, d = list(map(int, input().split()))
    f = [[[0]*(N//A-c+1) for A in range(a, b+1)] for N in range(1, n+1)]
    for N in range(1, n+1):
        for A in range(a, min(N//c, b)+1):
            temp = 1
            for C in range(1, c):
                temp = temp*nCr[N-(C-1)*A][A]*inv_n[C] % mod
            for C in range(c, min(d, N//A)+1):
                temp = temp*nCr[N-(C-1)*A][A]*inv_n[C] % mod
                f[N-1][A-a][C-c] = temp

    dp = [0]*(n+1)
    dp[0] = 1

    for A in range(b, a-1, -1):
        dp2 = [i for i in dp]
        for i in range(n-c*A+1):
            e = dp[i]
            if e:
                for C in range(c, min(d, (n-i)//A)+1):
                    dp2[i+C*A] = (dp2[i+C*A]+f[n-i-1][A-a][C-c]*e) % mod
        dp = dp2
    print((dp[-1]))


main()

# Optimized solution
def main():
    mod = 10**9+7
    inv_n = [0]*1001
    nCr = [[1]*(i+1) for i in range(1001)]
    for i in range(1001):
        inv_n[i] = pow(i, mod-2, mod)
    for i in range(2, 1001):
        for j in range(1, i):
            nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j]) % mod
    n, a, b, c, d = list(map(int, input().split()))
    dp = [0]*(n+1)
    dp[0] = 1

    for A in range(b, a-1, -1):
        dp2 = [i for i in dp]
        for N in range(n-c*A, -1, -1):
            e = dp[N]
            if e:
                temp = 1
                for C in range(1, c):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                for C in range(c, min(d, (n-N)//A)+1):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                    dp2[N+C*A] = (dp2[N+C*A]+temp*e) % mod
        dp = dp2
    print((dp[-1]))


main()
# Original solution
def main():
    a, b = list(map(int, input().split()))

    l = []
    for i in range(2, 1001):
        h = 0
        for j in range(1, i):
            h = h + j
        l.append(h)

    for i in range(len(l) - 1):
        if l[i] - a == l[i + 1] - b:
            print((l[i] - a))
            break


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    a, b = list(map(int, input().split()))

    l = []
    for i in range(2, 1001):
        h = 0
        for j in range(1, i):
            h = h + j
        l.append(h)

    for i in range(len(l) - 1):
        if l[i] - a == l[i + 1] - b:
            print((l[i] - a))
            break


def main2():
    a, b = list(map(int, input().split()))
    x = b - a

    s = 0
    for i in range(1, x):
        s = s + i

    print((s - a))


if __name__ == '__main__':
    main2()
# Original solution
a, b = list(map(int, input().split()))

l = 0
for i in range(1, 999):
    l += i
    r = l + i + 1
    if r - l == b - a:
        print((l - a))


# Optimized solution
a, b = list(map(int, input().split()))
l = 0
for i in range(1, 999):
    l += i
    if i + 1 == b - a:
        print((l - a))
        break
# Original solution
a,b=list(map(int,input().split()))
lis=[1]
for i in range(2,1000):
    lis.append(lis[-1]+i)
i=0
while True:
    if a in lis and lis[lis.index(a)+1]==b:
        print(i)
        break
    a+=1
    b+=1
    i+=1

# Optimized solution
a,b=list(map(int,input().split()))
print(((b-a)*(b-a+1)//2-b))
# Original solution
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in list(inspect.currentframe().f_back.f_locals.items())}
    print((', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args)))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    diff = b - a

    cur_tower = 1
    ts = []
    for add in range(2, 1000):
        next_tower = cur_tower + add
        ts.append((cur_tower, next_tower))

        cur_tower = next_tower

    for snow in range(1, 499951):
        if (a + snow, b + snow) in ts:
            print(snow)
            break

main()


# Optimized solution
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in list(inspect.currentframe().f_back.f_locals.items())}
    print((', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args)))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]
    diff = b - a

    tower = 0
    ts = []
    for add in range(1, 1000):
        tower += add
        ts.append(tower)

    print((ts[diff-2] - a))

main()
# Original solution
a,b = list(map(int,input().split()))
tower_list = [[1,3]]
for i in range(3,999):
    tower_list.append([tower_list[i-3][1],tower_list[i-3][1]+i])
i=0
while(True):
    ab_list = [a+i,b+i]
    if(ab_list in tower_list):
        print(i)
        exit()
    i += 1


# Optimized solution
a,b = list(map(int,input().split()))
print((int((b-a)*(b-a+1)/2-b)))
# Original solution
a, b = list(map(int, input().split()))
y = []
p = 0

for i in range(1, 1000):
    p += i
    y.append(p)

for x in range(1, 499501):
    for i in range(1, 999):
        if y[i] == b + x and y[i - 1] == a + x:
            print(x)
            break
    else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
        continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
    break  # 外側のforを抜ける"

# Optimized solution
a, b = list(map(int, input().split()))
y = []
p = 0

for i in range(1, 1000):
    p += i
    y.append(p)
    
c = b - a
for i in range(1, 999):
    if y[i] - y[i - 1] == c:
        print((y[i] - b))
        break
# Original solution
a,b = list(map(int,input().split()))
print((((a-b)**2 -a-b)//2))

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

# Optimized solution
a,b = list(map(int ,input().split()))
ans = 0
for i in range(1,b-a):
    ans += i
print((ans-a))
# Original solution
a, b = (int(i) for i in input().split())
print((sum(range(b-a))-a))

# Optimized solution
a, b = (int(i) for i in input().split())
c = b - a
d = c*(c+1)//2
print((d - b))
# Original solution
a,b=list(map(int,input().split()));print((sum(range(b-a))-a))

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

# Optimized solution
a,b = list(map(int,input().split()))
n = b-a
tmp = n*(n+1)//2
ans = tmp - b
print(ans)
# Original solution
a, b = [int(x) for x in input().split()]

n = b-a-1
An = n*(n+1)//2

print((An-a))

# Optimized solution
a, b = [int(x) for x in input().split()]

s = ss = 0
for i in range(1000):
    s += i
    if s-ss == b-a:
        break
    ss = s
print((s-b))
# Original solution
a, b = list(map(int, input().split()))
dif = b - a
sum = int(dif / 2 * (1 + dif))
print((sum - b))

# Optimized solution
a, b = list(map(int, input().split()))
x = int((b - a) * (b - a + 1) / 2 - b)
print(x)
# Original solution
a, b = list(map(int, input().split()))
for n in range(1, 1000):
    h1 = n*(n+1)//2
    h2 = (n+1)*(n+2)//2
    for x in range(1, h2+1):
        if h1 - x == a and h2 - x == b:
            print(x)
            exit(0)

# Optimized solution
a, b = list(map(int, input().split()))
for n in range(1, 1000):
    h1 = n*(n+1)//2
    h2 = (n+1)*(n+2)//2
    if h1 - a == h2 - b:
        print((h1-a))
        break
# Original solution
a,b = (int(i) for i in input().split())
tower = [sum(range(1, i+1)) for i in range(1,1000)]
print((tower[b-a-1]-b))

# Optimized solution
a,b = (int(i) for i in input().split())
print(([sum(range(1, i+1)) for i in range(1,1000)][b-a-1]-b))
# Original solution
a,b=[int(x) for x in input().split()]
temp=b-a
print((temp*(temp+1)//2-b))

# Optimized solution
a,b=list(map(int,input().split()))
n=abs(b-a)
val=int(n*(n+1)/2)
print((val-b))
# Original solution
icase=0
if icase==0:
    import sys
    a,b=list(map(int,input().split()))
    for i in range(1,999):
        isum=(i*(i+1))//2-a
        for j in range(i,1000):
            jsum=(j*(j+1))//2-b
            if jsum==isum and 1<=jsum and j==i+1:
                print(jsum)
                sys.exit()


# Optimized solution
icase=0
if icase==0:
    a,b=list(map(int,input().split()))
    n=b-a-1
    print((n*(n+1)//2-a))
# Original solution
# -*- coding: utf-8 -*-

a, b = list(map(int, input().split()))

# 本来の各柱の高さリスト
columns = [(i ** 2 + i) // 2 for i in range(1, 1000)]

for i in range(998):
    ab = columns[i+1] - columns[i]
    # 本来の柱と今見えている柱で差が一致する所を探す
    if ab == b - a:
        print((columns[i] - a))
        exit()

# Optimized solution
# -*- coding: utf-8 -*-

a, b = list(map(int, input().split()))

# 計算で全部出せるとfor文回さなくて済む
ans = (b - a - 1) * (b - a) // 2 - a
print(ans)
# Original solution
a,b = list(map(int,input().split()))
c = b-a
for i in range(1,999):
    x= (i+1)*i//2
    y= (i+2)*(i+1)//2
    if y-x == c:
        print((x-a))
        break

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