range-sum-2

You are given an two integers i and j such that i ≤ j.
Task is to find the sum of all integers from i to j (both inclusive).  

For example:
i = 3
j = 5
then sum from i to j will be 3+4+5 = 12  

Input:
Single line containing two space separated integers i and j.  

Output:
Print out the sum of integers from i to j (both inclusive).  

Constraints:
0 ≤ i ≤ 1000000000000000000 (10^18)
0 ≤ j ≤ 1000000000000000000 (10^18)
i ≤ j
Absolute difference between i and j can be upto 1000000000000000000 
i.e. |j-i| ≤ 1000000000000000000 (10^18)

Subtask 1: (50 points)
0 ≤ i ≤ 1000000
0 ≤ j ≤ 1000000
i ≤ j
Absolute difference between i and j can be upto 1000000 
i.e. |j-i| ≤ 1000000

Subtask 2: (50 points)
Original Constraints  

Hint:
Use mathematics instead of loop to find sum.
Use BigInteger class of Java for large number multiplication.

SAMPLE INPUT
99 1000000000000

SAMPLE OUTPUT
500000000000499999995149

Source: hackerearth | Difficulty: EASY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
i,j=input().split(" ")
i,j=int(i),int(j)
print(((j+i)*(j-i+1))/2)


import sys

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

for line in sys.stdin:
	nums = [int(n) for n in line.split()]
	sys.stdout.write(str((s(nums[1]) - s(nums[0])) + nums[0]))


def rangesum(s):
	a,b=list(map(int,s.split()))
	len=b-a+1
	s=(a+(b,b-1)[len%2])*int(len/2)+(0,b)[len%2]
	return s
print(rangesum(input()))


from sys import stdin, stdout

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

for line in stdin:
	nums = [int(n) for n in line.split()]
	stdout.write(str((s(nums[1]) - s(nums[0])) + nums[0]))


i,j = list(map(int,input().split()))
print(((j*(j+1))/2) - ((i*(i-1))/2))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
i,j=input().split(" ")
i,j=int(i),int(j)
p=(j*(j+1))/2
q=(i*(i-1))/2
print(p-q)


# Read input from stdin and provide input before running code

i,j = input().split()
i=int(i)
j=int(j)
n=j-i+1
ans = n*(i+j)/2
print((int(ans)))