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):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

SS = list(input())
W = N = S = E = 0
for s in SS:
	if s == 'W':
		W += 1
	elif s == 'N':
		N += 1
	elif s == 'S':
		S += 1
	elif s == 'E':
		E += 1

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

Solution (Python):
Ss = input()

setS = set(Ss)
lenS = len(setS)

if lenS in [1, 3]:
    print('No')
elif lenS == 4:
    print('Yes')
else:
    if setS in [set('NS'), set('WE')]:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()

from collections import Counter

cs = Counter(S)

result = not (((cs["N"] > 0) ^ (cs["S"] > 0)) | ((cs["W"] > 0) ^ (cs["E"] > 0)))

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

Solution (Python):
s=input();print(['Yes','No'][(('N'in s)^('S'in s))|(('E'in s)^('W'in s))])

Solution (Python):
s=input();print('No'if(('N'in s)^('S'in s))|(('E'in s)^('W'in s))else'Yes')

Solution (Python):
s = input()

cnt_n = s.count('N')
cnt_s = s.count('S')
cnt_e = s.count('E')
cnt_w = s.count('W')

p1 = ((cnt_n > 0) and (cnt_s > 0)) or ((cnt_n == 0) and (cnt_s == 0))
p2 = ((cnt_e > 0) and (cnt_w > 0)) or ((cnt_e == 0) and (cnt_w == 0))
print('Yes' if p1 and p2 else 'No')

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

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

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

backhome()

Solution (Python):
s = input()
print(["Yes","No"][(("N"in s) ^ ("S"in s)) or (("W"in s) ^ ("E" in s))])

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

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

Solution (Python):
import collections
s = input()
d = collections.Counter(s)
if len(d.keys()) == 4:
    print("Yes")
elif len(d.keys()) == 2 and "N" in d.keys() and "S" in d.keys():
    print("Yes")
elif len(d.keys()) == 2 and "E" in d.keys() and "W" in d.keys():
    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) or (s == 0 and n > 0) or (w == 0 and e > 0) or (e == 0 and w > 0):
    print("No")
else:
    print("Yes")

Solution (Python):
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

s = "".join(arr_data[0])

if s.find("N")>=0 and s.find("S")>=0 and s.find("E")>=0 and s.find("W")>=0:
    
    print("Yes")
    
elif s.find("N")>=0 and s.find("S")>=0 and s.find("E")==-1 and s.find("W")==-1:
    
    print("Yes")
    
elif s.find("E")>=0 and s.find("W")>=0 and s.find("N")==-1 and s.find("S")==-1:
    
    print("Yes")
    
else:
    
    print("No")

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

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

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

Solution (Python):
import collections
S = input().strip()
count = collections.Counter(S)

cond1 = (count['N']==0) == (count['S']==0)
cond2 = (count['E']==0) == (count['W']==0)
if cond1 and cond2:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
S_list = []
for i in range(len(S)):
    if S[i] == "N":
        S_list.append(0)
    elif S[i] == "W":
        S_list.append(1)
    elif S[i] == "S":
        S_list.append(2)
    elif S[i] == "E":
        S_list.append(3)

route = [0, 0, 0, 0]

for i in S_list:
    route[i] += 1
if route[0] != 0 and route[1] == 0 and route[2] != 0 and route[3] == 0:
    print("Yes")
elif route[0] == 0 and route[1] != 0 and route[2] == 0 and route[3] != 0:
    print("Yes")
elif route[0] != 0 and route[1] != 0 and route[2] != 0 and route[3] != 0:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from collections import Counter
a=Counter(set(list(input().strip())))

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

Solution (Python):
s=input();f=lambda c:c in s;print(['Yes','No'][f('N')^f('S') or f('E')^f('W')])

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

Solution (Python):
s=list(input())
n=len(s)
n_cnt,w_cnt,s_cnt,e_cnt=0,0,0,0
for i in range(n):
    if s[i]=="N":
        n_cnt=1
    elif s[i]=="W":
        w_cnt=1
    elif s[i]=="S":
        s_cnt=1
    elif s[i]=="E":
        e_cnt=1
if n_cnt+w_cnt+s_cnt+e_cnt==4:
    print("Yes")
elif n_cnt+s_cnt==2 and w_cnt+e_cnt==0:
    print("Yes")
elif e_cnt+w_cnt==2 and n_cnt+s_cnt==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
c = collections.Counter(input())
if (c['N'] > 0) ^ (c['S'] > 0):
    print('No')
elif (c['W'] > 0) ^ (c['E'] > 0):
    print('No')
else:
    print('Yes')

Solution (Python):
import collections
cnt = collections.Counter(input())
ans = 'Yes'
if (cnt['E'] == 0) ^ (cnt['W'] == 0):
    ans = 'No'
if (cnt['N'] == 0) ^ (cnt['S'] == 0):
    ans = 'No'
print(ans)

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

Solution (Python):
S = input()

M = ["N","W","S","E"]
Sw = [0,0,0,0]

for i in range(4):
    if M[i] in S: Sw[i] += 1
        
if (Sw[0]+Sw[2])%2==0 and (Sw[1]+Sw[3])%2==0:
    print("Yes")
else:
    print("No")

Solution (Python):






if __name__ == '__main__':
    s = input()

    
    
    
    if (('S' in s) ^ ('N' in s)) or (('W' in s) ^ ('E' in s)):
        print('No')
    else:
        print('Yes')

Solution (Python):






if __name__ == '__main__':
    from collections import Counter

    s = Counter(input())

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

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

Solution (Python):
a = input()

b = a.count('N')
c = a.count('S')
d = a.count('W')
e = a.count('E')

if (b != 0 and c== 0) or (b == 0 and c != 0):
    print('No')
elif (d != 0 and e== 0) or (d == 0 and e != 0):
    print('No')
else:
    print('Yes')

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    s = input()
    parity_sn = 0
    if "S" in s:
        parity_sn += 1
    if "N" in s:
        parity_sn += 1
    parity_ew = 0
    if "E" in s:
        parity_ew += 1
    if "W" in s:
        parity_ew += 1
    if parity_sn % 2 == parity_ew % 2 == 0:
        print("Yes")
    else:
        print("No")

main()

Solution (Python):




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

Solution (Python):
S = input()
flag = []
yoko = 0
tate = 0
for i in S:
    if i not in flag:
        flag.append(i)
        if i == "W":
            yoko += 1
        elif i == "E":
            yoko -= 1
        elif i == "N":
            tate += 1
        else:
            tate -= 1
if yoko == 0 and tate == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    S = input()

    s = set(S)
    if s == set("NWSE") or s == set("NS") or s == set("WE"):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

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

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):
t = input()

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

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

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

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




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

Solution (Python):
s = input().rstrip()
dir = set()
for i in range(len(s)):
  dir.add(s[i])
if len(dir)%2 == 0:
  if ('N' in dir and 'S' in dir) or ('E' in dir and 'W' in dir):
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

Solution (Python):
s = list(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())
if (("N" in s)^("S" in s)) or (("W" in s)^("E" in s)):
	print("No")
else:
	print("Yes")

Solution (Python):
import sys
s=input()
op={"N":"S","S":"N","W":"E","E":"W"}
for i in s:
  if(op[i] not in s):
    print("No")
    sys.exit()
print("Yes")

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

Solution (Python):
def isAbleToBack(plan):
    alphaToInt = {'E':0, 'W':1, 'N':2, 'S':3}
    count = [False]*4
    for c in plan:
        count[alphaToInt[c]] = True
    for i in xrange(4):
        if count[i] and not count[i^1]:
            return False
    return True

def main():
    plan = raw_input().strip()
    if isAbleToBack(plan):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()

Solution (Python):
S = [i for i in input()]
North = 0
East = 0
West = 0
South = 0
for i in S:
    if i == "N":
        North += 1
    elif i == "E":
        East += 1
    elif i == "W":
        West += 1
    else:
        South += 1
if North*East*West*South > 0:
    print("Yes")
else:
    if North *South == 0 and North+South > 0:
        print("No")
    elif East*West == 0 and East+West>0:
        print("No")
    else:
        print("Yes")

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

if S=={"E","N","S","W"} or S=={"N","S"} or S=={"E","W"}:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
S = input()
c = Counter(S)
if (c['N'] > 0 and c['S'] == 0) or (c['S'] > 0 and c['N'] == 0) or\
   (c['W'] > 0 and c['E'] == 0) or (c['E'] > 0 and c['W'] == 0):
    print('No')
else:
    print('Yes')

Solution (Python):

S = input()
y, x = set(), set()
for c in S:
    if c == 'N' or c == 'S':
        y.add(c)
    else:
        x.add(c)

print(('No', 'Yes')[len(y) % 2 == 0 and len(x) % 2 == 0])

Solution (Python):
S=raw_input()
print "No" if ("S" in S)+("N" in S)==1 or ("W" in S)+("E" in S)==1 else "Yes"

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

Solution (Python):
s = raw_input()
i=lambda c:c in s
print "No"*((i('N')^i('S'))or(i('W')^i('E')))or"Yes"

Solution (Python):
S = input()

print('No' if ('E' in S) ^ ('W' in S) or ('S' in S) ^ ('N' in S) else 'Yes')

Solution (Python):



import collections

def main():
    S = input()

    c = collections.Counter(S)
    if (c["N"] > 0 and c["S"] == 0) or (c["N"] == 0 and c["S"] > 0):
        ok = False
    elif (c["W"] > 0 and c["E"] == 0)  or (c["W"] == 0 and c["E"] > 0):
        ok = False
    else:
        ok = True

    print("Yes" if ok else "No")

if __name__ == "__main__": main()

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    S = input()
    c = Counter(S)
    n, w, s, e = c["N"], c["W"], c["S"], c["E"]
    if n == s or (n != 0 and s != 0):
        if w == e or (w != 0 and e != 0):
            print("Yes")
            return
    print("No")


if __name__ == '__main__':
    main()

Solution (Python):
def wanna_go_home():
	s = str(raw_input())
	setlist = sorted(list(set(s)))
	distinct_chars = len(setlist)
	if distinct_chars%2!=0:
		print "No"
	else:
		if distinct_chars==4:
			print "Yes"
		else:
			if ''.join(setlist)=='NS' or ''.join(setlist)=='EW':
				print "Yes"
			else:
				print "No"


if __name__ == "__main__":
	wanna_go_home()

Solution (Python):
from collections import Counter

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

Solution (Python):
from sys import stdin

def main():
    M = stdin.readline().strip()
    S,E,N,W=False,False,False,False
    for i in M:
        if i == 'S':
            S = True
        elif i == 'E':
            E = True
        elif i == 'N':
            N = True
        elif i == 'W':
            W = True
    if S == N and E == W:
        print('Yes')
    else:
        print('No')

main()

Solution (Python):
import sys

s = input()

if s.find('N') != -1:
    if s.find('S') == -1:
        print('No')
        sys.exit()

if s.find('S') != -1:
    if s.find('N') == -1:
        print('No')
        sys.exit()

if s.find('W') != -1:
    if s.find('E') == -1:
        print('No')
        sys.exit()

if s.find('E') != -1:
    if s.find('W') == -1:
        print('No')
        sys.exit()
        
print('Yes')

Solution (Python):
if __name__ == "__main__":
    S = input()
    res = set(S)
    ok = True
    for x in S:
        if x == 'N':
            if 'S' not in res:
                ok = False
        elif x == 'S':
            if 'N' not in res:
                ok = False
        elif x == 'E':
            if 'W' not in res:
                ok = False
        elif x == 'W':
            if 'E' not in res:
                ok = False
    if ok:
        print ('Yes')
    else:
        print ("No")

Solution (Python):

S = list(input())
flag1 = True 
flag2 = True
list1 = [ tmp for tmp in S if tmp == 'N' or tmp == 'S' ]
list2 = [ tmp for tmp in S if tmp == 'W' or tmp == 'E' ]
if len(list1) > 0:
    if 'N' in list1 and 'S' in list1:
        pass
    else:
        flag1 = False
if len(list2) > 0:
    if 'W' in list2 and 'E' in list2:
        pass
    else:
        flag2 = False
if flag1 and flag2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n+ss)%2==0 and (e+w)%2==0:
    print("Yes")
else:
    print("No")

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

if len(set("NS") & S) == 1:
    print "No"
elif len(set("WE") & S) == 1:
    print "No"
else:
    print "Yes"

Solution (Python):



from random import *

s = input()
m = {}
for ch in s:
    m.update({ch:1})
res = (m.get('N') == m.get('S')) and m.get('W') == m.get('E')
if res:
    print('Yes')
else:
    print('No')

Solution (Python):
s = raw_input()
bls = [False for _ in range(4)]
for c in s:
    if c == 'N':
        bls[0] = True
    elif c == 'E':
        bls[1] = True
    elif c == 'W':
        bls[2] = True
    elif c == 'S':
        bls[3] = True
if bls[0] == bls[3] and bls[1] == bls[2]:
    print 'Yes'
else:
    print 'No'

Solution (Python):
Str = input()
N = False
W = False
S = False
E = False

for i in Str:
    if i == 'N':
        N = True
    if i == 'W':
        W = True
    if i == 'S':
        S = True
    if i == 'E':
        E = True
if (N == True and S == False) or (N == False and S == True):
    print("No")
elif (W == True and E == False) or (W == False and E == True):
    print("No")
else:
    print("Yes")

Solution (Python):
d={"N":0,"W":0,"S":0,"E":0}
s=raw_input()
for i in xrange(len(s)):
    d[s[i]]+=1
if((d["N"]==0 and d["S"]==0) or (d["N"]>0 and d["S"]>0)) and ((d["E"]==0 and d["W"]==0) or (d["E"]>0 and d["W"]>0)):
    print "Yes"
else: print "No"

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

Solution (Python):
from collections import Counter
c = Counter(input())
print("Yes" if ((c["N"] > 0 and c["S"] > 0) or c["N"] == c["S"]) \
     and ((c["E"] > 0 and c["W"] > 0) or c["E"] == c["W"]) else "No")

Solution (Python):
S = raw_input()
S = list(S)
S = set(S)
flagSN = False
flagEW = False
if ('N' in S and 'S' in S) or ('N' not in S and 'S' not in S):
  flagSN = True
if ('W' in S and 'E' in S) or ('W' not in S and 'E' not in S):
  flagEW = True
if flagSN and flagEW:
  print 'Yes'
else:
  print 'No'

Solution (Python):
S = raw_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

ns = (n+s)%2
ew = (e+w)%2

print 'Yes' if ns+ew == 0 else 'No'

Solution (Python):
n = w = s = e = 0
for c in input():
	if c == "N":
		n += 1
	if c == "W":
		w += 1
	if c == "S":
		s += 1
	if c == "E":
		e += 1
b = ((n >= 1 and s >= 1) or (n==s==0)) and ((w >= 1 and e >= 1) or (w==e==0))
print("Yes" if b else "No")

Solution (Python):
str = input()

flg = [False]*4
for s in str:
    if s == 'N':
        flg[0] = True
    elif s == 'S':
        flg[1] = True
    elif s == 'E':
        flg[2] = True
    elif s == 'W':
        flg[3] = True

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

Solution (Python):


s=raw_input()
l=[s[i] for i in xrange(len(s))]
if l.count('N')==0 and l.count('S')>0:
 print "No"
elif l.count('N')>0 and l.count('S')==0:
 print "No"
elif l.count('E')==0 and l.count('W')>0:
 print "No"
elif l.count('E')>0 and l.count('W')==0:
 print "No"
else:
 print "Yes"

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

Solution (Python):
S = list(input())
direction = ["N", "W", "S", "E"]
cnt = [0] * 4

for s in S:
    for i in range(4):
        if s == direction[i]:
            cnt[i] += 1

f1 = False
f2 = False

if (cnt[0] > 0 and cnt[2] > 0) or (cnt[0] == 0 and cnt[2] == 0):
    f1 = True
if (cnt[1] > 0 and cnt[3] > 0) or (cnt[1] == 0 and cnt[3] == 0):
    f2 = True

if f1 and f2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = raw_input()
print 'No' if (('N' in s) ^ ('S' in s)) or (('W' in s) ^ ('E' in s)) else 'Yes'

Solution (Python):
s = input()
f = lambda c: c in s
print('No' if f('N')^f('S') or f('E')^f('W') else 'Yes')

Solution (Python):
str = raw_input()
countN = str.count("N")
countS = str.count("S")
firstPair = False
if (countN == countS) or (countN * countS != 0):
    firstPair = True

countE = str.count("E")
countW = str.count("W")
secondPair = False
if (countE == countW) or (countE * countW != 0):
    secondPair = True

if (firstPair * secondPair == 1):
    print "Yes"
else:
    print "No"

Solution (Python):
s=set(list(input()))
if s=={'N','S'} or s=={'E','W'} or s=={'N','E','W','S'}:
    print('Yes')
else:
    print('No')

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

Solution (Python):

if __name__ == '__main__':
    clist = list(input())
    chars = ['N', 'W', 'S', 'E']
    a = []
    for c in chars:
        a.append(clist.count(c))
    for i in [0, 1]:
        if (a[i] > 0):
            if (a[i + 2] == 0):
                print('No')
                exit()
        if (a[i + 2] > 0):
            if (a[i] == 0):
                print('No')
                exit()
    print('Yes')

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

flag_N,flag_E,flag_W,flag_S = 0,0,0,0

if "N" in s:
    flag_N = 1
if "E" in s:
    flag_E = 1
if "W" in s:
    flag_W = 1
if "S" in s:
    flag_S = 1

if ((flag_N == 1 and flag_S == 0) or (flag_N == 0 and flag_S == 1)
    or (flag_E == 1 and flag_W ==0) or (flag_E == 0 and flag_W == 1)):
    print("No")
else:
    print("Yes")

Solution (Python):
s = raw_input()
i=lambda c:c in s
print "No"*((i('N')^i('S'))or(i('W')^i('E')))or"Yes"

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

if (s == n):
 if (e>=1 & w >= 1):
  print ("Yes")
 else:
  print ("No")
elif (e == w):
 if (s >= 1 & n >= 1):
  print ("Yes")
 else:
  print ("No")
else:
 print ("No")

Solution (Python):
IN = list(raw_input())
N = 0
S = 0
E = 0
W = 0

for i in range(len(IN)):
    if IN[i] == 'N':
        N += 1
    elif IN[i] == 'S':
        S += 1
    elif IN[i] == 'E':
        E += 1
    elif IN[i] == 'W':
        W += 1

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

Solution (Python):
import sys
line = sys.stdin.readline().strip()

n = "N" in line
s = "S" in line
e = "E" in line
w = "W" in line

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

Solution (Python):
import numpy as np
s = np.array(list(raw_input()))
e = np.unique(s)
if len(e) % 2 == 1:
    print 'No'
elif len(e) == 2:
    if 'N' in e and 'S' in e:
        print 'Yes'
    elif 'W' in e and 'E' in e:
        print 'Yes'
    else:
        print 'No'
else:
    print 'Yes'

Solution (Python):
if __file__.startswith('/tmp/'):
	import sys; sys.stdin = open('input.txt')

ctr = [0] * 4

for c in raw_input().strip():
	ctr['NSWE'.index(c)] = 1

if ctr[0] == ctr[1] and ctr[2] == ctr[3]:
	print 'Yes'
else:
	print 'No'

Solution (Python):
S0=input()
N=E=W=S=False
for i in range(len(S0)):
    if S0[i]=='N':
        N=True
    elif S0[i]=='E':
        E=True
    elif S0[i]=='W':
        W=True
    else:
        S=True

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

Solution (Python):
x = raw_input()
n = x.count('N')
e = x.count('E')
w = x.count('W')
s = x.count('S')
if n > 0:n = 1
if e > 0:e = 1
if w > 0:w = 1
if s > 0:s = 1

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

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

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

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

Solution (Python):
S = input()

N_Flag = True if 'N' in S else False
E_Flag = True if 'E' in S else False
W_Flag = True if 'W' in S else False
S_Flag = True if 'S' in S else False

if ((N_Flag is S_Flag) and (E_Flag is W_Flag)):
    print ("Yes")
else:
    print ("No")

Solution (Python):



S = set(input())
if ('S' in S and 'N' not in S) or \
   ('N' in S and 'S' 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 = raw_input()

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

Solution (Python):
ans = 'Yes'

S = list(raw_input())

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

elif S.count('W') == 0 and S.count('E') != 0:
  ans = 'No'

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

elif S.count('E') == 0 and S.count('W') != 0:
  ans = 'No'

print ans

Solution (Python):
import sys

chars = list(raw_input())

directions = [0 for _ in range(4)]

for c in chars:
	if c == 'N':
		directions[0] = 1
	elif c == 'E':
		directions[1] = 1
	elif c == 'S':
		directions[2] = 1
	else:
		directions[3] = 1

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

Solution (Python):
import math,sys
s = list(raw_input())
if len(s) == 0:
    print "Yes"
    sys.exit()
if s.count("N") == s.count("S") == 0:
    if "E" in s and "W" in s:
        print "Yes"
        sys.exit()
if s.count("E") == s.count("W") == 0:
    if "N" in s and "S" in s:
        print "Yes"
        sys.exit()
if "W" in s and "E" in s and "N" in s and "S" in s:
    print "Yes"
    sys.exit()
print "No"

Solution (Python):
s = input()
str_set = set([i for i in s])
n = len(str_set)

if len(str_set) == 4:
    print("Yes")
elif len(str_set) == 2:
    if( "S" in str_set and "N" in str_set) or ("W" in str_set and "E" in str_set):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

if n-s !=0 and n*s==0:
    print('No')
    exit()
    
if w-e !=0 and w*e==0:
    print('No')
    exit()

print('Yes')

Solution (Python):
s=raw_input()
cntn=0
cnts=0
cnte=0
cntw=0
for i in s:
    if i=="S":
        cnts+=1
    elif i=="E":
        cnte+=1
    elif i=="N":
        cntn+=1
    else:
        cntw+=1
if cntn>0 and cnts>0 and cntw>0 and cnte>0:
    print("Yes")
elif cntn>0 and cnts>0 :
    if cntw==0 and cnte==0:
        print('Yes')
    else:
        print('No')
elif cntn==0 and cnts==0:
    if cntw>0 and cnte>0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
a = raw_input()
n, w, s, e = -1, -1, -1, -1

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

if w * e > 0 and n * s > 0:
	print "Yes"
else:
	print "No"

Solution (Python):
S = input()

def f(a, b, s):
    if a in s and b in s:
        return True
    elif not a in s and not b in s:
        return True
    else:
        return False

if f('N', 'S', S) and f('W', 'E', S):
    print("Yes")
else:
    print("No")

Solution (Python):
S = set(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()
for l in s:
	if l == "N":
		if "S" not in s:
			print("No")
			break
	if l == "S":
		if "N" not in s:
			print("No")
			break
	if l == "E":
		if "W" not in s:
			print("No")
			break
	if l == "W":
		if "E" not in s:
			print("No")
			break
else:
	print("Yes")

Solution (Python):
S = input()

flag = True

s = not (S.find("S") == -1)
n = not (S.find("N") == -1)
w = not (S.find("W") == -1)
e = not (S.find("E") == -1)

flag &= not s^n
flag &= not w^e

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

Solution (Python):
s = raw_input().strip()
ans = f = 0
for c in 'NS':
    if s.count(c):
        f ^= 1
ans |= f
f = 0
for c in 'EW':
    if s.count(c):
        f ^= 1
ans |= f
print "No" if ans else "Yes"