title: same program gives different outputs everytime I run
body: <p>I tried writing a program that outputs "YES" whether every x value or y value is all the same. Otherwise it gives the output "NO". The logic is, if all the x values maximum value is the same as the all the x values minimum value, than this value has never changed, hence all the x values are the same. Same for the y values.</p>
  
  <p>However, the output sometimes give the correct result, sometimes not (for the same input). Moreover, the outputs are not regular. (For example, 2 correct, 3 wrong, 5 correct, 1 wrong etc.)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;climits&gt;
  using namespace std;
  
  int main(){
      int n;
      int minX,minY=INT_MAX;
      int maxX,maxY=INT_MIN;
      cin&gt;&gt;n;
      while(n--){    //for the next n line
          int x,y;
          cin&gt;&gt;x&gt;&gt;y;
          maxX=max(maxX,x);
          //cout&lt;&lt;maxX&lt;&lt;" ";    //comments I write to find out what the heck is happening
  
          minX=min(minX,x);    // This value changes irregularly, which I suspect is the problem.
          //cout&lt;&lt;minX&lt;&lt;" ";
  
          maxY=max(maxY,y);
          //cout&lt;&lt;maxY&lt;&lt;" ";
  
          minY=min(minY,y);
          //cout&lt;&lt;minY&lt;&lt;endl;
  
      }
      if(maxX==minX||maxY==minY){    //If the x values or the y values are all the same, true
          cout&lt;&lt;"YES";
      }
      else{
          cout&lt;&lt;"NO";
      }
      return 0;
  }
  </code></pre>
  
  <p>Input:</p>
  
  <pre><code>5
  0 1
  0 2
  0 3
  0 4
  0 5
  </code></pre>
  
  <p>Output when it Works (with the couts I commented):</p>
  
  <pre><code>0 0 1 1
  0 0 2 1
  0 0 3 1
  0 0 4 1
  0 0 5 1
  YES
  </code></pre>
  
  <p>One of the output when it doesn't work(with the couts I commented)</p>
  
  <pre><code>0 -1319458864 1 1   // Not all the wrong outputs are the same, each wrong output is different than the other wrong output.
  0 -1319458864 2 1
  0 -1319458864 3 1
  0 -1319458864 4 1
  0 -1319458864 5 1
  NO
  </code></pre>