Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
n, m = list(map(int, input().split()))
def cutterl(l, lst) :
    if lst == [] :
        return []
    elif lst[0] < l :
        return cutterl(l, lst[1:])
    else :
        return lst
def cutterr(r, lst) :
    if lst == [] :
        return []
    elif r < lst[-1] :
        return cutterr(r, lst[:-1])
    else :
        return lst
nlist = list(map(lambda x : x + 1, range(n)))
llist=[]
rlist=[]
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
nlist = cutterl(max(llist), nlist)
nlist = cutterr(min(rlist), nlist)
print(len(nlist))

Fixed submission:
n, m = list(map(int, input().split()))
llist = []
rlist = []
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
ll = max(llist)
rr = min(rlist)
print(max(0, min(rr, n)-ll+1))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
def cutterl(l, lst) :
    if lst == [] :
        return []
    elif lst[0] < l :
        return cutterl(l, lst[1:])
    else :
        return lst
def cutterr(r, lst) :
    if lst == [] :
        return []
    elif r < lst[-1] :
        return cutterr(r, lst[:-1])
    else :
        return lst
nlist = list(map(lambda x : x + 1, range(n)))
llist=[]
rlist=[]
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
nlist = cutterl(max(llist), nlist)
nlist = cutterr(min(rlist), nlist)
print(len(nlist))

Fixed submission:
n, m = list(map(int, input().split()))
llist = []
rlist = []
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
ll = max(llist)
rr = min(rlist)
print(max(0, min(rr, n)-ll+1))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
def cutterl(l, lst) :
    if lst == [] :
        return []
    elif lst[0] < l :
        return cutterl(l, lst[1:])
    else :
        return lst
def cutterr(r, lst) :
    if lst == [] :
        return []
    elif r < lst[-1] :
        return cutterr(r, lst[:-1])
    else :
        return lst
nlist = list(map(lambda x : x + 1, range(n)))
for i in range(m) :
    l, r = list(map(int, input().split()))
    nlist = cutterl(l, nlist)
    nlist = cutterr(r, nlist)
print(len(nlist))

Fixed submission:
n, m = list(map(int, input().split()))
llist = []
rlist = []
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
ll = max(llist)
rr = min(rlist)
print(max(0, min(rr, n)-ll+1))
Buggy python submission (verdict: Runtime Error):
N = int(input())
B_start, A_end, B__A, AB_in = 0, 0, 0, 0
for n in range(N) :
    star = input()
    if star[0] == "B" :
        B_start += 1
    if star[-1] == "A" :
        A_end += 1
        if star[0] == "B" :
            B__A += 1
    AB_in += star.count("AB")
    
if B_start == A_end and A_end == B__A :
    print(B__A+AB_in-1)
else :
    print(min(B_start, A_end)+AB_in)

Fixed submission:
n, m = list(map(int, input().split()))
print(n-m+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for a in range(n) :
    if s[a] != s[k] :
        s = s[:a]+"*"+s[a+1:]
print(s)

Fixed submission:
n = int(input())
s = input()
k = int(input())
for a in range(n) :
    if s[a] != s[k-1] :
        s = s[:a]+"*"+s[a+1:]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n
for m in range(n+1) :
    r = s[:m].count("#")
    t = s[m:].count(".")
    ans = min(ans, r+t)
print(ans)

Fixed submission:
n = int(input())
s = input()

t = s.count(".")
r = 0
ans = t
for m in range(n) :
    if s[m] == "." :
        t -= 1
    else :
        r += 1
    ans = min(ans, t+r)
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
if A == B :
    print(2*A)
else :
    print(2*max(a, b)-1)

Fixed submission:
A, B = list(map(int, input().split()))
if A == B :
    print(2*A)
else :
    print(2*max(A, B)-1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Slen = len(S)
s = int(S, 2)
x = 0
for n in range(Slen) :
    if n%2 == 0 :
        x += 2**n
nuri = s^x
ans = 0
while nuri > 0 :
    if nuri&1 == 1 :
        ans += 1
    nuri >>= 1
print(min(ans, Slen-ans))

Fixed submission:
S = input()
a = 0
for n in range(len(S)) :
    if n%2 == 0 :
        if S[n] == "0" :
            a += 1
    else :
        if S[n] == "1" :
            a += 1
print(min(a, len(S)-a))
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a+b > k :
            break
        for c in range(z) :
            if a+b+c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

Fixed submission:
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a*b > k :
            break
        for c in range(z) :
            if a*b*c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
delist = []
for a in alist :
    for b in blist :
        for c in clist :
            delist.append(a+b+c)
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

Fixed submission:
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a*b > k :
            break
        for c in range(z) :
            if a*b*c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)
Buggy python submission (verdict: Runtime Error):
n,s=open(0);b=s.count("B");print("YNeos"[b>=n-b::2])

Fixed submission:
n,s=open(0);b=s.count("B");print("YNeos"[b>=int(n)-b::2])
Buggy python submission (verdict: Runtime Error):
a, b, c = int(input())
print(min(b//a, c))

Fixed submission:
a, b, c = list(map(int, input().split()))
print(min(b//a, c))
Buggy python submission (verdict: Runtime Error):
import math
n, a, b, c = list(map(int, input().split()))
ll = tuple([int(input()) for _ in range(n)])

def nearest(key, lst) :
    ans = math.inf
    d = math.inf
    for el in lst :
        if abs(el - key) < d :
            ans = el
            d = abs(el - key)
    return ans, d

def tend(lln) :
    llm = list(lln)
    al, ad = nearest(a, llm)
    llm.remove(al)
    bl, bd = nearest(b, llm)
    llm.remove(bl)
    cl, cd = nearest(c, llm)
    return ad + bd + cd

def synth(lln) :
    lol = []
    for i in range(len(lln)-1) :
        for j in range(i+1, len(lln)) :
            llm = list(lln)
            lj = llm.pop(j)
            li = llm.pop(i)
            llm.append(li+lj)
            lol.append(tuple(llm))
    return lol

def synth2(lolln) :
    lol = []
    for lln in lolln :
        lol.extend(synth(lln))
    return tuple(lol)


ans = tend(ll)
lolln = set((ll,))
for i in range(5) :
    if n >= i+4 :
        lolln = set(synth2(lolln))
        for lln in lolln :
            ans = min(ans, 10*(i+1)+tend(lln))

print(ans)

Fixed submission:
from itertools import product, combinations

n, *abc = list(map(int, input().split()))
ll = [int(input()) for _ in range(n)]

# 合成してから短縮/延長すればよい
# 合成方法を全探索する

ans = float("inf")
for n_use in range(3, n+1) : # 何本使うか
    for l_use in combinations(ll, n_use) : # どの竹を使うか
        for dist in product(*[range(3) for _ in range(n_use)]) : #竹をどう合成するか
            if len(set(dist)) != 3 :
                continue

            labc = [0, 0, 0]
            for i, l in zip(dist, l_use) :
                labc[i] += l
    
            diff = [abs(labc[i]-abc[i]) for i in range(3)]
            ans = min(ans, 10*(n_use-3)+sum(diff))

print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import*
d=lambda x,y:d(x,y%x)if y%x else x
_,a=open(0)
print(reduce(d,map(int,a.split())))

Fixed submission:
from functools import*
d=lambda x,y:d(y%x,x)if y%x else x
_,a=open(0)
print(reduce(d,map(int,a.split())))
Buggy python submission (verdict: Runtime Error):
n,h,w=map(int,open(0).read().split);print((n-h+1)*(n-w+1))

Fixed submission:
n,h,w=map(int,open(0).read().split());print((n-h+1)*(n-w+1))
Buggy python submission (verdict: Runtime Error):
N,A,B,*P=map(int,open(0).read().split());b=len(p for p in P if p>A);c=len(p for p in P if p>B);print(min(N-b,b-c,c))

Fixed submission:
N,A,B,*P=map(int,open(0).read().split());b=len([p for p in P if p>A]);c=len([p for p in P if p>B]);print(min(N-b,b-c,c))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def primes(m) :
    ps = [2]
    for i in range(3, m) :
        for p in ps :
            if i%p == 0 :
                break
        else :
            ps.append(i)
    return ps

def fdivisor(m) :
    ps = primes(m)
    df = {p:0 for p in ps}
    for i in range(1, m+1) :
        ii = i
        while ii != 1 :
            for p in ps :
                if ii%p == 0 :
                    df[p] += 1
                    ii //= p
    return df

ans = 0
df = fdivisor(n)
over2 = len([v for v in df.values() if v >= 2])
over4 = len([v for v in df.values() if v >= 4])
over14 = len([v for v in df.values() if v >= 14])
over24 = len([v for v in df.values() if v >= 24])
over74 = len([v for v in df.values() if v >= 74])
ans += over4*(over4-1)//2*(over2-2)
ans += over14*(over4-1)
ans += over24*(over2-1)
ans += over74

print(ans)

Fixed submission:
n = int(input())

def primes(m) :
    ps = [2]
    for i in range(3, m+1) :
        for p in ps :
            if i%p == 0 :
                break
        else :
            ps.append(i)
    return ps

def fdivisor(m) :
    ps = primes(m)
    df = {p:0 for p in ps}
    for i in range(1, m+1) :
        ii = i
        while ii != 1 :
            for p in ps :
                if ii%p == 0 :
                    df[p] += 1
                    ii //= p
    return df

ans = 0
df = fdivisor(n)
over2 = len([v for v in df.values() if v >= 2])
over4 = len([v for v in df.values() if v >= 4])
over14 = len([v for v in df.values() if v >= 14])
over24 = len([v for v in df.values() if v >= 24])
over74 = len([v for v in df.values() if v >= 74])
ans += over4*(over4-1)//2*(over2-2)
ans += over14*(over4-1)
ans += over24*(over2-1)
ans += over74

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
xyhl = [list(map(int, input().split())) for _ in range(n)]

tmaps = np.zeros((101, 101, n), dtype="int64")
for d in range(n) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl[d]
            tmaps[i, j, d] = abs(x-i)+abs(y-j)+h

dmaps = np.diff(tmaps, axis=2)
xmap = np.logical_or.reduce(dmaps, axis=2)
place = np.where(np.logical_not(xmap))
cx, cy = place[0][0], place[1][0]
h = tmaps[cx, cy, 0]
print("{} {} {}".format(cx, cy, h))

Fixed submission:
import numpy as np
n = int(input())
xyhl = [list(map(int, input().split())) for _ in range(n)]
xyhl1 = [xyh for xyh in xyhl if xyh[2] != 0]
xyhl0 = [xyh for xyh in xyhl if xyh[2] == 0]

tmaps = np.zeros((101, 101, len(xyhl1)), dtype="int64")
for d in range(len(xyhl1)) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl1[d]
            tmaps[i, j, d] = abs(x-i)+abs(y-j)+h

tmap0 = np.zeros((101, 101, len(xyhl0)), dtype="int64")
for d in range(len(xyhl0)) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl0[d]
            tmap0[i, j, d] = abs(x-i)+abs(y-j)+h

dmaps = np.diff(tmaps, axis=2)
xmap = np.logical_or.reduce(dmaps, axis=2)
place = np.where(np.logical_not(xmap))

for i, j in zip(place[0],place[1]) :
    for t in tmap0[i, j, :].flat :
        if tmaps[i, j, 0] > t :
            break
    else :
        ans = [i, j, tmaps[i, j, 0]]

print("{} {} {}".format(ans[0], ans[1], ans[2]))
Buggy python submission (verdict: Runtime Error):
from sympy import factorint

n, m = map(int, input().split())

mod = 10**9+7

def comb(n, r) :
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

vv = factorint(m).values()
ans = 1
for v in vv :
    a = 0
    for i in range(min(n, v)) :
        a += comb(n, i+1)*comb(v-1, i)
    ans *= a
    ans %= mod
print(ans)

Fixed submission:
from math import sqrt
from collections import Counter

n, m = map(int, input().split())

mod = 10**9+7

def factor(n) :
    factors = Counter()
    p = 2
    while p*p <= n :
        while n%p == 0 :
            factors.update([p])
            n //= p
        p += 1
    if n > 1 :
        factors.update([n])
    return factors

def comb(n, r) :
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

vv = factor(m).values()
ans = 1
for v in vv :
    a = 0
    for i in range(min(n, v)) :
        a += comb(n, i+1)*comb(v-1, i)
    ans *= a
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));print(gcd.reduce(x-int(X)))

Fixed submission:
from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));g=lambda x,y:g(y%x,x)if y%x else x;print(abs(frompyfunc(g,2,1).reduce(x-int(X))))
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split());B=[];l=[]
for y in range(H):
  A=list(map(int,input().split()))
  for x in range(1,W):
    if A[x-1]%2:l.append((y+1,x,y+1,x+1));A[x]+=1
  B.append(A[x])
  if y and B[-2]%2:l.append((y,W,y+1,W));B[y]+=1
print(len(l))
for a in l:print(*a)

Fixed submission:
H, W = map(int, input().split())
lastcol = []
anslist = []
for y in range(H) :
    A = list(map(int, input().split()))
    for x, a in enumerate(A) :
        if x == W-1 :
            lastcol.append(a)
        elif a%2 :
            anslist.append((y+1, x+1, y+1, x+2))
            A[x+1] += 1
for y, a in enumerate(lastcol) :
    if y == H-1 :
        pass
    elif a%2 :
        anslist.append((y+1, W, y+2, W))
        lastcol[y+1] += 1

print(len(anslist))
for ans in anslist :
    print(*ans)
Buggy python submission (verdict: Runtime Error):
n,a=open(0);print(eval(a.replace(" ","+")+"-"+n[:-1]))

Fixed submission:
print(-int(input())+sum(map(int,input().split())))

Buggy python submission (verdict: Runtime Error):
n,a=open(0);print(eval(a.replace(" ","+")+"-"+n))

Fixed submission:
print(-int(input())+sum(map(int,input().split())))
Buggy python submission (verdict: Runtime Error):
from math import log2
N = int(input())
A = list(map(int, input().split()))
B = [a-i for i, a in enumerate(A)]
m = sum(B)//N
l = int(log2(N))
print(min(sum(abs(b-m-i) for b in B)for i in range(-l,l)))

Fixed submission:
from statistics import median
N = int(input())
A = list(map(int, input().split()))
B = [a-i for i, a in enumerate(A)]
m = int(median(B))
print(sum(abs(b-m) for b in B))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
pp = list(map(int, input().split()))
xyxy = [list(map(int, input().split())) for _ in range(m)]

class UnionFind(list) :
    def __init__(self, n) :
        super().__init__(range(n))

    def find(self, i) :
        if self[i] == i : return i
        self[i] = self.find(self[i])
        return self[i]

    def union(self, x, y) :
        from copy import copy
        x = self.find(x)
        y = self.find(y)
        self.new = copy(self)
        self.new[y] = x
        return self.new

    def sameroot(self, x, y) :
        return self.find(x) == self.find(y)

uf = UnionFind(n)
for x, y in xyxy :
    uf = uf.union(x-1, y-1)
for i in range(n) :
    uf.find(i)

d = {}
for i, k in enumerate(uf) :
    if k not in d :
        d[k] = {i}
    else :
        d[k].add(i)

e = {}
for k, set0 in d.items():
    e[k] = set()
    for i in set0 :
        e[k].add(pp[i]-1)

ans = 0
for k in d.keys() :
    set0 = d[k]
    set1 = e[k]
    ans += len(set0&set1)

print(ans)

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

class UnionFind(list) :
    def __init__(self, n) :
        super().__init__(range(n))

    def find(self, i) :
        if self[i] == i : return i
        self[i] = self.find(self[i])
        return self[i]

    def union(self, x, y) :
        x = self.find(x)
        y = self.find(y)
        self[y] = x

    def sameroot(self, x, y) :
        return self.find(x) == self.find(y)

uf = UnionFind(n)
for x, y in xyxy :
    uf.union(x-1, y-1)
for i in range(n) :
    uf.find(i)

d = {}
for i, k in enumerate(uf) :
    if k not in d :
        d[k] = {i}
    else :
        d[k].add(i)

e = {}
for k, set0 in d.items():
    e[k] = set()
    for i in set0 :
        e[k].add(pp[i]-1)

ans = 0
for k in d.keys() :
    set0 = d[k]
    set1 = e[k]
    ans += len(set0&set1)

print(ans)
Buggy python submission (verdict: Runtime Error):
print(sum(s[0]==s[4]for s in map(str,range(*map(sum,enumerate(map(int,input().split()))))))if s[1]==s[3])

Fixed submission:
print(sum(s[0]==s[4]and s[1]==s[3]for s in map(str,range(*map(sum,enumerate(map(int,input().split())))))))
Buggy python submission (verdict: Runtime Error):
from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))

Fixed submission:
from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations([sum(1for s in S if s[0]==c)for c in"MARCH"],3)))

Buggy python submission (verdict: Runtime Error):
from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))

Fixed submission:
from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations([sum(1for s in S if s[0]==c)for c in"MARCH"],3)))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

H, W = map(int, input().split())
S = [input() for _ in range(H)]
G = [[float("inf")]*W for _ in range(H)]
G[0][0] = 1

for _, i, j in product(range(H*W), range(H), range(W)) :
    if S[i][j] == "." :
        for x, y in [(1, 0), (0, 1), (-1, 0), (0, -1)] :
            if 0 <= i+x < H and 0<= j+y < W :
                G[i][j] = min(1+G[i+x][j+y], G[i][j])

d = sum(s.count(".") for s in S)
a = d-G[-1][-1]
print(-1 if a==-float("inf") else a)

Fixed submission:
H,W=map(int,input().split());S=[input() for _ in range(H)];G=[[-1]*W for _ in range(H)];G[0][0]=1;q=[(0,0)]
while q:
 i,j=q[0];q=q[1:]
 for x,y in[(1,0),(0,1),(-1,0),(0,-1)]:
  t,u=i+x,j+y
  if 0<=t<H and 0<=u<W and G[t][u]<0 and S[t][u]==".":
   G[t][u]=1+G[i][j];q+=[(t,u)]
print(-1*(G[-1][-1]<0)or sum(s.count(".")for s in S)-G[-1][-1])

Buggy python submission (verdict: Runtime Error):
from itertools import product

H, W = map(int, input().split())
S = [input() for _ in range(H)]
G = [[float("inf")]*W for _ in range(H)]
G[0][0] = 1

for _  i, j in product(range(H*W), range(H), range(W)) :
    if S[i][j] == "." :
        for x, y in [(1, 0), (0, 1), (-1, 0), (0, -1)] :
            try :
                G[i][j] = min(1+G[i+x][j+y], G[i][j])
            except : pass

d = sum(s.count(".") for s in S)
a = d-G[-1][-1]
print(-1 if a==-float("inf") else a)

Fixed submission:
H,W=map(int,input().split());S=[input() for _ in range(H)];G=[[-1]*W for _ in range(H)];G[0][0]=1;q=[(0,0)]
while q:
 i,j=q[0];q=q[1:]
 for x,y in[(1,0),(0,1),(-1,0),(0,-1)]:
  t,u=i+x,j+y
  if 0<=t<H and 0<=u<W and G[t][u]<0 and S[t][u]==".":
   G[t][u]=1+G[i][j];q+=[(t,u)]
print(-1*(G[-1][-1]<0)or sum(s.count(".")for s in S)-G[-1][-1])
Buggy python submission (verdict: Runtime Error):
s=input();l=[]
for i in range(len(s)-1):
 if s[i]!=s[i+1]:l+=[max(i+1,len(s)-i-1)]
print(min(l))

Fixed submission:
s=input();l=[];n=len(s)
for i in range(n-1):
 if s[i]!=s[i+1]:l+=[max(i+1,n-i-1)]
print(min(l)if l else n)

Buggy python submission (verdict: Runtime Error):
s=input();l=[]
for i in range(len(s)-1):
 if s[i]!=s[i+1]:l+=[max(i,len(s)-i-1)]
print(min(l))

Fixed submission:
s=input();l=[];n=len(s)
for i in range(n-1):
 if s[i]!=s[i+1]:l+=[max(i+1,n-i-1)]
print(min(l)if l else n)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
c = 0
for a in A:
 for b in B[bisect(B, a):] :
  c += N - bisect(C, b)
print(c)

Fixed submission:
from bisect import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
D = [0]*N
E = [0]*(N+1)
for i, b in enumerate(B) :
    D[i] = N - bisect(C, b)
for i, d in enumerate(D[::-1]) :
    E[N-i-1] = E[N-i] + d
c = 0
for a in A:
    c += E[bisect(B, a)]
print(c)
Buggy python submission (verdict: Runtime Error):
N,*A=map(int,open(0).read().split())
i=2*sorted(enumerate(A[::2]),lambda x:x[1])[-1][0]
print(A[i]+A[i+1])

Fixed submission:
N,*A=map(int,open(0).read().split())
i=2*sorted(enumerate(A[::2]),key=lambda x:x[1])[-1][0]
print(A[i]+A[i+1])
Buggy python submission (verdict: Runtime Error):
from itertools import*;from scipy.sparse.csgraph import*
N,M,R=map(int,input().split());r=map(int,input().split())
G=[[9e9]*N for _ in[0]*N]
for _ in[0]*M:A,B,C=map(int,input().split());G[A-1][B-1]=G[B-1][A-1]=C
D=dijkstra(G)
print(int(min(sum(D[i-1,j-1]for i,j in zip(t,t[1:]))for t in permutations(r))))

Fixed submission:
from itertools import*;from scipy.sparse import*
N,M,R=map(int,input().split());r=map(int,input().split())
G=[[9e9]*N for _ in[0]*N]
for _ in[0]*M:A,B,C=map(int,input().split());G[A-1][B-1]=G[B-1][A-1]=C
D=csgraph.dijkstra(csr_matrix(G))
print(int(min(sum(D[i-1,j-1]for i,j in zip(t,t[1:]))for t in permutations(r))))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import*;N,M,R=map(int,input().split())
r=map(int,input().split());G=[[9e9]*N for _ in[0]*N]
for _ in[0]*M:A,B,C=map(int,input().split());G[A-1][B-1]=G[B-1][A-1]=C
for i in range(N):
 for j in range(N):
  for k in range(N):G[j][k]=min(G[j][k],G[j][i]+G[i][k])
print(min(sum(G[i-1][j-1]for i,j in zip(t,t[1:]))for t in permutations(r)))

Fixed submission:
from itertools import*;from scipy.sparse import*
N,M,R=map(int,input().split());r=map(int,input().split())
G=[[9e9]*N for _ in[0]*N]
for _ in[0]*M:A,B,C=map(int,input().split());G[A-1][B-1]=G[B-1][A-1]=C
D=csgraph.dijkstra(csr_matrix(G))
print(int(min(sum(D[i-1,j-1]for i,j in zip(t,t[1:]))for t in permutations(r))))