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:
A = []
for _ in range(3):
    a, b = map(int, input().split())
    A.append(a)
    A.append(b)

num_1 = A.count(0)
num_2 = A.count(1)
num_3 = A.count(2)
num_4 = A.count(3)

ma = max(num_1, num_2, num_3, num_4)
if ma < 3:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

  for i in range(4):
    if t[i] == None:
      print("NO")
      return
    if t[i] == i:
      print("NO")
      return
  else:
    print("YES")
solve()

Submission status: Wrong Answer

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

for i in range(4):
  if t[i] == None:
    print("NO")
    break
  if t[i] == i:
    print("NO")
    break
else:
  print("YES")

Submission status: Wrong Answer

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

if d[0] <= 2 and d[1] <= 2 and d[2] <= 2 and d[3] <= 2:
    print("YES")
else:
    print("N0")
    
#YESとYesは一緒でいいだろ

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    #rは長さ、Noneでiteraterの長さ
    for j in range(2):
        now=i[0][j]
        seen=set([now])
        for a,b in i:
            if b!=now!=a:break
            now=b+a-now
        else:
            if len(seen)==4:print('YES');exit()
print("NO")

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    #rは長さ、Noneでiteraterの長さ
    now=i[0][0]
    for a,b in i:
        if b!=now!=a:break
        now=b+a-now
    else:print('YES');exit()
print("NO")

Submission status: Wrong Answer

Solution code:
print('YNEOS'[len(set(a for b in[map(int,input().split())for i in range(3)]for a in b))!=4::2])

Submission status: Wrong Answer

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

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

for i in range(4):
    cnt = route_lists.count(i)
    cnt_lists.append(cnt)

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

print(ans)

Submission status: Wrong Answer

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

route_lists = [a1, b1, a2, b2, a3, b3]
count_lists = []
for i in range(1, 4, 1):
    cnt = route_lists.count(i)
    count_lists.append(cnt)

max = count_lists[0]
for j in range(1, 3, 1):
    if max < count_lists[j]:
        max = count_lists[j]

if max > 2:
    ans = 'NO'
else:
    ans = 'YES'

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
if n >= 2*k - 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())

A=[a1,b1,a2,b2,a3,b3]
B=set(A)
if len(B)==4:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
l = []

for i in range(3):
    l += list(map(int, input().split()))
    
for i in range(4):
    if l.count(i) == 3:
        print('NO')
        break
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
l = []

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

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

Submission status: Wrong Answer

Solution code:
   
print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
cnt = [0] * 4
for _ in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
for i in range(1, 4):
    if cnt[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())
if b1==a2 and b2==a3:
  print("YES")
elif b1==a3 and b3==a2:
  print("YES")
elif b2==a1 and b1==a3:
  print("YES")
elif b2==a3 and b3==a1:
  print("YES")
elif b3==a1 and b1==a2:
  print("YES")
elif b3==a2 and b2==a1:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
A = []
for i in range(3):
    a,b = map(int,input().split())
    A.append(a)
    A.append(b)
c = Counter(A)
for i in c.values():
    if i >=2:
        print('NO')
        sys.exit()
print('YES')

Submission status: Wrong Answer

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

for i in range(3):
    p,q = map(int,input().split())
    dic[p] += q

L = []
for v in dic.values():
    L.append(v)

odd = [x%2 ==1 for x in L]
even = [x%2 ==0 for x in L]

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, 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, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

dim = [0]*4

for _ in range(3):
	a, b = MAP()
	dim[a-1] += 1
	dim[b-1] += 1
print(dim)
c = Counter(dim)
print(c)
if c[1] == 2 and c[2] == 2:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
SET = set()
for _ in range(3):
  SET |= set(IL())
if len(SET)==4:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

for i in range(1,5):
  cnt=0
  for itm in l:
    if i==l:
      cnt+=1
  if cnt>=3:
    print("NO")
    exit()
print("YES")

Submission status: Wrong Answer

Solution code:
from collections import deque
S = [list(map(int, input().split())) for _ in range(3)]
S.sort()
l=[0,0,0,0]

for i in range(3):
    for j in range(2):
        l[S[i][j]-1]+=1
print(l)
if max(l)==3:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

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

#入力
# s = input()[0:-1]
# n = int(input())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


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


     
def main():
    count =[0]*4
    for i in range(3):
       a,b = map(int, input().split())
       count[a-1]+=1
       count[b-1]+=1
    flag = True
    for i in count:
        if i ==3:
            flag=False
    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
abl = [map(int,input().split()) for nesya in range(3)]
s = [1,1,2,2,3,3,4,4]
c = 0
for ab in abl:
  for n in ab:
    if n in abl:
      s.remove(n)
    else:
      c += 1
if c == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
n = 3
num_list = [list(map(int, input().split())) for _ in range(n)]
N = (sum(num_list, []))
N1 = N.count(1)
N2 = N.count(2)
N3 = N.count(3)
N4= N.count(4)
if (N1 or N2 or N3 or N4) >= 3:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
n = 3
num_list = [list(map(int, input().split())) for _ in range(n)]
N = (sum(num_list, []))
N1 = N.count(1)
N2 = N.count(2)
N3 = N.count(3)
N4= N.count(4)
if (N1 or N2 or N3 or N4) > 3:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

mx = 0
for i in range(1, 5):
    mx = max(mx, li.count(i))

if mx == 3:
    ans = "No"
else:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
L = []
for _ in range(3):
  A,B = map(int,input().split()) 
  L.append(A)
  L.append(B)
L.sort()
M = []
a = L.count('1')
b = L.count('2')
c = L.count('3')
d = L.count('4')
M.append(a)
M.append(b)
M.append(c)
M.append(d)
M.sort()
if M == [1,1,2,2]:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

a[0],b[0]=map(int,input().split())
a[1],b[1]=map(int,input().split())
a[2],b[2]=map(int,input().split())

c=a+b
c.sort()
if c[0]==1 and c[-1]==2:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

a[0],b[0]=map(int,input().split())
a[1],b[1]=map(int,input().split())
a[2],b[2]=map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
from collections import*
print("YNEOS"[Counter(open(0).read().split()).most_common()[0][1]!=3::2])

Submission status: Wrong Answer

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(max(s.values())==3)

main()

Submission status: Wrong Answer

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)
    print(N)
    N=Counter(N)
    print(N)
    NN=N.most_common(1)
    print(NN)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Submission status: Wrong Answer

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 range(4):
  if ans[i] >= 3:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

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

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 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 count1 >=3:
            print("NO")
            exit()

print("YES")

Submission status: Wrong Answer

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,4):
    if l.count(i) == 3:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lista = []
for i in range(3):
  a,b = map(int,input().split())
  lista.append(a)
  lista.append(b)
l1 = 0
l2 = 0
l3 = 0
l4 = 0
for j in lista:
  if j == 1:
    l1 += 1
  if j == 2:
    l2 += 1
  if j == 3:
    l3 += 1
  if j == 4:
    l4 += 1
c = (l1)%2 + (l2)%2 + (l3)%2 + (l4)%2
if c%2 == 0:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

z = []
for i in range(3):
    a,b = inpl()
    z.append(a)
    z.append(b)
c = Counter(z)
for key in c.keys():
    if c[key] > 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
I=input;s=I()+I()+I();print("YNEOS"[any(s.count(x)>1for x in "1234")::2])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
 #B-Path
a1,b1=map(int,input().split( ))
a2,b2=map(int,input().split( ))
a3,b3=map(int,input().split( ))
x=[a1,b1,a2,b2,a3,b3]
y=[x.count(i) for i in range(1,4)]
if max(y)==3:
    print("NO")
if max(y)==2:
    print("YES")

Submission status: Wrong Answer

Solution code:
city={1:0, 2:0, 3:0, 4:0}
for _ in range(3):
    a,b=map(int, input().split())
    city[a]+=1
    city[b]+=1
    
if list(city.values()).count(2)==2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
R=[int(x) for x in input().split() for _ in range(3)]
ans="YES"
for r in R:
  if R.count(r)==3 :
    ans="NO"
    break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

graph = [[] for _ in range(4)]
for a, b in AB:
	a, b = a - 1, b - 1
	graph[a] += [b]
	graph[b] += [a]

visited = [False] * 4
def dfs(n=0):
	if visited[n]:
		return
	visited[n] = True
	for nn in graph[n]:
		dfs(nn)
dfs()

print(["YES", "NO"][not(all(visited))])

Submission status: Wrong Answer

Solution code:
Inp1 = list(input().split())
Inp1.extend(input().replace(' ',''))
Inp1.extend(input().replace(' ',''))

Inp_dict = {'1':0,'2':0,'3':0,'4':0}
for i in Inp1:
	Inp_dict[i] +=1

ans = list()
for k in Inp_dict.keys():
	if Inp_dict[k] == 2 : ans.extend(k)

if len(ans) == 2: print('Yes')
else: print('No')

Submission status: Wrong Answer

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

ans = "YES"

for i in range(4):
  a = lis.count(i+1)
  if a >= 3:
    ans = "NO"
    break
print(ans)

Submission status: Wrong Answer

Solution code:
L=[]
for i in range(3):
  L.append(list(map(int,input().split())))
A=[]
for i in L:
  for ii in i:
    A.append(ii)
if len(set(A))==4 and len(A)-len(set(A))==2:
  print("YES")
else:
  print(len(set(A)))
  print(len(A)-len(set(A)))
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 3 in p:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
list_ = [[int(x) for x in input().split()] for i in range(3)]
count = [0]*4
for i in range(3):
  count[list_[i][0]-1]+=1
  count[list_[i][1]-1]+=1
print(count)
if 3 in count:
  print('NO')
else:
  print('YES')

Submission status: Wrong Answer

Solution code:
L = [set(map(int,input().split())) for i in range(3)]
L += [set([1,0]),set([2,0]),set([3,0]),set([4,0])]
import copy
def dfs(left_towns, current_town):
    if len(left_towns) == 0:
        return 1
    
    ret = 0
    for t in left_towns:
        if set([t,current_town]) in L:
            new_left_towns = copy.deepcopy(left_towns)
            new_left_towns.remove(t)
            ret += dfs(new_left_towns, t)
    
    if ret>0:
        return 1
    else:
        return 0

ans = 'Yes' if dfs([1,2,3,4],0)>0 else 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
count1=0
count2=0
count3=0
count4=0
for i in range(3):
  a,b=(int(x) for x in input().split())
  if a==1 or b==1:
    count1 = count1 + 1
  elif a==2 or b==2:
    count2 = count2 + 1
  elif a==3 or b==3:
    count3 = count3 + 1
  elif a==4 or b==4:
    count4 = count4 + 1
if count1>2 or count2>2 or count3>2 or count4>2:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
import numpy as np
ans = 'YES'
a = np.array([])
for i in range(3):
    b, c = input().split()
    a = np.append(a, [b, c])
a = a.astype(np.int32)
for i in range(4):
    count = np.sum(a == i + 1)
    if count > 2:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    for i in range(4):
        if sum(x==i+1 for x in a):
            print('NO')
            return
    print('YES')
f()

Submission status: Wrong Answer

Solution code:
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    b = []
    for i in range(4):
        b.append(sum(x==i for x in a))
    for i in b:
        if i > 2:
            print('NO')
            return
    print('YES')
f()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
sum = [0]*4

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

for i in range(0,3):
    if sum[i] == 3:
        print("NO")
        sys.exit()

print("YES")

Submission status: Wrong Answer

Solution code:
A = [[0 for x in range(1)]for y in range(3)]
one_count = 0
two_count = 0
three_count = 0
four_count = 0
for i in range(3):
     A[i] = [int(x) for x in input().split()]

     if(A[i][0]==1 or A[i][1]==1):
         one_count += 1
     if(A[i][0]==2 or A[i][1]==2):
         two_count += 1
     if(A[i][0]==3 or A[i][1]==3):
         three_count += 1
     if(A[i][0]==1 or A[i][1]==1):
         four_count += 1

if(one_count >= 3 or two_count >= 3 or three_count >= 3 or four_count >= 3):
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
L = list(map(int,input().split()))
M = list(map(int,input().split()))
N = list(map(int,input().split()))
O = [L,M,N]
P = L.count(1)+M.count(1)+N.count(1)
Q = L.count(2)+M.count(2)+N.count(2)
R = L.count(3)+M.count(3)+N.count(3)
S = L.count(4)+M.count(4)+N.count(4)
T = [P,Q,R,S]
T.sort()
if T[0] == T[1] == 1:
  if T[2] == T[3] == 2:
    if [T[1],T[2]] in O:
      print('YES')
    else:
      print('NO')
  else:
    print('NO')
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 == 10 or a2+b2+a3+b3 == 10 or a1+a2+a3+b3 == 10 or a1+b1+b2+b3 == 10 or b1+b2+b3+a3 == 10 or b1+a1+a2+a3==10  or a1+a2+b2+b3 == 10 or b1+b2+a2+a3 == 10:
    print("YES")
else:
    print("NO")