func_code_string: #include <bits/stdc++.h>   using namespace std;   long long a[2][2010];   long long b[2010];   int dp[2010][2010][2];   int way[2010][2010][2];   int sz[2];   int r(int p1, int p2, int w) {     if ((p1 == sz[0]) && (p2 == sz[1])) return 0;     if (dp[p1][p2][w] != -1) return dp[p1][p2][w];     if ((p1 == 0) && (p2 == 0)) {       int v1 = r(p1 + 1, p2, 0);       int v2 = r(p1, p2 + 1, 1);       if (v1 < v2)         way[p1][p2][w] = 0;       else         way[p1][p2][w] = 1;       return dp[p1][p2][w] = ((v1 < v2) ? (v1) : (v2));     }     long long last;     if (w == 0)       last = a[0][p1 - 1];     else       last = a[1][p2 - 1];     int res1 = 2000000000, res2 = 2000000000;     if (p1 != sz[0]) {       int t = 0;       if (a[0][p1] < last) t = 1;       res1 = t + r(p1 + 1, p2, 0);     }     if (p2 != sz[1]) {       int t = 0;       if (a[1][p2] < last) t = 1;       res2 = t + r(p1, p2 + 1, 1);     }     if (res1 < res2)       way[p1][p2][w] = 0;     else       way[p1][p2][w] = 1;     return dp[p1][p2][w] = ((res1 < res2) ? (res1) : (res2));   }   int main() {     int it;     scanf( %d , &it);     for (int i = (0); i < (it); ++i) {       scanf( %d , &sz[i]);       cin >> a[i][0];       int x, y, m;       cin >> x >> y >> m;       for (int j = (1); j < (sz[i]); ++j) a[i][j] = (a[i][j - 1] * x + y) % m;     }     memset(dp, -1, sizeof(dp));     int res = r(0, 0, 0);     cout << res << endl;     int p1 = 0, p2 = 0, w = 0;     while ((p1 < sz[0]) || (p2 < sz[1])) {       if (way[p1][p2][w] == 0) {         printf( %d 1 n , a[0][p1]);         p1++;         w = 0;       } else {         printf( %d 2 n , a[1][p2]);         p2++;         w = 1;       }     }     return 0;   }   