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):
A = [0, 0, 0, 0]
for i in range(3):
  x, y = map(int, input().split())
  A[x-1] += 1
  A[y-1] += 1
f = 0
for i in range(4):
  if A[i] == 3:
    print("NO")
    f = 1
    break
if f == 0:
  print("YES")

Solution (Python):
a = set(input().split())
b = set(input().split())
c = set(input().split())
print("YES" if len(a&b&c)==0 else "NO")

Solution (Python):
a = set(input().split())
b = set(input().split())
c = set(input().split())
print("YES" if len(a&b&c)==0 else "NO")

Solution (Python):
dp=[0]*4
for i in range(3):
  a,b=map(int,input().split())
  dp[a-1]+=1
  dp[b-1]+=1
if dp.count(3)==1 or dp.count(0)==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())

load = [a1, b1, a2, b2, a3, b3]
load_dict = dict()
for i in range(6):
    if load[i] in load_dict:
        load_dict[load[i]] += 1
    else:
        load_dict[load[i]] = 1
        
if max(load_dict.values()) >= 3 or len(load_dict) <= 3:
    print("NO")
else:
    print("YES")

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
for i in range(1,5):
  if i in a[0] and i in a[1] and i in a[2]:
    print('NO')
    exit()
print('YES')

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

num = []
for i in range(4):
    num.append(len(G[i]))

cnt = num.count(1)
if cnt < 3:
    print('YES')
else:
    print('NO')

Solution (Python):

cnts=[0]*4
for i in range(3):
    ai,bi=map(int, input().split())
    ai-=1;bi-=1
    cnts[ai]+=1;cnts[bi]+=1
for i in range(4):
    if cnts[i]>2:
        print("NO")
        exit()
print("YES")

Solution (Python):

cnts=[0]*4
for i in range(3):
    ai,bi=map(int, input().split())
    ai-=1;bi-=1
    cnts[ai]+=1;cnts[bi]+=1
for i in range(4):
    if cnts[i]>2:
        print("NO")
        exit()
print("YES")

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

link = [[0 for _ in range(4)] for _ in range(4)]
for path in paths:
  link[path[0]-1][path[1]-1] += 1
  link[path[1]-1][path[0]-1] += 1

ans = 'YES'
for i in range(4):
  tmp = 0
  for j in range(4):
    tmp += link[i][j]

  if tmp >= 3:
    ans = 'NO'

print(ans)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import defaultdict, Counter
import bisect
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    a, b = i2(3)
    c = a+b
    if c.count(1) == 3 or c.count(2) == 3 or c.count(3) == 3 or c.count(4) == 3:
        print('NO')
    else:
        print('YES')




if __name__ == '__main__':
    main()

Solution (Python):
def cin():  return list(map(int,input().split()))
c = [0] * 4
for i in range(3):
    in1, in2 = cin()
    c[in1 - 1] += 1
    c[in2 - 1] += 1
c = sorted(c)
if c == [1, 1, 2, 2]:  print("YES")
else:  print("NO")

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

Solution (Python):

a, b = [], []
for _ in range(3):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

paths = a + b
passed_cities = []

for city in range(1, 5):
    passed_cities.append(paths.count(city))

print('NO' if max(passed_cities) == 3 else 'YES')

Solution (Python):
from collections import Counter

G=[[] for _ in range(4)]

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

c = Counter(deg)

cnt=0
for k in c.keys():
  if k%2: cnt += c[k]
    
if cnt in (0,2):
  print('YES')
else:
  print('NO')

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

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

    odd, even = 0, 0
    for path in path_list:
        if path % 2 == 0:
            even += 1
        else:
            odd += 1

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


if __name__ == "__main__":
    main()

Solution (Python):
a,b = map(int,input().split())
c,d = map(int,input().split())
e,f = map(int,input().split())
l = [a,b,c,d,e,f]
if l.count(1)>=3:
  print("NO")
  exit()
if l.count(2)>=3:
  print("NO")
  exit()
if l.count(3)>=3:
  print("NO")
  exit()
if l.count(4)>=3:
  print("NO")
  exit()
print("YES")

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

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
if max(cnt)<3:
    print('YES')
else:
    print('NO')

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

for i in [1,2,3,4]:
    cnt=0
    for j in l:
        if i==j:
            cnt+=1
    if cnt==0 or cnt>2:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
list1 =[]
total =0
for i in range(3):
  MM = input().split()
  a = int(MM[0])
  b = int(MM[1])
  list1.append(a)
  list1.append(b)
for i in range(5):
  x = list1.count(i)
  if x >2:
    total +=1
if total == 0:
  print('YES')
else:
  print('NO')

Solution (Python):
import collections
cc = collections.Counter()
for _ in range(3):
	u,v = map(int ,raw_input().split())
	cc[u]+=1
	cc[v]+=1
print 'YES' if sorted([cc[a] for a in [1,2,3,4]]) == [1,1,2,2] else 'NO'

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

Solution (Python):
def solve():
  t = [[] for _ in range(4)]
  for _ in range(3):
    a, b = map(int, input().split())
    if b-1 in t[a-1]:
      print("NO")
      return
    if a-1 in t[b-1]:
      print("NO")
      return
    t[a-1].append(b-1)
    t[b-1].append(a-1)

  for i in range(4):
    if len(t[i]) == 0:
      print("NO")
      return
    if len(t[i]) == 3:
      print("NO")
      return

  print("YES")
solve()

Solution (Python):
l=[]
for i in range(3):
    x,y=map(int,input().split())
    l.append(x)
    l.append(y)
d=[]
d.append(l.count(1))
d.append(l.count(2))
d.append(l.count(3))
d.append(l.count(4))
if(max(d)==3):
    print("NO")
else:
    print('YES')

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

num = []
num.append(L.count(1))
num.append(L.count(2))
num.append(L.count(3))
num.append(L.count(4))

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

Solution (Python):
import networkx as nx
a=[[int(i) for i in input().split()] for _ in range(3)]
g = nx.Graph()
for x in a:
     g.add_edge(x[0],x[1])
print("YES" if nx.is_semieulerian(g) else "NO")

Solution (Python):
import sys
A = []
for i in range(3):
  a,b = map(int,input().split())
  A.append(a)
  A.append(b)
if A.count(1) == 1:
  if A.count(4) == 1:
    if A.count(2) == 2:
      print("YES")
      sys.exit()
print("NO")

Solution (Python):
import sys
import itertools

abset=set()
for _ in range(3):
  a,b=map(int,input().split())
  abset.add((a,b))


for perm in itertools.permutations(range(1,5)):
  
  
  for i in range(1,4):
    if not (perm[i-1],perm[i]) in abset and not (perm[i],perm[i-1]) in abset:
      break
  else:
    
    print("YES")
    sys.exit(0)
else:
  print("NO")

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

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

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

Solution (Python):
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    
    for j in range(2):
        now=i[0][j]
        seen=set([now])
        for a,b in i:

            if b!=now and now!=a:break
            now=b+a-now
            seen.add(now)
        else:
            if len(seen)==4:print('YES');exit()

print("NO")

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

Solution (Python):
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  l=[0]*4
  for i in range(3):
    a,b=map(int,pin().split())
    l[a-1]+=1
    l[b-1]+=1
  t=sorted(list(set(l)))
  if t==[1,2]:
    print("YES")
  else:
    print("NO")
  return 

main()

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

route_lists = [a1, b1, a2, b2, a3, b3]
cnt_lists = []

for i in range(1, 5, 1):
    cnt = route_lists.count(i)
    cnt_lists.append(cnt)

if 3 in cnt_lists:
    ans = 'NO'
else:
    ans = 'YES'

print(ans)

Solution (Python):
ab=[]
ba=[]
fullpath=[]
for i in range(3):
    ab.append(list(map(int,input().split())))
for i in range(3):
    ba.append(list(reversed(ab[i])))
fullpath=ab+ba
fullpath1=[]
for i in range(len(fullpath)):
    fullpath1.append(fullpath[i][0])
count=[]
for i in range(1,5):
    count.append(fullpath1.count(i))
if count.count(1)==2 and count.count(2)==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
if cnt[0] == 1 and cnt[1] == 2 and cnt[2] == 2 and cnt[3] == 1:
    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
if cnt[0] == 1 and cnt[1] == 2 and cnt[2] == 2 and cnt[3] == 1:
    print("YES")
else:
    print("NO")

Solution (Python):
import itertools
import collections
l=[list(map(int,input().split())) for _ in range(3)]
l=list(itertools.chain(*l))
c=collections.Counter(l)
if sorted(list(c.values()))==[1,1,2,2]:
    print("YES")
else:
    print("NO")

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

one = 0
two = 0
for i in range(4):
    if cnt[i] == 1:
        one += 1
    elif cnt[i] == 2:
        two += 1
if one == two and one == 2:
    print("YES")
else:
    print("NO")

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

even = 0
for i in range(4):
    if town[i]%2 == 0:
        even += 1

if even == 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())

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

import collections
L=collections.Counter(A)

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

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

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

cnt1 = vis.count(1)
cnt2 = vis.count(2)

if cnt1 == 2 and cnt2 == 2:
    print("YES")
else:
    print("NO")

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

if 3 in L:
    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())
L=[a,b,c,d,e,f]
R=set(L)
if len(R)==4 and L.count(1)<3 and L.count(4)<3 and L.count(3)<3 and L.count(2)<3:
  print("YES")
else:
  print("NO")

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

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

n = [0]*4

for i in lis:
    n[i[0]-1] += 1
    n[i[1]-1] += 1

for j in n:
    if j >=3 or j ==0:
        print('NO')
        exit()
print('YES')

Solution (Python):
import sys
from collections import Counter
def main():
    read = sys.stdin.read
    A = map(int, read().split())
    c = Counter(A).most_common()[0][1]
    print('YES') if c == 2 else print('NO')

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import collections
import bisect


def main():
    k = [list(map(int, input().split())) for _ in range(3)]

    c = collections.Counter(k[0] + k[1] + k[2])
    print('YES' if sorted(c.values()) == [1, 1, 2, 2] else 'NO')


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    cnt = {1: 0, 2: 0, 3: 0, 4: 0}
    for _ in range(3):
        a, b = map(int, input().split())
        cnt[a] += 1
        cnt[b] += 1

    ans = 'YES'
    for k, v in cnt.items():
        if v > 2:
            ans = 'NO'
            break

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for _ in range(3):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

ans = 'YES'
for k, v in cnt.items():
    if v > 2:
        ans = 'NO'
        break

print(ans)

Solution (Python):
l = []

for _ in range(3):
    l += list(map(int, input().split()))

for i in range(4):
    if l.count(i + 1) == 3:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
ab = []
for i in range(3):
  p, q = map(int, input().split())
  ab.append(p)
  ab.append(q)
o, d = 0, 0
count = 0
for i in range(1, 5):
  if ab.count(i) == 2 or ab.count(i) == 1:
    count += 1
if count == 4:
  print('YES')
else:
  print('NO')

Solution (Python):
from collections import deque

def bfs():
    q = deque()
    t = 0
    x = [-1 + i for i in range(5)]
    for i in range(1, 5):
        q.append(i)
        dist = [-1] * 5
        dist[i] = 0
        while q:
            j = q.popleft()
            for i in G[j]:
                if dist[i] == -1:
                    dist[i] = dist[j] + 1
                    q.append(i)
        dist.sort()
        if x == dist:
            t = 1
            break
    return t

G = [[] for _ in range(5)]
for _ in range(3):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
print("YES" if bfs() else "NO")

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
from collections import defaultdict
dic1 = defaultdict(int)
for i in range(3):
    n,m = map(int,readline().split())
    dic1[n] += 1
    dic1[m] += 1

lst1 = list(dic1.values())
lst1.sort()

if lst1 == [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())
lst=[a,b,c,d,e,f]
ans='NO'
if lst.count(1)==1:
  if lst.count(2)==2:
    if lst.count(3)==2:
      if lst.count(4)==1:
        ans='YES'
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


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

    if count.count(1) == 2 and count.count(2) == 2:
        ans = "YES"
    else:
        ans = "NO"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
def main():
    d = defaultdict(int)
    for _ in range(3):
        a, b = list(map(int, input().split()))
        d[a] += 1
        d[b] += 1
    if sorted(d.values()) == [1, 1, 2, 2]:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Solution (Python):
import sys
a = list(map(int, input().split()))
a += list(map(int, input().split()))
a += list(map(int, input().split()))

for i in [1, 2, 3, 4]:
    if 1 <= a.count(i) <= 2:
        continue
    else:
        print('NO')
        sys.exit()
print('YES')

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

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

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

Solution (Python):
T = [0 for _ in range(4)]
for i in range(3):
    a, b = map(int, input().split())
    T[a - 1] += 1
    T[b - 1] += 1
if max(T) == 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())
temp=[a1,a2,a3,b1,b2,b3]
t1=temp.count(1)
t2=temp.count(2)
t3=temp.count(3)
t4=temp.count(4)
if max(t1,t2,t3,t4)==2:
  print("YES")
else:
  print("NO")

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

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

print('YES')

Solution (Python):
C=[0]*4
for _ in range(3):
    a,b=map(int,input().split())
    C[a-1]+=1
    C[b-1]+=1
print('YNEOS'[any(c>2 for c in C)::2])

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    cnt=[0]*5
    for _ in range(3):
        a,b=MI()
        cnt[a]+=1
        cnt[b]+=1
    for c in cnt:
        if c>2:
            print("NO")
            exit()
    print("YES")

main()

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

Solution (Python):
from collections import Counter
import sys
A = []
for i in range(3):
    a,b = map(int,input().split())
    A.append(a)
    A.append(b)
c = Counter(A)
for i in c.values():
    if i >=3:
        print('NO')
        sys.exit()
print('YES')

Solution (Python):
from collections import deque

n=4
m=3
g=[[] for _ in range(n)] 
for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    
def bfs(u, g, n):
    u -= 1
    queue = deque([u])
    d = [-1] * n
    d[u] = 0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                d[i] = d[v] + 1
                queue.append(i)
    return d

d = bfs(1, g, n)
d.sort()
if d[-1]==3:
    print('YES')
else:
    print('NO')

Solution (Python):
ab=[list(map(int, input().split())) for _ in range(3)]
ab=sum(ab,[])
if ab.count(1)>=3 or ab.count(2)>=3 or ab.count(3)>=3 or ab.count(4)>=3:
    print('NO')
else:
    print('YES')

Solution (Python):


from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    ab = [list(map(int, input().split())) for _ in range(3)]
    count = [0] * 4
    for a, b in ab:
        count[a - 1] += 1
        count[b - 1] += 1
    if count.count(3) >= 1:
        print('NO')
    else:
        print("YES")


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

Solution (Python):
from collections import Counter
lst = []
for i in range(3):
  a, b = map(int, input().split())
  lst.append(a)
  lst.append(b)
if sorted(list(Counter(lst).values())) == [1, 1, 2, 2]:
  print('YES')
else:
  print('NO')

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

visited = [False] * 4
visited[0] = True

def dfs(s):
    if all(visited):
        print('YES')
        exit()

    for i in root[s]:
        if visited[i]:
            continue

        visited[i] = True
        dfs(i)
        visited[i] = False

dfs(0)
print('NO')

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

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

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a1 = l()
a2 = l()
a3 = l()
AB = a1+a2+a3
c = Counter(AB)
if 1 in AB and 2 in AB and 3 in AB and 4 in AB and list(reversed(sorted(list(c.values()))))[0] == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import Counter
from itertools import chain
from sys import stdin
d = Counter(chain.from_iterable([list(map(int, stdin.readline().rstrip().split())) for _ in range(3)]))
if d[1] <= 2 and d[2] <= 2 and d[3] <= 2 and d[4] <= 2:
    print('YES')
else:
    print('NO')

Solution (Python):
miti = [[] for _ in range(5)]

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

cnt_list = []

for m in miti:
    cnt_list.append(len(m))
cnt_list.sort()
if cnt_list == [0, 1, 1, 2, 2]:
    print("YES")
else:
    print("NO")

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

for i in range(4):
    if lst[i]==0 or lst[i]==3:
        print("NO")
        break
else:
    print("YES")

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

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

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)

for i in range(3):
    p,q = map(int,input().split())
    dic[p] += 1
    dic[q] += 1

L = []
for v in dic.values():
    L.append(v)

odd = [x%2 ==1 for x in L]
even = [x%2 ==0 for x in L]

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

Solution (Python):
d = {1:0, 2:0, 3:0, 4:0}
for i in range(3):
  a, b = map(int, input().split())
  d[a] += 1
  d[b] += 1
d = sorted(d.items(), key=lambda x:x[1])
if len(d) == 4 and d[0][1] == 1 and d[1][1] == 1 and d[2][1] == 2 and d[3][1] == 2:
  print('YES')
else:
  print('NO')

Solution (Python):
t=sorted(map(int,open(0).read().split()))
print(['YES','NO'][max([t.count(i)for i in range(1,5)])>2])

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

dim = [0]*4

for _ in range(3):
	a, b = MAP()
	dim[a-1] += 1
	dim[b-1] += 1

c = Counter(dim)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

a = []
for _ in range(3):
	a.extend(LIST())

C = sorted(Counter(a).values())

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





dic = DD(int)
for _ in range(3):
  a,b = IL()
  dic[a] += 1
  dic[b] += 1
  
if max(dic[k] for k in dic)<=2:
  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)

for i in range(1,5):
  cnt=0
  for itm in l:
    if i==itm:
      cnt+=1
  if cnt>=3:
    print("NO")
    exit()
print("YES")

Solution (Python):
import collections
import itertools

li = [list(map(int,input().split())) for i in range(3)]
li = list(itertools.chain.from_iterable(li))
li.sort()

c = list(collections.Counter(li).values())

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

Solution (Python):
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]

l=[0,0,0,0]

for i in range(3):
    for j in range(2):
        l[S[i][j]-1]+=1

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