Language: C++

#ifndef COMPETITIVE_HEADER
    #pragma GCC optimize ("Ofast")
    #ifdef ONLINE_JUDGE
        #pragma GCC target ("avx512f")
    #else
        #pragma GCC target ("avx")
    #endif
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%d", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;
#endif

inline unsigned long long rdtsc()
{
#ifdef __amd64
  unsigned long long a, d;
  __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
  return (d << 32) | a;
#else
  unsigned long long x;
  __asm__ volatile ("rdtsc" : "=A" (x));
  return x;
#endif
}

inline double gettime(){return rdtsc()/2993344000.0;}
inline double elapsed(double st){return gettime()-st;}
class Xorshift128 {
private:
  static constexpr unsigned MASK = 0x7FFFFFFF;
  unsigned x = 123456789, y = 987654321, z = 1000000007, w;
public:
  unsigned rnd(){
    unsigned t = x ^ (x << 11);
    x = y; y = z; z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return w & MASK;
  }
  inline double rnd_d(){
      return (double)rnd() / INT32_MAX;
  }
  
  Xorshift128(const unsigned seed=114514) : w(seed) {}
};
Xorshift128 prng(21);

const int D = 365;
int c[26], s[365][26];

int compute_score(const vi& out){
    int satisfy = 0;
    vi lst(26);
    REP(i,D){
        int dlst = i+1 - lst[out[i]];
        lst[out[i]] = i+1;
        satisfy += s[i][out[i]];
        satisfy -= c[out[i]] * dlst * (dlst-1) / 2;
    }
    REP(i,26) satisfy -= c[i] * (365-lst[i]) * (365-lst[i]+1) / 2;
    return satisfy;
}
inline int cost(const int a, const int b){
    int d = b-a;
    return d * (d-1) / 2;
}
inline int cost(const int a, const int b, const int c){
    int d = b-a; d *= d;
    int e = c-b; e *= e;
    return (d+e+a-c) / 2;
}

struct State{
    vi out;
    int score;
    vvi prv, nxt;

    State(const vi t) : out(t) {
        prv = vvi(26, vi(366, -1));
        nxt = vvi(26, vi(366, 365));
        REP(d,D){
            REP(i,26) prv[i][d+1] = prv[i][d];
            prv[out[d]][d+1] = d;
        }
        REPN(d,D){
            REP(i,26) nxt[i][d] = nxt[i][d+1];
            nxt[out[d]][d] = d;
        }
        score = compute_score(out);
    }
    int try_shift(int d, int d2){
        int i = out[d];
        int prev = prv[i][d];
        int next = nxt[i][d+1];
        int before = s[d][i] - c[i] * (cost(prev, d, next));
        int after = (d2 == -1 ? -c[i] * cost(prev, next) : 
                s[d2][i] - c[i] * (cost(prev, d2, next)) );
        return after - before;
    }
    int try_insert(int d, int i){
        int prev = prv[i][d];
        int next = nxt[i][d+1];
        int before = -c[i] * cost(prev, next);
        int after = s[d][i] - c[i] * (cost(prev, d, next));
        return after - before;
    }
    void update(int i, int prev, int d2, int next){
        FOR(d, prev+1, d2+1){
            prv[i][d] = prev;
			nxt[i][d] = d2;
        }
        FOR(d, d2+1, next+1){
            prv[i][d] = d2;
			nxt[i][d] = next;
        }
    }
    void change(int d, int i){
        int j = out[d];
        int prev1 = prv[i][d]; int next1 = nxt[i][d+1];
        int prev2 = prv[j][d]; int next2 = nxt[j][d+1];
        out[d] = i;
        update(i, prev1, d, next1);
        FOR(d, prev2+1, next2+1){
            prv[j][d] = prev2;
			nxt[j][d] = next2;
        }
    }
    bool dfs(int d, int diff, int diff0, vector<bool>& used, int s, int depth){
        if (d != s) 
        if (s == -1){
            int diff2 = diff + diff0 + try_shift(d, -1);
            if (diff2 > 0){
                score += diff2;
                return true;
            }
        } else {
            int i = out[d];
            if (prv[i][d] + 1 <= s && s < nxt[i][d + 1]) {
                int diff2 = diff + try_shift(d, s);
                if (diff2 > 0) {
                    score += diff2;
                    change(s, i);
                    return true;
                }
            }
        }
        int i = out[d];
        int prev = prv[i][d];
        int next = nxt[i][d + 1];
        if (depth < 2){
            FOR(d2, prev+1, next) {
                if (used[out[d2]]) continue;
                int diff2 = diff + try_shift(d, d2);
                if (diff2 > 0) {
                    int j = out[d2];
                    used[j] = true;
                    bool ok = dfs(d2, diff2, diff0, used, s, depth + 1);
                    used[j] = false;
                    if (ok) {
                        change(d2, i);
                        return true;
                    }
                }
            }
        } else if (s != -1){
            int max_diff = 0;
            int max_d2 = -1;
            FOR(d2, prev+1, next) {
                if (used[out[d2]]) continue;
                int new_diff = diff + try_shift(d, d2);
                if (max_diff < new_diff){
                    max_diff = new_diff;
                    max_d2 = d2;
                }
            }
            if (max_diff > 0) {
                used[out[max_d2]] = true;
                bool ok = dfs(max_d2, max_diff, diff0, used, s, depth + 1);
                used[out[max_d2]] = false;
                if (ok) {
                    change(max_d2, i);
                    return true;
                }
            }
        }
        return false;
    }
};

State exec(const double T0 = 2e3, const double T1 = 2e2, const double insert_ratio = 0.5, const double diff_ratio = 0.25){
    const double TL = 2;
    vi t(D);
    REP(i,D) t[i] = prng.rnd() % 26;
    State state = State(t);
    vector<bool> used(26, false);
    int cnt = 0;
    int best_score = state.score;
    State best = State(state);

    double st = gettime();
    while(true){
        double t = elapsed(st) / TL;
        if (t > 0.99) break;
        double T = powf(T0, 1.0 - t) * powf(T1, t);

        REP(_,100){
            int add = (-T * log(prng.rnd_d()) );

            if (prng.rnd_d() < insert_ratio){
                int d = prng.rnd() % D;
                int i = prng.rnd() % 26;
                if(state.out[d] == i) continue;
                int j = state.out[d];
                int diff = state.try_insert(d, i);
                used[i] = used[j] = true;
                if (state.dfs(d, add + diff * diff_ratio, diff - diff * diff_ratio, used, -1, 0)) {
                    state.change(d, i);
                    state.score -= add;
                }
                used[i] = used[j] = false;
            } else {
                int s = prng.rnd() % D;
                int i = state.out[s];
                used[i] = true;
                if (state.dfs(s, add, 0, used, s, 0)) state.score -= add;
                used[i] = false;
            }
            if (best_score < state.score) {
                best_score = state.score;
                best = State(state);
            }
        }
        cnt += 100;
        // state.score = compute_score(state.out);
    }
    return best;
}
void input(){
    I(c[0]);
    REP(i,26) I(c[i]);
    REP(i,D) REP(j,26) I(s[i][j]);
}


int main(){
    input()
    auto S = exec(850, 440, 0.663, 0.0919); 
    REP(i,D) printf("%d\n", S.out[i]+1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:277:12: error: expected ';' before 'auto'
  277 |     input()
      |            ^
      |            ;
  278 |     auto S = exec(850, 440, 0.663, 0.0919);
      |     ~~~~    
a.cc:279:29: error: 'S' was not declared in this scope
  279 |     REP(i,D) printf("%d\n", S.out[i]+1);
      |                             ^