semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int a, b, n1[300]={0}, i=0, j=0, k=0, number, n3[300]={0};
	long n2=0;
	char n[300]={0}, n_[300]={0};
	scanf("%d%s%d", &a, n, &b);
//	printf("%d %s %d", a, n, b);
	number=strlen(n);
//	printf("%d", number);
	for(i=0;i<number;i++)
	{
		if(n[i]>=48 && n[i]<=57)
			n1[i]=n[i]-48;
		else if(n[i]>=65 &&n[i]<=90)
			n1[i]=n[i]-55;
		else if(n[i]>=97 && n[i]<=122)
			n1[i]=n[i]-87;
		n2=n2+n1[i]*pow(a, number-i-1);
	}
	if(n2==0)
		printf("0");
	if(b==10)
		printf("%d", n2);
	else
	{
		while(n2>0)
		{
			n3[j]=n2%b;
			n2=n2/b;
			j++;
		}
		for(k=0;k<j;k++)
		{
			if(n3[j-k-1]>=0 && n3[j-k-1]<=9)
				n_[k]=n3[j-k-1]+48;
			else if(n3[j-k-1]>=10 && n3[j-k]<= 35)
				n_[k]=n3[j-k-1]+55;
		}
		printf("%s\n", n_);
	}
	return 0;
}
main()
{
     int a,b,l,i,m,j,s;
     char n[100];
     scanf("%d %s %d",&a,&n,&b);
     l=strlen(n);
     for(i=0;i<=l-1;i++)
       {
        if(n[i]>='A'&&n[i]<='Z')
           n[i]=n[i]-'A'+10;
        else if(n[i]>='a')
           n[i]=n[i]-'a'+10;
        else
           n[i]=n[i]-'0';
       }                                     
     s=0;
     for(i=l-1;i>=0;i--)
       {
        m=n[i];
        for(j=0;j<l-i-1;j++)
          {
           m*=a;
          }
        s+=m;
       }                                         
     i=0;
     int x[100];
     int y[100];
     for(s=s;s>=b;s=s/b)
       {
        x[i]=s%b;
        i++;
       }
     x[i]=s;
     for(j=0;j<=i;j++)
       {
        y[j]=x[i-j];
       }
     for(j=0;j<=i;j++)
       {
        if(y[j]<=9&&y[j]>=0)
          {
            n[j]=y[j]+48;
          }
        else
          n[j]=y[j]+55;
     }
     n[j]='\0';
     puts(n);     
}
/**
* file homwork.cpp
* author ???
* data 2011-11-14
* description ????
*/ 

int length , i ;
char n[1000];         //??????
unsigned turn(int n1 , char a[]);
void f(int n2 , unsigned s , int j);

int main()
{
	int a , b ;
	unsigned number;
	char str[1000] ; 
	while(cin >> a)
	{
		cin >> str >> b ; 
		length = strlen (str) ;
		number = turn( a , str ) ;
		f(b , number , 0) ;
		memset(str , 0 ,sizeof(str));  //???0?
	}

	return 0;
}

unsigned turn(int n1 , char a[])    //???????10???
{
    int sum = 0;
	for( i = 0 ; i <= length - 1 ; i++)
	{
		if(a[i] >= '0' && a[i] <= '9')
			sum = sum * n1 +  (a[i] - '0');
		
		else if(a[i] >= 'A' && a[i] <= 'Z')
			sum = sum * n1 + (a[i] - 'A' + 10);
		
		else if(a[i] >= 'a' && a[i] <= 'z')
			sum = sum * n1 + (a[i] - 'a' + 10);
	}
	return sum;
}

void f(int n2 , unsigned s , int j)    //?????????????
{
	int  k;
	if(s == 0)
	{
		if(j == 0)
			cout << 0;
		for(i = j - 1 ; i >= 0 ; i --)
			printf("%c",n[i]);
	}
	else 
	{
		k  = s  %  n2 ;
		s = s / n2 ;
		
		if(k  <=  9 && k >= 0)
			n[j] = k  + '0' ;
		else
			n[j] = (k - 10) + 'A';
		
        f(n2 , s , j + 1);                    //?????
	}                    
	
	return;
}
int main()
{
	double a, b;
	int s = 0, i, l, j;
	int c[100];
	char n[100];
	cin >> a >> n >> b;
	l = strlen(n);
	for (i = l - 1; i >= 0; i --)
	{
		if (n[i] >= 48 && n[i] <= 57)
		{
			s = s + (n[i] - '0') * pow(a,(double)(l - i - 1));
		}
		if (n[i] >= 65 && n[i] <= 90)
		{
			s = s + (n[i] - 55) * pow(a,(double)(l - i - 1));
		}
		if (n[i] >= 97 && n[i] <= 122)
		{
			s = s + (n[i] - 87) * pow(a,(double)(l - i - 1));
		}
	}
	if (s == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	if (b <= 10)
	{
		for (i = 0; ;i ++)
		{
			c[i] = s % (int)b;
			s = s / (int)b;
			if (s < b)
			{
				c[i + 1] = s;
				break;
			}
		}
		for (j = i + 1; j >= 0; j --)
		{
			cout << c[j];
		}
	}
	else
	{
		memset(n, 0, sizeof(n));
		for (i = 0; ;i ++)
		{
			if ((s % (int)b) > 9)
			{
				n[i] = (char)(s % (int)b + 55);
			}
			else
			{
				n[i] = (char)(s % (int)b + '0');
			}
			s = s / (int)b;
			if (s < b)
			{
				if (s > 9)
				{
					n[++ i] = (char)(s + 55);
				}
				else
				{
					n[++ i] = (char)(s + '0');
				}
				break;
			}

		}
		for (j = i; j >= 0; j --)
		{
			cout << n[j];
		}
	}
	cout << endl;
	return 0;
}
void main()
{
	int a,b,l,i,m,t,j;
	long sum=0;
	char n[40],y[40],z[40];
	scanf("%d %s %d",&a,n,&b);
	l=strlen(n);
	m=1;
	for(i=1;i<=l;i++)
	{
		t=n[l-i];
		if(t<60)
			sum=sum+(n[l-i]-48)*m;
		else if(t<91)
			sum+=(n[l-i]-55)*m;
		else
			sum+=(n[l-i]-87)*m;
		m=m*a;
	}
	//printf("%d",sum);
	i=0;
	if(sum!=0)
	{while(sum!=0)
	{
		i++;
		t=sum%b;
		if(t<=9)
			y[29-i]=t+48;
		else
			y[29-i]=t+55;
		sum=sum/b;
	}
	for(j=0;j<=i-1;j++)
	{
		z[j]=y[29-i+j];
	}
	z[i]='\0';
	printf("%s",z);}
	else
		printf("0");
}
int main()
{
	char n[100];
	int a,b;
	cin>>a>>n>>b;
	int num=0;
	int i;
	int len=strlen(n);//???????
	for(i=0;i<len;i++)//??????10??
	{
		if(n[i]<='9' && n[i]>='0')
		{
			n[i]=n[i]-48;
		}
		if(n[i]<='z' && n[i]>='a')
		{
			n[i]=n[i]-87;
		}
		if(n[i]<='Z' && n[i]>='A')
		{
			n[i]=n[i]-55;
		}
		num=num+n[i]*((double)pow((double)a,(double)(len-1-i)));
	}
	if(num==0)
	{
		cout<<0;
	}
	else//???b??????????
	{
		int latter[100];
		i=0;
		do
		{latter[i]=num%b;
		 num=num/b;
		 i++;
		}while(num/b!=0);
		latter[i]=num%b;
		latter[i+1]='\0';
		char n2[100];
		int j;
		for(j=0;i>=0;i--,j++)
		{
			if(latter[i]>=0 && latter[i]<=9)
			{
				n2[j]=latter[i]+48;
			}
			if(latter[i]>=10 && latter[i]<=36)
			{
				n2[j]=latter[i]+55;
			}
			cout<<n2[j];
		}
	}
	cout<<endl;
	return 0;
}
int main()
{
	char s3[100],s1[100],s2[100],s[100];
	long q=0,a,b;
	int i,p=0,m,t;
	scanf ("%ld %s %ld",&a,s3,&b);
	t=strlen (s3);
	for (i=t-1;i>=0;i--)
	{
		s[t-1-i]=s3[i];
		s[t-i]='\0';
	}
	for (i=0;s[i]!='\0';i++)
	{
        if (s[i]>='a'&&s[i]<='z')
        {
            q=q+(s[i]-'a'+10)*pow(a,i);
        }
        else if (s[i]>='A'&&s[i]<='Z')
        {
            q=q+(s[i]-'A'+10)*pow(a,i);
        }
        else if (s[i]>='0'&&s[i]<='9')
		{
            q=q+(s[i]-'0')*pow(a,i);
		}
     }
        if (q==0)
        {
            printf ("0");
        }
        else if (q!=0)
         {
           for (i=0;q!=0;i++)
         {
             p=q%b;
			 if (p>=10)
			 {
				s1[i]=p+55;
			 }
			 else 
			 {
				s1[i] =p+48;
			 }
             s1[i+1]='\0';
             q=q/b;
		  }
		   m=strlen(s1);
		   for (i=m-1;i>=0;i--)
		   {
              s2[m-1-i]=s1[i];
			  s2[m-i]='\0';
		   }
            printf ("%s",s2);
           }
               
               return 0;
}
main()
{
      int a,b,i,j,h,s,g,p,q,l;
      char n[100];
      int m[100];
      char z[100];
      scanf("%d %s %d",&a,n,&b);
      l=strlen(n) ;
      h=0;
  for(i=1,g=1,s=0;i<=l;i++)
  {  if(n[l-i]>='a'&&n[l-i]<='z')
     h=n[l-i]-'a'+10;
     else 
     {if(n[l-i]>='A'&&n[l-i]<='Z')
     h=n[l-i]-'A'+10;
     else
     h=n[l-i]-'0';}
     s=s+h*g;
     g=g*a;     }
if(s==0) printf("0");
else
{
  for(j=0;s>0;j++)
  {  m[j]=s%b;
     s=s/b;  
     q=j;}
  for(p=0;p<=q;p++)
  {  if (m[p]>=0&&m[p]<=9)
      z[q-p]=m[p]+'0';
      else 
       z[q-p]=m[p]+'A'-10;          } 
    z[q+1]='\0';
     printf("%s",z);
     }

}
main ()
{

  int a2i[128],from,to,len=0,i;
    char  i2a[] ="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ,in[255],out[255]="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]);
    
      

}
int main(int argc, char* argv[])
{
	char a[100],f[100],p;
	int n,m,i,k=-1,sum=1,s=0,b[100],j,msum=0;
	scanf("%d %s %d",&n,a,&m);
	for(i=0;a[i]!='\0';i++){
		k++;
	}
	for(i=0;i<=k;i++){
		if(a[i]>96&&a[i]<123){
			a[i]=a[i]-32;
		}
	}
	for(i=0;i<=k;i++){
		if(a[i]>47&&a[i]<58){
			sum=sum*(a[i]-48);
		   for(j=i;j<k;j++){
			   sum=sum*n;
		   }
		}
		else if(a[i]>64&&a[i]<91){
			sum=sum*(a[i]-55);
			for(j=i;j<k;j++){
				sum=sum*n;
			}
		}
		msum=msum+sum;
		sum=1;
	}
	for(i=0;msum>=m;i++){
		b[i]=msum%m;
		if(b[i]>=0&&b[i]<10){
			f[i]=b[i]+48;
		}
		else if(b[i]>=10&&b[i]<=36){
			f[i]=b[i]+55;
		}
		msum=msum/m;
		s++;
	}
	if(msum>=0&&msum<10){
			p=msum+48;
	}
	else if(msum>=10&&msum<36){
		p=msum+55;
	}
	printf("%c",p);
	for(i=s-1;i>=0;i--){
	    printf("%c",f[i]);
	}
	return 0;
}
int main()
{
	int a,i,len,N=0,b,o[100];
	char n[100],p[100];
	cin>>a>>n>>b;
	if(a<2||b>=36)
	{
		cout<<"...";
		return 0;
	}
	len=strlen(n);
	for(i=0;i<len;i++) 
	{
		if(n[i]>='0'&&n[i]<='9') 
		{
			if(n[i]<a+'0')
			{
				N=N*a+n[i]-'0';
			}
			else
			{
				cout<<"...";
				return 0;
			}
		}
		else
		{
			if(n[i]>='a'&&n[i]<='z') 
			{
				if(n[i]<a+'a'-10)
				{
					N=N*a+n[i]-'a'+10;
				}
				else
				{
					cout<<"...";
					return 0;
				}
			}
			else
			{
				if(n[i]<a+'A'-10) 
				{
					N=N*a+n[i]-'A'+10;
				}
				else
				{
					cout<<"...";
					return 0;
				}
			}
		
		}
	}
	i=0; 
	if(N==0)
	{
		cout<<"0";
		return 0;
	}
	while(N>0)
	{
		o[i]=N%b;
		if(o[i]>=10)
		{
			p[i]='A'+o[i]-10;
		}
		else
		{
			p[i]=o[i]+'0';
		}
		i++;
		N=N/b; 
	}
	i--;
	for(;i>=0;i--)
	{
		cout<<p[i];
	}
	cout<<endl;
	return 0;
}
void main()
{
	int a1,b1,temp=0,numtemp[10];
	char num1[10],num2[10],c;
	int i=0,j=0,k=0,n;
	scanf("%d %s %d",&a1,num1,&b1);
	while(num1[i]!='\0')
	{
		if(num1[i]>=97&&num1[i]<=122)
			num1[i]-=32;
		if(num1[i]>=65&&num1[i]<=90)
			numtemp[i]=num1[i]-55;
		else
			numtemp[i]=num1[i]-48;
		i+=1;
	}
	i-=1;
	for(j=0;j<=i;j++)
		temp+=numtemp[j]*power(a1,i-j);
	i=0;
	j=0;
	while(power(b1,i)<temp)
		i++;
	j=i-1;
	for(k=0;k<i;k++)
	{
		n=temp/power(b1,j);
		if(n>=10)
			c=(char)(n+55);
		else
			c=(char)(n+48);
		temp-=power(b1,j)*n;
		j--;
		num2[k]=c;
		n=0;
	}
	num2[k]='\0';
	if(k!=0)
	    printf("%s\n",num2);
	else
		printf("0\n");
}
long pow(int a,int b)
{
	long c;
	if(b==0)
		c=1;
	if(b>0)
		c=pow(a,b-1)*a;
	return c;
}

int main()
{
	int a,b,i,j;
	char form[1000],late[1000];
	long ten=0;
	cin>>a;
	cin>>form;
	cin>>b;
	for(i=0;i<strlen(form);i++)
		if(form[i]>=97&&form[i]<=122)
			form[i]-=32;
	for(i=strlen(form)-1,j=0;i>=0;i--,j++)
	{
		if(form[i]>=48&&form[i]<=57)
		{
			form[i]-=48;
			ten+=form[i]*pow(a,j);
		}
		if(form[i]>=65&&form[i]<=90)
		{
			form[i]-=55;
			ten+=form[i]*pow(a,j);
		}
	}
	if(ten==0)
	{
		cout<<ten<<endl;
		return 0;
	}
	for(i=0;i<=1000;i++)
	{
		if(ten%b<10)
			late[i]=ten%b+48;
		if(ten%b>=10)
			late[i]=ten%b+55;
		if(ten/b==0&&ten%b==0)
			late[i]='\0';
		ten=ten/b;
	}
	for(i=strlen(late)-1;i>=0;i--)
	{
		if(i!=0)
			cout<<late[i];
		else cout<<late[i]<<endl;
	}
	return 0;
}
int main()
{
long num=0,reminder;
int a,b,i,j;
char figure1[100],figure2[100];
cin>>a;
getchar();
for(i=0;;i++)
{
	figure1[i]=getchar();
	if(figure1[i]>='a'&&figure1[i]<='z')
		figure1[i]=figure1[i]-87;
	else if(figure1[i]>='A'&&figure1[i]<='Z')
		figure1[i]=figure1[i]-55;
	else if(figure1[i]>=42&&figure1[i]<=57)
		figure1[i]=figure1[i]-'0';
	else
		break;
	num=num*a+figure1[i];
}
reminder=num;
cin>>b;
for(j=0;;j++)
{
	if(reminder%b>=10)
		figure2[j]=reminder%b+55;
	else 
		figure2[j]=reminder%b+'0';
	reminder=reminder/b;
	if(reminder==0)
		break;	
}
for(;j>=0;j--)
	cout<<figure2[j];
cout<<endl;
return 0;
}
void main()
{   
	int a,b,k,i,m,j,n,o;
	long ten=0;
	char x[32]="\0"; char y[32]="\0";
    scanf("%d %s %d",&a,x,&b);
	k=strlen(x);
	for(i=0;i<k;i++)
	{   
		ten=a*ten;
		if(x[i]<60)
		ten=ten+(x[i]-48);
		else if(x[i]<95) ten=ten+(x[i]-55);
		else ten+=(x[i]-87);
	}
	j=0;
	do{
		m=ten%b;
		ten=(ten-m)/b;
		if(m<10) y[j]=m+48;
		else y[j]=m+55;
		j++;
	}
	while(ten!=0);
        n=strlen(y);
	for(o=n-1;o>=0;o--)
	{
		printf("%c",y[o]);
	}
}
//????
int ji(int a,int b);
int main()
{
	int jinzhi1=0; //????1
	int jinzhi2=0;  //????2
	int p=0; //????
	int i=0; //???
	int j=0; //?????
	char n[100];   //?????????
	char m[100];  //?????????
	long s=0;   //?????????
	cin>>jinzhi1>>n>>jinzhi2;
	p=strlen(n);
	//???????????
	while(i<p)
	{
		(int) n[i];
		if(n[i]>96)     //??????????,???s?????
		{
            s=s+(n[i]-87)*ji(jinzhi1,(p-i-1));
		}
		else
		{
			if(n[i]>64)
			{
				s=s+(n[i]-55)*ji(jinzhi1,(p-i-1));
			}
			else
			{
				s=s+(n[i]-'0')*ji(jinzhi1,(p-i-1));
			}
		}
		i=i+1;
	}


	i=0;//?????
	if(s==0)
	{
        cout<<0<<endl;
    }
    else
    {
    while(s!=0) //????
	{
        m[i]=s%jinzhi2;
		s=(s-m[i])/jinzhi2;
		i+=1;
	}
	for(j=0;j<i;j++)  //?????????????
	{
		if(m[i-1-j]>9)
		{
			m[i-1-j]=m[i-1-j]+55;
			cout<<m[i-1-j];
		}
		else
		{
			m[i-1-j]=m[i-1-j]+48;
			cout<<m[i-1-j];
		}
    }
    }
	return 0;
}

int ji(int a,int b) //???????? 
{
	int i=0;
	int ji=1;
	for(i=0;i<b;i++)
	{
		ji=ji*a;
	}
	return ji;
}
//????

int main()

{
	int n,m;
	int i,j,k,l;
	char a[33];
	int b[33];
	long int mid;
	int ar;
	
	cin>>n;
	
	for(i=0;i<33;i++)
	{
		a[i]=48;
		b[i]=-1;
	}
	
	cin>>a;
	i=0;
	
	while(a[i]!='\0')
		i++;
	a[i]=48;
	k=33-i;
	for(l=0;l<i;l++)
	{
		a[k]=a[l];
		a[l]=48;
		k++;
	}
	
	//????????
	//??????????????
	
	for(k=0;k<33;k++)
	{
		if((a[k]>='0')&&(a[k]<='9'))
			a[k]-='0';
		else if((a[k]>='a')&&(a[k]<='z'))
			a[k]=a[k]-87;
		else 
			a[k]=a[k]-55;
	}
	
	//???????ing
	
	mid=0;
	ar=1;
	for(j=32;j>=33-i;j--)
	{
		mid+=a[j]*ar;
		ar*=n;
	}
	
	//?????????
	
	cin>>m;
	k=0;
	while(mid!=0)
	{
		b[k]=mid%m;
		mid=mid/m;
		k++;
	}
	for(i=32;i>=0;i--)
		if(b[i]!=-1)
		{
			if(b[i]>=10)
			{
				char m=b[i]+55;
				cout<<m;
			}
			else
				cout<<b[i];
		}
		cout<<'\n';
        return 0;
}
int main()
{ 
	int i,l,a,b,c[100],d,A=0;
	char s[100];
	scanf("%d %s %d",&a,s,&b);
	l=strlen(s);
	for(i=0;i<l;i++)
	{
		if(s[l-i-1]>='0'&&s[l-i-1]<='9')
			c[i]=s[l-i-1]-'0';
		if(s[l-i-1]>='a'&&s[l-i-1]<='z')
			c[i]=s[l-i-1]-'a'+10;
		if(s[l-i-1]>='A'&&s[l-i-1]<='Z')
			c[i]=s[l-i-1]-'A'+10;
		A=(double)A+(double)c[i]*pow((double)a,(double)i);
	}
	for(i=0;;i++)
	{
		d=A%b;
		if(d<=9)
			s[i]=d+'0';
		else
			s[i]=d-10+'A';
		A=A/b;
		if(A==0)
			break;
	}
	for(;i>=0;i--)
	{
		printf("%c",s[i]);
	}
	return 0;
}
int main()
{
 int i,j,n,num,sum=0,x,k,o,t,a,b;
 char *p;
  sum=0;
  p=(char*)malloc(sizeof(char)*20);
  scanf("%d %s %d",&a,p,&b);
   for(j=0;j<strlen(p);j++)
   if(*(p+j)<='z'&&*(p+j)>='a')
   *(p+j)-=32;
  
  for(j=0;j<strlen(p);j++)
  {
   if(*(p+j)<='9'&&*(p+j)>='0')
    {num=(int)*(p+j)-48;
     t=strlen(p)-j;
     while(t>1) num*=a,t--;}
   else
    {num=(int)*(p+j)-65+10;
     t=strlen(p)-j;
     while(t>1) num*=a,t--;}
   sum+=num;
  }
  
  
  
  x=sum; k=0;
  while(x/b!=0) k++,x=x/b;
  char *q;
  q=(char*)malloc(sizeof(char)*k);
  x=sum;
  *(q+k+1)='\0';
  while(k>=0)
  {o=x%b;
   if(o<=9&&o>=0)
   {*(q+k)=(char)(o+48);
    x=x/b;
    k--;}
   else
   {*(q+k)=(char)(o+55);
    x=x/b;
    k--;}
  }
  printf("%s\n",q);
 }
int main()
{
	int a,b,num10=0;
	char pre[200];
	cin>>a;
	cin>>pre;
	
	cin>>b;
	
	for(int i=0;i<=strlen(pre);i++)
	{
		int temp=1;
		for(int j=1;j<strlen(pre)-i;j++)
		
			temp*=a;
		if(pre[i]>='0'&&pre[i]<='9')
			num10+=(int)(pre[i]-'0')*temp;
		if(pre[i]>='a'&&pre[i]<='z')
			num10+=(int)(pre[i]-'a'+10)*temp;
		if(pre[i]>='A'&&pre[i]<='Z')
			num10+=(int)(pre[i]-'A'+10)*temp;
		}
	
	char aft[120];
	int k=0;
	do
	{
		if(num10%b<=9)
		{
			aft[k]=num10%b+'0';
		}
		else aft[k]=num10%b+'A'-10;
		num10/=b;
		k++;
	}
	while(num10!=0);
	while(k>=1)
	{
		cout<<(char)aft[k-1];
		k--;
	}

	return 0;
}
//????a?
int nta(long a)
{
	if(a>=10)
	{
	char b;
	b=(char)('A'-10+a);
	return ((char) (b));
	}
	else
	{
	char b;
	b=(char)('1'-1+a);
	return ((char) (b));
	}
}
//a????
int atn(char i)
{
	long j=i;
	if(j>96)
	{
		j=j-'a'+10;
	}
	else
	{   if ((j>33)&&(j<58))
	{
		j=j-'1'+1;
	}
	else
	{
		j=j-'A'+10;
	}
	}
	return((long)(j));
}
//???????
int ten(long k)
{
	long l,m;
	l=k;
	for (int n = 0; n < 69; n++)
	{
		l=l/10;
		if (l>0)
		{
			m=n+1;
		}
	}
	return (m);
}
//??e??
int loe(long t,long v)
{
	long u,w=0;
	u=t;
	for (int x = 0; x < 69; x++)
	{
		u=u/v;
		if (u>0)
		{
			w=x+1;
		}
	}
	return (w);
}
//??????
int lth(char o[])
{
	long f=0;
	for (int g = 0; g <69 ; g++)
	{
		if((o[g]!=0)&&(o[g]!=32))f=f+1;
	}
	return ((f));
}
int main()
{
	long d,e;
	char h[70];
	memset(h,0,sizeof(h));
	cin>>d>>h>>e;
	long p;
	p=lth(h);
	long s=0;
	for (int q = 0; q < p; q++)
	{
		s=s*d+(atn(h[q]));
	}
	long y;
	y=(loe(s,e));
	char aa[70];
	memset(aa,0,sizeof(aa));
	long ab=s,ac=0;
	for (int z = 0; z < y+1; z++)
	{
		ac=ab;
		ab=ab/e;
		if (ab>0)
		{
			aa[z]=nta(ac%e);
		}
		else
		{
			aa[z]=nta(ac);
		}

	}
	if(aa[y]!=0)
	{
	for (int ad = 0; ad < y+1; ad++)
	{
		cout<<aa[y-ad];
	}
	}
	else cout<<"0";
	return 0;
}
int main() {
	int a, b, ten = 0;
	char str[100], str2[100];
	cin >> a >> str >> b;
	int len = strlen( str );
	for ( int i = 0; str[i] != '\0'; i ++ ) {
		if ( str[i] >= '0' && str[i] <= '9' ) ten += ( str[i] - '0' ) * pow ( ( double ) a, ( double ) ( len - 1 - i ) ) ;
		else if ( str[i] <= 'z' && str[i] >= 'a' ) ten += ( str[i] - 'a' + 10 ) * pow ( ( double ) a, ( double ) ( len - 1 - i ) );
		else ten += ( str[i] - 'A' + 10 ) * pow ( ( double ) a, ( double ) ( len - 1 - i ) );
	}
	int j = 0;
	if ( ten == 0 ) cout << 0;
	else {
		while ( ten != 0 ) {
			if ( ten % b <= 9 ) str2[j ++] = ( char )( ten % b + '0' );
			else str2[j ++] = ( char )( ten % b - 10 + 'A' );
			ten /= b;
		}
		j --;
		for ( int i = j; i >= 0; i -- ) {
			cout << str2[i];
		}
	}
	return 0;
}
void main()
{
	int a,b,i,j,t,k;
	char m[32],n[32];
	long middle,mult;
	middle=0;
	scanf("%d",&a);
	scanf("%s",m);
	scanf("%d",&b);
	i=strlen(m);
	for(j=0;j<=i-1;j++)
	{
		if(m[j]>='0'&&m[j]<='9')m[j]=m[j]-'0';
		if(m[j]>='a'&&m[j]<='z')m[j]=m[j]-'a'+10;
		if(m[j]>='A'&&m[j]<='Z')m[j]=m[j]-'A'+10;
	}
	for(j=0;j<=i-1;j++)
	{
		mult=1;
		for(t=i-1-j;t>=1;t--)
		{
			mult=mult*a;
		}
		middle=middle+m[j]*mult;
	}
if(middle==0)printf("0");
if(middle>0)
{	j=0;
	while(middle>0)
	{
		n[j]=middle%b;
		middle=middle/b;
		j++;
	}
	for(k=0;k<=j-1;k++)
	{
		if(n[k]<=9&&n[k]>=0)n[k]=n[k]+'0';
		else if(n[k]>=10)n[k]='A'-10+n[k];
	}
	for(k=j-1;k>=0;k--)
	{
		printf("%c",n[k]);
	}
}
}
int main()
{
    char str[100000];
    long int k,t,n,m,a,i,j;
    scanf("%d%s%d",&k,str,&t);
    n=strlen(str);
    for(i=0;i<n;i++)
    {
        if(str[i]>96)
        str[i]=str[i]-32;
    }
    m=0;
    for(i=0;i<n;i++)
    {
        a=1;
        for(j=1;j<n-i;j++)
        {
            a=a*k;
        }
        if(str[i]>=65)
        m=m+(str[i]-55)*a;
        else
        m=m+(str[i]-48)*a;
    }
    if(m==0)
    printf("0");
    else
    {i=0;
    while(m>0)
    {
        j=m%t;
        if(j<10)
        str[i]=j+48;
        else str[i]=j+55;
        i=i+1;
        m=(m-j)/t;
    }
    for(j=i-1;j>=0;j--)
    printf("%c",str[j]);}
    return 0;
}
void main()
{
	long a,b,k,h,n,i,m;
	char s[100],t[100];
	scanf("%d%s%d",&a,&s,&b);
	n=strlen(s);
	for(k=0,i=0;i<n;i++)
	{
		if(s[i]<='Z'&&s[i]>='A')
			s[i]=s[i]-55;
		else if(s[i]<='z'&&s[i]>='a')
			s[i]=s[i]-87;
		else 
			s[i]=s[i]-48;
		for(h=1,m=(int)s[i];h<=n-i-1;h++)
			m=m*a;
		k=k+m;
	}

	h=0;
	if(k!=0)
	{
		while (k!=0)
	{
		t[h]=k%b;
		h++;
		k=k/b;
	}
	for(i=h-1;i>=0;i--)
	{
		if(t[i]<10)
			t[i]=t[i]+48;
		else
			t[i]=t[i]+55;
		printf("%c",t[i]);	
	}
	
	}
	else 
		printf("0");
	printf("\n");

}
int convert1(char a)
{
	if ((a >= '0') && (a <= '9'))
		return a - '0';
	if ((a >= 'a') && (a <= 'z'))
		return (a - 'a' + 10);
	if ((a >= 'A') && (a <= 'Z'))
		return (a - 'A' + 10);
}
char convert2(int a)
{
	if ((a >= 0) && (a <= 9))
		return (a + 48);
	else
		return (a + 55);
}
int main()
{
	int a , b , len , k = 1 , i , j;
	long t = 0;
	char num[100] , p;
	int num1[100];
	cin >> a >> num >> b;
	len = strlen(num);
	for (i = len - 1 ; i >= 0 ; i--)
	{
		t = t + k * convert1(num[i]);
		k = k * a;
	}
	i = 1;
	while(t >= b)
	{
		num1[i] = t % b;
		i++;
		t = t / b;
	}
	num1[i] = t;
	for (j = i ; j >= 1; j--)
	{
		p = convert2(num1[j]);
		cout << p;
	}
	return 0;
}
int main()
{
    char s[33];
    int i, a, b, n;
    long x = 0, y = 1;
    scanf("%d %s %d", &a, s, &b);
    for (i = strlen(s)-1; i >= 0; i--)
    {
        if (s[i] >= 'a')
           x += (s[i] - 'a' + 10) * y;
        else if (s[i] >= 'A')
           x += (s[i] - 'A' + 10) * y;
        else 
           x += (s[i] - '0') * y;
        y *= a;
    }
    y = 1;
    while (x / y >= b)
       y *= b;
    do
    {   
        n = x / y;
        x = x % y;
        if (n >= 10)
            printf("%c", 'A' + (n - 10));
        else
            printf("%d", n);
        y = y / b;
    }
    while (y >= 1);
    return 0;
}
int main()
{
	int a,b;
	char s[100];
	long num=0;;
	for(int i=0;i<100;i++)
		s[i]='\0';
	scanf("%d",&a);
	scanf("%s",&s);
	scanf("%d",&b);
	for(int j=0;j<100;j++)
	{
		if(s[j]>='0'&&s[j]<='9')
			num=num*a+s[j]-'0';
		if(s[j]>='a'&&s[j]<='z')
			num=num*a+s[j]-'a'+10;
		if(s[j]>='A'&&s[j]<='Z')
			num=num*a+s[j]-'A'+10;
	}
	for(int p=0;p<100;p++)
		s[p]='\0';
	int m,n=num;
	for(int t=0;;t++)
	{
		m=n%b;
		n=n/b;
		if(m>=10)
			s[t]=m-10+'A';
		else
			s[t]=m+'0';
		if(n==0)
			break;
	}
	for(int q=99;q>=0;q--)
	{
		if(s[q]!='\0')
			printf("%c",s[q]);
	}
	return 0;
}
int main()
{
      long k=0,a,b,i,h=0,c;
      unsigned int e[100];
      char n[100];
      scanf("%d %s %d",&a,n,&b);
      c = strlen(n);
      for(i=0;i<=c-1;i++)
      {
            if(n[i]>='0'&& n[i]<='9')
            n[i]=n[i]-('0'-0);
            if(n[i]<='Z' && n[i]>='A')
            n[i]=n[i]-('A'-10);
            if(n[i]>='a' && n[i]<='z')
            n[i]=n[i]-'a'+10;
            h=a*h+n[i];      
      }
      if(h==0)
      printf("0");
      for(i=0;h>0;i++)
      {
            e[i]=h%b;
            h=h-e[i];
            h=h/b;
            k=k+1;
      }
      for(i=0;i<=k-1;i++)
      {
            n[i]=e[k-1-i];
            if (n[i]>9)
            n[i]=n[i]+'A'-10;
            else
            n[i]=n[i]+'0';
      }
      n[k]='\0';
      printf("%s\n",n);
      getchar();
      getchar();
      getchar();
      getchar();
return 0;
}
int main()
{
   char x[200],y[200];
   int a,b,i,j,num[200];
   long int n=0;
   cin>>a;
  cin>>x;
   cin>>b;
   int nlen1=strlen(x);
 
   for(i=0;i<=nlen1-1;i++)
   {
       if(x[i]>='0'&&x[i]<='9')
		   num[i]=x[i]-'0';
	   else if(x[i]>='a'&&x[i]<='z')
		   num[i]=x[i]-'a'+10;
	   else if(x[i]>='A'&&x[i]<='Z')
		   num[i]=x[i]-'A'+10;
	   n=n*a+num[i];	}
   for(i=0;;i++)
   {
       num[i]=n%b;
	   n=n/b;
     if(n==0)
     break;
   }
      for(j=i;j>=0;j--)
   {
      if(num[j]>=0&&num[j]<=9)
		  cout<<num[j];
	  else
	  {y[j]=num[j]-10+'A';
	  cout<<y[j];}
   }
   


return 0;
	  
	   
}
main()
{
      long a,b,l,k,i,j,ten,goal,t;
      char s[1000];
      char s3;
      long s2[1000];
      
      scanf("%d %s %d",&a,s,&b);
      ten=0; goal=0;
      l=strlen(s);
      l--;k=1;
      for (i=l;i>=0;i--)
      {
          if (s[i]>='0' && s[i]<='9')
          {
               ten+=(s[i]-'0')*k;                        
          }
          else if (s[i]>='a' && s[i]<='z')
          {
               ten+=(s[i]-'a'+10)*k;  
          }
          else if (s[i]>='A' && s[i]<='Z')
          {
               ten+=(s[i]-'A'+10)*k;          
          }
            
          k*=a;
      }
      t=0;
      if (ten==0) 
          printf("%d",ten);
      while (ten>0)
      {
            
            k=ten%b;
            s2[t]=k;
            ten=ten/b;
            t++;  
      }
      t--;
      for (i=t;i>=0;i--)
      {
          if (s2[i]<10)
              printf("%d",s2[i]);
          else
          {
              s3=s2[i]-10+'A';
              printf("%c",s3);
          }          
      }
     
      getchar();
      getchar();
      getchar();
}
int main()
{   char str1[1000];
    char str2[1000]="0";
    int a1;
    long num=0;
    int b1;

    int num1[1000]={0};
    char char1[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int i;
    for(i='0';i<='9';i++)
    {
        num1[i]=i-'0';

    }
    for(i='A';i<='Z';i++)
    {
        num1[i]=i-'A'+10;
    }
    for(i='a';i<='z';i++)
    {
        num1[i]=i-'a'+10;
    }


    scanf("%d%s%d",&a1,str1,&b1);

    for(i=0;str1[i]!='\0';i++)
    {
        num=num*a1+num1[str1[i]];

    }


    int l2=0;
    l2=(num==0)?1:0;
    while(num>0)
    {
        str2[l2]=char1[num%b1];
        num=num/b1;
        l2=l2+1;
    }
    for(i=l2-1;i>=0;i--)
    {
        cout<<str2[i];
    }

    return 0;
}