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:
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())
if a1+b1+a2+b2 == 10 or a2+b2+a3+b3 == 10 or a1+a2+a3+b3 == 10 or a1+b1+b2+b3 == 10 or a1+a2+b2+b3 == 10 or b1+b2+a2+a3 == 10:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
ds = {}
for i in range(3):
    s = input()
    ks = [int(i) for i in s.split(' ')]
    for k in ks:
        if k in ds:
            ds[k] += 1
        else:
            ds[k] = 1


for k in ds:
    if ds[k] == 3:
        print('NO')
print('YES')

Submission status: Wrong Answer

Solution code:
ds = {}
for i in range(3):
    s = input()
    n, k = [int(i) for i in s.split(' ')]
    
    if n in ds:
        ds[n] += 1
    else:
        ds[n] = 1

for k in ds:
    if ds[k] == 3:
        print('NO')
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
s += input()
s += input()

if(
    not(s.count("1")!=1 or s.count("1")!=2) or 
    not(s.count("2")!=1 or s.count("2")!=2) or
    not(s.count("3")!=1 or s.count("3")!=2) or
    not(s.count("4")!=1 or s.count("4")!=2)
    ) :
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
a_b=[]
a=[]
b=[]
judge=[]
judge_count=0
yes_no_count=0
for i in range(3):
    a_blank,b_blank=map(int,input().split())
    a.append(a_blank)
    b.append(b_blank)

a_b.extend(a)
a_b.extend(b)
for i in range(1,4+1):
    for j in a_b:
        if i==j:
            judge_count+=1
    judge.append(judge_count)
    judge_count=0

for i in judge:
    yes_no_count+=1
    if i==0 or i>=3:
        print("NO")
        break
    elif len(judge)==yes_no_count:
        print("YES")

print(yes_no_count)

Submission status: Wrong Answer

Solution code:
a_b=[]
a=[]
b=[]
judge=[]
judge_count=0
yes_no_count=1
for i in range(3):
    a_blank,b_blank=map(int,input().split())
    a.append(a_blank)
    b.append(b_blank)

a_b.extend(a)
a_b.extend(b)
for i in range(1,4+1):
    for j in a_b:
        if i==j:
            judge_count+=1
    judge.append(judge_count)
    judge_count=0

for i in judge:
    yes_no_count+=1
    if i==0 or i>=3:
        print("NO")
        break
    elif len(judge)==yes_no_count:
        print("YES")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

nums = [0 for _ in range(4)]

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

nums.sort()

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

Submission status: Wrong Answer

Solution code:
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
ans='YES'
for j in range(1,4):
  cnt=0
  for i in range(6):
    if c[i]==j:
      cnt+=1
  if cnt>2:
    ans='NO'
    break

print(ans)

Submission status: Wrong Answer

Solution code:
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
ans='YES'
for j in range(4):
  cnt=0
  for i in range(6):
    if c[i]==j:
      cnt+=1
  if cnt>2:
    ans='NO'
    break

print(ans)

Submission status: Wrong Answer

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

d=set()
d.add(c[4])
d.add(c[0])
d.add(c[2])
if len(d)==3:
  print('YES')
else:
  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())
if [a1, b1, a2, b2, a3, b3].count(1) == 3 or [a1, b1, a2, b2, a3, b3].count(2) == 3 or [a1, b1, a2, b2, a3, b3].count(3) == 3 or [a1, b1, a2, b2, a3, b3].count(4) == 3:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
c=[]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)
c=sorted(c)
if c[5]==c[3]:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ab = []
for i in range(3):
    ab.extend(list(map(int,input().split())))
    
    
for i in range(1,4):
    if ab.count(i) >= 3:
        print("NO")
        exit()
        
print("YES")

Submission status: Wrong Answer

Solution code:
s = []
for i in range(3):
  s.extend(input().split())

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

Submission status: Wrong Answer

Solution code:
print('YNEOS'[sum(map(int,open(0).read().split()))<15::2])

Submission status: Wrong Answer

Solution code:
s1 = input().split()
s2 = input().split()
s3 = input().split()
count = 0

for i in s2:
    if str(i) in str(s1):
        count += 1
        for j in s3:
            if str(j) in str(s1):
                count += 1
            else:
                pass
    else:
        pass
if count == 2:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s1 = input().split()
s2 = input().split()
s3 = input().split()
count = 0

for i in s2:
    if str(i) in str(s1):
        count += 1
        for j in s3:
            if str(j) in str(s1):
                count += 1
            else:
                pass
    else:
        pass
if count >= 3:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
ROADS = 3

range_city = list(range(1, 4+1))
appearance = []
for i in range(ROADS):
    a, b = map(int, input().split())
    appearance.append(a)
    appearance.append(b)

count = [appearance.count(city) for city in range_city]
if 2 <= max(count):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
ROADS = 3

range_city = list(range(1, 4+1))
appearance = []
for i in range(ROADS):
    a, b = map(int, input().split())
    appearance.append(a)
    appearance.append(b)

count = [appearance.count(city) for city in range_city]
if ROADS in count:
    print('YES')
else:
    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())


cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
    if not i+1 in [a1, a2, a3, b1, b2, b3]:
        print('NO')
        exit()

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

c = 0
for l in range(4):
    cnt = lis.count(l+1)
    if cnt > 1:
        c += 1

if c <= 2:
    print('NO')

print('YES')

Submission status: Wrong Answer

Solution code:
s1 =  input().split()
s2 = input().split()
s3 = input().split()
count = 0

for i in s2:
    if str(i) in str(s1):
        count += 1
        for j in s3:
            if str(j) in str(s1):
                count += 1
            else:
                pass
    else:
        pass
if count >= 2:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s1 = int, input().split()
s2 = input().split()
s3 = input().split()
count = 0

for i in s2:
    if str(i) in str(s1):
        count += 1
        for j in s3:
            if str(j) in str(s1):
                count += 1
            else:
                pass
    else:
        pass
if count >= 2:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
a1,b1 = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())
 
ne = [1,1,2,3,4]
count = [0,0,0,0,0]
ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a1,b1)] = ne[min(a1,b1)]
ne[max(a3,b3)] = ne[min(a3,b3)]
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a1,b1)] = ne[min(a1,b1)]
count[a1] += 1
count[b1] += 1
count[a2] += 1
count[b2] += 1
count[a3] += 1
count[b3] += 1
ne = set(ne)
ne = list(ne)
 
if len(ne) == 1 and (3 in count) == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
p = input().split()
q = input().split()
r = input().split()

list_a = p + q + r
list_b = list(map(int, list_a))
#print(list_b)
list_b.sort()


if list_b.count(1)>=3:
    print("NO")
elif list_b.count(2)>=3:
    print("NO")
elif list_b.count(3)>=3:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
# cook your dish here
a1,b1 = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())
 
ne = [1,1,2,3,4]
count = [0,0,0,0,0]
ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a1,b1)] = ne[min(a1,b1)]
ne[max(a3,b3)] = ne[min(a3,b3)]
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a1,b1)] = ne[min(a1,b1)]
count[a1] += 1
count[b1] += 1
count[a2] += 1
count[b2] += 1
count[a3] += 1
count[b3] += 1
ne = set(ne)
ne = list(ne)
 
if len(ne) == 1 and (3 in count) == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = [[0 for i in range(5)] for j in range(5)]

a[a1][b1] = 1
a[a2][b2] = 1
a[a3][b3] = 1
a[b1][a1] = 1
a[b2][a2] = 1
a[b3][a3] = 1


ver = [0 for i in range(5)]

def dfsr(a,s):
    
    for i in range(0,5):
        if a[s][i] == 1 and ver[i] == 0:
            s = i
            ver[s] += 1
            a[s][i] = 0
            a[i][s] = 0
            dfsr(a,s)

dfsr(a,a1)

if sum(ver) == 4:
    print("YES")
else :
    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())
 
ne = [1,1,2,3,4]
count = [0,0,0,0,0]
ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a3,b3)] = ne[min(a3,b3)]
count[a1] += 1
count[b1] += 1
count[a2] += 1
count[b2] += 1
count[a3] += 1
count[b3] += 1
ne = set(ne)
ne = list(ne)
 
if len(ne) == 1 and (3 in count) == 0:
  print('YES')
else:
  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())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if (l[i] == l[i+1]) and (l[i] == l[i+2]):
        x = False

print("YES" if x == True else "No")

Submission status: Wrong Answer

Solution code:
inputList = []
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())

one = 0
two = 0
three = 0
four = 0

for i in inputList:
    if i == 1:
        one = one + 1
    elif i == 2:
        two = two + 1
    elif i == 3:
        three = three + 1
    elif i == 4:
        four = four + 1

if one < 1 or one >= 3 or two < 1 or  two >= 3 or three < 1 or three >= 3 or four < 1 or four >= 3:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
inputList = []
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())
inputList.extend(int(i) for i in input().split())

one = 0
two = 0
three = 0
four = 0

for i in inputList:
    if i == 1:
        one = one + 1
    elif i == 2:
        two = two + 1
    elif i == 3:
        three = three + 1
    elif i == 4:
        four = four + 1

if one >= 3 or two >= 3 or three >= 3 or four >= 3:
    print('No')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
a1,b1 = map(int, input().split())
a2,b2 = map(int, input().split())
a3,b3 = map(int, input().split())
 
ne = [1,1,2,3,4]
 
ne[max(a1,b1)] = min(a1,b1)
ne[max(a2,b2)] = ne[min(a2,b2)]
ne[max(a3,b3)] = ne[min(a3,b3)]
 
ne = set(ne)
ne = list(ne)
 
if len(ne) == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

ways = [False] * 4


def f(now, count):
    if count > 4:
        return False
    for n in ab[now]:
        if ways[n - 1]:
            continue
        ways[n - 1] = True
        if all(ways):
            print("Yes")
            exit()
        f(n, count + 1)
        ways[n - 1] = False

for i in range(1, 5):
    ways = [False] * 4
    ways[i - 1] = True
    f(i, 1)
    ways[i - 1] = False
print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

a0,b0= map(int,input().split())
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())

a=[a0,a1,a2,b0,b1,b2]
ans = 0
for i in range(1,5):
	count = 0
	for j in a:
		if i == j:
			count += 1
	if count > 2:
		ans = 1
		
if ans == 1:
	print('YES')
else:
	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())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False

print("YES" if x == True else "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())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False
        break

for j in range(4):
    try:
        n = l.index(j+1)
    except ValueError:
        x = False


print("YES" if x == True else "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())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False
        break

for j in range(4):
    try:
        n = l.index(j+1)
    except ValueError:
        x = False


print("YES" if x == True else "No")

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 = a + b + c
if 1 in d and 2 in d and 3 in d and 4 in d:
    if a[0] in b and a[1] in b:
        if b[0] in c and b[1] in c:
            print("YES")
        else:
            print("NO")
    if a[0] in c and a[1] in c:
        if c[0] in b and c[1] in b:
            print("YES")
        else:
            print("NO")
        
    if c[0] in b and c[1] in b:
        if b[0] in a and b[1] in a:
            print("YES")
        else:
            print("NO")
    if c[0] in a and c[1] in a:
        if a[0] in b and a[1] in b:
            print("YES")
        else:
            print("NO")
        
    if b[0] in c and b[1] in c:
        if c[0] in a and c[1] in a:
            print("YES")
        else:
            print("NO")
    if b[0] in a and b[1] in a:
        if a[0] in c and a[1] in c:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
    
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
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]
flag = True

for i in range(1, 4):
    if not(1 <= l.count(i) and l.count(i) <= 2):
        flag = False

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

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False
        break

for j in range(4):
    try:
        n = l.index(j)
    except ValueError:
        x = False


print("YES" if x == True else "No")

Submission status: Wrong Answer

Solution code:
import copy
roads = []
roads2 = []
roads_stay = []
for s in range(3):
    a = [int(i) for i in input().split()]
    roads += [a]
    roads2 += [a]
    roads_stay += [a]

flag1 = False
flag2 = False
flag3 = False
flag4 = False

road = roads.pop(0)

visited = [road[0], road[1]]
tag = road[1]
for k in range(3):
    roads = copy.deepcopy(roads_stay)
    roads2 = copy.deepcopy(roads_stay)
    road = roads.pop(k)
    visited = [road[0], road[1]]
    tag = road[1]
    out = True
    while out:
        formers = [roads[i][0] for i in range(len(roads))]
        latters = [roads[i][1] for i in range(len(roads))]
        """
        print(visited)
        print(tag)
        print(formers)
        print(latters)
        print('\n\n\n')
        """
        if tag in formers:
            inde = formers.index(tag)
            road = roads.pop(inde)
            visited.append(road[1])
            tag = road[1]
        elif tag in latters:
            inde = latters.index(tag)
            road = roads.pop(inde)
            visited.append(road[0])
            tag = road[0]
        else:
            out = False
            break

        if len(set(visited)) == 4:
            print('YES')
            exit(0)
        elif len(set(visited)) != 4 and len(visited) == 4:
            out = False
            break
    road = roads2.pop(0)
    visited = [road[0], road[1]]
    tag = road[0]
    while True:
        formers = [roads2[i][0] for i in range(len(roads2))]
        latters = [roads2[i][1] for i in range(len(roads2))]
        """
        print(visited)
        print(tag)
        print(formers)
        print(latters)
        print('\n\n\n')
        """
        if tag in formers:
            inde = formers.index(tag)
            road = roads2.pop(inde)
            visited.append(road[1])
            tag = road[1]
        elif tag in latters:
            inde = latters.index(tag)
            road = roads2.pop(inde)
            visited.append(road[0])
            tag = road[0]
        else:
            break

        if len(set(visited)) == 4:
            print('YES')
            exit(0)
        elif len(set(visited)) != 4 and len(visited) == 4:
            break
print('NO')

Submission status: Wrong Answer

Solution code:
p_str = input().split()
p = [int(s) for s in p_str]
p_str = input().split()
p.extend([int(s) for s in p_str])
p.extend([int(s) for s in p_str])
#print(p)
count_list = []
for i in range(4):
   count =  p.count(i+1)
   count_list.append(count)
#print(count_list)
#==
count_list2 = []
#for j in range(2):
#   count2 = count_list2.count(j+1)
#   count_list2.append(count2)
#print(count_list2)
#==
if(count_list.count(1)==2 and count_list.count(2)==2):
   print("YES")
else:
   print("NO")

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)

ok = 0

roads = [[a,b,c], [a,c,b], [b,a,c], [b,c,a], [c,a,b], [c,b,a]]

for check in roads:
    flag = 1
    seen = [0]*4
    cur = 0
    nxt = check[cur][1]
    while seen.count(1)<4:
        seen[check[cur][0]-1]=1
        seen[check[cur][1]-1]=1
        if cur+1<len(check) and nxt in check[cur+1]:
            if nxt==check[cur+1][0]:
                nxt = check[cur+1][1]
            else:
                nxt = check[cur+1][0]
            cur+=1
            
        else:
            break

    if seen.count(1)==4:
        ok = 1
        #print(check)
        break

    nxt = check[cur][0]
    seen = [0]*4
    cur = 0
    
    while seen.count(1)<4:
        seen[check[cur][0]-1]=1
        seen[check[cur][1]-1]=1
        if cur+1<len(check) and nxt in check[cur+1]:
            if nxt==check[cur+1][0]:
                nxt = check[cur+1][1]
            else:
                nxt = check[cur+1][0]
            cur+=1
            
        else:
            break
    if seen.count(1)==4:
        ok = 1
        #print(check)
        break


if ok:
    print('YES')
else:
    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())

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

res = [sum([1 for _ in l if _ == __]) for __ in [1,2,3,4]]

if 3 in res:
    print("No")
else:
    print("Yes")

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)

ok = 0

roads = [[a,b,c], [a,c,b], [b,a,c], [b,c,a], [c,a,b], [c,b,a]]

for check in roads:
    flag = 1
    seen = [0]*4
    cur = 0
    nxt = check[cur][1]
    while seen.count(1)<4:
        seen[check[cur][0]-1]=1
        seen[check[cur][1]-1]=1
        if cur+1<len(check) and nxt in check[cur+1]:
            if nxt==check[cur+1][0]:
                nxt = check[cur+1][1]
            else:
                nxt = check[cur+1][0]
            cur+=1
            
        else:
            break

    nxt = check[cur][0]
    seen = [0]*4
    cur = 0
    
    while seen.count(1)<4:
        seen[check[cur][0]-1]=1
        seen[check[cur][1]-1]=1
        if cur+1<len(check) and nxt in check[cur+1]:
            if nxt==check[cur+1][0]:
                nxt = check[cur+1][1]
            else:
                nxt = check[cur+1][0]
            cur+=1
            
        else:
            break
    if seen.count(1)==4:
        ok = 1
        #print(check)
        break


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

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)

ok = 0

roads = [[a,b,c], [a,c,b], [b,a,c], [b,c,a], [c,a,b], [c,b,a]]

for check in roads:
    flag = 1
    seen = [0]*4
    cur = 0
    nxt = check[cur][1]
    while seen.count(1)<4:
        seen[check[cur][0]-1]=1
        seen[check[cur][1]-1]=1
        if cur+1<len(check) and nxt in check[cur+1]:
            if nxt==check[cur+1][0]:
                nxt = check[cur+1][1]
            else:
                nxt = check[cur+1][0]
            cur+=1
            
        else:
            break
    if seen.count(1)==4:
        ok = 1
        #print(check)
        break


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
num =[]
ans =0
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:
        ans +=1
    if num.count(i)==0:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
range_city = list(range(1, 4+1))
roads = [list(map(int, input().split())) for i in range(3)]
for road in roads:
    if road[0] not in range_city:
        print('NO')
        exit()
    elif road[1] not in range_city:
        print('NO')
        exit()


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:
# coding: utf-8
# Your code here!
num =[]
ans =0
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 or num.count(i)==0:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
num =[]
ans =0
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:
        ans +=1
if ans>0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
x=[]#入力画面の二文字を別々の文字に格納
x=input().split(" ")
a1=int(x[0])
b1=int(x[1])
y=[]#入力画面の二文字を別々の文字に格納
y=input().split(" ")
a2=int(y[0])
b2=int(y[1])
z=[]#入力画面の二文字を別々の文字に格納
z=input().split(" ")
a3=int(z[0])
b3=int(z[1])
X=[]
X.append(a1)
X.append(a2)
X.append(a3)
X.append(b1)
X.append(b2)
X.append(b3)
import collections
c=len(collections.Counter(X)) #リスト内の要素の種類数cを調べる
x1=X.count(1)
x2=X.count(2)
x3=X.count(3)
x4=X.count(4)
if x1==3 or x2==3 or x3==3 or x1==3 :
    print("NO")
elif c==4 :
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
roads=[]
roads2=[]
for s in range(3):
    a=[int(i) for i in input().split()]
    roads+=[a]
    roads2+=[a]

flag1=False
flag2=False
flag3=False
flag4=False

road=roads.pop(0)

visited=[road[0],road[1]]
tag=road[1]
while True:
    out=True
    while out:
        formers=[roads[i][0] for i in range(len(roads))]
        latters=[roads[i][1] for i in range(len(roads))]
        """
        print(visited)
        print(tag)
        print(formers)
        print(latters)
        print('\n\n\n')
        """
        if tag in formers:
            inde=formers.index(tag)
            road=roads.pop(inde)
            visited.append(road[1])
            tag=road[1]
        elif tag in latters:
            inde=latters.index(tag)
            road=roads.pop(inde)
            visited.append(road[0])
            tag=road[0]
        else:
            out=False
            break

        if len(set(visited))==4:
            print('YES')
            exit(0)
        elif len(set(visited))!=4 and len(visited)==4:
            out=False
            break
    road = roads2.pop(0)
    visited = [road[0], road[1]]
    tag = road[0]
    while True:
        formers = [roads2[i][0] for i in range(len(roads2))]
        latters = [roads2[i][1] for i in range(len(roads2))]
        """
        print(visited)
        print(tag)
        print(formers)
        print(latters)
        print('\n\n\n')
        """
        if tag in formers:
            inde = formers.index(tag)
            road = roads2.pop(inde)
            visited.append(road[1])
            tag = road[1]
        elif tag in latters:
            inde = latters.index(tag)
            road = roads2.pop(inde)
            visited.append(road[0])
            tag = road[0]
        else:
            print('NO')
            exit(0)

        if len(set(visited)) == 4:
            print('YES')
            exit(0)
        elif len(set(visited)) != 4 and len(visited) == 4:
            exit(0)

Submission status: Wrong Answer

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]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False
        break

print("YES" if x == True else "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
    elif a.count(str(i)) == 0 :
        result = "NO"
        break
    
print(result)

Submission status: Wrong Answer

Solution code:
X = []
for i in range(3):
    X.append(input().split())
a1 = 0
a2 = 0
a3 = 0
a4 = 0
for i in X:
    for j in i:
        if j == "1":
            a1 = 1
        elif j == "2":
            a2 = 1
        elif j == "3":
            a3 = 1
        elif j == "4":
            a4 = 1
if a1 == 1 and a2 == 1 and a3 == 1 and a4 == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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


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

    for road in roads:
        if key == road[0] and road not in already:
            roads.remove(road)
            already.append(road)
            func(road[0], roads)
        elif key == road[1] and road not in already:
            already.append(road)
            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:
city = [0, 0, 0, 0]
for i in range(3):
    a, b = ([int(x)-1 for x in input().split()])
    city[a] += 1
    city[b] += 1
    if city[a] > 2 or city[b] > 2:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
li = []
n = 3

for i in range(n):
    a,b = input().split()
    li.append(a)
    li.append(b)
    
an = li.count("1")+li.count("2")+li.count("3")+li.count("4")
if an >= 6:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])
k = 0
if A[1] - A[0] == 2:
    k += 1
if B[1] - B[0] == 2:
    k += 1
if C[1] - C[0] == 2:
    k += 1

if k == 1:
    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 = a + b + 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")
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 or a.count(str(i)) == 0:
        result = "NO"
        break
    
print(result)