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



Sample input:
SENW


Sample output:
Yes

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


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

    # See:
    # http://agc003.contest.atcoder.jp/data/agc/003/editorial.pdf
    # https://beta.atcoder.jp/contests/agc003/submissions/849782
    if (('S' in s) ^ ('N' in s)) or (('W' in s) ^ ('E' in s)):
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 文字列の読み込み
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
t = input()

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

# print(f'N : {n}, S : {s}')
# print(f'E : {e}, W : {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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
if (('N' in s)^('S' in s)) or (('W' in s)^('E' in s)):
	print("No")
else:
	print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
S=set(input())

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
S = set(raw_input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#AGC003A

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"

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3                                                          
# -*- coding: utf-8 -*-                                                         

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

Submission status: Accepted

Solution code:
# coding: UTF-8
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"

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
import sys
#sys.stdin = open('a_3.txt', 'r')
chars = list(raw_input())
#N, E, S, W
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'

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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'

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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