semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
 char c[1000];
 int n,x=0,i;
 int a,b;
 scanf("%d%s%d",&a,c,&b);
 n=strlen(c);
 for(i=0;i<=n-1;i++)
 {
  if('A'<=c[i] && c[i]<='Z')
   c[i]=c[i]-'A'+10;
  else if('a'<=c[i]&&c[i]<='z')
   c[i]=c[i]-'a'+10;
  else if('0'<=c[i]&&c[i]<='9')
   c[i]=c[i]-'0';
 }
  for(i=0;i<=n-1;i++)
  {
   x=x+c[i]*pow(a,n-i-1);
  }
  if(x==0)
   printf("%d",x);
  if(x!=0)
  {
  int y;int n[100],j;
   y=x;
   for(i=0;y!=0;i++)
   {
       n[i]=y%b;
       y=y/b;
   }
   for(j=i-1;j>=0;j--)
   {
    if(0<=n[j] && n[j]<10)
     printf("%d",n[j]);
    else if(n[j]>=10)
    {
     n[j]=n[j]+'A'-10;
        printf("%c",n[j]);
    }
   }
  }
   printf("\n");
   getchar();
   getchar();
}
void main()
{
	int from,to;
	char num[33],result[33]={0};
	long dec=0;
	int i,j;
	scanf("%d%s%d",&from,num,&to);
    if (num[0]=='0') printf("0");
	else 
	{
		//??10??
		for(i=0;i<strlen(num);i++)
		{
			dec*=from;
			if (num[i]>='0' && num[i]<='9')
				dec=dec+num[i]-'0';
			else if (num[i]>='A' && num[i]<='Z')
				dec=dec+num[i]-'A'+10;
			else if (num[i]>='a' && num[i]<='z')
				dec=dec+num[i]-'a'+10;
		}
		//??????
		if (to==10)
			printf("%d",dec);
		else
		{
			int digit;
			i=0;
			while(dec!=0)
			{
				digit=dec%to;
				if (digit>=0 && digit<=9)
					result[i]=digit+'0';
				else
					result[i]=digit-10 +'A';
				i++;
				dec=(dec-digit)/to;
			}
			//????
			for(j=strlen(result)-1;j>=0;j--)
				putchar(result[j]);
				
		}
	}
}
int main()
{
	long a,b,n,i,p[100];
	long sum=0;
	char u[100];
	scanf("%ld%s%ld",&a,u,&b);
	n=strlen(u);
	if(u[0]=='0')
		printf("0\n");
	else{
	for(i=0;i<n;i++)
	{
		if(u[i]>='0'&&u[i]<='9')
			sum=sum+(u[i]-48)*pow(a,n-i-1);
		if(u[i]>='a'&&u[i]<='z')
			sum=sum+(u[i]-87)*pow(a,n-i-1);
		if(u[i]>='A'&&u[i]<='Z')
			sum=sum+(u[i]-55)*pow(a,n-i-1);
	}
	long t;
	t=sum;
	i=0;
	n=0;
	while(t!=0)
	{
		p[i]=t%b;
		t=t/b;
		i++;
		n++;
	}
	for(i=n-1;i>=0;i--)
	{
        if(p[i]<=9)
			printf("%ld",p[i]);
		if(p[i]>=10)
			printf("%c",p[i]+55);
	}
	}
	return 0;
}
int pow(int di,int mi)
{
	int k,p=1;
	if(mi>=1)
	{
	    for(k=1;k<=mi;k++)
		{
			p*=di;
		}
	}
	return p;
}
int main()
{
	int a,b,num=0,i,j;
	char n[100];
	int  m[100];
	cin>>a>>n>>b;
	for(i=0;i<=100;i++)
	{
		if(n[i]=='\0')break;
		m[i]=(int)(n[i]);
		if(n[i]<=57&&n[i]>=48)m[i]=m[i]-48;
	    if(n[i]<=90&&n[i]>=65)m[i]=m[i]-55;
		if(n[i]<=122&&n[i]>=97)m[i]=m[i]-87;
	}
    for(j=0;i>=1;j++)
	{
		num=num+m[j]*pow(a,i-1);
		i--;
	}
	if(num==0)cout<<'0'<<endl;
	else
	{
		int q,w;
	    char r[100];
		int t[100];
		for(q=0;q<100;q++)
		{
			if(num==0)break;
			t[q]=num%b;
			num=num/b;
		}
	    for(w=0;q>=1;w++)
		{
			r[w]=(char)(t[q-1]);
			if(0<=t[q-1]&&t[q-1]<=9)r[w]+=48;
			if(10<=t[q-1]&&t[q-1]<=35)r[w]+=55;
			q--;		
		}
	    r[w]='\0';
	    cout<<r<<endl;
	}
	return 0;
}
int zh(char a)
{
	int b;
	if((a>='A')&&(a<='Z'))
	{
		b=(int)(a)-55;
		return b;
	}
	else
	{
		b=(int)(a)-48;
		return b;
	}
}
char fzh(int a)
{
	char b;
	if(a>9)
	{
		b=(char)(a+55);
		return b;
	}
	else
	{
		b=(char)(a+48);
		return b;
	}
}
int cf(int a,int b)
{
	int i;
	int sum=a;
	if(b==0)
	{
		sum=1;
	}
	for(i=0;i<b-1;i++)
	{
		sum*=a;
	}
	return sum;
}
int main()
{
	int a,b;
	int i,j;
	int l;
	
	char c[10000];
	char t[10000];
	int sum=0;
	
	
	scanf("%d%s%d",&a,c,&b);
	l=strlen(c);
	for(i=0;i<l;i++)
	{
		if((c[i]>='a')&&(c[i]<='z'))
	{
			c[i]=c[i]-'a'+'A';
		}
	}
	
	
	for(i=0;i<l;i++)
	{
		sum+=cf(a,l-1-i)*zh(c[i]);
	}
	
	
	if(sum==0)
	{
	printf("0");
	}
	
	
	for(i=0;sum!=0;i++)
	{
		t[i]=fzh(sum%b);
		sum=sum/b;
	}
	
	for(j=i-1;j>=0;j--)
	{
		printf("%c",t[j]);
	}

	
	printf("\n");
	
	return 0;
}
int trans(char a)       //???????????????10??????a????????????
{
    int m;      //m???10??????
    if (a >= '0' && a <= '9')     //a???
        m = a - '0';
    else if (a >= 'a' && a <= 'z')      //a?????
        m = a - 'a' + 10;
    else
        m = a - 'A' + 10;          //a?????
    return m;       //????????????
}

void change(int a, char n[], int b)    //a?n?b???????????????????????????????
{
    int m = 0, i, j = 1, d, k, num[100];   //m?????????????i?j???d????k??????????????num????10??????????????
    for (i = 0; n[i] != ' '; i++)     //???????????????10??????????????????
    {
        num[i] = trans(n[i]);         //????????????????????????10??
    }
    k = i;          //??????????
    char c[100];      //c???????????
    for (i = k - 1; i >= 0; i--)      //?????????????j???????????????123=3*1+2*10+1*100?
    {
        m = m + num[i] * j;
        j = j * a;
    }
    if (m == 0)    //??????0?????0
        cout << "0";
    else
    {
        i = 0;
        while (m > 0)
        {
            d = m % b;    //???
            m = m / b;       //??
            if (d >= 10)      //??????10????c
            {
                c[i] = 'A' + d - 10;
            }
            else              //??????10?????c
                c[i] = d + '0';
            i++;           //????????????
        }
        for (i--; i >= 0; i--)       //??
        {
            cout << c[i];
        }
    }
}

int main()       //???
{
    char n[100];        //n??????
    int a, b, i, num[100];    //a???????b????????i?????num?????????????????????????
    cin >> a;
    cin.get();     //??a???????
    for (i = 0; (n[i] = cin.get()) != ' ';)    //???????????
        i++;
    cin >> b;
    change(a, n, b);       //??????????????10???????????????????
    return 0;
}
int main()
{
    char n[100],m[100];
    int i,j,a,b,num=0,x[100],y[100];
    cin>>a>>n>>b;
    for(i=0;i<strlen(n);i++)
    {
	if(n[i]>='A' && n[i]<='Z')x[i]=n[i]-'A'+10;
	else if(n[i]>='a' && n[i]<='z')x[i]=n[i]-'a'+ 10;
	else if(n[i]>='0' && n[i]<='9')x[i]=n[i]-'0';
	num=num*a+x[i];	
    }         
    for(i=0;;i++)
   {
	y[i]=num%b;
	num=(num-y[i])/b;
	if(y[i]>=0 && y[i]<=9)
	     m[i]=y[i]+'0';
	else m[i]=y[i]-10+'A';
	if (num == 0)	break;
   }                                  
    for(j=i;j>=0;j--)
   {
	cout<<m[j];           
   }
	return 0;
}
main()
{
int a,c,d,e,f,l,x,i;
char b[40000];
scanf("%d %s %d",&a,b,&c);
l=strlen(b);
if(b[0]=='0')
printf("0\n");
else
{
    for(d=0;d<l;d++)
    {
                    if(b[d]>='A' && b[d]<='Z')
                    b[d]=b[d]-'A'+'a';
    }
    x=0;
    for(e=0;e<l;e++)
    {
             if(b[e]>='a')
             f=b[e]-'a'+10;
             else
             f=b[e]-'0';
             x=f+x*a;
    }
    int g[40000];
    for(e=0;x!=0;e++)
    {
           g[e]=x%c;
           x=x/c;
     }
    char h[40000];
    for(i=0;i<e;i++)
    {
           if(g[i]<10)
           h[e-i-1]=g[i]+'0';
           else
           h[e-i-1]=g[i]+'A'-10;
     }
     h[e]='\0';
     printf("%s",h);
}
getchar();
getchar();
}
void main()
{
	char c[100],d[100],e='a';
    long int a,b,m,k,s=0,p,q,i=0,j;
	scanf("%d%s%d",&a,c,&b);
    m=strlen(c);
	while(c[i]!=0)
	{
		if('A'<=c[i]&&c[i]<='Z')
			c[i]+='a'-'A';
		i++;
	}
	for(i=0;i<m;i++)
	{
		if(a<=10)
		k=c[i]-48;
		else 
		{
			if(48<=c[i]&&c[i]<=57)
				k=c[i]-48;
			else
			{
				k=9;
				while(e<=c[i])
				{
					k=k++;
					e++;
				}
			}
		}

		for(j=1;j<(m-i);j++)
		    k=k*a;
		s=s+k;
		e='a';
	}
	i=0;
	e='A';
	if(s==0)
	printf("0");
	else
	{
		while(s>0)
	{
		p=s/b;
		q=s%b;
		s=p;
		if(0<=q&&q<=9)
			d[i]=q+48;
		else
			for(j=10;j<=q;j++)
			{
				d[i]=e;
				e++;
			}
        i++;
		e='A';
	}
	i--;
	for(;i>=0;i--)
	printf("%c",d[i]);
	}
}
main()
{
    long a,b,c,i,m,j;
    char n[33];
    scanf("%ld %s %ld",&a,n,&b);
    c=strlen(n);
    for(i=0,m=0;i<c;i++)
    {
        if(n[i]>='0'&&n[i]<='9')
            m=m*a+(n[i]-'0');
        else if(n[i]>='a'&&n[i]<='z')
            m=m*a+(n[i]+10-'a');
        else if(n[i]>='A'&&n[i]<='Z')
            m=m*a+(n[i]+10-'A');
    }
    for(i=0,n[0]=0;m>=0;i++)
    {
        for(j=i;j>=0;j--)
            n[j+1]=n[j];
        if(m%b<=9)
            n[0]=m%b+'0';
        else
            n[0]=m%b+'A'-10;
        m=m/b;
		if(m==0)
			break;
    }
    printf("%s",n);
}
void main()
{
   long int a,b,i,j=0,r,t=0,d[10000];
   char c[100];
   scanf("%ld %s %ld",&a,c,&b);
   r=strlen(c);
   for(i=0;i<r;i++)
   {	  
	   if(c[i]>=65 && c[i]<=90 )
	       c[i]=c[i]-55;
	   else if( c[i]<=122 && c[i]>=97)
		   c[i]=c[i]-87;
	   else 
           c[i]=c[i]-'0';
	   if((r-i-1)!=0)
	      t=t+c[i]*(int)pow(a,r-i-1);
	   else
		   t=t+c[i];
   }
   while(t>=b)
   {
	   d[j]=t%b;
	   t=t/b;
	   j=j+1;
   }
   d[j]=t;
   for(i=j;i>=0;i--)
   {
	   if(d[i]>=0 && d[i]<=9)
	          printf("%d",d[i]);
	   else
	          printf("%c",d[i]+55);
   }
   printf("\n");
}
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+=num[i]*((int)pow(a,(nlen1-1-i)));
	}
if(n!=0)
{
   for(i=0;n>=b;i++)
   {
       num[i]=n%b;
	   n=(n-num[i])/b;
   }
   if(n>0)num[i]=n;
   else i-=1;
   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];}
   }
}
else cout<<0;

return 0;
	  
	   
}
int zheng(char x);
char fan(int x);
int main(){	
	int n,m,f,sum,i;
	char zhuan[50];
	scanf("%d",&n);
	char x[10];
	scanf("%s",x);
	scanf("%d",&m);
	f=strlen(x);      
	sum=0;
	int wei=0;
	for(i=0;i<f;i++){
		sum=sum+zheng(x[i])*pow(n,f-i-1);
	}
	for(i=49;i>=0;i--){
		zhuan[i]=fan(sum%m);
		wei++;
		sum=sum/m;
		if(sum==0)
			break;
	}
	for(i=50-wei;i<50;i++){         
		printf("%c",zhuan[i]);
	}
  return 0;
}

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

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

    printf("%s",y);
}
    getchar();
    getchar();
            
}
void main()
{
	int a[1000],b[1000],d[1000];
	int i,n,m,lc,ld=0,n1,sum=0;
	char c[1000],e[1000];
	scanf("%d %s %d",&n,c,&m);
	lc=strlen(c);
	if(c[0]=='0')
	{
		printf("0");
	}
	if(c[0]!='0')
	{
		for(i=0;i<lc;i++)
		{
			if(c[i]<=90&&c[i]>=65)
			{
				a[i]=c[i]-55;
			}
			if(c[i]<=122&&c[i]>=97)
			{
				a[i]=c[i]-87;
			}
			if(c[i]<=57&&c[i]>=48)
			{
				a[i]=c[i]-48;
			}
		}
		for(i=0;i<lc;i++)
		{
			n1=(int)pow(n,i);
			b[i]=a[lc-i-1]*n1;
			sum=sum+b[i];
		}
		for(i=0;sum>0;i++)
		{
			d[i]=sum%m;
			ld++;
			sum=sum/m;
		}
 
		for(i=ld-1;i>=0;i--)
		{
			if(d[i]<=9&&d[i]>=0)
			{
				e[i]=d[i]+48;
			}
			if(d[i]<=36&&d[i]>=10)
			{
				e[i]=d[i]+55;
			}
			printf("%c",e[i]);
		}
	 }
}
void main()
{
char intonumber(char x);
char intochar(int y);
char str[N];
gets(str);

int i=0,c1=0;
while(str[i]!=' ')
{
	c1=c1*10+intonumber(str[i++]);
}
while(str[i]==' ')
	i++;

unsigned long n1=0;
while(str[i]!=' ')
{
	n1=n1*c1+intonumber(str[i++]);

}
while(str[i]==' ')
	i++;

int l1=0;
while(str[i]!='\0')
{
l1=l1*10+intonumber(str[i++]);
}

int f;
char yu[M];
for(f=0;n1>0;f++)
{
	yu[f]=intochar(n1%l1);
	n1=n1/l1;
}
if (f==0) printf("%d",0);
for(f--;f>=0;f--)
printf("%c",yu[f]);

}



char intonumber(char x)
{
	if(x>='a'&&x<='z')
		x=x-87;
	else if(x>='A'&&x<='Z')
		x=x-55;
	else if(x>=48&&x<=57)
		x=x-48;
	return(x);
}

char intochar(int y)
{
	if(y>=0&&y<=9)
		y=y+48;
	else if(y>9&&y<=35)
		y=y+55;
	return(y);

}
void main()
{
char A[200],B[200];
int a,b,i=0,m=0;
long int n=0,k=0;

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

while (A[i]!='\0')
{
	n=n*a;
	if(A[i]<=60) n=n+A[i]-48;
	else if(A[i]<=90) n=n+A[i]-55;
	else  n=n+A[i]-87;
	i++;
}

k=n;
i=0;
if(k==0) printf("%ld",k);


while (n>0)
{
	m=n%b;
	if(m<=9) B[i]=m+48;
	else if(m>=10) B[i]=m+55;
	n=n/b;
	i++;
}

B[i]='\0';
m=strlen(B);
n=k;
i=m-1;

while (i>=0)
{
	m=n%b;
	if(m<=9) B[i]=m+48;
	else if(m>=10) B[i]=m+55;
	n=n/b;
	i--;
}

printf("%s\n",B);


}
long int sum=0;
char a[10000];
long int c[10000];
int main()
{
    long int i,j,k,l,n,m,y=0,x,t=0;
    long int hhh(int q, int p); 
    char b[10000];                
    scanf("%d %s %d",&n,a,&x);
    l=strlen(a);
    for(i=0;i<l;i++)
       {if(a[i]>96&&a[i]<123)
           a[i]=a[i]-87;
        if(a[i]>64&&a[i]<91)
           a[i]=a[i]-55;
        if(a[i]>47&&a[i]<58)
           a[i]=a[i]-48;
        }
    for(i=l-1;i>=0;i--)
       {c[i]=(int)a[i]*hhh(n,l-1-i);
        }
    for(i=0;i<l;i++)
       sum=sum+c[i];
    if(sum==0)t=1;
    while(sum>0)
         {b[y]=sum%x;
          sum=sum/x;
          y++;
          }
    for(i=0;i<y;i++)
       {if(b[i]>9)
          b[i]=b[i]+55;
       else b[i]=b[i]+48;
       }
    if(t==0)
    {
    for(i=y-1;i>=0;i--)
       printf("%c",b[i]);
    }
    if(t==1)
        printf("0");

}
long int hhh(int q, int p)
{
     long int i,w=1;
     for(i=0;i<p;i++) 
        w=q*w;
     return w;          
}
/**
grids???????
http://programming.grids.cn/programming/problem/24947e911f454e43abea1300d470e3c4/show.do
-----------------------------
??
?????????????????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
-----------------------------
??
???????????????
-----------------------------

???
2010.10.22
*/


/**
?originBase?number???10?? 
*/
int change2Dec(char * number, int len_number, int originBase) {

	int result = 0;
	//for?? 
	for (int i=0; i<len_number; i++) {
		//???????10????????
		int numberBit = 0;
		if (number[i]>='0' && number[i]<='9') {
			numberBit = number[i]-'0';
		}
		else if (number[i]>='a' && number[i]<='z') {
			numberBit = number[i]-'a'+10;
		}
		else {
			numberBit = number[i]-'A'+10;
		}

		//???????????
		int position = len_number-i;

		//???????????? 
		int currentBitValue = numberBit;
		for (int j=1; j<position; j++) {
			currentBitValue *= originBase;
		}
		result += currentBitValue;
	}
	return result;       
} 

/**
?10??decNumber???newBase??????newNumber???????????? 
*/
int changeDec2NewBase(int decNumber, int newBase, char * newNumber) {
	
	int bitValue[100];                     //??????????????????? 
	int length=0;                          //??????? 
	while (decNumber/newBase > 0) {
		bitValue[length++] = decNumber%newBase;         //??
		decNumber /= newBase;
	}
	bitValue[length++] = decNumber;                     //??????

	//????bitValue????????newNumber
	for (int i=length-1,j=0; i>=0; i--,j++) {
		int currentBit = bitValue[i];
		if (currentBit < 10)
			newNumber[j]=currentBit+'0';
		else
			newNumber[j]=currentBit+'A'-10;
	}
	return length;
}

int main()
{
	int originBase;         //????
	int newBase;            //???
	char number[100];       //????????
	char newNumber[100];    //?????? 
	cin >> originBase >> number >> newBase;

	int len_number = strlen(number);  //????????
	int len_newNumber;                //????????

	int decNumber = change2Dec(number, len_number, originBase);       //?originBase????number???int??decNumber
	len_newNumber = changeDec2NewBase(decNumber, newBase, newNumber); //?int?decNumber???newBase???????newNumber????
	newNumber[len_newNumber] = NULL;
	cout << newNumber << endl;

	return 0;
}
int main()
{
	int a,b,i=0,k=0,len;
	char n[100],m[100];
	cin>>a>>m>>b;
	len=strlen(m);
	for(i=0;m[i]!='\0';i++)
	{
		k*=a;
		if(m[i]>='a'&&m[i]<='z')
			k+=m[i]-'a'+10;
		else if(m[i]>='A'&&m[i]<='Z')
			k+=m[i]-'A'+10;
		else if(m[i]>='0'&&m[i]<='9')
			k+=m[i]-'0';
	}
	i=0;
	n[0]='0';
	n[1]='\0';
	while(k!=0)
	{
		if(k%b<=9)
		{
			n[i++]='0'+k%b;
			k=k/b;
		}
		else
		{
			n[i++]='A'+k%b-10;
			k=k/b;
		}
	}
	if(i!=0)
		n[i]='\0';
	len=strlen(n);
	for(i=len-1;i>=0;i--)
	{
		cout<<n[i];
	}
	cout<<endl;
	return 0;
}
int main ()
{
	long b,c,i,j,d=0,z[100],sum=0,k;
	char a[100],s[36];
	for (i=0;i<36;i++)
	{
		if(i>=0&&i<=9)
			s[i]=i+48;
		else
			s[i]=i+55;
	}
	scanf ("%d %s %d",&b,a,&c);
	d=strlen(a);
		for (i=0;i<d;i++)
	{
		if (a[i]<123&&a[i]>96)
			a[i]=a[i]-32;
	}
	for (i=0;i<d;i++)
	{
		for(j=0;j<36;j++)
		{
			if (a[i]==s[j])
				sum=sum+j*pow(b,d-1-i);
		}
	}
	for (i=0;i>=0;i++)
	{
		if (sum==0)
		{
			k=i;
			break;
		}
		else
		{
			z[i]=sum%c;
			sum=sum/c;
		}
	}
	for(i=k-1;i>=0;i--)
		printf("%c",s[z[i]]);
	if (a[0]=='0')
		printf("%c",a[0]);
	return 0;
}
int xToTen(int x, char c[])
{
	int i, lenth, ten, num;
	lenth = strlen(c);
	for(i = 0, ten = 0; i < lenth; i++)
	{
		if(c[i] >= '0' && c[i] <= '9')
			num = c[i] - '0';
		if(c[i] >= 'A' && c[i] <= 'Z')
			num = c[i] - 'A' + 10;
		if(c[i] >= 'a' && c[i] <= 'z')
			num = c[i] - 'a' + 10;
		ten = ten * x + num;
	}
	return (ten);
}

void tenToYout(int ten, int y)
{
	int a[100];
	int i, lenth;
	for(lenth = 0; ten >= y; lenth++)
	{
		a[lenth] = ten % y;
		ten /= y;
	}
	a[lenth] = ten;
	for(i = lenth; i >= 0; i--)
	{
		if(a[i] < 10)
			cout << a[i];
		else
			cout << (char)(a[i] - 10 + 'A');
	}
	cout << endl;
}

int main()
{
	char c[100];
	int x, y;
	cin >> x >> c >> y;
	tenToYout (xToTen(x, c), y);
	return 0;
}
int main()
{
    int a,b;
    char n[100];
    scanf("%d %s %d",&a,n,&b);
    int c[100];
    int e[100];
    int d=0; //n?????? 
    int i,j;
    for(i=0;i<100&&n[i]!='\0';i++)
    {
     if(n[i]>='a'&&n[i]<='z')
     c[i]=n[i]-'a'+10;
     else if(n[i]>='A'&&n[i]<='Z')
     c[i]=n[i]-'A'+10;
     else if(n[i]>='0'&&n[i]<='9')
     c[i]=n[i]-'0';
     d=d*a+c[i];                                                                                                                  
    }
    if(d==0)
    printf("%d",d);
    for(i=0;i<100&&d!=0;i++)
    {
     e[i]=d%b;
     d=d/b;                                  
    }
    for(j=0;j<i;j++)
    {
    if(e[i-j-1]<=9&&e[i-j-1]>=0)
    n[j]=e[i-j-1]+'0';
    else if(e[i-j-1]>=10)
    n[j]=e[i-j-1]-10+'A';
    }
    n[i]='\0';
    puts(n);
    getchar();
     getchar();
     getchar();
    getchar();
                                             
    
    
    
    
    
    
    
    }
main()
{
      int a=0,b=0,m=0,j=0,i=0,k=0,l=0,y=0;
      char n[1000],o[1000];
      for(j=0;j<=1000;j++)
      {o[j]='\0';}
      scanf("%d %s %d",&a,n,&b);
      //strlwr(n);
      for(j=0;n[j]!='\0';j++)
      if(n[j]>='A'&&n[j]<='Z')
      n[j]=n[j]-'A'+'a';
      //j=strlen(n);
      for(i=0;i<j;i++)
      {
          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]-'1'+1;
          }
      for(i=0;i<j;i++)
      {
          k=n[i];
          for(l=0;l<(j-i-1);l++)
          {
              k=k*a;               
          }
          m=m+k;            
      }        
      //printf("%d",m);
      do
      {
          for(y=1;o[y]!='\0';y++);
          //y=strlen(o);
          for(i=y;i!=0;i--)
          {
              o[i]=o[i-1];                
          }
          o[0]=m%b;
          if(o[0]=='\0')
          o[0]=46;
          m=(int)m/b;           
      }
      while(m!=0);
      y=strlen(o);
      for(i=0;i<y;i++)
      {
          if(o[i]>=10&&o[i]<=36)
          o[i]=o[i]-10+'A';
          else if(o[i]>=0&&o[i]<=9)
          o[i]=o[i]-1+'1';
          else if(o[i]==46)
          o[i]='0';
      }
      printf("%s",o);
      return 0;
      }
void shuchu(int c[], int i)
{
	int j;
	for(j = i - 1 ; j >= 0 ; j--)
	{
		if(c[j] >= 0 && c[j] <= 9)
		{
			cout << c[j];
		}
		if(c[j] >= 10)
		{
			cout << (char)(c[j] + 55);
		}
	}
	cout << endl;
}
int main()
{
	char str1[10000], str2[10000], l;
	int i, j, num[10000] = {0}, sum = 0, c[10000] = {0}, nlen, k;
	double  before , after;
	memset(str1, ' ', sizeof(str1));
	memset(str2, ' ', sizeof(str2));
	cin >> before;
	cin >> str1;
	cin >> after;
	nlen = strlen(str1);
	for(i = 0 ; i < nlen ; i++)
	{
		if(str1[i] >= 97 && str1[i] < 122)
		{
			str1[i] = (char)toupper(str1[i]);
		}
		if(str1[i] >= 65 && str1[i] <= 90)
		{
			num[i] = str1[i] - '7';
		}
		else
			num[i] = str1[i] - '0';
	}
	k = nlen - 1;
	for(i = 0 ; i < nlen ; i++)
	{

		sum = sum + num[i] * pow(before, k);
		k--;
	}
	i = 0;
	do
	{
		c[i] = sum % (int)after;
	
		sum = sum / after;
		i++;
	}while(sum > 0);
	shuchu(c, i);
	
	return 0;
}
int main() {
		int a, b, ten = 0;
	char num[1000];
	char num1[1000];
	cin >> a >> num >> b;
	for ( int i = 0; i < strlen(num); i ++ ) {//??????????????
		if ( num[i] >= (int)'A' && num[i] <= (int)'Z')
			num[i] += 32;
	}
	for ( int i = 0; i < strlen(num); i ++ ) { //????????????
		if ( num[i] >= (int)'a' && num[i] <= (int)'z')
			ten += ( (int)num[i] - 87 ) * pow( (double)a , (double)strlen(num) - 1 - i) ;
		else if ( num[i] >= (int)'1' && num[i] <= (int)'9')
			ten += ( (int)num[i] - 48 ) * pow( (double)a , (double)strlen(num) - 1 - i) ;
	}
	if ( ten == 0 ) cout << 0; //????? ??0
	else {
		int j = 0;
		for ( ; ; ){  //?????????b???
		if ( ten == 0 )  break;
		if ( ten % b < 10 ) num1[j] = (char)(ten % b + 48);
		else num1[j] = (char)(ten % b + 55 );
		ten = ten / b;
		j ++;
	}
	for ( int i = j - 1; i >= 0; i -- ) {
		cout << num1[i];       //??
	}
	}
	return 0;
}