semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int j1,j2,i,an[10000],bn[10000],shijinzhi=0,changdu;
	char a[10000],b[10000];
	scanf("%d%s%d",&j1,a,&j2);
	changdu=strlen(a);
	for(i=0;i<changdu;i++)
	{
		if(a[i]<123&&a[i]>96)
		{
			an[i]=a[i]-87;
		}
		else if(a[i]<91&&a[i]>64)
		{
			an[i]=a[i]-55;
		}
		else
		{
			an[i]=a[i]-48;
		}
	}
	for(i=0;i<changdu;i++)
	{
		shijinzhi+=an[i]*pow(j1,changdu-1-i);
	}
	for(i=0;;i++)
	{
		bn[i]=shijinzhi%j2;
		shijinzhi=shijinzhi/j2;
		if(shijinzhi==0)
		{
			changdu=i+1;
			break;
		}
	}
	for(i=changdu-1;i>=0;i--)
	{
		if(bn[i]>=0&&bn[i]<10)
			b[changdu-1-i]=bn[i]+48;
		else b[changdu-1-i]=bn[i]+55;
	}
	for(i=0;i<changdu;i++)
	{
		printf("%c",b[i]);
	}
	
	return 0;
}
main()
{
    int f,t,n[10000],m[10000],l,i,s=0,k,g,h;
    char c[10000],d[10000];
    scanf("%d %s %d",&f,&c,&t);
    l=strlen(c);
    for (i=l-1;i>=0;i--)
    {
        if (c[i]>='0' && c[i]<='9')
            n[l-1-i]=c[i]-'0'; 
        else
        {
            if (c[i]>='a' && c[i]<='z')
                n[l-1-i]=c[i]-'a'+10;
            else
            {
                if (c[i]>='A' && c[i]<='Z')
                    n[l-1-i]=c[i]-'A'+10;
            }
        }
    }
    for (i=0;i<l;i++)
    {   
        g=1;
        for (k=0;k<i;k++)
            g*=f;
        s+=n[i]*g;
    }
    if (s==0)
        h=1;
    else
        h=0;
    for (k=0;s!=0;k++)
    {
        m[k]=s%t;
        s=s/t;
    }
    for (i=k-1;i>=0;i--)
    {
        if (m[i]<=9)
            d[k-1-i]=m[i]+'0';
        else
            d[k-1-i]=m[i]-10+'A';
    }
    for (i=0;i<k;i++)
    {
        printf("%c",d[i]);
    }
    if (h==1)
        printf("0");
    printf("\n");
}
int main()
{
	int a, b;
	char num[100], t[100];
	scanf("%d%s%d", &a, num, &b);
	long shi = 0;
	int i;
	for(i = 0; num[i] != '\0'; i++)
	{
		if(num[i] >= '0' && num[i] <= '9')
		{
			shi = shi * a + num[i] - '0';
		}
		if(num[i] >= 'a' && num[i] <= 'z')
		{
			shi = shi * a + num[i] - 'a' + 10;
		}
		if(num[i] >= 'A' && num[i] <= 'Z')
		{
			shi = shi * a + num[i] - 'A' + 10;
		}
	}
	for(i = 0; shi != 0; i++)
	{
		if((shi % b) <= 9)
		{
			t[i] = (shi % b) + '0';
		}
		else
		{
			t[i] = (shi % b) - 10 + 'A';
		}
		shi = shi / b;
	}

	int j;
	for(j = i - 1; j >= 0; j--)
	{
		printf("%c", t[j]);
	}
	printf("\n");

	return 0;
}
void main()
{ 
	char c[101],q[101];
	int a,i,j,b,len;
	long int p=0,x,d;
	scanf("%d",&a);
	scanf("%s",c);
	scanf("%d",&b);
	len=strlen(c);
	for(i=0;i<len;i++)
	{
		if((c[i]>='A')&&(c[i]<='Z')) x=c[i]-'A'+10;
		else if((c[i]>='a')&&(c[i]<='z')) x=c[i]-'a'+10;
		else x=c[i]-'0'+0;
		for(j=1;j<len-i;j++) x*=a;
		p+=x;
	}
	i=0;
	do
	{
		
		x=p%b;
		if(x>9) q[i]=x-10+'A';
		else q[i]='0'+x;
		p/=b;
		i++;
	}while(p!=0);
	for(j=i-1;j>=0;j--) printf("%c",q[j]);
}
void main()
{
	int a,b;
	char n[100];
	scanf("%d %s %d",&a,n,&b);
	int i,j=0;
	int ten[100];
	for(i=0;n[i]!='\0';i++)
	{
		j++;
		if(n[i]>='0' && n[i]<='9')
			ten[i]=n[i]-48;
		else if(n[i]>='A' && n[i]<='Z')
			ten[i]=n[i]-55;
		else
			ten[i]=n[i]-87;
	}
	int te[100];
	te[0]=1;
	for(i=0;i<j;i++)
		te[i+1]=te[i]*a;
	int t=0;
	for(i=0;i<j;i++)
		t+=te[i]*ten[j-i-1];
	char m[100];
	int ben[100];
	j=0;
	if(t==0)
		printf("0\n");
	else
	{
	for(i=0;t!=0;i++)
	{
		j++;
		ben[i]=t%b;
		t=t/b;
	}
	for(i=0;i<j;i++)
	{
		if(ben[j-i-1]>=0 && ben[j-1-i]<=9)
			m[i]=ben[j-1-i]+48;
		else
			m[i]=ben[j-1-i]+55;
	}
	for(i=0;i<j;i++)
		printf("%c",m[i]);
	printf("\n");
	}
}
int main()
{
	char zhuan[36]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int a,b;
	char c[64],r[64];
	int i,k;
	long sum=0;
	int q=0,w[64];
	scanf("%d %s %d",&a,c,&b);
	for(i=0;c[i];i++)
	{if(c[i]>='0'&&c[i]<='9')
	    k=c[i]-'0';
    else if(c[i]>='A'&&c[i]<='Z')
		k=c[i]-'A'+10;
	else if(c[i]>='a'&&c[i]<='z')
		k=c[i]-'a'+10;
	sum=sum*a+k;}
    if(sum==0)
		printf("0\n");
	if(sum!=0)
	{while(sum>0)
	{w[q]=sum%b;
	sum=sum/b;
	q++;}//*
	for(i=0;i<q;i++)
	{r[q-1-i]=zhuan[w[i]];
	}
	for(i=0;i<q;i++)
		printf("%c",r[i]);}
	
    return 0;
}
void main()
{	int a,b,i=0,k;
	long unsigned x[100]={0},y=0;
	scanf("%d",&a);
	k=getchar();
	while((k=getchar())!=' '){	
		if(k>='A'&&k<='Z') k=k-55;
		if(k>='a'&&k<='z') k=k-55-32;
		if(k>='0'&&k<='9') k=k-48;
		y=y*a+k;
	}
	scanf("%d",&b);
	i=0;
	if(y==0) printf("0");
	while(y>0){
		x[i]=y%b;
		y=y/b;
		i++;
	}
	
	for(i--;i>=0;i--)
	{if(x[i]<10) printf("%d",x[i]);
	else printf("%c",x[i]+55);
	}
}
int main(int argc, char* argv[])
{

    int a,b,i=0,k,x=0,n=0,m=0;
	char s[20];
	int t[20];
    scanf("%d%s%d",&a,s,&b);

	
 	while(s[i]!='\0')
	{
		n++;
		i++;	
	}

	for(i=0;i<n;i++)
	{
		if(s[i]<=57) k=(int)s[i]-48;
		else if(s[i]<=90) k=(int)s[i]-55;
		else k=(int)s[i]-87;
        x=x+k*(int)pow(a,n-i-1);
	}


	i=0;

loop:;
		    t[i]=x%b;
	        x=x/b;
			i++;
			m++;
			if(x!=0) goto loop; 

	for(i=m-1;i>=0;i--)
	{
		if(t[i]<=9)
		printf("%d",t[i]);
		else if(t[i]>=10)
		{
			t[i]=t[i]+55;
	    	printf("%c",t[i]);
		}
	}


	return 0;
}
void main()
{
	int a,b,i,j;long int shijinzhi=0,result=0,q,p=0,k=0;
	char n[100];
	scanf("%d%s%d",&a,n,&b);
	if(n[0]>=48&&n[0]<=57)
		j=n[0]-48;
	if(n[0]>=65&&n[0]<=90)
		j=n[0]-55;
	if(n[0]>=97&&n[0]<=122)
		j=n[0]-87;
	shijinzhi=shijinzhi+j;
	for(i=1;;i++)
	{
		if(n[i]=='\0')
			break;
		else
		{
		if(n[i]>=48&&n[i]<=57)
			j=n[i]-48;
		if(n[i]>=65&&n[i]<=90)
			j=n[i]-55;
		if(n[i]>=97&&n[i]<=122)
			j=n[i]-87;
		shijinzhi=shijinzhi*a+j;
		}
	}
	q=shijinzhi;
	int s=1,t;
	shijinzhi=shijinzhi/b;
	while(shijinzhi!=0)
	{
		shijinzhi=shijinzhi/b;
		s=s*b;
		p++;
	}
	shijinzhi=q;
	while(shijinzhi!=0)
	{
		t=shijinzhi/s;
		if(t<=9)
			printf("%c",t+48);
		else
			printf("%c",t+55);
		shijinzhi=shijinzhi-t*s;
		s=s/b;
		k++;
	}
	if(k<p+1)
	{
		for(i=0;i<p+1-k;i++)
			printf("%c",48);
	}
}
int main()
{
    int a=0,b=0;//a,b???????
    char m[32];//m?????b???
    char n[32];//n????a???
    int i=1;//i?????
    long sum=0;//sum?????????
    cin>>a;
    n[0]=getchar();//????????
    while((n[i]=getchar())!=' ')
    {
        if(n[i]>47&&n[i]<58)//????ASCII??????
        n[i]-=48;
        else if(n[i]>64&&n[i]<91)
        n[i]-=55;
        else if(n[i]>96&&n[i]<123)
        n[i]-=87;
        sum=a*sum+n[i];//?a??????????
        i++;
    }
    cin>>b;
    i=0;
    do
    {
        m[i]=sum%b;
        if(m[i]>=0&&m[i]<=9)
        m[i]+=48;
        else if(m[i]>9&&m[i]<36)
        m[i]+=55;
        sum=sum/b;
        i++;
    }while(sum!=0);
    for(int j=i-1;j>=0;j--)
    cout<<m[j];
    return 0;
}
//????????
//??????
int main ()
{
  char string1[1000],string2[1000];   //?????string1,string2
  int b,c=0,i;       //??????????b,?????c,????i
  float a,d;           //????????????a,????????????d
  cin>>a>>string1>>d;  
  b=strlen(string1);   //?????string1???
  for(i=0;i<b;i++)     //??a?????10??
  {
	  if(string1[i]>='0'&&string1[i]<='9')
		c+=(string1[i]-48)*pow(a,b-i-1);
	  if(string1[i]>='a'&&string1[i]<='z')
		c+=(string1[i]-87)*pow(a,b-i-1);
	  if(string1[i]>='A'&&string1[i]<='Z')
		c+=(string1[i]-55)*pow(a,b-i-1);
   }
int index=0;             //????????index,????e
int e;
if(c==0)   
cout<<'0'<<endl;           //????10????0,????0
while(c!=0)                //???????d??
{
	e=c%(int)d;
	c=c/d;
	if(e>=10)
		string2[index]='A'+e-10;
	else
		string2[index] ='0'+e;
	index++;
}
for(i=index-1;i>=0;i--)
	cout<<string2[i];  //??????d???
cout<<endl;
return 0;
}
int t[100]={0};
int a,b;

unsigned long int atoten(char *p)
{
	unsigned long int s=0;
    int len,i;

	len=strlen(p);

	p=p+len-1;

	for(i=0;i<len;i++,p--)
	{
		if(*p>='0' && *p<='9')
		s=s+(*p-'0')*pow(a,i);
		else if(*p>='a' && *p<='z')
			s=s+(*p-'a'+10)*pow(a,i);
		else s=s+(*p-'A'+10)*pow(a,i);

	}

	return s;

}


int tentob(unsigned long int s)
{
	int i,k;

	for(i=0;s!=0;i++)
	{
		t[i]=s%b;
		s=s/b;
	}
	k=i-1;
	return k;

}

void print(int k)
{
	int i;

	if(k<0) printf("0");

	for(i=k;i>=0;i--)
	{
		if(t[i]>9)
		{
			t[i]+='A'-10;
			printf("%c",t[i]);
		}
		else printf("%d",t[i]);
		
	}

}

void main()
{
	unsigned long int s;
	char n[100]={'\0'};
	int k;

	scanf("%d %s %d",&a,n,&b);
	

	s=atoten(n);
	k=tentob(s);
	print(k);


}
void main()
{
	char s[20]="0",d[20],k;
	int a,b,c,i=0,e;
	long n=0;
	scanf("%d ",&a);
	while((s[i]=getchar())!=' ')
	{
		i++;
	}
	scanf("%d",&b);
	c=strlen(s)-1;
    for(i=c-1;i>=0;i--)
	{
		if (s[i]>=65&&s[i]<=90)
			s[i]=s[i]-55;
		else if (s[i]>=48&&s[i]<=57)
			s[i]=s[i]-48;
		else if (s[i]>=97&&s[i]<=122)
			s[i]=s[i]-87;
		n=n+s[i]*pow(a,c-1-i);
	}
	i=0;
	e=n;
	do
	{
		d[i]=e%b;
		if (d[i]>=10)
			d[i]=d[i]+55;
		else d[i]=d[i]+48;
		i++;
		e=e/b;
	}while (e!=0);
	for(i=i-1;i>=0;i--)
	{
		if (i!=0)
		    printf("%c",d[i]);
		else printf("%c\n",d[i]);
	}

}
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]>=(int)'A'&&num1[i]<=(int)'Z')
		num1[i]+=32;
}
for(int i=0;i<strlen(num1);i++)
{
	if(num1[i]>=(int)'a'&&num1[i]<=(int)'z') c+=((int)num1[i]-87)*pow((double)a,(double)(strlen(num1)-1-i));
	else if(num1[i]>=(int)'1'&&num1[i]<=(int)'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 n,i,k,a,b,y,w=0;
	char s1[100]={'\0'},s2[100]={'\0'},e;
	scanf("%d%s%d",&a,s1,&b);
	for(i=0;s1[i];i++){
		if(s1[i]<='Z'&&s1[i]>='A'){
			s1[i]=s1[i]-'A'+'a';
		}
	}
	for(i=0;s1[i];i++){
		if(s1[i]<='z'&&s1[i]>='a'){
			w=w*a+s1[i]-'a'+10;
		}else{
			w=w*a+s1[i]-'0';
		}
	}
//	printf("%d\n",w);
	for(i=0;1;i++){
		y=w%b;
		if(y<=9&&y>=0){
			s2[i]=y+'0';
		}else{
			s2[i]=y-10+'A';
		}
		w=w/b;
		if(w==0){
			break;
		}
	}
	w=strlen(s2);
	for(i=0;i<w-i;i++){
		e=s2[i];
		s2[i]=s2[w-i-1];
		s2[w-i-1]=e;
	}
	printf("%s",s2);
//	scanf("%d",&n);
	return 0;
}
long ab(char s){
	long r=100;

	if(s>='0'&&s<='9'){
		r=s-48;
	}
	else if(s>='a'&&s<='z'){
		r=s-87;
	}
	else if(s>='A'&&s<='Z'){
		r=s-55;
	}

	return r;
}

char ba(long k){

	char r='!';

	if(k>=0&&k<=9){
		r=k+48;
	}
	else if(k>=10&&k<=35){
		r=k+55;
	}

	return r;
}

int main(){

	long a=0;

	long b=0;

	char str[3000];

	char out[3000];

	cin>>a>>str>>b;

	long n=0;
	long num=0;
	long k=1;

	while(ab(str[n])!=100){
		n++;
	}

	for(int i=n-1;i>=0;i--){
		num+=ab(str[i])*k;
		k*=a;
	}

	int i=0;
	

	while(num!=0){
		out[i]=ba(num%b);
		num/=b;
		i++;
	}

	if(i==0) cout<<0;

	for(int j=i-1;j>=0;j--){
		cout<<out[j];
	}


	return 0;
	
}
/*
 * shujuzuzhi2_6.cpp
 *Name?????
 *  Created on: 2011-1-13
 *      Author: ??
 */

int main() {
	int a, b, l, n = 0, i;//a?????????????b??????????l?????????????n?????????
	int y[100] = { 0 };//???????????????????
	char num[100] = { 0 };//??????????a????
	cin >> a;//????????
	cin >> num;//???????
	cin >> b;//????????
	l = strlen(num);//???????????????
	for (i = 0; i < l; i++)//????????????????
	{
		if ((num[i] >= 'a') && (num[i] <= 'z'))
			num[i] = num[i] - 87;
		else if ((num[i] >= 'A') && (num[i] <= 'Z'))
			num[i] = num[i] - 55;
		else if ((num[i] >= 48) && (num[i] <= 57))
			num[i] = num[i] - 48;
		n = n * a + num[i]; //??????n*a+num[i]???????a??num?????????10??????n??
	}
	if (n == 0)
		cout << 0;//????0???0
	else {//?10???n???b??????y???
		i = 0;
		while (n != 0) {
			y[i++] = n % b;
			n = n / b;
		}
		for (i--; i >= 0; i--) //????????y??????????
		{
			if (y[i] > 9)
				cout << (char) (y[i] + 55);
			else
				cout << y[i];
		}
	}
	cout << endl;
	return 0;
}
int zheng(char x);
char fan(int x);


int main(int argc, char* argv[])
{
	int n,m,f,sum,i;
	char zhuan[50];
	scanf("%d",&n);
	char x[10];
	scanf("%s",x);
	scanf("%d",&m);
	f=strlen(x);
 

	sum=0;
	int wei=0;
	for(i=0;i<f;i++){
		sum=sum+zheng(x[i])*pow(n,f-i-1);
	}
	for(i=49;i>=0;i--){
		zhuan[i]=fan(sum%m);
		wei++;
		sum=sum/m;
		if(sum==0)
			break;
	}
	for(i=50-wei;i<50;i++){
		printf("%c",zhuan[i]);
	}
  return 0;
}
int zheng(char x){
	int m;
   switch(x){
     case '1':m=1;break;
     case '2':m=2;break;
     case '3':m=3;break;
     case '4':m=4;break;
	 case '5':m=5;break;
	case '6':m=6;break;
	case '7':m=7;break;
	case '8':m=8;break;
	 case '9':m=9;break;
	 case '0':m=0;break;
	 case 'a':m=10;break;
	case 'A':m=10;break;
	case 'b':m=11;break;
	case 'B':m=11;break;
    case 'c':m=12;break;
    case 'd':m=13;break;
	case 'e':m=14;break;
	case 'f':m=15;break;
	case 'g':m=16;break;
	case 'h':m=17;break;
    case 'i':m=18;break;
	case 'j':m=19;break;
	case 'k':m=20;break;
	case 'l':m=21;break;
	case 'm':m=22;break;
	case 'n':m=23;break;
	case 'o':m=24;break;
	case 'p':m=25;break;
	case 'q':m=26;break;
	case 'r':m=27;break;
	case 's':m=28;break;
	case 't':m=29;break;
	case 'u':m=30;break;
	case 'v':m=31;break;
	case 'w':m=32;break;
	case 'x':m=33;break;
	case 'y':m=34;break;
	case 'z':m=35;break;
	case 'C':m=12;break;
	case 'D':m=13;break;
	case 'E':m=14;break;
	case 'F':m=15;break;
	case 'G':m=16;break;
	case 'H':m=17;break;
	case 'I':m=18;break;
	case 'J':m=19;break;
	case 'K':m=20;break;
	case 'L':m=21;break;
	case 'M':m=22;break;
	case 'N':m=23;break;
	case 'O':m=24;break;
	case 'P':m=25;break;
	case 'Q':m=26;break;
	case 'R':m=27;break;
	case 'S':m=28;break;
	case 'T':m=29;break;
	case 'U':m=30;break;
	case 'V':m=31;break;
    case 'W':m=32;break;
	case 'X':m=33;break;
	case 'Y':m=34;break;
	case 'Z':m=35;break;
	 
   }
   return m;
}

char fan(int x){
	char m;
	switch(x){
	case 0:m='0';break;
	case 1:m='1';break;
	case 2:m='2';break;
	case 3:m='3';break;
	case 4:m='4';break;
	case 5:m='5';break;
	case 6:m='6';break;
	case 7:m='7';break;
	case 8:m='8';break;
	case 9:m='9';break;
	case 10:m='A';break;
	case 11:m='B';break;
	case 12:m='C';break;
	case 13:m='D';break;
	case 14:m='E';break;
	case 15:m='F';break;
	case 16:m='G';break;
	case 17:m='H';break;
	case 18:m='I';break;
	case 19:m='J';break;
	case 20:m='K';break;
	case 21:m='L';break;
	case 22:m='M';break;
	case 23:m='N';break;
	case 24:m='O';break;
	case 25:m='P';break;
	case 26:m='Q';break;
	case 27:m='R';break;
	case 28:m='S';break;
	case 29:m='T';break;
	case 30:m='U';break;
	case 31:m='V';break;
	case 32:m='W';break;
	case 33:m='X';break;
	case 34:m='Y';break;
	case 35:m='Z';break;
	
	}
	return m;
}
void main()
{
	int x=0,y=0,k=0,t=0,i,m=0,j;
	char a[100]="",b[100]="";
    int A[100]={0},B[100]={0};
	
	scanf("%d%s%d",&x,a,&y);
	k=strlen(a);
    

	for(i=0;i<k;i++)
	{
        if(a[i]>96)
			a[i]=a[i]-32;
		if(a[i]>64&&a[i]<91)
			A[i]=a[i]-55;
		if(a[i]>47&&a[i]<59)
			A[i]=a[i]-48;
        t=t*x+A[i];
	}
	//printf("@@%d&&  ",t);??debug~
	if(t==0)
		printf("0");//??????????????????????empty output??
	
	for(j=0;;j++)
	{
		if(t/(int)(pow(y,j))==0)
			break;
	}
	
	
	//printf("!!%d!!  ",j);
	for(i=j-1;i>=0;i--)//????~
	{
		B[i]=t%y;
		t=(t-B[i])/y;
	    if(B[i]<10)
			b[i]=B[i]+48;
		if(B[i]>9)
			b[i]=B[i]+55;
	}
	for(i=0;i<j;i++)
		printf("%c",b[i]);
	
}
void main()
{ 
	long int s=0;
	int a,b,n,m,i=0,x[100],y[100];
	char d[100],c[100];
	scanf("%d %s %d",&a,d,&b);
	n=strlen(d);
	for(i=0;i<n;i++)
	{
		if(d[i]>='A'&&d[i]<='Z')
			x[i]=d[i]-55;
		else if(d[i]>='a'&&d[i]<='z')
				x[i]=d[i]-87;
		else if(d[i]>='0'&&d[i]<='9')
				x[i]=d[i]-48;		
	}
	for(i=0;i<n;i++)
		s=s*a+x[i];
	m=0;
	while(s>=b)
	{
		y[m]=s%b;
		s=s/b;
		m++;
	}
	y[m]=s;
	for(i=m;i>=0;i--)
	{
		if(y[i]<9)
			c[i]=y[i]+48;
		else
			c[i]=y[i]+55;
		printf("%c",c[i]);
	}
}
int main()
{
    int a,b,x,m,l,g,i,j,k,y,z;
    char c[40];
    scanf("%d %s %d",&a,c,&b);
    l=strlen(c);
    if (c[0]=='0') printf("0\n");
    else
    {
     for (i=0;i<l;i++)     //×?0?9?0?7ó?0?4?0?3?0?4?0?7 
         if (c[i]>='A'&&c[i]<='Z') c[i]=c[i]-'A'+'a';   
     x=0;
     int d[40];
     for (i=0;i<l;i++)  //×?0?9?0?3?0?4?0?6?0?7?0?8?0?3?0?5?0?3?0?0?0?4x 
     {
        if (c[i]>='a') 
             c[i]=c[i]-'a'+10;  
        else 
             c[i]=c[i]-'0';
        d[i]=1;
        for (j=l-i;j>1;j--) 
             d[i]=d[i]*a;
        x=x+d[i]*c[i];
     }
     char e[40];
     for (k=0;x!=0;k++)    //×?0?9?0?3?0?4?0?6?0?7b?0?5?0?3?0?0?0?4 
     {
        e[k]=x%b;            //?0?5?0?0?0?1?0?6?0?5°?0?8?0?2?0?3?0?8?0?8?0?5?0?7?0?3?0?8?0?5e ·?0?7?0?4ò 
        x=x/b;
     } 
      e[k]='\0'; 
        
      char f[40];          //?0?5?0?0e×?0?9?0?3?0?4?0?6?0?7asc?0?0?0?5 ·?0?7?0?4ò?0?7?0?3?0?6?0?5f 
      for (y=0;y<k;y++)
      {
       if (e[y]<10) 
           f[k-1-y]=e[y]+'0';
       else 
           f[k-1-y]=e[y]-10+'A';
      }
      f[k]='\0';
      printf("%s",f);
   }
}
//*******************************************
//????5.cpp
//????a??????b??
//?????
//*******************************************

int main()
{
	
	int m,i,dec=0;                            //????
	double temp=0,b,a;                 
	char num[32];                             //???????
	int p[32],q[32];                          //????
	cin>>a>>num>>b;                           //????
	m=strlen(num);                            //??num???
	for(i=0;i<m;i++)
	{
		p[i]=num[i];                          //??????????????
		    if(p[i]<58)                       //??????????
		       p[i]=p[i]-48;
		    else if(p[i]<91)
		       p[i]=p[i]-55;
		    else if(p[i]<123)
	 	       p[i]=p[i]-87;
	}
	    for(i=0;i<m;i++)                       //for?????????
	    {
		 dec+=p[i]*pow(a,m-1-i);
		}	 
		if(dec==0)
			cout<<"0";                          //??????0?????
		else
		{	
			for(i=0;i<32;i++)                   //????b???????
			{
			  temp=pow(b,i);
			  if(temp>dec)
			  {
				m=i;
			    break;
			  }
		    }
            
			q[0]=dec/pow(b,m-1);                 //??b???
			for(i=1;i<m;i++)
			{
			   q[i]=(dec-q[i-1]*pow(b,m-i))/pow(b,m-1-i);
			   dec=dec-q[i-1]*pow(b,m-i);
			}
            for(i=0;i<m;i++)	                  //????????????
			{
			   if(q[i]<10)
		       q[i]=q[i]+48;
			   else q[i]=q[i]+55;
			}
			for(i=0;i<m;i++)	
			   num[i]=q[i];                       //?????????

			num[m]='\0';
		    cout<<num;
		}
			return 0;
}
int main()
{
	int a, b, i;
	long int x = 0, y;
	char num1[100], num2[100], c;
	
	scanf("%d%s%d", &a, &num1, &b);
	
	for ( i = 0; i < strlen(num1); i ++ ){
		if ( num1[i] >= 'a' && num1[i] <= 'z' )
			x = x * a + num1[i] - 'a' + 10;
		 if ( num1[i] >= 'A' && num1[i] <= 'Z' )
			 x = x * a + num1[i] - 'A' + 10;
		 if ( num1[i] >= '0' && num1[i] <= '9' )
			 x = x * a + num1[i] - '0';
	}
	if ( x == 0 ){
		printf("0");
		return 0;
	}
	i = 0;
	while ( x > 0 ){
		num2[i++] = x % b;
		x = x / b;
	}
	for ( ; i > 0; i-- ){
		if ( num2[i - 1] >= 0 && num2[i - 1] <= 9 )
			printf("%d", num2[i - 1]);
		if ( num2[i - 1] >9)
			printf("%c", num2[i - 1] - 10 + 'A');
	}
	printf("\n");

	return 0;
}
void main ()
{
	int a,b,i,j,len;
	long k;
	long num;
	char c[70];
	scanf ("%d%s%d",&a,&c,&b);
	len=strlen(c);
	for (i=len-1,num=0,k=1;i>=0;i=i-1,k=k*a)
	{
		if (c[i]>='a'&&c[i]<='z') c[i]=c[i]-'a'+10;
		else if (c[i]>='A'&&c[i]<='Z') c[i]=c[i]-'A'+10;
		else c[i]=c[i]-'0'+0;	
		num=num+c[i]*k;	
	}    /*ok*/

	if (num==0) printf ("0");
	for (i=0,k=b;num!=0;i++,num=num/k)
	{
		c[i]=num%k;
		if (c[i]<=9) c[i]=c[i]+'0';
		else c[i]=c[i]-10+'A';
	}
	for (j=i-1;j>=0;j--) printf("%c",c[j]);
}
int main()
{
      long a,b,i,j,length,result=0;
      char c[100];
      long final[100];
	  long temp;
      scanf("%d %s %d",&a,c,&b);
      int decimal[100];
      length=strlen(c);
	  char finalString[1000];
      for(i=0;i<length;i++)
      {
                 if(c[i]>='A'&&c[i]<='Z')
                 {
                      decimal[i]=c[i]-'A'+10;
                  }
                 else if(c[i]>='a'&&c[i]<='z')
                 {
                      decimal[i]=c[i]-'a'+10;
                  }
                else if(c[i]>='0'&&c[i]<='9')
                 {
                      decimal[i]=c[i]-'0';
                 }
          }
      for(i=0;i<length;i++)
      {
            result=result+decimal[length-i-1]*(int)(pow((double)a,i));      
      }
      if(result==0)
      {
          printf("0");
      }
else
{	
      for(i=0;result!=0;i++)
      {
           final[i]=result%b;
           result=result/b;
       }
	  for(j=0;j<i/2;j++)
	  {
		  temp=final[j];
		  final[j]=final[i-j-1];
		  final[i-j-1]=temp;
	  }
      for(j=0;j<i;j++)
      {
            if(final[j]<10)
            {
                finalString[j]=final[j]+'0';
            }
            else
            {
                finalString[j]=final[j]+'A'-10;
            }
      }
	  finalString[i]='\0';
	  puts(finalString);
	  

     printf("\n");
}   
}
//itc online test nov 15
main() {
       char s[100];
       int a,b;
       scanf("%d %s %d",&a,&s,&b);
       int slen=strlen(s);
       long indec=0;
       long tempdec;
       int i,j;
       for (i=0;i<=slen-1;i++) {
           if (s[i]>=48&&s[i]<=57) {
                                   s[i]=s[i]-48;
           } else if (s[i]>=65&&s[i]<=90) {
                  s[i]=s[i]-55;
           } else {
                  s[i]=s[i]-87;
           }
           tempdec=1; 
           for (j=1;j<=slen-i-1;j++) {
                tempdec=tempdec*a;
           }
           indec=indec+tempdec*s[i];
       }
       char res[100];
       int temp;
       int point=0; 
       while (indec>=b) {
              temp=indec%b;
              indec=indec/b;
              if (temp<10) {
                   res[point]=temp+48;
              } else {
                     res[point]=temp+55;
              }
              point++;
       }
       if (indec<10) {
                    res[point]=indec+48;
       } else {
              res[point]=indec+55;
       }
       for (i=point;i>=0;i--) {
           printf("%c",res[i]);
       }
       scanf("%d",&i);
}
int f(char n)   //???????????????????
{int t;
	if(n>47&&n<58) t=n-48;
	else
	{if(n>64&&n<91) t=n-55;
	else
	{
	if(n>96&&n<123) t=n-87;
	}
	}
	return t;
}

int main()
{
	int a,i,s=0,k,b,g=1;
	char n[32],m[32];//??????????????????
	cin>>a>>n>>b;//??
    for(i=0;i<strlen(n);i++)//????????????s
	{	for(k=0;k<strlen(n)-i-1;k++)
	    g=g*a;
		s=s+f(n[i])*g;
		g=1;
	}
	i=0;//?i???0?????????
	if(s==0) cout<<s;//?s?0???0
	while(s!=0)
	{   k=s%b;//?b???????????????
		if (k>=10) m[i]=k+55;//?????10??????
		else m[i]=k+48;//?????10????????????
        s=s/b;//??s????????????
		i++;//??m[i]
	}
	k=i;
	for(i=k-1;i>=0;i--) 
	{	cout<<m[i];}	//??????????
    return 0;
}
int main()
{
	int i,a,b,n,e[100],f[100],value=0;//?????????????
	char c[100],d[100];//????????????

	cin>>a>>c>>b;
	n=strlen(c);

	for(i=0;i<n;i++)
		if(c[i]>91)c[i]=c[i]-32;//???????????????


	for(i=0;i<n;i++)
	{
		if(c[i]>60)c[i]=c[i]-55;//?????A~Z?????10~35
		else 
			c[i]=c[i]-48;//???0~9?????0~9/*	cout<<f[i];*/	
	}


	for(i=0;i<n;i++) 
		e[i]=(int)(c[i]);//?????c[i]??????????e[i]
	

	for(i=0;i<n;i++)
	    value=value+e[i]*pow((double)a,(double)(n-i-1));//?????????

	if(value==0)cout<<value;

	for(i=0;i<100;i++)
	    if(pow((double)b,(double)i)<value)
		{
			f[i]=(value%((int)pow((double)b,(double)(i+1))))/
				 (int)pow((double)b,(double)i);//?f[i]?????????

		    d[i]=(char)(f[i]);
	
		if(d[i]>9)d[i]=d[i]+55;//???10~35???????A~Z
		else 
			d[i]=d[i]+48;//?0~9???????0~9			
		}


    for(i=99;i>=0;i--)
	    if(pow((double)b,(double)i)<value)
        {
			cout<<d[i];
		}
	
	
	return 0;
}
int main()
{	
        int a,b,i,x=0,len,c[10000],m[10000];
	char n[10000];	cin>>a>>n>>b;
	for (i=0;n[i]!='\0';i++)
	{	if (n[i]>='a' && n[i]<='z' )
			c[i]=n[i]-'a'+10;
		else if(n[i]>='A' && n[i]<='Z')
			c[i]=n[i]-'A'+10;
		else c[i]=n[i]-'0';
		         x=x*a+c[i];
	}
	i=0;
	for (i=0;x>=b;i++)
	{
		m[i]=x%b;
		x=x/b;
	}
	m[i]=x;	len=i;
	for (i=len;i>=0;i--)
	{
		if (m[i]>9) cout<<(char)(m[i]-10+'A');
		else cout<<m[i];
	}
	return 0;
}