Problem:
 Score : 200 points    Problem Statement There are four towns, numbered 1,2,3 and 4 .
Also, there are three roads. The i -th road connects different towns a_i and b_i bidirectionally.
No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.      Constraints  1 \leq a_i,b_i \leq 4(1\leq i\leq 3)  a_i and b_i are different. (1\leq i\leq 3)  No two roads connect the same pair of towns.  Any town can be reached from any other town using the roads.         Input Input is given from Standard Input in the following format:  a_1  b_1  a_2  b_2  a_3  b_3       Output If we can visit all the towns by traversing each of the roads exactly once, print YES ; otherwise, print NO .        Sample Input 1 4 2
1 3
2 3      Sample Output 1 YES  We can visit all the towns in the order 1,3,2,4 .       Sample Input 2 3 2
2 4
1 2      Sample Output 2 NO       Sample Input 3 2 1
3 2
4 3      Sample Output 3 YES

Solution (Python):
a1, b1 = input().split()
a2, b2 = input().split()
a3, b3 = input().split()
town = [a1, b1, a2, b2, a3, b3]
if town.count('1')>=3 or town.count('2')>=3 or town.count('3')>=3 or town.count('4')>=3:
    print('NO')
elif town.count('1')==0 or town.count('2')==0 or town.count('3')==0 or town.count('4')==0:
    print('NO')
else:
    print('YES')

Solution (Python):
import sys
import numpy as np

def parse(inp):
    road=np.array([],dtype=int)
    for i in range(3):
        road=np.append(road,np.array([list(next(inp).split())],dtype=int))
    return road
  
def main(inp):
    road=parse(inp)
    count=[0,0,0,0]
    for i in range(len(road)):
        count[road[i]-1]+=1
        if(count[road[i]-1]==3):
            return """NO
"""
            break
            
    return """YES
"""

print(main(sys.stdin))

Solution (Python):
x = []
for i in range(3):
    x.append(list(map(int,input().split())))
one,two,three,four = 0,0,0,0
def push(a):
    global one,two,three,four
    if a == 1:
        one = one + 1
    elif a ==2:
        two += 1
    elif a == 3:
        three += 1
    else :
        four +=1
for i in x:
    push(i[0])
    push(i[1])
if one*two*three*four ==0 or one ==3 or two ==3 or three ==3 or four ==3:
    print("NO")
else :
    print("YES")

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

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

A = [a, b, c, d, e, f]

p = A.count(1)
q = A.count(2)
r = A.count(3)
s = A.count(4)

B = [p, q, r, s]
B.sort()
if B == [1, 1, 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 = list(map(int, input().split()))
	d[a] += 1
	d[b] += 1

if max(d.values()) <= 2:
	print("YES")
else:
	print("NO")

Solution (Python):
numbers = list()

for _ in range(3):
    lst = [int(s) for s in input().split()]
    numbers.append(lst[0])
    numbers.append(lst[1])


cnts = list()
for i in range(1,5):
    cnts.append(numbers.count(i))


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

Solution (Python):
first = 0
second = 0
third = 0
forth = 0
for i in range(3):
    p = input().split()
    a = p[0]
    if a == "1":first += 1
    if a == "2":second += 1
    if a == "3":third += 1
    if a == "4":forth += 1
    a = p[1]
    if a == "1":first += 1
    if a == "2":second += 1
    if a == "3":third += 1
    if a == "4":forth += 1
c = 0
if first % 2 == 1:c += 1
if second % 2 == 1:c += 1
if third % 2 == 1:c += 1
if forth % 2 == 1:c += 1
if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

Solution (Python):

import sys
import collections





"""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 main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

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

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

import numpy as np

if __name__ == "__main__":
    
    a = [0, 0, 0]
    b = [0, 0, 0]

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

    a.extend(b)
    a = np.array(a)

    flag = True
    for i in range(1, 5):
        num = np.sum(i == a)
        if num > 2:
            flag = False

        elif num == 0:
            flag = False

    if flag is True:
        print("YES")
    else:
        print("NO")

Solution (Python):
numlist = []
count = 0
for i in range(3):
    a,b = input().split()
    numlist.append(a)
    numlist.append(b)
if numlist.count("1") >= 3:
    print("NO")
elif numlist.count("2") >= 3:
    print("NO")
elif numlist.count("3") >= 3:
    print("NO")
elif numlist.count("4") >= 3:
    print("NO")
elif numlist.count("1") == 0:
    print("NO")
elif numlist.count("2") == 0:
    print("NO")
elif numlist.count("3") == 0:
    print("NO")
elif numlist.count("4") == 0:
    print("NO")
else:
    print("YES")

Solution (Python):




path_list = [list(map(int, input().split())) for _ in range(3)]
path = {}
for p in path_list:
    if not p[0] in path:
        path[p[0]] = []
    path[p[0]].append(p[1])
    if not p[1] in path:
        path[p[1]] = []
    path[p[1]].append(p[0])
count = 0
for k, v in path.items():
    if 2 > len(v):
        count += 1
print("YES" if 3 > count else "NO")

Solution (Python):


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


if r >= 3:
  print('NO')
else:
  print('YES')

Solution (Python):
cnt = [0] * 6

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

cnt_ = 0
ok = True
for i in range(1, 5):
    if cnt[i] % 2 == 1:
        cnt_ += 1
    if cnt[i] == 0:
        ok = False

print("YES" if ok and cnt_ == 2 else "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, b1, a2, b2, a3, b3]
col = [l.count(1), l.count(2), l.count(3), l.count(4)]
if col.count(1) == 2 & col.count(2) == 2:
    print('YES')
else:
    print('NO')

Solution (Python):

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

    cnt1 = 0
    cnt2 = 0
    for k,v in d.items():
        if v == 1:
            cnt1 += 1
            continue

        if v == 2:
            cnt2 += 1
            continue
        return "NO"
    if cnt1 == 2 and cnt2 == 2:
        return "YES"
    else:
        return "NO"
print(m())

Solution (Python):
from sys import stdin

def main():
    AB = stdin.read().splitlines()

    ab = ''.join(AB)
    cnt = [0] * 5
    for i in range(1, 5):
        cnt[i] = ab.count(str(i))

    ans = tuple(sorted(cnt))
    if ans == (0, 1, 1, 2, 2):
        print('YES')
    else:
        print('NO')

main()

Solution (Python):
def calc(x:list, y:int):
    if x.count(y) == 0:
        return -100
    elif x.count(y) == 1:
        return -1
    elif x.count(y) == 2:
        return 1
    elif x.count(y) > 2:
        return -100

loads = []
for _ in range(3):
    loada, loadb = input().split()
    loads.append(int(loada))
    loads.append(int(loadb))

x = 0
for i in range(1,5):
    x = x + calc(loads, i)

if x == 0:
    print('YES')
else:
    print('NO')

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

d = {}

for e in l:
  if e[0] not in d:
    d[e[0]] = 1
  else:
    d[e[0]] += 1
  if e[1] not in d:
    d[e[1]] = 1
  else:
    d[e[1]] += 1

v = sorted(list(d.values()))

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

Solution (Python):
R=[]
for _ in range(3):
    R.extend(list(map(int,input().split())))
c1=R.count(1)
c2=R.count(2)
c3=R.count(3)
c4=R.count(4)
if c1==3 or c2==3 or c3==3 or c4==3:
    print('NO')
else:
    print('YES')

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

Solution (Python):
route = [[] for _ in range(4)]
for i in range(3):
    ai, bi = list(map(int, input().split()))
    route[ai-1].append(bi)
    route[bi-1].append(ai)



cnt1 = 0
cnt0 = 0
for a in route:
    if len(a) == 1:
        cnt1 += 1
    elif len(a) == 0:
        cnt0 += 1
        

if cnt1 > 2 or cnt0 >0:
    print('NO')
else:
    print('YES')

Solution (Python):
c = [0]*4
for _ in range(3):
    for j in [int(i) for i in input().split()]:
        c[j-1] += 1
flag = True
for i in c:
    if i == 3:
        flag = False
if flag:
    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())
l = [a1,b1,a2,b2,a3,b3]

yes = 1
for i in range(1,5):
    if l.count(i)==3:
        yes *= 0

if yes == 1:
    print("YES")
else:
    print("NO")

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

sum_1=0
sum_2=0
sum_3=0
sum_4=0
for i in range(6):
  if a[i] == 1:
    sum_1 = sum_1+1
  elif a[i] == 2:
    sum_2 = sum_2+1
  elif a[i] == 3:
    sum_3 = sum_3+1
  else:
    sum_4 = sum_4+1
if sum_1 > 2 or sum_2 > 2 or sum_3 > 2 or sum_4 > 2:
  print("NO")
else:
  print("YES")

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

s = a1 + b1 + a2 + b2 + a3 + b3
i1 = s.count("1")
i2 = s.count("2")
i3 = s.count("3")
i4 = s.count("4")

ans ="YES"
if (i1>2) or (i2>2) or (i3>2) or (i4>2):
    ans = "NO"
print(ans)

Solution (Python):
line = []
for r in range(3):
    for part in input().split():
        line.append(int(part))

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

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

Solution (Python):
ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]))
    ll.append(int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("NO")
else:
    print("YES")

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

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

degree = defaultdict(int)

for r in roads:
    degree[r[0]] += 1
    degree[r[1]] += 1

odd_num = 0
for val in degree.values():
    if val % 2 != 0:
        odd_num += 1

if odd_num == 0 or odd_num == 2:
    print("YES")
else:
    print("NO")

Solution (Python):

road = [[] for _ in range(4)]
for _ in range(3):
    index_0, index_1 = map(int, input().rstrip().split())
    road[index_0-1].append(index_1)
    road[index_1-1].append(index_0)

ans = ''
for can_go in road:
    length = len(can_go)
    if not(length == 1 or length == 2):
        ans = 'NO'
        break

if ans == '':
    ans = 'YES'

print(ans)

Solution (Python):
import itertools

roads = [list(map(int, input().split(" "))) for i in range(3)]

len_route = 4
routes = list(itertools.permutations(range(1, len_route+1)))

flag = False
for route in routes:
    success = True
    for road in roads:
        cond = sum([set(road) ==  set(route[i:i+2]) for i in range(len_route - 1)])
        
        if cond != 1:
            success = False
            break
    if success:
        flag = True
        
        break

out_txt = "YES" if flag else "NO"
print(out_txt)

Solution (Python):
l=[]
y=set([1,1,2,2])
for s in range(3):
	x=list(map(int,input().split()))
	l.extend(x)
z=set([l.count(1),l.count(2),l.count(3),l.count(4)])
print("YES") if y==z else print("NO")

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

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

road_cnt = [0] * 4

for road in roads:
    a = road[0] - 1
    b = road[1] - 1
    road_cnt[a] += 1
    road_cnt[b] += 1

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

Solution (Python):
d={}
def addT(d,a,b):
    if a in d:
        d[a].add(b)
    else:
        d[a]={b}
for _ in range(3):
    a,b = input().split()
    a,b=int(a),int(b)

    addT(d,a,b)
    addT(d,b,a)

for a in d:
    if len(d[a]) == 3:
        print("NO")
        exit()
print("YES")

Solution (Python):


import sys

way = []
way.append([int(i) for i in input().split(' ')])
way.append([int(i) for i in input().split(' ')])
way.append([int(i) for i in input().split(' ')])



w_l = [0, 0, 0, 0]

for w in way:
    w_l[w[0]-1] += 1
    w_l[w[1]-1] += 1

for i in w_l:
    if i >= 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())
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):
inp = [list(map(int, input().split())) for _ in range(3)]
inputs = inp[0] + inp[1] + inp[2]
one = inputs.count(1)
two = inputs.count(2)
three = inputs.count(3)
four = inputs.count(4)
counts = one, two, three, four
if counts == (1, 1, 2, 2) or counts == (1, 2, 1, 2) or counts == (2, 1, 1, 2) or counts == (1, 2, 2, 1) or counts == (2, 2, 1, 1) or counts == (2, 1, 2, 1):
    print("YES")
else:
    print("NO")

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

Solution (Python):
lst = [9, 9, 9, 9, 9, 9]
lst[0], lst[1] = [int(i) for i in input().split()]
lst[2], lst[3] = [int(i) for i in input().split()]
lst[4], lst[5]  = [int(i) for i in input().split()]
   
flag = [False, False, False, False]
 
f = 1
for i in range(1, 4+1):
    if (lst.count(i) == 0) or (lst.count(i) == 3):
        print("NO")
        f = 0
        break
 
if f == 1:
    print("YES")

Solution (Python):


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

tapple = (a1,a2,a3,b1,b2,b3)
city_list = list(tapple)

city_num = []
isYes = True

for index in range(4):
    num = index+1
    city_num.append(city_list.count(num))
    if city_list.count(num) >= 3:
        isYes = False
if isYes:
    print('YES')
else:
    print('NO')

Solution (Python):
def main():
    c = []
    for _ in range(3):
        c.extend(list(map(int, input().split())))
    for i in range(1, 5):
        if c.count(i) == 3:
            print('NO')
            exit()
    print('YES')


main()

Solution (Python):
import sys
count=[0]*4
for i in range(3):
    a,b=map(int,input().split())
    if a==1 or b==1:
        count[0]+=1
    if a==2 or b==2:
        count[1]+=1
    if a==3 or b==3:
        count[2]+=1
    if a==4 or b==4:
        count[3]+=1
for i in range(4):
    if count[i]>2:
        print('NO')
        sys.exit(0)
else:
    print('YES')

Solution (Python):
from collections import Counter

node = []
for i in range(3):
    node.extend([int(_) - 1 for _ in input().split()])


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

Solution (Python):
ab = [list(map(int,input().split())) for _ in range(3)]
d = {}
for a,b in ab:
  if(a not in d):
    d[a] = 1
  else:
    d[a] += 1
  if(b not in d):
    d[b] = 1
  else:
    d[b] += 1
for k, v in d.items():
  if(v > 2):
    print("NO")
    break
else:
  print("YES")

Solution (Python):
ab = [list(map(int, input().split())) for _ in range(3)]
ichi = 0
ni = 0
san = 0
yon = 0
flag = 0
for l in ab:
    for n in l:
        if n == 1:
            ichi += 1
        elif n == 2:
            ni += 1
        elif n == 3:
            san += 1
        elif n == 4:
            yon += 1
if ichi == 2:
    flag += 1
if ni == 2:
    flag += 1
if san == 2:
    flag += 1
if yon == 2:
    flag += 1
if flag == 2:
    print("YES")
else:
    print("NO")

Solution (Python):
a = list()
for i in range(3):
    a.append(list(map(int, input().split())))
cnt0=cnt1=0
for i in range(2):
    for j in range(2):
        if a[0][0]==a[i+1][j]:
            cnt0+=1
        if a[0][1]==a[i+1][j]:
            cnt1+=1
if cnt0>=2 or cnt1>=2:
    print("NO")
else:
    print("YES")

Solution (Python):
from collections import Counter

ab = []
for i in range(3):
    ab.extend(list(map(int, input().split())))

ab = Counter(ab)

count = 0

for i in ab.values():
    if i == 2:
        count += 1
if count == 2:
    print('YES')
else:
    print('NO')

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

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

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

for _ in range(3):
    for c in input().split():
        x[int(c)] += 1

y = [0] * 5
for n in range(1, 5):
    y[x[n]] += 1

if y[1] == 2 and y[2] == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
import sys
input = sys.stdin.readline
ab = [tuple(map(int, input().split())) for i in range(3)]
ans1 = [(1,3), (3,1), (2,3), (3,2), (2,4), (4,2)]
ans2 = [(1,3), (3,1), (1,4), (4,1), (2,4), (4,2)]
ans3 = [(1,2), (2,1), (2,3), (3,2), (3,4), (4,3)]
ans4 = [(1,2), (2,1), (1,4), (4,1), (3,4), (4,3)]
flg1 = False
flg2 = False
flg3 = False
flg4 = False
if (ab[0] in ans1) and (ab[1] in ans1) and (ab[2] in ans1):
    flg1 = True
if (ab[0] in ans2) and (ab[1] in ans2) and (ab[2] in ans2):
    flg2 = True
if (ab[0] in ans3) and (ab[1] in ans3) and (ab[2] in ans3):
    flg3 = True
if (ab[0] in ans4) and (ab[1] in ans4) and (ab[2] in ans4):
    flg4 = True

if flg1 or flg2 or flg3 or flg4:
    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())

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

yy = [0] * 4

for x in data:
    yy[x - 1] += 1

flag = True

for y in yy:
    if y > 2:
        flag = False
        break

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

Solution (Python):
p = []
for _ in range(3):
    p += list(map(int, input().split()))
for i in range(1,4+1):
    if p.count(i) >= 3:
        print('NO')
        exit(0)
print('YES')

Solution (Python):

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

if 3 in num_list:
    print('NO')
else:
    print('YES')

Solution (Python):
road = []

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

flag = 0

for j in range(4):
  if road.count(j + 1) >= 3 or road.count(j + 1) == 0:
    flag = 1

if flag == 0:
  print("YES")
else:
  print("NO")

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

    if (count[a] > 2 or count[b] > 2):
        print("NO")
        exit(0)

print("YES")

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

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

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

Solution (Python):
x=[]
for i in range(3):
  y,z=map(int,input().split())
  x.append(y)
  x.append(z)
a=x.count(1)
b=x.count(2)
c=x.count(3)
d=x.count(4)

if a==3 or b==3 or c==3 or d==3:
  print("NO")
else:
  print("YES")

Solution (Python):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

d = collections.defaultdict(int)
for i in range(3):
    a,b = Is()
    d[a] += 1
    d[b] += 1
ans = "YES"
for e in d:
    if d[e] >= 3:
        ans = "NO"
        break
print(ans)

Solution (Python):
A = []
count = [0,0,0,0]
for i in range(3):
    a,b = (int(x) for x in input().split())
    A.append(a)
    A.append(b)

ans = 0

for i in range(6):
    a = A[i]
    count[a-1] += 1

count.sort()
if count == [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())

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

cnt1 = road.count(1)
cnt2 = road.count(2)
cnt3 = road.count(3)
cnt4 = road.count(4)

if cnt1 >= 3 or cnt2 >= 3 or cnt3 >= 3 or cnt4 >= 3:
    print("NO")
else:
    print("YES")

Solution (Python):
'''
Check Semi Eulerian graph
'''

l = [0, 0, 0, 0]


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


odd_count = 0
for x in l:
    if x % 2 == 1:
        odd_count += 1

if odd_count == 2:
    print('YES')
else:
    print('NO')

Solution (Python):
ab =[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:
            ab[j-1] += 1
ab.sort()
if ab[2] == 2:
    print('YES')
else:
    print('NO')

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

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

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

Solution (Python):
count = [0,0,0,0,0]
a1,b1=map(int,input().split())
count[a1]=count[a1]+1
count[b1]=count[b1]+1
a1,b1=map(int,input().split())
count[a1]=count[a1]+1
count[b1]=count[b1]+1
a1,b1=map(int,input().split())
count[a1]=count[a1]+1
count[b1]=count[b1]+1

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

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

print(["NO", "YES"][pl == [1,1,2,2]])

Solution (Python):
x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
x3, y3 = [int(i) for i in input().split()]

list = [x1,x2,x3,y1,y2,y3]

a=0
b=0
c=0
d=0

for i in list:
    if i == 1:
        a += 1
    if i == 2:
        b += 1
    if i == 3:
        c +=1
    if i == 4:
        d+=1

ans =0
list2 = [a,b,c,d]

for i in list2:
    if i % 2 == 1:
        ans += 1

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

Solution (Python):
node1234= [0, 0, 0, 0]
for i in range(3):
    ai , bi = list(map(int, input().split()))
    
    node1234[ai-1] +=1
    node1234[bi-1] +=1

odd = 0
for ele in node1234:
    if ele/2 == 1:
        odd+=1


if odd == 2:
    print('YES')
else:
    print('NO')

Solution (Python):












import sys
sys.setrecursionlimit(10000)

def read_int(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return int(read)

def read_int_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [int(x) for x in read.split()]

def read_float(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return float(read)

def read_float_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [float(x) for x in read.split()]

def read_str(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return str(read)

def read_str_n(read=None):
	if read == None:
		read = sys.stdin.readline().strip()
	return [str(x) for x in read.split()]	
	
def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(A):
	ans = 'YES'
	for i in range(1, 5):
		if A.count(i) > 2:
			ans = 'NO'
	return ans

def main():
	t = '''2 1
	3 2
	4 3'''.splitlines()
	
	a1, b1 = read_int_n()
	a2, b2 = read_int_n()
	a3, b3 = read_int_n()
	A = [a1, b1, a2, b2, a3, b3]
	
	print(slv(A))

if __name__ == '__main__':
	main()

Solution (Python):
"""

問題文

4 つの街があり、順に 1,2,3,4 と番号が付いています。 道が 3 本あり、i 本目の道は異なる街 ai,bi を双方向に結んでいます。 同じ街の対の間を結ぶ道が複数あることはありません。街同士を行き来する手段は、道以外にはありません。 どの 2 つの街の間も、道を何本か通ることで行き来することができます。

すべての道をちょうど 1 回ずつ通ることですべての街を訪れることが可能かどうか判定してください。
制約

    1≤ai,bi≤4(1≤i≤3)
    ai と bi は異なる (1≤i≤3)
    同じ街の対の間を結ぶ道は複数存在しない
    どの 2 つの街の間も、道を何本か通ることで行き来することができる
"""

def func(a_list , b_list) : 
    dic = {}
    for a in a_list : 
        if not a in dic : 
            dic[a] = 1
        else : 
            dic[a] += 1
    
    for b in b_list : 
        if not b in dic : 
            dic[b] = 1
        else : 
            dic[b] += 1

    cnt = 0
    for key in dic : 
        if dic[key] == 1: cnt += 1
    if cnt == 3: 
        return "NO"
    else : 
        return "YES"


if not func([4 , 1, 2], [2 , 3, 3]) == "YES" : 
    raise Exception("test 1 fail")

if not func([3 , 2, 1], [2 , 4, 2]) == "NO" : 
    raise Exception("test 2 fail")

if not func([2 , 3, 4], [1 , 2, 3]) == "YES" : 
    raise Exception("test 3 fail")

a_list = []
b_list = []
for i in range(3) : 
    s = input().split(" ")
    a_list.append(int(s[0]))
    b_list.append(int(s[1]))
print(func(a_list , b_list))

Solution (Python):


N = [0]*4

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

N.sort()


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

Solution (Python):
a=input()
a_1=int(a.split()[0])
b_1=int(a.split()[1])
a=input()
a_2=int(a.split()[0])
b_2=int(a.split()[1])
a=input()
a_3=int(a.split()[0])
b_3=int(a.split()[1])

num=[]
num.append(a_1)
num.append(a_2)
num.append(a_3)
num.append(b_1)
num.append(b_2)
num.append(b_3)

count_a=0
count_b=0
count_c=0
count_d=0

for i in(num):
  if(i==1): count_a+=1
  elif(i==2): count_b+=1
  elif(i==3): count_c+=1
  elif(i==4): count_d+=1

if(count_a>2 or count_b>2 or count_c>2 or count_d>2):
  print('NO')
else:
  print('YES')

Solution (Python):
path = []
for _ in [0]*3:
    path.extend(input().split())

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

Solution (Python):
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(inputArr1(3))


def func():
    if (n[0][0] in n[1] and n[0][0] in n[2]) or (n[0][1] in n[1] and n[0][1] in n[2]):
        return "NO"
    return "YES"
    
print(func())

Solution (Python):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
lis=[a,b,c,d,e,f]

a=lis.count(1)
b=lis.count(2)
c=lis.count(3)
d=lis.count(4)
kekka=[a,b,c,d]
a=kekka.count(1)
b=kekka.count(2)

if a!=2 and b!=2 :
    print("NO")
else:
    print("YES")

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

C=[0,0,0,0,0]
for i in range(len(A)) :
    C[A[i][0]]+=1
    C[A[i][1]]+=1
 

co=0
for i in range(1,5):
    if C[i]==1 or C[i]==3 :
        co+=1
 
if co==0 or co==2 :
    print("YES")
else :
    print("NO")