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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
num =[]
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,4):
    if num.count(i)==3:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
num =[]
for i in range(3):
    x,y = map(int,input().split(" "))
    num.append(x)
    num.append(y)
for i in range(1,4):
    if num.count(i)>=3:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
a = []
result = "YES"
for i in range(3) :
    a.extend(input().split(" "))

for i in range(4) :
    if a.count(str(i)) >= 3 :
        result = "NO"
        break
    
print(result)

Submission status: Wrong Answer

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


def func(key, roads):
    if len(roads) == 0:
        print('YES')
        exit()

    for road in roads:
        if key == road[0]:
            roads.remove(road)
            func(road[0], roads)
        elif key == road[1]:
            roads.remove(road)
            func(road[1], roads)

    return -1


if __name__ == "__main__":
    ret = func(roads[0][0], roads)
    if ret == -1:
        ret = func(roads[0][1], roads)
        if ret == -1:
            print('NO')

Submission status: Wrong Answer

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(3):
    i+=1
    if n[i] != 1 and n[i] != 2:
        t=1
        
if t == 0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
a=[0 for i in range(3)]
b=[0 for i in range(3)]

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

    
a=(set(a))
b=(set(b))



if len(a)==3 and len(b)==3:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = []
d.append(a)
d.append(b)
d.append(c)
if 1 in d and 2 in d and 3 in d and 4 in d:
    if a[1] == b[0] and b[1] == c[0]:
        print('YES')
    if a[1] == c[0] and c[1] == b[0]:
        print('YES')
    if b[1] == a[0] and a[1] == c[0]:
        print('YES')
    if b[1] == c[0] and c[1] == a[0]:
        print('YES')
    if c[1] == b[0] and b[1] == a[0]:
        print('YES')
    if c[1] == a[0] and a[1] == b[0]:
        print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
a=input().split()
b=a[0]
c=a[1]
d=input().split()
e=d[0]
f=d[1]
g=input().split()
h=g[0]
i=g[1]
L=[b,c,e,f,h,i]
if L.count('1') or L.count('2') or L.count('3') or L.count('4') ==3:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
 
print(A)
C=[0,0,0,0,0]
for i in range(len(A)) :
    C[A[i][0]]+=1
    C[A[i][1]]+=1
 
print(C)
co=0
for i in range(1,5):
    if C[i]==1 or C[i]==3 :
        co+=1
 
if co==0 or co==2 :
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
A=[]
B=[]
for i in range(3):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
if A[0]==B[1] and B[1]==A[2] and B[0]!=A[1] and A[1]!=B[2]:print("NO")
elif B[0]==A[1] and A[1]==B[2] and A[0]!=B[1] and B[1]!=A[2]:print("NO")
else:print("YES")

Submission status: Wrong Answer

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

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

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

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

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

        else:
            flag = True

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

Submission status: Wrong Answer

Solution code:
# import bisect
# import heapq
# import math
# import random
# from fractions import gcd
# from collections import Counter, defaultdict, deque
# from decimal import Decimal
# from functools import lru_cache, reduce
# from itertools import combinations, combinations_with_replacement, product, permutations
# from operator import add, mul, sub, itemgetter
# import numpy as np

import sys
sys.setrecursionlimit(10000)

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

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

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

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

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

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

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

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

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

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
a=input().split()
b=int(a[0])
c=int(a[1])
d=input().split()
e=int(d[0])
f=int(d[1])
g=input().split()
h=int(g[0])
i=int(g[1])
L=[b,c,e,f,h,i]
if L.count('1') or L.count('2') or L.count('3') or L.count('4') ==3:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 or c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())

Submission status: Wrong Answer

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


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

B = [sum(A[i]) for i in range(4)]

for i in range(3):
    if B[i] == 3 or B[i] == 0:
        flag = False
        break
    else:
        flag = True

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

Submission status: Wrong Answer

Solution code:
A=[]
B=[]
for i in range(3):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
if A[0]==B[1] and B[1]==A[2] or B[0]==A[1] and A[1]==B[2]:print("NO")
else:print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# import bisect
# import heapq
# import math
# import random
# from fractions import gcd
# from collections import Counter, defaultdict, deque
# from decimal import Decimal
# from functools import lru_cache, reduce
# from itertools import combinations, combinations_with_replacement, product, permutations
# from operator import add, mul, sub, itemgetter
# import numpy as np

import sys
sys.setrecursionlimit(10000)

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

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

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

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

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

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

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

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

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

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
nodes = [[] for i in range(4)]

a = [int(i) for i in input().split()]
nodes[a[0]-1].append(a[1]-1)
nodes[a[1]-1].append(a[0]-1)

b = [int(i) for i in input().split()]
nodes[b[0]-1].append(b[1]-1)
nodes[b[1]-1].append(b[0]-1)

c = [int(i) for i in input().split()]
nodes[c[0]-1].append(c[1]-1)
nodes[c[1]-1].append(c[0]-1)

seen = [0]*4
roads = [a, b, c]
used = [0]*3
def dfs(i):
    seen[i] = 1
    #print('at', i)
    for j in nodes[i]:
        ind = 0
        for k in range(len(roads)):
            if j in roads[k]:
                ind = k
        if seen[j]==0 and used[ind]==0:
            used[ind] = 1
            dfs(j)
    #return 0
dfs(0)
if seen.count(1)==4:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
l=[]
d={}
for s in range(3):
	x=list(map(int,input().split()))
	d[min(x)]=max(x)
r={1: 2, 2: 3, 3: 4}
print("YES") if d==r else print("NO")

Submission status: Wrong Answer

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

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

#print(C)
co=0
for i in range(1,5):
    if C[i]==1 or C[i]==3 :
        co+=1

if co==0 or co==2 :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

odd = 0
for ele in node:
    if ele/2 == 1:
        odd+=1
# print(node)
# print(odd)
if odd == 2:
    print('YES')
else:
    print('No')

Submission status: Wrong Answer

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(3):
    if(a[i] == 3):
        print("NO")
        exit()
    if(a[i] == 0):
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
lst=[a1,a2,a3,b1,b2,b3]
for i in range(1,4):
    if lst.count(i) > 2:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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(3):
    if(a[i] == 3):
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter
def solve(ABs):
    ABs = sorted([ (min(a, b), max(a, b)) for (a, b) in ABs])
    ac = Counter([a for (a, b) in ABs])
    bc = Counter([a for (a, b) in ABs])
    if len(ac) == 3 or len(bc) == 3:
        return "YES"
    else:
        return "NO"


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

Submission status: Wrong Answer

Solution code:
nodes = [[] for i in range(4)]

a = [int(i) for i in input().split()]
nodes[a[0]-1].append(a[1]-1)
nodes[a[1]-1].append(a[0]-1)

b = [int(i) for i in input().split()]
nodes[b[0]-1].append(b[1]-1)
nodes[b[1]-1].append(b[0]-1)

c = [int(i) for i in input().split()]
nodes[c[0]-1].append(c[1]-1)
nodes[c[1]-1].append(c[0]-1)

seen = [0]*4

def dfs(i):
    seen[i] = 1
    #print('at', i)
    for j in nodes[i]:
        if seen[j]==0:
            dfs(j)
    #return 0
dfs(0)
if seen.count(1)==4:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

Submission status: Wrong Answer

Solution code:
s = []
a,b = map(int,input().split(" "))
s.append(a)
s.append(b)
c,d = map(int,input().split(" "))
e,f = map(int,input().split(" "))
s.append(c)
s.append(d)
s.append(e)
s.append(f)

s = set(s)
if len(s) == 4:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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) == 4:
    print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
A = [0, 0, 0, 0]
for i in range(3):
  x, y = map(int, input().split())
  A[x-1] += 1
  A[y-1] += 1
f = 0
for i in range(4):
  if A[i] == 3:
    print("NO")
    f = 1
    break
if f == 0:
  print("YES")

Submission status: Accepted

Solution code:
a = set(input().split())
b = set(input().split())
c = set(input().split())
print("YES" if len(a&b&c)==0 else "NO")

Submission status: Accepted

Solution code:
dp=[0]*4
for i in range(3):
  a,b=map(int,input().split())
  dp[a-1]+=1
  dp[b-1]+=1
if dp.count(3)==1 or dp.count(0)==1:
  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())

load = [a1, b1, a2, b2, a3, b3]
load_dict = dict()
for i in range(6):
    if load[i] in load_dict:
        load_dict[load[i]] += 1
    else:
        load_dict[load[i]] = 1
        
if max(load_dict.values()) >= 3 or len(load_dict) <= 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
for i in range(1,5):
  if i in a[0] and i in a[1] and i in a[2]:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

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

num = []
for i in range(4):
    num.append(len(G[i]))

cnt = num.count(1)
if cnt < 3:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
#どの 2 つの街の間も、道を何本か通ることで行き来することができる
cnts=[0]*4
for i in range(3):
    ai,bi=map(int, input().split())
    ai-=1;bi-=1
    cnts[ai]+=1;cnts[bi]+=1
for i in range(4):
    if cnts[i]>2:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

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

link = [[0 for _ in range(4)] for _ in range(4)]
for path in paths:
  link[path[0]-1][path[1]-1] += 1
  link[path[1]-1][path[0]-1] += 1

ans = 'YES'
for i in range(4):
  tmp = 0
  for j in range(4):
    tmp += link[i][j]

  if tmp >= 3:
    ans = 'NO'

print(ans)

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import defaultdict, Counter
import bisect
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    a, b = i2(3)
    c = a+b
    if c.count(1) == 3 or c.count(2) == 3 or c.count(3) == 3 or c.count(4) == 3:
        print('NO')
    else:
        print('YES')




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def cin():  return list(map(int,input().split()))
c = [0] * 4
for i in range(3):
    in1, in2 = cin()
    c[in1 - 1] += 1
    c[in2 - 1] += 1
c = sorted(c)
if c == [1, 1, 2, 2]:  print("YES")
else:  print("NO")

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# みんなのプロコン 2019: B – Path
a, b = [], []
for _ in range(3):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

paths = a + b
passed_cities = []

for city in range(1, 5):
    passed_cities.append(paths.count(city))

print('NO' if max(passed_cities) == 3 else 'YES')

Submission status: Accepted

Solution code:
from collections import Counter

G=[[] for _ in range(4)]

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

c = Counter(deg)

cnt=0
for k in c.keys():
  if k%2: cnt += c[k]
    
if cnt in (0,2):
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
def main():
    path_list = [0] * 4

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

    odd, even = 0, 0
    for path in path_list:
        if path % 2 == 0:
            even += 1
        else:
            odd += 1

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c,d = map(int,input().split())
e,f = map(int,input().split())
l = [a,b,c,d,e,f]
if l.count(1)>=3:
  print("NO")
  exit()
if l.count(2)>=3:
  print("NO")
  exit()
if l.count(3)>=3:
  print("NO")
  exit()
if l.count(4)>=3:
  print("NO")
  exit()
print("YES")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in [1,2,3,4]:
    cnt=0
    for j in l:
        if i==j:
            cnt+=1
    if cnt==0 or cnt>2:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
list1 =[]
total =0
for i in range(3):
  MM = input().split()
  a = int(MM[0])
  b = int(MM[1])
  list1.append(a)
  list1.append(b)
for i in range(5):
  x = list1.count(i)
  if x >2:
    total +=1
if total == 0:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
import collections
cc = collections.Counter()
for _ in range(3):
	u,v = map(int ,raw_input().split())
	cc[u]+=1
	cc[v]+=1
print 'YES' if sorted([cc[a] for a in [1,2,3,4]]) == [1,1,2,2] else 'NO'

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
  t = [[] for _ in range(4)]
  for _ in range(3):
    a, b = map(int, input().split())
    if b-1 in t[a-1]:
      print("NO")
      return
    if a-1 in t[b-1]:
      print("NO")
      return
    t[a-1].append(b-1)
    t[b-1].append(a-1)

  for i in range(4):
    if len(t[i]) == 0:
      print("NO")
      return
    if len(t[i]) == 3:
      print("NO")
      return

  print("YES")
solve()

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
    x,y=map(int,input().split())
    l.append(x)
    l.append(y)
d=[]
d.append(l.count(1))
d.append(l.count(2))
d.append(l.count(3))
d.append(l.count(4))
if(max(d)==3):
    print("NO")
else:
    print('YES')

Submission status: Accepted

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

num = []
num.append(L.count(1))
num.append(L.count(2))
num.append(L.count(3))
num.append(L.count(4))

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

Submission status: Accepted

Solution code:
import networkx as nx
a=[[int(i) for i in input().split()] for _ in range(3)]
g = nx.Graph()
for x in a:
     g.add_edge(x[0],x[1])
print("YES" if nx.is_semieulerian(g) else "NO")

Submission status: Accepted

Solution code:
import sys
A = []
for i in range(3):
  a,b = map(int,input().split())
  A.append(a)
  A.append(b)
if A.count(1) == 1:
  if A.count(4) == 1:
    if A.count(2) == 2:
      print("YES")
      sys.exit()
print("NO")

Submission status: Accepted

Solution code:
import sys
import itertools

abset=set()
for _ in range(3):
  a,b=map(int,input().split())
  abset.add((a,b))
#print(abset)

for perm in itertools.permutations(range(1,5)):
  #print(perm)
  
  for i in range(1,4):
    if not (perm[i-1],perm[i]) in abset and not (perm[i],perm[i-1]) in abset:
      break
  else:
    #print(perm)
    print("YES")
    sys.exit(0)
else:
  print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    #rは長さ、Noneでiteraterの長さ
    for j in range(2):
        now=i[0][j]
        seen=set([now])
        for a,b in i:

            if b!=now and now!=a:break
            now=b+a-now
            seen.add(now)
        else:
            if len(seen)==4:print('YES');exit()

print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  l=[0]*4
  for i in range(3):
    a,b=map(int,pin().split())
    l[a-1]+=1
    l[b-1]+=1
  t=sorted(list(set(l)))
  if t==[1,2]:
    print("YES")
  else:
    print("NO")
  return 

main()

Submission status: Accepted

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

route_lists = [a1, b1, a2, b2, a3, b3]
cnt_lists = []

for i in range(1, 5, 1):
    cnt = route_lists.count(i)
    cnt_lists.append(cnt)

if 3 in cnt_lists:
    ans = 'NO'
else:
    ans = 'YES'

print(ans)

Submission status: Accepted

Solution code:
ab=[]
ba=[]
fullpath=[]
for i in range(3):
    ab.append(list(map(int,input().split())))
for i in range(3):
    ba.append(list(reversed(ab[i])))
fullpath=ab+ba
fullpath1=[]
for i in range(len(fullpath)):
    fullpath1.append(fullpath[i][0])
count=[]
for i in range(1,5):
    count.append(fullpath1.count(i))
if count.count(1)==2 and count.count(2)==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
if cnt[0] == 1 and cnt[1] == 2 and cnt[2] == 2 and cnt[3] == 1:
    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
if cnt[0] == 1 and cnt[1] == 2 and cnt[2] == 2 and cnt[3] == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import itertools
import collections
l=[list(map(int,input().split())) for _ in range(3)]
l=list(itertools.chain(*l))
c=collections.Counter(l)
if sorted(list(c.values()))==[1,1,2,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())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1

one = 0
two = 0
for i in range(4):
    if cnt[i] == 1:
        one += 1
    elif cnt[i] == 2:
        two += 1
if one == two and one == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

even = 0
for i in range(4):
    if town[i]%2 == 0:
        even += 1

if even == 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())

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

import collections
L=collections.Counter(A)

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

Submission status: Accepted

Solution code:
vis = [0]*4

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

cnt1 = vis.count(1)
cnt2 = vis.count(2)

if cnt1 == 2 and cnt2 == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

if 3 in L:
    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())
L=[a,b,c,d,e,f]
R=set(L)
if len(R)==4 and L.count(1)<3 and L.count(4)<3 and L.count(3)<3 and L.count(2)<3:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
check = []
for i in range(3):
    a,b = map(int,input().split())
    check.append(a)
    check.append(b)
if check.count(1) == 1 and check.count(2) == 2 and check.count(3) == 2 and check.count(4) == 1: 
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

n = [0]*4

for i in lis:
    n[i[0]-1] += 1
    n[i[1]-1] += 1

for j in n:
    if j >=3 or j ==0:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
import sys
from collections import Counter
def main():
    read = sys.stdin.read
    A = map(int, read().split())
    c = Counter(A).most_common()[0][1]
    print('YES') if c == 2 else print('NO')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import collections
import bisect


def main():
    k = [list(map(int, input().split())) for _ in range(3)]

    c = collections.Counter(k[0] + k[1] + k[2])
    print('YES' if sorted(c.values()) == [1, 1, 2, 2] else 'NO')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

    ans = 'YES'
    for k, v in cnt.items():
        if v > 2:
            ans = 'NO'
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 'YES'
for k, v in cnt.items():
    if v > 2:
        ans = 'NO'
        break

print(ans)

Submission status: Accepted

Solution code:
l = []

for _ in range(3):
    l += list(map(int, input().split()))

for i in range(4):
    if l.count(i + 1) == 3:
        print('NO')
        break
else:
    print('YES')