Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,int> mpci;
typedef map<int,int> mpii;
typedef map<string,int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))
#define INF 1e9

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
void finish(string s)
{
	cout<<s<<endl;
	exit(0);
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
const ll power(int n,int k)
{
	ll t=1;
	rep(i,k)
	  t*=n;
	return t;
}
const string turn2(int n)
{
	string s="";
	while(n!=0)
	{
		s+=(char)(n%2+'0');
		n/=2;
	}
	reverse(s.begin(),s.end());
	return s;
}
string turn(int n,int k)
{
	string s="";
	while(n)
	{
		s+=(char)(n%k+'0');
		n/=k;
	}
	reverse(s.begin(),s.end());
	return s;
}
const string turn16(int n)
{
	string s="";
	while(n!=0)
	{
		if(n%16>9)
		  s+=(char)('A'+n%16-10);
		else
		  s+=(char)('0'+n%16);
		n/=16;
	}
	reverse(s.begin(),s.end());
	return s;
}
const ll quickpower(int n,int k)
{
	if(k==1)
	  return n;
	if(k%2==1)
	  return n*quickpower(n,k/2)*quickpower(n,k/2);
	else
	  return quickpower(n,k/2)*(quickpower(n,k/2));
}
/*
void merge(int a[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)
	{
	  l[i]=a[i+left];
    }
	for(int i=0;i<n2;i++)
	{
	  r[i]=a[mid+i];
	}
	r[n2]=l[n1]=INF;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++)
	{
		if(l[i]<=r[j])
		{
			a[k]=l[i++];
		}
		else
		{
			a[k]=r[j++];
		}
	}
}
void mergesort(int a[],int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}
int binsearch(int x,int v[],int n)
{
	int low=0,high=n-1;
	int mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(x<v[mid])
		  high=mid-1;
		else
		  if(x>v[mid])
		    low=mid+1;
		  else
		    return mid+1;
	}
	return -1;
}
int partition(int a[],int left,int right)
{
	int p=a[left];
	int i=left;
	int j=right+1;
	for(;;)
	{
		while(a[++i]<p)
		  if(i>=right)
		    break;
		while(a[j--]>p)
		  if(j<=left)
		    break;
		if(i>=j)
		  break;
		else
		  swap(a[i],a[j]);
	}
	if(j>=left)
	  return j;
	swap(a[left],a[j]);
	return j;
}
void quicksort(int a[],int left,int right)
{
	int q;
	while(right>left)
	{
		q=partition(a,left,right);
	    if(n-q+1==k)
	    {
	        cout<<a[q];
	  		exit(0);
		}
		quicksort(a,left,q-1);
		quicksort(a,q+1,right);
	}
}
void dfs(int n)
{
	if(use[n])
	  return;
	use[n]=true;
	cout<<n<<endl;
	for(int i=0;i<v[n].size();i++)
	  dfs(v[n][i]);
}*/
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
string s[20];
int h[20],l[1010];
int n,m,cnt=0,k;  
int dp[20][1010];
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  cin>>n>>m>>k;
  rep(i,n)
  {
  	cin>>s[i];
  }
  memset(dp,0,sizeof(dp));
  forn(i,1,n)
  {
    forn(j,1,m)
    {
    	dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+(s[i-1][j-1]=='1');
    }
  }
  if(dp[n][m]==n*m&&k==1)
  {
  	cout<<n+m-2<<endl;
  	return 0;
  }
  /*rep(i,n+1)
  {
  	rep(j,m+1)
  	{
  		cout<<dp[i][j]<<" ";
	}
	cout<<endl;
  }*/
  //cout<<(1<<n)<<endl;
  vi v;
  int ans=1e9;
  for(int mask=0;mask<(1<<(n-1));mask++)
  {
  	int now=0;
  	v.clear();
  	rep(i,n-1)
  	{
  	  if(mask&(1<<i))	
  	  {
  	  	//cout<<i<<endl;
  	  	now++;
  	  	v.pb(i);
	  }
	}
	v.pb(n-1);
	bool f=0;
	rep(i,m)
	{
		int last=-1;
		rep(j,v.size())
		{
			if((dp[v[j]+1][i+1]-dp[last+1][i+1]-dp[v[j]+1][i]+dp[last+1][i])>k)
			{				
			  f=1;
			}
			last=v[j];
		}
	}
	if(f)
	  continue;
	//cout<<endl;
	int last=-1,lasth=-1;
	f=0;
	//int last=-1,lasth=-1;
	rep(i,m+1)
	{
		last=-1;
		rep(j,v.size())
		{
			//cout<<v[j]<<endl;
			//cout<<dp[v[j]+1][m]<<" "<<dp[last][m]<<" "<<dp[v[j]+1][lasth]<<" "<<dp[last][lasth]<<endl;
			//cout<<(dp[v[j]+1][m]-dp[last+1][m])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])<<endl;
			if((dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])>k)
			{
				lasth=i-1;
				now++;
				break;
			}
			last=v[j];
		}
		//cout<<endl;
	}
	ans=min(ans,now);
	//cout<<endl;
	/*if(now<ans)
	{
		cout<<v.size()-1<<" "<<now-v.size()+1<<endl;
		rep(i,v.size())
		{
			cout<<v[i]<<endl;
		}
		cout<<endl;
	lasth=-1;
	rep(i,m+1)
	{
		last=-1;
		rep(j,v.size())
		{
			//cout<<v[j]<<endl;
			//cout<<dp[v[j]+1][m]<<" "<<dp[last][m]<<" "<<dp[v[j]+1][lasth]<<" "<<dp[last][lasth]<<endl;
			cout<<(dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])<<endl;
			if((dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])>k)
			{
				lasth=i-1;
				//now++;
				break;
			}
			last=v[j];
		}
		//cout<<endl;
	}
	}
	*/
	ans=min(ans,now);
  }
  /*if(ans==1e9)
    cout<<n+m-2<<endl;
  else*/
    cout<<ans<<endl;
  //cout<<l<<endl;
  return 0;
}
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,int> mpci;
typedef map<int,int> mpii;
typedef map<string,int> mpsi;
typedef set<int> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))
#define INF 1e9

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
void finish(string s)
{
	cout<<s<<endl;
	exit(0);
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
const ll power(int n,int k)
{
	ll t=1;
	rep(i,k)
	  t*=n;
	return t;
}
const string turn2(int n)
{
	string s="";
	while(n!=0)
	{
		s+=(char)(n%2+'0');
		n/=2;
	}
	reverse(s.begin(),s.end());
	return s;
}
string turn(int n,int k)
{
	string s="";
	while(n)
	{
		s+=(char)(n%k+'0');
		n/=k;
	}
	reverse(s.begin(),s.end());
	return s;
}
const string turn16(int n)
{
	string s="";
	while(n!=0)
	{
		if(n%16>9)
		  s+=(char)('A'+n%16-10);
		else
		  s+=(char)('0'+n%16);
		n/=16;
	}
	reverse(s.begin(),s.end());
	return s;
}
const ll quickpower(int n,int k)
{
	if(k==1)
	  return n;
	if(k%2==1)
	  return n*quickpower(n,k/2)*quickpower(n,k/2);
	else
	  return quickpower(n,k/2)*(quickpower(n,k/2));
}
/*
void merge(int a[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)
	{
	  l[i]=a[i+left];
    }
	for(int i=0;i<n2;i++)
	{
	  r[i]=a[mid+i];
	}
	r[n2]=l[n1]=INF;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++)
	{
		if(l[i]<=r[j])
		{
			a[k]=l[i++];
		}
		else
		{
			a[k]=r[j++];
		}
	}
}
void mergesort(int a[],int left,int right)
{
	if(left+1<right)
	{
		int mid=(left+right)/2;
		mergesort(a,left,mid);
		mergesort(a,mid,right);
		merge(a,left,mid,right);
	}
}
int binsearch(int x,int v[],int n)
{
	int low=0,high=n-1;
	int mid;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(x<v[mid])
		  high=mid-1;
		else
		  if(x>v[mid])
		    low=mid+1;
		  else
		    return mid+1;
	}
	return -1;
}
int partition(int a[],int left,int right)
{
	int p=a[left];
	int i=left;
	int j=right+1;
	for(;;)
	{
		while(a[++i]<p)
		  if(i>=right)
		    break;
		while(a[j--]>p)
		  if(j<=left)
		    break;
		if(i>=j)
		  break;
		else
		  swap(a[i],a[j]);
	}
	if(j>=left)
	  return j;
	swap(a[left],a[j]);
	return j;
}
void quicksort(int a[],int left,int right)
{
	int q;
	while(right>left)
	{
		q=partition(a,left,right);
	    if(n-q+1==k)
	    {
	        cout<<a[q];
	  		exit(0);
		}
		quicksort(a,left,q-1);
		quicksort(a,q+1,right);
	}
}
void dfs(int n)
{
	if(use[n])
	  return;
	use[n]=true;
	cout<<n<<endl;
	for(int i=0;i<v[n].size();i++)
	  dfs(v[n][i]);
}*/
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
string s[20];
int h[20],l[1010];
int n,m,cnt=0,k;  
int dp[20][1010];
/*======================================================================*/
int main()
{
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  cin>>n>>m>>k;
  rep(i,n)
  {
  	cin>>s[i];
  }
  memset(dp,0,sizeof(dp));
  forn(i,1,n)
  {
    forn(j,1,m)
    {
    	dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+(s[i-1][j-1]=='1');
    }
  }
  if(dp[n][m]==n*m&&k==1)
  {
  	cout<<n+m-2<<endl;
  	return 0;
  }
  /*rep(i,n+1)
  {
  	rep(j,m+1)
  	{
  		cout<<dp[i][j]<<" ";
	}
	cout<<endl;
  }*/
  //cout<<(1<<n)<<endl;
  vi v;
  int ans=1e9;
  for(int mask=0;mask<(1<<(n-1));mask++)
  {
  	int now=0;
  	v.clear();
  	rep(i,n-1)
  	{
  	  if(mask&(1<<i))	
  	  {
  	  	//cout<<i<<endl;
  	  	now++;
  	  	v.pb(i);
	  }
	}
	v.pb(n-1);
	bool f=0;
	rep(i,m)
	{
		int last=-1;
		rep(j,v.size())
		{
			if((dp[v[j]+1][i+1]-dp[last+1][i+1]-dp[v[j]+1][i]+dp[last+1][i])>k)
			{				
			  f=1;
			}
			last=v[j];
		}
	}
	if(f)
	  continue;
	//cout<<endl;
	int last=-1,lasth=-1;
	f=0;
	//int last=-1,lasth=-1;
	rep(i,m+1)
	{
		last=-1;
		rep(j,v.size())
		{
			//cout<<v[j]<<endl;
			//cout<<dp[v[j]+1][m]<<" "<<dp[last][m]<<" "<<dp[v[j]+1][lasth]<<" "<<dp[last][lasth]<<endl;
			//cout<<(dp[v[j]+1][m]-dp[last+1][m])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])<<endl;
			if((dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])>k)
			{
				lasth=i-1;
				now++;
				break;
			}
			last=v[j];
		}
		//cout<<endl;
	}
	ans=min(ans,now);
	//cout<<endl;
	/*if(now<ans)
	{
		cout<<v.size()-1<<" "<<now-v.size()+1<<endl;
		rep(i,v.size())
		{
			cout<<v[i]<<endl;
		}
		cout<<endl;
	lasth=-1;
	rep(i,m+1)
	{
		last=-1;
		rep(j,v.size())
		{
			//cout<<v[j]<<endl;
			//cout<<dp[v[j]+1][m]<<" "<<dp[last][m]<<" "<<dp[v[j]+1][lasth]<<" "<<dp[last][lasth]<<endl;
			cout<<(dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])<<endl;
			if((dp[v[j]+1][i+1]-dp[last+1][i+1])-(dp[v[j]+1][lasth+1]-dp[last+1][lasth+1])>k)
			{
				lasth=i-1;
				//now++;
				break;
			}
			last=v[j];
		}
		//cout<<endl;
	}
	}
	*/
	ans=min(ans,now);
  }
  /*if(ans==1e9)
    cout<<n+m-2<<endl;
  else*/
    cout<<ans<<endl;
  //cout<<l<<endl;
  return 0;
}


Compiler output:
a.cc:502:13: error: redefinition of 'void read(int&)'
  502 | inline void read(int &x)
      |             ^~~~
a.cc:74:13: note: 'void read(int&)' previously defined here
   74 | inline void read(int &x)
      |             ^~~~
a.cc:517:13: error: redefinition of 'void write(long long int)'
  517 | inline void write(long long x) {
      |             ^~~~~
a.cc:89:13: note: 'void write(long long int)' previously defined here
   89 | inline void write(long long x) {
      |             ^~~~~
a.cc:526:6: error: redefinition of 'void finish(std::string)'
  526 | void finish(string s)
      |      ^~~~~~
a.cc:98:6: note: 'void finish(std::string)' previously defined here
   98 | void finish(string s)
      |      ^~~~~~
a.cc:531:8: error: redefinition of 'std::string int_to_string(int)'
  531 | string int_to_string(int n)
      |        ^~~~~~~~~~~~~
a.cc:103:8: note: 'std::string int_to_string(int)' previously defined here
  103 | string int_to_string(int n)
      |        ^~~~~~~~~~~~~
a.cc:543:5: error: redefinition of 'int string_to_int(std::string)'
  543 | int string_to_int(string s)
      |     ^~~~~~~~~~~~~
a.cc:115:5: note: 'int string_to_int(std::string)' previously defined here
  115 | int string_to_int(string s)
      |     ^~~~~~~~~~~~~
a.cc:554:4: error: redefinition of 'll lcm(int, int)'
  554 | ll lcm(int a,int b)
      |    ^~~
a.cc:126:4: note: 'll lcm(int, int)' previously defined here
  126 | ll lcm(int a,int b)
      |    ^~~
a.cc:558:6: error: redefinition of 'bool prime(int)'
  558 | bool prime(int n)
      |      ^~~~~
a.cc:130:6: note: 'bool prime(int)' previously defined here
  130 | bool prime(int n)
      |      ^~~~~
a.cc:567:10: error: redefinition of 'const ll power(int, int)'
  567 | const ll power(int n,int k)
      |          ^~~~~
a.cc:139:10: note: 'const ll power(int, int)' previously defined here
  139 | const ll power(int n,int k)
      |          ^~~~~
a.cc:574:14: error: redefinition of 'const std::string turn2(int)'
  574 | const string turn2(int n)
      |              ^~~~~
a.cc:146:14: note: 'const std::string turn2(int)' previously defined here
  146 | const string turn2(int n)
      |              ^~~~~
a.cc:585:8: error: redefinition of 'std::string turn(int, int)'
  585 | string turn(int n,int k)
      |        ^~~~
a.cc:157:8: note: 'std::string turn(int, int)' previously defined here
  157 | string turn(int n,int k)
      |        ^~~~
a.cc:596:14: error: redefinition of 'const std::string turn16(int)'
  596 | const string turn16(int n)
      |              ^~~~~~
a.cc:168:14: note: 'const std::string turn16(int)' previously defined here
  168 | const string turn16(int n)
      |              ^~~~~~
a.cc:610:10: error: redefinition of 'const ll quickpower(int, int)'
  610 | const ll quickpower(int n,int k)
      |          ^~~~~~~~~~
a.cc:182:10: note: 'const ll quickpower(int, int)' previously defined here
  182 | const ll quickpower(int n,int k)
      |          ^~~~~~~~~~
a.cc:722:11: error: redefinition of 'const int dx []'
  722 | const int dx[]={-1,0,1,0};
      |           ^~
a.cc:294:11: note: 'const int dx [4]' previously defined here
  294 | const int dx[]={-1,0,1,0};
      |           ^~
a.cc:723:11: error: redefinition of 'const int dy []'
  723 | const int dy[]={0,-1,0,1};
      |           ^~
a.cc:295:11: note: 'const int dy [4]' previously defined here
  295 | const int dy[]={0,-1,0,1};
      |           ^~
a.cc:724:11: error: redefinition of 'const int month [2][12]'
  724 | const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
      |           ^~~~~
a.cc:296:11: note: 'const int month [2][12]' previously defined here
  296 | const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
      |           ^~~~~
a.cc:725:8: error: redefinition of 'std::string s [20]'
  725 | string s[20];
      |        ^
a.cc:297:8: note: 'std::string s [20]' previously declared here
  297 | string s[20];
      |        ^
a.cc:726:5: error: redefinition of 'int h [20]'
  726 | int h[20],l[1010];
      |     ^
a.cc:298:5: note: 'int h [20]' previously declared here
  298 | int h[20],l[1010];
      |     ^
a.cc:726:11: error: redefinition of 'int l [1010]'
  726 | int h[20],l[1010];
      |           ^
a.cc:298:11: note: 'int l [1010]' previously declared here
  298 | int h[20],l[1010];
      |           ^
a.cc:727:5: error: redefinition of 'int n'
  727 | int n,m,cnt=0,k;
      |     ^
a.cc:299:5: note: 'int n' previously declared here
  299 | int n,m,cnt=0,k;
      |     ^
a.cc:727:7: error: redefinition of 'int m'
  727 | int n,m,cnt=0,k;
      |       ^
a.cc:299:7: note: 'int m' previously declared here
  299 | int n,m,cnt=0,k;
      |       ^
a.cc:727:9: error: redefinition of 'int cnt'
  727 | int n,m,cnt=0,k;
      |         ^~~
a.cc:299:9: note: 'int cnt' previously defined here
  299 | int n,m,cnt=0,k;
      |         ^~~
a.cc:727:15: error: redefinition of 'int k'
  727 | int n,m,cnt=0,k;
      |               ^
a.cc:299:15: note: 'int k' previously declared here
  299 | int n,m,cnt=0,k;
      |               ^
a.cc:728:5: error: redefinition of 'int dp [20][1010]'
  728 | int dp[20][1010];
      |     ^~
a.cc:300:5: note: 'int dp [20][1010]' previously declared here
  300 | int dp[20][1010];
      |     ^~
a.cc:730:5: error: redefinition of 'int main()'
  730 | int main()
      |     ^~~~
a.cc:302:5: note: 'int main()' previously defined here
  302 | int main()
      |     ^~~~