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:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		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 -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		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()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

s = readChar()

d = {"N":0,"W":0,"S":0,"E":0}

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

flg = 1
if not(d["N"]+d["S"]==0 or (d["N"]>0 and d["S"]>0)):
	flg = 0

if not(d["W"]+d["E"]==0 or (d["W"]>0 and d["E"]>0)):
	flg = 0

if flg==1:
	print("Yes")
else:
	print("No")

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=list(input())
p=set(s)

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

Submission status: Accepted

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

import sys
import numpy as np
from collections import defaultdict
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = readline().decode().rstrip()
dicts = defaultdict(int)

for c in S:
  dicts[c] += 1

for pair in [('N', 'S'), ('W', 'E')]:
  if min(dicts[pair[0]], dicts[pair[1]]) == 0:
    if max(dicts[pair[0]], dicts[pair[1]]) != 0:
      print('No')
      sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
S = list(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()
pr=True
if (s.count("N")==0)^(s.count("S")==0):
  pr=False
if (s.count("E")==0)^(s.count("W")==0):
  pr=False

if pr:
  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, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

S = input()

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

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

Submission status: Accepted

Solution code:
s=input()
ryoko={'S':False,'N':False,'W':False,'E':False}
for c in s:
    ryoko[c]=True
if (ryoko['S']!=ryoko['N']) or (ryoko['W']!=ryoko['E']):
    print('No')
else:
    print('Yes')

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:
s = input()
p = ['N', 'S', 'E', 'W']
cnt = []
for i in p:
    cnt.append(s.count(i))
if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
    if cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
        print("Yes")
    else:
        print("No")
elif cnt[2] != 0 and cnt[3] != 0 or cnt[2] == 0 and cnt[3] == 0:
    if cnt[0] != 0 and cnt[1] != 0 or cnt[0] == 0 and cnt[1] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
S = S()

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):
  NE()
YE()

Submission status: Accepted

Solution code:
s=input()
print('No' 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 else 'Yes')

Submission status: Accepted

Solution code:
S = input()
count = {s: 0 for s in "NWSE"}
for s in S:
    count[s] += 1

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

Submission status: Accepted

Solution code:
s = input();

st = set(s)
print("Yes" if st == set("WE") or st == set("NS") or st == set("SENW") else "No")

Submission status: Accepted

Solution code:
a=list(input())

n = 0

s = 0

e = 0

w = 0

for i in a:
  if i == 'N':
    n += 1
  elif i == 'S':
    s += 1
  elif i == 'E':
    e += 1
  elif i == 'W':
    w += 1

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

Submission status: Accepted

Solution code:
import collections

s=input()
a=collections.Counter(s)
f=True

if a['N']>0:
	if a['S']==0:
		f=False
		
if a['S']>0:
	if a['N']==0:
		f=False
		
if a['W']>0:
	if a['E']==0:
		f=False
		
if a['E']>0:
	if a['W']==0:
		f=False
		
if f:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
from collections import Counter

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:
string = input()
news = "NEWS"
flg = [False for _ in range(4)]
for s in string:
    for i in range(4):
        if s == news[i]:
            flg[i] = True
            break
if flg[0] != flg[3] or flg[1] != flg[2]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
dir_set = set()
for s in S:
    dir_set.add(s)

if 'N' in dir_set and 'S' in dir_set and 'W' in dir_set and 'E' in dir_set:
    ### "NSFW" 全部ある場合    
    print("Yes")
elif not 'N' in dir_set and not 'S' in dir_set and 'W' in dir_set and 'E' in dir_set:
    ### "NS" はなく "EW" が両方ある場合
    print("Yes")
elif 'N' in dir_set and 'S' in dir_set and not 'W' in dir_set and not 'E' in dir_set:
    ### "NS" が両方あり "EW" がない場合
    print("Yes")
else:
    ### 上記以外
    print("No")

Submission status: Accepted

Solution code:
s = input()
if "N" in s and "S" in s and "W" in s and "E" in s:
  print("Yes")
elif not "N" in s and not "S" in s and "W" 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")
else:
  print("No")

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 and w>0 and e>0)or(n==0 and s==0 and w>0 and e>0) or (n>0 and s>0 and w==0 and e==0):
    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")
if N==0 and S==0:
    if E==0 and W==0:
        print("Yes")
    elif E>0 and W>0:
        print("Yes")
    else:
        print("No")
elif N>0 and S>0:
    if E==0 and W==0:
        print("Yes")
    elif E>0 and W>0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

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

    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=set(input())
if len(s)==4:
    print("Yes")
elif len(s)%2:
    print("No")
else:
    if ("N" in s and "S" in s) or ("W"in s and "E" in s):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
S=input()
nsflag=False
weflag=False
if(("N" in S and "S" in S)or("N" not in S and "S" not in S)):
  if(("W" in S and "E" in S)or("W" not in S and "E" not in S)):
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Count = [0,0,0,0]
for j in input():
    if j == 'N':
        Count[0] +=1
    elif j == 'S':
        Count[1] +=1
    elif j == 'W':
        Count[2] +=1
    elif j == 'E':
        Count[3] +=1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
n, w = S.count('N'), S.count('W')
s, e = S.count('S'), S.count('E')
flag = True
if n == 0 or s == 0:
    if n != s:
        flag = False
if w == 0 or e == 0:
    if w != e:
        flag = False
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    go_back_home = True
    if "N" in S:
        if "S" not in S:
            go_back_home = False
    if "S" in S:
        if "N" not in S:
            go_back_home = False
    if "W" in S:
        if "E" not in S:
            go_back_home = False
    if "E" in S:
        if "W" not in S:
            go_back_home = False

    ans = "Yes" if go_back_home else "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
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:
# coding: utf-8
S = set(input())
i = {'N', 'S'}
j = {'W', 'E'}
k = {'N', 'S', 'W', 'E'}
if S == i or S == j or S == k:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
x = 0
y = 0
s = list(set(s))
for i in range(len(s)):
    if s[i] == 'N':
        y += 1
    elif s[i] == 'W':
        x -= 1
    elif s[i] == 'S':
        y -= 1
    else:
        x += 1
print('Yes' if x == 0 and y == 0 else 'No')

Submission status: Accepted

Solution code:
s = input()
c = 0
d = 0
if 'W' in s:
  c += 1
if 'E' in s:
  c -= 1
if 'N' in s:
  d += 1
if 'S' in s:
  d -= 1
if c == d == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S="".join(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:
S = input()
has_N = "N" in S
has_S = "S" in S
has_E = "E" in S
has_W = "W" in S
reachable_NS = has_N and has_S or not has_N and not has_S
reachable_SW = has_E and has_W or not has_E and not has_W
if reachable_NS and reachable_SW:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())

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

Submission status: Accepted

Solution code:
x = input()
n = x.count('N')
e = x.count('E')
w = x.count('W')
s = x.count('S')
if ((n and not s) or (not n and s) or (w and not e) or (not w and e)):
	print("No")
else:
	print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())
c = Counter(S)

ans = True

if (c["N"]> 0 and c["S"] == 0) or (c["N"]== 0 and c["S"] > 0) or (c["W"] > 0 and c["E"] == 0) or (c["W"] == 0 and c["E"] > 0):
    ans = False

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

Submission status: Accepted

Solution code:
S = set(input())
if len(S) == 2:
  if len(S & {'N', 'S'}) == 2 or len(S & {'E', 'W'}) == 2:
    print('Yes')
  else:
    print('No')
elif len(S) == 4:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n,w,s,e = 0,0,0,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 
  elif(S[i] == 'E'): e = 1
    
judge = [n,w,s,e]
if((judge == [1,0,1,0])or(judge == [0,1,0,1])or(judge == [1,1,1,1])):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
dic = defaultdict(bool)
for s in S:
    dic[s] = True
if dic["N"] != dic["S"] or dic["W"] != dic["E"]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
st = input()
if "N" in st:
    if ("S" in st) is False:
        print("No")
        exit()
if "W" in st:
    if ("E" in st) is False:
        print("No")
        exit()
if "S" in st:
    if ("N" in st) is False:
        print("No")
        exit()
if "E" in st:
    if ("W" in st) is False:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
S = list(input())
def zeroandnot0(a, b):
    if (a == 0 and b != 0) or (a != 0 and b == 0):
        return True
    else:
        return False
c = Counter(S)
if zeroandnot0(c['E'], c['W']) or zeroandnot0(c['N'], c['S']):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = list(set(input()))
l = [["N","S"], ["W","E"], ["N", "S", "W", "E"]]
if len(s) != 2 and len(s) != 4:
    print("No")
    exit()
for i in l:
    x = 0
    for j in s:
        if j in i:
            x += 1
    if x == len(i):
        print("Yes")
        exit()
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 ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1000
if 'W' in s:
    judge += 1
if 'S' in s:
    judge -= 1000
if 'E' in s:
    judge -= 1

print('Yes' if judge == 0 else 'No')

Submission status: Accepted

Solution code:
s = list(input())
x = 0
y = 0

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

Submission status: Accepted

Solution code:
S = input()
res = "Yes"
if S.count('N') and not S.count('S'):
    res = "No"
if not S.count('N') and S.count('S'):
    res = "No"
if S.count('E') and not S.count('W'):
    res = "No"
if not S.count('E') and S.count('W'):
    res = "No"
print(res)

Submission status: Accepted

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


S = instr()
r = "Yes"
e, w, n, s = 0, 0, 0, 0
for i in S:
    if i in "N":
        n += 1
    elif i == "S":
        s += 1
    elif i == "E":
        e += 1
    else:
        w += 1
if (n > 0 and s > 0) or (n == 0 and s == 0):
    pass
else:
    r = "No"
if (e > 0 and w > 0) or (e == 0 and w == 0):
    pass
else:
    r = "No"
print(r)

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 ("W" in s and "E" in s) or ("W" not in s and "E" not in s):
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
S = input()
n = int('N' in S)
s = int('S' in S)
w = int('W' in S)
e = int('E' in S)

if n + s == 1 or w + e == 1:
  print('No')
else:
  print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    T=ST()
    E="E" in T
    W="W" in T
    N="N" in T
    S="S" in T
    if(W^E or N^S):
        print("No")
    else:
        print("Yes")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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 "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:
import sys

input = sys.stdin.readline

def main():
    S = input().rstrip('\n')
    if (('S' in S) == ('N' in S)) and (('E' in S) == ('W' in S)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    snflg = True
    ewflg = True
    S = input().rstrip('\n')
    if 'S' in S or 'N' in S:
        snflg = False       
        if 'S' in S and 'N' in S:
            snflg = 'Yes'
    if 'E' in S or 'W' in S:
        ewflg = False
        if 'E' in S and 'W' in S:
            ewflg = 'Yes'
    if snflg and ewflg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
ok = True
if s.count("N") >= 1:
    if s.count("S") == 0:
        ok = False
if s.count("S") >= 1:
    if s.count("N") == 0:
        ok = False

if s.count("E") >= 1:
    if s.count("W") == 0:
        ok = False

if s.count("W") >= 1:
    if s.count("E") == 0:
        ok = False
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

S_set = set(S)
if len(S_set) % 2 == 0:
    if S_set == set() or S_set == set(['N', 'S']) or S_set == set(['E', 'W']) or S_set == set(['N', 'S', 'E', 'W']):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
flag = 1
if "S" in S:
  if not("N" in S):
    flag = 0
if "N" in S:
  if not("S" in S):
    flag = 0
if "E" in S:
  if not("W" in S):
    flag = 0
if "W" in S:
  if not("E" in S):
    flag = 0
if flag:
  print("Yes")
else:
  print("No")