Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main () {
	long H,W,h,w;
	cin >> H >> W >> h >> w;
	if (h == 1 && w == 1) {
		cout << "No\n";
		return 0;
	}
	if (h == H && w == W) {
		cout << "No\n";
		return 0;
	}

	long lb = H*W - 4;
	long olb = lb;
	long ub = abs(4*(w*z - 1));
	long oub = ub;
	for (long x = lb+1; x <= ub-1; x++) {
		if ((x%4) == 0 && x < pow(10,9)) {
			//Possible
			cout << "Yes\n";
			long a = x;
			long b = -1;
			for (long i = 0; i < H; i++) {
					for (long j = 0; j < W; j++) {
						if ((i == 0 && j == (W-1)) ||
							(i == 0 && j == 0) ||
							(i == (H-1) && j == 0) ||
							(i == (H-1) && j == (W-1))) {
							cout << a << " ";
						} else {
							cout << b << " ";
						}
					}
					cout << "\n";
				}
			return 0;
		}
	}
	lb += olb;
	ub += oub;
	for (long x = lb+1; x <= ub-1; x++) {
		if ((x%4) == 0 && x <= pow(10,9)) {
			//Possible
			cout << "Yes\n";
			long a = x;
			long b = -2;
			for (long i = 0; i < H; i++) {
					for (long j = 0; j < W; j++) {
						if ((i == 0 && j == (W-1)) ||
							(i == 0 && j == 0) ||
							(i == (H-1) && j == 0) ||
							(i == (H-1) && j == (W-1))) {
							cout << a << " ";
						} else {
							cout << b << " ";
						}
					}
					cout << "\n";
				}
			return 0;
		}
	}
	lb += olb;
	ub += oub;
	for (long x = lb+1; x <= ub-1; x++) {
		if ((x%4) == 0 && x < pow(10,9)) {
			//Possible
			cout << "Yes\n";
			long a = x;
			long b = -3;
			for (long i = 0; i < H; i++) {
					for (long j = 0; j < W; j++) {
						if ((i == 0 && j == (W-1)) ||
							(i == 0 && j == 0) ||
							(i == (H-1) && j == 0) ||
							(i == (H-1) && j == (W-1))) {
							cout << a << " ";
						} else {
							cout << b << " ";
						}
					}
					cout << "\n";
				}
			return 0;
		}
	lb += olb;
	ub += oub;
	for (long x = lb+1; x <= ub-1; x++) {
		if ((x%4) == 0 && x < pow(10,9)) {
			//Possible
			cout << "Yes\n";
			long a = x;
			long b = -4;
			for (long i = 0; i < H; i++) {
					for (long j = 0; j < W; j++) {
						if ((i == 0 && j == (W-1)) ||
							(i == 0 && j == 0) ||
							(i == (H-1) && j == 0) ||
							(i == (H-1) && j == (W-1))) {
							cout << a << " ";
						} else {
							cout << b << " ";
						}
					}
					cout << "\n";
				}
			return 0;
		}
	}

	cout << "No\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:28: error: 'z' was not declared in this scope
   19 |         long ub = abs(4*(w*z - 1));
      |                            ^
a.cc:22:39: error: 'pow' was not declared in this scope
   22 |                 if ((x%4) == 0 && x < pow(10,9)) {
      |                                       ^~~
a.cc:46:40: error: 'pow' was not declared in this scope
   46 |                 if ((x%4) == 0 && x <= pow(10,9)) {
      |                                        ^~~
a.cc:70:39: error: 'pow' was not declared in this scope
   70 |                 if ((x%4) == 0 && x < pow(10,9)) {
      |                                       ^~~
a.cc:93:39: error: 'pow' was not declared in this scope
   93 |                 if ((x%4) == 0 && x < pow(10,9)) {
      |                                       ^~~
a.cc:117:2: error: expected '}' at end of input
  117 | }
      |  ^
a.cc:5:13: note: to match this '{'
    5 | int main () {
      |             ^