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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
fac = [-1] * (10**7+1)
inv = [-1] * (10**7+1)
finv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod
initNCMMod(1000)
def main():
    N, M = LI()
    print(NCMMod(N, 2) + NCMMod(M, 2))


main()

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
2 1
'''

def solve(l):
	n = len(l)
	

N,M = list(map(int, stdin.readline().rstrip().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:
a,b=[int(x) for x in input().split()]

def solve(n):
    if n ==1:
        return 0
    return n*(n-1)//2

print(solve(a)+ solve(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#def main(S, b):
if __name__ == '__main__':
    n, m = map(int, input().split())

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

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:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

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





# 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")


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

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

print(out)

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


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

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

print(n)

Submission status: Accepted

Solution code:
from functools import reduce

def binom(n, r):
    if n < r or n < 0 or r < 0: return 0
    
    if n - r < r: r = n - r
    if r == 0: return 1
    elif r == 1: return n

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

    # reduce prod(numerator)//prod(denominator)
    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
    
    # calculate nCr
    return reduce(lambda x, y: x*y, numerator)

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

Submission status: Accepted

Solution code:
input = raw_input

a, b = map(int, input().split(" "))
out1 = a * (a-1) // 2
out2 = b * (b-1) // 2
out = out1 + out2
print(out)

Submission status: Accepted

Solution code:
N, M = [int(x) for x in input().split()]
ans = (N * (N - 1) + 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(round(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, M = LI()

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:
x,y=list(map(int, input().split()))
print((x*(x-1)//2)+(y*(y-1)//2))

Submission status: Accepted

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

    print(ans)
    

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

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

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:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().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())

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

Submission status: Accepted

Solution code:
def xgcd(a, b):
  x0, y0, x1, y1 = 1, 0, 0, 1
  while b != 0:
    q, a, b = a // b, b, a % b
    x0, x1 = x1, x0 - q * x1
    y0, y1 = y1, y0 - q * y1
  return a, x0, y0
def modinv(a, m):
  g, x, y = xgcd(a, m)
  if g != 1:
    raise Exception('modular inverse does not exist')
  else:
    return x % m
def combination(n, k, mod=1e9+7) -> int:
  ret = 1
  for i in range(1, k+1):
    ret = (ret * (n-k+i) * modinv(i, mod))%mod
  return int(ret)

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

Na = combination(N,2) if N >=2 else 0
Ma = combination(M,2) if M >=2 else 0

print(Na+Ma)

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(i) for i in input().strip().split(" ")]

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

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

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


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

Submission status: Accepted

Solution code:
#abc159 a

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

#ここから書き始める
n, m = map(int, input().split())
ans1 = n * (n - 1) // 2
ans2 = m * (m - 1) // 2
print(ans1 + ans2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n, m = rli()
    print(n*(n-1)//2+m*(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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
from operator import mul
from functools import reduce

def cmb(n, r):
  if not n >= r:return 0
  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


n,m = map(int,input().split())
print(cmb(n,2)+cmb(m,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:
n,m=(int(i) for i in input().split())
print(n*(n-1)//2+m*(m-1)//2)

Submission status: Accepted

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

print(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 = list(map(int, input().split(' ')))

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

Submission status: Accepted

Solution code:
def main():
    n,m = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    main()

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:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, M = map(int, input().split())
    ans = (N * (N - 1) + M * (M - 1)) // 2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations
from math import factorial


def main():
    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 = [int(i) for i in input().split()]
print(int((N*(N-1)/2)+(M*(M-1)/2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    n,m = map(int,input().split())
    print(n*(n-1)//2 + m*(m-1)//2)
if __name__ == "__main__":
    main() #endline===============================================

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:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
print(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:
#create date: 2020-03-22 21:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m = na()
    print(n*(n-1)//2 + m*(m-1)//2)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M):
    return ((N) * (N-1) + (M) * (M-1)) // 2


def main():
    N, M = read_int_n()
    print(slv(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:
import sys
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    ans = N * (N - 1) // 2 + M * (M - 1) // 2
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    print(N*(N-1)//2+M*(M-1)//2)
resolve()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def get_ints():
    return map(int, input().split())

n, m = get_ints()
pats = 0
if n >= 2:
    pats += n * (n - 1) // 2
if m >= 2:
    pats += m * (m - 1) // 2

print(pats)

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:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

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

tmp=n*(n-1)//2
tmp2=m*(m-1)//2
print(tmp+tmp2)

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:
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

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

Submission status: Accepted

Solution code:

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



if __name__ == "__main__":
    resolve()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict, deque

N, M = [int(x) for x in input().split()]

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

Submission status: Accepted

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

print(main())
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m = get_nums_l()

print((n-1)*n//2 + (m-1)*m//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:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)
if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    n = N*(N-1)//2 if N >=2 else 0
    m = M*(M-1)//2 if M >=2 else 0
    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:
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
print(int(N*(N-1)/2+M*(M-1)/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

Submission status: Accepted

Solution code:
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
 
def main():
    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 = [int(x) for x in input().split()]
ans = n * (n-1) / 2
ans += m * (m-1) /2
print(int(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

if N < 2 and M < 2:
    print(0)
    exit()

ans = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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:
import sys


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


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

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:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

def main():
  n,m=LI()
  ans=0

  ans+=nCr(n,2)
  ans+=nCr(m,2)

  return ans

# main()
print(main())

Submission status: Accepted

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


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    ans = 1
    for i in range(1, k + 1):
        ans *= n - i + 1
        ans //= i
    return ans


ans = comb(n, 2) + comb(m, 2)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

N,M = inputIL()

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

Submission status: Accepted

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

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