semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*

?? 
?????????????????2???36?????????long?????????? 
???????????0?1?...?9?a?b?...?z????0?1?...?9?A?B?...?Z??
 
???? 
?????????????a?n?b?a?????n ?a?????b????a????n???b????? 
a?b???????2 ? a?b < 36?
 
???? 
???????????????????b?????????????????????0?1?...?9?A?B?...?Z??
 
???? 
15 Aab3 7
 
???? 
210306
 
?? 
??????????????? 
*/


int dec(char nf[100],int ii,int sysf)     //?????????????
{                                         //nf???????????nf?0??nf?ii??????sysf?????????
	int sum=0,exp=1;
	int k,j;
	for (k=ii;k>=0;k--)
	{
		if (ii!=k)  exp=exp*sysf;
		sum+=((int)nf[k])*exp;
	}
	return sum;
}


void trans(char outf[100],int pos,int decf,int sysf) //?????????????????????????????????????????
{  //outf????????????outf?99??outf?0????pos?????????????decf??????????sysf??????
	int rem,t;
	while((decf!=0)&&(pos>=0))
	{
	    rem=decf%sysf;   //rem???????????
	    decf=(int)(decf/sysf);   //decf??????????
	    if ((rem>=0)&&(rem<=9))   outf[pos]=rem+48;
	    else if ((rem>=10)&&(rem<=35))  outf[pos]=rem+55;
		pos--;
	}
	for (t=pos+1;t<=99;t++)     cout<<outf[t];
	cout<<endl;
}

int main()
{
	int a,b,i=0,k,temp;
	char n[100],c;
	char output[100];
	cin>>a;
	getchar();
	while (c=getchar(),c!=' ')
	{
		n[i]=c;
		i++;
	}
	i--;
	cin>>b;
	for (k=0;k<=i;k++)
	{
		if ((n[k]>='a')&&(n[k]<='z'))  n[k]-=87;
		else if ((n[k]>='A')&&(n[k]<='Z'))  n[k]-=55;
		else if ((n[k]>='0')&&(n[k]<='9'))  n[k]-=48;
	}
	temp=dec(n,i,a);
	if (temp==0)  cout<<"0"<<endl;
	else   trans(output,99,temp,b);
    return 0;
}
void run(int base1, char a[50], int base2)
{
	char d[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 len = strlen(a);
	int b[50] = {0}, c[50] = {0}, s = 0, i =0;
	for (i = 0; i < len; i++)
	{
		if (a[i] >= 'A' && a[i] <= 'Z')
			b[i] = a[i] - 55;
		else
		{
			if (a[i] >= 'a' && a[i] <= 'z')
				b[i] = a[i] - 87;
			else
				b[i] = a[i] - '0';
		}
		s += b[i] * pow(base1 + 0.0,len - i - 1);
	}
	i = 0;
	while (s > 0)
	{
		c[i++] = s % base2;
		s = s / base2;
	}
	if (i == 0)
	{cout << "0";}
	else
	{
		i--;
		for (; i >= 0; i--)
			cout << d[c[i]];
	}
}
int main()
{
	int base1, base2, i;
	char a[50];
	for (i = 0; i < 50; i++)
	{
		a[i] = '\0';
	}
	cin >> base1 >> a >> base2;
	run (base1,a,base2);
	return 0;
}
int main()
{
	unsigned long shuz1,shuz2,total=0; 
	int i=0,j=0,k=0,length; 
	char n[33],result[33]; 
	cin>>shuz1>>n>>shuz2;
	for(i=0;i<33;i++)
	{
		if(n[i]=='\0')
		{
			 length=i;
		break;
		}
	}
	for(i=0;i<length;i++)
	{
		if(n[i]>60&&n[i]<93)
			total+=(n[i]-55)*pow((double)shuz1,length-i-1);
		else if(n[i]>93)
			total+=(n[i]-87)*pow((double)shuz1,length-i-1);
		else
			total+=(n[i]-48)*pow((double)shuz1,length-i-1);
	}
        if (total == 0) {
            cout << 0 << endl;
            return 0;
        }
	for(j=0;total>0;j++)
	{
		result[j]=total%shuz2;
		total=(total-result[j])/shuz2;
	}
	for(k=0;k<33;k++)
	{
	if(result[k]<10)
		result[k]=result[k]+48;
	else 
		result[k]=result[k]+55;
	}
	for(k=j-1;k>=0;k--)
		cout<<result[k];
        cout << endl;
	return 0;
}
int main()
{
 int n,m;
 int i,k,num=0;
 char in[255],out[255]="0";
 char a2[128];
 char a[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 for(i=0;i<='9';i++)
  a2[i]=i-'0';
 for(i='a';i<='z';i++)
  a2[i]=i-'a'+10;
 for(i='A';i<='Z';i++)
  a2[i]=i-'A'+10;
 
 scanf("%d%s%d",&n,in,&m);

 for(i=0;in[i]!='\0';i++) 
  num=num*n+a2[in[i]];
 
 if(num==0)
  k=1;
 else k=0;

 while(num>0)
 {  
  out[k]=a[num%m];
  k++;
  num=num/m;
 }

 for(i=k-1;i>=0;i--)
  printf("%c",out[i]);
 printf("\n");
 return 0;
}
void main()
{
	int a,b,i,p,len;
	long int w=0;
	char s[1000],s1[1000];
	int zs[1000],zs1[1000];
	scanf("%d %s %d",&a,s,&b);
    len=strlen(s);
    
	for(i=0;i<len;i++)
	{
		if(s[i]>=48&&s[i]<=57)
		zs[i]=s[i]-48;
	else if(s[i]<=90&&s[i]>=65)
		zs[i]=s[i]-55;
	else if(s[i]<=122&&s[i]>=97)
		zs[i]=s[i]-87;
        w=w*a+zs[i];
	}
	for(i=0;i<1000;i++)
	{
		p=i;
		zs1[i]=w%b;
	    w=w/b;
		if(w==0)
			break;

	}

	  
	for(i=0;i<=p;i++)
	{
		if(zs1[i]>=0&&zs1[i]<=9)
			s1[i]=zs1[i]+48;
		else if(zs1[i]>=10)
			s1[i]=zs1[i]+55;
		else break;
		
	}
	
	for(i=p;i>=0;i--)
		printf("%c",s1[i]);
}
//*******************************************************
//*11.11??  ????                                  *
//*?????  ?? 1100012844                          *
//*???2011?11?11?                                 *
//*******************************************************
int atoDec(int i, char a[])
{
	int Dec = 0, k;
	for (k = 0; a[k] != '\0'; k++)
	{
		if (a[k] >= '0' && a[k] <= '9')
			Dec = Dec * i + a[k] - '0';
		if (a[k] >= 'A' && a[k] <= 'Z')
			Dec = Dec * i + a[k] - 'A' + 10;
		if (a[k] >= 'a' && a[k] <= 'z')
			Dec = Dec * i + a[k] - 'a' + 10;
	}
	return Dec;
}
int main()
{
	char o[100], f[100];
	int a, b, temp, r, j = 99, m;
	cin >> a;
	cin.get();
	cin >> o;
	cin >> b;
	temp = atoDec(a, o);
	if (temp != 0)
	{
		while (temp != 0)
		{
			r = temp % b;
			if (r < 10)
			{
				f[j] = r + '0';
				j--;
			}
			else
			{
				f[j] = r - 10 + 'A';
				j--;
			}
			temp = temp / b;
		}
		for (m = j + 1; m <= 99; m++)
			cout << f[m];
	}
	else
		cout << "0";
	return 0;
}
void main()
{	
	int i,j,k,l,a,b,c,s,m=0;
	char n[32],x[32];
	scanf("%d %s %d",&a,n,&b);
	l=strlen(n);
	for(i=0;i<l;i++)
	{
		for(j=1,s=1;j<=i;j++)s=s*a;
		if(n[l-i-1]>=65&&n[l-i-1]<=90) k=n[l-i-1]-55;
		else
			if(n[l-i-1]>=97&&n[l-i-1]<=122)	k=n[l-i-1]-87;
		else k=n[l-i-1]-48;
		k=k*s;
		m=m+k;
	}
	for(i=0;;i++)
	{
		c=m%b;	
		if(c<=9) x[i]=c+48;
		else x[i]=c+55;
	if(m/b==0) break;
	m=m/b;
	}
	for(j=0;j<=i;j++)
	printf("%c",x[i-j]);
}
int ctruth(char);
char itruth(int);
int main()
{
    int a,b,i,j,k,S=0,len;
	
	char m[32],n[32];
	    
	   cin>>a>>m>>b;
        len=strlen(m);	
	for(i=0;m[i]!='\0';i++)
		if(m[i]<=90&&m[i]>=65)m[i]+=32;
	for(i=0;i<=len-1;i++)
		S+=ctruth(m[len-i-1])*pow(a,i);
	   
	if(S<b)cout<<itruth(S);
	else{
	    k=S;
		for(i=0;k>=b;i++)
	{
		n[i]=itruth(k%b);
		k=k/b;
		}n[i]=itruth(k);
	  for(j=i;j>=0;j--)
		  cout<<n[j];}
      return 0;
}
 int ctruth(char a)
 {	
	 int t;
	 if(a>=48&&a<=57)t=a-48;
	 if(a>=97&&a<=122)t=a-87;
	 return t;
 }
 char itruth(int a)
 {
	 char c;
	 if(a>=0&&a<=9)c=a+48;
	 if(a>=10&&a<=35)c=a+55;
	 return c;
 }
int main(int argc, char* argv[])
{
	char s[10];
	int a, b;
	scanf("%d %s %d",&a,s,&b);
	int i,sum=0,d;
	d=strlen(s);
	for(i=0;i<d;i++){
		if(s[i]>47&&s[i]<58)
			sum=sum*a+(s[i]-48);
		if(s[i]>64&&s[i]<91)
			sum=sum*a+(s[i]-55);
		if(s[i]>96&&s[i]<123)
			sum=sum*a+(s[i]-87);
	}
	char ss[20];
	int c,e=0;
	for(i=0;;i++){
		c=sum%b;
		sum=sum/b;
		if(c>=0&&c<10)
			ss[i]=c+48;
		if(c>9&&c<36)
			ss[i]=c+55;
		e++;
		if(sum==0)
			break;
	}
	for(i=e;i>0;i--)
		printf("%c",ss[i-1]);
	return 0;
}
void main()
{
int i,n,m,l,k=1,c[100],e,j;
long int a=0;
char s[100],v[100];
scanf("%d",&n);
scanf("%s",s);
scanf("%d",&m);
l=strlen(s);
for(i=0;i<l;i++)
{
	if (s[i]>='a'&&s[i]<='z') c[i]=s[i]-87;
	if (s[i]>='A'&&s[i]<='Z') c[i]=s[i]-55;
	if (s[i]>='0'&&s[i]<='9') c[i]=s[i]-48;
}
for(i=l-1;i>=0;i--)
{a=a+c[i]*k;
if (i==0) break;
k=k*n;}
j=0;
if (a==0) {printf("0");goto end;}
while(a>0)
{
e=a%m;
if(e>=0&&e<=9) v[j]=e+48;
if(e>=10) v[j]=e+55;
j++;
a=a/m;
}
for(i=j-1;i>=0;i--)
	printf("%c",v[i]);
end:;
}
/*
2010 10 22 ??
????
?? 1000012760
*/



int main() {
	char s[32];													//??????s[32]???????(???????32)
	int t[32], ex, i, j, p, n= 0, a, b, size;					//???????t[32]??ex????i????j?s????????p???????n???a???b???????size


	cin >> a >> s >> b;											//???????a??????s??????b
	size = strlen(s);											//?????????size

	for(i = 0; i < 32; ++ i) {									//?s???????????10???
		if(s[i] >= 48 && s[i] <= 57) t[i] = s[i] - '0';
		else if(s[i]>=65&&s[i]<=90) t[i]=s[i]-55;
		else t[i]=s[i]-87;
	}

	for(i=size-1;i>=0;i--) {									//????????????a???
        p=a;
		ex=size-i-1;											//?????i???ex

		if(ex == 0) p=1;
		else 
			for(j=1; j<ex; j++)									//?????i?????????a???p
				p=p*a;
		n=n+p*t[i];												//???????10?????
	}
    
    for(i=0; i<32; i++)											//?s?????????
		s[i]=0;
	
    for(i=0;i<32;i++) {											//???/??????????s
        t[i]=n%b;
		n=(n-(n%b))/b;
		if(t[i]>=10)
			s[i]=t[i]+55;
		else
			s[i]=t[i]+48;
		if(n==0) break;
	}

	for(i=31;i>=0;i--) {										//??????s???????
         if(s[i]!=0)
		 cout<<s[i];
	}

	return 0;
}
/*
 * ????.cpp
 * ???????????????????2???36???
 * ????: 2010-11-9
 * ??: ??
 */

//?????


//???
int main() {

	//??a, n, b???????
	char n[101];
	int a, b, length, i, j, temp; //length????????temp???
	long int value = 0, product; //value???????product??????
	cin >> a >> n >> b;

	//?a???n???????????value
	length = strlen(n);

	for (i = 0; i < length; i++) {
		product = 1;

		//?n[i]?????A-Z????????10-35
		if (n[i] >= 65 && n[i] <= 90) {
			temp = n[i] - 55;
		}

		//?n[i]?????????????10-35
		else if (n[i] >= 97 && n[i] <= 122) {
			temp = n[i] - 87;
		}

		//?n[i]?'0'-'9'????????0-9
		else {
			temp = n[i] - 48;
		}

		//???????value
		for (j = 0; j < length - i - 1; j++) {
			product *= a;
		}
		value += temp * product;
	}

	//?value???b???????????
	if (value == 0) {

		//??n=0????0?????
		cout << "0" << endl;
		return 0;

	} else {
		//?n??0???value??b?????????????m?
		char m[101];
		for (i = 0;; i++) {
			temp = value % b;
			if (value == 0) {
				break;
			} else if (temp >= 0 && temp <= 9) {
				m[i] = temp + 48;
			} else {
				m[i] = temp + 55;
			}
			value /= b;
		}

		//?m????????
		length = i;
		for (i = length - 1; i >= 0; i--) {
			cout << m[i];
		}
	}

	return 0; //????
}
int main()
{    
     int n,m,x=0,sum=0,i;
     cin>>n;
     char a[110],b[110];
     cin>>a;
     cin>>m;
     for (i=0;i<strlen(a);i++)
     {
     if (a[i]>='0'&&a[i]<='9')
     x=a[i]-'0';
     if (a[i]>='A'&&a[i]<='Z')
     x=10+a[i]-'A';
     if(a[i]>='a'&&a[i]<='z')
     x=10+a[i]-'a'; 
     sum=sum*n+x;}
     i=0;
     do 
     {
     b[i]=sum%m;
     if (b[i]>=10)
     b[i]=b[i]-10+'A';
     else b[i] += '0';
     sum=sum/m;
     i++;
     }while(sum>0);
     for (int k=i-1;k>=0;k--)
     cout<<b[k];
     return 0;
}
char Change(int x);
int change(char x);
int main()
{
	int a,b,i,length,Length;
	char num[30],NUM[100];
	long number=0;
	cin>>a>>num>>b;
	for(i=0;i<30;i++)
	{
		if(num[i]!='\0') ;
		else break;
	}
	length=i;
	for(i=0;i<length;i++)
	{
          number+=change(num[length-i-1])*pow((double)a,(double)i);
	}
	for(i=0;i<100&&number>=b;i++)
	{
		NUM[i]=Change(number-(number/b)*b);
		number=number/b;
	}
	Length=i+1;
	NUM[i]=Change(number);
	for(i=0;i<Length;i++)
	{
		cout<<NUM[Length-1-i];
	}
    return 0;
}
 int change(char x)
 {
	if(x>=48&&x<=57) return(x-48);
	if(x>=65&&x<=90) return(x-55);
    if(x>=97&&x<=122) return(x-87);
 }
 char Change(int x)
 {
	 if(x<=9) return(x+48);
	 if(x>=10) return(x+55);
 }
main()
{
	long int a,b,i=0,x=0,k;  char c[20], n[20];
	scanf("%d", &a);
	scanf("%s", &c);
	scanf("%d", &b);
    while(c[i]!='\0')
	{
		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;
		i++;
	}
	for(k=0;k<=i-1;k++)
	{
		x=a*x+c[k];
	}
	i=0;
	if(x==0) printf("0");
	while(x!=0)
	{
		n[i]=x%b;
		x=x/b;
		if(n[i]>=10)
			n[i]=n[i]+55;
		else n[i]=n[i]+48;
		i++;
	}
	n[i]='\0';
	for(i=0;;i++)
		if(n[i]=='\0') break;
	for(k=i-1;k>=0;k--)
		printf("%c",n[k]);
	printf("\n");
}
void main()
{
	int a,b,t,i,j,n;
	char s1[33],s2[33],temp;
	scanf("%d %s %d",&a,s1,&b);
	n=strlen(s1);
	t=0;
	for(i=0;i<n;i++)
	{
		if(s1[i]>='0'&&s1[i]<='9') t=t*a+(s1[i]-'0'); 
		if(s1[i]>='a'&&s1[i]<='z') t=t*a+(s1[i]-'a'+10); 
		if(s1[i]>='A'&&s1[i]<='Z') t=t*a+(s1[i]-'A'+10);
	}
	i=0;
	do
	{
		if(t%b>=0&&t%b<=9) s2[i]=t%b+'0'; 
		if(t%b>=10&&t%b<36) s2[i]=t%b-10+'A';
		t=t/b;
		i++;
	}
	while(t!=0);
	s2[i]='\0';
	for(j=i-1;j>=i/2;j--) 
	{
		temp=s2[j];
		s2[j]=s2[i-1-j];
		s2[i-1-j]=temp;
	}
	printf("%s",s2);
}
void main()
{
	int a,b,len,i,nn[100],c,k=0;
	long m=0;
	char n[100],nnn[100];
	scanf("%d%s%d",&a,n,&b);
	len=strlen(n);
	for(i=0;i<len;i++)
	{
		if(n[i]>='A' && n[i]<='Z')
			nn[i]=n[i]-'A'+10;
		else if(n[i]>='a' && n[i]<='z')
			nn[i]=n[i]-'a'+10;
		else if(n[i]>='0' && n[i]<='9')
			nn[i]=n[i]-'0';
		m=m*a+nn[i];
	}
	i=0;
	while(m!=0)
	{
		nnn[i]=m%b;
		m=m/b;
		i++;
	}
	c=i-1;
	for(i=c;i>=0;i--)
	{
		if(nnn[i]==0)
			k++;
	}
	if(k==c+1)
	{
			printf("0");
	}
	else
	{
	for(i=c;i>=0;i--)
	{
		if(nnn[i]>=0 && nnn[i]<=9)
			printf("%d",nnn[i]);
		else if(nnn[i]>=10)
		{
			nnn[i]=nnn[i]-10+'A';
			printf("%c",nnn[i]);
		}
	}
	}
	printf("\n");
}
int main()
{
	char n[100],y[100];
	int m[100],x[100];
	int a,b,ten=0,i=0,j=0,k,l;
	cin>>a>>n>>b;
	l=strlen(n);
	for(i=0;i<l;i++)
	{
		if(n[i]>='0'&&n[i]<='9')
			m[i]=n[i]-48;
		else if(n[i]>='A'&&n[i]<='Z')
			m[i]=n[i]-55;
		else if(n[i]>='a'&&n[i]<='z')
			m[i]=n[i]-87;
		double pow(double x,double y);
		ten=ten+m[i]*(int)pow((double)a,(double)(l-1-i));
	}
	if(ten==0)
		cout<<"0";
	while(ten!=0)
	{
		x[j]=ten%b;
		ten=ten/b;
		if(x[j]>=0&&x[j]<=9)
			y[j]=x[j]+48;
		else if(x[j]>=10&&x[j]<=35)
			y[j]=x[j]+55;
		j=j+1;
	}
	for(k=j-1;k>=0;k--)
		cout<<y[k];
	cout<<endl;
	return 0;
}
int main()
{
	long int a,b,i,m,j=0,c=0,d=0,k=0;
	char s[100];
	scanf("%d %s %d",&a,s,&b);
	char x[100];
	if(s[0]!=0)
	{
        for(i=0;s[i]!='\0';i++)
		{
		    if(s[i]=='9')
			s[i]=9;
		else if(s[i]=='8')
			s[i]=8;
		else if(s[i]=='7')
			s[i]=7;
		else if(s[i]=='6')
			s[i]=6;
		else if(s[i]=='5')
			s[i]=5;
		else if(s[i]=='4')
			s[i]=4;
		else if(s[i]=='3')
			s[i]=3;
		else if(s[i]=='2')
			s[i]=2;
		else if(s[i]=='1')
			s[i]=1;
		else if(s[i]=='0')
			s[i]=0;
		else if(s[i]=='A'||s[i]=='a')
			s[i]=10;
		else if(s[i]=='B'||s[i]=='b')
			s[i]=11;
		else if(s[i]=='C'||s[i]=='c')
			s[i]=12;
		else if(s[i]=='D'||s[i]=='d')
			s[i]=13;
		else if(s[i]=='E'||s[i]=='e')
			s[i]=14;
		else if(s[i]=='F'||s[i]=='f')
			s[i]=15;
		else if(s[i]=='G'||s[i]=='g')
			s[i]=16;
		else if(s[i]=='H'||s[i]=='h')
			s[i]=17;
		else if(s[i]=='I'||s[i]=='i')
			s[i]=18;
		else if(s[i]=='J'||s[i]=='j')
			s[i]=19;
		else if(s[i]=='K'||s[i]=='k')
			s[i]=20;
		else if(s[i]=='L'||s[i]=='l')
			s[i]=21;
		else if(s[i]=='M'||s[i]=='m')
			s[i]=22;
		else if(s[i]=='N'||s[i]=='n')
			s[i]=23;
		else if(s[i]=='O'||s[i]=='o')
			s[i]=24;
		else if(s[i]=='P'||s[i]=='p')
			s[i]=25;
		else if(s[i]=='Q'||s[i]=='q')
			s[i]=26;
		else if(s[i]=='R'||s[i]=='r')
			s[i]=27;
		else if(s[i]=='S'||s[i]=='s')
			s[i]=28;
		else if(s[i]=='T'||s[i]=='t')
			s[i]=29;
		else if(s[i]=='U'||s[i]=='u')
			s[i]=30;
		else if(s[i]=='V'||s[i]=='v')
			s[i]=31;
		else if(s[i]=='W'||s[i]=='w')
			s[i]=32;
		else if(s[i]=='X'||s[i]=='w')
			s[i]=33;
		else if(s[i]=='Y'||s[i]=='y')
			s[i]=34;
		else if(s[i]=='Z'||s[i]=='z')
			s[i]=35;
		j++;
	}
	for(i=0;i<j;i++)
	{
		m=pow(a,j-i-1);
		c=s[i]*m;
		d=d+c;
	}
	for(i=0;d!=0;i++)
	{
		x[i]=d%b;
		d=d/b;
		k++;
	}
	for(i=0;i<k;i++)
	{
        if(x[i]==35)
			x[i]='Z';
		else if(x[i]==34)
			x[i]='Y';
		else if(x[i]==33)
			x[i]='X';
		else if(x[i]==32)
			x[i]='W';
		else if(x[i]==31)
			x[i]='V';
		else if(x[i]==30)
			x[i]='U';
		else if(x[i]==29)
			x[i]='T';
		else if(x[i]==28)
			x[i]='S';
		else if(x[i]==27)
			x[i]='R';
		else if(x[i]==26)
			x[i]='Q';
		else if(x[i]==25)
			x[i]='P';
		else if(x[i]==24)
			x[i]='O';
		else if(x[i]==23)
			x[i]='N';
		else if(x[i]==22)
			x[i]='M';
		else if(x[i]==21)
			x[i]='L';
		else if(x[i]==20)
			x[i]='K';
		else if(x[i]==19)
			x[i]='J';
		else if(x[i]==18)
			x[i]='I';
		else if(x[i]==17)
			x[i]='H';
		else if(x[i]==16)
			x[i]='G';
		else if(x[i]==15)
			x[i]='F';
		else if(x[i]==14)
			x[i]='E';
		else if(x[i]==13)
			x[i]='D';
		else if(x[i]==12)
			x[i]='C';
		else if(x[i]==11)
			x[i]='B';
		else if(x[i]==10)
			x[i]='A';
		else if(x[i]==9)
			x[i]='9';
		else if(x[i]==8)
			x[i]='8';
		else if(x[i]==7)
			x[i]='7';
		else if(x[i]==6)
			x[i]='6';
		else if(x[i]==5)
			x[i]='5';
		else if(x[i]==4)
			x[i]='4';
		else if(x[i]==3)
			x[i]='3';
		else if(x[i]==2)
			x[i]='2';
		else if(x[i]==1)
			x[i]='1';
		else if(x[i]==0)
			x[i]='0';
	}
	for(i=k-1;i>=0;i--)
	{
		printf("%c",x[i]);
	}
	}
	if(s[0]==0)
		printf("0\n");
	return 0;
}
int main()
{  
	int a,b,c,i,d=0,e; 
    char h[25];
	char n[20];
	int s[20];
	
	cin>>a>>n>>b;
	c=strlen(n);
	for(i=0;i<=c-1;i++)
	{
		if(isdigit(n[i])!=0)
			d=d+(n[i]-48)*(int)pow((double)a,c-1-i);
		else if(islower(n[i])!=0)
			d=d+(n[i]-87)*(int)pow((double)a,c-1-i);
		else
			d=d+(n[i]-55)*(int)pow((double)a,c-1-i);

	}
   for(i=0;d>=b;i++)
   {
	   if(d%b<10)
		   h[i]=d%b+48;
	   else
		   h[i]=d%b+55;
	   d=d/b;
   }
      if(d<10)
		  h[i]=d+48;
	  else
		  h[i]=d+55;
	  for(;i>=0;i--)
		  cout<<h[i];

	return 0;
	
}
//????
int main()
{
	int a,b,j=0;
	char str1[33],str2[33],str3[33];
	cin>>a>>str1>>b;           //????????????????
	int i=0,dec=0;
	while(str1[i]!=0)     //?????????
	{
		dec=dec*a;
		if(str1[i]<='9'&&str1[i]>='0')
			dec=dec+str1[i]-'0';
		else if(str1[i]>='A'&&str1[i]<='Z')
			dec=dec+str1[i]-'A'+10;
		else if(str1[i]>='a'&&str1[i]<='z')
		dec=dec+str1[i]-'a'+10;
		i++;
	}
	if(dec==0){
        cout<<dec<<endl;
        return 0;
    }
	while(dec!=0)         //??????b???
	{
		str3[j]=dec%b;
		if(str3[j]>9||str3[j]<0) str3[j]=str3[j]+'A'-10;
		else str3[j]+='0';
		dec=dec/b;
		j++;
	}
	for(j--;j>=0;j--)   //????
	{
		cout<<str3[j];
	}
	cout<<endl;
	return 0;
}
int main(){
int a,b,x=0,i,l;
char s[50];
cin>>a>>s>>b;
for (i=0;s[i]!=0;i++)
if(s[i]<='9') x=x*a+s[i]-48;
else if(s[i]<='Z') x=x*a+s[i]-55;
else x=x*a+s[i]-87;
for (l=0;x!=0;l++){
i=x%b;
if(i<10) s[l]=i+48;
else s[l]=i+55;
x/=b;
}
for (i=l-1;i>=0;i--) cout<<s[i];
if(l==0) cout<<0;
return 0;
}
int main()
{	long i,k=0,a1,a2,x;
	char a[32],b[80];
	scanf("%d%s%d",&a1,a,&a2);
	for(i=0;a[i]!='\0';i++)
	{if(a[i]>='0'&&a[i]<='9')
			k=a1*k+a[i]-'0';
		if(a[i]>='a'&&a[i]<='z')
			k=a1*k+a[i]-'a'+10;
		if(a[i]<='Z'&&a[i]>='A')
			k=a1*k+a[i]-'A'+10;
	}
	if(k==0)printf("0");
	for(i=0;k!=0;i++)
	{
		x=k%a2;
		if(x>=10)
			b[i]=x-10+'A';
		else
			b[i]=x+'0';
			k=k/a2;
	}
	while(i)
	{
		i--;
		printf("%c",b[i]);
	}
	return 0;}
//****************************************
//*???????                            **
//*????? 1100013004                     **
//*???2010.11.13                          **
//****************************************
int a,b,i,j,n,sum = 0,mi,k = 1;
char num[100],input[100];
void calc(){
for(i = n - 1; i >= 0 ;i--) 
	{
		if(num[i] <= '9')
			sum += (num[i] - '0') * k;
		else
		{
			if(num[i] <= 'Z')
                sum += ((num[i] - 'A') + 10) * k;
			else
				sum += ((num[i] - 'a') + 10) * k;
		}
	   k *= a;
	}
}
int main() 
{
  
    cin>>a;
	cin.get();
	cin.getline(num,100,' ');
    cin>>b;
	for(i = 0; num[i] != 0;i++);
    n = i;
    calc();
	i = 0;
	do
	{
		mi = sum % b;
		if (mi < 10)
			input[i] = mi + '0';
		else 
			input[i] = 'A' + mi - 10;
		sum = sum / b;
		i++;
	}while(sum > 0);
	for (j = i - 1;j >= 0;j--)
		cout<<input[j];
	return 0;
}
int main()
{
    char c[100],t;
    int d[100]={0};//??????????
    int a,b,n,i=0,lc;//a,b???????? 
    int number=0,decimal=0; 
    cin>>a>>c>>b;
    if(c[0]=='0')cout<<'0';
    lc=strlen(c); 
    for(i=0;c[i]!='\0';i++)
    {
       if(c[i]>='0'&&c[i]<='9')
           decimal=c[i]-'0';
       if(c[i]>='a'&&c[i]<='z')
          decimal=c[i]-'A'-22;
       if(c[i]>='A'&&c[i]<='Z')
           decimal=c[i]-'A'+10;
       number=number*a+decimal;
    }
    //cout<<number<<endl;
    i=0;
    while(number>0)
    {
       d[i]=number%b;
       number=number-d[i];
       number/=b;
       i++;  
    }
    i--;
    for(;i>=0;i--)
    {
      if(d[i]>=10)
      {t=d[i]+'A'-10;cout<<t;}
      else  
      cout<<d[i];
    }
    
      int ss;cin>>ss;
      return 0;
}
main()
{
int a,b,d,i,l,m,n;
long s=0;
char c[32],e[32];
scanf("%d %s %d",&a,c,&b);
if(c[0]=='0')
printf("%d\n",0);
else
{ 
l=strlen(c);
for(i=0;i<=l-1;i++)
{
if(c[i]<'A')
d=c[i]-'0';
else if(c[i]<'a')
d=c[i]-'A'+10;
else
d=c[i]-'a'+10;
s=s*a+d;
}                  
for(i=0;s>0;i++)
{
n=s%b;
if(n<10)
e[i]=n+'0';
else
e[i]=n-10+'A';
s=s/b;         
}
for(m=i-1;m>0;m--) 
printf("%c",e[m]);
printf("%c\n",e[0]);
}
getchar();
getchar();  
getchar();
getchar();
getchar();  
getchar();
getchar();
getchar();  
getchar();         
}
int main(int argc, char* argv[])
{
	int i,j=0,k,b,a,x[20],y[20],M;
	long int N=0;
	char s[20];
	scanf ("%d %s %d",&a,&s,&b);
	k=strlen(s);
	for (i=0;i<k;i++)
	{
		if (s[i]>47&&s[i]<58)
			x[i]=s[i]-48;
		else if (s[i]>64&&s[i]<90)
			x[i]=s[i]-55;
		else if (s[i]>96&&s[i]<123)
			x[i]=s[i]-87;
	}
	for (i=0;i<k;i++)
	{
		N=N+x[i]*pow(a,k-i-1);		
	}
	M=N;
	if (N==0)
		printf ("0\n");
	else
	{
	do {
		N=N/b;
		j++;
	} while (N>=b);
	for (i=0;i<=j;i++)
	{
		y[i]=M%b;
		M=M/b;
		if (y[i]<10)
			y[i]=y[i]+48;
		else if (y[i]>=10)
			y[i]=y[i]+55;
	}
	for (i=j;i>=0;i--)
	{
		printf ("%c",y[i]);
	}
	}
	return 0;
}
int main()
{
	int i,from,to,len;
	int num=0;
	char in[100],out[100];
	char i2a[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int a2i[128];
	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]];
	}
	if(num==0)
	{
		len=1;
		out[0]='0';
	}
	else 
		len=0;
	while(num>0)
	{
		out[len++]=i2a[num%to];
		num=num/to;
	}
	for(i=len-1;i>=0;i--)
		printf("%c",out[i]);

	return 0;
}
int main() 
{ 
char k[33],l[33];
long j[33]; 
int a,b,d,i,s,n=0; 
i=0; 
s=1; 
n=0; 
scanf("%d%s%d",&a,k,&b); 
d=strlen(k); 
while(i<=d-1) 
{s=pow(a,d-i-1); 
if(k[i]>='A'&&k[i]<='Z') 
n=n+(k[i]-'A'+10)*s; 
else if(k[i]>='a'&&k[i]<='z') 
n=n+(k[i]-'a'+10)*s; 
else 
n=n+(k[i]-48)*s; 
i++; 
s=1; 
} 
j[0]=n; 
if(n==0) 
{ 
printf("0"); 
return 0; 
} 
for(i=0;i<=33;i++) 
l[i]=0; 
for(i=0;j[i]!=0;i++) 
{ l[i]=j[i]%b+1; 
j[i+1]=(j[i]-l[i]+1)/b; 
} 
d=strlen(l); 
for(i=0;i<=d-1;i++) 
{if(l[d-1-i]>=11) 
{k[i]=l[d-1-i]+54; 
} 
else 
k[i]=l[d-1-i]+47; 
printf("%c",k[i]);} 
return 0; 
}
int main()
{
	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=num/to;
	}
	for(i=len-1;i>=0;i--)
		printf("%c",out[i]);
	printf("\n");
	return 0;
}
void main()
{
      long a,b,i,j,length,result=0;
      char c[100];
      long final[100]={0};
      scanf("%d %s %d",&a,c,&b);
      int decimal[100]={0};
      length=strlen(c);
      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");
      }     
      for(i=0;result!=0;i++)
      {
           final[i]=result%b;
           result=result/b;
       }
      for(j=i-1;j>=0;j--)
      {
            if(final[j]<10)
            {
                  printf("%d",final[j]);
            }
            else
            {
                 printf("%c",(char)(final[j]+'A'-10));
            }
      }
     printf("\n");
    
}
int main ()
{
	char string1[1000];
	int b,i;
	long c = 0;;
	int a;
	cin>>a>>string1;
	b=strlen(string1);
	for(i=0;i<b;i++)
	{
		if(string1[i]>='0'&&string1[i]<='9')
			c+=(string1[i]-'0')*pow(a,b-i-1);
		if(string1[i]>='a'&&string1[i]<='z')
			c+=(string1[i]-'a' + 10)*pow(a,b-i-1);
		if(string1[i]>='A'&&string1[i]<='Z')
			c+=(string1[i]-'A'+10)*pow(a,b-i-1);
		//cout << c<<endl;
	}
	//cout << c<<endl;
	int index = 0;
	char string2[1000];
	int d;
	cin >> d;
	int e;
	if(c == 0)
		cout << '0' << endl;
	while(c != 0)
	{
		e = c % d;
		c = c / d;
		if(e >= 10)
			string2[index] = 'A' + e - 10;
		else
			string2[index] = '0' + e;
		index ++;
	}
	string2[index] = '\0';
	for( i = index - 1;i>=0;i--)
		cout<<string2[i];
	cout<<endl;

	//cout<<string2<<endl;
	//while(1);
	return 0;
}