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:
z = input().split()
x = int(z[0])
y = int(z[1])

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
print(gcd(x,y))

Submission status: Runtime Error

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)

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

Submission status: Runtime Error

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: Runtime Error

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(N - 1):
		v = l[i]
		j = i - 1
		while j >= 0 and l[l] > v:
			A[j + 1] = A[j]
			j -= 1
		A[j + 1] = v
		print(l[0],l[1],l[2],l[3],[4],l[5])

Submission status: Runtime Error

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[l] > v:
			A[j + 1] = A[j]
			j -= 1
		A[j + 1] = v
		print(l[0],l[1],l[2],l[3],[4],l[5])

Submission status: Runtime Error

Solution code:
count = int(input());
data = [];
for n in range(count):
    data.append(int(input()));

def insert_sort(data):
    show(data);
    for i in range(1, len(data)):
        n = data[i];
        j = i - 1;
        while j >= 0 and data[j] > n:
            data[j + 1] = data[j];
            j -= 1;
        data[j + 1] = n;
        show(data);

def show(data):
    print(" ".join(str(n) for n in data));

insert_sort(data);

Submission status: Runtime Error

Solution code:
def trace(A,input_num):
    if i != input_num - 1:   
        for i in range(input_num):
            print(A[i],end = " ")
    else:
        print(A[i])
        
    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: Runtime Error

Solution code:
def trace(A,input_num):
    if i != input_num - 1:   
        for i in range(input_num):
            print(A[i],end = " ")
    else:
        print(A[i])
        
    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()))

insertionSort(A,input_num)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
*a=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:
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: Runtime Error

Solution code:
N = 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: Runtime Error

Solution code:
n = int(input())
a = [i in int(input())]
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: Runtime Error

Solution code:
n = int(input())
a = [i in int(input())]
for  i in range(1,n+1):
    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: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
for  i in range(1,n+1):
    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: Runtime Error

Solution code:
n = int(input())
a = [i in int(input())]
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
    print(*a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [i in 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
    print(*a)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [i in int(input().split()))]
for  i in range(1,n+1):
    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
    print(*a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
for  i in range(1,n+1):
    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: Runtime Error

Solution code:
n = int(input())
a = [i in int(input().split())]
for  i in range(1,n+1):
    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: Runtime Error

Solution code:
n = int(input())
a = [i for i in int(input().split())]
for  i in range(1,n+1):
    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: Runtime Error

Solution code:
n = int(input())
a = [i for i in 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: Runtime Error

Solution code:
n = int(input())
A = 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: Runtime Error

Solution code:
#include<iostream>
#include<cstdlib>
void insertionSort(int A[],int N){
  int v,j;
  for(int i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 and A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
  }
}
int main(){
  int N;
  std::cin>>N;
  int a[N]={0};
  for(int i=0;i<N;i++){
    std::cin>>a[i];
  }
  for(int j=1;j<=N;j++){
    insertionSort(a,j);
    for(int k=0;k<N;k++){
      std::cout<<a[k]<<" ";
    }
    std::cout<<'\n';
  }  
  return 0;
}

Submission status: Runtime Error

Solution code:
# 1_A 16D8101023J 久保田凌弥 2018/4/18
import numpy as np

a=int(input())
*A, = map(int, input().split())
for i in range(a):
 j=0
 while 1:
  if j==i:
   print(np.round(A))
   break
  if A[i]<A[j]:
   x=A[i]
   A[i]=A[j]
   A[j]=x
  j+=1

Submission status: Runtime Error

Solution code:
#16D8102008K 1-A:Insertion Sort 柳生　葉月　Yagyu Hauzki
import numpy as np
N=int(input(""))
A=np.zeros(N)
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=j-1
    A[j+1]=v
    print(A)

Submission status: Runtime Error

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

def prt(A):
    for i in A:
        if i != A[len(A)-1]: print(i, end=" ")
        else print(i)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
file:///jugyou/ise/16D8104004E/%E5%AE%9F%E8%B7%B5%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0/Insertion.py

Submission status: Runtime Error

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
    while j >= 0 and A[j]>v:
        A[j+1] = A[j]
        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(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)

Submission status: Runtime Error

Solution code:
#16D8102008K 1-A:Insertion Sort 柳生　葉月　Yagyu Hauzki
import numpy as np
N=int(input(""))
A=np.zeros(N)
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=j-1
    A[j+1]=v
    print(''.join(map(str,A)))

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input(""))
A=np.zeros(N)
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=j-1
    A[j+1]=v
    print(''.join(map(str,A)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

import numpy as np
N=int(input(""))
A=np.zeros(N)
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=j-1
    A[j+1]=v
    print(''.join(map(str,A)))

Submission status: Runtime Error

Solution code:
# 16D8101022L 小林勇希 ID:k_mb python3

import math

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

for i in range(n):
    a_sq = int(math.sqrt(A[i]))
    for j in range(2,a_sq+2):
        if(A[i]%j==0 and not(A[i]==j)):
            break
        if(j==a_sq+1):
            cou += 1

print(cou)

"""実行結果

5
2
3
4
5
6
3



5
2
2
2
2
2
5

"""

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
A=np.empty((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: Runtime Error

Solution code:
import numpy as np
N=int(input())
A=np.empty((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
    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        else:
            print(A[k])

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
A=np.empty((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
    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        if k==N-1:
            print(A[k])

Submission status: Runtime Error

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(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):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])

"""

Submission status: Runtime Error

Solution code:
# リストの宣言
A = []

# 入力の最初の行に、数列の長さを表す整数 N が与えられます。
# 2 行目に、N 個の整数が空白区切りで与えられます。
NUM =int(input())
A = input().split()

NUMLIST = range (1, NUM + 1)

# for i = 1 to A.length-1
for i in NUMLIST:
#    key = A[i]
  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:
import numpy as np
n=int(input())
A=np.empty(n)
for i in range(n):
    A[i]=int(input())

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)

Submission status: Runtime Error

Solution code:
import numpy as np
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=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=j-1
	a[j+1]=v
	print(' '.join(map(str,a)))

Submission status: Runtime Error

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

print(' '.join(map(str,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(map(str,a)))

Submission status: Runtime Error

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3
import numpy as np

a=int(input())
A=map(int, raw_input().split())

for i in range(a):
  for j in range(a):
   if i==j:
    print(np.round(A)
    continue
   if A[j]>=A[i]:
    x=A[j]
    A[j]=A[i]
    A[i]=x

Submission status: Runtime Error

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3
import numpy as np

a=int(input())
A=map(int, raw_input().split())

for i in range(a):
 for j in range(a):
  if i==j:
   print(np.round(A))
   continue
  if A[j]>=A[i]:
   x=A[j]
   A[j]=A[i]
   A[i]=x

Submission status: Runtime Error

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3
import numpy as np

a=int(input())
A=map(int, raw_input().split())

for i in range(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(np.round(A)

Submission status: Runtime Error

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3
import numpy as np

a=int(input())
A=map(int, raw_input().split())

for i in range(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(np.round(A))

Submission status: Runtime Error

Solution code:
import numpy as np

a=int(input())
A=map(int, raw_input().split())

for i in range(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(np.round(A))

Submission status: Runtime Error

Solution code:
#16D8101023J 久保田凌弥 kubotarouxxx python3
import numpy as np

a=int(input())
A=map(int, input().split())
for i in range(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(np.round(A))

Submission status: Runtime Error

Solution code:
import numpy as np
def trace(A,N):
  for i in range(N):
  	print(A[i]," ",end="")
  print("")  
def insertion_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	
		trace(A,N)

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

Submission status: Runtime Error

Solution code:
n=int(input())

list=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
    for i in range(len(A)):
        if i!=len(A)-1:
            print(A[i],end=' ')
        else :
            print(A[i])

Submission status: Runtime Error

Solution code:
#include<stdio.h>
int main(void){
  int n;
  int v,j=0,i=0,k=0;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    v=A[i];
    j=i-1;
    if(i>=1){
      for(k=0;k<n;k++){
	printf("%d ",A[k]);
      }
    }
    printf("\n");
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j=j-1;
      A[j+1]=v;
    }
  }
for(k=0;k<n;k++){
  printf("%d ",A[k]);
 }
return 0;
}

Submission status: Runtime Error

Solution code:
def print_tmp(a_li):
    t = ' '.join(a_li)
    print(t)


n = int(input())
a = input()
A = [int(i) for i in a.split(' ')]
print_tmp(A)
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
    print_tmp(A)
print_tmp(A)

Submission status: Runtime Error

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

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

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

    for k in range(N):
        print('{0} '.format(A[k]), end='')
    print()

Submission status: Runtime Error

Solution code:
  #include <iostream>
  #include <stdlib.h>
  #include <algorithm>
  #include <numeric>
  #include <ctype.h>
  using namespace std;
  void print(vector<int> v);
  int main(void){
      int N, num;
      vector<int> v;
      cin >> N;
      for(int i = 0; i < N; i++){
          cin >> num;
          v.push_back(num);
      }
      for(int i = 1; i < N; i++){
          int x = v[i];
          int j = i - 1;
          while(j >= 0 && v[j] > x){
              v[j + 1] = v[j];
              j--;
              v[j + 1] = x;
          }
print(v);
      }
  }
  
  void print(vector<int> v){
    for(int i = 0; i < v.size(); i++){
          cout << v[i];
        if(i != v.size() - 1) cout << ' ';
      }
      cout << endl;
  }

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <ctype.h>
using namespace std;
void print(vector<int> v);
int main(void){
    int N, num;
    vector<int> v;
    cin >> N;
    for(int i = 0; i < N; i++){
	cin >> num;
	v.push_back(num);
    }
    for(int i = 1; i < N; i++){
	print(v);
	int x = v[i];
	int j = i - 1;
	while(j >= 0 && v[j] > x){
	    v[j + 1] = v[j];
	    j--;
	    v[j + 1] = x;
	}
    }
    print(v);
}

void print(vector<int> v){
    for(int i = 0; i < v.size(); i++){
	cout << v[i];
	if(i != v.size() - 1) cout << ' ';
    }
    cout << endl;
}

Submission status: Runtime Error

Solution code:
#!usr/env/python3
#-*- encode: utf-8 -*-

n = input()
data = map(int, input().split())

i = 1
print(" ".join(map(str, data)))
while (i < len(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(" ".join(map(str, data)))
    i += 1

Submission status: Runtime Error

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

i = 1
print(" ".join(map(str, data)))
while (i < len(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(" ".join(map(str, data)))
    i += 1

Submission status: Runtime Error

Solution code:
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(str, A)))

Submission status: Runtime Error

Solution code:
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(str, A)))

Submission status: Runtime Error

Solution code:
intMax = -100000000

inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

inputDataMax = intMax
inputDataMin = inputList[0]
count2 = 1
while count2 < inputData:
    inputDataMax = max(inputDataMax,  inputList[count2] - inputDataMin)
    inputDataMin = min(inputDataMin, inputList[count2])
    count2 = count2 + 1

print(inputDataMax)

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

inputDataMax = intMax
inputDataMin = inputList[0]
count2 = 1

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    inputList.append(int(input()))
    count = count + 1

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0

while count < inputData:
    inputList.append(int(input()))
    count = count + 1

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list(int(input()))
count = 1

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    tmpData = int(input())
    inputList.append(tmpData)
    count = count + 1

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    tmpData = int(input())

Submission status: Runtime Error

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    tmpData = int(input())
    inputList.append(tmpData)
    count = count + 1

Submission status: Runtime Error

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

if __name__ == '__main__':
    print(" ".join(A))
    for i in range(1, N):
        target_num = A[i]
        for j in range(i):
            if A[j] > target_num:
                tmp_idx = i
                while j < tmp_idx:
                    A[tmp_idx] = A[tmp_idx-1]
                    tmp_idx -= 1
                A[j] = target_num
                break
        print(" ".join(A))

Submission status: Runtime Error

Solution code:
N = map(int, raw_input().split())
a = []
for i in range(N):
    a.append(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 = j-1
        a[j+1] = v
    print(a)

Submission status: Runtime Error

Solution code:
N = map(int, raw_input())
a = []
for i in range(N):
    a.append(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 = j-1
        a[j+1] = v
    print(a)

Submission status: Runtime Error

Solution code:
N =　input()
a = []
for i in range(N):
    a.append(input())
    

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: Runtime Error

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

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: Runtime Error

Solution code:
N =　int(input(0))
a = []
for i in range(N):
    a.append(input(1))
    
    

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: Runtime Error

Solution code:
N = input()
a = []
for i in range(N):
    a.append(input())
    

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: Runtime Error

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

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: Runtime Error

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

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: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())

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: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())

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: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())
N = N+1
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: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())
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: Runtime Error

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(map(int, input())

int(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)

Submission status: Runtime Error

Solution code:
N =  map(int,input())
a = []
for i in range(N):
    a.append(map(int, input())



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: Runtime Error

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

Submission status: Runtime Error

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

v = a[0]

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: Runtime Error

Solution code:
N =  map(int,input().split())
N = N+1
a = []
for i in range(N):
    a.append(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(a)

Submission status: Runtime Error

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

a = []
for i in range(N):
    a.append(map(int, input().split())
N = N+1


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: Runtime Error

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

a = []
for i in range(N):
    a.append(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(a)

Submission status: Runtime Error

Solution code:
N = input()
a = []
for i in range(N):
    a.append(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(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
a.append(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(a)

Submission status: Runtime Error

Solution code:
import sys
for lineCnt, line in enumerate(sys.stdin):
    if lineCnt == 0:
        N = int(line.rstrip('\n'))
    else:
        A = map(int, line.rstrip('\n').split(' '))

for j in range(1, N):
    print ' '.join(map(str, A))
    key = A[j]
    i = j - 1
    while i >= 0 and A[i] > key:
        A[i+1] = A[i]
        i -= 1
    A[i+1] = key
print ' '.join(map(str, A))