Why am I getting wrong answer?

Hi, Can anybody tell me what exactly are we suppose to find in problem RECTCNC ?

So far I understood, we have to find the number of rectangles in a co-ordinate system which I am perfectly getting. Still I got “wrong answer” reply when I submitted the code.

Here is my code.

/*#####################################################################################################
#   TO FIND THE NUMBER OF RECTANGLES PRESENT IN A CARTESIAN CO-ORDINATE SYSTEM WHERE POINTS ARE GIVEN #
#   AND NO TWO CO-ORDINATES HAVE SAME ABSCISSA                                                        #
#                                                                                                     #
#                            PROGRAM BY-: AMRUTANSU GARANAIK                                          #
#####################################################################################################*/
#include<stdio.h>

#include<stdlib.h>
main()
{
      printf("Enter the number of co-ordinates and press RETURN key....\nThen input the co-ordinates (x,y)\nNo three co-ordinates should have same abscissa\n\n");
      int n;        //total inputs
      scanf("%d",&n);
      int x[n],y[n];      
      int i,j,k,l;
      for(i=0;i<n;i++)
                              scanf("%d%d",&x[i],&y[i]);
      int count;              //To count number of co-ordinates with same abscissa

      for(i=0;i<n;i++)
      {
                      count=1;          //First value is 1 as we take one abscissa and compare it with others..first abscissa makes count 1
                      for(j=i+1;j<n;j++)
                                        if(x[i]==x[j])
                                                      count++;
                      if(count>2)       //Checks if three co-ordinates or more have same abscissa
                      {
                                 printf("Invalid input");
                                
                                 exit(1);
                      }
      }
      
      int rec_count=0;        //Number of rectangles before counting begins
      for(i=0;i<n;i++)        //Counting the number of rectangles
      for(j=0;j<n;j++)
                      if(x[i]==x[j])
                                    for(k=i+1;k<n;k++)
                                    for(l=k+1;l<n;l++)
                                                      if((x[k]==x[l])&&((y[i]==y[k])&&(y[j]==y[l])))
                                                                                                   rec_count++;
      printf("Number of rectangles = %d",rec_count);
     
}

Please read FAQ - http://www.codechef.com/wiki/faq#How_does_Codechef_test_whether_my_solution_is_correct_or_not, especially this part is important in your case:

If your program starts by printing ‘Enter the number’ and the problem does not tell you to do so, then since this is not part of the correct output, you will be never be judged correct regardless of what the rest of your program does.

don’t ask for imputing number at terminal, rather type all input into a file and redirect it to as a input of your program… e.g create file input_file with these input
6
7 1
3 5
3 1
1 5
1 1
7 5
0

and run your program as ./a.out < input_file. and now your program should print only 3 on terminal.

//