semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	char p[100],z[100],a;         //??????????
	long sum=0;                   //??????
	int  x,m,n,t,b;
	int i,k,c;
	scanf("%d",&m);
	scanf("%s",p);
	scanf("%d",&t);//????
    n=strlen(p);//p???
	for(i=0;p[i]!='\0';i++)
	{
	  a=p[i];
	  if(a>='a'){b=a-'a'+10;}
	  else if(a>='A'){b=a-'A'+10;}
	  else if(a<='9'){b=a-'0';}
	  sum=sum+(long)(b*pow(m,n-1));
      n--;
	}//?p????????
	long r=sum;
	if(sum==0){printf("0");}
	int w=0;
	for(c=0;r>0;c++){ x=r%t;r=r/t;w++;}//?????
	for(k=w-1;k>=0;k--)
	{
	  x=sum%t;
	  sum=sum/t;
	  if(x<=10)
	  {
	     switch(x)
		 {
	     case 0:z[k]='0';break;
	     case 1:z[k]='1';break;
	     case 2:z[k]='2';break;
         case 3:z[k]='3';break;
	     case 4:z[k]='4';break;
	     case 5:z[k]='5';break;
	     case 6:z[k]='6';break;
	     case 7:z[k]='7';break;
	     case 8:z[k]='8';break;
	     case 9:z[k]='9';break;
		 case 10:z[k]='A';break;
		 }
	  }
	  else if(x>=11&&x<=20)
	  {
		  switch(x)
		  {
	      case 11:z[k]='B';break;
	      case 12:z[k]='C';break;
	      case 13:z[k]='D';break;
	      case 14:z[k]='E';break;
	      case 15:z[k]='F';break;
	      case 16:z[k]='G';break;
	      case 17:z[k]='H';break;
	      case 18:z[k]='I';break;
	      case 19:z[k]='J';break;
	      case 20:z[k]='K';break;
		  }
	  }
	  else if(x>=21&&x<=30){
		  switch(x){
	      case 21:z[k]='L';break;
	      case 22:z[k]='M';break;
	      case 23:z[k]='N';break;
	      case 24:z[k]='O';break;
          case 25:z[k]='P';break;
	      case 26:z[k]='Q';break;
	      case 27:z[k]='R';break;
	      case 28:z[k]='S';break;
	      case 29:z[k]='T';break;
	      case 30:z[k]='U';break;
		  }
	  }
	  else{
		  switch(x){
	      case 31:z[k]='V';break;
	      case 32:z[k]='W';break;
	      case 33:z[k]='X';break;
	      case 34:z[k]='Y';break;
	      case 35:z[k]='Z';break;
		  }
	  }//??????????????
	}
	  z[w]='\0';//??
	  printf("%s",z);//????????
	return 0;
}
int main()
{
	int zheng[255];
	char fan[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int from,to;
	char in[255];
	scanf("%d%s%d",&from,in,&to);
	int i;
	for(i='0';i<='9';i++)
		zheng[i]=i-'0';
	for(i='A';i<='Z';i++)
		zheng[i]=i-'A'+10;
	for(i='a';i<='z';i++)
		zheng[i]=i-'a'+10;
	int sum=0;
	for(i=0;in[i];i++)
	{
		sum=sum*from+zheng[in[i]];
	}
	char out[255]="0";
	int l=0;
	l=(sum==0)?1:0;
	while(sum>0)
	{	out[l]=fan[sum%to];
		l++;
		sum/=to;
	}
	for(i=l-1;i>=0;i--)
		printf("%c",out[i]);
	return 0;

}
void main()
{
        int x[100]={0}, n, i, p, y;
        char c[100]={'\0'} ;
        int a, b, m, num=0;
        scanf("%d",&a);
		scanf("%s",c);
    scanf("%d",&b);
		n=strlen(c);
        for(i=n-1;i>=0;i--)
        {
                m=pow(a,n-1-i);
                if(c[i]<65)
        num=num+m*(c[i]-48);        
		else if(c[i]<96)
		  num=num+(c[i]-55)*m;
		else
			num=num+(c[i]-87)*m;
        }
     y=0;
        for(i=0;;i++)
        {
                y++;
                x[i]=num%b;
                m=pow(b,i);
				p=num/b;
                if(p<b)
                        break;
                num=num/b;
        }
                if(p<=9&&p>0)
                        printf("%d",p);
                else
					if(p>9)
                        printf("%c",p+55);
        for(i=y-1;i>=0;i--)
        {
                if(x[i]<=9)
                        printf("%d",x[i]);
                else
                        printf("%c",(x[i]+55));
        }
		printf("\n");
}
int main ()
{
    int a,b,l;
    char n[50],d[50],m[50];
    scanf ("%d %s %d",&a,n,&b);
    if (n[0]=='0')
    printf ("0\n");
    else
    {
      l=strlen(n);
      int x=0;
      int j=0;
      for (int i=0;i<l;i++)
      {
        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 if (n[i]>='0' && n[i]<='9')
        n[i]=n[i]-'0';
        x=x*a+n[i];
      }
       for (;x!=0;j++)
       {
        d[j]=x%b;
        x=x/b;
       }
       d[j]='\0';
      for (int y=0;y<j;y++)
      {
        m[y]=d[j-y-1];
      }
       m[j]='\0';
      for (int z=0;z<j;z++)
      {
        if (m[z]<=9)
        m[z]=m[z]+'0';
        else 
        m[z]=m[z]+'A'-10;
      }
        printf ("%s",m); 
        getchar();
        getchar();
    }
}
int main()
{
	int a,b,m,i,k,j;
	unsigned long long int sum;
	char z1[200]={'\0'}, z2[200]={'\0'};
	scanf("%d %s %d",&a,z1,&b);
	k=strlen(z1);
	for(sum=0,i=0;i<k;i++)
	{
		if(z1[i]>='0'&&z1[i]<='9')
		{
			m=z1[i]-'0';
		}
		else if(z1[i]>='a'&&z1[i]<='z')
		{
			m=z1[i]-'a'+10;
		}
		else
		{
			m=z1[i]-'A'+10;
		}

		sum=sum+((unsigned long long int)pow(1.0*a,1.0*(k-i-1)))*m;
		
	}
	for(i=0;sum>0;i++)
	{
		if(sum%b<=9)
		{
			z2[i]=sum%b+'0';
		}
		else
		{
			z2[i]=sum%b-10+'A';
		}
		sum=sum/b;
	}
	for(j=strlen(z2)-1;j>=0;j--)
	{
		printf("%c",z2[j]);
	}
	if(z1[0]=='0')
	{
		printf("0");
	}
	return 0;
}
main()
{
      int m,n,b,d,i,j,k,l;
      char a[100],c[100],e[100];
      scanf("%d %s %d",&m,a,&n);
      b=0;
      for(i=0;a[i]!='\0';i++);
      {
      for(j=0;j<i;j++)
      {
           for(d=1,k=0;k<i-j-1;k++)
           {                
                d*=m;
           }
           if(a[j]<='9'&&a[j]>='0')
                   b+=(d*(a[j]-'0'));
           else if(a[j]<='z'&&a[j]>='a')
                   b+=(d*(a[j]-'a'+10));
           else
                   b+=(d*(a[j]-'A'+10));
      }
      }
      if(b==0)
      printf("0");
      else
      {
      for(l=0;b!=0;l++)
      {
           c[l]=b%n;
           if(c[l]>9)
              c[l]=c[l]-10+'A';
           else
           c[l]=c[l]+'0';
           b=(b/n);
      }
      c[l]='\0';
      for(i=0;i<l;i++)
      e[i]=c[l-1-i];
      e[l]='\0';
      printf("%s",e);
      getchar();
      getchar();
      }
}
void main()
{
	long int a,b,n=0;
	long int i,j,l;
	char c[1000],d[1000];
	scanf("%d",&a);
	scanf("%s",c);
	scanf("%d",&b);
	l=strlen(c);
	for(i=0;i<l;i++)
	{    if(c[i]>=65&&c[i]<=90)
		 c[i]=c[i]-55;
	     else if(c[i]>=97&&c[i]<=122)
			 c[i]=c[i]-87;
		 else c[i]=c[i]-48;
	}
    for(i=0;i<l;i++)
		n=n*a+c[i];
    for(i=0,j=0;;i++,j++)
	{
		d[i]=n%b;
	    n=n/b;
		if(n!=0)
			continue;
		else break;
	}
	for(i=0;i<=j;i++)
		if(d[i]>=10)
			d[i]=d[i]+55;
		else
			d[i]=d[i]+48;
     for(i=j;i>=0;i--)
		 printf("%c",d[i]);
}
int main()
{
	int a,b,i,e=0,num[100];
	long n=0;
	char sz[100];
	scanf("%d%s%d",&a,sz,&b);
	for(i=0;i<strlen(sz);i++)
	{
		if(sz[i]>='0'&&sz[i]<='9')
		{
			num[i]=sz[i]-'0';
		}
		if(sz[i]>='a'&&sz[i]<='z')
		{
			num[i]=sz[i]-'a'+10;
		}
		if(sz[i]>='A'&&sz[i]<='Z')
		{
			num[i]=sz[i]-'A'+10;
		}
	}
	for(i=0;i<strlen(sz);i++)
	{
		n+=num[i]*pow(a,strlen(sz)-1-i);
	}
	while(n>=b)
	{
		num[e]=n%b;
		n=n/b;
		e++;
	}
	num[e]=n%b;
	for(i=0;i<e+1;i++)
	{
		if(num[i]>=0&&num[i]<=9)
		{
			sz[i]=num[i]+'0';
		}
		if(num[i]>9)
		{
			sz[i]=num[i]+'A'-10;
		}
	}
	for(i=e;i>=0;i--)
	{
		printf("%c",sz[i]);
	}
	return 0;
}
int main()
{
	int a,b,x,n,i,j = 0,k,h,m,num1 = 0;
	char str[100],num[100];
	cin >> a >> str >> b;
	n = strlen(str);
	for(i = 0; i < n; i++)
	{
		int y = 1;
		for(m = 0; m < n - 1 - i;m++)
		{	
			y = y * a;
		}
		if(str[i] <= 57)
			num1 = num1 + (str[i] - 48) * y;
		if((str[i] >= 65)&&(str[i] < 97))
			num1 = num1 + (str[i] - 55) * y;
		if(str[i] >= 97)
			num1 = num1 + (str[i] - 87) * y;
	}
	x = num1;
	do
	{
		num1 = num1 / b;
		j++;                        
	}while(num1 > 0);
    for(k = 0 ; k < j; k++)
    {   
	    if(x % b < 10)
			num[j - 1 - k] = x % b + 48;
		if(x % b >= 10)
			num[j - 1 - k] = x % b + 55;
		x = x / b;
	}
	for(h = 0; h < j ; h++)
		cout << num[h];
	return 0;
}
void main()
{
	int a,b,k,i,q,f=0;
	char x[30],*p=x;
	long n=0,t;
	scanf("%d %s %d",&a,x,&b);
	k=strlen(x)-1;
	for(;k>=0;k--,p++)
	{
		if(*p>=48 && *p<=57)		t=(long)*p-48;
		else if(*p>=65 && *p<=90)	t=(long)*p-55;
		else if(*p>=97 && *p<=122)  t=(long)*p-87;
		i=k;
		while(i>0)
		{
			t=t*a;
			i--;
		}
		n+=t;
	}
	for(t=n,i=0;t>=b;i++)
	{
		t=t/b;
	}
	for(k=i,t=1;k>=0;k--,t=1)
	{
		i=k;
		while(i>0)
		{
			t=t*b;
			i--;
		}
		q=n/t;
		if(q==0 && f==0) continue;
		else if(f==0)
		{
			f=1;
			goto z;
		}
		else
		{
z:			if(q>=0 && q<=9)
			{
				printf("%d",q);
			}
			else if(q>=10)
			{
				printf("%c",q+55);
			}
			n=n-q*t;
		}
	}
	if(f==0) printf("0");
}
int main()
{
    long a,b,i,n=0,t=0,sum;
    char s[1000];
    long q[1000]; 
    char p[1000];
    char m[1000];
    scanf("%d %s %d",&a,s,&b);
    for(i=0;s[i]!='\0';i++)
    n=n+1;
    for(i=0;i<=n-1;i++)
    {
    if(s[i]>='a'&&s[i]<='z')            
    s[i]=s[i]-'a'+10;
    if(s[i]>='0'&&s[i]<='9') 
    s[i]=s[i]-'0';                       
    if(s[i]>='A'&&s[i]<='Z')
    s[i]=s[i]-'A'+10;                          
    }
    sum=1;
    for(i=n-1;i>=0;i--)
    {  
    t=s[i]*sum+t;
    sum=sum*a;            
    }
if(t==0)
printf("0");
    q[0]=t;
    for(i=0;q[i]!=0;i++)
       q[i+1]=q[i]/b;      
    for(i=0;q[i]!=0;i++)
    {
      p[i]=q[i]%b;
      if(p[i]>9)
      p[i]=p[i]-10+'A';     
      else
      p[i]=p[i]+'0'-0;
    }
    p[i]='\0';
    n=0;
    for(i=0;p[i]!='\0';i++)
       n=n+1;
    for(i=0;i<=n-1;i++)
    m[i]=p[n-i-1];
    m[n]='\0';
    printf("%s",m);
    getchar();
    getchar();
}
char a[32];
int b[32];
char trans[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 main()
{
	int n,m;
	int i,j,k;
	long int mid;
	int ar;
	scanf("%d %s %d",&n,a,&m);
	int len=strlen(a);
	for(k=0;k<len;k++)
	{
		if((a[k]>='0')&&(a[k]<='9'))
			a[k]-='0';
		if((a[k]>='a')&&(a[k]<='z'))
			a[k]=a[k]-'a'+10;
		if((a[k]>='A')&&(a[k]<='Z'))
			a[k]=a[k]-'A'+10;
		
	}
	mid=0;
	ar=1;
	for(j=len-1;j>=0;j--)
	{
		mid+=a[j]*ar;
		ar*=n;
	}
	k=0;
	while(mid!=0)
	{
		b[k]=mid%m;
		mid=mid/m;
		k++;
	}
	for(i=k-1;i>=0;i--)
		if(b[i]!=-1)
			printf("%c",trans[b[i]]);
		printf("\n");
	return 0;
}
main()
{
	long int n0[31], t, m0[31],  s[31]={0};
	//sum????10?????? t???????10????????????sum; s??????????m????
	
	int sum=0, a, b, l, i, j;
	char n[31]={'\0'}, m[31]={'\0'};
	scanf("%d %s %d", &a, n, &b);
	
	for(i=0; n[i]!='\0'; i++)
	{
		if(n[i]>=65&&n[i]<=90)
			n0[i]=n[i]-55;
		else if(n[i]>=97&&n[i]<=122)//????else if??? 
			n0[i]=n[i]-87;
		else
			n0[i]=n[i]-48;
	}
	
	l=strlen(n);
	for(i=0; i<l; i++)
	{
		t=(int)(n0[i]*pow(a, l-i-1));
		sum=sum+t;
	}
	
	
	i=0;
	do
	{
		s[i]=sum%b;
		sum=(sum-s[i])/b;
		i++;
	}while(sum!=0);
	
	for(j=0; j<i; j++)
	{
		m0[j]=s[i-1-j];
		if(m0[j]>=10)
			m[j]=m0[j]+55;
		else
			m[j]=m0[j]+48;
	}
	puts(m);
	return 0;
}
struct stack  
{  
    char data[101];  
    int top;  
};  
  
long int change(int a, char *s);  
  
int main()  
{  
    long int a, b, n;  
    char str[101];  
  
    while(scanf("%ld %s %ld", &a, str, &b) != EOF)  
    {  
        n = change(a, str);  
        if(n == 0)  
        {  
            printf("0");  
        }else  
        {  
            int temp;  
            struct stack *s = (struct stack *)malloc(sizeof(struct stack));  
            s->top = 0;  
  
            while(n)  
            {  
                temp = n % b;  
                if(temp >= 0 && temp <= 9)  
                {  
                    s->data[s->top ++] = temp + '0';  
                }else  
                {  
                    s->data[s->top ++] = temp - 10 + 'A';  
                }  
                n /= b;  
            }  
  
            while(s->top)  
            {  
                printf("%c", s->data[-- s->top]);  
            }  
        }  
        printf("\n");  
    }  
  
    return 0;  
}  
  
  
long int change(int a, char *s)  
{  
    int i, b;  
    long int n, c;  
  
    for(n = 0, c = 1, i = strlen(s) - 1; i >= 0; i --)  
    {  
        if(s[i] >= 'A' && s[i] <= 'Z')  
            b = s[i] - 55;  
        else if(s[i] >= 'a' && s[i] <= 'z')  
            b = s[i] - 87;  
        else  
            b = s[i] - '0';  
        n += b * c;  
        c *= a;  
    }     
  
    return n;  
}
void main()
{
	char shurudeshu[1000];int n,shijingzhi=0,i;
	int jingzhi,daizhuanhuandejingzhi;
	scanf("%d ",&jingzhi);scanf("%s ",shurudeshu);scanf("%d",&daizhuanhuandejingzhi);
	n=strlen(shurudeshu);
	for(i=0;i<=n-1;i++)
	{
		if(('A'<=shurudeshu[i])&&(shurudeshu[i]<='Z'))
			shurudeshu[i]=shurudeshu[i]-'A'+10;
		else if(('a'<=shurudeshu[i])&&(shurudeshu[i]<='z'))
			shurudeshu[i]=shurudeshu[i]-'a'+10;
		else if(('0'<=shurudeshu[i])&&(shurudeshu[i]<='9'))
			shurudeshu[i]=shurudeshu[i]-'0';
	}
		for(i=0;i<=n-1;i++)
		{
			shijingzhi=shijingzhi+(int)(shurudeshu[i]*pow(jingzhi,n-i-1));
		}
		if(shijingzhi==0)
			printf("%d",shijingzhi);
		if(shijingzhi!=0)
		{
		int shang;int yushu[100],j;
   shang=shijingzhi;
   for(i=0;shang!=0;i++)
   {
       yushu[i]=shang%daizhuanhuandejingzhi;
       shang=shang/daizhuanhuandejingzhi;
   }
   for(j=i-1;j>=0;j--)
   {
	   if((0<=yushu[j])&&(yushu[j]<=9))
		   printf("%d",yushu[j]);
	   else if(yushu[j]>=10)
	   {
		   yushu[j]=yushu[j]+'A'-10;
	       printf("%c",yushu[j]);
	   }
   }
		}
   printf("\n");
}
int main()
{
    int a,b,i,j,sum10=0,n10[100],nb[100],lenn,q;
    char n[100],nc[100];
    cin>>a>>n>>b;
    lenn=strlen(n);
    for(i=0;n[i]!='\0';i++)
    {
                           if((n[i]>='a')&&(n[i]<='z'))
                           {
                                                       n10[i]=n[i]-'a'+10;
                           }else if((n[i]>='A')&&(n[i]<='Z'))
                           {
                                 n10[i]=n[i]-'A'+10;                       
                           }else {n10[i]=n[i]-'0';}
                           for(j=1;j<=lenn-i-1;j++)
                           {
                                                   n10[i]=n10[i]*a;
                           }
                           sum10=sum10+n10[i];
    }
    if(sum10==0){cout<<0;}
    else
    {i=0;
    while(sum10!=0)
    {
                 nb[i]=sum10%b;
                 sum10=sum10/b;
                 i++;
    }
    for(j=i-1;j>=0;j--)
    {
                     if(nb[j]>9)
                     {
                                nc[j]=nb[j]-10+'A';
                     }else nc[j]=nb[j]+'0';
                     cout<<nc[j];
    }
    }
    cin>>q;
    return 0;
}
int main()
{
	int a,b,l;                       //?????????????????
	long n=0;                    
	char c[100];
	cin>>a>>c>>b;                    //??
	l=strlen(c);
	for(int i=0;i<=l-1;i++)          //????
		if(c[i]<='z'&&c[i]>='a')
			c[i]=c[i]-'a'+'A';
	for(int i=0;i<l;i++)             //??????
	{
		int m;
		if(c[i]<='Z'&&c[i]>='A')
			m=10+c[i]-'A';
		else m=c[i]-'0';
		n+=m*pow((double)a,l-i-1);
	}
	for(int i=0;;i++)                //???????
	{
		int m;
		m=n%b;
		n=(n-m)/b;
		if(m<10)
			c[i]=m+'0';
		else c[i]=m-10+'A';
		if(n==0)
		{
			l=i+1;
			break;
		}
	}
	for(int i=l-1;i>=0;i--)         //??
		cout<<c[i];
	return 0;
}
int main(int argc, char* argv[])
{
	int a2i[128];
	char i2a[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char in[255],out[255]="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]);
	return 0;
}
int main()
{
	int a,b,i=0,j=0,k=0,shijinzhi=0,power=1;
	int x[30];
	cin>>a;
    x[0]=getchar()+1;
	while(x[i]!=-16)
	{
		i++;
		x[i]=getchar();
		if(x[i]>96) x[i]-=87;
		else if(x[i]>64) x[i]-=55;
		else x[i]-=48;
	}
	if (x[1]==0) cout<<"0";
	else
	{
	for(j=i-1;j>=1;j--)
	{
		shijinzhi+=x[j]*power;
		power=power*a;
	}
	cin>>b;
	i=0;
	while(shijinzhi>0)
	{
		i++;
		x[i]=shijinzhi%b;
		shijinzhi=shijinzhi/b;
		if(x[i]<10) x[i]+=48;
		else x[i]+=55;
	}
	for(k=i;k>0;k--)
	{
		putchar(x[k]);
	}
	}
	return 0;
}
int main()
{
	int a=0, b=0, i=0, k=0, l=0;//a, b ???,k ???????.l????
	char n_b[30]={0}, n[30]={0};//???????n. n_b[30]??????
	unsigned long  n_10=0;//?????n[30]???
	cin>>a>>n>>b;
	l= strlen(n);//???
	i=l;//???????????
	for (k=0; k<l; k++)//????????????????
	{
		if ( n[k]>=48 && n[k]<=57 && i >= 1)//??0-9????n[k]-48
		{
			n_10 = n_10 + pow ((double)a, (double)(i-1))*(n[k]-48);
		}
		else if ( n[k]>=65 && n[k]<=90 &&  i >= 1)//??A-Z??n[k]-55
		{
			n_10 = n_10 + pow ((double)a, (double)(i-1))*(n[k]-55);
		}
		     else if ( n[k]>=97 && n[k]<=122 &&  i >= 1)//??a-z??n[k]-87
			 {
				 	n_10 = n_10 + pow ((double)a, (double)(i-1))*(n[k]-87);
			 }
		          else
					  break;
		i--;
	}
    if ( n_10==0 )//??????
		cout<<0;
	for ( k=0;; k++)//???????b???????????
	{
		 	if ( n_10 != 0)
			{
				if ( n_10 % b >= 0 && n_10 % b <=9)//??
				{
					n_b[k]=n_10 % b + 48;
				}
                else if ( n_10 % b >= 10 && n_10 % b <=35)
				{
					n_b[k]=n_10 % b + 55;
				}
				n_10 = n_10 / b;//??
			}
			else
				break;
	}
	for ( i=k-1; i>=0; i--)//????
	{
		cout<<n_b[i];
	}
	cout<<endl;
	return 0;
}
int power(long int a,long int i)
{
	unsigned long j,k=1;
	for (j=0;j<i;j++)
		k=k*a;
	return(k);
}
int main()
{
	long int a,b,i,j,l,t,y,k;
	unsigned long  temp=0,x;
	char p[100]={0},re[100]={0};
	scanf("%d %s %d",&a,p,&b);
	l=strlen(p);
	for (i=0;i<l;i++)
	{
		if (p[l-1-i]>='a'&&p[l-1-i]<='z')
           temp+=(p[l-1-i]-'a'+10)*power(a,i);
		if (p[l-1-i]>='A'&&p[l-1-i]<='Z')
           temp+=(p[l-1-i]-'A'+10)*power(a,i);
		if (p[l-1-i]>='0'&&p[l-1-i]<='9')
           temp+=(p[l-1-i]-'0')*power(a,i);
	}
	for (j=0;;j++)
	{
		x=power(b,j);
		y=temp/x;
		if (y<b)
			break;
	}
	j++;
	for (k=j-1;k>=0;k--)
	{
		x=power(b,k);
		t=temp/x;
		if (t>=10)
			re[j-1-k]='A'+t-10;
		else
			re[j-1-k]='0'+t;
		temp-=x*t;
	}
	printf("%s",re);
	return (0);
}
int chrtoint(char ch)
{
	if (ch>='0' && ch<='9')
		return ch-'0';
	else if (ch>='A' && ch<='Z')
		return ch-'A'+10;
	else if (ch>='a' && ch<='z')
		return ch-'a'+10;
	else
		return -1;
}

char inttochr(int a)
{
	if (a>=0 && a<=9)
		return (char)(a+'0');
	else if (a>=10 && a<=35)
		return (char)(a-10+'A');
	else
		return -1;
}

int main()
{
	char str[100]={0};
	long a, b;
	long num;
	scanf("%d %s %d", &a, str, &b);
	int len=0, i;
	while (str[len]>0)
		len++; //???????

	//a??->10??
	num=0;
	for (i=0;i<len;i++)
	{
		num=num*a+chrtoint(str[i]);
	}

	//10??->b??
	str[0]='0';
	len=0;
	while (num>0)
	{
		str[len]=inttochr(num%b);
		len++;
		num/=b;
	}
	if (len==0) len++; //??0???

	//????
	for (i=len-1;i>=0;i--)
		putchar(str[i]);

	return 0;
}
int cifang(int u,int g)
{
 long int l=1;
 for(int i=1;i<=g;i++)
 {
  l=l*u;
 }
 return l;
}

int main()
{
 int n,m;
 long int sum=0;
 char a[1000];
 cin>>n;
 cin>>a;
 cin>>m;
 char c[26]={'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 s=strlen(a);
 for(int i=0;i<=s-1;i++)
 {
  if(a[i]>='0' && a[i]<='9')
  {
   int t=a[i]-'0';
   sum=sum+t * cifang(n,s-1-i);
  }
  else if(a[i]>='A' && a[i]<='Z')
  {
   int t=a[i]-'A'+10;
   sum=sum+t*cifang(n,s-1-i);
  }
  else if(a[i]>='a' && a[i]<='z')
  {
   int t=a[i]-'a'+10;
   sum=sum+t*cifang(n,s-1-i);
  }
 }
 int b[1000];
 int j;
 
 for(int d=0;d<=999;d++)
 {
  b[d]=sum%m;
  sum=(sum-b[d])/m;
  if(sum<m)
  {
   if (sum>0)
   {
    if(sum>10)
    
     cout<<c[sum-10];
    else
     cout<<sum;
    
    for(int f=d;f>=0;f--)
    {
     if(b[f]>=10)
     {
      cout<<c[b[f]-10];
     }
     else
     {
      cout<<b[f];
     }
    }
   break;
   }
   else
   {
    for(int f=d;f>=0;f--)
    {
     if(b[f]>=10)
     {
      cout<<c[b[f]-10];
     }
     else
     {
      cout<<b[f];
     }
    }
    break;
   }
  }
 }
 
 
 return 0;
}
int main()
{
 long int input,output,n,ex1[20000],ex2[20000],sum=0,s[20000],f[20000],g[20000],out[20000];  //?????????
 char str1[20000],str2[20000],str3[20000];                                                   //?????????
 int i,j,k,l=0,m,h,o,p;                                                                      //????????
 cin>>input>>str1>>output;                                                                  //?????? ???? ????
 n=strlen(str1);                                                                           //??????????
 for(i=0;i<n;i++)                                                                          
 {ex1[i]=str1[i];}                                                                            //????????????
 for(j=0;j<n;j++)
 {if((ex1[j]>=48)&&(ex1[j]<=57))
 ex2[j]=ex1[j]-48;
 else if((ex1[j]>=65)&&(ex1[j]<=90))
  ex2[j]=ex1[j]-55;
 else if((ex1[j]>=97)&&(ex1[j]<=122))
  ex2[j]=ex1[j]-87;
 }                                                                                          //??ascii????0z?????????
 for(k=0;k<n;k++)
 {sum=sum+ex2[k]*pow((double)input,n-1.0-k);}                                              //??????????????
 s[0]=sum;
 while(s[l]>0)
 {s[l+1]=s[l]/output;
 f[l]=s[l]%output;
 l=l+1;}                                                                                  //??????????????????????????????
 for(m=0;m<l;m++)
  g[m]=f[l-m-1];
 for(h=0;h<m;h++){
  if((g[h]>=0)&&(g[h]<=9))
   out[h]=g[h]+48;
  else if((g[h]>=10)&&(g[h]<=35))
   out[h]=g[h]+55;
 }                                                                                      //??acsii??????????????????????????
 for(o=0;o<m;o++)
  str3[o]=out[o];                                                                     //??acsii????????????????????????????????
 for(p=0;p<m;p++)
  cout<<str3[p];
 if(sum == 0)
  cout<<0;
  //????
 return 0;
}
int main()
{
	int a,b,i,j=0;
	char str[100001];
	long sum=0;
	cin>>a>>str>>b;
	for(i=0;i<100001&&str[i]!=0;i++)
	{
		if(str[i]>='0'&&str[i]<='9')str[i]-='0';
		else if(str[i]>='a'&&str[i]<='z')str[i]=str[i]-'a'+10;
		else if(str[i]>='A'&&str[i]<='Z')str[i]=str[i]-'A'+10;
		sum*=a;
		sum+=str[i];
	}
	int save[100000]={0};
	while(sum!=0)
	{
		save[j++]=sum%b;
		sum/=b;
	}
	char temp;
	for(i=j-1;i>=0;i--)
	{
		if(save[i]<10)temp=save[i]+'0';
		else temp=save[i]-10+'A';
		cout<<temp;
	}
if(j==0)cout<<0<<endl; 
	return 0;
}
int main()
{
	int a,b,i,j,wa,wb,t=1;
	long dec=0,x,y;
	char n[100],m[100];
	scanf("%d%s%d",&a,n,&b);
	wa=strlen(n);
	for(i=0;i<=wa-1;i++)
		if(n[i]!=48) {t=0; break;}
    if(t==1) printf("0\n");
	else
	{for(i=0;i<=wa-1;i++)
	{if(n[i]>=48&&n[i]<=57) 
     {x=n[i]-48;
	  for(j=1;j<=wa-i-1;j++)
	     x=x*a;
	  dec=dec+x;}
	 if(n[i]>=65&&n[i]<=90)
     {x=n[i]-55;
	  for(j=1;j<=wa-i-1;j++)
	  x=x*a;
	  dec=dec+x;}
	 if(n[i]>=97&&n[i]<=122)
	 {x=n[i]-87;
	  for(j=1;j<=wa-i-1;j++)
         x=x*a;
	  dec=dec+x;}
	} 
	wb=(int)(log(dec)/log(b))+1;
	for(i=0;i<=wb-1;i++)
	{y=dec;
	 for(j=1;j<=wb-i-1;j++)
        y=y/b;
     y=y%b;
	 if(y>=0&&y<=9) m[i]=y+48;
	 else m[i]=y+55;}
	 for(i=0;i<=wb-1;i++)
         printf("%c",m[i]);
	 printf("\n");}
    return(0);
}
int main()
{
	int i,j,a,b,l;
	long s=0,ss[1001]={0};
	char s1[1001],s2[1001];
	cin>>a>>s1>>b;
	l=strlen(s1);
	for(i=0;i<1000;i=i+1)
		s2[i]=',';
	for(i=0;i<l;i=i+1)
	{
		if(s1[i]>='0'&&s1[i]<='9')
			ss[i+1]=ss[i]*a+s1[i]-'0';
		else if(s1[i]>='A'&&s1[i]<='Z')
			ss[i+1]=ss[i]*a+s1[i]-'A'+10;
		else
			ss[i+1]=ss[i]*a+s1[i]-'a'+10;
	}
	s=ss[l];
	for(i=0;i<1000;i=i+1)
	{
		j=s%b;
		if(j<=9)
			s2[i]='0'+j;
		else
			s2[i]='A'+j-10;
		s=s/b;
		if(s==0)
			break;
	}
	for(i=0;i<1000;i=i+1)
		if(s2[i]==',')break;
	for(i=i-1;i>=0;i=i-1)
		cout<<s2[i];
	cout<<endl;
	return 0;
}
int f1(char p);
char f2(int p);
void main()
{ 
 long t=0;
 char s[11],x[11]={""};
 int a,b,i,k,n;
 scanf("%d %s %d",&a,s,&b);
 n=strlen(s);
 for (i=0;i<=n-1;i++)
   t=f1(s[i])+t*a;
 n=0;
 if (t==0) printf("0");
 while(t!=0)
 { k=t%b;
   t=(t-k)/b;
   x[n]=f2(k);
   n++;
 }
 for (i=n-1;i>=0;i--)
	 printf("%c",x[i]);
printf("\n");
}


int f1(char p)
{ int t;
 if ((p>=48)&&(p<=57)) t=p-48;
 else if ((p>=55)&&(p<=90)) t=p-55;
      else  t=p-87;
 return(t);
}


char f2(int p)
{ char t;
 if ((p>=0)&&(p<=9)) t=p+48;
 else  t=p+55;
return (t);
}