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:
route_list = []
for i in range(3):
    route_list.append(list(map(int, input().strip().split())))

city_routes = [0, 0, 0, 0]
for route in route_list:
    city_routes[route[0] - 1] += 1
    city_routes[route[1] - 1] += 1

ans = "YES"
if(max(city_routes) > 2):
    ans = "NO"
if(min(city_routes) < 1):
    ans = "NO"
print(ans)

Submission status: Accepted

Solution code:
l=[0 for i in range(5)]
for i in range(3):
    a, b = map(int, input().split())
    l[a] += 1
    l[b] += 1
ans=True
for i in range(1, 5):
    if l[i] <= 0:
        ans = False
    if l[i] >= 3:
        ans = False
print('YES' if ans else 'NO')

Submission status: Accepted

Solution code:
deg = {1 : 0, 2: 0, 3: 0, 4: 0}

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

cnt = 0
for i in range(1, 5):
    if deg[i] % 2 == 1:
        cnt += 1

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

Submission status: Accepted

Solution code:
a = []
l = []
for i in range(3):
	x,y = map(int,input().split( ))
	a.append(x)
	a.append(y)
a.sort()
for i in range(4):
	l.append(a.count(i+1))
ans ="YES"
if l.count(3) > 0:
	ans = "NO"
print(ans)

Submission status: Accepted

Solution code:
def main():
    nxt = [0] * 5
    for i in range(3):
        a, b = map(int, input().split())
        nxt[a] += 1
        nxt[b] += 1
    edge = 0
    for i in range(1, 5):
        if nxt[i] % 2 == 1:
            edge += 1
    if edge == 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if all([A[i] < 3 for i in range(4)]):
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
count = [0, 0, 0, 0]
for i in range(3):
    a, b = map(int, input().split())
    count[a-1] += 1
    count[b-1] += 1
res = True
for a in count:
    if a>2:
        res = False
if res:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from itertools import permutations


def is_ok(a0, a1, a2):
    v = [False] * 4
    v[a0[0]] = True
    v[a0[1]] = True
    if a0[1] != a1[0]:
        return False
    v[a1[1]] = True
    if a1[1] != a2[0]:
        return False
    v[a2[1]] = True
    return all(v)


def main():
    p = []
    for _ in range(3):
        a, b = map(int, raw_input().split())
        p.append([a - 1, b - 1])
    for a0, a1, a2 in permutations(p):
        for i in range(8):
            if i & 1:
                b0 = a0
            else:
                b0 = a0[::-1]
            if i & 2:
                b1 = a1
            else:
                b1 = a1[::-1]
            if i & 4:
                b2 = a2
            else:
                b2 = a2[::-1]
            if is_ok(b0, b1, b2):
                print 'YES'
                return
    print 'NO'


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a1, b1 = LI()
    a2, b2 = LI()
    a3, b3 = LI()

    l = [0, 0, 0, 0]
    l[a1-1] += 1
    l[a2-1] += 1
    l[a3-1] += 1
    l[b1-1] += 1
    l[b2-1] += 1
    l[b3-1] += 1

    return max(l) <= 2


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

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  road = [0 for _ in range(4)]
  for i in range(3):
    c1, c2 = map(int, input().split())
    road[c1-1] += 1
    road[c2-1] += 1

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


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
d = [set([]) for i in range(4)]
for i in range(3):
    a, b = list(map(int, input().split()))
    d[a-1].add(b-1)
    d[b-1].add(a-1)

flag = False
def BFS(now, visited, depth):
    global flag
    if depth == 3:
        if len(visited) == 4:
            flag = True
        return

    for i in d[now]:
        if i in visited:
            continue
        next_visited = visited.copy()
        next_visited.add(i)
        BFS(i, next_visited, depth+1)

for i in range(4):
    BFS(i, set([i]), 0)

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

Submission status: Accepted

Solution code:
L=[]
for i in range(3):
    a,b=input().split()
    L.append(int(a))
    L.append(int(b))
    
def solve(L):
    for i in range(1,5):
        if L.count(i)==3:
            return 'NO'
    return 'YES'

print(solve(L))

Submission status: Accepted

Solution code:
n=[]
for i in range(3):
    m=list(map(int,input().split()))
    n.append(m[0])
    n.append(m[1])
if n.count(1)<3 and n.count(2)<3 and n.count(3)<3 and n.count(4)<3 :
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
# 200 points
import math

# -*- coding: utf-8 -*-
dic = [0, 0, 0, 0]
# スペース区切りの整数の入力
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

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

x1 = len([i for i, x in enumerate(dic) if x == 1])
x2 = len([i for i, x in enumerate(dic) if x == 2])

if x1 == 2 and x2 == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:

x = [0]*6

for i in range(0,6,2):
    x[i-1], x[i] = map( int, input().split() )


town = [1,2,3,4]

yes = True
for ti in town:
    yes &= x.count(ti) == 2 or x.count(ti) == 1


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

Submission status: Accepted

Solution code:
F = [None] * 4

for i in range(4):
    F[i] = []

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

L = [len(f) for f in F]

L.sort()

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

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:
# import collections
l = [0]*4

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

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

Submission status: Accepted

Solution code:
numList=[0]*5

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

numList.sort()

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

Submission status: Accepted

Solution code:
#!venv/bin/python

import math

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

over = False
for p in points:
    if p >= 3:
        over = True
if over:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
IN=lambda:list(map(int,input().split()))
a=IN()
a+=IN()
a+=IN()
c=Counter(a)

if max(c.values())>=3:
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
from collections import Counter

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

for i, j in count.items():
    if j > 2:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
#coding:utf-8
s = set(map(int,input().split()))
for i in range(2):
    s = s & set(map(int,input().split())) 
if (len(s)):
    print ("NO")
else:
    print ("YES")

Submission status: Accepted

Solution code:
a = []
b = []
count1=0
count2=0
count3=0
count4=0
for i in range(3):
    tempa,tempb = map(int, input().split())
    if tempa == 1:
        count1 += 1
    if tempb == 1:
        count1 += 1
    if tempa == 2:
        count2 += 1
    if tempb == 2:
        count2 += 1
    if tempa == 3:
        count3 += 1
    if tempb == 3:
        count3 += 1
    if tempa == 4:
        count4 += 1
    if tempb == 4:
        count4 += 1
if (count1>2) or(count2>2) or(count3>2) or (count4>2):
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
a=[]
b=[]
for i in [0]*3:
	a_,b_ = map(int,input().split(' '))
	a.append(a_)
	b.append(b_)

f = True


for i in range(1,5):
	if not i in a and not i in b:
		f = False

for i in range(1,5):
	t = False
	for A,B in zip(a,b):
		if not(i == A or i == B):
			t = True 
	if not t:
		f = False

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

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
  a,b=map(int,input().split())
  l.append(a)
  l.append(b)
w=0
x=0
y=0
z=0
for i in range(6):
  if l[i]==1:
    w+=1
  elif l[i]==2:
    x+=1
  elif l[i]==3:
    y+=1
  else:
    z+=1
if x==0 or y==0 or z==0 or w==0:
  print('NO')
elif w>2 or x>2 or y>2 or z>2:
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
import  numpy as np
ab = []
for i in range(3):
    ab.append(list(map(int,input().split())))
ans = "YES"
ab = np.array(ab)
for i in range(1,5):
    if (ab==i).sum()>2:
        ans = "NO"
        break
print(ans)

Submission status: Accepted

Solution code:
A=[]
for i in range(3):
    a,b=map(int,input().split())
    A.append(a)
    A.append(b)
c=0
d=0
e=0
f=0
for j in A:
    if j==1:
        c+=1
    elif j==2:
        d+=1
    elif j==3:
        e+=1
    else:
        f+=1
if c>=3 or d>=3 or e>=3 or f>=3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
lis = [0 for i in range(4)]
for i in range(3):
    a,b = map(int,input().split())
    lis[a-1] += 1
    lis[b-1] += 1
if lis.count(2) == 2:
    print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
path = {1: 0, 2: 0, 3: 0, 4: 0}
odd = 0
for _ in range(3):
    ai, bi = map(int, input().split())
    path[ai] += 1
    path[bi] += 1

for count in path.values():
    if count % 2 == 1:
        odd += 1

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

Submission status: Accepted

Solution code:
city=[0,0,0,0]

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

flag=0
for i in range(4):
    if city[i]==0:
        print("NO")
        flag=1
    elif city[i]>=3:
        print("NO")
        flag=1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 20:33:11 2019

@author: Yamazaki Kenichi
"""

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

a=[]
for j in range(3):
    for i in range(2):
        a.append(A[j][i])
        
ans = 'YES'
for i in range(1,5):
    if a.count(i) >=3 :
        ans ='NO'
        
print(ans)

Submission status: Accepted

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

counter = [0] * 4
for i in ab:
    for j in i:
        counter[j-1] += 1
counter.sort()

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

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
def inpl(): return list(map(int, input().split()))

#### START
a_1, b_1 = map(int,input().split())
a_2, b_2 = map(int,input().split())
a_3, b_3 = map(int,input().split())

ans = [a_1, b_1, a_2, b_2, a_3, b_3]
c = collections.Counter(ans)
if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2 and c.most_common()[2][1] == 1 and c.most_common()[3][1] == 1:
  print("YES")
else:
  print("NO")
# if N-K>0:
#   print("YES")
# else:
#   print("NO")
# N, K = map(int,input().split())

# ans = math.ceil(N/2)
# if ans>=K:
#   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())
    ab[a-1]+=1
    ab[b-1]+=1
ab.sort()
if ab==[1,1,2,2]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
from itertools import permutations
def inpl(): return list(map(int, input().split()))

D = defaultdict(int)
for _ in range(3):
    x, y = inpl()
    D[(x-1, y-1)] = 1
    D[(y-1, x-1)] = 1

for X in permutations(range(4)):
    #print(X)
    for i in range(3):
        if D[(X[i], X[i+1])] == 0:
            break
    else:
        print("YES")
        break
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
roads = [a1, b1, a2, b2, a3, b3]
roads.sort()
check = [1, 2, 2, 3, 3, 4]
flag = 0
for i in range(6):
    if roads[i] != check[i]:
        flag = 1
        break
if flag == 0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#a,b,k = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

a =[]
for i in range(3):
    b = [int(i) for i in input().split()]
    b.sort()
    a.append(b)
if [1,2] in a and [3,4] in a:j(1)
if [1,3] in a and [2,4] in a:j(1)
if [1,4] in a and [2,3] in a:j(1)
j(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
one = 2
two = 2
for i in range(1, 5):
    if c.count(i) == 1:
        one -= 1
    elif c.count(i) == 2:
        two -= 1
if one == 0 and two == 0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]

# if __name__ == '__main__':


rt1 = list(map(int, input().split()))
rt2 = list(map(int, input().split()))
rt3 = list(map(int, input().split()))

for r in rt1:
	if (r in rt2) and (r in rt3):
		print("NO")
		sys.exit()
print("YES")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 21:05:16 2019

@author: doppe
"""
count = [0, 0, 0, 0]

for i in range (0, 3):
    a, b = map(int, input().split())
    count[a - 1] += 1
    count[b - 1] += 1
flag = 0
for i in count:
    if(i >= 3):
        flag = 1
        break
if (flag == 1):
    print('NO')
else:
    print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[0]*5
x,y=map(int,input().split())
a[x]+=1
a[y]+=1
x1,y1=map(int,input().split())
a[x1]+=1
a[y1]+=1
x2,y2=map(int,input().split())
a[x2]+=1
a[y2]+=1
b=[]
for i in range(1,5):
  b.append(a[i])
b.sort()
if(b[0]==1 and b[1]==1 and b[2]==2 and b[3]==2):
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

a = [a1,a2,a3]
b = [b1,b2,b3]

from collections import Counter

c = Counter(a+b)

x = 0
y = 0
for k in c.keys():
    if c[k] == 1:
        x += 1

if x != 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
path = [list(map(int, input().split())) for _ in range(3)]
counter = [0, 0, 0, 0, 0]
for p in path:
    counter[p[0]] += 1
    counter[p[1]] += 1
if 3 in counter:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
a1,a2 = map(int,input().split())
a3,a4 = map(int,input().split())
a5,a6 = map(int,input().split())
x = [0,0,0,0,0]
x[a1]+=1
x[a2]+=1
x[a3]+=1
x[a4]+=1
x[a5]+=1
x[a6]+=1
del x[0]
if 0 in x or 3 in x:
    print('NO')
else:
    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())

dict = {1: 0, 2: 0, 3: 0, 4: 0}

dict[a1] += 1
dict[a2] += 1
dict[a3] += 1
dict[b1] += 1
dict[b2] += 1
dict[b3] += 1

odd_points = 0
for key in dict:
    if dict[key] % 2 == 1:
        odd_points += 1

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

Submission status: Accepted

Solution code:
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
l=l1+l2+l3
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:
import collections

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

c = collections.Counter(a)
ans = c.most_common()

flg = "NO"

if (ans[0][1]) == 2:
    if (ans[0][1]) == 2:
        if (ans[2][1]) == 1:
            if (ans[3][1]) == 1:
                flg = "YES"

print(flg)

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    cities = []
    for _ in range(3):
        cities.extend(get_int_list())

    counter = Counter()
    for c in cities:
        counter[c] += 1
    c2 = Counter()
    for v in counter.values():
        c2[v] += 1
    if list(c2.values()) == [2, 2]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
a1,b1 = input().split()
a2,b2 = input().split()
a3,b3 = input().split()
a1 = int(a1)
b1 = int(b1)
a2 = int(a2)
b2 = int(b2)
a3 = int(a3)
b3 = int(b3)
list = [a1,a2,a3,b1,b2,b3]
if list.count(1) == 3 or list.count(2) == 3 or list.count(3) == 3 or list.count(4) == 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

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


for a in (list(itertools.permutations(ab))):
    for f in [a[0],list(reversed(a[0]))]:
        for g in [a[1],list(reversed(a[1]))]:
            for h in [a[2],list(reversed(a[2]))] :
                if f[1]==g[0] and g[1]==h[0] and len(set([f[0],g[0],h[0],h[1]]))==4:
                    print("YES")
                    exit()


print("NO")

Submission status: Accepted

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
path=[]
c=[0,0,0,0]
used=[False for i in range(4)]
for i in range(3):
    a,b=IL()
    c[a-1]+=1
    c[b-1]+=1
    path.append([a-1,b-1])
c.sort()
if c==[1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
c1=0
c2=0
c3=0
c4=0
a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    for j in range(2):
        if a[i][j] == 1 :
            c1 += 1
        elif a[i][j] == 2 :
            c2 += 1
        elif a[i][j] == 3 :
            c3 += 1
        else:
            c4 += 1
if max(c1,c2,c3,c4) > 2:
    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())

for i in range(0,4):
    if i+1 == a or i+1 == b:
        if i+1 == c or i+1 == d:
            if i+1 == e or i+1 == f:
                print("NO")
                exit()

print("YES")

Submission status: Accepted

Solution code:
import collections

path = []

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

c = collections.Counter(path)
if set(c.values()) == {1,2}:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
list=[];

for i in range(3):
    A, B = map(int, input().split())
    list.append(A);
    list.append(B);

townNum=[3,3,3,3];
result=0;

for i in list:
    townNum[i-1]-=1;
    if(townNum[i-1]==0):
        result=1;
        break;

if(result==1):
    print("NO");
else:
    print("YES");

Submission status: Accepted

Solution code:
import numpy as np

ll = []
# li=[1,2,3,4,5,...,n]
li = list(map(int,input().split()))
ll += li
li = list(map(int,input().split()))
ll += li
li = list(map(int,input().split()))
ll += li

cnt = 0
cnt += ll.count(1)%2
cnt += ll.count(2)%2
cnt += ll.count(3)%2
cnt += ll.count(4)%2

if ll.count(1) > 2 or ll.count(2) > 2 or ll.count(3) > 2 or ll.count(4) > 2:
    print("NO")
    exit()

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

Submission status: Accepted

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

def solve():
    *x1, = map(int, input().split())
    *x2, = map(int, input().split())
    *x3, = map(int, input().split())
    x = x1 + x2 + x3
    if max(x.count(i) for i in range(1,5)) <= 2:
        res = 'YES'
    else:
        res = 'NO'
    return str(res)
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

counter = 0
for i in range(1,5):
	counter = 0
	if a1 == i or b1 == i:
		counter += 1
	if a2 == i or b2 == i:
		counter += 1
	if a3 == i or b3 == i:
		counter += 1
	if counter == 3:
		print("NO")
		exit()
		
print("YES")

Submission status: Accepted

Solution code:
a = []
for i in range(3):
    tmpa, tmpb = map(int, input().split())
    a.append(tmpa)
    a.append(tmpb)

count = []
for i in range(4):
    c = 0
    for j in range(6):
        if a[j] == i+1:
            c += 1
    count.append(c)

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

Submission status: Accepted

Solution code:
# coding: utf-8
# author: ismdeep
# dateime: 2019-02-09 20:08:40
# filename: b.py
# blog: https://ismdeep.com
a = [0, 0, 0, 0, 0]
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1
s = input().split()
a[int(s[0])] += 1
a[int(s[1])] += 1

a.sort()

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

Submission status: Accepted

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

from collections import defaultdict

def solve():
    cnt = defaultdict(int)
    for i in range(3):
        a, b = input().split()
        cnt[a] += 1
        cnt[b] += 1
    ok = len(cnt.keys()) == 4
    one, two = 0, 0
    for v in cnt.values():
        if v == 1:
            one += 1
        if v == 2:
            two += 1
    ok = ok and (one == 2 and two == 2)
    print("YES" if ok else "NO")
    

if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from itertools import permutations as p

d=dd(list)
a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

for i in p(range(1,5)):
  a=i[0]
  for j in i[1:]:
    if not j in d[a]:
      break
    a=j
  else:
    print("YES")
    break
else:
  print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

Edge = defaultdict(lambda: 0)
for _ in [0]*3:
    a, b = inpl()
    Edge[a] += 1
    Edge[b] += 1

print(['YES', 'NO'][max(Edge.values()) == 3])

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter()
count = [0,0,0,0]
for i in range(3):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    c[a] += 1
    c[b] += 1
for i in c:
    count[c[i]-1] += 1

if count == [2,2,0,0]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
dic = {1:0, 2:0, 3:0, 4:0}

for _ in range(3):
    a, b = map(int, input().split(' '))
    dic[a] += 1
    dic[b] += 1
    
if sorted(list(dic.values())) == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
A=[0,0,0,0]

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

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

Submission status: Accepted

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

counter = [-1, 0, 0, 0, 0]
for a in A:
    counter[a] += 1
for b in B:
    counter[b] += 1

for count in counter[1:]:
    if count == 3:
        print("NO")
        exit(0)

print("YES")

Submission status: Accepted

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

count = 0
for i in range(4):
    if city[i] % 2 == 1:
        count += 1
if count <= 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
a=[list(map(int, input().split())) for i in range(3)]
b=a[0]+a[1]+a[2]
b=Counter(b)
d=[2,2,1,1]
for i,j in b.most_common():
    if j in d:
        d.remove(j)
if d:print('NO')
else:print('YES')

Submission status: Accepted

Solution code:
count = [0, 0, 0, 0]

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

flag = True
for e in count:
    if e == 3:
        print("NO")
        flag = False
        break

if flag:
    print("YES")

Submission status: Accepted

Solution code:
a = []
b = []

x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)
x,y = map(int,input().split())
a.append(x)
b.append(y)

for i in range(1,5):
    if a.count(i)+b.count(i)>= 2:
        continue
    if a.count(i)==1:
        k = b[a.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
    if b.count(i)==1:
        k = a[b.index(i)]
        if a.count(k)+b.count(k)==2:
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
import collections
path = []
for i in range(3):
    path += list(map(int, input().split()))
path = collections.Counter(path)
if len(path.most_common()) == 4:
    if path.most_common()[0][1] == 2 and path.most_common()[1][1] == 2 and path.most_common()[2][1] == 1 and path.most_common()[3][1] == 1:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Accepted

Solution code:
import collections
t = []
for i in range(3):
    a,b = map(int,input().split())
    t.append(a)
    t.append(b)
    
c = collections.Counter(t)

cv = []
for v in c.values():
    cv.append(v)
cv.sort()

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

Submission status: Accepted

Solution code:
arr=[]
for i in range(3):
    a,b=map(int, input().split(" "))
    if a in arr:
        arr.remove(a)
    else:
        arr.append(a)
    
    if b in arr:
        arr.remove(b)
    else:
        arr.append(b)

if len(arr)==2:
    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()))
r = [a1, b1, a2, b2, a3, b3]
if r.count(1) <= 2 and r.count(2) <= 2 and r.count(3) <= 2 and r.count(4) <= 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import Counter


def main():
    ab = [
        [int(a) for a in input().split()]
        for _ in range(3)
    ]
    fl = [a for b in ab for a in b]

    c = Counter(fl)
    res = c.items()

    vvv = [v for k, v in res]

    if all(a in [1, 2] for a in vvv):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=[0,0,0,0]
for i in range(3):
    a,b=map(int,input().split())
    x[a-1]+=1
    x[b-1]+=1
y=0
for j in range(4):
    if x[j]%2==1:
        y+=1
if y>2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
Edge = [[] for i in range(4)]
for i in range(3):
	a, b = map(int, input().split())
	Edge[a-1].append(b)
	Edge[b-1].append(a)
for edge in Edge:
	if len(edge) == 3:
		print("NO")
		break
else: print("YES")