Problem:


Score : 100 points

Problem Statement

We have N+M balls, each of which has an integer written on it.

It is known that:  

The numbers written on N of the balls are even.

The numbers written on M of the balls are odd.

Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.

It can be shown that this count does not depend on the actual values written on the balls.

Constraints

0 \leq N,M \leq 100

2 \leq N+M

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the answer.

Sample Input 1

2 1

Sample Output 1

1

For example, let us assume that the numbers written on the three balls are 1,2,4.

If we choose the two balls with 1 and 2, the sum is odd;

If we choose the two balls with 1 and 4, the sum is odd;

If we choose the two balls with 2 and 4, the sum is even.

Thus, the answer is 1.

Sample Input 2

4 3

Sample Output 2

9

Sample Input 3

1 1

Sample Output 3

0

Sample Input 4

13 3

Sample Output 4

81

Sample Input 5

0 3

Sample Output 5

3



Sample input:
2 1


Sample output:
1

Submission status: Runtime Error

Solution code:
from math import *
  
# Function to find the nCr 
def printNcR(n, r): 
  
    # p holds the value of n*(n-1)*(n-2)..., 
    # k holds the value of r*(r-1)... 
    p = 1
    k = 1
  
    # C(n, r) == C(n, n-r), 
    # choosing the smaller value 
    if (n - r < r): 
        r = n - r 
  
    if (r != 0):  
        while (r): 
            p *= n 
            k *= r 
  
            # gcd of p, k 
            m = gcd(p, k) 
  
            # dividing by gcd, to simplify product 
            # division by their gcd saves from the overflow 
            p //= m 
            k //= m 
  
            n -= 1
            r -= 1
  
        # k should be simplified to 1 
        # as C(n, r) is a natural number 
        # (denominator should be 1 )  
  
    else: 
        p = 1
  
    # if our approach is correct p = ans and k =1 
    return p



n , m  = map(int , input().split())

if n == 1:
	ans1 = 0
else:
	ans1 = printNcR(n,2)
if m == 1:
	ans2 = 0
else:
	ans2 = printNcR(m,2)
print(ans1+ans2)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())

from scipy.special import comb
# a = comb(n, r)
a = comb(N+M, 2, exact=True)
print(a-N*M)

Submission status: Runtime Error

Solution code:
import math
N,M = (int(x) for x in input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = combinations_count(N, 2) + combinations_count(M, 2)
print(a)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

n, m = map(int, input().split())

print(comb(n, 2, exact=True) + comb(m, 2, exact=True))

Submission status: Runtime Error

Solution code:
# 200322 A

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N,M = list(map(int,input().split()))

print(cmb(N,2)+cmb(M,2))

Submission status: Runtime Error

Solution code:
#n = int(input())
n,m = map(int,input().split())
#a_L = list(map(int,input().split()))

nCr = {}


def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if n != 1:
    a = cmb(n,2)
else:
    a = 0

if m != 1:
    b = cmb(m,2)
else:
    b = 0
print(a + b)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
  return 0;
}

Submission status: Runtime Error

Solution code:
from math import factorial as f
x,y=map(int,input().split())
a=f(x)//(f(x-2)*2)
b=f(y)//(f(y-2)*2)
print(a+b)

Submission status: Runtime Error

Solution code:
import math
N,M = list(map(int, input().split()))


def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N,2)+combinations_count(M,2))

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
N,M = map(int,input().split())
nCr = {}
def cmb(n, r):
    if r == 0 or r == n:
         return 1
    if r == 1:
         return n
    if (n,r) in nCr:
         return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2)
b = cmb(M,2)
print(a+b)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

N,M = map(int, input().split())

print(comb(M, 2, exact=True) + comb(N, 2, exact=True))

Submission status: Runtime Error

Solution code:
f=[1]
for i in range(1,100):
    f.append(i*f[i-1])

n,m=map(int,input().split())
sum=0
if m>=2:
    sum+=(f[m]//(f[2]*f[m-2]))
if n>=2:
    sum+=(f[n]//(f[n-2]*f[2]))
print(sum)

Submission status: Runtime Error

Solution code:
def main():
    line = input().strip()
    n, m = [int(v) for line.split(' ')]

    ans_n = n * (n - 1) if n > 1 else 0
    ans_m = m * (m - 1) if m > 1 else 0
    ans = ans_n + ans_m
    return ans


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from scipy.special import comb
a = list(map(int,input().split()))

print(comb(a[0], 2, exact=True) + comb(a[1], 2, exact=True))

Submission status: Runtime Error

Solution code:
A,B=map(int, input().split())
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))

Submission status: Runtime Error

Solution code:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int,input().split())

print(comb(n, 2) + comb(m, 2))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N,2)+combinations_count(M,2))

Submission status: Runtime Error

Solution code:
import sys
from math import ceil, floor, comb
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n,m = map(int, input().split())
    print((comb(n,2)) + (comb(m,2)))
    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import math
import collections
from collections import deque
#n = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#x = list(map(int, sys.stdin.readline().split()))

a = math.factorial(n) // (math.factorial(n - 2) * 2)
b = math.factorial(m) // (math.factorial(m - 2) * 2)

print(a+b)

Submission status: Runtime Error

Solution code:
n,m = (int(x) for x in inpit().split())
N = n *(n -1) /2
M = m *(m-1) / 2
print(N+M)

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
from scipy.special import comb
base = comb(N, 2, exact=True)
base2 = comb(M, 2, exact=True)
print(base + base2)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())

from scipy.special import comb
base = comb(N, 2, exact=True)
base2 = comb(M, 2, exact=True)
print(base+base2)

Submission status: Runtime Error

Solution code:
x,y = map(int,input().split())	

# even + even 
ans = x*(x – 1) / 2

# odd + odd
ans += y*(y-1) / 2

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
print(N * (N - 1) // 2 + M * (M + 1) // 2)

Submission status: Runtime Error

Solution code:
lst = input()
n = int(lst[0])
m = int(lst[1])
print((n*(n-1)+m*(m-1))//2)

Submission status: Runtime Error

Solution code:
n,m=int(input().split())
if n<=1:
    n=0
if m<=1:
    m=0
print((n*(n-1)//2)+(m*(m-1)//2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    FIO
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2;

    return 0;
}

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

ans = N*(N-1)/2 + M(M-1)/2

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

n,m = map(int,input().split())
import math
def c(n,k):
    return math.factorial(n)//math.factorial(k)//math.factorial(n-k)

print(c(n,2) + c(m,2))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;



int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    ans += n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans;

}