In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.
It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not covered with snow, and the results are a meters for the west tower, and b meters for the east tower.
Assuming that the depth of snow cover and the altitude are the same everywhere in the village, find the amount of the snow cover.
Assume also that the depth of the snow cover is always at least 1 meter.

-----Constraints-----
 - 1 \leq a < b < 499500(=1+2+3+...+999)
 - All values in input are integers.
 - There is no input that contradicts the assumption.

-----Input-----
Input is given from Standard Input in the following format:
a b

-----Output-----
If the depth of the snow cover is x meters, print x as an integer.

-----Sample Input-----
8 13

-----Sample Output-----
2

The heights of the two towers are 10 meters and 15 meters, respectively.
Thus, we can see that the depth of the snow cover is 2 meters.

Difficulty: introductory

Starter code:

Solutions:
a,b = map(int, input().split())
print((((b-a)**2)-(a+b))//2)

a,b=map(int,input().split())
c=b-a
d=0
for i in range(1,c):
  d+=i

print(d-a)

def main():
    a, b = list(map(int, input().split()))
    print((sum(list(range(1, b - a))) - a))


def __starting_point():
    main()

__starting_point()

a,b = map(int,input().split())
c = b-a
cnt =0
for i in range(c):
    cnt += (i+1)
print(cnt-b)

a,b = map(int,input().split())
n = b-a
sum = 0
for i in range(1,n+1):
    sum += i
print(sum-b)

a, b = map(int, input().split())
sum = 0
for i in range(b-a):
  sum += i+1
print(sum-b)

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

print(sum(range(1, b - a)) - a)

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

diff = b - a

x = 1
y = 3
i = 3

while True:
  if y - x == diff:
    break
  
  x = y
  y = y + i
  i = i + 1

print(y - b)

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

for n in range(0, 1000):
    west = ((n*(n-1))/2)-a
    east = ((n*(n+1))/2)-b

    if west == east:
        print((int(east)))
        return


a, b  = map(int,input().split())
c = b - a
ans = 0
for i in range(c):
  ans += i
  
print(ans - a)

a, b = map(int, input().split())
d = b - a 

print(sum(i for i in range(1, d)) - a)

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

ans = (b-a)*(b-a+1)//2 - b

print(ans)

def Gauss_sum(n):
  return n*(n+1)//2
a,b=map(int,input().split())
for i in range(999):
  if Gauss_sum(i+1)-a == Gauss_sum(i+2)-b:
    print(Gauss_sum(i+1)-a)
    break

a,b = list(map(int,input().split()))
x = b - a 
tower = 0
for i in range(1,x+1):
    tower += i 
print((tower - b))


a,b=map(int,input().split())
c=b-a
ans=0

for i in range(1,c+1):
  ans+=i
  
print(ans-b)

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

a, b = list(map(int, input().split()))
d = b-a
print((d*(d+1)//2 - b))


a, b = map(int, input().split())
print(((b - a) * (b - a + 1) // 2) - b)

a,b = map(int, input().split())
b2 = sum(range(1,b-a+1))
print(b2-b)

a,b=map(int,input().split())
print((1+(b-a))*(b-a)//2-b)

import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return list(map(int, stdin.readline().split()))
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b = nm()
    print((sum(range(1, b - a)) - a))


def __starting_point():
    main()

__starting_point()

a, b = map(int, input().split())
m = b - a # [m-1] と [m]
t = 0
for i in range(m):
  t += i
print(t - a)

a,b = map(int,input().split())
c = 0
for i in range(1,b- a + 1):
    c += i
print(c - b)

a, b =map(int,input().split())
cnt=[i for i in range(b-a)]
print(sum(cnt)-a)

def main():
    a, b = list(map(int, input().split()))
    distance = b - a
    high_a = sum(list(range(1, distance)))
    print((high_a - a))


def __starting_point():
    main()

__starting_point()

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

n = b - a
he = n * (n + 1) / 2
x = he - b
print(int(x))

def answer(a: int, b: int) -> int:
    return sum(range(1, b - a + 1)) - b


def main():
    a, b = list(map(int, input().split()))
    print((answer(a, b)))


def __starting_point():
    main()

__starting_point()

a,b=map(int,input().split())
c=b-a

d=0

for i in range(c):
  d+=i
  
print(d-a)

N,M=map(int,input().split())
K=M-N
from functools import reduce
from operator import add
NL=reduce(add,range(1,K))
ans=NL-N
print(ans)

def fallen_snow(a, b):
    return (b - a) * (b - a + 1) // 2 - b


def main():
    a, b = map(int, input().split())
    print(fallen_snow(a, b))


def __starting_point():
    main()
__starting_point()

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

c = b-a
res = sum(i for i in range(c))
print(res-a)

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b = Input()
    towers = [1] * 999
    for i in range(1, 999):
        towers[i] = towers[i-1] + i + 1
    n = b - a
    ans = 0
    for i in range(998):
        if towers[i+1] - towers[i] == n:
            ans = towers[i] - a
    print(ans)


main()

a, b = map(int, input().split())
ri = b - a
print(ri * (ri + 1) // 2 - b)

a,b=list(map(int,input().split()))
height=0
for i in range(b-a):
  height+=i+1
print(height-b)

a,b = map(int, input().split())
n = b - a
print(n*(n+1)//2 - b)

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

h = 0
p = 1
li = []

for i in range(999):
    h +=p
    p +=1
    li.append(h)

for i in range(len(li)):
    for k in range(len(li)):
        if (a[0]-li[i])==(a[1]-li[k]) and k == i+1:
            print((abs(a[0]-li[i])))
            



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

print((b-a)*(b-a+1)//2-b)

a, b = map(int, input().split())
print((b - a) * (b - a - 1) // 2 - a)

a, b = map(int, input().split())
x = b-a
cnt = 0
for i in range(x+1):
    cnt += i
print(cnt - b)

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

n = b - a
m = n * (n + 1) // 2
print(int(m - b))

x, y = map(int, input().split())
 
tower = []
for i in range(1, 1000):
    tower.append(i * (i + 1) / 2) 
    
for n in range(0,998):
    if tower[n] - x == tower[n + 1] - y:
        print(int(tower[n] - x)) 

n,m = [int(x) for x in input().split()]

def su(p):
  c = 0
  for i in range(p+1):
    c += i
  return c

l = m - n

print(su(l-1) - n)

a,b = map(int,input().split())
ans = 0
for i in range(b-a+1):
  ans += i
print(ans - b)

lst = input().split()
a = int(lst[0])
b = int(lst[1])

d = b - a

print(sum(range(1, d+1)) - b)

a,b = 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

a,b = map(int,input().split())
print(sum(range(b-a))-a)

def main():
    a, b = list(map(int, input().split()))
    diff = b - a
    high_a = sum(list(range(1, diff)))
    print((high_a - a))


def __starting_point():
    main()

__starting_point()

m,n = list(map(int,input().split()))
#lis = list(map(int,input().split()))
h = sum([i for i in range(1,n-m+1)])
print((h-n))


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

n = b-a-1

x = (n**2 + n - a*2) // 2

print(x)

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

ab = list([int(x) for x in input().split(" ")])
a = ab[0]
b = ab[1]

n = b - a - 1

x = n * (n + 1) // 2 - a

print(x)


a, b = list(map(int, input().split()))
print((sum(range(b-a))-a))


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

N = b - a
print(((N * (N + 1) // 2) - b))


a,b = map(int,input().split())
n = b - a
real_b = n * (n + 1) // 2

print(real_b - b)

#!/usr/bin/env python3

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

tmp = 1
for i in range(2, 1000):
    if i == (b-a):
        # print(tmp, tmp+i)
        print((tmp-a))
    tmp += i


a, b = map(int, input().split())
c = b - a
n = 0
for i in range(1, 999+1):
    n += i
    if c == i:
        ans = n - b

print(ans)

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

ans = 0
for i in range(b-a):
	ans += i+1

print(ans-b)

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

d = b - a
d -= 1
x = 0
for i in range(d):
    x += i + 1
print(x - a)

a,b=map(int,input().split())
k=b-a-1
print(k*(k+1)//2-a)

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




a,b=map(int,input().split())
A=[]
c=1
for i in range(2,1001):
    A.append(c)
    c+=i
d=b-a
print(A[d-2]-a)

a,b=map(int,input().split())
d=b-a
print(d*(d+1)//2-b)

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

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

n=b-a

ans=n*(n+1)//2-b

print(ans)

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

d = b - a

print(d * (d+1) // 2 - b)

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

numbers = []
for i in range(1, 1000):
    numbers.append(i)

steel_towers = []
for i in range(999):
    steel_towers.append(sum(numbers[:i + 1]))

print((steel_towers[b - a - 1] - b))


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


a, b = [int(i) for i in input().split()]
b_no_snow = sum(range(1, b - a + 1))
print(b_no_snow - b)

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

bt = sum([i for i in range(1,m-n+1)])
print(bt-m)

a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)

a,b=map(int,input().split())
k = b-a
al = (1+k)*k
al //= 2
print(al-b)

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

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

ans = s - a
print(ans)

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

diff = b - a
sum = 0
for i in range(1, diff, 1):
  sum += i

ans = sum - a
print(ans)

a, b = map(int, input().split())
c = b - a
tmp = 0
for i in range(1, c+1):
    tmp += i
print(tmp - b)

a,b=map(int,input().split())
N=b-a
c=0

for i in range(N+1):
  c=c+i

print(c-b)

import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
a, b = [int(num) for num in lines.pop(0).split(" ")]
dif = b - a
height = dif * (dif - 1)  // 2
print((height - a))


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


a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)

a,b = map (int, input ().split ())
x = 0
for i in range (b-a):
  x += i
print (x-a)

a,b = map(int,input().split())
c = b-a
d = (c)*(c-1)//2

print(d-a)

a,b=list(map(int,input().split()))
x=b-a
print((x*(x+1)//2-b))


a, b = list(map(int, input().split()))
x = 0
for i in range(1000):
    x += i
    y = x - i
    if a - y == b - x:
        print((y - a))




a, b = map(int, input().split())
diff = b - a
towers = [0] * diff
for i in range(1, diff):
    towers[i] = towers[i - 1] + i
print(towers[-1] - a)

a,b = list(map(int,input().split()))
s = b-a
tall = 0
for i in range(1,s):
    tall +=i

print((tall - a))


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

tower_height = 0
tower_height_list = []
for i in range(1,999+1):
    tower_height += i
    tower_height_list.append(tower_height)
    i += 1

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

a,b = map(int,input().split())
dif = b-a 
temp = 0
for i in range(dif):
    temp += i 
ans = temp - a
print(ans)

a,b=map(int,input().split())
total=0
for i in range(1,b-a+1):
  total+=i
print(total-b)

a, b = map(int, input().split())
l = (b - a + 1) * (b - a) // 2
print(l - b)

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

difference = b - a
answer = 0
for x in range(difference):
    answer += x
    
print(answer - a)

from itertools import accumulate
import sys
a,b=map(int,input().split())
n = 500000
l=[]
for i in range(n):
    l.append(i)
    tmp = sum(l)
    if abs(abs(a+tmp) - abs(b+tmp)) == i:
        print(tmp -b)
        return

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

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


a,b = map(int,input().split())
c = abs(b - a)
x = 0
for i in range(1,c+1):
  x += i
print(x-b)

a,b=map(int,input().split())
ans=0
for num in range(1,b-a):
    ans+=num
print(ans-a)

a, b = map(int, input().split())
c = 0
for i in range(1, b - a + 1):
  c += i
  
print(c - b)

a,b = map(int, input().split())
height = (b-a)*(b-a+1)//2
ans  = height -b
print(ans)

a,b=input().split()
a=int(a)
b=int(b)
print(int((b-a)*(b-a-1)/2-a))

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

c = b - a

height_a = 0
for i in range(1, c):
    height_a += i
ans = height_a - a

print(ans)

A, B = map(int, input().split())
d = B-A
s = sum([x for x in range(1, d)])
print(s-A)

def n_sum(n):
    myList = [int(i) for i in range(1,n+1)]
    return sum(myList)
    
a,b = map(int,input().split())
print(n_sum(b-a)-b)