Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))

cnt = 0
num = 1
G = [1]
while 1:
    if num*3+1 > n:
        break
    G.insert(0, num*3+1)
    num = num*3 + 1
m = num

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

print m
for i in range(m):
    if i == m-1:
        print G[i]
    else:
        print G[i],
        
print cnt

for i in range(n):
    print a[i]

Fixed submission:
n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))

cnt = 0
num = 1
G = [1]
while 1:
    if num*3+1 > n:
        break
    G.insert(0, num*3+1)
    num = num*3 + 1
m = len(G)

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

for i in range(m):
    cnt = insertionSort(a, n, G[i], cnt)

print m
for i in range(m):
    if i == m-1:
        print G[i]
    else:
        print G[i],
        
print cnt

for i in range(n):
    print a[i]
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())
if n > 1:
    s = map(int, raw_input().split())
else:
    s = int(raw_input())
    
q = int(raw_input())
if q > 1:
    t = map(int, raw_input().split())
else:
    t = [int(raw_input())]

count = 0
for i in range(q):
    tmp = int(n/2)
    gap = 1./2
    flag = 0
    if t[i] < s[0] or t[i] > s[n-1]:
        continue
    else:
        while True:
            if s[tmp] < t[i]:
                tmp = tmp + int(n*gap)
            elif s[tmp] > t[i]:
                tmp = tmp - int(n*gap)
            else:
                count += 1
                break
            if int(gap*n) == 1 and flag == 0:
                flag = 1
                continue
            elif int(gap*n) < 1:
                break
            gap *= 1./2
        
print count 

Fixed submission:
n = int(raw_input())
if n > 1:
    s = map(int, raw_input().split())
else:
    s = int(raw_input())
    
q = int(raw_input())
if q > 1:
    t = map(int, raw_input().split())
else:
    t = [int(raw_input())]

# f = open('ALDS1_4_B-in8.txt', 'r')
# data = f.readlines()
# n = int(data[0])
# s = map(int, data[1].split())
# q = int(data[2])
# t = map(int, data[3].split())

def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = int((left + right)/2)
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False

count = 0
for i in range(q):
    if binarySearch(s, t[i]):
        count += 1
print count
Buggy python submission (verdict: Time Limit Exceeded):
n = int(raw_input())

dict = []
for i in range(n):
    command, word = raw_input().split()
    if command == 'insert':
        dict.append(word)
    else:
        try:
            dict.index(word)
            print 'yes'
        except:
            print 'no'
            pass
        

Fixed submission:
n = int(raw_input())

def makeHash(letter):
    if letter == 'A':
        return 1
    elif letter == 'C':
        return 2
    elif letter == 'G':
        return 3
    elif letter == 'T':
        return 4
    return 0

dict = {}
for i in range(n):
    command, word = raw_input().split()
    key = 0
    if command == 'insert':
         dict[word] = 1
    elif command == 'find':
        if word in dict: 
            print 'yes'
        else:
            print 'no'
Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    PT = []
    for i in range(N):
        PT.append(map(int, raw_input().split()))
    Max = 0
    (S, T) = map(int, raw_input().split())
    for i in range(1, W+1):
        for j in range(1, H+1):
            cnt = 0
            for w in range(i, i+S):
                for t in range(j, j+T):
                    if [w, t] in PT:
                        cnt += 1
            if Max < cnt:
                Max = cnt
    print Max

    N = int(raw_input())

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    E = [[0]*H for i in range(W)]
    for i in range(N):
        (x, y) = map(int, raw_input().split())
        E[x-1][y-1] = 1
    (S, T) = map(int, raw_input().split())

    Max = 0
    for i in range(W-S+1):
        for j in range(H-T+1):
            Sum = 0
            for k in range(S):
                for l in range(T):
                    Sum += E[i+k][j+l]
            if Sum > Max:
                Max = Sum
    print Max
    N = int(raw_input())

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    PT = []
    for i in range(N):
        PT.append(map(int, raw_input().split()))
    Max = 0
    (S, T) = map(int, raw_input().split())
    PT.sort()
    for i in range(1, W+1):
        for j in range(1, H+1):
            cnt = 0
            for k in range(N):
                if i <= PT[k][0] and PT[k][0] < i+S and \
                        j <= PT[k][1] and PT[k][1] < j+T:
                            cnt += 1
            if Max < cnt:
                Max = cnt
    print Max

    N = int(raw_input())

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    E = [[0]*H for i in range(W)]
    for i in range(N):
        (x, y) = map(int, raw_input().split())
        E[x-1][y-1] = 1
    (S, T) = map(int, raw_input().split())

    Max = 0
    for i in range(W-S+1):
        for j in range(H-T+1):
            Sum = 0
            for k in range(S):
                for l in range(T):
                    Sum += E[i+k][j+l]
            if Sum > Max:
                Max = Sum
    print Max
    N = int(raw_input())
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

while 1:
    ans = 0
    (w, h) = map(int, raw_input().split())
    used = [[False]*w for i in range(h)]
    if h == 0:break
    que = [[0, 0, 1]]
    vir = []
    hor = []
    for i in range(h):
        vir.append(map(int, raw_input().split()))
        if i == h-1:break
        hor.append(map(int, raw_input().split()))
    while que!=[]:
        y = que[0][0]
        x = que[0][1]
        cost = que[0][2]
        used[y][x] = True
        que.pop(0)
        if y==h-1 and x==w-1:
            ans = cost
            break
        if x+1 < w and used[y][x+1] == False and vir[y][x] == 0:
            que.append([y, x+1, cost+1])
        if x-1 >= 0 and used[y][x-1] == False and vir[y][x-1] == 0:
            que.append([y, x-1, cost+1])
        if y+1 < h and used[y+1][x] == False and hor[y][x] == 0:
            que.append([y+1, x, cost+1])
        if y-1 >= 0 and used[y-1][x] == False and hor[y-1][x] == 0:
            que.append([y-1, x, cost+1])
    print ans
    

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

while 1:
    ans = 0
    (w, h) = map(int, raw_input().split())
    used = [[False]*w for i in range(h)]
    if h == 0:break
    que = [[0, 0, 1]]
    used[0][0] = True
    vir = []
    hor = []
    for i in range(h):
        vir.append(map(int, raw_input().split()))
        if i == h-1:break
        hor.append(map(int, raw_input().split()))
    while que!=[]:
        y = que[0][0]
        x = que[0][1]
        cost = que[0][2]
        que.pop(0)
        if y==h-1 and x==w-1:
            ans = cost
            break
        if x+1 < w and used[y][x+1] == False and vir[y][x] == 0:
            que.append([y, x+1, cost+1])
            used[y][x+1] = True
        if x-1 >= 0 and used[y][x-1] == False and vir[y][x-1] == 0:
            que.append([y, x-1, cost+1])
            used[y][x-1] = True
        if y+1 < h and used[y+1][x] == False and hor[y][x] == 0:
            que.append([y+1, x, cost+1])
            used[y+1][x] = True
        if y-1 >= 0 and used[y-1][x] == False and hor[y-1][x] == 0:
            que.append([y-1, x, cost+1])
            used[y-1][x] = True
    print ans
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    (n, w) = map(int, raw_input().split())
    if n == 0: break

    vcnt = [0]*10
    vr = 0
    for i in range(n):
        v = int(raw_input())
        if v/w > vr:
            vr = v/w
        vcnt[v/w] += 1
    
    vmax = max(vcnt)
    ans = 0
    for i in range(10):
        ans += ((vr-i)/float(vr))*(vcnt[i]/float(vmax))

    print ans+0.01

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    (n, w) = map(int, raw_input().split())
    if n == 0: break

    vcnt = [0]*11
    vr = 0
    for i in range(n):
        v = int(raw_input())
        if v/w > vr:
            vr = v/w
        vcnt[v/w] += 1
    
    vmax = max(vcnt)
    ans = 0
    for i in range(11):
        ans += ((vr-i)/float(vr))*(vcnt[i]/float(vmax))

    print ans+0.01
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

def change(val):
    v500 = val/500
    v100 = (val-v500)/100
    v50 = (val%100)/50
    v10 = (val%50)/10
    return v10+v50+v100+v500

n = int(raw_input())
cnt = 0
while n!=0:
    if cnt > 0:
        print
    (c10, c50, c100, c500) = map(int, raw_input().split())
    Min = 1000000
    a10=0
    a50=0
    a100=0
    a500=0
    for i1 in range(c10+1):
        for i2 in range(c50+1):
            for i3 in range(c100+1):
                for i4 in range(c500+1):
                    Sumc = i1+i2+i3+i4
                    Sumv = i1*10+i2*50+i3*100+i4*500
                    if Sumv >= n:
                        Re = change(Sumv-n)
                        if Min > Re-Sumc:
                            Min = Re-Sumc
                            a10 = i1
                            a50 = i2
                            a100 = i3
                            a500 = i4
    if a10 > 0:
        print 10, a10
    if a50 > 0:
        print 50, a50
    if a100 > 0:
        print 100, a100
    if a500 > 0:
        print 500, a500
    
    n = int(raw_input())
    cnt += 1

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

n = int(raw_input())
cnt = 0
while n!=0:
    if cnt > 0:
        print
    (c10, c50, c100, c500) = map(int, raw_input().split())
    Sum = 10*c10+50*c50+100*c100+500*c500
    while Sum-500 >= n:
        Sum -= 500
        c500 -= 1
    while Sum-100 >= n:
        Sum -= 100
        c100 -= 1
    while Sum-50 >= n:
        Sum -= 50
        c50 -= 1
    while Sum-10 >= n:
        Sum -= 10
        c10 -= 1

    if c10 > 0:
        print 10, c10
    if c50 > 0:
        print 50, c50
    if c100 > 0:
        print 100, c100
    if c500 > 0:
        print 500, c500

    n = int(raw_input())
    cnt += 1
Buggy python submission (verdict: Runtime Error):
while 1:
    n=map(int,input().split())
    print(n[0]+n[1])
except EOFError:
    break

Fixed submission:
# coding: utf-8
# Here your code !
while 1:
    try:
     n=list(map(int,input().split()))
     print(n[0]+n[1])
    except EOFError:
        break

Buggy python submission (verdict: Runtime Error):
while 1:
    try:
     n=map(int,input().split())
     print(n[0]+n[1])
except EOFError:
    break

Fixed submission:
# coding: utf-8
# Here your code !
while 1:
    try:
     n=list(map(int,input().split()))
     print(n[0]+n[1])
    except EOFError:
        break
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !
def mcg(a,b):
    while a%b !=0:
        x = a%b
        a = b
        b = x
    return x

num =sorted(list(map(int,input().split(" "))))
print(mcg(num[0],num[1]))

Fixed submission:
# coding: utf-8
# Here your code !
def mcg(a,b):
    if a==b:
        return a
    else:
        
        while a%b !=0:
            x = a%b
            a = b
            b = x
        return x

num =sorted(list(map(int,input().split(" "))))
print(mcg(num[0],num[1]))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Here your code !
import math
i = input()
count=0

for m in range(int(i)):
    num = int(input())
    arr=[]
    #print(num)
    sq = math.sqrt(num)
    for n in range(1,num):
        if num%n==0:
            arr.append(n)   
    if len(arr)==1:
        count+=1
print(count)

Fixed submission:
# coding: utf-8
# Here your code !
import math
i = input()
count=0

def isPrime(x):
    global count
    if x == 2:
        return True
    if x>2 and x%2==0:
        return False
    i = 3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i+=2
    return True

for j in range(int(i)):
    j=int(input())
    if isPrime(j):
        count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Here your code !
import math
i = input()
count=0

for m in range(int(i)):
    num = int(input())
    arr=[]
    #print(num)
    sq = math.sqrt(num)
    for n in range(1,num):
        if num%n==0:
            arr.append(n)   
    if len(arr)==1:
        count+=1
print(count)

Fixed submission:
# coding: utf-8
# Here your code !
import math
i = input()
count=0

def isPrime(x):
    global count
    if x == 2:
        return True
    if x>2 and x%2==0:
        return False
    i = 3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i+=2
    return True

for j in range(int(i)):
    j=int(input())
    if isPrime(j):
        count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Here your code !
prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max =li[1]-li[0]

while len(li)>1:
    for i in range(len(li)):
        if li[i]-li[0]>max and i!=0:
            max= li[i]-li[0]
    li=li[1:]
    
print(max)

Fixed submission:
# coding: utf-8
# Here your code !
import math
prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max=float("-inf")
min=li[0]
for j in range(1,d):
    if li[j]-min>max:
        max=li[j]-min
    if li[j]<min:
        min=li[j]

print(max)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        deq.remove(n[1])
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))

Fixed submission:
# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
dict=[]
for i in range(N):
    a=input().split()
    if a[0]=="insert":
        dict.append(a[1])
    elif a[0]=="find":
        if a[1] in dict:
            print("yes")
        else:
            print("no")

Fixed submission:
# coding: utf-8
# Here your code !
N=int(input())
dict={}
for i in range(N):
    a,b=input().split()
    if a=="insert":
        dict[b]=i
    else:
        if b in dict:
            print("yes")
        else:
            print("no")
Buggy python submission (verdict: Runtime Error):
M, N = map(int, raw_input().split())
K = input()

d = {}

for i in range(M):
    a = raw_input()
    for j in range(N):
        d[i+1, j+1] = a[j]

for _ in range(K):
    b = map(int, raw_input().split())
    D = {}
    D['J'] = D['O'] = D['I'] = 0
    for i in range(b[0], b[2]+1):
        for j in range(b[1], b[3]+1):
            D[d[i, j]] += 1
    print D['J'], D['O'], D['I']

Fixed submission:
from array import array

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

D0 = [array('l', [0]) * (N+1) for _ in xrange(M+1)]
D1 = [array('l', [0]) * (N+1) for _ in xrange(M+1)]

for i in xrange(1, M+1):
    a = raw_input()
    for j in xrange(1, N+1):
        D0[i][j] = D0[i-1][j] + D0[i][j-1] - D0[i-1][j-1] + (a[j-1] == 'J')
        D1[i][j] = D1[i-1][j] + D1[i][j-1] - D1[i-1][j-1] + (a[j-1] == 'O')

for _ in xrange(K):
    b0, b1, b2, b3 = map(int, raw_input().split())
    nJ = D0[b2][b3]-D0[b0-1][b3]-D0[b2][b1-1]+D0[b0-1][b1-1]
    nO = D1[b2][b3]-D1[b0-1][b3]-D1[b2][b1-1]+D1[b0-1][b1-1]
    nI = (b2-b0+1)*(b3-b1+1)-nJ-nO
    print nJ, nO, nI
Buggy python submission (verdict: Runtime Error):
x = int(raw_input(x))
print x*x*x

Fixed submission:
x = int(raw_input())
print x*x*x
Buggy python submission (verdict: Runtime Error):
a = raw_input()
b, c, d = a.split()
B = int(b)
C = int(c); D = int(d)

if x <= y <= z: print x, y, z

Fixed submission:
a = raw_input()
b, c, d = a.split()
x = int(b)
y = int(c); z = int(d)
  
if x <= y <= z: print x, y, z
elif x <= y > z: print x, z, y
elif y <= x <= z: print y, x, z
elif y < z <= x: print y, z, x
elif y < x: print z, y, x
else: print z, x, y

Buggy python submission (verdict: Runtime Error):
a = raw_input()
b, c, d = a.split()
B = int(b)
C = int(c); D = int(d)
 
if x <= y <= z: print x, y, z
elif x <= y > z: print x, z, y
elif y <= x <= z: print y, x, z
elif y < z <= x: print y, z, x
elif y < x: print z, y, x
else: print z, x, y

Fixed submission:
a = raw_input()
b, c, d = a.split()
x = int(b)
y = int(c); z = int(d)
  
if x <= y <= z: print x, y, z
elif x <= y > z: print x, z, y
elif y <= x <= z: print y, x, z
elif y < z <= x: print y, z, x
elif y < x: print z, y, x
else: print z, x, y
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import deque
n = int(input())
d = [-1] * (n + 1)
def bfs():
    d[1] = 0
    dq = deque([1])
    while len(dq) != 0:
        v = dq.popleft()
        for c in G[v]:
            if d[c] != -1 : continue
            d[c] = d[v] + 1
            dq.append(c)
    for i, x in enumerate(d[1:], start=1):
        print(i, x)
G = [0] + [list(map(int, inpput().split()[2:])) for i in range(n)]
bfs()

Fixed submission:
from collections import deque
def MAIN():
    n = int(input())
    li = [[] for _ in range(n + 1)]
    ans = [[i, -1] for i in range(n + 1)]
    ans[1][1] = 0
    for _ in range(n):
        u, k, *v = map(int, input().split())
        li[u] = v
    dp = deque([1])
    while dp:
        u = dp.popleft()
        for v in li[u]:
            if ans[v][1] == -1:
                ans[v][1] = ans[u][1] + 1
                dp.append(v)
    for d in ans[1:]:
        print(*d)
MAIN()
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
            return
        f2(li[a], b)
        li[a] = b
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        elif f(x) < f(y):
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
		print("yes" if f(a) == f(b) else "no")
MAIN()



Fixed submission:
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
        else:
            f2(li[a], b)
            li[a] = b
    def solve(a, b):
        if f(a) == f(b):
            return "yes"
        return "no"
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        else:
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print(solve(x, y))
MAIN()

Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
            return
        f2(li[a], b)
        li[a] = b
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        elif f(x) < f(y):
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print("yes" if f(a) == f(b) else "no")
MAIN()



Fixed submission:
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
        else:
            f2(li[a], b)
            li[a] = b
    def solve(a, b):
        if f(a) == f(b):
            return "yes"
        return "no"
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        else:
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print(solve(x, y))
MAIN()
Buggy python submission (verdict: Time Limit Exceeded):
def MAIN():
    T = input()
    Q = int(input())
    P = ""
    for _ in range(Q):
        P = input()
        print(1 if P in T else 0)
MAIN()



Fixed submission:
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
    dl = tl - pl
    tmp = set()
    t = 1
    for _ in range(pl):
        t = (t * base) & mask
    e = 0
    for i in range(pl):
        e = (e * base + f[i]) & mask
    for i in range(dl):
        tmp.add(e)
        e = (e * base - t * f[i] + f[i + pl]) & mask
    tmp.add(e)
    return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
    p = input()
    if p in c:
        a.append(c[p])
        continue
    p = tuple(ord(c) for c in p)
    pl = len(p)
    if pl > tl:
        a.append("0")
        continue
    bs = min(19, pl)
    keys = calc_hash(p, bs, pl)
    if bs not in h:
        h[bs] = calc_hash(t, bs, tl)
    a.append("1" if keys <= h[bs] else "0")
print('\n'.join(a))
Buggy python submission (verdict: Runtime Error):
def insertionSort(n, A):
    print(*A)
    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A)
n = int(readline())
A = [int(j) for j in readline().split(" ")]
insertionSort(n, A)

Fixed submission:
def insertionSort(A, N):
    print(*A)
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A)
n = int(input())
A = list(map(int, input().split()))
insertionSort(A, n)
Buggy python submission (verdict: Time Limit Exceeded):
prime = set([2])
for i in range(3, 100000000, 2):
    for j in prime:
        if i % j == 0:
            break
    else:
        prime.add(i)
n = int(input())
cnt = 0
for i in (int(input()) for _ in range(n)):
    if i in prime:
        cnt += 1
print(cnt)


Fixed submission:
from sys import stdin
import math
def isPrime(x):
    if x == 2 or x == 3: return True
    elif (x < 2 or x % 2 == 0 or x % 3 == 0): return False
    s = int(math.sqrt(x) + 1)
    for i in range(5, s + 1, 2):
        if x % i == 0: return False
    return True
print(sum([isPrime(int(stdin.readline())) for _ in range(int(stdin.readline()))]))