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:
a1,b1 = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())

count_1 = 0
count_2 = 0
count_3 = 0
count_4 = 0

if a1 == 1:
    count_1 += 1
if a1 == 2:
    count_2 += 1
if a1 == 3:
    count_3 += 1
if a1 == 4:
    count_4 += 1

if b1 == 1:
    count_1 += 1
if b1 == 2:
    count_2 += 1
if b1 == 3:
    count_3 += 1
if b1 == 4:
    count_4 += 1

if a2 == 1:
    count_1 += 1
if a2 == 2:
    count_2 += 1
if a2 == 3:
    count_3 += 1
if a2 == 4:
    count_4 += 1

if b2 == 1:
    count_1 += 1
if b2 == 2:
    count_2 += 1
if b2 == 3:
    count_3 += 1
if b2 == 4:
    count_4 += 1

if a3 == 1:
    count_1 += 1
if a3 == 2:
    count_2 += 1
if a3 == 3:
    count_3 += 1
if a3 == 4:
    count_4 += 1

if b3 == 1:
    count_1 += 1
if b3 == 2:
    count_2 += 1
if b3 == 3:
    count_3 += 1
if b3 == 4:
    count_4 += 1

if 1 <= count_1 and count_1 <=2 and 1 <= count_2 and count_2 <=2 and 1 <= count_3 and count_3 <=2 and 1 <= count_4 and count_4 <=2:
    print("YES") 
else:
    print("NO")

Submission status: Accepted

Solution code:
def solve():
    graph = [[False] * 4 for i in range(4)]
    for i in range(3):
        a, b = [int(n) for n in input().split()]
        a-=1
        b-=1
        graph[a][b] = graph[b][a] = True

    import itertools
    for a,b,c,d in itertools.permutations([0,1,2,3]):
        if graph[a][b] and graph[b][c] and graph[c][d]:
            return True
    return False


def main():
    ans = solve()
    if ans:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def a():
    n, k = map(int, input().split())
    if int(n / 2 + 0.5) >= k:
        print("YES")
    else:
        print("NO")


def B():
    root = [[0 for i in range(4)] for j in range(4)]
    for i in range(3):
        a, b = map(int, input().split())
        #print(a, b)
        root[a - 1][b - 1] = 1
        root[b - 1][a - 1] = 1

    cnt_one = 0
    cnt_two = 0
    for i in range(4):
        if sum(root[i]) == 1:
            cnt_one += 1
        if sum(root[i]) == 2:
            cnt_two += 1
    if cnt_one == 2 and cnt_two == 2:
        print("YES")
    else:
        print("NO")

B()

Submission status: Accepted

Solution code:
num = []
for i in range(3):
    v1,v2 = map(int,input().split())
    num.append(v1)
    num.append(v2)

a = num.count(1)
b = num.count(2)
c = num.count(3)
d = num.count(4)

if a>2 or b>2 or c>2 or d>2:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
ABlist = list()

for x in range(0,3):
    S = list(map(int,input().split()))
    ABlist.append(S[0])
    ABlist.append(S[1])

number = 0
for x in range(1,5):
    n = ABlist.count(x)
    if n > number:
        number = n

if number == 3:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
import sys
l = []
for line in sys.stdin:
  l += list(map(int, line.strip().split(' ')))
for i in [1,2,3,4]:
  if l.count(i) == 3:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
li = [0]*4
li2 = [0]*2
for _ in range(3):
    a,b = [int(x) for x in input().split()]
    li[a-1]+=1
    li[b-1]+=1

for i in li:
    if(i == 1):
        li2[0]+=1
    elif(i == 2):
        li2[1]+=1
if(li2[0] == 2 and li2[1] == 2):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    dict = {}
    for i in range(1, 5):
        dict[i] = 0
    for i in range(3):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        dict[a] += 1
        dict[b] += 1

    max_n = 0
    for n  in dict:
        max_n = max(dict[n], max_n)

    if max_n >= 3:
        print "NO"
    else:
        print "YES"


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
rank = [0 for i in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    rank[a - 1] += 1
    rank[b - 1] += 1
print('YES' if sorted(rank) == [1, 1, 2, 2] else 'NO')

Submission status: Accepted

Solution code:
import sys

def move(FROM, edges):
  for edge in edges:
    if FROM in edge:
      edges.remove(edge)
      edge.remove(FROM)

      return edge[0]
  
  return 0


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

nowhere = startNode
for i in range(loadNum):
  nowhere = move(nowhere, a)
  if nowhere == 0:
    print('NO')
    sys.exit()

print('YES')

Submission status: Accepted

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

#%%
# ab = [
# [4, 2],
# [1, 3],
# [2, 3]]

#%%
node = [0] * 4


#%%


for abi in ab:
    node[abi[0]-1] += 1
    node[abi[1]-1] += 1


#%%
if len(ab) < 3:
    print("NO")
elif 3 in node:
    print("NO")
else:
    print("YES")

#%%

Submission status: Accepted

Solution code:
from itertools import chain
from collections import Counter

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


print(["NO", "YES"][sum([m%2 for m in Counter(chain(*AB)).values()])<=2])

Submission status: Accepted

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

for path in path_list:
    if path >= 3:
        count += 1
if count == 1:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    if (a[i][0] in a[(i+1) % 3] or a[i][0] in a[(i+2) % 3]) and \
     (a[i][1] in a[(i+1) % 3] or a[i][1] in a[(i+2) % 3]):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

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

a = a1
a.extend(a2)
a.extend(a3)

cnt = [0,0,0,0]
for ax in a:
  if ax == 1:
    cnt[0] += 1
  elif ax == 2:
    cnt[1] += 1
  elif ax == 3:
    cnt[2] += 1
  elif ax == 4:
    cnt[3] += 1
if set(cnt) == set([1,1,2,2]):
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
X=[]
for i in range(3):
    a,b=map(int,input().split())
    X.append(a)
    X.append(b)
   
count_1=0
count_2=0
count_3=0
count_4=0
for i in range(6):
    if X[i]==1:
        count_1+=1
    if X[i]==2:
        count_2+=1
    if X[i]==3:
        count_3+=1
    if X[i]==4:
        count_4+=1
        
H=[count_1,count_2,count_3,count_4]

if set(H)=={1,3}:
    print('NO')
else:
    print('YES')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(4):
  if len(edges[i])>=3:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

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

for x in itertools.permutations([1,2,3,4]):
  for i in range(3):
    f = False
    for y in a:
      if y[0]==x[i]and y[1]==x[i+1]:
        f = True
        break
      elif y[1]==x[i]and y[0]==x[i+1]:
        f = True
        break
    if not f: break
    if i==2:
      print("YES")
      sys.exit()
print("NO")

Submission status: Accepted

Solution code:
lis = [0,0,0,0]
for _ in range(3):
  n,m = list(map(int,input().split()))
  lis[n-1] += 1
  lis[m-1] += 1
if 3 in lis:
  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())

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

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

Submission status: Accepted

Solution code:
import collections

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

count = collections.Counter()
for a, b in ab:
    count[a] += 1
    count[b] += 1

cnt = 0
for key, value in count.items():
    if value >= 2:
       cnt += 1
if cnt >= 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    a = a + [int(i) for i in input().split()]
b = []
for j in [1,2,3,4]:
    b.append(a.count(j))
b = set(b)
if b == set([1,2]):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
towns = []
for i in range(3):
    ai, bi = map(int, input().split())
    towns.append(ai)
    towns.append(bi)
counter = Counter(towns)
if set(list(counter.values())) == set([1, 2]):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
[a1,b1] = [int(i)-1 for i in input().split()]
[a2,b2] = [int(i)-1 for i in input().split()]
[a3,b3] = [int(i)-1 for i in input().split()]

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

route = {0:0,1:0,2:0,3:0}
for i in s:
    route[i] += 1
#print(route)
ok = 1
for i in range(4):
    if route[i] != 1 and route[i] != 2:
        ok = 0

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

Submission status: Accepted

Solution code:
l = [0 for _ in range(4)]

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

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

Submission status: Accepted

Solution code:

city = [0, 0, 0, 0]

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

two = 0

for i in range(4):
  if city[i] == 2:
    two += 1

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

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
e=[0 for i in range(4)]
for i in range(3):
 [x,y]=i2()
 e[x-1]+=1
 e[y-1]+=1
e.sort()
e=tuple(e)
if e==(1,1,2,2):
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
cnt = [0] * 100
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
a, b = map(int, raw_input().split())
cnt[a] +=1
cnt[b] +=1
if max(cnt) == 3:print"NO"
else:print "YES"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
p = [0]*4

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

odd = 0
even = 0
for x in p:
    if x%2==1:
        odd += 1
    else:
        even += 1

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

Submission status: Accepted

Solution code:
a = []
b = []
res = [0]*4
two = 0

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

for i in range(3):
    for j in range(1,4):
        if a[i]==j:
            res[j] += 1
        if b[i]==j:
            res[j] += 1

for i in range(4):
    if res[i] == 2:
        two += 1
else:
    if two==2:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
def main():
    counts = [0, 0, 0, 0]
    for _ in range(3):
        v0, v1 = map(int, input().split())
        counts[v0 - 1] += 1
        counts[v1 - 1] += 1
    if max(counts) >= 3:
        print("NO")
    else:
        print("YES")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def solve(ABs):
    ac = Counter([a for (a, b) in ABs] + [b for (a, b) in ABs])
    if "".join(sorted([str(v) for v in ac.values()])) == "1122":
        return "YES"
    else:
        return "NO"


if __name__ == "__main__":
    ABs = [tuple(map(int, input().split(" "))) for _ in range(3)]
    print(solve(ABs))

Submission status: Accepted

Solution code:
list1 = input().split()
list2 = input().split()
list3 = input().split()
flag = 0
for i in range(len(list1)):
  list1[i] = int(list1[i])
  i = i + 1
i=0
for i in range(len(list2)):
  list2[i] = int(list2[i])
  i = i + 1
i=0
for i in range(len(list3)):
  list3[i] = int(list3[i])
  i = i + 1
i=0
for i in range(len(list1)):
  j = 0
  for j in range(len(list2)):
    k = 0
    for k in range(len(list3)):
      if(list1[i] == list2[j] == list3[k]):
        print("NO")
        flag = 1
        break
if flag == 0:
  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())

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

city = [0, 0, 0, 0]

for i in road:
  if i == 1:
    city[0] += 1
  elif i == 2:
    city[1] += 1
  elif i == 3:
    city[2] += 1
  elif i == 4:
    city[3] += 1

if max(city) > 2:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
a = [[0 for i in range(4)] for j in range(4)]
bb = [0,0,0,0]
for i in range(3):
	n,m = map(int,input().split())
	bb[n-1] += 1
	bb[m-1] += 1
su = 1
for i in range(4):
	su *= bb[i]
if su == 4:
	print("YES")
else:
	print("NO")

Submission status: Accepted

Solution code:
array = [[int(x) for x in input().split()] for y in range(3)]
tmp = [[] for x in range(5)]
for a, b in array:
    tmp[a].append(b)
    tmp[b].append(a)
for i in tmp:
    if len(i) == 3:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
route = [[] for i in range(4)]
for i in range(3):
    a, b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
#print(route)

maxlen = 0
for i in range(4):
    maxlen = max(maxlen, len(route[i]))
#print(maxlen)
if(maxlen >= 3): print("NO")
else: print("YES")

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
a_b=[]
time = [0,0,0,0]
for i in range(3):
    a_b=input().split()
    if a_b[0]=='1':
        time[0]+=1
    if a_b[0]=='2':
        time[1]+=1
    if a_b[0]=='3':
        time[2]+=1
    if a_b[0]=='4':
        time[3]+=1
    if a_b[1]=='1':
        time[0]+=1
    if a_b[1]=='2':
        time[1]+=1
    if a_b[1]=='3':
        time[2]+=1
    if a_b[1]=='4':
        time[3]+=1
print('YES' if max(time)<=2 else 'NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = 4*[0]
for i in range(3):
    n, k = list(map(int, input().split(" ")))
    a[n-1] += 1
    a[k-1] += 1

for i in range(4):
    if(a[i] == 3):
        print("NO")
        exit()

print("YES")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
A = np.empty(6,dtype=np.int)

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

for i in range(1,5):
  n = len(np.where(A==i)[0])
  if n==0 or n>2:
    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())
data_list=[a1,a2,a3,b1,b2,b3]
count=0
for i in range (4):
    if data_list.count(i)>=2:
        count+=1
if count>=2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

even = 0
for count in counts:
    if count % 2 == 0: even += 1

print('YES' if even == 2 else 'NO')

Submission status: Accepted

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

counter = [0] * 4

for i in range(3):
    counter[A[i] - 1] += 1
    counter[B[i] - 1] += 1

oddscounter = 0

for i in range(4):
    if counter[i] % 2 == 1:
        oddscounter += 1

answer = "YES"
if oddscounter >= 3:
    answer = "NO"
else:
    answer = "YES"

print(answer)

Submission status: Accepted

Solution code:
a1, b1 = map(int,input().split())
a2, b2 = map(int,input().split())
a3, b3 = map(int,input().split())
row = [a1,a2,a3,b1,b2,b3]
c =[0,0,0,0]
for i in row:
	if i == 1:
		c[0] += 1
	elif i == 2:
		c[1] += 1
	elif i == 3:
		c[2] += 1
	else:
		c[3] += 1
	
ans = 0
for i in c:
	if i == 3:
		ans = 1
	elif i == 0:
		ans = 1
		
if ans == 0:
	print("YES")
else:
	print("NO")

Submission status: Accepted

Solution code:
# input
P1 = list(map(int, input().split()))
P2 = list(map(int, input().split()))
P3 = list(map(int, input().split()))

P1_P2 = set(P1) & set(P2)
P2_P3 = set(P2) & set(P3)
P3_P1 = set(P3) & set(P1)

if P1_P2 == P2_P3:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
road = []
count_num = [1, 2, 3, 4]
for i in range(3):
    a, b = map(int, input().split())
    road.append(a)
    road.append(b)
flag = True
for i in count_num:
    if road.count(i) >= 3:
        flag = False
if flag is True:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
# coding: utf-8
mylist=[]
for i in range(3) :
    line = input().split()
    mylist.append(int(line[0]))
    mylist.append(int(line[1]))
if mylist.count(1)<=2 and mylist.count(2)<=2 and mylist.count(3)<=2 and mylist.count(4)<=2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
p1=list(map(int,input().split()))
p2=list(map(int,input().split()))
p3=list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(list)
for p in [p1,p2,p3]:
    a,b=p
    d[a].append(b)
    d[b].append(a)

for i in range(1,5):
    if len(d[i])>2:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
cnt = [0 for i in range(5)]
for i in range(3):
    temp = list(map(int,input().split()))
    cnt[temp[0]]+=1
    cnt[temp[1]]+=1
flg = 1
for i in range(1,5):
    if cnt[i] > 2:
        flg = 0
if flg == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

if ans.count(1) == 2 and ans.count(2) == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

x = [a, b, c, d, e, f]
x.sort()

if x == [1, 2, 2, 3, 3, 4]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
# encoding:utf-8

import copy
import numpy as np
import random

a = []
b = []

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

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

for i in range(3):
    town_dic[a[i]] += 1
    town_dic[b[i]] += 1

answer = "YES"
for i in range(4):
    if town_dic[i+1] == 3:
        answer = "NO"


print(answer)

Submission status: Accepted

Solution code:
import collections
x = []
for xx in range(3):
    aa, bb = (int(i) for i in input().split()) 
    x.append(aa)
    x.append(bb)

c = collections.Counter(x)
cc = c.most_common()

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

Submission status: Accepted

Solution code:
l=[[]for i in range(5)]
for i in range(3):
    a=[int(j) for j in input().split()]
    l[a[0]].append(a[1])
    l[a[1]].append(a[0])
p=0
for i in range(5):
    if len(l[i])>=3:
        p=1

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

Submission status: Accepted

Solution code:
from collections import Counter
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
cnt = Counter([a1, b1, a2, b2, a3, b3])
if sorted(cnt.values()) == [1, 1, 2, 2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys

road = []
for i in range(3):
    road = road + input().split()

road.sort()
town = [0]*4
for v in road:
    town[int(v)-1] +=1

for v in town:
    if v >=3:
        print("NO")
        sys.exit()
print("YES")

Submission status: Accepted

Solution code:
ab = []
for i in range(3):
    ab.append([int(v) for v in input().split()])

city_cnt = {i: 0 for i in range(1, 5)}
for a, b in ab:
    city_cnt[a] += 1
    city_cnt[b] += 1

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

Submission status: Accepted

Solution code:
flag = True
numbers = {}
for i in range(3):
    tmp = list(int(i) for i in input().split())
    if tmp[0] in numbers:
        numbers[tmp[0]] += 1
        if numbers[tmp[0]] > 2:
            flag = False
            break
    else:
        numbers[tmp[0]] = 1
    if tmp[1] in numbers:
        numbers[tmp[1]] += 1
        if numbers[tmp[1]] > 2:
            flag = False
            break
    else:
        numbers[tmp[1]] = 1

for i in range(4):
    if not i+1 in numbers:
        flag = False
        break

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

Submission status: Accepted

Solution code:
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_b

paths = [sorted(list(map(int, input().split()))) for _ in range(3)]

# print(paths)

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

for p in paths:
    for c in p:
        if c == 1:
            c1 += 1
        elif c == 2:
            c2 += 1
        elif c == 3:
            c3 += 1
        elif c == 4:
            c4 += 1

if [c1,c2,c3,c4].count(2) == 2 and [c1,c2,c3,c4].count(1) == 2:
    print("YES")
else:
    print("NO")
#
# print("{}, {}, {}, {}".format(c1,c2,c3,c4))

Submission status: Accepted

Solution code:
p = [[] for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    p[a-1].append(b-1)
    p[b-1].append(a-1)

if [] in p:
    print('NO')
    exit()

if all([len(x) < 3 for x in p]):
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


#A = [int(i) for i in input().split()]
#A=[ [int(i) for i in input().split()]
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()]

if a>= b:
    a,b=b,a
if c>= d:
    c,d=d,c
if e>= f:
    e,f=f,e
A=[a,b,c,d,e,f]
B=[]
#print(A)
for i in range(1,5):
    c=0
    for j in A:
        if i == j:
            c+=1
    B.append(c)

#print(B)
if set([a,b,c,d,e,f]) == set([1,2,3,4]) and 3 not in B and 4 not in B:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
a= list(map(int,input().split()))
b= list(map(int,input().split()))
c= list(map(int,input().split()))
lst=a+b+c
ans=[lst.count(i) for i in range(1,5)]
ans.sort()
if ans == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def func():
    pass


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

    l.sort()
    # print(l)
    if l == [1, 1, 2, 2]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
X = Counter([a1, b1, a2, b2, a3, b3])
N = Counter([x[1] for x in X.items()])
if N[1] == 2 and N[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())

arr = [a1, b1, a2, b2, a3, b3]
if arr.count(1) <= 2 and arr.count(2) <= 2 and arr.count(3) <= 2 and arr.count(4) <= 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
ab1=list(map(int,input().split()))
ab2=list(map(int,input().split()))
ab3=list(map(int,input().split()))
n = [0,0,0,0,0]
n[ab1[0]] = n[ab1[0]] +1
n[ab1[1]] = n[ab1[1]] +1
n[ab2[0]] = n[ab2[0]] +1
n[ab2[1]] = n[ab2[1]] +1
n[ab3[0]] = n[ab3[0]] +1
n[ab3[1]] = n[ab3[1]] +1
if n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 0 or n[1]%2+n[2]%2+n[3]%2+n[4]%2 == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
count = {}
for _ in range(3):
    for i in map(int,input().split()):
        if i in count:
            count[i] += 1
        else:
            count[i] = 1

if max(count.values()) > 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
P1 = list(map(int,input().split()))
P2 = list(map(int,input().split()))
P3 = list(map(int,input().split()))

li = []
for i in range(2):
    li.append(P1[i])
    li.append(P2[i])
    li.append(P3[i])

flag = 0
for j in range(1, 5):
    score = li.count(j)
    if score == 3:
        flag = 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!


town = input().split() + input().split() + input().split()


for _ in range(4):
    if town.count(str(_+1)) == 3:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
ans = [0,0,0,0]
for i in range(3):
    a = list(map(int,input().split()))
    for i in a:
        if i==1: ans[0]+=1
        elif i==2: ans[1]+=1
        elif i==3: ans[2]+=1
        else: ans[3]+=1
n = [0,0]
for i in ans:
    if i==1:
        n[0]+=1
if n[0]==2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
cnt = {"1":0,"2":0,"3":0,"4":0}
for i in range(3) :
    (j,k)=input().split()
    cnt[j]+=1
    cnt[k]+=1

if cnt["1"] == 3 or cnt["2"] == 3 or cnt["3"] == 3 or cnt["4"] == 3 :
    print("NO")
else :
    print("YES")

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
  c,d = map(int,input().split())
  a.append(c)
  a.append(d)
for i in range(1,5):
  if a.count(i) == 3:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

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

Submission status: Accepted

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

for n in count:
    if n == 0 or n == 3:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
for i in range(3):
    a,b = map(int,input().split())
    d[a] += 1
    d[b] += 1
a = sorted(d.items(),key=lambda x:x[1],reverse=True)
tc,oc = 0,0
for ai in a:
    if ai[1]==2:
        tc += 1
    elif ai[1]==1:
        oc += 1
print('YES' if tc==2 and oc==2 else 'NO')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

orders = [0, 0, 0, 0]

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

flag = True
nodds = 0
for e in orders:
    if e % 2 == 1:
        flag = False
        nodds += 1
if flag or nodds == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
town=[0 for i in range(4)]
for i in range(3):
    a,b=[int(j) for j in input().split()]
    town[a-1]+=1
    town[b-1]+=1
ans=0
for i in range(4):
    if town[i]>ans:
        ans=town[i]
if ans==3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
r=[]
x=0
for i in range(3):
    a,b=map(int,input().split())
    x+=a
    x+=b
print("YES" if x==15 else "NO")

Submission status: Accepted

Solution code:
towns = []
for i in range(3):
    a, b = map(int, input().split())
    towns.append(a)
    towns.append(b)
nums = []
for i in range(4):
    nums.append(towns.count(i+1))

if nums.count(1) == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
cnt = [0] * 4

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

cnt.sort()
if cnt[-1] == 3:
    print("NO")
elif cnt[0] == 0:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
l = [0] * 4

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

l.sort()
r = [1, 1, 2, 2]
if l == r:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
d = {1:0,2:0,3:0,4:0}
for i in range(3):
    j,k = map(int,input().split())
    d[j] += 1
    d[k] += 1
if d[1]==3 or d[2]==3 or d[3]==3 or d[4]==3:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
road_cnt = {}
for i in range(1, 5):
    road_cnt[i] = 0

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

one_road = 0
two_road = 0
for k, v in road_cnt.items():
    if v == 2:
        two_road += 1
    elif v == 1:
        one_road += 1

print("YES" if one_road == 2 and two_road == 2 else "NO")