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

Fixed submission:
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))

Buggy submission (verdict: Runtime Error):
m,n = map(int,input().split())
l = list(map(int,input().split()))
for i in range(n):
  s += l[i]
print(max(m-s,-1))
Problem p02921 (python)

Fixed submission:
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i]==t[i]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i]==s[t]:
    ans+=1
print(ans)
Problem p02971 (python)

Fixed submission:
n = int(input())
a  =[]
for i in range(n):
  x = int(input())
  a.append(x)
ma = max(a)
b = sorted(a)
for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(b[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a  =[]
for i in range(n):
  a.append(int(inpit())
ma = max(a)
b = sorted(a)
for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(b[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()), for _ in range(n)]

for i in range(n):
  tmp = a
  tmp[i-1] = 0
  print(max(tmp))
  tmp = a
Problem p02982 (python)

Fixed submission:
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

c=0
for i in range(n-1):
  for j in range(i+1,n):
    c+=(sum((a-b)**2 for a,b in zip(x[i],x[j]))**0.5).is_integer()

print(c)

Buggy submission (verdict: Runtime Error):
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

c=0
for i in range(n-1):
  for j in range(i+1,n):
    c+=(sum((a-b)**2 for a,b in zip(x[i],x[j]))**0.5).is_integer

print(c)
Problem p02983 (python)

Fixed submission:
l,r = map(int,input().split())
x = []
if r-l>2019:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      res = (i*j)%2019
      x.append(res)
  print(min(x))

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())
x = []
if r-l>2019:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      res = (i*j)%2019
      x.append(res)
   print(min(x))

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())
x = []
if r-l>2019:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      res = (i*j)%2019
      x.append(res)
print(min(x))

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())
x = []
for i in range(l,r-1):
  for j in range(i+1,r):
    res = (i*j)%2019
    x.append(res)
print(min(x))

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())
x = []
for i in range(l,r-1):
  for j in range(i+1,r):
    res = (i*j)%2019
    x.append(res)
xs = sorted(x)
print(x[1])

Buggy submission (verdict: Runtime Error):
l,r = map(int,input().split())
x = []
for i in range(l,r-1):
  for j in range(i+1,r):
    res = (i*j)%2019
    x.append(res)
xs = sorted(x)
print(x[1])
Problem p02993 (python)

Fixed submission:
s = input()
res = "Good"
for i in range(3):
  if s[i] == s[i+1]:
    res = "Bad"
print(res)

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  if s[i] == s[i+1]:
    print("Bad")
  else:
    print("Good")
Problem p03037 (python)

Fixed submission:
n,m = map(int,input().split())
L = []
R = []
for i in range(m):
  l,r = map(int,input().split())
  L.append(l)
  R.append(r)

ans = min(R)-max(L)+1
print(ans if ans >0 else "0")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = {}
for i in range(m):
  l,r = map(int,input().split())
  for j in range(l,r+1):
    l = []
    l.append(i)
    newset = set(l)
  s = s&newset
print(len(s))
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
if a>b:
  print(2*a-1)
elif a<b:
  print(2*b-1)
else:
  print(2*a)

Buggy submission (verdict: Runtime Error):
a,b = int(input())
if a>b:
  print(2*a-1)
elif a<b:
  print(2*b-1)
else:
  print(2*a)
Problem p03085 (python)

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

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

Fixed submission:
s = input()
acgt = ["A","C","G","T"]
cnt = 0
cnt_list = []
for i in range(len(s)):
    if s[i] in acgt:
        cnt +=1
        if s[-1] in acgt:
            cnt_list.append(cnt)
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
cnt_list = []
for i in range(len(s)):
  if s[i] == "A":
    cnt +=1
  elif s[i] == "C":
    cnt +=1
  elif s[i] == "G":
    cnt +=1
  elif s[i] == "T":
    cnt +=1
  else:
    cnt_list.append(cnt)
    cnt = 0
print(max(cnt_list))

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
cnt_list = []
for i in range(len(s)):
  if s[i] == "A" or "C" or "G" or "T":
    cnt +=1
  else:
    cnt_list.append(cnt)
  cnt = 0
print(max(cnt_list))
Problem p03102 (python)

Fixed submission:
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
  a = list(map(int,input().split()))
  sum = 0
  for j in range(m):
    sum += (a[j]*b[j])
  sum += c
  if sum > 0:
    cnt += 1
  else:
    pass
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = map(int,input().split())
cnt = 0
sum = 0
for i in range(n):
  a = map(int,input().split())
  for j in range(m):
    sum += (a[j]*b[j])
  sum += c
  if sum > 0:
    cnt += 1
  else:
    pass
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = map(int,input()split())
cnt = 0
sum = 0
for i in range(n):
  a = map(int,input().split())
  for j in range(m):
    sum += (a[j]*b[j])
    sum += c
  if sum > 0:
    cnt += 1
  else:
    pass
print(cnt)
Problem p03126 (python)

Fixed submission:
n,m = map(int,input().split())
S = set(range(1,m+1))
for i in range(n):
  a,*b = map(int,input().split())
  S &= set(b)
print(len(S))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input.split())
S = set(range(1,m+1))
for i in range(n):
  a,*b = map(int,input().split())
  S &= set(b)
print(len(S))
Problem p03136 (python)

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
if max(L)<sum(L)-max(L):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
L = [list(map(int,input().split()))]
if max(L)<sum(L)-max(L):
  print("Yes")
else:
  print("No")
Problem p03260 (python)

Fixed submission:
a,b = input().split()
if "2" in a or "2" in b:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if "2" in a or "2" in b:
  print("No")
else:
  print("Yes")
Problem p03292 (python)

Fixed submission:
s = sorted(map(int,input().split()))
v = s[2] - s[0]
print(v)

Buggy submission (verdict: Runtime Error):
s = sorted(map(int,input().splitu()))
v = s[2] - s[0]
print(v)
Problem p03359 (python)

Fixed submission:
a,b = map(int,input().split())
if a>b:
  print(a-1)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a=>b:
  print(a)
else:
  print(a-1)
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
L =["b"*(w+2)] + ["b"+ input() + "b" for i in range(h)] + ["b"*(w+2)]
ans = "ahe"
for i in range(1,h+1):
    for j in range(1,w+1):
        if L[i][j]=="#" and (L[i+1][j]!="#" and L[i-1][j]!="#" and L[i][j+1]!="#" and L[i][j-1]!="#"):
            ans="No"
if ans!="No":
    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input())
L = [input() for i in range(h)]
ans = "ahe"
if L[0][0]=="#" and (L[0][1]=="." and L[1][0]=="."):
    ans="No"
elif L[0][w]=="#" and (L[0][w-1]=="." and L[1][w]=="."):
    ans="No"
elif L[h][0]=="#" and (L[h][1]=="." and L[h-1][0]=="."):
    ans="No"
elif L[h][w]=="#" and (L[h][w-1]=="." and L[h-1][w]=="."):
    ans="No"
for i in range(1,w):
    if L[0][i]=="#" and (L[0][i+1]=="." and L[1][i] =="." and L[1][i-1]):
        ans="No"
for i in range(1,w):
    if L[h][i]=="#" and (L[h][i+1]=="." and L[h-1][i] =="." and L[h][i-1]):
        ans="No"
for i in range(1,h):
    if L[i][0]=="#" and (L[i][1]=="." and L[i+1][0]=="." and L[i-1][0]=="."):
        ans="No"
for i in range(1,h):
    if L[i][w]=="#" and (L[i][w-1]=="." and L[i+1][w]=="." and L[i-1][w]==".")
for i in range(1,h):
    for j in range(1,w):
        if L[i][j]=="#" and (L[i+1][j]=="." and L[i-1][j]=="." and L[i][j+1]=="." and L[i][j-1]=="."):
            ans="No"
if ans !="No":
    ans ="Yes"
print(ans)
Problem p03378 (python)

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
lcnt = 0
rcnt = 0
for i in range(m):
  if a[i] < x:
    lcnt += 1
  else:
    rcnt += 1
print(min(lcnt,rcnt))

Buggy submission (verdict: Runtime Error):
n,x,m = map(int,input().split())
a = list(map(int,input().split()))
lcnt = 0
rcnt = 0
for i in range(m):
  if a[i] < x:
    lcnt += 1
  else:
    rcnt += 1
print(min(lcnt,rcnt))
Problem p03385 (python)

Fixed submission:
s = str(input())
a = {"a","b","c"}
if set(s) == a:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = str(input())
a = {a,b,c}
if set(s) == a:
  print("Yes")
else:
  print("No")
Problem p03408 (python)

Fixed submission:
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

print(max(0,max(n.count(s[i])-m.count(s[i]) for i in range(len(s)))))

Buggy submission (verdict: Runtime Error):
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

print(max(0,max(n.count(s[i])-m.count(s[i]) for i in range(len(s))))
Problem p03416 (python)

Fixed submission:
a,b = map(int,input().split())
cnt = 0
for i in range(a,b+1):
  if str(i)[0]==str(i)[-1] and str(i)[1] == str(i)[-2]:
    cnt +=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
cnt = 0
for i in range(a,b+1):
  if str(i)[0]==str(i)[-1] and str(i)[1] = str(i)[-2]:
    cnt +=1
print(cnt)
Problem p03456 (python)

Fixed submission:
a,b = input().split()
s = a+b
print("Yes" if int((int(s)**(1/2)))**2 == int((int(s)**(1/2))**2) else "No")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
n  = int(str(a)+str(b)
m = n**(1/2)
if int(m**2) ==n:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
n  = int(str(a)+str(b)
m = n**(1/2)
if m**2 ==n:
  print("Yes")
else:
  print("No")
Problem p03469 (python)

Fixed submission:
s = input()
s = s.replace("2017","2018")
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s.replace("2017","2018)
Problem p03474 (python)

Fixed submission:
a,b = map(int,input().split())
s = input()
L = [i for i in range(10)]
ans = "Yes"
for i in range(a):
  if s[i]=="-" or not int(s[i]) in L:
    ans = "No"
if s[a] != "-":
  ans = "No"
for i in range(a+1,a+b+1):
    if s[i]=="-" or not int(s[i]) in L:
      ans = "No"
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
s = input()
L = [i for i in range(1,10)]
ans = "Yes"
for i in range(a):
  if  not int(s[i]) in L:
    ans = "No"
if s[a] != "-":
  ans = "No"
for i in range(a+1,a+b+1):
    if  not int(s[i]) in L:
    ans = "No"
print(ans)
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
s = input()
print(s.ccount("1"))
Problem p03494 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
cnt = 0
for j in range(31):
  cnt = 0
  for i in range(n):  
    if A[i]%2:
      break
    else:
      A[i] = A[i]/2
      cnt +=1
    if cnt ==n:
      ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
  cnt = 0
  if A[i]%2:
    break
  else:
    A[i] = A[i]/2
    cnt +=1
  if cnt ==n
  ans +=1
print(ans)
Problem p03502 (python)

Fixed submission:
n = input()
wa = 0
for i in range(len(n)):
  wa += int(n[i])
if int(n)%wa:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = input()
wa = 0
for i in range(len(n)):
  wa += int(n[i])
if n%wa:
  print("No")
else:
  print("Yes")
Problem p03548 (python)

Fixed submission:
x,y,z = map(int,input().split())
print((x-z)//(y+z))

Buggy submission (verdict: Runtime Error):
x,y,z = map(int,input().split())
print((x-2)//(Y+Z))
Problem p03597 (python)

Fixed submission:
n = int(input())
a = int(input())
print(n**2 - a)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
print(N**2 - a)
Problem p03606 (python)

Fixed submission:
n = int(input())
sum = 0
for i in range(n):
  l,r = map(int,input().split())
  sum += r - l + 1
print(sum)

Buggy submission (verdict: Runtime Error):
n = input()
sum = 0
for i in range(n):
  l,r = map(int,input().split())
  sum += r - l + 1
print(sum)
Problem p03632 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if a<=c:
  if b-c>0:
    print(min(b-c,d-c))
  else:
    print(0)
else:
  if d-a>0:
    print(min(d-a,b-a))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
if a<=c:
  if b-c>0
    print(b-c)
  else:
    print(0)
else:
  if d-a>0:
    print(d-a)
  else:
    print(0)
Problem p03657 (python)

Fixed submission:
a,b = map(int,input().split())
print("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
orint("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")
Problem p03760 (python)

Fixed submission:
o = str(input())
e = str(input())
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[i])
else:
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(o[-1])
print(*x,sep="")

Buggy submission (verdict: Runtime Error):
o = str(input())
e = str(input())
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[i])
else:
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(a[-1])
print(*x,sep="")

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[i])
else:
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(a[-1])
print(*x,sep="")

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[1])
else:
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(a[-1])
print(*x,sep="")

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[1])
else len(o) != len(e):
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(a[-1])
print(*x,sep="")

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
x = []
if len(o) = len(e):
  for i in range(len(o)):
    x.append(o[i]+e[1])
else len(o) != len(e):
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(a[-1])
print(*x,sep="")
Problem p03777 (python)

Fixed submission:
a,b = input().split()
if a=="H" and b=="H":
  print("H")
elif a=="H" and b=="D":
  print("D")
elif a=="D" and b=="H":
  print("D")
else:
  print("H")

Buggy submission (verdict: Runtime Error):
a,b = input(),split()
if a=="H" and b=="H":
  print("H")
elif a=="H" and b=="D":
  print("D")
elif a=="D" and b=="H":
  print("D")
else:
  print("H")
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n >= k:
  print(k*x + (n-k)*y)
else:
  print(n*x)

Buggy submission (verdict: Runtime Error):
n = input()
k = input()
x = input()
y = input()
print(k*x + (n-k)*y)
Problem p04044 (python)

Fixed submission:
n,l = map(int,input().split())
mylist=sorted([input() for i in range(n)])
print("".join(mylist))

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
mylist=sotrted([input() for i in range(n)])
print("".join(mylist))
Problem p03061 (python)

Fixed submission:
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
A = lmi()
Leftgcd = list(accumulate(A, gcd))
Rightgcd = list(accumulate(reversed(A), gcd))
Leftgcd.insert(0, 0)
Rightgcd.insert(0, 0)
maxgcd = 1
for i in range(N):
    maxgcd = max(maxgcd, gcd(Leftgcd[i], Rightgcd[N - 1 - i]))
print(maxgcd)

Buggy submission (verdict: Runtime Error):
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N = ii()
A = lmi()
old_gcd = gcd_list(A)
for i in range(N):
    A[i] = A[i] // old_gcd
i = N // 2
prev = 0
while i != prev:
    if gcd_list(A[i:N]) == 1:
        prev = i
        i = (i + N - 1) // 2
        continue
    else:
        i = (prev + i) // 2
        continue
A.pop(i)
print(old_gcd * gcd_list(A))
# print(A)
#
# num = N
# ans = []
# while num != 2:
#     ans = []
#     if num % 2 == 0:
#         num = -(-num // 2)
#         for i in range(num):
#             ans.append(math.gcd(A[2 * i], A[2 * i + 1]))
#     else:
#         num = -(-num // 2)
#         for i in range(num - 1):
#             ans.append(math.gcd(A[2 * i], A[2 * i + 1]))
#             ans.append(A[-1])
#     if ans.count(1) >= 2:
#         print(old_gcd)
#         break
# else:
#     print(max(ans))
Problem p03074 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template #


N, K = mi()
strS = li()
S = [int(i) for i in strS]
S.append(0)
# S.insert(0, 1)
# print(S)

cnt = 0
lis0 = []
if S[0] == 1:
    listart = [0]
    cnt += 1
else:
    listart = []
liend = []
for i in range(1, N):
    # if S[i] == 0:
    #     cnt += 1
    if S[i-1] == 0 and S[i] == 1:
        listart.append(i)
        lis0.append(i)
    if S[i-1] == 1 and S[i] == 0:
        liend.append(i-1)
# if S[N-1] == 0:
#     lis0.append(N)
if S[N-1] == 1:
    liend.append(N - 1)
    cnt += 1
# lis.append(N)
# lis.insert(0, -1)
len0 = len(listart) + 1 - cnt
# print(listart)
# print(liend)
# print(len0)
# print(ma)
if K >= len0:
    print(N)
else:
    ma = max(liend[K - 1] + 1, N - listart[-K])
    for i in range(len(listart) - K):
        ma = max(ma, liend[i+K]-listart[i]+1)
    print(ma)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template #


N, K = mi()
strS = li()
S = [int(i) for i in strS]
S.append(0)
# S.insert(0, 1)
# print(S)

cnt = 0
lis0 = []
if S[0] == 1:
    listart = [0]
else:
    listart = []
liend = []
for i in range(1, N):
    if S[i] == 0:
        cnt += 1
    if S[i] == 0 and S[i + 1] == 1:
        listart.append(i + 1)
        lis0.append(i)
    if S[i-1] == 1 and S[i] == 0:
        liend.append(i-1)
if S[N-1] == 0:
    lis0.append(N)
if S[N-1] == 1:
    liend.append(N-1)
# lis.append(N)
# lis.insert(0, -1)
# print(lis0)
# print(listart)
# print(liend)
ma = max(liend[K - 1] + 1, N - listart[-K])
# print(ma)
if K >= len(lis0):
    print(N)
else:
    for i in range(len(listart) - K):
        ma = max(ma, liend[i+K]-listart[i]+1)
    print(ma)
Problem p03085 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


b = input().rstrip()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
S = li()
Alist = []
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = mi()
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)
for i in range(N - 1):
    if i in Alist:
        AClist[i + 2] = AClist[i+1] + 1
    else:
        AClist[i+2] = AClist[i+1]

# print(AClist)

for i in range(Q):
    if AClist[l[i] - 1] != AClist[l[i]]:
        print(AClist[r[i]] - AClist[l[i]])
    else:
        print(AClist[r[i]] - AClist[l[i]-1])
Problem p03096 (python)

Fixed submission:
N = int(input())
C = [int(input()) for _ in range(N)]
MOD = 10**9 + 7
subC = [-2] * (2 * 10 ** 5 + 10)
cntC = [-1]*N
for num, i in enumerate(C):
    cntC[num] = subC[i]+1
    subC[i] = num

# print(cntC)

dp = [0] * (N + 10)
dp[0] = 1
for i in range(N):
    if cntC[i] < 0 or cntC[i] == i:
        dp[i + 1] = dp[i] % MOD
    else:
        dp[i + 1] = (dp[i] + dp[cntC[i]]) % MOD


print(dp[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
C = [int(input()) for _ in range(N)]
subC = [-2] * (2 * 10 ** 5)
cntC = [-1]*N
for num, i in enumerate(C):
    cntC[num] = subC[i]+1
    subC[i] = num

# print(cntC)

dp = [0] * (N + 10)
dp[0] = 1
for i in range(N):
    if cntC[i] == -1 or cntC[i] == i:
        dp[i + 1] = dp[i]
    else:
        dp[i + 1] = dp[i] + dp[cntC[i]]


print(dp[N])