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):
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

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

if li.count(1)>=3 or li.count(2)>=3 or li.count(3)>=3 or li.count(4)>=3:
  print("NO")
else:
  print("YES")

Solution (Python):

import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)


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


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


for i in [a, b, c, d, e, f]:
    count[i] += 1

count_list = []
for key in count.keys():
    count_list.append(count[key])

m = max(count_list)
if m >= 3:
    print("NO")
else:
    print("YES")

Solution (Python):
c = [0]*4
for i in xrange(3):
  ai, bi = map(int, raw_input().split())
  c[ai-1] += 1
  c[bi-1] += 1
r = "YES"
for j in xrange(4):
  if c[j]>=3:
    r = "NO"
print r

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

city.pop(0)
city=sorted(city)
if city==[1,1,2,2]:
    print("YES")
else:
    print("NO")

Solution (Python):
d = [0] * 4
for i in xrange(3):
    a, b = map(int, raw_input().split())
    d[a-1] += 1
    d[b-1] += 1
t = 0
for x in d:
    t += x % 2
print "YES" if t <= 2 else "NO"

Solution (Python):
A = [ list( map( int, input().split())) for _ in range(3)]
ans = "YES"
for t in range(1,5):
    for i in range(3):
        if A[i][1] == t or A[i][0] == t:
            pass
        else:
            break
    else:
        ans = "NO"
print(ans)

Solution (Python):
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

a1,b1 = getInts()
a2,b2 = getInts()
a3,b3 = getInts()
towns = [a1,a2,a3,b1,b2,b3]
print("YES" if all([towns.count(i) <=2 for i in range(1,5)]) else "NO")

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

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

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

Solution (Python):

def main():
    a = []
    b = []
    for i in range(3):
        buf = input()
        buflist = buf.split()
        a.append(int(buflist[0]))
        b.append(int(buflist[1]))
    count = [0, 0, 0, 0]
    for i in a:
        count[i-1] += 1
    for i in b:
        count[i-1] += 1
    for i in count:
        if i >= 3:
            print("NO")
            return
    print("YES")

if __name__ == '__main__':
    main()

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

Solution (Python):
ab = [list(map(int,input().split())) for i in range(3)]
num = [0,0,0,0]
for i in range(3):
    num[ab[i][0]-1]+=1
    num[ab[i][1]-1]+=1
if max(num) == 2 and min(num) == 1:
    print("YES")
else:
    print("NO")

Solution (Python):


import sys


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

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


G = [[] for _ in range(4)]
for i in range(3):
    a, b = LI_()
    G[a].append(b)
    G[b].append(a)

for v in G:
    if len(v) % 2 == 0:
        print('YES')
        break
else:
    print('NO')

Solution (Python):
a = []
a += list(map(int, input().split()))
a += list(map(int, input().split()))
a += list(map(int, input().split()))

for i in range(1, 5):
    c = a.count(i)
    if c == 0 or c >= 3:
        print("NO")
        exit(0)

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]

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

Solution (Python):

from collections import Counter

a = [ [int(a) for a in input().split()] for _ in range(3)]
b = sum(a, [])


b = Counter(b)

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

Solution (Python):
AB = [[int(_) for _ in input().split()] for _ in range(3)]
count = [0] * 5
for a, b in AB:
    count[a] += 1
    count[b] += 1
if sorted(count[1:]) == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

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

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

if max(cnt) < 3:
    print("YES")
else:
    print("NO")

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

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

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

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

Solution (Python):
li =[0]*4
for i in range(3):
  l =[int(i) for i in input().split()]
  for i in l:
    li[i-1] += 1

foo = 0
for i in li:
  if i%2!=0:
    foo += 1
if foo >2:
  print("NO")
else:
  print("YES")

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

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

Solution (Python):



from collections import deque
import heapq
import math
import bisect


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

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


if __name__ == '__main__':
    main()

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

Deg=[0 for i in range(4)]
for a in A:
    Deg[a-1]+=1
for b in B:
    Deg[b-1]+=1
if min(Deg)==1 and max(Deg)==2:
    print "YES"
else:
    print "NO"

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

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

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
ans = "YES"
for e in cnt:
    if e >= 3:
        ans = "NO"
        break
print(ans)

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

Solution (Python):

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

Solution (Python):
from collections import defaultdict

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

for k, v in items.items():
    if v >= 3:
        print("NO")
        exit()
print("YES")

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

A=[0]*4

for a,b in R:
    A[a-1]+=1
    A[b-1]+=1

if max(A)==2 and min(A)==1:
    print("YES")
else:
    print("NO")

Solution (Python):
from itertools import permutations

AB = [map(int, raw_input().split()) for _ in xrange(3)]

for p in permutations(range(3)):
    e1 = AB[p[0]]
    e2 = AB[p[1]]
    e3 = AB[p[2]]
    for p1 in permutations(e1):
        for p2 in permutations(e2):
            for p3 in permutations(e3):
                if p1[1] == p2[0] and p2[1] == p3[0] and p1[0] != p3[1]:
                    print "YES"
                    exit()

print "NO"

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

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

Solution (Python):

degree = [ 0 ] * 4
for _ in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    degree[a] += 1
    degree[b] += 1
odd = len(list(filter(lambda x: x % 2 == 1, degree)))
print(['NO', 'YES'][odd <= 2])

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Solution (Python):
import math
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

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

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

def mins(x, y):
    x = min(x, y)

def maxs(x, y):
    x = max(x, y)

while(True):
    try:
        cnt = [0] * 5
        for i in range(3):
            a, b = get_int_list()
            cnt[a] += 1
            cnt[b] += 1
        if cnt.count(2) == 2:
            print("YES")
        else:
            print("NO")
    except EOFError:
        exit()

Solution (Python):
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

path = [0,0,0,0]
for i in range(3):
    a,b = getMN()
    path[a-1] += 1
    path[b-1] += 1

if max(path) <= 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 = [0 for _ in [0]*4]

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

P = max(A)

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

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

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


cnt = [list.count(i) for i in range(1,5)]
cnt = sorted(cnt)
if cnt == [1,1,2,2]:
    print('YES')
else:
    print('NO')

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

Solution (Python):
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

c = [0] * 5
for i in range(3):
    a, b = mi()
    c[a] += 1
    c[b] += 1
print('YES' if c.count(1) == 2 else 'NO')

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

Solution (Python):
from collections import Counter
c = Counter()
for _ in range(3):
	a, b = map(int, input().split())
	c[a] += 1
	c[b] += 1
one, two = 0, 0
for i in range(1, 5):
	if c[i] == 1:
		one += 1
	elif c[i] == 2:
		two += 1
if (one, two) == (2, 2):
	print("YES")
else:
	print("NO")

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

Solution (Python):


import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    c = Counter()
    for _ in range(3):
        i, j = MI()
        c[i] += 1
        c[j] += 1
    return c.most_common(1)[0][1] == 2


if __name__ == "__main__":
    YESNO(main())

Solution (Python):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
a = [0]*4
for i in range(3):
    n,m = map(int,input().split())
    n-=1;m-=1
    a[n] += 1
    a[m] += 1
a.sort()
if a == [1,1,2,2]:
    print("YES")
else:
    print("NO")

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():
    c = collections.defaultdict(int)
    for _ in range(3):
        a,b = LI()
        c[a] += 1
        c[b] += 1
    if max(c.values()) == 3:
        return 'NO'

    return 'YES'



print(main())

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

cnt = [0]*4
for _ in range(3):
    a,b = li_()
    cnt[a] += 1
    cnt[b] += 1
    
if max(cnt) == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
A = [0]*5
for i in range(3):
    a, b = map(int, input().split())
    A[a]+=1
    A[b]+=1
if max(A)==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())
l = [0] * 4
l[a1-1]+=1
l[a2-1]+=1
l[a3-1]+=1
l[b1-1]+=1
l[b2-1]+=1
l[b3-1]+=1
l = sorted(l)
if l == [1,1,2,2]:
    print("YES")
else:
    print("NO")