#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include "transmission.h"
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int T = 2;

static vector<bool> data;

vector<bool> receive(const vector<bool>& message, int n, int d)
{
    if(d == 1)
        T = 2;
    else
        T = 7;
    int m = message.size();

    for(int i = 0; i < m;)
    {
        int island = 0, j = i;
        while(j < m && message[j] == message[i])
        {
            island++;
            j++;
        }

        if(island % T)
            island += T;
        for(int j = 1; j <= island / T; j++)
            data.pb(message[i]);

        i = j;
    }

    while((int)data.size() > n)
        data.pop_back();
    while((int)data.size() < n)
        data.pb(rand() % 2);
    //assert((int)data.size() == n);
    return data;
}


//int main()
//{
//    srand(time(NULL));
//
//    string want;
//    cin >> want;
//
//    int n = want.size();
//
//    int chosen = rand() % n;
//
//    vector <bool> mess;
//    for(int i = 0; i < n; i++)
//    {
//        int of = 0;
//        if(i == chosen)
//            of = 1;
//        if(want[i] == '0')
//        {
//            for(int j = 1; j <= T - of; j++)
//                mess.pb(0);
//        }
//        else
//        {
//            for(int j = 1; j <= T - of; j++)
//                mess.pb(1);
//        }
//    }
//
//    vector <bool> ans = receive(mess, n, 1);
//
//    for(auto x: ans)
//        cout << x;
//    cout << endl;
//
//    return 0;
//}
