Expand the Pond TLE

please see my code, i have referred the hints of this question & used the same approach, can you please help me out where I am doing error (getting tle in 4 test cases)
link for the code

hello @hv439606
your code is correct and passing all test cases.
submit it here-> https://csacademy.com/contest/archive/task/black-shapes/statement/

there is some issue with coding blocks checker ,it is showing tle for all solutions