ZhenlongDai/ACPR huggingface dataset:
Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math

s = input()
ans = math.ceil(len(s)/2) - s.count("p")
print(ans)

Failing test case input:
pgg

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

import math

s = input()
ans = math.floor(len(s)/2) - s.count("p")
print(ans)

Problem: p03965
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = str(input().rstrip())

def battle(s1, s2):
    l = {'g': {'g': 0, 'p': -1}, 'p': {'g': 1, 'p': 0}}
    return l[s1][s2]

hist = ['g']

g = 1
p = 0
ans = 0
if s[0] == 'p':
    ans = -1
for i in range(1, len(s)):
    cur = 'g'
    if s[i] == 'g':
        if p < g:
            cur = 'p'
    if cur == 'p':
        p += 1
    else:
        g += 1
    hist.append(cur)
    ans += battle(cur, s[i])



print(ans)


Failing test case input:
pggggggpgp

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s = str(input().rstrip())

def battle(s1, s2):
    l = {'g': {'g': 0, 'p': -1}, 'p': {'g': 1, 'p': 0}}
    return l[s1][s2]

hist = ['g']

g = 1
p = 0
ans = 0
if s[0] == 'p':
    ans = -1
for i in range(1, len(s)):
    cur = 'g'
    if s[i] == 'g':
        if p < g:
            cur = 'p'
    if s[i] == 'p':
        if p < g:
            cur = 'p'

    if cur == 'p':
        p += 1
    else:
        g += 1
    hist.append(cur)
    ans += battle(cur, s[i])



print(ans)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = [1 if _ == 'p' else 0 for _ in input()]
N = len(S)
count_g = 0
count_p = 0
score = 0
for hand_t in S:
    if hand_t == 0 and count_p < count_g:
        count_p += 1
        hand_a = 1
    else:
        count_g += 1
        hand_a = 0
    score += hand_a - hand_t

print(score)


Failing test case input:
ggggggpppg

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
S = [1 if _ == 'p' else 0 for _ in input()]
N = len(S)
count_g = 0
count_p = 0
score = 0
for hand_t in S:
    if count_p < count_g:
        count_p += 1
        hand_a = 1
    else:
        count_g += 1
        hand_a = 0
    score += hand_a - hand_t

print(score)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
score = 0
toUse = 0
for it in s:
  if it == 'g' and toUse > 0:
    toUse -= 1
    score += 1
    continue
  if it == 'g':
    toUse += 1
    continue
  if toUse > 0:
    toUse -= 1
  else:
    score -=1
    
print(score)


Failing test case input:
ggpgppgggg

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s = input()
score = 0
toUse = 0
for it in s:
  if it == 'g' and toUse > 0:
    toUse -= 1
    score += 1
    continue
  if it == 'g':
    toUse += 1
    continue
  if toUse > 0:
    toUse -= 1
  else:
    toUse += 1
    score -=1
    
print(score)
Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
n = len(s)

s = [i for i in s]
for i in range(n):
    if s[i] == "p":
        s[i] = 1
    else:
        s[i] = 0
print(s)

d = [0]*n
d[0] = 0
gc = 1
pc = 0
for i in range(1, n):
    if gc-1 >= pc:
        d[i] = 1
        pc += 1
    else:
        d[i] = 0
        gc += 1
print(d)

ans = 0
for i in range(n):
    ans += d[i]-s[i]

print(ans)

Failing test case input:
pppggggggg

Expected output:
2


Actual output:
[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
2


Fixed submission (verdict: Accepted):
s = input()
n = len(s)

s = [i for i in s]
for i in range(n):
    if s[i] == "p":
        s[i] = 1
    else:
        s[i] = 0

d = [0]*n
d[0] = 0
gc = 1
pc = 0
for i in range(1, n):
    if gc-1 >= pc:
        d[i] = 1
        pc += 1
    else:
        d[i] = 0
        gc += 1

ans = 0
for i in range(n):
    ans += d[i]-s[i]

print(ans)
Problem: p03965
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans



s = input()[:-1]

ja = [[0,0] for i in range(len(s)+1)]

for i in range(len(s)):
    if s[i] == "g":
        ja[i+1][0] = ja[i][0] + 1
        ja[i+1][1] = ja[i][1]
    else:
        ja[i+1][0] = ja[i][0]
        ja[i+1][1] = ja[i][1] + 1

co = 0

for i in range(len(s)-1,-1,-1):
    if s[i] == "g":
        if ja[i][0] - ja[i][1] - co > 0:
            co += 1
        
    

print(co)



Failing test case input:
ggggpgppgg

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans



s = input()[:-1]

po = 0

for i in range(len(s)):
    if s[i] == "p":
        po += 1
    

print(len(s)

Problem: p03965
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

ans = 0

r = 0
p = 0

for j in s:
  if j == 'g':
    r += 1
    if p > 1:
      ans -= p
    p = 0
  else:
    p += 1
    if r > 1:
      ans += r
    r = 0
if p > 1:
  ans -= p
if r > 1:
  ans += r
print (ans)

Failing test case input:
gppggpgggg

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
import math
s = input()
 
ans = 0
 
r = 0
p = 0
c = 0
for j in s:
  c = r-p
  if j == 'g':
    if c > 0:
      p += 1
      ans += 1
    else:
      r += 1
  else:
    if c > 0:
      p += 1
    else:
      r += 1
      ans -= 1
print (ans)
Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

p_count = 0
g_count = 0
win = 0

for i in list(s):

    if i == "g" and p_count <= g_count - 1:
        p_count += 1
        win += 1
    elif i == "g":
        g_count += 1
    else:
        p_count += 1

print(win)


Failing test case input:
gggpggggpp

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()

p_count = 0
g_count = 0
win = 0

for i in list(s):
    if i == "g" and p_count + 1 <= g_count:
        p_count += 1
        win += 1
    elif i == "g":
        g_count += 1
    elif i == "p" and p_count + 1 <= g_count:
        p_count += 1
    else:
        g_count += 1
        win -= 1

print(win)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
g, p = 0, 0
ans = 0
for e in s:
    if e == "g":
        if p+1 <= g:
            p += 1
            ans += 1
        else:
            g += 1
    else:
        p += 1

print(ans)


Failing test case input:
ggp

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
s = input()
g, p = 0, 0
ans = 0
for e in s:
    if e == "g":
        if p+1 <= g:
            p += 1
            ans += 1
        else:
            g += 1
    else:
        if p+1 <= g:
            p += 1
        else:
            g += 1
            ans -= 1

print(ans)

Problem: p03965
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

s = list(input().rstrip())
g = 0
p = 0
res = []
ans = 0

for i in range(len(s)):
    c = g-p
    if s[i] == "g":
        if c > 0:
            
            p += 1
            ans += 1
        else:
            
            g += 1
    else:
        
        p += 1
print(ans)

Failing test case input:
gggggpggpp

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

s = list(input().rstrip())
g = 0
p = 0
res = []
ans = 0

for i in range(len(s)):
    c = g-p
    if s[i] == "g":
        if c > 0:
            
            p += 1
            ans += 1
        else:
            
            g += 1
    else:
        if c > 0:
            
            p += 1
        else:
            
            g += 1
            ans -= 1
print(ans)
Problem: p03965
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = input()
n = len(s)
ans = 0
cnt = 0
for i in range(n):
    if s[i] == 'g':
        if cnt > 0:
            ans += 1
            cnt -= 1
        else:
            cnt += 1
    else:
        cnt -= 1
print(ans)


Failing test case input:
ggp

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = input()
n = len(s)
ans = 0
cnt = 0
for i in range(n):
    if s[i] == 'g':
        if cnt > 0:
            ans += 1
            cnt -= 1
        else:
            cnt += 1
    else:
        if cnt == 0:
            ans -= 1
            cnt += 1
        else:
            cnt -= 1
print(ans)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
  if cou > 0 and lis[i] == "g":
    cou -= 1
    ans += 1
  else:
    cou += 1
    if lis[i] == "p":
      ans -= 1
print(ans)

Failing test case input:
gpggggpggp

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
	if lis[i] == "g":
		if cou > 0:
			cou -= 1
			ans += 1
		else:
			cou += 1
	else:
		if cou > 0:
			cou -= 1
		else:
			cou += 1
			ans -= 1
print(max(0,ans))

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
g=s.count('g')
p=s.count('p')
a=g-p+(g+p)
print(a)

Failing test case input:
ggpggppggg

Expected output:
2


Actual output:
14


Fixed submission (verdict: Accepted):
s=input()
g=s.count('g')
p=s.count('p')
a=(-p+(g+p)
print(a)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
  if cou > 0 and lis[i] == "g":
    cou -= 1
    ans += 1
  else:
    cou += 1
    if lis[i] == "p":
      ans -= 1
print(max(ans,0))

Failing test case input:
gggggppgpg

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
	if lis[i] == "g":
		if cou > 0:
			cou -= 1
			ans += 1
		else:
			cou += 1
	else:
		if cou > 0:
			cou -= 1
		else:
			cou += 1
			ans -= 1
print(max(0,ans))
Problem: p03965
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

ans = 0

r = 0
p = 0

for j in s:
  if j == 'g':
    r += 1
    if p > 1:
      ans -= p
    p = 0
  else:
    p += 1
    if r > 1:
      ans += r
    r = 0
if p >= 1:
  if p == 1 and ans > 0:
    ans -= 1
  elif p > 1:
    ans -= p
if r > 1:
  ans += r
print (ans)

Failing test case input:
pgpggpgggg

Expected output:
2


Actual output:
6


Fixed submission (verdict: Accepted):
import math
s = input()
 
ans = 0
 
r = 0
p = 0
c = 0
for j in s:
  c = r-p
  if j == 'g':
    if c > 0:
      p += 1
      ans += 1
    else:
      r += 1
  else:
    if c > 0:
      p += 1
    else:
      r += 1
      ans -= 1
print (ans)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
hands = input()
ans = 0
for i, h in enumerate(hands):
  if i % 2 == 1:
    if h == "p":
      ans -= 1
  else:
    if h == "g":
      ans += 1
      
print(ans)
   

Failing test case input:
pgg

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
hands = input()
ans = 0
for i, h in enumerate(hands):
  if i % 2 == 0:
    if h == "p":
      ans -= 1
  else:
    if h == "g":
      ans += 1
      
print(ans)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
score = 0
toUse = 0
for it in s:
  if it == 'g' and toUse > 0:
    toUse -= 1
    score += 1
    continue
  if it == 'g':
    continue
  if toUse > 0:
    toUse -= 1
  else:
    score -=1
    
print(score)


Failing test case input:
gpgpggpggg

Expected output:
2


Actual output:
-3


Fixed submission (verdict: Accepted):
s = input()
score = 0
toUse = 0
for it in s:
  if it == 'g' and toUse > 0:
    toUse -= 1
    score += 1
    continue
  if it == 'g':
    toUse += 1
    continue
  if toUse > 0:
    toUse -= 1
  else:
    toUse += 1
    score -=1
    
print(score)

Problem: p03965
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
  if cou > 0 and lis[i] == "g":
    cou -= 1
    ans += 1
  else:
    cou += 1
    if lis[i] == "p":
      ans -= 1
print(ans - cou)

Failing test case input:
gggggpppgg

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
	if lis[i] == "g":
		if cou > 0:
			cou -= 1
			ans += 1
		else:
			cou += 1
	else:
		if cou > 0:
			cou -= 1
		else:
			cou += 1
			ans -= 1
print(max(0,ans))
Problem: p03965
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=input()
n=len(s)
res=0
tg,tp=0,0
for i in range(n):
    if s[i]=="g":
        if tg>tp:
            tp+=1
            res+=1
        else:
            tg+=1
    else:
        if tg<=tp:
            tp+=1
        else:
            tg+=1
            res-=1
print(res)

Failing test case input:
ggpggpgggp

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s=input()
n=len(s)
res=0
tg,tp=0,0
for i in range(n):
    if s[i]=="g":
        if tg>tp:
            tp+=1
            res+=1
        else:
            tg+=1
    else:
        if tg>tp:
            tp+=1
        else:
            tg+=1
            res-=1
print(res)
Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(input())
print("Yes" if ~(("N" in a) ^ ("S" in a)) and ~(("W" in a) ^ ("E" in a)) else "No")

Failing test case input:
NWND

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a = list(input())
print("No" if (("N" in a) ^ ("S" in a)) or (("W" in a) ^ ("E" in a)) else "Yes")

Problem: p04019
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
u = 0
l = 0
for i in s:
    if i == 'N':
        u += 1
    elif i == 'S':
        u -= 1
    elif i == 'E':
        l += 1
    else:
        l -= 1
    if u == 0 and l == 0:
        print('Yes')
        break
else:
    print('No')

    

Failing test case input:
YENN

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
c = Counter(s)
a,b,c,d = [c['N'], c['S'], c['W'], c['E']]
if (a and b) or (not a and not b):
    if (c and d) or (not c and not d):
        print('Yes')
        quit()
print('No')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k = str(input())


n = 0
w = 0
s = 0
e = 0
for i in range(len(k)):
    if k[i] == "N":
        n += 1
    elif k[i] == "W":
        w += 1
    elif k[i] == "S":
        s += 1
    else:
        e += 1
if (n == 0 and s > 0) or (s == 0 and n > 0) or (e == 0 and w > 0) or (w == 0 and e > 0):
    print("No")
else:
    print("No")

Failing test case input:
SEWN

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
k = str(input())


n = 0
w = 0
s = 0
e = 0
for i in range(len(k)):
    if k[i] == "N":
        n += 1
    elif k[i] == "W":
        w += 1
    elif k[i] == "S":
        s += 1
    else:
        e += 1
if (n == 0 and s > 0) or (s == 0 and n > 0) or (e == 0 and w > 0) or (w == 0 and e > 0):
    print("No")
else:
    print("Yes")

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(input())
print("Yes" if ~(("N" in a) ^ ("S" in a)) or ~(("W" in a) ^ ("E" in a)) else "No")

Failing test case input:
NZDN

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a = list(input())
print("No" if (("N" in a) ^ ("S" in a)) or (("W" in a) ^ ("E" in a)) else "Yes")
Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
N = 0
S = 0
W = 0
E = 0
for i in range(len(s)) :
    str = s[i]
    if str == 'N' :
        N = 1
    elif str == 'S':
        S = 1
    elif str == 'W':
        W = 1
    elif str == 'E':
        E = 1
if (N-S)==0 and (W-E)==0 :
    print('YES')
else:
    print('NO')


Failing test case input:
NNDW

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
N = 0
S = 0
W = 0
E = 0
for i in range(len(s)) :
    str = s[i]
    if str == 'N' :
        N = 1
    elif str == 'S':
        S = 1
    elif str == 'W':
        W = 1
    elif str == 'E':
        E = 1
if (N-S)==0 and (W-E)==0 :
    print('Yes')
else:
    print('No')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
print('Yes' if('W' in s == 'E' in s and 'S' in s == 'N' in s) else 'No')

Failing test case input:
ENWS

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()
print('Yes' if(('W' in s)==('E' in s) and ('N' in s)==('S' in s)) else 'No')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ins = input().strip()
if not ('S' in ins and 'N' in ins) and ('S' in ins or 'N' in ins):
        print('No')

if not ('E' in ins and 'W' in ins) and ('E' in ins or 'W' in ins):
        print('No')

 
print('Yes')

Failing test case input:
NNYD

Expected output:
No


Actual output:
No
Yes


Fixed submission (verdict: Accepted):
s = input().strip()
if not ('S' in s and 'N' in s) and ('S' in s or 'N' in s):
        print('No')
        exit()

if not ('E' in s and 'W' in s) and ('E' in s or 'W' in s):
        print('No')
        exit()

 
print('Yes')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
if 'N' in s and 'W' in s and 'S' in s and 'E' in s:
    print('Yes')
elif 'N' in s and 'W' in s and 'S' not in s and 'E' not in s:
    print('Yes')
elif 'N' not in s and 'W' not in s and 'S' in s and 'E' in s:
    print('Yes')
else:
    print('No')

Failing test case input:
WMEO

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
s = 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')
Problem: p04019
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    s = S()
    ans = [0, 0]
    for si in s:
        if si == "N":
            ans[0] = min(ans[0] + 1, 1)
        elif si == "W":
            ans[1] = min(ans[1] + 1, 1)
        elif si == "S":
            ans[0] = max(ans[0] - 1, -1)
        else:
            ans[1] = max(ans[1] - 1, -1)
    if ans == [0, 0]:
        print("Yes")
    else:
        print("No")
    return



if __name__ == '__main__':
    solve()


Failing test case input:
NSNNSNSN

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    s = S()
    ans = [0, 0]
    for si in s:
        if si == "N":
            ans[0] |= 1
        elif si == "W":
            ans[1] |= 1
        elif si == "S":
            ans[0] |= 2
        else:
            ans[1] |= 2
    if ans[0] in [0, 3] and ans[1] in [0, 3]:
        print("Yes")
    else:
        print("No")
    return



if __name__ == '__main__':
    solve()
Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
kita = s.count("N")
mina = s.count("W")
nisi = s.count("S")
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")

Failing test case input:
WNDN

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
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")

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 2
if 'W' in s:
    judge += 1/1000
if 'S' in s:
    judge -= 2
if 'E' in s:
    judge -= 1/1000

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

Failing test case input:
NEWS

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
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')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

Failing test case input:
WESN

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b*c*d > 0:
  print('Yes')
elif a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

Problem: p04019
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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 not ("N" in s and "S" in s):
    print("No")
    exit()
    if not ("E" in s and "W" in s):
        print("No")
        exit()

print("Yes")

Failing test case input:
MWER

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
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")
Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1
if 'W' in s:
    judge += 1/1000
if 'S' in s:
    judge -= 1
if 'E' in s:
    judge -= 1/1000

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

Failing test case input:
NESW

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
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')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

tmp = [0 for _ in range(4)]

res = 'Yes'
for i in range(len(S)):
    if S[i] == 'S':
        tmp[0] = 1
    elif S[i] == 'N':
        tmp[1] = 1
    elif S[i] == 'W':
        tmp[2] = 1
    else:
        tmp[2] = 1
        
if tmp[0] == 1 and tmp[1] == 0:
    res = 'No'
if tmp[1] == 1 and tmp[0] == 0:
    res = 'No'
if tmp[2] == 1 and tmp[3] == 0:
    res = 'No'
if tmp[3] == 1 and tmp[2] == 0:
    res = 'No'

print(res)



Failing test case input:
SENW

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
S = input()

tmp = [0 for _ in range(4)]

res = 'Yes'
for i in range(len(S)):
    if S[i] == 'S':
        tmp[0] = 1
    elif S[i] == 'N':
        tmp[1] = 1
    elif S[i] == 'W':
        tmp[2] = 1
    else:
        tmp[3] = 1
        
if tmp[0] == 1 and tmp[1] == 0:
    res = 'No'
if tmp[1] == 1 and tmp[0] == 0:
    res = 'No'
if tmp[2] == 1 and tmp[3] == 0:
    res = 'No'
if tmp[3] == 1 and tmp[2] == 0:
    res = 'No'

print(res)

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
ans = 'Yes'
n = 0
w = 0
sow = 0
e = 0

for i in range(len(s)):
    if s[i] == 'N':
        n += 1
    elif s[i] == 'W':
        w += 1
    elif s[i] == 'S':
        sow += 1
    else:
        e += 1



if (n == 0 and w != 0) or (n != 0 and w == 0):
    ans = 'No'
if (sow == 0 and e != 0) or (sow != 0 and e == 0):
    ans = 'NO'
print(ans)

Failing test case input:
NXNF

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
ans = 'Yes'
n = 0
w = 0
sow = 0
e = 0

for i in range(len(s)):
    if s[i] == 'N':
        n += 1
    elif s[i] == 'W':
        w += 1
    elif s[i] == 'S':
        sow += 1
    else:
        e += 1



if (n == 0 and sow != 0) or (n != 0 and sow == 0):
    ans = 'No'
if (w == 0 and e != 0) or (w != 0 and e == 0):
    ans = 'No'
print(ans)
Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S = input()


cn = S.count('N')
ce = S.count('E')
cs = S.count('S')
cw = S.count('W')
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')


Failing test case input:
MWER

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):

S = input()


cn = S.count('N')
ce = S.count('E')
cs = S.count('S')
cw = S.count('W')

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')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
if 'S' in s and 'N' in s or not ('S' in s or 'N' in s) or 'E' in s and 'W' in s or not ('E' in s or 'W' in s):
  print('Yes')
else:
  print('No')

Failing test case input:
XDNN

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s = list(input())
if ('N' in s and 'S' in s or not ('N' in s or 'S' in s)) and ('E' in s and 'W' in s or not ('E' in s or 'W' in s)):
  print('Yes')
else:
  print('No')

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
if s.count("N") == s.count("S") and s.count("W") == s.count("E"):
  print("Yes")
else:
  print("No")

Failing test case input:
NSNNSNSN

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
s = input()
if len(set(s))%2 == 0 and ((s.count("N") and s.count("S")) != 0 or (s.count("W") and s.count("E")) != 0):
  print("Yes")
else:
  print("No")

Problem: p04019
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
N = 0
W = 0
S = 0
E = 0
for i in s:
  if i == 'N':
    N = 1
  if i == 'W':
    W = 1
  if i == 'S':
    S = 1
  if i == 'E':
    E = 1
if ((N == 0 and S == 0) or (N == 1 and S == 1)) and ((W == 0 and E == 0) or (N == 1 and S == 1)):
  print('Yes')
else:
  print('No')

Failing test case input:
MWER

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
s = list(input())
N = 0
W = 0
S = 0
E = 0
for i in s:
  if i == 'N':
    N = 1
  if i == 'W':
    W = 1
  if i == 'S':
    S = 1
  if i == 'E':
    E = 1
if ((N == 0 and S == 0) or (N == 1 and S == 1)) and ((W == 0 and E == 0) or (W == 1 and E == 1)):
  print('Yes')
else:
  print('No')
Problem: p02914
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
A=[int(i) for i in input().split()]

suma=0
for i in range(n):
    suma^=A[i]

B=[~suma&me for me in A]
B.sort(reverse=True)

cnt=0
for i in range(59,-1,-1):
    B.sort(reverse=True)
    if B[cnt]&(1<<i)>0:
        
        for q in range(cnt):
            if B[q]&(1<<i)>1:
                B[q]^=B[cnt]
        for q in range(cnt+1,n):
            if B[q]&(1<<i)>1:
                B[q]^=B[cnt]
            else:
                break          
        cnt+=1

ans=0
B.sort(reverse=True)
for i in range(min(n,60)):
    ans^=B[i]

print(ans*2+suma)

Failing test case input:
4
6 17 66 3

Expected output:
88


Actual output:
86


Fixed submission (verdict: Accepted):
n=int(input())
A=[int(i) for i in input().split()]

suma=0
for i in range(n):
    suma^=A[i]

B=[~suma&me for me in A]
B.sort(reverse=True)

cnt=0
for i in range(59,-1,-1):
    B.sort(reverse=True)
    if B[cnt]&(1<<i)>0:
        
        for q in range(cnt):
            if B[q]&(1<<i)>0:
                B[q]^=B[cnt]
        for q in range(cnt+1,n):
            if B[q]&(1<<i)>0:
                B[q]^=B[cnt]
            else:
                break          
        cnt+=1

ans=0
B.sort(reverse=True)
for i in range(n):
    ans^=B[i]

print(ans*2+suma)

Problem: p02914
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.append(0)
for i in range(n):
    a[n] ^= a[i]
    
    
for i in range(n):
    a[i] &= ~a[n]
r = 0
for i in range(60, -1, -1):
    for j in range(r, n):
        if (a[j] >> i) & 1:
            a[r], a[j] = a[j], a[r]
            break
    else:
        continue
        
    for j in range(n):
        if (a[j] == a[r]):
            continue
        if (a[j]>>i) & 1:
            a[j] ^= a[r]
    r+=1
s = 0
for i in range(r):
    s ^= a[i]
    
print(s*2 + a[n])

Failing test case input:
20
1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 495007025435533594 172946206951478934 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181

Expected output:
1393667939037393010


Actual output:
1393667939036328046


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
 
s = 0
for i in range(N) :
    s ^= A[i]
    
for i in range(N) :
    A[i] &= ~s
 
r = 0
for i in range(60, -1, -1) :
    for j in range(r, N) :
        if (A[j] >> i) & 1 :
            A[r], A[j] = A[j], A[r]
            break
    else :
        continue
    
    for j in range(N) :
        if j == r :
            continue
        if (A[j] >> i) & 1 :
            A[j] ^= A[r]
    
    r += 1
    
ret = 0
for i in range(r) :
    ret ^= A[i]
    
print(ret * 2 + s)