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
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    L=[]
    for _ in range(3):
        a,b=map(int,input().split())
        L.append(a-1)
        L.append(b-1)
    LL=Counter(L).most_common()
    if LL[0][1]!=2:
        print('NO')
    else:
        print('YES')
    
    



resolve()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    c,d = map(int, input().split())
    e,f = map(int, input().split())
    c = Counter([a,b,c,d,e,f])
    a = 0
    b = 0
    for i in c.values():
        if i==1:
            a+=1
        if i==2:
            b+=1
    if a==2 and b==2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 第2回全国統一プログラミング王決定戦予選-A
if False:
    N=int(input())
    if N%2==0: print(N//2-1)
    else: print(N//2)

# 第1回同じ-A
if False:
    M,D=map(int,input().split())
    ans=0
    for m in range(1,M+1):
        for d in range(1,D+1):
            if len(str(d))==2:
                x,y=int(str(d)[0]),int(str(d)[1])
                if x>=2 and y>=2 and x*y==m:
                    ans+=1
    print(ans)

#d2019PC2 - A
if False:
    N,K=map(int,input().split())
    MAX=N-K+1
    print(MAX-1 if K!=1 else 0)

#https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_a
if False:
    N,A,B=map(int,input().split())
    MAX=min(A,B)
    MIN=A+B-N if A+B>=N else 0
    print(MAX,MIN)

# https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_b
if True:
    cnt=[0 for _ in range(4)]
    for _ in range(3):
        a,b=map(int,input().split())
        cnt[a-1]+=1
        cnt[b-1]+=1
    cnt.sort()
    print('YES' if cnt==[1,1,2,2] else 'NO')

Submission status: Accepted

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

ans = 'YES'
for i in d.values():
    if i == 3:
        ans = 'NO'
        break

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
###################################################
def main():
    s=defaultdict(int)
    for a in range(3):
        b,c=map(int,input().split())
        s[b]+=1
        s[c]+=1
    YN(not max(s.values())==3)

main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    N=[]
    for _ in range(3):
        a,b=map(int,input().split())
        N.append(a)
        N.append(b)
    N=Counter(N)
    NN=N.most_common(1)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Submission status: Accepted

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

for i in range(3):
  a, b = map(int, input().split())
  ans[a-1] += 1
  ans[b-1] += 1
  
for i in ans:
  if i >= 3:
    print("NO")
    exit()

print("YES")

Submission status: Accepted

Solution code:
li=[0]*4

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

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

Submission status: Accepted

Solution code:
ab = [list(map(int, input().split())) for i in range(3)]
one, two, three, four = 0, 0, 0, 0
for i in ab:
    one += i.count(1)
    two += i.count(2)
    three += i.count(3)
    four += i.count(4)
if one == 3 or two == 3 or three == 3 or four == 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
from itertools import permutations

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

ans = "NO"
for x in permutations(range(4)):
        cant = False
        for i in range(3):
                if pas[x[i]][x[i+1]]==0: cant = True
        if cant==False: ans = "YES"
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

dim = [0]*4

for _ in range(3):
	a, b = MAP()
	dim[a-1] += 1
	dim[b-1] += 1

c = Counter(dim)
if c[1] == 2 and c[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())

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

ans = "YES"
for i in range(1,5,1):
  if ls.count(i) == 3:
    ans ="NO"
print(ans)

Submission status: Accepted

Solution code:
x = list(map(int,(input().split())))
y = list(map(int,(input().split())))
z = list(map(int,(input().split())))
count1 =  0
count2 =  0
count3 =  0
count4 =  0

num = x + y + z

for i in range(len(num)):
    
    if num[i] == 1:
        count1 += 1
        if count1 >=3:
            print("NO")
            exit()
    if num[i] == 2:
        count2 += 1
        if count2 >=3:
            print("NO")
            exit()
    if num[i] == 3:
        count3 += 1
        if count3 >=3:
            print("NO")
            exit()
    if num[i] == 4:
        count4 += 1
        if count4 >=3:
            print("NO")
            exit()

print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)

ab = [list(map(int, input().split())) for _ in range(3)]
for i in range(len(ab)):
    a = ab[i][0]
    b = ab[i][1]
    d[a] += 1
    d[b] += 1
x = []
for v in d.values():
    x.append(v)
if x.count(1) == 2 and x.count(2) == 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
li=[a,b,c,d,e,f]
x=[li.count(i) for i in range(1,5)]
if max(x)<3:
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

if max(city)==2 and min(city)==1:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
l = []
for i in range(3):
    a,b = iim()
    l.append(a)
    l.append(b)

for i in range(1,5):
    if l.count(i) == 3:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

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

Submission status: Accepted

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

a = sorted([len(d[i]) for i in range(1,5)])
if a == [1,1,2,2]:
    print("YES")
else:print("NO")
# print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
G = [list(map(int,input().split())) for i in range(3)]
deg = [0]*4
for x in G:
    deg[x[0]-1] += 1
    deg[x[1]-1] += 1
odd = 0
for x in deg:
    if x%2 == 1:
        odd += 1
if odd == 0 or odd ==2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
g = [[] for _ in range(4)]
for _ in range(3):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  g[a].append(b)
  g[b].append(a)
  
for i in range(4):
  if len(g[i]) != 1 and len(g[i]) != 2:
    print('NO')
    exit()
else:
  print('YES')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if (max(l) == 3)or(min(l) == 0):
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
import collections as cl

# 全街のつながりは保証されていて、橋は3本固定なので、枝分かれしてなければたどり着けるはず
def main() :
    bridges = []
    for i in range(3) :
        in_list = [int(i) for i in input().split()]
        bridges.extend(in_list)
    
    c = cl.Counter(bridges)
    com = c.most_common()
    if (com[0][1] == 2 and com[1][1] == 2 and com[2][1] == 1 and com[3][1] == 1) :
        print("YES")
    else :
        print("NO")
        
        
    






main()

Submission status: Accepted

Solution code:
def main():
    N = 4
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = (int(i) for i in input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    even, odd = 0, 0
    for e in edge:
        if len(e) % 2 == 1:
            odd += 1
        else:
            even += 1
    if odd == 2 and even == 2:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    A = [[int(i)-1 for i in input().split()] for j in range(3)]
    A.sort()
    if A[0] == A[1] or A[1] == A[2] or A[2] == A[0]:
        return print("NO")
    from collections import Counter
    c = Counter(sum(A, []))
    if [1, 1, 2, 2] == sorted(c.values()):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
a=collections.Counter(open(0).read().split())
v,c=zip(*a.most_common())
print("YES" if c[0]==c[1]==2 and c[2]==c[3]==1 else "NO")

Submission status: Accepted

Solution code:
def main():
    roads = [[] for _ in range(4)]
    for _ in range(3):
        a, b = map(lambda x: int(x) - 1, input().split())
        roads[a].append(b)
        roads[b].append(a)
    length = [0, 0, 0, 0]
    for r in roads:
        length[len(r)] += 1
    print("YES" if length == [0, 2, 2, 0] else "NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if max(res) > 2:
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
c = [input().split() for i in range(3)]
c = sum(c, [])
for i in '1234':
    if c.count(i) > 2:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
s = [list(map(int, input().split())) for _ in range(3)]
flag = 0
cnt = 0
for i in range(1, 5):
    for j in s:
        if (j[0] == i) or (j[1] == i):
            cnt += 1
    if cnt == 3:
        flag = 1
        break
    else:
        cnt = 0
        continue

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

Submission status: Accepted

Solution code:
def main():
    a = [0]*4
    for _ in range(3):
        x, y = map(int, input().split())
        a[x-1] += 1
        a[y-1] += 1
    a.sort()
    if a[0] == 1 and a[1] == 1 and a[2] == 2 and a[3] == 2:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(3):
    city[path[i][0]-1]=city[path[i][0]-1]-1
    city[path[i][1] - 1] = city[path[i][1] - 1] - 1
city.sort()
if (city[1]==-1)and(city[2]==0):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
ret = []
for i in range(3):
  ret+=list(map(int,input().split()))
ret.sort()
if ret.count(1)==3 or ret.count(2)==3 or ret.count(3)==3 or ret.count(4)==3:
  print('NO')
else:
  print('YES')

Submission status: Accepted

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

Submission status: Accepted

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

if max(ab) >= 3:
    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())
ab = [a1, a2, a3, b1, b2, b3]

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

Submission status: Accepted

Solution code:
road = []

road += input().split()
road += input().split()
road += input().split()

from collections import Counter

c = Counter(road)

flag = True
for k, v in c.items():
    if v > 2:
        flag = False

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

Submission status: Accepted

Solution code:
from collections import Counter
L=sorted(Counter(map(int, open(0).read().split())).values())
print("YNEOS"[any(i!=j for i,j in zip(L,[1,1,2,2]))::2])

Submission status: Accepted

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

cnt = 0    
for value in dict.values():
    if(value >= 2):
        cnt += 1
print("YES" if cnt >= 2 else "NO")

Submission status: Accepted

Solution code:
dat = []
import collections
for i in range(3):
    a,b = map(int, input().split())
    dat.append(a)
    dat.append(b)
c = collections.Counter(dat)
res = []
for k in c:
    res.append(c[k])
res.sort()
if res == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    adj = [[] for _ in range(4)]
    visited = [False]*4
    for _ in range(3):
        x, y = get_list()
        adj[x-1].append(y-1)
        adj[y-1].append(x-1)
    def dfs(root):
        #print(root)
        visited[root] = True
        for v in adj[root]:
            if not visited[v]:
                dfs(v)
                return
    dfs(0)
    print("YES") if False not in visited else print("NO")


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Submission status: Accepted

Solution code:
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# setrecursionlimit(10**6)
# threading.stack_size(2**26)

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

# range = xrange
# input = raw_input

def main():
    dc=[2,0,0,0,0]
    no = 0
    for _ in range(3):
        a, b= lin()
        if a==b:
            no = 1
        dc[a]+=1
        dc[b]+=1
    print('YES' if max(dc)==2 and not no else 'NO')
    





        
main()
#threading.Thread(target=main).start()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lis = [0] * 5

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

Submission status: Accepted

Solution code:
def pin(type=int):
  return map(type,input().split())
counter = [0]*4
for i in range(3):
  a,b=pin()
  counter[a-1]+=1
  counter[b-1]+=1
ans=1
for j in counter:
  if j>2 or j<1:
    ans=0
print(["NO","YES"][ans])

Submission status: Accepted

Solution code:
a1, a2 = map(int, input().split())
a3, a4 = map(int, input().split())
a5, a6 = map(int, input().split())

ans = []

ans.append(a1)
ans.append(a2)
ans.append(a3)
ans.append(a4)
ans.append(a5)
ans.append(a6)

max = 0

for i in ans:
	if max < ans.count(i):
		max = ans.count(i)

print("YES" if max <= 2 else "NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examA():
    N, K = LI()
    if (N+1)//2>=K:
        print("YES")
    else:
        print("NO")
    return

def examB():
    d = [0]*4
    for _ in range(3):
        a, b = LI()
        a -=1; b -=1
        d[a] +=1
        d[b] +=1
    for i in d:
        if i>=3 or i==0:
            print("NO")
            return
    print("YES")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read

ab = list(map(int, read().split()))

for i in (1, 2, 3, 4):
    if ab.count(i) > 2:
        print('NO')
        exit()
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(int)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(a_b: list):
    l = [0 for _ in range(4)]

    for a, b in a_b:
        l[a - 1] += 1
        l[b - 1] += 1

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


if __name__ == "__main__":
    a_b = [list(map(int, input().split())) for _ in range(3)]

    main(a_b)

Submission status: Accepted

Solution code:
from collections import Counter

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

c=Counter(l)
if max(c.values())==2:
 print('YES')
else:
 print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

for m in machi:
    if m == 3:
        import sys
        print('NO')
        sys.exit()

print('YES')

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
lis = []
for i in range(3):
    for j in range(2):
        lis.append(li[i][j])
lis.sort()
lin = []
for key, value in groupby(lis):
    lin.append(len(list(value)))
lin.sort()
if lin == [1,1,2,2]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
p=[0]*4

for i in range(3):
    a,b=map(int,input().split())
    p[a-1]+=1
    p[b-1]+=1
    
odd=0
for i in range(4):
    if p[i]%2==1:
        odd+=1
        
if odd<=2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
a=[[int(i) for i in input().split()] for i in range(3)]
import collections 
d=collections.defaultdict(int)
for i in a:
    d[i[0]]+=1
    d[i[1]]+=1
x=[]
for i in d.values():
    x.append(i)
if x.count(1)==2 and x.count(2)==2:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    dic = defaultdict(int)
    for _ in range(3):
        a,b = map(int,input().split())
        dic[a] += 1
        dic[b] += 1
    
    for i in range(1,5):
        if dic[i]==3:
            print("NO")
            exit()
    print("YES")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
a = list(map(int,read().split()))
if len(set(a)) == 4:
  if max([a.count(x) for x in range(1,5)]) == 2:
    print("YES")
    exit()
print("NO")

Submission status: Accepted

Solution code:
ls = [[int(_) for _ in input().split()] for _ in range(3)]

cnt = [0] * 4

for i in range(3):
    for j in range(2):
        if ls[i][j] == 1:
            cnt[0] += 1
        elif ls[i][j] == 2:
            cnt[1] += 1
        elif ls[i][j] == 3:
            cnt[2] += 1
        elif ls[i][j] == 4:
            cnt[3] += 1

if min(cnt) == 0 or max(cnt) == 3:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

G=[[0]*4 for i in range(4)]
for i in range(3):
    a,b=map(int,input().split())
    a-=1;b-=1
    G[a].append(b)
    G[b].append(a)
visited=[0]*4
def dfs(node):
    visited[node]=1
    for gi in G[node]:
        if not visited[gi]:
            dfs(gi)
            return
dfs(0)
if all(visited):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys

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

for i in [1,2,3,4]:
	if t.count(i) > 2:
		print("NO")
		sys.exit()

print("YES")

Submission status: Accepted

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

path=a+b

import collections
c=collections.Counter(path)

values,counts =zip(*c.most_common())

if counts==(2,2,1,1):
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

print('YES' if 1<=min(cnt) and max(cnt)<=2 else 'NO')

Submission status: Accepted

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

Submission status: Accepted

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

odd = 0
for i in range(1,5):
    x = a.count(i)
    if x % 2 == 1:
        odd += 1
if odd <= 2:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = [0] * 4
for a, b in ab :
  cnt[a-1] += 1
  cnt[b-1] += 1
  
if cnt.count(1) == cnt.count(2) == 2 :
  print('YES')
else :
  print('NO')

Submission status: Accepted

Solution code:
miti = [0, 0, 0, 0]
d = [[] for _ in range(4)]

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

miti[0] = 1
index = 0
for i in range(3):
    for j in range(len(d[index])):
        if j < len(d[index]) and miti[d[index][j]] != 1:
            miti[d[index][j]] = 1
            index = d[index][j]

if sum(miti) == 4:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
x=[]
for i in range(3):
  a,b=input().split()
  x.append(a)
  x.append(b)
from collections import Counter as co
d=sorted(list(co(x).values()))
print('YES' if d==[1,1,2,2] else 'NO')