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

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

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

Submission status: Accepted

Solution code:
s=input()

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

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

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

print("No")

Submission status: Accepted

Solution code:
a = input()
v = 0
h = 0
if a.count('W') >=1:
  if a.count('E') ==0:
    print('No')
    exit()
if a.count('E') >=1:
  if a.count('W') ==0:
    print('No')
    exit()
if a.count('N')>= 1:
  if a.count('S') ==0:
    print('No')
    exit()
if a.count('S')>= 1:
  if a.count('N')==0:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
s = list(input())

s = set(s)

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

Submission status: Accepted

Solution code:
S = str(input())
ans = True
if ('N' in S) ^ ('S' in S) == 1:
  ans = False
if ('E' in S) ^ ('W' in S) == 1:
  ans = False
if ans: print('Yes')
else: print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = set(input())

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

Submission status: Accepted

Solution code:
S = input()

cN, cS, cW, cE = 0, 0, 0, 0
for ch in S:
    if ch == 'E':
        cE += 1
    elif ch == 'W':
        cW += 1
    elif ch == 'S':
        cS += 1
    else:
        cN += 1

# もし左右，上下の回数が割り切れたらOK
# 仮定: cE > cW, cN > cS

# if (cW == 0 and cE != 0) or (cW != 0 and cE == 0) or \
#     (cS == 0 and cN != 0) or (cS != 0 and cN == 0):
#     print("No")
# elif cW == 0 and cW == 0:
#     if cS != 0 and cN != 0:
#         print("Yes")
#     else:
#         print("No")
# else:
#     if cS != 0 and cN != 0:
#         print("Yes")
#     else:
#         print("No")

if (cW > 0 and cE == 0) or (cW == 0 and cE > 0) or \
    (cS > 0 and cN == 0) or (cS == 0 and cN > 0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = set(list(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 = set(list(input()))
ans = 'Yes'
if ('N' in s)!=('S' in s) or ('W' in s)!=('E' in s):ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = set(list(input()))
ans = 'Yes'
if ('N' in s)!=('S' in s):ans = 'No'
elif ('W' in s)!=('E' in s):ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = set(list(input()))
ans = "Yes"
if ("N" in s) != ("S" in s):
    ans = "No"
if ("E" in s) != ("W" in s):
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
s = set(list(input()))
ans = 'Yes'
if 'N' in s and not 'S' in s or 'S' in s and not 'N' in s:
    ans = 'No'
elif 'W' in s and not 'E' in s or 'E' in s and not 'W' in s:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
import collections
s = set(list(input()))
ans = 'Yes'
if 'N' in s and not 'S' in s or 'S' in s and not 'N' in s:
    ans = 'No'
elif 'W' in s and not 'E' in s or 'E' in s and not 'W' in s:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = input()
s = set(list(s))
if ("N" in s) != ("S" in s):
    print("No")
    exit()
if ("E" in s) != ("W" in s):
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
s = [s for s in input()]
cnt = Counter(s)
if "N" in cnt.keys() or "S" in cnt.keys():
    if "N" not in cnt.keys() or "S" not in cnt.keys():
        print("No")
        exit()
if "W" in cnt.keys() or "E" in cnt.keys():
    if "W" not in cnt.keys() or "E" not in cnt.keys():
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def main():
    from collections import Counter
    s = list(input())
    a = 'E' in s
    b = 'W' in s
    c = 'N' in s
    d = 'S' in s

    if not (a ^ b) and not (c ^ d):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())
f = {
    "N": False,
    "S": False,
    "W": False,
    "E": False
}
for i in s:
    f[i] = True

if (f["N"] ^ f["S"]):
    print("No")
elif (f["W"] ^ f["E"]):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S=input()

ans="No"
n=0
w=0
e=0
s=0
tate=0
yoko=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)

Submission status: Accepted

Solution code:
S = input()


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

Submission status: Accepted

Solution code:
s=input()
scnt,ncnt,wcnt,ecnt=0,0,0,0
for i in range(len(s)):
    if(s[i]=='S'):
        scnt+=1
    elif(s[i]=='N'):
        ncnt+=1
    elif(s[i]=='E'):
        ecnt+=1
    elif(s[i]=='W'):
        wcnt+=1
if((scnt!=0 and ncnt==0) or (scnt==0 and ncnt!=0) or (wcnt>0 and ecnt==0) or (wcnt==0 and ecnt>0)):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
bit = 0
for i in S:
  if i == 'N':
    bit |= 1
  elif i == 'E':
    bit |= 2
  elif i == 'S':
    bit |= 4
  elif i == 'W':
    bit |= 8
  if bit == 15:
    break
if bit % 5 == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
def main():
    direction = input()
    now = [0, 0]
    dir_count = {"N": 0, "E": 0, "S": 0, "W": 0}
    for d in direction:
        dir_count[d] += 1
        if d == "N":
            now[0] += 1
        elif d == "E":
            now[1] += 1
        elif d == "S":
            now[0] -= 1
        else:
            now[1] -= 1
    answer = False
    if ((now[1] < 0 and 0 < dir_count["E"]) or (0 < now[1] and 0 < dir_count["W"]) or now[1] == 0) and \
            ((now[0] < 0 and 0 < dir_count["N"]) or (0 < now[0] and 0 < dir_count["S"]) or now[0] == 0):
        answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
st = input()
sn = len(st)

n, s, e, w = 0, 0, 0, 0
for i in range(sn):
  if st[i] == "N":
    n += 1
  if st[i] == "S":
    s += 1
  if st[i] == "E":
    e += 1
  if st[i] == "W":
    w += 1

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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())

c = Counter(S)
flag1 = False
flag2 = False
if "S" in c and "N" in c:
    flag1 = True
elif "S" not in c and "N" not in c:
    flag1 = True

if "W" in c and "E" in c:
    flag2 = True
elif "W" not in c and "E" not in c:
    flag2 = True

if flag1 and flag2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(list(input()))

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

Submission status: Accepted

Solution code:
def examA():
    S = SI()
    if "W" in S and not "E" in S:
        print("No")
    elif "E" in S and not "W" in S:
        print("No")
    elif "N" in S and not "S" in S:
        print("No")
    elif "S" in S and not "N" in S:
        print("No")
    else:
        print("Yes")
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    S = [I()for _ in range(N)]

    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    travel_plan = input()
    S = 0
    W = 0
    N = 0
    E = 0
    for t in travel_plan:
        if t == "S":
            S += 1
        elif t == "W":
            W += 1
        elif t == "N":
            N += 1
        else:
            E += 1
    
    if S*N == 0 and S+N != 0:
        print('No')
        return
    
    if W*E == 0 and W+E != 0:
        print('No')
        return
    
    print('Yes')
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
L=[S.count("N"),S.count("S"),S.count("W"),S.count("E")]
if L[0:2].count(0)==1 or L[2:].count(0)==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
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:
    ans = "No"
else:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
s = input()
count = [0, 0, 0, 0]
for i in range(len(s)):
  if s[i] == "N":
    count[0] = 1
  if s[i] == "S":
    count[1] = 1
  if s[i] == "W":
    count[2] = 1
  if s[i] == "E":
    count[3] = 1
if (count[0] + count[1])%2 or (count[2] + count[3])%2:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
ss = input()
n = 1
w = 1
s = 1
e = 1

if "N" in ss:
  n = -1
if "W" in ss:
  w = -1
if "S" in ss:
  s = -1
if "E" in ss:
  e = -1
if n*s + w*e > 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s="".join(sorted(set([str(i) for i in input()])))
print("Yes" if s=="ENSW" or s=="EW" or s=="NS" else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A - Wanna go back home
S =input()
n = 0
w = 0
s = 0
e = 0
for i in range(len(S)):
    if S[i] == "N":
        n += 1
    elif S[i] == "W":
        w += 1
    elif S[i] == "S":
        s += 1
    else:
        e += 1

#print(n,w,s,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")

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    s = input()

    s = set(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input().rstrip()
    N, W, S, E = 0, 0, 0, 0
    for c in s:
        if c == "N":
            N += 1
        if c == "W":
            W += 1
        if c == "S":
            S += 1
        if c == "E":
            E += 1
    if (N==0 and S>0) or (N>0 and S==0) or (W==0 and E>0) or (W>0 and E==0):
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
sets = set()
for v in s:
    sets.add(v)
    
ans = "Yes"
if "N" in sets and "S" not in sets:
    ans = "No"
if "S" in sets and "N" not in sets:
    ans = "No" 
if "E" in sets and "W" not in sets:
    ans = "No" 
if "W" in sets and "E" not in sets:
    ans = "No"    
print(ans)

Submission status: Accepted

Solution code:
def solve():
  s = input()
  can = True
  isn = "N" in s
  isw = "W" in s
  iss = "S" in s
  ise = "E" in s
  if isn or iss:
    if isn and iss:
      pass
    else:
      print("No")
      exit()
  if isw or ise:
    if isw and ise:
      pass
    else:
      print("No")
      exit()
  print("Yes")
  
solve()

Submission status: Accepted

Solution code:
S = input()
dic_S = {}
flag  = True
for i in range(len(S)):
    if S[i] in dic_S:
        dic_S[S[i]] += 1
    else:
        dic_S[S[i]] = 1
dic_ans = {"N":"S", "W":"E", "S":"N", "E":"W"}
for k, v in dic_S.items():
    if v>=1:
        if dic_ans[k] not in dic_S:
            flag = False
            break
print("Yes") if flag else print("No")

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

S = input()
T = set(s for s in S)

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

Submission status: Accepted

Solution code:
S=input()
ecount=0
wcount=0
ncount=0
scount=0
flag=1
for i in range(len(S)):
    if S[i]=="E":
        ecount=ecount+1
    elif S[i]=="W":
        wcount=wcount+1
    elif S[i]=="N":
        ncount=ncount+1
    else:
        scount=scount+1
if (ncount>0)or(scount>0):
    if (ncount*scount==0):
        flag=0
if (wcount>0)or(ecount>0):
    if (wcount*ecount==0):
        flag=0
if flag==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=input()
ans="Yes"
cn=s.count("N")
cs=s.count("S")
ce=s.count("E")
cw=s.count("W")
if cn==0 and cs!=0:
    ans="No"
elif cn!=0 and cs==0:
    ans="No"
elif cw==0 and ce!=0:
    ans="No"
elif cw!=0 and ce==0:
    ans="No"
print(ans)

Submission status: Accepted

Solution code:
S = input()

n = 0
w = 0
s = 0
e = 0
for si in S:
    if si == 'N':
        n += 1
    elif si == 'W':
        w += 1
    elif si == 'S':
        s += 1
    else:
        e += 1


ans = False
if (n and s) or (not n and not s):
    if (w and e) or (not w and not e):
        ans = True

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

Submission status: Accepted

Solution code:
S=input()
print("YNeos"[(S.find("N")>=0)^(S.find("S")>=0) or (S.find("W")>=0)^(S.find("E")>=0)::2])

Submission status: Accepted

Solution code:
s = input()
f = True

if s.find("S") != -1 and s.find("N") == -1:
    f = False
if s.find("S") == -1 and s.find("N") != -1:
    f = False
if s.find("E") != -1 and s.find("W") == -1:
    f = False
if s.find("E") == -1 and s.find("W") != -1:
    f = False
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
import collections
S = input()

table = collections.defaultdict(int)
for x in S:
    table[x] += 1

N = False
W = False
E = False
S = False

if table["N"] > 0:
    N = True
if table["W"] > 0:
    W = True
if table["E"] > 0:
    E = True
if table["S"] > 0:
    S = True


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

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    S = list(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")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    s = input().strip()
    p = 0
    if "N" in s:
        p += 1
    if "S" in s:
        p += 1
    if p == 1:
        print("No")
        return
    p = 0
    if "E" in s:
        p += 1
    if "W" in s:
        p += 1
    if p == 1:
        print("No")
        return
    
    print("Yes")
if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s=input()
C=collections.Counter(s)
if ((C["N"] or C["S"]) and C["N"]*C["S"] == 0):
  print("No")
elif ((C["W"] or C["E"]) and C["W"]*C["E"] == 0):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s=list(input())
t=set(s)
flag=True
if len(t)==3 or len(t)==1:
  flag=False
if len(t)==2:
  if t!={'N','S'} and t!={'W','E'}:
    flag=False
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
S = input()
C = [S.count("S"),S.count("N"),S.count("W"),S.count("E")]

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

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
d = defaultdict(int)

for s in S:
    d[s] += 1


ans = "Yes"
if d["N"] > 0 and d["S"] == 0:
    ans = "No"
if d["S"] > 0 and d["N"] == 0:
    ans = "No"
if d["W"] > 0 and d["E"] == 0:
    ans = "No"
if d["E"] > 0 and d["W"] == 0:
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = list(str(input()))

tmp = list(set(s))
tmp.sort()
if len(tmp) == 2 and ((tmp[0] == 'E' and s[1] == 'W') or (tmp[0] == 'N' and tmp[1] == 'S')):
    print("Yes")
elif len(tmp) == 4:
    print("Yes")
else:
    print("No")

"""
if len(set(s)) == 1 or len(set(s)) == 3:
    print("No")
else:
    print("Yes")
"""

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    s = input()

    tmp = set(s)

    if 'N' in tmp:
        if 'S' not in tmp:
            print('No')
            exit()

    if 'S' in tmp:
        if 'N' not in tmp:
            print('No')
            exit()

    if 'E' in tmp:
        if 'W' not in tmp:
            print('No')
            exit()

    if 'W' in tmp:
        if 'E' not in tmp:
            print('No')
            exit()

    print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
if (S.count("N") > 0 and (S.count("S") > 0)) or (S.count("N") == 0 and (S.count("S") == 0)):
  if (S.count("E") > 0 and (S.count("W") > 0)) or (S.count("E") == 0 and (S.count("W") == 0)):
    print("Yes")
    exit(0)
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    we = ("W" in S and "E" in S) or ("W" not in S and "E" not in S)
    ns = ("N" in S and "S" in S) or ("N" not in S and "S" not in S)
    if we and ns:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
if s.count('N') > 0 and s.count('S') == 0:
    print('No')
    exit()
if s.count('S') > 0 and s.count('N') == 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()

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

Submission status: Accepted

Solution code:
S=input()
x=set(S)
if len(x)%2==1:
  print('No')
else:
  if len(x)==4:
    print('Yes')
  else:
    if (('N' in S) and ('S' in S)) or (('E' in S) and ('W' in S)):
      print('Yes')
    else:
      print('No')

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
n_count = (1 if s.count('N')>=1 else 0)
s_count = (1 if s.count('S')>=1 else 0)
w_count = (1 if s.count('W')>=1 else 0)
e_count = (1 if s.count('E')>=1 else 0)
ns = not(n_count ^ s_count)
we = not(w_count ^ e_count)
if ns & we:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

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

if s.count("N") >= 1 and s.count("S") >= 1 and s.count("N") + s.count("S") == len(s):
    print("Yes")
    exit()
elif s.count("W") >= 1 and s.count("E") >= 1 and s.count("W") + s.count("E") == len(s):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
s = set(input())

if 'N' in s:
    if not 'S' in s:
        print('No')
        exit()

if 'S' in s:
    if not 'N' in s:
        print('No')
        exit()

if 'W' in s:
    if not 'E' in s:
        print('No')
        exit()

if 'E' in s:
    if not 'W' in s:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
c = Counter(S)
bool = True
if (c['N']==0) ^ (c['S']==0):
    bool = False
if (c['E']==0) ^ (c['W']==0):
    bool = False

print('Yes' if bool else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = set(input())
NS = {"N", "S"}
EW = {"E", "W"}

if(len(S)%2 != 0):
    print("No")
else:
    if(len(S) == 4):
        print("Yes")
    else:
        if(NS == S or EW == S):
            print("Yes")
        else:
            print("No")

Submission status: Accepted

Solution code:
s = input()
chk = [0, 0, 0, 0]
for c in s:
    if c == 'N':
        chk[0] += 1
    elif c == 'S':
        chk[1] += 1
    elif c == 'W':
        chk[2] += 1
    else:
        chk[3] += 1

if chk[0] > 0:
    if chk[1] == 0:
        print("No")
        exit()
if chk[1] > 0:
    if chk[0] == 0:
        print("No")
        exit()
if chk[2] > 0:
    if chk[3] == 0:
        print("No")
        exit()
if chk[3] > 0:
    if chk[2] == 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
S = sorted(set(list(input())))
if S == ["E","N","S","W"]:
    print("Yes")
elif S == ["E","W"]:
    print("Yes")
elif S == ["N","S"]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
C = Counter(input())
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")

Submission status: Accepted

Solution code:
s = input()
n = s.count("N")
ss = s.count("S")
w = s.count("W")
e = s.count("E")
if (n == 0 and ss > 0) or (ss == 0 and n > 0):
  print("No")
  exit()
if (w == 0 and e > 0) or (e == 0 and w > 0):
  print("No")
  exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()
S_set = set(S)
if S_set == set("WE") or S_set == set("NS") or S_set == set("WENS"):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
n, e, w, s = [0]*4
for i in input():
    if i=="N": n=1
    if i=="E": e=1
    if i=="W": w=1
    if i=="S": s=1
print("YNeos"[n!=s or e!=w::2])

Submission status: Accepted

Solution code:
S = input()
d = {'N': 0, 'W': 0, 'S': 0, 'E': 0}
prev = 'null'
for s_i in S:
    d[s_i] = 1
    if sum(d.values()) == 4:
        break
y = False
x = False
if (d['N'] and d['S']) or not(d['N'] or d['S']):
    y = True
if (d['W'] and d['E']) or not(d['W'] or d['E']):
    x = True
print('Yes' if y and x else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = input()
south = 'S' in s
north = 'N' in s
east = 'E' in s
west = 'W' in s

f = lambda x, y : x and not y or y and not x

if f(south, north) or f(west, east):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
import sys
s = input()
south = s.count('S')
north = s.count('N')
east = s.count('E')
west = s.count('W')

f = lambda x, y : x == 0 and y != 0 or x != 0 and y == 0

if f(south, north) or f(west, east):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s = input()
ans = 'Yes'
n = 0
w = 0
sow = 0
e = 0
#print(s)
for i in range(len(s)):
    if s[i] == 'N':
        n += 1
    elif s[i] == 'W':
        w += 1
    elif s[i] == 'S':
        sow += 1
    else:
        e += 1



if (n == 0 and sow != 0) or (n != 0 and sow == 0):
    ans = 'No'
if (w == 0 and e != 0) or (w != 0 and e == 0):
    ans = 'No'
print(ans)