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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = set(list(input()))
print("Yes" if ~("N" in a ^ "S" in a) and ~("W" in a ^ "E" in a) else "No")

Submission status: Runtime Error

Solution code:
    s = input()
    print(['Yes','No'][('N'in s)^('S'in s)|('E'in s)^('W'in s)])

Submission status: Runtime Error

Solution code:
s = set(input())
l = len(s)
if l in [1, 3]:
    print 'No'
elif l == 4:
    print 'Yes'
else:
    print ['No', 'Yes'][s in [set('NS'), set('WE')]]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    for line in sys.stdin:
		s = line
		if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
			print("Yes")
		else:
			print("No")

main()

Submission status: Runtime Error

Solution code:
def main():
    for line in sys.stdin:
		s = line
		if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
			print("Yes")
		else:
			print("No")

Submission status: Runtime Error

Solution code:
def back_home():
    r=input()
    t=r.count('S') +1
    y=r.count('N') +1
    u=r.count('W') +1
    i=r.count('E')+1
    if (t>1 and y>1 and u==1 and i==1):
        print("YES")
    elif((t==1 and y==1 and u>1 and i>1):
       print("YES")
    elif ((t>1 and y>1 and u>1 and i>1):
        print("YES")
    else:
        print("NO")
        
back_home()

Submission status: Runtime Error

Solution code:
def back_home():
    r=input()
    t=r.count('S') +1
    y=r.count('N') +1
    u=r.count('W') +1
    i=r.count('E')+1
    if (t>1 and y>1 and u==1 and i==1):
        print("YES")
    elif((t==1 and y==1 and u>1 and i>1):
       print("YES")
    elif ((t>1 and y>1 and u>1 and i>1):
        return("YES")
    else:
        print("NO")
        
back_home()

Submission status: Runtime Error

Solution code:
def back_home():
    r=input()
    t=r.count('S') +1
    y=r.count('N') +1
    u=r.count('W') +1
    i=r.count('E')+1
    if (t>1 and y>1 and u==1 and i==1):
        return("YES")
    elif((t==1 and y==1 and u>1 and i>1):
       return("YES")
    elif ((t>1 and y>1 and u>1 and i>1):
        return("YES")
    else:
        return("NO")
        
back_home()

Submission status: Runtime Error

Solution code:
def back_home():
    r=input()
    print(r)
    l = dict()
    for i in r:
        if i in l:
            l[i]=int(l[i])+1
        else:
            l[i]=1
    if (len(l)==1):
        return('NO')
    elif(len(l)==2):
        if (l['S']>0 and l['N']>0):
            return ("yes")
        elif(l['E']>0 and l['W']>0):
            return("yes")
        else:
            return("NO")
    elif(len(l)==3):
        return("NO")
    else:
        return("YES")
        
back_home()

Submission status: Runtime Error

Solution code:
def back_home(r):
    l = dict()
    for i in r:
        if i in l:
            l[i]=int(l[i])+1
        else:
            l[i]=1
    if (len(l)==1):
        return('NO')
    elif(len(l)==2):
        if (len(l['S'])>0 and len(l['N']>0)):
            return ("yes")
        elif(len(l['E'])>0 and len(l['W']>0)):
            return("yes")
        else:
            return("NO")
    elif(len(l)==3):
        return("NO")
    else:
        return("YES")
        
back_home(S):

Submission status: Runtime Error

Solution code:
def ch(l):
  return l[0] != l[-1]


S = str(input())
v = []
h = []


for i in range(len(S)):
  p = S[i]
  if (p in 'NS'):
    v.append(p)
  else:
    h.append(p)

if (len(v) == 0 and len(h) == 0):
  print('Yes')
elif (len(v) == 0 and ch(h)):
  print('Yes')
elif (len(h) == 0 and ch(v)):
  print('Yes')
elif (ch(h) and ch(v)):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
    s=raw_input()
    n=False
    e=False
    w=False
    ss=False
    for i in xrange(len(s)):
        if s[i]=="N":n=True
        elif s[i]=="E":e=True
        elif s[i]=="W":w=True
        else:ss=True
    if (n and ss) or (e and w):
        print("Yes")
    else:
        if not n and not ss and not e and not w:
            print("Yes")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(n):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n and ss) or (e and w):
    print("Yes")
else:
    if not n and not ss and not e and not w:
        print("Yes")
    else:
        print("No")

else:
    if not n and not ss and not e and not w:
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
import sys

#sys.stdin = open('b_2.txt', 'r')

N = int(raw_input())
rest = [0 for _ in range(N)]
ins = [0 for _ in range(N)]
pairs = 0
for x in range(N):
	n = long(raw_input())
	ins[x] = n
	pairs += n / 2
	rest[x] = n % 2

for x in range(0, N - 1, 1):
	if ((rest[x] == 1) and (rest[x + 1] == 1)):
		pairs += 1
	elif ((rest[x] == 1) and (rest[x + 1] == 0) and (ins[x + 1] > 0)):
		rest[x + 1] = 1
		ins[x + 1] -= 2
		rest[x] = 0
	else:
		pass

print str(pairs)

Submission status: Runtime Error

Solution code:
#AGC003B

n=int(raw_input())
s=[]
for i in xrange(1,n+1):
 x=int(raw_input())
 for j in xrange(x):
  s.append(i)
cnt=0
i=0
while i<len(s)-1:
 if s[i+1]-s[i]==0 or s[i+1]-s[i]==1:
  cnt+=1
  i+=2
 else:
  i+=1
print cnt

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(raw_input())
A = [0] * N
for idx in xrange(N):
  A[idx] = int(raw_input())
total =  0
pre = 0
for item in A:
  total += (item+pre) / 2
  if item == 0:
    pre = 0
  else:
    pre = (item+pre) % 2

print total

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(raw_input())
A = [0] * N
for idx in xrange(N):
  A[idx] = int(raw_input())
total =  0
pre = 0
for item in A:
  total += (item+pre) / 2
  if item == 0:
    pre = 0
  else:
    pre = (item+pre) % 2

print total

Submission status: Runtime Error

Solution code:
n, w, s, e = 0
for c in input():
	if c == "N":
		n += 1
	if c == "W":
		w += 1
	if c == "S":
		s += 1
	if c == "E":
		e += 1
b = ((n >= 1 and s >= 1) or (n==s==0)) and ((w >= 1 and e >= 1) or (w==e==0))
print("Yes" if b else "No")

Submission status: Runtime Error

Solution code:
#coding: cp932
N = int(input())
inp =[]
for s in range(N):
	inp.append(int(input()))
check = inp[:]
check.sort()
flag=1
s,ans,lis2 = 0,0,[]

while flag==1:
	#lis.append(check[s])
	lis2.append(inp[s])
	s+=2
	if s>N-1:
		flag=0
num =len(lis)
#print(lis)
#print(lis2)
for s in range(num):
	if s!=0:
		if check[s+2] not in lis2:
			ans+=1
			lis[s] =-1
		continue
	else:
		if check[s] not in lis2:
			ans+=1
			lis[s]=-1
print(ans)

Submission status: Runtime Error

Solution code:
#coding: cp932
N = int(input())
i=[]
for s in range(N):
	i.append(input())

ans=0
for s in range(N-1):
	if i[1+s]==0:
		continue
	cul= int((i[1+s]+i[2+s])/2)
	ans += cul
	if i[1+s]>i[2+s]:
		amari = (i[1+s]+i[2+s])%2
print(ans)

Submission status: Runtime Error

Solution code:
#coding: cp932
i=int(input())
#i = [int(input())for s in range(M)]
i = list(i)
#print(i)
N = int(i[0])
ans=0
for s in range(N-1):
	if i[1+s]==0:
		continue
	cul= int((i[1+s]+i[2+s])/2)
	ans += cul
	if i[1+s]>i[2+s]:
		amari = (i[1+s]+i[2+s])%2
print(ans)

Submission status: Runtime Error

Solution code:
import math
import collections

p_max = int(10**(10./3))

marked = [True]*2+[False]*(p_max-2)
ps = []

for n in range(2,p_max):
    if marked[n]:
        continue
    ps.append(n)
    for n2 in range(n, p_max):
        if n2 % n == 0:
            marked[n2] = True

def getexp(n, p):
    ans = 0
    while n > 1 and n % p == 0:
        ans += 1
        n = n // p
    return ans

def getcanon(n):
    canon = []
    for p in ps:
        if n == 1:
            return tuple(canon)
        e = getexp(n, p)
        n = n//(p**e)
        if e % 3 != 0:
            canon.append((p, e % 3))
    sqr = int(math.sqrt(n+0.5))
    if sqr**2 == n:
        canon.append((sqr, 2))
    else:
        canon.append((n,1))
    return tuple(canon)

def getcomp(canon):
    return tuple([(p,3-e) for (p,e) in canon])


N = int(raw_input())
s = [int(raw_input()) for i in range(N)]

ctr = collections.Counter()

for si in s:
    ctr[getcanon(si)] += 1

ans = 0

cans = list(ctr.keys())

for can in cans:
    ct = ctr[can]
    if ct == 0:
        continue
    if can == ():
        ans += 1
        ctr[can] = 0
        continue
    comp = getcomp(can)
    c_ct = ctr[comp]
    if c_ct == 0:
        ans += ct
    else:
        ans += max(ct, c_ct)
        ctr[comp] = 0

print ans

Submission status: Runtime Error

Solution code:
n=raw_input()
a=n[-1:]
b=n[-2:]
if a==N and b==S or a==S and b==N:
    print "Yes"
elif a==E and b==W or a==W and b==E:
    print "Yes"
else:
    print "No"

Submission status: Runtime Error

Solution code:
#
N = input()
#S = []
count = 0
flag = 0
for i in range(1,N+1):
    IN = input()
    #S.append(IN)
    if flag:
        if (flag == i - 1):
            if  IN > 0:
                IN -= 1
                count += 1
    flag = 0

    count += IN/2
    if IN%2 == 1:
        flag = i

print count

Submission status: Runtime Error

Solution code:
# coding: UTF-8
s = raw_input()

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

Submission status: Runtime Error

Solution code:
s = input()
a = s.count("S") - s.count("N")
b = s.count("E") - s.count("W")
if (a == 0 && a == b):
 print ("Yes")
else:
 print ("No")

Submission status: Runtime Error

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