Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03308 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0

for i in range(0,N):
  for j in range(i,N):
    ans = max(abs(A[i]-A[j]),ans)
    
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0

for i in range(0,N):
  for j in range(i,N):
    ans = max(abs(i-j))
    
print(ans)
Problem p03341 (python)

Fixed submission:
N=int(input())
S=input()

left=[0]*N
right=[0]*N
to_change=[0]*N

if S[0]=="E":
    right[0]=1
else:
    left[0]=1

for i in range(1,N):
    if S[i]=="W":
        left[i] = left[i-1]+1
        right[i] = right[i-1]
    if S[i]=="E":
        right[i] = right[i-1]+1
        left[i]= left[i-1]

to_change[0]=right[-1]-right[0]
to_change[-1]=left[-2]

for j in range(1,N-1):
    to_change[j]=(right[-1]-right[j])+(left[j-1])
#print(to_change)
print(min(to_change))

Buggy submission (verdict: Runtime Error):
ARC098 - Attention
 
Shoji Taisaku(FJK 庄司 大作)
2020/03/11 (水) 11:33
受信トレイ; 送信済みトレイ
宛先:
Shoji Taisaku(FJK 庄司 大作);
N=int(input())
S=input()

left=[0]*N
right=[0]*N
to_change=[0]*N

if S[0]=="E":
    right[0]=1
else:
    left[0]=1

for i in range(1,N):
    if S[i]=="W":
        left[i] = left[i-1]+1
        right[i] = right[i-1]
    if S[i]=="E":
        right[i] = right[i-1]+1
        left[i]= left[i-1]

to_change[0]=right[-1]-right[0]
to_change[-1]=left[-2]

for j in range(1,N-1):
    to_change[j]=(right[-1]-right[j])+(left[j-1])
#print(to_change)
print(min(to_change))
Problem p03360 (python)

Fixed submission:
A,B,C=map(int,input().split())
K=int(input())

m=max(A,B,C)
print((2**K)*m + (A+B+C-m))

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
K=int(input())

m=max(A,B,C)
print((2**K)*m + (A+B+C-m)
Problem p03408 (python)

Fixed submission:
from collections import Counter
N=int(input())
s=[0]*N

for i in range(N):
    s[i]=input()
M=int(input())
t=[0]*M
for j in range(M):
    t[j]=input()

c=dict(Counter(s))
d=dict(Counter(t))
maxi=0
#print(c)
#print(d)

for item in c:
    if item in d:
        tmp = c[item]-d[item]
    else:
        tmp = c[item]
    maxi=max(maxi, tmp)
   
print(maxi)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
s=[0]*N
t=[0]*M
for i in range(N):
    s[i]=input()
M=int(input())
for j in range(M):
    t[j]=input()

c=dict(Counter(s))
d=dict(Counter(t))
maxi=0
#print(c)
#print(d)

for item in c:
    if item in d:
        tmp = c[item]-d[item]
    else:
        tmp = c[item]
    maxi=max(maxi, tmp)
   
print(maxi)
Problem p03424 (python)

Fixed submission:
N=int(input())
S=list(input().split() )

M=set(S)
if len(M)==4:
  print("Four")
else:
  print("Three")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(map(int,input().split()))

M=set(S)
if len(M)==4:
  print("Four")
else:
  print("Three")
Problem p03433 (python)

Fixed submission:
N=int(input())
A=int(input())
flag=True
ans="No"

for i in range(0,A+1):
  if flag:
    for j in range(0,N//500+1):
      if i+500*j==N:
        ans="Yes"
        flag=False
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=int(input())
flag=True
ans="No"

for i in range(0,A+1):
  flag:
    for j in range(0,N//500+1)):
      if i+500*j==N:
        ans="Yes"
        flag=False
        break

print(ans)
Problem p03435 (python)

Fixed submission:
c=[list(map(int,input().split())) for i in range(3)]


  
for i in range(101):
  info=True
  a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if c[1][2]!=a2+b3:
    info=False
  if c[2][2]!=a3+b3:
    info=False
  
  if info:
    print("Yes")
    break
else:
  print("No")

Buggy submission (verdict: Runtime Error):
c=[list(map(int,input().split())) for i in range(3)]



for i in range(101):
　info=True
　a1=i
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1
  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if min(a1,a2,a3,b1,b2,b3)<0:
    info=False
  if c[1][1]!=a2+b2:
    info=False
  if c[2][1]!=a3+b2:
    info=False
  if info:
    print("Yes")
    break
else:
  print("No")
Problem p03436 (python)

Fixed submission:
from collections import deque

H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]
c = [[-1 for _ in range(W)] for _ in range(H)]

black=0
for tate in s:
  for yoko in tate:
    if yoko=="#":
      black += 1

def search(y,x,H,W,c,i):
  child=[]      
  if y<H-1:
    if s[y+1][x]=="." and c[y+1][x]==-1:
      c[y+1][x]=i
      child.append([y+1,x])
  if 0<y:
    if s[y-1][x]=="." and c[y-1][x]==-1:
      c[y-1][x]=i
      child.append([y-1,x])
  if 0<x:
    if s[y][x-1]=="." and c[y][x-1]==-1:
      c[y][x-1]=i
      child.append([y,x-1])
  if x<W-1:
    if s[y][x+1]=="." and c[y][x+1]==-1:
      c[y][x+1]=i
      child.append([y,x+1])
  return child

def dfs(y,x,c):
  visited=[[y,x]]
  c[y][x]=0
  i=1
  
  while visited:
    tmp=[]
    for a in visited:
      p=search(a[0],a[1],H,W,c,i)  #listが戻る
      tmp += p
    visited=tmp
    i += 1

dfs(0,0,c)
a=c[-1][-1]
if a==-1:
  print(-1)
else:
  print(H*W-black-a-1)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]
black=0

for tate in s:
  for yoko in tate:
    if yoko=="#":
      black += 1

def search(y,x,H,W,s):
  child=[]
  if y<H-1:
    if s[y+1][x]==".":
      child.append([y+1,x])
  if 0<y:
    if s[y-1][x]==".":
      child.append([y-1,x])
  if 0<x:
    if s[y][x-1]==".":
      child.append([y,x-1])
  if x<W-1:
    if s[y][x+1]==".":
      child.append([y,x+1])
  return child

def dfs(y,x,cnt,H,W,s):
  node_to_visit=search(y,x,H,W,s)
  flag=True
  
  while flag:
    cnt += 1
    tmp=[]
    tmp2=[]
    for next_point in node_to_visit:
      t=next_point[0]
      u=next_point[1]
      if t!= y or u!=x:
        tmp=search(u,t,H,W,s)
      tmp2 += tmp
    node_to_visit=tmp2
    if [H-1,W-1] in node_to_visit:
      white=cnt
      flag=False
      break
      
  ans=H*W-white-black-2
  print(white,black,ans)

  
dfs(0,0,0,H,W,s)
Problem p03448 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0

for i in range(0,A+1):
  for j in range(0,B+1):
    for k in range(0,C+1):
      if 500*i+100*j+50*k==X:
        cnt +=1
print(cnt)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0

for i in range(0,A+1):
  for j in range(0,B+1):
    for k in range(0,C+1):
      if 500*i+100*j+50*K==X:
        cnt +=1
print(cnt)
Problem p03471 (python)

Fixed submission:
N,Y=map(int,input().split())
flag=False

for i in range(0,N+1):
  if flag==False:
    for j in range(0,N-i+1):
      P=10000*i+5000*j+1000*(N-i-j)
      if Y==P:
        print(i,j,N-i-j)
        flag=True
        break
      
if flag==False:
  print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
N,Y=map(int,input().split())
flag=False

for i in range(0,N+1):
  if flag==False:
    for j in range(0,N-i+1):
      P=10000*i+5000*j+1000*(N-i-j)
      if Y==P:
        print(i,j,N-i-j)
        flag=True
        break
      
if flag==False::
  print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
N,Y=map(int,input().split())
flag=False

for i in range(0,N+1):
  for j in range(0,N-i+1):
    P=10000*i+5000*j+1000*(N-i-j)
    if Y==P:
      print(i,j,N-i-j)
      flag=True
      
if flag==False::
  print(-1,-1,-1)
Problem p03478 (python)

Fixed submission:
N,A,B=map(int,input().split())
ans=0

for i in range(1,N+1):
  S=str(i)
  sum=0
  for num in S:
    sum += int(num)
  if A<=sum and sum<=B:
    ans+= i
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
ans=0

for i in range(1,N+1):
  S=str(i)
  sum=0
  for num in S:
    sum += num
  if A<=sum and sum<=B:
    ans+= i
    
print(ans)
Problem p03486 (python)

Fixed submission:
s=list(input())
t=list(input())

s.sort()
t.sort(reverse=True)

if s==t:
  print("No")
else:
  u=[s,t]
  u.sort()
  if u[0]==s:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()

s.sort()
t.sort()

if s==t:
  print("No")
else:
  u=[s,t].sort()
  if u[0]==s:
    print("Yes")
  else:
    print("No")
Problem p03497 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))

from collections import Counter
cnt=0

a=Counter(A)
b=list(a.values())
b.sort()
leng=len(b)

for item in b:
  if leng>K:
    cnt+=item
    leng-=1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

cnt=0
bflag=False
sflag=False

for i in range(1,N):
  if A[i]>A[i-1]:
    if sflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:
      bflag=True
      sflag=False
  elif A[i]<A[i-1]:
    if bflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:  
      bflag=False
      sflag=True    
  else:
    pass
    
print(cnt+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

cnt=0
bflag=False
sflag=False

for i in range(1,N):
  if A[i]>A[i-1]:
    if sflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:
      bflag=True
      sflag=False
  elif A[i]<A[i-1]:
    if bflag==True:
      cnt+=1
      bflag=False
      sflag=False
    else:  
      bflag=False
      sflag=True    
  else:
    pass
    
print(cnt+1)
Problem p03503 (python)

Fixed submission:
from itertools import product

N=int(input())
F=[ [[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
P= [[0] for _ in range(N)]
total= [[0 for _ in range(5)] for _ in range(2)]

for i in range(N):
  tmp=list( map(int,input().split()) )
  for j in range(5):
    for k in range(2):
      F[i][j][k]=tmp[2*j+k]
for i in range(N):
  P[i]=list(map(int,input().split()))
  
maxi=float("-inf")
combi=product([1,0],repeat=10)

for kumi in combi:
  mini=float("-inf")
  if sum(kumi)==0:
    pass
  else:      
    tmp=0
    for i in range(N):
      summ=0
      for k,open in enumerate(kumi):
        m,n = k//2, k%2
        summ += open * F[i][m][n]
      tmp += P[i][summ]
  maxi=max(maxi,tmp)
      
print(maxi)

Buggy submission (verdict: Runtime Error):
N=int(input())
F=[ [[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
P= [[0 for _ in range(10)] for _ in range(N)]
total= [[0 for _ in range(5)] for _ in range(2)]

for i in range(N):
  tmp=list( map(int,input().split()) )
  for j in range(5):
    for k in range(2):
      F[i][j][k]=tmp[j+k]
for i in range(N):
  P[i]=list(map(int,input().split()))

for i in range(N):
  tmp=0
  for j in range(5):
    for k in range(2):
      tmp +=
Problem p03564 (python)

Fixed submission:
N=int(input())
K=int(input())
ans=1

for i in range(N):
  ans=min(ans*2,ans+K)
  
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
K=int(input())
ans=1

for i in range(N):
  ans=mini(ans*2,ans+K)
  
print(ans)
Problem p03577 (python)

Fixed submission:
S=input()
print(S[:-8])

Buggy submission (verdict: Runtime Error):
S=input()
print(S-"FESTIVAL")
Problem p03612 (python)

Fixed submission:
N=int(input())
p=list(map(int,input().split()))

cnt=0
for i in range(N-1):
  if p[i]==i+1:
    p[i],p[i+1] = p[i+1],p[i]
    cnt+=1
if p[N-1]==N:
  p[N-2],p[N-1] = p[N-1],p[N-2]
  cnt+=1
  
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().split()))

cnt=0
for i in range(N-1):
  if p[i]==i+1:
    p[i],p[i+1] = p[i+1],p[i]
    cnt+=1
if p[N-1]==N:
  p[N-1],p[N] = p[N],p[N-1]
  cnt+=1
  
print(cnt)
Problem p03624 (python)

Fixed submission:
S=input()
al=[chr(ord('a') + i) for i in range(26)]
ss=set(al)

for str in S:
  if str in ss:
    ss.remove(str)

if len(ss)>0:
  print(sorted(ss)[0])
else:
  print("None")

Buggy submission (verdict: Runtime Error):
S=input()
al=[chr(ord('a') + i) for i in range(26)]
ss=set(al)

for str in S:
  if str in ss:
    ss.remove(str)

print(sorted(ss)[0])
Problem p03627 (python)

Fixed submission:
from collections import Counter

N = int(input())
A=list(map(int,input().split()))
c=dict(Counter(A))
#print(c)
e=[]
f=[]

for i in c:
  if c[i]>1:
    e.append(i)
  if c[i]>=4:
    f.append(i)

e.sort(reverse=True)
f.sort(reverse=True)
if len(f)>=1:
  if f[0]>=e[0]:
    print(f[0]**2)
  else:
    if len(e)>=2:
      print(e[0]*e[1])
    else:
      print(0)
else:
  if len(e)>=2:
    print(e[0]*e[1])
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
A=list(map(int,input().split()))
c=dict(Counter(A))
#print(c)
e=[]
f=[]

for i in c:
  if c[i]>1:
    e.append(i)
  if c[i]>=4:
    f.append(i)

e.sort(reverse=True)
f.sort(reverse=True)
if f[0]>=e[0]:
  print(f[0]**2)
else:
  if len(e)>=2:
    print(e[0]*e[1])
  else:
    print(0)
Problem p03632 (python)

Fixed submission:
A,B,C,D=map(int,input().split())

s=min(B,D)-max(A,C)
print(max(0,s))

Buggy submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())

print(max(0,min(C,D))-max(A,B)))
Problem p03659 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))

b=[0]*N
b[0]=a[0]
for i in range(1,N):
    b[i]=b[i-1]+a[i]

x=[0]*N
y=[0]*N
z=[0]*N
for j in range(N):
    x[j]=b[j]
    y[j]=b[-1]-b[j]
    z[j]=abs(x[j]-y[j])

print(min(z[:-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input().split())

b=[0]*N
b[0]=a[0]
for i in range(1,N):
    b[i]=b[i-1]+a[i]

x=[0]*N
y=[0]*N
z=[0]*N
for j in range(N):
    x[j]=b[j]
    y[j]=b[-1]-b[j]
    z[j]=abs(x[j]-y[j])

print(min(z[:-1]))
Problem p03699 (python)

Fixed submission:
N=int(input())
s=[0]*N
for i in range(N):
  s[i] = int(input())
s.sort()
s_sum=sum(s)

if s_sum%10 !=0:
  ans = s_sum
else:
  for num in s:
    if (s_sum-num)%10 !=0:
      maxi_1 = s_sum-num
      #print(num,maxi_1)
      break
    else:
      maxi_1=0
  tmp=0
  for num in s:
    tmp += num
    if (s_sum-tmp)%10 !=0:
      maxi_2= s_sum-tmp
      #print(num,maxi_2)
      break
    else:
      maxi_2=0
  ans=max(maxi_1,maxi_2)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[0]*N
for i in range(N):
  s[i] = int(input())
s.sort()
s_sum=sum(s)

if s_sum%10 !=0:
  ans = s_sum
else:
  for num in s:
    if (s_sum-num)%10 !=0:
      maxi_1 = s_sum-num
      #print(num,maxi_1)
      break
    else:
      maxi_1=0
  tmp=0
  for num in s:
    tmp += num
    if (s_sum-tmp)%10 !=0:
      maxi_2= s_sum-tmp
      #print(num,maxi_2)
      break
    else:
      maxi_2=0
    ans=max(maxi_1,maxi_2)
print(ans)
Problem p03720 (python)

Fixed submission:
N,M=map(int,input().split())
a=[0]*M
b=[0]*M
r=[0]*N
for i in range(M):
  a[i],b[i]=map(int,input().split())
  #print(a[i]-1,b[i]-1)
  r[a[i]-1] +=1
  r[b[i]-1] +=1
  
for item in r:
  print(item)

Buggy submission (verdict: Runtime Error):
N,N=map(int,input().split())
a=[0]*M
b=[0]*M
r=[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
  r[A[i]-1] +=1
  r[B[i]-1] +=1
  
for item in r:
  print(item)
Problem p03797 (python)

Fixed submission:
N,M=map(int,input().split())
O = M//2

if N>=O:
  print(O)
else:
  P = (N+O)//2
  print(P)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
O = M//2
if N>=O:
  print(N)
elpe:
  P = (N+O)//2
  print(P)
Problem p03854 (python)

Fixed submission:
S=input()

for i in range(100000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=="":
    print("YES")
    break
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
S=input()

for i in range(10000):
  if S[-6:]=="dreamer" or S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=[]:
    print("YES")
    break
else:
  print("NO")
Problem p03910 (python)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    i=k
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = int(i*(i+1)//2 - N)

for j in range(1,i+1):
  if j!=c:
    print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = i*(i+1)//2 - N

for j in range(1,i+1):
  if j!=c:
    print(j)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=0

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = i*(i+1)//2 - N

for j in range(1,i+1):
  if j!=c:
    print(j)
Problem p03943 (python)

Fixed submission:
a,b,c=map(int,input().split())

if (a+b+c)-max(a,b,c)==max(a,b,c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if (a+b+C)-max(a,b,c)==max(a,b,c):
  print("Yes")
else:
  print("No")
Problem p03957 (python)

Fixed submission:
s=input()

ans="No"
for i in range(len(s)):
  if s[i]=="C":
    for j in range(i+1,len(s)):
      if s[j]=="F":
        print("Yes")
        exit()
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
s=input()

ans="No"
for i in range(len(s)):
  if s[i]=="C":
    for j in range(i+1,len(s)):
      if s[j]="F":
        print("Yes")
        exit()
else:
  print(ans)
Problem p03962 (python)

Fixed submission:
a,b,c=map(int,input().split())

print(len({a,b,c}))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

print(len(set(a,b,c)))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

print(len(set(a,b,c))
Problem p03971 (python)

Fixed submission:
N,A,B= map(int,input().split())
S=input()
sanka=0
kaigai=0

for i in range(N):
  if S[i]=="a":
    if sanka< A+B:
      print("Yes")
      sanka += 1
    else:
      print("No")
  elif S[i]=="b":
    if sanka < A+B and kaigai <B:
      print("Yes")
      sanka += 1
      kaigai += 1
    else:
      print("No")    
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
S=input()
pas=0
kai=0

for num in S:
  if num=="a":
    if pas<A+B:
      pas +=1
      print("Yes")
    else:
      print("No")
  elif num=="b":
    if pas<A+B and :
      pas +=1
Problem p04019 (python)

Fixed submission:
S=input()

ans="No"
n=0
w=0
e=0
s=0
tate=0
yoko=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()

ans="NO"
n=0
w=0
e=0
s=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)
Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f=map(lambda x: int(x), input().split())

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w==0:
            j+=1
            continue
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e)+1)
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if 100*s/(s+w)>=max_per and s+w<=f:
            ans_w=w
            ans_s=s
            max_per=100*s/(s+w)
print('{} {}'.format(ans_w+ans_s,ans_s))

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(lambda x: int(x), input().split())

dic_w={}
i=0
while True:
    if (a*i*100)>f:
        break
    j=0
    while True:
        w=(a*i+b*j)*100
        if w>f:
            break
        else:
            dic_w[w]=dic_w.get(w,0)+1
        j+=1
    i+=1
list_w=list(dic_w.keys())
list_w.sort()

dic_s={}
max_s=int(e*f/(100+e))
i=0
while True:
    if c*i>max_s:
        break
    j=0
    while True:
        s=c*i+d*j
        if s>max_s:
            break
        else:
            dic_s[s]=dic_s.get(s,0)+1
        j+=1
    i+=1
list_s=list(dic_s.keys())
list_s.sort()

max_per=0
flag=False
ans_w=0
ans_s=0
for w in list_w:
    if flag==True:
        break
    for s in list_s:
        if s/(w/100)==e and s+w<=f:
            ans_w=w
            ans_s=s
            flag=True
            break
        if s/(w/100)>e:
            break
        if s/(w/100)>max_per and s+w<=f:
            ans_w=w
            ans_s=s
print('{} {}'.format(ans_w+ans_s,ans_s))
Problem p02555 (python)

Fixed submission:
from scipy.special import comb
S = int(input())
ans = 0
mod = 10**9+7
for i in range(3, S+1, 3):
  ans = (ans +comb(S-2*(i//3)-1, i//3-1, exact=True)) % mod 
print(ans)

Buggy submission (verdict: Runtime Error):
import scipy.special.comb
S = int(input)
ans = 0
for i in range(3, S+1, 3):
  ans += scipy.special.comb(S-2*(i//3)-1, i//3-1, exact=True)
print(ans)
Problem p03160 (python)

Fixed submission:
N=int(input())
h=list(map(int,input().split()))

a=[0]*N
a[1] = abs(h[0]-h[1])

for i in range(2,N):
    a[i]=min(a[i-2]+abs(h[i-2]-h[i]),a[i-1]+abs(h[i-1]-h[i]))

print(a[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))

dp = [-1 for i in range(N)]

dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(N-2):
    dp[i+2] = max(dp[i+1] + abs(h[i+1]-h[i+2]), dp[i] + abs(h[i] - h[i+2])
print(dp[N-1])
Problem p03719 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a <= c <= b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split)
if a <= c <= b:
    print("Yes")
else:
    print("No")
Problem p02755 (python)

Fixed submission:
a,b=map(int,input().split())
for i in range(1500):
  if int(i*.08)==a and int(i*.1)==b:
    print(i);exit()
print(-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());f=lambda t,x:set([i for i in range(1500)if int(i*t)==x]);print(min(f(.08,a)&f(.1,b)))
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
N = len(A)
amax = A[-1]
P = [0 for _ in range(amax+1)]
for i in range(N):
    P[A[i]] = 1
for i in range(N):
    a = A[i]
    for j in range(a*2,amax+1,a):
        P[j] = 0
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
for i in range(N):
    a = A[i]
    if P[a]==1 and C[a]>1:
        P[a] = 0
print(sum(P))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
A = []
for a in C:
    if C[a]==1:
        A.append(a)
if len(A)==0:
    print(0)
else:
    A = sorted(A)
    amax = A[-1]
    P = [0 for _ in range(amax+1)]
    for i in range(N):
        P[A[i]] = 1
    for i in range(N):
        a = A[i]
        for j in range(a*2,amax+1,a):
            P[j] = 0
    print(sum(P))