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=set(list(input()))
ns=0
ew=0
if 'N' in s and 'S' in s:
  ns=1
elif 'N' not in s and 'S' not in s:
  ns=1

if 'E' in s and 'W' in s:
  ew=1
elif 'E' not in s and 'W' not in s:
  ew=1

if ns&ew:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=set(input())
    YesNo(len(S)%2==0 and (('N' in S and 'S' in S) or ('W' in S and 'E' in S)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

S = input()
NSEW = [S.count("N"), S.count("S"), S.count("E"), S.count("W")]

if np.prod(NSEW) > 0:
    print("Yes")
    exit()
elif NSEW[0] + NSEW[1] > 0 and NSEW[0] * NSEW[1] == 0:
    print("No")
    exit()
elif NSEW[2] + NSEW[3] > 0 and NSEW[2] * NSEW[3] == 0:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
s = list(input())

set_s = sorted(set(s))
if len(set_s)%2==1:
    print('No')
if len(set_s)==4:
    print('Yes')
if len(set_s)==2:
    if list(set_s)==['N','S']:
        print('Yes')
    elif list(set_s)==['E','W']:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
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
if n > 0 and w > 0 and s > 0 and e > 0:
    print("Yes")
elif n > 0 and s > 0 and w == 0 and e == 0:
    print("Yes")
elif w > 0 and e > 0 and s == 0 and n == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding:utf-8

S = input()
n = S.count('N')
s = S.count('S')
e = S.count('E')
w = S.count('W')
# print(n, s, e, w)

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

Submission status: Accepted

Solution code:
def main():
    S = set(input())
    if ('N' in S and 'S' not in S) or ('N' not in S and 'S' 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')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

ns = 0
we = 0

if "N" in s and "S" in s:
    ns = 1
elif "N" not in s and "S" not in s:
    ns = 1
if "W" in s and "E" in s:
    we = 1
elif "W" not in s and "E" not in s:
    we = 1
    
if ns == 1 and we == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = set(list(input()))
if len(s)==4:
    print("Yes")
    exit()
elif len(s)==2:
    if "N" in s and "S" in s:
        print("Yes")
        exit()
    elif "E" in s and "W" in s:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
S = input()

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

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

print('Yes')

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

cnt = Counter(S)
ans = "Yes"
if not((cnt["N"]==0 and cnt["S"]==0) or (cnt["N"]>0 and cnt["S"]>0)):
    ans = "No"
if not((cnt["W"]==0 and cnt["E"]==0) or (cnt["W"]>0 and cnt["E"]>0)):
    ans = "No"

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
import collections
S = list(input())

def judge(S):
    if "N" in S and "S" in S:
        if "W" in S and "E" in S:
            judge = "Yes"
            return judge
        elif "W" not in S and "E" not in S:
            judge = "Yes"
            return judge
        else:
            judge = "No"
            return judge
    elif "W" in S and "E" in S:
        if "N" not in S and "S" not in S:
            judge = "Yes"
            return judge
        else:
            judge = "No"
            return judge
    else:
        judge = "No"
        return judge

print(judge(S))

Submission status: Accepted

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

flg=True
for x,y in ['NS', 'SN', 'EW', 'WE']:
    if (x in S) and (y not in S):
        flg=False
        break
ans = 'Yes' if flg else 'No'
print(ans)

Submission status: Accepted

Solution code:
S = input()
flg=True

if ('N' in S) and ('S' not in S):
    flg=False
if ('S' in S) and ('N' not in S):
    flg=False
if ('W' in S) and ('E' not in S):
    flg=False
if ('E' in S) and ('W' not in S):
    flg=False

ans = 'Yes' if flg else 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b*c*d > 0:
  print('Yes')
elif a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
S = S()
condition1 = ('S' in S) == ('N' in S)
condition2 = ('E' in S) == ('W' in S)
print('Yes' if condition1 and condition2 else 'No')

Submission status: Accepted

Solution code:
# agc003_a.py
S = input()
direct = [0]*4
for i in S:
    if i == "W":
        direct[0] = 1
    elif i == "E":
        direct[1] = 1
    elif i == "S":
        direct[2] = 1
    elif i == "N":
        direct[3] = 1
if direct[0] == direct[1] and direct[3] == direct[2]:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
S = S()
ans = 1
if 'S' in S:
    if not 'N' in S:
        ans = 0
if 'N' in S:
    if not 'S' in S:
        ans = 0
if 'E' in S:
    if not 'W' in S:
        ans = 0
if 'W' in S:
    if not 'E' in S:
        ans = 0
print({1:'Yes',0:'No'}[ans])

Submission status: Accepted

Solution code:
S = input()

S = set(S)

if 'N' in S and 'S' in S:
    pass
elif 'N' not in S and 'S' not in S:
    pass
else:
    print('No')
    exit()
if 'E' in S and 'W' in S:
    pass
elif 'E' not in S and 'W' not in S:
    pass
else:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
t = input()

n = t.count('N')
s = t.count('S')
w = t.count('W')
e = t.count('E')

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

Submission status: Accepted

Solution code:
s = input()
for i, j in zip('NWSE', 'SENW'):
    if i in s and j not in s:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
d = {'S':0,'N':0,'E':0,'W':0}
for i in s:
    d[i] += 1
ns = (d['S'] > 0) == (d['N'] > 0)
ew = (d['E'] > 0) == (d['W'] > 0)
if ns and ew:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict

s = input()
move = defaultdict(int)
ans = 'Yes'

for c in s:
    move[c] += 1

if move['N'] > 0 and move['S'] == 0:
    ans = 'No'
if move['S'] > 0 and move['N'] == 0:
    ans = 'No'
if move['W'] > 0 and move['E'] == 0:
    ans = 'No'
if move['E'] > 0 and move['W'] == 0:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
def myAnswer(S:list)->str:
   dic ={"W":0,"N":0,"E":0,"S":0}
   for s in S:
      dic[s]+=1
   if(min(dic["W"],dic["E"])==0 and max(dic["W"],dic["E"])>=1):
      return "No"
   elif(min(dic["N"],dic["S"])==0 and max(dic["N"],dic["S"])>=1):
      return "No"
   else:
      return "Yes"

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   print(myAnswer(S[:]))

if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
s =  list(input())
if len(set(s)) == 4:
    print("Yes")
elif len(set(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")

Submission status: Accepted

Solution code:
def solve(s):
    for dirs in ('NS', 'SN', 'EW', 'WE'):
        d, o = dirs[0], dirs[1]
        if d in s and o not in s:
            return False
    return True


s = input()
print('Yes' if solve(s) else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
c = Counter(s)

if len(c) == 4:
    print('Yes')
elif len(c) == 3:
    print('No')
elif len(c) == 1:
    print('No')
elif len(c) == 2:
    if c['N'] > 0 and c['S'] > 0:
        print('Yes')
    elif c['W'] > 0 and c['E'] > 9:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

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

if 'N' in S and 'S' not in S:
    print('No')
    exit()
if 'W' in S and 'E' 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()

print('Yes')

Submission status: Accepted

Solution code:
i=input()
n,s,w,e=map(lambda x: min(1,i.count(x)),"NSWE")
print("YNeos"[(n^s)|(w^e)::2])

Submission status: Accepted

Solution code:
i = input()
n, s, w, e = map(lambda x: min(1, i.count(x)), "NSWE")
print(["Yes","No"][(n ^ s)|(w ^ e)])

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

Solution code:
s = input()

dicts = {'N':0, 'S':0, 'W':0, 'E':0}
for i in s:
    dicts[i] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

s = input()
cnt = [0]*4
for i in range(len(s)):
    if s[i] == "N":
        cnt[0] = 1
    elif s[i] == "W":
        cnt[1] = 1
    elif s[i] == "E":
        cnt[2] =1
    else:
        cnt[3] =1

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
x = y = 0
n = w = s = e = 0
for c in S:
  if c == 'N':
    n += 1
  elif c == 'W':
    w += 1
  elif c == 'S':
    s += 1
  else:
    e += 1
if (n == 0 and s > 0) or (s == 0 and n > 0):
  y = 1
if (w == 0 and e > 0) or (e == 0 and w > 0):
  x = 1
print('Yes' if x == 0 and y == 0 else 'No')

Submission status: Accepted

Solution code:
S = input()

direct = set()
for s in S:
    direct.add(s)

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

Submission status: Accepted

Solution code:
s = input()
cnt = {'N':0,'S':0,'E':0,'W':0}
ok = True
for x in s:
    cnt[x] +=1
if ((cnt['N'] >0)^(cnt['S']>0)) == 1:ok = False
if ((cnt['E'] >0)^(cnt['W']>0)) == 1:ok = False
if ok:print('Yes')
else:print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
North = S.count("N")
South = S.count("S")
East = S.count("E")
West = S.count("W")
if ((North > 0 and South > 0) or (North == 0 and South == 0)) and ((East > 0 and West > 0) or (East == 0 and West == 0)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

sn = not ('N' in s)^('S' in s)
ew = not ('E' in s)^('W' in s)

if sn and ew:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
# print(s)
d = {}
for i in range(len(s)):
    d[s[i]] = d.get(s[i], 0)+1
# print(d)
ans = 0
if 'N' in d:
    ans += 1
if 'S' in d:
    ans -= 1
if 'E' in d:
    ans += 100
if 'W' in d:
    ans -= 100
if ans == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
s = input()
yes = True
if "N" in s:
    if "S" not in s:
        yes = False
if "S" in s:
    if "N" not in s:
        yes = False
if "E" in s:
    if "W" not in s:
        yes = False
if "W" in s:
    if "E" not in s:
        yes = False
if yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
s=input()
cnt=defaultdict(lambda :0)

for i in s:
    cnt[i]+=1

if cnt['N']*cnt['S']==0 and (cnt['N']+cnt['S'])>0:
    print('No')
elif cnt['E']*cnt['W']==0 and (cnt['E']+cnt['W'])>0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input()
C = dict([[s, False] for s in 'NWSE'])
for s in S:
    C[s] = True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

x = defaultdict(int)
for s in S:
	x[s] = 1
if x["N"] == x["S"] and x["W"] == x["E"]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = list(input())
s_set = set(s)

s_unique = list(s_set)
s_unique.sort()

s_unique_len = len(s_unique)

if s_unique_len == 4:
  print('Yes')
elif s_unique_len == 2:
  if s_unique[0] == 'E' and s_unique[1] == 'W':
    print('Yes')
  elif s_unique[0] == 'N' and s_unique[1] == 'S':
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())
v = ["N", "W", "S", "E"]
a, b = 0, 0
for i in range(4):
    if v[i] in s:
        if i % 2 == 0:
            a += 1
        else:
            b += 1
print("Yes" if a % 2 == b % 2 == 0 else "No")

Submission status: Accepted

Solution code:
K = input()

K_S =K.count("S")
K_N =K.count("N")
K_W =K.count("W")
K_E =K.count("E")

if ((K_S != 0) and (K_N == 0)) or \
((K_E != 0) and (K_W == 0)) or \
((K_N != 0) and (K_S == 0)) or \
((K_W != 0) and (K_E == 0)):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
S = list(input())

S.sort()

flag = 1

if 'N' in S:
    if 'S' not in S:
        flag = 0

if 'S' in S:
    if 'N' not in S:
        flag = 0

if 'E' in S:
    if 'W' not in S:
        flag = 0

if 'W' in S:
    if 'E' not in S:
        flag = 0

if flag:
    print('Yes')

else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
d = {}

for s in S:
  d[s] = True

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

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

Submission status: Accepted

Solution code:
def resolve():

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

resolve()

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input())

def isNotOk():
    WE = (S['W'] > 0) ^ (S['E'] > 0)
    NS = (S['N'] > 0) ^ (S['S'] > 0)
    return WE or NS

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

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"] and not C["S"]) or ((not C["N"]) and C["S"]) or  (C["W"] and not C["E"]) or ((not C["W"]) and C["E"]):
  print("No")
else:
  print("Yes")

# print(bool(((C["W"] and not C["E"]))))

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

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

Submission status: Accepted

Solution code:
s = str(input())
d = {}
d['N'] = 0
d['W'] = 0
d['S'] = 0
d['E'] = 0
flag1 = False
flag2 = False

for i in range(len(s)):
    if s[i] == 'N' or s[i] == 'S':
        flag1 = True
        d[s[i]] = 1
    if s[i] == 'W' or s[i] == 'E':
        flag2 = True
        d[s[i]] = 1

if flag1:
    if d['N'] == 0 or d['S'] == 0:
        print('No')
        exit()

if flag2:
    if d['W'] == 0 or d['E'] == 0:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
S = list(input())
ans = "Yes"
if S.count("W") > 0:
  if "E" not in S: ans = "No"
if S.count("E") > 0:
  if "W" not in S: ans = "No"
if S.count("N") > 0:
  if "S" not in S: ans = "No"
if S.count("S") > 0:
  if "N" not in S: ans = "No"
print(ans)

Submission status: Accepted

Solution code:
S = input()
Flags = [False] * 4
for s in S:
    if "N" == s:
        Flags[0] =True
    elif "S" == s:
        Flags[1] =True
    elif "W" == s:
        Flags[2] =True
    elif "E" == s:
        Flags[3] =True

if all(Flags) or (Flags[0] and Flags[1] and not Flags[2] and not Flags[3]) or \
        (Flags[2] and Flags[3] and not Flags[0] and not Flags[1]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = list(input())
ans = Counter(s)
flag = False
if 'S' in ans:
    if 'E' in ans:
        if 'N' in ans:
            if 'W' in ans:
                flag = True
    else:
        if 'W' not in ans:
            if 'N' in ans:
                flag = True
else:
    if 'N' not in ans:
        if 'E' in ans:
            if 'W' in ans:
                flag = True
print('Yes' if flag==True else 'No')

Submission status: Accepted

Solution code:
from collections import*
s=input()

c=Counter(s)

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

Submission status: Accepted

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

    p = set(s)

    if len(p) % 2 == 1:
        print('No')
        exit()

    if 'S' in p and 'N' in p:
        print('Yes')
    elif 'W' in p and 'E' in p:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
S=input()
n=w=s=e=0
for c in S:
    if c =='N': n=1
    elif c=='W': w=1
    elif c=='S': s=1
    elif c=='E': e=1
print('Yes' if n==s and w==e else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
if ('W' in s and 'E' not in s) or\
   ('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):
   print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

s = list(STR())
flag = True
if s.count('N') and not s.count('S'):
    flag = False
if s.count('E') and not s.count('W'):
    flag = False
if not s.count('N') and s.count('S'):
    flag = False
if not s.count('E') and s.count('W'):
    flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
set_ = set(s)

if not((("N" in set_) ^ ("S" in set_))) and not((("W" in set_) ^ ("E" in set_))):
    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:
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
S = list(input())
c = Counter(S)
news = ['N','E','W','S']
sa = set(S)
if sa == {'N','S'} or sa == {'E','W'}:
    print("Yes")
    exit()
for i in range(4):
    if c[news[i]] == 0:
        print("No")
        exit()
print("Yes")