Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import numpy as np
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shop_a = []
    shop_b = []
    shopsA0 = []

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b+1)
        else:
            shop_a.append(a)
            shop_b.append(b)
    
    shopsA0.sort()

    shop_a = np.array(shop_a, dtype=np.int64)
    shop_b = np.array(shop_b, dtype=np.int64)
    key = shop_a / (shop_b+1)
    sort_index = np.argsort(key)[::-1]
    shop_a = shop_a[sort_index]
    shop_b = shop_b[sort_index]

    DP = np.full(29, t+10, dtype=np.int64)
    DP[0] = 0

    for a, b in zip(shop_a, shop_b):
        np.minimum(DP[1:], (DP[:-1] + 1) * (a + 1) + b, out=DP[1:])

    cumA0 = np.cumsum(shopsA0, dtype=np.int64)

    DP = DP[DP <= t]
    DPA0 = np.searchsorted(cumA0, t - DP, side='right')
    ans = np.arange(len(DP)) + DPA0
    print(ans.max())


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import numpy as np
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = []

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b+1)
        else:
            shops.append([a/(b + 1), a, b])

    shops.sort(reverse=True)
    shopsA0.sort()

    DP = np.array([t+10]*29, dtype=np.int64)
    DP[0] = 0

    for _, a, b in shops:
        np.minimum(DP[1:], (DP[:-1]+1)*(a+1)+b, out=DP[1:])

    cumA0 = np.cumsum(shopsA0, dtype=np.int64)

    DP = DP[DP <= t]
    DPA0 = np.searchsorted(cumA0, t-DP, side='right')
    ans = np.arange(len(DP)) + DPA0
    print(ans.max())


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

input = sys.stdin.readline

n, t = map(int, input().split())
shops = [list(map(int, input().split())) for _ in range(n)]
shops.sort(reverse=True, key=lambda x: x[0]/(x[1]+1))
shops = np.array(shops, dtype=np.int64)

A0 = shops[:, 0] == 0
A1 = shops[:, 0] != 0

shopsA0 = shops[A0][:, 1] + 1
shopsA0.sort()

shops = shops[A1]

DP = np.array([t+10]*30, dtype=np.int64)
DP[0] = 0

for a, b in shops:
    np.minimum(DP[1:], (DP[:-1]+1)*(a+1)+b, out=DP[1:])

cumA0 = np.cumsum(shopsA0, dtype=np.int64)

DP = DP[DP <= t]
DPA0 = np.searchsorted(cumA0, t-DP, side='right')
ans = np.arange(len(DP)) + DPA0
print(ans.max())

Fixed submission:
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input = sys.stdin.readline

n, t = map(int, input().split())
shops = []
shopsA0 = [0]

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0:
        shopsA0.append(b + 1)
    else:
        shops.append([a / (b + 1), a, b])

shops.sort(reverse=True)
shopsA0.sort()

DP = np.array([t + 10] * 30, dtype=np.int64)
DP[0] = 0

for _, a, b in shops:
    np.minimum(DP[1:], (DP[:-1]+1)*(a+1)+b, out=DP[1:])

cumA0 = np.cumsum(shopsA0, dtype=np.int64)

DP = DP[DP <= t]
residual_time = t - DP
ans = [0]
count_A0 = len(cumA0) - 1
for count, residue in enumerate(residual_time):
    while count_A0 > 0 and cumA0[count_A0] > residue:
        count_A0 -= 1
    ans.append(count_A0+count)
print(max(ans))


Fixed submission:
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

input = sys.stdin.readline

n, t = map(int, input().split())
shops = []
shopsA0 = []

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0:
        shopsA0.append(b+1)
    else:
        shops.append([a/(b + 1), a, b])

shops.sort(reverse=True)
shopsA0.sort()

DP = np.array([t+10]*30, dtype=np.int64)
DP[0] = 0

for _, a, b in shops:
    np.minimum(DP[1:], (DP[:-1]+1)*(a+1)+b, out=DP[1:])

cumA0 = np.cumsum(shopsA0, dtype=np.int64)

DP = DP[DP <= t]
DPA0 = np.searchsorted(cumA0, t-DP, side='right')
ans = np.arange(len(DP)) + DPA0
print(ans.max())


Fixed submission:
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a / (b + 1), a, b])

    shopsA0.sort()
    shops.sort(reverse=True)


    DP = [t+10] * 30
    DP[0] = 0

    for _, a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()