Problem:


Insertion Sort

Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:

for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key

Note that, indices for array elements are based on 0-origin.

To illustrate the algorithms, your program should trace intermediate result for each step.

Input

The first line of the input includes an integer N, the number of elements in the sequence.

In the second line, N elements of the sequence are given separated by a single space.

Output

The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.

Constraints

1 ≤ N ≤ 100

Sample Input 1

6
5 2 4 6 1 3

Sample Output 1

5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3
1 2 3
1 2 3

Hint

Template in C



Sample input:
6
5 2 4 6 1 3


Sample output:
5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, raw_input().split()))
for i in range(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(" ".join(str(s) for s in a)

Submission status: Runtime Error

Solution code:

from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = raw_input()
        unsorted_array = list(map(int, raw_input().split()))

        for i in range(1, array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(str(i) for i in unsorted_array))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()

Submission status: Runtime Error

Solution code:

from __future__ import print_function


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def insertion_sort():
        # write your code here
        array_length = int(raw_input())
        unsorted_array = map(int, raw_input().line.strip().split(" "))

        for i in range(1, array_length):
            v = unsorted_array[i]
            j = i - 1
            while j >= 0 and unsorted_array[j] > v:
                unsorted_array[j + 1] = unsorted_array[j]
                j -= 1
            unsorted_array[j + 1] = v
            print(" ".join(str(i) for i in unsorted_array))


if __name__ == '__main__':
    solution = Solution()
    solution.insertion_sort()

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i input().split()]

for i in range(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(" ".join(map(int, a)))

Submission status: Runtime Error

Solution code:
def insertion_sort(A, N):
  for i in range(len(N):
    v = A[i]
    j = i - 1
    while j >= 0 and a[j] > v:
      A[j + 1] = A[j]
      j--
    A[j + 1] = v

if __name__=='__main__':
   n=int(input()) 
   A=list(map(int,input().split()))
   insertion_sort(A)
   print(*A)

Submission status: Runtime Error

Solution code:
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)

for i in range(N):
    v = card[i]
    j = i - 1
    while j >= 0 and card[j] > v:
        card[j+1] = card[j]
        j = j -1
    card[j+1] = v
    #print(card)
    card_str = ""
    
    for k in range(N-1):
        card_str += str(card[k])
        card_str += " "
    card_str += str(card[k+1])
    print(card_str)

Submission status: Runtime Error

Solution code:
#input number
n = raw_input()

if n < 1 and n > 100:
	exit()

# input elements
l = raw_input()

elements = l.split()

for e in elements:
	o += str(e) + ' '
print o

for i in range(1, int(n)):
	key = elements[i]
	j = i - 1
	while j >= 0 and elements[j] > key:
		elements[j + 1] = elements[j]
		j -= 1
	elements[j + 1] = key
	# output
	o = ''
	for e in elements:
		o += str(e) + ' '
	print o

Submission status: Runtime Error

Solution code:
# coding:utf-8

def insert_sort(list):
    for i in range(1, n):
        temp = list[i] # ?§??????????????´?
        while i>=1 and temp<list[i-1]: list[i]=list[i-1] ; i-=1
        list[i] = temp
        s = " ".join(list) ; print(s)
    s = " ".join(list) ; print(s)

n=int(input())
buff = list(map(int,input().split()))
insert_sort(buff)

Submission status: Runtime Error

Solution code:
def insertion_sort(target_list, leng):
    '????????????????????????????????\???????????§??????????????????????????¨?????????'
    sorted_list = [target_list.pop(0)]
    for target in target_list[:]:
        print(('{} ' * (leng - 1)).format(*sorted_list,
                                          *target_list[0:-1]), end='')
        print(target_list[-1])
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
    print(('{} ' * (N - 1)).format(*sorted_list[0:-1]), end='')
    print(sorted_list[-1], end='')
N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A, N)

Submission status: Runtime Error

Solution code:
def insertion_sort(target_list, leng):
    sorted_list = [target_list.pop(0)]
    for target in target_list[:]:
        print(('{} ' * (leng - 1)).format(*sorted_list,
                                          *target_list[0:-1]), end='')
        print(target_list[-1])
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
    print(('{} ' * (N - 1)).format(*sorted_list[0:-1]), end='')
    print(sorted_list[-1], end='')

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A, N)

Submission status: Runtime Error

Solution code:
def insertion_sort(target_list, leng):
    '????????????????????????????????\???????????§??????????????????????????¨?????????'
    sorted_list = [target_list.pop(0)]
    for target in target_list[:]:
        print(('{} ' * (leng - 1)).format(*sorted_list, *target_list[0:-1]), end='')
        print(target_list[-1])
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
    print(('{} ' * (N - 1)).format(*sorted_list[0:-1]), end='')
    print(sorted_list[-1], end='')

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A, N)

Submission status: Runtime Error

Solution code:
class sort:
    def __init__(self, num):
        self.num = num
 
    def insert(self, lst):
        print(*lst)
        for i in range(1,self.num):
            j = i - 1
            while (j >= 0) * (lst[j] > lst[i]):
                j -= 1
            lst[j+1:i+1] = lst[i] , *lst[j+1:i]
            print(*lst)

sort(int(input())).insert(list(map(int,input().split())))

Submission status: Runtime Error

Solution code:
class sort:
    def __init__(self, num):
        self.num = num
 
    def insert(self, lst):
        print(*lst)
        for i in range(1,self.num):
            j = i - 1
            while (j >= 0) * (lst[j] > lst[i]):
                j -= 1
            lst[j+1:i+1] = lst[i] , *lst[j+1:i]
            print(*lst)

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

s = sort(n)
s.insert(l)

Submission status: Runtime Error

Solution code:
class sort1:
    def __init__(self, num):
        self.num = num
 
    def p_insert(self, lst):
        print(*lst)
        for i in range(1,self.num):
            j = i - 1
            while (j >= 0) * (lst[j] > lst[i]):
                j -= 1
            lst[j+1:i+1] = lst[i] , *lst[j+1:i]
            print(*lst)

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

s = sort1(n)
s.p_insert(l)

Submission status: Runtime Error

Solution code:
input()
lst = input().split()
for i in range(len(lst)):
    j = i - 1
    while (j >= 0) * (lst[j] > lst[i]):
        j -= 1
    lst[j+1:i+1] = lst[i] , *lst[j+1:i]
    print(*lst)

Submission status: Runtime Error

Solution code:
input()
lst = list(map(int,input().split()))
for i in range(len(lst)):
    j = i - 1
    while (j >= 0) * (lst[j] > lst[i]):
        j -= 1
    lst[j+1:i+1] = lst[i] , *lst[j+1:i]
    print(*lst)

Submission status: Runtime Error

Solution code:
input()
lst = list(map(int,input().split()))
for i in range(len(lst)):
    j = min(0, i-1)
    while (j >= 0) * (lst[j] > lst[i]):
        j -= 1
    lst[j+1:i+1] = lst[i] , *lst[j+1:i]
    print(*lst)

Submission status: Runtime Error

Solution code:
n = int(input())
lst = list(map(int, input().split()))
print(*lst)
for i in range(1,n):
    j = i-1
    while j >= 0 and lst[j] > lst[i]:
        j -= 1
    lst[j+1:i+1] = lst[i] , *lst[j+1:i]
    print(*lst)

Submission status: Runtime Error

Solution code:
def insertionSort(lis,leng):
    for i in range(leng):
        v = lis[i]
        j = i - 1
        while j >= 0 and lis[j] > v:
            lis[j+1] = lis[j]
            j = j-1
        lis[j+1]=v
        print("".join(lis))

        
if __name__ == "__main__":
    leng=int(input())
    lis=map(int,input().split())
    insertionSort(lis,leng)

Submission status: Runtime Error

Solution code:
def insertionSort(lis,leng):
    for i in range(leng):
        v = lis[i]
        j = i - 1
        while j >= 0 and lis[j] > v:
            lis[j+1] = lis[j]
            j = j-1
        lis[j+1]=v
        print("".join(lis))

        
if __name__ == "__main__":
    lengg=int(input())
    liss=map(int,input().split())
    insertionSort(liss,lengg)

Submission status: Runtime Error

Solution code:
def insertionSort(lis,leng):
    for i in range(leng):
        v = lis[i]
        j = i - 1
        while j >= 0 and lis[j] > v:
            lis[j+1] = lis[j]
            j = j-1
        lis[j+1]=v
        print("".join(lis))

        
if __name__ == "__main__":
    lengg=int(input())
    liss=list(map(int,input().split()))
    insertionSort(liss,lengg)

Submission status: Runtime Error

Solution code:
N = int(input())

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

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
	B = [print(" ".join({A[k]})) for k in range(N)]

Submission status: Runtime Error

Solution code:
N = int(input())

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

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
	B = [print(" ".join(A[k])) for k in range(N)]

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)+1):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key

Submission status: Runtime Error

Solution code:
N = input()
A = map(int,raw_input().split())

for i in range(N-1):
        print A[i],
    print A[-1]

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
    for i in range(N-1):
        print A[i],
    print A[-1]

Submission status: Runtime Error

Solution code:
import sys

def echo(A):
    for i, a in enumerate(A):
        if i < len(A) - 1:
            sys.stdout('%d ' % a)
        else:
            sys.stdout('%d\n' % a)

def insertionSort(A, N):
    echo(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
        echo(A)

if __name__ == '__main__':
    n = raw_input()
    a = raw_input()
    insertionSort(a, n)

Submission status: Runtime Error

Solution code:
import sys

def echo(A):
    for i, a in enumerate(A):
        if i < len(A) - 1:
            sys.stdout('%d ' % a)
        else:
            sys.stdout('%d\n' % a)

def insertionSort(A, N):
    echo(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
        echo(A)


n = raw_input()
a = raw_input()
insertionSort(a, n)

Submission status: Runtime Error

Solution code:
import sys, re

def echo(A):
    for i, a in enumerate(A):
        if i < len(A) - 1:
            sys.stdout('%d ' % a)
        else:
            sys.stdout('%d\n' % a)

def insertionSort(A, N):
    echo(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
        echo(A)


n = int(raw_input())
a_text = raw_input()
splits = re.split(a_text)
a = []
for i, s in enumerate(splits): 
    if s:
        a.append(int(s))

insertionSort(a, n)

Submission status: Runtime Error

Solution code:
import sys, re

def echo(A):
    for i, a in enumerate(A):
        if i < len(A) - 1:
            sys.stdout('%d ' % a)
        else:
            sys.stdout('%d\n' % a)

def insertionSort(A, N):
    echo(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
        echo(A)


n = int(raw_input())
a_text = raw_input()
splits = re.split(' ', a_text)
a = []
for i, s in enumerate(splits): 
    if s:
        a.append(int(s))

insertionSort(a, n)

Submission status: Runtime Error

Solution code:
n = input()
lst = list(map(int,input().split())
for i in range(n):
    key = lst[i]
    j = i-1
    while j >= 0 and lst[j] > key:
        lst[j+1] = lst[j]
        j -= 1
    lst[j+1] = key
    print(' '.join(map(str,lst)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int,input().split())
for i in range(1,n):
    key = a[i]
    j = i-1
    while j >=0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = key
    print(' '.join(map(str,a)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split().strip())
for i in range(n):
    key = a[i]
    j = i - 1
    while j >= 0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = key
    print(' '.join(map(str,a)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().strip().split())
for i in range(n):
    key = a[i]
    j = i -1
    while j > 0 and a[j] > key:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = key
    print(' '.join(map(str,a)))

Submission status: Runtime Error

Solution code:
def insertionSort(N,A):
    for i in range(0,N):
        innum = A[i]
        j = j -1
        while j>0 and A[i] > innum:
            A[j+1] = A[j]
            j = j -1
        A[j+1] = innum
        B[k] = A
    return B

if __name__ == "__main__":
    N = input()
    A = input()
    for i in range(0,B.length()):
        print(B[i])

Submission status: Runtime Error

Solution code:

l = input
A = input().strip()

for i in range(1,l):
    j = i-1
    v = A[i]
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
        
    A[j+1] = v
    
    s = [str(a) for a in A]
    
    print(' '.join(s))

Submission status: Runtime Error

Solution code:

l = input
A = input().strip()

for i in xrange(1,l):
    j = i-1
    v = A[i]
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
        
    A[j+1] = v
    
    s = [str(a) for a in A]
    
    print(' '.join(s))

Submission status: Runtime Error

Solution code:

l = int(input)
A = [ int(x) for x in  input().strip()]

for i in xrange(1,l):
    j = i-1
    v = A[i]
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
        
    A[j+1] = v
    
    s = [str(a) for a in A]
    
    print(' '.join(s))

Submission status: Runtime Error

Solution code:
def insertionSort(*args):
    l = list(args)
    for i in range(1, n):
        v = l[i]
        j = i - 1
        while j >= 0 and l[j] > v:
            l[j + 1] = l[j]
            j -= 1
            l[j + 1] = v
            print ' '.join(map(str, l))

n = input()
l = [input() for i in range(n)]
insertionSort(*l)

Submission status: Runtime Error

Solution code:
n=int(input())
z=list(map(int,input().split()))
for i in range(1,n):
    v=z[i]
    j=i-1
    while j>=0 and z[j]>v:
        z[j+1]=z[j]
        j-=1
        
    z[j+1]=v
    print(''.join(z))

Submission status: Runtime Error

Solution code:
def output(list):
    for i,row in enumerate(list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    

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

output(list)
print()

#print(list)
start = time.time()
i = 0
for count in range(len(list)-1):

#   Judge: now > next
    if list[i] > list[i+1]:

#       Change: now > next
        ins_num = list[i+1]
        list[i+1] = list[i]
        list[i]   = ins_num

        j = i - 1

        while j >= 0:
            if list[j] > ins_num:
                list[j+1] = list[j]
                list[j]   = ins_num

            j -= 1
        output(list)
    else:
        output(list)        
    
    print()
    i += 1

Submission status: Runtime Error

Solution code:
def output(list):
    for i,row in enumerate(list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    
def main():
    s = input()
    s_list = []
    s_list = list(map(int,input().split()))

    output(s_list)
    print()

#print(list)
    start = time.time()
    i = 0
    for count in range(len(s_list)-1):

#   Judge: now > next
        if s_list[i] > s_list[i+1]:

#       Change: now > next
            ins_num = s_list[i+1]
            s_list[i+1] = s_list[i]
            s_list[i]   = ins_num

            j = i - 1

            while j >= 0:
                if s_list[j] > ins_num:
                    s_list[j+1] = s_list[j]
                    s_list[j]   = ins_num

                j -= 1
            output(s_list)
        else:
           output(s_list)        
    
        print()
        i += 1

    result = time.time() - start
#print(result)
#print(list)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import output
N = int(input())
A = [int(n) for n in input().split()]
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
    output.print_1(A)

Submission status: Runtime Error

Solution code:
import output
N = int(input())
A = [int(n) for n in input().split()]
output.print_1(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
    output.print_1(A)

Submission status: Runtime Error

Solution code:
nums  = int(input())
array = [int(n) for n in input().split()]

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
        array[j+1] = v
        print array

Submission status: Runtime Error

Solution code:
nums  = int(input())
array = list(map(int, input().split()))

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print array

Submission status: Runtime Error

Solution code:
kazu=input()
A=[int(i) for i in range(kazu)]
# kazu=6
# A=[5,2,4,6,1,3]

j=0
for i in range(kazu - 1):
    print(A[i], end=" ")
print(A[kazu-1])

for i in range(1,kazu):
    v=A[i]
    j=i-1

    while j>=0 and A[j] >v:
        A[j+1]=A[j]
        j =j -1
        A[j+1]=v
    for i in range(kazu-1):
        print(A[i],end=" ")
    print(A[kazu-1])

Submission status: Runtime Error

Solution code:
kazu=int(input())
A=[int(i) for i in input().spllit()]
# kazu=6
# A=[5,2,4,6,1,3]

j=0
for i in range(kazu - 1):
    print(A[i], end=" ")
print(A[kazu-1])

for i in range(1,kazu):
    v=A[i]
    j=i-1

    while j>=0 and A[j] >v:
        A[j+1]=A[j]
        j =j -1
        A[j+1]=v
    for i in range(kazu-1):
        print(A[i],end=" ")
    print(A[kazu-1])

Submission status: Runtime Error

Solution code:
#coding: UTF-8

x=[4,50,3,10,89,37,1,15]

for i in range(1,len(x)):

    j=i

    while (j>0) and (x[j-1] > x[j])
:

         tmp=x[j-1]

         x[j-1]=x[j]

         x[j]=tmp

         j -= 1
    print x

print "-"*30

print x

Submission status: Runtime Error

Solution code:
#coding: UTF-8

x=[5,2,6,1,3]

for i in range(1,len(x)):

    j=i

    while (j>0) and (x[j-1] > x[j])
:

         tmp=x[j-1]

         x[j-1]=x[j]

         x[j]=tmp

         j -= 1
    print x

print "-"*30

print x

Submission status: Runtime Error

Solution code:
#coding: UTF-8

x=[4,50,3,10,89,37,1,15]

for i in range(1,len(x)):

    j=i

    while (j>1) and (x[j-1] > x[j])
:

         tmp=x[j-1]

         x[j-1]=x[j]

         x[j]=tmp

         j -= 1
    print x

Submission status: Runtime Error

Solution code:
n = map(int, input())
l = map(int, input().split())

for i in range(n):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key

Submission status: Runtime Error

Solution code:
n = list(map(int, input()))
l = list(map(int, input().split()))

for i in range(n):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key

Submission status: Runtime Error

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]
print(n)
 
for i in range(1,n):
  key = l[i]
  j = i 0 1
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
  print(" ".join(str(x) for x in l))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(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)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(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)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print( array, split = ' ')

for i in range(N):
    for j in reversed(range(i-1)):
        if array[i] < array[j]:
            array[j + 1] = array[j]
        else:
            break
    print( array, split = ' ')

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print( array, split = ' ')

for i in range(N):
    for j in reversed(range(i-1)):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print( array, split = ' ')

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print( array)

for i in range(N):
    for j in reversed(range(i-1)):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print( array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(N):
    for j in reversed(range(i-1)):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N):
    for j in reversed(range(i-1)):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N):
    for j in reversed(range(1, i-1)):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N):
    for j in list(reversed(range(1, i-1))):
        if array[i] > array[j]:
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N):
    for j in list(reversed(range(i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(reversed(1, range(i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(reversed(range(1, i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(reversed(range(1, i-1))):
        if array[i] > array[j]:
            print(*rray)
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(range(1, i-1)):
        if array[i] > array[j]:
            print(*rray)
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(range(1, i-1)):
        if array[i] > array[j]:
        array[j + 1] = array[j]

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in range(1, i-1):
        if array[i] > array[j]:
        array[j + 1] = array[j]

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(reversed(range(1, i-1))):

        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in range(1, i):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    for j in list(reversed(range(1, i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
        else:
            array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())

print(*array)

for i in range(1, N):
    for j in array(reversed(range(1, i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())

print(*array)

for i in range(1, N):
    for j in range(1, i-1):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())

print(*array)

for i in range(1, N):
    for j in list(reversed(range(1, i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
N = int(input())
array = map(int, input().split())

print(*array)

for i in range(1, N):
    for j in list(reversed(range(0, i-1))):
        if array[i] > array[j]:
            array[j + 1] = array[i]
            break
        array[j + 1] = array[j]
    print(*array)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n=int(raw_input())
l=list(map(int, raw_input().split()))
for i in range(1,n+1):
    l[0:i]=sorted(l[0:i])
    print *l

Submission status: Runtime Error

Solution code:
for i in range(1,len(A)-1)
v=A[i]
j=i-1
while(j>0) and (A[j]>v)
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=[1,22,3,1,11]
for i in range(1,len(A)-1)
v=A[i]
j=i-1
while(j>0) and (A[j]>v)
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=[1,22,3,1,11]
for i in range(1,len(A))
v=A[i]
j=i-1
while(j>0) and (A[j]>v)
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=input()
for i in range(1,len(A)-1)
v=A[i]
j=i-1
while(j>0) and (A[j]>v)
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=[5,6,4,1,11]
for i in range(1,len(A)-1)
v=A[i]
j=i-1
while(j>0) and (A[j]>v)
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=[5,6,4,1,11]
for i in range(1,len(A)-1):
v=A[i]
j=i-1
while(j>0) and (A[j]>v):
    A[j+1] = A[j]
    j-=1
A[j+1]=v

Submission status: Runtime Error

Solution code:
A=[5,6,4,1,11]
for i in range(1,len(A)-1):
   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

Submission status: Runtime Error

Solution code:
A=[5,6,4,1,11]

for i in range(1,len(A)-1):
   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

Submission status: Runtime Error

Solution code:
A=[5,2,4,6,1,3]

for i in range(1,len(A)-1):
   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

Submission status: Runtime Error

Solution code:
A = [5,2,4,6,1,3]
for i in range(1, len(A) - 1):
   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

Submission status: Runtime Error

Solution code:
#coding: UTF-8

A = [5,2,4,6,1,3]
for i in range(1, len(A) - 1):
   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

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]

for i in range(len(a)):
    v = a[i]
    j = i 

    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v

print(" ".join(a))

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
print(" ".join(a))

for i in range(len(a)-1):
    v = a[i]
    j = i 

    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(" ".join(a))