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 = map(int,input().split())
n = N*(N-1)/2
m = M*(M-1)/2

print(int(n+m))

Submission status: Accepted

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

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:
def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

ans = 0
if N >= 2:
    ans += N * (N - 1) // 2
if M >= 2:
    ans += M * (M - 1) // 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = n*(n-1)/2 + m*(m-1)/2

print(int(res))

Submission status: Accepted

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

a1=int(n*(n-1)/2)
a2=int(m*(m-1)/2)

ans=a1+a2

print(ans)

Submission status: Accepted

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

print(result)

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())

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

Submission status: Accepted

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


def solve(N: int, M: int):
    n = 0
    m = 0
    if N >1:
        n = N * (N-1) // 2
    if M >1:
        m = M * (M-1) // 2
    print(n+m)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, m = map(int, sys.stdin.readline().split())
print ((n-1)*n //2+ (m-1)*m//2)

Submission status: Accepted

Solution code:
def nCk(n, k, m=10**9+7):
    a = b = 1
    for i in range(k):
        a = (a * (n-i)) % m
        b = (b * (i+1)) % m
    return (a * pow(b, m-2, m)) % m

n,m = map(int, input().split())
ans = 0
if n > 1:
    ans += nCk(n, 2)
if m > 1:
    ans += nCk(m, 2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

ans = 0
if N > 1:
    ans += N * (N-1) // 2
if M > 1:
    ans += M * (M-1) // 2
print(ans)

Submission status: Accepted

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

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())

n=N*(N-1)//2
m=M*(M-1)//2

print(n+m)

Submission status: Accepted

Solution code:
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
N, M = map(int, input().split())
if N > 1:
    ans1 = C(N,2)
else:
    ans1 = 0
if M > 1:
    ans2 = C(M,2)
else:
    ans2 = 0
print(ans1+ans2)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = min(r,n-r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) % mod

N,M = map(int,input().split())
a = 0
b = 0
if N <= 1:
    a = 0
else:
    a = combination(N,2)
if M <= 1:
    b = 0
else:
    b =  combination(M,2)
print(a+b)

Submission status: Accepted

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

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:
#coding:utf-8
n, m = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

if m > 1:
    count += int(m*(m-1)/2)
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

ans += n * (n - 1) // 2

ans += m * (m - 1) //2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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())

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

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    return str((n*(n-1)//2) + (m*(m-1)//2))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

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

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

Submission status: Accepted

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

print(a*(a-1)//2 + b*(b-1)//2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, m = list(map(int, input().strip().split()))
    print(n * max(0, n-1) // 2 + m * max(0, m-1) // 2)

if __name__ == '__main__':
    main()

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()]
print((n*(n-1))//2+(m*(m-1))//2)

Submission status: Accepted

Solution code:
n, m = list(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())

even_even = int(M*(M-1)/2)
odd_odd = int(N*(N-1)/2)

print(even_even+odd_odd)

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:
def main():
    N, M = map(int, input().split())
    ans = (N * (N - 1)) // 2 + (M * (M - 1)) // 2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

n,m = input_multiple_number()

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:
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 = int((N*(N-1)+M*(M-1))/ 2)
print(ans)

Submission status: Accepted

Solution code:
def cmb(n, r):
    if n <= 0 or n < r:
        return 0
    if n == r or r == 0:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r-1) + cmb(n-1,r)
def main():
    n, m = map(int, input().split())
    a = cmb(n, 2)
    a += cmb(m, 2)
    print(a)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
def main():
    n,m = [int(j) for j in sys.stdin.readline().split()]
    ans = (n+m)*(n+m-1)//2-n*m
    sys.stdout.write(str(ans))
    sys.stdout.write("\n")
    
main()

Submission status: Accepted

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

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:
N,M=map(int,input().split())
ans=0
ans+=N*(N-1)//2
ans+=M*(M-1)//2
print(ans)

Submission status: Accepted

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




print(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:

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

ret = 0
if N > 1:
    ret += N*(N-1) // 2
if M > 1:
    ret += M*(M-1) // 2

print(ret)

Submission status: Accepted

Solution code:

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs



def main(inputs):
	n,m=getIntList(inputs[0])
	
	ans=n*(n-1)//2+m*(m-1)//2
	print(ans)
	
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)

Submission status: Accepted

Solution code:
import sys
import itertools
import bisect
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
def combi(n, r):
  r = min(r, n-r)
  numer = denom = 1
  for i in range(1, r+1):
    numer = numer * (n+1-i) %mod
    denom = denom * i %mod
  return numer * pow(denom, mod-2, mod) %mod

N,M = IL()

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,M = MI()
	print(int((N+M)*(N+M-1)/2 - N*M))

if __name__ == '__main__':
	main()

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:
N, M = map(int, input().split())
ans = 0
if N >= 2:
    ans += N * (N - 1) // 2
if M >= 2:
    ans += M * (M - 1) // 2

print(ans)

Submission status: Accepted

Solution code:
n,m = list(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(' '))
print(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
ans += (m * (m - 1)) / 2

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:
n, m = map(int, input().split())

mC2 = m * (m - 1) * 0.5
nC2 = n * (n - 1) * 0.5

print(int(mC2 + nC2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class v:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N, M = read_values()
    print((N + M) * (N + M - 1) // 2 - N * M)


if __name__ == "__main__":
    main()

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:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, M = read_int()

def solve():
    ans = 0
    return N * (N - 1) // 2 + M * (M - 1) // 2

if __name__ == "__main__":
    print(solve())

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:
N,M = map(int, input().split())

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

Submission status: Accepted

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

n,m=map(int,input().split())
ans=0
if n>=2:
    ans+=com(n,2)
if m>=2:
    ans+=com(m,2)
print(ans)

Submission status: Accepted

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

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:
N_even, M_odd = map(int, input().split())

ans = N_even * (N_even - 1) // 2 + M_odd * (M_odd - 1) // 2
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def solve(n, m):
    A = [0] * n + [1] * m
    ans = 0
    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            if (A[i] + A[j]) % 2 == 0:
                ans += 1
    return ans

def main():
    n, m = map(int, input().split())
    ans = solve(n, m)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

def solve():
  n, m = map(int, input().split())
  a = len(list(itertools.combinations(range(n), 2)))
  b = len(list(itertools.combinations(range(m), 2)))
  print(a + b)
  return 0

if __name__ == "__main__":
  solve()

Submission status: Accepted

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

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

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())
print((M*(M-1)+N*(N-1))//2)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 1000  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

n, m = MAP()
ans = cmb(n, 2) + cmb(m, 2)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy

#import numpy as np

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

print(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:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


n,m=l_in()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = (int(n * (n - 1) / 2) + int(m * (m - 1) / 2))
print(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:
N,M = list(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()) 
a = N*(N-1)/2+M*(M-1)/2
print(int(a))

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()
    n = [2] * N
    m = [1] * M
    arr = n + m
    ans = 0

    for pair in list(itertools.combinations(arr, 2)):
        if (pair[0] + pair[1]) % 2 == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))


def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a,b = inpl()
res = 0
if a > 1:
    res += conb(a,2)
if b > 1:
    res += conb(b,2)
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

a = n*(n-1)+m*(m-1)
print(a//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)+M*(M-1))//2
print(ans)

Submission status: Accepted

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

def nCr(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

even = nCr(n, 2)
odd = nCr(m, 2)
print(even + odd)

Submission status: Accepted

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

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

Submission status: Accepted

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

o = max(m * (m-1) //2 , 0) + max(n * (n-1) //2 , 0)

print(o)

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Sun Mar 22 11:54:41 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a, b = na()
print(a * (a - 1) // 2 + b * (b - 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:
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())
n = N*(N-1)+M*(M-1)
print(n//2)

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

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())

print(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())

from math import factorial
def comb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

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

Submission status: Accepted

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

p = 7+pow(10,9)
def cmb(n,r,p):
    numerator = 1
    for i in range(n-r+1, n+1):
        numerator = numerator * i % p
    denominator = 1
    for i in range(1, r+1):
        denominator = denominator * i % p
    return numerator * pow(denominator, p-2, p) % p


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#nC2
#mC2

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,m = list(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(int(ans))

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n,m = map(int,input().split())
    ans = n*(n-1)
    ans += m*(m-1)
    ans = ans //2
    print(ans)
if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# 偶数だけ
# 奇数だけ


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


t = 0
if N >= 2:
    t += C(N, 2)
if M >= 2:
    t += C(M, 2)
ans = t
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

Submission status: Accepted

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    a,b = mi()
    if a == 0:
        a = 1
    if b == 0:
        b = 1
    print((a*(a-1)//2)+(b*(b-1)//2))






main()

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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:
inp = input().split()

n,m = map(int,inp)

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

print(ans)

Submission status: Accepted

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

answer = n*(n-1)//2
answer += 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:
import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N, M = get_inputs(int)

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




if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
if N >= 2:
  ans += N * (N-1) // 2

if M >= 2:
  ans += M * (M-1) // 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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