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:
from operator import mul
from functools import reduce

def cmb(n,r):
    if 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 = list(map(int, input().split()))
print(cmb(N, 2) + cmb(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 math

def comb(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 += comb(N, 2)
if M >= 2:
    ans += comb(M, 2)
print(ans)

Submission status: Accepted

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

if m > 1:
    b = m * (m-1) / 2
else:
    b = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A
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())

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

n, m = map(int, input().split())
tmp1 = len(list(combinations(range(n), 2)))
tmp2 = len(list(combinations(range(m), 2)))

print(tmp1+tmp2)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

a = 0 if n <= 1 else n*(n-1)//2
b = 0 if m <= 1 else m*(m-1)//2

print(a+b)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(x*(x-1)//2+y*(y-1)//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
nm=input().rstrip().split(" ")
n=int(nm[0])
m=int(nm[1])
ans=n*(n-1)/2+m*(m-1)/2
print(int(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = [int(v) for v in input().strip().split(' ')]
print((N * (N - 1) + 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:
import sys
input = sys.stdin.readline

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

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())
Q = N*(N-1)*0.5
P = M*(M-1)*0.5
print(int(P+Q))

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())

allconbi = (n+m)*(n+m-1)//2
minus = n*m

ans = allconbi-minus
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, M = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

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

    if M >= 2:
        m = M * (M - 1) / 2
    else:
        m = 0

    print(int(n + m))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 3"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """13 3"""
        output = """81"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """0 3"""
        output = """3"""
        self.assertIO(input, output)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())

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


main()

Submission status: Accepted

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

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

print (s)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, M):
    ans = (N*(N-1) + M*(M-1)) // 2
    return ans


if __name__ == "__main__":

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

    print(ans)

Submission status: Accepted

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

	print(int(ans))

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

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

n, m = map(int, input().split())
print(combinations_count(n, 2) + combinations_count(m, 2))

Submission status: Accepted

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

ans=0

for i in range(1, N):
    ans += i

for ii in range(1, M):
    ans += ii


print(ans)

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))
ans=0
if N>1:
  ans+=combinations_count(N, 2)
if M>1:
  ans+=combinations_count(M, 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(a + b)

Submission status: Accepted

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

even = n*(n - 1)/2
odd = m*(m - 1)/2
com = int(even + odd)
print(com)

Submission status: Accepted

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

Submission status: Accepted

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

a = (N * (N - 1) // 2) if N >= 2 else 0
b = (M * (M - 1) // 2) if M >= 2 else 0

print(a + b)

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

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

kisuu = N*M

print(all-kisuu)

Submission status: Accepted

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

Submission status: Accepted

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

sum1 = n * (n-1) // 2
sum2 = m * (m-1) // 2

ans = sum1 + sum2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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:
a,b = [int(x) for x in input().split()]
s = a*(a-1)/2 + b*(b-1)/2
print(int(s))

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


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

Submission status: Accepted

Solution code:
def comb(n,k):
    nCk = 1
    MOD = 10**9+7
    # X
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    # Y
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk


# n = int(input())
n, m = map(int, input().split())
# k = list(map(int, input().split()))
ans = 0

if n >= 2:
    ans += comb(n, 2)

if m >= 2:
    ans += comb(m, 2)

print(ans)

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

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

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

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

print(pat - odpat)

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

Submission status: Accepted

Solution code:
# ABC159_A
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())
ans=0
if M>1:
  ans+=M*(M-1)//2
if N>1:
  ans+=N*(N-1)//2
print(ans)

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 = [int(x) for x in input().split()]
r = n * (n - 1) // 2 + m * (m - 1) // 2
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
E, O = map(int, input().split())

answer = 0
if E > 0:
    answer += E * (E-1)//2
if O > 0:
    answer += O * (O-1)//2
print(answer)

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

n, m = map(int, input().split())
ans = 0
for i in range(n):
    ans += i
for j in range(m):
    ans += j
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:
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, m = gi()
print((n * (n - 1)) // 2 + (m * (m - 1)) // 2)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 1), 1)

    def test_2(self):
        self.assertEqual(think(4, 3), 9)

    def test_3(self):
        self.assertEqual(think(1, 1), 0)

    def test_4(self):
        self.assertEqual(think(13, 3), 81)


def solve():
    n, m = read()
    result = think(n, m)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, m):
    result = 0
    if n >= 2:
        result += (n * (n - 1)) // 2
    if m >= 2:
        result += (m * (m - 1)) // 2
    return result


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s


#@lru_cache(maxsize=None)  
def f():
    return 1
#main
N,M=list(map(int,input().split()))
print(N*(N-1)//2+M*(M-1)//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

even_list = list(itertools.combinations(range(N), 2))
odd_list = list(itertools.combinations(range(M), 2))

print(len(even_list) + len(odd_list))

Submission status: Accepted

Solution code:
input_line = [int(i) for i in input().split()]
n = input_line[0]
m = input_line[1]

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

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:
# ABC159a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    import math

    def dump(*args):
        sys.stderr.write(str(args))

    def c_count(n, r):  # 組み合わせ
        if n - r < 0:
            return 0
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    n, m = map(int, input().split())
    print(c_count(n, 2)+c_count(m, 2))


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

Submission status: Accepted

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

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

x = 0

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

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit
setrecursionlimit(10**6)

def array2D(row, col ,val=0):
    return [[val]*col for i in range(row)]

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

a = 0
b = 0
if n >=2:
    a = n*(n-1)//2
if m>=2:
    b = m*(m-1)//2
print(a+b)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# N : even
# M : odd
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=0
if n>1:
  ans+=n*(n-1)//2
if m>1:
  ans+=m*(m-1)//2
print(ans)

Submission status: Accepted

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

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

if __name__=='__main__':
  main()

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

Submission status: Accepted

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

Submission status: Accepted

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

result=0

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

print(result)

Submission status: Accepted

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

base = (n+m) * (n+m-1) // 2
odd = n * m

print(base - odd)

Submission status: Accepted

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

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

Submission status: Accepted

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


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

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

print(int(r))

Submission status: Accepted

Solution code:
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

N, M = map(int, input().split())
def c(num):
    if num == 1 or num == 0:
        return 0
    else:
        return (num * (num-1))//2
print(c(N)+c(M))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read


n,m = [int(i) for i in read().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())
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
print(combination(n+m, 2)-n*m)

Submission status: Accepted

Solution code:
A,B = map(int,input().rstrip().split(" "))
ans = int((A * ( A-1) /2) + (B * (B -1) /2))
print(ans)

Submission status: Accepted

Solution code:
def comb(a,b):
    import math
    return math.factorial(a)//(math.factorial(a-b)*math.factorial(b))
N,M = map(int,input().split())
ans = 0
if N > 1:
    ans += comb(N,2)
if M > 1:
    ans += comb(M,2)

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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:
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

Submission status: Accepted

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

def nC2(n):
    if n < 2:
        return 0
    return n * (n-1) // 2

def solve(N, M):
    return nC2(N) + nC2(M)

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Submission status: Accepted

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

ans=0
if n>1:
    ans+=ncr(n,2)
if m>1:
    ans+=ncr(m,2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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