func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 20005;   const int INF = -1;   int n, m, p;   int a[N];   int b[N];   int F[2][N];   int Ra[N];   int Rb[N];   string Path;   inline void checkmax(int &t, const int x) {     if (x > t) t = x;   }   inline int w(int i, int j) {     int ret = a[i] + b[j];     if (ret >= p) ret -= p;     return ret;   }   long long Gao(int sx, int sy, int ex, int ey) {     if (sx == ex && sy == ey) return w(sx, sy);     int step = ex - sx + ey - sy;     if (step == 1) {       if (sx < ex)         Path +=  C ;       else         Path +=  S ;       return w(sx, sy) + w(ex, ey);     }     int s1 = step / 2;     int s2 = step - s1;     for (int j = 0; j + sy <= ey; j++) F[0][j] = F[1][j] = INF;     for (int j = sy; j <= ey; j++) Ra[j] = Rb[j] = INF;     F[0][0] = w(sx, sy);     for (int i = 1; i <= s1; i++) {       int p = i & 1;       for (int j = max(0, i + sx - ex); j <= i && j <= ey - sy; j++) {         F[p][j] = INF;         int nx = i - j + sx;         int ny = sy + j;         if (F[p ^ 1][j] != INF) checkmax(F[p][j], F[p ^ 1][j] + w(nx, ny));         if (j && F[p ^ 1][j - 1] != INF)           checkmax(F[p][j], F[p ^ 1][j - 1] + w(nx, ny));         if (i == s1) Ra[ny] = F[p][j];       }     }     for (int j = 0; j + sy <= ey; j++) F[0][j] = F[1][j] = INF;     F[0][0] = w(ex, ey);     for (int i = 1; i <= s2; i++) {       int p = i & 1;       for (int j = max(0, sx + i - ex); j <= i && j <= ey - sy; j++) {         F[p][j] = INF;         int nx = ex - (i - j);         int ny = ey - j;         if (F[p ^ 1][j] != INF) checkmax(F[p][j], F[p ^ 1][j] + w(nx, ny));         if (j && F[p ^ 1][j - 1] != INF)           checkmax(F[p][j], F[p ^ 1][j - 1] + w(nx, ny));         if (i == s2) Rb[ny] = F[p][j] - w(nx, ny);       }     }     int bx = -1;     int by = -1;     int ret = -1;     for (int j = sy; j <= ey; j++) {       if (Ra[j] != INF && Rb[j] != INF && Ra[j] + Rb[j] > ret) {         bx = sx + s1 - (j - sy);         by = j;         ret = Ra[j] + Rb[j];       }     }     Gao(sx, sy, bx, by);     Gao(bx, by, ex, ey);     return ret;   }   int main() {     scanf( %d%d%d , &n, &m, &p);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       a[i] %= p;     }     for (int i = 0; i < m; i++) {       scanf( %d , &b[i]);       b[i] %= p;     }     cout << Gao(0, 0, n - 1, m - 1) << endl;     cout << Path << endl;   }   