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 sys
import numpy as np
from collections import defaultdict
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = readline().decode().rstrip()
dicts = defaultdict(int)

for c in S:
  dicts[c] += 1

for pair in [('N', 'S'), ('W', 'E')]:
  if min(dicts[pair[0]], dicts[pair[1]]) == 0:
    if max(dicts[pair[0]], dicts[pair[1]]) != 0:
      print('No')
      sys.exit()
print('Yes')

Solution (Python):
S = list(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()
pr=True
if (s.count("N")==0)^(s.count("S")==0):
  pr=False
if (s.count("E")==0)^(s.count("W")==0):
  pr=False

if pr:
  print("Yes")
else:
  print("No")

Solution (Python):
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
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 *

S = input()

x = defaultdict(int)

for s in S:
	x[s] = 1

if x["N"] == x["S"] and x["W"] ==x["E"]:
	print("Yes")
else:
	print("No")

Solution (Python):
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
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 *

S = input()

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

if n+s == 0 and 0 < w*e:
	print("Yes")
elif 0 < n*s and w+e == 0:
	print("Yes")
elif 0 < n*s and 0< w*e:
	print("Yes")
else:
	print("No")

Solution (Python):
s=input()
ryoko={'S':False,'N':False,'W':False,'E':False}
for c in s:
    ryoko[c]=True
if (ryoko['S']!=ryoko['N']) or (ryoko['W']!=ryoko['E']):
    print('No')
else:
    print('Yes')

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()
p = ['N', 'S', 'E', 'W']
cnt = []
for i in p:
    cnt.append(s.count(i))
if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
    if cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
        print("Yes")
    else:
        print("No")
elif cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
    if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






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






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)]


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()


def DD(arg): return defaultdict(arg)



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


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


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


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


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


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


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


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


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))))


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




S = S()

if ("N" in S and "S" not in S) or ("S" in S and "N" not in S) or ("E" in S and "W" not in S) or ("W" in S and "E" not in S):
  NE()
YE()

Solution (Python):
s=input()
print('No' 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 else 'Yes')

Solution (Python):
S = input()
count = {s: 0 for s in "NWSE"}
for s in S:
    count[s] += 1

if count["N"] == 0 and count["S"] >= 1 or count["N"] >= 1 and count["S"] == 0:
    print("No")
elif count["E"] == 0 and count["W"] >= 1 or count["E"] >= 1 and count["W"] == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
s = input();

st = set(s)
print("Yes" if st == set("WE") or st == set("NS") or st == set("SENW") else "No")

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

n = 0

s = 0

e = 0

w = 0

for i in a:
  if i == 'N':
    n += 1
  elif i == 'S':
    s += 1
  elif i == 'E':
    e += 1
  elif i == 'W':
    w += 1

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

Solution (Python):
S = input()

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

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

Solution (Python):
import collections

s=input()
a=collections.Counter(s)
f=True

if a['N']>0:
	if a['S']==0:
		f=False
		
if a['S']>0:
	if a['N']==0:
		f=False
		
if a['W']>0:
	if a['E']==0:
		f=False
		
if a['E']>0:
	if a['W']==0:
		f=False
		
if f:
	print('Yes')
else:
	print('No')

Solution (Python):
from collections import Counter

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):
string = input()
news = "NEWS"
flg = [False for _ in range(4)]
for s in string:
    for i in range(4):
        if s == news[i]:
            flg[i] = True
            break
if flg[0] != flg[3] or flg[1] != flg[2]:
    print("No")
else:
    print("Yes")

Solution (Python):
S = list(input())
dir_set = set()
for s in S:
    dir_set.add(s)

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

Solution (Python):
s = input()
if "N" in s and "S" in s and "W" in s and "E" in s:
  print("Yes")
elif not "N" in s and not "S" in s and "W" 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")
else:
  print("No")

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 and w>0 and e>0)or(n==0 and s==0 and w>0 and e>0) or (n>0 and s>0 and w==0 and e==0):
    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==0 and S==0:
    if E==0 and W==0:
        print("Yes")
    elif E>0 and W>0:
        print("Yes")
    else:
        print("No")
elif N>0 and S>0:
    if E==0 and W==0:
        print("Yes")
    elif E>0 and W>0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

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

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


    
    
    
    

if __name__ == '__main__':
    main()

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

Solution (Python):
S=input()
nsflag=False
weflag=False
if(("N" in S and "S" in S)or("N" not in S and "S" not in S)):
  if(("W" in S and "E" in S)or("W" not in S and "E" not in S)):
    print("Yes")
    exit()
print("No")

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

Solution (Python):
Count = [0,0,0,0]
for j in input():
    if j == 'N':
        Count[0] +=1
    elif j == 'S':
        Count[1] +=1
    elif j == 'W':
        Count[2] +=1
    elif j == 'E':
        Count[3] +=1

if (Count[0] > 0 and Count[1] > 0) and (Count[2] > 0 and Count[3] > 0):
    print("Yes")
elif (Count[0] == 0 and Count[1] == 0) and (Count[2] > 0 and Count[3] > 0):
    print("Yes")
elif (Count[0] > 0 and Count[1] > 0) and (Count[2] == 0 and Count[3] == 0):
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = input()
n, w = S.count('N'), S.count('W')
s, e = S.count('S'), S.count('E')
flag = True
if n == 0 or s == 0:
    if n != s:
        flag = False
if w == 0 or e == 0:
    if w != e:
        flag = False
print('Yes' if flag else 'No')

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    go_back_home = True
    if "N" in S:
        if "S" not in S:
            go_back_home = False
    if "S" in S:
        if "N" not in S:
            go_back_home = False
    if "W" in S:
        if "E" not in S:
            go_back_home = False
    if "E" in S:
        if "W" not in S:
            go_back_home = False

    ans = "Yes" if go_back_home else "No"
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin
S = stdin.readline().rstrip()
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):

S = set(input())
i = {'N', 'S'}
j = {'W', 'E'}
k = {'N', 'S', 'W', 'E'}
if S == i or S == j or S == k:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
x = 0
y = 0
s = list(set(s))
for i in range(len(s)):
    if s[i] == 'N':
        y += 1
    elif s[i] == 'W':
        x -= 1
    elif s[i] == 'S':
        y -= 1
    else:
        x += 1
print('Yes' if x == 0 and y == 0 else 'No')

Solution (Python):
s = input()
c = 0
d = 0
if 'W' in s:
  c += 1
if 'E' in s:
  c -= 1
if 'N' in s:
  d += 1
if 'S' in s:
  d -= 1
if c == d == 0:
  print('Yes')
else:
  print('No')

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

Solution (Python):
S="".join(sorted(set(input())))
print("Yes" if S=="ENSW" or S=="NS" or S=="EW" else "No")

Solution (Python):
S="".join(set(input()))
print("Yes" if len(S)==4 or (len(S)==2 and S.count("N")==S.count("S")) else "No")

Solution (Python):
S = input()
has_N = "N" in S
has_S = "S" in S
has_E = "E" in S
has_W = "W" in S
reachable_NS = has_N and has_S or not has_N and not has_S
reachable_SW = has_E and has_W or not has_E and not has_W
if reachable_NS and reachable_SW:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
x = input()
n = x.count('N')
e = x.count('E')
w = x.count('W')
s = x.count('S')
if ((n and not s) or (not n and s) or (w and not e) or (not w and e)):
	print("No")
else:
	print("Yes")

Solution (Python):
S=input()
ans='Yes'
if S.count('N')>=1 and S.count('S')==0:
    ans='No'
elif S.count('S')>=1 and S.count('N')==0:
    ans='No'
elif S.count('E')>=1 and S.count('W')==0:
    ans='No'
elif S.count('W')>=1 and S.count('E')==0:
    ans='No'
print(ans)

Solution (Python):
from collections import Counter

S = list(input())
c = Counter(S)

ans = True

if (c["N"]> 0 and c["S"] == 0) or (c["N"]== 0 and c["S"] > 0) or (c["W"] > 0 and c["E"] == 0) or (c["W"] == 0 and c["E"] > 0):
    ans = False

if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
S = set(input())
if len(S) == 2:
  if len(S & {'N', 'S'}) == 2 or len(S & {'E', 'W'}) == 2:
    print('Yes')
  else:
    print('No')
elif len(S) == 4:
  print('Yes')
else:
  print('No')

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

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

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

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

n,w,s,e = 0,0,0,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 
  elif(S[i] == 'E'): e = 1
    
judge = [n,w,s,e]
if((judge == [1,0,1,0])or(judge == [0,1,0,1])or(judge == [1,1,1,1])):
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import defaultdict

S = input()
dic = defaultdict(bool)
for s in S:
    dic[s] = True
if dic["N"] != dic["S"] or dic["W"] != dic["E"]:
    print("No")
else:
    print("Yes")

Solution (Python):
st = input()
if "N" in st:
    if ("S" in st) is False:
        print("No")
        exit()
if "W" in st:
    if ("E" in st) is False:
        print("No")
        exit()
if "S" in st:
    if ("N" in st) is False:
        print("No")
        exit()
if "E" in st:
    if ("W" in st) is False:
        print("No")
        exit()
print("Yes")

Solution (Python):
from collections import Counter
S = list(input())
def zeroandnot0(a, b):
    if (a == 0 and b != 0) or (a != 0 and b == 0):
        return True
    else:
        return False
c = Counter(S)
if zeroandnot0(c['E'], c['W']) or zeroandnot0(c['N'], c['S']):
    print('No')
else:
    print('Yes')

Solution (Python):
s = list(set(input()))
l = [["N","S"], ["W","E"], ["N", "S", "W", "E"]]
if len(s) != 2 and len(s) != 4:
    print("No")
    exit()
for i in l:
    x = 0
    for j in s:
        if j in i:
            x += 1
    if x == len(i):
        print("Yes")
        exit()
print("No")

Solution (Python):
s = input()

if ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s):
    if ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s):
        print('Yes')
        exit()

print('No')

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

Solution (Python):
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1000
if 'W' in s:
    judge += 1
if 'S' in s:
    judge -= 1000
if 'E' in s:
    judge -= 1

print('Yes' if judge == 0 else 'No')

Solution (Python):
s = list(input())
x = 0
y = 0

if (s.count("S") > 0 and s.count("N") > 0) or (s.count("S") == 0 and s.count("N") == 0):
    if (s.count("E") > 0 and s.count("W") > 0) or (s.count("E") == 0 and s.count("W") == 0):
        print("Yes")
        exit()
    
print("No")

Solution (Python):
S = input()
res = "Yes"
if S.count('N') and not S.count('S'):
    res = "No"
if not S.count('N') and S.count('S'):
    res = "No"
if S.count('E') and not S.count('W'):
    res = "No"
if not S.count('E') and S.count('W'):
    res = "No"
print(res)

Solution (Python):

import math


def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


S = instr()
r = "Yes"
e, w, n, s = 0, 0, 0, 0
for i in S:
    if i in "N":
        n += 1
    elif i == "S":
        s += 1
    elif i == "E":
        e += 1
    else:
        w += 1
if (n > 0 and s > 0) or (n == 0 and s == 0):
    pass
else:
    r = "No"
if (e > 0 and w > 0) or (e == 0 and w == 0):
    pass
else:
    r = "No"
print(r)

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

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

if n + s == 1 or w + e == 1:
  print('No')
else:
  print('Yes')

Solution (Python):
s=input()
import collections
c = collections.Counter(s)

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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    T=ST()
    E="E" in T
    W="W" in T
    N="N" in T
    S="S" in T
    if(W^E or N^S):
        print("No")
    else:
        print("Yes")
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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 "E" in S and "W" not in S:
    print("No")
elif "W" in S and "E" not in S:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    if (('S' in S) == ('N' in S)) and (('E' in S) == ('W' in S)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    snflg = True
    ewflg = True
    S = input().rstrip('\n')
    if 'S' in S or 'N' in S:
        snflg = False       
        if 'S' in S and 'N' in S:
            snflg = 'Yes'
    if 'E' in S or 'W' in S:
        ewflg = False
        if 'E' in S and 'W' in S:
            ewflg = 'Yes'
    if snflg and ewflg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
ok = True
if s.count("N") >= 1:
    if s.count("S") == 0:
        ok = False
if s.count("S") >= 1:
    if s.count("N") == 0:
        ok = False

if s.count("E") >= 1:
    if s.count("W") == 0:
        ok = False

if s.count("W") >= 1:
    if s.count("E") == 0:
        ok = False
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

S_set = set(S)
if len(S_set) % 2 == 0:
    if S_set == set() or S_set == set(['N', 'S']) or S_set == set(['E', 'W']) or S_set == set(['N', 'S', 'E', 'W']):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

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

Solution (Python):
S = list(input())
flag = 1
if "S" in S:
  if not("N" in S):
    flag = 0
if "N" in S:
  if not("S" in S):
    flag = 0
if "E" in S:
  if not("W" in S):
    flag = 0
if "W" in S:
  if not("E" in S):
    flag = 0
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):

def can_go_home(dir1, dir2):
	if dir1 > 0 and dir2 > 0:
		return True
	elif dir1 == 0 and dir2 == 0:
		return True
	else:
		return False


n, w, s, e = 0, 0, 0, 0

for dir in input():
	if dir == 'N':
		n += 1
	elif dir == 'W':
		w += 1
	elif dir == 'S':
		s += 1
	else:
		e += 1

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

Solution (Python):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    str = (input().rstrip())
    W = 0
    N = 0
    S = 0
    E = 0

    for s in str:
        if(s == 'W'):
            W += 1
        elif(s =='E'):
            E += 1
        elif(s == 'N'):
            N += 1
        else:
            S += 1
    

    if(S*N*E*W > 0 or (S + N == 0 and E*W > 0) or(E +W == 0 and S*N > 0)):
        print("Yes")
    else:
        print("No")
    
if __name__ == '__main__':
    solve()

Solution (Python):
s = input()
n_cnt = 0
s_cnt = 0
e_cnt = 0
w_cnt = 0
for i in range(len(s)):
  if s[i] == 'N':
    n_cnt += 1
  if s[i] == 'S':
    s_cnt += 1
  if s[i] == 'W':
    w_cnt += 1
  if s[i] == 'E':
    e_cnt += 1
if (n_cnt > 0 and s_cnt > 0) or (n_cnt == 0 and s_cnt == 0):
  length = True
else:
  length = False
if (e_cnt > 0 and w_cnt > 0) or (e_cnt == 0 and w_cnt == 0):
  width = True
else:
  width = False
  
if length and width:
  print('Yes')
else:
  print('No')

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

k, m, n, h = 0, 0, 0, 0

if 'N' in s:
    k = 1
if 'S' in s:
    m = 1
if 'W' in s:
    n = 1
if 'E' in s:
    h = 1

if (abs(k-m))%2 == 0 and (abs(n-h))%2 == 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()
cannot = [
    "N" in S and "S" not in S,
    "N" not in S and "S" in S,
    "W" in S and "E" not in S,
    "W" not in S and "E" in S,
]
print("No" if any(cannot) else "Yes")

Solution (Python):
s = input()
flag = [0] * 4
for i in range(len(s)):
    if s[i] == "N":
        flag[0] = 1
    elif s[i] == "W":
        flag[1] = 1
    elif s[i] == "S":
        flag[2] = 1
    else:
        flag[3] = 1

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

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

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

Solution (Python):
S = input()

NS = (("S" in S) & ("N" in S)) | (("S" not in S) & ("N" not in S))
EW = (("E" in S) & ("W" in S)) | (("E" not in S) & ("W" not in S))

print("Yes") if NS & EW else print("No")

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

Solution (Python):
import numpy as np

s = input()
ans = ['No', 'Yes']

judge = (('N' in s) == ('S' in s) and ('W' in s) == ('E' in s))
print(ans[judge])

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

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

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():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    

    s = input().rstrip()
    if ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s):
        if ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s):
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

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

if 'N' in s:
  if not 'S' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
if 'S' in s:
  if not 'N' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'W' in s:
  if not 'E' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'E' in s:
  if not 'W' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
print("No")

Solution (Python):
S = input()

NS = 'NS'
WE = 'WE'
answer = 'Yes'

if S.count('N') == 0 and S.count('S') != 0:
    answer = 'No'
elif S.count('N') != 0 and S.count('S') == 0:
    answer = 'No'

if S.count('W') == 0 and S.count('E') != 0:
    answer = 'No'
elif S.count('W') != 0 and S.count('E') == 0:
    answer = 'No'
        
print(answer)

Solution (Python):
S = input()

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


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