/**
#include <stdio.h>
int a[10001];
int n, i, j, temp,k = 0,m=0;
int main() {
scanf("%d", &n);
for (i=1; i<=n; i++)
scanf("%d", &a[i]);
m=n-1;
for(i=1; i<n; i++)
{
k = 0;
for (j = 1 ; j <= n - i ; j ++)
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
k++;
}
}
if (k == 0)
{
m = i-1;
break;
}
}
printf("%d",m);
return 0;
}
#include <stdio.h>
int a[10001];
int n, i, j, temp, key;
int main() {
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (i=2; i<=n; i++)
{
key=a[i];
for(j = i - 1 ; j >= 1 && a[j] > key ; j--)
{
a[j+1]=a[j];
}
a[j+1]=key;
}
for (i=1; i<=n; i++)
printf("%d\n", a[i]);
return 0;
}
#include<stdio.h>
#include<string.h>
typedef struct
{
char name[51];
int score;
}student;
int main()
{
int i,j,n,m;
student arr[101], k;
scanf("%d", &n);
for (i = 1 ; i <= n ; i ++)
{
scanf("%s %d", arr[i].name, &arr[i].score);
}
for (i = 1 ; i < n ; i ++)
{
for (j = 1 ; j <= n - i ; j ++)
{
if (arr[j].score < arr[j + 1].score)
{
k = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = k;
}
}
}
printf("%s", arr[3].name);
return 0;
}
#include<stdio.h>
typedef struct
{
char name[101];
int score;
}student;
int main()
{
int i,j,n,m;
student arr[1001],k;
scanf("%d %d", &n,&m);
for (i = 1 ; i <= n ; i ++)
{
scanf("%s %d",arr[i].name,&arr[i].score);
}
for (i = 1 ; i < n ; i ++)
{
for (j = 1 ; j <= n - i ; j ++)
{
if (arr[j].score < arr[j + 1].score)
{
k = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = k;
}
}
}
for (i = 1 ; i <= m ; i ++)
{
printf("%s\n",arr[i].name);
}
return 0;
}
#include<stdio.h>
typedef struct
{
char name[50];
int sum;
}calender;
int main()
{
int i,j,n,m,a,b,c;
calender arr[101], k;
scanf("%d\n",&n);
for (i = 1 ; i <= n ; i ++)
{
scanf("%s %d %d %d",arr[i].name, &a,&b,&c);
arr[i].sum = a 10000 + b 100 + c;
}
for (i = 1 ; i < n ; i ++)
{
for (j = 1 ; j <= n - i ; j ++)
{
if (arr[j].sum > arr[j + 1].sum)
{
k = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = k;
}
else if (arr[j].sum == arr[j + 1].sum)
{
if (strcmp(arr[j].name, arr[j + 1].name) > 0)
{
k = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = k;
}
}
}
}
for (i = 1 ; i <= n ; i ++)
{
printf("%s\n",arr[i].name);
}
return 0;
}
**/