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

Fixed submission:
n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
"""
ポラード・ロー法で素因数分解
"""
n,target=map(int,input().split())
seed = 0

# 最大公約数
def gcd(a, b):
    if a<b:
        return gcd(b, a)
    while b>0:
        a, b = b, a%b
    return a

# 素数判定
def isprime(n):
    if n<2:
        return False
    for m in range(2, int(n**0.5+1)):
        if n%m==0:
            return False
    return True

# 疑似乱数発生器（らしい）
def f(n):
    ret = n**2+seed
    return ret%target

# 素数になるまで割る？
def factoring(n, _seed = 3):
    if isprime(n):
        return n
    x, y, d = 2, 2, 1
    tmp = n
    seed = _seed
    while d==1:
        x = f(x)
        y = f(f(y))
        dif = x-y if x>y else y-x
        d = gcd(dif, tmp)
        seed+=1

    seed = 0
    if(d%2==0):
        return 2
    if isprime(d) is False:
        return factoring(d, seed+1)
    return factoring(d, 1)

# メイン
def factors():
    dic = {}
    tmp = target
    if(isprime(tmp)):
        dic[tmp] = 1
        return dic

    ret = factoring(tmp)
    while tmp/ret is not 0:
        if ret in dic.keys():
            dic[ret]+=1
        else:
            dic[ret]=1
        tmp = int(tmp/ret)
        if tmp==1:
            break
        ret = factoring(tmp)

    return dic

def main():
    a=factors()
    res=1
    for b,c in a.items() :
        if c >= n : res *= b
    print(res)
    

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sympy
 
n,p=map(int,input().split())
 
def C(N,P):
    if N == 1: return P
    
    prime=2
    prime_list={}
    while P >= prime :
        if P % prime == 0:
            P /= prime
            if prime in prime_list:
                prime_list[prime]+=1
            else:
                prime_list[prime]=1
        else :
            prime+=1
    
    print(prime_list)
    res=1
    for b,c in prime_list.items() :
        if c >= 4 : res *= b
    return res
 
print(C(n,p))

Buggy submission (verdict: Runtime Error):
import sympy
 
n,p=map(int,input().split())
 
def C(N,P):
    if N == 1: return P
    a=sympy.factorint(P)
    res=1
    for b,c in a.items() :
        if c >= 4 : res *= b
    return res
 
print(C(n,p))

Buggy submission (verdict: Runtime Error):
import math
import sys

n,p=map(int,input().split())
a=math.sqrt(P)

def C(N,P):
    if N == 1: return P

    if N >= 4 :
        a=math.sqrt(a)
    if N >= 8 :
        a=math.sqrt(a)
    if N >= 16 :
        a=math.sqrt(a)
    if N >= 32 :
        a=math.sqrt(a)
    if N >= 64 :
        a=math.sqrt(a)
    if N >= 128 :
        a=math.sqrt(a)
    if N >= 256 :
        a=math.sqrt(a)
    if N >= 512 :
        a=math.sqrt(a)
    if N >= 1024 :
        a=math.sqrt(a)
    if N >= 2048 :
        a=math.sqrt(a)
    
    res=1

    for i in range(1,int(a)+2):
        if P % i**N: continue
        res = i
        
    return res

print(C(n,p))
Problem p03293 (python)

Fixed submission:
print('Yes' if (input() * 2).find(input()) != -1 else 'No')

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

x = len(s)

if s == t:
  print('Yes')

for z in range(x):
  u[0] = s[x-1]
  
  for y in range(x-2):
    u[y+1] = s[y]
  
  if t == u;
  print('Yes')

  s = u
  
print('No')

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

x = len(s)

if s == t:
  print('Yes')

for z in range(x):
  u[0] = s[x-1]
  
  for y in range(x-2):
    u[0] = s[x-1]
    u[y+1] = s[y]
  
  if t == u;
  print('Yes')

  s = u
  
print('No')

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

x = len(s)

if s == t:
  print('Yes')

for z in range(x):
  u[0] = s[x-1]
  
  for y in range(x-2):
    u[0] = s[x-1]
    u[y+1] = s[y]
  
  if t == u;
  print('Yes')

  s = u
Problem p02921 (python)

Fixed submission:
in1 = input()
in2 = input()
c = 0
if in1[0] == in2[0]: c +=1
if in1[1] == in2[1]: c +=1
if in1[2] == in2[2]: c +=1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(int((n-1)*n/2))
Problem p03164 (python)

Fixed submission:
N,W = map(int,input().split())
 
import numpy as np
dp = np.full(10 ** 5 + 1, W + 1, dtype = int)
dp[0] = 0

for i in range(N):
  w, v = map(int, input().split())
  np.minimum(dp[:-v] + w, dp[v:], out = dp[v:])

for i in range(len(dp) - 1, -1, -1):
    if dp[i] <= W:
        print(i)
        break

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

import numpy as np
 
dp = np.zeros(W + 1, dtype = int)

for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w] + v, dp[w:], out = dp[w:])

print(dp.max())
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split(" "))
s = []
for i in range(h):
    s.append(str(input()))
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ss = ["" for i in range(h)]
for i in range(h):
    for j in range(w):
        f = False
        if s[i][j] == ".":
            f = True
            continue
        for dy, dx in d:
            if 0 <= i + dy < h and 0 <= j + dx < w:
                if s[i + dy][j + dx] == "#":
                    f = True
                    break
        if not f:
            break
    if not f:
        break

if f:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split(" "))
s = []
for i in range(h):
    s.append(str(input()))
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ss = ["" for i in range(h)]
for i in range(h):
    for j in range(w):
        f = False
        if s[j][i] == ".":
            f = True
            continue
        for dx, dy in d:
            if 0 <= i + dx < w and 0 <= j + dy < h:
                if s[j + dy][i + dx] == "#":
                    f = True
                    break
        if not f:
            break
    if not f:
        break

if f:
    print("Yes")
else:
    print("No")
Problem p03470 (python)

Fixed submission:
n = int(input())
d = [0] * 101
for i in range(0, n):
    inp = int(input())
    d[inp] += 1

count = 0
for i in d:
    if i > 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [0] * 100
for i in range(0, n):
    inp = int(input())
    d[inp] += 1

count = 0
for i in d:
    if i > 0:
        count += 1
print(count)
Problem p02865 (python)

Fixed submission:
def solve():
    i = int(input())
    print(i // 2 -1 if i % 2 == 0 else i // 2)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    n = int(input())
    d = list(map(int, input().split()))

    print(calc(d, n))


def calc(d, n):
    if d[0] != 0:
        return 0
    else:
        k = max(d)
        a = [0] * (k + 1)
        for i in range(1, n):
            a[d[i]] += 1
        if a[0] > 0:
            return 0
        else:
            r = 1
            for i in range(2, k + 1):
                r *= a[i - 1] ** a[i]
            return r % 998244353


if __name__ == "__main__":
    solve()
Problem p02971 (python)

Fixed submission:
n = int(input())
li = list(int(input()) for i in range(n))

sorted_li = sorted(li)
a, b = sorted_li[-1], sorted_li[-2]

for i in li:
  if i == a:
    print(b)
  else:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(int(input()) for i in range(n))

for i in range(n):
  li_copy = li.copy()
  del li_copy[i]
  print(max(li_copy))
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(int, input().split())

c_x = w/2
c_y = h/2

if x == c_x and y == c_y:
  print(w*h/2, 1)
else:
  print(w*h/2, 0)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

c_x = w/2
c_y = h/2

if x = c_x and y = c_y:
  print(w*h/2, 1)
else:
  print(w*h/2, 0)
Problem p03037 (python)

Fixed submission:
n, m = map(int, input().split())
li = [list(map(int, input().split())) for i in range(m)]

left = 0
right = n

for i in li:
  left = max(i[0], left)
  right = min(i[1], right)
  
if right < left:
  print(0)
else:
  print(right - left + 1)

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

left = 0
right = n

for i in li):
  left = max(i[0], left)
  right = min(i[1], right)
  
print(right - left + 1)
Problem p02850 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
import queue

def create_graph(N, a, b):
    g = {}
    for i in range(N-1):
        if a[i] in g:
            g[a[i]][b[i]] = 0
        else:
            g[a[i]] = {b[i]: 0}
        if b[i] in g:
            g[b[i]][a[i]] = 0
        else:
            g[b[i]] = {a[i]: 0}
    return g


def bfs(g, s):
    Q = queue.Queue()
    Q.put(s)
    while not Q.empty():
        p = Q.get()
        cs = set(range(len(g[p])+2)) - set([v for k, v in g[p].items()])
        for q in g[p].keys():
            # print(f"p:{p} q:{q} g:{g[p][q]}")
            if not g[p][q]:
                c = cs.pop()
                g[p][q] = c
                g[q][p] = c
                Q.put(q)


def solve(N: int, a, b):
    g = create_graph(N, a, b)
    bfs(g, a[0])
    # print(g)
    m = 1
    for i in range(N-1):
        m = max(m, g[a[i]][b[i]])
    print(m)
    for i in range(N-1):
        print(g[a[i]][b[i]])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def create_graph(N, a, b):
    g = {}
    for i in range(N-1):
        if a[i] in g:
            g[a[i]][b[i]] = 0
        else:
            g[a[i]] = {b[i]: 0}
        if b[i] in g:
            g[b[i]][a[i]] = 0
        else:
            g[b[i]] = {a[i]: 0}
    return g


def find_color(used, m):
    for i in range(1, m+1):
        if i not in used:
            return i
    return m+1


def dfs(g, p):
    for q in g[p].keys():
        # print(f"p:{p} q:{q} g:{g[p][q]}")
        if not g[p][q]:
            c = find_color(set([v for k, v in g[p].items() if v > 0]), len(g[p]))
            g[p][q] = c
            g[q][p] = c
            dfs(g, q)


def solve(N: int, a, b):
    g = create_graph(N, a, b)
    dfs(g, a[0])
    # print(g)
    m = 1
    for i in range(N-1):
        m = max(m, g[a[i]][b[i]])
    print(m)
    for i in range(N-1):
        print(g[a[i]][b[i]])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()
Problem p03276 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def append_zero(x):
    if 0 in x:
        return
    if x[0] > 0:
        x.insert(0, 0)
        return
    if x[len(x)-1] < 0:
        x.append(0)
        return
    for i in range(1, len(x)):
        if x[i-1] < 0 and x[i] > 0:
            x.insert(i, 0)
            return


def solve(N, K, x):
    y = [0]
    append_zero(x)
    n = len(x)
    z = 0
    for i in range(1, n):
        y.append(y[i-1] + x[i] - x[i-1])
        if x[i] == 0:
            z = i
    # print(x)
    # print(y)
    if n == K:
        if n-1 == z or z == 0:
            return y[n-1]
        else:
            l = y[z] + y[n-1]
            r = y[n-1] - y[z] + y[n-1]
            return min(l, r)
    ans = 10e20
    for i in range(n - K):
        k = i + K
        if k <= z:
            ans = min(ans, y[z] - y[i])
        if z <= i:
            ans = min(ans, y[k] - y[z])
        if i <= z and z < k:
            l = y[z] - y[i] + y[k] - y[i]
            r = y[k] - y[z] + y[k] - y[i]
            ans = min(ans, l, r)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, x))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

def append_zero(x):
    if 0 in x:
        return
    if x[0] > 0:
        x.insert(0, 0)
        return
    if x[len(x)-1] < 0:
        x.appnd(0)
        return
    for i in range(1, len(x)):
        if x[i-1] < 0 and x[i] > 0:
            x.insert(i, 0)
            return

def solve(N, K, x):
    y = [0]
    append_zero(x)
    n = len(x)
    z = 0
    for i in range(1, n):
        y.append(y[i-1] + x[i] - x[i-1])
        if x[i] == 0:
            z = i
    # print(x)
    # print(y)
    if n == K:
        if n-1 == z or z == 0:
            return y[n-1]
        else:
            l = y[z] + y[n-1]
            r = y[n-1] - y[z] + y[n-1]
            return min(l, r)
    ans = 10e20
    for i in range(n - K):
        k = i + K
        if k <= z:
            ans = min(ans, y[z] - y[i])
        if z <= i:
            ans = min(ans, y[k] - y[z])
        if i <= z and z < k:
           l = y[z] - y[i] + y[k] - y[i]
           r = y[k] - y[z] + y[k] - y[i]
           ans = min(ans, l, r)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, x))

if __name__ == '__main__':
    main()
Problem p02837 (python)

Fixed submission:
numbers = list(map(int, input().split()))
n = numbers[0]

v = []

for i in range(n):
    numbers = list(map(int, input().split()))
    a = numbers[0]
    
    w = []
    
    for j in range(a):
        z = list(map(int, input().split()))
        w.append(z)
        
    v.append(w)
    
rezultat = 0

max_steps = 2 ** n

for i in range(max_steps):
    w = [-1] * n
    
    for j in range(n):
        if i >> j & 1:
            w[j] = 1
        else:
            w[j] = 0
    
    ok = 1
    
    for j in range(n):
        if ok == 0:
            break
        for a, b in v[j]:
            if w[j] == 1:
                a = a - 1
                if w[a] != b:
                    ok = 0
                    break
                
    if ok:
        rezultat = rezultat if rezultat > sum(w) else sum(w)
        
print(rezultat)

Buggy submission (verdict: Runtime Error):
numbers = list(map(int, input().split()))
n = numbers[0]

v = []

for i in range(n):
    numbers = list(map(int, input().split()))
    a = numbers[0]
    
    w = []
    
    for j in range(a):
        z = list(map(int, input().split()))
        w.append(z)
        
    v.append(w)
    
rezultat = 0

max_steps = 2 ** n

for i in range(max_steps):
    w = [-1] * n
    
    for j in range(n):
        if i >> j & 1:
            w[j] = 1
        else:
            w[j] = 0
    
    ok = 1
    
    for j in range(n):
        if ok == 0:
            break
        for a, b in v[j]:
            if w[j] == 1:
                a = a - 1
            if w[a] != b:
                ok = 0
                break
                
    if ok:
        rezultat = rezultat if rezultat > sum(w) else sum(w)
        
print(rezultat)
Problem p03846 (python)

Fixed submission:
def __is_even(num):
    return num % 2 == 0


DIVISOR = 10 ** 9 + 7
ITR_NUM = 1000

N = int(input())
reported_num_count = {}
power_num = 0
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int(N / 2)
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    power_num = int((N - 1) / 2)

result = 1
while power_num > ITR_NUM:
    result *= 2 ** ITR_NUM % DIVISOR
    result %= DIVISOR
    power_num -= ITR_NUM
result *= 2 ** power_num % DIVISOR
print(result % DIVISOR)

Buggy submission (verdict: Runtime Error):
def __is_even(num):
    return num % 2 == 0


N = int(input())
reported_num_count = {}
if __is_even(N):  # Nが偶数の場合
    # 報告が正しい場合、値は全て奇数であり、1 ~ N-1 (1つ飛ばし) が2回ずつ出現する
    for i in range(1, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (1 <= i <= N - 1) and not __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** (N / 2)) % (10 ** 9 + 7)))
else:  # N が奇数の場合
    # 報告が正しい場合、値は全て偶数であり、0 が 1回、 2 ~ N-1（1つ飛ばし）が2回ずつ出現する
    for i in range(0, N, 2):
        reported_num_count[i] = 0
    for i in list(map(int, input().split())):
        if (i == 0) and reported_num_count[0] < 1:
            reported_num_count[0] += 1
        elif (2 <= i <= N - 1) and __is_even(i) and reported_num_count[i] < 2:
            reported_num_count[i] += 1
        else:
            print(0)
            exit()
    print(int((2 ** ((N - 1) / 2)) % (10 ** 9 + 7)))
Problem p03006 (python)

Fixed submission:
N = int(input())
x = [0]*N
y = [0]*N
L1_dict = dict()
for i in range(N):
    x[i], y[i] = map(int, input().split())
xy = zip(x, y)
xy = sorted(xy, key=lambda x: (x[0], x[1]))
x, y = zip(*xy)
for i in range(N-1):
    for j in range(i, N):
        if i != j:
            x_diff = x[j] - x[i]
            y_diff = y[j] - y[i]
            if (x_diff, y_diff) not in L1_dict:
                L1_dict[(x_diff, y_diff)] = 1
            else:
                L1_dict[(x_diff, y_diff)] = 1 + L1_dict[(x_diff, y_diff)]
if L1_dict:
    M = max(L1_dict.values())
    print(N - M)
else:
    print(N)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0]*N
y = [0]*N
L1_dict = dict()
for i in range(N):
    x[i], y[i] = map(int, input().split())
for i in range(N-1):
    for j in range(i, N):
        if i != j:
            x_diff = x[j] - x[i]
            y_diff = y[j] - y[i]
            if (x_diff, y_diff) not in L1_dict:
                L1_dict[(x_diff, y_diff)] = 1
            else:
                L1_dict[(x_diff, y_diff)] = 1 + L1_dict[(x_diff, y_diff)]
M = max(L1_dict.values())

print(N - M)
Problem p03007 (python)

Fixed submission:
from collections import deque
N = int(input())
A = list(map(int, input().split()))
plus = 0
minus = 0
for i in range(N):
    if A[i] >= 0:
        plus += 1
    else:
        minus += 1
bb = deque(sorted(A))
x = [0]*(N-1)
y = [0]*(N-1)
for i in range(N-1):
    if len(bb) == 2:
        l = bb.popleft()
        r = bb.pop()
        if l > r:
            ret = l-r
            x[i] = l
            y[i] = r
        else:
            ret = r - l
            x[i] = r
            y[i] = l
    else:
        l = bb.popleft()
        r = bb.pop()

        if plus > minus:
            ret = l - r
            x[i] = l
            y[i] = r
            plus -= 1
        else:
            ret = r - l
            x[i] = r
            y[i] = l
            minus -= 1
    if ret > 0:
        bb.append(ret)
    else:
        bb.appendleft(ret)
print(bb.pop())
for i in range(N-1):
    print(x[i], y[i])

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
x = [0]*(N-1)
y = [0]*(N-1)
start_bool = 1 if N % 2 == 0 else -1
for i in range(N-1):
    print(A)
    l = A.pop(0)
    r = A.pop(-1)
    if start_bool < 0:
        if l > r:
            ret = r - l
            x[i] = r
            y[i] = l
        else:
            ret = l - r
            x[i] = l
            y[i] = r
    else:
        if l > r:
            ret = l - r
            x[i] = l
            y[i] = r
        else:
            ret = r - l
            x[i] = r
            y[i] = l
    if ret > 0:
        bisect.insort(A, ret)
    else:
        bisect.insort(A, ret)
    start_bool *= -1
print(A[0])
for i in range(N-1):
    print(x[i], y[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = list(map(int, input().split()))
bb = deque(sorted(A))
x = [0]*(N-1)
y = [0]*(N-1)
start_bool = 1 if N % 2 == 0 else -1
for i in range(N-1):
    print(bb)
    l = bb.popleft()
    r = bb.pop()
    if start_bool < 0:
        if l > r:
            ret = r - l
            x[i] = r
            y[i] = l
        else:
            ret = l - r
            x[i] = l
            y[i] = r
    else:
        if l > r:
            ret = l - r
            x[i] = l
            y[i] = r
        else:
            ret = r - l
            x[i] = r
            y[i] = l
    if ret > 0:
        bb.append(ret)
    else:
        bb.appendleft(ret)
    start_bool *= -1
print(bb.pop())
for i in range(N-1):
    print(x[i], y[i])
Problem p03074 (python)

Fixed submission:
n,k = map(int,input().split())
s = input()
c = [int(s[i]) for i in range(n)]
ids = [0]
for i in range(1,n):
  if c[i] != c[i-1]:
    ids.append(i)
ids.append(n)
l = len(ids)
result = []
for i in range(l-1):
  if c[ids[i]] == 0:
    if i + 2*k < l:
      result.append(ids[i+2*k] - ids[i])
    else:
      result.append(n - ids[i])
  else:
    if i + 2*k + 1 < l:
      result.append(ids[i+2*k+1] - ids[i])
    else:
      result.append(n - ids[i])
print(max(result))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
c = [int(s[i]) for i in range(n)]
ids = [0]
for i in range(1,n):
  if c[i] != c[i-1]:
    ids.append(i)
ids.append(n)
l = len(ids)
result = []
for i in range(l-1):
  if c[ids[i]] == 0:
    if i + 2*k < l:
      result.append(ids[i+2*k] - ids[i])
    else:
      result.append(n - ids[i])
  else:
    if i + 2*k < l:
      result.append(ids[i+2*k+1] - ids[i])
    else:
      result.append(n - ids[i])
print(max(result))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
c = [int(s[i]) for i in range(n)]
count = []
cost = 0
if c[0] == 0:
  cost += -1
else:
  cost += 1
for i in range(1,n):
  if c[i] == c[i-1]:
    cost += -1 if cost < 0 else 1
  else:
    count.append(cost)
    cost = -1 if cost > 0 else 1
count.append(cost)
i = 0
M = 0
l = 0
r = 0
for j in range(len(count)):
  if count[j] < 0:
    M += -count[j]
    i += 1
  else:
    M += count[j]
  if i == k:
    if j < len(count)-2:
      M += count[j+1]
      r = j + 1
    else:
      r = j
    break
tmp = M
if r < len(count) - 2:
  if count[0] < 0:
    tmp += count[0]
    l += 1
    r += 1
    tmp += -count[r]
    if r+1 < k:
      tmp += count[r + 1]
      r += 1
    M = max(M,tmp)
  while r + 1 < K -1:
    tmp -= count[l]
    tmp += count[l+1]
    l += 2
    r += 1
    tmp += -count[r]
    if r+1 < k:
      tmp += count[r + 1]
      r += 1
    M = max(M,tmp)
print(M)
Problem p03086 (python)

Fixed submission:
s = input()
l = 0
l_max = 0
for i in range(len(s)):
  b = s[i]
  if b == 'A' or b == 'C' or b == 'T' or b == 'G':
    l += 1
  else:
    l_max = max(l_max,l)
    l = 0
l_max = max(l_max,l)
print(l_max)

Buggy submission (verdict: Runtime Error):
s = input()
l = 0
l_max = 0
for i in range(len(s)):
  b = S[i]
  if b == 'A' or b == 'C' or b == 'T' or b == 'G':
    l += 1
  else:
    l_max = max(l_max,l)
    l = 0
print(l_max)
Problem p03759 (python)

Fixed submission:
a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else
  print("NO")