semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
   char numa[100],numb[100];//???a???b??
   long na[100],nb[100];
   long a,b;
   cin>>a>>numa>>b;
   long digit_a=0;
   long m=1,j;
   while(numa[digit_a]!=0)
      digit_a++;
   //??a??????

   for(j=1;j<digit_a;j++)
    m=m*a;
   long i;
   long numd=0;
   for(i=0;i<digit_a;i++)
   {
    if((numa[i]>='a')&&(numa[i]<='z'))
     na[i]=numa[i]-87;
    if((numa[i]>='A')&&(numa[i]<='Z'))
     na[i]=numa[i]-55;
    if((numa[i]>='0')&&(numa[i]<='9'))
     na[i]=numa[i]-48;
    numd=numd+m*na[i];
    m=m/a;
   }
   //???????numd
   if(numd==0)
     cout<<0<<endl;
   long k=0;
   while(numd!=0)
   {
      nb[k]=numd%b;
   numd=numd/b;
   if((nb[k]>=0)&&(nb[k]<=9))
    numb[k]=nb[k]+48;
   else
    numb[k]=nb[k]+55;
   k++;
   }
   //k?b??????
   long t;
   for(t=k-1;t>=0;t--)
    cout<<numb[t];
   return 0;
}
main()
{
    int a,n,b,c[60],d[60],i=0,j=0,x,y,z,sum1=0,sum2=0;
	scanf("%d ",&a);//*??a*//

	while((n=getchar())!=' ')//*??n*//
	{
		i++;
		c[i]=n;
	}
	x=i;

	scanf("%d",&b);//*??b*//

	for(i=1;i<=x;i++)         //* n??????????? *//
	{
		for(y='A';y<='Z';y++)
			if(c[i]==y)
			{
				c[i]=c[i]-7;
			    break;
			}
		for(y='a';y<='z';y++)
			if(c[i]==y)
				c[i]=c[i]-39;
		
	}
	for(i=1;i<=x;i++)
		c[i]=c[i]-48;

	for(i=1;i<=x;i++)    //* a??n???10?? *//
	{
		sum1=sum1+c[i]*pow(a,x-i);
	}

    if(sum1==0)
    printf("0");
    
    while(sum1!=0)   //* 10??n???b??*//
	{
		j++;
		d[j]=sum1%b;
		sum1=sum1/b;
	}

	z=j;
	for(j=z;j>=1;j--)    //*?????????*//
	{
		if(d[j]>=10)
			printf("%c",d[j]+55);
		else
			printf("%d",d[j]);
	}
	printf("\n");
}
int main(int argc, char* argv[])
{
	char a[3],b[100],c[3],after[100],strtmp,after1[100];
	int before=0 ;
	int n1,n2,i,n,A[100],tmp,m;
	scanf ("%s %s %s",a,b,c);
    n1=atoi (a);
	n2=atoi (c); 
	n=strlen (b);
    //printf ("%d\n%d\n",n1,n2);
    for (i=0;i<n;i++)
	{
		if (b[i]>='a'&&b[i]<='z')
			b[i]=b[i]-32;
		if (b[i]>='0'&&b[i]<='9')
			A[i]=b[i]-48;
		if (b[i]>='A'&&b[i]<='Z')
			A[i]=b[i]-55;
		//printf ("%d\n",A[i]);
	}
	
    for (i=0;i<n;i++)
	{
         before = before*n1+A[i];
	}//printf ("%d\n",before);
	if (before==0)
	{after1[0]='0';after1[1]='\0';}
	else {
	for (i=0;i<100;i++)
	{
		if (before<1)
			break;
		else
		{  
            tmp=before%n2;
			before=before/n2;
			if(tmp>=10)
               strtmp=tmp+55;
			else
			   strtmp=tmp+48;
			after[i]=strtmp;
		}
	}
	after[i]='\0';
	//puts (after);
	m=strlen (after);
	//printf ("%d\n",m);
    for (i=0;i<m;i++)
	{
         after1[i]=after[m-i-1];
	}
	after1[i]='\0';}
	puts (after1);
	return 0;
}
char CHR[120];
int p1,p2,p3,num;

int deal(char Q)
{
	if ((Q>='0')&&(Q<='9')) return Q-'0';
	if ((Q>='A')&&(Q<='Z')) return Q-'A'+10;
	return -1;
}
char laed(int Q)
{
	if ((Q>=0)&&(Q<=9)) return '0'+Q;
	if (Q>9) return 'A'+Q-10;
}
void output(int ans)
{
	if (ans==0) return;
	else 
	{
		output(ans/p3);
		cout<<laed(ans%p3);
	}
}
int main()
{
	cin>>p1;cin.get();
	p2=0;num=0;
	while ((CHR[p2]=cin.get())!=' ') 
	{
		if ((CHR[p2]>='a')&&(CHR[p2]<='z')) CHR[p2]=CHR[p2]-'a'+'A';
		num=num*p1+deal(CHR[p2]);
		p2++;
	}
	cin>>p3;
	if (num==0) cout<<0;
	else output(num);
	cout<<endl;
	return 0;
}
int main()
{
    int m,n,l,i,j,b[65535];
    long t=0,k=1;
    char a[65535];
    scanf("%d %s %d",&m,a,&n);
    l=strlen(a);
    for(i=0;i<l;i++)
       {
           if((a[i]<='9')&&(a[i]>='0'))
               b[i]=a[i]-'0';
           if((a[i]<='z')&&(a[i]>='a'))
               b[i]=a[i]-'a'+10;
           if((a[i]<='Z')&&(a[i]>='A'))
               b[i]=a[i]-'A'+10;
       }
    for(i=0;i<l;i++)
        {
            t=t+b[i]*pow(m,l-i-1);
        }
    if(t==0)
        printf("%d",t);
    j=0;
    while(t!=0)
        {
            b[j]=t%n;
            t=t/n;
            j++;
        }
    for(i=0;i<j;i++)
        {
            if(b[i]<=9)
                a[j-1-i]='0'+b[i];
            else
                a[j-1-i]='A'+b[i]-10;
        }
    a[j]='\0';
    printf("%s",a);
    getchar();
    getchar();
}
int main()
{
int a=0,b=0,length=0;                              
long long dec = 0;
char origin[100],final[100];            //???char origin?a???~int temp?a???~dec?????~int answer?b???~char final?b???                   
int temp[100]={0},answer[100]={0};
cin>>a>>origin>>b;

length=strlen(origin);

for(int i=length-1;i>=0;i--)          //char origin?a???~int temp?a???
   {
  if(origin[i]>='a'&&origin[i]<='z')
            temp[i]=origin[i]-87;
  else if(origin[i]>='A'&&origin[i]<='Z')
       temp[i]=origin[i]-55;
  else
   temp[i]=origin[i]-48;
    }





for(int i=length-1;i>=0;i--)       //int temp?a???~dec?????
  {

 dec=dec+temp[i]*pow((double)a,(length-i-1));

  }
//cout<<dec;
 
int j=0;
   while((dec/b)!=0)            //dec?????~int answer?b????????
    {
        answer[j]=dec%b;
   dec=dec/b;
j++;
    }
   answer[j]=dec%b;

  for(int k=j;k>=0;k--)           //int answer?b???~char final?b??????????
  {
      if(answer[k]>=10&&answer[k]<=35)
 {
 final[k]=(char)(answer[k]+55);
 cout<<final[k];
      }
 else
 cout<<answer[k];
  
  }




}
void main()
{
	int a1,a2,i,len,j;
    unsigned long t=0,n[40],k;
	char num1[40];
	scanf("%d%s%d",&a1,&num1,&a2);
	len=strlen(num1);
	for(i=len-1,j=0;i>=0;i--,j++)
	{
		if(num1[i]>='A'&&num1[i]<='Z')n[i]=10+num1[i]-'A';
		if(num1[i]>='a'&&num1[i]<='z')n[i]=10+num1[i]-'a';
		if(num1[i]>='0'&&num1[i]<='9')n[i]=1+num1[i]-'1';
		t=t+n[i]*(int)pow(a1,j);
	}
	for(i=0;;i++)
	{
		k=t/(int)pow(a2,i);
		if(k<a2)/* ! */
		break;
	}
      for(;i>=0;i--)
	  {
		n[i]=t/(int)pow(a2,i);
		t=t-(int)pow(a2,i)*n[i];
			if(n[i]>=0&&n[i]<=9)
				printf("%c",n[i]+48);
			if(n[i]>=10&&n[i]<=35)
				printf("%c",n[i]+55);	
	  }
}
void main()
{
	char n[20],tab[100];
	int a,b,nlen,k,z[10];
	long d=0,i;
	scanf("%d%s%d",&a,n,&b);
     nlen=strlen(n);
    for(i=0;i<nlen;i++)
	  {
		if(n[i]>='0'&&n[i]<='9')
			z[i]=n[i]-48;
		else
			if(n[i]>='a'&&n[i]<='z')
				z[i]=n[i]-87;
	    else
			if(n[i]>='A'&&n[i]<='Z')
				z[i]=n[i]-55;
	  }

	   for(i=0;i<nlen;i++)
	   {
        k=pow(a,nlen-i-1);
		d=d+z[i]*k;
	   }
	   if(d==0)
		   printf("0");
	   else
	   {
       for(i=0;i<36;i++) 
	   { 
          if(d%b<=9) 
            tab[i]=d%b; 
            switch(d%b) 
			{ 
                 case 10:tab[i]='A';break; 
                 case 11:tab[i]='B';break; 
                 case 12:tab[i]='C';break; 
                 case 13:tab[i]='D';break; 
                 case 14:tab[i]='E';break; 
                 case 15:tab[i]='F';break; 
                 case 16:tab[i]='G';break; 
                 case 17:tab[i]='H';break; 
                 case 18:tab[i]='I';break; 
                 case 19:tab[i]='J';break; 
                 case 20:tab[i]='K';break; 
                 case 21:tab[i]='L';break; 
                 case 22:tab[i]='M';break; 
                 case 23:tab[i]='N';break; 
                 case 24:tab[i]='O';break; 
                 case 25:tab[i]='P';break; 
                 case 26:tab[i]='Q';break; 
                 case 27:tab[i]='R';break; 
                 case 28:tab[i]='S';break; 
                 case 29:tab[i]='T';break; 
                 case 30:tab[i]='U';break; 
                 case 31:tab[i]='V';break; 
                 case 32:tab[i]='W';break; 
                 case 33:tab[i]='X';break; 
                 case 34:tab[i]='Y';break; 
                 case 35:tab[i]='Z';break; 
			} 

           d/=b; 
	   } 
      for(i=35;i>=0;i--) 
         if(tab[i]!=0) 
          break; 

      for(;i>=0;i--) 
	  { 
       if(tab[i]>9) 
       printf("%c",tab[i]); 
         else 
      printf("%d",tab[i]); 
	  }
	   }
}
char ch(char a)
{
char c;
if(a>='A'&&a<='Z')c='A'-10;
else if(a>='a'&&a<='z')c='a'-10;
else c='0';
return c;
}
void main()
{
int a,b,i,j;
long sum=0;
char n[32]="\0",m[32]="\0",c;
scanf("%d ",&a);
for(i=0;i<32;i++){scanf("%c",&n[i]);if(n[i]==' ')break;}
scanf("%d",&b);
for(j=0;j<i;j++)sum=sum*a+n[j]-ch(n[j]);
for(j=0;j<32;j++){c='0';if(sum%b>9)c='A'-10;m[j]=sum%b+c;sum=sum/b;if(sum==0)break;}
for(i=0;i<=j;i++)printf("%c",m[j-i]);
}
void zhuanhuan(char a[])
{
 char t;
 int i,length;
 length=strlen(a);
 for(i=0;i<length/2;i++)
 {
  t=a[i];
  a[i]=a[length-i-1];
  a[length-i-1]=t;
 }
}

void main()
{
 unsigned int i=0;
 int sum=0,a,b; 
 char num_1[100],num_2[100];
 scanf("%d %s %d",&a,num_1,&b);

 while(num_1[i]!='\0')
 {
  if(num_1[i]>='0'&&num_1[i]<='9')
   sum=sum*a+num_1[i]-'0';
  else if(num_1[i]>='A'&&num_1[i]<='Z')
   sum=sum*a+num_1[i]-'A'+10;
  else if(num_1[i]>='a'&&num_1[i]<='z')
   sum=sum*a+num_1[i]-'a'+10;
  i++;
 }
 
 i=0;
 while(sum/b!=0)
 { 
  int yu=sum%b;
  if(yu>=0&&yu<=9)num_2[i]='0'+yu;
  else if(yu>=10)
	  num_2[i]='A'+yu-10;
  sum=sum/b;
 
  i++;

 }
 
 if(sum>=0&&sum<=9)num_2[i]='0'+sum;
 if(sum>=10)num_2[i]='A'+sum-10;

num_2[i+1]='\0';
 zhuanhuan(num_2);
 
 if(num_2[0]!=0)puts(num_2);
 else for(i=1;i<strlen(num_2)-1;i++)printf("%c",num_2[i]);

}
int fim[255], map[37]; char C[1000];

int main(void) {
	int a, b; char ch[100];
	for (int i = 0; i <= 36; i++) if (i <= 9) fim[i + 48] = i; else fim['a' + i - 10] = i; //??????
	for (int i = 0; i <= 36; i++) if (i <= 9) map[i] = i + 48; else map[i] = i + 'A' - 10; //??
	scanf("%d %s %d", &a, ch, &b);
	int S = 0;
	for (int i = 0; i < (int)strlen(ch); i++) {
		ch[i] = tolower(ch[i]);
		S = S * a + fim[ch[i]];
	} //??????
	if (S == 0) {
		puts("0");
	} else {
		int l = 0;
		while (S) 
			C[l++] = map[S % b], S /= b; //???b??
		reverse(C, C + l);
		puts(C);

	}
	return 0;
}
void preProcess(char *p)
{
	for (int i = 0; i < strlen(p); i++)
	{
		if (*(p + i) - 'a' >= 0 && *(p + i) - 'z' <= 0)
		{
			*(p + i) = '0' + (*(p + i) - 'a' + 10);
			continue;
		}
		if (*(p + i) - 'A' >= 0 && *(p + i) - 'Z' <= 0)
		{
			*(p + i) = '0' + (*(p + i) - 'A' + 10);
			continue;
		}
	}
}

int main()
{
	int m, n;
	char sOrig[200], sRes[200];

	cin >> m >> sOrig >> n;

	preProcess(sOrig);

	//cout << sOrig << endl;

	int nValue = 0;

	char *p = sOrig;
	while (*p != '\0')	nValue = nValue * m + *p++ - '0';

	char *s = sRes;
	if (nValue == 0)
	{
		*s++ = '0';
	}
	while (nValue)
	{
		if (nValue % n < 10)	*s++ = nValue % n + '0';
		else	*s++ = nValue % n - 10 + 'A';
		nValue /= n;
	}
	*s-- = '\0';

	while(s >= sRes)	cout << *s--;
	cout << endl;

	return 0;
}
int main()
{
	long m,p,i,n,x,ten=0,k,j,q,y,sum=0;
	char c[100]={0};
	scanf("%ld%s%ld",&m,c,&p);
	n=strlen(c);
	if(c[0]=='0')
		printf("0\n");
	else{
		for(i=0;i<n;i++)
		if(c[i]>='A'&&c[i]<='Z')
			c[i]+=32;
		for(i=n-1;i>=0;i--)
		{
			if(c[i]>='a'&&c[i]<='z')
				x=(c[i]-87)*pow(m,n-1-i);
			else
				x=(c[i]-48)*pow(m,n-1-i);
			ten=ten+x;
		}
		sum=ten;k=ten;i=0;
		while(k)
		{
			k=k/p;	i++;	
		}
		for(j=0;j<i;j++)
		{ten=sum;
			for(y=j+1;y<i;y++)
				ten=ten/p;
			q=ten%p;
			if(q<=9)
				printf("%c",q+48);
			if(q>9)
				printf("%c",q+55);
		}
	}
		return 0;
}
int main(int argc, char* argv[])
{
    int a[50],i,z1,z2,n;
    long x,z;
    char s1[3],s2[50],s3[3],s[50];
	scanf("%s %s %s",s1,s2,s3);
    z1=atoi(s1);z2=atoi(s3);z=1;x=0;
         n=strlen(s2);
	for (i=0;i<n;i++)
		if ((s2[i]>='A')&&(s2[i]<='Z')) s2[i]=s2[i]+32;

    for (i=0;i<n;i++)
	{
        if (s2[i]<='9') a[i]=s2[i]-'0';
        else a[i]=s2[i]-'a'+10;
    }
	for (i=n-1;i>=0;i--)
	{
		x=x+a[i]*z;
		z=z*z1;
	}
	i=0;
	while (x!=0)
	{
		a[i]=x%z2;
		i++;
		x=(x-x%z2)/z2;
	}
	if (i==0) printf("0");
	else
	{
	n=i-1;
	for (i=n;i>=0;i--)
                   if (a[i]<10) s[n-i]='0'+a[i];
		else	s[n-i]='A'+a[i]-10;
        s[n+1]='\0'; 
		puts(s);
	}
	return 0;
}
int main()
{
	int i,a,b,c=0,t[100],l,k[100];
	char s[100];
	scanf("%d %s %d",&a,s,&b);
	l=strlen(s);
	for(i=0;i<l;i++)
	{
		if((s[i]>='a')&&(s[i]<='z'))
		t[i]=s[i]-87;
		else if((s[i]>='A')&&(s[i]<='Z'))
		t[i]=s[i]-55;
		else
			t[i]=s[i]-48;
	}
	for(i=l-1;i>-1;i--)
	{
		c+=t[i]*pow(a,l-1-i);
	}
	for(i=1;;i++)
	{

		k[i]=c%b;

		if(k[i]>9)
			k[i]=k[i]+55;
		if(c<b)
			break;
		int h=c/b;
		c=h;
	
	}
	for(;i>0;i--)
	{	
		if(k[i]>=55)
			printf("%c",k[i]);
		else
		printf("%d",k[i]);
	}
	return 0;
}
int main()
{
	long convert_to10(char str[], int a);
	void convert_from10(long a, int b);
	int a, b;
	char str[100];
	cin >> a >> str >> b;

	convert_from10(convert_to10(str, a), b);
	return 0;
	
}

long convert_to10(char str[], int a)
{
	int len, i;
	long num10 = 0;
	len = strlen(str);
	for (i = 0; i < len; i++)
	{
		if (str[i] >= 'A' && str[i] <= 'Z')
			num10 = num10 * a + str[i] - 'A' + 10;
		if (str[i] >= 'a' && str[i] <= 'z')
			num10 = num10 * a + str[i] - 'a' + 10;
		if (str[i] >= '0' && str[i] <= '9')
			num10 = num10 * a + str[i] - '0';
	}
	return num10;
}


void convert_from10(long a, int b)
{
	char str[10000];
	int i, j, k, len;
	for (i = 0;;i++)
	{
		k = a % b;
		if (k < 10)
			str[i] = k + '0';
		else
			str[i] = k - 10 + 'A';
	    a = (a - k) / b;
		len = i;
		
		if (a == 0)
		{
			for (j = len; j >= 0; j--)
				cout << str[j];
			break;
		}

	}
}
long p(int r,int s);
int main()
{
	char num[1000]={0},numx[1000]={0};               //?????????num????a???n?numx?????b???
	int n[1000]={0},x[1000];                         //n???num??????????
	int a,b,j=0;
	long c;
	unsigned long N=0;                               //N?n??????
	cin>>a;
	getchar();                                       //?????
	cin.getline(num,1001,' ');                       //??n??????????num?
	cin>>b;
	for (int i=0;i<strlen(num);i++)                  //?num??????????
	{
		if (num[i]>=65&&num[i]<91)                   //????????????????
			n[i]=num[i]-65+10;
        else if (num[i]>=97&&num[i]<123)             //????????????????
			n[i]=num[i]-97+10;
		else n[i]=num[i]-'0';                        //?????????????
		N=N+n[i]*p(a,strlen(num)-i-1);               //??N
	}
    c=N; 
	if (c==0)                                        //?N?0???????
		cout<<"0";
	while (c!=0)                                     //?unsigned long??N ???b????????????numx?
	{
		x[j]=c%b;
		c=c/b;
		j++;
	}
	for (int i=j-1;i>=0;i--)                     //?numx????
	{
		if (x[i]>=10)                             //??????10???????
			numx[i]=x[i]+'A'-10;
		else
			numx[i]=x[i]+'0';
	    cout<<numx[i];                               //??
	}
	return 0;
}

long p(int r,int s)                         //p?????????
{
	long ans=1;
	for (int k=0;k<s;k++)
		ans=ans*r;
	return (ans);
}
int main()
{
    int n=-1,a=0,b=0,num,s=0,i=0,j=1;//??????n ???a ????b  ??????????num ??????????s ????i,j
    char numb[32];//?????? 
    cin >>a;//????? 
    numb[0]=cin.get();
    do  
        {n++;}
    while ((numb[n]=cin.get())!=' '); //?????? 
    for (i=0;i<n;i++)//???????????
       {
          num=1;
          if (numb[i]<58)
             numb[i]=numb[i]-48;
          else if (numb[i]>96)
                  numb[i]=numb[i]-87;
               else numb[i]=numb[i]-55;                                
          for (j=1;j<n-i;j++) num=num*a;
          s+=num*numb[i];     
       }
    cin >>b;
    n=0;
    do
       {
          num=s%b;
          if (num<10)
             numb[n]=num+48;
          else 
             numb[n]=num+55;   
          n++;
          s=s/b;
       }
    while (s!=0) ; 
    for (n=n-1;n>=0;n--) cout <<numb[n];//???????? 
    return 0;    
}
int main( )
{
	int a,b,k,length,i=0,j,n=0,m=0,t=1;
	char c,str[34],str1[34];
	cin>>a>>str>>b;
	length=strlen(str);
	for (i=1;i<=length;i++)
	{
		if ((str[i-1]>=48)&&(str[i-1]<=57)) k=str[i-1]-48;
		else if ((str[i-1]>=65)&&(str[i-1]<=90)) k=str[i-1]-55;
		else if ((str[i-1]>=97)&&(str[i-1]<=122)) k=str[i-1]-87;
		m=length-i;
		t=1;
		for (j=1;j<=m;j++)
			t=t*a;
		n=n+k*t;
	}
	i=0;
	do
	{
		k=n%b;
		n=n/b;
		if ((k>=0)&&(k<=9)) str1[i]=k+48;
		else if (k>=10) str1[i]=k+55;
	    i++;
	} while (n!=0);
    for (j=i;j>=1;j=j-1)
		cout<<str1[j-1];
	return 0;
}
main()
{
    int i,j;
    int n,m,a=0,b[1000];
    char str[1000],c;
    scanf("%d%c%s%c%d",&n,&c,str,&c,&m);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]>=48&&str[i]<=57)
            a=a*n+(str[i]-'0');
        if(str[i]>=97&&str[i]<=122)
            a=a*n+(str[i]-'a'+10);
        if(str[i]>=65&&str[i]<=90)
            a=a*n+(str[i]-'A'+10);
    }
        for(i=1;;i++)
    {
        
        b[i]=(a%(int)pow(m,i))/(int)pow(m,i-1);
        a=a-a%(int)pow(m,i);
        if(a==0)
            break;
    }
    for(j=i;j>=1;j--)
    {
        if(b[j]>=0&&b[j]<10)
            printf("%c",b[j]+'0');
        else
            printf("%c",b[j]-10+'A');
    }
    }
void main()
{
	char c[101],d[101];
	int a,b,i,j,p,x;
	long n=0;
	scanf("%d %s %d",&a,c,&b);
	for(i=0;i<=100;i++)
	{
	if(c[i]==0)break;
	else if(c[i]<='Z'&&c[i]>='A')c[i]=c[i]-'A'+10;
	else if(c[i]<='z'&&c[i]>='a')c[i]=c[i]-'a'+10;
	else if(c[i]<='9'&&c[i]>='0')c[i]=c[i]-'0';
	}x=i;
	for(i=0;i<=x-1;i++)
	{
		p=1;
		for(j=1;j<=x-i-1;j++)
		{
			p=p*a;
		}
		n=n+p*c[i];

	}
	i=0;
	while((n/b)!=0)
	{
		i++;
		d[i]=n%b;
		n=n/b;
	}
	d[i+1]=n%b;
	i++;
	for(j=1;j<=i;j++)
	{
		if(d[j]>=10){d[j]=d[j]-10+'A';}
		else d[j]=d[j]+'0';
	}
	for(j=i;j>=1;j--)
	{
		 printf("%c",d[j]);
	}

}
int main(){
	int i,j;
	int a,b;
	long mid=0;
	char out[100];
	cin>>a;
	
	cin.get();
	char tempC;
	int temp;
	while((tempC = cin.get()) != ' '){
		
		if(tempC>='0' && tempC<='9')
			temp = tempC-'0';
		else if(tempC>='a' && tempC<='z')
			temp = tempC-'a'+10;
		else if(tempC>='A' && tempC<='Z')
			temp = tempC-'A'+10;
		mid *= a;
		mid += temp;
	}
	
	cin>>b;
	i = 0;
	while(mid > 0){
		temp = mid%b;
		if(temp >9){
			tempC = temp-10+'A';
		}
		else{
			tempC = temp+'0';
		}
		out[i]=tempC;
		++i;
		mid /= b;
	}
	if(i==0)
		cout<<"0"<<endl;
	else{
		for(j = i-1;j>=0;--j){
			cout<<out[j];
		}
		cout<<endl;
	}
	cin>>a;
	return 0;
}
long f1(char n[500], int a, int l)
{
	long m;
	int i, j, k, c[500] = {0};
	m = 0;
	k = 0;
    for (i = l - 1; i >= 0; i--)
		if (n[i] <= '9' && n[i] >= '0')
			c[i] = n[i] - '0';
		else
		    if (n[i] <= 'Z' && n[i] >= 'A')
                c[i] = n[i] - 'A' + 10;
			else
		        if (n[i] <= 'z' && n[i] >= 'a')
                    c[i] = n[i] - 'a' + 10;
	for (i = l - 1; i >= 0; i--)
	{
		k = c[i];
		for (j = 1; j < l - i; j++)
			k = k * a;
        m = m + k;
	}
	return m;
}
void f2(long m, int b)
{
	int a[500] = {0}, i = 0, j;
	char c[500];
	do
	{
		i++;
		a[i] = m % b;
		m = m / b;
	}while(m != 0);
    for (j = 1; j <= i; j++)
		if (a[j] <= 9 && a[j] >= 0)
			c[j] = '0' + a[j];
		else
			c[j] = a[j] + 'A' - 10;
    for (j = i ; j > 0; j--)
		cout << c[j];
}
int main()
{
	int a, b, l;
	long m;
	char n[500];
	cin >> a >> n >> b;
	l = strlen(n);
	m = f1(n, a, l);
    f2(m, b);
	return 0;
}
int main()
{
	int a,b;
	char c[PI];

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

	int len;
	len=strlen(c);
	int i;
	for (i=0;i<len;i++)
	{
		if (c[i]>='a'&&c[i]<='z')
		{
			c[i]=c[i]-32;
		}
	}


	long int sum=0;
	i=0;
	int tmp;
	int j=len;
	while (i<len)
	{
		if (c[i]>=65&&c[i]<=90)
		{
			tmp=(c[i]-55)*(long int)pow(a,j-1);
		}
		if (c[i]>=48&&c[i]<=57)
		{
			tmp=(c[i]-48)*(long int)pow(a,j-1);
		}
		sum+=tmp;
		j--;
		i++;
	}


	char d[PI];
	
	i=0;
	if (sum==0)
		printf("0");
	while (sum!=0)
	{
		d[i]=sum%b;
		sum=sum/b;
		i++;
	}
	for (j=i-1;j>=0;j--)
	{
		if (d[j]>=0&&d[j]<=9)
		{
			printf("%c",d[j]+48);
		}
		if (d[j]>=10&&d[j]<=35)
		{
			printf("%c",d[j]+55);
		}
	}
	return 0;
}
int main(){
	int a,b,l,i,j,k=0,d[255];
	char c[255];
	long num=0;
	scanf("%d%s%d",&a,c,&b);
	l=strlen(c);
	for(i=0;i<l;i++){
		if(c[i]>='0' && c[i]<='9') d[i]=c[i]-'0';
		else if(c[i]>='a' && c[i]<='z') d[i]=c[i]-'a'+10;
		else d[i]=c[i]-'A'+10;
	//	printf("%d ",d[i]);
	}
	for(j=0;j<l;j++){
		num+=d[j]*pow(a,i-1);
		i--;
	//	printf("%ld ",num);
	}
//	printf("%d ",num);
	if(num==0)printf("0\n");
	else{
	while(num>0){
		d[k]=num%b;
		if(d[k]>=0 && d[k]<=9) c[k]=d[k]+'0';
		else if(d[k]>=10 && d[k]<='z'-'a'+10) c[k]=d[k]-10+'A';
		num=num/b;
		k++;
	}
	k--;
	while(k>0){
		printf("%c",c[k]);
		k--;
	}
	printf("%c\n",c[k]);
	}
	return 0;
}
int main()

{

    char input[100],output[100];

    int number[100],remainder[100],sum=0,a,b,i,t,l,g=1;

    scanf("%d %s %d",&a,input,&b);
	l=strlen(input);

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

  {

   if(input[i]>='A' && input[i]<='Z')

      number[i]=input[i]-'A'+10;

   if(input[i]>='a' && input[i]<='z')

      number[i]=input[i]-'a'+10;

   if(input[i]>='0' && input[i]<='9')

      number[i]=input[i]-'0';

}  
	for (i=0;i<l;i++)
	{
		g=1;
		for (t=0;t<i;t++)
		{
			g*=a;
		}
		 sum=sum+number[l-1-i]*g;
	}

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

{

                  remainder[i]=sum%b;
                  
                  if(sum/b==0)

                       break;

                 sum=sum/b;

}
  t=i+1;

  for(i=t-1;i>=0; i--)

{

       if(remainder[i]>=0 && remainder[i]<=9)

    output[t-i-1]=       remainder[i]+'0';

    if(remainder[i]>=10 && remainder[i]<=35)

    output[t-i-1]=       remainder[i]+'A'-10;

}
  output[t]=0;
printf("%s\n",output);

return 0;

}
int main ()
{ 
	int number = 0;
	int inum[1000] ;
	int b, e;
	int p = 0;
	char cnum[1000];
	cin >> b >> cnum >> e;
	int len = strlen (cnum);
	int i;
	for (i = len - 1; i >= 0; i--)
	{
		if ( cnum [i] >= '0' && cnum[i] <= '9')
			inum[p++] = cnum[i] - '0';
		else if (cnum[i] >= 'a' && cnum[i] <= 'z')
			inum[p++] = cnum[i] - 'a' + 10;
		else inum[p++] = cnum[i] - 'A' + 10;
	}
	for (i = p - 1; i > 0; i--)
	{
		number = (number + inum[i]) * b;
	}
	int temp;
	number += inum[0];
	if (number == 0)
		cout << "0" << endl;
	for (i = 0; number > 0; i++)
	{
		temp = number % e;
		number = number / e;
		if (temp <= 9 && temp >= 0)
			cnum[i] = temp + '0';
		else 
			cnum[i] = temp + 'a' - 42;
	}
	for (p = i - 1; p >= 0; p--)
		cout << cnum[p];
	cout << endl;
	return 0;
}
void main()
{
	int x,y;
	scanf("%d",&x);
	char a[100];
	scanf("%s",a);
	scanf("%d",&y);
	int i,n=0;
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]>='0'&&a[i]<='9')
			n=n*x+a[i]-'0';
		else if(a[i]>='A'&&a[i]<='Z')
			n=n*x+a[i]-'A'+10;
		else if(a[i]>='a'&&a[i]<='z')
			n=n*x+a[i]-'a'+10;
	}
	int b[100];
	int j=0,k;
	if(n==0)
		printf("0");
	else while(n>0)
	{
		b[j]=n%y;
		j++;
		n=n/y;
	}
	for(k=j-1;k>=0;k--)
	{
		if(b[k]<10)
			printf("%d",b[k]);
		if(b[k]>=10)
			printf("%c",b[k]+55);
	}
}
int main()
{
	int a,b;
	cin>>a;
	char num[12000];
	cin>>num;
	cin>>b;
	int ln=strlen(num);
	int sum=0;
	for(int i=0;i<ln-1;i++)
	{
		if(num[i]>='0'&&num[i]<='9')
			sum=(sum+(num[i]-'0'))*a;
		if(num[i]>='a'&&num[i]<='z')
			sum=(sum+(num[i]-'a'+10))*a;
		if(num[i]>='A'&&num[i]<='Z')
			sum=(sum+(num[i]-'A'+10))*a;
	}
	if(num[ln-1]>='0'&&num[ln-1]<='9')
		sum+=num[ln-1]-'0';
	if(num[ln-1]>='a'&&num[ln-1]<='z')
		sum+=num[ln-1]-'a'+10;
	if(num[ln-1]>='A'&&num[ln-1]<='Z')
		sum+=num[ln-1]-'A'+10;
	int j=0;
	char output[11000];
	if (sum==0)
		cout<<'0'<<endl;
	else
	{
		while(sum!=0)
		{
			if(sum%b>=0&&sum%b<=9)
				output[j]=sum%b+'0';
			else if(sum%b>=10)
				output[j]=sum%b+'A'-10;
			sum=sum/b;
			j++;
		}
		for(int i=j-1;i>=0;i--)
			cout<<output[i];	
	}
	return 0;
}
int main ()
{
	char string1[1000],string2[1000];
	int b,c=0,i,j=0,temp;
	float a,d;
	cin>>a>>string1>>d;
	b=strlen(string1);
	for(i=0;i<b;i++)
	{
		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;
	int e;
	if(c==0)
		cout<<'0'<<endl;
	while(c!=0)
	{
		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];
	cout<<endl;
	return 0;
}
int i;
int zh(char c[],int i)
{
	if ((c[i] >= 48) && (c[i] <= 57))
		return c[i]-48;
	if ((c[i] >= 65) && (c[i] <= 90))
		return c[i]-55;
	if ((c[i] >= 97) && (c[i] <= 122))
		return c[i]-87;
}
char ch(int a)
{
	if (a <= 9)
		return a+48;
	if( a > 9)
		return a+55;
}
int main()
{
	int a, b, i, j, k, l, s = 0;
	char c[99], d[99];
	for (k = 0; k<= 99; k++)
	{
		c[k] = ' ';
	    d[k] = ' ';
	}
	cin >> a >> c >> b;
	for (i = 0; c[i]!='\0'; i++)
	{
		s = a * s + zh(c,i);
	}
	for (j = 0; j <= 99; j++)
	{
		d[j] = ch ( s % b );
		s = s / b;
		if (s == 0)
			break;
	}
	for (l = 30; l >= 0; l--)
		if (d[l] != ' ')
		cout << d[l];
	return 0;
}