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

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

n, m = [int(x) for x in input().split()]

ans = 0

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

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

print(int(ans))

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

tmp1 = (n * (n-1)) // 2
tmp2 = (m * (m-1)) // 2

print(tmp1 + tmp2)

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:
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:
a,b=map(int,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:

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

# 多次元配列
# dp = [[0] * 3 for _ in range(5)]

# 入力を受け取る
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-1)*N//2+(M-1)*M//2)

Submission status: Accepted

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

ans = n*(n-1)//2 + m*(m-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:
#n = int(input())
#s = input()
a,b = map(int,input().split())
#da = list(map(int,input().split()))
#a = [int(input()) for i in range(n)]

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

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    readline=stdin.readline
    N,M=map(int,readline().split())
    a=N*(N-1)//2
    b=M*(M-1)//2
    print(a+b)
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

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

print (a + b)

Submission status: Accepted

Solution code:

import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

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

if __name__ == "__main__":
  main()

Submission status: Accepted

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

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

print ans

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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 = 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:
n,m = map(int,input().split())
ans = (n+m)*(n+m-1)//2-n*m
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from math import factorial
def com(n,r):
    if n<r:
        return 0
    return int(factorial(n) // factorial(r) // factorial(n-r))
N, M = map(int, input().split())
print(com(N, 2) + com(M, 2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input():
    return sys.stdin.readline()[:-1]
def pri(x):
    if type(x) is list:
        print('\n'.join(map(str, x)))
    else:
        print(x)

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

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

Submission status: Accepted

Solution code:
def examA():
    N, M = LI()
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Submission status: Accepted

Solution code:
InputIntList = lambda : list(map(int, input().split()))
InputStrList = lambda : list(input().split())

N, M = InputIntList()

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 = [int(s) for s in input().split()]

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

    return 0

if __name__ == "__main__":
    solve()

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:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()

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

if __name__ == "__main__":
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b = m()

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:
N,M=[int(i) for i in input().split(" ")]

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
    
def resolve():
    N,M=pin()
    print(N*(N-1)//2+M*(M-1)//2)
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

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)

if __name__=="__main__":resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    print(n*(n-1)//2+m*(m-1)//2)
    
if __name__ == "__main__":
    main()

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:
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
print(n * (n-1) // 2 + m * (m-1) // 2)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

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

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().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:
import sys


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


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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:
def c(i):
  return i * (i-1) // 2

a, b = input().split()
a, b = int(a), int(b)

print(c(a) + c(b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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())
if (n<=1) and (m<=1):
  ans=0
else:
  if n==0:
    ans=comb(m,2)
  elif m==0:
    ans=comb(n,2)
  else:
    ans=comb(n,2)+comb(m,2)
  
print(ans)

Submission status: Runtime Error

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())
if (n<=1) and (m<=1):
  ans=0
elif (n==0) or (m==0):
  ans=0
else:
  ans=comb(n,2)+comb(m,2)
  
print(ans)

Submission status: Runtime Error

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 = combinations_count(m, 2) + combinations_count(n, 2)

print(ans)

Submission status: Runtime Error

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))
if N == 0:
  ans = combinations_count(M, 2)
elif M == 0:
  ans = combinations_count(N, 2)
elif N == 0 and M == 0:
  ans = 0
else:
  ans = combinations_count(N, 2) +  combinations_count(M, 2)
print(ans)

Submission status: Runtime Error

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))
if N == 0:
  ans = combinations_count(M, 2)
elif M == 0:
  ans = combinations_count(N, 2)
else:
  ans = combinations_count(N, 2) +  combinations_count(M, 2)
print(ans)

Submission status: Runtime Error

Solution code:
""" スニペット """
def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))
""" スニペット """
import math
# 2つ選ぶ通り数を算出 nC2
def choose2(n):
    return math.floor(n*(n-1)/2)

# インプット
N = get_int()
An = get_ints()
""" 全ての要素から2つのボールを選ぶ通り数を求める """
uni = [0] * (N+1)
# ユニーク数の配列を求める
for i in range(N+1):
    uni[An[i]] += 1
sumWay = 0
# 各数値の2通りの選択通り数を足していく
for i in range(N):
    sumWay += choose2(uni[i])
""" 全ての要素数 - 削除する要素の通り数 + 削除する要素を引いた際の通り数 を求める """
for i in range(N):
    print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1))

Submission status: Runtime Error

Solution code:
""" スニペット """
def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))
""" スニペット """
import math
# 2つ選ぶ通り数を算出 nC2
def choose2(n):
    return math.floor(n*(n-1)/2)

# インプット
N = get_int()
An = get_ints()
""" 全ての要素から2つのボールを選ぶ通り数を求める """
uni = [0] * (N+1)
# ユニーク数の配列を求める
for i in range(N):
    uni[An[i]] += 1
sumWay = 0
# 各数値の2通りの選択通り数を足していく
for i in range(N):
    sumWay += choose2(uni[i])
""" 全ての要素数 - 削除する要素の通り数 + 削除する要素を引いた際の通り数 を求める """
# for i in range(N):
#     print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1)) 

for i in range(N):
    ans = sumWay
    ans -= choose2(uni[An[i]])
    ans += choose2(uni[An[i]]-1)
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(int(math.factorial(n)/(2 * math.factorial(n-2)) + math.factorial(m)/(2 * math.factorial(m-2))))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
nm = input()
n = int(nm[0])
m = int(nm[1])

ans = 0

n1 = n*(n-1)/2

n2 = m*(m-1)/2

ans = n1 + n2

print(ans)

Submission status: Runtime Error

Solution code:
import math
N,M=map(int,input().split())
def combination(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
if N>=2 and M>=2:
    print(combination(N,2)+combination(M,2))
elif N>=2 and M<=2:
    print(combination(N,2))
else:
    print(combination(M,2))

Submission status: Runtime Error

Solution code:
import math
N,M=int(input())
def combination(n,r):
    return math.factrial(n)//(math.factrial(n-r)*math.factrial(r))
if N>=2 and M>=2:
    print(combination(N,2)+combination(M,2))
elif N>=2 and M<=2:
    print(combination(N,2))
else:
    print(combination(M,2))

Submission status: Runtime Error

Solution code:
import math
N,M=int(input())
def combination(n,r):
    return math.factrial(n)//math.factrial(n-r)*math.factrial(r)
if N>=2 and M>=2:
    print(combination(N,2)+combination(M,2))
elif N>=2 and M<=2:
    print(combination(N,2))
else:
    print(combination(M,2))

Submission status: Runtime Error

Solution code:
import math
N,M=int(input())
def combination(n,r):
    return math.factrial(n)//math.factrial(n-r)*math.factrial(r)
print(combination(N,M))

Submission status: Runtime Error

Solution code:
import math
N,M=input()
def combination(n,r):
    return math.factrial(n)//math.factrial(n-r)*math.factrial(r)
print(combination(N,M))

Submission status: Runtime Error

Solution code:
n=int(input())
m=int(input())
k =(n*(n-1))//2
j=(m*(m-1))//2
print(j+k)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(inr(a*(a-1)/2)))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int((b*(b-1)/2)))
else:
    print(str(int((a*(a-1)/2)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
test

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print((int(input()))**3/27)

Submission status: Runtime Error

Solution code:
# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 0:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)

Submission status: Runtime Error

Solution code:
from math import factorial

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

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

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

print(combN + combM)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split)
ans = 0
for x in range(N):
    for y in range(M):
        if x * 2 + y % 2 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

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

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

print( ans )

Submission status: Runtime Error

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())
    print(combinations_count(n, 2) + combinations_count(m, 2))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
L=len(S)
ans='No'
    if S[:(L-1)/2+1]==S[(L-1)/2+1::-1] and S[L+3/2:]==S[:(L+3/2)-1:-1]:
    ans='Yes'
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l=int(input())

import numpy as np
result = 0
for x in np.arange(l/3-0.1, l/3+0.1, 0.1):
  for y in np.arange(x, l/3+0.1, 0.1):
    z = l - (x+y)
    if z <= 0:
      break
    v = x*y*z
    result = max(v, result)
print(result)

Submission status: Runtime Error

Solution code:

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

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

Submission status: Runtime Error

Solution code:
import math

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

#偶数偶数
Nf = math.factorial(N)/math.factorial(N-2)/2

#奇数奇数
Mf = math.factorial(M)/math.factorial(M-2)/2

ans = int(Nf + Mf)

print(ans)

Submission status: Runtime Error

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

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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
ans += combi(M,2)
ans += combi(N,2)
print(ans)

Submission status: Runtime Error

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
ans += combi(M,2)
ans += combi(N,2)
print(ans)

Submission status: Runtime Error

Solution code:
import math
def combi(n,r):
  ans = math.factorial(N) // (math.factorial(n-r) * math.factorial(r))
  return ans

M = int(input())
N = int(input())

ans = 0
ans += combi(M,2)
ans += combi(N,2)
print(ans)

Submission status: Runtime Error

Solution code:
l=int(input())
ans=0
sum=0
 
for i in range(l):
 for j in range(l-i):
   sum=i*j*(l-i-j)
   if ans<sum:
      ans=sum
print(ans)

Submission status: Runtime Error

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

print(r)

Submission status: Runtime Error

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

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

if n == 1:
    n_ans = 0
else:
    n_ans = solve(n) // (solve(n - 2) * 2)
if m == 1:
    m_ans = 0
else:
    m_ans = solve(m) // (solve(m - 2) * 2)
ans = n_ans + m_ans
print(ans)

Submission status: Runtime Error

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

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

print(str(a))

Submission status: Runtime Error

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

ans1 = 0
if N > 1:
  ans1 = math.factorial(N)/math.factorial(N-2)/2
ans2 = 0
if N > 1:
  ans2 = math.factorial(M)/math.factorial(M-2)/2
print(int(ans1 + ans2))

Submission status: Runtime Error

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

ans1 = 0
if N != 0:
  ans1 = math.factorial(N)/math.factorial(N-2)/2
ans2 = 0
if N != 0:
  ans2 = math.factorial(M)/math.factorial(M-2)/2
print(int(ans1 + ans2))

Submission status: Runtime Error

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

ans1 = math.factorial(N)/math.factorial(N-2)/2
ans2 = math.factorial(M)/math.factorial(M-2)/2
print(int(ans1 + ans2))

Submission status: Runtime Error

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

ans1 = math.factorial(N)//math.factorial(N-2)//2
ans2 = math.factorial(M)//math.factorial(M-2)//2
print(ans1 + ans2)