stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

	int n, al = 0;

	cin >> n;

	vector<int> mt(n);

	vector<int> dm(n);

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

	{

		cin >> dm[i];

		al += dm[i];

	}

	for (int i = 0; i < n - 1; i += 2)

	{

		al -= dm[i] * 2;

	}

	mt[n - 1] = al;

	for (int i = n - 2; i >= 0; i--)

	{

		mt[i] = 2 * dm[i] - mt[i + 1];

	}

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

	{

		cout << mt[i] << ' ';

	}

	return 0;

}

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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd = 1e5+10;

int a[maxd],n;

long long b[maxd];

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

    for(int i=1;i<=n;i++) scanf("%d",&a[i]);

    b[1] = 0ll;

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

    {

        if(i%2) b[1] += a[i];

        else b[1] -= a[i];

    }

    b[1] /=2; a[n] -= b[1];

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

        b[i+1] = a[i] - b[i];

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

        printf("%lld ",b[i]*2);

    //printf("%lld",ans);

    return 0;

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

using namespace std;

int main()

{

    long long int numlist[100000]={},sum=0,sum1,a;

    int n=0,i=0,j=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>numlist[i];

        sum+=numlist[i];

    }

    sum1=sum;

    for(i=1;i<n-1;i+=2)

    {

        sum1=sum1-2*numlist[i];

    }

    a=sum1;

    for(i=0;i<n;i++)

    {

        cout<<a<<" ";

        a=2*numlist[i]-a;

    }

    return 0;

}


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

using namespace std;

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

#define ll long long

#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

double const EPS = 1e-12, PI = acos(-1);

const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;

const ll inf = 1e18;



ll x[N], y[N];



int main() {

  fastIO;

#ifdef LOCAL

  freopen("input.in", "rt", stdin);

#endif

  int n;

  ll sum = 0, sum2 = 0;

  cin >> n;

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

    cin >> x[i];

    sum += x[i];

    if(!(i & 1))

      sum2 += x[i];

  }

  y[1] = sum - (2 * sum2);

  cout << y[1];

  for (int i = 2; i <= n; ++i) {

    y[i] = 2*x[i-1] - y[i-1];

    cout << ' ' << y[i];

  }

  return 0;

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

using namespace std;

int main()

{

    long long int numlist[100000]={},sum=0,sum1,a;

    int n=0,i=0,j=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>numlist[i];

        sum+=numlist[i];

    }

    sum1=sum;

    for(i=1;i<n-1;i+=2)

    {

        sum1=sum1-2*numlist[i];

    }

    a=sum1;

    for(i=0;i<n;i++)

    {

        cout<<a<<" ";

        a=2*numlist[i]-a;

    }

    return 0;

}


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

#include <unordered_set>

#include <map>

#include <string>

#include <vector>

#include <algorithm>

#include <utility>

#include <iostream>

#include <istream>

#include <ostream>

#include <sstream>



using namespace std;



/* macros */

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

#define SIZE(v)			((int)((v).size()))

#define LOG(x)			log((double)x)

#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)

#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)

#define ROUND(x,m)			(round((double)x/m)*m)

#define DIGITS(x)			(floor(log10((double)x))+1)

#define READSTR(x)			getline(cin,x)

#define sort_g(a,b)              sort(a, b, greater<int>());

#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);

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

#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)

#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)



/*typedefs*/

typedef long long ll;



/*functions*/

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)

{

    return p1.first > p2.first;

}

unsigned long long

choose(unsigned long long n, unsigned long long k) {

    if (k > n) {

        return 0;

    }

    unsigned long long r = 1;

    for (unsigned long long d = 1; d <= k; ++d) {

        r *= n--;

        r /= d;

    }

    return r;

}

int toInt(string str) {

    int num;

    istringstream iss(str); //put string in input stream

    iss>>num; return num; //read from stream as integer

}



template <class T> string toStr(T par) {

    ostringstream oss;  //output stream string

    oss<<par;    //write par to the stream

    return oss.str(); //return string of output

}



const int MAXN = 10e5;

int arr[MAXN]= {0};

int ans[MAXN] = {0};

int main() {

    IOS();

    int n;

    cin>>n;

    REP(i,n)

    {

        cin>>arr[i];

    }



    //draw and solve 2*x 2*y ..

    //x+y =

    //y+z =

    //z+w =

    //w+v =

    //v+x



    // + - + = 2*first

    // 2 2 4

    int sgn = 1;

    ll acc =0;

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

    {

        acc += sgn*arr[i];

        sgn *=-1;

    }

    ans[0] = acc;

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

    {

        ans[i] = (arr[i-1] -ans[i-1]/2)*2;

    }

    REP(i,n)

    {

        cout<<ans[i]<<" ";

    }

    cout<<std::endl;



    return 0;

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

using namespace std;

int main()

{

    long long int numlist[100000]={},sum=0,sum1,a;

    int n=0,i=0,j=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>numlist[i];

        sum+=numlist[i];

    }

    sum1=sum;

    for(i=1;i<n-1;i+=2)

    {

        sum1=sum1-2*numlist[i];

    }

    a=sum1;

    for(i=0;i<n;i++)

    {

        cout<<a<<" ";

        a=2*numlist[i]-a;

    }

    return 0;

}


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

#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

#include<set>

#include<vector>

using namespace std;

#define ll long long

#define db double

ll a[100005];

ll sumj[100005];

ll sumo[100005];

int main()

{

    ll n,cntj=1,cnto=1;

    scanf("%lld",&n);

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

    {

        scanf("%lld",&a[i]);

        if(i%2)

        {

            sumj[cntj]=sumj[cntj-1]+a[i];

            cntj++;

        }

        else

        {

            sumo[cnto]=sumo[cnto-1]+a[i];

            cnto++;

        }

    }

    ll sum=sumj[cntj-1]+sumo[cnto-1];

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

    {

        if(i%2)

        {

            ll ans=a[i]-sumj[(i-1)/2]+sumo[(i-1)/2]+(sumj[cntj-1]-sumj[(i+1)/2])-(sumo[cnto-1]-sumo[(i-1)/2]);

            printf("%lld ",ans);

        }

        else

        {

            ll ans=a[i]+sumj[i/2]-sumo[i/2-1]+(sumo[cnto-1]-sumo[i/2])-(sumj[cntj-1]-sumj[i/2]);

            printf("%lld ",ans);

        }

    }

    return 0;

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

using namespace std;

int main()

{

    long long int numlist[100000]={},sum=0,sum1,a;

    int n=0,i=0,j=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>numlist[i];

        sum+=numlist[i];

    }

    sum1=sum;

    for(i=1;i<n-1;i+=2)

    {

        sum1=sum1-2*numlist[i];

    }

    a=sum1;

    for(i=0;i<n;i++)

    {

        cout<<a<<" ";

        a=2*numlist[i]-a;

    }

    return 0;

}


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

#include <bitset>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <deque>

#include <fstream>

#include <iostream>

#include <map>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <vector>

#define ll long long

#define ull unsigned long long

using namespace std;

void io() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

}



const int MAXN = 1e5 + 5;

const ll INF = 0x3f3f3f3f3f3f3f;

const ll prim = 1e9 + 7;



int a[MAXN];

int n;



int main() {

    io();

    cin >> n;

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

        cin >> a[i];

    }

    ll ans = 0;

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

        if (i & 1) {

            ans -= a[i];

        } else {

            ans += a[i];

        }

    }

    cout << ans << ' ';

    for (int i = 0; i < n - 1; i++) {

        ans -= a[i];

        ans = -ans;

        ans += a[i];

        cout << ans << ' ';

    }

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

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <queue>

#include <ctime>

#include <cassert>

#include <complex>

#include <string>

#include <cstring>

#include <chrono>

#include <random>

#include <queue>

#include <bitset>



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

#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)

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

#define clr(ar, val) memset(ar, val, sizeof(ar))

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair <int,int> P;

typedef long double ld;



int main(void)

{

	ll n, a[100001], w[100001] = {};

	cin >> n;

	rep(i, n) cin >> a[i];

	rep(i, n) {

		w[i + 1] = 2 * a[i];

		a[i + 1] -= a[i];

		a[i] = 0;

	}

	ll tmp = w[n] / 2;

	rep(i, n) {

		w[i] += tmp * (i % 2 ? -1 : 1);

		cout << w[i] << (i + 1 < i_len ? ' ' : '\n');

	}

	return 0;

}

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

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <queue>

#include <ctime>

#include <cassert>

#include <complex>

#include <string>

#include <cstring>

#include <chrono>

#include <random>

#include <queue>

#include <bitset>

#include <stack>

#include <functional>



#ifdef LOCAL

    #define eprintf(...) fprintf(stderr, __VA_ARGS__)

#else

    #define eprintf(...) 42

#endif



#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)

#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)

#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)

#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)

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

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair <int,int> P;

typedef long double ld;



int main (void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n; cin >> n;

    vector<ll> a(n); rep (i, n) cin >> a[i];

    vector<ll> ans(n + 1); rep (i, n) ans[i + 1] = 2 * a[i] - ans[i];

    rep (i, n + 1) eprintf("%d ", ans[i]); eprintf("\n");

    ll f = ans[n] / 2;

    rep (i, n) ans[i] += f * (i % 2 == 0 ? 1LL : -1LL);

    rep (i, n) cout << ans[i] << (i != i_len - 1 ? ' ' : '\n');

    return 0;

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

#include <iostream>



using namespace std;



const int mod = 1'000'000'007;



void add(int &a, int b) {

  a += b;

  if (a >= mod) {

    a -= mod;

  }

}



int mul(int a, int b) {

  return (int)((long long)a * b % mod);

}



int pw(int a, int b) {

  int res = 1;

  while (b > 0) {

    if (b % 2 == 1) {

      res = mul(res, a);

    }

    a = mul(a, a);

    b /= 2;

  }

  return res;

}



int get(int b) {

  int res = pw(10, b);

  add(res, mod - pw(10, b - 1));

  return res;

}



int main() {

  int s;

  scanf("%d", &s);

  int ans = 0;

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

    if (s % i == 0) {

      int cnt = get(i);

      if (i >= 9 || cnt >= s / i) {

        add(ans, cnt);

        add(ans, mod - s / i + 1);

      }

    }

  }

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

    long long v = 0;

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

      for (int k = 1; k <= get(i); ++k) {

        if (v + i * k >= s) {

          break;

        }

        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= get(j)) {

          add(ans, 1);

        }

      }

      v += j * get(j);

      if (v >= s) {

        break;

      }

    }

  }

  for (int i = 9; i < s; ++i) {

    int v = s / (i + 1);

    if (s % (i + 1) == 0) {

      --v;

    }

    int r = s % i;

    if (v >= r) {

      add(ans, (v - r) / i + (r != 0));

    }

  }

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

}


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

#include <iostream>



using namespace std;



const int mod = 1'000'000'007;



void add(int &a, int b) {

  a += b;

  if (a >= mod) {

    a -= mod;

  }

}



int mul(int a, int b) {

  return (int)((long long)a * b % mod);

}



int pw(int a, int b) {

  int res = 1;

  while (b > 0) {

    if (b % 2 == 1) {

      res = mul(res, a);

    }

    a = mul(a, a);

    b /= 2;

  }

  return res;

}



int get(int b) {

  int res = pw(10, b);

  add(res, mod - pw(10, b - 1));

  return res;

}



int main() {

  int s;

  scanf("%d", &s);

  int ans = 0;

  for (int i = 1; i * i <= s; ++i) {

    if (s % i == 0) {

      {

        int cnt = get(i);

        if (i >= 9 || cnt >= s / i) {

          add(ans, cnt);

          add(ans, mod - s / i + 1);

        }

      }

      if (s / i != i) {

        int cnt = get(s / i);

        if (s / i >= 9 || cnt >= i) {

          add(ans, cnt);

          add(ans, mod - i + 1);

        }

      }

    }

  }

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

    int cnt_i = get(i);

    long long v = 0;

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

      int cnt_j = get(j);

      for (int k = 1; k <= cnt_i; ++k) {

        if (v + i * k >= s) {

          break;

        }

        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= cnt_j) {

          add(ans, 1);

        }

      }

      v += j * cnt_j;

      if (v >= s) {

        break;

      }

    }

  }

  for (int i = 9; i <= s / 2; ++i) {

    int v = s / (i + 1);

    if (s % (i + 1) == 0) {

      --v;

    }

    int r = s % i;

    if (v >= r) {

      add(ans, (v - r) / i + (r != 0));

    }

  }

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

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

int main(void)

{

	int N,i,c;

	int *k,*kk;

	while(1){

		scanf("%d",&N);

		if(N==0) break;

		k = new int [N];

		kk = new int [N];

		for(i=0;i<N;i++)

			kk[i] = 0;

		for(i=0;i<N;i++)

			scanf("%d",&k[i]);

		

		i=0,c=0;

		while(1){

			if(k[i%N] > 0){

				k[i%N]--;

				kk[i%N]++;

				c++;

			}

			if(kk[i%N] == 2){

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

				break;

			}

			if(i > N * 2){

				printf("NA\n");

				break;

			}

			i++;

		}

	}

	return 0;

}

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



int k[10000];



int main()

{



	int N, cnt, same, Not;



	while( 1 ) {



		cnt = 0;

		same = 0;

		Not = 0;



		for( int i = 0; i < 10000; i++ ) k[i] = 0;



	 	scanf( "%d", &N );

		if( N == 0 ) break;

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



			scanf( "%d", &k[i] );

			if( k[i] > 1 ) same++;

			else if( k[i] == 0 ) Not++;



		}



		if( N == 1 && k[0] >= 2 ) {

			printf( "2\n" );

			continue;

		}

		else if( same == 0 ) {

			printf( "NA\n" );

			continue;

		}



		printf( "%d\n", N + 1 - Not );



	}



	return 0;



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

#include<vector>

#include<algorithm>



using namespace std;



int main(){

	int N;

	vector<int> data;



	while (1){

		data.clear();

		scanf("%d", &N);

		if (N == 0)break;



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

			int temp;

			scanf("%d", &temp);

			data.push_back(temp);

		}

		bool flag = false;

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

			if (data[i] > 1){

				flag = true;

				break;

			}

		}

		if (!flag){

			printf("NA\n");

		}

		else{

			if(N == 1)

				printf("2\n");

			else{

				int ans = 1;

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

					if (data[i] != 0 )ans++;

				}

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

			}

		}

	}

	return 0;

}

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

#include <vector>

#include <algorithm>



int N;



int main(){



    while(1){

start:

        scanf("%d",&N);



        if(N == 0)break;

        int cnt = 0;

        bool flag = false;



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

            int tmp;

            scanf("%d",&tmp);

            if(tmp != 0)cnt++;

            if(tmp > 1) flag = true;

        }

        if(N == 1 && flag){

            printf("2\n");

            goto start;

        }

        if(!flag){

            printf("NA\n");

            goto start;

        }



        int ans = cnt + 1;



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

    }

    return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

int a[10];

char s[10],c[10];



int main()

{

	scanf("%s",&s);

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

	{

		a[i]=s[i]-'0';

	}

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

	{

		a[i]*=(-1);

		if(a[0]+a[1]+a[2]+a[3]==7)

		{

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

			{

				if(a[i]<0) {c[i]='-';a[i]*=(-1);}

				else c[i]='+';

			}

			

			printf("%d%c%d%c%d%c%d=7",a[0],c[1],a[1],c[2],a[2],c[3],a[3]);

			return 0;

		}

	}

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

	{

		a[i]*=(-1);

		if(a[0]+a[1]+a[2]+a[3]==7)

		{

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

			{

				if(a[i]<0) {c[i]='-';a[i]*=(-1);}

				else c[i]='+';

			}

			

			printf("%d%c%d%c%d%c%d=7",a[0],c[1],a[1],c[2],a[2],c[3],a[3]);

			return 0;

		}

	}

	a[2]*=(-1);

	if(a[0]+a[1]+a[2]+a[3]==7)

	{

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

		{

			if(a[i]<0) {c[i]='-';a[i]*=(-1);}

			else c[i]='+';

		}

		printf("%d%c%d%c%d%c%d=7",a[0],c[1],a[1],c[2],a[2],c[3],a[3]);

	}

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

	{

		a[i]*=(-1);

		if(a[0]+a[1]+a[2]+a[3]==7)

		{

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

			{

				if(a[i]<0) {c[i]='-';a[i]*=(-1);}

				else c[i]='+';

			}

			

			printf("%d%c%d%c%d%c%d=7",a[0],c[1],a[1],c[2],a[2],c[3],a[3]);

			return 0;

		}

	}

	return 0;

}

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

#include<math.h>

int main()

{

        char fuhao[4];



        int i;

        int n,nn;

        int a,b,c,d;

        scanf("%d",&n);

        nn=n;

        d=n%10;

        n/=10;

        c=n%10;

        n/=10;

        b=n%10;

        n/=10;

        a=n;

        if(a+b+c+d==7)

        {

                printf("%d+%d+%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a+b+c-d==7)

        {

                printf("%d+%d+%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a+b-c+d==7)

        {

                printf("%d+%d-%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a+b-c-d==7)

        {

                printf("%d+%d-%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a-b+c+d==7)

        {

                printf("%d-%d+%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a-b+c-d==7)

        {

                printf("%d-%d+%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a-b-c+d==7)

        {

                printf("%d-%d-%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a-b-c-d==7)

        {

                printf("%d-%d-%d-%d=7",a,b,c,d);

                return 0;

        }

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

#include <iostream>

#include <string>



using namespace std;



int main() {

	int a, b, c, d;

	string num;

	while (cin >> num) {

		int flag = 0;

		a = num[0] - '0';

		b = num[1] - '0';

		c = num[2] - '0';

		d = num[3] - '0';

		for (int i = 0; i < 2&&!flag; i++) {

			for (int j = 0; j < 2&&!flag; j++) {

				for (int k = 0; k < 2; k++) {

					//cout << a << b << c << d;

					if (i) b = -b;

					if (j) c = -c;

					if (k) d = -d;

					if ((a + b + c + d) == 7)

					{

						cout << a;

						if (b < 0) cout << "-" << abs(b);

						else cout << "+" << b;

						if (c < 0) cout << "-" << abs(c);

						else cout << "+" << c;

						if (d < 0) cout << "-" << abs(d);

						else cout << "+" << d;

						cout << "=7" << endl;

						flag = 1;

						break;

					}

					b = abs(b);

					c = abs(c);

					d = abs(d);

				}

			}

		}

	}

	return 0;

}

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

#include<math.h>

int main()

{

        char fuhao[4];



        int i;

        int n,nn;

        int a,b,c,d;

        scanf("%d",&n);

        nn=n;

        d=n%10;

        n/=10;

        c=n%10;

        n/=10;

        b=n%10;

        n/=10;

        a=n;

        if(a+b+c+d==7)

        {

                printf("%d+%d+%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a+b+c-d==7)

        {

                printf("%d+%d+%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a+b-c+d==7)

        {

                printf("%d+%d-%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a+b-c-d==7)

        {

                printf("%d+%d-%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a-b+c+d==7)

        {

                printf("%d-%d+%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a-b+c-d==7)

        {

                printf("%d-%d+%d-%d=7",a,b,c,d);

                return 0;

        }

        if(a-b-c+d==7)

        {

                printf("%d-%d-%d+%d=7",a,b,c,d);

                return 0;

        }

        if(a-b-c-d==7)

        {

                printf("%d-%d-%d-%d=7",a,b,c,d);

                return 0;

        }

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

using namespace std;

#define lor(a,b,c) for(register int a=b;a<=c;++a)

#define ror(a,b,c) for(register int a=c;a>=b;--a)

typedef long long ll;



const int N=3e5+5;

const ll MOD=1e9+7;



char s[N]; int n;

ll f[N][3][3],ans;



inline void inc(ll &a,ll b){

	(a+=b)>=MOD?a-=MOD:a;

}



inline void trans(int &a,int &b,int c){

	if(!c){

		++b; if(b>=3) b-=2;

	}

	else{

		if(b) --b;

		else ++a,a=min(a,2);

	}

}



int main(){

	//freopen("test.in","r",stdin);



	scanf("%s",s+1); n=strlen(s+1);

	f[0][0][0]=1ll;

	lor(k,1,n){

		if(s[k]!='0'){

			lor(i,0,2) lor(j,0,2){

				int a=i,b=j; trans(a,b,1);

				inc(f[k][a][b],f[k-1][i][j]);

			}

		}

		if(s[k]!='1'){

			lor(i,0,2) lor(j,0,2){

				int a=i,b=j; trans(a,b,0);

				inc(f[k][a][b],f[k-1][i][j]);

			}			

		}

	}

	lor(i,0,2) lor(j,0,i) inc(ans,f[n][i][j]);

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



	return 0;

}

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

#define p 1000000007

int i,j,_[8][2]={{},{2,3},{4,1},{5,7},{2,2},{6,3},{5,5},{7,7}},dp[2][8];

char s[300005];

int main()

{

	scanf("%s",s+1);

	int*f=dp[0],*g=dp[1],*q;

	for(f[1]=i=1;s[i];i++,q=f,f=g,g=q)for(j=1;j<8;f[j++]=0)if(f[j])s[i]!='1'&&((g[_[j][0]]+=f[j])%=p),s[i]!='0'&&((g[_[j][1]]+=f[j])%=p);

	printf("%d",(f[3]+f[7])%p);

}