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:
# 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, 5):
		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: Accepted

Solution code:
"""

問題文

4 つの街があり、順に 1,2,3,4 と番号が付いています。 道が 3 本あり、i 本目の道は異なる街 ai,bi を双方向に結んでいます。 同じ街の対の間を結ぶ道が複数あることはありません。街同士を行き来する手段は、道以外にはありません。 どの 2 つの街の間も、道を何本か通ることで行き来することができます。

すべての道をちょうど 1 回ずつ通ることですべての街を訪れることが可能かどうか判定してください。
制約

    1≤ai,bi≤4(1≤i≤3)
    ai と bi は異なる (1≤i≤3)
    同じ街の対の間を結ぶ道は複数存在しない
    どの 2 つの街の間も、道を何本か通ることで行き来することができる
"""

def func(a_list , b_list) : 
    dic = {}
    for a in a_list : 
        if not a in dic : 
            dic[a] = 1
        else : 
            dic[a] += 1
    
    for b in b_list : 
        if not b in dic : 
            dic[b] = 1
        else : 
            dic[b] += 1

    cnt = 0
    for key in dic : 
        if dic[key] == 1: cnt += 1
    if cnt == 3: 
        return "NO"
    else : 
        return "YES"


if not func([4 , 1, 2], [2 , 3, 3]) == "YES" : 
    raise Exception("test 1 fail")

if not func([3 , 2, 1], [2 , 4, 2]) == "NO" : 
    raise Exception("test 2 fail")

if not func([2 , 3, 4], [1 , 2, 3]) == "YES" : 
    raise Exception("test 3 fail")

a_list = []
b_list = []
for i in range(3) : 
    s = input().split(" ")
    a_list.append(int(s[0]))
    b_list.append(int(s[1]))
print(func(a_list , b_list))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = [0]*4

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

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

Submission status: Accepted

Solution code:
a=input()
a_1=int(a.split()[0])
b_1=int(a.split()[1])
a=input()
a_2=int(a.split()[0])
b_2=int(a.split()[1])
a=input()
a_3=int(a.split()[0])
b_3=int(a.split()[1])

num=[]
num.append(a_1)
num.append(a_2)
num.append(a_3)
num.append(b_1)
num.append(b_2)
num.append(b_3)

count_a=0
count_b=0
count_c=0
count_d=0

for i in(num):
  if(i==1): count_a+=1
  elif(i==2): count_b+=1
  elif(i==3): count_c+=1
  elif(i==4): count_d+=1

if(count_a>2 or count_b>2 or count_c>2 or count_d>2):
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
path = []
for _ in [0]*3:
    path.extend(input().split())

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

Submission status: Accepted

Solution code:
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(inputArr1(3))


def func():
    if (n[0][0] in n[1] and n[0][0] in n[2]) or (n[0][1] in n[1] and n[0][1] in n[2]):
        return "NO"
    return "YES"
    
print(func())

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
lis=[a,b,c,d,e,f]
#print(lis)
a=lis.count(1)
b=lis.count(2)
c=lis.count(3)
d=lis.count(4)
kekka=[a,b,c,d]
a=kekka.count(1)
b=kekka.count(2)

if a!=2 and b!=2 :
    print("NO")
else:
    print("YES")

Submission status: Accepted

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

Solution code:
li = list(map(int,input().split()))
li.extend(list(map(int,input().split())))
li.extend(list(map(int,input().split())))

num = []
for i in range(1,5):
    num.append(li.count(i))

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

Submission status: Accepted

Solution code:
a = []
b = []

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

for i in range(3):
    for j in range(3):
        if not i == j:
            for k in range(3):
                if not j == k:
                    if not i == k:
                        if a[i] == a[j]:
                            if (b[j] == a[k]) or (b[j] == b[k]):
                                print("YES")
                                quit()
                        if a[i] == b[j]:
                            if (a[j] == a[k]) or (a[j] == b[k]):
                                print("YES")
                                quit()
                        if b[i] == a[j]:
                            if (b[j] == a[k]) or (b[j] == b[k]):
                                print("YES")
                                quit()
                        if b[i] == b[j]:
                            if (a[j] == a[k]) or (a[j] == b[k]):
                                print("YES")
                                quit()

print("NO")

Submission status: Accepted

Solution code:
a = []
b = []
c = [0,0,0,0]
for i in range(3):
  ab = list(map(int,input().split()))
  a.append(ab[0])
  b.append(ab[1])
  a.append(ab[1])
  b.append(ab[0])
  c[ab[0]-1] += 1
  c[ab[1]-1] += 1
k = c.index(1)+1
for i in range(3):
  if k in a:
    j = a.index(k)
    k = b[j]
    a.pop(j)
    a.pop(j+-1*(j%2))
    b.pop(j)
    b.pop(j+-1*(j%2))
  else:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
import collections

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

N = []
N.extend([a,b,c,d,e,f])

k = collections.Counter(N)

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

Submission status: Accepted

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

point = [0, 0, 0, 0]
for town in p:
    point[town-1] += 1
    if point[town-1] > 2:
        print('NO')
        quit()

print('YES')

Submission status: Accepted

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

dic = {}

for i in li:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

dicc = {}
for i in dic.values():
    if i in dicc.keys():
        dicc[i] += 1
    else:
        dicc[i] = 1

if dicc[1] == 2 and dicc[2] == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

n = 1
v = [1,0,0,0]
for k in range(10):
    for e in L:
        if e[0] == n and v[e[1]-1] == 0:
            n = e[1]
            v[e[1]-1] = 1
        elif e[1] == n and v[e[0]-1] == 0:
            n = e[0]
            v[e[0]-1] = 1

if min(v) == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

def main():
    """Function."""
    p1 = list(map(int, input().split()))
    p2 = list(map(int, input().split()))
    p3 = list(map(int, input().split()))

    counter = [0, 0, 0, 0]
    for l in [p1, p2, p3]:
        for i in l:
            if i == 1:
                counter[0] += 1
            elif i == 2:
                counter[1] += 1
            elif i == 3:
                counter[2] += 1
            elif i == 4:
                counter[3] += 1

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

cnt = [0] * 4
cnt[a1-1] += 1
cnt[b1-1] += 1
cnt[a2-1] += 1
cnt[b2-1] += 1
cnt[a3-1] += 1
cnt[b3-1] += 1

flag = True
for c in cnt:
    if c == 0 or c > 2:
        flag = False
        break

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

Submission status: Accepted

Solution code:
l = []

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

d = {}
for aa,bb in l:
    if aa not in d.keys():
        d[aa] = 0
    if bb not in d.keys():
        d[bb] = 0
    d[aa] += 1
    d[bb] += 1

for i in d.values():
    if i >= 3:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
    a.extend(list(map(int, input().split())) )
    
count_list =sorted([a.count(i) for i in range(1, 5)])

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

Submission status: Accepted

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

for i in range(1,5):
  if p.count(i) > 2:
    print('NO')
    break
else:
  print('YES')

Submission status: Accepted

Solution code:
adj = [[0 for _ in range(4)] for _ in range(4)]
for i in range(3):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a][b] = 1
    adj[b][a] = 1
for i in range(4):
    for j in range(4):
        if i == j:
            continue
        for k in range(4):
            if i == k or j == k:
                continue
            for l in range(4):
                if i == l or j == l or k == l:
                    continue
                elif adj[i][j] == 1 and adj[j][k] == 1 and adj[k][l] == 1:
                    print("YES")
                    exit()
print("NO")

Submission status: Accepted

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

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

    towns[a] += 1
    towns[b] += 1

result = True

for town in towns.values():
    if town > 2:
        result = False

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

Submission status: Accepted

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

li = []
for i in ab:
    for j in i:
        li.append(j)
res =0
for i in range(1,4):
    if(li.count(i)==2):
        res+=1

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

Submission status: Accepted

Solution code:
a1, b1 = (int(i) for i in input().split())
a2, b2 = (int(i) for i in input().split())
a3, b3 = (int(i) for i in input().split())
list = [a1, b1, a2, b2, a3, b3]
count_list = [list.count(i) for i in range(1,5)]
if 3 in count_list:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
d = {}
for i in range(3):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)

    if b not in d:
        d[b] = [a]
    else:
        d[b].append(a)

ans = True
for a in range(1, 5):
    if len(d[a]) >= 3:
        ans = False
if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

if set(paths) != set([1, 2, 3, 4]):
    print("NO")
elif paths.count(1) >= 3 or paths.count(2) >= 3 or paths.count(3) >= 3 or paths.count(4) >= 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
import collections


points = []

for i in range(0, 3):
    p1, p2 = map(int, input().split(' '))
    points.extend([p1, p2])

counter = collections.Counter(points)
num_mode = counter.most_common(1)[0][1]
# print(num_mode)

if num_mode >= 3:
    print("NO")
else:
    print("YES")

exit(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in a:
    x[i-1] += 1

f = 0
for i in range(4):
    if x[i] in [1, 2]:
        f += 1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# 2019/02/09
# Minnano Procon 2019 - B

# Input
cnt = [0, 0, 0, 0]
for i in range(3):
    a, b = list(map(int,input().split()))
    cnt[a-1] += 1
    cnt[b-1] += 1
    
# Check cnt
cnt_1 = 0
cnt_2 = 0

for i in range(3):
    if cnt[i] == 1:
        cnt_1 += 1
    elif cnt[i] == 2:
        cnt_2 += 1

if cnt_1 == 1 and cnt_2 == 2:
    ans = "YES"
else:
    ans = "NO"

# Output
print(ans)

Submission status: Accepted

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(4):
    if B[i] == 3 or B[i] == 0:
        flag = False
        break
    else:
        flag = True

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

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
li = li + list(map(int,input().split()))
li = li + list(map(int,input().split()))
a = li.count(1)
b = li.count(2)
c = li.count(3)
d = li.count(4)
if 1<=a<=2 and 1<=b<=2 and 1<=c<=2 and 1<=d<=2:
    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()))
d = [x for x in a]
d.extend(b)
d.extend(c)
d.sort()
li = [d.count(i+1) for i in range(4) ]
if max(li)>=3 or min(li)==0:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
l=[]
for i in range(3):
  a,b=map(int,input().split())
  l+=[a,b]
c =Counter(l)
if all(c[i]<3 for i in range(1,5)):
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

a = Counter(t).most_common()
if len(a) < 4:
    print("NO")
else:
    for i in range(4):
        if i <= 1:
            if a[i][1] == 2:
                continue
            else:
                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())
ab = [a1, b1, a2, b2, a3, b3]
one = 0
two = 0
for i in range(1, 5, 1):
    if ab.count(i) == 1:
        one += 1
    elif ab.count(i) == 2:
        two += 1
print("YES" if one == 2 and two == 2 else "NO")

Submission status: Accepted

Solution code:
#入力に1~4が現れる回数
counter = [0,0,0,0]

#入力をリストに格納していく
ip = []
a1, b1 = map(int,input().split())
ip.append(a1)
ip.append(b1)
a2, b2 = map(int,input().split())
ip.append(a2)
ip.append(b2)
a3, b3 = map(int,input().split())
ip.append(a3)
ip.append(b3)

#数字ごとの出現回数をカウント
for city in ip:
    counter[city - 1] += 1

#3回現れる数字があればX
counter.sort()
if counter[3] == 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

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

if c==a or d==a:
    if a==e or a==f:
        print("NO")
    else:
        print("YES")
elif c==b or d==b:
    if b==e or b==f: 
        print("NO")
    else:
        print("YES")
else:
    print("YES")

Submission status: Accepted

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

num_1_set = set()
for i in range(4):
    if num[i] == 1:
        num_1_set.add(i+1)

ans = 'NO'
for a, b in path:
    if a != b:
        if a not in num_1_set and b not in num_1_set:
            ans = 'YES'
            break
print(ans)

Submission status: Accepted

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 and c != 2: continue
    time[c - 1] += 1

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

print(solve())

Submission status: Accepted

Solution code:
AB = [input() for _ in range(3)]

AB = list(map(int, ' '.join(AB).split()))

c = [0] * 4

for ab in AB:
    c[ab-1] += 1

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

Submission status: Accepted

Solution code:
a = [[int(i) for i in input().split()] for j in range(3)]
c = [0,0,0,0]
for i in range(3):
    for j in range(2):
        c[a[i][j]-1] += 1
r = "YES"
for i in range(4):
    if c[i]>=3:
        r="NO"
        break
print(r)

Submission status: Accepted

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

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

if path.count(1) <=2 and path.count(2) <=2 and path.count(3) <=2 and path.count(4) <=2 :
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
AB = []
for i in range(3):
    a,b = map(int, input().split())
    AB.append((min(a,b),max(a,b)))

AB = sorted(AB)

if 1 in AB[0]:
    tmp = AB
    ne = AB[0][1]
    AB = AB[1:]
else:
    print('NO')
    exit()

a = AB[0][0]
b = AB[0][1]

c = AB[1][0]
d = AB[1][1]

if ne == a or ne == b:
    if ne == a:
        ne = b
    elif ne == b:
        ne = a

    if ne == c or ne == d:
        ans = 'YES'
    else:
        ans = 'NO'

elif ne == c or ne == d:
    if ne == c:
        ne = d
    elif ne == d:
        ne = c

    if ne == a or ne == b:
        ans = 'YES'
    else:
        ans = 'NO'

else:
    ans = 'NO'

print(ans)

Submission status: Accepted

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,5):
#    print(i)
    if lst.count(i) > 2:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
ab1 = [int(i) for i in input().split()]
ab2 = [int(i) for i in input().split()]
ab3 = [int(i) for i in input().split()]

node = [0, 0, 0, 0]
for i in [ab1, ab2, ab3]:
    for j in i:
        node[j-1] += 1
if max(node) == 2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
a = input()
b = input()
c = input()

d = a + b + c
result = "YES"
for i in ["1", "2", "3", "4"]:
    if d.count(i) == 3:
        result = "NO"
print(result)

Submission status: Accepted

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

for i in range(6):
  d[c[i]-1]+=1
d.sort()
if d==[1,1,2,2]:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
a=[0]*5
count=0
for x in range(3):
    for y in input().split():
        a[int(y)]+=1
for p in a:
    if(p==1):
        count+=1
if(count>=3):
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
cnt = [0 for i in xrange(5)]

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

x = 0
y = 0
for i in xrange(1,5):
	if cnt[i] == 1:
		x += 1
	elif cnt[i] == 2:
		y += 1

if x == y and x == 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 = []
l.append(a1)
l.append(b1)
l.append(a2)
l.append(b2)
l.append(a3)
l.append(b3)
cnt1 = l.count(1)
cnt2 = l.count(2)
cnt3 = l.count(3)
cnt4 = l.count(4)

if cnt1 >= 3 or cnt2 >= 3 or cnt3 >= 3 or cnt4 >= 3  :
    print('NO')
else:
    print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Solve(graph):
    one = 0
    two = 0
    for i in graph:
        if len(graph[i]) == 1:
            one += 1
        elif len(graph[i]) == 2:
            two += 1

    if one == two:
        return 'YES'
    return 'NO'
        

def main():
    graph = {}
    for i in range(1,5):
        graph[i] = []
        
    a1,b1 = map(int,input().split())
    a2,b2 = map(int,input().split())
    a3,b3 = map(int,input().split())

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

    print (Solve(graph))

main()

Submission status: Accepted

Solution code:
a = [0] * 6
for i in range(3):
    a[2 * i], a[2 * i + 1] = map(int, input().split())
for i in range(4):
    if a.count(i + 1) == 3:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

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

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

  for i in range(4):
    if (2 < C[i]):
      print('NO')
      return

  print('YES')

main()

Submission status: Accepted

Solution code:
r = list(map(int,input().split()))
r = r + list(map(int,input().split()))
r = r + list(map(int,input().split()))
flag = True
for i in [1,2,3,4]:
    n = r.count(i)
    if n == 3:
        flag = False
if flag:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:

  
# Driver code 
  
# Create a graph given in 
# the above diagram 

from collections import defaultdict as df
g=df(list)
for i in range(3):
    a,b=list(map(int,input().split()))
    g[a].append(b)
    g[b].append(a)
count1=0
count2=0
for i in g:
    if len(g[i])==2:
        count2+=1
    elif len(g[i])==1:
        count1+=1
if count2==2 and count1==2:
    print('YES')
else:
    print('NO')

  
# This code is contributed by Neelam Yadav

Submission status: Accepted

Solution code:
import collections
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)

counter = [0] * 4
for i in range(3):
    a, b = map(int, input().rstrip().split())
    counter[a - 1] += 1
    counter[b - 1] += 1
if compare(counter, [1, 1, 2, 2]):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
X = []
for i in range(3):
  N = list(map(int, input().split()))
  X.extend(N)
# print(X)

import collections
c = collections.Counter(X)
# print(c)
X = list(c.values())
X = sorted(X)
if X == [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())
hoge=[]
no=0
hoge.append(A)
hoge.append(B)
hoge.append(C)
hoge.append(D)
hoge.append(E)
hoge.append(F)
if(hoge.count(1)==0):
  no=1
if(hoge.count(2)==0):
  no=1
if(hoge.count(3)==0):
  no=1
if(hoge.count(4)==0):
  no=1
if(hoge.count(1)==3):
  no=1
if(hoge.count(2)==3):
  no=1
if(hoge.count(3)==3):
  no=1
if(hoge.count(4)==3):
  no=1
if(no==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())

towns = [a1, b1, a2, b2, a3, b3]
res = True
for i in range(4):
    if towns.count(i+1) == 3:
        res = False

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

Submission status: Accepted

Solution code:
a = list(map(str,input().split()))
b = list(map(str,input().split()))
c = list(map(str,input().split()))
l = a + b + c
cnt = 0
for i in "1234":
    if l.count(i)==2:
        cnt += 1
if cnt==2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from collections import Counter
a,b = map(int,input().split())
c,d = map(int,input().split())
e,f = map(int,input().split())
if a != c and a != d and b != c and b!= d:
  print ("YES")
else:
  x = [a,b,c,d]
  x1 = Counter(x)
  y = x1.most_common()[0][0]
  if y != e and y != f:
    print ("YES")
  else:
    print ("NO")

Submission status: Accepted

Solution code:
"""
YESの条件

NOの条件
    数字が3個以上含まれる数列
    1,2,3,4のいずれがか含まれない数列

"""

n = 3
p = [list(map(int, input().split(" "))) for _ in range(n)]
p = p[0]+p[1]+p[2]


result = "YES"
for i in range(1,5):
    if 0 < p.count(i) < 3:
        pass
    else:
        result = "NO"
        break

print(result)

Submission status: Accepted

Solution code:
a = [None]*3
b = [None]*3

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

c = a
c.extend(b)

count = [str(c.count('1')),str(c.count('2')),str(c.count('3')),str(c.count('4'))]

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

Submission status: Accepted

Solution code:
#H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(3)]
#print(A)
A_flt = []
for s in A:
    A_flt.extend(s)
#print(A_flt)
import collections
A_cnt = collections.Counter(A_flt)
#print(A_cnt)
if A_cnt.most_common()[0][1] >= 3:
    print('NO')
else:
    print('YES')

Submission status: Accepted

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

for r1 in range(4):
    for r2 in range(4):
        if r1 == r2: continue
        if not e[r1][r2]: continue
        for r3 in range(4):
            if r3 == r1: continue
            if r3 == r2: continue
            if not e[r2][r3]: continue
            for r4 in range(4):
                if r4 == r1: continue
                if r4 == r2: continue
                if r4 == r3: continue
                if not e[r3][r4]: continue
                print('YES')
                exit()
print('NO')

Submission status: Accepted

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

for i in range(1,5):
	if L[i]==0 or L[i]==3:
		print "NO"
		quit()
else:
	print "YES"

Submission status: Accepted

Solution code:
import sys
import math

lines = sys.stdin.readlines()
a1, b1 = map(int, lines[0].split())
a2, b2 = map(int, lines[1].split())
a3, b3 = map(int, lines[2].split())

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

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

for k, v in dic.items():
  if 0 < v < 3:
    continue
  print('NO')
  exit(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())
d = [0,0,0,0]
d[a1-1] += 1
d[b1-1] += 1
d[a2-1] += 1
d[b2-1] += 1
d[a3-1] += 1
d[b3-1] += 1
r = sum([1 for x in d if x%2==1])
print("YES" if r == 0 or r == 2 else "NO")

Submission status: Accepted

Solution code:
from collections import defaultdict
l=[list(map(int, input().split())) for _ in range(3)]
dict=defaultdict(lambda: 0)
for i in l:
  dict[i[0]]+=1
  dict[i[1]]+=1

tmp=[]
for k in dict.keys():
  tmp.append(dict[k])

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

Submission status: Accepted

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

for i in range(1,5):
    count = 0
    for j in range(3):
        if i in A[j]:
            count += 1
    if count == 3:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
memo = [0] * 4

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

b = [0 for i in range(4)]
for i in range(6):
    b[a[i] - 1] += 1

if (max(b)) == 3:
    print('NO')
elif (min(b)) == 0:
    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())
l = [a1, a2, a3, b1, b2, b3]
if (1 <= l.count(1) and l.count(1) < 3) and (1 <= l.count(2) and l.count(2) < 3) and (1 <= l.count(3) and l.count(3) < 3) and (1 <= l.count(4) and l.count(4) < 3):
    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=[]
A.append(a1)
A.append(b1)
A.append(a2)
A.append(b2)
A.append(a3)
A.append(b3)
if A.count(a1)==3 or A.count(b1)==3:
    print("NO")
else:
    print("YES")