title: Time limit exceeded error C++
body: <p>I'm programming in C++ some problems in an automated platform an it gives me time limit exceeded, I tested the code in terminal and I don't know why it doesn't stop waiting for numbers and I put a limit for n numbers in a while loop. It should stop when I enter n numbers. Here's the code: </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  
  int main(){
      int n;
      while (cin &gt;&gt; n){
          vector&lt;int&gt; v(n);
          int count = 0;
          for (int i = 0; i &lt; n; ++i){
              cin &gt;&gt; v[i];
              bool unique = true;
              for (int j = 0; j &lt; i; ++j){
  
                  if (v[i] == v[j]){
                      unique = false;
                      j = 1;
                  }
              }
              if (unique)
              ++count;
          }
              cout &lt;&lt; count &lt;&lt; endl;
      }
  }
  </code></pre>