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:
     
n = int(input())
a = list(map(int,input().split()))

print(a)
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)

insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
length=int(input())
firstArray=input()
listForArray=list(map(int,firstArray.split()))
listForPrint=[firstArray]

def insertionSort(list,length):
    index=1
    while index<length:
        if listForArray[index]<listForArray[index-1]:
            for index2 in range(0,index):
                if listForArray[index2-1]<listForArray[index] and listForArray[index]<listForArray[index2] or index2==0 and listForArray[index]<listForArray[index2]:
                    newCommer=listForArray[index]
                    n=index
                    while n>index2:
                        listForArray[n]=listForArray[n-1]
                        n-=1
                    listForArray[index2]=newCommer
                    break   
        nowArray=str(listForArray[0])
        for index3 in range(1,length):
            nowArray+=" "+str(listForArray[index3])
        listForPrint.append(nowArray)
        index+=1
                
#---------------------main-------------------------
insertionSort(listForArray,length)
for array in listForPrint:
    print(array)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    Mtx = list(map(int, input().split()))
    
    for i in range(1,n):
        for j in range(i,0,-1):
            if Mtx[j] < Mtx[j-1]:
                Mtx[j-1], Mtx[j] = Mtx[j], Mtx[j-1]
            # print(i, j, sep=', ')
        showMtx(Mtx)
                

def showMtx(Mtx):    
    q = len(Mtx)
    for i in range(q):
        if i != q - 1:
            print(Mtx[i], sep=' ', end=' ')
        else:
            print(Mtx[i])



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def insertion_sort(lis, num):
    print(lis)
    for i in range(1, num):
        v = lis[i]
        j = i - 1  # j は iの前の数
        while j >= 0 and lis[j] > v:  # jが0以上で配列のj番目の要素が現在の要素より大きい場合
            lis[j + 1] = lis[j]  # 配列j+1番目の要素に配列j番目の要素を格納
            # print(' '.join(lis))
            j -= 1  # jを-1
            lis[j + 1] = v  # 配列j+1番目の要素にvを格納
        print(lis)
    return lis

insertion_sort(nums, n)

Submission status: Wrong Answer

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

def insertion_sort(lis, num):
    print(' '.join(map(str, lis)))
    for i in range(1, num):
        v = lis[i]
        j = i - 1  # j は iの前の数
        while j >= 0 and lis[j] > v:  # jが0以上で配列のj番目の要素が現在の要素より大きい場合
            lis[j + 1] = lis[j]  # 配列j+1番目の要素に配列j番目の要素を格納
            # print(' '.join(lis))
            j -= 1  # jを-1
            lis[j + 1] = v  # 配列j+1番目の要素にvを格納
        print(' '.join(map(str, lis)))
    return lis

Submission status: Wrong Answer

Solution code:

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(1,n):
    
    for j in range(0,n):
        print(sort_list[j])
        if j is not n - 1:
            print(" ")
        else:
            print("\n")
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1
    sort_list[j+1] = tmp

Submission status: Wrong Answer

Solution code:

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(1,n):
    
    for k in range(0,n):
        print(sort_list[k])
        if k is not n - 1:
            print(" ")
        else:
            print("\n")
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1
    sort_list[j+1] = tmp

Submission status: Wrong Answer

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

for i in range(1,n):

  for j in range(0,n):
      print(sort_list[j])
      if j is not n - 1:
          print(" ")
      else:
          print("\n")
  
  tmp = sort_list[i]
  j = i - 1
  while j >= 0 and sort_list[j] > tmp:
      sort_list[j+1] = sort_list[j]
      j = j - 1
  sort_list[j+1] = tmp

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

for i in range(0,n):
    
    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        else:
            print ""
    
    tmp = sort_list[i]
    j = i - 1
    while j >= 0 and sort_list[j] > tmp:
        sort_list[j+1] = sort_list[j]
        j = j - 1
    sort_list[j+1] = tmp

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        else:
            print ""

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        else:
            print ""
            
            
print ""

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            print ""
            
            
print ""

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            print ""

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        else:
            if i is not n - 1:
                print ""

Submission status: Wrong Answer

Solution code:
import sys

n = input()
sort_list = list()

sort_list = map(int, raw_input().split())

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

    sort_list[j+1] = tmp


    for k in range(0,n):
        sys.stdout.write(str(sort_list[k]))
        if k is not n - 1:
            sys.stdout.write(" ")
        elif i is not n - 1:
            sys.stdout.write("\n")

Submission status: Wrong Answer

Solution code:
#! /usr/local/bin/python3
# coding: utf-8

def insertion_sort(a):
    for i in range(1, len(a)):
        w = a[i]
        j = i - 1
        while j >= 0 and w < a[j]:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = w
        print(" ".join(map(str, a)))

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

Submission status: Wrong Answer

Solution code:
dum = input()
data = [ int(i) for i in input().split(" ")]
for i in range(1,len(data)):
  v = data[i]
  j = i-1
  while j>=0 and data[j] > v:
    data[j+1]=data[j]
    j-=1
  else:
    data[j+1]=v
  print(' '.join([str(n) for n in data]))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().rstrip().split()
list(map(int,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
   for k in range(n):
      print(a[k],end=" ")
   print()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().rstrip().split()
list(map(int,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
   for k in range(n):
      print(a[k],end=" ")
   if not i==(n-1):
      print()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().rstrip().split()
list(map(int,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
   for k in range(0,n):
      if k<n-1:
         print(a[k],end=" ")
      else:
         print(a[k])

Submission status: Wrong Answer

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

for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])
         
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 k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

Submission status: Wrong Answer

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

for k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

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 k in range(0,n):
      if k!=n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

Submission status: Wrong Answer

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

for k in range(0,n):
      if k<n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

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 k in range(0,n):
      if k<n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

Submission status: Wrong Answer

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

for k in range(0,n):
      if k<n-1:
         print(a[k],end=' ')
      else:
         print(a[k])

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:
n=int(input())
a=input().rstrip().split()
list(map(int,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)

Submission status: Wrong Answer

Solution code:
def insertionSort(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 += -1
        A[j+1] = v

Submission status: Wrong Answer

Solution code:
def insertionSort(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 += -1
        A[j+1] = v
    return A

Submission status: Wrong Answer

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

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(map(str, A)))

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

Submission status: Wrong Answer

Solution code:
input()
myarr = list(map(int, input().split()))
for i in range(1, len(myarr)):
    for j in range(i, 0,-1):
        if myarr[j] < myarr[j-1]:
            t = myarr[j]
            myarr[j] = myarr[j-1]
            myarr[j-1] = t
        else:
            break
    print(" ".join(map(str, myarr)))

Submission status: Wrong Answer

Solution code:
# 配列の要素数
num = int(input())

# 配列
array = list(map(int, input().split()))

# insertion sort
for i in range(num):
    insert = array[i]
    j = 0
    while array[j] < insert:
        j+=1
    for k in range(i, j, -1):
        array[k] = array[k - 1]
    array[j] = insert
    print(array)

Submission status: Wrong Answer

Solution code:
# 配列の要素数
num = int(input())

# 配列
array = list(map(int, input().split()))

def print_array():
    for i in range(num):
        print(array[i], end=' ')

# insertion sort
for i in range(num):
    insert = array[i]
    j = 0
    while array[j] < insert:
        j+=1
    for k in range(i, j, -1):
        array[k] = array[k - 1]
    array[j] = insert
    print_array()

Submission status: Wrong Answer

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

for i in range(N):
    j = i

    while j > 0 and A[j] < A[j-1]:
        if A[j] > A[j-1]:

            break
        k = A[j]
        l = A[j-1]
        A[j-1] = k
        A[j] = l
        j -= 1

    S = str(A[0])
    for k in range(1,N-1):
        S += " " + str(A[k])

    S = S + " "+str(A[N-1])
    print(S)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
k=list(str(a))
j='  '.join(k)
print(j)
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+1]=v
    b=a[:]
    c='  '.join(str(b))
    print(c)

Submission status: Wrong Answer

Solution code:
def insertion_sort(arr):
    for i in range(1,len(arr)):
        j = i
        while arr[j] < arr[j-1] and j > 0:
            arr[j-1], arr[j] = arr[j], arr[j-1]
            j -= 1
        print(" ".join(map(str, arr)))

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

Submission status: Wrong Answer

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

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)

if __name__ == '__main__':
    main()

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

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
    return A


N = int(input())
A = [int(x) for x in input().split(' ')]

A = insertionSort(A, N)
print(A)

Submission status: Wrong Answer

Solution code:
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 = [int(x) for x in input().split(' ')]

A = insertionSort(A, N)

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:
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:
n = int(input())
A = list(map(int, input().split()))

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)

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)

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

print(A)
insertionSort(A,N)

Submission status: Wrong Answer

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

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 -= 1
    a[j+1] = v
    ans = ' '.join(a)
    print(ans)

Submission status: Wrong Answer

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

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

        for a in A:
            print(str(a) + ' ', end='')
        print('')


insertion_sort(A, N)

Submission status: Wrong Answer

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

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

        string = list(map(str, A))
        print(' '.join(string))

insertion_sort(A, N)

Submission status: Wrong Answer

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

for i in range(1, n):
    j = i
    while a[j - 1] > a[j] and j > 0:
        a[j], a[j - 1] = a[j - 1], a[j]
        j -= 1
    print(" ".join([str(i) for i in 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 v < a[j]:
        a[j+1] = a[j]
        j -= 1

    a[j+1] = v

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

Submission status: Wrong Answer

Solution code:
def inserrtionsort(l,n):
  for i in range(1,n):
    v=l[i]
    j=i-1
    while v<l[j] and j>=0:
      l[j+1]=l[j]
      j-=1
    l[j+1]=v
    print("".join(l))
  print("".join(l))
m=int(input())
n=list(input())
inserrtionsort(n,m)

Submission status: Wrong Answer

Solution code:
def inserrtionsort(l,n):
  for i in range(1,n):
    v=l[i]
    j=i-1
    while v<l[j] and j>=0:
      l[j+1]=l[j]
      j-=1
    l[j+1]=v
    print(" ".join(l))
m=int(input())
n=list(input())
inserrtionsort(n,m)

Submission status: Wrong Answer

Solution code:
def inserrtionsort(l,n):
  for i in range(1,n):
    print(" ".join(l))
    v=l[i]
    j=i-1
    while v<l[j] and j>=0:
      l[j+1]=l[j]
      j-=1
    l[j+1]=v
  print(" ".join(l))
m=int(input())
n=list(input())
inserrtionsort(n,m)

Submission status: Wrong Answer

Solution code:
def inserrtionsort(l,n):
  for i in range(1,n):
    print(" ".join(l))
    v=l[i]
    j=i-1
    while v<l[j] and j>=0:
      l[j+1]=l[j]
      j-=1
    l[j+1]=v
  print(" ".join(l))
m=int(input())
n=list(input().split())
inserrtionsort(n,m)

Submission status: Wrong Answer

Solution code:
n = int(input())

data = input().split()

for i in range(1, n):
  print(*data)

  key = data[i]

  j = i - 1

  while j >= 0 and data[j] > key:
    data[j+1] = data[j]
    j -= 1

  data[j+1] = key 

print(*data)

Submission status: Wrong Answer

Solution code:
# -*- Coding: utf-8 -*-
def trace(A, N):
    for i in range(int(N)-1):
        print(A[i], end=' ')
    print(A[int(N)-1])

def insertionSort(A, N):
    for i in range(1, int(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
        trace(A, N)

if __name__ == '__main__':
    N = input()
    A = list(map(int, input().split()))

    insertionSort(A, N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(A)

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

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(' '.join(map(str,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 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 = list(map(int,input().split()))

def sort(N,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
        pr(A)

def pr(list):
    n = len(list)
    for i in range(n):
        if i < n-1:
            print(list[i],end=" ")
        else:
            print(list[i],end="\n")

sort(N,A)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

length = int(input())
data = list(input().split())

for i in range(1,len(data)):
    tmp = data[i]
    i2 = i - 1
    while i2 >=0 and data[i2] > tmp:
        data[i2+1] = data[i2]
        i2 -= 1

    data[i2+1] = tmp
    print(data)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

def printline(data):
    l=""
    for i,s in enumerate(data):
        l = l + s
        if i+1 != len(data):
            l = l+" "
    print(l)


length = int(input())
data = list(input().split())

for i in range(1,len(data)):
    tmp = data[i]
    i2 = i - 1
    while i2 >=0 and data[i2] > tmp:
        data[i2+1] = data[i2]
        i2 -= 1

    data[i2+1] = tmp
    printline(data)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

def printline(data):
    l=""
    for i,s in enumerate(data):
        l = l + s
        if i+1 != len(data):
            l = l+" "
    print(l)


length = int(input())
data = list(input().split())
printline(data)
for i in range(1,len(data)):
    tmp = data[i]
    i2 = i - 1
    while i2 >=0 and data[i2] > tmp:
        data[i2+1] = data[i2]
        i2 -= 1

    data[i2+1] = tmp
    printline(data)

Submission status: Wrong Answer

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

for i in range(1,n):
	print(a)
	j = i -1
	v = a[i]
	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(0,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 = list(map(int,A))
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

Solution code:
n = input()
a = raw_input().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(a))

Submission status: Wrong Answer

Solution code:
import sys

N = int(raw_input())
A = map(str, raw_input().split())
print " ".join(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(A))

Submission status: Wrong Answer

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

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(*A)

Submission status: Wrong Answer

Solution code:
n=input()
num_list=[int(x) for x in raw_input().split(" ")]

for idx in range(1, len(num_list)):
    
    key=num_list[idx]
    jdx = idx - 1
    
    while jdx >= 0 and num_list[jdx] > key:
        num_list[jdx+1] = num_list[jdx]
        jdx -= 1
    num_list[jdx+1] = key
    print " ".join([str(x) for x in num_list])

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python

if __name__ == "__main__":
	n = int(raw_input())
	array = map(int, raw_input().split())
	for i in range(1, n):
		key = array[i]
		j = i - 1 
		while j >= 0 and array[j] > key:
			array[j+1] = array[j]
			j -= 1
		array[j+1] = key
		print " ".join(map(str, array))
	print " ".join(map(str, array))

Submission status: Wrong Answer

Solution code:
def trace( nums ):
	output = []
	for num in nums:
		output.append( str( num ) )
		output.append( " " )
	output.pop( )
	print( "".join( output )  )

n = int( raw_input( ) )
nums = [ int( val ) for val in raw_input( ).split( " " ) ]
trace( nums )

for i in range( 1, len( nums )-1 ):
	key = nums[i]
	j = i - 1
	while 0 <= j and key < nums[j]:
		nums[ j+1 ] = nums[j]
		j -= 1
	nums[ j+1 ] = key
	trace( nums )

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

def InsertSort(N,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)


if __name__ == "__main__":
    N=int(input())
    arr=list(map(int,input().split()))
    InsertSort(N,arr)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
for i in range(1, len(a)):
#    print(''.join(map(str, 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 insertSort(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(map(str, a)))



if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().split()]
    insertSort(A, N)

Submission status: Wrong Answer

Solution code:
print("Spam")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys

def main():
	num = int(raw_input())
	list = map(int, raw_input().split())

def sort(num, list):
	output(list)
	for i in range(0, num):
		key = list[i]
		j = i - 1
		while j >= 0 and list[j] > key:
			list[j+1] = list[j]
			j -= 1
		list[j+1] = list[j]
		output(list)
def output(list):
	print " ".join(map(str, list))
			


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:

import sys

def main():
	num = int(raw_input())
	list = map(int, raw_input().split())

def sort(num, list):
	output(list)
	for i in range(0, num):
		key = list[i]
		j = i - 1
		while j >= 0 and list[j] > key:
			list[j+1] = list[j]
			j -= 1
		list[j+1] = list[j]
		output(list)
def output(list):
	print " ".join(map(str, list))
			


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
arr = map(int, raw_input().split(' '))

p = 1
while True:
    for j in range(0,p):
        if arr[p] < arr[j]:
            arr[p],arr[j] = arr[j],arr[p]
    p += 1
    print ' '.join(map(str, arr))
    if p >= len(arr):
        break

Submission status: Wrong Answer

Solution code:
def insertionSort(a, n):
  print " ".join(a)
  for i in xrange(1, n):
    v = a[i]
    j = i - 1
    # print "i = " + str(i) + ", j = " + str(j)
    while j >= 0 and v < a[j]:
      a[j + 1] = a[j]
      j -= 1
    a[j + 1] = v
    print " ".join(a)

n = int(raw_input())
a = raw_input().split(" ")
insertionSort(a, n)

Submission status: Wrong Answer

Solution code:
num = raw_input()
num_list = raw_input()
num_list = num_list.split()
print " ".join(num_list)

for i in range(1, len(num_list)):
        temp = num_list[i]
        j = i - 1
        while (j >= 0 and num_list[j] > temp):
                num_list[j+1] = num_list[j]
                j -= 1
        num_list[j+1] = temp
        print " ".join(num_list)

Submission status: Wrong Answer

Solution code:
num = raw_input()
num_list = raw_input()
num_list = num_list.split()
print " ".join(num_list)
 
for i in range(1, len(num_list)):
        temp = num_list[i]
        j = i - 1
        while (j >= 0 and num_list[j] > temp):
                num_list[j+1] = num_list[j]
                j -= 1
        num_list[j+1] = temp
        print " ".join(num_list)

Submission status: Wrong Answer

Solution code:
num = int(raw_input())
line = raw_input()

item_str = line.strip().split(" ")
A = map(int, item_str)

for i in range(1, num):
    v = A[i]
    j = i - 1
    for j in range(j, -1, -1):
        if A[j] > v:
            A[j+1] = A[j]
            j -= 1
        else:
            break
    A[j+1] = v
    str_A = map(str, A)
    print " ".join(str_A)

Submission status: Wrong Answer

Solution code:
n = raw_input()
num = raw_input()
array = []
for line in num:
    if line != " ":
        array.append(line)
print array

for i in range(1, int(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
    print array