Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

import collections


n = int(input())
a = list(map(int, input().split()))
a_counter = collections.Counter(a)
a_keys = sorted(a_counter.keys(), reverse=True)

targets = []

t = 0
vt = 1
for v in a:
    while v >= vt:
        t += 1
        vt *= 2
        targets.append(vt)
targets.reverse()


cnt = 0
for key in a_keys:
    if a_counter[key] <= 0:
        continue
    for t in targets:
        if key == t-key:
            p = max(0, min(a_counter[key], a_counter[t-key])) // 2
        else:
            p = max(0, min(a_counter[key], a_counter[t-key]))
        a_counter[key] -= p
        a_counter[t-key] -= p
        cnt += p
print(cnt)


Fixed submission:
import bisect

import collections


n = int(input())
a = list(map(int, input().split()))
a_counter = collections.Counter(a)
a_keys = sorted(a_counter.keys(), reverse=True)

targets = []

t = 0
vt = 1
for v in a:
    while v >= vt:
        t += 1
        vt *= 2
        targets.append(vt)
targets.reverse()


cnt = 0
for key in a_keys:
    if a_counter[key] <= 0:
        continue
    for t in targets:
        if key >= t:
            break
        if key == t-key:
            p = max(0, min(a_counter[key], a_counter[t-key])) // 2
        else:
            p = max(0, min(a_counter[key], a_counter[t-key]))
        a_counter[key] -= p
        a_counter[t-key] -= p
        cnt += p
print(cnt)
Buggy python submission (verdict: Runtime Error):
h, w, n = map(int, input().split())

ps = [[] for i in range(h)]
blocks = set()
for i in range(n):
    x, y = map(lambda x: int(x)-1, input().split())
    # if x < y:
    #     continue
    ps[y].append(x)
    blocks.add((x, y))
y_app_x = [[w+1] for i in range(h)]
x, y = (0, 0)
cands = [w]
while y < h:
    if (x+1, y) in blocks:
        # 高橋君は移動できなければ = 障害物に移動すると即死
        cands.append(x+1)
        break
    else:
        ps[y] = [p for p in ps[y] if p > x]
        if ps[y]:
            cands.append(min(ps[y]))
        x += 1
        while (x, y+1) in blocks and x < w:
            x += 1

    y += 1
print(min(cands))


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

ps = [[] for i in range(h)]
blocks = set()
for i in range(n):
    x, y = map(lambda x: int(x)-1, input().split())
    # if x < y:
    #     continue
    ps[y].append(x)
    blocks.add((x, y))
x, y = (0, 0)
cands = [w]
while y < h:
    if (x+1, y) in blocks:
        # 高橋君は移動できなければ = 障害物に移動すると即死
        cands.append(x+1)
        break
    else:
        x += 1
        ps[y] = [p for p in ps[y] if p > x]
        if ps[y]:
            cands.append(min(ps[y]))
        while (x, y+1) in blocks and (x+1, y) not in blocks and x+1 < w:
            x += 1
    
    if (x, y+1) in blocks:
        break
    y += 1
print(min(cands))
Buggy python submission (verdict: Runtime Error):
print('YES' if int(input()) in [3,5,7] else 'NO']

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

Buggy python submission (verdict: Runtime Error):
x=int(input())
print('YES' if x in [3,5,7] 'NO')

Fixed submission:
x=int(input())
print('YES' if x in [3,5,7] else 'NO')
Buggy python submission (verdict: Runtime Error):
s=input()
n=int(s)
cands=[abs(753-int(s[i,i+3])) for i in range(n-2)]
minv=min(cands)
print(minv)

Fixed submission:
s=input()
n=len(s)
print(min((abs(753-int(s[i:i+3])) for i in range(n-2))))

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
print(min((abs(753-int(s[i:i+3])) for i in range(n-2)))

Fixed submission:
s=input()
n=len(s)
print(min((abs(753-int(s[i:i+3])) for i in range(n-2))))
Buggy python submission (verdict: Runtime Error):
n,t= map(int, input().split())
m = min([c for c,ti in [map(int,input().split()) for i in range(n)] if ti <=t])
print(m if m else 'TLE')

Fixed submission:
n,t= map(int, input().split())
rs = [list(map(int, input().split())) for i in range(n)]
rs.sort()
for i in rs:
    ci, ti = i
    if ti<= t:
        print(ci)
        exit()
print('TLE')
Buggy python submission (verdict: Runtime Error):
a,b,c = *sorted(list(map(int, input().split())))
print(a*10+b+c)

Fixed submission:
a,b,c = sorted(list(map(int, input().split())))
print(c*10+b+a)
Buggy python submission (verdict: Runtime Error):
r = int(input())
if r < 1200:
  print('ABC')
else if r < 2800:
  print('ARC')
else:
  print('AGC')

Fixed submission:
r = int(input())
if r < 1200:
  print('ABC')
elif r < 2800:
  print('ARC')
else:
  print('AGC')
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
t = input()
n = len(t)

l_a = [0] * (n + 1)
l_q = [0] * (n + 1)
r_c = [0] * (n + 1)
r_q = [0] * (n + 1)
total = 0

for i in range(1, n):
    l_a[i] = l_a[i - 1] + (1 if t[i - 1] == 'A' else 0)
    l_q[i] = l_q[i - 1] + (1 if t[i - 1] == '?' else 0)
for i in range(n - 1, 0, -1):
    r_c[i - 1] = r_c[i] + (1 if t[i] == 'C' else 0)
    r_q[i - 1] = r_q[i] + (1 if t[i] == '?' else 0)
for i in range(n):
    if t[i] in 'B?':
        total += l_a[i] * r_c[i] * 3**(l_q[i] + r_q[i]) + \
            l_a[i] * r_q[i] * 3**(l_q[i] + r_q[i] - 1) +\
            l_q[i] * r_c[i] * 3**(l_q[i] + r_q[i] - 1) +\
            l_q[i] * r_q[i] * 3**(l_q[i] + r_q[i] - 2)
        total %= mod
print(int(total))


Fixed submission:
mod = 10**9 + 7
t = input()
n = len(t)

l_a = [0] * (n + 1)
l_q = [0] * (n + 1)
r_c = [0] * (n + 1)
r_q = [0] * (n + 1)
total = 0

for i in range(1, n):
    l_a[i] = l_a[i - 1] + (1 if t[i - 1] == 'A' else 0)
    l_q[i] = l_q[i - 1] + (1 if t[i - 1] == '?' else 0)
for i in range(n - 1, 0, -1):
    r_c[i - 1] = r_c[i] + (1 if t[i] == 'C' else 0)
    r_q[i - 1] = r_q[i] + (1 if t[i] == '?' else 0)


pow3mod = [1] * (n+1)
for i in range(n):
    pow3mod[i+1] = pow3mod[i] * 3 % mod

for i in range(n):
    if t[i] in 'B?':
        total += l_a[i] * r_c[i] * pow3mod[l_q[i] + r_q[i]] + \
            l_a[i] * r_q[i] * pow3mod[l_q[i] + r_q[i] - 1] +\
            l_q[i] * r_c[i] * pow3mod[l_q[i] + r_q[i] - 1] +\
            l_q[i] * r_q[i] * pow3mod[l_q[i] + r_q[i] - 2]
        total %= mod
print(int(total))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a + b <= 14:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
n = int(input())

min_cnt = float('inf')
for i in range(n//6+1):
  cnt = 0
  t = i
  while t>6:
	cnt += t%6
  	t //= 6
  cnt += t
  
  for j in range((n-6*i)//9+1):
    t = j
    while t>9:
      cnt += t%9
      t //= 9
    cnt += t
    cnt += (n-6*i-9*j)
    if cnt < min_cnt:
      min_cnt = cnt
print(min_cnt)


Fixed submission:
n = int(input())

min_cnt = float('inf')
for i in range(0, n+1, 9):
    cnt = 0
    t = i
    while t >= 9:
        cnt += t % 9
        t //= 9
    cnt += t

    t = (n-i)
    while t >= 1:
        cnt += t % 6
        t //= 6
    cnt += t

    if cnt < min_cnt:
        min_cnt = cnt
print(min_cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1,n+1):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])


Fixed submission:
import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1, min(i+6, n+1)):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import string
s=input()
n = len(s)
k = int(input())

subs = collections.defaultdict(set)
for i in range(n):
    for j in range(i+1,n+1):
        subs[s[i]].add(s[i:j])
for c in string.ascii_lowercase:
    l = len(subs[c])
    if k <= l:
        t = sorted(list(subs[c]))[k-1]
        print(t)
        exit()
    else:
        k -= l


Fixed submission:
import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1, min(i+6, n+1)):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n = len(s)
k = int(input())

subs = set()
for i in range(n):
    for j in range(i+1,n+1):
        subs.add(s[i:j])
print(sorted(list(subs))[k-1])


Fixed submission:
import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1, min(i+6, n+1)):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, c = map(int, input().split())
sushi = []
for i in range(n):
    x, v = map(int, input().split())
    sushi.append((x, v))
sushi.sort()
sushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))


# def solve(s, sr):
#     d = 0
#     v = 0
#     v_d_max = (0, 0)
#     v_2d_max = (0, 0)
#     conds = []

#     for x_i, v_i in s:
#         v = v + v_i - (x_i - d)
#         d = x_i
#         v_d_max = max(v_d_max, (v, d))
#         if v - d > v_2d_max[0]:
#             v_2d_max = (v - d, d)
#             conds.append((v - d, d))
#     return v_d_max, v_2d_max, conds

def solve(s, sr):
    d = 0
    v = 0
    v_2d_max = 0
    v_max = 0
    n = len(s)
    for i in range(n):
        x_i, v_i = s[i]
        v = v + v_i - (x_i - d)
        d = x_i
        v_max = max(v_max, v)
        if v - d > v_2d_max:
            v_2d_max = v - d
            v_sub = sub_solve(sr[:n - 1 - i])
            v_max = max(v_max, v_2d_max + v_sub)
    return v_max


def sub_solve(s):
    d = 0
    v = 0
    v_max = 0

    for x_i, v_i in s:
        v = v + v_i - (x_i - d)
        d = x_i
        v_max = max(v_max, v)
    return v_max

# l_v_d_max, l_v_2d_max, l_conds = solve(sushi, sushi_reversed)
# r_v_d_max, r_v_2d_max, r_conds = solve(sushi_reversed, sushi)
# print(l_v_d_max, l_v_2d_max, l_conds, r_v_d_max, r_v_2d_max, r_conds)

# max_v = max(l_v_d_max[0], r_v_d_max[0])
# if l_v_d_max[1] + r_v_2d_max[1] < c:
#     max_v = max(max_v, l_v_d_max[0] + r_v_2d_max[0])
# else:
#     for v, d in r_conds:
#         if l_v_d_max[1] + d < c:
#             max_v = max(max_v, l_v_d_max[0] + v)

# if l_v_2d_max[1] + r_v_d_max[1] < c:
#     max_v = max(max_v, l_v_2d_max[0] + r_v_d_max[0])
# else:
#     for v, d in l_conds:
#         if d + r_v_d_max[1] < c:
#             max_v = max(max_v, v + r_v_d_max[0])

# print(max_v)

# l_v_d_max, l_v_2d_max, l_conds = solve(sushi, sushi_reversed)
# r_v_d_max, r_v_2d_max, r_conds = solve(sushi_reversed, sushi)
# print(max_v)


l = solve(sushi, sushi_reversed)
r = solve(sushi_reversed, sushi)
print(max(solve(sushi, sushi_reversed), solve(sushi_reversed, sushi)))


Fixed submission:
n, c = map(int, input().split())
sushi = []
for i in range(n):
    x, v = map(int, input().split())
    sushi.append((x, v))
sushi.sort()
sushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))


def accum_max(s):
    v = 0
    res = [(0, 0)]
    for x_i, v_i in s:
        v += v_i
        res.append(max(res[-1], (v-x_i, x_i)))
    return res[1:]


max_sushi = accum_max(sushi)
max_sushi_reversed = accum_max(sushi_reversed)


def solve(s, msr):
    v_max = 0
    v_2d_max = 0
    v = 0
    n = len(s)
    for i in range(n-1):
        x_i, v_i = s[i]
        v += v_i
        if v - x_i*2 > v_2d_max:
            v_2d_max = v - x_i*2
            v_sub = msr[n - 2 - i][0]
            v_max = max(v_max, v_2d_max + v_sub)
    return v_max


l = solve(sushi, max_sushi_reversed)
r = solve(sushi_reversed, max_sushi)
print(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int, [input() for i in range(4)])
print(min(a,b) + (c,d))

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b) + min(c,d))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

print(0, flush=True)
s = input()
if s == 'Vacant':
    exit()
head_v = s
head_i = 0
print(n-1, flush=True)
s = input()
if s == 'Vacant':
    exit()
tail_v = s
tail_i = n-1

while True:
    mi = (head_i + tail_i) // 2
    print(mi, flush=True)
    s = input()
    if s == 'Vacant':
        exit()
    if s == head_v ^ (mi-head_i-1) % 2 == 1:
        head_i = mi
        head_v = s
    else:
        tail_i = mi
        tail_v = s


Fixed submission:
n = int(input())

print(0, flush=True)
s = input()
if s == 'Vacant':
    exit()
head_v = s
head_i = 0
print(n-1, flush=True)
s = input()
if s == 'Vacant':
    exit()
tail_v = s
tail_i = n-1

while True:
    mi = (head_i + tail_i) // 2
    print(mi, flush=True)
    mv = input()

    if mv == 'Vacant':
        exit()
    if tail_v == mv and (tail_i - mi) % 2 == 1 or tail_v != mv and (tail_i - mi) % 2 == 0:
        head_i = mi
        head_v = mv
    else:
        tail_i = mi
        tail_v = mv
Buggy python submission (verdict: Runtime Error):
print('Odd' if int(input())%2 else 'Even')

Fixed submission:
a,b=map(int, input().split())
print('Odd' if a*b%2 else 'Even')
Buggy python submission (verdict: Runtime Error):
n = int(input())
mochi = set([int(input()) for i in range(n)])
print(len(s))


Fixed submission:
n = int(input())
d = set([int(input()) for i in range(n)])
print(len(d))
Buggy python submission (verdict: Runtime Error):
import 
a,b = map(int, input().split())
s = input()

if len(s) == (a+b+1) and all([c != '-' for c in s[:a]+s[a+1:]]) and s[a] == '-':
  print('Yes')
else:
  print('No')

Fixed submission:
a,b = map(int, input().split())
s = input()

if len(s) == (a+b+1) and all([c != '-' for c in s[:a]+s[a+1:]]) and s[a] == '-':
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n, x, y = map(int, input().split())
a = list(map(int, input().split()))

if n == 1:
    print(abs(a[-1] - y))
else:
    print(max(abs(a[-1] - y), abs(a[-1] - a[-2])))


Fixed submission:
n, m = map(int, input().split())
print(2**m * (1800 * m + 100 * n))
Buggy python submission (verdict: Runtime Error):
import functools
n,x,y = map(int, input().split())
a = list(map(int, input().split()))

@functools.lru_cache()
def solve(x_turn, idx, x, y):
    if idx == n:
        return abs(x-y)
    if x_turn:
        score = [solve(False, i+1, a[i], y) for i in range(idx, n)]
        return max(score)
    else:
        score = [solve(True, i+1, x, a[i]) for i in range(idx, n)]
        return min(score)

print(solve(True, 0, x, y))        

Fixed submission:
n, x, y = map(int, input().split())
a = list(map(int, input().split()))

if n == 1:
    print(abs(a[-1] - y))
else:
    print(max(abs(a[-1] - y), abs(a[-1] - a[-2])))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, k = map(int, input().split())
p = []

vy = set()
vx = set()
for i in range(n):
    x, y = map(int, input().split())
    p.append((y,x))
    vy.add(y)
    vx.add(x)
vy = sorted(list(vy))
vx = sorted(list(vx))

min_area = float('inf')


for y in itertools.combinations(vy, r=2):
    for x in itertools.combinations(vx, r=2):
        cnt = 0
        for i in range(n):
            if y[0] <= p[i][0] <= y[1] and x[0] <= p[i][1] <= x[1]:
                cnt += 1
        if cnt >= k:
            min_area = min(min_area, (y[1]-y[0]) * (x[1]-x[0]))
print(min_area)

Fixed submission:
import itertools
n, k = map(int, input().split())
p = []

vy = set()
vx = set()
for i in range(n):
    x, y = map(int, input().split())
    p.append((y,x))
    vy.add(y)
    vx.add(x)
vy = sorted(list(vy))
vx = sorted(list(vx))

min_area = float('inf')


for y in itertools.combinations(vy, r=2):
    for x in itertools.combinations(vx, r=2):
        cnt = 0
        for i in range(n):
            if y[0] <= p[i][0] <= y[1] and x[0] <= p[i][1] <= x[1]:
                cnt += 1
        if cnt >= k:
            min_area = min(min_area, (y[1]-y[0]) * (x[1]-x[0]))
print(min_area)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m,r = map(int, input().split())
req = list(map(lambda x:int(x)-1, input().split()))
dist = [[float('inf') for j in range(n)] for i in range(n)]
for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    dist[a][b] = c
    dist[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

min_dist = float('inf')
for p in itertools.permutations(req):
    total_dist = 0
    for i in range(r-1):
        total_dist += dist[p[i]][p[i+1]]
    min_dist = min(min_dist, total_dist)
print(min_dist)
                

Fixed submission:
import itertools
n,m,r = map(int, input().split())
req = list(map(lambda x:int(x)-1, input().split()))
dist = [[float('inf') for j in range(n)] for i in range(n)]
for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    dist[a][b] = c
    dist[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

min_dist = float('inf')
for p in itertools.permutations(req):
    total_dist = 0
    for i in range(r-1):
        total_dist += dist[p[i]][p[i+1]]
    min_dist = min(min_dist, total_dist)
print(min_dist)
Buggy python submission (verdict: Runtime Error):
n,k=map(int, input().split())
l = list(map(int, input().split()))
l.sort(reversed=True)
print(sum(l[:k]))

Fixed submission:
n,k=map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[:k]))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n = int(input())
p = []
q = []
for i in range(n):
    x,y = map(int, input().split())
    p.append((x, y, i))
    q.append((y, x, i))

p.sort()
q.sort()
pid = [0 for i in range(n)]
qid = [0 for i in range(n)]
for i in range(n):
    pid[p[i][2]] = i
    qid[q[i][2]] = i
used = [False] * n

total = 0

hq = [(0, 0)]
cnt = 0
s = set()
while hq and cnt < n:
    c, i = heapq.heappop(hq)
    # print(c, i)
    if i not in s:
        cnt += 1
        s.add(i)
        total += c
    else:
        continue
    pi = pid[i]
    qi = qid[i]
    if pi > 0 and p[pi-1][2] not in s:
        heapq.heappush(hq, (p[pi][0] - p[pi-1][0], p[pi-1][2]))
    if pi < n-1 and p[pi+1][2] not in s:
        heapq.heappush(hq, (p[pi+1][0] - p[pi][0], p[pi+1][2]))
    if qi > 0 and q[qi-1][2] not in s:
        heapq.heappush(hq, (q[qi][0] - q[qi-1][0], q[qi-1][2]))
    if qi < n-1 and q[qi+1][2] not in s:
        heapq.heappush(hq, (q[qi+1][0] - q[qi][0], q[qi+1][2]))
    
        

print(total)

Fixed submission:
import heapq
n = int(input())
p = []
q = []
for i in range(n):
    x,y = map(int, input().split())
    p.append((x, y, i))
    q.append((y, x, i))

p.sort()
q.sort()
pid = [0 for i in range(n)]
qid = [0 for i in range(n)]
for i in range(n):
    pid[p[i][2]] = i
    qid[q[i][2]] = i
used = [False] * n

total = 0

hq = [(0, 0)]
cnt = 0
s = set()
while hq and cnt < n:
    c, i = heapq.heappop(hq)
    # print(c, i)
    if i not in s:
        cnt += 1
        s.add(i)
        total += c
    else:
        continue
    pi = pid[i]
    qi = qid[i]
    if pi > 0 and p[pi-1][2] not in s:
        heapq.heappush(hq, (p[pi][0] - p[pi-1][0], p[pi-1][2]))
    if pi < n-1 and p[pi+1][2] not in s:
        heapq.heappush(hq, (p[pi+1][0] - p[pi][0], p[pi+1][2]))
    if qi > 0 and q[qi-1][2] not in s:
        heapq.heappush(hq, (q[qi][0] - q[qi-1][0], q[qi-1][2]))
    if qi < n-1 and q[qi+1][2] not in s:
        heapq.heappush(hq, (q[qi+1][0] - q[qi][0], q[qi+1][2]))
    
        

print(total)
Buggy python submission (verdict: Runtime Error):
import string
s = input()
n = len(s)

min_cnt = float('inf')

for c in string.ascii_lowercase:
    if c not in s:
        continue
    cnt = 0
    s_ = s[:]
    while s_:
        is_same = True
        for d in s_:
            if d != c:
                is_same = False
                break
        if is_same:
            min_cnt = min(min_cnt, n - m)
        m = len(s_) - 1
        s_next = [''] * m
        for i in range(m):
            if s_[i] == c or s_[i + 1] == c:
                s_next[i] = c
            else:
                s_next[i] = s_[i]
        s_ = s_next

print(min_cnt)


Fixed submission:
s = input()
n = len(s)
min_t = float('inf')
for i in range(n):
    target = s[i]
    pre = -1
    max_t = 0
    for j in range(n):
        if s[j] == s[i]:
            max_t = max(max_t, j-pre-1)
            pre = j
    max_t = max(max_t, n - pre-1)
    if max_t < min_t:
        min_t = min(min_t, max_t)
print(min_t)
Buggy python submission (verdict: Runtime Error):
s = [x for x in input()]
print('yes' if all(s.count(c)==1 for c in s else 'no')

Fixed submission:
s = [x for x in input()]
print('yes' if all([(s.count(c)==1) for c in s])  else 'no')
Buggy python submission (verdict: Runtime Error):
n = int(input())

def prime_decomposition(n):
    # 素因数分解
    if n < 2:
        return []
    prime_factors = []
    while n % 2 == 0:
        prime_factors.append(2)
        n >>= 1

    while n % 3 == 0:
        prime_factors.append(3)
        n //= 3

    a = 5
    b = 7
    while a ** 2 <= n:
        if n % a == 0:
            prime_factors.append(a)
            n //= a
        elif n % b == 0:
            prime_factors.append(b)
            n //= b
        else:
            a += 6
            b += 6
    if n > 1:
        prime_factors.append(n)
    return prime_factors

pfs = prime_decomposition(n)
pfs.reverse()

def ds(n):

    ret = 1
    while 10**ret <= n:
        ret += 1
    return ret

ln = len(pfs)
size = 2**ln

min_v = 100
for i in range(size):
    p = 1
    for j in range(ln):
        if 1<<j & i:
            p *= pfs[j]
    min_v = min(min_v, max(ds(p), ds(n//p)))
print(min_v)

Fixed submission:
a,b=map(int, input().split())
print((a+b)%24)