semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n=0,m=0;
	scanf("%d %d\n",&n,&m);
	int a[200];
	for(int i=1;i<=n;i++)
	scanf("%d ",&a[i]);
	for(int j=n;j>=1;j--)
	a[j+m]=a[j];
	for(int b=1;b<=m;b++)
	a[b]=a[n+b];
	for(int c=1;c<=n;c++)
	{
		if(c!=n)
		printf("%d ",a[c]);
		else
		printf("%d",a[n]);
	 } 
	return 0;
}
int main()
{
 void de(int x[],int n, int m);
    int n,m,i,x[100];
    scanf("%d%d",&n,&m);
    for(i=0;i<=n-1;i++)
    scanf("%d",&x[i]);
    de(x,n,m);
    printf("%d",x[0]);
    for(i=1;i<=n-1;i++)
    printf(" %d",x[i]);
return 0;
}
void de(int x[],int n, int m)
{
     int i;
     for(i=0;i<=n-m-1;i++)
     x[i+n]=x[i];
     for(i=0;i<=n-1;i++)
     x[i]=x[i+n-m];
}
int main()
{
	int a[40],i,k,j=0,n,m,temp;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=n-m;i<=n-1;i++)
	{
		for(k=i;k>j;k--)
		{	
			temp=a[k];a[k]=a[k-1];a[k-1]=temp; 
		}
		j+=1;
	}
	cout<<a[0];
	for(i=1;i<n;i++)
		cout<<' '<<a[i];
		return 0;
}
void move(int *,int,int);

int main()
{
	int i,a[100]={0},m,n;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i];
	move(a,n,m);
	cout<<a[0];
	for(i=1;i<n;i++)
		cout<<" "<<a[i];
	return 0;
}
void move(int *num,int n,int m)
{
	int *p;
	int end,i;
	p=num;
	end=*(p+n-1);
	for(p=p+n-1;p>num;p--)
		*p=*(p-1);
	*p=end;
	m--;
	if(m>0)
		move(num,n,m);
}
int main()
{
	int n,m,i,j;
	int a[100],c;
	int *b;
	scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	b=a+m;
	for(i=0;i<m;i++)
	{
		c=a[n-1];b=&a[n-1];
		for(j=n-1;j>0;j--)
		{
			*b=*(b-1);
            b=b-1;
		}
		a[0]=c;
	}
	for(i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d",a[n-1]);

}
void main()
{
	int a[100],b,c,d,e,f;
	scanf("%d%d",&b,&c);
	for(d=0;d<b;d++)
		scanf("%d",&a[d]);
	for(d=b-1;d>=b-c;d--)
		for(e=b-1;e>=1;e--)
		{
			f=a[e-1];
			a[e-1]=a[e];
			a[e]=f;
		}
		for(d=0;d<b-1;d++)
			printf("%d ",a[d]);
		printf("%d",a[b-1]);
}
int main()
{
	int n,m,s[200],i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	j=100;
	for(i=n-m;i<n;i++)
	{	
		s[j]=s[i];
		j++;
	}
	j=100+m;
	for(i=0;i<n-m;i++)
	{	
		s[j]=s[i];
		j++;
	}
	for(j=100;j<100+n;j++)
	{
		if(j<99+n)
	      printf("%d ",s[j]);
		else
			printf("%d",s[j]);
	} 
	return 0;
}
int main()
{   
	int m,n;
	scanf("%d %d\n",&n,&m);
    int i,a[100];
	for(i=0;i<n;i++)
	{
	    scanf("%d",&a[i]);
	}
    int*point;
	//for(i=n-m;i<n;i++)
	//{
      //  printf("%d",a[i]);
	//}
	//for(i=0;i<n-m-1;i++)
	//{
	//	printf("%d",a[i]);
	//}
	//printf("%d\n",a[n-m-1]);
	for(point=&a[n-m];point<a+n;point++)
	{
		printf("%d ",*point);
	}
	for(point=a;point<a+n-m-1;point++)
	{
		printf("%d ",*point);
	}
	printf("%d\n",a[n-m-1]);
	return 0;
}
void main()
{
	void inv(int *a,int n,int m);
	int a[100];
	int m,n,i;	
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);//??
	inv(a,n,m);
	for(i=0;i<n;i++)
	{
		if(i!=0)
			printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}
void inv(int *a,int n,int m)
{	
	int *p,a_end;
	a_end=*(a+n-1);
	for(p=a+n-1;p>a;p--)
		*p=*(p-1);
	*a=a_end;
	m--;
	if(m>0)
		inv(a,n,m);
}
/**********************
*????
*?????
***********************/
int main()
{
	int n, m, a[100]={0};                //??????? n? ????m?
	cin >> n >> m;
	for(int i=0; i < n; i++)             //??n???
	{
		cin >> a[i];
	}
	for(int j=0; j < m; j++)              //????m?
	{
		int t=a[n-1];                     //????????
		for(int k = n-1; k >= 0; k--)     //?????????
		{
			if(k > 0)
			{
				*(a+k)=*(a+k-1);          //?????????
			}
			else
			{
				if(k == 0)
				{
					*a=t;                //????????????
					t=*(a+n-1);
				}
			}
		}
	}
	int mark=0;     //?????
	for(int i1=0; i1 < n; i1++)
	{
		if(mark == 0)//??????????
		{
			cout<<*(a+i1);
			mark++;
		}
		else    //?????????
		{
			cout<<" "<<*(a+i1);
		}
	}
return 0;
}
void main()
{
	void loop(int a[],int b);
	int n,m,i;
	int c[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&c[i]);
	}
	for(i=0;i<n-m;i++)
		loop(c,n);
	printf("%d",c[0]);
	for(i=1;i<n;i++)
		printf(" %d",c[i]);
}
void loop(int a[],int b)
{
	int i,temp=a[0];
	for(i=0;i<b-1;i++)
		a[i]=a[i+1];
	a[b-1]=temp;
}
int main()
{
int a,b;
int m[102];
cin>>a>>b;
for(int i = 0;i<a;i++)
{
cin>>m[i];
}
for(int i = a - b;i < a;i++)
cout<<m[i]<<" ";
for(int i = 0;i<a-b;i++)
{
cout<<m[i];
if(i != a - b -1)
cout<<" ";
}
}
int main()
{
	int *p, n, m, num[100], k = 1, t ;
	cin >> n >> m ;
	for (int i = 0 ; i < n ; i ++)
		cin >> num[i] ;
	while (k <= m)
	{
		p = &num[n - 1] ;
		t = *p ;
		for ( ; p > num ; p --)
		{
			*p = *(p - 1) ;
		}
		*p = t ;
		k ++ ;
	}
	for (p = num ; p < num + n - 1 ; p ++)
		cout << *p << " " ;
	cout << *p ;
	return 0 ;
}
struct Node;
typedef struct Node *pNode; 
struct Node
{
    int x;
	pNode next;
};


pNode create()/*??head*/
{
	pNode p;
	p=(pNode)malloc(sizeof(struct Node));
	p->next=NULL;
	return p;
}

void sort(pNode head,int n)/*head???????n???*/
{
	pNode p=NULL,q=NULL,s=NULL;
    int i;
	for (i=1;i<=n;i++)
	{
	s=(pNode)malloc(sizeof(struct Node));
	scanf("%d",&s->x);
    q=head;
	p=head->next;
	while (p)
	{
        if (p->x>=s->x)
			break;
		q=p;
		p=p->next;
	}
	q->next=s;
	s->next=p;
	}
	
}

void outputdata(pNode p)/*??head*/
{
    p=p->next;
	while(p->next)
	{
      printf("%d ",p->x);
	  p=p->next;
    }
	printf("%d",p->x);
}


pNode inputdata(int n)/*??head?????n???*/
{
	pNode q=NULL,p=NULL,head=NULL;
	int i;
	head=create();
	q=head;
	for (i=1;i<=n;i++)
	{p=(pNode)malloc(sizeof(struct Node));
	if (p!=NULL)
	 {
	 scanf("%d",&p->x);
     p->next=NULL;
	 q->next=p;
	 q=p;
	}
	}
	return head;
}

void del(pNode p,int k)/*??head??k???*/
{
	pNode q=NULL;
	q=p;
	p=p->next;
	while(p)
		if (p->x==k)
		{
			q->next=p->next;
			free(p);
			p=q->next;
		}
		else
		{q=p;p=p->next;}
}

pNode rinputdata(int n)/*??head,????n???*/
{
	pNode q=NULL,p=NULL,head=NULL;
    int i;
	head=create();
	for (i=1;i<=n;i++)
	{
		p=(pNode)malloc(sizeof(struct Node));
		if (p!=NULL)
		{
			scanf("%d",&p->x);
			p->next=q;
			q=p;
		}
	}
    head->next=q;
    return head;
}

void outputk(pNode p,int k)/*???k???*/
{
	int i=1;
    p=p->next;
	while(p)
	{
      if (i==k)
		 printf("%d",p->x);
	  p=p->next;
      i++;
	}
}

void change(pNode p,int n,int m)/*?head?n?????m???????*/
{
	int i=1;
	pNode q=NULL,s=NULL,head=NULL;
	q=p;
	head=p;
	p=p->next;
	while(p)
	{
		if (i==n-m+1)
			break;
		i++;
		q=p;
		p=p->next;
	}
	s=head;
	while(s->next)
		s=s->next;
	q->next=NULL;
	s->next=head->next;
	head->next=p;
}

void found(pNode p,int k)/*??head???k???*/
{
   pNode head=p;
   int ok=1;
   p=head->next;
   while(p)
   {
	   if (k==p->x)
	   {
		   printf("%d\n",p->x);
           ok=0;
	   }
	   p=p->next;
   }
   if (ok)
	   printf("No Found!");
}

int main()
{
    int m,n;
    pNode head=NULL;
    scanf("%d %d",&n,&m);
    head=inputdata(n);
    change(head,n,m);
	outputdata(head);

	return 0;
}
void main()
{
  int a[200];
  int m,n,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)
	  scanf("%d",&a[i]);
     //?????
    for(i=n-1+m;i>=m;i--)
		a[i]=a[i-m];
	for(i=0;i<m;i++)
		a[i]=a[n+i];
      printf("%d",a[0]);
	  for(i=1;i<n;i++)
		  printf(" %d",a[i]);
	  printf("\n");


}
void main()
{
	int n,m,i,j,s[150]={0},a[150]={0};
	scanf("%d %d",&n,&m);

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

	for(i=n-m,j=0;i<n;i++,j++)
		a[j]=s[i];

	for(i=n-m-1;i>=0;i--)
		s[i+m]=s[i];

	for(i=0;i<m;i++)
		s[i]=a[i];

	for(i=0;i<n-1;i++)
		printf("%d ",s[i]);
	printf("%d\n",s[n-1]);
}
int main(){
    int i,e[100],n,m;
    int sz[100],k[100];
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
       scanf("%d",&(sz[i]));              
                     }
    for(i=0;i<n;i++){
      e[i]=sz[i];
      k[i]=sz[i];              
                    } 
     for(i=n-m;i<n;i++){
                      
      sz[i-n+m]=k[i];                   
                         } 
    for(i=0;i<m;i++){
       printf("%d ",sz[i]);                
                       }                                
    for(i=0;i<n-m;i++){
                       
      sz[m+i]=e[i];               
                     }
    for(i=m;i<n-1;i++){
      printf("%d ",sz[i]);                 
                       }                 
     printf("%d",sz[n-1]);                                  
      scanf("%d",&m);               
     return 0;              
    }
void change(int a[],int n,int m)
{
	int a1[1000];
	int *p=a,*p1=a1;
	int i,j,t=1;
	for(i=n-m,j=0;i<n;i++,j++)
		*(p1+j)=*(p+i);
	for(i=n-m-1;i>=0;i--,t++)
		*(p+n-t)=*(p+i);
	for(t=0;t<m;t++)
		*(p+t)=*(p1+t);
}
void main()
{
	int a[1000],n,m,i=0;
	scanf("%d%d",&n,&m);
	do
	{
		scanf("%d",&a[i]);
		i++;
	}
	while(getchar()!='\n');
	scanf("%d",&m);
	n=i;
	change(a,n,m);
	for(i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d",a[i]);
}
void main()
{
	int n,m,i,a[100];
	int *p;
	scanf("%d%d",&n,&m);
	for(i=0;i<=n-1;i++)
		scanf("%d",&a[i]);
	p=&a[0];
	printf("%d",*(p+n-m));
	for(i=n-m+1;i<=2*n-m-1;i++)
		printf(" %d",*(p+i%n));
}
int main()
 {int m,n,i,j,tt,*l,k;
 int s[102];
 scanf("%d  %d",&m,&n);
 for(i=0;i<=m-1;i++)
 scanf("%d",&s[i]);
 int *p=&s[0];
 for(i=1;i<=n;i++)
 {tt=*(p+m-1);
	for(k=m-1;k>=1;k--)
	   {l=p+k;
	   *l=*(l-1);
		}
	*p=tt;
		}
printf("%d",*p);
for(j=1;j<=m-1;j++)
printf(" %d",*(p+j));
return 0;
 }
/*??
???????????????????????????????????????n????????????????m????????m????????m??(m<n)?

??????????m???????n-m??????????????????????

????????????????????????????????????????????

??????????????????????????????

????
????????????????n(n<=100)??????m??????n?????????????????????

????
???????????????????????????????????????

????
11 4
15 3 76 67 84 87 13 67 45 34 45

????
67 45 34 45 15 3 76 67 84 87 13

*/
int main()
{
	int n,m;cin>>n>>m;
	int ain[234];
	m++;
	int *p=ain,*q=ain;
	for(int i=1;i<=n;i++,p++)cin>>*p;
	q=p;
	for(int i=1; i<=m; ++i)--p;
	for(int i=1; i<=m; ++i){*q++=*p++;}
	q=p;
	for(int i=1; i<=m; ++i)--p;
	for(int i=1; i<=n-m; ++i){*--q=*--p;}
	q=&ain[n];
	for(int i=1; i<=m; ++i)*p++=*q++;
	cout<<ain[1];
	for(int i=2; i<=n; ++i)cout<<' '<<ain[i];
	return 0;
}
main()
{
	int m,n,i,j,k;
	int a[200];
	scanf("%d%d",&n,&m);
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (i=n-m;i<n;i++) printf("%d ", a[i]);
	for (i=0;i<n-m-1;i++) printf("%d ", a[i]);
	printf("%d",a[n-m-1]);
}
int main ()
{
	int i,m,n,a[110];
	cin>>n>>m;
	for(i=0;i<n;i++)    cin>>a[i];
	for(i=n-m;i<n;i++)   cout<<*(a+i)<<" ";
	for(i=0;i<n-m;i++)   
	{
		if(i<n-m-1)  cout<<*(a+i)<<" ";
		else cout<<*(a+i)<<endl;
	}
  	return 0;
}
void move(int n, int *p)
{
	int t=p[n-1];
	for (int i=n-1;i>0;i--)
		p[i]=p[i-1];
	*p=t;
}

int main( )
{
	int n,m,k,a[1000];
	cin>>n>>m;
	for (k=0;k<n;k++)
		cin>>a[k];
	for (k=1;k<=m;k++)
		move(n,a);
	for (k=0;k<n-1;k++)
		cout<<a[k]<<' ';
	cout<<a[n-1];
	return 0;
}
int main()
{
	int m,n,i;
	int a[202];
	scanf("%d %d",&n,&m);
	scanf("%d",&a[1]);
	for(i=2;i<=n;i++)
	{scanf(" %d",&a[i]);}
	for(i=n+1;i<=2*n-m;i++)
	{a[i]=a[i-n];}
	printf("%d",a[n-m+1]);
	for(i=n-m+2;i<=2*n-m;i++)
	{printf(" %d",a[i]);}
	return 0;
}
int main()
{
    int n,m,i,sz[100],sy[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&sz[i]);
	}
	for(i=0;i<n;i++)
	{
		if(i>=m)
		{
		  sy[i]=sz[i-m];  
		}
		else
		{ 
		  sy[i]=sz[i+n-m]; 
		}
	}
	for(i=0;i<n-1;i++)
	{
		printf("%d ",sy[i]);
	}
	printf("%d",sy[n-1]);
	return 0;
}
struct number
{
	int num;struct number *next;
};

struct number * creat(int n)
{
	struct number *head;
	struct number *p1,*p2;
	int i;
	p1=p2=(struct number *)malloc(LEN);
	scanf("%d",&p1->num);
	head=p1;
	i=1;
	while(i<n-1)
	{
		p1=(struct number *)malloc(LEN);
		scanf("%d",&p1->num);
		p2->next=p1;
		p2=p1;	
		i=i+1;
	}
	
	p1=(struct number *)malloc(LEN);
	scanf("%d",&p1->num);
	p2->next=p1;
	p2=p1;
	p2->next=head;
	return head;
}
void print(struct number *head,int n,int m)
{
	int i;
	struct number *p;
	struct number *t;
	p=head;
	for(i=0;i<n-m;i++)
	{   t=p;
	    p=p->next;
	}
	t->next=NULL;
	if(p!=NULL)
	{
      do
	  {printf("%d",p->num);
	  printf((p->next!=NULL)?" ":"\n");
	  p=p->next;
	  }while(p!=NULL);
	}
	
}
		    

void main()
{
	int n,m;
	struct number * p;
	scanf("%d%d",&n,&m);
	p=creat(n);
	print(p,n,m);
}
//      resort.c
//      
//      Copyright 2009 JacksonTB <jacksontb@jacksontb-laptop>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.



typedef struct NODE{
	int value;
	struct NODE *fwd;
	struct NODE *bwd;
}node;

int main(int argc, char** argv)
{
	int m, n, i;
	node *rootp, *recp, *prep,*lastp;
	
	rootp = (node*) malloc(sizeof(node));
	rootp -> fwd = NULL;
	prep = rootp;
	
	scanf("%d %d", &n, &m);
	for(i = 1;i <= n;i ++)
	{
		recp = (node*) malloc(sizeof(node));
		if(recp == NULL)
		{
			printf("Not enough memory");
			return EXIT_FAILURE;
		}
		scanf("%d", &(recp -> value));
		recp -> bwd = prep;
		prep -> fwd = recp;
		recp -> fwd = NULL;
		prep = recp;
	}
	
	recp = rootp;
	for(i = 1;i <= n - m + 1;i ++)
	{
		recp = recp -> fwd;
	}
	
	
	
	lastp = rootp;
	while(lastp -> fwd != NULL)
	{
		lastp = lastp -> fwd;
	}
	
	lastp -> fwd = rootp -> fwd;
	rootp -> fwd -> bwd = lastp;
	rootp -> fwd = recp;
	recp -> bwd -> fwd = NULL;
	recp = rootp -> fwd;
	while(recp != NULL)
	{
		printf("%d", recp -> value);
		prep = recp;
		recp = recp -> fwd;
		if(recp != NULL) printf(" ");
		free(prep);
	}
	
	return 0;
}
int main(){
	int n,m;
	scanf("%d %d", &n, &m);
	int num[100];
	int *p=num;
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(i=0;i<m;i++){
		int templast=*(p+n-1);
		int j;
		for(j=n-1;j>=1;j--){
			*(p+j)=*(p+j-1);
		}
		*p=templast;
	}
	printf("%d",*p);
	for(i=1;i<n;i++){
		printf(" %d",*(p+i));
	}
	printf("\n");

	return 0;
}
int main()
{
	int a[1000];
	int m,len;
	int i;
	int temp,temp1;
	int wz,counts=0;
	scanf("%d %d",&len,&m);
	for(i=0;i<len;i++)
	{
		scanf("%d",&a[i]);
	}
	temp=a[0];
	for(i=0;counts<=len;i=i+m)
	{
		
		wz=i+m;
		if(wz>len-1)
		{
			wz=wz-len;
			i=wz-m;
		}
		temp1=a[wz];
		a[wz]=temp;	
		temp=temp1;
		counts++;
	}
	printf("%d",a[0]);
	for(i=1;i<len;i++)
	{
		printf(" %d",a[i]);
	}
	return 0;
}
main()
{
	int i,n,m,a[200];
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (i=n+1;i<=n+n-m;i++)
		a[i]=a[i-n];
	for (i=n-m+1;i<n+n-m;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[i]);
}
int main()
{
	int i,j,n,m,a[100],t;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int *p=a;
	for(i=n-m-1;i>=0;i--)
	{
		p=a+i;
		for(j=0;j<m;j++)
		{
			t=*(p+1);
			*(p+1)=*p;
			*p=t;
			p++;
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)
	{
		printf(" %d",a[i]);
	}
	return 0;
}
void main()
{void move(int [20],int,int);
int num[20],n,m,i;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&num[i]);
move(num,n,m);
for(i=0;i<n;i++)
printf("%d%c",num[i],(i<n-1)?' ':'\n');
}
void move(int a[20],int n,int m)
{int *p,end;
end=*(a+n-1);
for(p=a+n-1;p>a;p--)
*p=*(p-1);
*a=end;
m--;
if(m>0)move(a,n,m);
}
//????
//2010?11?13?
//1000012753 ???
int main()
{
	int a[200], n, m, i, *p;
	cin >> n >> m;
	for (i = m; i < m + n; ++i)
		cin >> a[i];
	for (p = a + n; p < a + n + m; ++p)
		*(p - n) = *p;
	cout << *a;
	for (p = a + 1; p < a + n; ++p)
		cout << " " << *p;
	cout << endl;
	return 0;
}
void main()
{
	int n,m,i,a[100],b[100]={0},*p;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	p=&b[0];
	for(i=m;i<n;i++)
	{
		*(p+i)=a[i-m];
	}
	p=&b[0];
	for(i=0;i<m;i++)
	{
		*(p+i)=a[n-m+i];
	}
	for(i=0;i<n-1;i++)
	printf("%d ",*(p+i));
	printf("%d",*(p+n-1));
}
int main(int argc, char* argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	int i,temp,a[101];
	for(i=n-1;i>=0;i--){
		scanf("%d",&a[i]);}
	while(m--){
		
	temp=a[0];
	for(i=0;i<n-1;i++){
	a[i]=a[i+1];}
	a[n-1]=temp;}
	for(i=n-1;i>0;i--){
	printf("%d ",a[i]);}
	printf("%d\n",a[i]);
	return 0;
}
int main()
{
	void move(int*,int,int);
	int n,i,m;
	int a[N];
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	move(a,n,m);
	printf("%d",*(a+1));
	for(i=2;i<=n;i++)
	printf(" %d",*(a+i));
}
void move(int* a,int n,int m)
{
	int b[N],i;
	for(i=1;i<=n-m;i++)
	b[i+m]=a[i];
	for(i=n-m+1;i<=n;i++)
	b[i+m-n]=a[i];
	for(i=1;i<=n;i++)
	*(a+i)=*(b+i);
}
int main()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	int a[1000],*p;
	p=a;
	for(i=0;i<n;i++)
		scanf("%d",p+i);
	for(i=0;i<m;i++)
		*(p+n+i)=*(p+n-m+i);
	for(i=(n-1);i>=m;i--)
		*(p+i)=*(p+i-m);
	for(i=0;i<m;i++)
		*(p+i)=*(p+n+i);
	for(i=0;i<n-1;i++)
		printf("%d ",*(p+i));
	printf("%d",*(p+n-1));
return 0;
}
int main()
{
  int n,m,s;
  scanf("%d %d\n",&n,&m);
  int a[n];
  int i,j,k;
  scanf("%d",&a[0]);
  for(i=1;i<n;i++)
  {
   scanf(" %d",&a[i]);
  }
  scanf("\n");
  for(j=1;j<=m;j++)
  {
	s=a[n-1];
	for(k=n-2;k>=0;k--)
	{
	  a[k+1]=a[k];
	}
	a[0]=s;
  }
  printf("%d",a[0]);
  for(i=1;i<n;i++)
  {
	  printf(" %d",a[i]);
  }
return 0;
}
move (int a[],int n,int m)
{
	int *p,i,q = 0;
	p = a + n - 1 ;
	for (; q < m;)
	{
		for(;p > a;p--)
		{
			i = *p;
			*p = *(p - 1);
			*(p - 1) = i;
		}
		q++;
		p = a + n - 1;
	}
}
main()
{
	int n, m, *p;
	int b[10000];
	scanf("%d%d",&n,&m);
	for(p = b;p < b + n;p++)
	{
		scanf("%d",p);
	}
	move (b,n,m);
	for (p = b;p < b+n-1;p++)
	{
		printf("%d ",*p);
	}
	printf("%d",*p);
}
//????
int main()
{
	int n,m,A[100],a=0;
	cin>>n>>m;
	int *p=A;
	for(int i=0;i<n;i++)
	{
	    cin>>*(p+i);
	}
	for(int i=0;i<m;i++)
	{
		a=*(p+n-1);
		for(int j=n-1;j>0;j--)
		{
			*(p+j)=*(p+j-1);
		}
		*p=a;
	}
	for(int i=0;i<n;i++)
	{
		if(i==0)
			cout<<*(p+i);
		else
	        cout<<" "<<*(p+i);
	}
	return 0;
}
/*
 * CycleRemove.cpp
 *
 *  Created on: 2013-12-5
 *      Author: 111
 */

int main()
{
	int str[102];
	int n,m;
	cin >> n >> m;
	int *p=NULL;
	for (p=str;p<str+n;p++)
	cin >> *p;
	cout << str[n-m];
	for (p=str+n-m+1;p<str+n;p++)
		cout << ' ' << *p;
	for (p=str;p<str+n-m;p++)
		cout << ' ' << *p;
	return 0;
}
void main()
{
	int n,m,i,a[200],k,l,o;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
       scanf("%d",&a[i]);
	for(k=n-1;k>=0;k--)
		a[k+m]=a[k];
	for(l=0;l<m;l++)
		a[l]=a[n+l];
	for (o=0;o<n-1;o++)
		printf("%d ",a[o]);
	printf("%d\n",a[n-1]);
}
int main()
{
	int n, m;
	int zs[120];
	int i, ex;
	scanf("%d", &n);
	scanf("%d", &m);
	for(i=0;i<n;i++)
		scanf("%d", &(zs[i]));
	int z=(1+n)/2;
	for(i=0;i<z;i++)
	{
		ex=zs[n-1-i];
		zs[n-1-i]=zs[i];
		zs[i]=ex;
	}
	int z1=(1+m)/2;
	for(i=0;i<z1;i++)
	{
		ex=zs[m-1-i];
		zs[m-1-i]=zs[i];
		zs[i]=ex;		
	}
	int z2=m+(1+n-m)/2;
	for(i=m;i<z2;i++)
	{
		ex=zs[n-1-i+m];
		zs[n-1-i+m]=zs[i];
		zs[i]=ex;
	}
	for(i=0;i<n-1;i++)
		printf("%d ", zs[i]);
	printf("%d\n", zs[n-1]);
	return 0;
}
void main()
{
   int m,n,i,t,a[200];
   scanf("%d %d",&n,&m);
   for(i=1;i<=n;i++)
   scanf("%d",&a[i]);
   for(i=n+1;i<=n+n;i++)
   a[i]=a[i-n];
   for(i=n-m+1;i<=(n+n-m-1);i++)
   printf("%d ",a[i]);
   printf("%d",a[n+n-m]);
}
int main()	{
	int n, m, i;
	int a[220];
	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i ++)	{
		scanf("%d", &a[i]);
	}
	for(i = n-1; i >= 0; i --)	{
		a[i+m] = a[i];
	}
	for(i = 0; i < m; i ++)	{
		a[i] = a[i+n];
	}
	int flag = 0;
	for(i = 0; i < n; i ++)	{
		if(flag == 0)	{
			printf("%d", a[i]);
			flag = 1;
			continue;
		}
		if(flag == 1)	{
			printf(" %d", a[i]);
		}
	}
	return 0;
}
int main()
{
	int sz[1000],ss[1000];
	int m,n,i,e;
	scanf("%d %d",&n,&m);
	for(i=0;i<n-1;i++)
	{
		scanf("%d ",&(sz[i]));
	}
	scanf("%d",&(sz[n-1]));
	for(i=0;i<n;i++)
	{
		ss[m+i]=sz[i];
	}
	for(i>=n;i<m+n;i++)
	{
		ss[i-n]=ss[i];
	}
	for(i=0;i<n-1;i++)
	{
		printf("%d ",ss[i]);
	}
	printf("%d",ss[n-1]);
	return 0;
}
void main()
{
	int no[201];
	int n,m,t,i,j;
	int *p;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%d",&no[i]);
	p=no+n;
	for(i=1;i<=n;i++,p--)
		*(p+m)=*p;
	p++;
	for(i=1;i<=m;i++,p++)
		*p=*(p+n);
	for(i=1;i<=n;i++)
		printf((i==n)?"%d\n":"%d ",no[i]);
}
void main()
{
	int a[100],n,m,i;
	int*p;
	scanf("%d %d",&n,&m);
	for (i=0;i<n;i++)
		scanf("%d",&a[i]);
	p=a;
	for(i=1;i<=m;i++)
	{
		int j,t;
		t=*(p+n-1);
		for(j=n-1;j>=1;j--)
		{
			*(p+j)=*(p+j-1);
		}
		*p=t;
	}
	for(i=1;i<=n-1;i++)
	{
		printf("%d ",*(p+i-1));
	}
	printf("%d",*(p+n-1));
	printf("\n");
}
int main()
{
	int a[100],*p,*q,b,n,m,i;
	scanf("%d %d\n",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	p=a;
	q= (int*)malloc(n*sizeof(int));
	for(i=n-m;i<n;i++)
		*(q+i+m-n)=*(p+i);
	for(i=0;i<n-m;i++)
		*(q+i+m)=*(p+i);
	for(i=0;i<n-1;i++)
		printf("%d ",*(q+i));
	printf("%d",*(q+n-1));
	free (q);
	return 0;
}
void main()
{
	int a[200],n,m,i,j;
	scanf("%d%d\n",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=n-1;i>=0;i--)
		a[m+i]=a[i];
	for(i=0;i<m;i++)
		a[i]=0;
	for(j=n;j<n+m;j++)
		a[j-n]=a[j];
	for(j=0;j<n-1;j++)
	printf("%d ",a[j]);
		printf("%d",a[n-1]);
}
int main()


{

	int i,j,k,l,m,n,a[200]={0};

	cin>>n>>m;

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

	  cin>>a[i];

	for(j=n-1;j>=0;j--)

	  a[j+m]=a[j];

	for(k=n;k<=n+m-1;k++)

		a[k-n]=a[k];

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

             cout<<a[i]<<" ";

        cout<<a[n-1];

return 0;

}
int main()
{
	int sz[100],n,m,j;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&sz[i]);
	}
	printf("%d",sz[n-m]);
     for(j=m-2;j>=0;j--)
	{
	    printf(" %d",sz[n-1-j]);
	}
	for(int a=m+1;a<=n;a++)
	{
		printf(" %d",sz[a-m-1]);
	}
	
	return 0;
}
void main()
{
     void change(int *p,int n,int m);
     int a[100],n,m,i,*p=a;
     scanf("%d%d",&n,&m);
     printf("\n");
     for(i=0;i<n;i++,p++)
         scanf("%d",p);
	 p=a;
     change(p,n,m);
}
    

void change(int *p,int n,int m)
{   
     int *i,*j,b[100];
     j=b;
     i=p;
     for(j=b,i=p;i<p+n;i++,j++)
     {
        
         if(i<p+n-m)
         *(j+m)=*i;
         else
          *(j-n+m)=*i;
     }
     for(j=b;j<b+n-1;j++)
	 { printf("%d ",*j);}
         printf("%d",*(b+n-1));

}
////////////////////////
//???????      //
//??????        //
//???1200012823    //
//???2012?11?30?//
//????????    //
////////////////////////


// ???????fromP???blockSize??????targetP
void BlockMove(int* fromP, int* targetP, int blockSize)
{
	if (blockSize == 0)
		return;
	for (int i = 0; i < blockSize; i++) // ????
		*(targetP + i) = *(fromP + i);
}

int main()
{
	int m, i, nums[200], n;
	cin >> n >> m;
	for (i = 0; i < n; i++)
		cin >> nums[i + 100]; // ??????????100?????
	BlockMove(nums + 100 + n - m, nums + 100 - m, m); // ????m???????100?????
	cout << nums[100 - m]; // ????????????????
	for (i = 1; i < n; i++)
		cout << ' ' << nums[100 - m + i];
    return 0;
}
/*
 * yidongshuzu.cpp
 *
 *  Created on: 2011-12-9
 *      Author: Dai Guangda
 */
int main()
{
	int n,m,a[200],*p;
	cin >>n >>m;
	for (p=a; p<a+n; p++)
		cin >>*p;
	for (p=a+n-1; p>=a; p--)
		*(p+m) = *p;
	for (p=a; p<a+m; p++)
		*p = *(p+n);
	for (p=a; p<a+n-1; p++)
		cout <<*p <<' ';
	cout <<*p;
	return 0;
}
void main()
{
	int n,m,i;
	int a[200];          /*?????????????????????????*/
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
    scanf("%d",&a[i]);                 
	for(;i<200;i++)
		a[i]=0;                
	int *p1; 
	int *p2;
	p1=a;                     /*p1??a[0]*/
	p2=&a[99+m];              /*???a[0]??????????a[99]??????a[99+m]*/
	for(i=0;i<n-m;i++)
	{
        *p2=*p1;
        p1++;
        p2++;
       }                    
	p1=&a[n-m];    /*???????*/
	p2=&a[99]; /*?????????m????????100???m???????????m?*/
	for(i=0;i<m;i++)
    *p2++=*p1++;
    printf("%d",a[99]);
    for(i=100;i<99+n;i++)
		printf(" %d",a[i]);            /*??*/

}
int main()
{
    int n,m,num[101],t,i,k;  //??n??????????m??????
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>num[i];      //??n??
	for(k=1;k<=m;k++)            //?????????
	{
		t=num[n];           //??????????????????????
		for(i=n;i>=2;i--)
			num[i]=num[i-1];
		num[1]=t;       //???????????????????????
	}
	for(i=1;i<=n;i++)
	{
		if(i==1)
			cout<<num[i];
		else 
			cout<<" "<<num[i];
	}      //????????
	cout<<endl;
	return 0;
}