stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstdio>

using namespace std;



long long int ans=0,t;



void f(long long int k,bool r3,bool r5,bool r7){

    if(t<k)

        return ;

    else if(r3&&r5&&r7)

        ans++;

    f(10*k+3,true,r5,r7);

    f(10*k+5,r3,true,r7);

    f(10*k+7,r3,r5,true);

}



int main()

{

    scanf("%lld",&t);

    f(3,true,false,false);

    f(5,false,true,false);

    f(7,false,false,true);

    printf("%lld",ans);

}


// Faster C++ solution for the same problem (measured speedup: 4.675716673598034x):
#include<cstdio>



using namespace std;

int t,count=0;

void dfs(long long num,int flag357){

    if(num <= t){

        if(flag357==07)

            count++;

        dfs(num*10+3,flag357|01);

        dfs(num*10+5,flag357|02);

        dfs(num*10+7,flag357|04);

    }

}

int main()

{

    scanf("%d",&t);

    dfs(0,0);

    printf("%d",count);

    return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int N,count=0;

void dfs(long long,unsigned char);

int main(){

    cin>>N;

    dfs(0,0);

    cout<<count;

    return 0;

}

void dfs(long long nextNum,unsigned char flag357){

    if(nextNum<=N){

        if(flag357==07)    // 07 is BIN 111

            count++;

        dfs(nextNum*10+3,flag357|01); // BIN 001

        dfs(nextNum*10+5,flag357|02); // BIN 010

        dfs(nextNum*10+7,flag357|04); // BIN 100

    }

}

// Faster C++ solution for the same problem (measured speedup: 4.737418502527825x):
#include<cstdio>



using namespace std;

int t,count=0;

void dfs(long long num,int flag357){

    if(num <= t){

        if(flag357==07)

            count++;

        dfs(num*10+3,flag357|01);

        dfs(num*10+5,flag357|02);

        dfs(num*10+7,flag357|04);

    }

}

int main()

{

    scanf("%d",&t);

    dfs(0,0);

    printf("%d",count);

    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<iostream>

#include<algorithm>

#include<string>

#include<map>

#include<set>

#define maxn 1005

using namespace std;

typedef long long  LL;

int cnt=0;

LL n;

void f(LL num,int flag1,int flag2,int flag3)

{

    if(num<=n)

    {

        if(flag1&&flag2&&flag3)

            cnt++;

        f(num*10+3,1,flag2,flag3);

        f(num*10+5,flag1,1,flag3);

        f(num*10+7,flag1,flag2,1);

    }

    return ;

}

int main()

{



    scanf("%lld",&n);

    f(0,0,0,0);

    cout<<cnt<<endl;







    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.712027362223375x):
#include<cstdio>



using namespace std;

int t,count=0;

void dfs(long long num,int flag357){

    if(num <= t){

        if(flag357==07)

            count++;

        dfs(num*10+3,flag357|01);

        dfs(num*10+5,flag357|02);

        dfs(num*10+7,flag357|04);

    }

}

int main()

{

    scanf("%d",&t);

    dfs(0,0);

    printf("%d",count);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

using namespace std;



typedef long long LL;



int Total = 0;

int n;





void DPS(LL abc)

{

	if (abc > n)

		return;



	string check = to_string(abc);

	if (check.find('5') != string::npos && check.find('3') != string::npos&& check.find('7') != string::npos)

		Total++;

	DPS(abc * 10 + 5);

	DPS(abc * 10 + 3);

	DPS(abc * 10 + 7);

}



int main()

{

	cin >> n;

	DPS(0);

	cout << Total << endl;

}

// Faster C++ solution for the same problem (measured speedup: 8.067778158696482x):
#include<cstdio>



using namespace std;

int t,count=0;

void dfs(long long num,int flag357){

    if(num <= t){

        if(flag357==07)

            count++;

        dfs(num*10+3,flag357|01);

        dfs(num*10+5,flag357|02);

        dfs(num*10+7,flag357|04);

    }

}

int main()

{

    scanf("%d",&t);

    dfs(0,0);

    printf("%d",count);

    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<iostream>

#include<set>

#include<queue>

using namespace std;

int n;

int z;

int sum[1100000];

void dfs(int a,int b,int c,int num,int fl)

{

    if(num>1e9)

    {

        return ;

    }

    if(fl>9)

        return ;

    if(a&&b&&c)

    {

        sum[z++]=num;

        dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }

    else

    {

           dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }



}

int main()

{

    z=0;

    dfs(0,0,0,0,0);

    sort(sum,sum+z);

    int key;

    while(cin>>key)

    {



    int left = 0;

    int right =z-1;

    while (left <= right) {

        int mid = (left + right) / 2;

        if (sum[mid] > key) {

            right = mid - 1;

        }

        else {

            left = mid + 1;

        }

    }

    cout<<right+1<<endl;

    }



}




// Faster C++ solution for the same problem (measured speedup: 2.542971359252464x):
#include<bits/stdc++.h>

using namespace std;

#define int long long

#define pb push_back

vector<int>v, a, b, c;

int32_t main()

{

    ios_base::sync_with_stdio(0);

    int ans = 0, n = 0;

    cin >> n;



    int r = 1;

    for(int i = 1; v.size() <= 9; i++){

        v.pb(3);

        a = v;

        for(int j = i+1; v.size() <= 9; j++){

            v.pb(5);

            b = v;



            for(int k = j+1; v.size() <= 9; k++){

                v.pb(7);

                sort(v.begin(), v.end());

//                for(int ok = 0; ok < v.size(); ok++){

//                    cout << v[ok] <<" ";

//                }

//                cout << endl;



                do{

                    int rr = v[0];

                    for(int p = 1; p < v.size(); p++){

                        rr *= 10;

                        rr += v[p];

                    }

                    if(rr <= n){

                        ++ans;

                       // cout << rr << endl;

                    }

                    else{

                        break;

                    }





                }

                while(next_permutation(v.begin(), v.end()));



            }

            v = b;

        }

        v = a;

    }

    cout << ans;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<iostream>

#include<set>

#include<queue>

using namespace std;

int n;

int z;

int sum[1100000];

void dfs(int a,int b,int c,int num,int fl)

{

    if(num>1e9)

    {

        return ;

    }

    if(fl>9)

        return ;

    if(a&&b&&c)

    {

        sum[z++]=num;

        dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }

    else

    {

           dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }



}

int main()

{

    z=0;

    dfs(0,0,0,0,0);

    sort(sum,sum+z);

    int key;

    while(cin>>key)

    {



    int left = 0;

    int right =z-1;

    while (left <= right) {

        int mid = (left + right) / 2;

        if (sum[mid] > key) {

            right = mid - 1;

        }

        else {

            left = mid + 1;

        }

    }

    cout<<right+1<<endl;

    }



}




// Faster C++ solution for the same problem (measured speedup: 2.2924112868440023x):
#include<iostream>

#include<algorithm>

#include<stack>

using namespace std;

int coun=0;

long long T;

bool is_357(long long r)

{

    int j=0,i,cou[3]={3,7,5};

    while(r)

    {

        i=r%10;

        for(int p=0;p<3;p++)

            if(i==cou[p])

            {

                cou[p]=10;

                j++;

            }

        r/=10;

    }

    if(j==3)

        return true;

    return false;

}

void dfs(long long t)

{

    if(t<=T)

    {

        if(is_357(t))

        {

            coun++;

        }

        dfs(t*10+3);

        dfs(t*10+5);

        dfs(t*10+7);

    }

}

int main()

{

    scanf("%lld",&T);

    dfs(0);

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

    return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<iostream>

#include<set>

#include<queue>

using namespace std;

int n;

int z;

int sum[1100000];

void dfs(int a,int b,int c,int num,int fl)

{

    if(num>1e9)

    {

        return ;

    }

    if(fl>9)

        return ;

    if(a&&b&&c)

    {

        sum[z++]=num;

        dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }

    else

    {

           dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }



}

int main()

{

    z=0;

    dfs(0,0,0,0,0);

    sort(sum,sum+z);

    int key;

    while(cin>>key)

    {



    int left = 0;

    int right =z-1;

    while (left <= right) {

        int mid = (left + right) / 2;

        if (sum[mid] > key) {

            right = mid - 1;

        }

        else {

            left = mid + 1;

        }

    }

    cout<<right+1<<endl;

    }



}




// Faster C++ solution for the same problem (measured speedup: 2.4758069784607386x):
#include <iostream>

#include<cmath>

using namespace std;

long long int T,rs=0,sh;

int shu[3]={3,5,7};

bool g=0;int v[3]={0,0,0};

void cdt(int a,int b,long long int c)

{

	if(b==a)

	{

		if(c<=T)

			rs++;

		else

			g=1;

	}

	else

	{

		if(sh>=a-b)

		{

			for(int i=0;i<3;i++)

			{

				if(v[i]==0)

				{

					sh--;v[i]++;

					cdt(a,b+1,c+shu[i]*pow(10.0,a-b-1));

					sh++;v[i]--;

				}

				if(g)break;

			}

		}

		else

		{

			for(int i=0;i<3;i++)

			{

				if(v[i]==0){sh--;}

				v[i]++;

				cdt(a,b+1,c+shu[i]*pow(10.0,a-b-1));

				if(v[i]==1){sh++;}

				v[i]--;

				if(g)break;

			}

		}

	}

}

int main()

{

	cin>>T;

	for (int i=3;;i++)

	{	

		sh=3;

		cdt(i,0,0);

		if(g)break;

	}

	cout<<rs;

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<iostream>

#include<set>

#include<queue>

using namespace std;

int n;

int z;

int sum[1100000];

void dfs(int a,int b,int c,int num,int fl)

{

    if(num>1e9)

    {

        return ;

    }

    if(fl>9)

        return ;

    if(a&&b&&c)

    {

        sum[z++]=num;

        dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }

    else

    {

           dfs(1,b,c,num*10+3,fl+1);

        dfs(a,1,c,num*10+5,fl+1);

        dfs(a,b,1,num*10+7,fl+1);

    }



}

int main()

{

    z=0;

    dfs(0,0,0,0,0);

    sort(sum,sum+z);

    int key;

    while(cin>>key)

    {



    int left = 0;

    int right =z-1;

    while (left <= right) {

        int mid = (left + right) / 2;

        if (sum[mid] > key) {

            right = mid - 1;

        }

        else {

            left = mid + 1;

        }

    }

    cout<<right+1<<endl;

    }



}




// Faster C++ solution for the same problem (measured speedup: 2.68860270163888x):
#include <iostream>



using namespace std;



int N, total=0;



void dfs(long long n, unsigned char flag357) {

	if (n <= N) {

		if (flag357 == 07)

			total++;

		dfs(n * 10 + 3, flag357 | 01);

		dfs(n * 10 + 5, flag357 | 02);

		dfs(n * 10 + 7, flag357 | 04);

	}

}



int main() {

	cin >> N;

	dfs(0, 0);

	cout << total << endl;





	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n, nn;

set<string> res;

void f(string s) {

	if(s.length() > 0 && stoi(s) <= nn){

		set<char> st;

		for(int i=0; i<s.length(); ++i) {

			st.insert(s[i]);

		}

		if(st.size() == 3)

		  res.insert(s);

	} 

	if(s.length() == n) {

		return;

	}

	f(s + '3');

	f(s + '5');

	f(s + '7');

}



int main() {

	cin >> nn;

	n = to_string(nn).length();

	f("");

	cout << res.size() << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 13.094398560091259x):
/*

ID: espr1t

TASK: 

KEYWORDS: 

*/



#include <cstdio>

#include <cstring>

#include <algorithm>

#include <vector>

#include <string>



using namespace std;



const int MAX = 1024;



int ans;

int limit;



void recurse(long long num, int mask) {

    if (num > limit)

        return;

    if ((mask & 7) == 7)

        ans++;

    recurse(num * 10 + 3, mask | 1);

    recurse(num * 10 + 5, mask | 2);

    recurse(num * 10 + 7, mask | 4);

}



int main(void) {

	// in = fopen("C.in", "rt");

	

	scanf("%d", &limit);

	

	recurse(0, 0);

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

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long lint;

typedef pair<int, int> P;

#define REP(i, x, n) for(int i = x ; i < n ; ++i)

#define rep(i, n) REP(i, 0, n)

#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)

#define ALL(x) (x).begin(), (x).end()

#define SORT(x) sort(ALL(x))



const int IINF = 1e9 + 10;

const lint LLINF = (lint)1e18 + 10;

const lint MOD = (lint)1e9 + 7;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};

const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};



int main(){

    const int shichigosan[] = {3, 5, 7};

    vector<int> v;

    REP(i, 1, 8){

        REP(j, 1, 9 - i){

            REP(k, 1, 10 - i - j){

                vector<int> tmp;

                int cnt = 0;

                while(cnt < i){

                    tmp.push_back(shichigosan[0]);

                    ++cnt;

                }

                cnt = 0;

                while(cnt < j){

                    tmp.push_back(shichigosan[1]);

                    ++cnt;

                }

                cnt = 0;

                while(cnt < k){

                    tmp.push_back(shichigosan[2]);

                    ++cnt;

                }

                do{

                    int now = 0;

                    rep(l, tmp.size()){

                        now *= 10;

                        now += tmp[l];

                    }

                    v.push_back(now);

                }while(next_permutation(ALL(tmp)));

            }

        }

    }

    SORT(v);

    int n;

    cin >> n;

    int ans = upper_bound(ALL(v), n) - v.begin();

    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.1049598116278774x):
#include<bits/stdc++.h>

using namespace std;



typedef long long lint;

typedef pair<int, int> P;

#define REP(i, x, n) for(int i = x ; i < n ; ++i)

#define rep(i, n) for(int i = 0 ; i < n ; ++i)

#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)

#define ALL(x) (x).begin(), (x).end()

#define SORT(x) sort((x).begin(), (x).end())



const int IINF = 1e9 + 10;

const long long LLINF = (long long)1e18 + 10;

const long long MOD = (long long)1e9 + 7;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};

const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

const double EPS = 1e-8;



int n, ans = 0;



void solve(lint now, bool shichi, bool go, bool san){

    if(now > n){

        return;

    }

    if(shichi && go && san){

        ++ans;

    }

    solve(now * 10LL + 7LL, true, go, san);

    solve(now * 10LL + 5LL, shichi, true, san);

    solve(now * 10LL + 3LL, shichi, go, true);

    return;

}



int main(){

    cin >> n;

    solve(0, false, false, false);

    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <string>

#include <cmath>

#include <bitset>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <algorithm>

#include <complex>

#include <unordered_map>

#include <random>

using namespace std;

typedef long long int ll;

typedef pair<int, int> P;

vector<int> v;

int m;

void solve(int i){

	if(i==10) return;

	m*=10;

	m+=3;

	v.push_back(m);

	solve(i+1);

	m+=2;

	v.push_back(m);

	solve(i+1);

	m+=2;

	v.push_back(m);

	solve(i+1);

  m/=10;

}



int main()

{

	solve(1);

	sort(v.begin(), v.end());

	int n; cin>>n;

	int ans=0;

	for(int i=0; i<v.size(); i++){

		if(v[i]>n) break;

		int c[10]={};

		int n0=v[i];

		while(n0>0){

			c[n0%10]++;

			n0/=10;

		}

		if(c[3] && c[5] && c[7]) ans++;

	}

	cout<<ans<<endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.3969785659933436x):
#include <cstdio>

#include <cstring>

#include <string>

#include <iostream>

#include <cmath>

#include <bitset>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <algorithm>

#include <unordered_map>

#include <unordered_set>

using namespace std;

typedef long long int ll;

typedef pair<int, int> P;



int main()

{

	string s;

	cin>>s;

	int d=s.size();

	int c=0, p3=1;

	for(int i=1; i<d; i++){

		p3*=3;

		c+=p3;

	}

	int dp[2][2][2][2][10]={};

	dp[0][0][0][0][0]=1;

	for(int i=0; i<d; i++){

		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][1][k][l][i+1]+=(dp[1][1][k][l][i]+dp[1][0][k][l][i]);

		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][1][l][i+1]+=(dp[1][k][1][l][i]+dp[1][k][0][l][i]);

		for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][l][1][i+1]+=(dp[1][k][l][1][i]+dp[1][k][l][0][i]);

		if(3<s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][1][k][l][i+1]+=(dp[0][1][k][l][i]+dp[0][0][k][l][i]);

		}else if(3==s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][1][k][l][i+1]+=(dp[0][1][k][l][i]+dp[0][0][k][l][i]);

		}

		if(5<s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][1][l][i+1]+=(dp[0][k][1][l][i]+dp[0][k][0][l][i]);

		}else if(5==s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][k][1][l][i+1]+=(dp[0][k][1][l][i]+dp[0][k][0][l][i]);

		}

		if(7<s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[1][k][l][1][i+1]+=(dp[0][k][l][1][i]+dp[0][k][l][0][i]);

		}else if(7==s[i]-'0'){

			for(int k=0; k<2; k++) for(int l=0; l<2; l++) dp[0][k][l][1][i+1]+=(dp[0][k][l][1][i]+dp[0][k][l][0][i]);

		}

	}

	cout<<dp[0][1][1][1][d]+dp[1][1][1][1][d]+c-3*((1<<d)-2)+3*(d-1)<<endl;

	return 0;

}
// Slower C++ solution:
#include<stdio.h>

#include<iostream>

#include<algorithm>

using namespace std;

const int Mod = 1e9+7;

int S,dp[45][1<<17],ans=1;

int main()

{

    int n,x,y,z,now;

    scanf("%d%d%d%d",&n,&x,&y,&z);

    for(int i=1;i<=n;i++) ans=1LL*ans*10%Mod;

    now=(1<<(x-1))|(1<<(x+y-1))|(1<<(x+y+z-1));

    S=(1<<x+y+z)-1;

    dp[0][0]=1;

    for(int i=1;i<=n;i++)

    {

        for(int j=0;j<=S;j++)

        {

            for(int k=1;k<=10;k++)

            {

                int T=(j<<k)|(1<<k-1);

                T&=S;

                if((T&now)!=now) dp[i][T]=(dp[i][T]+dp[i-1][j])%Mod;

            }

        }

    }

    for(int i=0;i<=S;i++) ans=(ans-dp[n][i]+Mod)%Mod;

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.015008572721369x):
#include <bits/stdc++.h>



const int MAXN = 40;

const int P = 1e9 + 7;



inline int add(int a, int b) { return a + b >= P ? a + b - P : a + b; }

inline int sub(int a, int b) { return a - b < 0 ? a - b + P : a - b; }

inline int mul(int a, int b) { return 1LL * a * b % P; }

inline void inc(int &a, int b) { a = add(a, b); }

inline void dec(int &a, int b) { a = sub(a, b); }

inline void mlt(int &a, int b) { a = mul(a, b); }



int ans = 1;

int n, X, Y, Z, mask, valid;

int dp[MAXN + 9][1 << 17];



int main() {

  scanf("%d%d%d%d", &n, &X, &Y, &Z);

  mask = (1 << X + Y + Z) - 1;



  valid = (1 << X + Y + Z - 1) | (1 << Y + Z - 1) | (1 << Z - 1);

  // 满足要求的最小状态



  for (int i = 1; i <= n; ++i) mlt(ans, 10);



  dp[0][0] = 1;

  for (int i = 1; i <= n; ++i) 

    for (int s = 0; s <= mask; ++s) {

      if (!dp[i - 1][s]) continue;

      for (int j = 1; j <= 10; ++j) {

        int now = ((s << j) | (1 << j - 1)) & mask;

        if ((now & valid) != valid) inc(dp[i][now], dp[i - 1][s]);

      }

    }



  for (int s = 0; s <= mask; ++s) dec(ans, dp[n][s]);



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



  return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include<sstream>

#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<climits>

#include<cmath>

#include<string>

#include<vector>

#include<set>

#include<map>

#include<queue>

#include<numeric>

#include<functional>

#include<algorithm>

#include<bitset>

#include<tuple>

#include<unordered_set>

#include<random>

using namespace std;

#define INF (1<<29)

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define all(v) v.begin(),v.end()

#define uniq(v) v.erase(unique(all(v)),v.end())





#define MOD 1000000007









int dp[2][1 << 16];





int main() {

	ios::sync_with_stdio(0);

	cin.tie(0);

	int n, x, y, z;

	cin >> n >> x >> y >> z;



	long long ans = 1;

	rep(i, n)(ans *= 10) %= MOD;



	int(*cur)=dp[0], (*nxt)=dp[1];

	cur[0] = 1;

	rep(i,n) {

		memset(nxt, 0, sizeof(dp[0]));

		rep(j,1<<x+y+z-1) if(cur[j]){

			for (int a = 1; a <= 10;a++) {

				int b = j << a;

				b |= 1 << a - 1;

				if ((b & 1 << x - 1) == 0 || (b & 1 << x + y - 1) == 0 || (b & 1 << x + y + z - 1) == 0) {

					(nxt[b&((1 << x + y + z - 1) - 1)] += cur[j]) %= MOD;

				}

			}

		}

		swap(cur, nxt);

	}

	rep(i,1<<x+y+z-1) {

		ans -= cur[i];

	}

	ans %= MOD;

	ans += MOD;

	ans %= MOD;

	cout << ans << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.404608579319507x):
#define _CRT_SECURE_NO_WARNINGS

#include<sstream>

#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<climits>

#include<cmath>

#include<string>

#include<vector>

#include<set>

#include<map>

#include<queue>

#include<numeric>

#include<functional>

#include<algorithm>

#include<bitset>

#include<tuple>

#include<unordered_set>

#include<random>

using namespace std;

#define INF (1<<29)

#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define all(v) v.begin(),v.end()

#define uniq(v) v.erase(unique(all(v)),v.end())





#define MOD 1000000007









long long dp[41][1 << 16];





int main() {

	ios::sync_with_stdio(0);

	cin.tie(0);

	int n, x, y, z;

	cin >> n >> x >> y >> z;



	const int haiku = (1 << x - 1) | (1 << x + y - 1) | (1 << x + y + z - 1);

	dp[0][0] = 1;

	rep(i,n) {

		rep(j,1<<x+y+z-1) if(dp[i][j]){

			dp[i][j] %= MOD;

			for (int a = 1; a <= 10;a++) {

				int b = j << a;

				b |= 1 << a - 1;

				if ((b&haiku) != haiku) {

					dp[i + 1][b&((1 << x + y + z - 1) - 1)] += dp[i][j];

				}

			}

		}

	}



	long long ans = 1;

	rep(i, n)(ans *= 10) %= MOD;

	rep(i,1<<x+y+z-1) {

		(ans -= dp[n][i]) %= MOD;

	}

	ans += MOD;

	ans %= MOD;

	cout << ans << endl;



	return 0;

}