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):
s = input()
set1 = {"W","N","S","E"}
set2 = {"W","E"}
set3 = {"N","S"}

if set(s) == set1:
    print("Yes")
elif set(s) == set2:
    print("Yes")
elif set(s) == set3:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()
s = [str(i) for i in s]

s = list(set(s))
s.sort()

if s == ["N","S"] or s == ["E","W"] or s == ["E","N","S","W"]:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  
NO = "No"  

def solve(S: str):
    print(YES if (('W' in S) == ('E' in S))  and (('N' in S) == ('S' in S)) else NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

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

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

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

Solution (Python):

def main():
    s = set(input())
    l = len(s)
    if l % 2 != 0:
        print('No')
    else:
        if 'N' in s and 'S' in s:
            print('Yes')
        elif 'W' in s and 'E' in s:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()
if len(set(s))%2 == 0 and ((s.count("N") and s.count("S")) != 0 or (s.count("W") and s.count("E")) != 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 ('E' in S and 'W' not in S) or ('W' in S and 'E' not in S):
    print('No')
else:
    print('Yes')

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

t = 0
for _s in s:
    if _s == "N":
        t += 1
    if _s == "S":
        t -= 1
    if _s == "E":
        t += 2
    if _s == "W":
        t -= 2

print("Yes" if t == 0 else "No")

Solution (Python):
s = input()
if (-1) ** (int("N" in s) + int("S" in s))==1 and (-1) ** (int("E" in s) + int("W" in s))==1:
  print("Yes")
else:
  print("No")

Solution (Python):
S = list(set(list(input())))
c = 0
for i in S:
    if i == "N":
        c += 1
    elif i == "W":
        c += 2
    elif i == "S":
        c -= 1
    else:
        c -= 2
if c == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
dic={"W":1,"E":-1,"N":10,"S":-10}
ans=0
for c in set(list(input())):
  ans+=dic[c]
print(("No","Yes")[ans==0])

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
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))

s = input()
c = Counter(s)
a,b,c,d = [c['N'], c['S'], c['W'], c['E']]
if (a and b) or (not a and not b):
    if (c and d) or (not c and not d):
        print('Yes')
        quit()
print('No')

Solution (Python):

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

Solution (Python):

S = input()

dic = {}

for i in S:

    dic[i] = 1

if len(dic) == 4:
    print ("Yes")

elif len(dic) == 2 and (("N" in dic and "S" in dic) or ("W" in dic and "E" in dic)) :
    print ("Yes")

else:
    print ("No")

Solution (Python):
def inpl():
    return list(map(int, input().split()))


def f(a, b):
    if a == 0 and b == 0:
        return True
    elif a * b == 0:
        return False
    else:
        return True


S = input()

cN = S.count('N')
cW = S.count('W')
cS = S.count('S')
cE = S.count('E')

if f(cN, cS) is True and f(cW, cE) is True:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")
ans = "Yes"

if N>=1 and S==0:
    ans = "No"
elif N==0 and S>=1:
    ans = "No"

if W>=1 and E==0:
    ans = "No"
elif W==0 and E>=1:
    ans = "No"

print(ans)

Solution (Python):
s = [c for c in input()]
a = [0, 0, 0, 0]
for c in s:
    if c == 'N':
        a[0] += 1
    elif c == 'S':
        a[1] += 1
    elif c == 'E':
        a[2] += 1
    elif c == 'W':
        a[3] += 1
if (a[0] != 0 and a[1] == 0 or a[0] == 0 and a[1] != 0) \
    or (a[2] != 0 and a[3] == 0 or a[2] == 0 and a[3] != 0):
    print('No')
else:
    print('Yes')

Solution (Python):


s=list(input())
if s.count('N')>0 and s.count('S')>0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
elif s.count('N')>0 and s.count('S')>0 and s.count('E')==0 and s.count('W')==0:
    print('Yes')
elif s.count('N')==0 and s.count('S')==0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
else:
    print('No')

Solution (Python):
pos = {'N':0, 'W':0, 'S':0, 'E':0}

for s in input(): pos[s] += 1
    
ans = 'Yes'

if not (pos['N'] and pos['S'] or not pos['N'] and not pos['S']): ans = 'No'
if not (pos['W'] and pos['E'] or not pos['W'] and not pos['E']): ans = 'No'

print(ans)

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

north = s.count("N")
west = s.count("W")
south = s.count("S")
east = s.count("E")

if north == 0:
    if south > 0:
        print("No")
        exit()
if south == 0:
    if north > 0:
        print("No")
        exit()
if west == 0:
    if east > 0:
        print("No")
        exit()
if east == 0:
    if west > 0:
        print("No")
        exit()
        
print("Yes")

Solution (Python):

import collections

S = input()
c = collections.Counter(S)
ans = "No"

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

print(ans)

Solution (Python):
from collections import defaultdict

S = input()
d = defaultdict(int)
for i in S:
    d[i] += 1

if len(d) == 1 or len(d) == 3:
    print('No')
else:
    if len(d) == 4:
        print('Yes')
    elif 'N' in d:
        if 'S' in d:
            print('Yes')
        else:
            print('No')
    elif 'W' in d:
        if 'E' in d:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Solution (Python):
S = input()
cnt_n = 0
cnt_w = 0
cnt_s = 0
cnt_e = 0

for i in S:
    if i == "N":
        cnt_n += 1
    elif i == "W":
        cnt_w += 1
    elif i == "S":
        cnt_s += 1
    else:
        cnt_e += 1

if cnt_n * cnt_w * cnt_s * cnt_e > 0:
    print("Yes")
elif (cnt_n == 0 and cnt_s == 0) and cnt_e * cnt_w > 0:
    print("Yes")
elif (cnt_n * cnt_s > 0) and (cnt_e == 0 and cnt_w == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
S=input()


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

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

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

if "S" in S:
    if not "N" in S:
        print("No")
        exit()
        
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()

NS = ('N' in S and 'S' in S) or ('N' not in S and 'S' not in S)
EW = ('E' in S and 'W' in S) or ('E' not in S and 'W' not in S)

if NS and EW:
    print('Yes')
else:
    print('No')

Solution (Python):
def NS(s):
    return 'N' in s and 'S' in s

def EW(s):
    return 'W' in s and 'E' in s

s = list(input())
if len(set(s)) == 2:
    if NS(s) or EW(s):
        print("Yes")
    else:
        print("No")
elif len(set(s)) == 4:
    if NS(s) and EW(s):
        print("Yes")
    else:
        print("No")    
else:
    print("No")

Solution (Python):
str = input()

n,s,e,w = -1,-1,-1,-1

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

ch = 1

if(n>=0 and s==-1):
    ch  = 0
elif(n==-1 and s>=0):
    ch  = 0
elif(w>=0 and e==-1):
    ch = 0
elif(e>=0 and w==-1):
    ch = 0

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

Solution (Python):
from collections import Counter

S = input()

c = Counter(S)
print('No' if bool(c['N']) ^ bool(c['S']) |
      bool(c['W']) ^ bool(c['E']) else 'Yes')

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

if 'N' in S:
    n = True
if 'S' in S:
    s = True
if 'E' in S:
    e = True
if 'W' in S:
    w = True

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

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

if len(S) == 4:
    print('Yes')
elif len(S) == 1 or len(S) == 3:
    print('No')
else:
    if {'N', 'S'} == S or {'W', 'E'} == S:
        print('Yes')
    else:
        print('No')

Solution (Python):
s = input()
A = ["N", "S", "E", "W"]
B = [0] * 4
for i in range(4):
    B[i] = s.count(A[i]) > 0

print("No" if (B[0]^B[1]) or (B[2]^B[3]) else "Yes")

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n')))
    if len(s) == 4:
        print("Yes")
    elif len(s) == 2:
        if "N" in s and "S" in s:
            print("Yes")
        elif "E" in s and "W" in s:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    slove()

Solution (Python):



import sys


def main():
    S = input()
    ary = ['N' in S, 'W' in S, 'S' in S, 'E' in S]

    if ary[0] == ary[2] and ary[1] == ary[3]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
src = input()
a = False
b = False
c = False
d = False
for s in src:
    if s == 'N':
        a = True
    elif s == 'W':
        b = True
    elif s == 'S':
        c = True
    elif s == 'E':
        d = True
if a != c or b != d:
    print('No')
else:
    print('Yes')

Solution (Python):
S=input()
[fN,fS,fE,fW]=[False]*4
for c in S:
    if fN and fS and fE and fW:
        break
    if c=='N':
        fN=True
    if c=='S':
        fS=True
    if c=='E':
        fE=True
    if c=='W':
        fW=True

if (fN and not fS) or (not fN and fS) or (fE and not fW) or (not fE and fW):
    print('No')
else:
    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 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):
import sys,os,random
S=input()
c={}
c['S']=c['N']=c['E']=c['W']=0
for i in S:c[i]=1
if(c['S']^c['N'])or(c['E']^c['W']):print("No")
else:print("Yes")

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

Solution (Python):
s = set(input())
if s in [{"N", "W", "S", "E"}, {"N", "S"}, {"W", "E"}]:
    print("Yes")
else:
    print("No")

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

S.sort()
e,w,n,s=S.count('E'),S.count('W'),S.count('N'),S.count('S')
flag=True
if max(e,w)>0 and min(e,w)==0:
  flag=False
if max(n,s)>0 and min(n,s)==0:
  flag=False
  
if flag:
  print('Yes')
else:
  print('No')

Solution (Python):
n = input()
sets = set(n)
flg = False
for i in [{'N','S','W','E'},{'N','S'},{'W','E'}]:
    if sets == i:
        flg = True
        break
     
print('Yes' if flg else '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 "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):
S = input()
nwse = [0, 0, 0, 0]

for x in S:
    if x == "N":
        nwse[0] += 1
    elif x == "W":
        nwse[1] += 1
    elif x == "S":
        nwse[2] += 1
    elif x == "E":
        nwse[3] += 1

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

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

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

Solution (Python):
import collections

S=input()
S=collections.Counter(S)

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

Solution (Python):
S=input()
print(['No','Yes'][('W'in S)==('E'in S)and('N'in S)==('S'in S)])

Solution (Python):
S=list(input())
ans="Yes"
n=S.count("N")
e=S.count("E")
w=S.count("W")
s=S.count("S")
if n>0 and s>0:
  if e>0 and w>0:
    pass
  elif e==0 and w==0:
    pass
  else:
    ans="No"
elif n==0 and s==0:
  if e>0 and w>0:
    pass
  elif e==0 and w==0:
    pass
  else:
    ans="No"
elif e>0 and w>0:
  if n>0 and s>0:
    pass
  elif n==0 and s==0:
    pass
  else:
    ans="No"
elif e==0 and w==0:
  if n>0 and s>0:
    pass
  elif n==0 and s==0:
    pass
  else:
    ans="No"
else:
  ans="No"
print(ans)

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7




S = sys.stdin.readline().rstrip()


n = 'N' in S
w = 'W' in S
s = 'S' in S
e = 'E' in S

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

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


if __name__ == "__main__":
    resolve()

Solution (Python):
def solve(s):
    s = set(s)
    if ("N" in s) and (not "S" in s):
        return "No"
    if ("S" in s) and (not "N" in s):
        return "No"
    if ("W" in s) and (not "E" in s):
        return "No"
    if ("E" in s) and (not "W" in s):
        return "No"
    return "Yes"

s = input()
print(solve(s))

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()
nN = 0
nW = 0
nS = 0
nE = 0
for c in S:
  if c == "N":
    nN += 1
  if c == "W":
    nW += 1
  if c == "S":
    nS += 1
  if c == "E":
    nE += 1
if (nN > 0 and nS == 0) or (nS > 0 and nN == 0) or (nW > 0 and nE == 0) or (nE > 0 and nW == 0):
  print("No")
else:
  print("Yes")

Solution (Python):
S=set(input());print("YNeos"[S!=set("NEWS")and S!={"N","S"}and S!={"E","W"}::2])

Solution (Python):
S = input()
if ('N' in S) ^ ('S' in S) or ('W' in S) ^ ('E' in S):
  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):
s = input()
from collections import Counter
c = Counter(s)
flag = True
if c["S"]>0 and c["N"]==0:
  flag = False
if c["N"]>0 and c["S"]==0:
  flag = False
if c["W"]>0 and c["E"]==0:
  flag = False
if c["E"]>0 and c["W"]==0:
  flag = False
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
s = set(input())
ALL = set("NSWE") 
NS = set("NS")
EW = set("EW")
if s == ALL or s == NS or s == EW:
  print("Yes")
else:
  print("No")

Solution (Python):
s=input();b=[x in s for x in['N','S','E','W']];print('Yes'if b[0]==b[1]and b[2]==b[3]else'No')

Solution (Python):
s = input()
a = ['N','S','E','W']
b = [x in s for x in a]

if b[0]==b[1] and b[2]==b[3]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = {st for st in input()}
if ({'S','N'} & s == {'S','N'} or {'S','N'} & s == set()) and ({'E','W'} & s == {'E','W'} or {'E','W'} & s == set()):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

hor = ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s)
ver = ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s)

ans = hor and ver

if ans:
  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")
a=0
b=0
if S>0 and N>0:
	a+=1
elif S==N==0:
	a+=1
if E>0 and W>0:
	b+=1
elif E==W==0:
	b+=1
if a==b==1:
	print("Yes")
else:
	print("No")

Solution (Python):
s = set(list(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 "W" in s:
  if "E" not in s:
    print("No")
    exit()
if "E" in s:
  if "W" not in s:
    print("No")
    exit()

print("Yes")

Solution (Python):



import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
N,W,S,E = 0,0,0,0
for i in range(n):
    if s[i] == 'N':
        N = 1
    elif s[i] == 'W':
        W = 1
    elif s[i] == 'S':
        S = 1
    elif s[i] == 'E':
        E = 1
if N & S and W & E:
    print('Yes')
elif (N==0 and S==0) and W&E:
    print('Yes')
elif N&S and (W==0 and E==0):
    print('Yes')
else:
    print('No')

Solution (Python):
x=input()
n=0
w=0
s=0
e=0
for i in range(len(x)):
    if x[i]=="N":
        n+=1
    elif x[i]=="W":
        w+=1
    elif x[i]=="S":
        s+=1
    else:
        e+=1

f=1
if n:
    if s:
        pass
    else:
        f=0
if s:
    if n:
        pass
    else:
        f=0
if w:
    if e:
        pass
    else:
        f=0
if e:
    if w:
        pass
    else:
        f=0

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

Solution (Python):
s = set(list(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 'W' in s:
  if 'E' not in s:
    print('No')
    exit()
if 'E' in s:
  if 'W' not in s:
    print('No')
    exit()
print('Yes')

Solution (Python):
import collections

s = input()
c = collections.Counter(s)

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

Solution (Python):
s=input()

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

Solution (Python):
s = input()
ans = "Yes"

if ("N" in s) ^ ("S" in s):
  print("No")
  exit()
else:
  ans = "Yes"

if ("W" in s) ^ ("E" in s):
  ans = "No"
else:
  ans = "Yes"

print(ans)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    ss = str(input().rstrip('\n'))
    n = 1 if ss.count("N") != 0 else 0
    w = 1 if ss.count("W") != 0 else 0
    s = 1 if ss.count("S") != 0 else 0
    e = 1 if ss.count("E") != 0 else 0
    if n == s and w == e:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()

Solution (Python):
def main():
    S = input()
    lc = list(set(list(S)))
    lc.sort()
    
    if lc == ["E", "N", "S", "W"] or lc == ["E", "W"] or lc == ["N", "S"]:
        return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

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

Solution (Python):
dire = [0,0,0,0]
d = {c:i for i,c in enumerate('WENS')}
for c in input():
	dire[d[c]] = 1
print('No' if (dire[0] ^ dire[1]) or (dire[2] ^ dire[3]) else '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 '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, math, fractions, itertools, collections, copy, heapq

YES = "Yes"  
NO = "No"  

def solve(s: str):
    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) or (E == 0 and W != 0) or (E != 0 and W == 0):
        print('No')
    else:
        print('Yes')
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
S = list(input())
s = set(Counter(S).keys())
if len(s) == 4:
    print("Yes")
elif len(s) == 2 and "E" in s and "W" in s:
    print("Yes")
elif len(s) == 2 and "N" in s and "S" in s:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N") > 0
w = S.count("W") > 0
e = S.count("E") > 0
s = S.count("S") > 0

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):
import sys
input=sys.stdin.readline

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

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

Solution (Python):
s = input()

ns, ew = 0, 0
if "N" in s:
    ns += 1
if "S" in s:
    ns -= 1
if "E" in s:
    ew += 1
if "W" in s:
    ew -= 1

if ns == 0 and ew == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
a=input();f=lambda x:x in a;print("YNeos"[f("N")^f("S")|f("W")^f("E")::2])

Solution (Python):
a=input();print("YNeos"[("N"in a)^("S"in a)|("W"in a)^("E"in a)::2])

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

if len(S) == 4:
    print ('Yes')
    exit()

if 'N' in S and 'S' in S and len(S) == 2:
    print ('Yes')
    exit()

if 'E' in S and 'W' in S and len(S) == 2:
    print ('Yes')
    exit()

print ('No')

Solution (Python):


s=set(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):
s = input()
ls =[False] * 4
for i in range(len(s)):
    if s[i] == "N":
        ls[0] = True
    elif s[i] == "W":
        ls[1] = True
    elif s[i] == "S":
        ls[2] = True
    elif s[i] == "E":
        ls[3] = True
print("Yes" if not(ls[0] ^ ls[2]) and not(ls[1] ^ ls[3]) else "No")

Solution (Python):
s=input()
l=len(s)
a=[0,0,0,0]
for i in range(l):
  if(s[i]=='N'):
    a[0]=1
  elif(s[i]=='W'):
    a[1]=1
  elif(s[i]=='S'):
    a[2]=1
  else:
    a[3]=1
if(a[0]*a[2]==0 and a[0]+a[2]!=0 or a[1]*a[3]==0 and a[1]+a[3]!=0):
  print("No")
else:
  print("Yes")

Solution (Python):
s = input()
if len(set(s)) % 2 == 1: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()
if ('N' in s)^('S' in s) or ('W' in s)^('E' in s):print('No')
else:print('Yes')

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

if 'E' in S :
    if 'W' in S:
        pass
    else:
        check = 1

if 'W' in S :
    if 'E' in S:
        pass
    else:
        check = 1

if 'N' in S :
    if 'S' in S:
        pass
    else:
        check = 1

if 'S' in S :
    if 'N' in S:
        pass
    else:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s=list(input())
sets=list(set(s))
sets.sort()
l=sets
x=''.join(l)
if x=='ENSW' or x=='EW' or x=='NS':
  print('Yes')
else:
  print('No')

Solution (Python):


s = input()
d = {"N":0,"W":0,"S":0,"E":0}

for c in s:
    d[c] += 1
flag = True
if d["N"] > 0:
    if d["S"] <= 0:
        flag = False
if d["S"] > 0:
    if d["N"] <= 0:
        flag = False
if d["W"] > 0:
    if d["E"] <= 0:
        flag = False
if d["E"] > 0:
    if d["W"] <= 0:
        flag = False


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

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

Solution (Python):
s=input()
l=list(s)
N=l.count("N")
W=l.count("W")
S=l.count("S")
E=l.count("E")

if N*S!=0 and E*W!=0:
    print("Yes")
elif N*S==0 and E*W!=0:
    if N==0 and S==0:
        print("Yes")
    else:
        print("No")
elif E*W==0 and N*S!=0:
    if E==0 and W==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):

def main():
    s = list(input())
    s = list(set(s))
    
    if len(s)==4:
        print("Yes")
    elif len(s)==3:
        print("No")
    elif len(s)==2:
        if "N"in s and "S" in s:
            print("Yes")
        elif "E" in s and "W" in s:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
if __name__=='__main__':
    main()

Solution (Python):
def check(a,b,l):
    return(any([a in l and b not in l,b in l and a not in l]))

s=input()
if any([check("N","S",s),check("E","W",s)]):print("No")
else:print("Yes")

Solution (Python):
a = input()
b = [False] * 4
for i in range(len(a)):
    if a[i] == "N":
        b[0] = True
    elif a[i] == "E":
        b[1] = True
    elif a[i] == "S":
        b[2] = True
    elif a[i] == "W":
        b[3] = True
if b[0] == b[2] and b[1] == b[3]:
    print("Yes")
else:
    print("No")

Solution (Python):

def main():
    S = input().rstrip()
    flg = (("N" in S) ^ ("S" in S) ^ 1) & (("E" in S) ^ ("W" in S) ^ 1)
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Solution (Python):

from collections import Counter


def main():
    D = Counter(input().rstrip())
    flg = True
    if (
        (D["N"] != 0 and D["S"] == 0)
        or (D["N"] == 0 and D["S"] != 0)
        or (D["E"] != 0 and D["W"] == 0)
        or (D["E"] == 0 and D["W"] != 0)
    ):
        flg = False
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    S = input().rstrip()
    D = {"N": 0, "S": 0, "E": 0, "W": 0}
    for i in S:
        D[i] += 1

    flg = [True] * 2
    if (D["N"] != 0 and D["S"] == 0) or (D["N"] == 0 and D["S"] != 0):
        flg[0] = False
    
    if (D["E"] != 0 and D["W"] == 0) or (D["E"] == 0 and D["W"] != 0):
        flg[1] = False

    print("Yes" if all(flg) else "No")


if __name__ == "__main__":
    main()

Solution (Python):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


def main():
    trip  = input()
    logging.info("Hello!")

    if (not (("S" in trip) ^  ("N" in trip))) and (not (("E" in trip) ^  ("W" in trip))):
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
a = [False]*4
b = list(input())
for i in range(len(b)):
    if b[i] == "N":
        a[0] = True
    elif b[i] == "W":
        a[1] = True
    elif b[i] == "S":
        a[2] = True
    elif b[i] == "E":
        a[3] = True
print("Yes" if a[0] == a[2] and a[1] == a[3] else "No")

Solution (Python):
S = input()

no = False
so = False
ea = False
we = False
for s in S:
    if s == 'N':
        no = True
    elif s == 'S':
        so = True
    elif s == 'E':
        ea = True
    elif s == 'W':
        we = True

if ((no and so) or (not no and not so)) and ((ea and we) or (not ea and not we)):
    print('Yes')
else:
    print('No')

Solution (Python):
def check(d1, d2, direction):
    if d1 in direction and not d2 in direction:
        return False
    if d2 in direction and not d1 in direction:
        return False
    return True

S = input()
direction = {s for s in S}
for (x, y) in [("N", "S"), ("W", "E")]:
    if not check(x, y, direction):
        print("No")
        exit()

print("Yes")

Solution (Python):
S = list(input())
tmp = "NWSE"
n = False
w = False
s = False
e = False
for i in range(len(S)):
    if S[i] == "W":
        w = True
    elif S[i] == "N":
        n = True
    elif S[i] == "E":
        e = True
    else:
        s = True

if w and e:
    if n:
        if s:
            print("Yes")
        else:
            print("No")
    elif s:
        print("No")
    else:
        print("Yes")
elif w or e:
    print("No")
else:
    if n and s:
        print("Yes")
    elif n or s:
        print("No")
    else:
        print("Yes")

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