My code to this problem is getting partially accpeted

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define vi vector
#define vec(x) vector
#define matrix vector<vector>
#define pii pair<int,int>
#define repf(i,s,e) for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i–)
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define w(x) int x; cin>>x; while(x–)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(…) __f(#VA_ARGS, VA_ARGS)
template
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename… Args>
void __f(const char* names, Arg1&& arg1, Args&&… args){
const char* comma = strchr(names + 1, ‘,’);cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args…);
}
#else
#define trace(…)
#endif

typedef tree<int, null_type, less, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1) returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set

void solve(){
int n,m,k,s; cin>>n>>m>>k>>s;

char arr[n][m];
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		cin>>arr[i][j];
	}
}

bool ok=1;
repf(i,0,n){
	repf(j,0,m){
		// cin>>ch;
		// if(i==3) trace(j,ch);
		if(s<k){
			ok=0;break;
		}
		if(arr[i][j]=='.'){
			if(j==m-1) s-=2;
			else s-=3;
		}
		else if(arr[i][j]=='*'){
			if(j==m-1) s+=5;
			else s+=4;
		}
		else if(arr[i][j]=='#')
			break;
		// trace(i,j,s);
	}
	// trace(i,s);
}

// trace(s);
if(ok){
	cout<<"Yes\n";
}
else{
	cout<<"No\n";
}

}

int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// if(fopen(“input.txt”, “r”)){
// freopen(“input.txt”, “r”, stdin),
// freopen(“output.txt”, “w”, stdout);
// }

int t=1;
//cin>>t;
while(t--){
	solve();
}

}