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: Wrong Answer

Solution code:
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def insersion_sort(A, N):
    for i in range(1, N):
      for k in A:
        if k==len(A):
          print(k)
        else:
          print(k, " ", sep="", end="")
      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 k in A:
      if k==len(A):
        print(k)
      else:
        print(k, " ", sep="", end="")

N = int(input())
A = list(map(int, input().split()))
Algo.insersion_sort(A, N)

Submission status: Wrong Answer

Solution code:
import sys
def print_list(A):
    for k in range(len(A)):
        sys.stdout.write(str(A[k]))
        if not k == len(A) -1: sys.stdout.write(" ")
    print()
def insert_sort(A,N):
    for i in range(1,N-1):
        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
        print_list(A)
    print_list(A)
    
N = int(input())
A = list(map(int,input().split()))
insert_sort(A,N)

Submission status: Wrong Answer

Solution code:
import sys
def print_list(A):
    for k in range(len(A)):
        sys.stdout.write(str(A[k]))
        if not k == len(A) -1: sys.stdout.write(" ")
    print()
def insert_sort(A,N):
    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 = j-1
        A[j+1]=v
        print_list(A)
    

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    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
        print(*A)

def main():
    print("??°????????\???")
    A = list(map(int,input().split()))
    N = len(A)
    insertionSort(A,N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    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
        print(*A)

def main():
    N = int(input())
    A = list(map(int,input().split()))
    insertionSort(A,N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
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
    print(*A)

Submission status: Wrong Answer

Solution code:
def insertion_sort(A, N):
    for i in range(1, N):
        for s in A:
            tmp = s if A[0] == s else " "+s
            print(tmp, end="")
        print()

        j = i-1
        v = A[i]
        while v < A[j] and j >= 0:
            A[j+1] = A[j]
            j = j-1
        A[j+1] = v
    for s in A:                         
        tmp = s if A[0] == s else " "+s 
        print(tmp, end="")
    print()
    
if __name__ == "__main__":
    N = int(input())
    A = input().split()

    insertion_sort(A, N)

Submission status: Wrong Answer

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=j-1
    a[j+1]=v
print(" ".join(map(str,a)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N = int(input())
	l = input().split()

	for i in range(N):
		l[i] = int(l[i])

	for i in range(1, N - 1):
		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(l[0],l[1],l[2],l[3],l[4],l[5])

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N = int(input())
	l = input().split()

	for i in range(N):
		l[i] = int(l[i])

	for i in range(1, N):
		v = l[i]
		j = i - 1
		print(l[0],l[1],l[2],l[3],l[4],l[5])
		
		while j >= 0 and l[j] > v:
			l[j + 1] = l[j]
			j -= 1
		l[j + 1] = v
		print(l[0],l[1],l[2],l[3],l[4],l[5])

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N = int(input())
	l = input().split()

	for i in range(N):
		l[i] = int(l[i])

	print(l[0],l[1],l[2],l[3],l[4],l[5])
	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(l[0],l[1],l[2],l[3],l[4],l[5])

Submission status: Wrong Answer

Solution code:
def listprint(lists):
	for i in lists:
		print(i,end = '')
	print()

if __name__ == '__main__':
	N = int(input())
	l = input().split()

	for i in range(N):
		l[i] = int(l[i])

	for i in range(1, N):
		v = l[i]
		j = i - 1
		listprint(l)

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

		l[j + 1] = v
		listprint(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def pri(lst):
    for i in range(len(lst)-1):
        print(lst[i],end=" ")
    print(lst[-1])


for i in range(1,n):
    v = lst[i]
    j = i-1
    while True:
        if j < 0:
            lst[0] = v
            break
        if lst[j] > v:
            lst[j+1] = lst[j]
            j -= 1
        else:
            lst[j+1] = v
            break
    pri(lst)

Submission status: Wrong Answer

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

def insertationSort(A,N):
    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 = j - 1
        A[j+1] = v
        print(' '.join(A))

insertationSort(nums,n)

Submission status: Wrong Answer

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

def insertationSort(A,N):
    print(' '.join(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 = j - 1
        A[j+1] = v
        print(' '.join(A))

insertationSort(nums,n)

Submission status: Wrong Answer

Solution code:
def trace(A,input_num):
    for i in range(input_num):
        print(A[i],end = " ")
    print("\n")

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
        
input_num = int(input())
A = list(map(int, input().split()))

trace(A,input_num)

Submission status: Wrong Answer

Solution code:
def trace(A,input_num):
    i = 0
    if i != input_num - 1:   
        for i in range(input_num):
            print(A[i],end = " ")
    else:
        print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: Wrong Answer

Solution code:
def trace(A,input_num):
    i = 0
    for i in range(input_num):
        print(A[i],end = " ")
    

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: Wrong Answer

Solution code:
def trace(A,input_num):
    i = 0
    if i != input_num - 1:
        for i in range(input_num):
            print(A[i],end = " ")
    
    else:
        print(A[i])    

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: Wrong Answer

Solution code:
def trace(A,input_num):
    i = 0
    for i in range(input_num):
        if i != input_num - 1:
            print(A[i-1],end = " ")
        else:
            print(A[i])

def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        trace(A,input_num)
        if i != input_num-1:
            print("\n")
        
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)

Submission status: Wrong Answer

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

for i in range(N):
    num = a[i]
    if i >= 1:
        for j in range(i):
            j = i - j - 1
            if num < a[j]:
                 a[j+1] = a[j]
                 a[j] = num
                 print(a)

Submission status: Wrong Answer

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

for i in range(N):
    num = a[i]
    if i >= 1:
        for j in range(i):
            j = i - j - 1
            if num < a[j]:
                 a[j+1] = a[j]
                 a[j] = num
    print(a)

Submission status: Wrong Answer

Solution code:
def insertionSort(A, N):
    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 (' '.join([str(x) for x in A]))

if __name__ == '__main__':
    length = int(input())
    hoge = [int(x) for x in input().split()]
    insertionSort(hoge, length)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in 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: Wrong Answer

Solution code:
N = int(input())
A_str = input()
A = []
for s in A_str.split():
    A.append(int(s))

for i in range(1, len(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
    print(" ".join(map(str, A)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_str = input()
A = []
for s in A_str.split():
    A.append(int(s))

print(",".join(map(str, A)))
for i in range(1, len(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
    print(",".join(map(str, A)))

Submission status: Wrong Answer

Solution code:
def insertionSort(length, array):
    for i in range(1, length):
        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(' '.join(map(str, array)))

length = int(input())
num_array = [int(x) for x in input().split()]
insertionSort(length, num_array)

Submission status: Wrong Answer

Solution code:
def insertionSort(length, array):
    for i in range(1, length):
        v = array[i]
        j = i - 1
        while j >= 0 and array[j] > v:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = v
        if i < length - 1:
            print(' '.join(map(str, array)))
        else:
            print(' '.join(map(str, array)), end='')

length = int(input())
num_array = [int(x) for x in input().split()]
insertionSort(length, num_array)

Submission status: Wrong Answer

Solution code:
def insertionSort(length, array):
    for i in range(1, length):
        v = array[i]
        j = i - 1
        while j >= 0 and array[j] > v:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = v
        if i < length - 1:
            print(array[i], end=' ')
        else:
            print(array[i])

length = int(input())
num_array = [int(x) for x in input().split()]
insertionSort(length, num_array)

Submission status: Wrong Answer

Solution code:
def show(array):
    for i in range(len(array)):
        if i != len(array) - 1:
            print(array[i], end=' ')
        else:
            print(array[i])

length = int(input())
array = [int(x) for x in input().split()]

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

Submission status: Wrong Answer

Solution code:
def insertinSort(A,N):
    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)

Submission status: Wrong Answer

Solution code:
def insertinSort(A,N):
    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],' ',end='')
        print(A[N-1])

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(N-1):
            print(A[i],end=' ')
    print(A[N-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],end=' ')
        print(A[N-1])

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(N-1):
            print(A[i],end=' ')
    print(A[N-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
        if not i==N-1:
            for i in range(N-1):
                print(A[i],end=' ')
            print(A[N-1])
        else:
            for i in range(N):
                print(A[i],end=' ')

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(N-1):
            print(A[i],end=' ')
    print(A[N-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
        if not i==N-1:
            for i in range(N-1):
                print(A[i],end=' ')
            print(A[N-1])
        else:
            for i in range(N-1):
                print(A[i],end=' ')
            print(A[N-1],end='')

Submission status: Wrong Answer

Solution code:
input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
	sort_line[i] = int(l[i])
	

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

Submission status: Wrong Answer

Solution code:
import sys

input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
	sort_line[i] = int(l[i])
	

for i in range(1, input_len):
	v = sort_line[i]
	j = i - 1
	while (j >= 0 and v < sort_line[j]):
		sort_line[j+1] = sort_line[j]
		j -= 1
	sort_line[j + 1] = v

	for k in range(input_len):
		sys.stdout.write(str(sort_line[k]) + " ")
	print()

Submission status: Wrong Answer

Solution code:
import sys

input_len = int(input())
l = input().split()
sort_line = [0 for i in range(input_len)]
for i in range(input_len):
	sort_line[i] = int(l[i])
	

for k in range(input_len):
	if (k > 0):
		sys.stdout.write(" ")
	sys.stdout.write(str(sort_line[k]))
print()

for i in range(1, input_len):
	v = sort_line[i]
	j = i - 1
	while (j >= 0 and v < sort_line[j]):
		sort_line[j+1] = sort_line[j]
		j -= 1
	sort_line[j + 1] = v

	for k in range(input_len):
		if (k > 0):
			sys.stdout.write(" ")
	sys.stdout.write(str(sort_line[k]))
	print()

Submission status: Wrong Answer

Solution code:
def InsertionSort(A, N):
    ans = ''
    i = 1
    while i < 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
        ans += ' '.join(map(str, A)) + '\n'
        i += 1
    return ans[:-1]

n = int(input())
A = list(map(int, input().split(' ')))
ans = InsertionSort(A, n)
print(ans)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(N):
        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
        print(A)

A = [5,2,4,6,1,3]
insertionSort(A,6)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(N):
        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
        print(A)

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

Submission status: Wrong Answer

Solution code:
n = input()
nums = input()
nums = nums.split()

for idx in range(1, int(n)):
    v = nums[idx]
    j = idx - 1
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    print(' '.join(nums))

Submission status: Wrong Answer

Solution code:
n = input()
nums = input()
nums = nums.split()

print(' '.join(nums))

for idx in range(1, int(n)):
    v = nums[idx]
    j = idx - 1
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    print(' '.join(nums))

Submission status: Wrong Answer

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

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

	print(*a)

Submission status: Wrong Answer

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

	print(*a)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

num = int(raw_input())
elems = raw_input().split(' ')
lst = []
for elem in elems:
    lst.append(elem)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

num = int(raw_input())
elems = raw_input().split(' ')
lst = []
for elem in elems:
    lst.append(elem)

for i in range(1, len(lst)):
    v = lst[i]
    j = i - 1
    while j >= 0 and lst[j] > v:
        lst[j+1] = lst[j]
        j -= 1
    lst[j+1] = v
    for k in range(0, len(lst)):
        if not k == len(lst) - 1:
            print lst[k],
        else:
            print lst[k]

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
  for i in range(1,len(A)):
      j = i
      while (j > 0) and (A[j-1] > A[j]) :
          tmp = A[j-1]
          A[j-1] = A[j]
          A[j] = tmp
          j -= 1
      print(' '.join(map(str, A)))
 
N = input()
N = int(N)
A = input()
A = list(map(int, A.split()))
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def Insertion_Sort(A, N):
    A = list(map(int, A.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
        print(" ".join(map(str,A)))

N = int(input())
A = input()
Insertion_Sort(A, N)

Submission status: Wrong Answer

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


for i in range(1, N):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j + 1] = array[j]
        j -= 1
        array[j + 1] = v
    array = list(map(str, array))
    x = " ".join(array)
    print(x)

Submission status: Wrong Answer

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

array = list(map(str, array))
for i in range(1, N):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j + 1] = array[j]
        j -= 1
        array[j + 1] = v
    array = list(map(str, array))
    x = " ".join(array)
    print(x)

Submission status: Wrong Answer

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

n = input()
A = [int(x) for x in input().split()]
print(*insertion_sort(A))

Submission status: Wrong Answer

Solution code:
num = int(input())
cards = [int(i) for i in input().split()]

def insertion_sort(num, cards):
	for i in range(num):
		v = cards[i]
		j = i - 1
		while j >= 0 and cards[j] > v:
			cards[j+1] = cards[j]
			j -= 1
		cards[j+1] = v
		print(cards)

insertion_sort(num, cards)

Submission status: Wrong Answer

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

"""
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
"""

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 = j -1
    l[j+1] = v
    print(l)

Submission status: Wrong Answer

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

"""
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
"""

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 = j -1
    l[j+1] = v
    m = ''
    for i in range(n):
        m = m + ' ' + str(l[i])
    print(m.strip())

Submission status: Wrong Answer

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



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 = j -1
    l[j+1] = v
    m = ''
    for i in range(n):
        m = m + ' ' + str(l[i])
    print(m.strip())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    a[j] = v
    print(*a)

Submission status: Wrong Answer

Solution code:
N=int(input())
line=input().split()
A=[0]*N
for i in range(0,N):
    A[i]=int(line[i])
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: Wrong Answer

Solution code:
def insertionsort(A, n):
    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 = input().split()
A = [int(i) for i in A]
insertionsort(A, n)

Submission status: Wrong Answer

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

n=int(input())
A=input().split()
A=[int(i)for i in A]

insertionSort(A,n)
for i in range(n):
    print(A[i],end=" ")

Submission status: Wrong Answer

Solution code:
def prt(A):
    for i in A:
        print(i, end=" ")
        print()

def insertionsort(A, n):
    for i in range(1, n):
        prt(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

n = int(input())
A = input().split()
A = [int(i) for i in A]
insertionsort(A, n)

Submission status: Wrong Answer

Solution code:
def pr(A,n):
    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        else:
            print(A[i])

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

n=int(input())
A=input().split()
A=[int(i)for i in A]

insertionSort(A,n)

Submission status: Wrong Answer

Solution code:
#16D8101012J 伊藤惇　dj Python3

def Insertion_Sort():
    N=int(input())
    A=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=j-1
        A[j+1]=v
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")

if __name__ == "__main__":
    Insertion_Sort()

Submission status: Wrong Answer

Solution code:
N=int(input("N"))
A=[0]*N
A=input().split()
print(A)
for i in range(1,len(A)):
    j = i
    while (j > 0) and (A[j-1] > A[j]) :
        tmp = A[j-1]
        A[j-1] = A[j]
        A[j] = tmp
        j -= 1
    print(A)

Submission status: Wrong Answer

Solution code:
N=int(input("N"))
A=[0]*N
A=[int(i)for i in input().split()]
print(A)
for i in range(1,len(A)):
    j = i
    while (j > 0) and (A[j-1] > A[j]) :
        tmp = A[j-1]
        A[j-1] = A[j]
        A[j] = tmp
        j -= 1
    print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    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
    print(A)

Submission status: Wrong Answer

Solution code:

n=int(input("n:"))
A=[0 for i in range(n)]

A=input().split()
for i in range(n):
    A[i]=int(A[i])

print(A)

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

Submission status: Wrong Answer

Solution code:
#16D8101012J 伊藤惇　dj Python3

def Insertion_Sort():
    N=int(input())
    A=list(map(int,input().split()))
    print("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=j-1
        A[j+1]=v
        
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")
        


if __name__ == "__main__":
    Insertion_Sort()

Submission status: Wrong Answer

Solution code:
#16D8101012J 伊藤惇　dj Python3

def Insertion_Sort():
    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=j-1
        A[j+1]=v
        
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")
        


if __name__ == "__main__":
    Insertion_Sort()

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t


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

print(A)

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t


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


insertionsort(n,A)

l=len(A)
for i in range(l):
	print(A[i],end=" ")

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t
			for k in range(n):
				print(A[k],end=" ")


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


insertionsort(n,A)