Problem:
J: Horizontal-Vertical Permutation
Problem Statement
You are given a positive integer
N
. Your task is to determine if there exists a square matrix
A
whose dimension is
N
that satisfies the following conditions and provide an example of such matrices if it exists.
A_{i, j}
denotes the element of matrix
A
at the
i
-th row and
j
-th column.
For all
i, j
(1 \leq i, j \leq N)
,
A_{i, j}
is an integer that satisfies
1 \leq A_{i, j} \leq 2N - 1
.
For all
k = 1, 2, ..., N
, a set consists of
2N - 1
elements from the
k
-th row or
k
-th column is
\{1, 2, ..., 2N - 1\}
.
If there are more than one possible matrices, output any of them.
Input
N
Input consists of one line, which contains the integer
N
that is the size of a square matrix to construct.
Constraint
N
is an integer that satisfies
1 \leq N \leq 500
.
Output
Output
No
in a single line if such a square matrix does not exist.
If such a square matrix
A
exists, output
Yes
on the first line and
A
after that. More specifically, follow the following format.
Yes
A_{1, 1}
A_{1, 2}
...
A_{1, N}
A_{2, 1}
A_{2, 2}
...
A_{2, N}
:
A_{N, 1}
A_{N, 2}
...
A_{N, N}
Sample Input 1
4
Output for Sample Input 1
Yes
2 6 3 7
4 5 2 1
1 7 5 6
5 3 4 2
Sample Input 2
3
Output for Sample Input 2
No

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cassert>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
using ll = long long;
template<class E> using V = vector<E>;

V<V<int>> solve(int N){
    V<V<int>> ans(N, V<int>(N));
    if(N%4 == 0){
        auto sub = solve(N/2);
        REP(i,N/2) REP(j,N/2) ans[i*2][j*2] = sub[i][j] + N;
        REP(i,N/2) REP(j,N/2) ans[i*2+1][j*2+1] = sub[i][j] + N;
        int n = N / 2;
        REP(k,N/2){
            REP(f,N/2) ans[f*2][(f*2+k*2+1)%N] = k*2+0;
            REP(f,N/2) ans[(f*2+k*2+1)%N][f*2] = k*2+1;
        }
    } else {
        int n = N / 2;
        REP(k,n){
            ans[k*2][k*2+1] = k*4%N+0;
            ans[k*2+1][k*2] = k*4%N+1;
            REP(s,n) REP(t,n) if(s < t){
                ans[s*2+0][t*2+0] = (s+t)%n*2+0;
                ans[s*2+1][t*2+1] = (s+t)%n*2+1;
                ans[t*2+0][s*2+0] = (s+t)%n*2+1;
                ans[t*2+1][s*2+1] = (s+t)%n*2+0;
            }
        }
        REP(s,n) REP(t,n) if(s != t){
            ans[s*2+0][t*2+1] = N + (s+n-t-1)%n*2+0;
            ans[s*2+1][t*2+0] = N + (s+n-t-1)%n*2+1;
        }
        REP(i,N) ans[i][i] = N * 2 - 2;
    }
    return ans;
}

void testcase(){
    int N; cin >> N;
    if(N == 1){ cout << "Yes\n1\n"; return; }
    if(N%2 == 1){ cout << "No\n"; return; }
    cout << "Yes\n";
    auto ans = solve(N);
    REP(i,N){
        REP(j,N){
            if(j) cout << " ";
            cout << (ans[i][j] + 1);
        } cout << "\n";
    }
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    testcase();
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4484
final_rank: 14

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cassert>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
using ll = long long;
template<class E> using V = vector<E>;

V<V<int>> solve(int N){
    V<V<int>> ans(N, V<int>(N));
    if(N%4 == 0){
        auto sub = solve(N/2);
        REP(i,N/2) REP(j,N/2) ans[i*2][j*2] = sub[i][j] + N;
        REP(i,N/2) REP(j,N/2) ans[i*2+1][j*2+1] = sub[i][j] + N;
        int n = N / 2;
        REP(k,N/2){
            REP(f,N/2) ans[f*2][(f*2+k*2+1)%N] = k;
            REP(f,N/2) ans[(f*2+k*2+1)%N][f*2] = k+n;
        }
    } else {
        int n = N / 2;
        REP(k,n){
            ans[k*2][k*2+1] = k*2+0;
            ans[k*2+1][k*2] = k*2+1;
            REP(s,n) REP(t,n) if(s < t){
                ans[s*2+0][t*2+0] = (s+t)%n*2+0;
                ans[s*2+1][t*2+1] = (s+t)%n*2+1;
                ans[t*2+0][s*2+0] = (s+t)%n*2+1;
                ans[t*2+1][s*2+1] = (s+t)%n*2+0;
            }
        }
        REP(s,n) REP(t,n) if(s != t){
            ans[s*2+0][t*2+1] = N + (s+n-t-1)%n*2+0;
            ans[s*2+1][t*2+0] = N + (s+n-t-1)%n*2+1;
        }
        REP(i,N) ans[i][i] = N * 2 - 2;
    }
    return ans;
}

void testcase(){
    int N; cin >> N;
    if(N%2 == 1){ cout << "No\n"; return; }
    cout << "Yes\n";
    auto ans = solve(N);
    REP(i,N){
        REP(j,N){
            if(j) cout << " ";
            cout << (ans[i][j] + 1);
        } cout << "\n";
    }
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    testcase();
    return 0;
}
accuracy: 0.025974025974025976
time_ms: 10
memory_kb: 4528
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define REP(i, a) for (long long i = 0; i < (long long)(a); i++)
#define REP2(i, a, b) for (long long i = a; i < (long long)(b); i++)
#define RREP(i, a) for (long long i = (a)-1; i >= (long long)(0); --i)
#define RREP2(i, a, b) for (long long i = (b)-1; i >= (long long)(a); --i)
#define ALL(x) x.begin(), x.end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T> ostream& operator << (ostream &s, multiset<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for (auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }


int main() {
    int N;
    cin >> N;

    if (N == 1) {
        cout << "Yes" << endl;
        cout << 1 << endl;
        return 0;
    }
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int>> res(N, vector<int>(N, -1));

    for (int i = 0; i < N-1; i++) {
        int start = i;
        for (int j = 0; j < i; j++) {
            res[i][j] = start + 1;
            start = (start + 1) % (N-1);
        }
        res[N-1][i] = start + 1;
        start = (start + 1) % (N - 1);
        for (int k = i+1; k < N-1; k++) {
            res[k][i] = start + 1;
            start = (start + 1) % (N-1);
        }
    }

    for (int i = 0; i < N; i++) res[i][i] = N*2-1;
    for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
        res[i][j] = N*2-1 - res[j][i];
    }

    cout << "Yes" << endl;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (j) cout << " ";
            cout << res[i][j];
        }
        cout << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4332
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using ll = long long;
using pii = pair<ll, ll>;

template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b;return 1;}return 0;}
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b;return 1;}return 0;}

int main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
	int n;
	cin >> n;
	if (n == 1){
		cout << "Yes" << endl;
		cout << 1 << endl;
		return 0;
	}
	if (n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	vector<vector<int>> a(n, vector<int> (n, -1));
	for (int i = 0; i < n; i++){
		a[i][i] = n - 1;
	}

	for (int i = 1; i < n - 1; i++){
		int init = i - 1;
		for (int j = 0; j < i; j++){
			a[j][i] = init;
			init++;
			init %= (n - 1);
		}
	}
	for (int i = 0; i < n - 1; i++){
		a[i][n - 1] = ((2 * i - 1) % (n - 1) + n - 1) % (n - 1);
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < i; j++){
			a[i][j] = 2 * n - 2 - a[j][i];
		}
	}

	cout << "Yes" << endl;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cout << a[i][j] + 1 << (j == n - 1 ? '\n' : ' ');
		}
	}
}

/*
1 2 3 4 5 6 7 8 9 A
- 1 4 5 6 7 8 9 A 3
- - 1 6 7 8 9 A 2 5
- - - 1 8 9 A 2 3 7
- - - - 1 A 2 3 4 9
- - - - - 1 3 4 5 2
- - - - - - 1 5 6 4
- - - - - - - 1 7 6
- - - - - - - - 1 8
- - - - - - - - - 1

10 1 2 3 4 5 6 7 8 9 
- 10 3 4 5 6 7 8 0 1 
- - 10 5 6 7 8 0 1 2 
- - - 10 7 8 0 1 2 3 
- - - - 10 0 1 2 3 4 
- - - - - 10 2 3 4 5 
- - - - - - 10 4 5 6 
- - - - - - - 10 6 7 
- - - - - - - - 10 8 
- - - - - - - - - 10
*/
accuracy: 1
time_ms: 10
memory_kb: 4128
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using ll = long long;
using pii = pair<ll, ll>;

template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b;return 1;}return 0;}
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b;return 1;}return 0;}

int main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
	int n;
	cin >> n;
	if (n == 1){
		cout << "Yes" << endl;
		cout << 1 << endl;
		return 0;
	}
	if (n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}

	vector<vector<int>> a(n, vector<int> (n, -1));
	for (int i = 0; i < n; i++){
		a[i][i] = n - 1;
	}

	for (int i = 1; i < n - 1; i++){
		int init = i - 1;
		for (int j = 0; j < i; j++){
			a[j][i] = init;
			init++;
			init %= (n - 1);
		}
	}
	for (int i = 0; i < n - 1; i++){
		a[i][n - 1] = (2 * i + 2) % (n - 1);
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < i; j++){
			a[i][j] = 2 * n - 2 - a[j][i];
		}
	}
	
	cout << "Yes" << endl;
	for (int i = 0; i < n; i++){
	    for (int j = 0; j < n; j++){
	        cout << a[i][j] + 1 << (j == n - 1 ? '\n' : ' ');
	    }
	}
}

/*
1 2 3 4 5 6 7 8 9 A
- 1 4 5 6 7 8 9 A 3
- - 1 6 7 8 9 A 2 5
- - - 1 8 9 A 2 3 7
- - - - 1 A 2 3 4 9
- - - - - 1 3 4 5 2
- - - - - - 1 5 6 4
- - - - - - - 1 7 6
- - - - - - - - 1 8
- - - - - - - - - 1

10 1 2 3 4 5 6 7 8 9 
- 10 3 4 5 6 7 8 0 1 
- - 10 5 6 7 8 0 1 2 
- - - 10 7 8 0 1 2 3 
- - - - 10 0 1 2 3 4 
- - - - - 10 2 3 4 5 
- - - - - - 10 4 5 6 
- - - - - - - 10 6 7 
- - - - - - - - 10 8 
- - - - - - - - - 10
*/
accuracy: 0.025974025974025976
time_ms: 10
memory_kb: 4020
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define REP(i, a) for (long long i = 0; i < (long long)(a); i++)
#define REP2(i, a, b) for (long long i = a; i < (long long)(b); i++)
#define RREP(i, a) for (long long i = (a)-1; i >= (long long)(0); --i)
#define RREP2(i, a, b) for (long long i = (b)-1; i >= (long long)(a); --i)
#define ALL(x) x.begin(), x.end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T> ostream& operator << (ostream &s, multiset<T> P)
{ for (auto it : P) { s << "<" << it << "> "; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for (auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }


int main() {
    int N;
    cin >> N;

    if (N == 1) {
        cout << "Yes" << endl;
        cout << 1 << endl;
        return 0;
    }
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int>> res(N, vector<int>(N, -1));

    for (int i = 0; i < N-1; i++) {
        int start = i;
        for (int j = 0; j < i; j++) {
            res[i][j] = start + 1;
            start = (start + 1) % (N - 1);
        }
        res[N-1][i] = start + 1;
        start = (start + 1) % (N - 1);
        for (int k = i+1; k < N-1; k++) {
            res[k][i] = start + 1;
            start = (start + 1) % (N - 1);
        }
    }

    for (int i = 0; i < N; i++) res[i][i] = N;
    for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
        res[i][j] = N * 2 - res[j][i];
    }

    cout << "Yes" << endl;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (j) cout << " ";
            cout << res[i][j];
        }
        cout << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4324
final_rank: 8

code_snippet: #include "bits/stdc++.h"
#include <numeric>
// #include <atcoder/all>




using namespace std;

// clang-format off
/* accelration */
// 高速バイナリ生成
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// cin cout の結びつけ解除, stdioと同期しない(入出力非同期化)
// cとstdの入出力を混在させるとバグるので注意
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


/* alias */
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
using vs = vector<string>;

/* define short */
#define pb push_back
// #define mp make_pair
#define all(obj) (obj).begin(), (obj).end()
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

/* REP macro */
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)
#define repsd(i, a, n) for(ll i=n;i>=a;i--)
#define fore(i,a) for(auto &i:a)

/* 追加分 */
#define vsort(v) sort(v.begin(), v.end())
#define verase(v) v.erase(unique(v.begin(), v.end()), v.end())
#define vlb(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define argsort(v) sort(xy.begin(), xy.end(), [](const auto &p1, const auto &p2) { return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);})

/* debug */
// 標準エラー出力を含む提出はrejectされる場合もあるので注意
#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;

/* int128 */
#define __int128_t ll

/* func */
inline int in_int() { int x; cin >> x; return x; }
inline ll in_ll() { ll x; cin >> x; return x; }
inline string in_str() { string x; cin >> x; return x; }
// search_length: 走査するベクトル長の上限(先頭から何要素目までを検索対象とするか、1始まりで)
template <typename T> inline bool vector_finder(std::vector<T> vec, T element, unsigned int search_length) {
    auto itr = std::find(vec.begin(), vec.end(), element);
    size_t index = std::distance(vec.begin(), itr);
    if (index == vec.size() || index >= search_length) { return false; }
    else { return true; }
}
template <typename T> inline void print(const vector<T>& v, string s = " ")
{
    rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");
}
template <typename T, typename S> inline void print(const pair<T, S>& p)
{
    cout << p.first << " " << p.second << endl;
}
template <typename T> inline void print(const T& x) { cout << x << "\n"; }
inline void printd(double x) { cout << fixed << setprecision(15) << x << endl; }
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v)
{
    for (auto&& p : v) print(p);
}
// 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き
template <typename T> inline bool chmin(T& a, const T& b) { bool compare = a > b; if (a > b) a = b; return compare; }
template <typename T> inline bool chmax(T& a, const T& b) { bool compare = a < b; if (a < b) a = b; return compare; }
// gcd lcm
// C++17からは標準実装
// template <typename T> T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);}
// template <typename T> inline T lcm(T a, T b) {return (a * b) / gcd(a, b);}
// clang-format on

// 提出の際はコメントアウトすること
// #define __builtin_ctzll _tzcnt_u64
int alt__builtin_clz(unsigned int x)
{
    int rank = 0;
    while (x) {
        rank++;
        x >>= 1;
    }
    return 32 - rank;
}


static inline int alt__builtin_ctz(unsigned int x)
{
    rep(i, 32) {
        if (x & 1) return i;
        x >>= 1;
    }

}

static inline int alt__builtin_ctzll(unsigned long long x)
{
    rep(i, 64) {
        if (x & 1) return i;
        x >>= 1;
    }

}


template< typename T = int >
struct Edge {
    int from, to;
    T cost;
    int idx;

    Edge() = default;

    Edge(int from, int to, T cost = 1, int idx = -1) : from(from), to(to), cost(cost), idx(idx) {}

    operator int() const { return to; }
};

template< typename T = int >
struct Graph {
    vector< vector< Edge< T > > > g;
    int es;

    Graph() = default;

    explicit Graph(int n) : g(n), es(0) {}

    size_t size() const {
        return g.size();
    }

    void add_directed_edge(int from, int to, T cost = 1) {
        g[from].emplace_back(from, to, cost, es++);
    }

    void add_edge(int from, int to, T cost = 1) {
        g[from].emplace_back(from, to, cost, es);
        g[to].emplace_back(to, from, cost, es++);
    }

    void read(int M, int padding = -1, bool weighted = false, bool directed = false) {
        for (int i = 0; i < M; i++) {
            int a, b;
            cin >> a >> b;
            a += padding;
            b += padding;
            T c = T(1);
            if (weighted) cin >> c;
            if (directed) add_directed_edge(a, b, c);
            else add_edge(a, b, c);
        }
    }

    inline vector< Edge< T > >& operator[](const int& k) {
        return g[k];
    }

    inline const vector< Edge< T > >& operator[](const int& k) const {
        return g[k];
    }
};

template< typename T = int >
using Edges = vector< Edge< T > >;



// 定数
const ll INF = 1ll << 60;
const vi dd({ -1,0,1,0,-1 });
const double PI = atan(1) * 4;
double eps = 1e-10;
const ll MOD = 998244353;

// 最大公約数
ll gcd(ll a, ll b) {
    if (!b) return a;
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

// インタラクティブ用
void question(vll v) {
    cout << "?";
    rep(i, v.size()) {
        cout << " " << v[i];
    }
    cout << endl;
}
void answer(vll v) {
    cout << "!";
    rep(i, v.size()) {
        cout << " " << v[i];
    }
    cout << endl;
}

// 等差数列
ll arith_sum1(ll left, ll right, ll d) {
    return (left + right) * (right - left + d) / (2 * d);
}
ll arith_sum2(ll left, ll d, ll num) {
    return arith_sum1(left, left + d * (num - 1), d);
}


// 座標圧縮 (破壊的)
void comp(vll& a) {
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
}



int main() {

    ll n;
    cin >> n;

    if (n == 1) {
        print("Yes");
        print(1);
        return 0;
    }
    if (n % 2) {
        print("No");
        return 0;
    }
    else {
        print("Yes");
        vvll a(n, vll(n));
        rep(i, n) a[i][i] = 1;
        rep(j, n) rep(i, j) {
            if (i+j<n) a[i][j] = j + i+1;
            else if (j != n - 1) a[i][j] = j + i - n+2;
            else if (i < n / 2) a[i][j] = i * 2 + 1;
            else a[i][j] = (i - (n / 2)+1) * 2;
        }

        rep(j, n) rep(i, j) a[j][i] = a[i][j] + n - 1;
        rep(i, n) print(a[i]);
    }



}
accuracy: 1
time_ms: 10
memory_kb: 5140
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mkp make_pair
#define pb push_back
#define PII pair<int, int>
#define PLL pair<ll, ll>
int n, ans[510][510];
int change(int x){
	x--; if(x == 0) x = n;
	return x;
}
int change2(int x){
	x++; if(x == n + 1) x = 1;
	return x;
}
int main(){
	//用n-1种颜色对n个点的完全图进行着色 
	scanf("%d", &n);
	if(n == 1){
		puts("Yes\n1"); return 0;
	}
	if(n % 2){
		puts("No"); return 0;
	}
	puts("Yes");
	for(int i = 2; i <= n; i++){
		//标杆指向(1, i)，颜色为i-1 
		//cout<<"calc: "<<i<<endl;
		ans[1][i] = ans[i][1] = i - 1;
		int qwq = i * 2;
		for(int j = 1, k = i, l = i; j <= n / 2 - 1; j++){
			k = change(k); if(k == 1 || k == i) k = change(k);  if(k == 1 || k == i) k = change(k); 
			l = change2(k); if(l == 1 || l == i) l = change2(l);  if(l == 1 || l == i) l = change2(l);
			//cout<<k<<" "<<l<<endl; 
			ans[k][l] = ans[l][k] = i - 1;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++){
			if(i > j) ans[i][j] += n - 1;
			if(i == j) ans[i][j] = 2 * n - 1;
			printf("%d%c", ans[i][j], (j < n) ? ' ' : '\n');
		}
	return 0;
}
accuracy: 0.025974025974025976
time_ms: 10
memory_kb: 4432
final_rank: 19

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mkp make_pair
#define pb push_back
#define PII pair<int, int>
#define PLL pair<ll, ll>
int n, ans[510][510];
int main(){
	//用n-1种颜色对n个点的完全图进行着色 
	scanf("%d", &n);
	if(n % 2){
		puts("No"); return 0;
	}
	puts("Yes");
	for(int i = 2; i <= n; i++){
		//标杆指向(1, i)，颜色为i-1 
		ans[1][i] = ans[i][1] = i - 1;
	//	cout<<"calc: "<<i<<endl;
		int ze = 0;
		if(i + 1 <= n) ze += i + 1; else ze += 2;
		if(i - 1 > 1) ze += i - 1; else ze += n; 
		for(int j = 2; j <= n; j++){
			if(j == i) continue;
			int k = (ze + n - j) % n; if(k == 0) k = n;
			ans[j][k] = ans[k][j] = i - 1;
		//	cout<<j<<" "<<k<<" "<<i-1<<endl;
		} 
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++){
			if(i > j) ans[i][j] += n - 1;
			if(i == j) ans[i][j] = 2 * n - 1;
			printf("%d%c", ans[i][j], (j < n) ? ' ' : '\n');
		}
	return 0;
}
accuracy: 0.025974025974025976
time_ms: 10
memory_kb: 4380
final_rank: 18

code_snippet: //Love Patronum forever
#include <bits/stdc++.h>
using namespace std;
int n,a[501][501];
int main()
{
	scanf("%d",&n);
	if(n==1)
	{
		printf("Yes\n1\n");
		return 0;
	}
	if(n%2==1)
	{
		printf("No\n");
		return 0;
	}
	for(int i=1;i<=n;i++)a[i][i]=1,a[1][i]=i;
	for(int j=2;j<n;j++)
		for(int i=2;i<j;i++)
			a[i][j]=(a[i-1][j]-1)%(n-1)+2;
	for(int i=2;i<n;i++)
		a[i][n]=a[i-1][n]%(n-1)+2;
	for(int i=2;i<=n;i++)
		for(int j=1;j<i;j++)
			a[i][j]=a[j][i]+(n-1);
	printf("Yes\n");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)printf("%d ",a[i][j]);
		printf("%d\n",a[i][n]);
	}	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4200
final_rank: 5

code_snippet: #include<bits/stdc++.h>
using namespace std;

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  if(n==1){
    cout<<"Yes"<<endl;
    cout<<1<<endl;
    return 0;
  }

  if(n&1) drop("No");

  vector< vector<Int> > ans(n,vector<Int>(n,-1));

  Int cnt=1;
  for(Int i=0;i<n;i++) ans[i][i]=cnt;
  cnt++;

  for(Int t=0;t<2;t++){
    auto add_edge=
      [&](Int p,Int q,Int x){
        p=(p+n)%n;
        q=(q+n)%n;
        if(t==0) if(p>q) swap(p,q);
        if(t==1) if(p<q) swap(p,q);
        ans[p][q]=x;
      };
    for(Int i=0;i<n-1;i++){
      add_edge(i,n-1,cnt);
      for(Int j=1;j<n/2;j++){
        Int p=(i+(n-1)+j)%(n-1);
        Int q=(i+(n-1)-j)%(n-1);
        add_edge(p,q,cnt);
      }
      cnt++;
    }
  }

  cout<<"Yes"<<endl;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5060
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
const int N = 505;
int c[N][N],n;
int main() {
	scanf("%d",&n);
	if(n==1) printf("Yes\n1\n");
	else {
		if(n&1) printf("No\n");
		else {
			printf("Yes\n");
			for(int i=1;i<n;i++) c[i][1]=c[n-1][i+1]=i;
			for(int i=n-2;i>=2;i--) {
				for(int j=2;j<=i;j++) c[i][j]=c[i+1][j-1];
			}
			for(int i=1;i<n;i++) c[n][i]=c[i][i];
			for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(i<j) c[i][j]=c[j][i]+n-1;
			for(int i=1;i<=n;i++) c[i][i]=2*n-1;
			for(int i=1;i<=n;i++) 
				for(int j=1;j<=n;j++) printf("%d%c",c[i][j],j==n?'\n':' '); 
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4176
final_rank: 4

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 505

int table[SIZE][SIZE],work[SIZE][SIZE];


int main(){

	int N;
	scanf("%d",&N);

	if(N%2 == 1){

		if(N == 1){

			printf("Yes\n");
			printf("1\n");

		}else{

			printf("No\n");
		}
		return 0;
	}


	for(int row = 1; row <= N-1; row++){
		for(int col = 0; col < row; col++){

			work[row][col] = row+col;
			if(work[row][col] >= N){

				work[row][col] -= (N-1);
			}
		}
	}

	for(int i = 0; i < N; i++){

		table[i][i] = 2*N-1;
	}

	for(int col = 0; col <= N-2; col++){
		for(int row = col+2; row <= N-1; row++){
			table[row-1][col] = work[row][col];
		}
		table[N-1][col] = work[col+1][col];
	}
	for(int row = 0; row < N-1; row++){
		for(int col = row+1; col < N; col++){

			table[row][col] = (2*N-1)-table[col][row];
		}
	}

	printf("Yes\n");
	for(int row = 0; row < N; row++){
		printf("%d",table[row][0]);
		for(int col = 1; col < N; col++){

			printf(" %d",table[row][col]);
		}
		printf("\n");
	}

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5168
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=65537;
const int mo=65537;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head


const int N = 510;
int A[N][N],p[N][N];
/* 合并子问题 */
void merge(int n)
{
    /*
     * n 为偶数时，比赛 n - 1 天
     * n 为奇数时，比赛 n 天
     */
    int days = n&1 ? n  : n-1;
    /*
     * 中间值，若n为奇数，则使 m = (n / 2) + 1,
     * 即，前半部分不小于后半部分
     */
    int m = (int)ceil(n / 2.0);
    int passed_days = m& 1? m : m - 1;    /* 已经安排的天数 */

    /*
     *  通过前 n/2 的比赛安排，构造后n/2的比赛安排
     *  如果 n 为奇数，则会产生一个虚拟选手
     */
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= passed_days; j++)
        {
            if (A[i][j] != 0)   /* 如果 i 号在第 j 天有对手 */
            {
                /*
                 * 那么，(i + m) 号在第 j 天的对手为 i号的
                 * 对手往后数 m 号
                 */
                A[i + m][j] = A[i][j] + m;
            }
            else   /* 如果 i 号在第 j 天没有对手*/
            {
                /*
                 * 那么就让 i 号和 （i + m）号互为对手
                 */
                A[i + m][j] = i;
                A[i][j] = i + m;
            }
        }
    }

    int add_one = 0;        /*标志子问题是否是奇数，如果是的话构造增量加1 */
    if (A[1][passed_days] == m + 1)
        add_one = 1;
    for (int i = 1; i <= m; i++)
    {
        for (int j = passed_days + 1, count = 0; j <= days; j++, count++)
        {
            /*
             * 构造i 号在第 j 天的对手
             */
            int r_value = (count + (i - 1)  + add_one) % m + m + 1;
            A[i][j] = r_value;
            A[r_value][j] = i;
        }
    }
    if ( n & 1 )            /* 如果 n 为奇数，消除虚拟的选手 */
    {
        for (int i = 1; i <= 2 * m; i++)
        {
            for (int j = 1; j <= days; j++)
                if (A[i][j] == n + 1)
                    A[i][j] = 0;        /* A[i][j] = 0 ,表示 i 号选手在第 j 天没有比赛 */
        }
    }
}

/* 分治求解循环赛问题 */
void tournament(int n)
{
    if (n <= 1)
        return;
    else if (n == 2)        /* 2 个选手 */
    {
        A[1][1] = 2;
        A[2][1] = 1;
    }
    else
    {
        tournament((int)ceil(n / 2.0));
        merge(n);
    }
}

int main() {
    int n;
    scanf("%d",&n);
    if (n%2==1) {
        if (n==1) {
            puts("Yes\n1");
        } else {
            puts("No");
        }
        return 0;
    }
    tournament(n);
    for (int i=0;i<n;i++) p[i][i]=1;
    for (int i=1;i<=n-1;i++) {
        for (int j=1;j<=n;j++) if (A[j][i]>j) {
            p[j-1][A[j][i]-1]=i+1;
            p[A[j][i]-1][j-1]=n+i;
        }
    }
    puts("Yes");
    for (int i=0;i<n;i++) for (int j=0;j<n;j++) printf("%d%c",p[i][j]," \n"[j==n-1]);
}
accuracy: 1
time_ms: 10
memory_kb: 5204
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=65537;
const int mo=65537;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head


const int N = 510;
int A[N][N],p[N][N];
/* 合并子问题 */
void merge(int n)
{
    /*
     * n 为偶数时，比赛 n - 1 天
     * n 为奇数时，比赛 n 天
     */
    int days = n&1 ? n  : n-1;
    /*
     * 中间值，若n为奇数，则使 m = (n / 2) + 1,
     * 即，前半部分不小于后半部分
     */
    int m = (int)ceil(n / 2.0);
    int passed_days = m& 1? m : m - 1;    /* 已经安排的天数 */

    /*
     *  通过前 n/2 的比赛安排，构造后n/2的比赛安排
     *  如果 n 为奇数，则会产生一个虚拟选手
     */
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= passed_days; j++)
        {
            if (A[i][j] != 0)   /* 如果 i 号在第 j 天有对手 */
            {
                /*
                 * 那么，(i + m) 号在第 j 天的对手为 i号的
                 * 对手往后数 m 号
                 */
                A[i + m][j] = A[i][j] + m;
            }
            else   /* 如果 i 号在第 j 天没有对手*/
            {
                /*
                 * 那么就让 i 号和 （i + m）号互为对手
                 */
                A[i + m][j] = i;
                A[i][j] = i + m;
            }
        }
    }

    int add_one = 0;        /*标志子问题是否是奇数，如果是的话构造增量加1 */
    if (A[1][passed_days] == m + 1)
        add_one = 1;
    for (int i = 1; i <= m; i++)
    {
        for (int j = passed_days + 1, count = 0; j <= days; j++, count++)
        {
            /*
             * 构造i 号在第 j 天的对手
             */
            int r_value = (count + (i - 1)  + add_one) % m + m + 1;
            A[i][j] = r_value;
            A[r_value][j] = i;
        }
    }
    if ( n & 1 )            /* 如果 n 为奇数，消除虚拟的选手 */
    {
        for (int i = 1; i <= 2 * m; i++)
        {
            for (int j = 1; j <= days; j++)
                if (A[i][j] == n + 1)
                    A[i][j] = 0;        /* A[i][j] = 0 ,表示 i 号选手在第 j 天没有比赛 */
        }
    }
}

/* 分治求解循环赛问题 */
void tournament(int n)
{
    if (n <= 1)
        return;
    else if (n == 2)        /* 2 个选手 */
    {
        A[1][1] = 2;
        A[2][1] = 1;
    }
    else
    {
        tournament((int)ceil(n / 2.0));
        merge(n);
    }
}

int main() {
    int n;
    scanf("%d",&n);
    if (n%2==1) {
        if (n==1) {
            puts("Yes\n1\n");
        } else {
            puts("No");
        }
        return 0;
    }
    tournament(n);
    for (int i=0;i<n;i++) p[i][i]=1;
    for (int i=1;i<=n-1;i++) {
        for (int j=1;j<=n;j++) if (A[j][i]>j) {
            p[j-1][A[j][i]-1]=i+1;
            p[A[j][i]-1][j-1]=n+i;
        }
    }
    puts("Yes");
    for (int i=0;i<n;i++) for (int j=0;j<n;j++) printf("%d%c",p[i][j]," \n"[j==n-1]);
}
accuracy: 0.03896103896103896
time_ms: 10
memory_kb: 5168
final_rank: 16

code_snippet: #include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int ans[505][505];
int main() {
	int n;
	cin >> n;
	if (n % 2) {
		if (n == 1) cout << "Yes" << endl << 1 << endl;
		else {
			cout << "No" << endl;
		}
	}
	else {
		for (int i = 1; i <= n; i++)
			ans[i][i] = 1;
		for (int cs = 2; cs < 2 * n; cs += 2) {
			int pl = cs / 2;
			for (int j = 1; j < n; j++) {
				int nx = 0;
				if (j == pl) nx = n;
				else {
					nx = 2 * pl - j + n - 1;
					nx %= (n - 1);
					if (nx == 0) nx += n - 1;
				}
				if (nx < j) continue;
				ans[j][nx] = cs;
				ans[nx][j] = cs + 1;
			}
		}
		cout << "Yes" << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				printf("%d", ans[i][j]);
				if (j == n) printf("\n");
				else printf(" ");
			}
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4228
final_rank: 7

code_snippet: #include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n;
int ans[505][505];

int main(){
	n=readint();
	if(n==1){
		printf("Yes\n");
		printf("1\n");
		return 0;
	}
	if(n&1) return printf("No\n"),0;
	for(int i=1;i<=n;i++) ans[i][i]=2*n-1;
	for(int i=1;i<n;i++){
		ans[n][i]=2*i-1,ans[i][n]=2*i;
		int nl=i%(n-1)+1,nr=i-1;
		if(nr==0) nr=n-1;
		for(int j=1;j<=n/2-1;j++){
			ans[nl][nr]=2*i-1,ans[nr][nl]=2*i;
			nl=nl%(n-1)+1,nr--;
			if(nr==0) nr=n-1;
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			printf("%d",ans[i][j]);
			if(j<n) printf(" ");
		}
		printf("\n");
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4132
final_rank: 3

code_snippet: #include <iostream>
using namespace std;
int a[505][505];
int main() {
    int n;
    cin >> n;
    if(n == 1) {
        cout << "Yes" << endl << "1" << endl;
        return 0;
    }
    if(n % 2 == 1)
        cout << "No" << endl;
    else if(n % 2 == 0) {
        cout << "Yes" << endl;
        for(int i = 1; i <= n; i++)
            a[i][i] = n;
        for(int i = 1; i <= n / 2; i++)
            a[i][n - i + 1] = 2 * n - 1;
        for(int i = n / 2 + 1; i <= n; i++)
            a[i][n - i + 1] = 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[i][j] = i + j - 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[j][i] = 2 * n - i - (j - 1);
        for(int i = 2; i <= n / 2; i++)
            a[i][n] = 2 * n + 1 - 2 * i;
        for(int i = n - 1; i >= n / 2 + 1; i--)
            a[i][n] = n + 2 * (n - i);
        for(int i = n / 2 + 1; i <= n - 1; i++)
            a[n][i] = i * 2 - n;
        for(int i = 2; i <= n / 2; i++)
            a[n][i] = 2 * i - 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[i][j] = a[i][j - 1] + 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[j][i] = a[j - 1][i] - 1;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j < n; j++)
                cout << a[i][j] << " ";
            cout << a[i][n] << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4080
final_rank: 1

code_snippet: #include <iostream>
using namespace std;
int a[505][505];
int main() {
    int n;
    cin >> n;
    if(n % 2 == 1)
        cout << "No" << endl;
    else if(n % 2 == 0) {
        cout << "Yes" << endl;
        for(int i = 1; i <= n; i++)
            a[i][i] = n;
        for(int i = 1; i <= n / 2; i++)
            a[i][n - i + 1] = 2 * n - 1;
        for(int i = n / 2 + 1; i <= n; i++)
            a[i][n - i + 1] = 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[i][j] = i + j - 1;
        for(int j = 1; j <= n / 2 - 1; j++)
            for(int i = j + 1; i <= n - j; i++)
                a[j][i] = 2 * n - i - (j - 1);
        for(int i = 2; i <= n / 2; i++)
            a[i][n] = 2 * n + 1 - 2 * i;
        for(int i = n - 1; i >= n / 2 + 1; i--)
            a[i][n] = n + 2 * (n - i);
        for(int i = n / 2 + 1; i <= n - 1; i++)
            a[n][i] = i * 2 - n;
        for(int i = 2; i <= n / 2; i++)
            a[n][i] = 2 * i - 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[i][j] = a[i][j - 1] + 1;
        for(int i = n - 1; i >= n / 2 + 2; i--)
            for(int j = (n - i) + 2; j <= i - 1; j++)
                a[j][i] = a[j - 1][i] - 1;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j < n; j++)
                cout << a[i][j] << " ";
            cout << a[i][n] << endl;
        }
    }
    return 0;
}
accuracy: 0.03896103896103896
time_ms: 10
memory_kb: 4028
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define Maxn 510

int n, a[Maxn][Maxn];
int main()
{
    scanf("%d", &n);
    if (n==1) { puts("Yes"); puts("1"); return 0; }
    if (n&1) { puts("No"); return 0; }
    puts("Yes");
    for (int i=1; i<=n; i++)
        for (int j=i; j<=n; j++)
            a[i][j]=(i+j-2)%n+1;
    for (int i=2; i<=n; i++)
        for (int j=1; j<i; j++)
        {
            a[i][j]=(i+j-2)%(n-1)+n;
            if (a[i][j]==n) a[i][j]=(n<<1)-1;
        }
    for (int i=2; i<n; i++)
        if (a[n][i-1] + 2 > (n<<1) - 1) a[n][i]=a[n][i-1]-(n-3);
        else a[n][i]=a[n][i-1] + 2;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<n; j++)
            printf("%d ", a[i][j]);
        printf("%d\n", a[i][n]);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4200
final_rank: 5