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

Submission status: Accepted

Solution code:
score = list(map(int,input().split()))
if score[0] == 1:
    evennum = 0
else:
    evennum = score[0]*(score[0]-1)/2
if score[1] == 1:
    oddnum = 0
else:
    oddnum = score[1]*(score[1]-1)/2
print(int(evennum+oddnum))

Submission status: Accepted

Solution code:
from scipy.special import comb
a,b=map(int,input().split())
print(int(comb(a,2)+comb(b,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:
a, b = [int(x) for x in input().split()]
print(a*(a-1)//2 + b*(b-1)//2)

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

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 math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

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


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())
 
g = 0 if N < 2 else (N * (N - 1)) / 2
k = 0 if M < 2 else (M * (M - 1)) / 2
 
print(int(g + k))

Submission status: Accepted

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

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

    ans = choose_2(N + M) - N * M

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
from math import factorial

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

if N <= 1:
    combN = 0
else:
    combN = factorial(N) // (factorial(N - 2) * factorial(2))

if M <= 1:
    combM = 0
else:
    combM = factorial(M) // (factorial(M - 2) * factorial(2))

print(combN + combM)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def resolve(in_):
    n, m = map(int, in_.readline().split())
    return n * (n - 1) // 2 + m * (m - 1) // 2


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

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:
from itertools import combinations

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

cN = len(list(combinations(range(N),2)))
cM = len(list(combinations(range(M),2)))

print(cN + cM)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
def nC2(n):
  # n = 0 -> 0
  # n = 1 -> 0
  if n<2:
    return 0
  return math.factorial(n) // (math.factorial(n - 2) * 2)
n,m = map(int, input().split())
# 135 3C2
# 2468 4C2
# nC2
r=nC2(n)+nC2(m)
print(r)

Submission status: Accepted

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

def main():

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

    numN = N * (N - 1) / 2
    numM = M * (M - 1) / 2

    ans = 0

    if numN >= 0:
        ans += numN

    if numM >= 0:
        ans += numM

    print(int(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n, m = list(map(int, input().split()))
nC2 = math.factorial(n) // (math.factorial(2) * math.factorial(n - 2)) if n >= 2 else 0
mC2 = math.factorial(m) // (math.factorial(2) * math.factorial(m - 2)) if m >= 2 else 0
print(nC2 + mC2)

Submission status: Accepted

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

# [2, 0]
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        count += 1
# [0, 2]
for i in range(1, m + 1):
    for j in range(i + 1, m + 1):
        count += 1

print(count)

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

Submission status: Accepted

Solution code:
import math
import itertools

N, M = map(int, input().split())
print(len(list(itertools.combinations(range(N), 2))) + len(list(itertools.combinations(range(M), 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:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


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


def main():
    solve()


if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def nPr(n: int, r: int) -> int:
    return math.factorial(n) // math.factorial(n - r)


def nCr(n: int, r: int) -> int:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def solve(N: int, M: int):
    return (nCr(N, 2)if N > 1 else 0) + (nCr(M, 2) if M > 1 else 0)


def main():

    sys.setrecursionlimit(10 ** 6)

    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
    print(f'{solve(N, M)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# abc159_a.py
# https://atcoder.jp/contests/abc159/tasks/abc159_a

# A - The Number of Even Pairs /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# N+M個のボールがあります。各ボールには整数が 1つ書かれています。
# これらのボールに書かれている数について、
#     N個のボールに書かれている数は偶数
#     M個のボールに書かれている数は奇数
# であることがわかっています。

# これらの N+M個のボールの中から 2つ選んで、書かれた数の和が偶数になる方法の数を求めてください。
# 選ぶ順序は考慮しません。
# なお、この方法の数はボールに書かれている整数の実際の値によらないことが示せます。

# 制約
#     0≤N,M≤100
#     2≤N+M
#     入力はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M

# 出力
# 答えを出力せよ。

# 入力例 1
# 2 1

# 出力例 1
# 1

# 例えば 3つのボールに書かれている数がそれぞれ 1,2,4であるとすると、
#     1が書かれたボールと 2が書かれたボールを選ぶと、和は奇数
#     1が書かれたボールと 4が書かれたボールを選ぶと、和は奇数
#     2が書かれたボールと 4が書かれたボールを選ぶと、和は偶数
# であるので、答えは 1です。

# 入力例 2
# 4 3

# 出力例 2
# 9

# 入力例 3
# 1 1

# 出力例 3
# 0

# 入力例 4
# 13 3

# 出力例 4
# 81

# 入力例 5
# 0 3

# 出力例 5
# 3


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 0

    # 偶数二つ
    if N > 1:
        result += N*(N-1)/2
    # 奇数二つ
    if M > 1:
        result += M*(M-1)/2
    result = int(result)
    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 1']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['4 3']
        lines_export = [9]
    if pattern == 3:
        lines_input = ['1 1']
        lines_export = [0]
    if pattern == 4:
        lines_input = ['13 3']
        lines_export = [81]
    if pattern == 5:
        lines_input = ['0 3']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))
import math

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

if (n >= 2):
    a = math.factorial(n)//(2*math.factorial(n-2))
else:
    a = 0

if (m >= 2):
    b = math.factorial(m)//(2*math.factorial(m-2))
else:
    b = 0

print(a+b)

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())
x = n * (n - 1) // 2 if n > 1 else 0
y = m * (m - 1) // 2 if m > 1 else 0
print(x + y)

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

import math
if M >= 2:
    m = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
else:
    m = 0
if N >= 2:
    n = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
else:
    n = 0
print(m + n)

Submission status: Accepted

Solution code:
m,n =  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//2+M*~-M//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int(odd + even))

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:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
import math


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


def main():
    n, m = map(int, input().split())
    if n < 2:
        even = 0
    else:
        even = combinations_count(n, 2)
    if m < 2:
        odd = 0
    else:
        odd = combinations_count(m, 2)
    print(even + odd)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
print((N*(N-1)+M*(M-1))//2)

Submission status: Accepted

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

if not ( 0 <= N <= 100 and 0 <= M <= 100 ): sys.exit()
if not ( 2 <= N+M ): sys.exit()
if not ( isinstance(N,int) and isinstance(M,int) ): sys.exit()

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

Submission status: Accepted

Solution code:
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r


def solve():
    c=0
    a,b=mp()
    c+=((a-1)*(a))//2
    c+=((b-1)*(b))//2
    print(c)

for _ in range(1):
    solve()

Submission status: Accepted

Solution code:
# A The Number of Even Pairs

from itertools import combinations as com

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

n = [0] * N
m = [0] * M

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

Submission status: Accepted

Solution code:
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	#print(name)
	sys.stdin = open(name)

from math import factorial

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

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

#print(combinations_count(n,2))
#print(combinations_count(m,2))

#print(factorial(0))

print(combinations_count(n,2) + combinations_count(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 = map(int, input().split())

Ev = M * (M - 1) // 2
Od = N * (N - 1) // 2

print(Ev + Od)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
# 場合の数
# ans = perm(n, 2, exact=True)//perm(2, 2, exact=True)+perm(m, 2, exact=True)//perm(2, 2, exact=True)
ans = n * (n-1) // 2 + m * (m - 1) // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
偶数：偶数＋偶数 or 奇数＋奇数
奇数：偶数＋奇数
"""

def the_number_of_even_pairs():
    # 入力
    N, M = map(int, input().split())
    # 初期処理
    list_N = [0] * N
    list_M = [1] * M
    even_pairs_count = 0
    # 判別処理
    # 偶数＋偶数
    for _ in range(N):
        even_pairs_count += len(list_N)-1
        list_N.pop(0)
    # 奇数＋奇数
    for _ in range(M):
        even_pairs_count += len(list_M)-1
        list_M.pop(0)
    # 結果
    return even_pairs_count

result = the_number_of_even_pairs()
print(result)

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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


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

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

Submission status: Accepted

Solution code:
from operator import mul
from functools import reduce

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

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

cmb_n = cmb(n,2) if n>=2 else 0
cmb_m = cmb(m,2) if m>=2 else 0

print(cmb_n+cmb_m)

Submission status: Accepted

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

Submission status: Accepted

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

#even number
if n==1:
    even=0
else:
    even=int(n*(n-1)/2)
    
#odd number
if m==1:
    odd=0
else:
    odd=int(m*(m-1)/2)
    
print(even+odd)

Submission status: Accepted

Solution code:
N=list(map(int,input().split()))
ans=0
for x in range(2):
  if N[x]==0 or N[x]==1:
    pass
  else:
    ans += N[x]*(N[x]-1)/2
print(int(ans))

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

nn = []
i = 0
for _ in range(n):
    nn.append(i)
    i += 2

mm = []
i = 1
for _ in range(m):
    mm.append(i)
    i += 2

ans = 0
l = nn + mm

for v in itertools.combinations(l, 2):
    if (v[0] + v[1]) % 2 == 0:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from scipy.special import comb
N, M = map(int, input().split())
ans = 0
if N >= 2:
    ans += comb(N, 2, exact=True)
if M >= 2:
    ans += comb(M, 2, exact=True)
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:
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(int(M*(M-1)/2+N*(N-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 main():
 n,m = map(int,input().split())
 print(n * (n - 1) // 2 + m * (m - 1) // 2)
main()

Submission status: Accepted

Solution code:
import sys


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

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

Submission status: Accepted

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

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

print(tot)

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())
ans1 = 0
ans2 = 0

ans1 = N*(N-1)/2
ans2 = M*(M-1)/2

print(int(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:
#!/usr/bin/env python3
import math

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

nans = (n * (n - 1)) // 2
mans = (m * (m - 1)) // 2

print(nans + mans)

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

print(sum(range(n)) + sum(range(m)))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

sum = n * (n - 1) // 2
if 1 < m:
    sum += m * (m - 1) // 2
print(sum)

Submission status: Accepted

Solution code:
import math

N,M = map(int,input().split())
#Nは偶数
#Mは奇数

#偶数偶数
if N >= 2:
  Nf = math.factorial(N)//(math.factorial(N-2)*2)
else:
  Nf = 0
#奇数奇数
if M >= 2:
  Mf = math.factorial(M)//(math.factorial(M-2)*2)
else:
  Mf = 0
ans = int(Nf + Mf)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

even = n * (n - 1) // 2
odd = m * (m - 1) // 2

print(even + odd)

Submission status: Accepted

Solution code:
N, M = (int(x) for x in 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:
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 math
def combi(n,r):
  ans = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
  return ans

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

ans = 0
if N > 1:
  ans += combi(N,2)
if M > 1:
  ans += combi(M,2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def nCr(n, r):
    if n < r:
        return 0
    ans = 1
    for i in range (r):
        ans *= (n-r+i+1)
        ans = ans // (i+1)

    return ans

print(nCr(n, 2) + nCr(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:
import itertools 
n,m=map(int,input().split());l1=[];l2=[];ans=0
while len(l1)<n:
  if len(l1)==0:
    l1.append(2)
  else:
    l1.append(l1[-1]+2)
while len(l2)<m:
  if len(l2)==0:
    l2.append(1)
  else:
    l2.append(l2[-1]+2)
for i in list(itertools.combinations(l1+l2, 2)):
  if sum(i)%2==0:
    ans+=1
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())

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

Submission status: Accepted

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

Submission status: Accepted

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

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