I am a novice to CP and while I was doing this problem of finding the second maximum among three numbers I wrote this code which however works for int but doesn't work for long even though they are the same data types.
Input Format:
- The first line contains the number of triples, N. 
- The next N lines which follow each have three space separated integers. 
Input Used:
3
1 2 3
10 15 5
100 999 500
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
       int n;
       cin >>n ;
       while(n--){
          long a,b,c,d;//if i change long to int output is correct  
          scanf("%i%i%i",&a,&b,&c);
          d=min(max(a,b),max(a,c));
          printf("%i\n",d);// outputs 1 \n 10 \n 100 \n(\n means new line)
     }
    return 0;
    }
 
    