func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Activity {     int gym, contest;     bool gym_used, contest_used;   };   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int &e : v) cin >> e;     vector<Activity> res(n);     switch (v[0]) {       case 0:         res[0].gym = res[0].contest = 0;         res[0].gym_used = res[0].contest_used = false;         break;       case 1:         res[0].gym = 0;         res[0].contest = 1;         res[0].gym_used = false;         res[0].contest_used = true;         break;       case 2:         res[0].gym = 1;         res[0].contest = 0;         res[0].gym_used = true;         res[0].contest_used = false;         break;       case 3:         res[0].gym = res[0].contest = 1;         res[0].gym_used = res[0].contest_used = true;         break;     }     for (int i = 1; i < v.size(); i++) {       if (v[i] == 1) {         res[i] = res[i - 1];         res[i].contest_used = res[i].gym_used = false;       }       if (v[i] == 1 || v[i] == 3) {         if (res[i - 1].contest_used) {           if (res[i - 1].gym >= res[i - 1].contest) {             res[i].contest_used = true;             res[i].contest = res[i - 1].gym + 1;           } else {             res[i].contest_used = false;             res[i].contest = res[i - 1].contest;           }         } else {           res[i].contest_used = true;           res[i].contest = max(res[i - 1].gym, res[i - 1].contest) + 1;         }       }       if (v[i] == 0 || v[i] == 1) {         res[i].gym = res[i - 1].gym;         res[i].gym_used = false;       }       if (v[i] == 0 || v[i] == 2) {         res[i].contest = res[i - 1].contest;         res[i].contest_used = false;       }       if (v[i] == 2 || v[i] == 3) {         if (res[i - 1].gym_used) {           if (res[i - 1].contest >= res[i - 1].gym) {             res[i].gym_used = true;             res[i].gym = res[i - 1].contest + 1;           } else {             res[i].gym_used = false;             res[i].gym = res[i - 1].gym;           }         } else {           res[i].gym_used = true;           res[i].gym = max(res[i - 1].gym, res[i - 1].contest) + 1;         }       }     }     cout << n - max(res[n - 1].gym, res[n - 1].contest) << endl;   }   