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;
	
	while(t--)
	{
	    int N;
	    cin >> N;
	    int flag=0;
	    for (int i=0;i<N;i++){
	        for (int j=0;j<N;j++){
	            if(((2*i)+(7*j))==N){
	                cout<<"YES"<<endl;
	                flag=1;
	            }
	            
	        }
	    }
	    if (flag==0){
	        cout<<"NO"<<endl;
	    }
	   
	} 
	}

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

@sumitkrsah05
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.