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: Accepted

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

even = (N*(N-1))/2
odd = (M*(M-1))/2

print(int(even+odd))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
ans = int(N*(N-1)/2 + M*(M-1)/2)
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
a = N * (N - 1) / 2 + M * (M - 1) / 2
print(int(a))

Submission status: Accepted

Solution code:
import itertools
import math

N,M=map(int,input().split())
if N==M==1 or N==M==0:
  print(0)
  exit()
if N==0:
  even=0
  odd=math.factorial(M)/(math.factorial(M-2)*2)
  print(int(odd+even))
  exit()
if M==0:
  odd=0
  even=math.factorial(N)/(math.factorial(N-2)*2)
  print(int(odd+even))
  exit()
if N==1 or M==1:
  even=math.factorial(N)/2
  odd=math.factorial(M)/2
  print(int(odd+even))
  exit()

even=math.factorial(N)/(math.factorial(N-2)*2)
odd=math.factorial(M)/(math.factorial(M-2)*2)
print(int(odd+even))

Submission status: Accepted

Solution code:
# 2020/03/22
# AtCoder Beginner Contest 159 - A

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

# Calc
ans = (n * (n - 1)) // 2 + (m * (m - 1)) // 2

# Output
print(ans)

Submission status: Accepted

Solution code:
odd, even = map(int, input().split())
sum_odd = 0
sum_even = 0

if odd != 1:
	for i in range(1, odd):
  		sum_odd += i
else: 
  sum_odd = 0

if even != 1:
  for i in range(1, even):
  	sum_even += i
else:
  sum_even = 0
  
print(sum_odd + sum_even)

Submission status: Accepted

Solution code:
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 = [int(i) for i in input().split()]

if N >= 2 and M >= 2:
    ans = cmb(N,2) + cmb(M,2)
elif N <= 1 and M >=2:
    ans = cmb(M,2)
elif M <= 1 and N >=2:
    ans = cmb(N,2)
else:
    ans = 0


print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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())
count = 0
if N <= 1:
    a = 0
else:
    a = comb(N,2)

if M <= 1:
    b = 0
else:
    b = comb(M,2)
print(a+b)

Submission status: Accepted

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

print(int(n * (n-1) / 2 + m * (m - 1) / 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
N=i[0]
M=i[1]
NN=N*(N-1)//2
MM=M*(M-1)//2
print(NN+MM)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
even=(N*(N-1))/2
odd=(M*(M-1))/2
print(int(even)+int(odd))

Submission status: Accepted

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

ans = (n * (n -1) + m * (m-1))/2
print(int(ans))

Submission status: Accepted

Solution code:
nCr = {}
def cmb(n, r):
    if n == 0: return 0
    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)]
s = input().split()
print(cmb(int(s[0]),2) + cmb(int(s[1]),2))

Submission status: Accepted

Solution code:
def combination(n, x, mod=10**9+7):
    # nCx, a=n!, b=x!, c=(n-x)!
    # ex) combination(5, 2) = 10
    _factorial = [1] * (n+1)
    tmp = 1
    for i in range(1, n+1):
        tmp = (tmp * i) % mod
        _factorial[i] = tmp

    tmp = _factorial[n]
    tmp = (tmp * pow(_factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(_factorial[n-x], mod-2, mod)) % mod
    return tmp

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

if m > 1 and n > 1:
    M = combination(m, 2)
    N = combination(n, 2)
elif m <= 1 and n > 1:
    M = 0
    N = combination(n,2)
elif m > 1 and n <= 1:
    M = combination(m, 2)
    N = 0
else:
    M, N = 0, 0

print(M+N)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())

x=a*(a-1)/2
y=b*(b-1)/2

ans=x+y

print(int(ans))

Submission status: Accepted

Solution code:
import  math

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

def ans(a):
    if a<2:
        return 0
    else:
        return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

print(int(ans(n) + ans(m)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, m = [int(s) for s in input().strip().split()]
    result = n * (n - 1) // 2 + m * (m - 1) // 2
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
res = 0
if M<2:
    res = N*(N-1)/2
elif N<2:
    res = M*(M-1)/2
else:
    res = N*(N-1)/2 + M*(M-1)/2
print(int(res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().strip().split(" ")]

import math

def c(n, r):
    if n <= 1:
        return 0
    return int(math.factorial(n) / (math.factorial(r) * math.factorial(n - r)))

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

Submission status: Accepted

Solution code:
import bisect, collections
 
 
 
def solution():
    n, m = [int(x) for x in input().strip().split(" ")]
    print(n*(n-1)//2+m*(m-1)//2)
                

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

nums = list(map(int, input().split()))
n = nums[0] #偶数
m = nums[1] #奇数

if n == 0:
    print(int(m*(m-1) / 2))
elif m == 0:
    print(int(n*(n-1) / 2))

elif n == 1 and m == 1:
    print(0)
else:
    result = m*(m-1) / 2 + n*(n-1) / 2
    print(int(result))

Submission status: Accepted

Solution code:
a,b=map(int,input().split(" "))

odd=a*(a-1)/2
even=b*(b-1)/2

print(int(odd+even))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
even, odd = map(int, input().split())

even_r = 0
odd_r = 0

for i in range(even):
  for j in range(even - i - 1):
    even_r += 1
  
for i in range(odd):
  for j in range(odd - i - 1):
  	odd_r += 1

total = even_r + odd_r

print(total)

Submission status: Accepted

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

if N<=1:
  print(math.floor(M*(M-1)/2))
elif M<=1:
  print(math.floor(N*(N-1)/2))
else: 
  print(math.floor((N*(N-1)/2)+(M*(M-1)/2)))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = 0
d = 0
for i in range(n):
  c += i
for j in range(m):
  d += j
ans = c + d
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
import math
def comb(n, r):
    if (n-r) >= 0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0
base = comb(N,2)
base2 = comb(M,2)
print(base+base2)

Submission status: Accepted

Solution code:
i_data = input().split()
n = int(i_data[0])
m = int(i_data[1])

def kekka_hantei(i_n):
  if i_n<=1:
    return 0
  else:
    r  = 0
    for i in range(1,i_n):
      r +=i
  return r

print(kekka_hantei(n) + kekka_hantei(m))

Submission status: Accepted

Solution code:
import math

x, y = map(int, input().split(' '))
r = 0
x_comb = 0
y_comb = 0

if x <= 1:
    pass
else:
    x_comb = math.factorial(x)//(2 * math.factorial(x-2))

if y <= 1:
    pass
else:
    y_comb = math.factorial(y)//(2 * math.factorial(y-2))

print(x_comb+y_comb)

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())
if m >= 2 and n >= 2:
    s = math.factorial(n)/(math.factorial(2)*math.factorial(n-2)) + math.factorial(m)/(math.factorial(2)*math.factorial(m-2))
elif m >= 2 and n < 2:
    s = math.factorial(m)/(math.factorial(2)*math.factorial(m-2))
elif m < 2 and n >= 2:
    s = math.factorial(n)/(math.factorial(2)*math.factorial(n-2))
else:
    s = 0
print(round(s))

Submission status: Accepted

Solution code:
import sys
import math
N,M = map(int, sys.stdin.readline().strip().split())
def combinations(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
if (N > 1):
    count_even = combinations(N, 2)
else:
    count_even = 0
if (M > 1):
    count_odd = combinations(M, 2)
else:
    count_odd = 0
print(count_even + count_odd)

Submission status: Accepted

Solution code:
from math import factorial
N ,M = [int(x) for x in input().split()]

sumodd = 0
sumeven = 0

if N == 0 or N == 1:
    sumeven = 0
else: 
    sumeven = factorial(N) // factorial(2) // factorial(N-2)
if M == 0 or M == 1:
    sumodd = 0
else: 
    sumodd = factorial(M) // factorial(2) // factorial(M-2)
print(sumeven + sumodd)

Submission status: Accepted

Solution code:
from math import factorial
def cmb(n,r):
  if n == 0 or n == 1:
    return 0
  return factorial(n) / factorial(r) / factorial(n - r)
a,b = map(int,input().split())
print(int(cmb(a,2)+cmb(b,2)))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
mod = 92709568269121

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

mod = 10**9+7
def factrial(N):
    fc = [1, 1] + [None] * N
    inv = [0, 1] + [None] * N
    fcInv = [1, 1] + [None] * N
    for i in range(2, N+1):
        fc[i] = i*fc[i-1]%mod
        inv[i] = mod-(inv[mod%i]*(mod//i))%mod
        fcInv[i] = fcInv[i-1]*inv[i]%mod
    return fc, fcInv
fc, fcInv = factrial(1000)

def modCom(n, k):
    return 0 if n < k else fc[n] * fcInv[k] * fcInv[n-k] % mod

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

Submission status: Accepted

Solution code:
import math
m,n=map(int,input().split())
dm,dn=0,0
if m>=2:
    dm = math.factorial(m)//math.factorial(m-2)
if n>=2:
    dn = math.factorial(n)//math.factorial(n-2)
print((dm+dn)//2)

Submission status: Accepted

Solution code:
from scipy.misc import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))

Submission status: Accepted

Solution code:
import itertools


def resolve():
    N, M = map(int, input().split())
    ans = 0

    if N > 1:
        ans = len(
            list(itertools.combinations(list(range(N)), 2))
        )
    if M > 1:
        ans += len(
            list(itertools.combinations(list(range(M)), 2))
        )

    print(ans)

resolve()

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
print(int((N * (N-1) / 2) + (M * (M-1)/2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = (N*(N-1))//2 + (M*(M-1))//2
print(ans)

Submission status: Accepted

Solution code:
IN=input()
M=int(IN.split(" ")[0])
N=int(IN.split(" ")[1])

count=0

if M >= 2:
    x=M*(M-1)
    count=x/2

if N >= 2:
    x=N*(N-1)
    count=x/2 + count

print(int(count))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=0
if n>1:
    for i in range(n-1):
        ans+=n-i-1
if m>1:
    for j in range(m-1):
        ans+=m-j-1
print(ans)

Submission status: Accepted

Solution code:
def fac(n):
    result = 1
    for i in range(n):
        result = result * (i + 1)
    return result

def cmb(n, r):
    return fac(n) // (fac(r) * fac(n - r))

data = input().split()
n = int(data[0])
m = int(data[1])

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

Submission status: Accepted

Solution code:
N,M=map(int, input().split()) 
if M == 1 or M==0:
    answer = N * (N-1)//2
elif N == 1 or N==0:
    answer = M * (M-1)//2    
else:
    answer = (N * (N-1))//2 + (M * (M-1))//2
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

binomials = [0, 0, 1]
for i in range(3, 101):
    binomials.append(binomials[-1] * i // (i - 2))

ans = binomials[N] + binomials[M]

print(ans)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 0
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 0
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(int(a1() + b1()))

Submission status: Accepted

Solution code:
from math import factorial
def combination(n, r):
    if n>=r:
        return int( factorial(n)//(factorial(n-r)*factorial(r)) )
    else:
        return 0

N, M = list(map(int, input().split()))
print(combination(N, 2) + combination(M, 2))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
frac = [1]
p = 10**9 + 7
for i in range(max(n, m)):
    frac.append(frac[i]*(i+1)%p)

#フェルマーの小定理を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
if n >= 2:
  a = comb(n, 2, p)
else:
  a = 0
if m >= 2:
  b = comb(m, 2, p)
else:
  b = 0
print(a + b)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
def combination_formula(n, r):
    """nCrは、O(min(n-r, r))で実装する
    Notes:
        分子と分母がかなり大きな値になった場合、計算は遅くなるので注意
        求める値がmodをとった値でいい場合、フェルマーの小定理を使った方法が速い。
    """
    if r > n:
        return 0

    r = min(n-r, r)
    bunsi, bunbo = 1, 1
    for i in range(r):
        bunsi = bunsi*(n-i)
        bunbo = bunbo*(i+1)
    return bunsi//bunbo


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

    # 奇数＋奇数 または偶数＋偶数
    ans = combination_formula(N, 2) + combination_formula(M,2)
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
out = 0
if N >= 2:
    out += N * (N - 1) / 2
if M >= 2:
    out += M * (M - 1) / 2
print(int(out))

Submission status: Accepted

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

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

Submission status: Accepted

Solution code:
import math
N, M= list(map(int, input().split()))
'''
# 組み合わせ計算
print(math.factorial(N)//math.factorial(N-2)//2)
print(math.factorial(M)//math.factorial(max(M-2, 1))//2)
'''
num = math.factorial(N)//math.factorial(max(N-2, 1))//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2
print(num)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = 0
for i in range(n):
    for j in range(i+1,n):
        ans += 1
for i in range(m):
    for j in range(i+1,m):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = n * (n - 1) // 2
b = m * (m - 1) // 2

print(a + b)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if N==0:
    print(M*(M-1)//2)
elif M==0:
    print(N*(N-1)//2)
else:
    print(N*(N-1)//2+M*(M-1)//2)

Submission status: Accepted

Solution code:
from math import factorial

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

ans = 0
if n > 1:
    ans += factorial(n) / factorial(2) / factorial(n - 2)
if m > 1:
    ans += factorial(m) / factorial(2) / factorial(m - 2)

print(int(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
n_l = [i for i in range(0,n*2,2)]
m_l = [i for i in range(1,m*2,2)]
hoge = n_l + m_l
count = 0
for i in hoge:
    for j in hoge:
        if (i!=j)&((i+j)%2==0):
            count+=1
print(int(count/2))

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
print(int((N * (N - 1) / 2) + (M * (M - 1) / 2)))

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = [int(i) for i in input().split()]
if (s[0] == 0 or s[0] == 1):
  s0 = 0
else:
  s0 = s[0]*(s[0]-1)/2
if (s[1] == 0 or s[1]==1):
  s1 = 0
else:
  s1 = s[1]*(s[1]-1)/2

print(int(s0+s1))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
a,b=map(int,input().split())
if a>3:
    a_v=math.factorial(a)//math.factorial(a-2)//math.factorial(2)
elif a==3:
    a_v=2
elif a==2:
    a_v=1
else:
    a_v=0
if b>3:
    b_v=math.factorial(b)//math.factorial(b-2)//math.factorial(2)
elif b==3:
    b_v=3
elif b==2:
    b_v=1
else:
    b_v=0
print(a_v+b_v)

Submission status: Accepted

Solution code:
# coding:utf-8
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    n,m = map(int, input().split())
    diff = m * n
    print(int(combinations_count(n+m, 2)) - diff )

if __name__ == '__main__' :
    main()

Submission status: Accepted

Solution code:
import itertools

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

S = 0
S += len(list(itertools.combinations(range(N), 2)))

if M > 1:
    S += len(list(itertools.combinations(range(M), 2)))

print(S)

Submission status: Accepted

Solution code:
N,M=[int(i) for i in input().split()]
print(N*(N-1)//2+M*(M-1)//2)

Submission status: Accepted

Solution code:
line = input().strip().split(" ")
even = int(line[0])
odd = int(line[1])

if even > 1 and odd <= 1:
    result = (even * (even - 1)) / 2
    print(int(result))
elif even <= 1 and odd > 1:
    result = (odd * (odd -1)) / 2
    print(int(result))
elif even >1 and odd > 1:
    result = (even * (even -1)) / 2 + (odd * (odd - 1)) / 2
    print(int(result))
else:
    print(0)

Submission status: Accepted

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    N, M = MI()
    if N > 1:
        n = combinations_count(N, 2)
    else:
        n = 0
    if M > 1:
        m = combinations_count(M, 2)
    else:
        m = 0
    print(n+m)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
list_int = [int(e) for e in input().split()]
N = list_int[0]
M = list_int[1]

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
N_cnt = 0 
M_cnt = 0
if N == 2:
    N_cnt = 1
elif N <= 1:
    N_cnt = 0
else:
    N_cnt = permutations_count(N, 2)/2
if M < 2:
    M_cnt = 0
elif M == 2:
    M_cnt = 1
else:
    M_cnt = permutations_count(M, 2)/2
ans_cnt = N_cnt + M_cnt
print(int(ans_cnt))

Submission status: Accepted

Solution code:

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

even = N
odd = M

ans = N




def nc(n):
    return n*(n-1) / 2


ans = nc(N) + nc(M)      

print(int(ans))

Submission status: Accepted

Solution code:
from itertools import combinations
N,M = map(int, input().split())
a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  n, m = list(map(int, input().split()))
  
  if n == 1 and m == 1:
    return 0
  if n+m == 2:
    return 1
  
  total = factorial(n+m) / (factorial(n+m-2) * 2)
  return int(total - (n*m))

def factorial(value):
  result = value
  for i in range(1, value-1):
    result *= (value-i)

  return result

print(main())

Submission status: Accepted

Solution code:
from math import factorial

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

if N <= 1:
  a = 0
else:
  a = factorial(N) / 2 / factorial(N - 2)
  
if M <= 1:
  b = 0
else:
  b = factorial(M) / 2 / factorial(M - 2)
  
print(int(a+b))

Submission status: Accepted

Solution code:
m,n=map(int,input().split())
ans_m=0
ans_n=0
if m != 0 and m != 1:
  ans_m = m*(m-1)/2
if n != 0 and n != 1:
  ans_n = n*(n-1)/2
print(int(ans_m + ans_n))

Submission status: Accepted

Solution code:
from math import factorial

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

i=0
j=0
if N == 0 or N == 1:
  i += 0
else:
  i = factorial(N) / factorial(2) / factorial(N - 2)

if M == 0 or M == 1:
  j += 0
else:
  j = factorial(M) / factorial(2) / factorial(M - 2)

  
print(int(i+j))

Submission status: Accepted

Solution code:
from math import factorial


def perm(n, r):
    return factorial(n) // factorial(n - r)


def comb(n, r):
    if n < r:
        return 0
    return perm(n, r) // factorial(r)


N, M = map(int, input().split())
print(comb(N, 2) + comb(M, 2))

Submission status: Accepted

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

print(n*(n-1)//2+m*(m-1)//2)

Submission status: Accepted

Solution code:
a = input().split()
N = int(a[0])
M = int(a[1])

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

print(int(answer))

Submission status: Accepted

Solution code:
def Main(N, M):
    return N*(N-1)//2+M*(M-1)//2
                     

def main():
    N, M = map(int, input().split())
    print(Main(N, M))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations
N,M = map(int,input().split())

a= list(combinations(range(N),2))
b= list(combinations(range(M),2))
print(len(a)+len(b))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = 0
for n in range(N+1):
    if(n > 1):
        ans += (n-1)
for m in range(M+1):
    if(m > 1):
        ans += (m-1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def comb(n):
    if n < 2:
        return 0
    else:
        return n * (n - 1) // 2


N, M = map(int, input().split())
print(comb(N) + comb(M))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N != 0:
  if N != 1:
    N_sum = combinations_count(N, 2)
  else:
    N_sum = 0
else:
  N_sum = 0
if M != 0:
  if M != 1:
    M_sum = combinations_count(M, 2)
  else:
    M_sum = 0
else:
  M_sum = 0
print(N_sum + M_sum)

Submission status: Accepted

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

if N<= 1 and M <=1:
    print(0)

elif N >= 2 and M <=1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N <= 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Submission status: Accepted

Solution code:
def fact(k):
    val = 1
    for i in range(2, k+1):
        val = val*i
    return val

n, m = map(int, input().split())
if n < 2:
    even_comb = 0
else:
    even_comb = fact(n) / (fact(2) * fact(n-2))
if m < 2:
    odd_comb = 0
else:
    odd_comb = fact(m) / (fact(2) * fact(m-2))
print(int(even_comb + odd_comb))

Submission status: Accepted

Solution code:
from operator import mul
from functools import reduce

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

Nans = 0
Mans = 0

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

if N == 0 or N == 1:
    Nans = 0
else:
    Nans = cmb(N, 2)

if M == 0 or M == 1:
    Mans = 0
else:
    Mans = cmb(M, 2)

print(Nans + Mans)

Submission status: Accepted

Solution code:
from functools import reduce
def permu(n,r):
    return reduce(lambda a,b: a*b, range(n-r+1,n+1))
N,M = map(int, input().split())
print(int((permu(N,2)+permu(M,2))/2))

Submission status: Accepted

Solution code:
import itertools
a = list(map(int,input().split()))

s = [i for i in range(a[0])]
t = [i for i in range(a[1])]

n = list(itertools.combinations(s, 2))
m = list(itertools.combinations(t, 2))

print(len(n) + len(m))

Submission status: Accepted

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N !=0 and N != 1:
    a = combinations_count(N, 2)
else:
    a = 0

if M !=0 and M != 1:
    b = combinations_count(M, 2)
else:
    b = 0

print(a+b)

Submission status: Accepted

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

print(N * (N - 1) // 2 + M * (M - 1) // 2)

Submission status: Accepted

Solution code:
inputs = input().split(' ')
 
N = int(inputs[0])
M = int(inputs[1])
 
pattern_N = 0
pattern_M = 0
 
if N > 0:
  pattern_N = N * (N - 1) // 2 
  
if M > 0:
  pattern_M = M * (M - 1) // 2 
  
print(pattern_N + pattern_M)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
import itertools
def permutations_count(n,r):
    return len(list(itertools.combinations(range(n), r)))
print(permutations_count(int(n),2)+permutations_count(int(m),2))

Submission status: Accepted

Solution code:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

if N != 1 and N != 0:
    N = combinations_count(N, 2)
else:
    N = 0
if M != 1 and M != 0:
    M = combinations_count(M, 2)
else:
    M = 0


print(N+M)

Submission status: Accepted

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

Submission status: Accepted

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

print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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


h, w = input().split(" ")
h, w = int(h), int(w)

ans = 0
if (h > 1):
    ans += comb(h, 2)
if (w > 1):
    ans += comb(w, 2)
print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
if N>1 and M>1:
  print(int((N*(N-1)/2)+(M*(M-1)/2)))
elif N<=1:
    if M<=1:
      print(0)
    else:
        print(int(M*(M-1)/2))
else:
  print(int(N*(N-1)/2))

Submission status: Accepted

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