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())
d = {1:0, 2:0, 3:0, 4:0}
d[a1] += 1
d[a2] += 1
d[a3] += 1
d[b1] += 1
d[b2] += 1
d[b3] += 1
if 3 in d.values():
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
import sys
ab = [list(map(int, input().split())) for _ in range(3)]
count = [0] * 5
for i in range(3):
    count[ab[i][0]] += 1
    count[ab[i][1]] += 1

for i in count:
    if i >= 3:
        print('NO')
        sys.exit(0)
print('YES')

Submission status: Accepted

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

l = []
for i in range(3):
  n,m = IL()
  l.append(n)
  l.append(m)

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

if a == 1 and b == 2 and c == 2 and d == 1:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
import math

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

c.sort()
# print(c)

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

Submission status: Accepted

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

n = [0]*4

for d in data:
    for dd in d:
        n[dd-1] += 1

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

Submission status: Accepted

Solution code:
n1,k1=map(int,input().split())
n2,k2=map(int,input().split())
n3,k3=map(int,input().split())
a=[0,0,0,0,0]
a[n1]+=1
a[n2]+=1
a[n3]+=1
a[k1]+=1
a[k2]+=1
a[k3]+=1
if a[4]==3 or a[1]==3 or a[2]==3 or a[3]==3 :
    print("NO")
else:
    print("YES")

Submission status: Accepted

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

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

flag = -1

for i in range(4):
    if now[i]==1:
        f1 += 1
    elif now[i]==2:
        f2 += 1

if f1==2 and f2==2:
    flag = 1
    
if flag>0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(1,5) :
    if L.count(i) >= 3 :
        ans = "NO"
        break
else :
    ans = "YES"

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
cnt = [0] * 4
for i in range(3):
    a, b = map(lambda x: int(x) - 1, input().split())
    cnt[a] += 1
    cnt[b] += 1
ans = all(x < 3 for x in cnt)
print(['NO', 'YES'][ans])

Submission status: Accepted

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

num_odd = sum([d % 2 for d in dim])
if num_odd in [0, 2]:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
L = []
for i in range(3):
  L.extend(list(map(int, input().split())))
check = []
for i in range(4):
  check.append(L.count(i+1))
if max(check)>2:
  print("NO")
else:
  print("YES")

Submission status: Accepted

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

c = a + b
from collections import Counter
cnt = Counter(c).most_common()
if cnt[0][1] == 2 and cnt[1][1] == 2 and cnt[2][1] == 1 and cnt[3][1] == 1:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x1 = list(map(int,input().split()))
x2 = list(map(int,input().split()))
x3 = list(map(int,input().split()))
x1.sort()
x2.sort()
x3.sort()
count = []
for i in range(5):
  count.append(x1.count(i)+x2.count(i)+x3.count(i))
if max(count)>2:
  print("NO")
  exit()
if x1==x2 or x2==x3 or x3==x1:
  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())
count = [0, 0, 0, 0]
count[a1 - 1] += 1
count[a2 - 1] += 1
count[a3 - 1] += 1
count[b1 - 1] += 1
count[b2 - 1] += 1
count[b3 - 1] += 1
if 3 in count:
    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())
cnt=[0]*4
cnt[a-1]+=1
cnt[b-1]+=1
cnt[c-1]+=1
cnt[d-1]+=1
cnt[e-1]+=1
cnt[f-1]+=1
if max(cnt)<3:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

A = [a, b, c, d, e, f]
count= 0
for i in range(0, 5):
    ind = A.count(i)
    if(ind == 2):
        count+=1
if(count == 2):
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

if(3 in lis):print("NO")
else:print("YES")

Submission status: Accepted

Solution code:
N = 4
M = 3
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    A += [a]
    B += [b]

ans = False


def dfs(v, S):
    global ans
    # print(v, S)
    if len(S) == N:
        ans = True

    for i in range(M):
        if v == A[i] and B[i] not in S:
            t = set(S)
            t.add(B[i])
            dfs(B[i], t)
        if v == B[i] and A[i] not in S:
            t = set(S)
            t.add(A[i])
            dfs(A[i], t)

dfs(1, set([1]))
if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
ab=[list(map(int, input().split())) for _ in range(3)]
tmp=[0]*4
for i in range(3):
    tmp[ab[i][0]-1]+=1
    tmp[ab[i][1]-1]+=1
tmp2=sorted(tmp)
print("YES" if tmp2==[1, 1, 2, 2] else "NO")

Submission status: Accepted

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


def main():
    a1, b1 = list(map(int, input().split()))
    a2, b2 = list(map(int, input().split()))
    a3, b3 = list(map(int, input().split()))
    l = [0 for _ in range(5)]
    l[a1] += 1
    l[b1] += 1
    l[a2] += 1
    l[b2] += 1
    l[a3] += 1
    l[b3] += 1
    for n in range(1, 5):
        if l[n] == 0 or l[n] == 3:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

ab = []

for i in range(0, 3):
    ai, bi = [int(_) for _ in input().split()]
    ab.append(ai)
    ab.append(bi)

c = Counter(ab)
lis = sorted(list(c.values()))
if lis[0] == 1 and lis[1] == 1 and lis[2] == 2 and lis[3] == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


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


def read_str_n():
    return list(map(str, input().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(AB):
    c = Counter()
    for a, b in AB:
        c[a] += 1
        c[b] += 1
    
    return 'YES' if c[c.most_common()[0][1]] == 2 else 'NO'


def main():
    AB = [read_int_n() for _ in range(3)]
    print(slv(AB))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = 4


def main():
    deg = [0] * N
    for _ in range(N - 1):
        a, b = (int(z) - 1 for z in input().split())
        deg[a] += 1
        deg[b] += 1
    num_even = sum(d % 2 == 0 for d in deg)
    num_odd = N - num_even
    if num_odd == 0 or num_odd == 2 and num_even == N - 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=[0]*4
for i in range(3):
    a,b=map(int,input().split())
    s[a-1]+=1
    s[b-1]+=1
s.sort()
print("NO" if s[:2]!=[1,1] or s[2:]!=[2,2] else "YES")

Submission status: Accepted

Solution code:
p = []
for _ in range(3):
  a,b = list(map(int, input().split()))
  p.append(a)
  p.append(b)
f = True
for c in list(set(p)):
  if p.count(c) == 3:
    f = False
print('YES' if f else 'NO')

Submission status: Accepted

Solution code:

a,b = map(int,input().split(" "))
c,d = map(int,input().split(" "))
e,f = map(int,input().split(" "))

dic = {1:0,2:0,3:0,4:0}
dic[a] += 1
dic[b] += 1
dic[c] += 1
dic[d] += 1
dic[e] += 1
dic[f] += 1

for key , val in dic.items():
    if val == 0 or val >= 3:
        print("NO")
        exit(0)

print("YES")

Submission status: Accepted

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

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

print('YES' if max(array) == 2 else 'NO')

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(3):
  D = list(map(int, input().split()))
  Data[D[0] - 1] += 1
  Data[D[1] - 1] += 1

if 0 in Data or 3 in Data:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
import sys, os

def main():
	arr = [0,0,0,0]
	for _ in range(3):
		a,b = map(int, input().split())
		arr[a-1] += 1
		arr[b-1] += 1
	flg = True
	for i in range(4):
		if arr[i] is 3:
			flg = False
		if arr[i] is 0:
			flg = False
	print("YES" if flg else "NO")
	return

main()

Submission status: Accepted

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

s = [0, 0, 0, 0]

s[a-1]+= 1
s[b-1] += 1
s[c-1] += 1
s[d-1] += 1
s[e-1] += 1
s[f-1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

d= {}
d[1] = 0
d[2] = 0
d[3] = 0
d[4] = 0
for tmp in ab:
    d[tmp[0]] += 1
    d[tmp[1]] += 1
if max(d.values()) > 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
# import numpy as np

# import sys
# sys.setrecursionlimit(200000)

from collections import Counter


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

c = Counter([a1, b1, a2, b2, a3, b3])

if c.most_common(1)[0][1] == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

for i in range(3):
    a,b=map(int,input().split())
    L[a]+=1
    L[b]+=1
    
if max(L)==2:
    print("YES")
else:
    print("NO")

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

odd_count = 0
for l in L:
    if l % 2 == 1:
        odd_count += 1

if odd_count not in (0, 2):
    print("NO")
else:
    print("YES")

Submission status: Accepted

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

Submission status: Accepted

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

haji = [0,0,0,0]
for i in range(3):
  haji[a[i]] += 1
  haji[b[i]] += 1
  
cont = 0
for p in haji:
  if p == 1:cont+=1
if cont ==2:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
# encoding: utf-8
ab = [list(map(int, input().split())) for i in range(3)]

tab = [0] * 4
for ai, bi in ab:
    tab[ai - 1] += 1
    tab[bi - 1] += 1

if 0 in tab: print('NO')
elif 3 in tab: print('NO')
else: print('YES')

Submission status: Accepted

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

d = {i:0 for i in range(4)}

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

if max(d.values()) == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    a1,b1 = map(int, input().split())
    a2,b2 = map(int, input().split())
    a3,b3 = map(int, input().split())
    ans = [0,0,0,0]
    ans[a1-1]+=1
    ans[b1-1]+=1
    ans[a2-1]+=1
    ans[b2-1]+=1
    ans[a3-1]+=1
    ans[b3-1]+=1
    if max(ans)==3:
        print('NO')
    else:
        print('YES')

Submission status: Accepted

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

cnt = 0
for x in vec:
    if x%2==1:
        cnt+=1

if cnt >2:
    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())

li = []
li.append(a1)
li.append(a2)
li.append(a3)
li.append(b1)
li.append(b2)
li.append(b3)

if li.count(1)>=3 or li.count(2)>=3 or li.count(3)>=3 or li.count(4)>=3:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)


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


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


for i in [a, b, c, d, e, f]:
    count[i] += 1

count_list = []
for key in count.keys():
    count_list.append(count[key])

m = max(count_list)
if m >= 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
c = [0]*4
for i in xrange(3):
  ai, bi = map(int, raw_input().split())
  c[ai-1] += 1
  c[bi-1] += 1
r = "YES"
for j in xrange(4):
  if c[j]>=3:
    r = "NO"
print r

Submission status: Accepted

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

city.pop(0)
city=sorted(city)
if city==[1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
d = [0] * 4
for i in xrange(3):
    a, b = map(int, raw_input().split())
    d[a-1] += 1
    d[b-1] += 1
t = 0
for x in d:
    t += x % 2
print "YES" if t <= 2 else "NO"

Submission status: Accepted

Solution code:
A = [ list( map( int, input().split())) for _ in range(3)]
ans = "YES"
for t in range(1,5):
    for i in range(3):
        if A[i][1] == t or A[i][0] == t:
            pass
        else:
            break
    else:
        ans = "NO"
print(ans)

Submission status: Accepted

Solution code:
from sys import stderr, setrecursionlimit
setrecursionlimit(2147483647)
def getInt():
    return int(input())
def getInts():
    return [int(i) for i in input().split()]
def getIntLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInt())
    return res
def getIntsLines(n=1):
    res = []
    for _ in range(n):
        res.append(getInts())
    return res
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

a1,b1 = getInts()
a2,b2 = getInts()
a3,b3 = getInts()
towns = [a1,a2,a3,b1,b2,b3]
print("YES" if all([towns.count(i) <=2 for i in range(1,5)]) else "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()))

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

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

Submission status: Accepted

Solution code:

def main():
    a = []
    b = []
    for i in range(3):
        buf = input()
        buflist = buf.split()
        a.append(int(buflist[0]))
        b.append(int(buflist[1]))
    count = [0, 0, 0, 0]
    for i in a:
        count[i-1] += 1
    for i in b:
        count[i-1] += 1
    for i in count:
        if i >= 3:
            print("NO")
            return
    print("YES")

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
if x.count(1)==2 and x.count(2)==2:print('YES')
else:print('NO')

Submission status: Accepted

Solution code:
ab = [list(map(int,input().split())) for i in range(3)]
num = [0,0,0,0]
for i in range(3):
    num[ab[i][0]-1]+=1
    num[ab[i][1]-1]+=1
if max(num) == 2 and min(num) == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


G = [[] for _ in range(4)]
for i in range(3):
    a, b = LI_()
    G[a].append(b)
    G[b].append(a)

for v in G:
    if len(v) % 2 == 0:
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
a = []
a += list(map(int, input().split()))
a += list(map(int, input().split()))
a += list(map(int, input().split()))

for i in range(1, 5):
    c = a.count(i)
    if c == 0 or c >= 3:
        print("NO")
        exit(0)

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]

for i in range(1, 5):
  if l.count(i) == 3:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
from collections import Counter
# N,M = map(int, input().split())
a = [ [int(a) for a in input().split()] for _ in range(3)]
b = sum(a, [])

# print(b)
b = Counter(b)

if b.most_common()[0][1] >= 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
AB = [[int(_) for _ in input().split()] for _ in range(3)]
count = [0] * 5
for a, b in AB:
    count[a] += 1
    count[b] += 1
if sorted(count[1:]) == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

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

if max(cnt) < 3:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L=[0 for i in range(4)]
for i in range(3):
    a,b=map(int,input().split())
    L[a-1]+=1
    L[b-1]+=1
X=sorted(L)
Y=[1,1,2,2]
for i in range(4):
    if X[i]!=Y[i]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
li =[0]*4
for i in range(3):
  l =[int(i) for i in input().split()]
  for i in l:
    li[i-1] += 1

foo = 0
for i in li:
  if i%2!=0:
    foo += 1
if foo >2:
  print("NO")
else:
  print("YES")

Submission status: Accepted

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

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

Submission status: Accepted

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

from collections import deque
import heapq
import math
import bisect


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

    if 3 in cnt:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Deg=[0 for i in range(4)]
for a in A:
    Deg[a-1]+=1
for b in B:
    Deg[b-1]+=1
if min(Deg)==1 and max(Deg)==2:
    print "YES"
else:
    print "NO"

Submission status: Accepted

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

if c.most_common()[0][1] > 2:
    print('NO')
else:
    print('YES')

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
ans = "YES"
for e in cnt:
    if e >= 3:
        ans = "NO"
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

for k, v in items.items():
    if v >= 3:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

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

A=[0]*4

for a,b in R:
    A[a-1]+=1
    A[b-1]+=1

if max(A)==2 and min(A)==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from itertools import permutations

AB = [map(int, raw_input().split()) for _ in xrange(3)]

for p in permutations(range(3)):
    e1 = AB[p[0]]
    e2 = AB[p[1]]
    e3 = AB[p[2]]
    for p1 in permutations(e1):
        for p2 in permutations(e2):
            for p3 in permutations(e3):
                if p1[1] == p2[0] and p2[1] == p3[0] and p1[0] != p3[1]:
                    print "YES"
                    exit()

print "NO"

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
degree = [ 0 ] * 4
for _ in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    degree[a] += 1
    degree[b] += 1
odd = len(list(filter(lambda x: x % 2 == 1, degree)))
print(['NO', 'YES'][odd <= 2])

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

l = sorted(l)
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:
import math
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

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

def get_int_list():
    return list(map(int, input().split()))

def mins(x, y):
    x = min(x, y)

def maxs(x, y):
    x = max(x, y)

while(True):
    try:
        cnt = [0] * 5
        for i in range(3):
            a, b = get_int_list()
            cnt[a] += 1
            cnt[b] += 1
        if cnt.count(2) == 2:
            print("YES")
        else:
            print("NO")
    except EOFError:
        exit()

Submission status: Accepted

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

path = [0,0,0,0]
for i in range(3):
    a,b = getMN()
    path[a-1] += 1
    path[b-1] += 1

if max(path) <= 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 = [0 for _ in [0]*4]

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

P = max(A)

if P > 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
data=[]
for i in range(3):
    a,b=map(int,input().split())
    data.append(a)
    data.append(b)
data.sort()
if data==[1,2,2,3,3,4]:
    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)

# print(list)
cnt = [list.count(i) for i in range(1,5)]
cnt = sorted(cnt)
if cnt == [1,1,2,2]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())

c = [0] * 5
for i in range(3):
    a, b = mi()
    c[a] += 1
    c[b] += 1
print('YES' if c.count(1) == 2 else 'NO')

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter()
for _ in range(3):
	a, b = map(int, input().split())
	c[a] += 1
	c[b] += 1
one, two = 0, 0
for i in range(1, 5):
	if c[i] == 1:
		one += 1
	elif c[i] == 2:
		two += 1
if (one, two) == (2, 2):
	print("YES")
else:
	print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    c = Counter()
    for _ in range(3):
        i, j = MI()
        c[i] += 1
        c[j] += 1
    return c.most_common(1)[0][1] == 2


if __name__ == "__main__":
    YESNO(main())

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
a = [0]*4
for i in range(3):
    n,m = map(int,input().split())
    n-=1;m-=1
    a[n] += 1
    a[m] += 1
a.sort()
if a == [1,1,2,2]:
    print("YES")
else:
    print("NO")

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():
    c = collections.defaultdict(int)
    for _ in range(3):
        a,b = LI()
        c[a] += 1
        c[b] += 1
    if max(c.values()) == 3:
        return 'NO'

    return 'YES'



print(main())