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

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var h = r[0].ToInt();
            var w = r[1].ToInt();
            var k = r[2].ToInt();
            var ls = new List<string>();
            for (int i = 0; i < h; i++)
            {
                var s = Read();
                ls.Add(s);
            }
            var group = new int[10][];
            for (int i = 0; i < 10; i++) group[i] = new int[1005];
            var INF = 1001001;
            var ans = INF;
            for (int div = 0; div < 1 << h; div++)
            {
                var g = 0;
                var gId = new List<int>();
                for (int i = 0; i < h; i++)
                {
                    gId.Add(g);
                    if ((div >> i & 1)== 1)
                    {
                        g++;
                    }
                }
                g++;
                for (int i = 0; i < g; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        group[i][j] = 0;
                    }
                }
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        group[gId[i]][j] += ls[i][0] == '1' ? 1 : 0;
                    }
                }

                var ok = true;
                for (int i = 0; i < g; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (group[i][j] > k) ok = false;
                    }
                }
                if (!ok) continue;

                int num = g - 1;
                var now = new int[g];

                var add = new Predicate<int>(x =>
                {
                    for (int i = 0; i < g; i++)
                    {
                        now[i] += group[i][x];
                    }
                    for (int i = 0; i < g; i++)
                    {
                        if (now[i] > k) return false;
                    }
                    return true;
                });

                for (int j = 0; j < w; j++)
                {
                    if (!add(j))
                    {
                        num++;
                        now = new int[g];
                        add(j);
                    }
                }
                ans = Math.Min(ans, num);
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {   
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}