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,b = input().split()
c,d = input().split()
e,f = input().split()
list =[a,b,c,d,e,f]
print("YES" if list.count("2") == 2 and list.count("3") == 2 else "NO")

Solution (Python):
map = []

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

cnt = [0, 0, 0, 0]

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

for c in cnt:
    if c == 3:
        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())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if (l[i] == l[i+1]) and (l[i] == l[i+2]):
        x = False
if x == True:
    print("YES")
else:
    print("NO")

Solution (Python):
print("YES") if sum([sum(list(map(int,input().split()))) for i in range(3)])==15 else print("NO")

Solution (Python):
road = []

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

if road.count(1) >= 3:
	print('NO')
elif road.count(2) >= 3:
	print('NO')
elif road.count(3) >= 3:
	print('NO')
elif road.count(4) >= 3:
	print('NO')
else:
	print('YES')

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

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

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

for i in h:
    if i == 1:
        c1 += 1
    elif i == 2:
        c2 += 1
    elif i == 3:
        c3 += 1
    else:
        c4 += 1

ans = [c1, c2, c3, c4]

flag = False

for i in ans:
    if i == 3:
        flag = True

if flag == True:
    print("NO")
else:
    print('YES')

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

    visited = [False, False, False, False]
    degrees = [0, 0, 0, 0]
    for i in range(3):
        visited[a[i] - 1] = True
        visited[b[i] - 1] = True
        degrees[a[i] - 1] += 1
        degrees[b[i] - 1] += 1
    for i in range(4):
        if visited[i] == False:
            print('NO')
            return
    for i in range(4):
        if 3 <= degrees[i]:
            print('NO')
            return
    print('YES')

main()

Solution (Python):




def solveProblem(positionList):
	dictPosition = {"1":0,"2":0,"3":0,"4":0}
	for position in positionList:
		dictPosition[position] = dictPosition[position]+1
	oneBridgePosition = 0
	twoBridgePosition = 0
	for eachPosition in dictPosition:
		countBridge = dictPosition[eachPosition]
		if countBridge == 1:
			oneBridgePosition = oneBridgePosition + 1
		elif countBridge == 2:
			twoBridgePosition = twoBridgePosition + 1
	if oneBridgePosition == 2 and twoBridgePosition == 2:
		answer="YES"
	else :
		answer="NO"
	return answer


if __name__ == '__main__':
	positionList = list()
	a1,b1 = map(str,input().strip().split(' '))
	positionList.append(a1)
	positionList.append(b1)
	a2, b2 = map(str, input().strip().split(' '))
	positionList.append(a2)
	positionList.append(b2)
	a3, b3 = map(str, input().strip().split(' '))
	positionList.append(a3)
	positionList.append(b3)
	solution = solveProblem(positionList)
	print("{}".format(solution))

Solution (Python):


def walk(a,b,c):
    a.extend(b)
    a.extend(c)
    
    count1=a.count(1)
    count2=a.count(2)
    count3=a.count(3)
    count4=a.count(4)
    list=[count1,count2,count3,count4]
    
    if list.count(1)==2 and list.count(2)==2:
        return print("YES")
    else:
        return print("NO")
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
walk(a,b,c)

Solution (Python):

a = []
b = []
for i in range(3):
    a0, b0 = [int(i) for i in input().split()]
    if a0 != b0:
        a.append(a0)
        b.append(b0)
    else:
        print("NO")


if 1 <= all(a + b) <= 4:
    if a[0] + b[0] != a[1] + b[1] and a[1] + b[1] != a[2] + b[2] and a[2] + b[2] != a[0] + b[0]:
        one = (a + b).count(1)
        two = (a + b).count(2)
        three = (a + b).count(3)
        four = (a + b).count(4)
        if 1 <= one <=2 and 1 <= two <=2 and 1 <= three <=2 and 1 <= four <=2:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")

Solution (Python):
import collections

a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
lst=sorted([a1,b1,a2,b2,a3,b3])
ans=[]
l=collections.Counter(lst).values()
for i in l:
    ans.append(i)
print('YES') if ans==[1,2,2,1] 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()]


d = [[a1, b1], [a2, b2], [a3, b3]]
dl = [a1, b1, a2, b2, a3, b3]


def findn(n,l):
    res = []
    resl = []
    for it, t in enumerate(l):
        for iv, v in enumerate(t):
            if n == v:
                if iv == 0:
                    res.append(t[1])
                else:
                    res.append(t[0])
                lc = l[:]
                del lc[it]
                resl.append(lc)
    return res, resl



for i in range(1, 5):
    s, rest = findn(i, d)
    for iv, v in enumerate(s):
        last, lrest = findn(v, rest[iv])
        for ia, a in enumerate(last):
            res, nul = findn(a, lrest[ia])
            if len(res) >0 :
                judge = "YES"
            else:
                judge = "NO"

for i in range(1, 5):
    if not(i in dl):
        judge = "NO"

print(judge)

Solution (Python):
print("YES") if sum([sum(list(map(int,input().split()))) for i in range(3)]) == 15 else print("NO")

Solution (Python):
inputList = []
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())

one = 0
two = 0
three = 0
four = 0

for i in inputList:
    if i == 1:
        one = one + 1
    elif i == 2:
        two = two + 1
    elif i == 3:
        three = three + 1
    elif i == 4:
        four = four + 1

if one < 1 or one >= 3 or two < 1 or  two >= 3 or three < 1 or three >= 3 or four < 1 or four >= 3:
    print('NO')
else:
    print('YES')

Solution (Python):
in_a = input().split(" ")
in_b = input().split(" ")
in_c = input().split(" ")

total_a = set(in_a + in_b)
total_b = set(in_b + in_c)
total_c = set(in_c + in_a)


if len(total_a) != 4 and len(total_b) != 4 and len(total_c) != 4:
    print("NO")
else:
    print("YES")

Solution (Python):
a = []
for i in range(3):
  s,t = map(int, input().split())
  a.append(s)
  a.append(t)
b = [a.count(i)%2 for i in a]
if 0 not in a and b.count(1) == 2 or b.count(1) == 0:
  print('YES')
else:
  print('NO')

Solution (Python):
k1,k2 = [int(x) for x in input().split(' ')]
k3,k4 = [int(x) for x in input().split(' ')]
k5,k6 = [int(x) for x in input().split(' ')]
K = [k1,k2,k3,k4,k5,k6]
ss = [0,0,0,0]
for k in K:
    ss[k-1] += 1

ans = 'YES'
for s in ss:
    if s == 0:
        ans = 'NO'
    if s >= 3:
        ans = 'NO'
print(ans)

Solution (Python):
import collections

list_for_node_count = []

for _ in range(3):
    list_for_node_count.extend(input().split())
    
result_of_node_count = collections.Counter(list_for_node_count)

num_of_node = len(result_of_node_count)
odd_node_count = 0

for x in result_of_node_count.values():
    if int(x)%2 == 1:
        odd_node_count += 1

if odd_node_count == 2 or odd_node_count == 0:
    print('YES')
else:
    print('NO')

Solution (Python):


a0,b0= map(int,input().split())
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())

a=[a0,a1,a2,b0,b1,b2]

if a.count(1) > 2:
	print('NO')
elif a.count(2) > 2:
	print('NO')
elif a.count(3) > 2:
	print('NO')
elif  a.count(4) >2:
  print('NO')
else:
	print('YES')

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

a = []

ans = "YES"
for i in range(3):
    a.append(L[i][0])
    a.append(L[i][1])

for i in range(1,5):
    if a.count(i) >= 3:
        ans = "NO"

print(ans)

Solution (Python):
ab1 = list(map(int, input().split()))
ab2 = list(map(int, input().split()))
ab3 = list(map(int, input().split()))
roots = [ab1,ab2,ab3]
rootContainCity = []
rootContainCity.extend(ab1)
rootContainCity.extend(ab2)
rootContainCity.extend(ab3)

viaCityList = []
startOrGoalCityList = []

for i in range(4):
    if rootContainCity.count(i+1) == 2:
        viaCityList.append(i+1)
    else:
        startOrGoalCityList.append(i+1)
if len(viaCityList) == 2 and len(startOrGoalCityList) == 2:
    if [viaCityList[0],viaCityList[1]] in roots or [viaCityList[1],viaCityList[0]] in roots:
        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())

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

s = 0
t = 0
for i in range(len(li)):
    if li[i] == 2:
        s += 1
    if li[i] == 3:
        t += 1
if s == 2 and t == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
import copy
roads = []
roads2 = []
roads_stay = []
for s in range(3):
    a = [int(i) for i in input().split()]
    roads += [a]
lines=[]
for i in roads:
    lines.append(i[0])
    lines.append(i[1])

copys=copy.deepcopy(lines)
for i in range(len(lines)):
    lines=copy.deepcopy(copys)
    form=True if i%2==0 else False
    
    
    if form:
        tag=lines[i+1]
        end=[lines[i],lines[i+1]]
        lines[i]=0
        lines[i+1]=0
    else:
        tag=lines[i-1]
        end=[lines[i-1],lines[i]]
        lines[i]=0
        lines[i-1]=0
    flag=True

    while sum(lines)!=0:
        
        if tag in lines:
            index=lines.index(tag)
            form = True if index % 2==0 else False
            if form:
                tag = lines[index + 1]
                end += [lines[index + 1]]
                lines[index] = 0
                lines[index + 1] = 0
            else:
                tag = lines[index - 1]
                end += [lines[index - 1]]
                lines[index] = 0
                lines[index - 1] = 0
        else:
            break
    if len(set(end))==4 and sum(lines)==0:
        print('YES')
        exit(0)
    

print('NO')

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

ways = [False] * 4


def f(now, count):
    if count > 4:
        return False
    for n in ab[now]:
        if ways[n - 1]:
            continue
        ways[n - 1] = True
        if all(ways):
            print("YES")
            exit()
        f(n, count + 1)
        ways[n - 1] = False

for i in range(1, 5):
    ways = [False] * 4
    ways[i - 1] = True
    f(i, 1)
    ways[i - 1] = False
print("NO")

Solution (Python):
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 
c = [int(i) for i in input().split()] 

a.sort()
b.sort()
c.sort()

X = []

X.append(a[0])
X.append(a[1])
X.append(b[0])
X.append(b[1])
X.append(c[0])
X.append(c[1])

X.sort()
Y = set(X)
Z = set([1,2,3,4])
if Y != Z:
    print("NO")

w = [i for i in set(X) if X.count(i) > 1]

if w == a:
    print("YES")
elif w == b:
    print("YES")
elif w == c:
    print("YES")
else:
    print("NO")

Solution (Python):


num =[]
ans =0
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,5):

    if num.count(i)==3:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")

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

if __name__ == '__main__':
	main()

Solution (Python):
a1, b1 = (int(i) for i in raw_input().split(' '))
a2, b2 = (int(i) for i in raw_input().split(' '))
a3, b3 = (int(i) for i in raw_input().split(' '))


def func():
    count_1 = 0
    count_2 = 0
    count_3 = 0
    count_4 = 0
    for x in [a1,a2,a3,b1,b2,b3]:
        if x == 1:
            count_1 += 1
        elif x == 2:
            count_2 += 1
        elif x ==3:
            count_3 += 1
        elif x ==4:
            count_4 += 1
        else:
            print('error')

    for count in [count_1, count_2,count_3,count_4]:
        if count == 0 or count >= 3:
            print('NO')
            return
    print('YES')

func()

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

Solution (Python):
p=0
z= [0,0,0,0,0]
a,b=input().split( )
c,d=input().split( )
e,f=input().split( )
x = [a,b,c,d,e,f]
for i in range(6):
  x[i]=int(x[i])
  z[x[i]]=z[x[i]]+1
for i in range(1,5):
  if z[i] == 3:
    p = 1
if p==1:
  print ("NO")
else:
  print("YES")

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

a = [a,b,c,d,e,f]
al = list(Counter(a))

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

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

Solution (Python):
cnt = [0] * 5
for _ in range(3):
    s, t = map(int, input().split())
    cnt[s] += 1
    cnt[t] += 1
if cnt.count(2) == 2 and cnt.count(1) == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
nums = [input().split() for i in range(3)]
numss = nums[0] + nums[1] + nums[2]
if numss.count('1') >= 3 or numss.count('2') >= 3 or numss.count('3') >= 3 or numss.count('4') >= 3: 
    print("NO")
else:
    print("YES")

Solution (Python):
a=[0,0,0,0,0,0]
a[0],a[1] = map(int,input().split())
a[2],a[3] = map(int,input().split())
a[4],a[5] = map(int,input().split())

n1=a.count(1)
n2=a.count(2)
n3=a.count(3)
n4=a.count(4)

if n1<3:
    if n1>0:
        if n2<3:
            if n2>0:
                if n3<3:
                    if n3>0:
                        if n4<3:
                            if n4>0:
                                print("YES")
                                exit()
print("NO")

Solution (Python):
def main():
    edges = dict()

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

    odds = 0
    for i, cnt in edges.items():
        if cnt % 2 == 1:
            odds += 1

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

main()

Solution (Python):
listA=[] 
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        


listB=[]
for i in range(len(listA)):
    listB.extend(listA[i])

listc=[]
listc=[listB.count(i) for i in range(1,5)]

count1=listc.count(1)

if min(listc) > 0 and sum(listc)>5 and count1 <3:
  print('YES')
else:
  print('NO')

Solution (Python):
import sys
a=sys.stdin.read().split()
print(["YES","NO"][bool(sum(True for b in set(a)if a.count(b)>2))])

Solution (Python):
import sys


A = [0]*3
ptr = [[0,1,2],[0,2,1],[1,2,0],[1,0,2] ,[2,1,0], [2,0,1]]
for i in range(3):
    A[i] = [int(n) for n in input().split()]


for l in ptr:
    tmp = A[l[0]][0]
    ok = True
    for i in l:
        if not (tmp in A[i]):
            ok = False
            break
        elif(tmp == A[i][0]):
            tmp = A[i][1]
        else:
            tmp = A[i][0]
    if(ok):
        print("YES")
        sys.exit()
    tmp = A[l[0]][1]
    ok = True
    for i in l:
        if not (tmp in A[i]):
            ok = False
            break
        elif(tmp == A[i][0]):
            tmp = A[i][1]
        else:
            tmp = A[i][0]
    if(ok):
        print("YES")
        sys.exit()
print("NO")

Solution (Python):


"""
Created on Sat Feb  9 20:41:09 2019

@author: shinjisu
"""



def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def getIntLines(n): return [int(input()) for i in range(n)]


def zeros(n): return [0]*n


def db(x):
    global debug
    if debug:
        print(x)


def probA():
    N, K = getIntList()
    db((N, K))
    if (N+1)//2>=K:
        print('YES')
    else:
        print('NO')


def probB():
    a, b = zeros(3), zeros(3)
    db((a,b))
    for i in range(3):
        a[i], b[i] = getIntList()
    db((a,b))
    c = set([])
    e = zeros(5)
    for i in range(3):
        c.add(a[i])
        c.add(b[i])
        e[a[i]] += 1
        e[b[i]] += 1
    db((c,e))
    c0,c1,c2,c3,c4=0,0,0,0,0
    for i in range(1, 5):
        if e[i]==0:
            c0 += 1
        elif e[i] == 1:
            c1 += 1
        elif e[i] == 2:
            c2 += 1
        elif e[i] == 3:
            c3 += 1
        else:
            c4 += 1
    db((c0,c1,c2,c3,c4))
    if c1 == 2 and c2 == 2: 
        print('YES')
    else:
        print('NO')


def probC():
    return 0


debug = False
probB()

Solution (Python):
P1 = [int(x) for x in input().split()]
P2 = [int(x) for x in input().split()]
P3 = [int(x) for x in input().split()]
P = [0] * 4
count = 0
for i in range(0,2):
    P[P1[i]-1] += 1
    P[P2[i]-1] += 1
    P[P3[i]-1] += 1
for i in range(0,4):
    if P[i] == 3:
        count = 1
if count == 0:
    print("YES")
else:
    print("NO")

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

b = []
for i in range(3):
	for j in range(2):
		b.append(a[i][j])

if b.count(1) <= 2 and b.count(2) <= 2 and b.count(3) <= 2 and b.count(4) <= 2:
	print("YES")

else:
	print("NO")

Solution (Python):

import sys



def solve(lines):
    counts = [0,0,0,0]
    for i in range(3):
        a,b = map(int, lines.pop(0).split(' '))
        counts[a-1] += 1
        counts[b-1] += 1

    if max(counts) == 2 and min(counts) == 1:
        print('YES')
    else:
        print('NO')



lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):
ab1 = input().split(" ")
ab2 = input().split(" ")
ab3 = input().split(" ")
line = []
count = []

for i in range(2):
    line.append(int(ab1[i]))
    line.append(int(ab2[i]))
    line.append(int(ab3[i]))

count.append(line.count(1))
count.append(line.count(2))
count.append(line.count(3))
count.append(line.count(4))

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

Solution (Python):


machi = dict()
for i in range(4):
    machi[i+1] = []

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


count = 0
start, end = 0, 0
for i in range(4):
    if len(machi[i+1]) == 1:
        if count == 0:
            start = i+1
            count += 1
        else:
            end = i+1


if (start != 0) & (end != 0):
    second = machi[start][0]
    third = machi[end][0]
    if third in machi[second]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Solution (Python):


cnt=[0,0,0,0]
flg=True

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

for i in range(4):
    if cnt[i]==3:
        flg=False

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

Solution (Python):
line_list = []

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

ans = 'YES'

for now_point in [1, 2, 3, 4]:
    count = 0
    for i in range(len(line_list)):
        if line_list[i][0] == now_point:
            count += 1
    if count == 3:
        ans = 'NO'
        break

print(ans)

Solution (Python):
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))

total = [1]
now = 1
l = [l1,l2,l3]

for i in range(3):
    for ll in l:
        if now in ll:
            ll.pop(ll.index(now))
            now = max(ll)
            total.append(now)
            l.pop(l.index(ll))

if 1 in total and 2 in total and 3 in total and 4 in total:
    print("YES")
else:
    print("NO")

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

Solution (Python):
a = []
b = []
c = []
li = []
li2 = []
for i in range (3):
    if i == 0:
        a = list(map(int, input().split(' ')))
    if i == 1:
        b = list(map(int, input().split(' ')))
    if i == 2:
        c = list(map(int, input().split(' ')))
li = a
li.extend(b)
li.extend(c)
li = sorted(li)
for s in range (4):
    li2.append(li.count(s+1))

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

Solution (Python):
n1=0
n2=0
n3=0
n4=0

for i in range(3):
 nData = []
 nData  = input().rstrip().split(' ')

 nN1 = int(nData[0])
 nN2 = int(nData[1])

 if nN1==1:
  n1+=1
 elif nN1==2:
  n2+=1
 elif nN1==3:
  n3+=1
 elif nN1==4:
  n4+=1

 if nN2==1:
  n1+=1
 elif nN2==2:
  n2+=1
 elif nN2==3:
  n3+=1
 elif nN2==4:
  n4+=1

if n1==3:
 print('NO')
elif n2==3:
 print('NO')
elif n3==3:
 print('NO')
elif n4==3:
 print('NO')
else:
 print('YES')

Solution (Python):

count = {x+1: 0 for x in range(4)}
for _ in range(3):
    a, b = list(map(int, input().split()))
    count[a] += 1
    count[b] += 1
if 3 in count.values():
    print('NO')
else:
    print('YES')

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

ok = True
for i in [1,2,3,4]:
  icnt = abs.count(i)
  if icnt == 0 or icnt > 2:
    ok = False

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

Solution (Python):
import sys, copy, math, collections, itertools

a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
l=[]
l+=[a1,a2,a3,b1,b2,b3]
d=[0,0,0,0]
for i in l:
    d[i-1]+=1


a=len([i for i in d if i%2==0])
if a == 2:
    print("YES")
else:
    print("NO")

Solution (Python):


n = 3
e = [[int(i) for i in input().split()] for i in range(n)]

for path in e:
    if 1 in path:
        path.sort()
        next_city = path[1]

        e.remove(path)
        break



for path in e:
    if next_city in path:
        if next_city == path[0]:
            next_city = path[1]
        else:
            next_city = path[0]

        e.remove(path)
        break


for path in e:
    if next_city in path:
        if next_city == path[0]:
            next_city = path[1]
        else:
            next_city = path[0]
        e.remove(path)
        break


if len(e) == 0:
    print('YES')
else:
    print('NO')

Solution (Python):

lst = []


x,i = map(int, input().split())
lst.append(x)
lst.append(i)
y,j = map(int, input().split())
lst.append(y)
lst.append(j)
z,j = map(int, input().split())
lst.append(z)
lst.append(j)


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

if a <3 and b <3 and c <3 and d <3 :
    print('YES')
else:
    print('NO')

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


c1 = ls.count(1)
c2 = ls.count(2)
c3 = ls.count(3)
c4 = ls.count(4)
lst = [c1,c2,c3,c4]

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

Solution (Python):
def main() -> None:
    r = (str(input()) + " " + str(input()) + " " +  str(input())).split()
    pos = {
        1: 0,
        2: 0,
        3: 0,
        4: 0,
    }
    for i in r:
        pos[int(i)] += 1

    num = 0
    for i in pos.values():
        if i >= 2:
            num = num + 1

    print("%s" % "YES" if num >= 2 else "NO")


if __name__ == '__main__':
    main()

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

Solution (Python):
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
arr3=list(map(int,input().split()))
arrall=arr1+arr2+arr3
num=[]
for i in range(4):
    num.append(arrall.count(i+1))
num.sort()
if num == [1,1,2,2] :
    print("YES")
else:
    print("NO")

Solution (Python):
p = []
for i in range(3):
    a = input().rstrip().split(" ")
    p.append(int(a[0]))
    p.append(int(a[1]))


c = []
for i in range(4):
    a = p.count(i + 1)
    c.append(a)
c.sort()

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

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

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

for x in range(1, 5):
    if all_num.count(x) >= 3:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
import copy

def function(nums):
	path = copy.deepcopy(nums)
	clear = []

	newpath = 0
	for p1 in nums:
		for p2 in nums:
			if p1[0] == p2[1] and p1 != p2 :
				newpath = [[p1[1], p2[0]]]
				clear.append(p1[0])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[1] == p2[0] and p1 != p2 :
				newpath = [[p1[0], p2[1]]]
				clear.append(p1[1])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[1] == p2[1] and p1 != p2 :
				newpath = [[p1[0], p2[0]]]
				clear.append(p1[1])
				path.remove(p1)
				path.remove(p2)
				break
			elif p1[0] == p2[0] and p1 != p2 :
				newpath = [[p1[1], p2[1]]]
				clear.append(p1[0])
				path.remove(p1)
				path.remove(p2)
				break
		if len(clear) > 0:
			break
	newpath.append(path[0])

	if (newpath[0][0] == newpath[1][0] or newpath[0][0] == newpath[1][1] or newpath[0][1] == newpath[1][0] or newpath[0][1] == newpath[1][1]) and newpath[0] != newpath[1]:
		clear.append(newpath[0][0])
		clear.append(newpath[0][1])
		clear.append(newpath[1][0])
		clear.append(newpath[1][1])
		clear = list(set(clear))
	
	if 1 in clear and 2 in clear and 3 in clear and 4 in clear:
		print('YES')
	else:
		print('NO')

def main():
	strs = [input() for i in range(3)]
	nums = [[int(_.split(' ')[0]),int(_.split(' ')[1])] for _ in strs]
	function(nums)

if __name__ == '__main__':
	main()

Solution (Python):

import collections

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

c = []
for i in range(3):
    c.append([a[i], b[i]])
    c.append([b[i], a[i]])
    
def hitohude(route):
    if not (0 in route and 1 in route and 2 in route and 3 in route):
        return False
        
    for i in range(3):
        if [route[i], route[i+1]] in c:
            continue
        else:
            return False
    return True

finish=False
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                route = [i,j,k,l]
                flag = hitohude(route)
                if flag == True:
                    print('YES')
                    finish = True
                if finish==True:
                    break
            if finish==True:
                break
        if finish==True:
            break
    if finish==True:
        break
if finish==False:
    print('NO')

Solution (Python):
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    tree = [[] for _ in range(4)]
    for i in range(3):
        a, b = il()
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)

    def dfs(prev, s, ans):
        for t in tree[s]:
            if t == prev:
                continue
            ans.append(s)
            _ = dfs(s, t, ans)
        return len(set(ans))

    return "YES" if dfs(-1, 0, []) == 3 else "NO"


if __name__ == "__main__":
    print(solve())

Solution (Python):
import itertools

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

for li in itertools.permutations(lst, 3):
    for i in range(8):
        t = []
        if i & 1:
            t.append((li[0][1], li[0][0]))
        else:
            t.append(li[0])
        if i & 2:
            t.append((li[1][1], li[1][0]))
        else:
            t.append(li[1])
        if i & 4:
            t.append((li[2][1], li[2][0]))
        else:
            t.append(li[2])

        pre = t[0][1]
        for j in range(1, 3):
            if pre != t[j][0]:
                break
            pre = t[j][1]
        else:
            print("YES")
            exit()

else:
    print("NO")

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

block1 = 0
block2 = 0
block3 = 0
block4 = 0

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

for i in pathes:
    if (i == 1):
        block1 += 1
    if (i == 2):
        block2 += 1
    if (i == 3):
        block3 += 1
    if (i == 4):
        block4 += 1

if (block1 == 3 or block2 == 3 or block3 == 3 or block4 == 3):
    print("NO")
else:
    print("YES")

Solution (Python):
load = []
for i in range(3):
	tmp = input().split();
	load.append([int(tmp[0]),int(tmp[1])])
count = [0]*5
for i in range(len(load)):
	count[load[i][0]]+=1
	count[load[i][1]]+=1

ans = True

for i in range(1,5):
	if(count[i] == 3):
		ans = False

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

Solution (Python):
"""AtCoder"""

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

l = [a1, b1, a2, b2, a3, b3]
sl = set(l)

if l.count(1) < 3 and l.count(2) < 3 and l.count(3) < 3 and l.count(4) < 3 and len(sl) ==4:
  print("YES")
else:
  print("NO")

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

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

A=l.count(1)
B=l.count(2)
C=l.count(3)
D=l.count(4)

if A==3 or B==3 or C==3 or D==3:
  print("NO")
  
else:
  print("YES")