Language: C++

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
// #define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

#include <atcoder/maxflow>
using namespace atcoder;

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> grid(N);
    for(int i = 0; i < N; i++) {
        cin >> grid[i];
    }
    mf_graph<int> G(N * M + 2);
    int s = 0, t = N * M + 1;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M; j++) {
            if(grid[i - 1][j - 1] == '#') {
                continue;
            }
            if(i & 1) {
                if(j & 1) {
                    G.add_edge(s, (i - 1) * M + j, 1);
                } else {
                    G.add_edge((i - 1) * M + j, t, 1);
                }
            } else {
                if(j & 1) {
                    G.add_edge((i - 1) * M + j, t, 1);
                } else {
                    G.add_edge(s, (i - 1) * M + j, 1);
                }
            }
            if((i & 1) == (j & 1)) {
                for(int k = 0; k < 4; k++) {
                    int ni = i + dy[k], nj = j + dx[k];
                    if(ni <= 0 || ni > N || nj <= 0 || nj > M) {
                        continue;
                    }
                    if(grid[ni - 1][nj - 1] == '#') {
                        continue;
                    }
                    G.add_edge((i - 1) * M + j, (ni - 1) * M + nj, 1);
                }
            }
        }
    }
    int mf = G.flow(s, t);
    cout << mf << "\n";
    const auto &edges = G.edges();
    for(const auto &e : edges) {
        if(1 <= e.from && e.from <= N * M && 1 <= e.to && e.to <= N * M &&
           e.flow == 1) {
            int from_i = e.from / M;
            int from_j = e.from % M - 1;
            int to_i = e.to / M;
            int to_j = e.to % M - 1;
            if(e.from % M == 0) {
                from_i--;
                from_j = M - 1;
            }
            if(e.to % M == 0) {
                to_i--;
                to_j = M - 1;
            }
            debug(from_i, from_j, to_i, to_j);
            if(from_i == to_i) {
                grid[from_i][min(from_j, to_j)] = '>';
                grid[from_i][max(from_j, to_j)] = '<';
            } else {
                grid[min(from_i, to_i)][from_j] = 'v';
                grid[max(from_i, to_i)][from_j] = '^';
            }
        }
    }
    for(const auto &s : grid) {
        cout << s << "\n";
    }
}

Compiler output:
a.cc:69:10: fatal error: atcoder/maxflow: No such file or directory
   69 | #include <atcoder/maxflow>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.