shil-aditya-and-utkarsh

Shil, Aditya and Utkarsh go to a candy shop. There are N candies present in the shop, which are indexed from 1 to N. All three of them select one candy to eat.

However, a candy tastes delicious if and only if, the index of candy chosen by Shil is strictly less than the index of candy chosen by Aditya and the index of candy chosen by Aditya is strictly greater than index of candy chosen by Utkarsh. 

To state in simple Mathematical terms, if Shil chooses i^th candy, Aditya chooses j^th candy and Utkarsh chooses k^th candy, then the candies would taste delicious 
if and only if i < j and j > k.
You have to find the total number of ways in which they can choose candies such that the candies would taste delicious to them. Note that all of them choose distinct number of candies i.e.,  i!=j and j!=k and i!=k.

Input format:
The only line of input consists of a single integer N denoting the total number of candies.   

Output format:
Find the total number of ways by which all three can choose candies such that the candies would taste delicious to them.  

Constraints:
3 ≤ N ≤ 1000

SAMPLE INPUT
4

SAMPLE OUTPUT
8

Explanation

All the possible ways to choose candies are:  
[1,3,2]  
[2,3,1]  
[2,4,3]  
[3,4,2]  
[1,4,3]  
[3,4,1]  
[2,4,1]  
[1,4,2]  

The first integer in all the tuples denotes index of candy chosen by Shil, the second integer denotes index of candy chosen by Aditya and the third integer denotes index of candy chosen by Utkarsh.

Source: hackerearth | Difficulty: EASY
Tags: Mathematics


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n=eval(input());
ans=n*(n-1)*(n-2)/3
print(ans)


n=int(input())
c=0
while(n>2):
	c+=(n-1)*(n-2)
	n-=1
print(c)
	


n=eval(input())
t=0
temp=n
for i in range(n-1):
	t=t+(temp-1)*(temp-2)
	temp-=1
print(t)


n=eval(input())
s=0
for k in range(3,n+1):
	s+=(k-1)*(k-2)
print(s)	


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
N=eval(input())
sum=0
for i in range(3,N+1):
	a=math.factorial(i-1)
	b=math.factorial(i-3)
	sum+=a/b
print(sum)
	
	


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(input());
ans = 0;
for i in range(3,n+1):
	ans+= (i-1)*(i-2);
print(ans);


n=eval(input())
print((n*(n-1)*(n-2))/3)


import math
n=eval(input())

inc=4
res=0
a=[2]
for i in range(1,998):
	a.append(a[i-1]+inc)
	inc+=2
for i in range(n-2):
	res+=a[i]
print(res)


from math import factorial
def C(m,n):
	return factorial(m)/(factorial(m-n)*factorial(n))
def x(n):
	return sum(C(i,2) for i in range(2,n))
a=int(input())
print(x(a)*2)


n=int(input())
print(n*(n-1)*(n-2)/3)


import math

n = int(input())
result = 0
for i in range(3,n+1):
	
	K=(i-1)*(i-2)
	result+=K
	
print(result)


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
N=eval(input())
sum=0
for i in range(3,N+1):
	a=math.factorial(i-1)
	b=math.factorial(i-3)
	sum+=a/b
print(sum)