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



Sample input:
8 13


Sample output:
2

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
l = 0
cnt =0
while(cnt < b-a):
    cnt += 1
    l += cnt
print(l-b)

Submission status: Accepted

Solution code:
#! /usr/bin/env/python3

line = input().split()

west_leave = int(line[0])
east_leave = int(line[1])
for tower in range(1000):
    west_tower = (tower * (tower+1))/2
    east_tower = ((tower+1) * (tower+2))/2
    if( (west_tower - west_leave) == (east_tower - east_leave) ):
        print (int(west_tower - west_leave))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = input().split()
a = int(a)
b = int(b)
for i in range(1000):
    if (i * (i + 1) / 2 - a == (i + 2) * (i + 1) / 2 - b):
        print(int(i * (i + 1) / 2 - a))
        exit(0)

Submission status: Accepted

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

print(k-a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
lst=list(map(int,input().split()))
a=lst[0]
b=lst[1]
k=(b-a)*(b-a+1)/2-b
print(int(k))

Submission status: Accepted

Solution code:
a,b = map(int, raw_input().split())
d = b - a
if d % 2 == 0:
    print (d * (d + 1) / 2) - b
else:
    print (d * (d - 1) / 2) - a

Submission status: Accepted

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

t1 = 0
for i in range(1,1000):
    t1 += i
    if t1>a and t1+(i+1)>b and (t1-a)==(t1+i+1-b):break

print(t1-a)

Submission status: Accepted

Solution code:
def sum(i):
    sum = 0
    for j in range(i):
        sum += j+1
    return sum

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def height(n):
  if n % 2 == 0:
    h = n * (n + 1) // 2
  else:
    h = height(n + 1) - (n + 1)
  return h

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

Submission status: Accepted

Solution code:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#abc099b

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

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
d = b-a
for k in range(d):
    a -= k
print(0-a)

Submission status: Accepted

Solution code:
def solve(a, b):
    for i in range(1, 1000):
        c = (i-1)*i/2 - a
        d = i*(i+1)/2 - b
        if c == d:
            return c
    return -1

assert solve(8, 13) == 2
assert solve(54, 65) == 1
a, b = map(int, raw_input().split())
print solve(a, b)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sa = b - a
cost = 0
for i in range(1000):
    cost += i
    if sa == i:
        break

print(cost - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sa = b - a
east = (1 + sa) * sa / 2
snow = int(east - b)
print(snow)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
a, b = N[0], N[1]

b_height = 0
gap = b - a

for i in range(gap + 1):
    b_height += i
    if i == gap:
        break

print(b_height - b)

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())

# diff
d = b - a

# length of the larger
l = ( 1 + d ) * d // 2

print( l - b )

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
h=[]

for i in range(1,1000):
    h.append(i*(1+i)//2)
for i in range(1,1000):
    if h[i]-h[i-1]==b-a:
        print(h[i]-b)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())  
c = b-a
num = 0
for i in range(c):
     num += i

print(num-a)

Submission status: Accepted

Solution code:
from math import *

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
    a,b=map(int,raw_input().split())
    s=(b-a)*(b-a+1)//2
    print s-b

Submission status: Accepted

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

Submission status: Accepted

Solution code:

# coding: utf-8

# In[118]:


data = list(map(int,input().split()))
data_diff = data[0] - data[1]


# In[119]:


trees = [1]
for i in range(2,1000):
    num = trees[-1] + i
    trees.append(num)


# In[120]:


differences = []
idx = -1
for i in range(len(trees)-1):
    diff = trees[i] - trees[i+1]
    if diff == data_diff:
        idx = i
        break
print(trees[idx] - data[0])

Submission status: Accepted

Solution code:
tall=[int(i) for i in input().split()]
dist=tall[1]-tall[0]

left=0
for i in range(dist):
  left+=i
print(left-tall[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d = b - a

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def f():
  # n,m = (int(i) for i in input().split()) 
  # p = [int(i) for i in input().split()]
  # d >= then walk
  a,b = (int(i) for i in input().split()) 
  s = b-a
  bh=s*(s+1)//2
  print(bh-b)
f()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
dif = b - a
num = 0
for i in range(1, 1000):
    num += i
    if dif == i:
        print(num - i - a)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 雪に埋もれていない部分の高さがbの塔の高さは(1+2+...+ b-a)
# 1+2+...+X = X(X+1)/2 より、解は (b-a)(b-a+1)/2 - b
print((b-a)*(b-a+1)//2 - b)

Submission status: Accepted

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

t = b-a

s = (t*(t+1))//2
print(s - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split( ))
c = b-a
d = 0
i = 1
ans = 0

while c > i:
    d = d+i
    i += 1
ans = d-a
print(ans)

Submission status: Accepted

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

d = b - a

h = 0
for i in range(1,d):
    h += i

print(h-a)

Submission status: Accepted

Solution code:
(a,b)=map(int,raw_input().split(' '))
z = b-a
print (1+z)*z/2-b

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = (b-a)
sum = 0
for i in range(1,n):
    sum +=i
    if n**2==a+b+(sum-a)*2:    
        print(sum-a)
    else: 
        continue

Submission status: Accepted

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

Submission status: Accepted

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

c = b - a

d = 0

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

print(d - a)

Submission status: Accepted

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

Submission status: Accepted

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

dif = b-a
left_length = sum(range(1,dif))
print(left_length-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
listA=list(map(int,input().split()))
a=listA[0]
b=listA[1]
snow=[1]
for i in range(1,999):
    snow.append(0)
    snow[i]=snow[i-1]+i+1
for j in range(1,1000):
    if(b-a==j):
        print(snow[j-1]-b)
        break;

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tower = [0]

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

a, b = map(int, input().split())
t = tower[b - a]
print(t - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
c = b - a
d = range(1, c, 1)
e = sum(d)
f = e - a
print(f)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding : utf-8

if __name__ == '__main__':

    a,b = list(map(int,input().split()))
    tower = []
    for i in range(1000):
        if i == 0:
            tower.append(1)
        else:
            tower.append(tower[i-1]+i+1)
    d = []
    for i in range(999):
        d.append(tower[i+1]-tower[i])
    for i in range(999):
        if b-a == d[i]:
            print(tower[i]-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = (int(x) for x in input().split())
print(sum(x for x in range(b - a)) - a)

Submission status: Accepted

Solution code:
from sys import stdin
a,b = map(int,stdin.readline().split())
x = b - a
print (x * (x+1) ) /2 - b

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = [int(i) for i in input().split(' ')]
n=b-a#13-8=5
N=n-1#5-1=4
x=(1/2*N)*(N+1)#2*5=10
y= x - a#10-8=2
print(int(y))

Submission status: Accepted

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

Submission status: Accepted

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

n = b - a

N = (n * (n + 1))//2

print(N - b)

Submission status: Accepted

Solution code:
n = input().split()

a = int(n[1]) -int(n[0])

b = a-1
c = 0

while b > 0:
    c += b
    b = b - 1

#
d = c - int(n[0])

print(str(d))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
sum = 0
for i in range(1, 1000):
    sum = sum + i
    if a + i == b:
        ans = sum - b
        break
print(ans)

Submission status: Accepted

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

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

print(int(depth))

Submission status: Accepted

Solution code:
#Stone Monument
a,b = map(int, input().split())
M = []
for i in range(1,1000,1):
	n = 1/2*i*(i+1)
	M.append(n)
n = b-a-1
print(int(M[n-1]-a))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    w,e = map(int, input().split())
    wtower = 0
    for i in range(1,e-w):
        wtower +=i
    print(wtower-w)

Submission status: Accepted

Solution code:
a, b = map(int, raw_input().split(" "))
c = b - a

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

Submission status: Accepted

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

Submission status: Accepted

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

def height(n):
    sum = 0
    for i in range(n+1):
        sum += i
    return sum
    
#    if n==1:
#        return 1
#    else:
#        return n+height(n-1)
    
d = height(b-a)
print(d-b)

Submission status: Accepted

Solution code:
towers = [(0,0)]
for i in range (999):
    b = towers[-1][0] + (i + 1)
    towers.append((b, i))

towers.pop(0)

(a, b) = [int(i) for i in input().rstrip().split(' ')]

bi = b - a - 1
print(towers[bi][0] - b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a_b = input().split()
a = int(a_b[0])
b = int(a_b[1])
n = b - a

h = (n - 1) * n / 2 - a

print(int(h))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
x=1
y=1
for i in range(2,1000):
    x+=i
    y=x-i
    if x-b==y-a:
        print(x-b)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

a, b = read_line(int, int)

d = b - a
s = 1
for i in range(2, 1000):
    s += i

    if d == i:
        print(s - b)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int, input().split(" "))
diff=b-a
s=0
for i in range(1000):
    if i==diff:
        print(s-a)
        break
    s+=i

Submission status: Accepted

Solution code:
aaaa = input()

a = (int)(aaaa.split()[0])
b = (int)(aaaa.split()[1])
n = b - a

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

Submission status: Accepted

Solution code:
#B
a,b=map(int,input().split())
dif=b-a
height_west=sum(x for x in range(dif))
height_snow=height_west-a
print(height_snow)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
hight = 0
for _ in range(b-a+1):
    hight += _
print(hight - b)

Submission status: Accepted

Solution code:
a, b = tuple(map(int, input().split()))
nums = list(range(1, 1000))

print(sum(nums[:(b - a)]) - b)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b - a
hantei = 0

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

Submission status: Accepted

Solution code:
s =input().split()

a = int(s[0])
b=int(s[1])
c = b - a

K=c*(c+1)/2-b
print(int(K))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

A, B = map(int, input().split())
diff = B - A
left_idx = diff - 2

talls = []
t = 0
for i in range(999):
    t += (i + 1)
    talls.append(t)

t = talls[left_idx]
print(t - A)

Submission status: Accepted

Solution code:
inp = input()
a,b = inp.split(" ")
a = int(a)
b = int(b)
diff = b-a

oria = 0
for i in range(diff):
    oria +=i

print(oria -a)

Submission status: Accepted

Solution code:
import numpy as np
a, b = input().split(" ")
a = int(a)
b = int(b)

c = b - a
s = sum(list(np.arange(c)))
print(s - a)

Submission status: Accepted

Solution code:
i1, i2 = map(int, input().split())

iMargin = i2 - i1
iSum = 0

for i in range(1, iMargin):
    iSum = iSum + i

print (iSum - i1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a,b = map(int, raw_input().split())
diff=b-a
trueHeight=diff*(diff+1)/2
ret=trueHeight-b
print ret

Submission status: Accepted

Solution code:
A = input().split(" ")
a = int(A[1])-int(A[0])
c = 1
m = 1
while a != m:
    m += 1
    c += m
print(c-int(A[1]))

Submission status: Accepted

Solution code:
a,b=[int(i) for i in input().split()]
li = []
cnt=0
for j in range(1,1000):
    li.append(j+cnt)
    cnt += j

print(li[(b-a)-2] - a)
#print(li)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

X=0

A=1
B=2

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

print(X-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input() .split())
c = b-a
d = range(1, c, 1)
e = sum(d)
f = e-a
print(f)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

a,b =map(int, raw_input().split(' '))

n = b - a

sum = (n * n + n) / 2

output = sum - b

print output

Submission status: Accepted

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

c=b-a
d=sum(range(1,c+1))

ans=d-b

print(ans)

Submission status: Accepted

Solution code:
a,b = [int(x) for x in input().split()]
for i in range(999):
    j = i+1
    h1 = int(((i*(i+1))/2))-a
    h2 = int(((j*(j+1))/2))-b
    if h1 == h2:
        print(h1)
        break

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
def f(n):
	sum = 0
	for i in range(1, n+1):
		sum += i
	return sum

print(f(b-a-1)-a)

Submission status: Accepted

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

print('{}'.format(sum(range(1,b - a + 1)) - b))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

d = b - a
n = 1
for i in range(2, d):
	n += i

print n - a

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
tower_list=[]
tower_length=1
tower_list.append(tower_length)
for i in range(1,999):
    tower_length+=(i+1)
    tower_list.append(tower_length)

for idx in range(1,len(tower_list)-1):
    if tower_list[idx]>a and tower_list[idx+1]>b:
        x_west=tower_list[idx]-a
        x_east=tower_list[idx+1]-b
        if x_east==x_west:
            print(x_east)

Submission status: Accepted

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

Submission status: Accepted

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

print(sumn-b)

Submission status: Accepted

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

c = b - a

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

Submission status: Accepted

Solution code:
def sum(n):
    return n*(n+1)/2

def main():
    A, B = map(int, raw_input().split())
    n = B - A
    lefttower = sum(n-1)
    print(lefttower - A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
[a,b] =list(map(int,input().split(" ")))
print(( b -a -1)*(b -a)//2 -a)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
# k is piller that height is a
k = b - a - 1
print(k * (k + 1) // 2 - a)

Submission status: Accepted

Solution code:
A, B = map(int, raw_input().split())

N = B - A

no = 0

for i in range(N-1):
    no = no + i+1

print(no-A)

Submission status: Accepted

Solution code:
a,b = map(int,raw_input().split())
arr = []
arr.append(1)
for i in range(2,1000):
	arr.append(arr[i-2] + i)

sub = b-a

print arr[sub-1]-b

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
st_in = input()
tmp_in = re.split(" ",st_in)

a = int(tmp_in[0])
b = int(tmp_in[1])

i_sum = 1
for i in range(2,1000):
    i_sum += i
    if i_sum > b and i_sum - i > a:
        if i_sum - b == i_sum - i - a:
            print(i_sum-b)
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
a_b = b - a
nl = 0

for i in range(1, a_b):
    nl += i

print(nl - a)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
a=l[0]
b=l[1]

import numpy as np

east_num = b-a

tmp = np.arange(1,b-a+1)

east_hight = sum(tmp)

snow= east_hight-b

print(snow)

Submission status: Accepted

Solution code:
ai,bi = map(int,input().split())
c = bi - ai
sum = 0
for i in range(1,1000):
    sum += i
    if (sum - (sum - i)) == c:
        ans = sum - bi
        break
    
print(ans)

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
B_num = B-A
B_length = 0
for i in range(1,B_num+1):
    B_length = B_length + i

print(B_length-B)

Submission status: Accepted

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

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

Submission status: Accepted

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

c = b-a
hight = 0

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

print(hight-b)

Submission status: Accepted

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

count = b - a - 2

height = 1
up = 1
for i in range(count):
    up += 1
    height += up

print(str(height - a))

Submission status: Accepted

Solution code:
# coding: utf-8

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

diff = b - a

while True:
    b = b - diff

    if diff == 1:
        break
    diff -= 1
print(abs(b))

Submission status: Accepted

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

Submission status: Accepted

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

print(s - a)

Submission status: Accepted

Solution code:
a,b = (int(i) for i in input().split())

length = b - a
result = 0

for j in range(length):
  result += j
  
print(result + length - b)

Submission status: Accepted

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

diff = b - a

h = 1
for i in range(2, 1000):
    h += i
    if i == diff:
        print(h - b)
        exit()

Submission status: Accepted

Solution code:
from sys import stdin, stdout


a, b = map(int, stdin.readline().split())
prev, cur = 1, 3
ind = 3

while True:
    if a - prev == b - cur and b < cur:
        stdout.write(str(cur - b))
        break
    
    prev = cur
    cur += ind
    ind += 1

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def get_height(n):
    return n * (n + 1) // 2


h = get_height(b - a)

print(h - b)

Submission status: Accepted

Solution code:
num = input().split()
n = int(num[1]) - int(num[0])

print(int(n*(n+1)/2 - int(num[1])))

Submission status: Accepted

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


    sa = b - a

    lst =[0]

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

    print(lst[sa] - b)



if __name__ == "__main__":
        main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum-a)

Submission status: Accepted

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

c = b -a 
d = int(c*(c+1)/2)
e = d - b

print(e)

Submission status: Accepted

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

for i in range(999):
    if a - tower[i] == b - tower[i+1]:
        print(int(abs(tower[i]-a)))
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np


def func(n):
    return int(n * (n+1) / 2)

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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b= map(int, input().split())
s = []
j = 0
for i in range(1, 1000):
    j = j + i
    s.append(j)
x = s[b - a - 1] - b
print(x)

Submission status: Accepted

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

R=int(0.5*(b-a-1)*(b-a)-a)

print(R)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
SUM_1 = 0
SUM_2 = 1
i = 0
array = [x for x in range(1000)]
array.pop(0)

while True:
    SUM_1 = SUM_1 + array[i]#隣り合う2つ
    SUM_2 = SUM_2 + array[i+1]#隣り合う2つ

    if SUM_1 - a == SUM_2 - b:
        print(SUM_1 - a)
        break
    
    i += 1

Submission status: Accepted

Solution code:
a, b = map(int, input().split())		# 5 7

n=b-a

sum=0
for i in range(n, 0, -1):
	sum+=i

print(sum-b)

Submission status: Accepted

Solution code:
leng=[]
diff=[]
for i in range(1,1000):
	h=i*(i+1)//2
	leng.append(h)
for i in range(0,len(leng)-1):
	diff.append(leng[i+1]-leng[i])
a,b=map(int,input().split())
d=abs(a-b)
#print(leng)
#print(diff)
try:
	pos=diff.index(d)
except:
	ans=1
#print(pos)
#print(leng[pos])
ans=leng[pos]-a
print(ans)

Submission status: Accepted

Solution code:

ab = list(int(i) for i in input().split())

s = 0
devide = ab[1] - ab[0]

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

ans = s - ab[0]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

t = [1,]

for i in range(1000):
    t.append((i+2)+ t[i])

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

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
c=list(range(1,1000))
c2=[sum(c[:i+1]) for i in range(len(c))]
d=b-a
print(c2[d-2]-a)

Submission status: Accepted

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

c = b-a

d = c*(c-1)/2 -a
print(int(d))

Submission status: Accepted

Solution code:
import sys
a,b = map(int,input().split())

sa = abs(b-a)
tmp1 = 0
for i in range(1,1000):
    tmp2 = int(i*(i+1)/2)
    if tmp2 - tmp1 == sa:
        print(tmp1 - a)
        sys.exit()
    tmp1 = tmp2
print(1)

Submission status: Accepted

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

tmp = 1
tmp_1 = 0

for i in range(1, 999):
    tmp_1 = tmp + i + 1
    if tmp > a and tmp_1 > b:
        if tmp - a == tmp_1 - b:
            print(tmp - a)
            exit()

    tmp = tmp_1

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
N = b - a - 1

h = N*(N+1)/2 - a

print(int(h))

Submission status: Accepted

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