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):
c=[]
for i in range(3):
    a,b=map(int,input().split())
    c.append(a)
    c.append(b)
if c.count(1)<3 and c.count(2)<3 and c.count(3)<3 and c.count(4)<3:
    print('YES')
else:
    print('NO')

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

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

Solution (Python):
def pin(type=int):
  return map(type,input().split())
counter = [0]*4
for i in range(3):
  a,b=pin()
  counter[a-1]+=1
  counter[b-1]+=1
ans=1
for j in counter:
  if j>2 or j<1:
    ans=0
print(["NO","YES"][ans])

Solution (Python):
a1, a2 = map(int, input().split())
a3, a4 = map(int, input().split())
a5, a6 = map(int, input().split())

ans = []

ans.append(a1)
ans.append(a2)
ans.append(a3)
ans.append(a4)
ans.append(a5)
ans.append(a6)

max = 0

for i in ans:
	if max < ans.count(i):
		max = ans.count(i)

print("YES" if max <= 2 else "NO")

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

Solution (Python):
def examA():
    N, K = LI()
    if (N+1)//2>=K:
        print("YES")
    else:
        print("NO")
    return

def examB():
    d = [0]*4
    for _ in range(3):
        a, b = LI()
        a -=1; b -=1
        d[a] +=1
        d[b] +=1
    for i in d:
        if i>=3 or i==0:
            print("NO")
            return
    print("YES")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Solution (Python):
import sys

read = sys.stdin.read

ab = list(map(int, read().split()))

for i in (1, 2, 3, 4):
    if ab.count(i) > 2:
        print('NO')
        exit()
else:
    print('YES')

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

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

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

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

Solution (Python):
def main(a_b: list):
    l = [0 for _ in range(4)]

    for a, b in a_b:
        l[a - 1] += 1
        l[b - 1] += 1

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


if __name__ == "__main__":
    a_b = [list(map(int, input().split())) for _ in range(3)]

    main(a_b)

Solution (Python):
from collections import Counter

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

c=Counter(l)
if max(c.values())==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 max(cnt) >=3:
    print("NO")
else:
    print("YES")

Solution (Python):

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

for m in machi:
    if m == 3:
        import sys
        print('NO')
        sys.exit()

print('YES')

Solution (Python):
from sys import stdin
from itertools import groupby

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
lis = []
for i in range(3):
    for j in range(2):
        lis.append(li[i][j])
lis.sort()
lin = []
for key, value in groupby(lis):
    lin.append(len(list(value)))
lin.sort()
if lin == [1,1,2,2]:
    print("YES")
else:
    print("NO")

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

for i in range(3):
    a,b=map(int,input().split())
    p[a-1]+=1
    p[b-1]+=1
    
odd=0
for i in range(4):
    if p[i]%2==1:
        odd+=1
        
if odd<=2:
    print("YES")
else:
    print("NO")

Solution (Python):
a=[[int(i) for i in input().split()] for i in range(3)]
import collections 
d=collections.defaultdict(int)
for i in a:
    d[i[0]]+=1
    d[i[1]]+=1
x=[]
for i in d.values():
    x.append(i)
if x.count(1)==2 and x.count(2)==2:
    print("YES")
else:
    print("NO")

Solution (Python):
from collections import defaultdict

def main():
    dic = defaultdict(int)
    for _ in range(3):
        a,b = map(int,input().split())
        dic[a] += 1
        dic[b] += 1
    
    for i in range(1,5):
        if dic[i]==3:
            print("NO")
            exit()
    print("YES")
if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
a = list(map(int,read().split()))
if len(set(a)) == 4:
  if max([a.count(x) for x in range(1,5)]) == 2:
    print("YES")
    exit()
print("NO")

Solution (Python):
ls = [[int(_) for _ in input().split()] for _ in range(3)]

cnt = [0] * 4

for i in range(3):
    for j in range(2):
        if ls[i][j] == 1:
            cnt[0] += 1
        elif ls[i][j] == 2:
            cnt[1] += 1
        elif ls[i][j] == 3:
            cnt[2] += 1
        elif ls[i][j] == 4:
            cnt[3] += 1

if min(cnt) == 0 or max(cnt) == 3:
    print("NO")
else:
    print("YES")

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

G=[[0]*4 for i in range(4)]
for i in range(3):
    a,b=map(int,input().split())
    a-=1;b-=1
    G[a].append(b)
    G[b].append(a)
visited=[0]*4
def dfs(node):
    visited[node]=1
    for gi in G[node]:
        if not visited[gi]:
            dfs(gi)
            return
dfs(0)
if all(visited):
    print("YES")
else:
    print("NO")

Solution (Python):
import sys

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

for i in [1,2,3,4]:
	if t.count(i) > 2:
		print("NO")
		sys.exit()

print("YES")

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

path=a+b

import collections
c=collections.Counter(path)

values,counts =zip(*c.most_common())

if counts==(2,2,1,1):
    print('YES')
else:
    print('NO')

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

print('YES' if 1<=min(cnt) and max(cnt)<=2 else 'NO')

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

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

odd = 0
for i in range(1,5):
    x = a.count(i)
    if x % 2 == 1:
        odd += 1
if odd <= 2:
    print('YES')
else:
    print('NO')

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

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

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

cnt = [0] * 4
for a, b in ab :
  cnt[a-1] += 1
  cnt[b-1] += 1
  
if cnt.count(1) == cnt.count(2) == 2 :
  print('YES')
else :
  print('NO')

Solution (Python):
miti = [0, 0, 0, 0]
d = [[] for _ in range(4)]

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

miti[0] = 1
index = 0
for i in range(3):
    for j in range(len(d[index])):
        if j < len(d[index]) and miti[d[index][j]] != 1:
            miti[d[index][j]] = 1
            index = d[index][j]

if sum(miti) == 4:
    print('YES')
else:
    print('NO')

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

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

if maxa == 3:
    print("NO")
    exit(0)
print("YES")

Solution (Python):
import sys
from collections import Counter
ct = {i:0 for i in range(1,5)}
for i in range(3):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ct[a] += 1
    ct[b] += 1
ct2 = Counter(ct.values())
if ct2[1] == 2 and ct2[2] == 2:
    print("YES")
else:
    print("NO")

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

Solution (Python):
G = {i:[] for i in range(1,5)}
for _ in range(3):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
cnt = 0
for x in G:
    if len(G[x])%2==1:
        cnt += 1
if cnt>2:
    print("NO")
else:
    print("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
b=1
for i in range(4):
  if a[i]==3:
    print("NO")
    b=0
    break
if(b):
  print("YES")

Solution (Python):
lista = []
for i in range(3):
  a,b = map(int,input().split())
  lista.append(a)
  lista.append(b)
l1 = 0
l2 = 0
l3 = 0
l4 = 0
for j in lista:
  if j == 1:
    l1 += 1
  if j == 2:
    l2 += 1
  if j == 3:
    l3 += 1
  if j == 4:
    l4 += 1
c = (l1)%2 + (l2)%2 + (l3)%2 + (l4)%2
if c <= 2:
  print('YES')
else:
  print('NO')

Solution (Python):
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    ls = []
    for i in range(3):
        a, b = list(map(int, input().rstrip('\n').split()))
        ls.append(a)
        ls.append(b)
    ls = collections.Counter(ls).most_common()
    print("YES" if ls[0][1] == 2 and ls[1][1] == 2 and ls[2][1] == 1 and ls[3][1] == 1 else "NO")


if __name__ == '__main__':
    solve()

Solution (Python):
s={1,2,3,4}
for i in range(3):
    s&=set(map(int,input().split()))
print('YES' if not s else 'NO')

Solution (Python):


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

odd=0
for c in edge:
    if len(c)%2:odd+=1
print('YES' if odd==2 else 'NO')

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

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

Solution (Python):

import sys

YES = "YES"  
NO = "NO"  


def solve(a: "List[int]", b: "List[int]"):
    ab = a+b
    t1 = [ab.count(1), ab.count(2), ab.count(3), ab.count(4)]
    
    if t1.count(1) == t1.count(2):
        print(YES)
    else:
        print(NO)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = [int()] * (3)  
    b = [int()] * (3)  
    for i in range(3):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(a, b)

if __name__ == '__main__':
    main()

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

cnt = 0
for i in range(1,5):
  tmp = 0
  for j in range(3):
    tmp += a[j].count(i) 
  if tmp == 2:
    cnt += 1

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

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

Solution (Python):
from collections import Counter
abs = []
for i in range(3):
    ab = list(map(int, input().split()))
    abs.extend(ab)
c = Counter(abs)
if c.most_common(1)[0][1] <= 2:
    print("YES")
else:
    print("NO")

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



AB = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]

graph = [[] for _ in range(5)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

ok = False
for a, b, c, d in itertools.permutations(range(1, 5)):
    ok |= b in graph[a] and c in graph[b] and d in graph[c]
if ok:
    print('YES')
else:
    print('NO')

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random

import os
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a1, b1 = inputMap()
    a2, b2 = inputMap()
    a3, b3 = inputMap()
    
    maps = {}
    maps[a1] = 1
    maps[b1] = 1
    
    if a2 in maps:
        maps[a2] += 1
    else:
        maps[a2] = 1
        
    if b2 in maps:
        maps[b2] += 1
    else:
        maps[b2] = 1
        
    if a3 in maps:
        maps[a3] += 1
    else:
        maps[a3] = 1
        
    if b3 in maps:
        maps[b3] += 1
    else:
        maps[b3] = 1
        
    for k,v in maps.items():
        if v > 2:
            print("NO")
            sys.exit()
            
    print("YES")
    
    
if __name__ == "__main__":
	main()

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

Solution (Python):
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())
cnt = [0,0,0,0]
cnt[a1-1] += 1
cnt[a2-1] += 1
cnt[a3-1] += 1
cnt[b1-1] += 1
cnt[b2-1] += 1
cnt[b3-1] += 1
print("YES" if max(cnt) < 3 else "NO")

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

Solution (Python):
from collections import Counter

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

li = []

for i in range(3):
    for j in range(2):
        li.append(city[i][j])
        
c = Counter(li)

for i in range(1,5):
    if c[i] >= 3:
        print("NO")
        exit()
        
print("YES")

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

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

z = []
for i in range(3):
    a,b = inpl()
    z.append(a)
    z.append(b)
c = Counter(z)
for key in c.keys():
    if c[key] > 2:
        print('NO')
        break
else:
    print('YES')

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

for i in range(3):
    a, b = map(int, input().split())
    t[a - 1] += 1
    t[b - 1] += 1
print("NO" if 3 in t else "YES")

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

tmp=[]
for a,b in AB:
  tmp.append(a)
  tmp.append(b)
for i in set(tmp):
  if tmp.count(i)==3:
    print('NO')
    exit()
print('YES')

Solution (Python):
x=[]
b2=0
b3=0
b1=0
b4=0
a1=input().split()
a1[0]=int(a1[0])
a1[1]=int(a1[1])
a2=input().split()
a2[0]=int(a2[0])
a2[1]=int(a2[1])
a3=input().split()
a3[0]=int(a3[0])
a3[1]=int(a3[1])
x.append(a1[0])
x.append(a1[1])
x.append(a2[0])
x.append(a2[1])
x.append(a3[0])
x.append(a3[1])
for i in range(6):
    if x[i]==1:
        b1+=1
    elif x[i]==2:
        b2+=1
    elif x[i]==3:
        b3+=1
    else:
        b4+=1
if b2==2 and b3==2:
    print('YES')
elif b1==2 and b2==2:
    print('YES')
elif b1==2 and b3==2:
    print('YES')
elif b1==2 and b4==2:
    print('YES')
elif b4==2 and b3==2:
    print('YES')
elif b2==2 and b4==2:
    print('YES')
else:
    print('NO')

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

cnt=[0,0,0,0]

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

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

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

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

Solution (Python):
import sys

city = [0] * 4
for i in range(3):
    a, b = list(map(int, input().split()))
    city[a - 1] += 1
    city[b - 1] += 1
odd_count = 0
for count in city:
    if count % 2 == 1:
        odd_count += 1
        if odd_count > 2:
            print("NO")
            sys.exit()
print("YES")

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

Solution (Python):
n1=n2=n3=n4=0
for _ in range(3):
    a,b = map(int,input().split())
    if a==1:
        n1+=1
    elif a==2:
        n2+=1
    elif a==3:
        n3+=1
    else:
        n4+=1
    if b==1:
        n1+=1
    elif b==2:
        n2+=1
    elif b==3:
        n3+=1
    else:
        n4+=1
if n1*n2*n3*n4==4:
    print("YES")
else:
    print("NO")

Solution (Python):
I=input;s=I()+I()+I();print("YNEOS"[any(s.count(x)>2for x in"1234")::2])

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

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

for i in l:
    if i == 0 or i >= 3:
        print("NO")
        exit()

print("YES")

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 cnt.count(2) == 2 and cnt.count(1) == 2:
    print("YES")
else:
    print("NO")

Solution (Python):

a = [0] * 3
b = [0] * 3
c = []
d = [0] * 3

for i in range(3):
    a[i], b[i] = map(int, input().split())
    c.append(a[i])
    c.append(b[i])
    d[i] = ''.join(str(a[i])+str(b[i]))
    if a[i] == b[i] :
        flag = False

flag = True

if 1 <= c.count(1) <= 2 and 1 <= c.count(2) <= 2 and 1 <= c.count(3) <= 2 and 1 <= c.count(4) <= 2:
     pass
else:
    flag = False

if len(list(set(d))) == 3:
    pass
else:
    flag = False

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

Solution (Python):
cnt = [0] * 4
for _ in range(3):
    a, b = tuple(map(int, input().split()))
    cnt[a-1] += 1
    cnt[b-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( ))
x=[a1,b1,a2,b2,a3,b3]
y=[x.count(i) for i in range(1,5)]
if max(y)==3 or min(y)==0:
    print("NO")

else:
    print("YES")

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

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

f1=0
f2=0
for i in range(4):
    if ans[i]==1:
        f1+=1
    if ans[i]==2:
        f2+=1
if f1==2 and f2==2:
    print('YES')
else:
    print('NO')

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


print("NO" if max(L)==3 else "YES")

Solution (Python):
from collections import defaultdict


def resolve():
    d = defaultdict(int)
    ab = list(list(map(int, input().split())) for _ in range(3))
    for a, b in ab:
        d[a] += 1
        d[b] += 1
    print("YES" if set(d.keys()) == {1, 2, 3, 4} and all(v < 3 for v in d.values()) else "NO")


if __name__ == "__main__":
    resolve()

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

Solution (Python):

def main():
    *A, = map(int, open(0).read().split())
    cnt = [0] * 5
    for i in A:
        cnt[i] += 1
    flg = all(i < 3 for i in cnt[1:])
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    *A, = map(int, open(0).read().split())
    cnt = [0] * 5
    for i in A:
        cnt[i] += 1
    flg = all(0 < i < 3 for i in cnt[1:])
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

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

Solution (Python):
E = [set() for i in range(4)]
for i in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  E[a].add(b)
  E[b].add(a)
ok = True
for i in range(4):
  if len(E[i]) >= 3:
    ok = False
    break
if ok:
  print("YES")
else:
  print("NO")

Solution (Python):
def main():

    count = dict()
    for _ in range(3):
        a, b = map(int, input().split())
        count[a] = count.get(a, 0) + 1
        count[b] = count.get(b, 0) + 1
    if sorted(count.values()) == [1, 1, 2, 2]:
        return "YES"
    return "NO"


if __name__ == '__main__':
    print(main())

Solution (Python):
a=[0]*4
for i in range(3):
	x,y=map(int,input().split())
	a[x-1]+=1
	a[y-1]+=1
c=0
for i in range(4):
	if a[i]%2!=0:
		c+=1
if c==0 or c==2:
	print("YES")
else:
	print("NO")

Solution (Python):
d={}
for k in map(int,open(0).read().split()):d[k]=d.get(k,0)+1
for v in d.values():
 if v>2:print("NO");quit()
print("YES")

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

for i in range(3):
    if ab[i][0] not in dict_ab:
        dict_ab[ab[i][0]] = 1
    else:
        dict_ab[ab[i][0]] += 1
    if ab[i][1] not in dict_ab:
        dict_ab[ab[i][1]] = 1
    else:
        dict_ab[ab[i][1]] += 1

if min(dict_ab.values()) == 1 and max(dict_ab.values()) == 2:
    print('YES')
else:
    print('NO')

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

Solution (Python):
from collections import Counter
x = Counter()
for _ in range(3):
    a,b = input().split()
    x[a] += 1
    x[b] += 1
if len(x) == 4 and max(x.values()) != 3:
    print('YES')
else:
    print('NO')

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

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

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

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

Solution (Python):
AB = [list(map(int,input().split())) for _ in [0]*3]

E = [[] for _ in [0]*4]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

i = 0
for _ in [0]*2:
    d = [-1]*4
    d[i] = 0
    q = [i]
    while q:
        i = q.pop()
        for j in E[i]:
            if d[j]!= -1 : continue
            d[j] = d[i]+1
            q.append(j)
print("YES" if max(d)==3 else "NO")

Solution (Python):
def solve(a, b):
    v = [0,0,0,0]
    for i in range(3):
        v[a[i]-1] += 1
        v[b[i]-1] += 1
    return "YES" if sorted(v) == [1,1,2,2] else "NO"

a = [0]*3
b = [0]*3
for i in range(3):
    a[i], b[i] = map(int, input().split())
print(solve(a, b))

Solution (Python):
import collections


def main():
    routeList = [list(map(int,input().split())) for _ in range(3)]
    routeList = [i for inner in routeList for i in inner]
    ansList = collections.Counter(routeList)
    
    for i in ansList:
        if ansList[i] == 3:
            print("NO")
            exit()
    print('YES')
    

    


if __name__== "__main__":
    main()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from fractions import Fraction

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 c[i] > 2:
        print('NO')
        exit()
print('YES')

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

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

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

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

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

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

if lst.count(2) == 2:
    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
print("YNEOS"[d[1]==3or d[2]==3or d[3]==3or d[4]==3::2])

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

Solution (Python):


x = []
for i in range(3):
    p, q = map(int, input().split())
    x.append(p)
    x.append(q)
ans = []
for i in range(4):
    ans.append(x.count(i + 1))
ans.sort()
if ans == [1, 1, 2, 2]:
    print('YES')
else:
    print('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):
G = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if i != j and j != k and k != l and l != i and i != k and j != l:
                    if j in G[i] and k in G[j] and l in G[k]:
                        print("YES")
                        exit()
print("NO")

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

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

g = [[] for _ in range(4)]
for a, b in AB:
	a, b = a - 1, b - 1
	g[a] += [b]
	g[b] += [a]

def dfs(v, p, visited=None):
	if None == visited:
		visited = [False] * 4
	visited[v] = True
	for n in g[v]:
		if visited[n]:
			continue
		if n == p:
			continue
		return dfs(n, v, visited)
	return all(visited)


print(["YES", "NO"][not(any([dfs(x, -1) for x in range(4)]))])

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

for i in range(3):
    a,b = map(int,input().split())
    for j in range(1,5):
        if(a == j or b == j):
            li[j-1] += 1;

if(min(li) == 0 or max(li) == 3):
    print("NO")
else:
    print("YES")

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

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

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

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


def solve():
    odd = 0
    for c in cnt:
        if c == 0:
            return False
        elif c == 1:
            odd += 1

    return odd == 2


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

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    C = [0] * 4
    for _ in range(3):
        a, b = map(int, input().split())
        C[a - 1] += 1
        C[b - 1] += 1
    print("YES" if set(C) == {1, 2} else "NO")


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    C = [0] * 4
    for _ in range(3):
        a, b = list(map(int, input().rstrip().split()))
        C[a - 1] += 1
        C[b - 1] += 1
    print("YES" if set(C) == {1, 2} else "NO")


if __name__ == "__main__":
    main()

Solution (Python):

from collections import Counter
from itertools import chain


def main():
    P = [list(map(int, input().rstrip().split())) for _ in range(3)]
    C = Counter(chain.from_iterable(P)).most_common()
    c = [i[1] for i in C]
    print("YES" if c == [2, 2, 1, 1] else "NO")


if __name__ == "__main__":
    main()

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

Solution (Python):

def main():
    a = [0 for i in range(5)]

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

    flg = 1
    odd_flg = 0
    for i in range(1, 5):
        if a[i] == 0:
            flg = 0
        if a[i] % 2 == 1:
            odd_flg += 1

    if odd_flg > 2:
        flg = 0

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





if __name__ == '__main__':
    main()

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