/*Sorting the numbers using merge sort*/
#include <stdio.h> //To include standard input and output.

/*Defining a function min to find minimum of two numbers.*/
int min(int x, int y)
{
    int z;
    if(x>y)                             //Checking the condition.
        z=y;                            //assigning the minimum value to z
    else
        z=x;                            //assigning the minimum value to z
    return z;
}

/*Defining a function to merge two sorted (in increasing order) arrays in increasing order*/
void merge(int aa[], int ab[], int ac[], int p, int q)
{
    int i=1, j=0, k=0;                  //i, j and k are used to keep index of number in aa, ab and ac respectively.
    ac[0]=min(aa[0], ab[0]);            //assigning the minimum number of both arrays to ac[0].
    if(aa[0]==ac[0])
        j++;                            //incrementing j to go for next number of aa[].
    else
        k++;                            //incrementing k to go for next number of ab[].
    while(j<p&&k<q)                     // loop works till both arrays have at least one element in each.
    {
        ac[i]=min(aa[j],ab[k]);         //assigning the minimum number out of aa[j] and ab[k] to ac[i].
        if(aa[j]==ac[i])
            j++;                        //incrementing j to go for next number of aa[].
        else
            k++;                        //incrementing k to go for next number of ab[].
        i++;                            //incrementing i to go for next number of ac[] for next iteration.
    }
    while(j==p&&k<q)                    //loop runs when only array ab[] has elements.
    {
        ac[i]=ab[k];                    //assigning all the numbers of ab to ac.
        k++;                            //incrementing k to go for next number of ab[].
        i++;                            //incrementing i to go for next number of ac[].
    }
    while(j<p&&k==q)                    //loop runs when only array aa[] has elements.
    {
        ac[i]=aa[j];                    //assigning all the numbers of ab to ac.
        j++;                            //incrementing j to go for next number of aa[].
        i++;                            //incrementing i to go for next number of ac[].
    }
}

/*Defining a function mergesort to divide array into two arrays and again, and merge them*/
void mergesort(int a[], int m)
{
    if(m>1)
    {
        if(m%2==0)                                  //When the total numbers is even.
        {
            int i, left[m/2], right[m/2];           //defining two new arrays.
            for(i=0;i<m/2;i++)
            {
                left[i]=a[i];                       //storing first half in left[] array.
                right[i]=a[m/2+i];                  //storing second half in right[] array.
            }
            mergesort(left, m/2);                   //Repeating the mergesort function for left part of middle element.
            mergesort(right, m/2);                  //Repeating the mergesort function for right part of middle element.
            merge(left, right, a, m/2, m/2);        //merging the two sorted arrays.
        }
        else                                        //When the total numbers is odd.
        {
            int i, left[m/2], right[m/2+1];         //defining two new arrays.
            for(i=0;i<m/2;i++)
            {
                left[i]=a[i];                       //storing first half in left[] array.
            }
            for(i=0;i<m/2+1;i++)
            {
                right[i]=a[m/2+i];                  //storing second half in right[] array.
            }
            mergesort(left, m/2);                   //Repeating the mergesort function for left part of middle element.
            mergesort(right, m/2+1);                //Repeating the mergesort function for right part of middle element.
            merge(left, right, a, m/2, m/2+1);      //merging the two sorted arrays.
        }
    }
}

int main()                               //Starting the main function.
{
    int n, i;
    //printf("Enter the number of elements to be sorted :\n");
    scanf("%d", &n);                     //Storing the number of elements in n.
    int ar[n];                           //Defining an array of length n
    //printf("Enter the numbers :\n");
    for(i=0;i<n;i++)
        scanf("%d", &ar[i]);             //Storing the numbers in array.
    mergesort(ar, n);                    //calling the mergesort function.
    //printf("The numbers sorted in increasing order are :\n");
    for(i=0;i<n;i++)
        printf("%d ", ar[i]);            //Printing the sorted numbers.
    return 0;
}

#include<stdio.h>
    int i,n,x,C[101];
    int main(){
    for(scanf("%d",&n);i<n;i++){
        scanf("%d",&x),C[x]++;
    }
    for(i=0;i<101;i++)
    while(C[i]--)
    printf("%d ",i);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    int j,temp;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    for(i=0;i<n;i++)
    printf("%d ",a[i]);
    return 0;
}

#include <stdio.h>
void bubble_sort(long long int a[],long long int n)
{
    int i = 0, j = 0, tmp;
    for (i = 0; i < n; i++)
	{   // loop n times - 1 per element
        for (j = 0; j < n - i - 1; j++)
		{ // last i elements are sorted already
            if (a[j] > a[j + 1])
			{  // swop if order is broken
                tmp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = tmp;
            }
        }
    }
}
int main()
{
	long long int n;
    scanf("%lld",&n);
    long long int a[n];
	for(int i=0;i<n;i++)
	scanf("%lld",&a[i]);
	bubble_sort(a,n);
   	for(int i=0;i<n;i++)
   	printf("%lld ",a[i]);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    scanf("%d",&a);
   int x [100];
   int Temp=0;
   int i ,j;
   for (i=0;i<a;i++){
        scanf("%d",&x[i]);
   }

   for (i=0;i<a-1;i++){
      for(j=i+1;j<a;j++){
    if (x[i]>x[j] ){
      Temp=x[i];
      x[i]=x[j];
      x[j]=Temp;
    }
        }
   }

    for (i=0;i<a;i++){
     printf("%d ",x[i]);
    }

    return 0;
}

#include <stdio.h>
#define MAX 100
int main() {

    int G_tate[MAX][MAX];
    int ans[MAX];
    int i, j ,k;
    int n;
    int a;

    for( i = 0; i < MAX; i++ ) {
        for( j = 0; j < MAX; j++ ) {
            G_tate[i][j] = 0;
            ans[i] = 0;
        }
    }

    scanf("%d" ,&n);

    for( i = 0; i < n; i++ ) {

        scanf("%d" ,&a);

        for( j = 0; j < a; j++ ) {
            G_tate[i][j] = 1;
        }
    }

    /*for debag
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ ) {
            printf("%d ",G_tate[i][j]);

        }
        printf("\n");
    }
    printf("\n");
    /*for debag*/

    for(k = 0; k < MAX; k++) {
        for( i = 0; i < n; i++ ) {
            for( j = 0; j < MAX; j++ ) {

                if(G_tate[i][j] == 0 && G_tate[i - 1][j] == 1) {
                    G_tate[i][j] = 1;
                    G_tate[i - 1][j] = 0;
                }
            }
        }
    }

    /*for debag
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ ) {
            printf("%d ",G_tate[i][j]);

        }
        printf("\n");
    }
    printf("\n");
    /*for debag*/

    for( i = 0; i < MAX; i++ ) {
        for( j = 0; j < MAX; j++ ) {

            if(G_tate[i][j] == 1)ans[i]++;

        }
    }

    for(i = 0; i < n; i++ ) {
        printf("%d " ,ans[i]);
    }

    printf("\n");

    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main()
{
	int arr[100],tmp,n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);

	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n;j++)
        {
			if (arr[j] <= arr[i])
			{
				tmp = arr[i];
				arr[i] = arr[j];
				arr[j] = tmp;
			}

		}

	}

	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");

}

#include <stdio.h>      /* printf */
#include <stdlib.h>     /* qsort */

int n, a[105];

int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int main ()
{
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &a[i]);
    qsort (a, n, sizeof(int), compare);
    for(int i=0; i<n; i++) printf("%d ", a[i]);
    return 0;
}

#include<stdio.h>
int A[100];
int main()
{
  int n,m,k,max,i,r;
  scanf("%d",&n);
  for(i=1; i<=n; i++)
  scanf("%d",&A[i]);
  m=n;r=n;
  while(m--)
{
  max=A[1];
  for(i=1; i<=n; i++)
{
  if(A[i]>=max)
 {
   max=A[i];
  k=i;
 }
}
A[k]=A[n];
A[n]=max;
n--;
}
for(i=1; i<=r; i++)
printf("%d ",A[i]);
return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d\n",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d ",&a[i]);
    int pos,min;
    for(int i=0;i<n;i++)
    {
        min=a[i];
        pos=i;
        for(int j=i;j<n;j++)
        {
            if(min>=a[j])
            {
                pos=j;
                min=a[j];
            }
        }
        a[pos]=a[i];
        a[i]=min;
    }
    for(int i=0;i<n;i++)
        printf("%d ",a[i]);
    return 0;
}

//merge sort
#include <stdio.h>
#include <string.h>

int arr[100000],k;

void mergesort(int l, int mid, int r)
{
	if(l>=r)	return;
	int n=mid-l+1,m=r-mid,a1[n],a2[m],i,j;
	for(i=0;i<n;i++)
		a1[i]=arr[l+i];
	for(i=0;i<m;i++)
		a2[i]=arr[mid+i+1];
	i=0;j=0;
	while(i<n && j<m)
	{
		if(a1[i]<a2[j])
		{
			arr[i+j+l]=a1[i];
			i++;
		}
		else
		{
			arr[i+j+l]=a2[j];
			j++;
		}
	}
	while(i<n)
	{
		arr[i+j+l]=a1[i];
		i++;
	}
	while(j<m)
	{
		arr[i+j+l]=a2[j];
		j++;
	}
	//for(i=0;i<k;i++)
	//	printf("%d ",arr[i]);
	//printf("\n");
}
void merge(int start, int end)
{
	if(start>=end)	return;
	int mid=(start+end)/2;
	merge(start,mid);
	merge(mid+1,end);
	mergesort(start,mid,end);
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	    scanf("%d",&arr[i]);
	merge(0,n-1);
	for(i=0;i<n;i++)
		printf("%d ",arr[i]);
	return 0;
}

#include <stdio.h>

int main (){
	int r = 0;
	int c = 0;
	int k = 0;
	int n;
	int x = 0;
	scanf ("%i", &n);
	int pos[n];
	scanf ("%i", &pos[k]);
	n = n - 1;
	x = n;
	c = c + 1;
	while (n > 0){
		k = c;
		scanf ("%i", &pos[k]);
		while (k > 0){
			if (pos[k-1] > pos[k]){
				r = pos[k];
				pos[k] = pos[k-1];
				pos[k-1] = r;
				k = k - 1;
			}
			else
				k = k - 1;

		}
		n = n - 1;
		c = c + 1;
	}
	while (x >= 0){
		printf ("%i ", pos[n]);
		n = n + 1;
		x = x - 1;
	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,temp=0;
scanf("%d",&n);
int *p=(int*)malloc(sizeof(int)*n);
int i=0,flag=1;
//printf("enter boxes");
for(i;i<n;i++)
scanf("%d",(p+i));
while (flag)
{
flag=0;
for(i=0;i<n-1;i++)
{
if(p[i]>p[i+1])
{
temp=p[i];
p[i]=p[i+1];
p[i+1]=temp;
flag=1;
}
}
}
for(i=0;i<n;i++)
printf("%d\t",p[i]);
return 0;

}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int nc,i,j,aux;
	int T[100];
	scanf("%d",&nc);
	for (i=1;i<=nc;i++)
		{
			scanf("%d",&T[i]);
		}
	for (i=0;i<nc;i++)
		{
			j=nc;
			while (i!=j)
				{
					if (T[j]<T[j-1])
					{
						aux=T[j];
						T[j]=T[j-1];
						T[j-1]= aux;
					}
					j= j-1;
				}
		}
	for (i=0;i<nc;i++)
	{
		printf("%d ",T[i]);
	}
return 0;

}

#include<stdio.h>
int main (){
int m, i, meses[100], min, posmax,a;
m=0;

scanf("%d",&a);

for(i=1; i<=a; i++)
    scanf("%d", &meses[i]);

while(m<a)
{
posmax=min=101;
for(i=1; i<=a; i++)
{
if(meses[i]<min)
{
min=meses[i];
posmax=i;
}
}
printf("%d ", min);
meses[posmax]=101;
m++;

}

return 0;
}

#include<stdio.h>
int main()
{
    int n,i,j,k,dif=0;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
    scanf("%d",&arr[i]);
    j=n-1;
    for(i=j-1;i>=0;i--)
    {
        for(k=i;k<j;k++)
        {
            if(arr[k]>arr[k+1])
            {
                dif=arr[k]-arr[k+1];
                arr[k+1]=arr[k+1]+dif;
                arr[k]=arr[k]-dif;
            }
        }
    }
    for(i=0;i<n;i++)
    printf("%d ",arr[i]);
}

#include<stdio.h>
int main()
{
    int n,i,j,temp=0;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(arr[i]>arr[j])
            {
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",arr[i]);
    }
    return 0;
}

#include<stdio.h>
int main()
{
                    int n,temp,max,in;
                    scanf("%d",&n);
                    int a[n];
                    for(int i=0;i<n;i++)
                    {
                                        scanf("%d",&a[i]);
                    }

                    for(int i=0;i<n-1;i++)
                    {
                                        max=a[i],in=i;
                                        for(int j=i;j<n;j++)
                                        {
                                              if(a[j]<max)
                                              {
                                                       max=a[j];
                                                       in=j;
                                              }
                                        }
                                        temp=a[i];
                                        a[i]=max;
                                        a[in]=temp;
                    }
                     for(int i=0;i<n;i++)
                    {
                                        printf("%d ",a[i]);
                    }
}

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int array[n];
    for (int i=0;i<n;i++)
    {
      scanf("%d",&array[i]);

    }int swap =0;
     for (int c = 0 ; c < n - 1; c++)
  {
    for (int d = 0 ; d < n - c - 1; d++)
    {
      if (array[d] > array[d+1]) /* For decreasing order use < */
      {
        swap       = array[d];
        array[d]   = array[d+1];
        array[d+1] = swap;
      }
    }
  }
     for (int i=0;i<n;i++)
    {
      printf("%d ",array[i]);

    }

}

int compare(const void* a, const void* b){
    int value1 = *((int*) a);
    int value2 = *((int*)b);
    if (value1 <value2) return -1;
    if (value1 > value2) return 1;
    return 0;
}

int main(){
    int n,i,temp;
    scanf("%d", &n);
    int A[n];
    for (i=0; i<n;i++){
        scanf("%d",&A[i]);
    }
    qsort(A,n, sizeof(int), compare);
    /*for (i=0;i<n-1;i++){
        if (A[i]> A[i+1]){
            temp= A[i+1];
            A[i+1] = A[i];
            A[i] = temp;
        }
    }*/
    for(i =0;i<n;i++){
        printf("%d", A[i]);
        printf(" ");
       }
    return 0;

}

#include <stdio.h>
#include <stdlib.h>
void makeArray (int x);
void sortArray (int array[],int);
void swap (int * , int *);
void printArray(int array[],int);

int main()
{  int x ;
scanf("%d",&x);
  makeArray(x);
    return 0;
}
void makeArray(int x)
{
     int array[x];
     int i;
     for (i=0;i<x;i++)
     {
         scanf("%d",&array[i]);
     }

sortArray(array,x);
}
void sortArray(int array[],int x)
{
    int i= 0;int j=0;

     for (i=0;i<x;i++)
     {
         for (j=i+1;j<x;j++)
         {
             if (array[i]>array[j])
             {
                 swap(&(array[i]),&(array[j]));
             }
         }
     }
     printArray(array,x);
}
void swap(int*x,int*y)
{
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void printArray(int array[],int x)
{
    int i;
//int arraySize = sizeof(array)/sizeof(int);
  //  printf("Array size = %d \n",arraySize);
    for(i=0;i<x;i++)
    {
        printf("%d ",array[i]);
    }
}

#include <stdio.h>

int main() {

int n;

int sortArr(int *ptr, int n);

//printf("please enter number of columns\t");

scanf("%i", &n);

int a[n];

int *ptr=&a[n];

for (int i=0; i<n; i++)
	scanf("%i", &a[i]);

sortArr(a, n);

for (int i=0; i<n; i++)
	printf("%i ", a[i]);
}

int sortArr(int *ptr, int n){

int temp=0;

for (int j=0; j<n; j++){
for (int i=0; i<n-1; i++){

	if (*(ptr+(i+1)) < *(ptr+(i))){
		temp=*(ptr+(i));
		*(ptr+(i))=*(ptr+(i+1));
		*(ptr+(i+1))=temp;
		}
	}
}
}

#include<stdio.h>
#include<string.h>
int main(){
 int i,n,j,t;
 scanf("%d",&n);
 int a[n];
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 for(i=0;i<n-1;i++){
  for(j=i+1;j<n;j++){
   if(a[i]>a[j]){
    t=a[i];
    a[i]=a[j];
    a[j]=t;
}}}
 for(i=0;i<n;i++)
  printf("%d ",a[i]);
 return(0);
}

#include<stdio.h>
int main()
{
    int i,j,a,n,number[201];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&number[i]);
    }
    for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                    if(number[i]>number[j])
                    {
                        a=number[i];
                        number[i]=number[j];
                        number[j]=a;
                    }
            }
        }
    for(i=0;i<n;i++)
       {
           printf("%d ",number[i]);
        }
return 0;
    }

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n );
    int a[n];
    int temp;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(int i=0;i<n;i++){
        printf("%d ",a[i]);
    }
}

#include<stdio.h>

int main()
{
    int arr[99999],ar[99999];

    int n,i,j,temp,l,k;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
    }

    for(j=0; j<n; j++)
    {
        for(k=0; k<n; k++)
        {
            if(arr[j]<arr[k])
            {
                temp=arr[j];
                arr[j]=arr[k];
                arr[k]=temp;

            }
        }
    }

    for(l=0; l<n; l++)
        printf("%d ",arr[l]);

    return 0;
}

#include <stdio.h>
int main()
{
    int m,i,dattos[100],min,posmax,a;
    m=0;
    scanf("%d", &a);
    for(i=1;i<=a;i++)
        scanf("%d",&dattos[i]);

    while (m<a)
    {
        posmax=min=101;
        for (i=1; i<=a; i++)
    {
            if(dattos[i]<min)
            {
                min=dattos[i];
                posmax=i;
            }
        }
        printf("%d ", min);
        dattos[posmax]=101;
        m++;
    }
    return 0;
}

#include <stdio.h>
int main()
{
    int m,i,datos[100],min,posmax,a;
    m=0;
    scanf("%d", &a);
    for(i=1;i<=a;i++)
        scanf("%d",&datos[i]);

    while (m<a)
    {
        posmax=min=101;
        for (i=1; i<=a; i++)
    {
            if(datos[i]<min)
            {
                min=datos[i];
                posmax=i;
            }
        }
        printf("%d ", min);
        datos[posmax]=101;
        m++;
    }
    return 0;
}

#include<stdio.h>
// BUBBLE SORT
main()
{
    int n,a[100],i,j,temp,swap;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    while(1)
    {
        swap=0;
        for(i=0;i<n-1;i++)
        {
            if(a[i]>a[i+1])
            {
                temp=a[i];
                a[i]=a[i+1];
                a[i+1]=temp;
                swap=1;
            }
        }
        if(swap==0) break;
    }

for(i=0;i<n;i++)
    {
        printf("%d ",a[i]);
    }
}

#include<stdio.h>

int main()
{

    int n;
    scanf("%d", &n);
    int ara[n], i, j, temp,swapped;
    for(i=0; i<n; i++){
    scanf("%d", &ara[i]);
    }
     while(1){
        swapped=0;
        for(i=0; i<n-1; i++){
            if(ara[i]>ara[i+1]){
               temp=ara[i];
               ara[i]=ara[i+1];
               ara[i+1]=temp;
               swapped=1;
        }
        }
        if(swapped==0){
            break;
        }
     }
    for(i=0; i<n; i++){
        printf("%d ", ara[i]);
    }
}

#include<stdio.h>
int main()
{
    int n, i, j, mini, k;
    scanf("%d", &n);

    int ar[n];

    for(i = 0; i < n; i++){
        scanf("%d", &ar[i]);
    }

    //mini = ar[0];

    for(i = 0; i < n; i++){
        mini = ar[i];
        for(j = i; j < n; j++){
            if(mini >= ar[j]){
                mini = ar[j];
                k = j;
            }
        }

        ar[k] = ar[i];
        ar[i] = mini;
    }

    for(i = 0; i < n; i++){
        printf("%d ", ar[i]);
    }

    return 0;
}

#include<stdio.h>
int main()
{
    int n, i, j, mini, k;
    scanf("%d", &n);

    int ar[n];

    for(i = 0; i < n; i++){
        scanf("%d", &ar[i]);
    }

    //mini = ar[0];

    for(i = 0; i < n; i++){
        mini = ar[i];
        for(j = 0; j < n; j++){
            if(mini >= ar[j]){
                mini = ar[j];
                k = j;
            }
        }
       printf("%d ", mini);
       ar[k] = 101;
    }

    return 0;
}

#include<stdio.h>
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp=temp;
}

void bubbleSort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++) {
       for (j = 0; j < n-i-1; j++){
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
       }
   }
}
int main()
{
    int t,a,b;
    scanf("%d",&t);
    int ar[t],arr[t];
    for(a=0;a<t;a++)
    {
        scanf("%d",&ar[a]);
        arr[a]=ar[a];
    }

    bubbleSort(ar,t);

    for(a=0;a<t;a++)
    {
        printf("%d ",ar[a]);
    }
}

#include<stdio.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(a[j]>a[j+1])
            {
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }

    }
    for(i=0;i<n;i++)
    printf("%d ",a[i]);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main()
{
int c[111]={0};
int n,i,a;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a);
c[a]++;
}
for(i=0;i<111;i++)
{
while(c[i]>0)
{
printf("%d ",i);
c[i]--;
}
}
return 0;
}

#include <stdio.h>
#define SCAN(n) scanf("%d",&(n))
#define PRINT(n) printf("%d\n",(n))
#define N 101
#define loop(a,b) for(a=0;a<b;a++)
int main(){
     int n, sort[N]={0},num[N],c;
     SCAN(n);
     loop(c,n){
          SCAN(num[c]);
          sort[num[c]]++;
     }
     loop(c,N){
          while(sort[c]>0){
               PRINT(c);
               sort[c]--;
          }
     }
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int num[n+5], i;
    for (i=0; i<n; i++){
        scanf("%d", &num[i]);
    }

    int tem;

    for (i=0; i<(n-1); i++)
    {
        while (num[i]>num[i+1]){
            tem=num[i];
            num[i]=num[i+1];
            num[i+1]=tem;
            if (i!=0)
                i--;
        }

    }

    for (i=0; i<n; i++){
        printf("%d ", num[i]);
    }
}

#include<stdio.h>

main()
{
    int j,a,n,i,number[200];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&number[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {  if(number[i]>number[j]){
            a=number[i];
            number[i]=number[j];
            number[j]=a;
        }}
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",number[i]);

    }
    return 0;
}

#include<stdio.h>
#include<string.h>
main()
{
    int n,minimum,index_2,minimum_index,i;
    scanf("%d",&n);
    int ara1[n],ara2[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara1[i]);
    }
    for(index_2=0;index_2<n;index_2++)
    {
        minimum=10000;
        for(i=0;i<n;i++)
        {
            if(ara1[i]<minimum)
            {
                minimum=ara1[i];
                minimum_index=i;
            }
        }
        ara1[minimum_index]=10000;
        ara2[index_2]=minimum;
    }
    for(i=0;i<n;i++)
    {
        printf("%d ",ara2[i]);
    }
    return 0;
}

#include <stdio.h>

void insertionSort (int arr[],int n){
    for (int i=1;i<n;i++){
        int currData = arr[i];
        int j=i-1;
        while(j>=0 && currData < arr[j]){ //j>=0 to prevent out of bounds
            arr[j+1] = arr[j]; //If false , geser terosss
            j--;
        }
        arr[j+1] = currData; //Kalau udah bener , jangan ngegas terossss
    }
}

int main(){
    int n;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    insertionSort(arr,n);
    for(int i=0;i<n;i++){
        printf("%d ",arr[i]);
    }
}

#include<stdio.h>
#include<string.h>
main()
{
    int n,minimum,index_2,minimum_index,i;
    scanf("%d",&n);
    int ara1[n],ara2[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara1[i]);
    }
    for(index_2=0;index_2<n;index_2++)
    {
        minimum=10000;
        for(i=0;i<n;i++)
        {
            if(ara1[i]<minimum)
            {
                minimum=ara1[i];
                minimum_index=i;
            }
        }
        ara1[minimum_index]=10000;
        ara2[index_2]=minimum;
    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",ara2[i]);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main() {

   unsigned short n,m;
   scanf("%hu",&n);
   unsigned short num[n];

   for(unsigned short i = 0; i<n ;i++)
      scanf("%hu",&num[i]);
   m=n;
   for(unsigned short i = 0; i<m-1 ;i++)
   {
       for(unsigned short j = 0; j<n-1 ;j++)
       {
           if(num[j]>num[j+1])
           {
            unsigned short temp=num[j];
            num[j]=num[j+1];
            num[j+1]=temp;
           }
       }
       n--;
   }
   for(unsigned short i = 0; i<m ;i++)
      printf("%hu ",num[i]);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main() {

   unsigned short n;
   scanf("%hu",&n);
   unsigned short num[n];

   for(unsigned short i = 0; i<n ;i++)
      scanf("%hu",&num[i]);

   for(unsigned short i = 0; i<n-1 ;i++)
   {
       for(unsigned short j = 0; j<n-1 ;j++)
       {
           if(num[j]>num[j+1])
           {
            unsigned short temp=num[j];
            num[j]=num[j+1];
            num[j+1]=temp;
           }
       }
   }
   for(unsigned short i = 0; i<n ;i++)
      printf("%hu ",num[i]);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main() {

   unsigned short n,m;
   scanf("%hu",&n);
   unsigned short num[n];

   for(unsigned short i = 0; i<n ;i++)
      scanf("%hu",&num[i]);
   m=n;
   for(unsigned short i = 0; i<n-1 ;i++)
   {
       for(unsigned short j = 0; j<m-1 ;j++)
       {
           if(num[j]>num[j+1])
           {
            unsigned short temp=num[j];
            num[j]=num[j+1];
            num[j+1]=temp;
           }
       }
       m--;
   }
   for(unsigned short i = 0; i<n ;i++)
      printf("%hu ",num[i]);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,temp;
    scanf("%d",&n);
    int elements[n];
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d",&elements[i]);
    }

     for (i = 0; i < n; i++)
    {
        for (j = 0; j < (n - i - 1); j++)
        {
            if (elements[j] > elements[j + 1])
            {
                temp = elements[j];
                elements[j] = elements[j + 1];
                elements[j + 1] = temp;
            }
        }
    }
    for(i = 0 ; i < n ; i++)
    {
        printf("%d ",elements[i]);
    }
    return 0;
}

#include<stdio.h>

int main()
{
    int x;
    scanf("%d",&x);

    int i,j,arr[x];

    for (i = 0; i < x; i++)
    scanf("%d",&arr[i]);

    for(i = 0; i < x; i++)
        {
          for(j = i+1; j < x; j++)
              {
                  int temp;
                  if(arr[i] > arr[j])
                  {
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                  }
              }
        }
    for (i = 0; i < x; i++)
    printf("%d ",arr[i]);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){
    int n=0, vetor[100], menor=0, i=0, j=0;

    scanf("%d", &n);

    //Lendo os valor e colocando no vetor.
    for(i=0; i<n; i++){
        scanf("%d", &vetor[i]);
    }

    //Colocando os valores do vetor em ordem.
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            if(vetor[i]<=vetor[j]){
                menor=vetor[i];
                vetor[i]=vetor[j];
                vetor[j]=menor;
            }
        }
    }

    //Imprimindo o resultado.
    for(i=0; i<n; i++){
        printf("%d", vetor[i]);

        if(i==n-1){
            printf("\n");
        }
        else{
            printf(" ");
        }
    }

    return 0;
}

#include <stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	int s[a];
	int i;
	for(i=0;i<a;i++){
		scanf("%d",&s[i]);}
		int j;
	int max;
		for(i=0;i<a;i++)
		{
			for(j=0;j<a;j++)
			{
				if(s[i]<=s[j])
				{
					max=s[j];
					s[j]=s[i];
					s[i]=max;
				}
			}

		}
		for(i=0;i<a;i++){
		printf("%d ",s[i]);}
		return 0;
		}

#include <stdio.h>
#include <stdlib.h>

int cmpfunc (const int * a, const int * b) {
   return *a - *b;
}

int main(){
    int col;
    scanf("%d", &col);
    int * mat = (int*) malloc(sizeof(int) * col);
    for(int i = 0; i < col; i++){
        scanf("%d", &mat[i]);
    }
    qsort(mat, col, sizeof(int), cmpfunc);
    for(int i = 0; i < col - 1; i++){
        printf("%d ", mat[i]);
    }
    printf("%d\n", mat[col - 1]);
    return 0;
}

#include<stdio.h>
int main()
{
 long long int n,i,j,k,min,m;
 scanf("%lld",&n);
 long long int ar[n];
 for(i=0;i<n;i++)
 {
     scanf("%lld",&ar[i]);

 }
 for(i=0;i<n;i++){
  for(j=i+1;j<n;j++){
  if(ar[i]>ar[j])
  {
      m=ar[i];
      ar[i]=ar[j];
      ar[j]=m;
  }
    }}
  for(i=0;i<n;i++)
    printf("%lld ",ar[i]);

 printf("\n");
    return 0;
}

int main(){
    int a;
    int arr[500];
    int i;
    scanf("%d",&a);
    for(i=0;i<a;i++){
            scanf("%d",arr+i);
    }
    int c;
    int g;
    int ind;
    for(g=0;g<a;g++){
    for(i=0;i<a;i++){
        int temp=arr[i];
            for(c=i;c<a;c++){
                if(temp<=arr[c] && c!=i){
                ind=1;
                break;
                }
            }
            if(c==a)
            {
                int temp=arr[i];
                arr[i]=arr[i]-(arr[i]-arr[c-1]);
                arr[c-1]=arr[c-1]+(temp-arr[c-1]);
                ind=0;
                continue;
            }
            if(ind==1){
            int temp=arr[i];
            arr[i]=arr[i]-(arr[i]-arr[c-1]);
            arr[c-1]=arr[c-1]+(temp-arr[c-1]);
                }
            ind=0;
    }}
     for(i=0;i<a;i++){
         printf("%d ",arr[i]);
    }

}

int main() {
    int i,j,n,gecici;
    scanf("%d",&n);
    int dizi[n];
    for(i=0;i<n;i++)
        scanf("%d",&dizi[i]);
    for(i=0;i<n-1;i++)
        for(j=0;j<n-i-1;j++)
            if(dizi[j]>dizi[j+1]) {
                gecici=dizi[j];
                dizi[j]=dizi[j+1];
                dizi[j+1]=gecici;
            }
    for(i=0;i<n;i++)
        printf("%d ",dizi[i]);
}

#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n = 0;
    int *a = NULL;
    int i = 0;
    int j = 0;
    int t = 0;

    scanf("%d" , &n);

    a = (int *)calloc(n , sizeof(int));

    for(i=0 ; i<n ; ++i)
    {
    scanf("%d" , &a[i]);
    }

    for(i=0 ; i<n ; ++i)
    {
        for(j=i+1 ; j<n ; j++)
        {
            if(a[i] > a[j])
            {
                t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }
    }

    for(i=0 ; i<n ; ++i)
    {
        printf("%d " , a[i]);
    }

    return 0;

}

#include<stdio.h>
int main(void)
{
    int num = 0;
    scanf("%d", &num);

    int arr[num];

    for (int i = 0; i < num; i++)
    {
        scanf("%d", &arr[i]);
    }

    for (int i = 0; i < num; i++)
    {
        for (int j = 0; j < num; j++)
        {
            if (arr[j] >= arr[j + 1])
            {
                int temp = arr[j];
                arr[j] = arr[j +1];
                arr[j + 1] = temp;
            }
        }
    }

    for (int i = 0; i < num; i++)
    {
        printf("%d ", arr[i]);
    }

}

#include<stdio.h>
int main(){ int n ,i,j,temp;
    int a[101];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
     for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
         if(a[i]>a[j]){
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
         }
      }
   }
   for(i=0;i<n;i++){
        printf("%d ",a[i]);
    }
return 0;}

#include <stdio.h>
#include <stdlib.h>

int main(){
	int vetor[100],n,i,j,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&vetor[i]);
	}
	min = vetor[0];
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(vetor[i]<=vetor[j]){
				min = vetor[i];
				vetor[i] = vetor[j];
				vetor[j] = min;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d ",vetor[i]);
	}
	return(0);
}

#include <stdio.h>

int main()
{
 int NumberOfBoxes;
 int boxes[100];
 int i,j,S;

 scanf("%d",&NumberOfBoxes);

 for(i=1; i<=NumberOfBoxes; i++){
     scanf("%d",&boxes[i]);
 }

 for(int m=0; m<NumberOfBoxes; m++){
     for(j=0; j<NumberOfBoxes; j++){

     if(boxes[j]>boxes[j+1]){
        S=boxes[j+1];
         boxes[j+1]=boxes[j];
         boxes[j]=S;

     }else{

     }

 }
 }
 for(int n=0; n<NumberOfBoxes; n++){

     printf("%d ",boxes[n]);
 }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int j,g,i,n;
   int a[100];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
   }
   for(i=0;i<n;i++)
   {

   for(j=i+1;j<n;j++)
   {
       if(a[i]>a[j])
       {
           g=a[i];
           a[i]=a[j];
           a[j]=g;
       }

   }
   }
   for(i=0;i<n;i++)
   {
       printf("%d ",a[i]);
   }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	int x,n,j,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){scanf("%d", &a[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
			x=a[i];
			a[i]=a[j];
			a[j]=x;
			}
	}
	}
	for(i=0;i<n;i++){printf("%d ",a[i]);
	}
	return 0;
}

#include<stdio.h>
#define SIZE 100

int main(){
	int n,i,j;
	int min,temp;
	int arr[SIZE];
	min = 101;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&arr[i]);
		if(arr[i] <min )min = arr[i];
	}
	for(i=n-2;i>=0;i--){
		if(arr[i] > min){
			for(j=n-1;j>i;j--){
				temp = arr[j];
				while(arr[i] > temp){
					arr[i]--;
					arr[j]++;
				}
			}
		}
	}
	for(i=0;i<n;i++)
		printf("%d ",arr[i]);
	printf("\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
for(int i=0;i<n;i++)
{
    scanf("%d",&arr[i]);
}

for(int i=0;i<n;i++)
{
     for(int j=n-1;j>i;j--)
    {
      if(arr[i]>arr[j])
    {
      int temp= arr[i];
      arr[i]=arr[j];
      arr[j]=temp;
     }
    }
}
for(int i=0;i<n;i++)
{
printf("%d ",arr[i]);
}

    return 0;
}

#include<stdio.h>
int main(){
       int n;
       scanf("%d",&n);
       int a[n];
       for(int i=0;i<n;i++)
       scanf("%d",&a[i]);
       for(int i=0;i<n;i++){
              for(int j=i+1;j<n;j++){
                     if(a[i]>a[j]){
                            int t;
                            t=a[i];
                            a[i]=a[j];
                            a[j]=t;
                     }
              }
       }
              for(int i=0;i<n;i++)
       printf("%d ",a[i]);
return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("asd.out","w",stdout);

    char str[120];
    int ar[120];

    int len, i;
    scanf("%d",&len);

    for(i=0;i<len;i++)
        scanf("%d",&ar[i]);

    int num[120] = {};

    for(i=0;i<len;i++)
        num[ ar[i] ]++;

    int cnt = 0;
    for(i=1;i<=100;i++)
        while( num[i]-- ) {
            printf("%d ",i);
            //if( ++cnt != len ) printf("+");
        }
    printf("\n");
    return 0;
}

/* Bubble sort code */

#include <stdio.h>

int main()
{
  int  n, c, d, swap;

  //printf("Enter number of elements\n");
  scanf("%d", &n);

 int array[n];
  //printf("Enter %d integers\n", n);

  for (c = 0; c < n; c++)
    scanf("%d", &array[c]);

  for (c = 0 ; c < n - 1; c++)
  {
    for (d = 0 ; d < n - c - 1; d++)
    {
      if (array[d] > array[d+1]) /* For decreasing order use < */
      {
        swap       = array[d];
        array[d]   = array[d+1];
        array[d+1] = swap;
      }
    }
  }

  //printf("Sorted list in ascending order:\n");

  for (c = 0; c < n; c++)
     printf("%d\n", array[c]);

  return 0;
}

#include<stdio.h>
void merge(int a[],int low,int mid, int high)
{
    int temp[high-low+1];
    int p1=low,p2=mid+1,k=0,i;
    while(p1<=mid && p2<=high)
    {
        if(a[p1]<a[p2])
        {
            temp[k++]=a[p1++];

        }
        else
        {
            temp[k++]=a[p2++];
        }
    }
    while(p1<=mid)
    {
        temp[k++]=a[p1++];
    }
    while(p2<=high)
    {
        temp[k++]=a[p2++];
    }
    for(i=0;i<k;i++)
    {
        a[low++]=temp[i];
    }

}

void mergesort(int a[],int low, int high)
{
    if(low<high)
    {
        int mid=(low+high)/2;
        mergesort(a,low,mid);
        mergesort(a,mid+1,high);
        merge(a,low,mid,high);
    }
    else
    {
        return;
    }
}

int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    mergesort(a,0,n-1);
    for(i=0;i<n;i++)
    {
        printf("%d ",a[i]);
    }

    return 0;

}

#include<stdio.h>
int main()
{
int m=0,i,meses[105],min=0,pos_max=0,n=0;

scanf("%d",&n);
 for(i=0;i<n;i++){
 scanf("%d",&meses[i]);
 }
 while(m<n){
min=101;
 for(i=0;i<n;i++){
 if(meses[i]<min){
 min=meses[i];
 pos_max=i;
 }

 }
  printf("%d ",min);
  meses[pos_max]=101;
  m++;
 }

return 0;
}

#include<stdio.h>
int main()
{
int n,m,j,i,arr[105],min=0,pos_min,temp;
scanf("%d",&n);
min=arr[0];
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(j=0;j<n-1;j++)

for(i=j+1;i<n;i++)
{
 if(arr[i]<arr[j])
 {
     temp=arr[i];
     arr[i]=arr[j];
     arr[j]=temp;
 }
}

for(i=0;i<n;i++)
    printf("%d ",arr[i]);

return 0;
}

#include<stdio.h>
void sort(int x,int n[])
{
	for (int i = 1; i < x; i++)
	{
    	int j = i;
    	while(j > 0 && n[j-1] > n[j]){
      	int tmp = n[j];
      	n[j] = n[j-1];
      	n[j-1] = tmp;
      	j--;
    	}
  	}

  	for (int i=0;i<=x-1;i++)
  	{
  		printf("%d ",n[i]);
	}
	return;
}
int main()
{
	int x;
	int n[102];
	scanf("%d",&x);

	for (int i=0;i<x;i++)
	{
		scanf("%d",&n[i]);
	}
	sort (x,n);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{int x,y=0,i,j;
	scanf("%d",&x);
	int a[x];

	for(i=0;i<x;i++){

	scanf("%d",&a[i]);	}
	for(i=0;i<x;i++)
	{
	for(j=0;j<x;j++)
	{
		if(a[i]>=a[y]){
			a[y]=a[i];
		}

	}
	y++;}
		for(i=0;i<x;i++){
			printf("%d",a[i]);
		}

return 0;

}

#include<stdio.h>

int main()
{
    int arr[99999],ar[99999];

    int n,i,j,temp,l,k;

    scanf("%d",&n);

    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
    }

    for(j=0; j<n; j++)
    {
        for(k=0; k<n; k++)
        {
            if(arr[j]<arr[k])
            {
                temp=arr[j];
                arr[j]=arr[k];
                arr[k]=temp;

            }
        }
    }

    for(l=0; l<n; l++)
        printf("%d ",arr[l]);

    printf("\b");

    return 0;
}

///theatre square
/*#include<stdio.h>
int main()
{
    long long int a,i,b,c,j,k,n=0,m=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    j=a/c*(a%c);
    k=b/c*(b%c);
    printf("%lld\n",j*k);
    return 0;
}*/
/*#include<stdio.h>
int main()
{
    long long int a,b,c,m,n;
    int v,k;
    scanf("%lld%lld%lld",&a,&b,&c);
    m=a/c;
    if(a%c)
    //v=a;
    m++;
    n=b/c;
    if(b%c)
    //k=b;
    n++;
    printf("%lld\n",m);
    return 0;
}*/
#include<stdio.h>
int main()
{
    int arr[10],i,a,k,temp,j;
     for(j=1;j<=2;j++){
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&arr[i]);}
        for(i=0;i<a;i++){

        for(k=i+1;k<a;k++)
        {
            if(arr[i]>arr[k])
            {
                temp=arr[i];
                arr[i]=arr[k];
                arr[k]=temp;
            }

        }
        printf("%d\t",arr[i]);}
        printf("\n");}

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int main() {
	int n,i,j;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		j=0;
		while (j<n){
			if(a[j]>=a[j+1]){
				a[j]-=1;
				a[j+1]+=1;
				}
				 else if(a[n-1]>a[j])
			j=n+1;
	j++;	}
	}
	for(i=0;i<n;i++)
	printf("%d ",a[i]);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
void makeArray (int x);
void sortArray (int array[],int);
void swap (int * , int *);
void printArray(int array[],int);

int main()
{  int x ;
scanf("%d",&x);
  makeArray(x);
    return 0;
}
void makeArray(int x)
{
     int array[x];
     int i;
     for (i=0;i<x;i++)
     {
         scanf("%d",&array[i]);
     }

sortArray(array,x);
}
void sortArray(int array[],int x)
{
    int i= 0;int j=0;

     for (i=0;i<x;i++)
     {
         for (j=i+1;j<x;j++)
         {
             if (array[i]>array[j])
             {
                 swap(&(array[i]),&(array[j]));
             }
         }
     }
     printArray(array,x);
}
void swap(int*x,int*y)
{
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void printArray(int array[],int x)
{
    int i;
//int arraySize = sizeof(array)/sizeof(int);
  //  printf("Array size = %d \n",arraySize);
    for(i=0;i<x;i++)
    {
        printf("%d",array[i]);
    }
}

#include<stdio.h>
int main()
{
    int n,a[100],i,temp,mid,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        mid=i;
        for(j=i+1;j<n;j++)
        {
            if(a[mid]>a[j])
            mid=j;
        }
        if(mid!=i)
        {
            temp=a[mid];
            a[mid]=a[i];
            a[i]=temp;
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d",a[i]);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,arr[100],temp;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {

        scanf("%d",&arr[i]);

    }
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(arr[j]<arr[i])
            {
                temp=arr[j];
                arr[j]=arr[i];
                arr[i]=temp;
            }
        }
    }

        for(i=0;i<n;i++)
        {

            printf("%d",arr[i]);
        }

    return 0;
}

#include<stdio.h>
void merge(int a[],int low,int mid, int high)
{
    int temp[high-low+1];
    int p1=low,p2=mid+1,k=0,i;
    while(p1<=mid && p2<=high)
    {
        if(a[p1]<a[p2])
        {
            temp[k++]=a[p1++];

        }
        else
        {
            temp[k++]=a[p2++];
        }
    }
    while(p1<=mid)
    {
        temp[k++]=a[p1++];
    }
    while(p2<=high)
    {
        temp[k++]=a[p2++];
    }
    for(i=0;i<k;i++)
    {
        a[low++]=temp[i];
    }

}

void mergesort(int a[],int low, int high)
{
    if(low<high)
    {
        int mid=(low+high)/2;
        mergesort(a,low,mid);
        mergesort(a,mid+1,high);
        merge(a,low,mid,high);
    }
    else
    {
        return;
    }
}

int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    mergesort(a,0,n-1);
    for(i=0;i<n;i++)
    {
        printf("%d",a[i]);
    }

    return 0;

}

#include<stdio.h>
#include<string.h>
int main(){
 int i,n,j,t;
 scanf("%d",&n);
 int a[n];
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 for(i=0;i<n-1;i++){
  for(j=i+1;j<n;j++){
   if(a[i]>a[j]){
    t=a[i];
    a[i]=a[j];
    a[j]=t;
}}}
 for(i=0;i<t;i++)
  printf("%d ",a[i]);
 return(0);
}

#include<stdio.h>

int arr[103];

int main(){

    int i,j=1,n,temp=0,swp,k;

    scanf("%d",&n);
    for(i=0;i<n;i++){

        scanf("%d ",&arr[i]);
        if(arr[i]>n)temp=1;
    }

    //for(i=0;i<n;i++)printf("%d",arr[i]);
    if(temp != 1){
        for(j=1;j<n;j++)
        for(i=j;i>0;i--){
            if(arr[i]<arr[i-1]){swp=arr[i];arr[i]=arr[i-1];arr[i-1]=swp;}

        }
        for(k=0;k<n;k++)printf("%d ",arr[k]);
    }
    else for(i=0;i<n;i++)printf("%d ",arr[i]);

    return 0;
}

///theatre square
/*#include<stdio.h>
int main()
{
    long long int a,i,b,c,j,k,n=0,m=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    j=a/c*(a%c);
    k=b/c*(b%c);
    printf("%lld\n",j*k);
    return 0;
}*/
/*#include<stdio.h>
int main()
{
    long long int a,b,c,m,n;
    int v,k;
    scanf("%lld%lld%lld",&a,&b,&c);
    m=a/c;
    if(a%c)
    //v=a;
    m++;
    n=b/c;
    if(b%c)
    //k=b;
    n++;
    printf("%lld\n",m);
    return 0;
}*/
#include<stdio.h>
int main()
{
     int arr[10],i,a,k,temp,j;
     for(j=1;j<=2;j++){
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&arr[i]);}
        for(i=0;i<a;i++){

        for(k=i+1;k<a;k++)
        {
            if(arr[i]>arr[k])
            {
                temp=arr[i];
                arr[i]=arr[k];
                arr[k]=temp;
            }

        }
        printf("%d\n",arr[i]);}}

    return 0;
}

#include<stdio.h>

int main()
{

    int n;
    scanf("%d", &n);
    int ara[n], i, j, temp, sortted;
    for(i=1; i<=n; i++){
    scanf("%d", &ara[i]);

    }
    for(i=0; i<n; i++){
        sortted=0;
        for(j=0; j<n-i; j++){
            if(ara[j]>ara[j+1]){
                temp=ara[j];
                ara[j]=ara[j+1];
                ara[j+1]=temp;
                sortted=1;
            }

        }
        if(sortted==0){
            break;
        }
    }
    for(i=0; i<n; i++){
        printf("%d ", ara[i]);
    }
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,arr[100],flag,temp;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {

        scanf("%d",&arr[i]);
        if(arr[i]<1||arr[i]>100)
        {
            flag=1;
        }
    }
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(arr[j]<arr[i])
            {
                temp=arr[j];
                arr[j]=arr[i];
                arr[i]=temp;
            }
        }
    }
    if(n>=1&&n<=100&&flag!=1)
    {
        for(i=0; i<n; i++)
        {

            printf("%d\t",arr[i]);

        }
    }

    return 0;
}

#include<stdio.h>
int main()
{
                    int n,temp,max;
                    scanf("%d",&n);
                    int a[n];
                    for(int i=0;i<n;i++)
                    {
                                        scanf("%d",&a[i]);
                    }

                    for(int i=0;i<n;i++)
                    {
                                        max=a[i];
                                        for(int j=i;j<n;j++)
                                        {
                                              if(a[j]<max)
                                              {
                                                                  temp=a[i];
                                                                  a[i]=a[j];
                                                                  a[j]=temp;
                                              }
                                        }
                    }
                     for(int i=0;i<n;i++)
                    {
                                        printf("%d ",a[i]);
                    }
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
for(int i=0;i<n;i++)
{
    scanf("%d",&arr[i]);
}

for(int i=0;i<n-1;i++)
{
    if(arr[i]>arr[n-1])
    {
      int temp= arr[i];
      arr[i]=arr[n-1];
      arr[n-1]=temp;
    }
     if(arr[0]>arr[i])
    {
      int temp= arr[i];
      arr[i]=arr[0];
      arr[0]=temp;
    }
}
for(int i=0;i<n;i++)
{
printf("%d ",arr[i]);
}

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *arr, n, i, j, temp;
    scanf("%d",&n);
    arr = (int*)malloc(n*sizeof(int));
    for(i = 0; i < n; i++)
    scanf("%d", &arr[i]);
    for(i = 0; i < n; i ++)
    {
        for(j = 0; j < (n-1-i) ; j++)
        {
            if(arr[j] > arr[j+1])
            temp = arr[j];
            arr[j] = arr[j+1];
            arr[j+1] = temp;
        }
    }
    for(i = 0; i < n; i++)
    printf("%d ", arr[j]);
    return 0;
}

#include<stdio.h>

int main (){

int caja[120];
int x,j,b,aux;

scanf("%d",&b);

for(x=0;x<b;x++){

    scanf("%d",&caja[x]);

}

 for(x=0;x<b;x++){

    for(j=0;j<b;j++){

        if(caja[j]>caja[j+1]){
            aux=caja[j];
            caja[j]=caja[j+1];
            caja[j+1]=aux;

        }

    }

 }

    for(j=0;j<b;j++){

       printf("%d ",caja[j]);
    }

}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int n;
	scanf("%d", &n);
	int max=0, min=101;
	int *a=(int *)malloc(n*sizeof(int));
	int *res=(int *)malloc(n*sizeof(int));
	int cubes[101]={0};
	int i,j;
	for(i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
			if(a[i]>max)
				max=a[i];

			for(j=1;j<=a[i];j++)
				cubes[j]++;
		}

	for(i=n-1;i>=0;i--)
	{
		for(j=1;j<=max;j++)
		{
			if(cubes[j]>0)
				{
					res[i]+=1;
					cubes[j]--;
				}

		}

	}

	for(i=0;i<n;i++)
		printf("%d ",res[i]);
	printf("\n");

}

///theatre square
/*#include<stdio.h>
int main()
{
    long long int a,i,b,c,j,k,n=0,m=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    j=a/c*(a%c);
    k=b/c*(b%c);
    printf("%lld\n",j*k);
    return 0;
}*/
/*#include<stdio.h>
int main()
{
    long long int a,b,c,m,n;
    int v,k;
    scanf("%lld%lld%lld",&a,&b,&c);
    m=a/c;
    if(a%c)
    //v=a;
    m++;
    n=b/c;
    if(b%c)
    //k=b;
    n++;
    printf("%lld\n",m);
    return 0;
}*/
#include<stdio.h>
int main()
{
    int arr[10],i,a,k,temp,j;
     for(j=1;j<=2;j++){
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&arr[i]);}
        for(i=0;i<a;i++){

        for(k=i+1;k<a;k++)
        {
            if(arr[i]>arr[k])
            {
                temp=arr[i];
                arr[i]=arr[k];
                arr[k]=temp;
            }

        }
        printf("%d ",arr[i]);}
        }

    return 0;
}

#include <stdio.h>
int main()
{
    int m,meses[100],min,posmax,i,a;
    m=0;
    scanf("%d", &a);
    for(i=1;i<=a;i++)
        scanf("%d",&meses[i]);

    while (m<a)
    {
        posmax=min=101;
        for (i=1; i<a; i++)
    {
            if(meses[i]<min)
            {
                min=meses[i];
                posmax=i;
            }
        }
        printf("%d", min);
        meses[posmax]=101;
        m++;
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int n,max;
	scanf("%d",&n);
	int a[n];
    for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		max=a[0];
		if(a[i]>max)
		max=a[i];
	}
	int b[max];
	for(int i=0;i<=max;i++){
b[i]=0;
}
for(int i = 0;i<n;i++){
	for(int j =0;j<a[i];j++){
		b[j]++;
	}
}

    int c[max];
    for(int i=0;i<=max;i++){
c[i]=0;
}
for(int i = 0;i<max;i++){
	for(int j =0;j<b[i];j++){
		c[j]++;
	}
	}
for(int i=n-1;i>=0;i--){

printf("%d",c[i]);
printf(" ");
}

}

int main() {
    int i,j,n;
    scanf("%d",&n);
    int *dizi=(int*) malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
        scanf("%d",&dizi[i]);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            while(dizi[i]>dizi[j]) {
                dizi[i]--;
                dizi[j]++;
            }
    for(i=0;i<n;i++)
        printf("%d",dizi[i]);
}

#include<stdio.h>
int main()
{int n,i,t;
scanf("%d",&n);
int col[n];
for(i=0;i<n;i++)
scanf("%d",&col[i]);
for(i=0;i<n-1;i++)
{if(col[i]>col[i+1])
{t=col[i];
col[i]=col[i+1];
col[i+1]=t;
}
else
continue;
}
for(i=0;i<n;i++)
printf("%d\t",col[i]);
return 0;
}

#include<stdio.h>
int main(void)
{
    int num = 0;
    scanf("%d", &num);

    int arr[num], min = -1, index = 0;

    for (int i = 0; i < num; i++)
    {
        scanf("%d", &arr[i]);

        if (min > arr[i])
        {
            min = arr[i];
            index = i;
        }
    }
    if (arr[0] < arr[1])
        {
            for (int i = 0; i < num; i++)
            {
                printf("%d ", arr[i]);
            }
            return 0;
        }

    for (int i = 0; i < num; i++)
    {
        for (int j = 0; j < num; j++)
        {
            if (arr[j] >= arr[j + 1])
            {
                int temp = arr[j];
                arr[j] = arr[j +1];
                arr[j + 1] = temp;
            }
        }
    }
    if (arr[0] <= arr[1])
        {
            for (int i = 0; i < num; i++)
            {
                printf("%d ", arr[i]);
            }
            return 0;
        }

}

#include <stdio.h>

int main(void)
{
    int n,i,j,tp,a[1000];
    scanf("%d",&n);
    for (i=0;i<n;i++)
        scanf("%d",&a[i]);
    //Merge sort
    for (i=1;i<=n;i++)
    {
        j=i;
        tp=a[i];
        while (a[j-1]>tp && j>0) a[j]=a[j-1], j--;
        a[j]=tp;
    }
    for (i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d",a[i]);
}

#include <stdio.h>
int n,i,j,ctr;
int a[100],b[100];

int main()
{
    scanf("%d",&n);
    for(i=0; i<n; ++i)
        scanf("%d",a+i);
    for(i=0; i<n; ++i)
    {
        ctr=0;
        for(j=0; j<n; ++j)
            if(a[j]>i)
                ++ctr;
        b[i] = ctr;
    }
    for(i=n-1; i>=0; --i)
    {
        ctr=0;
        for(j=0; j<n; ++j)
            if(b[j]>i)
                ++ctr;
        printf("%d ",ctr);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(){
	int i = 0;
	int len = 0;
	int cols[100];
	scanf("%d", &len);
	for (i = 0; i < 100; i++){
		cols[i] = 0;
	}
	for (i = 0; i < len; i++){
		cols[getchar() - '0']++;
		getchar();
	}
	for (i = 0; i < len+1; i++){
		while (cols[i] > 0){
			printf("%d ", i);
		}
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
 int i,n,j,t;
 scanf("%d",&n);
 int a[n];
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 for(i=0;i<n-1;i++){
  for(j=i+1;j<n;j++){
   if(a[i]<a[j]){
    t=a[i];
    a[i]=a[j];
    a[j]=t;
}}}
 for(i=0;i<t;i++)
  printf("%d ",a[i]);
 return(0);
}

#include<stdio.h>
#include<math.h>
int main()
{
	int x;
	int temp=0;
	int a[100];
    scanf("%d", &x);
	for (int i = 0; i < x; i++)
	{
		scanf("%d", &a[i]);
	}
    for(int i=0;i<x-1;i++)
		for (int j = i; j < x; j++)
		{
			if (a[j] < a[i])
			{
				temp = a[j];
				a[j] = a[i];
				a[i] = temp;
			}
		}
	for (int i = 0; i < x; i++)
	{
		printf("%d", a[i]);
	}
//system("pause");

}

#include <stdio.h>
#define MAX 100
int main() {

    int G_tate[MAX][MAX];
    int ans[MAX];
    int i, j ,k;
    int n;
    int a;

    for( i = 0; i < MAX; i++ ) {
        for( j = 0; j < MAX; j++ ) {
            G_tate[i][j] = 0;
            ans[i] = 0;
        }
    }

    scanf("%d" ,&n);

    for( i = 0; i < n; i++ ) {

        scanf("%d" ,&a);

        for( j = 0; j < a; j++ ) {
            G_tate[i][j] = 1;
        }
    }

    /*for debag
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ ) {
            printf("%d ",G_tate[i][j]);

        }
        printf("\n");
    }
    printf("\n");
    /*for debag*/

    for(k = 0; k < n; k++) {
        for( i = 0; i < n; i++ ) {
            for( j = 0; j < n; j++ ) {

                if(G_tate[i][j] == 0 && G_tate[i - 1][j] == 1) {
                    G_tate[i][j] = 1;
                    G_tate[i - 1][j] = 0;
                }
            }
        }
    }

    /*for debag
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ ) {
            printf("%d ",G_tate[i][j]);

        }
        printf("\n");
    }
    printf("\n");
    /*for debag*/

    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ ) {

            if(G_tate[i][j] == 1)ans[i]++;

        }
    }

    for(i = 0; i < n; i++ ) {
        printf("%d " ,ans[i]);
    }

    printf("\n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int nc,i,j,aux;
	int T[100];
	scanf("%d",&nc);
	for (i=1;i<=nc;i++)
		{
			scanf("%d",&T[i]);
		}
	for (i=0;i<nc;i++)
		{
			j=nc;
			while (i!=j)
				{
					if (T[j]<T[j-1])
					{
						aux=T[j];
						T[j]=T[j-1];
						T[j-1]= aux;
					}
					j= j-1;
				}
		}
	for (i=0;i<nc;i++)
	{
		printf("%d",T[i]);
	}
return 0;

}

#include <stdio.h>

int main()
{
  int n,x,s,aux;
  int caja[200];

  scanf("%d",&n);

  for(x=0;x<n;x++){

    scanf("%d",&caja[x]);

                  }

   for(x=0;x<n;x++){

    for(s=0;s<n;s++){

        if(caja[s]>caja[s+1]){

            aux=caja[s];
            caja[s]=caja[s+1];
            caja[s+1]=aux;
        }

    }

   }

   for(x=0;x<n;x++){

    printf("%d ",caja[x]);

   }
}

#include <stdio.h>

int main()
{
  int n,x,s,aux;
  int caja[1000];

  scanf("%d",&n);

  for(x=0;x<n;x++){

    scanf("%d",&caja[x]);

                  }

   for(x=0;x<n;x++){

    for(s=0;s<n;s++){

        if(caja[s]>caja[s+1]){

            aux=caja[s];
            caja[s]=caja[s+1];
            caja[s+1]=aux;
        }

    }

   }

   for(x=0;x<n;x++){

    printf("%d ",caja[x]);

   }

}

#include <stdio.h>
#include <string.h>
int main()
{
 int n,max;
 scanf("%d",&n);
 int a[n];
    for(int i=0;i<n;i++){
     scanf("%d",&a[i]);
 }
 for(int i=0;i<n;i++){
  max=a[0];
  if(a[i]>max)
  max=a[i];
 }
 int b[max];
 for(int i=0;i<=max;i++){
b[i]=0;
}
for(int i = 0;i<n;i++){
 for(int j =0;j<a[i];j++){
  b[j]++;
 }
}
    int c[n];
    for(int i=0;i<n;i++){
c[i]=0;
}
for(int i = 0;i<=max;i++){
 for(int j =0;j<b[i];j++){
  c[j]++;
 }
 }
for(int i=n-1;i>=0;i--){

printf("%d",c[i]);
printf(" ");
}

}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int b[n];
    for(int i=0;i<n;++i)
    b[a[i]]=i+1;
    for(int i=1;i<=n;i++)
    printf("%d ",b[i]);
    return 0;
}

/*Sorting the numbers using quick sort*/
#include <stdio.h> //To include standard input and output.

/*Defining a function to swap two numbers.*/
void swap(int *x, int *y)
{
    int z;                  //defining a temporary variable.
    z=*x;                   //storing the value at address of x in z
    *x=*y;                  //assigning the value at address of y to the value at address of x.
    *y=z;                   //assigning the stored value of *x to the value at address of y.
}

/*Defining a function Break to divide the array into two parts.*/
void Break(int a[], int x, int y)       //x and y are the start and end point of array or part of array.
{
    if(y>x)                             //base condition for recursion.
    {
        int i=x, j=y-1;                //i and j are the index for comparing.
        while(i<j)
        {

            if(a[i]>a[y])               //checking the condition.
            {
                swap(&a[i], &a[j]);     //swapping numbers at index i and j.
                j--;                    //decreasing j if swapping happen.
            }
            else
                i++;                    //incrementing i if swapping is not done.
        }
        if(a[j]>a[y])
            swap(&a[j], &a[y]);         //swapping the last number according to condition.
        else
            swap(&a[j+1], &a[y]);       //swapping the last number according to condition.

        Break(a, x, j-1);               //Recursively calling the function for a smaller part of array.
        Break(a, j+1, y);               //Recursively calling the function for a smaller part of array.
    }
}

int main()                              //Starting the main function.
{
    int n, i;
    //printf("Enter the number of elements to be sorted :\n");
    scanf("%d", &n);                    //Storing the number of elements in n.
    int a[n];                           //Defining an array of length n
    //printf("Enter the numbers :\n");
    for(i=0;i<n;i++)
        scanf("%d", &a[i]);             //Storing the numbers in array.
    Break(a, 0, n-1);                    //sorting the array.
    //printf("The numbers sorted in increasing order are :\n");
    for(i=0;i<n;i++)
        printf("%d ", a[i]);            //Printing the sorted numbers.
    return 0;
}

int main()
{
    int x;
    scanf("%d",&x);

    int i,j,arr[x];
    for (i = 0; i < x; i++)
    {
        scanf("%d",&arr[i]); }

    for(i = 0; i < x; i++)
    {
      for(j = i+1; j < x; j++)
      {
          int temp;
          if(arr[i] > arr[j])
            temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
      }
    }
    for (i = 0; i < x; i++)
    {
       printf("%d ",arr[i]) ;
    }

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *arr, n, i, j, temp;
    scanf("%d",&n);
    arr = (int*)malloc(n*sizeof(int));
    for(i = 0; i < n; i++)
    scanf("%d", &arr[i]);
    for(i = 0; i < n; i ++)
    {
        for(j = 0; j < (n-1-i) ; j++)
        {
            if(arr[j] > arr[j+1])
            temp = arr[j];
            arr[j] = arr[j+1];
            arr[j+1] = temp;
        }
    }
    for(i = 0; i < n; i++)
    printf("%d ", arr[i]);
    return 0;
}

#include<stdio.h>
#include<conio.h>
int main()
{
    int arr[10],i,j,n,temp=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i= 0; i<n;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            if(arr[i]>arr[j])
            {
                temp= arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%d",arr[i]);
    }
    return 0 ;
}

#include<stdio.h>
#include<string.h>
int main(){
 int i,n,j,t;
 scanf("%d",&n);
 int a[i];
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 for(i=0;i<n-1;i++){
  for(j=i+1;j<n;j++){
   if(a[i]<a[j]){
    t=a[i];
    a[i]=a[j];
    a[j]=t;
}}}
 for(i=0;i<t;i++)
  printf("%d ",a[i]);
 return(0);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int j,g,i,n;
   int a[100];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
   }
   for(i=0;i<n;i++)
   {

   for(j=i+1;j<n;j++)
   {
       if(a[i]>a[j])
       {
           g=a[i];
           a[i]=a[j];
           a[j]=g;
       }

   }
   }
   for(i=0;i<n;i++)
   {
       printf("%d",a[i]);
   }

    return 0;
}

#include <stdio.h>
int main()
{
    int m,meses[100],min,posmax,i,a;
    m=0;
    scanf("%d", &a);
    for(i=1;i<=a;i++)
        scanf("%d",&meses[i]);

    while (m<a)
    {
        posmax=min=101;
        for (i=1; i<a; i++)
    {
            if(meses[i]<min)
            {
                min=meses[i];
                posmax=i;
            }
        }
        printf("%d", min);
        meses[posmax]=101;
        m++;
    }
    return 0;
}

#include<stdio.h>
//using namespace std;

int main()
{
	int a[100],n,temp=0,i,j,k;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	for(k=0;k<n;k++)
	{
		printf("%d ",a[k]);
	}
	return 0;
}

// https://codeforces.com/contest/405/problem/A

#include <stdint.h>
#include <stdio.h>

#define ARR_PRINT(arr, size)  for(uint32_t i = 0; i < size; i++){ printf("%d ", arr[i]); }
#define MAX_NUMS  100u

void Sort(uint32_t * arr, uint32_t size);
void Swap(uint32_t * a, uint32_t * b);

int main(void)
{
	uint32_t n = 0u;
  uint32_t nums[MAX_NUMS] = {0};

  scanf("%d", &n);

  for(uint32_t i = 0u; i < n; i++)
  {
    scanf("%d", &nums[i]);
  } /*  end for   */

  Sort(nums, n);

  ARR_PRINT(nums, n);

	return 0;
}

void Swap(uint32_t * a, uint32_t * b)
{
  uint32_t temp = *a;
  *a = *b;
  *b = temp;
}

void Sort(uint32_t * arr, uint32_t size)
{

  uint8_t max_so_far = 0u;

  for(uint8_t key = (size - 1); key > 0 ; key--)
  {

    max_so_far = key;

    for(uint8_t head = 0u; head < key; head++ )
    {

      if(arr[head] > arr[key])
      {
        max_so_far = head;
      } /*  end if  */

    } /*  end for   */

    if(max_so_far != key)
    {
      /*  swap key & max  */
      Swap(&arr[max_so_far], &arr[key]);
    } /*  end if  */

  } /*  end for   */
}

#include<stdio.h>
void sort(int x,int n[])
{
	for (int i = 1; i <= x; i++)
	{
    	int j = i;
    	while(j > 0 && n[j-1] > n[j]){
      	int tmp = n[j];
      	n[j] = n[j-1];
      	n[j-1] = tmp;
      	j--;
    	}
  	}

  	for (int i=1;i<=x;i++)
  	{
  		printf("%d ",n[i]);
	}
}
int main()
{
	int x;
	int n[101];
	scanf("%d",&x);

	for (int i=0;i<x;i++)
	{
		scanf("%d",&n[i]);
	}
	sort (x,n);
}

#include <stdio.h>

int main() {

int n;

int sortArr(int *ptr, int n);

//printf("please enter number of columns\t");

scanf("%i", &n);

int a[n];

int *ptr=&a[n];

for (int i=0; i<n; i++)
	scanf("%i", &a[i]);

sortArr(a, n);sortArr(a, n);sortArr(a, n);

for (int i=0; i<n; i++)
	printf("%i ", a[i]);
}

int sortArr(int *ptr, int n){

int temp=0;

for (int i=0; i<n-1; i++){

	if (*(ptr+(i+1)) < *(ptr+(i))){
		temp=*(ptr+(i));
		*(ptr+(i))=*(ptr+(i+1));
		*(ptr+(i+1))=temp;
		}
	}
}

#include <stdio.h>

int main(){
    int a;
    scanf("%d",&a);
    if(a<3){
        printf("-1");
        return 0;
    }
    for (int i=a;i>=1;i--){
        printf("%d ",i);
    }
    return 0;
}

#include <stdio.h>

int main()
{
 int NumberOfBoxes;
 int boxes[100];
 int i,j,S;

 scanf("%d",&NumberOfBoxes);

 for(i=0; i<NumberOfBoxes; i++){
     scanf("%d",&boxes[i]);
 }

 for(int m=1; m<NumberOfBoxes; m++){
     for(j=0; j<NumberOfBoxes; j++){

     if(boxes[j]>boxes[j+1]){
        S=boxes[j+1];
         boxes[j+1]=boxes[j];
         boxes[j]=S;

     }else{

     }

 }
 }
 for(int n=0; n<NumberOfBoxes; n++){

     printf("%d ",boxes[n]);
 }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, j, temp, nColumns, nCubes[101];

    scanf("%d",&nColumns);

    for(i=0;i<nColumns;i++) {
        scanf("%d",&nCubes[i]);
    }

    for(i=0;i<nColumns;i++) {
        for(j=0;j<nColumns;j++) {
            if(nCubes[j]>nCubes[j+1]) {
                temp = nCubes[j];
                nCubes[j] = nCubes[j+1];
                nCubes[j+1] = temp;
            }
        }
    }

    for(i=0;i<nColumns;i++)
    printf("%d ",nCubes[i]);

    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int num[n+5], i;
    for (i=0; i<n; i++){
        scanf("%d", &num[i]);
    }

    int tem;

    if (n!=2){
    for (i=0; i<n; i++)
    {
        while (num[i]>num[i+1]){
            tem=num[i];
            num[i]=num[i+1];
            num[i+1]=tem;
            if (i!=0)
                i--;
        }

    }
    }

    else{
    i=0;
    do
    {
        while (num[i]>num[i+1]){
            tem=num[i];
            num[i]=num[i+1];
            num[i+1]=tem;
            if (i!=0)
                i--;
        }
        i++;
    }
    while (i>(n-1));
    }
    for (i=0; i<n; i++){
        printf("%d ", num[i]);
    }
}

#include<stdio.h>
int main()
{int n,i,t;
scanf("%d",&n);
int col[n];
for(i=0;i<n;i++)
scanf("%d",&col[i]);
for(i=0;i<n-1;i++)
{if(col[i]>col[i+1])
{t=col[i];
col[i]=col[i+1];
col[i+1]=t;
}
else
continue;
}
for(i=0;i<n;i++)
printf("%d\t",col[i]);
return 0;
}

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int  cmp(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}
int main ()
{
    int n,i,a[102];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),cmp);
    for(i=0;i<n;i++)
    printf("%d",a[i]);
    return 0 ;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int b[n];
    for(int i=0;i<n;++i)
    b[a[i]]=i+1;
    for(int i=1;i<=n;i++)
    printf("%d ",b[i]);
    return 0;
}

int main()
{
    int x;
    scanf("%d",&x);

    int i,j,arr[x];

    for (i = 0; i < x; i++)
    scanf("%d",&arr[i]);

    for(i = 0; i < x-1; i++)
        {
          for(j = i+1; j < x; j++)
              {
                  int temp;
                  if(arr[i] > arr[j])
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
              }
        }
    for (i = 0; i < x; i++)
    printf("%d ",arr[i]);

    return 0;
}

#include<stdio.h>

void gravity(int c[],int n){
    if(n==1)
       return ;
    int max=0,i,k;
    for(i=0;i<n;i++){
        if(max<c[i]){
          max=c[i];k=i;
        }
    }
    c[k]=max-c[n-1];
    c[n-1]=max;
    gravity(c,n-1);
}

int main(){
    int n,i,j;
    scanf("%d",&n);
    int c[n];
    for(i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    gravity(c,n);
    for(i=0;i<n;i++){
        printf("%d",c[i]);
    }
    return 0;
}

///theatre square
/*#include<stdio.h>
int main()
{
    long long int a,i,b,c,j,k,n=0,m=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    j=a/c*(a%c);
    k=b/c*(b%c);
    printf("%lld\n",j*k);
    return 0;
}*/
/*#include<stdio.h>
int main()
{
    long long int a,b,c,m,n;
    int v,k;
    scanf("%lld%lld%lld",&a,&b,&c);
    m=a/c;
    if(a%c)
    //v=a;
    m++;
    n=b/c;
    if(b%c)
    //k=b;
    n++;
    printf("%lld\n",m);
    return 0;
}*/
#include<stdio.h>
int main()
{
    int arr[4],i,a,k,temp,j;
     for(j=1;j<=2;j++){
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&arr[i]);}
        for(i=0;i<a;i++){

        for(k=i+1;k<a;k++)
        {
            if(arr[i]>arr[k])
            {
                temp=arr[i];
                arr[i]=arr[k];
                arr[k]=temp;
            }

        }
        printf("%d\n",arr[i]);}
        }

    return 0;
}

#include <stdio.h>
void quickSort(int a[], int low, int high);
void swap(int *a, int *b);
int split(int a[], int low, int high);
int main(){
    int n;
    int columns[100];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &columns[i]);
    }

}
void quickSort(int a[], int low, int high){
	int middle;

	if (low >= high)
		return;

	middle = split(a, low, high);
	quickSort(a, low, middle -1);
	quickSort(a, middle + 1 , high);
}

int split(int a[], int low, int high){
	int pivot = a[high];

	while (1){
		 while (low < high && a[low] <= pivot)
			 low++;
		 swap(&a[high--], &a[low]);
		 while (low < high && a[high] >= pivot)
			 high--;
		 swap(&a[low++], &a[high]);
		 if (high <= low)
			 break;
	}
	return high; // low --> middle - 1 , middle
				// high --> middle - 1 , middle + 1
				// beacuse low decrements before the break
}

void swap(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int ar[n],i,tmp;
for(i=0;i<n;i++)
	{
	scanf("%d",&ar[i]);
        }
 int min,j;

     for(i=0;i<n;i++)

     {

           for(j=0;j<n-i;j++)

           {

                 if(ar[j]>ar[j+1])

                 {

                       tmp=ar[j];

                       ar[j]=ar[j+1];

                       ar[j+1]=tmp;
                 }
           }

     }
 for(i=0;i<n;i++)
 printf("%d",ar[i]);
 return 0;
 }

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>

void* mergesortRecursive(void* arg);
void mergesortHelper(int l,int mid,int r);
typedef struct mergeRecData
{
    int l;
    int r;
} mergeRecData;

int n;
int* arr;
int* sorted;

int main()
{
        scanf("%d",&n);
        arr=(int*)malloc(sizeof(int)*n);
        sorted=(int*)malloc(sizeof(int)*n);
        int i=0;
        for(i=0; i<n; i++)
        {
            scanf("%d",&arr[i]);
            if(i!=n-1)
                scanf(" ");
        }

        mergeRecData* data=(mergeRecData*)malloc(sizeof(mergeRecData));
        data->l=0, data->r=n-1;

        clock_t start,end;
        start=clock();
        mergesortRecursive(data);
        end=clock();
        for(i=0; i<n; i++)
            printf("%d ",arr[i]);

    return 0;
}

void* mergesortRecursive(void* arg)
{
    mergeRecData* data=(mergeRecData*)arg;
    if(data->l<data->r)
    {
        mergeRecData* leftData=(mergeRecData*)malloc(sizeof(mergeRecData));
        mergeRecData* rightData=(mergeRecData*)malloc(sizeof(mergeRecData));
        pthread_t threads[2];
        int mid=(data->l+data->r)/2;
        leftData->l=data->l, leftData->r=mid;
        rightData->l=mid+1, rightData->r=data->r;
        int rvl=pthread_create(&threads[0],NULL,mergesortRecursive,leftData);
        int rvr=pthread_create(&threads[1],NULL,mergesortRecursive,rightData);

        int jl=pthread_join(threads[0],NULL);
        int jr=pthread_join(threads[1],NULL);
        if(rvl!=0||rvr!=0||jl!=0||jr!=0)
            printf("\nerrroooooorrrr!!!!!!!\n");
        mergesortHelper(data->l,mid,data->r);
    }
}
void mergesortHelper(int l,int mid,int r)
{

    int i,j=l,z=mid+1;

    for(i=l; i<=r; i++)
    {
        if(j<=mid && z<=r)
        {
            if(arr[j]<arr[z])
            {
                sorted[i]=arr[j];

                j++;
            }
            else if(arr[z]<=arr[j])
            {
                sorted[i]=arr[z];

                z++;
            }
        }
        else if(z>r)
        {
            for(i=i; i<=r; i++)
            {
                sorted[i]=arr[j];

                j++;
            }
            break;
        }
        else
        {
            for(i=i; i<=r; i++)
            {
                sorted[i]=arr[z];

                z++;
            }
            break;
        }
    }

    for(int i=l; i<=r; i++)
    {
        arr[i]=sorted[i];
    }

}

int main() {
    int i,j,n;
    scanf("%d",&n);
    int *dizi=(int*) malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
        scanf("%d",&dizi[i]);
    for(i=0;i<n;i++)
        for(j=n-1;j>-1;j--)
            while(dizi[i]>dizi[j]) {
                dizi[i]--;
                dizi[j]++;
            }
    for(i=0;i<n;i++)
        printf("%d ",dizi[i]);
}

#include<stdio.h>
void sort(int x,int n[])
{
	for (int i = 1; i <= x; i++)
	{
    	int j = i;
    	while(j > 0 && n[j-1] > n[j]){
      	int tmp = n[j];
      	n[j] = n[j-1];
      	n[j-1] = tmp;
      	j--;
    	}
  	}

  	for (int i=1;i<=x;i++)
  	{
  		printf("%d ",n[i]);
	}
}
int main()
{
	int x;
	int n[101];
	scanf("%d",&x);

	for (int i=0;i<x;i++)
	{
		scanf("%d",&n[i]);
	}
	sort (x,n);
}

#include<stdio.h>
int main()
{
    int block[100] , n , i , j , temp;
    scanf("%d", &n);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d" , &block[i]);
    }

    block[i] = '\0';

    for(i = 0 ; i < n ; i++)
    {
        for(j = i + 1 ; j < n ; j++)
        {
            if(block[j-1] >= block[j])
            {

                temp = block[i];
                block[i] = block[j];
                block[j] = temp;
            }
        }
    }
    for(i = 0 ; i < n ; i++)
    {
        printf("%d " , block[i]);
    }

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,j,arr[100],flag,temp;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {

        scanf("%d",&arr[i]);
        if(arr[i]<1||arr[i]>100)
        {
            flag=1;
        }
    }
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(arr[j]<arr[i])
            {
                temp=arr[j];
                arr[j]=arr[i];
                arr[i]=temp;
            }
        }
    }
    if(n>=1&&n<=100&&flag!=1)
    {
        for(i=0;i<n;i++)
        {

            printf("%d\t",arr[i]);
 }
    }

    return 0;
}

#include<stdio.h>
int main(){
    int i,j,a,h,n;
    scanf("%d",&n);
    int arr[n];
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);
    ///
    for(i=1;i<10;i++){
        for(a=arr[i],h=i;h>0 && arr[h-1]>a;h--){
            arr[h]=arr[h-1];
        }
        arr[h]=a;
    }
    for(i=0;i<n;i++)
        printf("%d ",arr[i]);
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d\n",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d ",&a[i]);
    int pos,max;
    for(int i=0;i<n;i++)
    {
        max=a[i];
        pos=i;
        for(int j=i+1;j<n;j++)
        {
            if(max<a[j]);
            {
                pos=j;
                max=a[j];
            }
        }
        a[pos]=a[i];
        a[i]=max;
    }
    for(int i=0;i<n;i++)
        printf("%d ",&a[i]);
    return 0;
}

#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0;i<n;i++)
    {
      scanf("%d",&a[i]);

    }int temp=0;
    for (int i=0;i<n-1;i++)
    {
        for (int j=i+1;j<i-1;j++)
        {if (a[j]>a[j+1])
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }
     for (int i=0;i<n;i++)
    {
      printf("%d ",a[i]);

    }

}

#include <stdio.h>

int main()
{
  int n,x,s,aux;
  int caja[1000];

  scanf("%d",&n);

  for(x=0;x<n;x++){

    scanf("%d",&caja[x]);

                  }

   for(x=0;x<n;x++){

    for(s=0;s<n;s++){

        if(caja[s]>caja[s+1]){

            aux=caja[s];
            caja[s]=caja[s+1];
            caja[s+1]=aux;
        }

    }

   }

   for(x=0;x<n;x++){

    printf("%d ",caja[x]);

   }

}

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int  cmp(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}
int main ()
{
    int n,i,a[102];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),cmp);
    for(i=0;i<n;i++)
    printf("%d",a[i]);
    return 0 ;
}

#include<stdio.h>
//using namespace std;

int main()
{
	int a[1000],n,temp=0,i,j,k;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	for(k=0;k<n;k++)
	{
		printf("%d ",a[k]);
	}
	return 0;
}

#include <stdio.h>

int main(void)
{
    int n,i,j,tp,a[1000];
    scanf("%d",&n);
    for (i=0;i<n;i++)
        scanf("%d",&a[i]);
    //Merge sort
    for (i=1;i<=n;i++)
    {
        j=i;
        tp=a[i];
        while (a[j-1]>tp && j>0) a[j]=a[j-1], j--;
        a[j]=tp;
    }
    for (i=0;i<n-1;i++)
        printf("%d ",a[i]);
    printf("%d",a[i]);
}