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:
# A - Wanna go back home
def can_go_home(dir1, dir2):
	if dir1 > 0 and dir2 > 0:
		return True
	elif dir1 == 0 and dir2 == 0:
		return True
	else:
		return False


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

for dir in input():
	if dir == 'N':
		n += 1
	elif dir == 'W':
		w += 1
	elif dir == 'S':
		s += 1
	else:
		e += 1

if can_go_home(n, s) and can_go_home(e, w):
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    str = (input().rstrip())
    W = 0
    N = 0
    S = 0
    E = 0

    for s in str:
        if(s == 'W'):
            W += 1
        elif(s =='E'):
            E += 1
        elif(s == 'N'):
            N += 1
        else:
            S += 1
    

    if(S*N*E*W > 0 or (S + N == 0 and E*W > 0) or(E +W == 0 and S*N > 0)):
        print("Yes")
    else:
        print("No")
    
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
s = input()
n_cnt = 0
s_cnt = 0
e_cnt = 0
w_cnt = 0
for i in range(len(s)):
  if s[i] == 'N':
    n_cnt += 1
  if s[i] == 'S':
    s_cnt += 1
  if s[i] == 'W':
    w_cnt += 1
  if s[i] == 'E':
    e_cnt += 1
if (n_cnt > 0 and s_cnt > 0) or (n_cnt == 0 and s_cnt == 0):
  length = True
else:
  length = False
if (e_cnt > 0 and w_cnt > 0) or (e_cnt == 0 and w_cnt == 0):
  width = True
else:
  width = False
  
if length and width:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())

k, m, n, h = 0, 0, 0, 0

if 'N' in s:
    k = 1
if 'S' in s:
    m = 1
if 'W' in s:
    n = 1
if 'E' in s:
    h = 1

if (abs(k-m))%2 == 0 and (abs(n-h))%2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=list(set(input()))
if len(S)==4 or set(S)==set(['N','S']) or set(S)==set(['W','E']):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
cannot = [
    "N" in S and "S" not in S,
    "N" not in S and "S" in S,
    "W" in S and "E" not in S,
    "W" not in S and "E" in S,
]
print("No" if any(cannot) else "Yes")

Submission status: Accepted

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

print("Yes" if flag[0] == flag[2] and flag[1] == flag[3] else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

NS = (("S" in S) & ("N" in S)) | (("S" not in S) & ("N" not in S))
EW = (("E" in S) & ("W" in S)) | (("E" not in S) & ("W" not in S))

print("Yes") if NS & EW else print("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:
import numpy as np

s = input()
ans = ['No', 'Yes']

judge = (('N' in s) == ('S' in s) and ('W' in s) == ('E' in s))
print(ans[judge])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    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')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if 'N' in s:
  if not 'S' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
if 'S' in s:
  if not 'N' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'W' in s:
  if not 'E' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()

if 'E' in s:
  if not 'W' in s:
    print("No")
    exit()
  elif len(s) == 2 or len(s)==4:
    print("Yes")
    exit()
    
print("No")

Submission status: Accepted

Solution code:
S = input()

NS = 'NS'
WE = 'WE'
answer = 'Yes'

if S.count('N') == 0 and S.count('S') != 0:
    answer = 'No'
elif S.count('N') != 0 and S.count('S') == 0:
    answer = 'No'

if S.count('W') == 0 and S.count('E') != 0:
    answer = 'No'
elif S.count('W') != 0 and S.count('E') == 0:
    answer = 'No'
        
print(answer)

Submission status: Accepted

Solution code:
S = input()

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


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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################
def main():
    S=input()
    w="W" in S
    e="E" in S
    n="N" in S
    s="S" in S
    Yn(not(w^e) and not(n^s))
main()

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    S=input()
    a=[s in S for s in"NSEW"]
    if a[0]==a[1] and a[2]==a[3]:
        print("Yes")
        return
    print("No")
    #print()
#%%submit!
resolve()

Submission status: Accepted

Solution code:
s = input()
count = {"N":0, "W":0, "S":0, "E":0}
for i in s:
    count[i] += 1

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

else:
    print("No")

Submission status: Accepted

Solution code:
s = input().strip()

counts = {
    'N': 0, 'W': 0, 'S': 0, 'E': 0
}

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


def judge():
    if counts['N'] > 0 or counts['S'] > 0:
        if counts['N'] * counts['S'] == 0:
            return False

    if counts['W'] > 0 or counts['E'] > 0:
        if counts['W'] * counts['E'] == 0:
            return False

    return True


if judge():
    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:
s = input()
kita = s.count("N")
mina = s.count("S")
nisi = s.count("W")
higa = s.count("E")

if kita + mina != 0 and kita*mina == 0:
    print("No")
    exit()
if nisi + higa != 0 and nisi*higa == 0:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
s = input()
dirset = set()
for i in s:
  dirset.add(i)
if "N" in dirset and "S" in dirset:
  if ("E" in dirset and "W" in dirset) or (not "E" in dirset and not "W" in dirset):
    print("Yes")
  else:
    print("No")
elif "E" in dirset and "W" in dirset:
  if not "N" in dirset and not "S" in dirset:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
s = input() #sys.stdin.readlineは最後が改行

from collections import Counter

c = Counter(s)

if c['N'] >0 and c['S']==0:
    print('No')
    exit()
if c['S'] >0 and c['N']==0:
    print('No')
    exit()
if c['W'] >0 and c['E']==0:
    print('No')
    exit()
if c['E'] >0 and c['W']==0:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
nwse = [0]*4
for i in s:
  if i=="N":
    nwse[0] =1
  elif i=="W":
    nwse[1] =1
  elif i=="S":
    nwse[2]=1
  else:
    nwse[3]=1
    
    
if nwse[0]==nwse[2] and nwse[1]==nwse[3]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=set(input())
    ans='No'
    if s==set('NSWE') or s==set('NS') or s==set('WE'):
        ans='Yes'
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=set(input())
    ans='No'
    if s=={'N','S','W','E'} or s=={'N','S'} or s=={'W','E'}:
        ans='Yes'
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc003/tasks/agc003_a

s = input()
d = dict(N=0, W=0, S=0, E=0)

for i in range(len(s)):
    d[s[i]] += 1

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

Submission status: Accepted

Solution code:
s = input()
ans = 'Yes'
cn = 'N' in s
ce = 'E' in s
cw = 'W' in s
cs = 'S' in s
if (cn ^ cs) or (ce ^ cw):
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
x=dict()
for i in range(N):
    s = S[i]
    x[s]=s

if "N" in x:
    if "S" in x:
        pass
    else:
        print("No")
        exit()

if "S" in x:
    if "N" in x:
        pass
    else:
        print("No")
        exit()

if "W" in x:
    if "E" in x:
        pass
    else:
        print("No")
        exit()

if "E" in x:
    if "W" in x:
        pass
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

print("Yes")

Submission status: Accepted

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

def main():
    S = input()

    s = len([1 for _ in S if _ == 'S'])
    n = len([1 for _ in S if _ == 'N'])
    e = len([1 for _ in S if _ == 'E'])
    w = len([1 for _ in S if _ == 'W'])

    if (s > 0 and n > 0) or (s == n == 0):
        flag1 = True
    else:
        flag1 = False
    if (e > 0 and w > 0) or (e == w == 0):
        flag2 = True
    else:
        flag2 = False
    
    if flag1 and flag2:
        print('Yes')
    else:
        print('No')

main()

Submission status: Accepted

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

ew_flag = False
ns_flag = False

if (e > 0 and w > 0) or (e == 0 and w == 0):
  ew_flag = True
if (n > 0 and s > 0) or (n == 0 and s == 0):
  ns_flag = True

if ew_flag and ns_flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

List=list(set(S))
List.sort()

flag=0
if len(List)%2==0:
    if len(List)//2==1:
        if List[0]=="E" and List[1]=="W":
            flag=1
        elif List[0]=="N" and List[1]=="S":
            flag=1
    elif len(List)//2==2:
            flag=1
            
print("Yes" if flag==1 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
ans = 1
cE = s.count("E")
cW = s.count("W")
cS = s.count("S")
cN = s.count("N")
if cE >=1:
    if cW == 0:
        ans = 0
if cW >=1:
    if cE == 0:
        ans = 0
if cN >=1:
    if cS == 0:
        ans = 0
if cS >=1:
    if cN == 0:
        ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s)
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    S = Counter(input())
    ans = "Yes"
    if S["N"] > 0 or S["S"] > 0:
        if S["N"] == 0 or S["S"] == 0:
            ans = "No"
    if S["W"] > 0 or S["E"] > 0:
        if S["W"] == 0 or S["E"] == 0:
            ans = "No"
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    N = s.count('N')
    W = s.count('W')
    S = s.count('S')
    E = s.count('E')
    if N:
        if S:
            pass
        else:
            print('No')
            exit()
    if S:
        if N:
            pass
        else:
            print('No')
            exit()
    if W:
        if E:
            pass
        else:
            print('No')
            exit()
    if E:
        if W:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

S = input()[:-1]

x = [0,0,0,0]

for i in range(len(S)):
    if S[i] == 'N':
        x[0]+=1
    if S[i] == 'S':
        x[1]+=1
    if S[i] == 'E':
        x[2]+=1
    if S[i] == 'W':
        x[3]+=1


if x.count(0) == 0:
    print("Yes")
    exit()
else:
    if x[:2].count(0) == 0 and x[2:].count(0) == 2:
        print("Yes")
        exit()
    if x[:2].count(0) == 2 and x[2:].count(0) == 0:
        print("Yes")
        exit()
    
print("No")

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

angle = {'N':0, 'W':0, 'S':0, 'E':0}

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


if angle['N'] > 0 and angle['S'] == 0:
    print('No')
    exit()

if angle['S'] > 0 and angle['N'] == 0:
    print('No')
    exit()

if angle['W'] > 0 and angle['E'] == 0:
    print('No')
    exit()

if angle['E'] > 0 and angle['W'] == 0:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

N_cnt = S.count('N')
W_cnt = S.count('W')
S_cnt = S.count('S')
E_cnt = S.count('E')

if ((N_cnt > 0 and S_cnt > 0) or (N_cnt == 0 and S_cnt == 0)) \
	and ((W_cnt > 0 and E_cnt > 0) or (W_cnt == 0 and E_cnt == 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()
N = s.count('N')
W = s.count('W')
S = s.count('S')
E = s.count('E')

ans = 'No'
if (N >= 1 and S >= 1) or (N == S == 0):
  if (W >= 1 and E >= 1) or (W == E == 0):
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
def c(S, a):
    return S.count(a)


S = input()
n, w, s, e = c(S, 'N'), c(S, 'W'), c(S, 'S'), c(S, 'E')
if ((n > 0 and s == 0) or (s > 0 and n == 0)):
    print('No')
elif ((w > 0 and e == 0) or (e > 0 and w == 0)):
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

s = list(input())
s = set(s)
s = list(s)

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

Submission status: Accepted

Solution code:
# import collections
S = input()
# CS = collections.Counter(S)
# print(CS)
cn = S.count('N')
ce = S.count('E')
cs = S.count('S')
cw = S.count('W')
# print(cn, cs, cw, ce)
if cn > 0 and cs > 0 and ce == 0 and cw == 0:
    print('Yes')
elif cn == 0 and cs == 0 and ce > 0 and cw > 0:
    print('Yes')
elif cn > 0 and cs > 0 and ce > 0 and cw > 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

if ('N' in S and 'S' not in S) or ('S' in S and 'N' not in S) or ('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:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

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



if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    n = S.count('N')
    w = S.count('W')
    s = S.count('S')
    e = S.count('E')
    if n == 0 and s == 0:
        pass
    else:
        if n!=0 and s!= 0:
            pass
        else:
            print('No')
            exit()
    if w == 0 and e == 0:
        pass
    else:
        if w!=0 and e!= 0:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = set(input())
    bl = False
    if S=={'E', 'W', 'N', 'S'}:
        bl = True
    if S=={'E', 'W'}:
        bl=True
    if S=={'N', 'S'}:
        bl = True
    print('Yes' if bl else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
A =["W" in S ,"E" in S ,"S" in S ,"N" in S ]
if A ==[1,1,1,1] or A ==[0,0,1,1] or A ==[1,1,0,0]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()

d = [False for _ in range(4)]

for c in s:
    if c == 'N':
        d[0] = True
    elif c == 'S':
        d[1] = True
    elif c == 'W':
        d[2] = True
    else:
        d[3] = True

if d[0] ^ d[1] or d[2] ^ d[3]:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# 2020/04/24
# AtCoder Grand Contest 003 - A

# Input
s = input()
d = dict()

d['N'] = 0
d['W'] = 0
d['S'] = 0
d['E'] = 0

for i in range(len(s)):
    d[s[i]] = d[s[i]] + 1

nsflg = False
if (d['N'] == 0 and d['S'] == 0) or (d['N'] > 0 and d['S'] > 0):
    nsflg = True

weflg = False
if (d['W'] == 0 and d['E'] == 0) or (d['W'] > 0 and d['E'] > 0):
    weflg = True

if nsflg and weflg:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

s = str(input())

c = Counter(s)
c_keys = c.keys()
c_value = c.values()

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

Submission status: Accepted

Solution code:
# AGC 003: A – Wanna go back home
S = input()

canReturn = 'Yes'

if (('N' in S and 'S' not in S) or ('N' not in S and 'S' in S)) \
        or (('E' in S and 'W' not in S) or ('E' not in S and 'W' in S)):
    canReturn = 'No'

print(canReturn)

Submission status: Accepted

Solution code:
S = list(input())
nc = S.count("N")
sc = S.count("S")
ec = S.count("E")
wc = S.count("W")

for i, j in zip([nc, ec], [sc, wc]):
    if i == 0 and j == 0:
        continue
    elif i == 0 or j == 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
S=set(list(input()))
n=0
s=0
e=0
w=0
if 'N' in S:
  n=1
if 'S' in S:
  s=1
if 'E' in S:
  e=1
if 'W' in S:
  w=1

if (n^s)|(e^w):
  print('No')
else:
  print('Yes')