Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
total = 0
for i in product('01', repeat=len(s)-1):
    buf = s[0]
    for j in range(len(s)-1):
        if i[j] == '1':
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Fixed submission:
s = input()
total = 0
n = 2**(len(s)-1)
for i in range(n):
    buf = s[0]
    for j in range(len(s)-1):
        if (i>>j)&1:
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Buggy python submission (verdict: Runtime Error):
s = input()
total = 0
for i in product('01', repeat=len(s)-1):
    buf = s[0]
    for j in range(len(s)-1):
        if i[j] == '1':
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Fixed submission:
s = input()
total = 0
n = 2**(len(s)-1)
for i in range(n):
    buf = s[0]
    for j in range(len(s)-1):
        if (i>>j)&1:
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)
Buggy python submission (verdict: Runtime Error):
l = map(int, input().split())
l.sort()
print("YES" if l == [5, 5, 7] else "NO")

Fixed submission:
l = input().split()
print("YES" if sorted(l) == ['5', '5', '7'] else "NO")

Buggy python submission (verdict: Runtime Error):
l = map(int, input().split())
l.sort()
print("Yes" if l == [5, 5, 7] else "No")

Fixed submission:
l = input().split()
print("YES" if sorted(l) == ['5', '5', '7'] else "NO")

Buggy python submission (verdict: Runtime Error):
l = map(int, input().split())
print("Yes" if l.sort() == [5, 5, 7] else "No")

Fixed submission:
l = input().split()
print("YES" if sorted(l) == ['5', '5', '7'] else "NO")

Buggy python submission (verdict: Runtime Error):
l = map(int, input().split())
print("Yes") if l.sort() == [5, 5, 7] else print("No")

Fixed submission:
l = input().split()
print("YES" if sorted(l) == ['5', '5', '7'] else "NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())

arr = list(map(int, input().strip().split()))

ma = arr[0]
cnt = 1

for i in range(1,n):
  	if arr[i] >= ma:
      	cnt += 1
	ma = max(ma, arr[i])
    
print (ans)


Fixed submission:
n = int(input())

arr = list(map(int, input().strip().split()))

ma = arr[0]
cnt = 1

for i in range(1,n):
	if arr[i] >= ma:
		cnt += 1

	ma = max(ma, arr[i])

print (cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

n,m = map(int,input().split())
h = [int(i) for i in input().split()]
ab = [input().split() for i in range(m)]
tmp=[]
for i in ab:
    tmp.append([int(i[0]),int(i[1])])
ab=tmp

ans = 0

for num,i in enumerate(h):
    flag=0
    for j in ab:
        if j[0]==num+1 and h[j[0]-1]<=h[j[1]-1]:
            flag=1
        elif j[1]==num+1 and h[j[0]-1]>=h[j[1]-1]:
            flag=1
    if flag==0:
        ans+=1
print(ans)

Fixed submission:
n,m = map(int,input().split())
h = [int(i) for i in input().split()]
ab = [input().split() for i in range(m)]
tmp=[]
for i in ab:
    tmp.append([int(i[0]),int(i[1])])
ab=tmp

ans = [0 for i in h]

for j in ab:
    if h[j[0]-1]<=h[j[1]-1]:
        ans[j[0]-1]=-1
    if h[j[0]-1]>=h[j[1]-1]:
        ans[j[1]-1]=-1

ans1=0
for i in ans:
    if i>-1:
        ans1+=1
print(ans1)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a//k != b//k:
    print("OK")
else:
    print("NG")

Fixed submission:
k = int(input())
a,b = map(int,input().split())
if a//k != b//k:
    print("OK")
elif a%k == 0:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if l-r>=2019:
    print(0)
elif b-a<=0:
    print(0)
elif (a%3==0)&(b%673==0):
    print(0)
elif (a%3==0)&(b%3==0):
    print(0)
elif a<=20&b>=101:
    print(1)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
print(ans)

Fixed submission:
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if r-l>=2018:
    print(0)
elif b-a<=0:
    print(0)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

def conbi(arg1, arg2):
    k=1
    l=1
    if arg2>arg1/2:
        arg2=arg1-arg2
    for i in range(arg2):
        k=k*(arg1-i)
        l=l*(i+1)
    if arg1==0:
        return 1
    else:
        return k/l
        
for o in range(1,m+1):
    print(int((conbi(n-m+1,o)%(1000000007))*(conbi(m-1,o-1)%(1000000007))))

Fixed submission:
s=input()
st=[]
d=[]
for i in s:
    if i in d:
        st[d.index(i)]+=1
    else:
        d.append(i)
        st.append(1)

if len(st)==2 & st[0]==2 & st[1]==2:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

def conbi(arg1, arg2):
    k=1
    l=1
    for i in range(arg2):
        k=k*(arg1-i)
        l=l*(i+1)
    if arg1==0:
        k=1
    return k/l
        
for i in range(1,m+1):
    print(int(conbi(n-m+1,i)*conbi(m-1,i-1))%(1000000007))

Fixed submission:
s=input()
st=[]
d=[]
for i in s:
    if i in d:
        st[d.index(i)]+=1
    else:
        d.append(i)
        st.append(1)

if len(st)==2 & st[0]==2 & st[1]==2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
a=a-1
b=b-b//c-b//d+b//(int(c*d/math.gcd(c,d)))
a=a-a//c-a//d+a//(int(c*d/math.gcd(c,d)))
print(b-a)

Fixed submission:
a,b,c,d=map(int,input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
def lcm(a,b):
    return a*b//gcd(a,b)
    
a=a-1
b=b-b//c-b//d+b//lcm(c,d)
a=a-a//c-a//d+a//lcm(c,d)
print(b-a)
Buggy python submission (verdict: Runtime Error):
n=input()
s=input()

r=0
b=0

for i in s:
    if i=='R':
	r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')

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

r=0
b=0

for i in s:
    if i=='R':
        r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=input()
s=input()

r=0
b=0

for i in s:
    if i=='R':
	r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')


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

r=0
b=0

for i in s:
    if i=='R':
        r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=1
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)

Fixed submission:
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=a
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

mod = 10**9+7

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return (a*b//gcd(a,b))

now = a[0]
for i in range(1, n):
    now = lcm(max(now, a[i]), min(now, a[i]))
result = 0
for i in range(n):
    result =(result + now // a[i])%mod
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
ism = defaultdict(int)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

for i in range( n):
    dl = factorization(a[i])
    for x, y in dl:
        if ism[x] < y:
            ism[x] = y
lcd = 1
for i in ism.keys():
    lcd = (lcd * (i ** ism[i]))%mod
result = 0
for i in range(n):
    result =(result + lcd *extgcd(a[i],mod)[0])%mod
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
inmax = max(a)

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return (a*b//gcd(a,b))

now = a[0]
for i in range(1, n):
    now = lcm(max(now, a[i]), min(now, a[i]))
result = 0
for i in range(n):
    result =(result + now // a[i])%mod
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
ism = defaultdict(int)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

for i in range( n):
    dl = factorization(a[i])
    for x, y in dl:
        if ism[x] < y:
            ism[x] = y
lcd = 1
for i in ism.keys():
    lcd = (lcd * (i ** ism[i]))%mod
result = 0
for i in range(n):
    result =(result + lcd *extgcd(a[i],mod)[0])%mod
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
h, w = map(int, input().split())
graph = []
for i in range(h):
    a = list(map(int, sys.stdin.readline().split()))
    graph.append(a)
for i in range(h):
    b = list(map(int, sys.stdin.readline().split()))
    for j in range(w):
        graph[i][j] = abs(graph[i][j] - b[j])
result = [[set()]*w for _ in range(h)]
result[0][0].add(graph[0][0])
for i in range(1, h+w-1):
    for j in range(max(0, i-(w-1)), min(i+1, h)):
        ps = set()
        if j > 0:
            for k in result[j-1][i-j]:
                em = abs(k - graph[j][i-j])
                ps.add(em)
                eu = k + graph[j][i-j]
                if k <= 80 * (h + w) // 2 +1:
                    ps.add(eu)
        if i-j > 0:
            for k in result[j][i-j-1]:
                em = abs(k - graph[j][i-j])
                ps.add(em)
                eu = k + graph[j][i-j]
                if k <= 80 * (h + w) // 2 +1:
                    ps.add(eu)
        result[j][i-j] = ps
print(min(result[h-1][w-1]))

Fixed submission:
import sys
from collections import deque
h, w = map(int, input().split())
graph = []
for i in range(h):
    a = list(map(int, sys.stdin.readline().split()))
    graph.append(a)
for i in range(h):
    b = list(map(int, sys.stdin.readline().split()))
    for j in range(w):
        graph[i][j] = abs(graph[i][j] - b[j])
result = [[0]*w for _ in range(h)]
result[0][0] = 1 << graph[0][0]
def ts(a, b):
    result = 0
    for i in range(b+1):
        if (a >> i) & 1 > 0:
            result |= (1 << b) >> i
    return result

for i in range(1, h+w-1):
    for j in range(max(0, i-(w-1)), min(i+1, h)):
        ps = 0
        nt = graph[j][i-j]
        if j > 0:
            k= result[j-1][i-j]
            result[j][i-j] |= k << nt | k >> nt | ts(k, nt)
        if i-j > 0:
            k= result[j][i-j-1]
            result[j][i-j] |= k << nt | k >> nt | ts(k, nt)
ans = result[h-1][w-1]
ans = (-ans&ans).bit_length() - 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, m = map(int, input().split())
dist = []
for i in range(m):
    l, r, c = map(int, sys.stdin.readline().split())
    dist.append([l, r, c])

dist.sort(key=lambda x:x[2])
dist.sort(key=lambda x:x[1])
dist.sort(key=lambda x:x[0])

res = [-1] * (n+1)
res[1] = 0
for i in dist:
    if res[i[0]] == -1:
        print(-1)
        exit()
    sh = res[i[0]] + i[2]
    if res[i[1]]!= -1 and  sh >= res[i[1]]:
        continue
    for j in range(i[0]+1, i[1]+1):
        if res[j] == -1 or res[j] > sh:
            res[j] = sh

print(res[n])

Fixed submission:
import sys
import heapq
n, m = map(int, input().split())

nextL = [[] for _ in range(n+1)]
for i in range(2, n+1):
    nextL[i].append([i-1, 0])

INF = 10**18

costs = [INF] * (n+1)
costs[1] = 0

for i in range(m):
    l, r, c = map(int, sys.stdin.readline().split())
    nextL[l].append([r, c])

pc = []
heapq.heappush(pc, (0, 1))

unreach = set(range(1, n+1))

while len(pc) > 0 :
    cost, target = heapq.heappop(pc)
    if cost > costs[target]:
        continue
    for i in nextL[target]:
        nex = i[0]
        cos = i[1]
        if nex in unreach and cost + cos < costs[nex]:
            costs[nex] = cost + cos
            heapq.heappush(pc, (cost+cos, nex))
    unreach.remove(target)

if costs[n] == INF:
    print(-1)
else:
    print(costs[n])
Buggy python submission (verdict: Runtime Error):
import math
from collections import defaultdict
a, b = map(int, input().split())

g = math.gcd(a, b)
l = defaultdict(int)
for i in range(2, int(g**0.5)+1):
    if g % i == 0:
        while g % i == 0:
            l[i] += 1
            g = g // i
if g != 1:
    l[g] += 1
print(len(l)+1)


Fixed submission:
import fractions
from collections import defaultdict
a, b = map(int, input().split())

g = fractions.gcd(a, b)
l = defaultdict(int)
for i in range(2, int(g**0.5)+1):
    if g % i == 0:
        while g % i == 0:
            l[i] += 1
            g = g // i
if g != 1:
    l[g] += 1
print(len(l)+1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import copy
n, m = map(int, input().split())
keys = []
box = [[] for _ in range(n+1)]
for i in range(m):
    a, b = map(int, sys.stdin.readline().split())
    c = list(map(int, sys.stdin.readline().split()))
    keys.append([a, b, c])
    for j in c:
        box[j].append(i)


def deta(n, remain, price):
    if len(remain) == 0:
        return price
    res = -1
    r = copy.copy(remain)
    b = remain.pop()
    for k in box[b]:
        bn = copy.copy(remain)
        for nb in keys[k][2]:
            if nb in bn:
                bn.remove(nb)
        p = deta(n, bn, price + keys[k][0])
        if res == -1 or p < res:
            res = p
    return res

rem = set(range(1, n+1))
result = deta(n, rem, 0)
print(result)

Fixed submission:
import sys
n, m = map(int, input().split())
keys = []
box = [[] for _ in range(n+1)]

dr = 2**n
dp = [-1] * dr
dp[0] = 0

for i in range(m):
    a, b = map(int, sys.stdin.readline().split())
    c = list(map(int, sys.stdin.readline().split()))
    k = 0
    for box in c:
        k += 1 << box-1
    for j in range(dr):
        if dp[j] != -1:
            price = dp[j] + a
            nex = j | k
            if dp [nex] == -1 or dp[nex] > price:
                dp[nex] = price

print(dp[dr-1])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
p = list(map(int, input().split()))

index = [0] * (n+1)

for i in range(n):
    index[p[i]] = i

poss = []
result = 0
for i in range(1, n+1)[::-1]:
    x = index[i]
    if len(poss) == 0:
        poss.append(x)
        continue
    dx = bisect.bisect_left(poss, x)
    # 左に１番目の数がある
    if dx > 0:
        lbl = 0
        if dx > 1:
            lbl = poss[dx-2]+1
        lbr = poss[dx-1]
        rbl = n-1
        if len(poss) != dx:
            rbl = poss[dx] -1
        result += (lbr-lbl+1) * (rbl-x+1) * i
    # 右に1番目の数がある
    if dx < len(poss):
        rbr = n-1
        if dx < len(poss) -1:
            rbr = poss[dx+1]-1
        rbl = poss[dx]
        lbr = 0
        if dx > 0:
            lbr = poss[dx-1] +1
        result += (rbr-rbl+1) * (x-lbr+1) * i
    poss.insert(dx, x)

print(result)

Fixed submission:
class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

n = int(input())
p = list(map(int, input().split()))

index = [0] * (n+1)

for i in range(n):
    index[p[i]] = i+1

used = BIT(n)
result = 0
for i in range(1, n+1)[::-1]:
    x = index[i]
    if used.len() == 0:
        used.add(x, 1)
        continue
    dx = used.sum(x)
    # 左に１番目の数がある
    if dx > 0:
        lbl = 1
        if dx > 1:
            lbl = used.search(dx-1)+1
        lbr = used.search(dx)
        rbl = n
        if used.len() != dx:
            rbl = used.search(dx+1) -1
        result += (lbr-lbl+1) * (rbl-x+1) * i
    # 右に1番目の数がある
    if dx < used.len():
        rbr = n
        if dx < used.len() -1:
            rbr = used.search(dx+2)-1
        rbl = used.search(dx+1)
        lbr = 1
        if dx > 0:
            lbr = used.search(dx) +1
        result += (rbr-rbl+1) * (x-lbr+1) * i
    used.add(x, 1)
 
print(result)
Buggy python submission (verdict: Runtime Error):
import sys

n, q = map(int, sys.stdin.readline().split())

near = [[] for _ in range(n+1)]
solved = [0] * n+1

child = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    near[a].append(b)
    near[b].append(a)

wait = [1]

while True:
    target = wait.pop()
    for nex in near[target]:
        if solved[nex] != 1:
            child[target].append(nex)
            wait.append(nex)
            solved[nex] = 1
        if len(wait) == 0:
            break

score = [0] * (n+1)
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    score[p] += x

wait = [1]

while True:
    target = wait.pop()
    for nex in child[target]:
        score[nex] += score[target]
        wait.append(nex)
    if len(wait) == 0:
        break

score.pop(0)

print(' '.join(map(str, score)))


Fixed submission:
import sys

n, q = map(int, sys.stdin.readline().split())

child = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    child[a].append(b)

score = [0] * (n+1)
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    score[p] += x

wait = [1]

while True:
    target = wait.pop()
    for nex in child[target]:
        score[nex] += score[target]
        wait.append(nex)
    if len(wait) == 0:
        break

score.pop(0)

print(' '.join(map(str, score)))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())[::-1]

mod = 10**9 + 7

rest = []
for i in range(6):
    res = []
    for j in range(10):
        res.append(((10**i)*j) % 13)
    rest.append(res)

nowtable = [0] * 13
nowtable[0] = 1

for i in range(len(s)):
    degree = i % 6
    nextable = [0] * 13
    if s[i] == '?':
        for j in range(10):
            for k in range(13):
                index = (k + rest[degree][j]) % 13
                nextable[index] = (nextable[index] + nowtable[k]) % mod
    else:
        num = int(s[i])
        for k in range(13):
            index = (k + rest[degree][num]) % 13
            nextable[index] = (nextable[index] + nowtable[k]) % mod
    nowtable = nextable

print(nowtable[5])


Fixed submission:
s = list(input())[::-1]

mod = 10**9 + 7

rest = []
for i in range(6):
    res = []
    for j in range(10):
        res.append(((10**i)*j) % 13)
    rest.append(res)

nowtable = [0] * 13
nowtable[0] = 1

for i in range(len(s)):
    degree = i % 6
    nextable = [0] * 13
    if s[i] == '?':
        for j in range(10):
            for k in range(13):
                index = (k + rest[degree][j]) % 13
                nextable[index] = (nextable[index] + nowtable[k]) % mod
    else:
        num = int(s[i])
        for k in range(13):
            index = (k + rest[degree][num]) % 13
            nextable[index] = (nextable[index] + nowtable[k]) % mod
    nowtable = nextable

print(nowtable[5])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
prevMaxs = []
for i in range(n):
    num = int(input())
    if len(prevMaxs) == 0 :
        prevMaxs.append(num)
    else:
        key = bisect.bisect_left(prevMaxs, num)
        if key == 0:
            prevMaxs.insert(0, num)
        else:
            prevMaxs[key - 1] = num
print(len(prevMaxs))

Fixed submission:
import sys
import bisect

n = int(input())
a = [int(sys.stdin.readline().rstrip()) for _ in range(n)][::-1]

bottoms = [a[0]]

for i in range(1, n):
    pos = bisect.bisect_right(bottoms, a[i])
    if pos == len(bottoms):
        bottoms.append(a[i])
    else:
        bottoms[pos] = a[i]

print(len(bottoms))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
prevMaxs = []
for i in range(n):
    num = int(input())
    if len(prevMaxs) == 0 :
        prevMaxs.append(num)
    else:
        key = bisect.bisect_left(prevMaxs, num)
        if key == 0:
            prevMaxs.insert(0, num)
        else:
            prevMaxs[key - 1] = num
print(len(prevMaxs))

Fixed submission:
import sys
import bisect

n = int(input())
a = [int(sys.stdin.readline().rstrip()) for _ in range(n)][::-1]

bottoms = [a[0]]

for i in range(1, n):
    pos = bisect.bisect_right(bottoms, a[i])
    if pos == len(bottoms):
        bottoms.append(a[i])
    else:
        bottoms[pos] = a[i]

print(len(bottoms))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
nums = [int(input()) for i in range(n)]
count = 0
prevMaxs = []
for i in range(n):
    num = nums[i]
    if len(prevMaxs) == 0 :
        prevMaxs.append(num)
    else:
        key = bisect.bisect_left(prevMaxs, num)
        if key == 0:
            prevMaxs.insert(0, num)
        else:
            prevMaxs[key - 1] = num
print(len(prevMaxs))

Fixed submission:
import sys
import bisect

n = int(input())
a = [int(sys.stdin.readline().rstrip()) for _ in range(n)][::-1]

bottoms = [a[0]]

for i in range(1, n):
    pos = bisect.bisect_right(bottoms, a[i])
    if pos == len(bottoms):
        bottoms.append(a[i])
    else:
        bottoms[pos] = a[i]

print(len(bottoms))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [int(input()) for i in range(n)]
count = 0
prevMaxs = []
for i in range(n):
    num = nums[i]
    if len(prevMaxs) == 0 :
        prevMaxs.append(num)
    else:
        maxIndex = -1
        maxNum = -1
        for j in range((len(prevMaxs))):
            if prevMaxs[j] < num and maxNum < prevMaxs[j]:
                maxIndex = j
                maxNum = prevMaxs[j]
        if maxIndex == -1:
            prevMaxs.append(num)
        else:
            prevMaxs[maxIndex] = num
print(len(prevMaxs))

Fixed submission:
import sys
import bisect

n = int(input())
a = [int(sys.stdin.readline().rstrip()) for _ in range(n)][::-1]

bottoms = [a[0]]

for i in range(1, n):
    pos = bisect.bisect_right(bottoms, a[i])
    if pos == len(bottoms):
        bottoms.append(a[i])
    else:
        bottoms[pos] = a[i]

print(len(bottoms))