Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed
 
# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""
 
# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Fixed submission:
# 解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed

# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""

# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Buggy python submission (verdict: Runtime Error):
解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed
 
# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""
 
# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])

Fixed submission:
# 解説放送の１つめ
N,M = map(int, input().split())
A = list(map(int, input().split()))
f = [-1, 2,5,5,4,5,6,3,7,6] # 1-indexed

# dp[i]: マッチi本数で作れる最大の数(str)
dp = [None]*(N+1)
dp[0] = ""

# strの数の大きいほう
def max_str(s1:str, s2:str)->str:
    """return bigger one"""
    l1, l2 = len(s1), len(s2)
    if l1 != l2:
        return s1 if l1>l2 else s2
    if l1 == l2: 
        return s1 if s1>s2 else s2
    
for i in range(2, N+1):
    nxt = ""
    for aj in A:
        # 配列外参照と，i本ちょうどで作れないものはだめ
        if i-f[aj]<0 or dp[i-f[aj]]==None: continue
        nxt = max_str(nxt, 
                      dp[i-f[aj]]+str(aj))
    if nxt!="":
        dp[i] = nxt
    #print(dp)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1:]):
  print("Yes")
else:
  print("No")

Fixed submission:
T,X=map(int,input().split())
print(T/X)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1,]):
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1:]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1,]):
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
L=sorted(A,reverse=True)
if L[0]<sum(L[1:]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
dp=[float("INF")]*(N+1)
dp[0]=0
for i in range(N):
  for j in range(1,K+1):
    if j+i>=N:
      break
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
dp=[float("INF")]*(N+1)
dp[0]=0
for i in range(N):
  for j in range(1,K+1):
    if j+i>=N:
      break
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A+=[0]*N
dp=[float("INF")]*(2N)
dp[0]=0
for i in range(N):
  for j in range(K):
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
dp=[float("INF")]*(N+1)
dp[0]=0
for i in range(N):
  for j in range(1,K+1):
    if j+i>=N:
      break
    dp[i+j]=min(abs(A[i+j]-A[i])+dp[i],dp[i+j])
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
  w,v=map(int,input().split())
  for j in range(1,W+1):
    if j<w:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j-w]+v,dp[i-1][j])
print(dp[N][W])

Fixed submission:
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j>=w:
      dp[i+1][j]=max(dp[i][j-w]+v,dp[i][j])
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
  w,v=map(int,input().split())
  for j in range(1,W+1):
    if j>=w:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Fixed submission:
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j>=w:
      dp[i+1][j]=max(dp[i][j-w]+v,dp[i][j])
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
dp = [[0 for i in range(w+1)]for j in range(n+1)]

for i in range(n):
    weight,value = map(int,input().split())
    for j in range(w+1):
        if j >= weight:
            dp[i+1][j] = max(dp[i][j-weight]+value,dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])


Fixed submission:
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j>=w:
      dp[i+1][j]=max(dp[i][j-w]+v,dp[i][j])
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])

Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N)]
for i in range(N-1):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j>=w:
      dp[i+1][j]=max(dp[i][j-w]+v,dp[i][j])
    else:
      dp[i+1][j]=dp[i][j]
print(dp[n][W])

Fixed submission:
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    if j>=w:
      dp[i+1][j]=max(dp[i][j-w]+v,dp[i][j])
    else:
      dp[i+1][j]=dp[i][j]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
V=list(map(int,input().split()))
V0=Counter(V[::2]).most_common()
V1=Counter(V[1::2]).most_common()
ans=0
if V0[0][0]==V1[0][0]:
  if len(V0)==1 and len(V1)==1:
    print(N//2)
    exit()
  elif len(V0)!=1 and len(V1)!=1:
    if V0[1][0]>=V1[1][0]:
      V0[0],V0[1]=V0[1],V0[0]
    else:
      V1[0],V1[1]=V1[1],V1[0]
  elif len(V0)>len(V1):
     V0[0],V0[1]=V0[1],V0[0]
  else:
    V1[0],V1[1]=V1[1],V1[0]
for i in range(1,len(V0)):
  ans+=V0[i][1]
for i in range(1,len(V1)):
  ans+=V1[i][1]
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
A=[]
B=[]
c,d=0,0
for i in range(len(S)):
  if S[i]==S[i+1]:
    c+=1
  else:
    A.append(c)
    c=0

for i in range(len(T)):
  if T[i]==T[i+1]:
    d+=1
  else:
    B.append(d)
    d=0
print("Yes" if A==B else "No")

Fixed submission:
s=input()
t=input()
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")
Buggy python submission (verdict: Runtime Error):
import collections deque
S=deque(input())
T=deque(input())
for i in range(len(T)):
  if S==T:
    print("Yes")
    exit()
  t=T.popleft()
  T.appendleft(t)
print("No")

Fixed submission:
from collections import deque
S=deque(input())
T=deque(input())
for i in range(len(T)):
  if S==T:
    print("Yes")
    exit()
  t=T.pop()
  T.appendleft(t)
print("No")
Buggy python submission (verdict: Runtime Error):
A=[1,6,36,216,1296,7776,46656,9,81,729,6561,59049]
N=int(input())
ans=0
while N!=0:
  N-=max([a for _ in A if A<=N])
  ans+=1
print(ans)

Fixed submission:
N=int(input())
dp=[float("INF")]*(N+1)
dp[0]=0
six,nine=1,1
for i in range(1,N+1):
  if i==six*6:
    six*=6
  if i==nine*9:
    nine*=9
  dp[i]=min(dp[i-1],dp[i-six],dp[i-nine])+1
print(dp[N])
Buggy python submission (verdict: Runtime Error):
A=min([int(input()) for i in range(2)])
print(A+min([int(input()) for i in range(2)])

Fixed submission:
A=min([int(input()) for i in range(2)])
print(A+min([int(input()) for i in range(2)]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
print("Four" if sum(["Y" if in input().split() for i in range(n)])!=0 else "Three")

Fixed submission:
n=int(input())
A=sorted(list(input().split()))
if A[-1]=="Y":
  print("Four")
else:
  print("Three")
Buggy python submission (verdict: Runtime Error):
print("Yes" if sorted(input())<sorted(input(),reversed=True) else "No")

Fixed submission:
s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
m,k=map(int,input().split())
A=list(map(int,input().split()))
d=Counter(A)
l=d.most_common()[::-1]
s=set(A)
ans=0
i=0
while len(s)>k:
  ans+=l[i][1]
  del d[l[i]]
  s=len(d)
  i+=1
print(ans)

Fixed submission:
from collections import Counter
m,k=map(int,input().split())
A=list(map(int,input().split()))
d=Counter(A)
l=d.most_common()[::-1]
ans=0
i=0
while len(d)>k:
  ans+=l[i][1]
  del d[l[i][0]]
  i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(a+"+"+b+"+"+c+"+"+d+"="+7)
  exit()
if a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"="+7)
  exit()
if a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"="+7)
  exit()
if a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"="+7)
  exit()
if a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"="+7)
  exit()
if a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"="+7)
  exit()
if a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"="+7)
  exit()
if a-b-c-d==7:
  print(a+"-"+b+"-"+c+"-"+d+"="+7)
  exit()

Fixed submission:
N=input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a+b+c+d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c+d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b-c+d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a+b+c-d==7:
  print(N[0]+"+"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c+d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"+"+N[3]+"=7")
  exit()
if a-b+c-d==7:
  print(N[0]+"-"+N[1]+"+"+N[2]+"-"+N[3]+"=7")
  exit()
if a+b-c-d==7:
  print(N[0]+"+"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
if a-b-c-d==7:
  print(N[0]+"-"+N[1]+"-"+N[2]+"-"+N[3]+"=7")
  exit()
Buggy python submission (verdict: Runtime Error):
N=int(input())
for i in range(N):
  if (i**2)>N:
    break:
print(max((i-1)**2,1))

Fixed submission:
N=int(input())
for i in range(N):
  if (i**2)>N:
    break
print(max((i-1)**2,1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=Counter(input().split())
B=Counter(input().split())
C=Counter(input().split())
ans=0
for a_key,a_count in A.most_common():
    for b_key,b_count in B.most_common():
        for c_key,c_count in C.most_common():
            a_key,b_key,c_key=int(a_key),int(b_key),int(c_key)
            if a_key<b_key and b_key<c_key:
                ans+=a_count*b_count*c_count
print(ans)


Fixed submission:
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=set()
for i in range(N):
  s^=｛input()｝
print(len(s))


Fixed submission:
N=int(input())
s=set()
for i in range(N):
  a=int(input())
  if a in s:
    s.remove(a)
  else:
    s.add(a)
print(len(s))

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=set()
for i in range(N):
  a=set(int(input()))
  s^=a
print(len(a))

Fixed submission:
N=int(input())
s=set()
for i in range(N):
  a=int(input())
  if a in s:
    s.remove(a)
  else:
    s.add(a)
print(len(s))
Buggy python submission (verdict: Runtime Error):
s=input()
a=[chr(i) for i in range(ord("a"),ord("z")+1) if i not in s]
print("None" if len(a)==0 else a[0])

Fixed submission:
s=set(list(input()))
a=set([chr(i+97) for i in range(26)])
a-=s
print(sorted(list(a))[0] if len(a)!=0 else "None")
Buggy python submission (verdict: Runtime Error):
S=input()
for i in range(N-1):
  S=S[:-1]
  N=len(S)//2
  if S==S[:N]*2:
    print(N*2)
    exit()
print(1)

Fixed submission:
S=input()
for i in range(len(S)-1):
  S=S[:-1]
  N=len(S)//2
  if S==S[:N]*2:
    print(N*2)
    exit()
print(1)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=deque()
for i in range(N):
  if i%2==0:
    l.append(A[i])
  else:
    l.appendleft(A[i])
print(*l if N%2==0 else *list(revrsed(l)))

Fixed submission:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
if N%2==0:
  print(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i])
  B=list(reversed(B))
print(*B)

Fixed submission:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
if N%2==0:
  print(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))

Buggy python submission (verdict: Runtime Error):
from collections import deque
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i])
  B=reversed(B)
print("".join(B))

Fixed submission:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
for i in range(N):
  if i%2==0:
    r.append(A[i])
  else:
    l.append(A[i])
if N%2==0:
  print(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print("GREATER", if a>b else "LESS" if a<b else "EQUAL")

Fixed submission:
a=int(input())
b=int(input())
print("GREATER" if a>b else "LESS" if a<b else "EQUAL")
Buggy python submission (verdict: Runtime Error):
O=input()
E=input()
R=[:len(E)]
print(*[e+r for e,r in zip(E,R)],sep="",end="")
if len(O)!=len(E):
  print(O[-1])

Fixed submission:
O=input()
E=input()
R=O[:len(E)]
print(*[r+e for r,e in zip(R,E)],sep="",end="")
if len(O)!=len(E):
  print(O[-1])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
d={chr(i):100 for i in range(ord("a"),ord("z")+1)}
for i in range(N):
  A=Counter(list(input()))
  for i in A:
    if d[i]>A[i]:
      d[i]=A[i]
for i in d:
  if d[i]==100:
    d[i]=0
ans=""
for i in d:
  ans=d*d[i]+ans
print(ans)

Fixed submission:
from collections import Counter
N=int(input())
d={chr(i):100 for i in range(ord("a"),ord("z")+1)}
for i in range(N):
  A={chr(i):0 for i in range(ord("a"),ord("z")+1)}
  A.update(Counter(list(input())))
  for i in A:
    if d[i]>A[i]:
      d[i]=A[i]
for i in d:
  if d[i]==100:
    d[i]=0
ans=""
key=sorted(d.keys())
for i in key:
  ans+=i*d[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
print(math.factorial(int(input()))%(10**9+7)

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
s=input()
d=Conter(s)
da=[i for i in d if d[i]%2==0]
if len(da)==len(set(s)):
  print("Yes")
else:
  print("No")

Fixed submission:
from collections import Counter
s=input()
d=Counter(s)
da=[i for i in d if d[i]%2==0]
if len(da)==len(set(s)):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque
s=deque(input())
A=deque()
for i in range(len(s)):
  a=s.popleft()
  if a=="B":
    A.pop()
  else:
    A.append(a)
print("".join(A))

Fixed submission:
from collections import deque
s=deque(input())
A=deque()
for i in range(len(s)):
  a=s.popleft()
  if a=="B":
    if len(A)>0:
      A.pop()
  else:
    A.append(a)
print("".join(A))
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
B=[0]


for i in range(1,len(a)+1):
    A.append(a[i-1]+A[i-1])

for i in range(1,len(b)+1):
    B.append(b[i-1]+B[i-1])
    

maxman=0
for i in range(len(A)):
    for j in range(len(B)):
        if A[i]+B[j]<=k:
            maxman=max(maxman,i+j)
            
print(maxman)

Fixed submission:
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a, b=[0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
ans, j=0, M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans, i+j)
print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())

if K%2==0:
    ans = -1
else:
    flag=0
    mod = 7
    count = 1
    while flag==0:
        if mod==0:
            flag = 1
        else:
            count += 1
            mod = (mod*10+7) % K

print(ans)

Fixed submission:
K = int(input())


if K%2==0 or K%5==0:
    count = -1
else:
    flag=0
    mod = 7
    count = 1
    while mod%K!=0:
        count += 1
        mod = (mod*10+7) % K

print(count)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

As = list(map(int,input().split()))

As.sort(reverse=True)

al = sum(As)

ans = 'No' if al/(4*M)>As[M] else 'Yes'
print(ans)

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

As = list(map(int,input().split()))

As.sort(reverse=True)

al = sum(As)

ans = 'No' if al/(4*M)>As[M-1] else 'Yes'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())


count = 1
que = [(0,0)]
check = set()
check.add((0,0))
while que:
    points = que.pop()

    ru = (points[0]+1,points[1]-1)
    if ru[0]<W and -1<ru[1] and ru not in check:
        que.append(ru)
        check.add(ru)
        count += 1
    
    rd = (points[0]+1,points[1]+1)
    if rd[0]<W and rd[1]<H and rd not in check:
        que.append(rd)
        check.add(rd)
        count += 1
    
    lu = (points[0]-1,points[1]-1)
    if -1<lu[0] and -1<lu[1] and lu not in check:
        que.append(lu)
        check.add(lu)
        count += 1
    
    ld = (points[0]-1,points[1]+1)
    if -1<ld[0] and ld[1]<H and ld not in check:
        que.append(ld)
        check.add(ld)
        count += 1


ans = count
print(ans)

Fixed submission:
H,W = map(int,input().split())

# count = 1
# que = [(0,0)]
# check = set()
# check.add((0,0))
# while que:
#     points = que.pop()

#     ru = (points[0]+1,points[1]-1)
#     if ru[0]<W and -1<ru[1] and ru not in check:
#         que.append(ru)
#         check.add(ru)
#         count += 1
    
#     rd = (points[0]+1,points[1]+1)
#     if rd[0]<W and rd[1]<H and rd not in check:
#         que.append(rd)
#         check.add(rd)
#         count += 1
    
#     lu = (points[0]-1,points[1]-1)
#     if -1<lu[0] and -1<lu[1] and lu not in check:
#         que.append(lu)
#         check.add(lu)
#         count += 1
    
#     ld = (points[0]-1,points[1]+1)
#     if -1<ld[0] and ld[1]<H and ld not in check:
#         que.append(ld)
#         check.add(ld)
#         count += 1

block = H//2 * W
tip = W//2 if W%2==0 else W//2+1
tip = tip if H%2!=0 else 0


ans = 1 if H==1 or W==1 else block+tip
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())

AA = A*100//8
AF = (A+1)*100//8 + 1 if (A+1)*100%8!=0 else (A+1)*100//8
BB = B*10
AAA = [i for i in range(AA,AF]
BBB = [i for i in range(BB,(B+1)*10)]
AB_list = list(set(AAA)&set(BBB))

ans = min(AB_list) if AB_list and (12<min(AB_list)<=1000) else -1
print(ans)

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

AA = A*100//8 + 1 if A*100%8!=0 else A*100//8
AF = (A+1)*100//8 + 1 if (A+1)*100%8!=0 else (A+1)*100//8
BB = B*10
AAA = [i for i in range(AA,AF)]
BBB = [i for i in range(BB,(B+1)*10)]
AB_list = list(set(AAA)&set(BBB))

ans = min(AB_list) if AB_list and (12<min(AB_list)<=1000) else -1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

INF = float('inf')

h,w = map(int, input().split())

point_list = []
for i in range(w*h):
    point_list.append([w*h]*w*h)
maze = []

Q = deque([])


for i in range(h):
    tmp = list(input())
    maze.append(tmp)

for s_y in range(h):
    for s_x in range(w):
        if maze[s_y][s_x] == "#":
            continue
        check = []
        Q.append((s_y,s_x))
        check.append((s_y,s_x))
        point_list[s_x+s_y*w][s_x+s_y*w] = 0
        while Q:
            y, x = Q.popleft()
            if y == 0:
                pass
            elif maze[y-1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y-1)*w] = min(point_list[s_x+s_y*w][x+(y-1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y-1,x) in check:
                    pass
                else:
                    check.append((y-1,x))
                    Q.append((y-1,x))
                    

            if y == h-1 :
                pass
            elif maze[y+1][x]=="#":
                pass
            else:
                point_list[s_x+s_y*w][x+(y+1)*w] = min(point_list[s_x+s_y*w][x+(y+1)*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y+1,x) in check:
                    pass
                else:
                    check.append((y+1,x))
                    Q.append((y+1,x))
                    

            if x==0:
                pass
            elif maze[y][x-1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x-1)+y*w] = min(point_list[s_x+s_y*w][(x-1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x-1) in check:
                    pass
                else:
                    check.append((y,x-1))
                    Q.append((y,x-1))
                    

            if x==w-1:
                pass
            elif maze[y][x+1]=="#":
                pass
            else:
                point_list[s_x+s_y*w][(x+1)+y*w] = min(point_list[s_x+s_y*w][(x+1)+y*w],point_list[s_x+s_y*w][x+y*w]+1)
                if (y,x+1) in check:
                    pass
                else:
                    check.append((y,x+1))
                    Q.append((y,x+1))
                    
max_list = []
for i in range(w*h):
    tmp = set(point_list[i])
    if min(tmp)==w*h:
        continue
    if w*h in tmp:
        tmp.remove(w*h)
    max_list.append(max(tmp))

ans = max(max_list)
print(ans)

Fixed submission:
al = input()

b = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'
b = b.split()

idx = b.index(al)
ans = b[idx+1]

print(ans)