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:
from collections import defaultdict

S = input()

cnt = defaultdict(bool)
for s in S:
  cnt[s] = True

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

Submission status: Accepted

Solution code:
import collections

S = input()

c = collections.Counter(S)
K = c.keys()

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

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
C = Counter(s)
if len(C) % 2 != 0:
    print('No')
    exit()
else:
    if len(s) == 4:
        print('Yes')
    else:
        if 'N' in s and 'S' in s:
            print('Yes')
        elif 'E' in s and 'W' in s:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
S = input()
S = list(S)
count = 0
while count == 0:
  if 'N' in S:
    if'S' in S:
      count += 1
    else:
      print('No')
      break
  if 'S' in S:
    if'N' in S:
      count += 1
    else:
      print('No')
      break
  if 'E' in S:
    if'W' in S:
      count += 1
    else:
      print('No')
      break
  if 'W' in S:
    if'E' in S:
      count += 1 
    else:
      print('No')
      break
else:
  print('Yes')

Submission status: Accepted

Solution code:
s=input()
ans=[0]*4
check='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#a, b = map(int,input().split())
S = input()
F = [False] * 4
n = len(S)
flg = False
V = ["E", "W", "N", "S"]
for i in range(n):
    s = S[i]
    F[V.index(s)] = True

if not (F[0]^F[1]):
    if not (F[2]^F[3]):
        flg = True
a = True
b=  False
c=False
if flg:
    print("Yes")
else:
    print("No")

#print(a^b, b^c)

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="".join(sorted(set(input())))
print("Yes" if S=="ENSW" or S=="NS" or S=="EW" else "No")

Submission status: Accepted

Solution code:
S=list(set(input()))
print("Yes" if len(S)==4 or (len(S)==2 and S.count("N")==S.count("S")) else "No")

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

from collections import Counter
c = Counter(rs())
f = False
if (c['N'] > 0 and c['S'] > 0) or (c['N'] == 0 and c['S'] == 0):
    if (c['W'] > 0 and c['E'] > 0) or (c['W'] == 0 and c['E'] == 0):
        f = True
print('Yes' if f else 'No')

Submission status: Accepted

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

S = set(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

def f(n,s):
  return (n==0 and s==0) or (n>0 and s>0)

b = f(n,s) and f(e,w)

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

Submission status: Accepted

Solution code:
s = list(input())
we = [0,0]
ns = [0,0]

for i in range(len(s)):
    if s[i] == ('N'):
        ns[0] = 1
    elif s[i] == ('W'):
        we[0] = 1
    elif s[i] == ('S'):
        ns[1] = 1
    else:
        we[1] = 1

if sum(we) % 2 == 0 and sum(ns) % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    ok = [{"N", "S"}, {"E", "W"}, {"N", "S", "E", "W"}]
    if set(s) in ok:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

L = [['W', 'E'], ['S', 'N']]

for l in L:
  if l[0] in s:
    if l[1] not in s:
      print("No")
      exit(0)
  if l[1] in s:
    if l[0] not in s:
      print("No")
      exit(0)

print("Yes")

Submission status: Accepted

Solution code:
S = 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 'E' in S:
  if not 'W' in S:
    print('No')
    exit()
if 'W' in S:
  if not 'E' in S:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
dir = [0]*4
move = "NWSE"
for i in S:
    dir[move.index(i)] += 1
p1 = (dir[0] > 0 and dir[2] > 0) or (dir[0] == 0 and dir[2] == 0)
p2 = (dir[1] > 0 and dir[3] > 0) or (dir[1] == 0 and dir[3] == 0)
print("Yes" if p1 and p2 else "No")

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

Solution code:
s=input()
s=set(s)
s=sorted(s)
ans=[['E','W'],['N','S'],['E','N','S','W']]
print("Yes" if s in ans else "No")

Submission status: Accepted

Solution code:
S = input()

n = 0
e = 0
w = 0
s = 0

for v in S:
    if v == 'N': n+=1
    if v == 'E': e+=1
    if v == 'W': w+=1
    if v == 'S': s+=1
if ((0<n and 0<s) or (n==0 and s==0)) and ((0<e and 0<w) or (e==0 and w==0)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit
s = input()
if "N" in s:
    if "S" not in s:
        exit(print("No"))
if "S" in s:
    if "N" not in s:
        exit(print("No"))
if "W" in s:
    if "E" not in s:
        exit(print("No"))
if "E" in s:
    if "W" not in s:
        exit(print("No"))
print("Yes")

Submission status: Accepted

Solution code:
import sys
D = input()

if ('N' in D and 'S' not in D) or ('N' not in D and 'S' in D):
  print('No')
  sys.exit()

if ('W' in D and 'E' not in D) or ('W' not in D and 'E' in D):
  print('No')
  sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
S=input()
sn = "N" in S
se = "E" in S
ss = "S" in S
sw = "W" in S
if (sn==ss) and (se==sw):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=set(x for x in input())
if len(S)==4:
  print('Yes')
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')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

cn,cs,ce,cw = 0,0,0,0
for i in range(len(s)):
	if s[i] == "N":
		cn = 1
	elif s[i] == "S":
		cs = 1
	elif s[i] == "E":
		ce = 1
	else:
		cw = 1

if (cn and cs) and (ce and cw):
	print("Yes")
elif (cn and cs) and not(ce or cw):
	print("Yes")
elif not(cn or cs) and (ce and cw):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import collections
s = input()

cnt = collections.Counter(s)

cond = True

if (cnt["N"] > 0) ^ (cnt["S"] > 0):
    cond = False
if (cnt["W"] > 0) ^ (cnt["E"] > 0):
    cond = False

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

Submission status: Accepted

Solution code:
s = input()

a = 'N' in s
b = 'S' in s
c = 'E' in s
d = 'W' in s

ans = 'Yes' if all([a == b, c == d]) else 'No'
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
s = {i for i in s}
if len(s) == 4 or s == {"N", "S"} or s == {"W", "E"}:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

A = input().rstrip('\n')

N = A.count("N")
S = A.count("S")
W = A.count("W")
E = A.count("E")

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = set([x for x in input()])
    n = len(s)
    if n == 4 or (n == 2 and ('S' in s and 'N' in s or 'W' in s and 'E' in s)):
        print("Yes")
    else:
        print("No")



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""

Submission status: Accepted

Solution code:
S=input()
S=sorted(set(S))
if S.count("N")==1:
	if S.count("S")==0:
		print("No")
		exit()
if S.count("S")==1:
	if S.count("N")==0:
		print("No")
		exit()
if S.count("E")==1:
	if S.count("W")==0:
		print("No")
		exit()
if S.count("W")==1:
	if S.count("E")==0:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
t=input()
n=0
s=0
w=0
e=0
for i in range(int(len(t))):
    if t[i] =="N":
        n=1
    if t[i] =="S":
        s=1
    if t[i] =="E":
        e=1
    if t[i] =="W":
        w=1
if (w+e)%2==0 and (n+s)%2==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)
def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
st = input()
n = s = e = w = False
if 'N' in st: n = True
if 'S' in st: s = True
if 'E' in st: e = True
if 'W' in st: w = True
print("Yes" if not(n^s) and not(e^w) else "No")


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Submission status: Accepted

Solution code:
s = input()

s = list(s)
sowth = s.count('S') if 'S' in s else 0
east  = s.count('E') if 'E' in s else 0
north = s.count('N') if 'N' in s else 0
west  = s.count('W') if 'W' in s else 0

if (sowth + north != 0 and sowth * north == 0) or\
    (west + east != 0 and west * east == 0):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()

s = list(s)
sowth = s.count('S') if 'S' in s else 0
east  = s.count('E') if 'E' in s else 0
north = s.count('N') if 'N' in s else 0
west  = s.count('W') if 'W' in s else 0

if (sowth != 0 and north == 0) or\
    (sowth == 0 and north != 0) or\
    (west != 0 and east == 0) or\
    (west == 0 and east != 0):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
v1 = ("N" in s) + ("S" in s)
v2 = ("W" in s) + ("E" in s)
if v1==1 or v2==1:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s = input()

s = list(s)
sowth = s.count('S') if 'S' in s else 0
east  = s.count('E') if 'E' in s else 0
north = s.count('N') if 'N' in s else 0
west  = s.count('W') if 'W' in s else 0

if (west != 0 and east != 0 and sowth == 0 and north == 0) or\
    (sowth != 0 and north != 0 and west == 0 and east == 0) or\
    (sowth != 0 and north != 0 and west != 0 and east != 0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
NS = set()
EW = set()
for s in S:
  if s in ["N", "S"]:
    NS.add(s)
  if s in ["E", "W"]:
    EW.add(s)
if len(NS) == 1 or len(EW) == 1:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s = input()
li = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1]]

direction = [0] * 4

for i in s:
    if i == 'N':
        direction[0] = 1
    elif i == 'S':
        direction[1] = 1
    elif i == 'W':
        direction[2] = 1
    else:
        direction[3] = 1

if direction in li:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = input()

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

Submission status: Accepted

Solution code:
S=input()

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

cand1=not n^s
cand2=not w^e

ans="Yes" if cand1 and cand2 else "No"
print(ans)

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
ok=(n==s==0 or (n>0 and s>0)) and (w==e==0 or (w>0 and e>0))
ans="Yes" if ok else "No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

D={s:False for s in ["N","W","S","E"]}

for s in S:
    D[s]=True

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

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    chk = set(S)
    if len(chk) != 4:
        if ("N" in chk and "S" not in chk) or ("E" in chk and "W" not in chk) or (
                "S" in chk and "N" not in chk) or ("W" in chk and "E" not in chk):
            print("No")
            return
    print("Yes")


resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
d = defaultdict(lambda: 0)
for c in s:
   d[c] += 1

if d["N"] > 0:
   if d["S"] == 0:
      print("No")
      exit()
if d["S"] > 0:
   if d["N"] == 0:
      print("No")
      exit()
if d["W"] > 0:
   if d["E"] == 0:
      print("No")
      exit()
if d["E"] > 0:
   if d["W"] == 0:
      print("No")
      exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def main():
	S = input().rstrip()
	res = 1

	n,w,s,e=[S.count(x) for x in "NWSE"]
	
	if n+s and not n*s: res=0
	if w+e and not w*e: res=0
	
	sT = "No Yes".split()
	print(sT[res])
	

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
S=input()
a=set()
for s in S:
  a.add(s)
a=list(a)
if len(a)==4:
  print('Yes')
elif len(a)==2:
  if (a[0]=='N' or a[0]=='S') and (a[1]=='N' or a[1]=='S'):
    print('Yes')
  elif (a[0]=='E' or a[0]=='W') and (a[1]=='E' or a[1]=='W'):
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
a = s.count("N")
b = s.count("W")
c = s.count("S")
d = s.count("E")
if (a  == 0 and c != 0) or (c  == 0 and a != 0) or (b  == 0 and d != 0) or (d  == 0 and b != 0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import collections
s = list(input())
ans = "Yes"
c = collections.Counter(s)

if c["N"] * c["S"] == 0:
    if c["N"] != c["S"]:
        ans = "No"
if c["W"] * c["E"] == 0:
    if c["W"] != c["E"]:
        ans = "No"

print(ans)

Submission status: Accepted

Solution code:
string=input()
n=[]
for letter in string:
    n.append(letter)
if ('N' in n and 'S' not in n) or ('S' in n and 'N' not in n) or ('E' in n and 'W' not in n)or ('W' in n and 'E' not in n):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
ans = True

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

Submission status: Accepted

Solution code:
S = input()

moved = {"N": False, "W": False, "S": False, "E": False}
for s in S:
    if not moved[s]:
        moved[s] = True

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

Submission status: Accepted

Solution code:
string = input()

c1 = True
c2 = True
c3 = True

if ("W" in string and not("E" in string)) or "E" in string and not("W" in string): c1 = False
    
if ("N" in string and not("S" in string)) or "S" in string and not("N" in string): c2 = False

if "N" in string and "S" in string and "E" in string and "W" in string:
    N = string.count("N")
    S = string.count("S")
    W = string.count("W")
    E = string.count("E")
    if not(N/S == W/E or N/S == E/W): c3 = False
    
if c1 and c2 and c3: print("Yes")
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
ans1, ans2="No", "No"
ans3, ans4="No", "No"
if 'N' in n:
  if 'S' in n:
    ans1="Yes"
if 'S' in n:
  if 'N' in n:
    ans2="Yes"
if 'E' in n:
  if 'W' in n:
    ans3="Yes"
if 'W' in n:
  if 'E' in n:
    ans4="Yes"
if "W" not in n and "E" not in n:
    ans3, ans4 = "Yes", "Yes"
if "N" not in n and "S" not in n:
    ans1, ans2 = "Yes", "Yes"
if ans1=="Yes" and ans2=="Yes" and ans3=="Yes" and ans4=="Yes":
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc003/tasks/agc003_a
S = str(input())
n,w,e,s = 'N' in S, 'W' in S, 'E' in S, 'S' in S
print('Yes' if n == s and e == w else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
ss=set(s)
a=["N","W","S","E"]
flg=False
if all(a[i] in s for i in range(4)):
    flg=True
if a[0] in s and a[1] not in s and a[2] in s and a[3] not in s:
    flg=True
if a[0] not in s and a[1] in s and a[2] not in s and a[3] in s:
    flg=True
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if any(s == set(list(i)) for i in ["NS","EW","NEWS"]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = str(input())

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

Submission status: Accepted

Solution code:
S=input()
t=set()
for i in range(len(S)):
    t.add(S[i])
if len(t)==4:
    print('Yes')
elif len(t)==3:
    print('No')
elif len(t)==2:
    if 'N' in t and 'S' in t:
        print('Yes')
    elif 'W' in t and 'E' in t:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

# In[7]:


S = input()


# In[8]:


s_set = set(S)
if "S" in s_set and "N" in s_set:
    if "E" in s_set and "W" in s_set:
        print("Yes")
    elif "E" in s_set or "W" in s_set:
        print("No")
    else:
        print("Yes")
elif "S" in s_set or "N" in s_set:
    print("No")
else:
    if "E" in s_set and "W" in s_set:
        print("Yes")
    elif "E" in s_set or "W" in s_set:
        print("No")
    else:
        print("Yes")


# In[ ]:

Submission status: Accepted

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

if len(S) == 4:
    ans = "Yes"
elif len(S) == 3 or len(S) == 1:
    ans = "No"
else:
    # print(list(S))
    if ("N" in S and "S" in S) or ("E" in S and "W" in S):
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
vertical,side = ['N', 'S'], ['W', 'E']

ans1,ans2 = 0,0

for l in vertical:
  if l in S:
    ans1 += 1
for l in side:
  if l in S:
    ans2 += 1
if ans1 >= 2 and ans2 >= 2:
  print('Yes')
elif ans1 >= 2 and ans2 == 0:
  print('Yes')
elif ans1 == 0 and ans2 >= 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().decode()

N, W, S, E = 'N' in S, 'W' in S, 'S' in S, 'E' in S

cond1 = not N ^ S
cond2 = not W ^ E

print('Yes' if cond1 and cond2 else 'No')

Submission status: Accepted

Solution code:
S=input()
A=[]
for letter in S:
    A.append(letter)
if ('N' in A and 'S' not in A) or ('S' in A and 'N' not in A) or ('E' in A and 'W' not in A)or ('W' in A and 'E' not in A):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = set(list(input()))
if any(s==set(list(cand)) for cand in ['NS','EW','NEWS']):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def resolve():
    S = str(input())
    n = S.count('N')
    s = S.count('S')
    w = S.count('W')
    e = S.count('E')
    if n > 0 and s == 0:
        print('No')
        return
    if n == 0 and s > 0:
        print('No')
        return
    if w > 0 and e == 0:
        print('No')
        return
    if w == 0 and e > 0:
        print('No')
        return
    print('Yes')

    return


resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter

def solve(S):
    s = Counter(S)
    if len(S) == 1:
        return "No"
    elif (s["N"]*s["S"] == 0 and s["N"]+s["S"] > 0) or \
         (s["E"]*s["W"] == 0 and s["E"]+s["W"] > 0):
        return "No"
    else:
        return "Yes"

def main():
    S = input()
    print(solve(S))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
NEWS = {'N':0, 'E':0, 'W':0, 'S':0}
for char in S:
    NEWS[char] = 1
if NEWS['N']^NEWS['S'] | NEWS['E']^NEWS['W']:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()
res = "Yes"
if "N" in S:
    if "S" not in S:
        res = "No"
if "W" in S:
    if "E" not in S:
        res = "No"
if "S" in S:
    if "N" not in S:
        res = "No"
if "E" in S:
    if "W" not in S:
        res = "No"
print(res)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = input()
    x1 =0
    x2=0
    y1=0
    y2=0

    for i in s:
        if i =="N":
            y1+=1
        if i == "S":
            y2+=1
        if i == "E":
            x1+=1
        if i == "W":
            x2+=1
    if ((x1 ==0 and x2 ==0) or (x1>0 and x2>0) ) and ((y1 ==0 and y2 ==0)or(y1 > 0and y2 > 0)):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = input()
kita, minami = sorted([s.count('N'),s.count('S')])
nisi, higasi = sorted([s.count('W'),s.count('E')])
result = ['No','Yes']
r = 1
if kita==minami or kita*minami > 0:
    r *= 1
else:
    r = 0

if nisi==higasi or nisi*higasi > 0:
    r *= 1
else:
    r = 0
print(result[r])

Submission status: Accepted

Solution code:
S=input()

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