Language: C++

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int D;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));
const int types = 26;
mt19937 mt{ random_device{}() };

int get_score(vector<int> &t) {
	int score = 0;
	vector<int> last(26, -1);
	rep(i, t.size()) {
		score += s[i][t[i]];
		last[t[i]] = i;
		rep(j, 26) score -= c[j] * (i - last[j]);
	}
	return score;
}

int evaluate(vector<int> &t, int k) {
	int score = 0;
	vector<int> last(26, -1);
	rep(i, t.size()) {
		score += s[i][t[i]];
		last[t[i]] = i;
		rep(j, 26) score -= c[j] * (i - last[j]);
	}

	for(int d = t.size(); d < min<int>(D, t.size() + k); d++) {
		rep(j, 26) {
			score -= (d - last[j]) * c[j];
		}
	}
	return score;
}


vector<int> solve(int k) {
	vector<int> res;
	rep(i, D) {
		ll max_score = LLONG_MIN;
		int type = -1;
		rep(j, 26) {
			res.push_back(j);
			int score = evaluate(res, k);
			if(max_score < score) {
				max_score = score;
				type = j;
			}
			res.pop_back();
		}
		res.push_back(type);
	}
	return res;
}

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	vector<int> ans;
	ans = solve(10);
	auto start = chrono::system_clock::now();
	cin >> D;
	rep(i, 26) {
		cin >> c[i];
		c[i]--;
	}
	rep(i, D) {
		rep(j, 26) cin >> s[i][j];
	}

	int ans_score = get_score(ans);
	while(true) {
		auto now = chrono::system_clock::now();
		int elapsed = chrono::duration_cast<chrono::milliseconds>(now - start).count();
		if(elapsed >= 1975) break;
		uniform_int_distribution<int> rand_day(0, D - 1);
		uniform_int_distribution<int> rand_type(0, types - 1);
		uniform_int_distribution<double> rand_01(0, 1);

		if(rand_01(mt) < 0.5) {
			int day = rand_day(mt);
			int type = rand_type(mt);
			int prev_val = ans[day];
			ans[day] = type;
			int score = get_score(ans);
			if(ans_score < score) {
				ans_score = score;
			} else {
				ans[day] = prev_val;
			}
		} else {
			int day1 = max(0, rand_day(mt) - 1);
			uniform_int_distribution<int> rand_day2(day1 + 1, min(D - 1, day1 + 16));
			int day2 = rand_day2(mt);
			swap(ans[day1], ans[day2]);
			int score = get_score(ans);
			if(ans_score < score) {
				ans_score = score;
			} else {
				swap(ans[day1], ans[day2]);
			}
		}
	}
	rep(i, D) cout << ans[i] + 1 << endl;
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algo.h:65,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/uniform_int_dist.h: In instantiation of 'class std::uniform_int_distribution<double>':
a.cc:103:43:   required from here
  103 |                 uniform_int_distribution<double> rand_01(0, 1);
      |                                                         ^
/usr/include/c++/14/bits/uniform_int_dist.h:90:49: error: static assertion failed: template argument must be an integral type
   90 |       static_assert(std::is_integral<_IntType>::value,
      |                                                 ^~~~~
/usr/include/c++/14/bits/uniform_int_dist.h:90:49: note: 'std::integral_constant<bool, false>::value' evaluates to false