semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	
    int num=0,j,i,a,b,x;
	char m[50],n[50];   
    cin>>a;
    cin.get();
    cin>>m;
	cin>>b;

	 for(i=0;m[i]!='\0';i++)
	 {if(m[i]>=65&&m[i]<=90) m[i]=m[i]+32;}     //??????????

	for(i=0;m[i]!='\0'; i++)
     {
          if(m[i]>=48&&m[i]<=57)  x=m[i]-48;
        else x=m[i]-97+10;
          num=num*a+x;                           //?a??????10????num???
     }
        
	 if(num==0) cout<<num<<endl;
	  
	 for(i=0;num!=0;i++)//??????b????n????
	  { 
		  n[i]=num%b;
		  if(n[i]>=9) n[i]=n[i]+55;
		  else n[i]=n[i]+48;
		  num=num/b;
	  }
     

	for(j=i-1;j>=0;j--) cout<<n[j];   

	cout<<endl;

	return 0;
     }
void main()
{
	int a,b,i,m,n,t,sum=0;
	char str[100]={'0'},s[100]={'0'},c[100]={'0'};
	scanf("%d %s %d",&a,str,&b);
	n=strlen(str);
	for (i=0;i<n;i++)
	{
		if (str[i]>=48 && str[i]<=57)
		    sum=sum*a+(int)str[i]-48;
		else
		{	if (str[i]>=65 && str[i]<=90)
                 sum=sum*a+(int)str[i]-55;
            else
			{	 if (str[i]>=97 && str[i]<=122) 
			         sum=sum*a+(int)str[i]-87;
			}
		}
	}
	for (i=0;sum!=0;i++)
	{	t=sum%b;
	    sum=sum/b;
	    if (t<=9)
			s[i]=(char)(t+48);
		else
			s[i]=(char)(t+55);
	}
	m=strlen(s);
	for (i=0;i<m;i++)
	{	c[i]=s[m-1-i];}
	for (i=0;i<m;i++)
	{	printf("%c",c[i]);}
	printf("\n");
}
int main()
{
	int a,b,n,c=0,d,j,i=0,m,s[100];
	char num1[100]={0},num2[100]={0};
	scanf("%d",&a);
	scanf("%s",num1);
	scanf("%d",&b);
	n=strlen(num1);
	for(i=0;i<n;i++)
	{
		if(num1[i]>='a'&&num1[i]<='z')
		{
			num1[i]=num1[i]-32;
		}
	}
	for(i=0;i<n;i++)
    {
        d=1;
        if(num1[i]>='0' &&num1[i]<='9')
        {
            for(j=1;j<n-i;j++)
            {
                d=d*a;
            }
            c=c+(num1[i]-'0')*d;
        }
        else if(num1[i]>='A'&&num1[i]<='Z')
        {    
            for(j=1;j<n-i;j++)
            {
                d=d*a;
            }

            c=c+(num1[i]-'A'+10)*d;
        }
        
    } 
	m=0;
	if(c!=0){
	while(c!=0)
	{
		s[m]=c%b;
		c=(c-s[m])/b;
		m++;
	}
	for(i=0;i<m;i++)
	{
		if(s[i]>=0&&s[i]<=9)
		{
			num2[m-i-1]=s[i]+'0';
		}
		else
		{
			num2[m-i-1]=s[i]-10+'A';
		}
	}
	for(i=0;i<m;i++)
	{
		printf("%c",num2[i]);
	}
	printf("\n");
	}
	else if(c==0)
	{
		printf("%d\n",c);
	}
	return 0;
}
int main()
{
	int i,j,a,n,b;
	char s[100];
	char str[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int c[100];
	scanf("%d%s%d",&a,s,&b);
	n=strlen(s);
	for(i=0;i<n;i++){
		if(s[i]>='a'&&s[i]<='z')
		   c[i]=s[i]-'a'+10;
        if(s[i]>='A'&&s[i]<='Z')
		   c[i]=s[i]-'A'+10;
        if(s[i]>='0'&&s[i]<='9')
		   c[i]=s[i]-'0';
	}
	int k=0;
	for(i=0;i<n;i++){
	    k=k*a;
		k+=c[i];	
	}
	j=0;
	if(k==0)
	printf("0");
	else{
	  while(k!=0){
		s[j]=str[k%b];
		k=k/b;
		j++;		
	    }
	}
	for(i=j-1;i>=0;i--){
		printf("%c",s[i]);
	}
}
main()
{
	int a,b,flag;
	char n[100],m[100];
	char c;
	long i,s=0,k,x,y,t,u;
	scanf("%d%s%d",&a,n,&b);
	for(i=0;n[i]!='\0';i++) {}
	k=i-1;
	for(i=0;i<=k;i++)
	{
		c=n[i];
		if(c>='a' && c<='z') x=c-87;
		if(c>='A' && c<='Z') x=c-55;
		if(c>='0' && c<='9') x=c-48;
		if(c=='0') flag=0;
		s=s+x*(long)pow(a,k-i);
	}
	t=s;
	for(i=0;t>0;i++) 
		u=t%b,t=(t-u)/b;
	k=i-1;
	for(i=0;s>0;i++)
	{
		y=s%b;
		if(y>9) c=y+55;
		else c=y+48;
		m[k-i]=c;
		s=(s-y)/b;
	}
	for(i=0;i<=k;i++) printf("%c",m[i]);
	if(flag==0) printf("0");
	printf("\n");
}
int main()
{
int a,b,c=0;
char num1[200],num2[200];
cin>>a>>num1>>b;
for(int i=0;i<strlen(num1);i++)
{
	if(num1[i]>='A'&&num1[i]<='Z')
		num1[i]+=32;
}
for(int i=0;i<strlen(num1);i++)
{
	if(num1[i]>='a'&&num1[i]<='z') c+=((int)num1[i]-87)*pow((double)a,(double)(strlen(num1)-1-i));
	else if(num1[i]>='1'&&num1[i]<='9') c+=((int)num1[i]-48)*pow((double)a,(double)(strlen(num1)-1-i));
}
if(c==0) cout<<c<<endl;
else{
	int j=0;
for(;;)
{
	if(c==0) break;
	if(c%b<10) num2[j]=(char)(c%b+48);
	else num2[j]=(char)(c%b+55);
	c=c/b;
	j++;
}
for(int i=j-1;i>=0;i--)
{
	cout<<num2[i];
}
cout<<endl;
}
return 0;
}
int main()
{
	int a[100],b[100],in,out,sum=0,num,nnn,i;
	char c;
	scanf("%d",&in);
	getchar();
	for(i=0;i<100;i++)
	{
		scanf("%c",&c);
		if(c<='9' && c>='0')
			a[i]=c-'0';
		if(c<='z' && c>='a')
			a[i]=c-'a'+10;
		if(c<='Z' && c>='A')
			a[i]=c-'A'+10;
		if(c==' ')
		{
			num=i;
			break;
		}
	}
	scanf("%d",&out);
	for(i=0;i<num;i++)
	{
		sum+=a[i]*pow(in,num-i-1);
	}
	for(i=0;i<100;i++)
	{
		b[i]=sum%out;
		sum=(sum-b[i])/out;
		if(sum==0)
		{
			nnn=i+1;
			break;
		}
	}
	for(i=nnn-1;i>=0;i--)
	{
		if(b[i]<=9 && b[i]>=0)
			c=b[i]+'0';
		if(b[i]>9)
			c=b[i]-10+'A';
		printf("%c",c);
	}
	return 0;
}
int main()
{
	int a,b,i,j,la,lb,decimal,number=0,t;
	char str1[1000],str2[1000]={'\0'};
	cin>>a;
	cin.get();
	cin.getline(str1,1000,' ');
	cin>>b;
	la=strlen(str1);
	for(i=0;i<la;i++)
	{
		
      if (str1[i] >= '0' && str1[i] <= '9')    
             decimal = str1[i] - '0';
      else if(str1[i]>='A'&&str1[i]<='Z')
      		decimal = str1[i] - 'A' + 10;
	  else
		  decimal=str1[i]-'a'+10;
      number = number * a + decimal;  
    }
	i=0;
	do
	{
		str2[i]=number%b;
		if(str2[i]>9)
			str2[i]=str2[i]-10+'A';
		else str2[i]=str2[i]+'0';
		number=number/b;
		i++;
	}
	while(number!=0);
	t=i;
	for(j=t-1;j>=0;j--)
	{
		cout<<str2[j];
	}
	
	return 0;
}
main()
{
int i,j,k,m,n;
int n1,n2;
int a[1000];
unsigned long int sum=0,t=1;
char s[500];
scanf("%d %s %d",&n1,s,&n2);
n=strlen(s);
for(i=n-1;i>=0;i--)
{
                   if(s[i]<='Z'&&s[i]>='A')
                   s[i]=s[i]-'A'+10;
                   if(s[i]<='z'&&s[i]>='a')
                   s[i]=s[i]-'a'+10;
                   if(s[i]>='0'&&s[i]<='9')
                   s[i]=s[i]-'0';
                   sum=sum+s[i]*t;
                   if(i==0)
                   break;
                   t=t*n1;                   }
if(sum==0)
printf("0");
else{
i=0;
while(sum!=0)
{
                k=sum%n2;
                a[i]=k;
                i++;
                sum=sum/n2;
                }
i=i-1;
for(j=i;j>=0;j--)
{
                 if(a[j]>=10)
                 printf("%c",a[j]+'A'-10);
                 else
                 printf("%d",a[j]);
                 }}
}
int main(){
	int a,b,i,zhen,chu,result;
	long x=0;
	char n[32],m[32];
	scanf("%d%s%d",&a,n,&b);
	result=strlen(n);
	 
	for(i=0;i<result;i++){
		switch(n[i]){
		case '0':zhen=0;break;
		case '1':zhen=1;break;
		case '2':zhen=2;break;
                  case '3':zhen=3;break;
		case '4':zhen=4;break;
		case '5':zhen=5;break;
		case '6':zhen=6;break;
		case '7':zhen=7;break;
		case '8':zhen=8;break;
		case '9':zhen=9;break;
		case 'a':
        case 'A':
			zhen=10;
		    break;
		case 'b':
		case 'B':
			zhen=11;
			break;
		case 'c':
		case 'C':
			zhen=12;
			break;
		case 'd':
		case 'D':
			zhen=13;
			break;
		case 'e':
		case 'E':
			zhen=14;
			break;
		case 'f':
        case 'F':
			zhen=15;
			break;
		}
		x+=zhen*pow(a,result-1-i);
	}
	for(i=0;x>0;i++){
		chu=x%b;
		x=x/b;
		switch(chu){
        case 0:m[i]='0';break;
		case 1:m[i]='1';break;
        case 2:m[i]='2';break;
		case 3:m[i]='3';break;
        case 4:m[i]='4';break;
		case 5:m[i]='5';break;
		case 6:m[i]='6';break;
		case 7:m[i]='7';break;
		case 8:m[i]='8';break;
		case 9:m[i]='9';break;
		case 10:m[i]='A';break;
		case 11:m[i]='B';break;
		case 12:m[i]='C';break;
		case 13:m[i]='D';break;
		case 14:m[i]='E';break;
		case 15:m[i]='F';break;
		}
	}
	i=i-1;
	for(;i>=0;i--){
		printf("%c",m[i]);
	}
	printf("\n");
	return 0;
}
int change1(char a,int b,int c)
{
	int d;
	if(a>='0'&&a<='9') a=a-'0';
	else if(a>='a'&&a<='z') a=a-'a'+10;
	else if(a>='A'&&a<='Z') a=a-'A'+10;
	d=a*pow(c,b);
	return d;
};
char change2(char a)
{
	if(a>=0&&a<=9) a=a+'0';
	else if(a>=10) a=a+'A'-10;
	return a;
}

int main()
{
	int a,b,c,d,e,f,g,sum=0;
	char s[30],s2[30],s3[30];
	scanf("%d %s %d",&a,s,&b);
	c=strlen(s);
	for(d=0;d<c;d++)
	{
		sum+=change1(s[c-d-1],d,a);
	}
	if(sum==0)
	{
		printf("0");
		return 0;
	}
	for(e=0;;e++)
	{
		s2[e]=sum%b;
		sum=sum/b;
		if(sum<b)
		{
			s2[e+1]=sum;
			break;
		}
	}
	for(f=0;f<30;f++)
	{
		s2[f]=change2(s2[f]);
	}
	for(g=e+1;g>=0;g--)
	{
		printf("%c",s2[g]);
	}
}
int main()
{
	int a,b,n,i,sum=0,t,r;
	char str1[255],str2[255];
	scanf("%d %s %d",&a,str1,&b);
	n=strlen(str1);
	for(i=0;i<n;i++){
		if(str1[i]>='0'&&str1[i]<='9')
			t=str1[i]-'0';
		else if(str1[i]>='A'&&str1[i]<='Z')
			t=str1[i]-'A'+10;
		else if(str1[i]>='a'&&str1[i]<='z')
			t=str1[i]-'a'+10;
			sum=sum*a+t;
	}
	i=0;
	if (sum==0) printf("0\n");
	else
	{
		while (sum!=0)


		while(sum!=0){
			r=sum%b;
			if(r<10)
				str2[i]=r+'0';
			else if(r>=10)
				str2[i]=r-10+'A';
			sum=sum/b;
			i++;
		}
		str2[i]='\0';
		i=strlen(str2)-1;
		while(str2[i]=='0')
			i--;
		for(;i>=0;i--)
		{
			printf("%c",str2[i]);
		}
		printf("\n");
	}
	return 0;
}
int main()
{	char c[1][33],e[1][33]={1};int i=0, j=0,t=0;
   long f,k,m=1,a,b;
     long s=0;int d[1000];
  
cin>>a;
	cin>>c[0];  cin>>b;
	if(c[0][0]==48){cout<<s;}
   else{ 
         while(c[0][i]!='\0'){i++;}
              i=i-1;
                   for(j=0;j<=i;j++){if(i>j){for(f=0;f<i-j;f++)m=m*a;}
                  if(c[0][j]<65) k=(c[0][j]-48)*m;
                  if(c[0][j]>=65&&c[0][j]<97)k=(c[0][j]-55)*m;
                  if(c[0][j]>=97)k=(c[0][j]-87)*m;

                        s=s+k;m=1;}    
           while(s>0){d[t]=s%b;if(d[t]>9)e[0][t]=d[t]+55;
                       s/=b;t++;}
           for(j=t-1;j>=0;j--){if(e[0][j]!='\0'&&e[0][j]!=1)cout<<e[0][j];
					else cout<<d[j]; }
        }					
return 0;}
int main()
{
	int a2i[128]={0};
	char i2a[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char in[MAX],out[MAX]="0";
	int i,from,to,len=0;
	long num=0;
	for(i='0';i<='9';i++)
	{
		a2i[i]=i-'0';
	}
	for(i='A';i<'Z';i++)
	{
		a2i[i]=i-'A'+10;
	}
	for(i='a';i<'z';i++)
	{
		a2i[i]=i-'a'+10;
	}
	scanf("%d%s%d",&from,in,&to);
	for(i=0;in[i]!='\0';i++)
	{
		num=num*from+a2i[in[i]];
	}
	len=(num==0)?1:0;
	while(num>0)
	{
		out[len++]=i2a[num%to];
		num/=to;
	}
	for(i=len-1;i>=0;i--)
	{
		printf("%c",out[i]);
	}
	printf("\n");
	return 0;
}
main(){
	char str[10000], m[10000];
	long a, b, i, j, n[10000], sum=0;
	scanf("%d %s %d", &a, str, &b);
	for(i=0; i<strlen(str); i++){
		if(str[i]<='z' && str[i]>='a') str[i]-=32;
		else str[i]+=0;
	}
	for(i=0; i<strlen(str); i++){
		if('0'<=str[i] && str[i]<='9') str[i]-=48;
		else str[i]-=55;
		n[i]=str[i];
	}
	for(i=0; i<strlen(str); i++) sum+=n[i]*pow(a, strlen(str)-i-1);
	for(i=0; ;i++){
		n[i]=sum%b;
		sum/=b;
		if(sum==0) break;
		else continue;
	}
	for(j=0; j<=i; j++){
		if(n[j]<10) m[j]=n[j]+48;
		else m[j]=n[j]+55;
	}
	for(j=i; j>=0; j--) printf("%c", m[j]);
}
int main()
{
    
    int a,b,c,d,e,f,g,h,i,j,k;
    long int n;
    char str1[40],str2[40];
    scanf("%d %s %d",&a,str1,&b);
    c=strlen(str1);
    n=0;
    for(i=c-1,j=0;i>=0,j<=c-1;i--,j++)
   
    {
     if(str1[j]>='0'&&str1[j]<='9')
     d=str1[j]-48;    
     else 
     {
          if(str1[j]>='A'&&str1[j]<='Z')
           d=str1[j]-55;
           else
           d=str1[j]-87;
     }
     e=1;  
     if(i>0)
     {
    for(k=i;k>0;k--)
     e=e*a;
     }
     n=n+d*e;
    }
    
    
    for(k=0;k<=40;k++)
    {if(n<b)
    {f=n;
     if(f>=0&&f<=9)
     str2[k]=f+48;
     else
     str2[k]=f+55;
     break;}
     else
     {f=n%b;
      if(f>=0&&f<=9)
      str2[k]=f+48;
      else
      str2[k]=f+55;}
      n=(n-f)/b;
     }
g=strlen(str2);
for(h=g-1;h>=0;h--)
printf("%c",str2[h]); 

}
int main()
{
    int a,b,c,sum,i,k,l;
    char n[40];
    scanf("%d %s %d",&a,n,&b);
    l=strlen(n);
    if(n[0]=='0') 
       printf("0\n");
    else
    {
        for(i=0,sum=0;i<l;i++)
        {
            if(n[i]>='a' && n[i]<='z')
               c=n[i]-'a'+10;
            if(n[i]>='A' && n[i]<='Z')
               c=n[i]-'A'+10;
            if(n[i]>='0' && n[i]<='9') 
               c=n[i]-'0';
            sum=c+sum*a;
        }
        char d[40];
        for(k=0;sum!=0;k++)
        {
            d[k]=sum%b;
            sum=sum/b;
        }
        d[k]='\0';
        char e[40];
        for(i=0;i<k;i++)
        {
            if(d[i]<10)
               e[k-1-i]=d[i]+'0';
            else
               e[k-1-i]=d[i]-10+'A';     
        }
        e[k]='\0';
        printf("%s",e);
    }
    getchar();
    getchar();
}
int main()
{
	int a,b,i,k=0,l;
	char n[31],s[31];
	cin>>a>>n>>b;
	l=strlen(n);
	for (i=0;i<l;i++)
	{
		if (n[i]<58) n[i]-=48;
		else if (n[i]>96) n[i]-=87;
		else n[i]-=55;
		k=k*a+n[i];
	}
	i=0;
	if (k==0) cout<<k;
	while(k)
	{
		s[i]=k%b+48;
		if (s[i]>57) s[i]+=7;
		k/=b;
		i++;
	}
	for (;i>0;i--) cout<<s[i-1];
  	return 0;
}
int main()
{
	int a,b,i=0,c=0,d,j=0,e,f,k,x;
	char n[65],m[65]={0};
	scanf("%d %s %d",&a,n,&b);
	d=strlen(n);
	while(n[i]!='\0')
	{
		if(n[i]>='a'&&n[i]<='z')
		     n[i]=n[i]-'a'+10;
		else if(n[i]>='A'&&n[i]<='Z')
		     n[i]=n[i]-'A'+10;
		else n[i]=n[i]-'0'+0;
		i++;
	}	
	i=0;
	c=n[0];
	for(i=0;i<d-1;i++)
	c=c*a+n[i+1];
	while(c>=b)
	{
		m[j]=c%b;
		c=c/b;
		j++;
	}
	m[j]=c;
	for(k=0;k<=j;k++)
	{
		if(m[k]>9) m[k]=m[k]-10+'A';
		else if(m[k]>=0)m[k]=m[k]-0+'0';
	}
	e=strlen(m);
	f=e/2;
	for(k=0;k<=f-1;k++)
	{
		x=m[e-k-1];
		m[e-k-1]=m[k];
		m[k]=x;
	}
	printf("%s",m);
}
/*
 * 1000012761_306.cpp
 *?????????????????2???36?????????long??????????
???????????0?1?...?9?a?b?...?z????0?1?...?9?A?B?...?Z??
 *  Created on: 2010-11-12
 *      Author: 378073652
 */

int main(){
	int a,sn,b,j,k,q,l,t,i;//??????
	double m;
	int s=0;
	char n[100],p[100];//????????
	cin>>a;//
	cin>>n;
	cin>>b;
	sn=strlen(n);
	for(i=0;i<sn;i++)
		{if(n[i]>=97) n[i]=n[i]-32;}

	for(i=sn-1;i>=0;i--)   //????10??
		{
		if(n[i]<=57) {j=n[i]-48;t=sn-1-i;
		s=s+(j*pow((double)a,(double)(t))); }
		else {j=n[i]-55; m=pow((double)a,(double)(sn-1-i)); s=s+j*m;}//s?10??? ????
		}



  if(s==0){ cout<<s; return 0;}//??s?0 ??0
  for(i=0;s!=0;i++)//??  ?????b??
  {q=s%b;
  if(q<=9) p[i]=(48+q);
  else p[i]=(55+q);

  s=(s-q)/b;


  }
p[i]='\0';
l=strlen(p);


for(i=l-1;i>=0;i--)//??
  cout<<p[i];

}
void main()
{
	int a,b;
	long n=0;
	char na[40],nb[40];
	scanf("%d%s%d",&a,na,&b);
	int la;
	la=strlen(na);
	int i,j,s,y;
	for(i=0;i<la;i++)
		if(na[i]-'0'<10) n=a*n+na[i]-'0';
		else if((na[i]-'A'>=0)&&(na[i]-'A'<26)) n=a*n+na[i]-'A'+10;
		else n=a*n+na[i]-'a'+10;
	s=n;
	if(s==0) i=1;
	else
	{for(i=1;s>0;i++)
		s=s/b;
	i--;}
	for(j=1;j<=i;j++)
	{
	y=n%b;
	n=n/b;
	if(y<10) nb[i-j]=y+'0';
	else nb[i-j]=y-10+'A';}
	nb[i]=0;
	puts(nb);
}
void main(void)
{
	int a, b, c, i, z;
	long x = 0;
	char n[65], p[65];
	scanf("%d%s%d", &a, n, &b);
	c = strlen(n);
	for(i = 0;i <= (c - 1);i++)
	{
		if(n[i] <= 'Z'&&n[i] >= 'A')
			n[i] = n[i] + 32;
	}
	i = 0;
	while(n[i] == '0'&&i <= c - 1)
		i = i + 1;
	if (i == c)
		printf("0");
	for(i = 0;i <= (c - 1);i++)
	{
		if(n[i] <= 'z'&&n[i] >= 'a')
			x = x * a + (n[i] - 'a' + 10);
		else
			x = x * a + (n[i] - '0');
	}
	i = 0;
	while(x > 0)
	{
		z = x % b;
		if (z > 9)
			p[i] = 'A' + z - 10;
		else
			p[i] = z + '0';
		i = i + 1;
		x = x / b;
	}
	i = i - 1;
	while(i >= 0)
	{
		printf("%c",p[i]);
		i = i - 1;
	}
}
main()
{
	long int p=0;
	int m,n,e=1,i,q,N;
	char a[100],b[100];
	scanf ("%d",&m);
	scanf ("%s",a);
	scanf ("%d",&n);
	N=strlen(a);
	for(i=0;i<=N-1;i++)
	{
		if (a[i]>='a'&&a[i]<='z')
			b[i]=a[i]-'a'+10;
		else if (a[i]>='A'&&a[i]<='Z')
			b[i]=a[i]-'A'+10;
		else
			b[i]=a[i]-'0';
	}
	for(i=N-1;i>=0;i--)
	{
		p+=b[i]*e;
		e*=m;
	}
	for (i=0;;i++)
	{
      b[i]=p%n;
	  p=p/n;
	  if (p==0)
	  {
		  q=i;
		  break;
	  }
	}
    for (i=q;i>=0;i--)
	{
		if (b[i]>=0&&b[i]<=9)
			printf ("%c",b[i]+'0');
		else 
			printf ("%c",b[i]-10+'A');
	}
}
int main() 
{ 
char k[32]; 
int l[32]; 
long a,b,d,i,s,n=0; 
s=1; 
n=0; 
scanf("%d%s%d",&a,k,&b); 
d=strlen(k); 
i=d-1; 
while(i>=0) 
{ 
if(k[i]>='A'&&k[i]<='Z') 
n=n+(k[i]-'A'+10)*s; 
else if(k[i]>='a'&&k[i]<='z') 
n=n+(k[i]-'a'+10)*s; 
else 
n=n+(k[i]-'0')*s; 
i--; 
s*=a; 
}
if(n==0)
{
 printf("0");
 return 0;
}
for(i=0;n>0;i++) 
{ 
l[i]=n%b; 
n/=b; 
} 
d=i; 
for(i=d-1;i>=0;i--) 
{ 
if(l[i]>=10) 
printf("%c",l[i]-10+'A'); 
else 
printf("%d",l[i]); 
} 
printf("\n");
}
main()
{
     char S[N],T[N];
     long int a,n,b,S10=0,d=1,l=1,m=1,num[N];
     int i,j,k,r,t;
     scanf("%d %s %d",&a,S,&b);
     t=strlen(S);
     for(j=0;j<t-1;j++)
     {
          d=d*a;
     }
     for(i=0;i<t;i++)
     {
          if(S[i]<='9')
          {
                 l=S[i]-'0';
                 S10=S10+l*d;
                 d=d/a;
          }
          if(S[i]>'9')
          {
                 if(S[i]>'a'-1)
                 {
                         S[i]=S[i]-'a'+'A';
                 } 
                 l=10+S[i]-'A';
                 S10=S10+l*d;
                 d=d/a;
          }
     }
     for(k=0;;k++)
     {
          num[k]=S10%b;
          S10=S10/b;
          if(S10==0)
          {
                 break;
          }
     }
     t=k;
     for(r=0;r<=t;r++,k--)
     {
          if(num[k]<='9'-'0')
          {
                  T[r]='0'+num[k];
          }
          if(num[k]>'9'-'0')
          {
                  T[r]='A'+num[k]-10;
          }
     }
     T[r]='\0';
     printf("%s",T);
}
/**
* @file 2.cpp
* @author ??? 1100012944
* @date 2011-11-12
* @description
* ???????????
*/
long int change1(char n[], int a)
{
	long int s, y = 0;
	int i;
	for(i = 0; n[i] != '\0'; i++) 
	{ 
		if (n[i] >= '0' && n[i] <= '9') 
			s = n[i] - '0'; //9???????10???? 
		else if (n[i] >='A' && n[i] <='Z')
		{
			s = n[i] - 'A' + 10;
		}
		else
		{
			s = n[i] - 'a' + 10;
		}
		y = y * a + s;
	}
	return y;
}
int main()
{
	int a, b, i = 0, j;
	long int s, t;
	char n[200], r[200];
	cin >> a;
	cin >>n;
	cin >> b;
	s = change1(n, a);
	while( s >= b )
	{
		t = s % b;
		if ( t >= 0 && t <= 9)
		{
			r[i] = t + '0';
		}
		else 
		{
			r[i] = t - 10 + 'A';
		}

		i ++;
		s = s / b;
	}
	if ( s >= 0 && s <= 9)
	{
		r[i] = s  + '0';
	}
	else
	{
		r[i] = s - 10 + 'A';
	}
	for ( j = i; j >= 0; j --)
	{
		cout << r[j];
	}
	return 0;
}
void main()
{
	int a=0,b=0,i;
	long int e=0;
	char c[33];
	int f(char x);char g(int x);
       scanf("%d%s%d",&a,c,&b);
		for(i=0;c[i]!=0;i++)
			e=a*e+f(c[i]);
		if(e==0)printf("0");
		for(i=32;e>0;i--)
		{
			c[i]=g(e%b);
			e=e/b;
		}
		for(++i;i<=32;i++)
			printf("%c",c[i]);
		printf("\n");		
}
int f(char x)
{
	if('0'<=x&&x<='9')
		return(x-'0');
	else if('A'<=x&&x<='Z')
		return(x-'A'+10);
		else return(x-'a'+10);
}
char g(int x)
{
	if(0<=x&&x<=9)
		return(x+'0');
		else return(x+'A'-10);
}
void main()
{
	long int a,n=0,b,i,k,j,c,r;
	char x[100],y[100];
	scanf("%ld%s%ld",&a,x,&b);
	
	k=strlen(x);
	for(i=0;i<k;i++)
	{
		
		if(x[i]>='0'&&x[i]<='9')
		{
			c=x[i]-48;
			for(j=1;j<=k-1-i;j++)
				c=c*a;
			n=n+c;
		}
		else if(x[i]>='A'&&x[i]<='Z')
		{
			c=x[i]-55;
			for(j=1;j<=k-1-i;j++)
				c=c*a;
			n=n+c;
		}
		else 
		{
			c=x[i]-87;
			for(j=1;j<=k-1-i;j++)
				c=c*a;
			n=n+c;
		}
	}
    i=0;
	do
	{
		r=n%b;
		if(r>=0&&r<=9)
			y[i]=r+48;
		else y[i]=r+55;
		n=n/b;
		i=i+1;
	}while(n!=0);

	for(k=i-1;k>=0;k--)
		printf("%c",y[k]);
		

}
int main()
{
	char n[32],t[32];
	double a,b;
	int i,m[32],c[32],d[32],size,k;
	long n10=0;
	cin>>a>>n>>b;
	size=strlen(n);
	for(i=0;i<size;i++)
		if(toascii(n[i])>=48&&toascii(n[i])<=57)
			m[i]=toascii(n[i])-48;
		else if(toascii(n[i])>=65&&toascii(n[i])<=90)
			m[i]=toascii(n[i])-55;
		else if(toascii(n[i])>=97&&toascii(n[i])<=122)
			m[i]=toascii(n[i])-87;
		for(i=0;i<size;i++)
		n10=n10+m[i]*pow(a,size-i-1);
if (n10==0)
cout << 0 << endl;
	for(i=0;i<32;i++)
		if(pow(b,i)>n10)
		{
			k=i;
			break;
		}
		c[0]=n10/pow(b,k-1);
			for(i=1;i<k;i++)
				{
					n10=n10-c[i-1]*pow(b,k-i);
			        c[i]=n10/(pow(b,k-1-i));
			    }
				for(i=0;i<k;i++)
					if(c[i]<10) d[i]=c[i]+48;
					else if (c[i]>=10) d[i]=c[i]+55;
					for(i=0;i<k;i++)
						t[i]=d[i];
					t[k]='\0';
					cout<<t;
	return 0;
}
int convertorto10(char A[],int code,int right)
{
	if(right==0)
		return(A[0]-'0');
	else return(A[right]-'0'+code*convertorto10(A,code,right-1));
}
void main()
{
	int a,b,l,c,i,j;
	char n[100],nf[100],m[100],mf[100];
	scanf("%d %s%d",&a,n,&b);
	l=strlen(n);
	for(i=0;i<l;i++)
	{
		if(64<n[i]&&n[i]<91)
			nf[i]=n[i]-7;
		else if(n[i]>96)
			nf[i]=n[i]-39;
		else nf[i]=n[i];
	}
	c=convertorto10(nf,a,l-1);
	i=0;
	while(c/b>0)
	{
		m[i]=c%b;
		c=c/b;
		i=i+1;
	}
	m[i]=c;
	for(j=0;j<=i;j++)
		mf[j]=m[i-j];
	for(j=0;j<=i;j++)
	{
		if(mf[j]<10)
			mf[j]=mf[j]+48;
		else if(mf[j]>9)
			mf[j]=mf[j]+55;
	}
	for(j=0;j<=i;j++)
		printf("%c",mf[j]);
}
int main()
{
   int ah,af,i,j=0 ,len= 0,sum=0,jin=1 ,zhuan[100];
   char num[100],zhuanfu[100];
   cin>>ah;
   cin>>num;
   cin>>af;
   len = strlen(num);
   if( num[0]=='0' )
   printf("0");
   for( i = len-1;i >= 0;i--  )
   {
   if(num[i]>='a'&&num[i]<='z')
   num[i]-=87;
   if( num[i]>='A'&&num[i]<='Z' )
   num[i]-=55;
   if( num[i]>='0'&&num[i]<='9' )
   num[i]-=48;
   sum += num[i]*jin;
   jin*=ah;
   }
   while( sum != 0 )
   {
      zhuan[j]=sum%af;
      sum/=af;
      j++;
   }
   for( i = j-1;i>=0;i-- )
   {
   if( zhuan[i]>=10 )
   printf("%c",zhuan[i]+55);
   else
   printf("%d",zhuan[i]);
   }
}
main()
{
  char c[100],d[100];
  int a,n=0,b,l,i,j,e;
  scanf("%d %s %d",&a,c,&b);
  l=strlen(c);
  for(i=0;i<=l-1;i++)
  {
    if(c[i]>='A'&&c[i]<'a')
    e=c[i]-'A'+10;
    else if(c[i]>='a')
    e=c[i]-'a'+10;
    else
    e=c[i]-'0';
    n=n*a+e;                 
  }
  for(i=0;;i++)
  { 
    d[i]=n%b;
    n=n/b;
    if(d[i]>=10)
    d[i]=d[i]-10+'A';
    else
    d[i]=d[i]+'0';
    if(n==0)
    break;                 
  }
  for(j=i;j>=0;j--)
  printf("%c",d[j]);
  printf("\n");
  getchar();
  getchar();
  getchar();
  getchar();      
}
int main()
{
    char n[40],y[40],z[40];
    int a,b,c=0,l,i,k;    
    scanf("%d %s %d",&a,n,&b);
    l = strlen(n);
    for (i = 0;i<l;i++)
    {
     if(n[i]>='0'&&n[i]<='9')        
        n[i]=n[i]-'0';
     if(n[i]>='a'&&n[i]<='z')
        n[i]=n[i]-'a'+10;
     if(n[i]>='A'&&n[i]<='Z')   
        n[i]=n[i]-'A'+10;        
    }
    
    for (i = 0;i<l;i++)
    {       
        c = n[i] + a *c ;
    }
    for (k = 0;c!=0;k++)    
    {
     y[k] = c%b;
     c=c/b;
    }
    if (k == 0)
    printf("0\n");
    else 
    {
     for (i = 0;i<k;i++)
     {
     z[i]=y[k-i-1];   
     }
     for (i = 0;i<k;i++)
     {
     if(z[i]>=0&&z[i]<=9)        
        z[i]=z[i]+'0';
     if(z[i]>9&&z[i]<=36)
        z[i]=z[i]-10+'A';          
     }
    z[k]=0;
    
    printf("%s\n",z);
    }
}
//*******************
//*???????*
//*??????*
//*2011/11/14*
//*******************

int change(char a)					
{
	int b;
	if (( a <= '9' ) && ( a >= '0' ))
		b = a - '0';
	else if (( a >= 'a') && ( a <= 'z'))
		b = a - 'a' + 10 ;
	else 
		b = a - 'A' + 10 ;
	return b ;
} // ?????????????????

int main()
{
	int i = 0, j, num1, num2, m;		
	long ten = 0;	// ten???????
	char output[100];
	char chu, mo;
	cin >> num1;
	cin.get();
	
	while ((chu = cin.get()) != ' ')				
	{
		m = change(chu);	// ????
		ten = ten * num1;	// ?num1??????????????ten
		ten = ten + m;
	}
	
	cin >> num2;
	
	while (ten > 0)	
	{
		m = ten % num2;			
		if (m > 9)				
			mo = m - 10 + 'A';	
		else
			mo = m + '0';
		output[i] = mo;				
		i++ ;
		ten = ten / num2;
	} // ?????????????
	
	if (i == 0)			
		cout << "0" << endl ;
	else
		for (j = i - 1; j >= 0; j--)
			cout << output[j];	
	return 0;
}
int convertor(char A[],int code,int right)
{
	if(right==0)
		return(A[0]);
	else return(A[right]+code*convertor(A,code,right-1));
}

void main()
{int shuzhi1,shuzhi2,i,j,n,l;
 char num1[20],num2[20];
 scanf("%d",&shuzhi1);
 scanf("%s",num1);
 scanf("%d",&shuzhi2);
 n=strlen(num1);
 for(i=0;i<n;i++)
	{if(num1[i]>='A'&&num1[i]<='Z')
		 num1[i]=num1[i]-'A'+10;
     else if(num1[i]>='a'&&num1[i]<='z')
		 num1[i]=num1[i]-'a'+10;
	 else if(num1[i]>='0'&&num1[i]<='9')
		 num1[i]=num1[i]-'0';
	}
 l=convertor(num1,shuzhi1,n-1);
 j=0;
while(l/shuzhi2>0)
	{
	 num2[j]=l%shuzhi2;
     l=l/shuzhi2;
	 j++;
	}
 num2[j]=l;
 for(i=0;i<=j;i++)
	 	{if(num2[i]>9)
		 num2[i]=num2[i]-10+'A';
         else num2[i]=num2[i]+'0';
		}
 for(i=j;i>=0;i--)
	 printf("%c",num2[i]);
}