Problem:
 Score : 200 points    Problem Statement 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 1 8 13      Sample Output 1 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.       Sample Input 2 54 65      Sample Output 2 1

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a, b = nm()

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

Solution (Python):
def main():
    a, b = map(int, input().split())
    n = (b - a) - 1
    a_ = n*(n+1)/2
    print(int(a_ - a))
main()

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

Solution (Python):
a, b = map(int, input().split())

diff = b - a
for n in range(1000):
    if diff == n + 1:
        ans = n * (n + 1) // 2 - a
        print(ans)

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

Solution (Python):

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

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

Solution (Python):
a,b = map(int,input().split())

n = b - a

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

Solution (Python):
x, y = map(int,input().split())
z = y - x
ans = 0

for i in range(1,z):
  ans += i

print(ans-x)

Solution (Python):
a, b = map(int, input().split())

diff = b-a

def tower_height(x):
    return x * (x+1) // 2

west_tower = tower_height(diff-1)
east_tower = tower_height(diff)

print(west_tower-a)

Solution (Python):
a,b=map(int,input().split())
A=[]
for i in range(1,1000):
    A.append((i*(i+1))//2)

for j in range(5*(10**6)):
    if ((a+j) in A) and ((b+j) in A):
        if A.index(a+j)+1==A.index(b+j):
            print(j)
            exit()

Solution (Python):
A,B = map(int,input().split())

Ha = (B-A-1)*(B-A)//2

for x in range(1,Ha):
  if Ha-x == A:
    print(x)
    exit()

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

Solution (Python):
a=list(map(int,input().split()))
sum=0
for i in range(1,a[1]-a[0]):
    sum+=i
print(sum-a[0])

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

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

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

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

Solution (Python):
a,b=[int(i) for i in input().split()]
sa=b-a
ans=0
for i in range(sa):
    ans+=i
print(ans-a)

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

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

Solution (Python):
def resolve():
    a, b = list(map(int, input().split(" ")))
    diff = b - a
    b_height = 0
    for i in range(1, diff+1):
        b_height += i
    print(b_height - b)    

if '__main__' == __name__:
    resolve()

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

Solution (Python):
a, b = [int(num) for num in input().split()]
dif = b - a
hw = (dif-1)*dif/2
sol = hw - a
print(int(sol))

Solution (Python):
a, b = map(int, input().split())

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

Solution (Python):
import sys
a,b = map(int,input().split())
l = [(n*(n+1))//2 for n in range(1,1000)]
for i in range(len(l)-1):
  if l[i+1]-l[i] == b - a:
    print(l[i]-a)
    sys.exit()

Solution (Python):
a, b = map(int, input().split());t = a-b
print((t*t-t)//2-b)

Solution (Python):


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

num = 0
for i in range(1, 999):
    if b - a == i + 1:
        num = i
        break
ans = num * (num + 1) // 2 - a
print(ans)

Solution (Python):
a, b = map(int, input().split())

print(int(0.5*(b-a)*(b-a-1)-a))

Solution (Python):
A, B = map(int, input().split())

sub_AB = abs(A-B)

A_height = 0
for i in range(1, sub_AB):
    A_height += i

print(A_height - A)

Solution (Python):
a, b = map(int, input().split())

c = b-a

pole = 0

for i in range(c):
  pole += i

print(pole-a)

Solution (Python):
a,b = map(int,input().split())

sabun = b-a

high = 0

for i in range(sabun):
    high += i
    
print(high-a)

Solution (Python):
a, b = map(int, input().split())
print(int(0.5 * (b - a - 1) * (b - a) - a))

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

Solution (Python):

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

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

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

Solution (Python):
table = [1, ]
for i in range(2, 1000):
    table.append(table[i-2] + i)

a, b = map(int, input().split())
print(table[b-a-1] - b)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    a, b = map(int, input().split())
    diff = b - a
    high = sum([i for i in range(diff)])
    print(high - a)

if __name__ == '__main__':
    main()

Solution (Python):
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 

sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

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

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a,b = map(int,input().split())
  print(int((b-a) * (b-a+1)/2 - b))
  
if __name__ == '__main__':
  main()

Solution (Python):
import sys
input = sys.stdin.readline

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

n = 1
t = 0
for i in range(2, 1000):
    if (n - i) - a == n - b:
        t = n
        break
    n += i
ans = t - a
print(ans)

Solution (Python):
a,b = map(int,input().split())

maxh = 0
for i in range(b-a):
  maxh += i
print(maxh-a)

Solution (Python):
a, b = map(int, input().split())
diff = b - a
h = (diff-1) * diff // 2
print(h - a)

Solution (Python):
a, b = map(int, input().split())

n = b - a - 1

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

Solution (Python):
a, b = map(int, input().split())
c = b-a
k = 1
l = 0
ans = -1
for i in range(2, 1000):
    l = k
    k += i
    if k-l == c:
        ans = k-b
        break

print(ans)

Solution (Python):
a, b = map(int, input().split())
height_a = 0

for i in range(b-a):
  height_a += i
  
print(height_a - a)

Solution (Python):
a,b = map(int,input().split())

k=b-a-1
l=k*(k+1)/2
print(int(l-a))

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

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

Solution (Python):
a,b=map(int,input().split())
k=sum(list(range(1,b-a)))
print(k-a)

Solution (Python):
a, b = map(int, input().split())

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

print(sum - a)

Solution (Python):
a, b = [int(x) for x in input().split()]
print((b-a)*(b-a+1)//2 - b)

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

Solution (Python):
a, b = map(int, input().split())

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

print(sub - b)

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

Solution (Python):
a, b = map(int, input().split())

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

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

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b =iim()
tb = 0
for i in range(1,b-a+1):
    tb += i
print(tb-b)

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

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

print(result - b)

Solution (Python):
a, b = map(int, input().split())

n = b-a

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

Solution (Python):
def Stone_Mounment(a , b):

    i = b - a

    return i * (i + 1) // 2 - b

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

if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int,input().split())
i=b-a
h=(i*(i+1))//2
print(h-b)

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

Solution (Python):
a, b = map(int, input().split())
diff = b-a
high = (1+diff)*(diff/2)
print(int(high-b))

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

Solution (Python):
a,b=map(int,input().split())
x=[int(i) for i in range(1,1000)]
print(sum(x[:(b-a-1)])-a)

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

Solution (Python):
def main():
    a, b = map(int, input().split())
    diff = b - a
    height = 0
    for i in range(1, diff+1):
        height += i
    ans = height - b
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def factorial(n):
    if n == 1:
        return 1
    else:
        return n + factorial(n - 1)


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

diff = b - a

print(factorial(diff - 1) - a)

Solution (Python):
a,b=map(int,input().split())
tmp=0

for i in range(1,b-a+1):
    tmp+=i

print(tmp-b)

Solution (Python):
a,b =map(int,input().split())
for i in range(1,1000):
  c = int(i*(i+1)/2)
  d = int((i+1)*(i+2)/2)
  c = c-a
  d = d-b
  if c ==d:
    print(c)
    break

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

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

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

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

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

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

Solution (Python):
a, b = map(int, input().split())

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

print(ans - b)

Solution (Python):


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


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


print( int(x1) )

Solution (Python):
a,b=map(int,input().split())
k=b-a
print(sum(range(k))-a)

Solution (Python):
a, b = map(int, input().split())
cnt = 1
l = [1]
m = []

for i in range(2, 1000):
    cnt += i
    l.append(cnt)

for j in range(len(l) - 1):
    d = l[j + 1] - l [j]
    m.append(d)
n = m.index(b - a)
print(l[n] - a)

Solution (Python):
a,b=list(map(int,input().split()))
d=b-a
sum=0
l=[]
for i in range(1,d):
    sum+=i
    l.append(sum)
print(sum-a)

Solution (Python):

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

Solution (Python):
import math
import string


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b = readints()

sum = 0
x = []
for i in range(1, 1000):
    sum += i
    x.append(sum)


for i in range(998):
    if x[i]-a == x[i+1]-b:
        print(x[i]-a)
        exit()

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

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

Solution (Python):
a,b = map(int,input().split())
x = 1
y = 3
for i in range(10**5):
    if x-a == y-b:
        print(x-a)
        break
    else:
        x += i+2
        y += i+3

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

Solution (Python):
def main():
    a,b = map(int, input().split())

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


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import accumulate, tee


def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


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

towers = list(accumulate(range(1, 1000)))

for p, n in pairwise(towers):
    if n - p == b - a:
        print(p - a)
        break

Solution (Python):
def kaijou(num):
    wa = 0
    for i in range(num, 0, -1):
        wa += i
    return wa
a, b = map(int, input().split())
dst = kaijou(b-a) - b
print(dst)

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

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

Solution (Python):
a = [int(i) for i in input().split()]
b=a[0]
c=a[1]
x=c-b
print(round((x+1)*x/2)-c)

Solution (Python):

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

Solution (Python):
a,b = map(int,input().split())
c = b-a
ans = -a

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

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

Solution (Python):
a, b = map(int, input().split())

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

print(int(ans))

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

Solution (Python):








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


resolve()

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

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

Solution (Python):
a, b = (int(i) for i in input().split())
c = b - a
d = c*(c+1)//2
print(d - b)

Solution (Python):
a,b=map(int,input().split())
n=b-a
high=1
for i in range(2,n):
    high+=i

print(high-a)

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

Solution (Python):
a,b = map(int,input().split())

for i in range(1000):
    if i == b-a:
        print(i*(i+1)//2-b)
        break

Solution (Python):
x,y = map(int,input().split())

sa = y-x
tou = 0

for i in range(1,sa):
    tou += i
print(tou-x)

Solution (Python):


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

Solution (Python):
a,b=map(int,input().split())
a_l=[]
for i in range(b-a):
            a_l.append(i)
            i=i+1

print(sum(a_l)-a)

Solution (Python):
a, b = map(int, input().split())

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

Solution (Python):
a, b = map(int, input().split())
s = sum([i for i in range(1, (b-a)+1)])
print(s - b)

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

Solution (Python):
a, b = map(int, input().split())
diff = b - a
ah = sum(range(1, diff))
print(ah - a)

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

Solution (Python):
a,b = [int(x) for x in input().split()]

dif = b - a
org = sum([x for x in range(1,dif)])
print(org-a)

Solution (Python):
a,b = map(int,input().split())

c = b - a

x=0
for i in range(c):
  x += i
  

ans = x - a 

print(ans)

Solution (Python):
a,b=map(int,input().split())

res=1
A=[res]
for i in range(2,1000):
    res+=i
    A.append(res)
    if A[i-2]-a==res-b:
        print(res-b)
        exit()

Solution (Python):
a, b = map(int, input().split())

diff = b - a
alen = ((diff-1) * diff) // 2
print(alen - a)

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

Solution (Python):
a,b = map(int, input().split())

sa = b-a
left = 0
for i in range(1,sa):
    left+=i
print(left-a)

Solution (Python):
a,b = (int(x) for x in input().split())
s = 0
d = b - a

for i in range(d):
    s += i

print(s-a)

Solution (Python):
a,b=map(int,input().split())
n=b-a
ans=b
while n>0:
    ans-= n
    n -=1
print(-ans)

Solution (Python):
a, b = map(int, input().split())
diff = b - a
b_len = sum([i for i in range(1, diff + 1)])
print(b_len - b)

Solution (Python):
a, b = map(int, input().split())

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

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

Solution (Python):
a,b = map(int, input().split())
l = [1]*999
for i in range(1, 999):
    l[i] = l[i-1] + i+1
print(l[b-a-1]-b)

Solution (Python):
import math

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

Solution (Python):
a,b = map(int, input().split())
s = [0] * 1001
for i in range(1000):
  s[i+1] = s[i] + i+1
print(s[b - a] - b)

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

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

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

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

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

a, b = na()

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

Solution (Python):
a,b = map(int,input().split())
k = b-a
A = int((1+(k-1))*(k-1)/2)
B = int((1+k)*k/2)
print(A-a)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    c=b-a
    ct=0
    for i in range(c):
        ct+=i
    print(ct-a)
if __name__ == '__main__':
    do()

Solution (Python):
a, b = map(int, input().split())
k = b - a
l = [i for i in range(1,k+1)]
c = sum(l)
print(c - b)

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()

input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

a,b=LI()
x=b-a
ans=x*(x-1)//2-a

print(ans)

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

Solution (Python):
H = [1]
for i in range(2, 1000):
    H.append(H[-1] + i)

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

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

Solution (Python):
a,b=list(map(int,input().split()))
c=b-a
l=[]
for i in range(c):
    l.append(i+1)

print(sum(l)-b)

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

Solution (Python):
a, b = map(int, input().split())
diff = b - a
left = diff * (diff - 1) // 2
print(left - a)

Solution (Python):
a, b = map(int, input().split())

diff = b - a
hight = 0
for k in range(diff):
    hight += k
print(hight - a)

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

Solution (Python):
a, b = map(int, input().split())

cum = [0]
for i in range(1000):
    cum.append(cum[-1] + i)

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

Solution (Python):
a, b = map(int, input().split())


print(sum([i for i in range(b-a)]) - a)

Solution (Python):
def gauss(n):
    ans = n * (n - 1) // 2
    return ans

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

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

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

Solution (Python):
a, b = map(int, input().split())
x = b - a - 1

ans = x * (x+1) // 2 - a
print(ans)

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

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

Solution (Python):
x,y = map(int,input().split())
res = 0
for i in range(1, y-x):
    res += i
    

print(res-x)

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

Solution (Python):
a, b = map(int, input().split())
diff = b-a
print(sum(range(diff+1))-b)

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

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

Solution (Python):
def main():
    west_tower_height, east_tower_height = map(int, input().split(" "))
    east_tower_num = east_tower_height - west_tower_height
    print(east_tower_num * (east_tower_num + 1) // 2 - east_tower_height)


if __name__ == '__main__':
    main()

Solution (Python):




def main():
    A, B = map(int, input().split())

    print((B - A) * (B - A + 1) // 2 - B)


if __name__ == "__main__":
    main()

Solution (Python):




def main():
    A, B = map(int, input().split())
    T = [i for i in range(1, 1000)]
    print(sum(T[:B - A]) - B)


if __name__ == "__main__":
    main()

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

Solution (Python):
a,b = map(int, input().split())
h = b-a
tmp = [sum(range(1,i)) for i in range(1,h+2)]
print(tmp[-1] - b)

Solution (Python):
a, b = map(int, input().split())
lst = []
s = 0

for i in range(1, 1001):
    s += i
    lst.append(s)

for i in range(999):
    x = lst[i] - a
    y = lst[i+1] - b

    if x == y and x > 0 and y > 0:
        print(x)

Solution (Python):
a,b = map(int, input().split())

d = b-a

arr = [0] * 1000
for i in range(1,len(arr)):
    arr[i] = arr[i-1] + i
print(arr[d]-b)

Solution (Python):
a, b = [int(i) for i in input().split()]

N = b - a

cnt = 0
for n in range(1, N+1):
    cnt += n
    
print(cnt - b)

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

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

Solution (Python):



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

l= [1]
for i in range(1,1000):
    x = l[i-1] + i+1
    l.append(x)

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

Solution (Python):
a,b = map(int, input().split())

l= [1]
x = 0
for i in range(1,1000):
    x = l[i-1] + i+1
    l.append(x)

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

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

Solution (Python):
a, b = map(int, input().split())

print(sum([i for i in range(b - a)]) - a)

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

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

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

Solution (Python):
a,b=map(int,input().split())
x=b-a

wa=(x**2+x)//2
print(wa-b)

Solution (Python):
a,b = map(int,input().split())
x = b-a
y = (1/2)*(x-1)*x
print(int(y-a))

Solution (Python):
a,b = map(int,input().split())
c = b - a
n = (c - 1) * c // 2
print(n - a)

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

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

Solution (Python):
a, b = map(int, input().split())
ans = 0
ans1 = 0

for i in range(1, 1000):
    ans += i
    ans1 += i-1
    
    if(ans-ans1 == b-a):
        print(ans-b)
        break

Solution (Python):
a,b=map(int, input().split())
print(sum([x for x in range(b-a)])-a)

Solution (Python):
a,b = map(int,input().split())
def calc(n):
    return (n*(n+1))//2
ab = b -a
B = calc(ab)
ans = B - b
print(ans)

Solution (Python):
import sys

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

Solution (Python):
a,b = map(int,input().split())
sa = abs(a-b)
a_true = 0
for i in range(sa-1):
    a_true += i+1
print(a_true - a)

Solution (Python):
a,b=map(int,input().split())
print(sum(i for i in range(b-a))-a)

Solution (Python):
a,b = map(int,input().split())

count = 0

for i in range(b - a):
    count += i

print(count - a)

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

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

Solution (Python):
l=[1]
for i in range(2,1000):
  l.append(l[-1]+i)
a,b=map(int,input().split())
print(l[b-a-2]-a)

Solution (Python):
a, b = map(int, input().split())

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

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

Solution (Python):
def solve(a, b):
    n = b - a
    return n * (n + 1) // 2 - b

_a, _b = map(int, input().split())
print(solve(_a, _b))

Solution (Python):
a, b = map(int, input().split())

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

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

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


a, b = list(map(int, sys.stdin.buffer.readline().split()))

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

Solution (Python):
a, b = map(int, input().split())
ans = 0
tmp = b-a
while(tmp):
    ans += tmp
    tmp -= 1
print(ans-b)

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

Solution (Python):
a,b = map(int,input().split())
def f(n):
  return n*(n+1)//2

c = b-a

print(f(c)-b)

Solution (Python):
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

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

print(int(bt - b))

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

Solution (Python):
a, b = map(int, raw_input().split())
c = b - a
x = 1 + c
y = x * c
f = y / 2
print f - b

Solution (Python):
a, b = map(int, raw_input().split())
c = b - a
x = 1 + c
y = x * c
f = y / 2
print f - b

Solution (Python):
a, b = map(int, raw_input().split())
n = b - a
t = (1 + n) * n / 2
print t - b

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

Solution (Python):
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)

Solution (Python):
a, b = [int(x) for x in input().split()]

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

print(An-a)

Solution (Python):
a, b = map(int, input().split())

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

print(ans)

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

Solution (Python):
a, b = map(int, input().split())
diff = b - a

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

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

Solution (Python):


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

Solution (Python):
a, b = map(int,input().split())

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