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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % 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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
#a = flatten(a)
a = sum(a, [])
s = 1
for i in range(4):
  s *= a.count(i+1)
if(s == 4):
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:


"""
プラン
目的: 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:
            #village_dict[position].remove(position)
            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")

Submission status: Accepted

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

#print(yes_no_count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# みんなのプロコン 2019：B - Path


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b = [0]*4
for i in range(3):
    roads = list(map(int,input().split()))
    for j in roads:
        b[j-1] += 1
        #Count the degree of each vertice

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def b_path(Road):
    # (グラフを作り、4つの街の訪れる順番を決め、移動ができるか調べてもよいが)
    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))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list_a = p + q + r
list_b = list(map(int, list_a))
#print(list_b)
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")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = input().split()
c,d = input().split()
e,f = input().split()
list =[a,b,c,d,e,f]
print("YES" if list.count("2") == 2 and list.count("3") == 2 else "NO")

Submission status: Accepted

Solution code:
map = []

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

cnt = [0, 0, 0, 0]

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

for c in cnt:
    if c == 3:
        print("NO")
        exit()

print("YES")

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,a2,a3,b1,b2,b3]
l.sort()

x = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
road = []

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

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

Submission status: Accepted

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

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

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

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

ans = [c1, c2, c3, c4]

flag = False

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

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

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_YahooMinnanoProcon_Contest-B
#  TODO https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_b

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


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