Problem:
 Score : 200 points    Problem Statement Snuke lives on an infinite two-dimensional plane. He is going on an N -day trip.
At the beginning of Day 1 , he is at home. His plan is described in a string S of length N .
On Day i(1 ≦ i ≦ N) , he will travel a positive distance in the following direction:   North if the i -th letter of S is N  West if the i -th letter of S is W  South if the i -th letter of S is S  East if the i -th letter of S is E   He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N .      Constraints  1 ≦ | S | ≦ 1000  S consists of the letters N , W , S , E .         Input The input is given from Standard Input in the following format:  S       Output Print Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N . Otherwise, print No .        Sample Input 1 SENW      Sample Output 1 Yes  If Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4 .       Sample Input 2 NSNNSNSN      Sample Output 2 Yes       Sample Input 3 NNEW      Sample Output 3 No       Sample Input 4 W      Sample Output 4 No

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

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):
    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"):
    if n==0:
        if type=="int":return []
        else:return [False]
    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<=1):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 hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)

def main():
    S=input()
    w="W" in S
    e="E" in S
    n="N" in S
    s="S" in S
    Yn(not(w^e) and not(n^s))
main()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import Counter
def resolve():
    S=input()
    a=[s in S for s in"NSEW"]
    if a[0]==a[1] and a[2]==a[3]:
        print("Yes")
        return
    print("No")
    

resolve()

Solution (Python):
s = input()
count = {"N":0, "W":0, "S":0, "E":0}
for i in s:
    count[i] += 1

if ((count["N"] != 0 and count["S"] != 0) or (count["N"] == count["S"] == 0))and ((count["W"] != 0 and count["E"] != 0) or (count["W"] == count["E"] == 0)):
    print("Yes")

else:
    print("No")

Solution (Python):
s = input().strip()

counts = {
    'N': 0, 'W': 0, 'S': 0, 'E': 0
}

for c in s:
    counts[c] += 1


def judge():
    if counts['N'] > 0 or counts['S'] > 0:
        if counts['N'] * counts['S'] == 0:
            return False

    if counts['W'] > 0 or counts['E'] > 0:
        if counts['W'] * counts['E'] == 0:
            return False

    return True


if judge():
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

if "N" in s and "S" not in s:
  print("No")
elif "S" in s and "N" not in s:
  print("No")
elif "W" in s and "E" not in s:
  print("No")
elif "E" in s and "W" not in s:
  print("No")
else:
  print("Yes")

Solution (Python):
s = input()
kita = s.count("N")
mina = s.count("S")
nisi = s.count("W")
higa = s.count("E")

if kita + mina != 0 and kita*mina == 0:
    print("No")
    exit()
if nisi + higa != 0 and nisi*higa == 0:
    print("No")
    exit()

print("Yes")

Solution (Python):
s = input()
dirset = set()
for i in s:
  dirset.add(i)
if "N" in dirset and "S" in dirset:
  if ("E" in dirset and "W" in dirset) or (not "E" in dirset and not "W" in dirset):
    print("Yes")
  else:
    print("No")
elif "E" in dirset and "W" in dirset:
  if not "N" in dirset and not "S" in dirset:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
def main():
    S=set(list(input()))
    flag=0
    if len(S)%2:
        flag=1
    if ('N' in S and ('W' in S or 'E' in S)) or ('S' in S and ('W' in S or 'E' in S)):
        flag=1
    if len(S)==4:
        flag=0
    print('No' if flag else 'Yes')

main()

Solution (Python):
s = input() 

from collections import Counter

c = Counter(s)

if c['N'] >0 and c['S']==0:
    print('No')
    exit()
if c['S'] >0 and c['N']==0:
    print('No')
    exit()
if c['W'] >0 and c['E']==0:
    print('No')
    exit()
if c['E'] >0 and c['W']==0:
    print('No')
    exit()

print('Yes')

Solution (Python):
s = input()
if "N" in s:
  if "S" not in s :
    print("No")
    exit()
if "E" in s:
  if "W" not in s:
    print("No")
    exit()
if "S" in s:
  if "N" not in s :
    print("No")
    exit()
if "W" in s:
  if "E" not in s:
    print("No")
    exit()
print("Yes")

Solution (Python):
s = input()
nwse = [0]*4
for i in s:
  if i=="N":
    nwse[0] =1
  elif i=="W":
    nwse[1] =1
  elif i=="S":
    nwse[2]=1
  else:
    nwse[3]=1
    
    
if nwse[0]==nwse[2] and nwse[1]==nwse[3]:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=set(input())
    ans='No'
    if s==set('NSWE') or s==set('NS') or s==set('WE'):
        ans='Yes'
    print(ans)
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=set(input())
    ans='No'
    if s=={'N','S','W','E'} or s=={'N','S'} or s=={'W','E'}:
        ans='Yes'
    print(ans)
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()

Solution (Python):
from collections import Counter

S = Counter(input())

if "N" in S and "S" in S and "E" not in S and "W" not in S or \
    "N" not in S and "S" not in S and "E" in S and "W" in S or \
    "N" in S and "S" in S and "E" in S and "W" in S:
    print("Yes")
else:
    print("No")

Solution (Python):
A = set(list(input()))
if len(A) == 2 and("S" in A and "N" in A ):
    print("Yes")
elif  len(A) == 2 and ("W" in A and "E" in A):
    print("Yes")
elif len(A) == 4:
    print("Yes")
else:
    print("No")

Solution (Python):


s = input()
d = dict(N=0, W=0, S=0, E=0)

for i in range(len(s)):
    d[s[i]] += 1

if (d['N'] == 0 and d['S'] != 0) or (d['N'] != 0 and d['S'] == 0) or (d['W'] == 0 and d['E'] != 0) or (d['E'] == 0 and d['W'] != 0):
    print('No')
else:
    print('Yes')

Solution (Python):
s = input()
ans = 'Yes'
cn = 'N' in s
ce = 'E' in s
cw = 'W' in s
cs = 'S' in s
if (cn ^ cs) or (ce ^ cw):
    ans = 'No'
print(ans)

Solution (Python):
S=input()
N=len(S)
x=dict()
for i in range(N):
    s = S[i]
    x[s]=s

if "N" in x:
    if "S" in x:
        pass
    else:
        print("No")
        exit()

if "S" in x:
    if "N" in x:
        pass
    else:
        print("No")
        exit()

if "W" in x:
    if "E" in x:
        pass
    else:
        print("No")
        exit()

if "E" in x:
    if "W" in x:
        pass
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
s=input()
if 'N' in s and not 'S' in s:
  print('No')
elif 'S' in s and not 'N' in s:
  print('No')
elif 'W' in s and not 'E' in s:
  print('No')
elif 'E' in s and not 'W' in s:
  print('No')
else:
  print('Yes')

Solution (Python):
s = input()
if (s.count('N')>0)^(s.count('S')>0) or (s.count('E')>0)^(s.count('W')>0):
    print('No')
else:
    print('Yes')

Solution (Python):
s = input()

if "N" in s:
    if "S" not in s:
        print("No")
        exit()
if "S" in s:
    if "N" not in s:
        print("No")
        exit()
if "E" in s:
    if "W" not in s:
        print("No")
        exit()
if "W" in s:
    if "E" not in s:
        print("No")
        exit()

print("Yes")

Solution (Python):


def main():
    S = input()

    s = len([1 for _ in S if _ == 'S'])
    n = len([1 for _ in S if _ == 'N'])
    e = len([1 for _ in S if _ == 'E'])
    w = len([1 for _ in S if _ == 'W'])

    if (s > 0 and n > 0) or (s == n == 0):
        flag1 = True
    else:
        flag1 = False
    if (e > 0 and w > 0) or (e == w == 0):
        flag2 = True
    else:
        flag2 = False
    
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')

main()

Solution (Python):
S = input()
e = S.count("E")
w = S.count("W")
n = S.count("N")
s = S.count("S")

ew_flag = False
ns_flag = False

if (e > 0 and w > 0) or (e == 0 and w == 0):
  ew_flag = True
if (n > 0 and s > 0) or (n == 0 and s == 0):
  ns_flag = True

if ew_flag and ns_flag:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
if (s.count('N')>0)^(s.count('S')>0) or (s.count('E')>0)^(s.count('W')>0):
    print('No')
else:
    print('Yes')

Solution (Python):
import collections
S=str(input())

List=list(set(S))
List.sort()

flag=0
if len(List)%2==0:
    if len(List)//2==1:
        if List[0]=="E" and List[1]=="W":
            flag=1
        elif List[0]=="N" and List[1]=="S":
            flag=1
    elif len(List)//2==2:
            flag=1
            
print("Yes" if flag==1 else "No")

Solution (Python):
S = list(sorted(set(input())))
print('Yes' if S == ['E', 'N', 'S', 'W'] or S == ['E', 'W'] or S == ['N', 'S'] else 'No')

Solution (Python):
s = list(input())
ans = 1
cE = s.count("E")
cW = s.count("W")
cS = s.count("S")
cN = s.count("N")
if cE >=1:
    if cW == 0:
        ans = 0
if cW >=1:
    if cE == 0:
        ans = 0
if cN >=1:
    if cS == 0:
        ans = 0
if cS >=1:
    if cN == 0:
        ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s)
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')

Solution (Python):
t=input()
n='N' in t
w='W' in t
s='S' in t
e='E' in t

if n==s and w==e:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")


if (N == S == 0 or (N > 0 and S > 0)) and (E == W == 0 or (W > 0 and E > 0)):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
def main():
    S = Counter(input())
    ans = "Yes"
    if S["N"] > 0 or S["S"] > 0:
        if S["N"] == 0 or S["S"] == 0:
            ans = "No"
    if S["W"] > 0 or S["E"] > 0:
        if S["W"] == 0 or S["E"] == 0:
            ans = "No"
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    N = s.count('N')
    W = s.count('W')
    S = s.count('S')
    E = s.count('E')
    if N:
        if S:
            pass
        else:
            print('No')
            exit()
    if S:
        if N:
            pass
        else:
            print('No')
            exit()
    if W:
        if E:
            pass
        else:
            print('No')
            exit()
    if E:
        if W:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

S = input()[:-1]

x = [0,0,0,0]

for i in range(len(S)):
    if S[i] == 'N':
        x[0]+=1
    if S[i] == 'S':
        x[1]+=1
    if S[i] == 'E':
        x[2]+=1
    if S[i] == 'W':
        x[3]+=1


if x.count(0) == 0:
    print("Yes")
    exit()
else:
    if x[:2].count(0) == 0 and x[2:].count(0) == 2:
        print("Yes")
        exit()
    if x[:2].count(0) == 2 and x[2:].count(0) == 0:
        print("Yes")
        exit()
    
print("No")

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    s = set(IS())
    if s == {'N','S'} or s == {'W','E'} or s == {'N','S','W','E'}:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):


s=set(list(input()))

if ('N' in s)==('S' in s) and ('W' in s)==('E' in s):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

angle = {'N':0, 'W':0, 'S':0, 'E':0}

for i in s:
    angle[i] += 1


if angle['N'] > 0 and angle['S'] == 0:
    print('No')
    exit()

if angle['S'] > 0 and angle['N'] == 0:
    print('No')
    exit()

if angle['W'] > 0 and angle['E'] == 0:
    print('No')
    exit()

if angle['E'] > 0 and angle['W'] == 0:
    print('No')
    exit()

print('Yes')

Solution (Python):
S=input()
if (("S" not in S) and ("N" in S)) or (("S" in S) and ("N" not in S)):
    print("No")
elif (("W" not in S) and ("E" in S)) or (("W" in S) and ("E" not in S)):
    print("No")
else:
    print("Yes")

Solution (Python):
S = input()

N_cnt = S.count('N')
W_cnt = S.count('W')
S_cnt = S.count('S')
E_cnt = S.count('E')

if ((N_cnt > 0 and S_cnt > 0) or (N_cnt == 0 and S_cnt == 0)) \
	and ((W_cnt > 0 and E_cnt > 0) or (W_cnt == 0 and E_cnt == 0)):
	print('Yes')
else:
	print('No')

Solution (Python):
s = input()
if (("N" in s and "S" in s) or ("N" not in s and "S" not in s)) and (
    ("E" in s and "W" in s) or ("E" not in s and "W" not in s)
):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
N = s.count('N')
W = s.count('W')
S = s.count('S')
E = s.count('E')

ans = 'No'
if (N >= 1 and S >= 1) or (N == S == 0):
  if (W >= 1 and E >= 1) or (W == E == 0):
    ans = 'Yes'
print(ans)

Solution (Python):
def c(S, a):
    return S.count(a)


S = input()
n, w, s, e = c(S, 'N'), c(S, 'W'), c(S, 'S'), c(S, 'E')
if ((n > 0 and s == 0) or (s > 0 and n == 0)):
    print('No')
elif ((w > 0 and e == 0) or (e > 0 and w == 0)):
    print('No')
else:
    print('Yes')

Solution (Python):
s = list(input())
ss = set(s)
if (("W" in ss and "E" not in ss) or ("S" in ss and "N" not in ss) 
    or ("E" in ss and "W" not in ss) or ("N" in ss and "S" not in ss)):
    print("No")
else:
    print("Yes")

Solution (Python):

s = list(input())
s = set(s)
s = list(s)

if "N" in s and "S" in s and "W" in s and "E" in s:
    print("Yes")
elif "N" in s and "S" in s and "W" not in s and "E" not in s:
    print("Yes")
elif "N" not in s and "S" not in s and "W" in s and "E" in s:
    print("Yes")
elif "N" not in s and "S" not in s and "W" not in s and "E" not in s:
    print("Yes")
else:
    print("No")

Solution (Python):

S = input()


cn = S.count('N')
ce = S.count('E')
cs = S.count('S')
cw = S.count('W')

if cn > 0 and cs > 0 and ce == 0 and cw == 0:
    print('Yes')
elif cn == 0 and cs == 0 and ce > 0 and cw > 0:
    print('Yes')
elif cn > 0 and cs > 0 and ce > 0 and cw > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

if ('N' in S and 'S' not in S) or ('S' in S and 'N' not in S) or ('W' in S and 'E' not in S) or ('E' in S and 'W' not in S):
    print('No')
else:
    print('Yes')

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    if ("S" in s and "N" not in s) or ("N" in s and "S" not in s):
        print("No")
    elif ("W" in s and "E" not in s) or ("E" in s and "W" not in s):
        print("No")
    else:
        print("Yes")



if __name__ == '__main__':
    resolve()

Solution (Python):
S = input()
n, s, w, e = 0, 0, 0, 0
if 'N' in S:
    n = 1
if 'S' in S:
    s = 1
if 'W' in S:
    w = 1
if 'E' in S:
    e = 1
if n == s and w == e:
    print('Yes')
else:
    print('No')

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    n = S.count('N')
    w = S.count('W')
    s = S.count('S')
    e = S.count('E')
    if n == 0 and s == 0:
        pass
    else:
        if n!=0 and s!= 0:
            pass
        else:
            print('No')
            exit()
    if w == 0 and e == 0:
        pass
    else:
        if w!=0 and e!= 0:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = set(input())
    bl = False
    if S=={'E', 'W', 'N', 'S'}:
        bl = True
    if S=={'E', 'W'}:
        bl=True
    if S=={'N', 'S'}:
        bl = True
    print('Yes' if bl else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
A =["W" in S ,"E" in S ,"S" in S ,"N" in S ]
if A ==[1,1,1,1] or A ==[0,0,1,1] or A ==[1,1,0,0]:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()

d = [False for _ in range(4)]

for c in s:
    if c == 'N':
        d[0] = True
    elif c == 'S':
        d[1] = True
    elif c == 'W':
        d[2] = True
    else:
        d[3] = True

if d[0] ^ d[1] or d[2] ^ d[3]:
    print('No')
else:
    print('Yes')

Solution (Python):




s = input()
d = dict()

d['N'] = 0
d['W'] = 0
d['S'] = 0
d['E'] = 0

for i in range(len(s)):
    d[s[i]] = d[s[i]] + 1

nsflg = False
if (d['N'] == 0 and d['S'] == 0) or (d['N'] > 0 and d['S'] > 0):
    nsflg = True

weflg = False
if (d['W'] == 0 and d['E'] == 0) or (d['W'] > 0 and d['E'] > 0):
    weflg = True

if nsflg and weflg:
    ans = 'Yes'
else:
    ans = 'No'


print(ans)

Solution (Python):
from collections import Counter

s = str(input())

c = Counter(s)
c_keys = c.keys()
c_value = c.values()

if (c['S'] > 0 and c['N'] > 0) or (c['S'] == 0 and c['N'] == 0):
    if (c['W'] > 0 and c['E'] > 0) or (c['W'] == 0 and c['E'] == 0):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):

S = input()

canReturn = 'Yes'

if (('N' in S and 'S' not in S) or ('N' not in S and 'S' in S)) \
        or (('E' in S and 'W' not in S) or ('E' not in S and 'W' in S)):
    canReturn = 'No'

print(canReturn)

Solution (Python):
S = list(input())
nc = S.count("N")
sc = S.count("S")
ec = S.count("E")
wc = S.count("W")

for i, j in zip([nc, ec], [sc, wc]):
    if i == 0 and j == 0:
        continue
    elif i == 0 or j == 0:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
S=set(list(input()))
n=0
s=0
e=0
w=0
if 'N' in S:
  n=1
if 'S' in S:
  s=1
if 'E' in S:
  e=1
if 'W' in S:
  w=1

if (n^s)|(e^w):
  print('No')
else:
  print('Yes')

Solution (Python):
s=set(list(input()))
ns=0
ew=0
if 'N' in s and 'S' in s:
  ns=1
elif 'N' not in s and 'S' not in s:
  ns=1

if 'E' in s and 'W' in s:
  ew=1
elif 'E' not in s and 'W' not in s:
  ew=1

if ns&ew:
  print('Yes')
else:
  print('No')

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=set(input())
    YesNo(len(S)%2==0 and (('N' in S and 'S' in S) or ('W' in S and 'E' in S)))

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

S = input()
NSEW = [S.count("N"), S.count("S"), S.count("E"), S.count("W")]

if np.prod(NSEW) > 0:
    print("Yes")
    exit()
elif NSEW[0] + NSEW[1] > 0 and NSEW[0] * NSEW[1] == 0:
    print("No")
    exit()
elif NSEW[2] + NSEW[3] > 0 and NSEW[2] * NSEW[3] == 0:
    print("No")
    exit()
print("Yes")

Solution (Python):
s = list(input())

set_s = sorted(set(s))
if len(set_s)%2==1:
    print('No')
if len(set_s)==4:
    print('Yes')
if len(set_s)==2:
    if list(set_s)==['N','S']:
        print('Yes')
    elif list(set_s)==['E','W']:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()
n = 0
w = 0
s = 0
e = 0

for i in range(len(S)):
    if S[i] == "N":
        n += 1
    elif S[i] == "W":
        w += 1
    elif S[i] == "S":
        s += 1
    else:
        e += 1
if n > 0 and w > 0 and s > 0 and e > 0:
    print("Yes")
elif n > 0 and s > 0 and w == 0 and e == 0:
    print("Yes")
elif w > 0 and e > 0 and s == 0 and n == 0:
    print("Yes")
else:
    print("No")

Solution (Python):


S = input()
n = S.count('N')
s = S.count('S')
e = S.count('E')
w = S.count('W')


if (n == 0 and s != 0) or (n != 0 and s == 0):
    print('No')
elif (e == 0 and w != 0) or (e != 0 and w == 0):
    print('No')
else:
    print('Yes')

Solution (Python):
def main():
    S = set(input())
    if ('N' in S and 'S' not in S) or ('N' not in S and 'S' in S):
        print('No')
    elif ('E' in S and 'W' not in S) or ('E' not in S and 'W' in S):
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

ns = 0
we = 0

if "N" in s and "S" in s:
    ns = 1
elif "N" not in s and "S" not in s:
    ns = 1
if "W" in s and "E" in s:
    we = 1
elif "W" not in s and "E" not in s:
    we = 1
    
if ns == 1 and we == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
if 'N' in S and 'W' in S and 'S' in S and 'E' in S:
    print('Yes')
elif 'N' in S and 'S' in S and not 'W' in S and not 'E' in S:
    print('Yes')
elif 'E' in S and 'W' in S and not 'N' in S and not 'S' in S:
    print('Yes')
else:
    print('No')

Solution (Python):
s = set(list(input()))
if len(s)==4:
    print("Yes")
    exit()
elif len(s)==2:
    if "N" in s and "S" in s:
        print("Yes")
        exit()
    elif "E" in s and "W" in s:
        print("Yes")
        exit()

print("No")

Solution (Python):
S = input()

if 'N' in S or 'S' in S:
    if 'S' not in S or 'N' not in S:
        print('No')
        exit()

if 'E' in S or 'W' in S:
    if 'W' not in S or 'E' not in S:
        print('No')
        exit()

print('Yes')

Solution (Python):


from collections import deque,Counter













S = input()

cnt = Counter(S)
ans = "Yes"
if not((cnt["N"]==0 and cnt["S"]==0) or (cnt["N"]>0 and cnt["S"]>0)):
    ans = "No"
if not((cnt["W"]==0 and cnt["E"]==0) or (cnt["W"]>0 and cnt["E"]>0)):
    ans = "No"

print(ans)

Solution (Python):
import collections
S = list(input())

def judge(S):
    if "N" in S and "S" in S:
        if "W" in S and "E" in S:
            judge = "Yes"
            return judge
        elif "W" not in S and "E" not in S:
            judge = "Yes"
            return judge
        else:
            judge = "No"
            return judge
    elif "W" in S and "E" in S:
        if "N" not in S and "S" not in S:
            judge = "Yes"
            return judge
        else:
            judge = "No"
            return judge
    else:
        judge = "No"
        return judge

print(judge(S))

Solution (Python):
S = input()
S = set(S)

flg=True
for x,y in ['NS', 'SN', 'EW', 'WE']:
    if (x in S) and (y not in S):
        flg=False
        break
ans = 'Yes' if flg else 'No'
print(ans)

Solution (Python):
S = input()
flg=True

if ('N' in S) and ('S' not in S):
    flg=False
if ('S' in S) and ('N' not in S):
    flg=False
if ('W' in S) and ('E' not in S):
    flg=False
if ('E' in S) and ('W' not in S):
    flg=False

ans = 'Yes' if flg else 'No'
print(ans)

Solution (Python):
S = input()
if (("N" in S) ^ ("S" in S)) or (("E" in S) ^ ("W" in S)): print("No")
else: print("Yes")

Solution (Python):
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b*c*d > 0:
  print('Yes')
elif a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

Solution (Python):
A = input()
if (A.count("N") > 0 and A.count("S") == 0) or (A.count("N") == 0 and A.count("S") > 0):
    print("No")
elif (A.count("W") > 0 and A.count("E") == 0) or (A.count("W") == 0 and A.count("E") > 0):
    print("No") 
else:
    print("Yes")

Solution (Python):
S = input()
condition1 = ('S' in S) == ('N' in S)
condition2 = ('E' in S) == ('W' in S)
print('Yes' if condition1 and condition2 else 'No')

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())

S = S()
condition1 = ('S' in S) == ('N' in S)
condition2 = ('E' in S) == ('W' in S)
print('Yes' if condition1 and condition2 else 'No')

Solution (Python):

S = input()
direct = [0]*4
for i in S:
    if i == "W":
        direct[0] = 1
    elif i == "E":
        direct[1] = 1
    elif i == "S":
        direct[2] = 1
    elif i == "N":
        direct[3] = 1
if direct[0] == direct[1] and direct[3] == direct[2]:
    print('Yes')
    exit()
print('No')

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())

S = S()
ans = 1
if 'S' in S:
    if not 'N' in S:
        ans = 0
if 'N' in S:
    if not 'S' in S:
        ans = 0
if 'E' in S:
    if not 'W' in S:
        ans = 0
if 'W' in S:
    if not 'E' in S:
        ans = 0
print({1:'Yes',0:'No'}[ans])

Solution (Python):
S = input()

S = set(S)

if 'N' in S and 'S' in S:
    pass
elif 'N' not in S and 'S' not in S:
    pass
else:
    print('No')
    exit()
if 'E' in S and 'W' in S:
    pass
elif 'E' not in S and 'W' not in S:
    pass
else:
    print('No')
    exit()

print('Yes')

Solution (Python):
t = input()

n = t.count('N')
s = t.count('S')
w = t.count('W')
e = t.count('E')

if ((n == 0 and s == 0) or (n > 0 and s > 0)) and\
    ((w == 0 and e == 0) or (w > 0 and e > 0)):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
for i, j in zip('NWSE', 'SENW'):
    if i in s and j not in s:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
S=input()
if len(set(S))%2==1:
    print('No')
elif len(set(S))==4:
    print('Yes')
else:
    if 'S' in S and 'N' in S or 'W' in S and 'E' in S:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()
N = len(S)
n=0
e=0
w=0
s=0
for i in range(N):
  if S[i]=='N': n+=1
  elif S[i]=='W': w+=1
  elif S[i]=='E': e+=1
  elif S[i]=='S': s+=1
ok = True
if n>0 and s==0: ok=False
elif n==0 and s>0: ok=False
elif w==0 and e>0: ok=False
elif w>0 and e==0: ok=False
if ok: print("Yes")
else: print("No")

Solution (Python):
s = input()
if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
    print('Yes')
elif ('N' in s and 'S' in s) and ('W' not in s and 'E' not in s):
    print('Yes')
elif ('N' not in s and 'S' not in s) and ('W' in s and 'E' in s):
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
d = {'S':0,'N':0,'E':0,'W':0}
for i in s:
    d[i] += 1
ns = (d['S'] > 0) == (d['N'] > 0)
ew = (d['E'] > 0) == (d['W'] > 0)
if ns and ew:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

s = input()
move = defaultdict(int)
ans = 'Yes'

for c in s:
    move[c] += 1

if move['N'] > 0 and move['S'] == 0:
    ans = 'No'
if move['S'] > 0 and move['N'] == 0:
    ans = 'No'
if move['W'] > 0 and move['E'] == 0:
    ans = 'No'
if move['E'] > 0 and move['W'] == 0:
    ans = 'No'

print(ans)