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())
ans = [0]*1000
for i in range(1, 1000):
    ans[i] += ans[i-1] + i
print(ans[b-a] - b)

Submission status: Accepted

Solution code:
def resolve():
  a, b = map(int, input().split())
  num_b = b - a
  height_b = 0
  for i in range(num_b + 1):
    height_b += i
  print(height_b - b)
  return

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
c = b - a
i = 1
count = 0
while True:
  count += i
  if i == c:    
    break
  i += 1
print(count-b)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, 1000):
    tmp += i
    tower.append(tmp)
    
count = b - a

print(tower[count - 1] - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
def height(n):
    l = [k for k in range(1,n+1)]
    return sum(l)
print(height(b-a)-b)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(1, abs(b - a) + 1):
        t += i
    print(t - b)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    tour = [(i * (i + 1)) // 2 for i in range(1, 1000)]
    a, b = map(int, input().split())
    v = 0
    for i, j in zip(tour[:-1], tour[1:]):
        if i < a or j < b:
            continue
        if i - a == j - b:
            v = i - a
            break
    print(v)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
l=[]
ans=0
for i in range(1,1000):
    ans+=i
    l.append(ans)
#print(l[:10])
c=b-a
print(l[c-2]-a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(l[c-1] -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:
s=list(map(int,input().split()))
list=[]
for i in range(1,1000):
  list.append((i*(i+1))//2)
for j in range(998):
  if list[j]-s[0]==list[j+1]-s[1]:
    print(list[j]-s[0])
    break

Submission status: Accepted

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

Submission status: Accepted

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

counter = 1
while True:
    val_a = 0.5 * counter * (counter + 1) - a
    val_b = 0.5 * (counter + 1) * (counter + 2) - b
    if val_a == val_b:
        counter = int(val_a)
        break
    counter += 1
print(counter)

Submission status: Accepted

Solution code:
a,b = [int(x) for x in input().split()]
c = b-a
ans = 0
for i in range(1,c+1):
  ans += i
print(ans-b)

Submission status: Accepted

Solution code:
def bb099up(a,b):
    tou = 0
    for i in range(1, 1000):
        tou += i
        if tou > a:
            snow = tou - a
            if snow+b == tou+i+1:
                return snow

def bb099():
    a,b = list(map(int, input().split()))
    print(bb099up(a, b))

bb099()

Submission status: Accepted

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

for i in range(1, 999):
    west_tower = 0
    for n in range(1, i + 1):
        west_tower += n
    east_tower = west_tower + (i + 1)
    if west_tower - a == east_tower - b:
        print(west_tower - a)
        break
    else:
        pass

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
print(int((b-a)*(b-a+1)/2-b))
'''
(b-a)まで足す  
(b-a)(b-a+1)/2 高い方の木の高さ
(b-a)(b-a+1)/2 - b 雪が積もった高さ
'''

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:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b=map(int,input().split())
    n=b-a
    print(n*(n-1)//2-a)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
I = input().split()
S = int(I[1]) - int(I[0])
print (int(S * (S + 1) / 2) - int(I[1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
print((b-a)*(b-a-1)//2-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
idx = b-a
print((1+idx)*idx//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]=[int(x) for x in input().split()]
res=0
for i in range(b-a):
  res+=i
print(res-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:
n,m=map(int,input().split())
a=sum(range(m-n))
print(a-n)

Submission status: Accepted

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

x, y = 1, 3
while True:
    ax = x - a
    by = y - b
    if ax == by and ax >= 0 and by >= 0:
        break
    x, y = y, y + (y - x) + 1
print(ax)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def h(k):
    return (1 + k)*k // 2

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

ans = 1
for i in range(1, 999):
    x = h(i) - a
    y = h(i+1) - b
    if x == y:
        ans = x
        break
print(ans)

Submission status: Accepted

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

def S(i):
  return i*(i+1) //2

print(S(b - a) - b)

Submission status: Accepted

Solution code:
# B - Stone Monument
a,b =map(int,input().split())

tmp= (b-a)*( b-a-1)/2

print(  int(tmp-a))

Submission status: Accepted

Solution code:
# ABC099B - Stone Monument
def main():
    A, B = tuple(map(int, input().split()))
    ans = sum(range(1, B - A)) - A
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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())
towernumber = b-a
print(sum(list(range(towernumber+1)))-b)

Submission status: Accepted

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

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

print(tower-b)

Submission status: Accepted

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

Submission status: Accepted

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

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())
d = b - a
h = d * (d - 1) // 2
print(h - a)

Submission status: Accepted

Solution code:
# ABC099b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
a_len = sum([_ for _ in range(b-a)])
print(a_len-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
sum = 0
for i in range(1, dif+1):
    sum += i
print(sum - b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC099 B - Stone Monument 
a,b = map(int,input().split())
s = 0
for i in range(b-a):
    s += i
print(s-a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

a, b = ISI()
c = b - a
height = 0
for i in range(1, c):
    height += i
print(height - a)

Submission status: Accepted

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

import sys

sys.setrecursionlimit(2000)

def f(x):
    if x == 0:
        return x
    return x + f(x - 1)

diff = b - a
east = f(diff)
print(east - b)

Submission status: Accepted

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

Submission status: Accepted

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

b_a = b-a

hight_tower_a = 0
for i in range(1,b_a):
  hight_tower_a += i


ans = hight_tower_a - a
print(ans)

Submission status: Accepted

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

Si = 0
Sj = 0
k = 1
flag = False
for i in range(1, 1000):
  Si += i
  for j in range(k, i):
    Sj += j
    if (Si - Sj) == (b - a):
      flag = True
      break
    k = j+1
  if flag:
    break
print(Sj - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])
    trees = [0]
    for i in range(1, 1000):
        trees.append(trees[i-1] + i)

    diff = B - A
    return trees[diff] - B


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
(a, b) = (int(tok) for tok in input().split())
towers = b - a

snow = towers * (towers + 1) // 2 - b
print(snow)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = na()
li = [1]
d = b - a
for i in range(2, 1000):
    li.append(li[-1] +i)
print(li[d-2] - a)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = b-a
#高い方の塔の高さがsum(1,2,...,c)=c(c+1)/2になります
h = c*(c+1)//2
print(h-b)

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

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

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

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
a, b  =  map(int, sys.stdin.readline().split())

A = 0

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

print(A - b)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(1,1000):
  c.append(0)
for i in range(1,1000):
  c[i] = c[i-1] + i + 1 
  
  if b - a == i + 1 :
    print(c[i-1]-a)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
#隣の塔との差は雪に影響しない
#b-aがbのインデックス ここからbの高さがわかる
bi = b - a
b_height=sum(range(1,bi+1))
yuki = b_height - b
print(yuki)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:


def main():

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

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

if __name__== "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

i=1
cn=0
temp=0

while i<1000:
  cn=cn+i
  if i==b-a:
    print(cn-b)
    break
  
  i+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def summation(x):
    if x == 1:
        return 1
    else: 
        return x + summation(x-1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
m = b-a
ans = 0

for i in range(m+1):
    ans += i

print(ans-b)

Submission status: Accepted

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
d = b - a
for i in range(1,999):
    Si = i * (i + 1) // 2
    Sii = (i + 1) * (i + 2) // 2
    Sd = Sii - Si
    if d == Sd:
        height = Si
        break
print(height - a)

Submission status: Accepted

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

Submission status: Accepted

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

diff = b - a

org_b = 0
for i in range(1, diff + 1):
    org_b += i

print(org_b - b)

Submission status: Accepted

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

check=0
for i in range(1,ab+1):
    check+=i
    
print(check-b)

Submission status: Accepted

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

diff  = b - a
west_tower = sum([i for i in range(b-a)])

snow = west_tower - a

print(snow)

Submission status: Accepted

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

Submission status: Accepted

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

sigma = []
diff = []

tmp = 0
for i in range(1,1000):
    tmp += i
    sigma.append(tmp)

    if i >= 2:
        diff.append(sigma[i-1]-sigma[i-2]) 
        if sigma[i-1] - sigma[i-2] == sa:
            print(sigma[i-1] - b)

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

height=1
for i in range(2,b-a):
    height+=i
print(height-a)

Submission status: Accepted

Solution code:

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

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

    if i == diff:
        print(s - b)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

c=b-a
d=0

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

print(d-b)

Submission status: Accepted

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

i = 0
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())
c=b-a

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
a,b=map(int,input().split())
print(sum(range(b-a))-a)

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=list(map(int,input().split()))
n=b-a
print(n*(n+1)//2 - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    height = [0] * 1000

    for i in range(999):
        height[i+1] = height[i] + i + 1

    for i in range(1,999):
        diff_a = height[i] - a
        diff_b = height[i+1] - b
        if diff_a >= 0 and diff_b >= 0 and diff_a == diff_b:
            print(diff_a)
            exit()

main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
diff = b - a
c = sum(list(range(diff)))
ans = c - a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
c = b-a
tower_height = sum(list(range(1,c+1)))
#print(tower_height)
print(tower_height-b)

Submission status: Accepted

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

lst = [1]

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

Submission status: Accepted

Solution code:
w,e = map(int,input().split())
diff = e-w
true_height=0
for h in range(1,diff+1):
  true_height+=h
print(true_height-e)

Submission status: Accepted

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

Submission status: Accepted

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

sa = b - a
high = 0

for i in range(sa):
    high += i

print(high - a)

Submission status: Accepted

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

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 = (int(i) for i in input().split()) 
print(int(0.5*(b-a)*(b-a+1)-b))

Submission status: Accepted

Solution code:
#((n+1)^2+n+1-n^2-n)/2 = n+1

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

Submission status: Accepted

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

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

print(hight-a)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
polls = []
for i in range(1,1000):
    polls.append(sum(list(range(1,1000))[:i]))

d = {}
for i in range(1, len(polls)):
    d[polls[i]-polls[i-1]] = [polls[i-1],polls[i]]

print(d[b-a][0] - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
total = 0
for i in range(b - a):
    total += i
print(total - 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())

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
k = b - a - 1   # 西側の塔の位置
ans = k * (k + 1) // 2 - a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

res = (B-A)*(B-A-1)//2-A
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

var = b - a
len_right = var * (var + 1) // 2

print(len_right - b)

Submission status: Accepted

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

diff = b-a

sumb = diff*(diff+1)/2

print(int(sumb)-b)

Submission status: Accepted

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

stopper=b-a
height=0
ix=1

while stopper != ix:
    height += ix
    ix += 1

print(height - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = list(map(int,input().split(' ')))
ar = []
x = 0
for i in range(1,1000):
  x_ = x
  x+=i
  if x-x_ == b-a :
#    print(x)
    break
  
print(x-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())

n = b - a
ans = sum(range(n)) - a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 99, B - stone monument
a, b = map(int, input().split(' '))

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

Submission status: Accepted

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

s = b - a

cnt = 1
res = 0

for i in range(s):
    res += cnt
    cnt += 1
    
print(res - b)

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())
ans = 0
for i in range(b - a):
    ans += i
print(ans - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


# k
# t(k) = k * (k + 1) / 2
# t(k + 1) = (k + 1) * (k + 2) / 2

# a = t(k) - u
# b = t(k + 1) - u

# a + b = t(k) + t(k + 1) - 2u
# -a - b + t(k) + t(k + 1) = 2u

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

for k in range(1, 999):
    t1 = k * (k + 1) // 2
    t2 = (k + 1) * (k + 2) // 2
    u = t1 + t2 - a - b
    if (t1 + t2 - a - b) % 2 == 0 and u > 0:
        u = u // 2
        if u <= t1 and u <= t2 and t1 - u == a and t2 - u == b:
            print(u)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc099/tasks/abc099_b

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


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

Submission status: Accepted

Solution code:
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
a,b = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()

def ans(n):
  an = 0
  for i in range(1,n+1):
    an += i
  return an

print(ans(b - a) - b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
X = [1]
for i in range(1, 999):
    X.append(X[i-1]+i+1)
diff = b - a
print(X[diff-1] - 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:
def main():
    a, b = map(int, input().split())
    x = b - a
    ans = x * (x+1) // 2 - b
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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