Problem:
 Score : 200 points    Problem Statement There are four towns, numbered 1,2,3 and 4 .
Also, there are three roads. The i -th road connects different towns a_i and b_i bidirectionally.
No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.      Constraints  1 \leq a_i,b_i \leq 4(1\leq i\leq 3)  a_i and b_i are different. (1\leq i\leq 3)  No two roads connect the same pair of towns.  Any town can be reached from any other town using the roads.         Input Input is given from Standard Input in the following format:  a_1  b_1  a_2  b_2  a_3  b_3       Output If we can visit all the towns by traversing each of the roads exactly once, print YES ; otherwise, print NO .        Sample Input 1 4 2
1 3
2 3      Sample Output 1 YES  We can visit all the towns in the order 1,3,2,4 .       Sample Input 2 3 2
2 4
1 2      Sample Output 2 NO       Sample Input 3 2 1
3 2
4 3      Sample Output 3 YES

Solution (Python):
from collections import Counter
lis = [0 for i in range(4)]
for i in range(3):
    a,b = map(int,input().split())
    lis[a-1] += 1
    lis[b-1] += 1
if lis.count(2) == 2:
    print("YES")
else:print("NO")

Solution (Python):
path = {1: 0, 2: 0, 3: 0, 4: 0}
odd = 0
for _ in range(3):
    ai, bi = map(int, input().split())
    path[ai] += 1
    path[bi] += 1

for count in path.values():
    if count % 2 == 1:
        odd += 1

if odd == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
city=[0,0,0,0]

for i in range(3):
    a,b=map(int,input().split())
    city[a-1]+=1
    city[b-1]+=1

flag=0
for i in range(4):
    if city[i]==0:
        print("NO")
        flag=1
    elif city[i]>=3:
        print("NO")
        flag=1

if flag==0:
    print("YES")

Solution (Python):

"""
Created on Sat Feb  9 20:33:11 2019

@author: Yamazaki Kenichi
"""

A = [list(map(int,input().split())) for i in range(3)]

a=[]
for j in range(3):
    for i in range(2):
        a.append(A[j][i])
        
ans = 'YES'
for i in range(1,5):
    if a.count(i) >=3 :
        ans ='NO'
        
print(ans)

Solution (Python):
ab = [list(map(int, input().split())) for _ in range(3)]

counter = [0] * 4
for i in ab:
    for j in i:
        counter[j-1] += 1
counter.sort()

if counter == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Solution (Python):


















import collections
import math
def inpl(): return list(map(int, input().split()))


a_1, b_1 = map(int,input().split())
a_2, b_2 = map(int,input().split())
a_3, b_3 = map(int,input().split())

ans = [a_1, b_1, a_2, b_2, a_3, b_3]
c = collections.Counter(ans)
if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2 and c.most_common()[2][1] == 1 and c.most_common()[3][1] == 1:
  print("YES")
else:
  print("NO")

Solution (Python):
ab=[0,0,0,0]
for i in range(3):
    a,b=map(int,input().split())
    ab[a-1]+=1
    ab[b-1]+=1
ab.sort()
if ab==[1,1,2,2]:
    print('YES')
else:
    print('NO')

Solution (Python):

from collections import defaultdict
from itertools import permutations
def inpl(): return list(map(int, input().split()))

D = defaultdict(int)
for _ in range(3):
    x, y = inpl()
    D[(x-1, y-1)] = 1
    D[(y-1, x-1)] = 1

for X in permutations(range(4)):
    
    for i in range(3):
        if D[(X[i], X[i+1])] == 0:
            break
    else:
        print("YES")
        break
else:
    print("NO")

Solution (Python):
import sys

input = sys.stdin.readline
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
roads = [a1, b1, a2, b2, a3, b3]
roads.sort()
check = [1, 2, 2, 3, 3, 4]
flag = 0
for i in range(6):
    if roads[i] != check[i]:
        flag = 1
        break
if flag == 0:
    print('YES')
else:
    print('NO')

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())












a =[]
for i in range(3):
    b = [int(i) for i in input().split()]
    b.sort()
    a.append(b)
if [1,2] in a and [3,4] in a:j(1)
if [1,3] in a and [2,4] in a:j(1)
if [1,4] in a and [2,3] in a:j(1)
j(0)

Solution (Python):
l=[0]*4
for _ in range(3):
    a,b=map(int, input().split())
    l[a-1]+=1
    l[b-1]+=1
l.sort()
if l[0]==1 and l[1]==1 and l[2]==2 and l[3]==2:
    print('YES')
else:
    print('NO')

Solution (Python):
c = []
for i in range(3):
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
one = 2
two = 2
for i in range(1, 5):
    if c.count(i) == 1:
        one -= 1
    elif c.count(i) == 2:
        two -= 1
if one == 0 and two == 0:
    print("YES")
else:
    print("NO")

Solution (Python):
import math
import sys
from operator import itemgetter









rt1 = list(map(int, input().split()))
rt2 = list(map(int, input().split()))
rt3 = list(map(int, input().split()))

for r in rt1:
	if (r in rt2) and (r in rt3):
		print("NO")
		sys.exit()
print("YES")

Solution (Python):

"""
Created on Sat Feb  9 21:05:16 2019

@author: doppe
"""
count = [0, 0, 0, 0]

for i in range (0, 3):
    a, b = map(int, input().split())
    count[a - 1] += 1
    count[b - 1] += 1
flag = 0
for i in count:
    if(i >= 3):
        flag = 1
        break
if (flag == 1):
    print('NO')
else:
    print('YES')

Solution (Python):
P = [0] * 4
for _ in range(3):
    a, b = map(int, input().split())
    P[a-1] += 1
    P[b-1] += 1
if max(P) == 3:
    print('NO')
else:
    print('YES')

Solution (Python):
a=[0]*5
x,y=map(int,input().split())
a[x]+=1
a[y]+=1
x1,y1=map(int,input().split())
a[x1]+=1
a[y1]+=1
x2,y2=map(int,input().split())
a[x2]+=1
a[y2]+=1
b=[]
for i in range(1,5):
  b.append(a[i])
b.sort()
if(b[0]==1 and b[1]==1 and b[2]==2 and b[3]==2):
  print("YES")
else:
  print("NO")

Solution (Python):
import numpy as np
a1,b1 = list(map(int, input().split()))
a2,b2 = list(map(int, input().split()))
a3,b3 = list(map(int, input().split()))

a = [a1,a2,a3]
b = [b1,b2,b3]

from collections import Counter

c = Counter(a+b)

x = 0
y = 0
for k in c.keys():
    if c[k] == 1:
        x += 1

if x != 2:
    print('NO')
else:
    print('YES')

Solution (Python):
path = [list(map(int, input().split())) for _ in range(3)]
counter = [0, 0, 0, 0, 0]
for p in path:
    counter[p[0]] += 1
    counter[p[1]] += 1
if 3 in counter:
    print('NO')
else:
    print('YES')

Solution (Python):
a1,a2 = map(int,input().split())
a3,a4 = map(int,input().split())
a5,a6 = map(int,input().split())
x = [0,0,0,0,0]
x[a1]+=1
x[a2]+=1
x[a3]+=1
x[a4]+=1
x[a5]+=1
x[a6]+=1
del x[0]
if 0 in x or 3 in x:
    print('NO')
else:
    print('YES')

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

dict = {1: 0, 2: 0, 3: 0, 4: 0}

dict[a1] += 1
dict[a2] += 1
dict[a3] += 1
dict[b1] += 1
dict[b2] += 1
dict[b3] += 1

odd_points = 0
for key in dict:
    if dict[key] % 2 == 1:
        odd_points += 1

if odd_points == 0 or odd_points == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
l=l1+l2+l3
if l.count(1)>2 or l.count(2)>2 or l.count(3)>2 or l.count(4)>2:
  print('NO')
else:
  print('YES')

Solution (Python):
import collections

a = []
for i in range(3):
    a += (list(map(int, input().split())))

c = collections.Counter(a)
ans = c.most_common()

flg = "NO"

if (ans[0][1]) == 2:
    if (ans[0][1]) == 2:
        if (ans[2][1]) == 1:
            if (ans[3][1]) == 1:
                flg = "YES"

print(flg)

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    cities = []
    for _ in range(3):
        cities.extend(get_int_list())

    counter = Counter()
    for c in cities:
        counter[c] += 1
    c2 = Counter()
    for v in counter.values():
        c2[v] += 1
    if list(c2.values()) == [2, 2]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
a1,b1 = input().split()
a2,b2 = input().split()
a3,b3 = input().split()
a1 = int(a1)
b1 = int(b1)
a2 = int(a2)
b2 = int(b2)
a3 = int(a3)
b3 = int(b3)
list = [a1,a2,a3,b1,b2,b3]
if list.count(1) == 3 or list.count(2) == 3 or list.count(3) == 3 or list.count(4) == 3:
    print("NO")
else:
    print("YES")

Solution (Python):
import itertools
ab = [list(map(int,input().split())) for _ in range(3)]


for a in (list(itertools.permutations(ab))):
    for f in [a[0],list(reversed(a[0]))]:
        for g in [a[1],list(reversed(a[1]))]:
            for h in [a[2],list(reversed(a[2]))] :
                if f[1]==g[0] and g[1]==h[0] and len(set([f[0],g[0],h[0],h[1]]))==4:
                    print("YES")
                    exit()


print("NO")

Solution (Python):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
path=[]
c=[0,0,0,0]
used=[False for i in range(4)]
for i in range(3):
    a,b=IL()
    c[a-1]+=1
    c[b-1]+=1
    path.append([a-1,b-1])
c.sort()
if c==[1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
c1=0
c2=0
c3=0
c4=0
a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    for j in range(2):
        if a[i][j] == 1 :
            c1 += 1
        elif a[i][j] == 2 :
            c2 += 1
        elif a[i][j] == 3 :
            c3 += 1
        else:
            c4 += 1
if max(c1,c2,c3,c4) > 2:
    print('NO')
else:
    print('YES')

Solution (Python):
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

for i in range(0,4):
    if i+1 == a or i+1 == b:
        if i+1 == c or i+1 == d:
            if i+1 == e or i+1 == f:
                print("NO")
                exit()

print("YES")

Solution (Python):
import collections

path = []

for _ in range(3):
    a,b = map(int,input().split())
    path.append(a)
    path.append(b)

c = collections.Counter(path)
if set(c.values()) == {1,2}:
    print("YES")
else:
    print("NO")

Solution (Python):
list=[];

for i in range(3):
    A, B = map(int, input().split())
    list.append(A);
    list.append(B);

townNum=[3,3,3,3];
result=0;

for i in list:
    townNum[i-1]-=1;
    if(townNum[i-1]==0):
        result=1;
        break;

if(result==1):
    print("NO");
else:
    print("YES");

Solution (Python):
import numpy as np

ll = []

li = list(map(int,input().split()))
ll += li
li = list(map(int,input().split()))
ll += li
li = list(map(int,input().split()))
ll += li

cnt = 0
cnt += ll.count(1)%2
cnt += ll.count(2)%2
cnt += ll.count(3)%2
cnt += ll.count(4)%2

if ll.count(1) > 2 or ll.count(2) > 2 or ll.count(3) > 2 or ll.count(4) > 2:
    print("NO")
    exit()

if cnt>2:
    print("NO")
else:
    print("YES")

Solution (Python):


def solve():
    *x1, = map(int, input().split())
    *x2, = map(int, input().split())
    *x3, = map(int, input().split())
    x = x1 + x2 + x3
    if max(x.count(i) for i in range(1,5)) <= 2:
        res = 'YES'
    else:
        res = 'NO'
    return str(res)
if __name__ == '__main__':
    print(solve())

Solution (Python):
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

counter = 0
for i in range(1,5):
	counter = 0
	if a1 == i or b1 == i:
		counter += 1
	if a2 == i or b2 == i:
		counter += 1
	if a3 == i or b3 == i:
		counter += 1
	if counter == 3:
		print("NO")
		exit()
		
print("YES")

Solution (Python):
a = []
for i in range(3):
    tmpa, tmpb = map(int, input().split())
    a.append(tmpa)
    a.append(tmpb)

count = []
for i in range(4):
    c = 0
    for j in range(6):
        if a[j] == i+1:
            c += 1
    count.append(c)

if max(count) >= 3:
    print('NO')
else:
    print('YES')

Solution (Python):





a = [0, 0, 0, 0, 0]
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1

a.sort()

if 1 == a[1] and 1 == a[2] and 2 == a[3] and 2 == a[4]:
    print('YES')
else:
    print('NO')

Solution (Python):



from collections import defaultdict

def solve():
    cnt = defaultdict(int)
    for i in range(3):
        a, b = input().split()
        cnt[a] += 1
        cnt[b] += 1
    ok = len(cnt.keys()) == 4
    one, two = 0, 0
    for v in cnt.values():
        if v == 1:
            one += 1
        if v == 2:
            two += 1
    ok = ok and (one == 2 and two == 2)
    print("YES" if ok else "NO")
    

if __name__=="__main__":
    solve()

Solution (Python):
from collections import defaultdict as dd
from itertools import permutations as p

d=dd(list)
a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

for i in p(range(1,5)):
  a=i[0]
  for j in i[1:]:
    if not j in d[a]:
      break
    a=j
  else:
    print("YES")
    break
else:
  print("NO")

Solution (Python):
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

Edge = defaultdict(lambda: 0)
for _ in [0]*3:
    a, b = inpl()
    Edge[a] += 1
    Edge[b] += 1

print(['YES', 'NO'][max(Edge.values()) == 3])

Solution (Python):
from collections import Counter
c = Counter()
count = [0,0,0,0]
for i in range(3):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    c[a] += 1
    c[b] += 1
for i in c:
    count[c[i]-1] += 1

if count == [2,2,0,0]:
    print('YES')
else:
    print('NO')

Solution (Python):
dic = {1:0, 2:0, 3:0, 4:0}

for _ in range(3):
    a, b = map(int, input().split(' '))
    dic[a] += 1
    dic[b] += 1
    
if sorted(list(dic.values())) == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Solution (Python):
A=[0,0,0,0]

for i in range(3):
  a,b=map(int,input().split())
  A[a-1]+=1
  A[b-1]+=1
  
A.sort()

if A[0]==A[1] and A[0]==1 and A[2] == A[3] and A[2]==2:
  print("YES")
else:
  print("NO")

Solution (Python):
A = []
B = []
for _ in range(3):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

counter = [-1, 0, 0, 0, 0]
for a in A:
    counter[a] += 1
for b in B:
    counter[b] += 1

for count in counter[1:]:
    if count == 3:
        print("NO")
        exit(0)

print("YES")

Solution (Python):
city = [0 for i in range(4)]
for i in range(3):
    a, b = map(int, input().split(' '))
    city[a-1] += 1
    city[b-1] += 1

count = 0
for i in range(4):
    if city[i] % 2 == 1:
        count += 1
if count <= 2:
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import Counter
a=[list(map(int, input().split())) for i in range(3)]
b=a[0]+a[1]+a[2]
b=Counter(b)
d=[2,2,1,1]
for i,j in b.most_common():
    if j in d:
        d.remove(j)
if d:print('NO')
else:print('YES')

Solution (Python):
count = [0, 0, 0, 0]

for i in range(3):
    a, b = map(int, input().split())
    count[a - 1] += 1
    count[b - 1] += 1

flag = True
for e in count:
    if e == 3:
        print("NO")
        flag = False
        break

if flag:
    print("YES")

Solution (Python):
a = []
b = []

x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)

for i in range(1,5):
    if a.count(i)+b.count(i)>= 2:
        continue
    if a.count(i)==1:
        k = b[a.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
    if b.count(i)==1:
        k = a[b.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
print('NO')

Solution (Python):
import collections
path = []
for i in range(3):
    path += list(map(int, input().split()))
path = collections.Counter(path)
if len(path.most_common()) == 4:
    if path.most_common()[0][1] == 2 and path.most_common()[1][1] == 2 and path.most_common()[2][1] == 1 and path.most_common()[3][1] == 1:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Solution (Python):
import collections
t = []
for i in range(3):
    a,b = map(int,input().split())
    t.append(a)
    t.append(b)
    
c = collections.Counter(t)

cv = []
for v in c.values():
    cv.append(v)
cv.sort()

if cv == [1,1,2,2]:
    print('YES')
else:
    print('NO')

Solution (Python):
arr=[]
for i in range(3):
    a,b=map(int, input().split(" "))
    if a in arr:
        arr.remove(a)
    else:
        arr.append(a)
    
    if b in arr:
        arr.remove(b)
    else:
        arr.append(b)

if len(arr)==2:
    print("YES")
else:
    print("NO")

Solution (Python):
a1, b1 = list(map(int, input().split()))
a2, b2 = list(map(int, input().split()))
a3, b3 = list(map(int, input().split()))
r = [a1, b1, a2, b2, a3, b3]
if r.count(1) <= 2 and r.count(2) <= 2 and r.count(3) <= 2 and r.count(4) <= 2:
    print('YES')
else:
    print('NO')

Solution (Python):

from collections import Counter


def main():
    ab = [
        [int(a) for a in input().split()]
        for _ in range(3)
    ]
    fl = [a for b in ab for a in b]

    c = Counter(fl)
    res = c.items()

    vvv = [v for k, v in res]

    if all(a in [1, 2] for a in vvv):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
x=[0,0,0,0]
for i in range(3):
    a,b=map(int,input().split())
    x[a-1]+=1
    x[b-1]+=1
y=0
for j in range(4):
    if x[j]%2==1:
        y+=1
if y>2:
    print('NO')
else:
    print('YES')

Solution (Python):
Edge = [[] for i in range(4)]
for i in range(3):
	a, b = map(int, input().split())
	Edge[a-1].append(b)
	Edge[b-1].append(a)
for edge in Edge:
	if len(edge) == 3:
		print("NO")
		break
else: print("YES")

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
d = {1:0, 2:0, 3:0, 4:0}
d[a1] += 1
d[a2] += 1
d[a3] += 1
d[b1] += 1
d[b2] += 1
d[b3] += 1
if 3 in d.values():
  print("NO")
else:
  print("YES")

Solution (Python):
import sys
ab = [list(map(int, input().split())) for _ in range(3)]
count = [0] * 5
for i in range(3):
    count[ab[i][0]] += 1
    count[ab[i][1]] += 1

for i in count:
    if i >= 3:
        print('NO')
        sys.exit(0)
print('YES')

Solution (Python):
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

l = []
for i in range(3):
  n,m = IL()
  l.append(n)
  l.append(m)

a = l.count(1)
b = l.count(2)
c = l.count(3)
d = l.count(4)

if a == 1 and b == 2 and c == 2 and d == 1:
  print("YES")
else:
  print("NO")

Solution (Python):
import math

c = [0, 0, 0, 0]
for i in range(3):
    a, b = [int(x) for x in input().split()]
    c[a-1] += 1
    c[b-1] += 1

c.sort()


if c == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
data = [list(map(int, input().split())) for _ in range(3)]

n = [0]*4

for d in data:
    for dd in d:
        n[dd-1] += 1

n.sort()
if n == [1,1,2,2]:
    print('YES')
else:
    print('NO')

Solution (Python):
n1,k1=map(int,input().split())
n2,k2=map(int,input().split())
n3,k3=map(int,input().split())
a=[0,0,0,0,0]
a[n1]+=1
a[n2]+=1
a[n3]+=1
a[k1]+=1
a[k2]+=1
a[k3]+=1
if a[4]==3 or a[1]==3 or a[2]==3 or a[3]==3 :
    print("NO")
else:
    print("YES")

Solution (Python):
now = [0, 0, 0, 0]

for i in range(3):
    a, b = map(int, input().split())
    now[a-1]+=1
    now[b-1]+=1
    
f1 = 0
f2 = 0

flag = -1

for i in range(4):
    if now[i]==1:
        f1 += 1
    elif now[i]==2:
        f2 += 1

if f1==2 and f2==2:
    flag = 1
    
if flag>0:
    print('YES')
else:
    print('NO')

Solution (Python):
a = [0,0,0,0]
for i in range(3):
  b,c = map(int, input().split())
  a[b-1] += 1
  a[c-1] += 1
a.sort()
if a == [1,1,2,2]:
  print("YES")
else:
  print("NO")

Solution (Python):
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

L = [a1,b1,a2,b2,a3,b3]

for i in range(1,5) :
    if L.count(i) >= 3 :
        ans = "NO"
        break
else :
    ans = "YES"

print(ans)

Solution (Python):

cnt = [0] * 4
for i in range(3):
    a, b = map(lambda x: int(x) - 1, input().split())
    cnt[a] += 1
    cnt[b] += 1
ans = all(x < 3 for x in cnt)
print(['NO', 'YES'][ans])

Solution (Python):
dim = [0] * 4
for i in range(3):
  a, b = map(int, input().split())
  dim[a-1] += 1
  dim[b-1] += 1

num_odd = sum([d % 2 for d in dim])
if num_odd in [0, 2]:
  print('YES')
else:
  print('NO')

Solution (Python):
L = []
for i in range(3):
  L.extend(list(map(int, input().split())))
check = []
for i in range(4):
  check.append(L.count(i+1))
if max(check)>2:
  print("NO")
else:
  print("YES")

Solution (Python):
a, b = [0]*3, [0]*3
for i in range(3):
    a[i], b[i] = map(int, input().split())

c = a + b
from collections import Counter
cnt = Counter(c).most_common()
if cnt[0][1] == 2 and cnt[1][1] == 2 and cnt[2][1] == 1 and cnt[3][1] == 1:
    print('YES')
else:
    print('NO')

Solution (Python):
L = []
for i in range(3):
    a, b = map(int, input().split())
    L += [a, b]
m = 0
for i in range(4):
    m = max(m, L.count(i + 1))
if m < 3:
    print('YES')
else:
    print('NO')

Solution (Python):
x1 = list(map(int,input().split()))
x2 = list(map(int,input().split()))
x3 = list(map(int,input().split()))
x1.sort()
x2.sort()
x3.sort()
count = []
for i in range(5):
  count.append(x1.count(i)+x2.count(i)+x3.count(i))
if max(count)>2:
  print("NO")
  exit()
if x1==x2 or x2==x3 or x3==x1:
  print("NO")
else:
  print("YES")

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
count = [0, 0, 0, 0]
count[a1 - 1] += 1
count[a2 - 1] += 1
count[a3 - 1] += 1
count[b1 - 1] += 1
count[b2 - 1] += 1
count[b3 - 1] += 1
if 3 in count:
    print("NO")
else:
    print("YES")

Solution (Python):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
cnt=[0]*4
cnt[a-1]+=1
cnt[b-1]+=1
cnt[c-1]+=1
cnt[d-1]+=1
cnt[e-1]+=1
cnt[f-1]+=1
if max(cnt)<3:
    print("YES")
else:
    print("NO")

Solution (Python):
a = [0]*4
for i in range(3):
    b,c = map(int,input().split())
    a[b-1] += 1
    a[c-1] += 1
a.sort()
if a == [1,1,2,2]:
    print('YES')
else:
    print('NO')

Solution (Python):
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

A = [a, b, c, d, e, f]
count= 0
for i in range(0, 5):
    ind = A.count(i)
    if(ind == 2):
        count+=1
if(count == 2):
    print("YES")
else:
    print("NO")

Solution (Python):
rec = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    rec[a - 1] += 1
    rec[b - 1] += 1
k = [0] * 4
for i in range(4):
    k[rec[i]] += 1
if k[2] == 2 and k[1] == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
query = [0,0,0,0]
for i in range(3):
 a,b = (int(i) for i in input().split())
 query[a-1] += 1
 query[b-1] += 1
query.sort()
if query == [1,1,2,2]:
  print('YES')
else: print('NO')

Solution (Python):
import math

a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())

lis=[0,0,0,0,0]
lis[a1]+=1
lis[b1]+=1
lis[a2]+=1
lis[b2]+=1
lis[a3]+=1
lis[b3]+=1

if(3 in lis):print("NO")
else:print("YES")

Solution (Python):
N = 4
M = 3
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    A += [a]
    B += [b]

ans = False


def dfs(v, S):
    global ans
    
    if len(S) == N:
        ans = True

    for i in range(M):
        if v == A[i] and B[i] not in S:
            t = set(S)
            t.add(B[i])
            dfs(B[i], t)
        if v == B[i] and A[i] not in S:
            t = set(S)
            t.add(A[i])
            dfs(A[i], t)

dfs(1, set([1]))
if ans:
    print("YES")
else:
    print("NO")

Solution (Python):
ab=[list(map(int, input().split())) for _ in range(3)]
tmp=[0]*4
for i in range(3):
    tmp[ab[i][0]-1]+=1
    tmp[ab[i][1]-1]+=1
tmp2=sorted(tmp)
print("YES" if tmp2==[1, 1, 2, 2] else "NO")

Solution (Python):




def main():
    a1, b1 = list(map(int, input().split()))
    a2, b2 = list(map(int, input().split()))
    a3, b3 = list(map(int, input().split()))
    l = [0 for _ in range(5)]
    l[a1] += 1
    l[b1] += 1
    l[a2] += 1
    l[b2] += 1
    l[a3] += 1
    l[b3] += 1
    for n in range(1, 5):
        if l[n] == 0 or l[n] == 3:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

ab = []

for i in range(0, 3):
    ai, bi = [int(_) for _ in input().split()]
    ab.append(ai)
    ab.append(bi)

c = Counter(ab)
lis = sorted(list(c.values()))
if lis[0] == 1 and lis[1] == 1 and lis[2] == 2 and lis[3] == 2:
    print('YES')
else:
    print('NO')

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(AB):
    c = Counter()
    for a, b in AB:
        c[a] += 1
        c[b] += 1
    
    return 'YES' if c[c.most_common()[0][1]] == 2 else 'NO'


def main():
    AB = [read_int_n() for _ in range(3)]
    print(slv(AB))


if __name__ == '__main__':
    main()

Solution (Python):
N = 4


def main():
    deg = [0] * N
    for _ in range(N - 1):
        a, b = (int(z) - 1 for z in input().split())
        deg[a] += 1
        deg[b] += 1
    num_even = sum(d % 2 == 0 for d in deg)
    num_odd = N - num_even
    if num_odd == 0 or num_odd == 2 and num_even == N - 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Solution (Python):
s=[0]*4
for i in range(3):
    a,b=map(int,input().split())
    s[a-1]+=1
    s[b-1]+=1
s.sort()
print("NO" if s[:2]!=[1,1] or s[2:]!=[2,2] else "YES")

Solution (Python):
p = []
for _ in range(3):
  a,b = list(map(int, input().split()))
  p.append(a)
  p.append(b)
f = True
for c in list(set(p)):
  if p.count(c) == 3:
    f = False
print('YES' if f else 'NO')

Solution (Python):

a,b = map(int,input().split(" "))
c,d = map(int,input().split(" "))
e,f = map(int,input().split(" "))

dic = {1:0,2:0,3:0,4:0}
dic[a] += 1
dic[b] += 1
dic[c] += 1
dic[d] += 1
dic[e] += 1
dic[f] += 1

for key , val in dic.items():
    if val == 0 or val >= 3:
        print("NO")
        exit(0)

print("YES")

Solution (Python):
array = [0, 0, 0, 0]

for i in range(3):
    a, b = map(int, input().split())
    array[a-1]+=1
    array[b-1]+=1

print('YES' if max(array) == 2 else 'NO')

Solution (Python):
count = [0 for i in range(4)]
for i in range(3):
    a,b=list(map(int,input().split()))
    count[a-1]+=1
    count[b-1]+=1
    
count.sort()

if count[0]==1 and count[1]==1 and count[2]==2 and count[3]==2:
    print("YES")
else:
    print("NO")

Solution (Python):
Data = [0, 0, 0, 0]

for i in range(3):
  D = list(map(int, input().split()))
  Data[D[0] - 1] += 1
  Data[D[1] - 1] += 1

if 0 in Data or 3 in Data:
  print("NO")
else:
  print("YES")

Solution (Python):
import sys, os

def main():
	arr = [0,0,0,0]
	for _ in range(3):
		a,b = map(int, input().split())
		arr[a-1] += 1
		arr[b-1] += 1
	flg = True
	for i in range(4):
		if arr[i] is 3:
			flg = False
		if arr[i] is 0:
			flg = False
	print("YES" if flg else "NO")
	return

main()

Solution (Python):
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

s = [0, 0, 0, 0]

s[a-1]+= 1
s[b-1] += 1
s[c-1] += 1
s[d-1] += 1
s[e-1] += 1
s[f-1] += 1

if(max(s)==3):
    print('NO')
else:
    print('YES')

Solution (Python):
ab = [0, 0, 0, 0]
for _ in range(3):
  a, b = map(int, input().strip().split())
  ab[a-1] += 1
  ab[b-1] += 1
  
if ab.count(2) == 2 and ab.count(1) == 2:
  print('YES')
else:
  print('NO')

Solution (Python):
ab = [list(map(int, input().split())) for i in range(3)]

d= {}
d[1] = 0
d[2] = 0
d[3] = 0
d[4] = 0
for tmp in ab:
    d[tmp[0]] += 1
    d[tmp[1]] += 1
if max(d.values()) > 2:
    print('NO')
else:
    print('YES')

Solution (Python):





from collections import Counter


a1, b1 = list(map(int, input().split(" ")))
a2, b2 = list(map(int, input().split(" ")))
a3, b3 = list(map(int, input().split(" ")))

c = Counter([a1, b1, a2, b2, a3, b3])

if c.most_common(1)[0][1] == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
L=[0,0,0,0,0]

for i in range(3):
    a,b=map(int,input().split())
    L[a]+=1
    L[b]+=1
    
if max(L)==2:
    print("YES")
else:
    print("NO")

Solution (Python):
L = [0] * 4

for i in range(3):
    a, b = map(int, input().split())
    L[a - 1] += 1
    L[b - 1] += 1

odd_count = 0
for l in L:
    if l % 2 == 1:
        odd_count += 1

if odd_count not in (0, 2):
    print("NO")
else:
    print("YES")

Solution (Python):
A=[]
for i in range(3):
  a,b=map(int,input().split())
  A.append(a)
  A.append(b)
B=[]
for i in range(1,5):
  B.append(A.count(i))
if 3 in B:
  print("NO")
else:
  print("YES")

Solution (Python):
a = []
b = []
for i in range(3):
  x,y = map(int, input().split())
  a += [x-1]
  b += [y-1]

haji = [0,0,0,0]
for i in range(3):
  haji[a[i]] += 1
  haji[b[i]] += 1
  
cont = 0
for p in haji:
  if p == 1:cont+=1
if cont ==2:
  print("YES")
else:
  print("NO")

Solution (Python):

ab = [list(map(int, input().split())) for i in range(3)]

tab = [0] * 4
for ai, bi in ab:
    tab[ai - 1] += 1
    tab[bi - 1] += 1

if 0 in tab: print('NO')
elif 3 in tab: print('NO')
else: print('YES')

Solution (Python):


d = {i:0 for i in range(4)}

for _ in range(3):
    A, B = map(int, input().split())
    d[A-1] += 1
    d[B-1] += 1

if max(d.values()) == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    a1,b1 = map(int, input().split())
    a2,b2 = map(int, input().split())
    a3,b3 = map(int, input().split())
    ans = [0,0,0,0]
    ans[a1-1]+=1
    ans[b1-1]+=1
    ans[a2-1]+=1
    ans[b2-1]+=1
    ans[a3-1]+=1
    ans[b3-1]+=1
    if max(ans)==3:
        print('NO')
    else:
        print('YES')

Solution (Python):
vec = [0 for _ in range(4)]
for i in range(3):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    vec[a]+=1
    vec[b]+=1

cnt = 0
for x in vec:
    if x%2==1:
        cnt+=1

if cnt >2:
    print('NO')
else:
    print('YES')