Language: C++

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
#define F first
#define S second
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, m, a, b;
char s[1010][1010];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> m >> a >> b;
	rep(i, 1, n) rep(j, 1, m) s[i][j] = '.';
	int cnt4 = (n/2)*(m/2), cnta = 0, cntb = 0;
	if(n % 2 == 1) cnta = m-1;
	if(m % 2 == 1) cntb = n-1;
	{ // give to a
		cnta += n % 2;
		int g1 = cnta / 2, g2 = cntb / 2;
		int needa = max(a-g1, 0);
		int needb = max(b-g2, 0);
		if(needa + needb <= cnt4*2) {
			cout << "YES\n";
			for(int i = 2; i <= n; i += 2) {
				for(int j = 2; j <= m; j += 2) {
					if(needa) {
						s[i][j-1] = '<'; s[i][j] = '>';
						if(needa > 1) s[i-1][j-1] = '<', s[i-1][j] = '>';
						needa = max(needa - 2, 0);
						a -= 2;
						// cerr << a << ' '<< i << ' '<< j << nxtl;
					} else if(needb) {
						s[i-1][j] = '^', s[i][j] = 'v';
						if(b > 1) s[i-1][j-1] = '^', s[i][j-1] = 'v';
						needb = max(needb - 2, 0);
						b -= 2;
					}
				}
			}
			a = max(0, a);
			b = max(b, 0);
			if(a) for(int i = 2; i <= m; i += 2) s[n][i-1] = '<', s[n][i] = '>', a--;
			if(b) for(int i = 2; i < n; i += 2) s[i-1][m] = '^', s[i][m] = 'v', b--;
			rep(i, 1, n) {
				rep(j, 1, m) cout << s[i][j];
				cout << nxtl;
			}
			asser(!a && !b);
			return 0;
		}
		cnta -= n % 2;
	}
	{ // give to b
		cntb += m % 2;
		int g1 = cnta / 2, g2 = cntb / 2;
		int needa = max(a-g1, 0);
		int needb = max(b-g2, 0);
		if(needa + needb <= cnt4*2) {
			cout << "YES\n";
			for(int i = 2; i <= n; i += 2) {
				for(int j = 2; j <= m; j += 2) {
					if(needa) {
						s[i][j-1] = '<'; s[i][j] = '>';
						if(needa > 1) s[i-1][j-1] = '<', s[i-1][j] = '>';
						needa = max(needa - 2, 0);
						a -= 2;
					} else if(needb) {
						s[i-1][j] = '^', s[i][j] = 'v';
						if(b > 1) s[i-1][j-1] = '^', s[i][j-1] = 'v';
						needb = max(needb - 2, 0);
						b -= 2;
					}
				}
			}
			a = max(0, a);
			b = max(b, 0);
			if(a) for(int i = 2; i < m; i += 2) s[n][i-1] = '<', s[n][i] = '>', a--;
			if(b) for(int i = 2; i <= n; i += 2) s[i-1][m] = '^', s[i][m] = 'v', b--;
			rep(i, 1, n) {
				rep(j, 1, m) cout << s[i][j];
				cout << nxtl;
			}
			assert(!a && !b);
			return 0;
		}
		cntb -= m % 2;
	}
	cout << "NO\n";
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:25: error: 'asser' was not declared in this scope; did you mean 'assert'?
   79 |                         asser(!a && !b);
      |                         ^~~~~
      |                         assert