Language: C++

#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d1, d2;
    cin >> n >> d1 >> d2;
    // n = 25; d1 = 2; d2 = 25;
    // n = 4; d1 = 9; d2 = 25;
// for(int n = 1; n <= 25; n++){ for(int d1 = 1; d1 < 30; d1++){ for(int d2 = 1; d2 < 30; d2++){
    vector<string> board1;
    int times = 100;
for(int _ = 0; _ < times * times; _++){
    printde(d1, d2);
    vector<pair<int, int>> ps;
    for(int i = 0; i <= 2 * n; i++){
        for(int j = 0; j <= 2 * n; j++){
            if(d1 == i * i + j * j){ ps.emplace_back(i, j); }
            if(d2 == i * i + j * j){ ps.emplace_back(i, j); }
        }
    }
    // prints(ps);
    vector<string> board(2 * n, string(2 * n, '.'));
    auto put = [&](int y, int x){ 
        if(y < 0 || 2 * n <= y || x < 0 || 2 * n <= x){ return; }
        board[y][x] = '*';
    };
    int cnt = 0;
    for(int i = 0; i < 2 * n; i++){
        for(int j = 0; j < 2 * n; j++){
            if(board[i][j] == '.'){
                board[i][j] = 'x';
                cnt++;
                for(auto& p : ps){
                    put(i + p.first, j + p.second);
                    put(i + p.second, j + p.first);
                    put(i - p.first, j + p.second);
                    put(i - p.second, j + p.first);
                    put(i + p.first, j - p.second);
                    put(i + p.second, j - p.first);
                    put(i - p.first, j - p.second);
                    put(i - p.second, j - p.first);
                }
                j += _ % times;
                // j++;
                // i = 1000;
                // break;
            }
        }
        i += _ / times;
        // i++;
    }
    // printd(n * n, cnt);
    // for(auto& b : board){
    //     prints(b);
    // }
    if(n * n <= cnt){
        printd(n * n, cnt);
        board1 = board;
        break;
    }
    // if(n * n > cnt){ printde(n * n, cnt); return 1; }
}
// } } }
    if(board1.empty){
        return 0;
    }
    int cnt = 0;
    for(int i = 0; i < 2 * n; i++){
        for(int j = 0; j < 2 * n; j++){
            if(board1[i][j] == 'x'){
                cout << i << ' ' << j << '\n';
                cnt++;
                if(cnt == n * n){ return 0; }
            }
        }
    }
}
/*
1 2
x.....x
..*.*..
.*...*.
...x...
.*...*.
..*.*..
x.....x

x**x**x
x**x**x
x**x**x
x**x**x
x**x**x
x**x**x
x**x**x

3 4 | 5
x....*
.
.
.
.
*

2 3
x.........
..........
...*......
..*.......
..........
..........
..........
..........
..........
..........
..........
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:92:20: error: cannot convert 'std::vector<std::__cxx11::basic_string<char> >::empty' from type 'bool (std::vector<std::__cxx11::basic_string<char> >::)() const noexcept' to type 'bool'
   92 |     if(board1.empty){
      |                    ^