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 int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    int h, w, k, cnt = 0;
    cin >> h >> w >> k;
    char a[h+1][w+1];

    fori(i, 1, h)
    {
    	fori(j, 1, w) 
    	{
    		cin >> a[i][j];
    		if(a[i][j] == '1') cnt++;
    	}
    }

    if(cnt <= k) {cout << 0; return 0;}

    int req = cnt/k;
    if(cnt%k) req++;

    fori(i, 1, (h-1)*(w-1))
    {
    	int box = 0;
    	if(i %2 == 0) box = (i/2 + 1)*(i/2 + 1);
    	else box = (i/2 + 1)*(i/2 + 2);

    	if(box >= req) {cout << i; return 0;}
    }

    return 0;
}
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#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 int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    int h, w, k, cnt = 0;
    cin >> h >> w >> k;
    char a[h+1][w+1];

    fori(i, 1, h)
    {
    	fori(j, 1, w) 
    	{
    		cin >> a[i][j];
    		if(a[i][j] == '1') cnt++;
    	}
    }

    if(cnt <= k) {cout << 0; return 0;}

    int req = cnt/k;
    if(cnt%k) req++;

    fori(i, 1, (h-1)*(w-1))
    {
    	int box = 0;
    	if(i %2 == 0) box = (i/2 + 1)*(i/2 + 1);
    	else box = (i/2 + 1)*(i/2 + 2);

    	if(box >= req) {cout << i; return 0;}
    }

    return 0;
}


Compiler output:
a.cc:151:11: error: redefinition of 'const long long int INF'
  151 | const int INF = 4e18;
      |           ^~~
a.cc:53:11: note: 'const long long int INF' previously defined here
   53 | const int INF = 4e18;
      |           ^~~
a.cc:152:11: error: redefinition of 'const long long int mod'
  152 | const int mod = 1e9+7;
      |           ^~~
a.cc:54:11: note: 'const long long int mod' previously defined here
   54 | const int mod = 1e9+7;
      |           ^~~
a.cc:154:8: error: redefinition of 'int main()'
  154 | signed main()
      |        ^~~~
a.cc:56:8: note: 'int main()' previously defined here
   56 | signed main()
      |        ^~~~