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



Sample input:
4 2
1 3
2 3


Sample output:
YES

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
"""
https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a
"""

from collections import defaultdict
def sol(a1, b1, a2, b2, a3, b3):
    S = [a1, b1, a2, b2, a3, b3]
    d = defaultdict(int)
    for s in S:
        d[s] += 1
    if len(d) == 4:
        num2 = 0
        for k, v in d.items():
            if v == 2:
                num2 += 1
        if num2 == 2:
            return 'YES'
    return 'NO'


test = False
#test = True
if test:

    print(sol(4, 2, 1, 3, 2, 3))
    print(sol(3, 2, 2,4,1,2))
    print(sol(2,1,3,2,4,3))


    # n, k = 5, 5
    # #S =list( map(int, "7 4 0 3".split()))
    # print(sol(n, k))
    # #
    # n, k = 31, 10
    # #S =list( map(int, "1000000000000".split()))
    # print(sol(n, k))
    #
    # n, k = 10, 90
    # #S =list( map(int, "1000000000000".split()))
    # print(sol(n, k))

else:
    #n, k = map(int, input().split())
    a1, b1 =list( map(int, input().split()))
    a2, b2 =list( map(int, input().split()))
    a3, b3 =list( map(int, input().split()))
    print(sol(a1, b1, a2, b2, a3, b3))

Submission status: Accepted

Solution code:
A = [[0, 0]] + [[int(i) for i in input().split()] for j in range(3)]
V = [[] for i in range(5)]

for a, b in A:
    V[a].append(b)
    V[b].append(a)

print('NO' if any(len(v) == 3 for v in V) else 'YES')

Submission status: Accepted

Solution code:
AB = [[int(i) for i in input().split()] for i in range(3)] 
A =[]
for i in range(3):
    A.append(AB[i][0])
    A.append(AB[i][1])
A.sort()
flag = 0
X = 0
tmp = 0
for i in A:
    if tmp == i:
        flag += 1
        if flag == 2:
            X = -1
    else:
        flag=0
    tmp = i

if X == -1:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
numbers = list()

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

# 1-4の個数を数える
cnts = list()
for i in range(1,5):
    cnts.append(numbers.count(i))

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import collections
# import bisect
# import math
# 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進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        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])
                    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():
    # 1文字に省略
    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()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

if __name__ == "__main__":
    # input
    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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# 葉ノードが3つ以上あると、一筆で通過できない
# -> 道が1本以下(0含む)の町が3つ以上あると、一筆で通過できない
# 前提: 2つの町の間に存在する道は複数ない

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

#print(route)

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# coding: utf-8
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)

Submission status: Accepted

Solution code:
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)])
        #print(route, road, cond)
        if cond != 1:
            success = False
            break
    if success:
        flag = True
        #print(route)
        break

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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(' ')])

#print(way)

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# 02

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
'''
Check Semi Eulerian graph
'''

l = [0, 0, 0, 0]

# count each city in paths
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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]])

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
node1234= [0, 0, 0, 0]
for i in range(3):
    ai , bi = list(map(int, input().split()))
    # print('path is ', ai, bi)
    node1234[ai-1] +=1
    node1234[bi-1] +=1
# print(node1234)
odd = 0
for ele in node1234:
    if ele/2 == 1:
        odd+=1
# print(node)
# print(odd)
if odd == 2:
    print('YES')
else:
    print('NO')