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: Runtime Error

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

Submission status: Runtime Error

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

def generate(n):
    if n == 1:
        return 1
    return generate(n-1) + n

print(generate(diff) - b)

Submission status: Runtime Error

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

def generate(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    return generate(n-1) + n

print(generate(diff) - b)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
def cumsum(n):
  if n==1:
    return 1
  elif n>1:
    return cumsum(n-1)+n
print(cumsum(b-a)-b)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
def cumsum(n):
  if n==1:
    return 1
  else:
    return cumsum(n-1)+n
print(cumsum(b-a)-b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def su(c):
  if c == 1:
    return 1
  else:
    return c + su(c - 1)

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

c = b - a

east = su(c)

print(east - b)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
l=[]
k=0
c=0
for i in range(999):
    k+=i
    l.append(k)

for j in range(999):
   c=a+j
   if(c in l):
       d=l.index(c)
       if(l[d+1]-j==b):
           print(j)
       else:
           continue
   else:
       continue

Submission status: Runtime Error

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

c = b - a 

def count(n):
  if n ==1:
    return 1
  else:
    return count(n-1)+n

print(count(c)-b)

Submission status: Runtime Error

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

a, b = map(int, input().split())
x = b - a
ans = f(x) - b

print(ans)

Submission status: Runtime Error

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

a, b = map(int, input().split())
x = b - a
ans = f(x) - b

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

y = b - a - 1
w_hight = 0

for i in range(1, y):
    w_hight += i

print(w_hight - a)

Submission status: Runtime Error

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


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

upper=int(sig(b-a))
print(upper-b)

Submission status: Runtime Error

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


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

upper=int(sig(b-a))
print(upper-b)

Submission status: Runtime Error

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

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

upper=int(sigx(b-a))
print(upper-b)

Submission status: Runtime Error

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

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

upper=int(sigx(b-a))
print(upper-b)

Submission status: Runtime Error

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

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

upper=sigx(b-a)
print(upper-b)

Submission status: Runtime Error

Solution code:
# coding:utf-8
a, b= map(int, input().split())

diff = b-a
d = 0
for i in enumerate(diff+1, 1):
    d += i 

print(abs(d-a)

Submission status: Runtime Error

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

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

        if (h - old_h) == (b - a):
            print(h - b)
            exit()

        old_h = h

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    h = b - a

    i, ans = 0
    while True:
        i += 1
        ans += i

        if h == i:
            break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

diff = b - a

def func(x):
    if x == 0:
        return 0
    else:
        return x + func(x - 1)
    
print(func(diff) - b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

A = [1]
for i in range(2,11):
    tmp = A[-1] + i
    A.append(tmp)

dif = b-a
pos = dif - 2

print(A[pos] - a)

Submission status: Runtime Error

Solution code:
package main

import (
    "fmt"
    "math/rand"
    "time"
)

func swap(data []float64, i,

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for s in range(c):
    sum += s+1

print(sum-b)

Submission status: Runtime Error

Solution code:
N = int(input())
print('ABC') if N / 999 <= 1 else print('ABD')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int m[555555];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sum=0;
    for(int i=1;i<1000;i++){
        sum+=i;
        m[sum]++;
    }
    int x,y;
    cin>>x>>y;
    for(int i=0;i<555555;i++){
        if(m[x+i]&&m[y+i]){
            cout<<i<<'\n';
            return 0;
        }
    }
    return 0;
}

Submission status: Runtime Error

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

def memorize(f):
	table = []
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

Submission status: Runtime Error

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

def memorize(f):
	table = {}
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
d = b - a
def s(n):
	if n == 1:
		return 1
	else:
		return s(n-1)+n
print(s(d)-b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
X = b - a 
s = int((X*(X+1))/2 - b)
print(s)

Submission status: Runtime Error

Solution code:

a,b = input()
X = b - a 
s = int((X*(X+1))/2 - b)
print(s)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    a,b = input()
    X = b - a 
    s = int((X*(X+1))/2 - b)
    print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l = int(input().split())

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

n = b - a

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

print(h-b)

Submission status: Runtime Error

Solution code:
def poll_height(n):
    if n:
        return n + poll_height(n - 1)
    else:
        return 0

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

difference_a_b = b - a 
print(poll_height(difference_a_b) - b)

Submission status: Runtime Error

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

n = np.zeros(999)
for i in range(1000):
    if i != 0:
        n[i-1] = i


def snowh(k, l):
    for i in range(1000):
        if l-k == n[i-1]:
            return n[i-2]*(n[i-2]+1)*0.5 - k
        
print(snowh(k, l))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
s=0
for i in range(1,999):
    s = s+i
    if a<s:
        break
print(s%a)

Submission status: Runtime Error

Solution code:
def prog(x):
    if x == 0:
        return 0
    elif x == 1:
        return 1
    else:
        return x + prog(x-1)

def ans(a, b):
    for i in range(1, 999):
        ansA = prog(i-1) - a
        ansB = prog(i) - b
        if ansA == ansB:
            return ansA

def main():    
    argStr = input()
    x = argStr.split(" ")
    argA = int(x[0])
    argB = int(x[1])
    print(ans(argA, argB))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()

max_n = 0

for i in range(1,n):
    x = set()
    y = set()
    for j in range(0,i):
        x.add(s[j])
    for j in range(i,n):
        y.add(s[j])

    if len(x|y) > max_n:
        max_n = len(x|y)

print(max_n)

Submission status: Runtime Error

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

# 解く
def solve(x):
    a,b=map(int,input().split())
    x=[]
    y=0
    high=0
    z=0
    u=0
    for i in range(1,1000):
        y+=i
        x.append(y)
    high = b-a
    z=high-1
    u=x[z]-b
    return u

# 全体
def main():
    x = readQuestion(a,b)
    answer = solve(x)
    print(answer)

# mainを呼び出す
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# 問題データを読み込む
def readQuestion(a,b):
    a,b=map(int,input().split())

# 解く
def solve(x):
    a,b=map(int,input().split())
    x=[]
    y=0
    high=0
    z=0
    u=0
    for i in range(1,1000):
        y+=i
        x.append(y)
    high = b-a
    z=high-1
    u=x[z]-b
    print(u)

# 全体
def main():
    x = readQuestion(a,b)
    answer = solve(x)
    print(answer)

# mainを呼び出す
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main2():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    sa = strbufs[1] - strbufs[0];
    takasa = sa * (sa + 1) / 2;
    result = takasa - strbufs[1];
    print(result);


if __name__ == '__main__':
    main2()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())

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

x = souwa - b

print(x)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
y=0
high=0
for i in range(1,1000):
    y+=i
    x.append(y)
for xz in x:
    if xz <= b:
        high=xz
        d=high-a
print(d)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
y=0
high=0
for i in range(1,1000):
    y+=i
    x.append(y)
for xz in x:
    if xz < b:
        high=xz
print(high-a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
print((b-a-1)*(b-a)//2-a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(b - a)
print(( c * (c - 1) //2 + c - b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

a=input()
a=int(a)
b=input()
b=int(b)


sum=0
for x in range(b-a+1):
    sum+=x
    
high=sum-b

print(high)

Submission status: Runtime Error

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

d = b - a

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

print(h-a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
a=input()
a=int(a)
b=input()
b=int(b)
x=0

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

high=x-a

print(high)

Submission status: Runtime Error

Solution code:

a=input()
b=input()
a=int(a)
b=int(b)
x=0
for x in range(1,b-a+1):
    x+=x

high=x-a

print(high)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(b - a)
d = c * (c -1) 
p = d // 2
e = int(c -1)
f = int(1 + p + e)
print(int(f - b))

Submission status: Runtime Error

Solution code:

a=input()
b=input()
a=int(a)
b=int(b)

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

high=x-a

print(high)

Submission status: Runtime Error

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

c = b - a

print(a - (c - 1))

Submission status: Runtime Error

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

h = 0
i = 0
while h < a and i < 1000:
    i += 1
    h += i

if i > 999
    print(h-b)
else:
    print(h-a)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(b - a)
d = c * (c -1) 
p = d / 2
e = int(c -1)
f = int(1 + p + e)
print(int(f - b))

Submission status: Runtime Error

Solution code:
N = int(input())
if (N < 1000):
    str(N)
    print("ABC" + N)
else:
    A = N - 999
    str(A)
    print("ABD" + A)

Submission status: Runtime Error

Solution code:
N = int,input().split())
if (N < 1000):
    print("ABC" + "N")
else:
    A = N - 999
    print("ABD" + "A")

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(b - a)
d = c * (c -1) / 2
e = int(c -1)
f = int(1 + d + e)
print(int(f - b))

Submission status: Runtime Error

Solution code:
N = int,input().split())
if (N < 1000):
    print("ABC" + N)
else:
    A = N - 999
    print("ABD" + A)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(min(ans))

Submission status: Runtime Error

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

print(min(ans))

Submission status: Runtime Error

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

print(max(ans))

Submission status: Runtime Error

Solution code:
tower = [0]

for i in range(1, 15):
    tower.append(tower[i-1]+i)
a, b = map(int, input().split())
t = tower[b - a]
print(t - b)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

length = b - a
count = length - 1

for j in range(length):
  a -= count
  print(a)
  if a =< 0:
    print(1 - a)
    break
  else:
    count -= 1
    print(count)

Submission status: Runtime Error

Solution code:
def summation(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return n + summation(n-1)


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)
    
    return 0

    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

def height(n):
    if n==1:
        return 1
    else:
        return n+height(n-1)
    
d = height(b-a)
print(d-b)

Submission status: Runtime Error

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

ls = [0]*999
for i in range(999):
    ls[i] = int(i*(i+1)/2)

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

Submission status: Runtime Error

Solution code:
from sys import stdin
from itertools import accumulate


def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    c = list(accumulate(range(1, 1000)))
    for i in range(len(c) - 1):
        if (c[i + 1] - c[i]) == (b - a):
            print(f'{c[i] - a}')
            return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
if int(input()) < 1000:
    print('ABC')
else:
    print('ABD')

Submission status: Runtime Error

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


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


h = get_height(b - a)

print(i - b)

Submission status: Runtime Error

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


def main():
    a,b = map(int, input().split())
    
    n_plus1 = b-a
    
    ans = summation(n_plus1) - b
    
    print(ans)

    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

N=int(input())

if N>=1000:
    print("ABD")
else:
    print("ABC")

Submission status: Runtime Error

Solution code:
x,y = map(int,input( ))
z = y-x
t = 0
for s in range(z+1):
    t += s
    
print(t-y)