Language: C++

#include<bits/stdc++.h>
#define ui unsigned int
#define ll __int128
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=500+10,MAXM=1000000+10;
int n,vis[MAXM],prime[MAXM],cnt,p;
ll G[MAXN][MAXN];
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void init()
{
	memset(vis,1,sizeof(vis));
	vis[0]=vis[1]=0;
	REP(i,2,MAXM-1)
	{
		if(vis[i])prime[++cnt]=i;
		for(register int j=1;j<=cnt&&i*prime[j]<MAXM;++j)
		{
			vis[i*prime[j]]=0;
			if(i%prime[j]==0)break;
		}
	}
}
inline bool check(int x,int y)
{
	if(G[x][y]%G[x-1][y]!=1)return false;
	if(G[x][y]%G[x+1][y]!=1)return false;
	if(G[x][y]%G[x][y-1]!=1)return false;
	if(G[x][y]%G[x][y+1]!=1)return false;
	return true;
}
int main()

	read(n);init();int x,y;
	REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
	REP(i,0,n+1)if(i&1)
	{
		x=0,y=i,++p;
		while(x<=n+1&&y>=0)G[x][y]*=prime[p],x++,y--;
	}
	REP(i,n+1,0)if(i%2==0)
	{
		x=n+1,y=i,++p;
		while(x>=0&&y<=n+1)G[x][y]*=prime[p],x--,y++;
	}
	REP(i,0,n+1)if(i%2==0)
	{
		x=n+1,y=i,++p;
		while(x>=0&&y>=0)G[x][y]*=prime[p],x--,y--;
	}
	REP(i,0,n+1)if(i&1)
	{
		x=0,y=i,++p;
		while(x<=n+1&&y<=n+1)G[x][y]*=prime[p],x++,y++;
	}
	REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
	{
		G[i][j]=G[i-1][j]*G[i+1][j]+1,assert(check(i,j));
	}
	REP(i,1,n)
	{
		REP(j,1,n)assert(G[i][j]<=1e15),write(G[i][j],' ');puts("");
	}
	return 0;
}


Compiler output:
a.cc: In function 'void init()':
a.cc:43:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         REP(i,2,MAXM-1)
      |             ^
a.cc:14:37: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                     ^
a.cc:43:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         REP(i,2,MAXM-1)
      |             ^
a.cc:14:43: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                           ^
a.cc:46:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |                 for(register int j=1;j<=cnt&&i*prime[j]<MAXM;++j)
      |                                  ^
a.cc: At global scope:
a.cc:63:9: error: expected initializer before 'read'
   63 |         read(n);init();int x,y;
      |         ^~~~
a.cc:63:23: error: expected constructor, destructor, or type conversion before ';' token
   63 |         read(n);init();int x,y;
      |                       ^
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:64:9: note: in expansion of macro 'REP'
   64 |         REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
      |         ^~~
a.cc:64:13: error: 'i' does not name a type; did you mean 'ui'?
   64 |         REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:64:9: note: in expansion of macro 'REP'
   64 |         REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
      |         ^~~
a.cc:64:25: error: 'j' does not name a type
   64 |         REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
      |                         ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:64:21: note: in expansion of macro 'REP'
   64 |         REP(i,0,n+1)REP(j,0,n+1)G[i][j]=1;
      |                     ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:65:9: note: in expansion of macro 'REP'
   65 |         REP(i,0,n+1)if(i&1)
      |         ^~~
a.cc:65:13: error: 'i' does not name a type; did you mean 'ui'?
   65 |         REP(i,0,n+1)if(i&1)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:65:9: note: in expansion of macro 'REP'
   65 |         REP(i,0,n+1)if(i&1)
      |         ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:70:9: note: in expansion of macro 'REP'
   70 |         REP(i,n+1,0)if(i%2==0)
      |         ^~~
a.cc:70:13: error: 'i' does not name a type; did you mean 'ui'?
   70 |         REP(i,n+1,0)if(i%2==0)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:70:9: note: in expansion of macro 'REP'
   70 |         REP(i,n+1,0)if(i%2==0)
      |         ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:75:9: note: in expansion of macro 'REP'
   75 |         REP(i,0,n+1)if(i%2==0)
      |         ^~~
a.cc:75:13: error: 'i' does not name a type; did you mean 'ui'?
   75 |         REP(i,0,n+1)if(i%2==0)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:75:9: note: in expansion of macro 'REP'
   75 |         REP(i,0,n+1)if(i%2==0)
      |         ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:80:9: note: in expansion of macro 'REP'
   80 |         REP(i,0,n+1)if(i&1)
      |         ^~~
a.cc:80:13: error: 'i' does not name a type; did you mean 'ui'?
   80 |         REP(i,0,n+1)if(i&1)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:80:9: note: in expansion of macro 'REP'
   80 |         REP(i,0,n+1)if(i&1)
      |         ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:85:9: note: in expansion of macro 'REP'
   85 |         REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
      |         ^~~
a.cc:85:13: error: 'i' does not name a type; did you mean 'ui'?
   85 |         REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:85:9: note: in expansion of macro 'REP'
   85 |         REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
      |         ^~~
a.cc:85:23: error: 'j' does not name a type
   85 |         REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
      |                       ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:85:19: note: in expansion of macro 'REP'
   85 |         REP(i,1,n)REP(j,1,n)if((i+j)%2==0)
      |                   ^~~
a.cc:14:20: error: expected unqualified-id before 'for'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                    ^~~
a.cc:89:9: note: in expansion of macro 'REP'
   89 |         REP(i,1,n)
      |         ^~~
a.cc:89:13: error: 'i' does not name a type; did you mean 'ui'?
   89 |         REP(i,1,n)
      |             ^
a.cc:14:54: note: in definition of macro 'REP'
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                      ^
a.cc:14:64: error: expected unqualified-id before '++' token
   14 | #define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
      |                                                                ^~
a.cc:89:9: note: in expansion of macro 'REP'
   89 |         REP(i,1,n)
      |         ^~~
a.cc:93:9: error: expected unqualified-id before 'return'
   93 |         return 0;
      |         ^~~~~~
a.cc:94:1: error: expected declaration before '}' token
   94 | }
      | ^