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):

import sys


import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def d(self, p):
        re = 0
        for i in range(len(p) - 1):
            re += ((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2) ** 0.5
        return re


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = [0] * 4
    for _ in [0] * 3:
        a = ip.IL()
        s[a[0] - 1] += 1
        s[a[1] - 1] += 1

    o = sum(x for x in s if x % 2 == 1)
    if o == 0 or o == 2:
        print("YES")
    else:
        print("NO")


main()

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

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

for i in range(4):
    visited = [ False for _ in range(4) ]
    cur = i
    visited[cur] = True
    for j in range(3):
        for v in tree[cur]:
            if not visited[v]:
                next_v = v
                break
        visited[next_v] = True
        cur = next_v

    if all(visited):
        print ("YES")
        exit()

print("NO")

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

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

for i in range(4):
    visited = [ False for _ in range(4) ]
    cur = i
    visited[cur] = True
    for j in range(3):
        for v in tree[cur]:
            if not visited[v]:
                next_v = v
                break
        visited[next_v] = True
        cur = next_v

print ( "YES" if all(visited) else "NO" )

Solution (Python):

import sys
sum = [0]*4

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

for i in range(0,4):
    if sum[i] >= 3:
        print("NO")
        sys.exit()

print("YES")

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


if 0 in bridge or 3 in bridge:
    print('NO')
else:
    print('YES')

Solution (Python):
path = []
ans = "YES"
for i in range(3):
    path.append([int(num) for num in input().split()])
for i in range(4):
    if i+1 in path[0] and i+1 in path[1] and i+1 in path[2]:
        ans = "NO"
        
print(ans)

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

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

if len(list(set(l))) != 4:
    print("NO")
else:
    count_list = sorted([str(l.count(str(i))) for i in range(1, 5)])
    if "".join(count_list) == "1122":
        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())

flag = 0

for i in range(1,5):
    if [a1,a2,a3,b1,b2,b3].count(i) == 3:
        flag = 1
        break
    else:
        flag = 0
if flag == 1:
    print("NO")
else:
    print("YES")

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

Solution (Python):
A = [[0 for x in range(1)]for y in range(3)]
one_count = 0
two_count = 0
three_count = 0
four_count = 0
for i in range(3):
     A[i] = [int(x) for x in input().split()]

     if(A[i][0]==1 or A[i][1]==1):
         one_count += 1
     if(A[i][0]==2 or A[i][1]==2):
         two_count += 1
     if(A[i][0]==3 or A[i][1]==3):
         three_count += 1
     if(A[i][0]==4 or A[i][1]==4):
         four_count += 1

if(one_count >= 3 or two_count >= 3 or three_count >= 3 or four_count >= 3):
    print("NO")
else:
    print("YES")

Solution (Python):
import collections

ab=[[i for i in input().split()] for i in range(3)]
aball=ab[0]+ab[1]+ab[2]
cn=collections.Counter(aball)
cnv=list(cn.values())
cnv.sort(reverse=True)
print('YES'if cnv[0]==2 and cnv[1]==2 else 'NO')

Solution (Python):
L = list(map(int,input().split()))
M = list(map(int,input().split()))
N = list(map(int,input().split()))
O = [L,M,N]
P = L.count(1)+M.count(1)+N.count(1)
Q = L.count(2)+M.count(2)+N.count(2)
R = L.count(3)+M.count(3)+N.count(3)
S = L.count(4)+M.count(4)+N.count(4)
T = [P,Q,R,S]
T.sort()
if T[0] == T[1] == 1:
  if T[2] == T[3] == 2:
    if [T[1],T[2]] or [T[2],T[1]] in O:
      print('YES')
    else:
      print('NO')
  else:
    print('NO')
else:
  print('NO')

Solution (Python):
'''input
4 2
1 3
2 3
'''
import time
import math
l = [[] for i in range(5)]
flag = 0
for i in range(3):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if not flag else "NO")

Solution (Python):
d={}
for _ in '123':
  for k in map(int,input().split()):d[k]=d.get(k,0)+1
for v in d.values():
  if v>2:print('NO');exit()
print('YES')

Solution (Python):
c1,c2,c3,c4=0,0,0,0
for i in range(3):
  a,b=map(int,input().split(" "))
  if a==1 or b==1:
    c1+=1
  if a==2 or b==2:
    c2+=1
  if a==3 or b==3:
    c3+=1
  if a==4 or b==4:
    c4+=1  
if c1<=2 and c2<=2 and c3<=2 and c4<=2:
  print("YES")
else:
  print("NO")

Solution (Python):
from collections import deque
N, M = 4,4
inf = float("inf")
dp = []
dc=[0,0,0,0]
for _ in range(3):
    a, b = map(int, input().split())
    dc[a-1]+=1
    dc[b-1]+=1
    if a > b:
        a,b=b,a
    dp.append((a-1,b-1))
dp.sort()
for i in range(2):
    if dp[i] == dp[i+1] or max(dc)==3:
        print("NO")
        exit()
print("YES")

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



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


def main():
    g = defaultdict(list)
    for _ in range(3):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    for p in permutations([1, 2, 3, 4]):
        ok = True
        for i in range(3):
            a, b = p[i], p[i + 1]
            if b not in g[a]:
                ok = False
        if ok:
            print(YES)
            return
    print(NO)


if __name__ == '__main__':
    main()

Solution (Python):
data = []

for i in range(3):
    data.append(list(map(int, input().split())))
data = sum(data, [])

result = [0]*4
for i in data:
    result[i-1]+=1
if 3 in result:
    print("NO")
else:
    print("YES")

Solution (Python):
import collections

a = list(map(int,input().split()))
b = (map(int,input().split()))
c = (map(int,input().split()))
a.extend(b)
a.extend(c)
c = collections.Counter(a)
if c.most_common()[0][1]==2:
    print("YES")
else:
    print("NO")

Solution (Python):
ds = {}
for i in range(3):
    s = input()
    ks = [int(i) for i in s.split(' ')]
    for k in ks:
        if k in ds:
            ds[k] += 1
        else:
            ds[k] = 1


for k in ds:
    if ds[k] == 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

ans = "YES"
for c in C:
    if c==3:
        ans = "NO"
        break

print(ans)

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

Solution (Python):
R = []

C  = 0
C1 = 0
C2 = 0

for j in range(3):
	R.append(list(map(int, input().split())))

for i in range(1,5):
	for j in range(3):
		if (i == R[j][0]) or (i == R[j][1]):
			C += 1
	if C == 1:
		C1 += 1
	if C == 2:
		C2 += 1
	C = 0

if C1 == 2 and C2 == 2:
	print("YES")
else:
	print("NO")

Solution (Python):
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
f = 1
for i in range(1,5):
  if all(i in j for j in (x,y,z)): f = 0
if f: print("YES")
else: print("NO")

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

a = sum(a, [])
s = 1
for i in range(4):
  s *= a.count(i+1)
if(s == 4):
  print("YES")
else:
  print("NO")

Solution (Python):
s = input()
s += input()
s += input()

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

Solution (Python):


"""
プラン
目的: 1の街から開始して、全ての街を通れればよしとする
1. 街を作る。街はそれぞれ繋がっている街のデータを持つ
2. 初期値を1の街とし、今まで通った街のデータを記録する
3. もし街のデータが四つ揃えば、完了
"""

village_dict = {}
for i in range(4):
    village_dict[i + 1] = []

for i in range(3):
    line = [int(i) for i in input().split()]
    village_dict[line[0]].append(line[1])
    village_dict[line[1]].append(line[0])




def move(village_dict):
    position = 1
    visit_log = []
    visit_log.append(position)
    for i in range(3):
        if len(village_dict[position]) == 1:
            position = village_dict[position][0]
            visit_log.append(position)
        elif len(village_dict[position]) == 2:
            
            for pos in village_dict[position]:
                if pos in visit_log:
                    village_dict[position].remove(pos)
            position = village_dict[position][0]
            visit_log.append(position)
    return len(visit_log)

if move(village_dict) == 4:
    print("YES")
else:
    print("NO")

Solution (Python):
a_b=[]
a=[]
b=[]
judge=[]
judge_count=0
yes_no_count=0
for i in range(3):
    a_blank,b_blank=map(int,input().split())
    a.append(a_blank)
    b.append(b_blank)

a_b.extend(a)
a_b.extend(b)
for i in range(1,4+1):
    for j in a_b:
        if i==j:
            judge_count+=1
    judge.append(judge_count)
    judge_count=0

for i in judge:
    yes_no_count+=1
    if i==0 or i>=3:
        print("NO")
        break
    elif len(judge)==yes_no_count:
        print("YES")

Solution (Python):
Ncity = 4
Nroot = [0]*Ncity
for n in range(3):
	a, b = [int(s) for s in input().split()]
	Nroot[a-1] += 1
	Nroot[b-1] += 1

print('NO' if max(Nroot)>2 else 'YES')

Solution (Python):
x = []
y = []
while True:
  try:
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
  except:
    break

for i in range(3):
  a=x[i]
  b=y[i]
  
  if len(set([x[(i+1)%3], y[(i+1)%3], y[(i+2)%3], x[(i+2)%3]]))!=4:
    continue

  if not (set([x[(i+1)%3], y[(i+1)%3]]) - set([a,b])):
    continue
  elif not (set([x[(i+2)%3], y[(i+2)%3]]) - set([a,b])):
    continue
  else:
    print('YES')
    exit()

print('NO')

Solution (Python):
from collections import Counter
print("YES" if max(Counter("".join(input().replace(" ", "") for _ in range(3))).values()) <= 2 else "NO")

Solution (Python):
dic = {i+1:0 for i in range(4)}

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

flag = True
for v in dic.values():
    if v == 3: flag = False

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

Solution (Python):
l = []
l.extend([i for i in map(int,input().split())])
l.extend([i for i in map(int,input().split())])
l.extend([i for i in map(int,input().split())])
d = {1:0,2:0,3:0,4:0}
for i in l:
    d[i] += 1
flag = True
for u in d:
    if d[u] >= 3 or d[u] <= 0:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

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

city_list = [a1, a2, a3, b1, b2, b3]
count_list = []
count_list.append(city_list.count(1))
count_list.append(city_list.count(2))
count_list.append(city_list.count(3))
count_list.append(city_list.count(4))
if count_list.count(3)>=1:
    print("NO")
else:
    print("YES")

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

cnt = Counter(chain.from_iterable(map(int, input().split()) for _ in [0] * 3))
print('YES' if all(1 <= c <= 2 for c in cnt.values()) else 'NO')

Solution (Python):
from collections import Counter
print("YES" if sorted(Counter("".join(input().replace(" ", "") for _ in range(3))).values()) == [1, 1, 2, 2] else "NO")

Solution (Python):
import sys
input = sys.stdin.readline

nums = [0 for _ in range(4)]

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

nums.sort()

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

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

A = [input().split() for _ in range(3)]
c = Counter(Counter(chain(*A)).values())
print("YES" if c[1] == 2 else "NO")

Solution (Python):






def main():
    p = {}
    for _ in range(3):
        A, B = [int(i) for i in raw_input().strip().split(' ')]
        if A in p:
            p[A] += 1
        else:
            p[A] = 1
        if B in p:
            p[B] += 1
        else:
            p[B] = 1
    l = p.values()
    if 3 in l:
        print 'NO'
    else:
        print 'YES'


if __name__ == '__main__':
    main()

Solution (Python):
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
ans='YES'
for j in range(1,5):
  cnt=0
  for i in range(6):
    if c[i]==j:
      cnt+=1
  if cnt>2:
    ans='NO'
    break

print(ans)

Solution (Python):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
if [a1, b1, a2, b2, a3, b3].count(1) == 3 or [a1, b1, a2, b2, a3, b3].count(2) == 3 or [a1, b1, a2, b2, a3, b3].count(3) == 3 or [a1, b1, a2, b2, a3, b3].count(4) == 3:
    print("NO")
else:
    print("YES")

Solution (Python):
def path():
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    l3=list(map(int,input().split()))
    for i in l1:
        if i in l2:
            if i in l3:
                return("NO")
    return("YES")
print(path())

Solution (Python):

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

l = [0] * 4
for x in ab:
    l[x - 1] += 1

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

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

for i in range(0, 3):
  a, b = map(int, input().split(" "))
  d[a - 1] += 1
  d[b - 1] += 1
  
c = 0
for i in range(0, 4):
  if d[i] % 2 == 1:
    c += 1

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

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

for i in range(4):
    if rp.count(i+1) == 1:
        numSolo = numSolo + 1

print(['NO','YES'][numSolo == 2])

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

for i in range(4):
    if rp.count(i+1) == 1:
        numSolo = numSolo + 1

print(['NO','YES'][numSolo == 2])

Solution (Python):

from collections import *
import sys


def is_all_tarverse(start, mem, town_mem):

    if len(town_mem) == len(paths):
        return True

    for nxt in paths[start]:
        edge = frozenset((start, nxt))
        if edge in mem: continue
        if is_all_tarverse(nxt, mem | {edge}, town_mem | {nxt}):
            return True

    return False


paths = defaultdict(set)

for _ in range(3):
    a = input()
    st, dt = [int(x) for x in a.split()]
    paths[st].add(dt)
    paths[dt].add(st)


for start in paths:
    if is_all_tarverse(start, set(), {start}):
        print('YES')
        sys.exit()

print('NO')

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

Solution (Python):



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

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

    ab_count = Counter(ab)

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

    print('YES')


if __name__ == '__main__':
    main()

Solution (Python):
import collections
l=[]
for i in range(3):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)
c=collections.Counter(l)
n=[]
for i in range(1,5):
    n.append(c[i])
n.sort()
if n==[1,1,2,2]:
    print('YES')
else:
    print('NO')

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

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):
abList = []
for i in range(3):
    ab = [int(i) for i in input().split()]
    abList.append(ab)

visited = {}
for ab in abList:
    for i in ab:
        if i in visited:
            visited[i] += 1
        else:
            visited[i] = 1

ans = "YES"
for city in visited:
    if visited[city] == 0 or visited[city] > 2:
        ans = "NO"


print(ans)

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

n={1:0,2:0,3:0,4:0}
for x in m:
    n[x]+=1
    
t=0
for i in range(4):
    i+=1
    if n[i] != 1 and n[i] != 2:
        t=1
        
if t == 0:
    print("YES")
else:
    print("NO")

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

Solution (Python):
ab = []
for i in range(3):
    ab.extend(list(map(int,input().split())))
    
    
for i in range(1,5):
    if ab.count(i) >= 3:
        print("NO")
        exit()
        
print("YES")

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

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

numOdds = 0
for i in b:
    if i%2!=0:
        numOdds+=1

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

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

Solution (Python):
print('YES'*(sum(map(int,open(0).read().split()))%2)or'NO')

Solution (Python):
print('NYOE S'[sum(map(int,open(0).read().split()))%2::2])

Solution (Python):
A=list(map(int,input().split()))+list(map(int,input().split()))+list(map(int,input().split()))
print(["YES","NO"][A.count(1)==3 or A.count(2)==3 or A.count(3)==3 or A.count(4)==3])

Solution (Python):

def find(x):
    while table[x] >= 0:
        x = table[x]
    return x

def union(x, y):
    s1 = find(x)
    s2 = find(x)
    if s1 != s2:
        if table[s1] != table[s2]:
            if table[s1] < table[s2]:
                table[s2] = s1
            else:
                table[s1] = s2
        else:
            table[s1] -= 1
            table[s2] = s1
    return
    


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

ans = [0 for i in range(4)]

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

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

Solution (Python):
print('YNEOS'[sum(map(int,open(0).read().split()))!=15::2])

Solution (Python):
print('YNEOS'[eval('+'.join(open(0).read().split()))!=15::2])

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

Solution (Python):
r1 = []
r2 = []
r3 = []
r4 = []
for i in range(3):
    a,b = map(int,input().split())
    if a == 1:
        r1.append(b)
    elif a == 2:
        r2.append(b)
    elif a == 3:
        r3.append(b)
    else:
        r4.append(b)

    if b == 1:
        r1.append(a)
    elif b == 2:
        r2.append(a)
    elif b == 3:
        r3.append(a)
    else:
        r4.append(a)
if len(r1) <= 2 and len(r2) <= 2 and len(r3) <= 2 and len(r4) <= 2:
    print("YES")
else:
    print("NO")

Solution (Python):
def b_path(Road):
    
    appear_num = [0] * 4
    for a, b in Road:
        appear_num[a - 1] += 1
        appear_num[b - 1] += 1
    ans = 'NO' if [1 for v in appear_num if v >= 3] else 'YES'
    return ans

Road = [[int(i) for i in input().split()] for j in range(3)]
print(b_path(Road))

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] == l[i+2]:
        x = False

print("YES" if x == True else "NO")

Solution (Python):
print('YNEOS'[sum(map(int,open(0).read().split()))!=15::2])

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

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

print('YES' if all(k > 0 for k in t.values()) and sum(k%2 for k in t.values()) in {2, 0} else 'NO')

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

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

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

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

print('NO' if list(filter(lambda x: x == 3, deg)) else 'YES')

Solution (Python):
def main():
    s = [0]*5
    for _ in range(3):
        a,b=map(int, raw_input().split(" "))   
        s[a]+=1
        s[b]+=1
    for a in s:
        if a==3:
            print("NO")
            return
    print("YES")
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
ck = [0]*10
for i in range(4):
    ck[check[i]] += 1

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

Solution (Python):
print('YES'if __import__('collections').Counter(map(int,open(0).read().split())).most_common()[0][1]<3 else'NO')

Solution (Python):
ROADS = 3

range_city = list(range(1, 4+1))
appearance = []
for i in range(ROADS):
    a, b = map(int, input().split())
    appearance.append(a)
    appearance.append(b)

count = [appearance.count(city) for city in range_city]
if max(count) <= 2:
    print('YES')
else:
    print('NO')

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

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

cs = [0] * 4

for a, b in AB:
    cs[a - 1] += 1
    cs[b - 1] += 1

cs.sort()

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

Solution (Python):
s = ''
for i in range(3):
    a, b = input().split()
    s += a + b


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

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):

deg = [0]*4

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

print('YES' if any(d%2==0 for d in deg) else 'NO')

Solution (Python):
ROADS = 3

range_city = list(range(1, 4+1))
appearance = []
for i in range(ROADS):
    a, b = map(int, input().split())
    appearance.append(a)
    appearance.append(b)

count = [appearance.count(city) for city in range_city]
if ROADS not in count:
    print('YES')
else:
    print('NO')

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

for i in range(1,5):
    for j in range(1,5):
        for k in range(1,5):
            if i==j or i==k or j==k:
                continue
            tmp = set([1,2,3,4])
            tmp.remove(i)
            tmp.remove(j)
            tmp.remove(k)
            l = list(tmp)[0]
            if [i,j] in ab or [j,i] in ab:
                if [j,k] in ab or [k,j] in ab:
                    if [k,l] in ab or [l,k] in ab:
                        print('YES')
                        exit()
print('NO')

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

cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
    if not i+1 in [a1, a2, a3, b1, b2, b3]:
        print('NO')
        exit()

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

c = 0
for l in range(4):
    cnt = lis.count(l+1)
    if cnt > 1:
        c += 1

if c < 2:
    print('NO')
    exit()

print('YES')

Solution (Python):
import sys

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

for start in range(1, 5):
    visited_paths = [start]
    cnt = 0
    while len(visited_paths) < 4:
        for path in paths[:]:
            if path[0] == visited_paths[-1]:
                visited_paths.append(path[1])
                paths.remove(path)
                paths.remove([path[1], path[0]])
                break
        cnt += 1
        if cnt > 10:
            break
    if cnt > 10:
        continue
    print('YES')
    sys.exit()
print('NO')
sys.exit()

Solution (Python):
p = input().split()
q = input().split()
r = input().split()

list_a = p + q + r
list_b = list(map(int, list_a))

list_b.sort()


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

Solution (Python):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
s=a,b,c,d,e,f
if s.count(1)==3:
    print('NO')
elif s.count(2)==3:
    print('NO')
elif s.count(3)==3:
    print('NO')
elif s.count(4)==3:
    print('NO')
else :
    print('YES')

Solution (Python):
a = [input().split() for i in range(3)]
b = []
for i in range(3):
  for j in range(2):
    b.append(a[i][j])
c = [int(b[i]) for i in range(6)]
for i in range(1, 5):
  if c.count(i) == 3:
    print('NO')
    exit()
print('YES')