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):
import sys
import itertools
a = [list(map(int, input().split())) for _ in range(3)]

for x in itertools.permutations([1,2,3,4]):
  for i in range(3):
    f = False
    for y in a:
      if y[0]==x[i]and y[1]==x[i+1]:
        f = True
        break
      elif y[1]==x[i]and y[0]==x[i+1]:
        f = True
        break
    if not f: break
    if i==2:
      print("YES")
      sys.exit()
print("NO")

Solution (Python):
lis = [0,0,0,0]
for _ in range(3):
  n,m = list(map(int,input().split()))
  lis[n-1] += 1
  lis[m-1] += 1
if 3 in lis:
  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())

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

if r_city_list.count(1) == 3 or r_city_list.count(2) == 3 or r_city_list.count(3) == 3 or r_city_list.count(4) == 3:
    print('NO')
else:
    print('YES')

Solution (Python):
import collections

ab = []
for i in range(3):
    a, b = [int(s) for s in input().split()]
    ab.append((a, b))

count = collections.Counter()
for a, b in ab:
    count[a] += 1
    count[b] += 1

cnt = 0
for key, value in count.items():
    if value >= 2:
       cnt += 1
if cnt >= 2:
    print('YES')
else:
    print('NO')

Solution (Python):
a = []
for _ in range(3):
    a = a + [int(i) for i in input().split()]
b = []
for j in [1,2,3,4]:
    b.append(a.count(j))
b = set(b)
if b == set([1,2]):
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import Counter
towns = []
for i in range(3):
    ai, bi = map(int, input().split())
    towns.append(ai)
    towns.append(bi)
counter = Counter(towns)
if set(list(counter.values())) == set([1, 2]):
    print('YES')
else:
    print('NO')

Solution (Python):
[a1,b1] = [int(i)-1 for i in input().split()]
[a2,b2] = [int(i)-1 for i in input().split()]
[a3,b3] = [int(i)-1 for i in input().split()]

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

route = {0:0,1:0,2:0,3:0}
for i in s:
    route[i] += 1

ok = 1
for i in range(4):
    if route[i] != 1 and route[i] != 2:
        ok = 0

if ok == 1:
    print("YES")
else:
    print("NO")

Solution (Python):
l = [0 for _ in range(4)]

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

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

Solution (Python):

city = [0, 0, 0, 0]

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

two = 0

for i in range(4):
  if city[i] == 2:
    two += 1

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

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
e=[0 for i in range(4)]
for i in range(3):
 [x,y]=i2()
 e[x-1]+=1
 e[y-1]+=1
e.sort()
e=tuple(e)
if e==(1,1,2,2):
  print("YES")
else:
  print("NO")

Solution (Python):
cnt = [0] * 100
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"

Solution (Python):

p = [0]*4

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

odd = 0
even = 0
for x in p:
    if x%2==1:
        odd += 1
    else:
        even += 1

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

Solution (Python):
a = []
b = []
res = [0]*4
two = 0

for i in range(3):
    a1,b1 = map(int,input().split())
    a.append(a1)
    b.append(b1)

for i in range(3):
    for j in range(1,4):
        if a[i]==j:
            res[j] += 1
        if b[i]==j:
            res[j] += 1

for i in range(4):
    if res[i] == 2:
        two += 1
else:
    if two==2:
        print("YES")
    else:
        print("NO")

Solution (Python):
def main():
    counts = [0, 0, 0, 0]
    for _ in range(3):
        v0, v1 = map(int, input().split())
        counts[v0 - 1] += 1
        counts[v1 - 1] += 1
    if max(counts) >= 3:
        print("NO")
    else:
        print("YES")


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter


def solve(ABs):
    ac = Counter([a for (a, b) in ABs] + [b for (a, b) in ABs])
    if "".join(sorted([str(v) for v in ac.values()])) == "1122":
        return "YES"
    else:
        return "NO"


if __name__ == "__main__":
    ABs = [tuple(map(int, input().split(" "))) for _ in range(3)]
    print(solve(ABs))

Solution (Python):
list1 = input().split()
list2 = input().split()
list3 = input().split()
flag = 0
for i in range(len(list1)):
  list1[i] = int(list1[i])
  i = i + 1
i=0
for i in range(len(list2)):
  list2[i] = int(list2[i])
  i = i + 1
i=0
for i in range(len(list3)):
  list3[i] = int(list3[i])
  i = i + 1
i=0
for i in range(len(list1)):
  j = 0
  for j in range(len(list2)):
    k = 0
    for k in range(len(list3)):
      if(list1[i] == list2[j] == list3[k]):
        print("NO")
        flag = 1
        break
if flag == 0:
  print("YES")

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

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

city = [0, 0, 0, 0]

for i in road:
  if i == 1:
    city[0] += 1
  elif i == 2:
    city[1] += 1
  elif i == 3:
    city[2] += 1
  elif i == 4:
    city[3] += 1

if max(city) > 2:
  print("NO")
else:
  print("YES")

Solution (Python):
a = [[0 for i in range(4)] for j in range(4)]
bb = [0,0,0,0]
for i in range(3):
	n,m = map(int,input().split())
	bb[n-1] += 1
	bb[m-1] += 1
su = 1
for i in range(4):
	su *= bb[i]
if su == 4:
	print("YES")
else:
	print("NO")

Solution (Python):
array = [[int(x) for x in input().split()] for y in range(3)]
tmp = [[] for x in range(5)]
for a, b in array:
    tmp[a].append(b)
    tmp[b].append(a)
for i in tmp:
    if len(i) == 3:
        print("NO")
        break
else:
    print("YES")

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


maxlen = 0
for i in range(4):
    maxlen = max(maxlen, len(route[i]))

if(maxlen >= 3): print("NO")
else: print("YES")

Solution (Python):

from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007


"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""


c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")

Solution (Python):
a_b=[]
time = [0,0,0,0]
for i in range(3):
    a_b=input().split()
    if a_b[0]=='1':
        time[0]+=1
    if a_b[0]=='2':
        time[1]+=1
    if a_b[0]=='3':
        time[2]+=1
    if a_b[0]=='4':
        time[3]+=1
    if a_b[1]=='1':
        time[0]+=1
    if a_b[1]=='2':
        time[1]+=1
    if a_b[1]=='3':
        time[2]+=1
    if a_b[1]=='4':
        time[3]+=1
print('YES' if max(time)<=2 else 'NO')

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

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

for i in range(4):
    if(a[i] == 3):
        print("NO")
        exit()

print("YES")

Solution (Python):
array = [0] * 4
for i in range(3):
    thisData = list(map(int, input().split()))
    for j in thisData:
        array[j - 1] += 1

if max(array) == 3:
    print("NO")
else:
    print("YES")

Solution (Python):
import numpy as np
A = np.empty(6,dtype=np.int)

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

for i in range(1,5):
  n = len(np.where(A==i)[0])
  if n==0 or n>2:
    print('NO')
    exit()
print('YES')

Solution (Python):
a1, b1 =map(int,input().split())
a2, b2 =map(int,input().split())
a3, b3 =map(int,input().split())
data_list=[a1,a2,a3,b1,b2,b3]
count=0
for i in range (4):
    if data_list.count(i)>=2:
        count+=1
if count>=2:
    print("YES")
else:
    print("NO")

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

even = 0
for count in counts:
    if count % 2 == 0: even += 1

print('YES' if even == 2 else 'NO')

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

counter = [0] * 4

for i in range(3):
    counter[A[i] - 1] += 1
    counter[B[i] - 1] += 1

oddscounter = 0

for i in range(4):
    if counter[i] % 2 == 1:
        oddscounter += 1

answer = "YES"
if oddscounter >= 3:
    answer = "NO"
else:
    answer = "YES"

print(answer)

Solution (Python):
a1, b1 = map(int,input().split())
a2, b2 = map(int,input().split())
a3, b3 = map(int,input().split())
row = [a1,a2,a3,b1,b2,b3]
c =[0,0,0,0]
for i in row:
	if i == 1:
		c[0] += 1
	elif i == 2:
		c[1] += 1
	elif i == 3:
		c[2] += 1
	else:
		c[3] += 1
	
ans = 0
for i in c:
	if i == 3:
		ans = 1
	elif i == 0:
		ans = 1
		
if ans == 0:
	print("YES")
else:
	print("NO")

Solution (Python):

P1 = list(map(int, input().split()))
P2 = list(map(int, input().split()))
P3 = list(map(int, input().split()))

P1_P2 = set(P1) & set(P2)
P2_P3 = set(P2) & set(P3)
P3_P1 = set(P3) & set(P1)

if P1_P2 == P2_P3:
    print('NO')
else:
    print('YES')

Solution (Python):
road = []
count_num = [1, 2, 3, 4]
for i in range(3):
    a, b = map(int, input().split())
    road.append(a)
    road.append(b)
flag = True
for i in count_num:
    if road.count(i) >= 3:
        flag = False
if flag is True:
    print("YES")
else:
    print("NO")

Solution (Python):

mylist=[]
for i in range(3) :
    line = input().split()
    mylist.append(int(line[0]))
    mylist.append(int(line[1]))
if mylist.count(1)<=2 and mylist.count(2)<=2 and mylist.count(3)<=2 and mylist.count(4)<=2:
    print("YES")
else:
    print("NO")

Solution (Python):
p1=list(map(int,input().split()))
p2=list(map(int,input().split()))
p3=list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(list)
for p in [p1,p2,p3]:
    a,b=p
    d[a].append(b)
    d[b].append(a)

for i in range(1,5):
    if len(d[i])>2:
        print('NO')
        exit()
print('YES')

Solution (Python):
cnt = [0 for i in range(5)]
for i in range(3):
    temp = list(map(int,input().split()))
    cnt[temp[0]]+=1
    cnt[temp[1]]+=1
flg = 1
for i in range(1,5):
    if cnt[i] > 2:
        flg = 0
if flg == 1:
    print("YES")
else:
    print("NO")

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

if ans.count(1) == 2 and ans.count(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())

x = [a, b, c, d, e, f]
x.sort()

if x == [1, 2, 2, 3, 3, 4]:
    print("YES")
else:
    print("NO")

Solution (Python):


import copy
import numpy as np
import random

a = []
b = []

for i in range(3):
    a_now,b_now = map(int, input().split())
    a.append(a_now)
    b.append(b_now)

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

for i in range(3):
    town_dic[a[i]] += 1
    town_dic[b[i]] += 1

answer = "YES"
for i in range(4):
    if town_dic[i+1] == 3:
        answer = "NO"


print(answer)

Solution (Python):
import collections
x = []
for xx in range(3):
    aa, bb = (int(i) for i in input().split()) 
    x.append(aa)
    x.append(bb)

c = collections.Counter(x)
cc = c.most_common()

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

Solution (Python):
l=[[]for i in range(5)]
for i in range(3):
    a=[int(j) for j in input().split()]
    l[a[0]].append(a[1])
    l[a[1]].append(a[0])
p=0
for i in range(5):
    if len(l[i])>=3:
        p=1

if p==1:
    print("NO")
else:
    print("YES")

Solution (Python):
from collections import Counter
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
cnt = Counter([a1, b1, a2, b2, a3, b3])
if sorted(cnt.values()) == [1, 1, 2, 2]:
    print("YES")
else:
    print("NO")

Solution (Python):
import sys

road = []
for i in range(3):
    road = road + input().split()

road.sort()
town = [0]*4
for v in road:
    town[int(v)-1] +=1

for v in town:
    if v >=3:
        print("NO")
        sys.exit()
print("YES")

Solution (Python):
ab = []
for i in range(3):
    ab.append([int(v) for v in input().split()])

city_cnt = {i: 0 for i in range(1, 5)}
for a, b in ab:
    city_cnt[a] += 1
    city_cnt[b] += 1

if max(city_cnt.values()) == 3:
    print('NO')
else:
    print('YES')

Solution (Python):
flag = True
numbers = {}
for i in range(3):
    tmp = list(int(i) for i in input().split())
    if tmp[0] in numbers:
        numbers[tmp[0]] += 1
        if numbers[tmp[0]] > 2:
            flag = False
            break
    else:
        numbers[tmp[0]] = 1
    if tmp[1] in numbers:
        numbers[tmp[1]] += 1
        if numbers[tmp[1]] > 2:
            flag = False
            break
    else:
        numbers[tmp[1]] = 1

for i in range(4):
    if not i+1 in numbers:
        flag = False
        break

if flag:
    print("YES")
else:
    print("NO")

Solution (Python):


paths = [sorted(list(map(int, input().split()))) for _ in range(3)]



c1 = 0
c2 = 0
c3 = 0
c4 = 0

for p in paths:
    for c in p:
        if c == 1:
            c1 += 1
        elif c == 2:
            c2 += 1
        elif c == 3:
            c3 += 1
        elif c == 4:
            c4 += 1

if [c1,c2,c3,c4].count(2) == 2 and [c1,c2,c3,c4].count(1) == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
p = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    p[a-1].append(b-1)
    p[b-1].append(a-1)

if [] in p:
    print('NO')
    exit()

if all([len(x) < 3 for x in p]):
    print('YES')
else:
    print('NO')

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

Solution (Python):






a,b = [int(i) for i in input().split()]
c,d = [int(i) for i in input().split()]
e,f = [int(i) for i in input().split()]

if a>= b:
    a,b=b,a
if c>= d:
    c,d=d,c
if e>= f:
    e,f=f,e
A=[a,b,c,d,e,f]
B=[]

for i in range(1,5):
    c=0
    for j in A:
        if i == j:
            c+=1
    B.append(c)


if set([a,b,c,d,e,f]) == set([1,2,3,4]) and 3 not in B and 4 not in B:
    print("YES")
else:
    print("NO")

Solution (Python):
a= list(map(int,input().split()))
b= list(map(int,input().split()))
c= list(map(int,input().split()))
lst=a+b+c
ans=[lst.count(i) for i in range(1,5)]
ans.sort()
if ans == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
def func():
    pass


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

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
X = Counter([a1, b1, a2, b2, a3, b3])
N = Counter([x[1] for x in X.items()])
if N[1] == 2 and N[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())

arr = [a1, b1, a2, b2, a3, b3]
if arr.count(1) <= 2 and arr.count(2) <= 2 and arr.count(3) <= 2 and arr.count(4) <= 2:
    print("YES")
else:
    print("NO")

Solution (Python):
ab1=list(map(int,input().split()))
ab2=list(map(int,input().split()))
ab3=list(map(int,input().split()))
n = [0,0,0,0,0]
n[ab1[0]] = n[ab1[0]] +1
n[ab1[1]] = n[ab1[1]] +1
n[ab2[0]] = n[ab2[0]] +1
n[ab2[1]] = n[ab2[1]] +1
n[ab3[0]] = n[ab3[0]] +1
n[ab3[1]] = n[ab3[1]] +1
if n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 0 or n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
count = {}
for _ in range(3):
    for i in map(int,input().split()):
        if i in count:
            count[i] += 1
        else:
            count[i] = 1

if max(count.values()) > 2:
    print('NO')
else:
    print('YES')

Solution (Python):
P1 = list(map(int,input().split()))
P2 = list(map(int,input().split()))
P3 = list(map(int,input().split()))

li = []
for i in range(2):
    li.append(P1[i])
    li.append(P2[i])
    li.append(P3[i])

flag = 0
for j in range(1, 5):
    score = li.count(j)
    if score == 3:
        flag = 1

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

Solution (Python):




town = input().split() + input().split() + input().split()


for _ in range(4):
    if town.count(str(_+1)) == 3:
        print("NO")
        break
else:
    print("YES")

Solution (Python):
ans = [0,0,0,0]
for i in range(3):
    a = list(map(int,input().split()))
    for i in a:
        if i==1: ans[0]+=1
        elif i==2: ans[1]+=1
        elif i==3: ans[2]+=1
        else: ans[3]+=1
n = [0,0]
for i in ans:
    if i==1:
        n[0]+=1
if n[0]==2:
    print("YES")
else:
    print("NO")

Solution (Python):
cnt = {"1":0,"2":0,"3":0,"4":0}
for i in range(3) :
    (j,k)=input().split()
    cnt[j]+=1
    cnt[k]+=1

if cnt["1"] == 3 or cnt["2"] == 3 or cnt["3"] == 3 or cnt["4"] == 3 :
    print("NO")
else :
    print("YES")

Solution (Python):
a = []
for _ in range(3):
  c,d = map(int,input().split())
  a.append(c)
  a.append(d)
for i in range(1,5):
  if a.count(i) == 3:
    print("NO")
    exit()
print("YES")

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

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

for n in count:
    if n == 0 or n == 3:
        print("NO")
        exit()
print("YES")

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
    a,b = map(int,input().split())
    d[a] += 1
    d[b] += 1
a = sorted(d.items(),key=lambda x:x[1],reverse=True)
tc,oc = 0,0
for ai in a:
    if ai[1]==2:
        tc += 1
    elif ai[1]==1:
        oc += 1
print('YES' if tc==2 and oc==2 else 'NO')

Solution (Python):


orders = [0, 0, 0, 0]

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

flag = True
nodds = 0
for e in orders:
    if e % 2 == 1:
        flag = False
        nodds += 1
if flag or nodds == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
town=[0 for i in range(4)]
for i in range(3):
    a,b=[int(j) for j in input().split()]
    town[a-1]+=1
    town[b-1]+=1
ans=0
for i in range(4):
    if town[i]>ans:
        ans=town[i]
if ans==3:
    print("NO")
else:
    print("YES")

Solution (Python):
r=[]
x=0
for i in range(3):
    a,b=map(int,input().split())
    x+=a
    x+=b
print("YES" if x==15 else "NO")

Solution (Python):
towns = []
for i in range(3):
    a, b = map(int, input().split())
    towns.append(a)
    towns.append(b)
nums = []
for i in range(4):
    nums.append(towns.count(i+1))

if nums.count(1) == 2:
    print("YES")
else:
    print("NO")

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

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

cnt.sort()
if cnt[-1] == 3:
    print("NO")
elif cnt[0] == 0:
    print("NO")
else:
    print("YES")

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

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

l.sort()
r = [1, 1, 2, 2]
if l == r:
    print("YES")
else:
    print("NO")

Solution (Python):
d = {1:0,2:0,3:0,4:0}
for i in range(3):
    j,k = map(int,input().split())
    d[j] += 1
    d[k] += 1
if d[1]==3 or d[2]==3 or d[3]==3 or d[4]==3:
    print('NO')
else:
    print('YES')

Solution (Python):
road_cnt = {}
for i in range(1, 5):
    road_cnt[i] = 0

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

one_road = 0
two_road = 0
for k, v in road_cnt.items():
    if v == 2:
        two_road += 1
    elif v == 1:
        one_road += 1

print("YES" if one_road == 2 and two_road == 2 else "NO")

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

city_routes = [0, 0, 0, 0]
for route in route_list:
    city_routes[route[0] - 1] += 1
    city_routes[route[1] - 1] += 1

ans = "YES"
if(max(city_routes) > 2):
    ans = "NO"
if(min(city_routes) < 1):
    ans = "NO"
print(ans)

Solution (Python):
l=[0 for i in range(5)]
for i in range(3):
    a, b = map(int, input().split())
    l[a] += 1
    l[b] += 1
ans=True
for i in range(1, 5):
    if l[i] <= 0:
        ans = False
    if l[i] >= 3:
        ans = False
print('YES' if ans else 'NO')

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

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

cnt = 0
for i in range(1, 5):
    if deg[i] % 2 == 1:
        cnt += 1

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

Solution (Python):
a = []
l = []
for i in range(3):
	x,y = map(int,input().split( ))
	a.append(x)
	a.append(y)
a.sort()
for i in range(4):
	l.append(a.count(i+1))
ans ="YES"
if l.count(3) > 0:
	ans = "NO"
print(ans)

Solution (Python):
def main():
    nxt = [0] * 5
    for i in range(3):
        a, b = map(int, input().split())
        nxt[a] += 1
        nxt[b] += 1
    edge = 0
    for i in range(1, 5):
        if nxt[i] % 2 == 1:
            edge += 1
    if edge == 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

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

if all([A[i] < 3 for i in range(4)]):
  print("YES")
else:
  print("NO")

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
res = True
for a in count:
    if a>2:
        res = False
if res:
    print("YES")
else:
    print("NO")

Solution (Python):
from itertools import permutations


def is_ok(a0, a1, a2):
    v = [False] * 4
    v[a0[0]] = True
    v[a0[1]] = True
    if a0[1] != a1[0]:
        return False
    v[a1[1]] = True
    if a1[1] != a2[0]:
        return False
    v[a2[1]] = True
    return all(v)


def main():
    p = []
    for _ in range(3):
        a, b = map(int, raw_input().split())
        p.append([a - 1, b - 1])
    for a0, a1, a2 in permutations(p):
        for i in range(8):
            if i & 1:
                b0 = a0
            else:
                b0 = a0[::-1]
            if i & 2:
                b1 = a1
            else:
                b1 = a1[::-1]
            if i & 4:
                b2 = a2
            else:
                b2 = a2[::-1]
            if is_ok(b0, b1, b2):
                print 'YES'
                return
    print 'NO'


if __name__ == '__main__':
    main()

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a1, b1 = LI()
    a2, b2 = LI()
    a3, b3 = LI()

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

    return max(l) <= 2


if main():
    print('YES')
else:
    print('NO')

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  road = [0 for _ in range(4)]
  for i in range(3):
    c1, c2 = map(int, input().split())
    road[c1-1] += 1
    road[c2-1] += 1

  if max(road) <= 2:
    print('YES')
  else:
    print('NO')


if __name__ == '__main__':
  main()

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

Solution (Python):
d = [set([]) for i in range(4)]
for i in range(3):
    a, b = list(map(int, input().split()))
    d[a-1].add(b-1)
    d[b-1].add(a-1)

flag = False
def BFS(now, visited, depth):
    global flag
    if depth == 3:
        if len(visited) == 4:
            flag = True
        return

    for i in d[now]:
        if i in visited:
            continue
        next_visited = visited.copy()
        next_visited.add(i)
        BFS(i, next_visited, depth+1)

for i in range(4):
    BFS(i, set([i]), 0)

if flag:
    print("YES")
else:
    print("NO")

Solution (Python):
L=[]
for i in range(3):
    a,b=input().split()
    L.append(int(a))
    L.append(int(b))
    
def solve(L):
    for i in range(1,5):
        if L.count(i)==3:
            return 'NO'
    return 'YES'

print(solve(L))

Solution (Python):
n=[]
for i in range(3):
    m=list(map(int,input().split()))
    n.append(m[0])
    n.append(m[1])
if n.count(1)<3 and n.count(2)<3 and n.count(3)<3 and n.count(4)<3 :
    print("YES")
else:
    print("NO")

Solution (Python):

import math


dic = [0, 0, 0, 0]

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

dic[a1-1] += 1
dic[a2-1] += 1
dic[a3-1] += 1
dic[b1-1] += 1
dic[b2-1] += 1
dic[b3-1] += 1

x1 = len([i for i, x in enumerate(dic) if x == 1])
x2 = len([i for i, x in enumerate(dic) if x == 2])

if x1 == 2 and x2 == 2:
    print('YES')
else:
    print('NO')

Solution (Python):

x = [0]*6

for i in range(0,6,2):
    x[i-1], x[i] = map( int, input().split() )


town = [1,2,3,4]

yes = True
for ti in town:
    yes &= x.count(ti) == 2 or x.count(ti) == 1


print('YES' if yes else 'NO')

Solution (Python):
F = [None] * 4

for i in range(4):
    F[i] = []

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

L = [len(f) for f in F]

L.sort()

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

Solution (Python):
r1 = []
r2 = []
r3 = []
r4 = []
for i in range(3):
    a,b = map(int,input().split())
    if a == 1:
        r1.append(b)
    elif a == 2:
        r2.append(b)
    elif a == 3:
        r3.append(b)
    else:
        r4.append(b)

    if b == 1:
        r1.append(a)
    elif b == 2:
        r2.append(a)
    elif b == 3:
        r3.append(a)
    else:
        r4.append(a)
if len(r1) <= 2 and len(r2) <= 2 and len(r3) <= 2 and len(r4) <= 2:
    print("YES")
else:
    print("NO")

Solution (Python):

l = [0]*4

for _ in range(3):
    for i in input().split():
        l[int(i)-1] += 1

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

Solution (Python):
numList=[0]*5

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

numList.sort()

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

Solution (Python):


import math

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

over = False
for p in points:
    if p >= 3:
        over = True
if over:
    print("NO")
else:
    print("YES")

Solution (Python):
from collections import Counter
IN=lambda:list(map(int,input().split()))
a=IN()
a+=IN()
a+=IN()
c=Counter(a)

if max(c.values())>=3:
  print('NO')
else:
  print('YES')

Solution (Python):
from collections import Counter

a = []
for i in range(3):
    x, y = map(int, input().split())
    a.append(x)
    a.append(y)
count = Counter(a)

for i, j in count.items():
    if j > 2:
        print("NO")
        exit()
print("YES")

Solution (Python):

s = set(map(int,input().split()))
for i in range(2):
    s = s & set(map(int,input().split())) 
if (len(s)):
    print ("NO")
else:
    print ("YES")

Solution (Python):
a = []
b = []
count1=0
count2=0
count3=0
count4=0
for i in range(3):
    tempa,tempb = map(int, input().split())
    if tempa == 1:
        count1 += 1
    if tempb == 1:
        count1 += 1
    if tempa == 2:
        count2 += 1
    if tempb == 2:
        count2 += 1
    if tempa == 3:
        count3 += 1
    if tempb == 3:
        count3 += 1
    if tempa == 4:
        count4 += 1
    if tempb == 4:
        count4 += 1
if (count1>2) or(count2>2) or(count3>2) or (count4>2):
    print("NO")
else:
    print("YES")

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

f = True


for i in range(1,5):
	if not i in a and not i in b:
		f = False

for i in range(1,5):
	t = False
	for A,B in zip(a,b):
		if not(i == A or i == B):
			t = True 
	if not t:
		f = False

if f:
	print('YES')
else:
	print('NO')

Solution (Python):
l=[]
for i in range(3):
  a,b=map(int,input().split())
  l.append(a)
  l.append(b)
w=0
x=0
y=0
z=0
for i in range(6):
  if l[i]==1:
    w+=1
  elif l[i]==2:
    x+=1
  elif l[i]==3:
    y+=1
  else:
    z+=1
if x==0 or y==0 or z==0 or w==0:
  print('NO')
elif w>2 or x>2 or y>2 or z>2:
  print('NO')
else:
  print('YES')

Solution (Python):
import  numpy as np
ab = []
for i in range(3):
    ab.append(list(map(int,input().split())))
ans = "YES"
ab = np.array(ab)
for i in range(1,5):
    if (ab==i).sum()>2:
        ans = "NO"
        break
print(ans)

Solution (Python):
A=[]
for i in range(3):
    a,b=map(int,input().split())
    A.append(a)
    A.append(b)
c=0
d=0
e=0
f=0
for j in A:
    if j==1:
        c+=1
    elif j==2:
        d+=1
    elif j==3:
        e+=1
    else:
        f+=1
if c>=3 or d>=3 or e>=3 or f>=3:
    print("NO")
else:
    print("YES")