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 in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection.Emit;
using System.Runtime.Remoting.Proxies;
using System.Text;
using static System.Console;
using static System.Math;
using static Ex;
class Simple {
    private int a, b;
    void Solve() {
        io.i(out a, out b);
        const int size = 999;
        var T = new int[size];
        T[0] = 1;
        FOR(1, size, i => T[i] = T[i - 1] + (i + 1));
        var diff = b - a;
        var orig = T[diff - 1];
        var ans = orig - b;
        io.o(ans);
    }
    void Test() {
        //
    }
    public static void Main(string[] args) => new Simple().Stream();
    IO io = new IO();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        //Test();
        io.Flush();
    }
}
class IO {
    #region INPUT
    private const int Size = 1 << 12;
    private readonly Stream _stream = OpenStandardInput();
    private readonly byte[] _buffer = new byte[Size];
    private int _ptr = 0, _buffLen = 0;
    private bool HasNextByte() {
        if(_ptr < _buffLen)
            return true;
        _ptr = 0;
        _buffLen = _stream.Read(_buffer, 0, Size);
        return _buffLen > 0;
    }
    private byte ReadByte() {
        if(HasNextByte())
            return _buffer[_ptr++];
        else
            throw new EndOfStreamException();
    }
    private bool IsAscii(int c) => '!' <= c && c <= '~';
    private char NextChar() {
        byte b = 0;
        do
            b = ReadByte(); while(!IsAscii(b));
        return (char)b;
    }
    private string Next() {
        var sb = new StringBuilder();
        for(var b = NextChar(); IsAscii(b); b = (char)ReadByte())
            sb.Append(b);
        return sb.ToString();
    }
    private void Read <T>(out T v) => v = SuitType <T>(Next());
    private T ConvertType <T, TU>(TU v) => (T)Convert.ChangeType(v, typeof(T));
    private bool TypeEqual <T, TU>() => typeof(T) == typeof(TU);
    private T SuitType <T>(string s) {
        if(TypeEqual <T, int>())
            ConvertType <T, int>(int.Parse(s));
        if(TypeEqual <T, long>())
            ConvertType <T, long>(long.Parse(s));
        if(TypeEqual <T, double>())
            ConvertType <T, double>(double.Parse(s));
        if(TypeEqual <T, char>())
            ConvertType <T, char>(char.Parse(s));
        return ConvertType <T, string>(s);
    }
    private T i <T>() => SuitType <T>(String);
    public string String => Next();
    public char Char => NextChar();
    public int Int => int.Parse(Next());
    public long Long => long.Parse(Next());
    public double Double => double.Parse(Next());
    public void i <T>(out T v) => Read(out v);
    public void i <T, TU>(out T t, out TU u) {
        i(out t);
        i(out u);
    }
    public void i <T, TU, TV>(out T t, out TU u, out TV v) {
        i(out t, out u);
        i(out v);
    }
    public void i <T, TU, TV, TW>(out T t, out TU u, out TV v, out TW w) {
        i(out t, out u, out v);
        i(out w);
    }
    public void i <T, TU, TV, TW, TX>(out T t, out TU u, out TV v, out TW w, out TX x) {
        i(out t, out u, out v, out w);
        i(out x);
    }
    public void ini <T>(out T[] a, int n) {
        a = new T[n];
        for(int i = 0; i < n; ++i)
            a[i] = i <T>();
    }
    public void ini <T, TU>(out T[] a, out TU[] b, int n) {
        a = new T[n];
        b = new TU[n];
        for(int i = 0; i < n; ++i) {
            a[i] = i <T>();
            b[i] = i <TU>();
        }
    }
    public void ini <T, TU, TV>(out T[] a, out TU[] b, out TV[] c, int n) {
        a = new T[n];
        b = new TU[n];
        c = new TV[n];
        for(int i = 0; i < n; ++i) {
            a[i] = i <T>();
            b[i] = i <TU>();
            c[i] = i <TV>();
        }
    }
    public void ini <T>(out T[,] a, int h, int w) {
        a = new T[h, w];
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
                a[i, j] = i <T>();
    }
    #endregion
    #region OUTPUT
    private readonly StreamWriter _sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public void Flush() => Console.Out.Flush();
    public void o(params Object[] xs) => Print(false, xs);
    public void ol(params Object[] xs) => Print(true, xs);
    private void Print(bool isOneLine, params Object[] xs) {
        foreach(var x in xs) {
            if(x is int[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <int[], object>(x));
                else
                    Array.ForEach(ConvertType <int[], object>(x), WriteLine);
                continue;
            }
            if(x is long[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <long[], object>(x));
                else
                    Array.ForEach(ConvertType <long[], object>(x), WriteLine);
                continue;
            }
            if(x is double[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <double[], object>(x));
                else
                    Array.ForEach(ConvertType <double[], object>(x), WriteLine);
                continue;
            }
            if(x is char[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <char[], object>(x));
                else
                    Array.ForEach(ConvertType <char[], object>(x), WriteLine);
                continue;
            }
            if(x is string[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <string[], object>(x));
                else
                    Array.ForEach(ConvertType <string[], object>(x), WriteLine);
                continue;
            }
            if(x is bool[]) {
                if(isOneLine)
                    PrintArr1D(ConvertType <bool[], object>(x));
                else
                    Array.ForEach(ConvertType <bool[], object>(x), WriteLine);
                continue;
            }
            if(x is int[,]) {
                PrintArr2D(ConvertType <int[,], object>(x));
                continue;
            }
            if(x is long[,]) {
                PrintArr2D(ConvertType <long[,], object>(x));
                continue;
            }
            if(x is double[,]) {
                PrintArr2D(ConvertType <double[,], object>(x));
                continue;
            }
            if(x is char[,]) {
                PrintArr2D(ConvertType <char[,], object>(x));
                continue;
            }
            if(x is string[,]) {
                PrintArr2D(ConvertType <string[,], object>(x));
                continue;
            }
            if(x is bool[,]) {
                PrintArr2D(ConvertType <bool[,], object>(x));
                continue;
            }
            if(x is int[][]) {
                PrintJagArr(ConvertType <int[][], object>(x));
                continue;
            }
            if(x is long[][]) {
                PrintJagArr(ConvertType <long[][], object>(x));
                continue;
            }
            if(x is double[][]) {
                PrintJagArr(ConvertType <double[][], object>(x));
                continue;
            }
            if(x is char[][]) {
                PrintJagArr(ConvertType <char[][], object>(x));
                continue;
            }
            if(x is string[][]) {
                PrintJagArr(ConvertType <string[][], object>(x));
                continue;
            }
            if(x is bool[][]) {
                PrintJagArr(ConvertType <bool[][], object>(x));
                continue;
            }
            WriteLine(x); // int, long, double ...
        }
    }
    private void PrintArr2D <T>(T[,] a) {
        int a0 = a.GetLength(0), a1 = a.GetLength(1);
        for(int i = 0; i < a0; ++i) {
            for(int j = 0; j < a1 - 1; ++j)
                Write(a[i, j] + " ");
            WriteLine(a[i, a1 - 1]);
        }
    }
    private void PrintJagArr <T>(T[][] a) {
        for(int i = 0; i < a.Length; ++i) {
            var l = a[i].Length;
            for(int j = 0; j < l - 1; ++j)
                Write(a[i][j] + " ");
            WriteLine(a[i][l - 1]);
        }
    }
    private void PrintArr1D <T>(T[] a) => WriteLine(string.Join(" ", a));
    public void YN(bool f) => WriteLine(f ? "YES" : "NO");
    public void Yn(bool f) => WriteLine(f ? "Yes" : "No");
    public void yn(bool f) => WriteLine(f ? "yes" : "no");
    #endregion
    public IO() { SetOut(_sw); }
}
static class Ex {
    public static void REP(int a, Action <int> act) => FOR(0, a, act);
    public static void FOR(int a, int b, Action <int> act) {
        for(int i = a; i < b; ++i)
            act(i);
    }
    public static void REPEQ(int a, Action <int> act) => FOR(0, a + 1, act);
    public static void FOREQ(int a, int b, Action <int> act) => FOR(a, b + 1, act);
    public static T MIN <T>(params T[] a) => a.Min();
    public static T MAX <T>(params T[] a) => a.Max();
}
static class NumEx {
    public static string toString(this double d) => d.ToString("R");
    public static string Pad0 <T>(this T s, int n) => s.ToString().PadLeft(n, '0');
    public static int RoundOff(this double v, int n)
        => (int)Math.Round(v, n - 1, MidpointRounding.AwayFromZero);
    public static int RoundUp(this double v) => (int)Math.Ceiling(v);
    public static int RoundDown(this double v) => (int)Math.Floor(v);
    public static bool Odd(this int v) => (v & 1) != 0;
    public static bool Odd(this long v) => (v & 1) != 0;
}
static class ArrayEx {
    public static int MEAN(this int[] a) => (int)a.Aggregate(0L, (acc, x) => acc + x) / a.Length;
    public static long MEAN(this long[] a) => a.Sum() / a.Length;
    public static double MEAN(this double[] a) => a.Sum() / a.Length;
}