Language: C++

#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

#include <sstream>

#define debug(args...) { std::string _s = #args; std::replace(_s.begin(), _s.end(), ',', ' '); std::stringstream _ss(_s); std::istream_iterator<std::string> _it(_ss); _err(std::cerr, _it, args); }
#define WHATIS(x) std::cerr << #x << " is " << x << '\n'

template<typename T>
std::ostream& operator<<(std::ostream&o,const std::vector<T>&v) {
	o<<'['; for(int i=0;i<v.size();i++) o<<v[i]<<","[i==v.size()-1]; o<<']'; return o;
}

void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
template<typename T, typename... Args>
void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    _err(cerr,++it, args...);
}


signed main() {
	int h,w,a,b;
	std::cin >> h >> w >> a >> b;
	if(a==0&&b==0) {
		std::vector<std::vector<int> > grid(h,std::vector<int>(w,0));
		for(auto i:grid) {
			for(auto j:i) {
				std::cout << j;
			}
			std::cout << ENDL;
		}
		return 0;
	}
	if(a==0&&w==1) {
		rep(i,b) std::cout << 1 << ENDL;
		rep(i,h-b) std::cout << 0 << ENDL;
		return 0;
	}
	if(b==0&&h==1) {
		rep(i,a) std::cout << 1;
		rep(i,w-a) std::cout << 0;
		return 0;
	}
	if(a==0 || b==0) print("No");
	if(w%a==0 && h%b==0 && w/a==h/b) {
		std::vector<std::vector<int> > grid(h,std::vector<int>(w,0));
		for(int i=0;i*a<w;i++) {
			rep(x,a) {
				rep(y,b) {
					grid[i*b+y][i*a+x]=1;
				}
			}
		}
		for(auto i:grid) {
			for(auto j:i) {
				std::cout << j;
			}
			std::cout << ENDL;
		}
	} else {
		print("No");
	}
	return 0;
}


Compiler output:
a.cc:37:30: error: 'std::istream_iterator' has not been declared
   37 | void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
      |                              ^~~
a.cc:37:51: error: expected ',' or '...' before '<' token
   37 | void _err(std::ostream& cerr,std::istream_iterator<std::string> it) { cerr << '\n'; }
      |                                                   ^
a.cc:39:31: error: 'std::istream_iterator' has not been declared
   39 | void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
      |                               ^~~
a.cc:39:52: error: expected ',' or '...' before '<' token
   39 | void _err(std::ostream& cerr, std::istream_iterator<std::string> it, T a, Args... args) {
      |                                                    ^
a.cc: In function 'void _err(std::ostream&, int)':
a.cc:40:14: error: 'it' was not declared in this scope; did you mean 'int'?
   40 |     cerr << *it << " = " << a << "  ";
      |              ^~
      |              int
a.cc:40:29: error: 'a' was not declared in this scope
   40 |     cerr << *it << " = " << a << "  ";
      |                             ^
a.cc:41:21: error: 'args' was not declared in this scope; did you mean 'Args'?
   41 |     _err(cerr,++it, args...);
      |                     ^~~~
      |                     Args