Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    std::cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10, PI = acos(-1.0);
template <class T> auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T> auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T> auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T> void SORT(T& seq) { sort(seq.begin(), seq.end()); }
template <class T, class S> void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T> void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T, class S, class R> long long pow(T n_0, S k_0, R mod_0) {
    long long n = n_0 % mod_0, k = k_0, mod = mod_0, now = 1;
    while (k) {
        if (k & 1) now = (now * n) % mod;
        n = (n * n) % mod;
        n >>= 1;
    }
    return now;
}
template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}

// 頂点の数、辺の情報、indexed
template <class num_type> struct max_flow {
    int n;
    num_type flow;
    vector<map<int, num_type>> g_temp, g;
    vector<vector<int>> gkey_temp;
    max_flow(int& t1, vector<tuple<int, int, num_type>>& t2, int indexed = 1) {
        int u, v;
        num_type w;
        n = t1;
        g_temp.resize(n);
        gkey_temp.resize(n);
        for (tuple<int, int, num_type> t3 : t2) {
            tie(u, v, w) = t3;
            add_edge(u - indexed, v - indexed, w);
        }
        for (u = 0; u < n; u++) {
            for (tuple<int, num_type> t3 : g_temp[u]) {
                tie(v, w) = t3;
                gkey_temp[u].push_back(v);
            }
        }
    }
    void add_edge(int From, int to, num_type& cap) {
        g_temp[From][to] = cap;
        g_temp[to][-From - 1] = 0;
    }
    // 最大流を計算する、gの中に実際のフローが入っている
    num_type calc_flow(int s, int t) {
        flow = 0;
        g = g_temp;
        vector<vector<int>> gkey = gkey_temp;
        while (true) {
            num_type inf = pow(10, 6);
            vector<bool> used(n, false);
            vector<int> used2(n, 0);
            vector<tuple<int, num_type>> q(1, make_tuple(s, inf));
            vector<num_type> ans = {0};
            while (q.size()) {
                int v;
                num_type f, a = ans[0];
                tie(v, f) = q.back();
                if (!a) {
                    if (v == t) {
                        ans[0] = f;
                        continue;
                    }
                    map<int, num_type> gv = g[v];
                    vector<int> gkv = gkey[v];
                    int l = (int)gkv.size();
                    used[v] = true;
                    while (true) {
                        int i = used2[v];
                        used2[v]++;
                        if (i < l) {
                            int to = gkv[i];
                            num_type cap = gv[to];
                            if (to < 0) { to = -to - 1; }
                            if ((!used[to]) && cap) {
                                q.push_back(make_tuple(to, min(f, cap)));
                                break;
                            }
                        } else {
                            q.pop_back();
                            ans[0] = 0;
                            break;
                        }
                    }
                } else {
                    q.pop_back();
                    if (q.size()) {
                        v = get<0>(q.back());
                        int to = gkey[v][used2[v] - 1];
                        g[v][to] -= a;
                        if (to < 0) {
                            to = -to - 1;
                        } else {
                            v = -v - 1;
                        }
                        g[to][v] += a;
                    }
                }
            }
            if (!ans[0]) { return flow; }
            flow += ans[0];
        }
    }
};

// 最大マッチングを行う、最大フローのライブラリも一緒に持ってくる
// 入力：xのサイズ、yのサイズ、xy間の辺、indexed
vector<tuple<int, int>> bimatch(int x_size, int y_size,
                                vector<tuple<int, int>> xy, int indexed = 1) {
    int m = (int)xy.size(), n = x_size + y_size + 2;
    int m2 = x_size + y_size + m, hosei = 1 - indexed;
    vector<tuple<int, int, int>> edge(m2);
    for (int i = 0; i < m; i++) {
        int x, y;
        tie(x, y) = xy[i];
        edge[i] = make_tuple(x + hosei, y + hosei + x_size, 1);
    }
    for (int i = 0; i < x_size; i++) { edge[m + i] = make_tuple(0, i + 1, 1); }
    for (int i = 0; i < y_size; i++) {
        edge[m + x_size + i] = make_tuple(i + x_size + 1, n - 1, 1);
    }
    max_flow<int> flow(n, edge, 0);
    flow.calc_flow(0, n - 1);
    vector<map<int, int>> g = flow.g;
    vector<tuple<int, int>> ret;
    for (int x = 0; x < (int)g.size(); x++) {
        if (x == n - 1) continue;
        int y, z, v;
        for (auto t : g[x]) {
            tie(y, v) = t;
            if (v == 0 || y > -2) continue;
            ret.push_back(
                make_tuple(-y - 2 + indexed, x - x_size - 1 + indexed));
        }
    }
    return ret;
}

int main() {
    PRE_COMMAND
    int h, w, x, y;
    cin >> h >> w;
    vector<vector<char>> v_s(h, vector<char>(w));
    cin >> v_s;
    vector<tuple<int, int>> v_t;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if ((i + j) % 2 || v_s[i][j] == '#') { continue; }
            x = i * w + j;
            if (i != 0 && v_s[i - 1][j] == '.')
                v_t.push_back(make_tuple(x, x - w));
            if (i != h - 1 && v_s[i + 1][j] == '.')
                v_t.push_back(make_tuple(x, x + w));
            if (j != 0 && v_s[i][j - 1] == '.')
                v_t.push_back(make_tuple(x, x - 1));
            if (j != w - 1 && v_s[i][j + 1] == '.')
                v_t.push_back(make_tuple(x, x + 1));
        }
    }
    for (int i = 0; i < (int)v_t.size(); i++) {
        tie(x, y) = v_t[i];
        v_t[i] = make_tuple(x / 2, y / 2);
    }
    int y_size = h * w / 2;
    int x_size = h * w - y_size;
    vector<tuple<int, int>> b = bimatch(x_size, y_size, v_t, 0);
    for (auto temp : b) {
        tie(x, y) = temp;
        x = 2 * x, y = 2 * y;
        if ((x / w) % 2) x++;
        if ((y / w) % 2 == 0) y++;
        if (x > y) swap(x, y);
        if (x + 1 < y || w == 1) {
            v_s[x / w][x % w] = 'v';
            v_s[y / w][y % w] = '^';
        } else {
            v_s[x / w][x % w] = '>';
            v_s[y / w][y % w] = '<';
        }
    }
    DEBUG(b.size());
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) { cout << v_s[i][j]; }
        cout << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:213:5: error: 'DEBUG' was not declared in this scope
  213 |     DEBUG(b.size());
      |     ^~~~~