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



Sample input:
1 3


Sample output:
Yes

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())

ans = 'Yes'
if x in a and y in a:
    pass
elif x in b and y in b:
    pass
elif x in c and y in c:
    pass
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]

# if (x in g1 and y and g1) or (x in g2 and y in g2) or (x in g3 and y in g3):
#     print("Yes")
# else:
#     print("No")


if x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y = (int(i) for i in input().split())
groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]
if x in groupA and y in groupA:
  print('Yes')
elif x in groupB and y in groupB :
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
x, y = input().split()

a = ['1', '3', '5', '7', '8', '10', '12']
b = ['4', '6', '9', '11']

if (x in a and y in a) or (x in b and y in b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# ABC 062
def getIntList(): return [int(x) for x in input().split()]

A = {1, 3, 5, 7, 8, 10, 12}
B = {4, 6, 9, 11}
C = {2}
x,y = getIntList()
res = 'No'
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C): res = 'Yes'
print(res)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
gs = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for g in gs:
  if x in g and y in g:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
x, y = [int(x) for x in input().split()]
g = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

print('Yes' if any([(x in i) and (y in i) for i in g]) else 'No')

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, input().split())
for g in [a, b, c]:
    if x in g and y in g:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
x,y = (int(i) for i in input().split())
groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]
if x in groupA and y in groupA:
  print('Yes')
elif x in groupB and y in groupB :
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a_list=[1,3,5,7,8,10,12]
b_list=[4,6,9,11]
c_list=[2]
x,y=map(int,input().split())
print("Yes" if (x in a_list and y in a_list) or (x in b_list and y in b_list) or (x in c_list and y in c_list) else "No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=[1,3,5,7,8,10,12]
p=[4,6,9,11]
print("Yes"if(a in s and b in s)or(a in p and b in p)else"No")

Submission status: Accepted

Solution code:
X = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())
if X[x] == X[y]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int,input().split())
if x==y:
    print("Yes")
else:
    if A.count(x)==1 and A.count(y)==1:
        print("Yes")
    elif B.count(x)==1 and B.count(y)==1:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
X,Y = map(int,input().split())

Ans = "No"
A = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in range(3):
    if X in A[i] and Y in A[i]:
        Ans = "Yes"

print(Ans)

Submission status: Accepted

Solution code:
gp1 = [1,3,5,7,8,10,12]
gp2 = [4,6,9,11]
gp3 = [2]
x,y = [int(i) for i in input().split()]

if ((x in gp1 and y in gp1) or (x in gp2 and y in gp2) or(x in gp3 and y in gp3)) :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
X, Y = [int(_) for _ in input().split()]

#        1  2  3  4  5  6  7  8  9 10 11 12
gs = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]

if gs[X] == gs[Y]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
a=[2,1,8,1,0,1,0,1,1,0,1,0,1]
if a[x]==a[y]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = [4,6,9,	11]
b = [1,3,5,7,8,10,12]
x,y = list(map(int, input().split()))
if x ==2 or y ==2:
  print("No")
elif x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

x, y = getInts()
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
print("Yes" if (x in g1 and y in g1) or (x in g2 and y in g2) or (x == y == 2) else "No")

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]:
	print('Yes')
elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
x,y = map(int,input().split())

a = ([1,3,5,7,8,10,12])
b = ([4,6,9,11])
c = ([2])


if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
int_x, int_y = map(int, input().split())

g_a = [1, 3, 5, 7, 8, 10, 12]
g_b = [4, 6, 9, 11]

if int_x in g_a and int_y in g_a:
    print("Yes")
elif int_x in g_b and int_y in g_b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
L=[4,6,9,11]*2+[2]
print(['No','Yes'][L.count(a)==L.count(b)])

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
L=[1,3,5,7,8,10,12]*3+[4,6,9,11]*2+[2]
print(['No','Yes'][L.count(a)==L.count(b)])

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
setA = []
setA.append({1, 3, 5, 7, 8, 10, 12})
setA.append({4, 6, 9, 11})
setA.append({2})
 
for s in setA:
  if x in s and y in s:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
def grp(x,y):
    if x in y:
        return 1
    else:
      	return 0
x,y = map(int,input().split())
if grp(x,A)*grp(y,A) or grp(x,B)*grp(y,B) or grp(x,C)*grp(y,C):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int,input().split())
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a ,b  = map(int, input().split())
g2 =  [4,6,9,11]
g1 =[1,3,5,7,8,10,12]
if a in g2 and b in g2:
    print("Yes")
elif a == 2 and b ==2:
    print("Yes")
elif a in g1 and b in g1:
    print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

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

if((a in A and b in A) or (a in B and b in B) or (a in C and b in C)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def abc062_a():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print("Yes")
    else:
        print("No")


abc062_a()

Submission status: Accepted

Solution code:
x, y = [int(i) for i in input().split()]
 
A = (1, 3, 5, 7, 8, 10, 12)
B = (4, 6, 9, 11)
 
if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a, b = (int(x) for x in input().split())
list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]

if ((a in list1) & (b in list1)):
  print("Yes")
elif ((a in list2) & (b in list2)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
G=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y=map(int,input().split())
for g in G:
  if x in g and y in g:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
x, y = (int(x) for x in input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if ((x in a) and (y in a)) or ((x in b) and (y in b)) or ((x in c) and(y in c)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x,y=input().strip().split()
Z=['1','3','5','7','8','10','12']
I=['4','6','9','11']
if x in Z and y in Z:
    print('Yes')
elif x in I and y in I:
    print('Yes')
elif x==y:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x, y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if(((x in A)and(y in A)) or ((x in B)and(y in B)) or (x == 2 and y == 2)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if a.count(x) == 1 and a.count(y) == 1:
    print("Yes")
elif b.count(x) == 1 and b.count(y) == 1:
    print("Yes")
elif x == 2 and y == 2:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
def group(x):
    if x == 2:
        return 2
    if x in [4, 6, 9, 11]:
        return 1
    return 0


def main():
    x, y = map(int, input().split())
    if group(x) == group(y):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
print("Yes" if (x in a and y in a) or (x in b and y in b) or (x in c and y in c) else "No")

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
l = [1,3,5,7,8,10,12]
m = [4,6,9,11]
if x==y:
    print('Yes')
    exit()
if x==2 or y==2:
    print('No')
    exit()
if x in l and y in l:
    print('Yes')
elif x in m and y in m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
if x in A:
    if y in A:
        print("Yes")
    else:
        print("No")
elif x in B:
    if y in B:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
x, y = [int(i) for i in input().split()]
if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
    if y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
        print("Yes")
    else:
        print("No")
elif x == 4 or x == 6 or x == 9 or x == 11:
    if y == 4 or y == 6 or y == 9 or y == 11:
        print("Yes")
    else:
        print("No")
else:
    if y == 2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
g=[0,2,0,1,0,1,0,0,1,0,1,0]
a,b=map(int,input().split())
print('Yes' if g[a-1]==g[b-1] else 'No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
group_1 = (1,3,5,7,8,10,12)
group_2 = (4,6,9,11)
group_3 = (2,)
if x in group_1 and y in group_1:
    print('Yes')
elif x in group_2 and y in group_2:
    print('Yes')
elif x in group_3 and y in group_3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()
a= []
for i in range(len(x)):
    a.append(int(x[i]))

z = [1,3,5,7,8,10,12]
y = [4,6,9,11]
if a[0] in [2] or a[1] in [2]:print("No")
elif a[0] in z and a[1] in  z: print("Yes")
elif a[0] in y and a[1] in y:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
x,y = map(int,input().split())
A = {1,3,5,7,8,10,12}
B = {4,6,9,11}
C = {2}
S = {x,y}
if (S <= A or S <= B) is True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    x, y = map(int, input().split())
    g1 = [1, 3, 5, 7, 8, 10, 12]
    g2 = [4, 6, 9, 11]
    g3 = [2]

    if x in g1 and y in g1:
        print("Yes")
    elif x in g2 and y in g2:
        print("Yes")
    elif x in g3 and y in g3:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x,y=[int(i) for i in input().split()]
a=[[1,3,5,7,8,10,12],[4,6,9,11]]
ans="No"
for i in [0,1]:
  if a[i].count(x) and a[i].count(y):
    ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
x, y = [int(i) for i in input().split()]

A = (1, 3, 5, 7, 8, 10, 12)
B = (4, 6, 9, 11)

if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
l = [3, 0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0]
x, y = map(int, input().split())
if l[x] == l[y]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
a=[1,3,1,2,1,2,1,1,2,1,2,1]
print(["No","Yes"][a[x-1]==a[y-1]])

Submission status: Accepted

Solution code:
x, y = map( int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if(x in a and y in a):
    print("Yes")

elif(x in b and y in b):
    print("Yes")

elif(x in c and y in c):
    print("Yes")

else:
    print('No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split(" "))
s = set([4,6,9,11])
if x == 2 or y == 2:
  print("No")
elif (x in s and y in s) or ((not x in s) and (not y in s)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
k = [1, 3, 5, 7, 8, 10, 12]
g = [4, 6, 9, 11]
g2 = [2]
if x in k and y in k:
    print("Yes")
elif x in g and y in g:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x, y = [int(_) for _ in input().split()]
ABC = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i in range(3):
    if x in ABC[i] and y in ABC[i]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
import sys
a=list(map(int,input().split()))
flg=0
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
for i in range(len(A)):
    if A[i]==a[0]:
        for j in range(len(A)):
            if A[j]==a[1]:
                flg=1
for i in range(len(B)):
    if B[i]==a[0]:
        for j in range(len(B)):
            if B[j]==a[1]:
                flg=1
if flg==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
group = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
x, y = map(int, input().split())
if group[x-1] == group[y-1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y = (int(x) for x in input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in a and y in b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x, y = list(map(int, input().split()))

gA = [1, 3, 5, 7, 8, 10, 12]
gB = [4, 6, 9, 11]
gC = [2]

flg = False
for g in [gA, gB, gC]:
    if x in g:
        if y in g:
            print("Yes")
            flg = True

if not flg:
    print("No")

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, input().split())

if x in a:
    flagx = 0
if x in b:
    flagx = 1
if x in c:
    flagx = 2
if y in a:
    flagy = 0
if y in b:
    flagy = 1
if y in c:
    flagy = 2
if flagx == flagy:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
g = [3,0,2,0,1,0,1,0,0,1,0,1,0]

x, y = list(map(int, input().split()))

if g[x]== g[y]:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
if x==1 or x==3 or x==5 or x==7 or x==8 or x==10 or x==12:
    ans = 1
elif x==4 or x==6 or x==9 or x==11:
    ans = 2
else:
    ans = 3
if y==1 or y==3 or y==5 or y==7 or y==8 or y==10 or y==12:
    sna = 1
elif y==4 or y==6 or y==9 or y==11:
    sna = 2
else:
    sna = 3
if ans == sna:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
t = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

x, y = list(map(int, input().rstrip().split()))

result = 'No'
for ti in t:
    if x in ti and y in ti:
        result = 'Yes'
        break;

print(result)

Submission status: Accepted

Solution code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

d=input().strip().split(" ")
e=[int(i) for i in d]

if (e[0] in a and e[1] in a):
    print("Yes")

elif e[0] in b and e[1] in b:
    print("Yes")

elif e[0] in c and e[1] in c:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
#062-A
par=[]
rank=[]
def init(a): #初期化
    for i in range(a):
        par.append(i)
        rank.append(0)
def find(x): #根を見つける
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
    return par[x]
def unite(x,y): #併合
    x=find(x)
    y=find(y)
    if rank[x]==rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1
    return
def same(x,y): #同じ集合か判定
    return find(x)==find(y)

init(12)
unite(0,2)
unite(0,4)
unite(0,6)
unite(0,7)
unite(0,9)
unite(0,11)
unite(3,5)
unite(3,8)
unite(3,10)

x,y=map(int,input().split())
print('Yes' if same(x-1,y-1) else 'No')

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
l=[[4,6,9,11],[2],[1,3,5,7,8,10,12]]
for i in l:
  if x in i:xx=l.index(i)
  if y in i:yy=l.index(i)
print('YNeos'[xx!=yy::2])

Submission status: Accepted

Solution code:
x, y = map(int, input().split())

P = [1, 3, 5, 7, 8, 10, 12]
Q = [4, 6, 9, 11]
R = [2]

if x in P:
    if y in P:
        print('Yes')
    else:
        print('No')
if x in Q:
    if y in Q:
        print('Yes')
    else:
        print('No')
if x in R:
    if y in R:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = [0,1,3,1,2,1,2,1,1,2,1,2,1]
if b[a[0]] == b[a[1]]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x, y = map(int,input().split( ))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

ans = 'No'
if x in a and y in a:
	ans = 'Yes'
elif x in b and y in b:
	ans = 'Yes'
elif x in c and y in c:
	ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
a,b = map(int,input().split(" "))
if a == 2 or b == 2:
  print("No")
elif a == 1 or a == 3 or a == 5 or a == 7 or a == 8 or a == 10 or a == 12:
  if b == 1 or b == 3 or b == 5 or b == 7 or b == 8 or b == 10 or b == 12:
    print("Yes")
  else:
    print("No")
elif a == 4 or a == 6 or a == 9 or a == 11:
  if b == 4 or b == 6 or b == 9 or b == 11:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
class UnionFind():
	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank= [1] * (n + 1)

	def root(self, x):
		return x if self.par[x] == x else self.root(self.par[x])
	
	def same(self, x, y):
		return self.root(x) == self.root(y)

	def unite(self, x, y):
		rx = self.root(x)
		ry = self.root(y)
		if rx == ry:
			return
		if self.rank[rx] < self.rank[ry]:
			self.par[rx] = ry
		else:
			self.par[ry] = rx
			if self.rank[rx] == self.rank[ry]:
				self.rank[rx] += 1
		
			
			
x, y = map(int, raw_input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
uf = UnionFind(12)
for i in g1:
	uf.unite(g1[0], i)
for i in g2:
	uf.unite(g2[0], i)
for i in g3:
	uf.unite(g3[0], i)

print "Yes" if uf.same(x, y) else "No"

Submission status: Accepted

Solution code:
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
x, y = map(int, input().split())
if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = set([1,3,5,7,8,10,12])
B = set([4,6,9,11])
L = set([int(i) for i in input().split()])
if len(A&L) == 2 or len(B&L) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = map(int, input().split())

if (x in a and y in a) or \
    (x in b and y in b) or \
    (x in c and y in c):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
array = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
x, y = map(int, input().split())
for i in range(len(array)):
    if x in array[i]:
        if y in array[i]:
            print('Yes')
            break
        else:
            print('No')
            break

Submission status: Accepted

Solution code:
import calendar

a,b = map(int,input().split())
_, lastday =calendar.monthrange(2018, a)
_, lastdayb = calendar.monthrange(2018,b)
print("Yes" if lastday == lastdayb else "No")

Submission status: Accepted

Solution code:
x,y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
if (x==2)or(y==2):
    print('No')
elif x in a:
    if y in a:
        print('Yes')
    else:
        print('No')
else:
    if y in b:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
gg = lambda t: [i for i in range(0, 3) if t in groups[i]][0]
x, y = map(int, input().split())
print('Yes' if gg(x) == gg(y) else 'No')

Submission status: Accepted

Solution code:
lis = [[1,3,5,7,8,10,12],[4,6,9,11],[2]];a,b = map(int,input().split())
for i in lis:
    if a in i and b in i:print("Yes");exit()
print("No")

Submission status: Accepted

Solution code:
import numpy as np
lis = np.array([[1,3,5,7,8,10,12],[4,6,9,11],[2]]);a,b = map(int,input().split())
for i in lis:
    if a in i and b in i:print("Yes");exit()
print("No")

Submission status: Accepted

Solution code:
A = [4,6,9,11]
x,y = map(int,input().split())
if x in A:
  x = 4
elif x != 2:
  x = 3
if y in A:
  y = 4
elif y != 2:
  y = 3
if x == y:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
num = list(map(int, input().split()))
if num[0]==2  or num[1] ==2:
	print('No')
elif num[0] == 4:
	if num[1] == 6 or num[1] == 9 or num[1] == 11:
		print('Yes')
	else:
		print('No')
elif num[0] == 6:
	if num[1] == 9 or num[1] == 11:
		print('Yes')
	else:
		print('No')
elif num[0] == 9:
	if num[1] == 11:
		print('Yes')
	else:
		print('No')
elif num[0] == 11:
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
x,y = map(int,input().split())

def check(n):
    if n == 2:
        return 1
    elif n == 4 or n == 6 or n == 9 or n == 11:
        return 2
    else:
        return 3

if check(x) == check(y):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a:
    if y in a:
        print('Yes')
        sys.exit()
if x in b:
    if y in b:
        print('Yes')
        sys.exit()
if x in c:
    if y in c:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
x,y=input().split()
L1=["1","3","5","7","8","10","12"]
L2=["4","6","9","11"]
L3=["2"]
if (x in L1 and y in L1) or (x in L2 and y in L2) or (x in L3 and y in L3):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
a=[1,2,1,3,1,3,1,1,3,1,3,1]
if a[x-1]==a[y-1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x, y = list(map(int, input().split()))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]

if x in a and y in a:
    print('Yes')

elif x in b and y in b:
    print('Yes')

elif x == 2 and y == 2:
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
x, y = map(int,input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if (x in a) and (y in a):
    print('Yes')
elif (x in b) and (y in b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
g1 = set([1, 3, 5, 7, 8, 10, 12])
g2 = set([4, 6, 9, 11])
g3 = set([2])

ans = "No"
for g in [g1, g2, g3]:
    if x in g and y in g:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input().split())
print('NYoe s'[a.count(x)==a.count(y)!=0 or b.count(x)==b.count(y)!=0 or c.count(x)==c.count(y)!=0::2])

Submission status: Accepted

Solution code:
group1 = ['1', '3', '5', '7', '8', '10', '12']
group2 = ['4', '6', '9', '11']
group3 = ['2']

x, y = input().split()
if x in group1 and y in group1:
    print('Yes')
elif x in group2 and y in group2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
g1=[1,3,5,7,8,10,12]
g2=[4,6,9,11]

if x in g1 and y in g1 or x in g2 and y in g2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y = map(int, input().split())

risuto1 = [1,3,5,7,8,10,12]
risuto2 = [4,6,9,11]
risuto3 = [2]

if x in risuto1 and y in risuto1:
    print("Yes")
elif x in risuto2 and y in risuto2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
a =[1,3,5,7,8,10,12]
b = [4,6,9,11]
c =[2]

def grouping(x,y):
  if x in a and y in a:
    print('Yes')
  elif x in b and y in b:
    print('Yes')
  elif x in c and y in c:
    print('Yes')
  else:
    print('No')


grouping(x,y)

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if a.count(x)*a.count(y) == 1 or b.count(x)*b.count(y) == 1 \
or c.count(x)*c.count(y):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x,y = map(int, input().split())
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
ans = "No"
for i in li:
  if x in i and y in i:
    ans = "Yes"
    break
print(ans)

Submission status: Accepted

Solution code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
x,y=map(int,input().split())
if x in a and y in a or x in b and y in b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
listB = [4, 6, 9, 11]
listA = [1, 3, 5, 7, 8, 10, 12]

if x == 2 or y == 2:
    print("No")
else:
    if x in listB and y in listB:
        print("Yes")
    elif x in listA and y in listA:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
#coding: utf-8
x, y = map(int, input().split())
group = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]
print(["No", "Yes"][group[x] == group[y]])

Submission status: Accepted

Solution code:
#coding: utf-8
x, y = map(int, input().split())

G1 = [1,3,5,7,8,10,12]
G2 = [4,6,9,11]

if (x in G1 and y in G1) or (x in G2 and y in G2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
a = {1,3,5,7,8,10,12}
b = {4,6,9,11}
if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split())

ans = 0

if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
    if y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
        ans = 1

elif x == 4 or x == 6 or x == 9 or x == 11:
    if y == 4 or y == 6 or y == 9 or y == 11:
        ans = 1

else:
    if y == 2:
        ans = 1

if ans == 1:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
l = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i in l:
    if x in i:
        print('Yes' if y in i else 'No')

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]
list_all = [list1, list2, list3]
for lis in list_all:
  if x in lis:
    if y in lis:
      print("Yes")
    else:
      print("No")
  else:
    continue

Submission status: Accepted

Solution code:
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
x, y = map( int, input().split())
if (x in A and y in A) or (x in B and y in B):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
g=[0,1,3,1,2,1,2,1,1,2,1,2,1];x,y=map(int,input().split());print('YNeos'[g[x]!=g[y]::2])

Submission status: Accepted

Solution code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
x,y=map(int,input().split())
if (x in a and y in a) or (x in b and y in b):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
a = [ 0,2,0,1,0,1,0,0,1,0,1,0 ]
if a[x-1] == a[y-1]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
X=[1,3,5,7,8,10,12]
Y=[4,6,9,11]
Z=[2]
x,y=map(int,input().split())
if (x in X and y in X) or (x in Y and y in Y) or  (x in Z and y in Z):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a,b  = map(int, input().split())
array = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]

result='No'
for arr in array:
  if  a in arr and b in arr:
    result='Yes'
print(result)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
g1, g2, g3 = {1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}
print('Yes' if not ({a, b} - g1) or not ({a, b} - g2) else 'No')

Submission status: Accepted

Solution code:
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x, y = list(map(int, input().split()))
if x in a:
  if y in a:
    ans = 'Yes'
  else:
    ans = 'No'
elif x in b:
  if y in b:
    ans = 'Yes'
  else:
    ans = 'No'
else:
  ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
L = [1,3,5,7,8,10,12]
M = [4,6,9,11]
N = [2]
if ((x in L and y in L) or (x in M and y in M) or (x in N and y in N)):
  print('Yes')
else:
  print('No')