Problem:
Score : 100 points

Problem Statement

Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.
Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.

Constraints

x and y are integers.

1 ≤ x < y ≤ 12

Input

Input is given from Standard Input in the following format:

x y

Output

If x and y belong to the same group, print Yes; otherwise, print No.

Sample Input 1

1 3

Sample Output 1

Yes

Sample Input 2

2 4

Sample Output 2

No

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int h = int.Parse(s[0]);
            int w = int.Parse(s[1]);

            if(h % 3 == 0 || w % 3 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                int mx = h > w ? h : w;
                int mn = w < h ? w : h;
                int mx_h = mx / 3 + 1;
                int mx_w = mn;
                int d_mx = mx - mx_h;
                int mx1 = d_mx > mx_w ? d_mx : mx_w;
                int mn1 = mx_w < d_mx ? mx_w : d_mx;
                int mn_h = mx1 / 2;
                int mn_w = mn1;
                if(mn1 % 2 == 0)
                {
                    mn_h = mn1 / 2;
                    mn_w = mx1;
                }
                int diff1 = mx_h * mx_w - mn_h * mn_w;

                mx_h = mx / 3;
                mx_w = mn;
                d_mx = mx - mx_h;
                mx1 = d_mx > mx_w ? d_mx : mx_w;
                mn1 = mx_w < d_mx ? mx_w : d_mx;
                mn_h = mx1 / 2;
                mn_w = mn1;
                int mm_h = mn_h + (mx1 % 2);
                int mm_w = mn_w;
                if (mn1 % 2 == 0)
                {
                    mn_h = mn1 / 2;
                    mn_w = mx1;
                    mm_h = mn_h;
                    mm_w = mn_w;
                }
                int diffa = Math.Abs(mx_h * mx_w - mm_h * mm_w);
                int diffb = Math.Abs(mn_h * mn_w - mm_h * mm_w);
                int diff2 = diffa > diffb ? diffa : diffb;

                mx_h = mn / 3 + 1;
                mx_w = mx;
                d_mx = mn - mx_h;
                mx1 = d_mx > mx_w ? d_mx : mx_w;
                mn1 = mx_w < d_mx ? mx_w : d_mx;
                mn_h = mx1 / 2;
                mn_w = mn1;
                if (mn1 % 2 == 0)
                {
                    mn_h = mn1 / 2;
                    mn_w = mx1;
                }
                int diff3 = mx_h * mx_w - mn_h * mn_w;

                mx_h = mn / 3;
                mx_w = mx;
                d_mx = mn - mx_h;
                mx1 = d_mx > mx_w ? d_mx : mx_w;
                mn1 = mx_w < d_mx ? mx_w : d_mx;
                mn_h = mx1 / 2;
                mn_w = mn1;
                mm_h = mn_h + (mx1 % 2);
                mm_w = mn_w;
                if (mn1 % 2 == 0)
                {
                    mn_h = mn1 / 2;
                    mn_w = mx1;
                    mm_h = mn_h;
                    mm_w = mn_w;
                }
                diffa = Math.Abs(mx_h * mx_w - mm_h * mm_w);
                diffb = Math.Abs(mn_h * mn_w - mm_h * mm_w);
                int diff4 = diffa > diffb ? diffa : diffb;

                int diff = new List<int> { diff1, diff2, diff3, diff4 }.Min();
                
                Console.WriteLine(diff);
            }
        }
    }
}