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):
def solve(S):
  if 'N' in S and 'S' not in S: return False
  if 'S' in S and 'N' not in S: return False
  if 'E' in S and 'W' not in S: return False
  if 'W' in S and 'E' not in S: return False 
  return True
print('Yes' if solve(input()) else '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):
    print('No')
elif (c['W'] == 0 and c['E'] > 0) or (c['E'] == 0 and c['W'] > 0):
    print('No')
else:
    print('Yes')

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

n=False
e=False
s=False
w=False
for i in S:
    if(i=="N"):
        n=True
    elif(i=="E"):
        e=True
    elif(i=="S"):
        s=True
    elif(i=="W"):
        w=True
    if(n and e and s and w):
        break

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

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

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

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

Solution (Python):
S = str(input())
T = set([x for x in S])

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

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

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 = input()
dp = [False]*4

for c in s:
	if c == "N":
		dp[0] = True
	elif c == "S":
		dp[1] = True
	elif c == "E":
		dp[2] = True
	elif c == "W":
		dp[3] = True

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

Solution (Python):
s = raw_input()

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

Solution (Python):
directions=input()
sens=["N","S","W","E"]
compteur=[0]*4
for direction in directions:
    compteur[sens.index(direction)]+=1

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

Solution (Python):
y=raw_input()
f=0
if y.count('N')>0:
	if y.count('S')==0:
		f=1

if y.count('S')>0:
	if y.count('N')==0:
		f=1

if y.count('E')>0:
	if y.count('W')==0:
		f=1


if y.count('W')>0:
	if y.count('E')==0:
		f=1

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

Solution (Python):
s = raw_input()
up,down,left,right = False,False,False,False
for i in xrange(len(s)) :
    if s[i] == 'N' :
        up = True
    elif s[i] == 'S' :
        down = True
    elif s[i] == 'E' :
        left = True
    else :
        right = True
if (up!=down) or (left!=right) :
    print 'No'
else :
    print 'Yes'

Solution (Python):
s = raw_input()
count = {}
count['N'] = 0
count['W'] = 0
count['E'] = 0
count['S'] = 0
for c in s:
    count.setdefault(c,0)
    count[c] += 1

ok = True

if(count['N']==0 and count['S']!=0): ok = False
if(count['N']!=0 and count['S']==0): ok = False
if(count['W']==0 and count['E']!=0): ok = False
if(count['W']!=0 and count['E']==0): ok = False

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

Solution (Python):

import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
N = S = W = E = 0
for si in s:
    if si == "N": N = 1
    if si == "S": S = 1
    if si == "W": W = 1
    if si == "E": E = 1
print "Yes" if N == S and W == E else "No"

Solution (Python):
S = input()
is_N = S.find("N") != -1
is_W = S.find("W") != -1
is_S = S.find("S") != -1
is_E = S.find("E") != -1
if is_N:
    if is_S:
        flg = True
    else:
        flg = False
else:
    if is_S:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


if is_W:
    if is_E:
        flg = True
    else:
        flg = False
else:
    if is_E:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


print("Yes")

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()
check = set(S)

success = True

if 'W' in check and 'E' not in check\
    or 'E' in check and 'W' not in check\
    or 'N' in check and 'S' not in check\
    or 'S' in check and 'N' not in check:
    success = False

if success:
    print 'Yes'
else:
    print 'No'

Solution (Python):
S = raw_input()

ans = True

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

Solution (Python):
def solve():
    s = input()
    v = 0
    h = 0
    if 'N' in s:
        v -= 1
    if 'S' in s:
        v += 1
    if 'W' in s:
        h -= 1
    if 'E' in s:
        h += 1
    print('Yes' if v == 0 and h == 0 else 'No')


def main():
    solve()


if __name__ == '__main__':
    main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

s = input()
f = [False] * 4
for c in s:
    if c == 'N':
        f[0] = True
    elif c == 'S':
        f[1] = True
    elif c == 'W':
        f[2] = True
    else:
        f[3] = True
if f[0] == f[1] and f[2] == f[3]:
    print("Yes")
else:
    print("No")

Solution (Python):
S = raw_input()
if ((S.find("N")>=0 and S.find("S")>=0 or S.find("N")<0 and S.find("S")<0) and
    (S.find("E")>=0 and S.find("W")>=0 or S.find("E")<0 and S.find("W")<0)):
	print "Yes"
else:
	print "No"

Solution (Python):
home = True
s = raw_input().strip()
if 'N' in s and 'S' not in s:
    home = False
if 'S' in s and 'N' not in s:
    home = False
if 'W' in s and 'E' not in s:
    home = False
if 'E' in s and 'W' not in s:
    home = False
print('Yes' if home else 'No')

Solution (Python):
from collections import Counter

cnt = Counter(input())

print("No" if sum(x in cnt for x in "NS") == 1 or sum(x in cnt for x in "WE") == 1 else "Yes")

Solution (Python):
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')


def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())


def join(s):
    return ''.join(s)


def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)


def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m


def index(a, x):
    
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1


def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m



s=slist()
ns=0
ew=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%2==0 and ew%2==0):
    print "Yes"
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')