Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
for i in range(m):
    b += [int(input())]
a = np.array(a)
b = np.array(b)
b.reshape(4, 1)

c = np.dot(a, b)
for i in range(len(c))
    print(c[i])



Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
for i in range(m):
    b += [int(input())]
a = np.array(a)
b = np.array(b)
b.reshape(m, 1)

c = np.dot(a, b)
for i in range(len(c))
    print(c[i])



Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
for i in range(m):
    b += [int(input())]
a = np.array(a)
b = np.array(b)
b.reshape(m, 1)

c = np.dot(a, b)
for i in range(len(c)):
    print(c[i])



Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
for i in range(m):
    b += [int(input())]
a = np.array(a)
b = np.array(b)
b.reshape(m, 1)

c = np.dot(a, b)
for i in range(len(c)):
    print(c[i])



Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
for i in range(m):
    b += [int(input())]
a = np.array(a)
b = np.array(b)
b.reshape(m, 1)

c = np.dot(a, b)
for i in range(len(c)):
    print(c[i])



Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))


Fixed submission:
n, m = map(int, input().split())
A = [input().split() for _ in range(n)]
b = [input()for _ in range(m)]
for a in A:
    print(sum(int(x)*int(y) for x, y in zip(a,b)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a = [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m):
    b += [a[:][i]]
    a += [b]
for i in range(n):
    print(*a[i])


Fixed submission:
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m+1):
    b += [sum(x[i] for x in a)]
a += [b]
for i in range(n+1):
    print(*a[i])
Buggy python submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in rnage(m)]     

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][l] = int(a[i][k])*int(b[k][j])
for i in range(n):
    print(*c)


Fixed submission:
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])

Buggy python submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in rnage(m)]     

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] = int(a[i][k])*int(b[k][j])
for i in range(n):
    print(*c)


Fixed submission:
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])

Buggy python submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in rnage(m)]     
c = [[0]*l for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] = int(a[i][k])*int(b[k][j])
for i in range(n):
    print(*c)


Fixed submission:
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])
Buggy python submission (verdict: Runtime Error):
a = abcdefghijklmnopqrstuvwxyz
b = input()
for i in range(26):
    print(a[i],':',b.count(a[i]))


Fixed submission:
a = "abcdefghijklmnopqrstuvwxyz"
b = ''
while 1:
    try:
        b += input().lower()
    except:
        break
for i in range(26):
    print(a[i],':',b.count(a[i]))

Buggy python submission (verdict: Runtime Error):
a = "abcdefghijklmnopqrstuvwxyz"
while 1:
    try:
        b += input().lower()
    except:
        break
for i in range(26):
    print(a[i],':',b.count(a[i]))


Fixed submission:
a = "abcdefghijklmnopqrstuvwxyz"
b = ''
while 1:
    try:
        b += input().lower()
    except:
        break
for i in range(26):
    print(a[i],':',b.count(a[i]))
Buggy python submission (verdict: Runtime Error):
a = input()
cnt = 0
while 1:
    c = input().lower()
    if c = end_of_text:
        break
    cnt = c.split().count(a)
print(cnt)


Fixed submission:
a = input().lower()
cnt = 0
while 1:
    c = input()
    if c == 'END_OF_TEXT':
        break
    cnt += c.lower().split().count(a)
print(cnt)

Buggy python submission (verdict: Runtime Error):
a = input()
cnt = 0
while 1:
    c = input().lower()
    if c == end_of_text:
        break
    cnt = c.split().count(a)
print(cnt)


Fixed submission:
a = input().lower()
cnt = 0
while 1:
    c = input()
    if c == 'END_OF_TEXT':
        break
    cnt += c.lower().split().count(a)
print(cnt)

Buggy python submission (verdict: Runtime Error):
a = input()
cnt = 0
while 1:
    c = input().lower()
    if c = 'end_of_text':
        break
    cnt += c.split().count(a)
print(cnt)


Fixed submission:
a = input().lower()
cnt = 0
while 1:
    c = input()
    if c == 'END_OF_TEXT':
        break
    cnt += c.lower().split().count(a)
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])


Fixed submission:
while 1:
    a = input()
    if a == '-':
        break
    n = int(input())
    for i in range(n):
        h = int(input())
        a = a[h:] + a[:h]
    print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
x=0
y=0
for i in range(N):
    a,b=input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)


Fixed submission:
n = int(input())
x, y = 0, 0
for i in range(n):
    a, b = input().split()
    if a < b:
        y +=  3
    elif a == b:
        x += 1
        y += 1
    else:
        x += 3
print(x, y)
Buggy python submission (verdict: Runtime Error):
s = input()
n = input()
for i in range(n):
    order, a, b, c = input().split()
    if order == 'replace':
        s = s[:a] + c + s[b+1:]
    elif order[o] == 'r':
        s = s[:a] + a[a:b+1:-1] + a[b+1:]
    else:
        print(s)


Fixed submission:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])

Buggy python submission (verdict: Runtime Error):
s = input()
n = nt(input())
for i in range(n):
    order, a, b, c = input().split()
    if order == 'replace':
        s = s[:a] + c + s[b+1:]
    elif order[o] == 'r':
        s = s[:a] + a[a:b+1:-1] + a[b+1:]
    else:
        print(s)


Fixed submission:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])

Buggy python submission (verdict: Runtime Error):
s = input()
n = nt(input())
for i in range(n):
    order, a, b, *c = input().split()
    if order == 'replace':
        s = s[:a] + c + s[b+1:]
    elif order[o] == 'r':
        s = s[:a] + a[a:b+1:-1] + a[b+1:]
    else:
        print(s)


Fixed submission:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])

Buggy python submission (verdict: Runtime Error):
s = input()
n = nt(input())
for i in range(n):
    order, a, b, *c = input().split()
    if order == 'replace':
        s = s[:a] + *c + s[b+1:]
    elif order[o] == 'r':
        s = s[:a] + a[a:b+1:-1] + a[b+1:]
    else:
        print(s)


Fixed submission:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])

Buggy python submission (verdict: Runtime Error):
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][a:b+1] + s[b+1:]
    else:
        print(s[a:b+1])


Fixed submission:
s = input()
n = int(input())
for i in range(n):
    order, a, b, *c = input().split()
    a = int(a)
    b = int(b)
    if order == 'replace':
        s = s[:a] + c[0] + s[b+1:]
    elif order[0] == 'r':
        s = s[:a] + s[::-1][len(s)-b-1:len(s)-a]+ s[b+1:]
    else:
        print(s[a:b+1])
Buggy python submission (verdict: Runtime Error):
from collections import deque


def dfs(current, prev):
    global time
    # node currentを訪問した直後の処理
    ord[current] = time
    low[current] = time
    time += 1
    color[current] = BLACK

    for next in G[current]:
        if color[next] == WHITE:
            # node currentからnode nextへ訪問する直前の処理
            parent[next] = current
            dfs(next, current)

            # node nextの探索が終了した直後の処理
            low[current] = min(low[current], low[next])
        elif next != prev:
            # edge current --> next がback-edgeの場合の処理
            low[current] = min(low[current], ord[next])


def art_points():
    global time
    time = 1
    dfs(0, -1)  # 0をrootとしてlowの計算
    np = 0
    for i in range(1, v):
        p = parent[i]
        if p == 0:
            np += 1
        elif ord[p] <= low[i]:
            ap.add(p)
    if np > 1:
        ap.add(0)


G = {}
v, n = map(int, input().split())
for i in range(0, v):
    G[i] = []
for i in range(n):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)
WHITE = 0
BLACK = 2

color = [WHITE] * (v)
parent = [0] * (v)
ord = [0] * (v)
low = [0] * (v)
parent = [0] * (v)
ap = set([])
art_points()
if ap:
    print(*sorted(ap), sep='\n')



Fixed submission:
import sys


from collections import deque
sys.setrecursionlimit(1000000)


def dfs(current, prev):
    global time
    # node currentを訪問した直後の処理
    ord[current] = time
    low[current] = time
    time += 1
    color[current] = BLACK

    for next in G[current]:
        if color[next] == WHITE:
            # node currentからnode nextへ訪問する直前の処理
            parent[next] = current
            dfs(next, current)

            # node nextの探索が終了した直後の処理
            low[current] = min(low[current], low[next])
        elif next != prev:
            # edge current --> next がback-edgeの場合の処理
            low[current] = min(low[current], ord[next])


def art_points():
    global time
    time = 1
    dfs(0, -1)  # 0をrootとしてlowの計算
    np = 0
    for i in range(1, v):
        p = parent[i]
        if p == 0:
            np += 1
        elif ord[p] <= low[i]:
            ap.add(p)
    if np > 1:
        ap.add(0)


G = {}
v, n = map(int, input().split())
for i in range(0, v):
    G[i] = []
for i in range(n):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)
WHITE = 0
BLACK = 2

color = [WHITE] * (v)
parent = [0] * (v)
ord = [0] * (v)
low = [0] * (v)
parent = [0] * (v)
ap = set([])
art_points()
if ap:
    print(*sorted(ap), sep='\n')
Buggy python submission (verdict: Runtime Error):
from collections import deque
sys.setrecursionlimit(1000000)


def dfs(current, prev):
    global time
    # node currentを訪問した直後の処理
    ord[current] = time
    low[current] = time
    time += 1
    color[current] = BLACK

    for next in G[current]:
        if color[next] == WHITE:
            # node currentからnode nextへ訪問する直前の処理
            parent[next] = current
            dfs(next, current)

            # node nextの探索が終了した直後の処理
            low[current] = min(low[current], low[next])
        elif next != prev:
            # edge current --> next がback-edgeの場合の処理
            low[current] = min(low[current], ord[next])


def bridge():
    global time
    time = 1
    dfs(0, -1)  # 0をrootとしてlowの計算
    for u, v in edges:
        if ord[u] < low[v] or ord[v] < low[u]:
            br.add((u, v))


G = {}
edges = set([])
br = set([])
v, n = map(int, input().split())
for i in range(0, v):
    G[i] = []
for i in range(n):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)
    edges.add((s, t))
WHITE = 0
BLACK = 2

color = [WHITE] * (v)
parent = [0] * (v)
ord = [0] * (v)
low = [0] * (v)
parent = [0] * (v)
bridge()
if br:
    for ans in sorted(br):
        print(*ans, sep=' ')



Fixed submission:
import sys

from collections import deque
sys.setrecursionlimit(1000000)


def dfs(current, prev):
    global time
    # node currentを訪問した直後の処理
    ord[current] = time
    low[current] = time
    time += 1
    color[current] = BLACK

    for next in G[current]:
        if color[next] == WHITE:
            # node currentからnode nextへ訪問する直前の処理
            parent[next] = current
            dfs(next, current)

            # node nextの探索が終了した直後の処理
            low[current] = min(low[current], low[next])
        elif next != prev:
            # edge current --> next がback-edgeの場合の処理
            low[current] = min(low[current], ord[next])


def bridge():
    global time
    time = 1
    dfs(0, -1)  # 0をrootとしてlowの計算
    for u, v in edges:
        if ord[u] < low[v] or ord[v] < low[u]:
            br.add((u, v))


G = {}
edges = set([])
br = set([])
v, n = map(int, input().split())
for i in range(0, v):
    G[i] = []
for i in range(n):
    s, t = map(int, input().split())
    G[s].append(t)
    G[t].append(s)
    edges.add((s, t))
WHITE = 0
BLACK = 2

color = [WHITE] * (v)
parent = [0] * (v)
ord = [0] * (v)
low = [0] * (v)
parent = [0] * (v)
bridge()
if br:
    br = list(map(sorted, br))
    br.sort(key=lambda x: x[1])
    br.sort(key=lambda x: x[0])
    # 安定ソートだからこれができる
    for ans in br:
        print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = [int(input()) for i in range(N)]

sa = R[N - 1] - R[N - 2]
for i in reversed(range(N)):
    for j in reversed(range(i)):
        tmp = R[i] - R[j]
        if tmp > sa:
            sa = tmp
print(sa)


Fixed submission:
N = int(input())

min_v = int(input())
r = int(input())
max_v = r - min_v
if min_v > r:
    min_v = r

for _n in range(2, N):
    r = int(input())
    if max_v < r - min_v:
        max_v = r - min_v
    if min_v > r:
        min_v = r
print(max_v)
Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = int(line[1])
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        d.remove(key)
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

i = 0
while True:
    try:
        if i == 0:
            print(d.popleft(), end='')
        else:
            print(f' {d.popleft()}', end='')
        i += 1
    except IndexError:
        break
print()


Fixed submission:
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    order = input()
    if order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        order, key = order.split()
        if order == 'insert':
            d.appendleft(key)
        elif order == 'delete':
            try:
                d.remove(key)
            except ValueError:
                pass
        else:
            raise ValueError('Invalid order: {order}')

print(' '.join(d))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    line = input().split()
    order = line[0]
    if order in ('insert', 'delete'):
        key = int(line[1])
    if order == 'insert':
        d.appendleft(key)
    elif order == 'delete':
        try:
            d.remove(key)
        except ValueError:
            pass
    elif order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        raise ValueError('Invalid order: {order}')

i = 0
while True:
    try:
        if i == 0:
            print(d.popleft(), end='')
        else:
            print(f' {d.popleft()}', end='')
        i += 1
    except IndexError:
        break
print()


Fixed submission:
from collections import deque

n = int(input())
d = deque()
for _i in range(n):
    order = input()
    if order == 'deleteFirst':
        d.popleft()
    elif order == 'deleteLast':
        d.pop()
    else:
        order, key = order.split()
        if order == 'insert':
            d.appendleft(key)
        elif order == 'delete':
            try:
                d.remove(key)
            except ValueError:
                pass
        else:
            raise ValueError('Invalid order: {order}')

print(' '.join(d))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


count = 0
for t in T:
    S.append(t)
    i = 0
    while t != S[i]:
        i += 1
    if i != (len(S) - 1):
        count += 1
    S.pop()
print(count)



Fixed submission:
from typing import List
import math

N = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]


def binary_search(A: List[int], key: int) -> int:
    left = 0
    right = len(A)
    while left < right:
        mid = math.floor((left + right) / 2)
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return -1


count = 0
for t in T:
    if binary_search(S, t) != -1:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
data = [int(i) for i in input.split()]
out = ' '.join([str(i) for i in sorted(data)])
print(out)


Fixed submission:
data = [int(i) for i in input().split()]
out = ' '.join([str(i) for i in sorted(data)])
print(out)
Buggy python submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
A = [[0] * m for i in range(n)]
B = [[0] * l for i in range(m)]
C = [[0] * n for i in range(l)]
for i in range(n):
    A[i] = [int(i) for i in input().split()]
for i in range(m):
    B[i] = [int(i) for i in input().split()]

for i in range(n):
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[i][k] * B[k][j]
        C[i][j] = tmp
    print(' '.join(map(str, C[i])))



Fixed submission:

# 提出用のインプット
n, m, l = map(int, input().split())
A = [[0] * m for i in range(n)]
B = [[0] * l for i in range(m)]
C = [[0] * l for i in range(n)]
for i in range(n):
    A[i] = [int(i) for i in input().split()]
for i in range(m):
    B[i] = [int(i) for i in input().split()]

# # 動作確認用のインプット
# with open(file='input_itp1_7_d_1.txt', mode='r', encoding='utf8') as input:
#     n, m, l = map(int, next(input).split())
#     A = [[0] * m for i in range(n)]
#     B = [[0] * l for i in range(m)]
#     C = [[0] * l for i in range(n)]
#     for i in range(n):
#         A[i] = [int(i) for i in next(input).split()]
#     print(A)
#     for i in range(m):
#         B[i] = [int(i) for i in next(input).split()]
#     print(B)

for row in range(n):
    for col in range(l):
        tmp = 0
        for k in range(m):
            tmp += A[row][k] * B[k][col]
        C[row][col] = tmp
    print(' '.join(map(str, C[row])))
Buggy python submission (verdict: Runtime Error):
n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

matrices = [[0 for _ in range(n)] for _ in range(n)]

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = 1

for i in range(n):
    s = ""
    for m in matrices[i]:
        s += str(m) + " "
    print(s)


Fixed submission:
n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

matrices = [["0" for _ in range(n)] for _ in range(n)]

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = "1"

for i in range(n):
    print(" ".join(matrices[i]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
in_list = []
for i in range(n):
    in_list.append(list(map(int, input().split())))

matrices = [["0" for _ in range(n)] for _ in range(n)]

for i in range(n):
    inp = in_list[i]
    u = inp[0]
    k = inp[1]
    for j in range(k):
        m = inp[j+2]
        matrices[i][m-1] = "1"

for i in range(n):
    print(" ".join(matrices[i]))


Fixed submission:
import bisect

n = int(input())
a_list = [int(input()) for i in range(n)]


def lis(n, A):
    L = [0 for i in range(n + 1)]
    L[0] = A[0]
    length = 1
    for i in range(1, n):
        if L[length - 1] < A[i]:
            L[length] = A[i]
            length += 1
        else:
            index = bisect.bisect_left(L, A[i], 0, length - 1)
            L[index] = A[i]
    return length


print(lis(n, a_list))