Cloud Party

3.2

12 votes
Very-Easy
Problem

Badal Soni is organizing his marriage party in which N number of people are invited and only K people joined the party.

Note: Badal is also present in the party!

K <= N

In the party everyone starts shaking hands with everyone else. Given, any two persons shake hand exactly once.

Can you tell the total number of handshakes ?

Input Format

The first line contains the number of test-cases T, T lines follow.

Each line then contains integer N (the total number of invites sent by Raman) and space separated integer K (the total number of people joined the party)

Output Format

Print the number of handshakes for each test-case in a new line

Constraints

1 <= T <= 1000

0 < K <= N < 106

Time Limit: 3
Memory Limit: 1
Source Limit:
Explanation

Case 1 : Only one person comes to the party. That is one handshake.

Case 2 : Two people come to the party. Therefore total handshakes equals 3

Editor Image

?