source_code:
#include <stdio.h>
int main() {
    int a, b, c, d, x, y, i, j;
    scanf("%d%d%d%d", &a,&b,&c,&d);
    int max = a;
    if(c<max)
        max = c;
    if(d<max)
        max = d;

    x = 256*max;

    a = a - max;
    c = c - max;
    d = d - max;

    max = a;
    if(b<max)
        max = b;

    x = x + 32*max;

    printf("%d\n", x);
}

lang_cluster: C

exec_outcome: PASSED


source_code:
#include<stdio.h>
#include<string.h>
int main()
{
    int n,k,b[105],flag=0;
    char s[105];
    memset(b,0,sizeof(b));
    scanf("%d%d%s",&n,&k,s);
    for(int i=0;i<n;i++)
    {
        b[s[i]-'0']++;
    }
        for(int i=40;i<=100;i++)
            if(b[i]>k)
                flag=1;
        if(flag==1) printf("NO\n");
        else printf("YES\n");

    return 0;
}


source_code:
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b)
{
    return a>b ? a : b;
}

int a[100], count;

int main()
{
    int n;
    scanf("%d", &n);

    int i, j, temp;

    for (i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        count += a[i];
    }

    ///printf("count : %d\n", count);

    temp = a[0];

    if (n>1)
    {
        for (i=0; i<n; i++)
        {
            temp = max(temp, a[i]);
        }
    }

    ///printf("temp : %d\n", temp);

    int k;

    int ans;

    for (i=0; ; i++)
    {
        k = temp+i;
        if (((n*k)-count)>count)
        {
            ans = k;
            break;
        }
    }

    printf("%d", ans);

    return 0;
}


source_code:
/* P11- A DIFFERENCE ROW
	 Mauricio Tulio
      Jose Garcete  */

#include<stdio.h>
#include <stdlib.h>

int funcion (const void * a, const void * b);	//prototipo de la funcion

int main()
{

    int v[1000],i,n,aux;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&v[i]);
        qsort(v,n,sizeof(int),&funcion); // a=elemento inicial   n=tamano del arreglo	sizeof(int)= tamano de los datos de ese arreglo   funcion donde se compara

	    aux=v[n-1];		//cambio de posiciones variables una vez que se haya ordenado, segun pide el problema
        v[n-1]=v[0];
        v[0]=aux;

    for(i=0;i<n;i++)
        printf("%d ",v[i]);
        return 0;
}
int funcion (const void * a, const void * b)
{

   return ( *(int*)a - *(int*)b );   //retorna la diferencia de los valores de los punteros tipo entero a y b

}


source_code:
#include<stdio.h>

int main()
{
    int n;
    while (scanf("%d",&n) != EOF)
    {

        if(n % 2 != 0)
            printf("Ehab\n");
        else
            printf("Mahmoud\n");
    }
    return 0;
}


source_code:
#include<stdio.h>
int main()
{
    char str[100];
    int i, count = 0, n;
    scanf("%d", &n);
    scanf("%s", str);
    for(i = 0; i < n; i++)
    {
        if(str[i] == 'x' && str[i+1] == 'x' && str[i+2] == 'x')
            count++;
    }
    printf("%d", count);
}


source_code:
#include<stdio.h>

int main()
{
    int total;

    scanf("%d",&total);

    if( total<=10 || total>=22) // 10+11 is max
        printf("0\n");
    else
    {
        if( total == 20)
        {
                printf("15\n");
        }
        else
        {
            printf("4\n");
        }
    }
    return 0;

}
/****** PCCA -Fri Oct 07 12:57:29 GMT 2011 *******/


source_code:
#include<stdio.h>
#include<string.h>
int main()
{
    int l1,l2,c=0,j,k;
    char s1[101],s2[101];
    scanf("%s %s",s1,s2);
    l1=strlen(s1);
    l2=strlen(s2);
    for(j=0,k=l2-1; j<l1,k>=0; j++,k--) {
        if(s1[j]==s2[k]) {
            c++;
        }
    }
    if(l1==c) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
}


source_code:
#include<stdio.h>
main()
{
	int a,b,c,i,y;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<=c/a;i++)
	{
		y=(c-a*i);
		if(y%b==0)
		{
			printf("Yes");
			exit(0);
		}

	}
	printf("No");
}


source_code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	char s[101];
	scanf("%s",s);
	int len = strlen(s);
	int i;
	int flag = 0;
	char *ans;
	ans = "CODEFORCES";
	for(i=0;i<len;i++)
	{
		char val[10];
		int j;
		int k;
		for(j=0;j<i;j++)
			val[j] = s[j];
		k = i;
		for(j=len - 10 +i;j<len;j++){
			val[k] = s[j];
			k++;
		}
		for(j=0;j<10;j++){
			if(val[j]== ans[j])
				flag = 1;
			else{
				flag = 0;
				break;
			}
		}
		if(flag == 1)
			break;
	}
	if(flag == 0)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}


source_code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
	int n, d;
	scanf("%d%d", &n, &d);

	int arr[n];
	int maxn = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		maxn = arr[i] > maxn ? arr[i] : maxn;
	}

	int maxgrp = 1;
	for (int i = 0; i < n; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) {
			if (arr[j] - arr[i] <= d && arr[j]-arr[i] >= 0) {
				cur++;
			}
		}
		maxgrp = cur > maxgrp ? cur : maxgrp;
	}

	printf("%d\n", n-maxgrp);
}


source_code:
#include<stdio.h>

int isLeap(year)
{
	if(year%4==0 && year%100!=0 || year%400==0)
		return 29;
	else
		return 28;
}

int no_of_days_remaining(int mon,int year)
{
	int days=0;
	switch(mon)
		{
			case 1:days+=31;
			case 2:days+=isLeap(year);
			case 3:days+=31;
			case 4:days+=30;
			case 5:days+=31;
			case 6:days+=30;
			case 7:days+=31;
			case 8:days+=31;
			case 9:days+=30;
			case 10:days+=31;
			case 11:days+=30;
			case 12:days+=31;
		}
	return days;
}

int no_of_days_passed(int mon, int year)
	{
		int days=0;
		switch(mon)
			{
			case 12:days+=31;
			case 11:days+=30;
			case 10:days+=31;
			case 9:days+=30;
			case 8:days+=31;
			case 7:days+=31;
			case 6:days+=30;
			case 5:days+=31;
			case 4:days+=30;
			case 3:days+=31;
			case 2:days+=isLeap(year);
			case 1:days+=31;
			}
		return days;
	}

int no_of_days(int year)
{
	int k=31*7+30*4+isLeap(year);
	return k;
}

int main()
{
	int mm1,dd1,yy1,mm2,dd2,yy2,i,j,k,nodA,nodC,nodB=0,nod,start,end,m1,d1,y1,m2,d2,y2;
	scanf("%d:%d:%d",&yy1,&mm1,&dd1);
	scanf("%d:%d:%d",&yy2,&mm2,&dd2);
	if(yy2>yy1)
		{
			m1=mm1;
			y1=yy1;
			d1=dd1;
			m2=mm2;
			y2=yy2;
			d2=dd2;
		}
	else
		{
			m1=mm2;
			y1=yy2;
			d1=dd2;
			m2=mm1;
			y2=yy1;
			d2=dd1;
		}
		nodA=no_of_days_remaining(m1,y1);
		nodC=no_of_days_passed(m2-1,y2);
		if(yy2>yy1)
		{
			start=yy1;
			end=yy2;
		}
	else
		{
			start=yy2;
			end=yy1;
		}
	for(i=y1+1;i<=y2-1;i++)
	{
		nodB+=no_of_days(i);
	}
	nod=(nodA-d1+1) + (nodC+d2) + nodB-1;
	if(yy1==yy2)
		{
			if(mm2>mm1)
			   //nod=-1*(365-nod+1)+1;
			   nod=(no_of_days_remaining(mm1,yy1)-dd1+1)-(no_of_days_remaining(mm2,yy2)-dd2+1);
			else if(mm2<mm1)
				//nod=365-nod+1;
				nod=(no_of_days_remaining(mm2,yy2)-dd2+1)-(no_of_days_remaining(mm1,yy1)-dd1+1);
			else
				{
					if(dd1>dd2)
						nod=dd1-dd2;
					else
						nod=dd2-dd1;
				}
		}
	printf("%d",nod);
}


source_code:
#include<stdio.h>
#define m 1000000007

long int power(long int a,long int b)
{
    long int ans=1;
    if(b==0)
        return 1;
    while(b>0) {
        if (b % 2 != 0)
            ans= ans * a;
        a = a * a;
        b = b / 2;
    }
    return ans;
}

int main()
{
    long int n,i=0,index=0;
    scanf("%ld",&n);
    while(n>0)
    {
        int rem=n%10;
        if(rem==4)
            index+=power(2,i);
        else
            index+=power(2,i+1);
        n=n/10;
        i++;
    }
    printf("%ld\n",index);
}


source_code:
#include<stdio.h>
#include<math.h>
int main()
{
    long long int X, f;
    scanf("%lld",&X);
    if(X%2 == 0)
    {
        f = X/2;
        printf("%lld\n",f);
    }
    else
    { f = (- X - 1)/2 ;
        printf("%lld\n",f);}
    return 0;
}
// 1461347183703


source_code:
#include <stdio.h>
#include <math.h>
int main()
{
	int n,i,j,s,t,f,w,mini,min,maxi,max;
	scanf("%d",&n);
	int ara[10][4];
	for (i=0;i<n;i++){
		for (j=0;j<4;j++){
			scanf("%d",&ara[i][j]);
		}
	}
	f=0;
	for (i=0;i<n;i++){
		s=abs(ara[i][0]-ara[i][2]);
		t=abs(ara[i][1]-ara[i][3]);
		f=f+(s*t);
		//printf("%d\n",f);
	}
	mini=100000;
	min=100000;
	maxi=0;
	max=0;
	for(i=0;i<n;i++){
		if (ara[i][0]<mini){
			mini=ara[i][0];
		}
		if (ara[i][1]<min){
			min=ara[i][1];
		}
		if (ara[i][2]>maxi){
			maxi=ara[i][2];
		}
		if (ara[i][3]>max){
			max=ara[i][3];
		}
	}
	//printf("%d",maxi);
	w=(maxi-mini)*(max-min);
	//printf("%d",f);
	if (f==w && (maxi-mini)==(max-min)){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}


source_code:
#include<stdio.h>
int main()
{
    char myarray[1000];
    scanf("%s",&myarray);
    int i,cnt=0,j,k,l,len=0;
    len=strlen(myarray);
    for(i=0; i<len; i++)
    {
        if(myarray[i]=='Q')
        {
            for(j=i+1; j<len; j++)
            {
                if(myarray[j]=='A')
                {
                    for(l=j+1; l<len; l++)
                    {
                        if(myarray[l]=='Q')
                        {
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    printf("%d",cnt);
    return 0;
}


source_code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[110]={0};
    int i;
    for(i=1;;i++)
    {
        if(n==1) {break;}
        int yushu,deshu;
        yushu=n%2;
        n=n/2;
        a[i]=yushu;
        if(n==1) {i++;break;}
    }
    printf("%d",i);
    i--;
    for(;i>=0;i--)
        if(a[i]) printf(" %d",i);
    printf("\n");
}


source_code:
#include<stdio.h>
typedef struct abc
{
	int a;
	int b;
}abc;

abc ar[8];

static int compare(const void *i1,const void *i2)
{
	        const abc *p1=(const abc *)i1;
		const abc *p2=(const abc *)i2;
		return (p1->a-p2->a);
}

int main()
{
	int x,y,z,min,max;

	for(x=0;x<8;x++)
	{
		scanf("%d %d",&ar[x].a,&ar[x].b);
	}
        qsort(&ar[0],8,sizeof(abc),compare);

	if(ar[0].a != ar[1].a || ar[0].a != ar[2].a)
		printf("ugly\n");
	else if(ar[5].a != ar[6].a || ar[5].a != ar[7].a)
		printf("ugly\n");
	else if(ar[3].a != ar[4].a)
		printf("ugly\n");
	else if(ar[0].a == ar[7].a)
		printf("ugly\n");
	else if(ar[0].a == ar[3].a)
		printf("ugly\n");
	else
	{
		x=ar[0].b;y=ar[1].b;z=ar[2].b;
		if(x==y || x==z)
			printf("ugly\n");
		else
		{
			min=10000000;max=-1;
			for(x=5;x<8;x++)
			{
				if(ar[x].b<min)
					min=ar[x].b;
				if(ar[x].b>max)
					max=ar[x].b;
				for(y=0;y<=2;y++)
				{
					if(ar[x].b==ar[y].b)
						break;
				}
				if(y==3)
					break;
			}
			if(y==3)
				printf("ugly\n");
			else
			{
				x=ar[5].b;y=ar[6].b;z=ar[7].b;
				if(x==y || x==z)
					printf("ugly\n");
				else if(!(ar[3].b == min || ar[3].b ==max))
					printf("ugly\n");
				else if(!(ar[4].b == min || ar[4].b ==max))
					printf("ugly\n");
				else if(ar[3].b == ar[4].b)
					printf("ugly\n");
				else
					printf("respectable\n");
			}
		}
	}
	return 0;
}


source_code:
#include<stdio.h>
#include<string.h>
char s[220];
long n,len;
long check(long a)
{
    long i;
    for(i=1;i<=a-n;i++)
        if(s[len-i]!=s[len-i-a])
            return 0;
    return 1;
}
int main()
{
    long i,k,j,ans=0,key,max,min,temp=0;
    scanf("%s",s);
    len=strlen(s);
    scanf("%ld",&n);

    if(n>len)
        min=(len+n)/2;
    else min=n;

    max=(len+n)/2;
    for(i=0;i<len;i++)
        for(j=1;j*2+i<=len;j++)
            {   key=1;
                for(k=1;k<=j;k++)
                    if(s[i+k-1]!=s[i+k+j-1])
                    key=0;
                if(key==1)
                    if(j>temp)
                        temp=j;
            }

    for(i=max;(i>=min)&&(ans==0);i--)
        if(check(i)==1)
            ans=i;
    if(min>ans)
        ans=min;
    if(temp>ans)
        ans=temp;
    printf("%ld",2*ans);

return 0;
}


source_code:
#include <stdio.h>
#include <limits.h>

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)

#define SIZE 1000002

static int s[SIZE], p[SIZE], np, min;

static void sieve(void)
{
  int i, j;

  for (i = 2; i < SIZE; i++) {
    if (s[i] == 0) {
      p[np++] = i;

      for (j = 2; i * j < SIZE; j++) {
        s[i * j] = 1;
      }
    }
  }
}

#define MAX(x, y) ((x) > (y) ? (x) : (y))

static void solve(int x, int l)
{
  int i, d, lf = -1, ox = x;

  if (x < min) {
    min = x;
  }

  if (l == 0) {
    return;
  }

  for (i = 0; p[i] * p[i] <= x; i++) {
    if (ox % p[i] == 0) {
      lf = MAX(lf, p[i]);
      while (ox % p[i] == 0)
        ox /= p[i];
    }
  }
  if (ox > 1 && ox != x)
    lf = MAX(lf, ox);

  if (lf == -1) {
    return;
  }

  if (l == 1) {
    x = x - lf + 1;
    if(x < min)
      min = x;
    return;
  }

  for (d = x - lf + 1; d < lf * (x / lf); d++) {
    solve(d, l - 1);
  }
}

int main(void)
{
  int x2;

  s[0] = s[1] = 1;
  sieve();
  min = INT_MAX;

  scanf("%d", &x2);
  solve(x2, 2);
  printf("%d", min);

  return 0;
}


source_code:
#include<stdio.h>

int main()
{
    int x, y;
    scanf ("%d %d", &x, &y);
    if (x == y) {
        printf ("No\n");
        return 0;
    }
    else if (x < y) {
        if (y - x == 1) {
            printf ("Yes\n");
            return 0;
        }
        else {
            printf ("No\n");
            return 0;
        }
    }
    else {
        if (y == 0 || y == 1) {
            printf ("No\n");
            return 0;
        }
        y = y - 1;
        x = x - y;
        if (x & 1) {
            printf ("No\n");
            return 0;
        }
        else {
            printf ("Yes\n");
            return 0;
        }
    }
    return 0;
}


source_code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main()
{
    int k,a,b,x,y,m;
    scanf(" %d %d %d",&k,&a,&b);

    if((a<k && b<k) || (a<k && b%k!=0) || (b<k && a%k!=0)){
        printf("-1\n");
    }
    else{
        printf("%d\n",(a/k)+(b/k));
    }

    return 0;
}


source_code:
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int board[4][4] = {0};
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++) {
            char c;
            scanf("%c ", &c);
            if (c == 'x') board[i][j] = 1;
            else if (c == 'o') board[i][j] = -3;
            else board[i][j] = 0;
        }
    bool can_win = false;
    for (int i = 0; !can_win && i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (board[i][j] >= 0) { /* 'x' or '.' */
                int sum_hor = 0, sum_dia_up = 0, sum_dia_down = 0, sum_ver = 0;
                if (j < 2)
                    sum_hor = board[i][j] + board[i][j+1] + board[i][j+2];
                if (i < 2)
                    sum_ver = board[i][j] + board[i+1][j] + board[i+2][j];
                if (i < 2 && j < 2)
                    sum_dia_up = board[i][j] + board[i+1][j+1] + board[i+2][j+2];
                if (i >= 2 && j < 2)
                    sum_dia_down = board[i][j] + board[i-1][j+1] + board[i-2][j+2];

                if (sum_hor == 2 || sum_dia_up == 2 || sum_dia_down == 2 || sum_ver == 2) {
                    can_win = true;
                    break;
                }
            }
        }
    }
    if (can_win)
        puts("YES");
    else
        puts("NO");
    return 0;
}


source_code:
#include <stdio.h>
int main() {
    int n,min1,min2,min3,max1,max2,max3, left = 0, first = 0, second = 0, third = 0;
    scanf("%d",&n);
    scanf("%d",&min1);
    scanf("%d",&max1);
    scanf("%d",&min2);
    scanf("%d",&max2);
    scanf("%d",&min3);
    scanf("%d",&max3);
    left = n;
    first = min1;second = min2;third = min3;
    while(first < (left -(min2+min3)) && first < max1) first++;
    left -= first;
    while(second < (left -min3) && second < max2) second++;
    left -= second;
    while(third < left && third < max3) third++;

    printf("%d %d %d\n", first, second, third);
    return 0;
}


source_code:
/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:21/07/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define MOD 1000000007
int cmp(const void * a,const void * b);

int main()
{
    long long t=1,i=0;
    //scanf("%lld",&t);
    while(t--)
    {
        long long n,k;
        scanf("%lld%lld",&n,&k);
        long long l=-1,r=n+1;
        while(r-l>1)
        {
            long long m=(l+r)/2;
            if((n-m)*(n-m+1)/2-m>k)
                l=m;
            else
                r=m;
        }
        printf("%lld\n",r);
    }
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp(const void * a,const void * b)
{
    return (*(int*)a - *(int*)b);
}


source_code:
#include<stdio.h>
int main()
{
	int a,ta;
	scanf("%d%d",&a,&ta);
	int b,tb;
	scanf("%d%d",&b,&tb);
	int h,m;
	scanf("%d:%d",&h,&m);
	int x,y,w=0,z=300;
	x=60*h+m;
	y=60*h+m+ta;
	jump:
		if(z+tb<x)
		{
			z=z+b;
			goto jump;
		}
		else if(z+tb>x && z<y && z<1440)
		{
			w+=1;
			z=z+b;
			goto jump;
		}
		else if(z>y)
		{
			goto temp;
		}
		else if(z+tb==x || z==y)
		{
			z=z+b;
			goto jump;
		}
		temp:
		printf("%d\n",w);
	return 0;
}


source_code:
#include<stdio.h>
int main()
{
	long long int n,m,x;
	scanf("%lld%lld%lld",&n,&m,&x);

	n=n-((x-1)*2);
	m=m-((x-1)*2);
	if(n<=0 || m<=0)
		printf("0\n");
	else if(n==1 && m==1)
		printf("1\n");
	else
	{
	long long int c=n+m-2;
	if(n==1)
		c=(m+1)/2;
	if(m==1)
		c=(n+1)/2;
	printf("%lld\n",c);
	}
	return 0;

}


source_code:
#include <stdio.h>

long long int GCD(long long int a,long long int b){
	if(b==0)return a;
	if(a==0)return b;
	if(a<b)return(GCD(a,b%a));
	else return(GCD(b,a%b));
}

long long int LCM(long long int a,long long int b){
	long long int c=GCD(a,b);
	return((a/c)*(b/c)*c);
}

int bfs(int i,int visited[],int count,int index,int A[]){
	if(i==index){
		if(count%2)return count;
		else return(count/2);
	}
	if(visited[i]==0){
		visited[i]=1;
		return(bfs(A[i],visited,count+1,index,A));
	}
	return(-1);
}

int main(){
	int i,n,A[105],cycle,visited[105];
	long long int ans;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
		A[i]--;
	}
	for(i=0;i<n;i++)visited[i]=0;
	ans=1;
	for(i=0;i<n;i++){
		if(visited[i]==0){
			visited[i]=1;
			cycle=bfs(A[i],visited,1,i,A);
			if(cycle==-1){
				ans=-1;
				break;
			}
			else ans=LCM(ans,(long long int)cycle);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


source_code:
#include <stdio.h>

int tran(int a, int b){
   int t;
   int res = 0;
   int pow = 1;
   do {
      t = a/b;
      res += pow *(a-(a/b)*b);
      a = t;
      pow*=10;
   } while(t>=b);
   res +=pow*t;
   return res;
}

int main(){
   int b,i,j;
   scanf("%d",&b);
   for(i = 1; i<b; i++){
      for(j = 1; j<b; j++){
	 printf("%d ",tran(i*j,b));
      }
      printf("\n");
   }
   return 0;
}


source_code:
#include<stdio.h>
int main()
{
    long long n,a,b,c,i,j,k,diff,min=10000000000,max;
    scanf("%lld",&n);
    for(i=1;i*i*i<=n;i++)
    {
        if(n%i==0)
        {
            for(j=i;j*j<=n/i;j++)
            {
                if(n%j==0)
                k=n/(i*j);
                a=i+1;b=j+2;c=k+2;
                if((a-1)*(b-2)*(c-2)==n)
                diff=(a*b*c)-n;
                if(min>diff)
                min=diff;

        }
        }
    }
    max=9*(n+1)-n;
    printf("%lld %lld",min,max);
    return 0;
}


source_code:
#include <stdio.h>

long long min(long long a, long long b) {
	return a < b ? a : b;
}

long long max(long long a, long long b) {
	return a > b ? a : b;
}

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int main() {
	static long long aa[2047];
	int l, r, i;
	long long x, y, ans;

	scanf("%d%d", &l, &r);
	aa[0] = 4;
	for (i = 1; i < 2047; i++)
		aa[i] = lucky(i + 1);
	ans = 0;
	for (i = 0; i < 2047; i++) {
		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}