Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

def z_algorithm(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    A[0] = l = len(S)
    while i < l:
        while i + j < l and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l - i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    tmp = 0
    for a in A:
        if 2 * a > N:
            continue
        else:
            tmp = max(tmp, a)
    return tmp

ans = 0
for i in range(N):
    ans = max(ans, z_algorithm(S[i:]))

print (ans)

Fixed submission:
N = int(input())
S = list(input())

def z_algorithm(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    A[0] = l = len(S)
    while i < l:
        while i + j < l and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l - i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    tmp = 0
    for index, a in enumerate(A):
        if a <= index:
            tmp = max(tmp, a)
    # print (A)
    return tmp

ans = 0
for i in range(N):
    ans = max(ans, z_algorithm(S[i:]))

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
t = list(input())

tmp = 0
sets = set(s)
# print (sets)
for T in t:
    if T not in sets:
        print (-1)
        exit()

T = 0
while T < len(t):
    if s[tmp % len(s)] == t[T]:
        T += 1
    tmp += 1

print (tmp)

Fixed submission:
# O (T * log(S))
from bisect import bisect_left

S = list(input())
T = list(input())
# S = 'a' * (10 ** 5) + 'b'
# T = 'b' * (10 ** 5)
#条件を満たせるかを調べる
setS = set(S)
for t in T:
    if t not in setS:
        print (-1)
        exit()

lst = [[] for _ in range(26)]
for index, x in enumerate(S):
    lst[ord(x) - 97].append(index)

tmp = 0 #現在地
roop = 0
for t in T:
    tmp = bisect_left(lst[ord(t) - 97], tmp)
    if tmp == len(lst[ord(t) - 97]):
        roop += 1
        tmp = lst[ord(t) - 97][0] + 1
    else:
        tmp = lst[ord(t) - 97][tmp] + 1

# print (roop)
# print (tmp)
print (roop * len(S) + tmp)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
t = list(input())

tmp = 0
sets = set(s)
# print (sets)
for T in t:
    if T not in sets:
        print (-1)
        exit()

T = 0
while T < len(t):
    if s[tmp % len(s)] == t[T]:
        T += 1
    tmp += 1

print (tmp)

Fixed submission:
# O (T * log(S))
from bisect import bisect_left

S = list(input())
T = list(input())
# S = 'a' * (10 ** 5) + 'b'
# T = 'b' * (10 ** 5)
#条件を満たせるかを調べる
setS = set(S)
for t in T:
    if t not in setS:
        print (-1)
        exit()

lst = [[] for _ in range(26)]
for index, x in enumerate(S):
    lst[ord(x) - 97].append(index)

tmp = 0 #現在地
roop = 0
for t in T:
    tmp = bisect_left(lst[ord(t) - 97], tmp)
    if tmp == len(lst[ord(t) - 97]):
        roop += 1
        tmp = lst[ord(t) - 97][0] + 1
    else:
        tmp = lst[ord(t) - 97][tmp] + 1

# print (roop)
# print (tmp)
print (roop * len(S) + tmp)
Buggy python submission (verdict: Runtime Error):
S = ['0'] + list(input())

def g(i):
    if i == 0:
        return 0
    if i == 1:
            return 1
    if i == 2:
        if S[2] == S[1]:
            return 1
        else:
            return 2     

    if S[i] == S[i - 1]:
        return g(i - 3) + 2
    if S[i] != S[i - 1]:
        return g(i - 1) + 1
# print (len(S) - 1)
print (g(len(S) - 1))

Fixed submission:
S = ['0'] + list(input())
N = len(S)

ans = 0
flag = False #直前の文字を使って2文字にするとき True
for i in range(1, N):
    #同じ文字が連続している時
    if S[i] == S[i - 1]:
        # print ('A')
        if flag == True: #その前に連続で使っているとき
            ans += 1
            flag = False
        elif flag == False: #その前を不連続で使っているとき
            flag = None
        elif flag == None:
            ans += 1
            flag = True

    #直前の文字と異なるとき-->1文字だけで使う
    elif S[i] != S[i - 1]:
        # print ('B')
        if flag == True: #直前が連続
            ans += 1
            flag = False
        elif flag == False: #直前が不連続
            ans += 1
            flag = False
        elif flag == None:
            ans += 1
            flag = True

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
n = len(S)
dp = [[0] * 13 for _ in range(n + 1)]

MOD = 10 ** 9 + 7

def solve():
    res = 0
    dp[0][0] = 1
    for i in range(n): #n文字順番に確かめる
        if S[i] == '?': #i文字目が自由のとき
            c = -1
        else:
            c = int(S[i])
        
        for j in range(10):
            if c != -1 and c != j:
                continue
            for k in range(13):
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
        
        for j in range(13):
            dp[i + 1][j] %= MOD
    # print (dp)
    res = dp[n][5]
    return res

print (solve())



Fixed submission:
S = list(input())
n = len(S)
dp = [[0] * 13 for _ in range(n + 1)]

MOD = 10 ** 9 + 7

def solve():
    res = 0
    dp[0][0] = 1
    for i in range(n): #n文字順番に確かめる
        if S[i] == '?': #i文字目が自由のとき
            c = -1
        else:
            c = int(S[i])
        
        for j in range(10):
            if c != -1 and c != j:
                continue
            for k in range(13):
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
        
        for j in range(13):
            dp[i + 1][j] %= MOD
    # print (dp)
    res = dp[n][5]
    return res

print (solve())
Buggy python submission (verdict: Runtime Error):
#全探索でO(N^2)
N = int(input())
A = [int(input()) for _ in range(N)]

count = 0
tmp = - 10 ** 10
for i in range(N):
    # print ('i', i)
    if A[i] == -10 ** 11:
        continue
    else:
        tmp = A[i]
        count += 1
        for j in range(i + 1, N):
            if tmp < A[j]:
                tmp = A[j]
                A[j] = - 10  ** 11
            if j == N - 1:
                tmp = - 10 ** 10
# print (A)
print (count)



Fixed submission:
r = int(input())

print (3 * r * r)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split()))

#  nの約数をO(root(n))で全列挙、
# sortするなら O(root(n) * root(n)log(root(n))) --> O(n * log(n))
def make_divisors(n):
    import math
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0: #割り切れるとき
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

B = [0] * (N + 1)
ans = [0] * (N + 1)
for i in range(N, 0, -1):
    if B[i] == A[i]:
        continue
    ans[i] = 1
    lst = make_divisors(i)
    for tmp in lst:
        B[tmp] += 1
        B[tmp] %= 2

M = sum(ans)
print (M)
for index, b in enumerate(ans):
    if b == 1:
        print (index, end = ' ')


Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))

ans = [-1] * (N+1)
count = 0
for i in range(N, 0, -1):
    tmp = 0
    p = i
    p += p
    # print (i, p)
    while p <= N: #pの倍数について確認
        tmp += ans[p]
        p += i
    ans[i] = abs(a[i] - (tmp%2))
    if ans[i] == 1:
        count += 1
    # print (ans)
    
# print (ans)
print (count)
for i in range(1, N + 1):
    if ans[i] == 1:
        print (i)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int(input().split()))

print (min(A * N, B))

Fixed submission:
N, A, B = map(int, input().split())

print (min(N*A, B))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())

A = list(map(int, input().split()))

matA = [[0] * N for _ in range(N)]
y = [0] * N
for i in range(N):
    matA[i][i] = 1
    matA[i][(i+1)%N] = 1

matA = np.matrix(matA)

y = []
for i in A:
    y += [[2 * i]]

inverseA = np.linalg.inv(matA) * y

# print (matA)
# print (inverseA)

lst = inverseA.tolist()
for i in lst:
    print (int(i[0]), end =' ')
print ()

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

a = 0
for i in range(N):
    a += A[i] * ((-1) ** i)

print (a, end = ' ')
for i in range(N-1):
    print (2 * (A[(i)%N] - a//2 ), end = ' ')
    a = 2 * (A[(i)%N] - a//2)
print ()
Buggy python submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7

N, K = map(int, input().split())


def permutation(n,r):
    import math
    return math.factorial(n)//math.factorial(n-r)

cal_lst = [None] * (K)
def calc(n):
    if cal_lst[n] != None:
        return cal_lst[n]
    if n == 0:
        cal_lst[n] = 1
        return cal_lst[n]
    if n > K-2:
        return 0;
    cal_lst[n] = permutation(K-2, n)
    return cal_lst[n]

lst = [0] * (N)
children = []
for _ in range(N-1):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    #子の数を記録
    lst[a-1] += 1
    #親が1のもののリスト
    if a-1 == 0:
        children += [b-1]

# lst2.sort()
# print (lst)
# print (lst2)

ans = K
for i in range(N):
    if i == 0:
        ans *= permutation(K-1, lst[i])
    else:
        # if lst[i] in children:
        #     ans *= permutation(K-1, lst[i])
        ans *= calc(lst[i])
    ans = ans%MOD
print (ans)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, input().split())


def permutation(n,r):
    import math
    return math.factorial(n)//math.factorial(n-r)

cal_lst = [None] * (K)
def calc(n):
    if cal_lst[n] != None:
        return cal_lst[n]
    if n == 0:
        cal_lst[n] = 1
        return cal_lst[n]
    if n > K-2:
        return 0;
    cal_lst[n] = permutation(K-2, n)
    return cal_lst[n]

g = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    g[a] += [b]
    g[b] += [a]

# print (g)

s = 1
Q = deque([s])
ans = K
searced = [0] * (N+1)
searced[s] = 1
cand = K-1
while len(Q) != 0:
    tmp = 1
    v = Q.popleft()
    for i in g[v]:
        if searced[i] == 1:
            continue
        else:
            searced[i] = 1
            tmp = (tmp * cand) % MOD
            cand -= 1
            Q.append(i)
    ans = (ans * tmp) % MOD
    cand = K-2
print (ans % MOD)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    if (x * 2 == W and y * 2 == H) {
        cout << H / 2 * W << " " << 1 << endl;     
    }
    else cout << H / 2 * W << " " << 0 << endl;     


    return 0;
}


Fixed submission:
W, H, x, y = map(int, input().split())

print (W * H /2, end = ' ')
if W/2 == x and H/2 == y:
    print (1)
else:
    print (0)
Buggy python submission (verdict: Runtime Error):
#再帰回数が多すぎてエラー

S = list(input()) + ['D']*100
N = len(S)-10

# print (S)
# print (N)

memo = [-1] * (N+100) 

# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    memo[k] = 0
    return memo[k]

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)


Fixed submission:
#再帰回数が多すぎてエラー
import sys

sys.setrecursionlimit(210000)
S = list(input()) + ['D']*100
N = len(S)-10

# print (S)
# print (N)

memo = [-1] * (N+100) 

# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    memo[k] = 0
    return memo[k]

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)

Buggy python submission (verdict: Runtime Error):
S = list(input()) + ['D']*100
N = len(S)-10
# print (S)
# print (N)
memo = [-1] * (N+100) 
# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    memo[k] = 0
    return memo[k]

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)


Fixed submission:
#再帰回数が多すぎてエラー
import sys

sys.setrecursionlimit(210000)
S = list(input()) + ['D']*100
N = len(S)-10

# print (S)
# print (N)

memo = [-1] * (N+100) 

# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    memo[k] = 0
    return memo[k]

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)

Buggy python submission (verdict: Runtime Error):
S = list(input()) + ['D']*10
N = len(S)-10
# print (S)
# print (N)
memo = [-1] * (N+10) 
# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    return 0

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)


Fixed submission:
#再帰回数が多すぎてエラー
import sys

sys.setrecursionlimit(210000)
S = list(input()) + ['D']*100
N = len(S)-10

# print (S)
# print (N)

memo = [-1] * (N+100) 

# print (memo)

def check(k):
    if memo[k] != -1:
        return memo[k]
    if S[k+1] == 'B' and S[k+2] == 'C':
        memo[k] = check(k+2) + 1
        return memo[k]
    if S[k+1] == 'A':
        memo[k] = check(k+1)
        return memo[k]
    memo[k] = 0
    return memo[k]

ans = 0
for i in range(N):
    if S[i] =='A':
        ans += check(i)
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        if (N - (R * r) - (G * g)) % B == 0 and 0 <= ((N - (R * r) - (G * g)) // B) <= 3000:
            ans += 1
print (ans)


Fixed submission:
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        if (N - (R * r) - (G * g)) % B == 0 and 0 <= ((N - (R * r) - (G * g)) // B) <= 3000:
            ans += 1
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

W = S.count('.') #全部の白の数
B = N - W #全部の黒の数

count = N

for i in range(0,N+1):
    a = S[0:i]
#    print (a)
    w = a.count('.') #前半の白の数
    b = i - w #前半の黒の数
    count = min(count, b+(W-w)) #反転すべき数 = 前半の黒の数＋後半の白の数
print (count)

Fixed submission:
N = int(input())
S = list(input())

W = S.count('.')
B = 0
ans = W
if W == 0:
    print (0)
else:
    for i in range(0,N):
#        print (i)
        if S[i] == '#':
            B += 1
        else:
            W -= 1
        ans = min(ans, B+W)
    print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
S  = str(input())
lst_even = []
lst_odd = []
for i in range(len(S)):
    if i % 2 == 0:
        lst_even = lst_even + [S[i]]
    else:
        lst_odd =  lst_odd + [S[i]]
even_white = lst_even.count('1')
even_black = lst_even.count('0')
odd_white = lst_odd.count('1')
odd_black = lst_odd.count('0')
bw = even_white + odd_black
wb = even_black + odd_white
print (min(wb, bw))

Fixed submission:
S  = str(input())
even_black = 0
even_white = 0
odd_black = 0
odd_white = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '0':
            even_black += 1
        else:
            even_white += 1
    else:
        if S[i] == '0':
            odd_black += 1
        else:
            odd_white += 1
bw = even_white + odd_black
wb = even_black + odd_white
print (min(wb, bw))
Buggy python submission (verdict: Runtime Error):
#何も考えずに全探索したらO(N^2)で間に合わない

N, K = map(int, input().split())
S = list(input())

#左端の文字は前の文字と変わった直後のみが候補
lst = [0]
for i in range(0, N-1):
    if S[i] != S[i+1]:
        lst += [i+1]

ans = 0
roop = len(lst)
lst = lst + [N]*(N+100)
# print (lst)
# print ('roop', roop)
for i in range(roop):
    if S[lst[i]] == '0':
        # print ('A', lst[i+2*K]- lst[i])
        ans = max(ans, lst[i+2*K]- lst[i])
    if S[lst[i]] == '1':
        # print ('B', lst[i+2*K +1]- lst[i])
        ans = max(ans, lst[i+2*K +1]- lst[i])
print (ans)

Fixed submission:
#何も考えずに全探索したらO(N^2)で間に合わない

N, K = map(int, input().split())
S = list(input())

#左端の文字は前の文字と変わった直後のみが候補
lst = [0]
for i in range(0, N-1):
    if S[i] != S[i+1]:
        lst += [i+1]

ans = 0
roop = len(lst)
lst = lst + [N]*(N+10**5)
# print (lst)
# print ('roop', roop)
for i in range(roop):
    if S[lst[i]] == '0':
        # print ('A', lst[i+2*K]- lst[i])
        ans = max(ans, lst[i+2*K]- lst[i])
    if S[lst[i]] == '1':
        # print ('B', lst[i+2*K +1]- lst[i])
        ans = max(ans, lst[i+2*K +1]- lst[i])
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
S = list(input())

ans = 1
#左端の文字を全探索
for i in range(0, N):
    #count = 切り替わりを潰しても良い回数
    if S[i] == '0':
        count = 2 * K -1
    else:
        count = 2 * K
#切り替わりを探す
    for j in range(i+1, N):
        if S[j] != S[j-1]: #1つ前と今の位置が違う時、変えて良い回数を1つ減らす
            count -= 1
        if count == 0: #これ以上変えることができない時
            ans = max(ans, j-i+1) #今までの答えとi番目からj番目までの個数=j-i+1の大きい方を答えに記録
            # print ('A', j)
        elif j == N -1 and count > 0: #最後まで探索したが、交換回数が余っている時
            ans = max(ans, j-i+1) #今までの答えとi番目からj番目までの個数=j-i+1の大きい方を答えに記録
            # print ('B')
        
print (ans)


Fixed submission:
#何も考えずに全探索したらO(N^2)で間に合わない

N, K = map(int, input().split())
S = list(input())

#左端の文字は前の文字と変わった直後のみが候補
lst = [0]
for i in range(0, N-1):
    if S[i] != S[i+1]:
        lst += [i+1]

ans = 0
roop = len(lst)
lst = lst + [N]*(N+10**5)
# print (lst)
# print ('roop', roop)
for i in range(roop):
    if S[lst[i]] == '0':
        # print ('A', lst[i+2*K]- lst[i])
        ans = max(ans, lst[i+2*K]- lst[i])
    if S[lst[i]] == '1':
        # print ('B', lst[i+2*K +1]- lst[i])
        ans = max(ans, lst[i+2*K +1]- lst[i])
print (ans)
Buggy python submission (verdict: Runtime Error):
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
#print (lst)
count = len(lst) - 1
#print (count)
lst.sort()
#print (lst)
time2 = (len(lst) -1)*10 + lst[0]
print (time1 + time2)

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

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
if len(lst) == 0:
    print (time1)
else:
    #print (lst)
    count = len(lst) - 1
    #print (count)
    lst.sort()
    #print (lst)
    time2 = (len(lst) -1)*10 + lst[0]
    print (time1 + time2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
lst = [n] + [0] * 5
#print ('0', lst)
i = 0
tmp0 = 0

lst[0] != 0
tmp0 = min(lst[0], a)
lst[0] -= tmp0
lst[1] += tmp0
#print ('1', lst)

lst[1] != 0
tmp0 = min(lst[1], b)
lst[1] -= tmp0
lst[2] += tmp0
lst[0] != 0
tmp0 = min(lst[0], a)
lst[0] -= tmp0
lst[1] += tmp0
#print ('2', lst)

lst[2] != 0
tmp0 = min(lst[2], c)
lst[2] -= tmp0
lst[3] += tmp0
lst[1] != 0
tmp0 = min(lst[1], b)
lst[1] -= tmp0
lst[2] += tmp0
lst[0] != 0
tmp0 = min(lst[0], a)
lst[0] -= tmp0
lst[1] += tmp0
#print ('3', lst)

lst[3] != 0
tmp0 = min(lst[3], d)
lst[3] -= tmp0
lst[4] += tmp0
lst[2] != 0
tmp0 = min(lst[2], c)
lst[2] -= tmp0
lst[3] += tmp0
lst[1] != 0
tmp0 = min(lst[1], b)
lst[1] -= tmp0
lst[2] += tmp0
lst[0] != 0
tmp0 = min(lst[0], a)
lst[0] -= tmp0
lst[1] += tmp0
#print ('4', lst)

lst[4] != 0
tmp0 = min(lst[4], e)
lst[4] -= tmp0
lst[5] += tmp0
lst[3] != 0
tmp0 = min(lst[3], d)
lst[3] -= tmp0
lst[4] += tmp0
lst[2] != 0
tmp0 = min(lst[2], c)
lst[2] -= tmp0
lst[3] += tmp0
lst[1] != 0
tmp0 = min(lst[1], b)
lst[1] -= tmp0
lst[2] += tmp0
lst[0] != 0
tmp0 = min(lst[0], a)
lst[0] -= tmp0
lst[1] += tmp0
#print ('5', lst)

while i < (n + 4):
    if lst == [0, 0, 0, 0, 0, n]:
        print (i + 5)
        break
    else:
        i +=1
    if lst[4] != 0:
        tmp0 = min(lst[4], e)
        lst[4] -= tmp0
        lst[5] += tmp0
    if lst[3] != 0:
        tmp0 = min(lst[3], d)
        lst[3] -= tmp0
        lst[4] += tmp0
    if lst[2] != 0:
        tmp0 = min(lst[2], c)
        lst[2] -= tmp0
        lst[3] += tmp0
    if lst[1] != 0:
        tmp0 = min(lst[1], b)
        lst[1] -= tmp0
        lst[2] += tmp0
    if lst[0] != 0:
        tmp0 = min(lst[0], a)
        lst[0] -= tmp0
        lst[1] += tmp0
#    print (lst)

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

m = min(a, b, c, d, e)

print ((n + m -1)//m + 4)
Buggy python submission (verdict: Runtime Error):
lst = list(map(int, input().split()))
s = set(lst)

if len(s) == 1:
  print (`Yes`)
else:
  print (`No`)

Fixed submission:
lst = list(map(int, input().split()))
s = set(lst)

if len(s) == 1:
  print ('Yes')
else:
  print ('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())
i = []
j = 1
while j <= (N + 1):
    part_S = S[0:j]
    i = i + [part_S.count('AC')]
    j += 1
k = 1
#print (i)
while k <= Q:
    l, r = map(int, input().split())
    ans = i[r-1]-i[l-1]
    k += 1
    print (ans)

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
i = [0] * (N + 1)
j = 1
while j < N:
    i[j+1] = i[j] 
    if (S[j-1] == 'A' and S[j] == 'C'):
        i[j+1] += 1
    j += 1
k = 0
#print (i)
while k < Q:
    l, r = map(int, input().split())
    ans = i[r]-i[l]
    k += 1
    print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())
i = 1
while i <= Q:
    l, r = map(int, input().split())
    s = S[l-1:r]
    ans = s.count('AC')
    print (ans)
    i += 1

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
i = [0] * (N + 1)
j = 1
while j < N:
    i[j+1] = i[j] 
    if (S[j-1] == 'A' and S[j] == 'C'):
        i[j+1] += 1
    j += 1
k = 0
#print (i)
while k < Q:
    l, r = map(int, input().split())
    ans = i[r]-i[l]
    k += 1
    print (ans)