Problem:
Score : 100 points

Problem Statement

There are two buttons, one of size A and one of size B.

When you press a button of size X, you get X coins and the size of that button decreases by 1.

You will press a button twice. Here, you can press the same button twice, or press both buttons once.

At most how many coins can you get?

Constraints

All values in input are integers.

3 \leq A, B \leq 20

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of coins you can get.

Sample Input 1

5 3

Sample Output 1

9

You can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.

Sample Input 2

3 4

Sample Output 2

7

Sample Input 3

6 6

Sample Output 3

12

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

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        
        int[] nk = cin.arrayInt(2);
        int n = nk[0];
        int k = nk[1];
        string s = ReadLine();
        List<int> renzoku = new List<int>();
        int count = 0;
        int now = 1;
        if (s[0] == "0"[0]) {
            renzoku.Add(0);
            now = 0;
        }
        for (int a = 0; a < n; a++)
        {
            if (now == int.Parse(s[a].ToString())) count++;
            else
            {
                now ^= 1;
                renzoku.Add(count);
                count = 0;
                count++;
            }
            
        }
        renzoku.Add(count);
        //累積和
        var sum = new int[renzoku.Count+1];
        for(int a = 0; a < sum.Length-1; a++)
        {
            sum[a + 1] += renzoku[a] + sum[a];
        }

        if (s[s.Length-1]=="0"[0]) renzoku.Add(0);
        int max = 0;
        for(int a = 0; a < renzoku.Count; a+=2)
        {
            int left = a;
            int right = Math.Min(a + k * 2 + 1, renzoku.Count);

            max = Math.Max(max,sum[right]-sum[left]);
        }

        WriteLine(max);
        Console.ReadLine();

    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string input()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return input();
        i = 0;
        return s[i++];
    }

    public int inputInt()
    {
        return int.Parse(input());
    }
    public int[] arrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputInt() + add;
        }
        return Array;
    }

    public long inputLong()
    {
        return long.Parse(input());
    }

    public long[] arrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputLong() + add;
        }
        return Array;
    }

    public double inputDouble()
    {
        return double.Parse(input());
    }


    public double[] arrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputDouble() + add;
        }
        return Array;
    }
}