Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


if a % 2 != 0:
    a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
cnt = cnt + cmb(a, 2) + cmb(b, 2)
print(cnt)


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


#if a != 0:
#    if a % 2 != 0:
#        a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
if a != 0:
    cnt = cnt + cmb(a, 2)
cnt = cnt + cmb(b, 2)
print(cnt)


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


#if a != 0:
#    if a % 2 != 0:
#        a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
if a > 2:
    cnt = cnt + cmb(a, 2)

if b > 2:
    cnt = cnt + cmb(b, 2)
print(cnt)


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


if a != 0:
    if a % 2 != 0:
        a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
if a != 0:
    cnt = cnt + cmb(a, 2)
cnt = cnt + cmb(b, 2)
print(cnt)


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


if a != 0:
    if a % 2 != 0:
        a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
cnt = cnt + cmb(a, 2) + cmb(b, 2)
print(cnt)


# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0


#if a != 0:
#    if a % 2 != 0:
#        a = a - 1





nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
if a > 1:
    cnt = cnt + cmb(a, 2)

if b > 1:
    cnt = cnt + cmb(b, 2)
print(cnt)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted