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

Fixed submission:
n=int(input())
a,b,c=0,0,0
count=0
for i in range(n):
  s=input()
  count+=s.count('AB')
  if s[0]=='B' and s[-1]=='A':
    a+=1
  elif s[0]=='B':
    b+=1
  elif s[-1]=='A':
    c+=1
if b==0 and c==0:
  print(count+max(0,a-1))
else:
  print(count+a+min(b,c))

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=0,0,0
count=0
for i in range(n):
  s=input()
  count+=s.count('AB')
  if s[0]=='B' and s[-1]=='A':
    a+r=1
  elif s[0]=='B':
    b+=1
  elif s[-1]=='A':
    c+=1
if b==0 and c==0:
  print(count+a-1)
else:
  print(count+a+min(b,c))
Problem p03074 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
A=[]
cur=s[0]
for i in range(1,n):
  if s[i]!=cur:
    A.append(i)
    cur=s[i]
A.append(n)
start,end=s[0],s[-1]
nn=len(A)
ans=0
if start=="0" and nn<=2*k:
  ans=n
elif start=="1" and nn<=2*k+1:
  ans=n
elif start=="0":
  ans=A[2*k-1]
  for i in range(1,nn//2-k+1):
    ans=max(ans,A[2*k-1+2*i]-A[2*i-2])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
else:
  ans=A[2*k]
  for i in range(1,(nn-1)//2-k+1):
    ans=max(ans,A[2*k+2*i]-A[2*i-1])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
List=[]
i=1
j=1
while i<n:
  if s[i-1]==s[i]:
    j+=1
    i+=1
    if i==n-1:
      List.append(j)
  else:
    List.append(j)
    i+=1
    j=1
if s[0]=="0":
  List.insert(0,0)
ans=max(List)
rg=2*k+1
for i in range(0,len(List)-rg+1,2):
  ans=max(ans,sum(List[i:i+rg]))
print(ans)
Problem p03085 (python)

Fixed submission:
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C")

Buggy submission (verdict: Runtime Error):
B=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C" if B=="G")

Buggy submission (verdict: Runtime Error):
b=input()
print("T" if B=="A" else "A" if B=="T" else "G" if B=="C" else "C" if B=="G")

Buggy submission (verdict: Runtime Error):
b=input()
print("T" if B="A" else "A" if B="T" else "G" if B="C" else "C" if B="G")
Problem p03086 (python)

Fixed submission:
S=input()
SS=S+"X"
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while SS[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)

Buggy submission (verdict: Runtime Error):
s=input()
ans=0
cur=0
ACGT=set("A","C","G","T")
for ss in s:
  if ss in ACGT:
    cur+=1
  else:
    ans=max(cur,ans)
    cur=0
print(max(ans,cur))

Buggy submission (verdict: Runtime Error):
S=input()
ACGT=["A","C","G","T"]
m=0
for i in range(len(S)):
  j=0
  while S[i+j] in ACGT:
    j+=1   
  m=max(m,j)
print(m)
Problem p03087 (python)

Fixed submission:
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
count=0
AC_count=[0]
for i in range(1,N+2):
  if S[i-1:i+1]=="AC":
    count+=1
  AC_count.append(count)
AC_count.append(count)
k=0
for j in range(Q):
  k=AC_count[r_list[j]-1]-AC_count[l_list[j]-1]
  print(k)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
count=0
AC_count=[]
for i in range(1,N):
  if S[i-1:i+1]=="AC":
    count+=1
  AC_count.append(count)
k=0
for j in range(Q):
  k=AC_count[r_list[j]-1]-AC_count[l_list[j]-1]
  print(k)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
for i in range(Q):
  S_i=S[int(l_list[i])-1,int(r_list[i])]
  n=0
  while "AC" in S_i:
    n+=1
  print(n)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,(input()).split())
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=input().split()
  l_list.append(int(l))
  r_list.append(int(r))
for i in range(Q):
  S_i=S[l_list[i]-1,r_list[i]]
  n=0
  while "AC" in S_i:
    n+=1
  print(n)

Buggy submission (verdict: Runtime Error):
N,Q=int(input()).split()
S=input()
l_list=[]
r_list=[]
for i in range(Q):
  l,r=int(input()).split()
  l_list.append(l)
  r_list.append(r)
for i in range(Q):
  S_i=S[l_list[i]-1,r_list[i]]
  n=0
  while "AC" in S_i:
    n+=1
  print(n)
Problem p03101 (python)

Fixed submission:
H,W=map(int,(input()).split())
h,w=map(int,(input()).split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,(input()).split())
List_B=[int(i) for i in (input()).split()]
t=0
for j in range(1,N+1):
  List_A=[int(k) for k in (input()).split()]
  if sum([x*y for (x,y) in zip(List_A,List_B)])>-C:
    t+=1
print(t)

Buggy submission (verdict: Runtime Error):
H,W=int(input()).split()
h,w=int(input()).split()
print((H-h)*(W-w))
Problem p03106 (python)

Fixed submission:
A,B,K=map(int,input().split())
count=0
i=min(A,B)+1
while count<K:
  i-=1
  if A%i==0 and B%i==0:
    count+=1
print(i)

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
count=1
i=1
while count<K:
  i+=1
  if A%i=0 and B%i=0:
    count+=1
print(i)
Problem p03109 (python)

Fixed submission:
S=input()
Y=S[0:4]
M=S[5:7]
D=S[8:10]
YMD=int(Y+M+D)
if YMD<=20190430:
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
S=input()
Y=S[0:4]
M=S[5:7]
D=S[7:9]
YMD=int(Y+M+D)
if YMD<=20190430:
  print("Heisei")
else:
  print("TBD")
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
Problem p03112 (python)

Fixed submission:
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i-1],list[i]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))

Buggy submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
S,T=[],[]
for i in range(a):
  S.append(int(input()))
for i in range(b):
  T.append(int(input()))
def f(list,n):
  if n<list[0]:
    return [-float("inf"),list[0]]
  elif list[-1]<n:
    return [list[-1],float("inf")]
  else:
    i=bisect.bisect_left(list,n)
    return [list[i],list[i+1]]
def g(SS,TT,x):
  a,b,c,d=x-SS[0],SS[1]-x,x-TT[0],TT[1]-x
  dis1=max(a,c)
  dis2=min(2*a+d,2*d+a)
  dis3=max(b,d)
  dis4=min(2*b+c,2*c+b)
  return min([dis1,dis2,dis3,dis4])
for i in range(q):
  x=int(input())
  print(g(f(S,x),f(T,x),x))
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
if 2 in A and 3 in A:
  A.remove(2)
if 3 in A and 5 in A:
  A.remove(3)
if 2 in A and 5 in A:
  A.remove(2)
if 6 in A and 9 in A:
  A.remove(6)
m=len(A)
D={}
D[1]=2
D[2]=5
D[3]=5
D[4]=4
D[5]=5
D[6]=6
D[7]=3
D[8]=7
D[9]=6
DP=[-float("inf")]*(n+1)
DP[0]=0
for i in range(n):
  for j in range(m):
    if D[A[j]]<=i+1 and DP[i+1-D[A[j]]]!=float("inf") and DP[i+1-D[A[j]]]+1>=DP[i+1]:
      DP[i+1]=DP[i+1-D[A[j]]]+1
A.sort(reverse=True)
k=DP[n]
ans=""
cur=n
for _ in range(k):
  for j in range(m):
    if cur>=D[A[j]] and DP[cur-D[A[j]]]==DP[cur]-1:
      ans+=str(A[j])
      cur-=D[A[j]]
      break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
if 2 in A and 3 in A:
  A.remove(2)
if 3 in A and 5 in A:
  A.remove(3)
if 2 in A and 5 in A:
  A.remove(2)
if 6 in A and 9 in A:
  A.remove(6)
m=len(A)
D={}
D[1]=2
D[2]=5
D[3]=5
D[4]=4
D[5]=5
D[6]=6
D[7]=3
D[8]=7
D[9]=6
DP=[-float("inf")]*(n+1)
DP[0]=0
for i in range(n):
  for j in range(m):
    if D[A[j]]<=i+1 and DP[i+1-D[A[j]]]!=float("inf") and DP[i+1-D[A[j]]]+1>=DP[i+1]:
      DP[i+1]=DP[i+1-D[A[j]]]+1
A.sort(reverse=True)
k=DP[n]
ans=""
cur=n
for _ in range(k):
  for j in range(m):
    if DP[cur-D[A[j]]]==DP[cur]-1:
      ans+=str(A[j])
      cur-=D[A[j]]
      break
print(ans)
Problem p03163 (python)

Fixed submission:
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
DP=[[0 for i in range(w_max+1)] for j in range(n)]
for i in range(w_max+1):
  if i>=W[0]:
    DP[0][i]=V[0]
for i in range(1,n):
  for j in range(w_max+1):
    if j>W[i]:
      DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i])
    elif j==W[i]:
      DP[i][j]=max(DP[i-1][j],V[i])
    else:
      DP[i][j]=DP[i-1][j]
print(DP[n-1][w_max])

Buggy submission (verdict: Runtime Error):
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
w_tot=sum(W)
DP=[[0 for i in range(w_tot+1)] for j in range(n)]
for i in range(w_max+1):
  if i>=W[0]:
    DP[0][i]=V[0]
for i in range(1,n):
  for j in range(w_tot+1):
    if j>W[i]:
      DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i])
    elif j==W[i]:
      DP[i][j]=max(DP[i-1][j],V[i])
    else:
      DP[i][j]=DP[i-1][j]
print(DP[n-1][w_max])

Buggy submission (verdict: Runtime Error):
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
w_tot=sum(W)
DP=[[0 for i in range(w_tot+1)] for j in range(n)]
for i in range(w_max+1):
  if i>=W[0]:
    DP[0][i]=V[0]
for i in range(1,n):
  for j in range(w_tot+1):
    if j>W[i]:
      DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i])
    elif j==W[i]:
      DP[i][j]=max(DP[i-1][j],V[i])
    else:
      DP[i][j]=DP[i-1][j]
print(DP[n-1][w_max])

Buggy submission (verdict: Runtime Error):
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
w_tot=sum(W)
DP=[[0 for i in range(w_tot+1)] for j in range(n)]
DP[0][W[0]]=V[0]
for i in range(1,n):
  for j in range(w_tot+1):
    if j>W[i]:
      DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i])
    elif j==W[i]:
      DP[i][j]=max(DP[i-1][j],V[i])
    else:
      DP[i][j]=DP[i-1][j]
print(DP[n-1][w_max+1])

Buggy submission (verdict: Runtime Error):
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
w_tot=sum(W)
DP=[[-float("inf") for i in range(w_tot+1)] for j in range(n)]
for i in range(n):
  DP[i][0]=0
DP[0][W[0]]=V[0]
for i in range(1,n):
  for j in range(w_tot+1):
    if j>=W[i]:
      DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i])
    else:
      DP[i][j]=DP[i-1][j]
print(max(DP[n-1][i] for i in range(w_max+1)))
Problem p03206 (python)

Fixed submission:
D=int(input())
if D==25:
  print("Christmas")
else:
  if D==24:
    print("Christmas Eve")
  else:
    if D==23:
      print("Christmas Eve Eve")
    else:
      print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
D=int(input())
if D==25:
  print("Christmas")
else:
  if D==24:
    print("Christmas Eve")
  else:
    if D=23:
      print("Christmas Eve Eve")
    else:
      print("Christmas Eve Eve Eve")
Problem p03210 (python)

Fixed submission:
x=int(input())
if x in [7,5,3]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
List=[7,5,3]
X=int(input())
if X in List:
  print("YES")
Else:
  print("NO")
Problem p03230 (python)

Fixed submission:
n=int(input())
nn=int((n*2)**0.5)
if n*2!=nn*(nn+1):
  print("No")
else:
  print("Yes")
  print(nn+1)
  Ans=[[0]*nn for _ in range(nn+1)]
  for i in range(nn):
    for j in range(nn-i):
      Ans[i][i+j]+=nn*i-i*(i-1)//2+j+1
      Ans[i+j+1][i]+=nn*i-i*(i-1)//2+j+1
  for a in Ans:
    print(nn,*a)

Buggy submission (verdict: Runtime Error):
import sys
input=lambda: sys.stdin.readline().rstrip()
from collections import defaultdict
n=int(input())
D=defaultdict(int)
i=1
while i*(i+1)//2<=10**5:
  D[i*(i+1)//2]=i
  i+=1
if D[n]==0:
  print("No")
else:
  print("Yes")
  k=D[n]+1
  print(k)
  A=[[0]*(k) for _ in range(k)]
  for i in range(k):
    A[i][0]=k-1
  D=dict()
  D[1]=1*k+1
  for i in range(2,n+1):
    d1,d2=D[i-1]//k,D[i-1]%k
    if d2==k-d1:
      D[i]=(d1+1)*k+1
    else:
      D[i]=d1*k+d2+1
  for i in range(1,n+1):
    d1,d2=D[i]//k,D[i]%k
    A[d1-1][d1+d2-1]=i
    A[d1+d2-1][d1]=i
  for a in A:
    print(*A)
Problem p03240 (python)

Fixed submission:
n=int(input())
XYH=[]
for i in range(n):
  x,y,h=map(int,input().split())
  XYH.append([x,y,h])
XYH.sort(key=lambda x:x[2])
for i in range(101):
  for j in range(101):
    peak=abs(i-XYH[-1][0])+abs(j-XYH[-1][1])+XYH[-1][2]
    flag=1
    for k in range(n-1):
      if max(0,peak-abs(i-XYH[k][0])-abs(j-XYH[k][1]))!=XYH[k][2]:
        flag=0
    if flag==1:
      Ans=[i,j,peak]
print(*Ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
XYH=[]
for i in range(n):
  x,y,h=map(int,input().split())
  XYH.append([x,y,h])
XYH.sort(key=lambda x:x[2])
for i in range(101):
  for j in range(101):
    peak=abs(i-XYH[0][0])+abs(j-XYH[0][1])+XYH[0][2]
    flag=1
    for k in range(1,n):
      if max(0,peak-abs(i-XYH[k][0])-abs(j-XYH[k][1]))!=XYH[k][2]:
        flag=0
    if flag==1:
      Ans=[i,j,peak]
print(*Ans)
Problem p03241 (python)

Fixed submission:
n,m=map(int,input().split())
ans=1
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    if i>=n:
      ans=max(ans,m//i)
    elif m//i>=n:
      ans=max(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=1
for i in range(1,m**0.5+1):
  if m%i==0:
    if i>=n:
      ans=max(ans,m//i)
    elif m//i>=n:
      ans=max(ans,i)
print(ans)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
ans=1
ans_c=0
for i in range(len(s)):
  if s[i] !="1" and ans==1:
    ans=int(s[i])
    ans_c=i+1
print(ans if ans_c<=k else 1)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(len(s)):
  if s[i] !="1" and ans==1:
    ans=int(s[i])
    ans_c=i+1
print(ans if ans_c<=k else 1)
Problem p03284 (python)

Fixed submission:
n,k=map(int,input().split())
print(0 if n%k==0 else 1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(0 if n%k=0 else 1)
Problem p03360 (python)

Fixed submission:
A=list(map(int,input().split()))
k=int(input())
print(sum(A)-max(A)+max(A)*(2**k))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
k=int(input())
print(sum(a,b,c)-max(a,b,c)+max(a,b,c)**k)
Problem p03393 (python)

Fixed submission:
s=input()
abc="abcdefghijklmnopqrstuvwxyz"
if len(s)<26:
  print(s+sorted(list(set(abc)-set(s)))[0])
else:
  x=s[-1]
  Tail=[x]
  count,flag=0,0
  for i in range(2,27):
    if s[-i]<x:
      count=i
      flag=1
      break
    else:
      x=s[-i]
      Tail.append(x)
  t="z"
  if count!=0:
    for tt in Tail:
      if tt>s[26-count]:
        t=min(t,tt)  
  print(-1 if flag==0 else s[:-count]+t)

Buggy submission (verdict: Runtime Error):
s=input()
abc="abcdefghijklmnopqrstuvwxyz"
if len(s)<26:
  print(s+sorted(list(set(abc)-set(s)))[0])
else:
  x=s[-1]
  Tail=[x]
  count,flag=0,0
  for i in range(2,27):
    if s[-i]<x:
      count=i
      flag=1
      break
    else:
      x=s[-i]
      Tail.append(x)
  t="z"
  for tt in Tail:
    if tt>s[26-count]:
       t=min(t,tt)  
  print(s[:-count]+t if flag==1 else -1)
Problem p03420 (python)

Fixed submission:
n,k=map(int,input().split())
ans=0
for i in range(k+1,n+1):
  ans+=(n//i)*(i-k)+max(n%i-k+1,0)
print(n**2 if k==0 else ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=0
for i in range(k+1,n+1):
  ans+=(n//i)*(i-k)+max(n%i-k+1,0)
print(n**2 if k== else ans)
Problem p03427 (python)

Fixed submission:
n=int(input())
ans=int(str(n)[0])+9*(len(str(n))-1)
if str(n)[1:]=="9"*(len(str(n))-1):
  print(ans)
else:
  print(ans-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
print(int(str(n)[0])-1+9*(len(n)-1))
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print("Left" if a+b>c+d else "Balanced" if a+b==c+d else "Right")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print("Left" if a+b>c+d else "Balanced" if a+b=c+d else "Right")
Problem p03480 (python)

Fixed submission:
s=input()
n=len(s)
ss=s[0]
C=[]
for i in range(1,n):
  if s[i]!=ss:
    C.append(max(i,n-i))
  ss=s[i]
print(n if len(C)==0 else min(C))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
ss=s[0]
C=[]
for i in range(1,n):
  if s[i]!=ss:
    C.append(max(i,n-i))
  ss=s[i]
print(min(C))
Problem p03497 (python)

Fixed submission:
import collections
n,k=map(int,input().split())
A=list(map(int,input().split()))
c=collections.Counter(A)
tot=0
for i in c.most_common(min(k,len(set(A)))):
  tot+=i[1]
print(n-tot)

Buggy submission (verdict: Runtime Error):
import collections
n,k=map(int,input().split())
A=list(map(int,input().split()))
c=collections.Counter(A)
tot=0
for i in range(k):
  tot+=c.most_common()[i][1]
print(n-tot)
Problem p03523 (python)

Fixed submission:
s=input()
ss=s.replace("A","")
print("YES" if ss=="KIHBR" and "AA" not in s and "KIH" in s else "NO")

Buggy submission (verdict: Runtime Error):
s=input()
ss=s.replace("A","")
print("YES" if ss="KIHBR" and "AA" not in s and "KIH" in s else "NO")

Buggy submission (verdict: Runtime Error):
s=input()
ss=s.replace.("A","")
print("YES" if ss="KIHBR" and "AA" not in s and "KIH" in s else "NO")
Problem p03525 (python)

Fixed submission:
n=int(input())
D=[int(i) for i in input().split()]
C=[1]+[0]*12

for d in D:
  C[min(d,24-d)]+=1
if max(C)>2 or C[0]>1 or C[12]>1:
  print(0)
else:
  ans=0
  
  for i in range(2**(11)):
    CC=[1]+[0]*23+[1]
    for j in range(1,12):
      if C[j]==2:
        CC[j]=1
        CC[24-j]=1
      elif C[j]==1:
        if i&(1<<(j-1)):
          CC[j]=1
        else:
          CC[24-j]=1
    if C[12]==1:
      CC[12]=1
    cur=24
    t=0
    for j in range(1,25):
      if CC[j]==1:
        cur=min(cur,t+1)
        t=0
      else:
        t+=1
    ans=max(ans,cur)
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
D=[int(i) for i in input().split()]
if n>=24:
  print(0)
else:
  ans=0
  for i in range(2**(n-1)):
    C=[0,D[0],24]
    for j in range(n-1):
      if i&(1<<j):
        C.append(24-D[j+1])
      else:
        C.append(D[j+1])
    C.sort()
    cur=24
    for j in range(n):
      cur=min(cur,C[j+1]-C[j])
    ans=max(ans,cur)
print(ans)
Problem p03557 (python)

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 submission (verdict: Runtime Error):
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))
Problem p03565 (python)

Fixed submission:
s=input()
t=input()
ns,nt,nd=len(s),len(t),len(s)-len(t)
ans="z"*ns
flag=0
for i in range(nd+1):
  judge=True
  for j in range(nt):
    ss=s[i+j]
    tt=t[j]
    if ss!="?" and ss!=tt:
      judge=False
  if judge:
    Key=s[:i]+t+s[i+nt:]
    ans=min(ans,Key.replace("?","a"))
    flag=1
print(ans if flag==1 else "UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ans="z"*len(s)
flag=0
for i in range(2**len(t)):
  K=str(bin(i))[2:].zfill(5)
  T=""
  for j in range(len(t)):
    if K[j]=="0":
      T+="?"
    else:
      T+=t[j]
  for k in range(len(s)-len(t)+1):
    if s[k:k+len(t)]==T:
      Key=s[:k]+t+s[k+len(t):]
      ans=min(ans,Key.replace("?","a"))
      flag=1
print(ans if flag==1 else "UNRESTORABLE")
Problem p03605 (python)

Fixed submission:
n=input()
if "9" in n:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=input()
if "9" in n:
    print("Yes")
elif:
    print("No")

Buggy submission (verdict: Runtime Error):
n=input()
if 9 in n:
    print("Yes")
elif:
    print("No")

Buggy submission (verdict: Runtime Error):
n=input()
if 9 in n:
    print("Yes")
elif
    print("No")
Problem p03681 (python)

Fixed submission:
import math
n,m=map(int,input().split())
ans=math.factorial(m)*math.factorial(n)%(10**9+7)
if n==m:
  ans*=2
  ans%=(10**9+7)
elif abs(n-m)>1:
  ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
def f(n):
  if n==1:
    return 1
  else:
    return f(n-1)*n

n,m=map(int,input().split())
ans=f(m)*f(n)
if n==m:
  ans*=2
elif abs(n-m)>1:
  ans=0
print(ans)
Problem p03698 (python)

Fixed submission:
s=input()
S=[]
for i in range(len(s)):
  S.append(s[i])
print("yes" if len(set(S))==len(s) else "no")

Buggy submission (verdict: Runtime Error):
s=input()
S=[]
for i in range(len(s)):
  S.append(s[i])
print("yes" if len(setS))==len(s) else "No")
Problem p03703 (python)

Fixed submission:
n,k=map(int,input().split())
A=[]
for i in range(n):
  A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
  AA[i]=AA[i+1]+A[i]
  BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
  if BB[i]==BB[i-1]:
    continue
  else:
    cur+=1
    D[BB[i]]=cur
AAA=[0]*(n+1)
for i in range(n+1):
  AAA[i]=D[AA[i]]

nn=18
BIT=[0]*(2**nn)
BIT.insert(0,0)
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s
def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

ans=0
for i in range(n+1):
  ans+=i-bitsum(BIT,AAA[i]-1)
  bitadd(BIT,AAA[i],1)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=[]
for i in range(n):
  A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
  AA[i]=AA[i+1]+A[i]
  BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
  if BB[i]==BB[i-1]:
    continue
  else:
    cur+=1
    D[BB[i]]=cur
AAA=[0]*(n+1)
for i in range(n+1):
  AAA[i]=D[AA[i]]

import math
n_max=2*10**5
nn=int(math.log2(n_max))+1
BIT=[0]*(2**nn)
BIT.insert(0,0)
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s
def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

ans=0
for i in range(n+1):
  ans+=i-bitsum(BIT,AAA[i]-1)
  bitadd(BIT,AAA[i],1)
print(ans)
Problem p03715 (python)

Fixed submission:
h,w=map(int,input().split())
if h*w%3==0:
  print(0)
else:
  ans=min(h,w)
  hh=h//2
  for ww in range(1,w):
    A=[hh*ww,(h-hh)*ww,h*(w-ww)]
    ans=min(ans,max(A)-min(A))
  ww=w//2
  for hh in range(1,h):
    B=[ww*hh,(w-ww)*hh,(h-hh)*w]
    ans=min(ans,max(B)-min(B))
  print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if h*w%3==0:
  print(0)
else:
  ans=min(h,w)
  hh=h//2
  for ww in range(1,w):
    A=[hh*ww,(h-hh)*ww,h*(w-ww)]
    ans=min(ans,max(A)-min(A))
  ww=w//2
  for hh in range(1,h):
    B=[ww*hh,(w-ww)*hh,(h-hh)*w]
    ans=min(ans,max(B)-min(B))
print(ans)
Problem p03737 (python)

Fixed submission:
List=list(input().upper().split())
for s in List:
  print(s[0],end="")

Buggy submission (verdict: Runtime Error):
List=list(input().upper().split())
for s in List:
  print(n[0],end="")

Buggy submission (verdict: Runtime Error):
List=list(input().split())
for n in List:
  print(n[0].Upper(),end="")