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 sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import defaultdict
    S = list(input())
    d = defaultdict(int)
    for s in S:
        d[s] += 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["W"] > 0 and d["E"] == 0):
        print("No")
    else:
        print("Yes")

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def resolve(in_):
    S = next(in_).strip()
    
    H = None
    W = None

    for c in S:
        if c == 'N':
            if H == 'S':
                H = False
            elif H is None:
                H = c
        elif c == 'S':
            if H == 'N':
                H = False
            elif H is None:
                H = c
        elif c == 'W':
            if W == 'E':
                W = False
            elif W is None:
                W = c
        elif c == 'E':
            if W == 'W':
                W = False
            elif W is None:
                W = c
    
    return not (H or W)
    
    return True


def main():
    answer = resolve(sys.stdin)
    print('Yes' if answer else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

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

Submission status: Accepted

Solution code:
s = input()

x = False
if 'N' in s and 'S' in s:
    x = True
if 'N' not in s and 'S' not in s:
    x = True
y = False
if 'W' in s and 'E' in s:
    y = True
if 'W' not in s and 'E' not in s:
    y = True

if x and y:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

if ('N' in s and 'S' not in s) or ('N' not in s and 'S' in s):
    print('No')
    sys.exit(0)
if ('W' in s and 'E' not in s) or ('W' not in s and 'E' in s):
    print('No')
    sys.exit(0)
print('Yes')

Submission status: Accepted

Solution code:
# A
from collections import Counter
S = list(input())
count = Counter(S)
flag = True

if count['N'] > 0:
  if count['S'] == 0:
    flag = False
if count['S'] > 0:
  if count['N'] == 0:
    flag = False
if count['E'] > 0:
  if count['W'] == 0:
    flag = False
if count['W'] > 0:
  if count['E'] == 0:
    flag = False
print("Yes") if flag == True else print("No")

Submission status: Accepted

Solution code:
print('YNeos'[set(input())not in map(set,['NS','EW','NEWS'])::2])

Submission status: Accepted

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

for i in S:
    set_.add(i)

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

Submission status: Accepted

Solution code:
a = set(input())
print("Yes" if a == set("NEWS") or a == set("NS") or a == set("EW") else "No")

Submission status: Accepted

Solution code:
from collections import Counter


cntr = Counter(input())
x_ok, y_ok = False, False
if (cntr["E"] and cntr["W"]) or (not cntr["E"] and not cntr["W"]):
    x_ok = True
if (cntr["N"] and cntr["S"]) or (not cntr["N"] and not cntr["S"]):
    y_ok = True
print("Yes") if x_ok and y_ok else print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#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,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
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 = list(input())
flag = True
if "N" in S:
  if "S" not in S:
    flag = False
if "S" in S:
  if "N" not in S:
    flag = False
if "E" in S:
  if "W" not in S:
    flag = False
if "W" in S:
  if "E" not in S:
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

if len(s) == 1 or len(s)==3: ans = "No"
elif len(s) == 2 or len(s)==4:
    if s == ["N","S"] or s == ["E", "W"]: ans = "Yes"
    elif s == ["E", "N", "S", "W"]: ans = "Yes"
    else: ans = "No"
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
s = Counter(input())
if (s['N'] > 0) ^ (s['S'] > 0) or (s['E'] > 0) ^ (s['W'] > 0):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input().strip()
C = {"N":0,"S":0,"E":0,"W":0}
for i in range(len(S)):
    C[S[i]] += 1
if C["N"]>0 and C["S"]>0 and C["E"]>0 and C["W"]>0 or C["N"]==0 and C["S"]==0 and C["E"]>0 and C["W"]>0\
or C["N"]>0 and C["S"]>0 and C["E"]==0 and C["W"]==0 or C["N"]==0 and C["S"]==0 and C["E"]==0 and C["W"]==0:
    print("Yes")
else:
    print("No")

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

Submission status: Accepted

Solution code:
def main():
    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):
        if (w_cnt == 0 and e_cnt == 0) or (w_cnt > 0 and e_cnt > 0):
            print("Yes")
            exit()

    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = list(input())
Ncnt, Ecnt, Wcnt, Scnt = 0, 0, 0, 0

for i in S:
    if i == 'N':
        Ncnt += 1
    elif i == 'E':
        Ecnt += 1
    elif i == 'W':
        Wcnt += 1
    else:
        Scnt += 1

if (Ncnt > 0 and Scnt == 0) or (Scnt > 0 and Ncnt == 0) or (Ecnt > 0 and Wcnt == 0) or (Wcnt > 0 and Ecnt == 0):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S=input()
n=0
s=0
w=0
e=0
for i in range(len(S)):
    if S[i]=="N":
        n+=1
    if S[i]=="S":
        s+=1
    if S[i]=="W":
        w+=1
    if S[i]=="E":
        e+=1

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:
def solve():
    S = input()
    n = S.count('N')
    e = S.count('E')
    w = S.count('W')
    s = S.count('S')
    if (n and not s) or (not n and s) or (e and not w) or (not e and w):
        print('No')
    else:
        print('Yes')

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

def main():
    S = list(input())
    Sset = set(S)
    if len(Sset) in [1, 3]:
        print('No')
    elif Sset == set(['S', 'N']) or Sset == set(['W', 'E']):
        print('Yes')
    elif len(Sset) == 4:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

L = [0] * 4

for s in S:
  if s == "N":
    L[0] = 1
  elif s == "S":
    L[1] = 1
  elif s == "E":
    L[2] = 1
  elif s == "W":
    L[3] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(set(list(input())))
ans = "Yes"

import collections
c = collections.Counter(s)

if c["N"] + c["S"] == 1 or c["W"] + c["E"] == 1:
    ans = "No"
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
t = input()

n = False
s = False
e = False
w = False

for i in range(len(t)):
    n = n or t[i] == 'N'
    s = s or t[i] == 'S'
    e = e or t[i] == 'E'
    w = w or t[i] == 'W'

ok = True
ok = (n and s) or (not n and not s)
ok = ok and ((e and w) or (not e and not w))
print('Yes' if ok else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
hasN = S.find('N') >= 0
hasS = S.find('S') >= 0
hasE = S.find('E') >= 0
hasW = S.find('W') >= 0
if (hasN and hasS or not hasN and not hasS) and (hasE and hasW or not hasE and not hasW):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
x,y=0,0
li=s
if 'N' in li and 'S' in li and not 'E' in li and not 'W' in li:
  print('Yes')
  exit()
  
if 'E' in li and 'W' in li and not 'S' in li and not 'N' in li:
  print('Yes')
  exit()
 
for i in s:
    if(i=='N'):
        y+=1
    elif(i=='S'):
        y-=1
    elif(i=='W'):
        x-=1
    else:
        x+=1
if(x==0 and y==0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
li = list(map(str, input()))
x=0
y=0

if 'N' in li and 'S' in li and not 'E' in li and not 'W' in li:
  print('Yes')
  exit()
  
if 'E' in li and 'W' in li and not 'S' in li and not 'N' in li:
  print('Yes')
  exit()

for i in range(len(li)):
  if li[i]=='N':
    x=x+1
  elif li[i]=='S':
    x=x-1
  elif li[i]=='E':
    y=y+1
  elif li[i]=='W':
    y=y-1

if x==0 and y==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(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()

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

Submission status: Accepted

Solution code:
S = list(set(list(input())))
S.sort()
ans = "No"
if S[0] == 'E':
  if S[-1] == 'W':
    if len(S)==2 or len(S)==4:
      ans = "Yes"
if S[0] == 'N':
  if S[-1] == 'S':
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s=input()
ok = True

if s.count('N')*s.count('S')==0 and s.count('N')+s.count('S')!=0:
    ok=False
if s.count('W')*s.count('E')==0 and s.count('W')+s.count('E')!=0:
    ok=False
    
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
'''
Created on 2020/08/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  T=list(set(S))
  if len(T)==4:
    print("Yes")
  elif len(T)==3 or len(T)==1:
    print("No")
  else:
    if (("N" in S )and ("S" in S)) or (("W" in S) and ("E" in S)):
      print("Yes")
    else:
      print("No")
  return 

main()

Submission status: Accepted

Solution code:
*S, = input()

flag_x = False
flag_y = False

if 'S' in S and 'N' in S:
    flag_y = True
if 'S' not in S and 'N' not in S:
    flag_y = True

if 'E' in S and 'W' in S:
    flag_x = True
if 'E' not in S and 'W' not in S:
    flag_x = True

if flag_x and flag_y:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()


def walk(s):
    ls = len(s)
    nc = 0
    sc = 0
    wc = 0
    ec = 0
    l=[]
    for i in range(ls):
        if s[i] == "W":
            wc += 1
            l.append(wc)
        elif s[i] == "E":
            ec += 1
            l.append(ec)
        elif s[i] == "N":
            nc += 1
            l.append(nc)
        else:
            sc += 1
            l.append(sc)
    if (wc>0 and ec==0) or (wc==0 and ec>0) or (nc==0 and sc>0) or (nc>0 and sc==0):
        print("No")
        return
    
    else:
        print("Yes")
        return
walk(s)

Submission status: Accepted

Solution code:
s = input()

ans1 = (("S" in s) and ("N" in s)) or (("S" not in s) and ("N" not in s))
ans2 = (("E" in s) and ("W" in s)) or (("E" not in s) and ("W" not in s))

print("Yes" if ans1 and ans2 else "No")

Submission status: Accepted

Solution code:
import sys
from collections import Counter

tmp = sys.stdin.readline().strip()
directions = ""
pre = ""
for c in tmp:
    if c == pre:
        continue
    directions += c
    pre = c
    
counter = Counter(directions)
# print(counter)

d = {"S": 0, "E": 0, "N": 0, "W": 0}
for t, count in counter.items():
    d[t] = count

sn = False
if 0 < d["S"] and 0 < d["N"] and abs(d["S"] - d["N"]) < 2:
    sn = True
if d["S"] == d["N"]:
    sn = True

ew = False
if 0 < d["E"] and 0 < d["W"] and abs(d["E"] - d["W"]) < 2:
    ew = True
if d["E"] == d["W"]:
    ew = True

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

Submission status: Accepted

Solution code:
S = input().strip()
C = {"N":0,"S":0,"E":0,"W":0}
for i in range(len(S)):
    C[S[i]] += 1
if C["N"]>0 and C["S"]>0:
    if (C["E"]>0 and C["W"]>0) or (C["E"]==0 and C["W"]==0):
        print("Yes")
    else:
        print("No")
elif C["N"]==0 and C["S"]==0:
    if (C["E"]>0 and C["W"]>0) or (C["E"]==0 and C["W"]==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
S = list(input())
S = Counter(S)
ans = "No"
if len(S) == 4:
    ans = "Yes"
elif len(S) == 2:
    if "N" in S and "S" in S:
        ans = "Yes"
    if "W" in S and "E" in S:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = "Yes"

if "N" in s:
    if "S" not in s: ans = "No" 
if "S" in s:
    if "N" not in s: ans = "No"
if "W" in s:
    if "E" not in s: ans = "No"
if "E" in s:
    if "W" not in s: ans = "No"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
from collections import Counter
c = Counter(S)

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
list_s = list(set(s))
ans = ''
if len(set(s)) == 4:
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('E') == list_s.count('W'):
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('N') == list_s.count('S'):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
#A - Wanna go back home
S = list(input())

N = S.count('N')
E = S.count('E')
W = S.count('W')
s = S.count('S')

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

Submission status: Accepted

Solution code:
import collections
S=list(str(input()))
cc=collections.Counter(S)

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

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    se = input().rstrip()

    S = "S" in se
    N = "N" in se
    E = "E" in se
    W = "W" in se

    if (S ^ N) or (E ^ W):
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    S = input().rstrip()
    C = Counter(S)
    n = C['N']
    s = C['S']
    w = C['W']
    e = C['E']
    if (n != 0 and s != 0) or (n == 0 and s == 0):
        if (w != 0 and e != 0) or (w == 0 and e == 0):
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l = list(input())
n = l.count('N')
w = l.count('W')
s = l.count('S')
e = l.count('E')
if n == s or (n != 0 and s != 0):
    if w == e or (w != 0 and e != 0):
        print('Yes')
        exit(0)
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = list(input())

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

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

Submission status: Accepted

Solution code:
import collections


def main():
    s = list(input())
    c = collections.Counter(s)
    keys = list(c.keys())
    print("Yes" if ((keys.count("S") == 0 and keys.count("N") == 0) or (keys.count("S") == 1 and keys.count("N") == 1)) and (
        (keys.count("E") == 0 and keys.count("W") == 0) or (keys.count("E") == 1 and keys.count("W") == 1)) else "No")


if __name__ == '__main__':
    main()

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('W') > 0 and S.count('E') == 0 or S.count('W') == 0 and S.count('E') > 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=set(input())

flg=0
if "N" in s:
    flg+=1
if "S" in s:
    flg-=1
if "W" in s:
    flg+=10
if "E" in s:
    flg-=10

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    cnt = collections.Counter(S)
    n = cnt['N']
    w = cnt['W']
    s = cnt['S']
    e = cnt['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')

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
f = True
if S.count("N")*S.count("S") == 0 and S.count("N")+S.count("S") != 0:
    f = False
if S.count("E")*S.count("W") == 0 and S.count("E")+S.count("W") != 0:
    f = False
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
import sys
from collections import Counter

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

if "N" in s and "S" in s and "E" in s and "W" in s:
    print("Yes")
    exit()

if ("N" in s and "S" in s) and ("E" not in s and "W" not in s):
    print("Yes")
    exit()

if ("E" in s and "W" in s) and ("N" not in s and "S" not in s):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
s = list(input())
ew = []
sn = []
for i in s:
    if i == "E" or i == "W":
        ew.append(i)
    else:
        sn.append(i)
if len(set(ew)) == 1 or len(set(sn)) == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()

if s.count("N") > 0:
    if s.count("S") == 0:
        print("No")
        exit()

if s.count("S") > 0:
    if s.count("N") == 0:
        print("No")
        exit()

if s.count("W") > 0:
    if s.count("E") == 0:
        print("No")
        exit()

if s.count("E") > 0:
    if s.count("W") == 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
s= input().strip()
f="Yes"
if (s.count('N')!=s.count('S') and s.count('N')*s.count('S')==0):
    f="No"
elif(s.count('E')*s.count('W')==0 and s.count('E')!=s.count('W')):
    f="No"
print(f)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
n = 0
w = 0
s = 0
e = 0
x = len(S)
for i in range(x):
    if S[i] == 'N':
        n += 1
    elif S[i] == 'W':
        w += 1
    elif S[i] == 'S':
        s += 1
    elif S[i] == 'E':
        e += 1

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

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

else:
    print('No')

Submission status: Accepted

Solution code:
U=list(str(input()))
if "N" in U:
  if "S" not in U:
    print("No")
    exit()
if "S" in U:
  if "N" not in U:
    print("No")
    exit()
if "E" in U:
  if "W" not in U:
    print("No")
    exit()
if "W" in U:
  if "E" not in U:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
S = list(input())

res = True

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

if (n > 0) ^ (s > 0):
    res = False

if (w > 0) ^ (e > 0):
    res = False

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

Submission status: Accepted

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

S = input()
sS = set(S)
if "N" in sS or "S" in sS:
    if not ("N" in sS and "S" in sS):
        print('No')
        quit()
if "W" in sS or "E" in sS:
    if not ("W" in sS and "E" in sS):
        print('No')
        quit()
print('Yes')