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):
li = list(map(int,input().split()))
li.extend(list(map(int,input().split())))
li.extend(list(map(int,input().split())))

num = []
for i in range(1,5):
    num.append(li.count(i))

if num.count(1) == 2 and num.count(2) == 2:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

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

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

for i in range(3):
    for j in range(3):
        if not i == j:
            for k in range(3):
                if not j == k:
                    if not i == k:
                        if a[i] == a[j]:
                            if (b[j] == a[k]) or (b[j] == b[k]):
                                print("YES")
                                quit()
                        if a[i] == b[j]:
                            if (a[j] == a[k]) or (a[j] == b[k]):
                                print("YES")
                                quit()
                        if b[i] == a[j]:
                            if (b[j] == a[k]) or (b[j] == b[k]):
                                print("YES")
                                quit()
                        if b[i] == b[j]:
                            if (a[j] == a[k]) or (a[j] == b[k]):
                                print("YES")
                                quit()

print("NO")

Solution (Python):
a = []
b = []
c = [0,0,0,0]
for i in range(3):
  ab = list(map(int,input().split()))
  a.append(ab[0])
  b.append(ab[1])
  a.append(ab[1])
  b.append(ab[0])
  c[ab[0]-1] += 1
  c[ab[1]-1] += 1
k = c.index(1)+1
for i in range(3):
  if k in a:
    j = a.index(k)
    k = b[j]
    a.pop(j)
    a.pop(j+-1*(j%2))
    b.pop(j)
    b.pop(j+-1*(j%2))
  else:
    print("NO")
    break
else:
  print("YES")

Solution (Python):
import collections

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

N = []
N.extend([a,b,c,d,e,f])

k = collections.Counter(N)

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

Solution (Python):
p = []
for i in range(3):
    a1, b1 = map(int, input().split())
    p.append(a1)
    p.append(b1)

point = [0, 0, 0, 0]
for town in p:
    point[town-1] += 1
    if point[town-1] > 2:
        print('NO')
        quit()

print('YES')

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

dic = {}

for i in li:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

dicc = {}
for i in dic.values():
    if i in dicc.keys():
        dicc[i] += 1
    else:
        dicc[i] = 1

if dicc[1] == 2 and dicc[2] == 2:
    print('YES')
else:
    print('NO')

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

n = 1
v = [1,0,0,0]
for k in range(10):
    for e in L:
        if e[0] == n and v[e[1]-1] == 0:
            n = e[1]
            v[e[1]-1] = 1
        elif e[1] == n and v[e[0]-1] == 0:
            n = e[0]
            v[e[0]-1] = 1

if min(v) == 1:
    print("YES")
else:
    print("NO")

Solution (Python):


def main():
    """Function."""
    p1 = list(map(int, input().split()))
    p2 = list(map(int, input().split()))
    p3 = list(map(int, input().split()))

    counter = [0, 0, 0, 0]
    for l in [p1, p2, p3]:
        for i in l:
            if i == 1:
                counter[0] += 1
            elif i == 2:
                counter[1] += 1
            elif i == 3:
                counter[2] += 1
            elif i == 4:
                counter[3] += 1

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

if __name__ == "__main__":
    main()

Solution (Python):


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

cnt = [0] * 4
cnt[a1-1] += 1
cnt[b1-1] += 1
cnt[a2-1] += 1
cnt[b2-1] += 1
cnt[a3-1] += 1
cnt[b3-1] += 1

flag = True
for c in cnt:
    if c == 0 or c > 2:
        flag = False
        break

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

Solution (Python):
l = []

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

d = {}
for aa,bb in l:
    if aa not in d.keys():
        d[aa] = 0
    if bb not in d.keys():
        d[bb] = 0
    d[aa] += 1
    d[bb] += 1

for i in d.values():
    if i >= 3:
        print("NO")
        exit()
print("YES")

Solution (Python):

a = []
for i in range(3):
    a.extend(list(map(int, input().split())) )
    
count_list =sorted([a.count(i) for i in range(1, 5)])

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

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

for i in range(1,5):
  if p.count(i) > 2:
    print('NO')
    break
else:
  print('YES')

Solution (Python):
adj = [[0 for _ in range(4)] for _ in range(4)]
for i in range(3):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a][b] = 1
    adj[b][a] = 1
for i in range(4):
    for j in range(4):
        if i == j:
            continue
        for k in range(4):
            if i == k or j == k:
                continue
            for l in range(4):
                if i == l or j == l or k == l:
                    continue
                elif adj[i][j] == 1 and adj[j][k] == 1 and adj[k][l] == 1:
                    print("YES")
                    exit()
print("NO")

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

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

    towns[a] += 1
    towns[b] += 1

result = True

for town in towns.values():
    if town > 2:
        result = False

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

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

li = []
for i in ab:
    for j in i:
        li.append(j)
res =0
for i in range(1,4):
    if(li.count(i)==2):
        res+=1

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

Solution (Python):
a1, b1 = (int(i) for i in input().split())
a2, b2 = (int(i) for i in input().split())
a3, b3 = (int(i) for i in input().split())
list = [a1, b1, a2, b2, a3, b3]
count_list = [list.count(i) for i in range(1,5)]
if 3 in count_list:
    print("NO")
else:
    print("YES")

Solution (Python):
d = {}
for i in range(3):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)

    if b not in d:
        d[b] = [a]
    else:
        d[b].append(a)

ans = True
for a in range(1, 5):
    if len(d[a]) >= 3:
        ans = False
if ans:
    print("YES")
else:
    print("NO")

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

if set(paths) != set([1, 2, 3, 4]):
    print("NO")
elif paths.count(1) >= 3 or paths.count(2) >= 3 or paths.count(3) >= 3 or paths.count(4) >= 3:
    print("NO")
else:
    print("YES")

Solution (Python):
import collections


points = []

for i in range(0, 3):
    p1, p2 = map(int, input().split(' '))
    points.extend([p1, p2])

counter = collections.Counter(points)
num_mode = counter.most_common(1)[0][1]


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

exit(0)

Solution (Python):
L = [list(map(int,input().split())) for i in range(3)]
dp = [0, 0, 0, 0]
for l in L:
  for i in l:
    dp[i-1] += 1

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

Solution (Python):
G = [[] for i in range(4)]
for i in range(3):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)
GL = [len(x) for x in G]
GL.sort()
if GL[0] == 1 and GL[1] == 1 and GL[2] == 2 and GL[3] == 2:
    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()))
a.append(b[0])
a.append(b[1])
a.append(c[0])
a.append(c[1])
x = [0] * 4

for i in a:
    x[i-1] += 1

f = 0
for i in range(4):
    if x[i] in [1, 2]:
        f += 1

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

Solution (Python):
deg = [0 for i in range(4)]

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

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

Solution (Python):




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

cnt_1 = 0
cnt_2 = 0

for i in range(3):
    if cnt[i] == 1:
        cnt_1 += 1
    elif cnt[i] == 2:
        cnt_2 += 1

if cnt_1 == 1 and cnt_2 == 2:
    ans = "YES"
else:
    ans = "NO"


print(ans)

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


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

B = [sum(A[i]) for i in range(4)]

for i in range(4):
    if B[i] == 3 or B[i] == 0:
        flag = False
        break
    else:
        flag = True

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

Solution (Python):
li = list(map(int,input().split()))
li = li + list(map(int,input().split()))
li = li + list(map(int,input().split()))
a = li.count(1)
b = li.count(2)
c = li.count(3)
d = li.count(4)
if 1<=a<=2 and 1<=b<=2 and 1<=c<=2 and 1<=d<=2:
    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()))
d = [x for x in a]
d.extend(b)
d.extend(c)
d.sort()
li = [d.count(i+1) for i in range(4) ]
if max(li)>=3 or min(li)==0:
    print('NO')
else:
    print('YES')

Solution (Python):
from collections import Counter
l=[]
for i in range(3):
  a,b=map(int,input().split())
  l+=[a,b]
c =Counter(l)
if all(c[i]<3 for i in range(1,5)):
  print("YES")
else:
  print("NO")

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

a = Counter(t).most_common()
if len(a) < 4:
    print("NO")
else:
    for i in range(4):
        if i <= 1:
            if a[i][1] == 2:
                continue
            else:
                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())
ab = [a1, b1, a2, b2, a3, b3]
one = 0
two = 0
for i in range(1, 5, 1):
    if ab.count(i) == 1:
        one += 1
    elif ab.count(i) == 2:
        two += 1
print("YES" if one == 2 and two == 2 else "NO")

Solution (Python):

counter = [0,0,0,0]


ip = []
a1, b1 = map(int,input().split())
ip.append(a1)
ip.append(b1)
a2, b2 = map(int,input().split())
ip.append(a2)
ip.append(b2)
a3, b3 = map(int,input().split())
ip.append(a3)
ip.append(b3)


for city in ip:
    counter[city - 1] += 1


counter.sort()
if counter[3] == 3:
    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())

if c==a or d==a:
    if a==e or a==f:
        print("NO")
    else:
        print("YES")
elif c==b or d==b:
    if b==e or b==f: 
        print("NO")
    else:
        print("YES")
else:
    print("YES")

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

num_1_set = set()
for i in range(4):
    if num[i] == 1:
        num_1_set.add(i+1)

ans = 'NO'
for a, b in path:
    if a != b:
        if a not in num_1_set and b not in num_1_set:
            ans = 'YES'
            break
print(ans)

Solution (Python):
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 and c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())

Solution (Python):
AB = [input() for _ in range(3)]

AB = list(map(int, ' '.join(AB).split()))

c = [0] * 4

for ab in AB:
    c[ab-1] += 1

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

Solution (Python):
a = [[int(i) for i in input().split()] for j in range(3)]
c = [0,0,0,0]
for i in range(3):
    for j in range(2):
        c[a[i][j]-1] += 1
r = "YES"
for i in range(4):
    if c[i]>=3:
        r="NO"
        break
print(r)

Solution (Python):

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

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

if path.count(1) <=2 and path.count(2) <=2 and path.count(3) <=2 and path.count(4) <=2 :
    print('YES')
else:
    print('NO')

Solution (Python):
AB = []
for i in range(3):
    a,b = map(int, input().split())
    AB.append((min(a,b),max(a,b)))

AB = sorted(AB)

if 1 in AB[0]:
    tmp = AB
    ne = AB[0][1]
    AB = AB[1:]
else:
    print('NO')
    exit()

a = AB[0][0]
b = AB[0][1]

c = AB[1][0]
d = AB[1][1]

if ne == a or ne == b:
    if ne == a:
        ne = b
    elif ne == b:
        ne = a

    if ne == c or ne == d:
        ans = 'YES'
    else:
        ans = 'NO'

elif ne == c or ne == d:
    if ne == c:
        ne = d
    elif ne == d:
        ne = c

    if ne == a or ne == b:
        ans = 'YES'
    else:
        ans = 'NO'

else:
    ans = 'NO'

print(ans)

Solution (Python):


a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
lst=[a1,a2,a3,b1,b2,b3]
for i in range(1,5):

    if lst.count(i) > 2:
        print("NO")
        exit()
print("YES")

Solution (Python):
ab1 = [int(i) for i in input().split()]
ab2 = [int(i) for i in input().split()]
ab3 = [int(i) for i in input().split()]

node = [0, 0, 0, 0]
for i in [ab1, ab2, ab3]:
    for j in i:
        node[j-1] += 1
if max(node) == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
a = input()
b = input()
c = input()

d = a + b + c
result = "YES"
for i in ["1", "2", "3", "4"]:
    if d.count(i) == 3:
        result = "NO"
print(result)

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

for i in range(6):
  d[c[i]-1]+=1
d.sort()
if d==[1,1,2,2]:
  print("YES")
else:
  print("NO")

Solution (Python):
a=[0]*5
count=0
for x in range(3):
    for y in input().split():
        a[int(y)]+=1
for p in a:
    if(p==1):
        count+=1
if(count>=3):
    print("NO")
else:
    print("YES")

Solution (Python):



def main():
    from collections import Counter
    ab = list()

    for i in range(3):
        ai, bi = map(int, input().split())
        ab.append(ai)
        ab.append(bi)

    ab_count = Counter(ab)

    for ab_val in ab_count.values():
        if ab_val == 3:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()

Solution (Python):
cnt = [0 for i in xrange(5)]

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

x = 0
y = 0
for i in xrange(1,5):
	if cnt[i] == 1:
		x += 1
	elif cnt[i] == 2:
		y += 1

if x == y and x == 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 = []
l.append(a1)
l.append(b1)
l.append(a2)
l.append(b2)
l.append(a3)
l.append(b3)
cnt1 = l.count(1)
cnt2 = l.count(2)
cnt3 = l.count(3)
cnt4 = l.count(4)

if cnt1 >= 3 or cnt2 >= 3 or cnt3 >= 3 or cnt4 >= 3  :
    print('NO')
else:
    print('YES')

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

Solution (Python):
def Solve(graph):
    one = 0
    two = 0
    for i in graph:
        if len(graph[i]) == 1:
            one += 1
        elif len(graph[i]) == 2:
            two += 1

    if one == two:
        return 'YES'
    return 'NO'
        

def main():
    graph = {}
    for i in range(1,5):
        graph[i] = []
        
    a1,b1 = map(int,input().split())
    a2,b2 = map(int,input().split())
    a3,b3 = map(int,input().split())

    graph[a1].append(b1)
    graph[b1].append(a1)
    graph[a2].append(b2)
    graph[b2].append(a2)
    graph[a3].append(b3)
    graph[b3].append(a3)

    print (Solve(graph))

main()

Solution (Python):
a = [0] * 6
for i in range(3):
    a[2 * i], a[2 * i + 1] = map(int, input().split())
for i in range(4):
    if a.count(i + 1) == 3:
        print('NO')
        exit()
print('YES')

Solution (Python):
def main():
  C = [0] * 4

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

  for i in range(4):
    if (2 < C[i]):
      print('NO')
      return

  print('YES')

main()

Solution (Python):
r = list(map(int,input().split()))
r = r + list(map(int,input().split()))
r = r + list(map(int,input().split()))
flag = True
for i in [1,2,3,4]:
    n = r.count(i)
    if n == 3:
        flag = False
if flag:
    print('YES')
else:
    print('NO')

Solution (Python):

  

  



from collections import defaultdict as df
g=df(list)
for i in range(3):
    a,b=list(map(int,input().split()))
    g[a].append(b)
    g[b].append(a)
count1=0
count2=0
for i in g:
    if len(g[i])==2:
        count2+=1
    elif len(g[i])==1:
        count1+=1
if count2==2 and count1==2:
    print('YES')
else:
    print('NO')

Solution (Python):
import collections
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)

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

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


import collections
c = collections.Counter(X)

X = list(c.values())
X = sorted(X)
if X == [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())
hoge=[]
no=0
hoge.append(A)
hoge.append(B)
hoge.append(C)
hoge.append(D)
hoge.append(E)
hoge.append(F)
if(hoge.count(1)==0):
  no=1
if(hoge.count(2)==0):
  no=1
if(hoge.count(3)==0):
  no=1
if(hoge.count(4)==0):
  no=1
if(hoge.count(1)==3):
  no=1
if(hoge.count(2)==3):
  no=1
if(hoge.count(3)==3):
  no=1
if(hoge.count(4)==3):
  no=1
if(no==1):
  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())

towns = [a1, b1, a2, b2, a3, b3]
res = True
for i in range(4):
    if towns.count(i+1) == 3:
        res = False

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

Solution (Python):
a = list(map(str,input().split()))
b = list(map(str,input().split()))
c = list(map(str,input().split()))
l = a + b + c
cnt = 0
for i in "1234":
    if l.count(i)==2:
        cnt += 1
if cnt==2:
    print("YES")
else:
    print("NO")

Solution (Python):
from collections import Counter
a,b = map(int,input().split())
c,d = map(int,input().split())
e,f = map(int,input().split())
if a != c and a != d and b != c and b!= d:
  print ("YES")
else:
  x = [a,b,c,d]
  x1 = Counter(x)
  y = x1.most_common()[0][0]
  if y != e and y != f:
    print ("YES")
  else:
    print ("NO")

Solution (Python):
"""
YESの条件

NOの条件
    数字が3個以上含まれる数列
    1,2,3,4のいずれがか含まれない数列

"""

n = 3
p = [list(map(int, input().split(" "))) for _ in range(n)]
p = p[0]+p[1]+p[2]


result = "YES"
for i in range(1,5):
    if 0 < p.count(i) < 3:
        pass
    else:
        result = "NO"
        break

print(result)

Solution (Python):
a = [None]*3
b = [None]*3

for i in range(3):
    a_,b_ = map(int,input().split())
    a[i] = str(a_)
    b[i] = str(b_)

c = a
c.extend(b)

count = [str(c.count('1')),str(c.count('2')),str(c.count('3')),str(c.count('4'))]

if count.count('1')==2 and count.count('2')==2:
    print('YES')
else:
    print('NO')

Solution (Python):

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

A_flt = []
for s in A:
    A_flt.extend(s)

import collections
A_cnt = collections.Counter(A_flt)

if A_cnt.most_common()[0][1] >= 3:
    print('NO')
else:
    print('YES')

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

for r1 in range(4):
    for r2 in range(4):
        if r1 == r2: continue
        if not e[r1][r2]: continue
        for r3 in range(4):
            if r3 == r1: continue
            if r3 == r2: continue
            if not e[r2][r3]: continue
            for r4 in range(4):
                if r4 == r1: continue
                if r4 == r2: continue
                if r4 == r3: continue
                if not e[r3][r4]: continue
                print('YES')
                exit()
print('NO')

Solution (Python):
L=[ 0 for i in range(5)] 
for i in range(3):
	a,b=map(int, raw_input().split())
	L[a]+=1
	L[b]+=1

for i in range(1,5):
	if L[i]==0 or L[i]==3:
		print "NO"
		quit()
else:
	print "YES"

Solution (Python):
import sys
import math

lines = sys.stdin.readlines()
a1, b1 = map(int, lines[0].split())
a2, b2 = map(int, lines[1].split())
a3, b3 = map(int, lines[2].split())

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

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

for k, v in dic.items():
  if 0 < v < 3:
    continue
  print('NO')
  exit(0)
print('YES')

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
d = [0,0,0,0]
d[a1-1] += 1
d[b1-1] += 1
d[a2-1] += 1
d[b2-1] += 1
d[a3-1] += 1
d[b3-1] += 1
r = sum([1 for x in d if x%2==1])
print("YES" if r == 0 or r == 2 else "NO")

Solution (Python):
from collections import defaultdict
l=[list(map(int, input().split())) for _ in range(3)]
dict=defaultdict(lambda: 0)
for i in l:
  dict[i[0]]+=1
  dict[i[1]]+=1

tmp=[]
for k in dict.keys():
  tmp.append(dict[k])

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

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

for i in range(1,5):
    count = 0
    for j in range(3):
        if i in A[j]:
            count += 1
    if count == 3:
        print('NO')
        break
else:
    print('YES')

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

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

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

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

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

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

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

b = [0 for i in range(4)]
for i in range(6):
    b[a[i] - 1] += 1

if (max(b)) == 3:
    print('NO')
elif (min(b)) == 0:
    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())
l = [a1, a2, a3, b1, b2, b3]
if (1 <= l.count(1) and l.count(1) < 3) and (1 <= l.count(2) and l.count(2) < 3) and (1 <= l.count(3) and l.count(3) < 3) and (1 <= l.count(4) and l.count(4) < 3):
    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())
A=[]
A.append(a1)
A.append(b1)
A.append(a2)
A.append(b2)
A.append(a3)
A.append(b3)
if A.count(a1)==3 or A.count(b1)==3:
    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_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0

if a1 == 1:
    count_1 += 1
if a1 == 2:
    count_2 += 1
if a1 == 3:
    count_3 += 1
if a1 == 4:
    count_4 += 1

if b1 == 1:
    count_1 += 1
if b1 == 2:
    count_2 += 1
if b1 == 3:
    count_3 += 1
if b1 == 4:
    count_4 += 1

if a2 == 1:
    count_1 += 1
if a2 == 2:
    count_2 += 1
if a2 == 3:
    count_3 += 1
if a2 == 4:
    count_4 += 1

if b2 == 1:
    count_1 += 1
if b2 == 2:
    count_2 += 1
if b2 == 3:
    count_3 += 1
if b2 == 4:
    count_4 += 1

if a3 == 1:
    count_1 += 1
if a3 == 2:
    count_2 += 1
if a3 == 3:
    count_3 += 1
if a3 == 4:
    count_4 += 1

if b3 == 1:
    count_1 += 1
if b3 == 2:
    count_2 += 1
if b3 == 3:
    count_3 += 1
if b3 == 4:
    count_4 += 1

if 1 <= count_1 and count_1 <=2 and 1 <= count_2 and count_2 <=2 and 1 <= count_3 and count_3 <=2 and 1 <= count_4 and count_4 <=2:
    print("YES") 
else:
    print("NO")

Solution (Python):
def solve():
    graph = [[False] * 4 for i in range(4)]
    for i in range(3):
        a, b = [int(n) for n in input().split()]
        a-=1
        b-=1
        graph[a][b] = graph[b][a] = True

    import itertools
    for a,b,c,d in itertools.permutations([0,1,2,3]):
        if graph[a][b] and graph[b][c] and graph[c][d]:
            return True
    return False


def main():
    ans = solve()
    if ans:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
def a():
    n, k = map(int, input().split())
    if int(n / 2 + 0.5) >= k:
        print("YES")
    else:
        print("NO")


def B():
    root = [[0 for i in range(4)] for j in range(4)]
    for i in range(3):
        a, b = map(int, input().split())
        
        root[a - 1][b - 1] = 1
        root[b - 1][a - 1] = 1

    cnt_one = 0
    cnt_two = 0
    for i in range(4):
        if sum(root[i]) == 1:
            cnt_one += 1
        if sum(root[i]) == 2:
            cnt_two += 1
    if cnt_one == 2 and cnt_two == 2:
        print("YES")
    else:
        print("NO")

B()

Solution (Python):
num = []
for i in range(3):
    v1,v2 = map(int,input().split())
    num.append(v1)
    num.append(v2)

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

if a>2 or b>2 or c>2 or d>2:
    print("NO")
else:
    print("YES")

Solution (Python):
ABlist = list()

for x in range(0,3):
    S = list(map(int,input().split()))
    ABlist.append(S[0])
    ABlist.append(S[1])

number = 0
for x in range(1,5):
    n = ABlist.count(x)
    if n > number:
        number = n

if number == 3:
    print('NO')
else:
    print('YES')

Solution (Python):
import sys
l = []
for line in sys.stdin:
  l += list(map(int, line.strip().split(' ')))
for i in [1,2,3,4]:
  if l.count(i) == 3:
    print('NO')
    exit()
print('YES')

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

for i in li:
    if(i == 1):
        li2[0]+=1
    elif(i == 2):
        li2[1]+=1
if(li2[0] == 2 and li2[1] == 2):
    print('YES')
else:
    print('NO')

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    dict = {}
    for i in range(1, 5):
        dict[i] = 0
    for i in range(3):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        dict[a] += 1
        dict[b] += 1

    max_n = 0
    for n  in dict:
        max_n = max(dict[n], max_n)

    if max_n >= 3:
        print "NO"
    else:
        print "YES"


if __name__ == '__main__':
    main()

Solution (Python):

rank = [0 for i in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    rank[a - 1] += 1
    rank[b - 1] += 1
print('YES' if sorted(rank) == [1, 1, 2, 2] else 'NO')

Solution (Python):
import sys

def move(FROM, edges):
  for edge in edges:
    if FROM in edge:
      edges.remove(edge)
      edge.remove(FROM)

      return edge[0]
  
  return 0


loadNum = 3
startNode = 1
a = [0]*loadNum
for i in range(loadNum):
    a[i] = list(map(int, input().split()))

nowhere = startNode
for i in range(loadNum):
  nowhere = move(nowhere, a)
  if nowhere == 0:
    print('NO')
    sys.exit()

print('YES')

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








node = [0] * 4





for abi in ab:
    node[abi[0]-1] += 1
    node[abi[1]-1] += 1



if len(ab) < 3:
    print("NO")
elif 3 in node:
    print("NO")
else:
    print("YES")

Solution (Python):
from itertools import chain
from collections import Counter

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


print(["NO", "YES"][sum([m%2 for m in Counter(chain(*AB)).values()])<=2])

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

for path in path_list:
    if path >= 3:
        count += 1
if count == 1:
    print('NO')
else:
    print('YES')

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    if (a[i][0] in a[(i+1) % 3] or a[i][0] in a[(i+2) % 3]) and \
     (a[i][1] in a[(i+1) % 3] or a[i][1] in a[(i+2) % 3]):
        print('YES')
        break
else:
    print('NO')

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

a = a1
a.extend(a2)
a.extend(a3)

cnt = [0,0,0,0]
for ax in a:
  if ax == 1:
    cnt[0] += 1
  elif ax == 2:
    cnt[1] += 1
  elif ax == 3:
    cnt[2] += 1
  elif ax == 4:
    cnt[3] += 1
if set(cnt) == set([1,1,2,2]):
  print("YES")
else:
  print("NO")

Solution (Python):
X=[]
for i in range(3):
    a,b=map(int,input().split())
    X.append(a)
    X.append(b)
   
count_1=0
count_2=0
count_3=0
count_4=0
for i in range(6):
    if X[i]==1:
        count_1+=1
    if X[i]==2:
        count_2+=1
    if X[i]==3:
        count_3+=1
    if X[i]==4:
        count_4+=1
        
H=[count_1,count_2,count_3,count_4]

if set(H)=={1,3}:
    print('NO')
else:
    print('YES')

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

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

for i in range(4):
  if len(edges[i])>=3:
    print('NO')
    exit()
print('YES')