Help me in solving BMCV2C09 problem

My issue

while submission I am shown status “time limit exceeded” but the code is running properly.
what should i do??

My code

// Update the code below to solve the problem

#include <bits/stdc++.h>
using namespace std;

int main() 
	int t;
    cin >> t;
	    int N;
	    cin >> N;
	    int flag=0;
	    for (int i=0;i<N;i++){
	        for (int j=0;j<N;j++){
	    if (flag==0){

Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

Its because u are using O(n^2) complexity .
The logic is its yes for all even .
Its also yes for all odd >= 7.
but its no for odd numbers <7.

when you output yes then also use break function.