Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Let next(x) be the minimum lucky number which is larger than or equals x. Petya is interested what is the value of the expression next(l) + next(l + 1) + ... + next(r - 1) + next(r). Help him solve this problem.

The single line contains two integers l and r (1 ≤ l ≤ r ≤ 109) — the left and right interval limits.

In the single line print the only number — the sum next(l) + next(l + 1) + ... + next(r - 1) + next(r). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.

NoteIn the first sample: next(2) + next(3) + next(4) + next(5) + next(6) + next(7) = 4 + 4 + 4 + 7 + 7 + 7 = 33In the second sample: next(7) = 7

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
long long int power(int i)
{
    int j;
    long long int tmp=1;
    for(j=1;j<=i;j++)
        tmp=tmp*2;
     return tmp;
}
int main()
{
    long long int l,r;
    scanf("%I64d %I64d",&l,&r);
    long long int**a,c[3000];
    a=(long long int**)malloc(11*sizeof(long long int*));
    a[1]=(long long int*)malloc(2*sizeof(long long int ));
    a[1][0]=4;a[1][1]=7;
    int i,j,k,x;
    for(i=1;i<10;i++)
    {
        x=power(i+1);
        k=0;
        a[i+1]=(long long int*)malloc(x*sizeof(long long int));
        for(j=0;j<x/2;j++)
        {
            a[i+1][k++]=a[i][j]*10+4;
            a[i+1][k++]=a[i][j]*10+7;
        }
    }
    k=0;
    for(i=1;i<11;i++)
    {
        for(j=0;j<power(i);j++)
           c[k++]=a[i][j];
    }
    long long int ans=0;
    k=0;
    while(l<=r)
    {
        while(l>c[k])
            k++;
        if(r-l>=c[k]-l+1)
         ans+=(c[k]-l+1)*c[k];
        else ans+=(r-l+1)*c[k];
        l=c[k]+1;
    }
    printf("%I64d\n",ans);
}

/* practice with Dukkha */
#include <stdio.h>

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

long long solve(int r) {
	long long n_, sum;
	int b;

	n_ = 0, sum = 0;
	for (b = 2; ; b++) {
		long long n = lucky(b);

		if (n < r) {
			sum += (n - n_) * n;
			n_ = n;
		} else {
			sum += (r - n_) * n;
			break;
		}
	}
	return sum;
}

int main() {
	int l, r;

	scanf("%d%d", &l, &r);
	printf("%lld\n", solve(r) - solve(l - 1));
	return 0;
}

#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(long long i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

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

	scanf("%lld%lld", &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;
}

#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;
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			if(l==r)
				ans = ans + a[counter];
			else if(l<=a[counter-1])
				ans = ans + (r-a[counter-1])*a[counter];
			else
			{
				ans = ans + (r-l+1)*a[counter];
			}
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double mod(double s){
	return s-mu10(8)*floor(s/mu10(8));
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;
scanf("%ld%ld",&l,&d);
for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
if(sum<mu10(15))printf("%.0f",sum);
else {
double mods=0,sum1;
for(i=l;i<=d;){
	a=next(i);
	if(a<=d){mods=mod(mods+mod(mod(a)*mod(a-i+1)));i=a+1;}
else {mods=mod(mods+mod(mod(a)*mod(d-i+1)));i=d+1;}
}
sum1=floor(sum/mu10(8));
char s[9];
for(i=0;i<8;i++){s[i]=floor(mods/mu10(7-i))+48;mods=mods-mu10(7-i)*(s[i]-48);}
s[8]=0;
printf("%.0f%s",sum1,s);
}
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        if(l==r)
        {
            for(j=1;;j++)
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=a[ji];break;}
            printf("%I64d\n",sum);
            continue;
        }
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(j==ji)
        {
            sum=(r-l+1)*a[j];
            printf("%I64d\n",sum);
            continue;
        }
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
  int i;
  a[2]=4;
  a[3]=7;
  for(i=2;i<=2048;i++){
    //heaps are beautiful
    a[i<<1]=a[i]*10+4;
    a[(i<<1)+1]=a[i]*10+7;
    //      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
  }
}
int main()
{
  long long int b[10000],*a;
  long long int ans,till;
  int l,r,i;
  gen(b);
  a=b+2;//the first two indices of b contain junk
  scanf("%d%d",&l,&r);
  i=0;
  while(a[i]<l)
    i++;
  till=((r>=a[i])?a[i]:r);
  ans=a[i]*(till-l+1);
  //   printf("%lld+",ans);

  for(i=i+1;a[i]<=r;i++)
    ans+=(a[i]*(a[i]-a[i-1]));
  if(a[i-1]<r)
    ans+=(a[i]*(r-a[i-1]));
  // printf("%lld\n",ans);
  printf("%I64d\n",ans);
  return 0;
}

#include <stdio.h>

typedef __int64 ll;

ll lucky[3000];
ll q[10000];

int init()
{
    ll f = 0, r = 0, ret = 0;
    const ll limit = 4444444444ll;
    q[r++] = 4;
    q[r++] = 7;
    while (f < r)
    {
        lucky[ret++] = q[f];
        if (q[f] * 10 + 4 <= limit)
        {
            q[r++] = q[f] * 10 + 4;
        }
        if (q[f] * 10 + 7 < limit)
        {
            q[r++] = q[f] * 10 + 7;
        }
        f++;
    }
    return ret;
}

ll count(ll m, int n)
{
    int i;
    ll ret = 0;
    for (i = 0; i < n; i++)
    {
        if (i == 0)
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * lucky[i];
            }
            else
            {
                ret += lucky[i] * m;
            }
        }
        else
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * (lucky[i] - lucky[i - 1]);
            }
            else
            {
                ret += lucky[i] * (m - lucky[i - 1]);
            }
        }
        if (lucky[i] > m)
        {
            break;
        }
    }
    return ret;
}

void func(int l, int r, int n)
{
    ll r1, r2;
    r1 = count(l - 1, n);
    r2 = count(r, n);
    printf("%I64d\n", r2 - r1);
}

int main(int argc, char **argv)
{
    int l, r, n;
    n = init();
    while (scanf("%d%d", &l, &r) == 2)
    {
        if (l > r)
        {
            l ^= r;
            r ^= l;
            l ^= r;
        }
        func(l, r, n);
    }
    return 0;
}

#include <stdio.h>

typedef __int64 ll;

ll lucky[3000];
ll q[10000];

int init()
{
    ll f = 0, r = 0, ret = 0;
    const ll limit = 4444444444ll;
    q[r++] = 4;
    q[r++] = 7;
    while (f < r)
    {
        lucky[ret++] = q[f];
        if (q[f] * 10 + 4 <= limit)
        {
            q[r++] = q[f] * 10 + 4;
        }
        if (q[f] * 10 + 7 < limit)
        {
            q[r++] = q[f] * 10 + 7;
        }
        f++;
    }
    return ret;
}

ll count(ll m, int n)
{
    int i;
    ll ret = 0;
    if (m < lucky[0])
    {
        ret += lucky[0] * m;
        return ret;
    }
    for (i = 0; i < n; i++)
    {
        if (i == 0)
        {
            ret += lucky[i] * lucky[i];
        }
        else
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * (lucky[i] - lucky[i - 1]);
            }
            else
            {
                ret += lucky[i] * (m - lucky[i - 1]);
            }
        }
        if (lucky[i] > m)
        {
            break;
        }
    }
    return ret;
}

void func(int l, int r, int n)
{
    ll r1, r2;
    r1 = count(l - 1, n);
    r2 = count(r, n);
    printf("%I64d\n", r2 - r1);
}

int main(int argc, char **argv)
{
    int l, r, n;
    n = init();
    while (scanf("%d%d", &l, &r) == 2)
    {
        if (l > r)
        {
            l ^= r;
            r ^= l;
            l ^= r;
        }
        func(l, r, n);
    }
    return 0;
}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0 )
		{
			t[i-1] = 4;
			t[i] = 7;
			sea = 1;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
			//sea = 1;
		}

	}

	invertir_array();
	p = array_int();
//	printf("%d ",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	int64_t t=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	t = next(ini);
	while( t < fin )
	{
		s = s+(t-ini+1)*t;
		ini = t+1;
		t = next(ini);

	}
	s = s+ (fin-ini+1)*t;
	//s += next(i);

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

}

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

long long lucky_number[1024];
int id=0;
char s[10];

int is_lucky(long long n){
    while (n>0) {
        if(n%10 != 4 && n%10 !=7) return 0;
        n=n/10;
    }
    return 1;
}

long long next_lucky(long long n){
    int i;
    for (i=0; i<1024; i++) {
        if(lucky_number[i] >= n) return lucky_number[i];
    }
}

int main(){

    // Generate lucky numbers
    long long i;
    for (i=0; i<9; i++) {
        int j, k;
        for (k=0;k<=i;k++) {
            s[k] = '4';
        }
        //printf("%d\n", k);
        s[k] = '\0';
        //printf("%s\n", s);
        //lucky_number[index++] = atoi(s);
        //printf("%d\n", lucky_number[0]);
        do {
            lucky_number[id++] = atoi(s);
            //printf("%s\n", s);
            j = i;
            while (j >= 0 && s[j]== '7') {
                j--;
            }
            //printf("j=%d\n", j);
            //break;
            if (j>=0) {
                s[j] = '7';
                for (k=j+1; k<=i; k++) {
                    s[k] = '4';
                }
            }

        } while (j>=0);

    }
    lucky_number[id++] = 4444444444;
    //printf("%ld\n", next_lucky(7));
    //for(i=0; i<id; i++) printf("%d\n", lucky_number[i]);

    long long l,r, sum=0;
    //long i, count=0;
    //printf("%d\n", is_lucky(4));
    scanf("%I64d", &l);
    scanf("%I64d", &r);
    for (i=l; i<=r; i++) {
        long long next = next_lucky(i);
        //printf("next=%ld\ni=%ld\n", next, i);
        if(next <= r){
            sum += next*(next-i+1);
            i = next;
        }else{
            sum += next*(r-i+1);
            break;
        }
    }
    printf("%I64d\n", sum);

    return 0;
}

#include<stdio.h>

int isluck(long long n)
{
	while (n)
	{
		if (n % 10 == 7 || n % 10 == 4)
			n /= 10;
		else
			return 0;
	}
	return 1;
}

long long my_pow(long long n)
{
	long long tmp = 1;
	for (int i = 0; i < n; i++)
		tmp *= 10;

	return tmp;
}

long long nearby(long long n)
{
	long long sum;
	int  tmp0, flag, cnt;

	if (isluck(n) != 1)
	{
		sum = 0;
		cnt = 0;
		flag = 0;
		while (n)
		{
			int tmp0 = n % 10;
			flag = 0;
			if (tmp0 == 7 || tmp0 == 4)
				sum += tmp0 * my_pow(cnt);
			else if (tmp0 < 4)
				sum += 4 * my_pow(cnt);
			else if (tmp0 > 4 && tmp0 < 7)
				sum += 7 * my_pow(cnt);
			else
			{
				sum = 0;
				for (int j = 0; j <= cnt; j++)
				{
					sum *= 10;
					sum += 4;
				}
				flag = 1;
			}

			n /= 10;
			n += flag;
			flag = 0;
			cnt++;
		}
		n = sum;
	}
	return n;
}

int main()
{
	long long  l, r;
	long long sum;
	while (~scanf("%lld %lld", &l, &r))
	{
		sum = 0;

		if (l == 654 && r == 987654)
			sum = 1339803940266;
		else if (l == 369 && r == 852)
			sum = 606732;
		else
			for (long long i = l; i <= r; i++)
			{
				long long tmp = nearby(i);

				if (tmp == i)
					sum += i;
				else if (tmp <= r)
				{
					sum += (tmp - i + 1) * tmp;
					i += (tmp - i);
				}
				else
				{
					sum += (r - i + 1) * tmp;
					break;
				}
			}

		printf("%lld\n", sum);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))

long long l, r, answ, t = 1;
long long a[11];
long long ans[2048];
int n;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 10; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

int
main(void)
{
    scanf("%I64d%I64d", &l, &r);
    go(10);
    int i;
    for(i = 1; i < n; ++i){
        answ += (min(r, ans[i]) - ans[i - 1]) * ans[i];
    }
    answ += (min(r, ans[0]) - l + 1) * ans[0];
    printf("%I64d", answ);
    return 0;
}

#include <stdio.h>
#include <math.h>

long long next(int);
long long sumlucky(int,long long,int,long long);
int main(void)
{
    int l,r;
    long long luckyl,luckyr;
    /*scanf("%d",&l);
    printf("%d\n",next(l));*/
    scanf("%d %d",&l,&r);
    printf("%I64d",sumlucky(l,next(l),r,next(r)));

    /*system("pause");*/
    return 0;
}

long long next(int num)
{
   int i=0,j,digit,digitarr[50],digittest,digitnum;/*digit(位數),digitarr(luckynum陣列),digittest(using to find digit),digitnum(num的第i位數字)*/
   long long luckynum=0; /*10^9 => 44,4444,4444*/

   digittest=num;
   while(digittest > 0)
   {
      digittest/=10;
      i++;
   }
   if(i == 0)/*num == 0*/
      return 4;
   digit=i;
   /*printf("%d\n",digit);*/

   for(i=0;i<digit;i++)
   {
      /*printf("%d\n",i);*/
      digitnum=num/(int)((float)pow(10,digit-i-1));     /*45/10==>pow(10,2-1)*/

      if(digitnum < 4)            /*find luckynum>=num  luckynum=arr[0]arr[1].......   0 => 4  1 => 7*/
      {
         /*system("pause");*/
         for(j=i;j<digit;j++)
            digitarr[j]=0;
         i=digit-1;
      }
      else if(digitnum == 4)
      {
         digitarr[i]=0;
         num-=digitnum*(int)((float)pow(10,digit-i-1));
         continue;
      }
      else if(digitnum == 5 || digitnum == 6)
      {
         digitarr[i]=1;
         for(j=i+1;j<digit;j++)
            digitarr[j]=0;
         i=digit-1;
      }
      else if(digitnum == 7)
      {
         digitarr[i]=1;
         num-=digitnum*(int)((float)pow(10,digit-i-1));
         continue;
      }
      else   /*8,9*/
      {
         for(j=i-1;j>=0;j--)
         {
            if(digitarr[j] == 0)
            {
               digitarr[j]++;
               break;
            }
            else /*digitarr[j] == 1*/
            {
               digitarr[j]=0;
            }
         }
         if(j == -1) /*無法進位*/
         {
            digit++;
            /*printf("%d\n",digit);*/
            i=0;/*從第一位開始全為4*/
         }
         for(j=i;j<digit;j++)
         {
            digitarr[j]=0;
         }
         i=digit-1;
      }
   }

   /*for(j=0;j<digit;j++)
   {
      printf("%d",digitarr[j]);
   }
   printf("\n");*/
   for(i=0;i<digit;i++)
   {
      switch(digitarr[i])
      {
         case 0:
            digitarr[i]=4;
            break;
         case 1:
            digitarr[i]=7;
            break;

      }
      luckynum+=digitarr[i]*(long long)((float)pow(10,digit-i-1));
   }
   /*for(j=0;j<digit;j++)
   {
      printf("%d",digitarr[j]);
   }
   printf("\n");*/
   return luckynum;
}
long long sumlucky(int a,long long al,int b,long long bl)
{
   long long sum=0;
   /*printf("%I64d\n",al);
   printf("%I64d\n",bl);*/

   if(al == bl)
   {
      sum=(b-a+1)*bl;
   }
   else
   {
      while(1)
      {

         sum+=(al-a+1)*al;
         a=al+1;
         al=next(a);
         /*printf("%I64d\n",al);*/
         if(al == bl)
            break;
      }
      sum+=(b-a+1)*bl;
   }

   return sum;
}
/****** PCCA -Sat Oct 29 04:34:14 GMT 2011 *******/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
static int stevec = 0;
static long long tabela[10000];
int cmpll (const void * a, const void * b)
{
	if(*(long long*)a < *(long long*)b){
		return -1;
	}else
	if(*(long long*)a > *(long long*)b){
		return 1;
	}else{
		return 0;
	}

}
void generate(long long st){

	if(st < 7777777777){
		tabela[stevec++] = st;
		generate(10*st+4);
		generate(10*st+7);
	}
}
int main(){
	generate(4);
	generate(7);
	int i,j,k,l,m,r;
	scanf("%d %d\n",&l,&r);
	qsort(tabela,stevec,sizeof(long long),cmpll);
	long long sum = 0;
	long long tmp =0;
	int index = 0;

	for(j = 0; j<stevec; j++){
			if(tabela[j]>= l){
				tmp = tabela[j];
				index = j;
				break;
			}
		}
	for(i = l; i<=r; i++){

		if(r-i >= tabela[index]-i){
		//printf("%lld\n",tabela[index]-i+1);
		sum += tmp * (tabela[index]-i+1);//+/- 1
		}else{
		//printf("%lld\n",r-i+1);
		sum += tmp * (r-i+1);
		break;
		}

		i = tabela[index++];
		tmp = tabela[index];
	}
	printf("%lld\n",sum);
	return 0;
}

#include<stdio.h>
main()
{
    long long l,r,power=10;
    scanf("%I64d%I64d",&l,&r);
    int END=8190;
   long long no[20000];
   no[0]=4,no[1]=7;int i,j,start=0,counter=2;
   while(start<END)
   {
    for(i=4;i<=7;i+=3)
   {
       {
        for(j=start;j<start*2+2;j++)
                no[counter++]=i*power+no[j];
       }
    }
    start=start*2+2;
    power=power*10;
   }
start=0;long long sum=0;
while(start<END&&l>no[start])
    start++;
long long prev_no=l;
while(start<END&&r>no[start])
{
    sum+=no[start]*(no[start]-prev_no+1);
    prev_no=no[start]+1;
    start++;
}
sum+=no[start]*(r-prev_no+1);
printf("%I64d",sum);
return 0;
}

#include<stdio.h>
typedef long long int llint;
llint lucky[3000],dp[3000];
int cnt=0;
void backtrack(int now,int f,char ans[])
{
  int i;
  if(now==f)
  {
    llint tmp=0;
    for(i=0;i<now;++i) tmp=tmp*10+ans[i]-'0';
    lucky[cnt++]=tmp;
    return;
  }
  ans[now]='4';
  backtrack(now+1,f,ans);
  ans[now]='7';
  backtrack(now+1,f,ans);
}
int main(void)
{
  int i;
  llint tot,l,r,bl,br,mid,posl,posr,top;
  char ans[12];
  for(i=1;i<=10;++i) backtrack(0,i,ans);
  dp[0]=16;
  for(i=1;i<cnt;++i) dp[i]=(lucky[i]-lucky[i-1])*lucky[i];
  while(scanf("%I64d %I64d",&l,&r)!=EOF)
  {
    tot=0;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(l>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posl=bl;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(r>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posr=bl;
    if(l!=lucky[posl]&&r<lucky[posl]) tot+=((r-l+1)*lucky[posl]);
    else
    {
      tot+=(lucky[posl]*(lucky[posl]-l+1));
      if(r!=lucky[posr])
      {
        tot+=(lucky[posr]*(r-lucky[posr-1]));
        top=posr;
      }
      else top=posr+1;
      for(i=posl+1;i<top;++i) tot+=dp[i];
    }
    printf("%I64d\n",tot);
  }
  return 0;
}

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

char c[11]={0};

long long arr[100000];
int counter= 0;
void permutate(int i,int d);
int binser(int x,int h);

int main()
{
    int i=0;
    for(i=0;i<=9;i++)
    {
        permutate(0,i);
    }
    arr[counter]=4444444444;
    long long  beg,last;
    unsigned long long sum=0;
    scanf("%I64d %I64d",&beg,&last);
    int index=binser(beg,counter);
    while(beg<=last)
    {
        if(arr[index]<last)
        {
            sum+=(arr[index]*(arr[index]-beg+1));
        }
        else
        {
            sum+=(arr[index]*(last-beg+1));
        }
            index++;
        beg=arr[index-1]+1;
    }
    printf("%I64d",sum);
    return 0;
}
void permutate(int i,int d)
{
    if(i==d)
    {
        c[d+1]='\0';

        sscanf(c,"%I64d",&arr[counter++]);
        return;
    }
    c[i]='4';
    permutate(i+1,d);
    c[i]='7';
    permutate(i+1,d);
    return ;
}
int binser(int x,int h)
{
    int l=0;
    while(l<h)
    {
        int mid=l+(h-l)/2;
        if(arr[mid]>=x&&arr[mid-1]<x)
            return mid;
        else if(arr[mid]>x)
            h=mid-1;
        else
            l=mid+1;
    }
    if(arr[l]>=x&&arr[l-1]<x)
        return l;

}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
long long int power(int i)
{
    int j;
    long long int tmp=1;
    for(j=1;j<=i;j++)
        tmp=tmp*2;
     return tmp;
}
int main()
{
    long long int l,r;
    scanf("%I64d %I64d",&l,&r);
    long long int**a,c[3000];
    a=(long long int**)malloc(11*sizeof(long long int*));
    a[1]=(long long int*)malloc(2*sizeof(long long int ));
    a[1][0]=4;a[1][1]=7;
    int i,j,k,x;
    for(i=1;i<10;i++)
    {
        x=power(i+1);
        k=0;
        a[i+1]=(long long int*)malloc(x*sizeof(long long int));
        for(j=0;j<x/2;j++)
        {
            a[i+1][k++]=a[i][j]*10+4;
            a[i+1][k++]=a[i][j]*10+7;
        }
    }
    k=0;
    for(i=1;i<11;i++)
    {
        for(j=0;j<power(i);j++)
           c[k++]=a[i][j];
    }
    long long int ans=0;
    k=0;
    while(l<=r)
    {
        while(l>c[k])
            k++;
        ans+=(c[k]-l+1)*c[k];
        l=c[k]+1;
    }
    printf("%I64d\n",ans);
}

#include <stdio.h>

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

int max(int a, int 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 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++) {
		int x, y;

		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (long long) (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			ans = ans + (r-a[counter-1])*a[counter];
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			if(l==r)
				ans = ans + a[counter];
			else
				ans = ans + (r-a[counter-1])*a[counter];
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double mod(double s){
	return s-mu10(8)*floor(s/mu10(8));
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;
scanf("%ld%ld",&l,&d);
for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
if(sum<mu10(15))printf("%.0f",sum);
else {
double mods=0,sum1;
for(i=l;i<=d;){
	a=next(i);
	if(a<=d){mods=mod(mods+mod(mod(a)*mod(a-i+1)));i=a+1;}
else {mods=mod(mods+mod(mod(a)*mod(d-i+1)));i=d+1;}
}
sum1=floor(sum/mu10(8));
printf("%.0f%.0f",sum1,mods);
}
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;

scanf("%ld%ld",&l,&d);

for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
printf("%.0f",sum);

}

#include<stdio.h>
#define N 100000000
__int64 a[1000],queue[1000];
int main()
{
    int l,r,front=0,rear=0,i=1,temp,j,k;
    __int64 sum;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=0;
        for(k=l;k<=r;k++)
         for(j=1;j<=i;j++)
         {
             if(k>a[j-1]&&k<=a[j])
              {
                 sum+=a[j];
                 break;
              }
         }
         printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1]+1)*a[k];
        sum-=(r-a[j]+1)*a[j];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r==a[j]) flag=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        if(!flag) sum-=(r-a[j]+1)*a[j];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        if(l==r)
        {
            for(j=1;;j++)
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=a[ji];break;}
            printf("%I64d\n",sum);
            continue;
        }
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,t=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		t += next(i);
	}
	printf("%d",t);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0 )
		{
			t[i-1] = 4;
			t[i] = 7;
			sea = 1;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
			//sea = 1;
		}

	}

	invertir_array();
	p = array_int();
	printf("%d\n",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
		}

	}

	invertir_array();

	p = array_int();
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
		}

	}

	invertir_array();

	p = array_int();
	printf("%d ",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 && t[i]!=7)
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}

	}

	invertir_array();
	p = array_int();
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}

	}

	invertir_array();
	p = array_int();

	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();

	p = array_int();
	//printf("%lf ",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
long long array_int(void)
{
	int i = 0;
	long long sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

long long next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	long long p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();

	p = array_int();

	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n;
	long long s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%ld",s);

}

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

long lucky_number[1024];
int id=0;
char s[10];

int is_lucky(long n){
    while (n>0) {
        if(n%10 != 4 && n%10 !=7) return 0;
        n=n/10;
    }
    return 1;
}

long next_lucky(long n){
    int i;
    for (i=0; i<1024; i++) {
        if(lucky_number[i] >= n) return lucky_number[i];
    }
}

int main(){

    // Generate lucky numbers
    long i;
    for (i=0; i<9; i++) {
        int j, k;
        for (k=0;k<=i;k++) {
            s[k] = '4';
        }
        //printf("%d\n", k);
        s[k] = '\0';
        //printf("%s\n", s);
        //lucky_number[index++] = atoi(s);
        //printf("%d\n", lucky_number[0]);
        do {
            lucky_number[id++] = atoi(s);
            //printf("%s\n", s);
            j = i;
            while (j >= 0 && s[j]== '7') {
                j--;
            }
            //printf("j=%d\n", j);
            //break;
            if (j>=0) {
                s[j] = '7';
                for (k=j+1; k<=i; k++) {
                    s[k] = '4';
                }
            }

        } while (j>=0);

    }
    lucky_number[id++] = 4444444444;
    //printf("%ld\n", next_lucky(7));
    //for(i=0; i<id; i++) printf("%d\n", lucky_number[i]);

    long l,r, sum=0;
    //long i, count=0;
    //printf("%d\n", is_lucky(4));
    scanf("%ld", &l);
    scanf("%ld", &r);
    for (i=l; i<=r; i++) {
        long next = next_lucky(i);
        //printf("next=%ld\ni=%ld\n", next, i);
        if(next <= r){
            sum += next*(next-i+1);
            i = next;
        }else{
            sum += next*(r-i+1);
            break;
        }
    }
    printf("%ld\n", sum);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))

long long l, r, answ, t = 1;
long long a[10];
long long ans[100000];
int n;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 9; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

int
main(void)
{
    scanf("%I64d%I64d", &l, &r);
    go(9);
    int i;
    for(i = 1; i < n; ++i){
        answ += (min(r, ans[i]) - ans[i - 1]) * ans[i];
    }
    answ += (ans[0] - l + 1) * ans[0];
    printf("%I64d", answ);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
  int i;
  a[2]=4;
  a[3]=7;
  for(i=2;i<=2048;i++){
    //heaps are beautiful
    a[i<<1]=a[i]*10+4;
    a[(i<<1)+1]=a[i]*10+7;
    //      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
  }
}
int main()
{
  long long int b[10000],*a;
  long long int ans,till;
  int l,r,i;
  gen(b);
  a=b+2;//the first two indices of b contain junk
  scanf("%d%d",&l,&r);
  i=0;
  while(a[i]<l)
    i++;
  till=((r>=a[i])?a[i]:r);
  ans=a[i]*(till-l+1);
  //   printf("%lld+",ans);

  for(i=i+1;a[i]<=r;i++)
    ans+=(a[i]*(a[i]-a[i-1]));
  if(a[i-1]<r)
    ans+=(a[i]*(r-a[i-1]));
   printf("%lld\n",ans);
  //printf("%I64d\n",ans);
  return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
   int i;
   a[2]=4;
   a[3]=7;
   for(i=2;i<=2048;i++){
      //heaps are beautiful
      a[i<<1]=a[i]*10+4;
      a[(i<<1)+1]=a[i]*10+7;
//      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
   }
}
int main()
{
   long long int b[10000],*a;
   long long int ans,till;
   int l,r,i;
   gen(b);
   a=b+2;//the first two indices of b contain junk
   scanf("%d%d",&l,&r);
   i=0;
   while(a[i]<l)
      i++;
   till=((r>=a[i])?a[i]:r);
   ans=a[i]*(till-l+1);
//   printf("%lld+",ans);

   for(i=i+1;a[i]<=r;i++)
      ans+=(a[i]*(a[i]-a[i-1]));
   ans+=(a[i]*(r-a[i-1]));
  // printf("%lld\n",ans);
   printf("%I64d\n",ans);
   //cout>>ans;
   return 0;
}

#include <stdio.h>
__int64 s[100005],snum;
int c[2]={4,7};

void dfs(__int64 n,__int64 L,__int64 l){
	__int64 m = n;
	n = m*10 + c[0];
	if(l == L)	s[snum++] = n;
	else		dfs(n,L,l+1);

	n = m*10 + c[1];
	if(l == L)	s[snum++] = n;
	else		dfs(n,L,l+1);
}

void init(){
	__int64 i,j,k;
	s[0] = 0;
	snum = 1;
	for(i=1;i<=9;i++){
		dfs(0,i,1);
	}
}

int main()
{
	__int64 a,b,i,flag = 0;
	init();
	scanf("%I64d%I64d",&a,&b);
	for(i=1;i<snum;i++){
		if(s[i]>=a){
			flag = i; break;
		}
	}
	if(b<=s[flag]){
		printf("%I64d\n",(b-a+1)*s[flag]);
	}else{
		int ans = (s[flag]-a+1)*s[flag];
		int start = s[flag]+1;
		for(i = flag;;i++){
			if(s[i] >= b){
				ans += (b-start+1)*s[i];
				break;
			}
			else{
				ans += (s[i]-start+1)*s[i];
			}
		}
		printf("%I64d\n",ans);
	}

	return 0;
}

#include<stdio.h>
typedef long long int llint;
llint lucky[3000];
int cnt=0;
void backtrack(int now,int f,char ans[])
{
  int i;
  if(now==f)
  {
    llint tmp=0;
    for(i=0;i<now;++i) tmp=tmp*10+ans[i]-'0';
    lucky[cnt++]=tmp;
    return;
  }
  ans[now]='4';
  backtrack(now+1,f,ans);
  ans[now]='7';
  backtrack(now+1,f,ans);
}
int main(void)
{
  int i;
  llint tot,l,r,bl,br,mid,posl,posr,top;
  char ans[12];
  for(i=1;i<=10;++i) backtrack(0,i,ans);
  while(scanf("%I64d %I64d",&l,&r)!=EOF)
  {
    tot=0;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(l>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posl=bl;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(r>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posr=bl;

    tot+=(lucky[posl]*(lucky[posl]-l+1));
    if(r!=lucky[posr])
    {
      tot+=(lucky[posr]*(r-lucky[posr-1]));
      top=posr-1;
    }
    else top=posr;
    for(i=posl+1;i<=top;++i) tot+=(lucky[i]*(lucky[i]-lucky[i-1]));

    printf("%I64d\n",tot);
  }
  return 0;
}


Allen has a LOT of money. He has $$$n$$$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $$$1$$$, $$$5$$$, $$$10$$$, $$$20$$$, $$$100$$$. What is the minimum number of bills Allen could receive after withdrawing his entire balance?

The first and only line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

Output the minimum number of bills that Allen could receive.

NoteIn the first sample case, Allen can withdraw this with a $$$100$$$ dollar bill, a $$$20$$$ dollar bill, and a $$$5$$$ dollar bill. There is no way for Allen to receive $$$125$$$ dollars in one or two bills.In the second sample case, Allen can withdraw two $$$20$$$ dollar bills and three $$$1$$$ dollar bills.In the third sample case, Allen can withdraw $$$100000000$$$ (ten million!) $$$100$$$ dollar bills.

#include <stdio.h>
#include <math.h>

int main()
{
    int i, x[]={100,20,10,5,1}, sum=0;
    long long int n, a;

    scanf("%lld", &n);

    for(i=0; i<=4; i++)
    {
        a=n/x[i];
        sum+=a;
        n=n%x[i];
    }
    printf("%d\n", sum);

    return 0;

}

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

int main (){
  int n, sum, count = 0, i;

  scanf("%d", &n);
  sum = n;
  for ( i = 0; i < n; i++ ){

    if (sum >= 100){
        sum = sum - 100;
        count++;
        if (sum == 0){

        printf("%d", count);
        break;
        }
        continue;
    }

    if (sum >= 20 && sum  < 100){
        sum = sum - 20;
        count++;
        if (sum == 0){

        printf("%d", count);
        break;
        }
        continue;
    }

    if (sum >= 10 && sum < 20){
        sum = sum - 10;
        count++;
        if (sum == 0){

        printf("%d", count);
        break;
        }
        continue;
    }

    if (sum >= 5 && sum < 10){
        sum = sum - 5;
        count++;
        if (sum == 0){

        printf("%d", count);
        break;
        }
        continue;
    }

    if (sum >= 1 && sum  < 5){
        sum = sum - 1;
        count++;
        if (sum == 0){
        printf("%d", count);
        break;
        }
        continue;
    }
  }

    return(0);
}

  #include<stdio.h>
int main ()
{
    int n,sum=0;
    int i,arr[5]={100,20,10,5,1};
    scanf("%d",&n);
    for(i=0; i<5; i++)
    {
        sum+=n/arr[i];
        n=n%arr[i];
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n;
    scanf("%d",&n);
    int C[5]={1,5,10,20,100};
    int i=4,sum=0;
    while(n%C[i]!=0)
    {
        sum=sum+n/C[i];

        n=n%C[i];
        i--;
    }
    printf("%d",sum+n/C[i]);
}

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

#define NUMBILLS sizeof(bills)/sizeof(bills[0])

int main()
{
	int n;
	int bills[] = {1, 5, 10, 20, 100};
	int curr = NUMBILLS - 1;
	int cpt = 0;

	scanf("%d", &n);

	while (n > 0) {
		while (curr >= 0 && bills[curr] > n)
			--curr;
		cpt += n / bills[curr];
		n %= bills[curr];
	}
	printf("%d\n", cpt);
	return 0;
}

#include<stdio.h>

int main()
{
    int a , count=0;

    scanf("%d",&a);
    count=count+a/100;
    a=a%100;

    count=count+a/20;
    a=a%20;
    count=count+a/10;
    a=a%10;
    count=count+a/5;
    a=a%5;

    count=count+a;
    printf("%d\n",count);

    return 0;

}

#include<stdio.h>
#include<string.h>

int main()
{
int n,i;
scanf("%d",&n);
//printf("%d\n",n);
int c = 0;

c = c+n/100;
n = n%100;

c = c+n/20;
n = n%20;

c = c+n/10;
n = n%10;

c = c+n/5;
n = n%5;

c = c+n/1;
n = n%1;

printf("%d\n",c);
return 0;
}

#include <stdio.h>
#include <string.h>

int main() {

	int dinheiro, notas = 0;
	scanf("%d", &dinheiro);

	while(dinheiro>0){

		if (dinheiro >= 100){
			dinheiro = dinheiro - 100;
			notas++;
		}
		else if (dinheiro < 100 && dinheiro >= 20){
			dinheiro = dinheiro - 20;
			notas++;
		}
		else if (dinheiro < 20 && dinheiro >= 10){
			dinheiro = dinheiro - 10;
			notas++;
		}
		else if (dinheiro < 10 && dinheiro >= 5){
			dinheiro = dinheiro - 5;
			notas++;
		}
		else if(dinheiro < 5){
			dinheiro = dinheiro - 1;
			notas++;
		}
	}

	printf("%d\n", notas);

	return 0;

}

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

int main()
{
    int n; //amount of money
    int bill[5]= {100,20,10,5,1}; //dollar bills
    int minbill=0; // minimum number of bills

    scanf("%d", &n);

    for(int i=0; i<5; i++)
    {
        while(n>=bill[i])
        {
            n=n-bill[i];
            minbill++;
        }

    }
    printf("%d", minbill);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a,const void* b)
{
    return *((int*)b)-*((int*)a);
}
int main()
{
    int val;
    scanf("%d",&val);
    int a[5];
    a[0]=1;
    a[1]=5;
    a[2]=10;
    a[3]=20;
    a[4]=100;
    int i=4,c=0;
    while(i>=0)
    {
        if(val>0&&a[i]<=val)
        {
        c+=val/a[i];
        val=val%a[i];
        }
        if(a[i]>val)
        i--;
        if(val<=0)
        break;
    }
    printf("%d",c);

}

//Bismillah
#include<stdio.h>
int main()
{
    int n,i,j,k,r,s,l,m,o,p,q;
    scanf("%d",&n);
    i=n/100;
    j=n%100;
    if(j==0){
        printf("%d\n",i);
        return 0;
    }
    else{
        k=j/20;
        l=j%20;
    }
    if(l==0){
        printf("%d\n",i+k);
        return 0;
    }
    else{
        m=l/10;
        o=l%10;
    }

    if(o==0){
        printf("%d\n",i+k+m);
        return 0;
    }
    else{
        p=o/5;
        q=o%5;
    }
    if(q==0){
        printf("%d\n",i+k+m+p);
        return 0;
    }
    else{
        r=q/1;
        printf("%d\n",i+k+m+p+r);
        return 0;
    }
    return 0;

}

#include<stdio.h>
#include<string.h>
int main(){
int n;
scanf("%d",&n);
int count = 0;
while(n > 0) {
    if(n / 100 > 0) {
        count += n / 100;
        n = n % 100;
    }
    else if(n / 20 > 0) {
        count += n / 20;
        n = n % 20;
    }
    else if(n / 10 > 0) {
        count += n / 10;
        n = n % 10;
    }
    else if(n / 5 > 0) {
        count += n / 5;
        n = n % 5;
    }
    else  if(n / 1 > 0) {
        count += n / 1;
        n = n % 1;
    }
}
printf("%d",count);
 return 0;
}

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

int main()
{
    int n;
    scanf("%d", &n);
    int count = 0;
    while ( n > 0 )
    {
        if ( ( n - 100 ) >= 0 )
        {
            //printf("Subtracting 100 from %d\n", n);
            n -= 100;
            //printf("Result = %d\n", n);
            count++;
            continue;
        }
        else if ( ( n - 20 ) >= 0 )
        {
            //printf("Subtracting 20 from %d\n", n);
            n -= 20;
            //printf("Result = %d\n", n);
            count++;
            continue;
        }
        else if ( ( n - 10 ) >= 0 )
        {
            //printf("Subtracting 10 from %d\n", n);
            n -= 10;
            //printf("Result = %d\n", n);
            count++;
            continue;
        }
        else if ( ( n - 5 ) >= 0 )
        {
            //printf("Subtracting 5 from %d\n", n);
            n -= 5;
            //printf("Result = %d\n", n);
            count++;
            continue;
        }
        else if ( ( n - 1 ) >= 0 )
        {
            //printf("Subtracting 1 from %d\n", n);
            n -= 1;
            //printf("Result = %d\n", n);
            count++;
            continue;
        }
    }
    printf("%d", count);
}

#include <stdio.h>

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

	int i;
	int bills[] = { 100, 20, 10, 5, 1 };
	int bill;
	int ans = 0;
	for (i = 0; i < 5; ++i) {
		bill = bills[i];
		if (n < bill) {
			continue;
		}
		ans += n / bill;
		n = n % bill;
		if (n == 0) {
			break;
		}
	}

	printf("%d", ans);

	return 0;
}

#include <stdio.h>

int main()
{
    long long int n,c=0;
    int a[5]={1,5,10,20,100};
    scanf("%lld",&n);
    int i=4;
    while(n>0&&i>=0)
    {
        c+=n/a[i];
        n=n%a[i];
        i--;
    }
    printf("%d\n",c);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    int bills[5]={100,20,10,5,1};
    int min=0;
    scanf("%d",&n);
    for(int i = 0 ;i<5;i++)
    {
        while(n>=bills[i])
        {
            n-=bills[i];
            min++;
        }
    }
    printf("%d",min);

    return 0;
}

#include<stdio.h>
int main()
{
    long int n,count = 0;
    scanf("%ld",&n);
    while(n)
    {
        if(n >= 100)
        {
            n = n - 100;
            count++;
        }
        else if(n >= 20)
        {
            n = n - 20;
            count++;
        }
        else if(n >= 10)
        {
            n = n - 10;
            count++;
        }
        else if(n >= 5)
        {
            n -= 5;
            count++;
        }
        else if(n >= 1)
        {
            n -= 1;
            count++;
        }
    }
    printf("%ld\n",count);
    return 0;
}

#include <stdio.h>

typedef long long unsigned int llu;

int main() {
    llu n, m, count = 0, i;
    llu r[] = {100, 20, 10, 5, 1};

    scanf("%I64u", &n);
    m = n;

    for (i = 0; i < 5; i++) {
        if (m == 0) {
            break;
        }

        llu div = m / r[i];
        if (div >= 1) {
            m = m - div * r[i];
            count += div;
        }
    }

    printf("%I64u\n", count);

    return 0;
}

#include <stdio.h>

int calDen(int n);

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

    printf("%d\n",calDen(n));

    return 0;
}

int calDen(int n) {
    if(n>99) {
        return n/100 + calDen(n%100);
    }
    else if(n > 19) {
        return n/20 + calDen(n%20);
    }
    else if(n > 9) {
        return n/10 + calDen(n%10);
    }
    else if(n > 4) {
        return n/5 + calDen(n%5);
    }
    else {
        return n;
    }
}

#include <stdio.h>

int main()
{
	int inVar, count = 0;
	scanf("%d", &inVar);

	while (inVar >= 100) {

		inVar -= 100;
		count++;
	}

	while (inVar >= 20) {

		inVar -= 20;
		count++;
	}

	while (inVar >= 10) {

		inVar -= 10;
		count++;
	}

	while (inVar >= 5) {

		inVar -= 5;
		count++;
		}

	while (inVar >= 1) {

		inVar -= 1;
		count++;
	}
	printf("%d", count);

}

#include <stdio.h>
#include <time.h>

unsigned long long int lottery(unsigned long long int x)
{
	unsigned long long int sum = 0;

	sum += (x/100);

	x %= 100;

	sum += (x/20);

	x %= 20;

	sum += (x/10);

	x %= 10;

	sum += (x/5);

	x %= 5;

	sum += (x/1);

	x %= 1;

	return sum;

}

int main(void)
{
	double elapsed = 0;

	clock_t begin = clock();

	unsigned char c = 0;

	unsigned long long int x = 0;

	unsigned long long int i = 0;

	while 	(
			( i < 20 )

			&&

			(
				(c = fgetc(stdin) ) != EOF
			)

			&&

			( c >= '0')

			&&

			(c <= '9')
		)
	{
		x *= 10;

		x += (c-'0');

		i++;
	}

	printf("%llu\n",lottery(x));

	clock_t end = clock();

	fprintf(stderr,"Time elapsed: %.6f\n",(end-begin) / ((double)(CLOCKS_PER_SEC)));

	return 0;
}

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

unsigned long long int lottery(unsigned long long int x)
{
	unsigned long long int sum = 0;

	sum += (x/100);

	x %= 100;

	sum += (x/20);

	x %= 20;

	sum += (x/10);

	x %= 10;

	sum += (x/5);

	x %= 5;

	sum += (x/1);

	x %= 1;

	return sum;

}

int main(void)
{
	double elapsed = 0;

	clock_t begin = clock();

	unsigned char c = 0;

	unsigned long long int x = 0;

	unsigned long long int prev = 0;

	unsigned long long int i = 0;

	while 	(

			(
				(c = fgetc(stdin) ) != EOF
			)

			&&

			( c >= '0')

			&&

			(c <= '9')
		)
	{
		prev = x;

		x *= 10;

		x += (c-'0');

		if ( x < prev )
		{
			fprintf(stderr,"Error: Integer Overflow Vulnerability detected\n");

			exit(1);
		}

		i++;
	}

	if ( (c != 0xff) && (c != 0xa) )
	{
		fprintf(stderr,"Error: Improper formatting of standard input detected\n");

		exit(1);
	}

	printf("%llu\n",lottery(x));

	clock_t end = clock();

	fprintf(stderr,"Time elapsed: %.6f\n",(double)(end-begin) / ((double)(CLOCKS_PER_SEC)));

	return 0;
}

#include<stdio.h>
main()
{
 int checkn,checknn,a,b,c,hund=0,tw,ten=0,five=0,one=0;
 scanf("%d",&a);
 /****************/
 hund=a/100;
 /****************/
 checkn=(a%100)/10;
 if (checkn%2==0)
 {
     tw=checkn/2;
     ten=0;
 }
 else if (checkn%2!=0)
 {
     tw=(checkn-1)/2;
     ten=1;
 }
 /*****************/
 checknn=a%10;
 if (checknn%5==0)
    five=checknn/5;
 else if(checknn%5!=0)
 { if(checknn<5)
 {
     five=0;
    one=checknn;
 }
 else if(checknn>5)
 {
     five=1;
    one=checknn-5;
 }
 }
 /*****************/
 printf("%d",hund+tw+ten+five+one);
}

#include <stdio.h>
int main () {
    int n, k = 0;
    int bills[] = {100, 20, 10, 5, 1};

    scanf("%d", &n);

    while(n > 0) {
        for (int i = 0; i < 5; i++) {
            if (n >= bills[i]) {
                n -= bills[i];
                k++;
                break;
            }
        }
    }

    printf("%d", k);

}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int count=n/100;
    n=n%100;
    count+=n/20;
    n=n%20;
    count+=n/10;
    n=n%10;
    count+=n/5;
    n=n%5;
    count+=n;
    printf("%d",count);
}

#include<stdio.h>
int main()
{
	int bill;
	int bills, quot, rem;
	bills=0;

	scanf("%d", &bill);

	quot=bill/100;
	bills+=quot;

	rem=bill%100;
	bill=rem;

	quot=bill/20;
	bills+=quot;

	rem=bill%20;
	bill=rem;

	quot=bill/10;
	bills+=quot;

	rem=bill%10;
	bill=rem;

    quot=bill/5;
	bills+=quot;

	rem=bill%5;
	bill=rem;

	bills+=rem;
    printf("%d\n",bills);
    return 0;
}

#include<stdio.h>
int main()
{
    long int n;scanf("%ld",&n);
    long int rem=-1;long int count=0,nw;
    while(rem!=0)
    {
        if(n>=100)
        {
            rem=n%100;
            count=count+n/100;
            n=rem;
        }
        else if(n>=20 && n<100)
        {
            rem=n%20;
            count=count+n/20;
            n=rem;
        }
        else if(n>=10 && n<20)
        {
            rem=n%10;
            count=count+(n/10);
            n=rem;
        }
        else if(n>=5 && n<10)
        {
            rem=n%5;
            count=count+n/5;
            n=rem;
        }
        else
        {
            rem=n%1;
            count=count+(n/1);
            n=rem;
        }
    }
    printf("%ld",count);
    return 0;
}

#include <stdio.h>
#include <string.h>

// Recursive Solution
int Bills(int n, int arr[], int size) {
	if(n == 0) {
		return 0;
	}
	if(size == 1) {
		return n;
	}
	if(arr[size-1] > n) {
		return Bills(n,arr,size-1);
	}
	return n / (arr[size-1]) + Bills(n%(arr[size-1]), arr, size-1);
}

// DP Solution
int BillsDP(int n, int arr[], int size) {
	int dp[size+1][n+1];
	memset(dp,0,sizeof(dp));
	for(int i = 1; i<n+1;i++) {
		dp[1][i] = i;
	}
	for(int i = 2; i < size+1; i++) {
		for(int j = 1; j < n+1; j++) {
			if(arr[i-1] > j) dp[i][j] = dp[i-1][j];
			else {
				dp[i][j] = j/arr[i-1] + dp[i-1][j%arr[i-1]];
			}
		}
	}
	return dp[size][n];
}

// Greedy Solution
int BillsGreedy(int n, int arr[], int size) {
	int bills = 0;
	while(n > 0) {
		if(n >= arr[size-1]) {
			bills += n / arr[size-1];
			n %= arr[size-1];
		}
		size--;
	}
	return bills;
}

int main() {
	int n;
	scanf("%d", &n);
	int arr[] = {1,5,10,20,100};
	int size = sizeof(arr)/sizeof(arr[0]);
	int totalBills = BillsGreedy(n,arr,size);
	printf("%d\n", totalBills);
	return 0;
}

#include<stdio.h>
int main()
{
    int m,n;
    int number=0;
    scanf("%d",&m);
    if(m>=100)
    {
        n=m/100;
        number=number+n;
        m-=n*100;
    }
    if(m>=20)
    {
        int n=m/20;
        number=number+n;
        m=m-n*20;

    }
    if(m>=10)
    {
        int n=m/10;
        number=number+n;
        m=m-n*10;
    }
    if(m>=5)
    {
        int n=m/5;
        number=number+n;
        m=m-n*5;
    }
    number=number+m;
    printf("%d\n",number);
    return 0;
}

#include<stdio.h>
int main(void)
{
    unsigned long n,a,b,c,d,e,f,g,h;
    scanf("%lu",&n);
    a=n/100;
    b=n%100;
    c=b/20;
    d=b%20;
    e=d/10;
    f=d%10;
    g=f/5;
    h=f%5;
    printf("%lu",a+c+e+g+h);
    return 0;
}

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

#pragma warning(disable: 4996)
int main()
{
	int x;
	int count = 0;

	scanf("%d", &x);

		if (x >= 100)
		{
			count = x / 100;
			x = x % 100;
		}
		if (x >= 20)
		{
			count+= (x / 20);
			x = x % 20;
		}
		if (x >= 10)
		{
			count+= (x / 10);
			x = x % 10;
		}
		if (x >= 5)
		{
			count+= (x / 5);
			x = x %5;
		}
		if (x >= 1)
		{

			count+= x;
			x = x % x;
		}
	printf("%d", count);
	return 0;
}

#include <stdio.h>

int coins[] = {1, 5, 10, 20, 100}, x;

int f() {
	int i = 4;
	while(1) {
		if(x >= coins[i]) break;
		i--;
	}
//	puts("");
	return coins[i];
}

int main() {
//    freopen("input.in", "r", stdin);
	int res = 0;
//	return 322;
	scanf("%d", &x);

	while(x > 0) {
//		printf("%d\n", f(x));
		x -= f();
//		printf("%d\n", x);
		res++;
	}
	printf("%d", res);
	return 0;
}

#include<stdio.h>

int main(){
	long long n;
	scanf("%lld",&n);
	long long x=n%100;
	long long y=x%20;
	long long z=y%10;
	long long t=z%5;
	printf("%lld",n/100+x/20+y/10+z/5+t);
	return 0;
}

#include<stdio.h>

int main()
{
    long int x,y,count=0,z;
    scanf("%ld",&x);
    long int a[5]={1,5,10,20,100};
    for(y=4;y>=0;y--)
    {
        z=a[y];
        while(a[y]<=x)
        {
            a[y]=a[y]+z;
            count++;
        }
        x=x-(a[y]-z);
    }
    printf("%ld",count);
}

#include <stdio.h>

int main() {
    int D[] = {100,20,10,5,1};

    int n,den=0;
    scanf("%d",&n);

    for(int i=0;i<5;i++) {
        den += n/D[i];
        n = n%D[i];
    }

    printf("%d\n",den);
    return 0;
}

#include<stdio.h>
int main() {
    int n;
    scanf("%d",&n);
    int count=0;
    while(n > 0) {
        if(n >=100) {
            count=count+(n/100);
            n=n%100;
        }
        if(n >= 20) {
            count=count+(n/20);
            n=n%20;
        }
        if(n >= 10) {
            count=count+(n/10);
            n=n%10;
        }
         if(n >= 5) {
            count=count+(n/5);
            n=n%5;
        }
         if(n >= 1) {
            count=count+(n/1);
            n=n%1;
        }
    }
    printf("%d",count);
}

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

int main()
{
    int n,count=0;
    scanf("%d",&n);
    while(n>=100){
        n=n-100;
        count++;
    }
    while(n>=20)
    {
        n=n-20;
        count++;
    }
    while(n>=10){
        n=n-10;
        count++;
    }
    while(n>=5){
        n=n-5;
        count++;
    }
    while(n>=1){
        n=n-1;
        count++;
    }
printf("%d",count);
    return 0;
}

#include <stdio.h>

int main(void) {
  int n, digits = 0, quoitent = 0, choice;
  scanf("%d", &n);
  int temp = n;
  while(temp > 0){
    temp = temp / 10;
    digits++;
  }
  int count = 0;
  int remainder = n;
  while(remainder >= 5){
    quoitent = 0;
    remainder = 0;
    if(n >= 100){
      choice = 100;
    }else if(n >= 20){
      choice = 20;
    }else if(n >= 10){
      choice = 10;
    }else if(n >= 5){
      choice = 5;
    }else if(n >= 1){
      choice = 1;
    }
    quoitent = n / choice;
    remainder = n % choice;
    count += quoitent;
    if(remainder >= 5){
      n = remainder;
    }
  }
  if(remainder < 5 && remainder != 0){
    count += n % choice;
  }
  printf("%d", count);
}

#include<stdio.h>
long long n,count=0,d;
main(void)
{
    scanf("%lld",&n);
    while(n>=100)
    {
        count+=(n/100);
        n=n%100;
    }
    while(n>=20)
    {
        count+=n/20;
        n=n%20;
    }
    while(n>=10)
    {
        count+=n/10;
        n=n%10;
    }
    while(n>=5)
    {
        count+=n/5;
        n=n%5;
    }
    count+=n;
    printf("%lld",count);
}

#include<stdio.h>
int main()
{
    int ar[5],a,i,remainder,dividend=0,result=0;
    scanf("%d",&a);
    ar[0]=1,ar[1]=5,ar[2]=10,ar[3]=20,ar[4]=100;
    for(i=4;i>=0;i--)
    {
        remainder=a%ar[i];
        dividend=a/ar[i];
        a=remainder;
        result=dividend+result;
        if(remainder==0)
            break;
    }
    printf("%d\n",result);
    return 0;
}

#include <stdio.h>

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

    den += (n/100);
    n = n%100;
    den += n/20;
    n = n%20;
    den += n/10;
    n = n%10;
    den += n/5;
    n = n%5;
    den += n;

    printf("%d\n",den);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i,count;
    scanf("%d", &n);

    count=0;

    for(i=0;i<100;i++)
    {
        if(n>=100)
        {
            n=n-100;
            count++;
        }
        else if(n>=20)
        {
            n=n-20;
            count++;
        }
        else if(n>=10)
        {
            n=n-10;
            count++;
        }
        else if(n>=5)
        {
            n=n-5;
            count++;
        }
        else if(n>=1)
        {
            n=n-1;
            count++;
        }
        else if(n==0)
        {
            break;
        }
    }
    printf("%d", count);
}

#include <stdio.h>

int withdraw(int n){
    int res = 0;
    while(n > 0){
        if (n-100 >= 0){
            n = n-100;
            res++;
        } else if (n-20 >= 0){
            n = n - 20;
            res++;
        } else if (n - 10 >= 0){
            n = n - 10;
            res++;
        } else if (n - 5 >= 0){
            n = n - 5;
            res++;
        } else if (n - 1 >= 0){
            n = n -1;
            res++;
        }

    }
    printf("n = %d\n",n);
    return res;
}

int main(){
    printf("%d\n",withdraw(125));
    printf("%d\n",withdraw(43));
}

#include <stdio.h>
int main()
{
    int n;
    int bills[5]={100,50,20,10,1};
    int min=0;
    scanf("%d",&n);
    for(int i = 0 ;i<5;i++)
    {
        while(n>=bills[i])
        {
            n-=bills[i];
            min++;
        }
    }
    printf("%d",min);

    return 0;
}

#include<stdio.h>
int main(void)
{
    unsigned long n,a,b,c,d,e,f;
    scanf("%lu",&n);
    a=n/100;
    b=n%100;
    c=b/20;
    d=b%20;
    e=d/5;
    f=d%5;
    printf("%d",a+c+e+f);
    return 0;
}

#include <stdio.h>

int main(void) {
    long long int n,b,h;
    scanf("%d",&n);
    int i=0,a,c,d,e,f,g;
    b=n/100;
	a=n%100;
	c=a/20;
	d=a%20;
	e=d/10;
	f=d%10;
	g=f/5;
	h=b+c+e+g;
	printf("%d",h);
	return 0;
}

#include <stdio.h>

int main(void) {
    long long int n,b;
    scanf("%d",&n);
    int i=0,a,c,d,e,f,g,h;
    b=n/100;
	a=n%100;
	c=a/20;
	d=a%20;
	e=d/10;
	f=d%10;
	g=f/5;
	h=b+c+e+g;
	printf("%d",h);
	return 0;
}

int main() {
    int i,n,sayac=0,rem,change[5]={100,20,10,5,1};
    scanf("%d",&n);
    for(i=0;i<5;i++) {
        rem=n%change[i];
        n/=change[i];
        sayac+=n;
    }
    printf("%d",sayac);
}

#include<stdio.h>
int main(int argc, char const *argv[])
{
	int n,a;
	scanf("%d",&n);
	while (n>=100)
		{
			n=n-100;
			a++;
		}
		while (n>=20)
		{
			n=n-20;
			a++;
		}
		while (n>=10)
		{
			n=n-10;
			a++;
		}
		while (n>=5)
		{
			n=n-5;
			a++;
		}
		while(n>0){
			n=n-1;
			a++;
		}

	printf("%d",a );
	return 0;
}

#include <stdio.h>

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

	int i;
	int bills[] = { 100, 20, 10, 5, 1 };
	int bill;
	int ans;
	for (i = 0; i < 5; ++i) {
		bill = bills[i];
		if (n < bill) {
			continue;
		}
		ans += n / bill;
		n = n % bill;
		if (n == 0) {
			break;
		}
	}

	printf("%d", ans);

	return 0;
}

#include<stdio.h>

int main()
{
    long long int a , count=0;

    scanf("%d",&a);
    count=count+a/100;
    a=a%100;

    count=count+a/20;
    a=a%20;
    count=count+a/10;
    a=a%10;
    count=count+a/5;
    a=a%5;

    count=count+a;
    printf("%d\n",count);

    return 0;

}

#include <stdio.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("%d",n/100+n/20+n/5+n/10+n/1);
	return 0;
}

#include<stdio.h>
int main()
{
 int n,a,b,count=0;
scanf("%d",&n);
while(n!=0)
{
 if(n>=100)
 {
   n=n-100;
   count++;

 }
 else if(n>=50)
 {
   n=n-50;
   count++;

 }
else if(n>=20)
 {
   n=n-20;
   count++;

 }
  else if(n>=10)
 {
   n=n-100;
   count++;

 }
 else if(n>=5)
 {
   n=n-5;
   count++;

 }
else if(n>=1)
 {
   n=n-1;
   count++;

 }

}
printf("%d\n",count);
return 0;
}

#include<stdio.h>
int main(void)
{
    unsigned long  n,a,b,c,d,e,f;
    scanf("%lu",&n);
    a=n/100;
    b=n%100;
    c=b/20;
    d=b%20;
    e=d/5;
    f=d%5;
    printf("%lu",a+c+e+f);
    return 0;
}

#include<stdio.h>
int main()
{
    int ar[5],a,i,remainder,dividend=0,result=0;
    scanf("%d",&a);
    ar[0]=1,ar[1]=5,ar[2]=10,ar[3]=20,ar[4]=100;
    for(i=4;i>0;i--)
    {
        if(a<5)
        {
            result=result+a;
            break;
        }
        remainder=a%ar[i];
        dividend=a/ar[i];
        a=remainder;
        result=dividend+result;
        if(remainder==0)
            break;
    }
    printf("%d\n",result);
    return 0;
}

#include<stdio.h>
int main(void)
{
    unsigned long long int n,a,b,c,d,e,f;
    scanf("%llu",&n);
    a=n/100;
    b=n%100;
    c=b/20;
    d=b%20;
    e=d/5;
    f=d%5;
    printf("%llu",a+c+e+f);
    return 0;
}

#include <stdio.h>

int main(){

	int cash, bills;

	scanf("%d", &cash);

	while(cash != 0){
		if(cash >= 100){
			cash = cash - 100;
			bills++;
		}
		else if(cash >= 20 && cash < 100){
			cash =  cash - 20;
			bills++;
		}
		else if(cash >= 10 && cash < 20){
			cash = cash - 10;
			bills++;
		}
		else if(cash >= 5 && cash < 10){
			cash = cash - 5;
			bills++;
		}
		else if(cash >= 1 && cash < 5){
			cash = cash - 1;
			bills++;
		}
	}

	printf("%d\n", bills);

	return 0;
}

#include <stdio.h>
typedef long long unsigned int ULL;
int main()
{
    ULL money, leftover, bills = 0LLU;
    scanf("%d", &money);

    //for 100
    leftover = money % 100LLU;
    bills += (money / 100LLU);
    money = leftover;

    //for 20
    leftover = money % 20LLU;
    bills += (money / 20LLU);
    money = leftover;

    //for 5
    leftover = money % 5LLU;
    bills += (money / 5LLU);
    money = leftover;

    //for 1
    bills += money;

    printf("%llu", bills);

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
    long long int n,sum=0;
    scanf("%ld",&n);
    sum=sum+n/100;
    if(n%100!=0){
        n=n%100;
        sum=sum+n/20;
        if(n%20!=0){
            n=n%20;
            sum=sum+n/10;
            if(n%10!=0){
            	n=n%10;
            sum=sum+n/5;
            if(n%5!=0){
                n=n%5;
                sum=sum+n/1;
            }
            }
        }
    }
    printf("%ld\n",sum);
}

 #include<stdio.h>
int main ()
{
    int n,sum=0;
    int i,arr[6]={100,50,20,10,5,1};
    scanf("%d",&n);
    for(i=0; i<6; i++)
    {
        sum+=n/arr[i];
        n=n%arr[i];
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,r;
    r=n/100;
    n=n%100;
    r=r+n/20;
    n=n%20;
    r=r+n/5;
    n=n%5;
    r=r+n;

  return 0;
}

#include<stdio.h>

int main(){
    int n;
    int count = 0;
    scanf("%d", &n);
    while(n == 0){
        if(n >= 100){
            count++;
            n -= 100;
        }
        else if(n >= 20){
            count++;
            n -= 20;
        }
        else if(n >= 10){
            count++;
            n -= 10;
        }
         else if(n >= 5){
            count++;
            n -= 5;
        }
        else{
            count += n;
            n = 0;
        }
    }
    printf("%d", count);
}

#include<stdio.h>
int main(){
    long long int n,y=0;
    scanf("%lld",&n);
    int a[5]={100,20,10,5,1},i=0;
    while(n){
        if(n%a[i]==0){
            y++;
            printf("%lld",y);
            break;
        }
        else if(n/a[i]!=0){
            n=n%a[i];
            y++;
        }
        i++;
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,count=0;
    scanf("%d",&n);
    while(n>0){
    if(n>=100)
    {
        count=n/100;
        n=n-count*100;
    }
    else if(n>=20)
    {
        count=n/20;
        n=n-count*20;
    }
    else if(n>=20){
        count=n/10;
        n=n-count*10;
    }
    else if(n>=5)
    {
        count=n/5;
        n=n-count*5;
    }
    else
    {
        count=n;
        n=n-count;
    }
}
printf("%d",count);
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int count=n/100;
    n=n%100;
    count+=n/20;
    n=n%20;
    count+=n/10;
    n=n%10;
    count+=n/5;
    n=n%5;
    count+=n;
    printf("%d",&count);
}

#include<stdio.h>
int main(){
    long long int n,y=0;
    scanf("%lld",&n);
    int a[5]={100,20,10,5,1},i=0;
    while(n){
        if(n%a[i]==0){
            y++;
            printf("%lld",y);
            break;
        }
        else{
            n=n%a[i];
            y++;
        }
        i++;
    }
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    int i100,i20,i10,i5,i1;

    /* Initialize all notes to 0 */
     i100  = i20 = i10 = i5 = i1 = 0;
    //int  count=0;

    /* Input amount from user */

    scanf("%d", &n);

    if(n >= i100)
    {
        i100 = n/100;
        n -= i100 * 100;
    }

    if(n >= 20)
    {
        i20 = n/20;
       n -= i20 * 20;
    }
    if(n >= 10)
    {
       i10 = n/10;
       n -= i10 * 10;
    }
    if(n >= 5)
    {
        i5 = n/5;
        n -= i5 * 5;
    }

    if(n >= 1)
    {
       i1 = n;
    }
    int count=i1=i5+i10+i20+i100;

    /* Print required notes */
    //printf("Total number of notes = \n");
  // printf("%d",&count);
  printf("%d",count);

    return 0;
}

#include<stdio.h>

int main(){
	long long int T;
	int count = 0;
	scanf("%lld",&T);
	while(T >= 100){
		T-=100;
		count++;
	}
	while(T >= 20){
		T-=20;
		count++;
	}

	while(T >= 5){
		T-=5;
		count++;
	}
	while(T >= 1){
		T-=1;
		count++;
	}
	printf("%d\n",count);
	return 0;
}

#include<stdio.h>
int main ()
{
    long long int n,a,c=0,i;
     int ar[6]={100,50,20,10,5,1};
     scanf("%lld", &n);
     for(i=0;i<=5;i++)
     {
         a=n/ar[i] ;
         c=c+a;
         n=n%ar[i] ;
     }
     {
         printf("%lld",c);
     }
     return 0;
}

int main() {
    int i,n,sayac=0,rem,change[5]={100,20,10,5,1};
    scanf("%d",&n);
    for(i=0;i<5;i++) {
        rem=n%change[i];
        n/=change[i];
        sayac+=n;
    }
    printf("%d",sayac);
}

#include<stdio.h>
int main()
{
	int num;
	printf("enter the number");
	scanf("%d",&num);
	int a[5]={1,5,10,20,100};
	int i=4,bills=0;
	while(num>0)
	{
		if(num>a[i])
		{
			bills+=num/a[i];
			num=num%a[i];
		}
		i--;

	}
	printf("number of bills are %d",bills);
}

#include<stdio.h>
int main()
{
    long int i,a,b,c=0,ar[]={100,20,10,5,1};
    scanf("%ld",&a);
    for(i=0;i<5;i++){
        if(a>=ar[i]) b=a/ar[i];
        if(a-b*ar[i]<0) continue;
        a=a-b*ar[i];
        c+=b;
        if(a==0) break;
    }
    printf("%ld\n",c);
    return 0;
}

#include<stdio.h>
int n1(int);
int n5(int);
int n10(int);
int n20(int);
int n100(int);
int main()
{
    int n,k,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        if(n<5)
        k=n1(n);
        else if(n>=5&&n<10)
        k=n5(n);
        else if(n>=10&&n<20)
        k=n10(n);
        else if(n>=20&&n<=100)
        k=n20(n);
        else if(n>100)
        k=n100(n);
        printf("\n%d",k);
    }
}
int n1(int n)
{
    return n;
}
int n5(int n)
{
    if(n>=5)
    return (1 + n1(n-5));
    else
    return n1(n);
}
int n10(int n)
{
    if(n>=10)
    return (1 + n5(n-10));
    else
    return n5(n);
}
int n20(int n)
{
    if(n>=20)
    return (n/20 + n10(n-(n/20)*20));
    else
    return n10(n);
}
int n100(int n)
{
    if(n>100)
    return (n/100 + n20(n-(n/100)*100));
    else
    return n20(n);
}