Language: C++

#include <iostream>
#include <vector>
#include <cmath>


using namespace std;






int main() {






//    freopen("/Users/balazskemenes/Documents/temp/practise/src/problems/input.txt","r",stdin);




    int studentCount;
    cin >> studentCount;

    int checkpointCount;
    cin >> checkpointCount;




    vector<int> studentsX;
    vector<int> studentsY;

    vector<int> checkpointsX;
    vector<int> checkpointsY;


    for(int i = 0; i < studentCount; ++i) {


        int sX;
        int sY;

        cin >> sX;
        cin >> sY;


        studentsX.emplace_back(sX);
        studentsY.emplace_back(sY);

    }





    for(int i = 0; i < checkpointCount; ++i) {


        int cX;
        int cY;

        cin >> cX;
        cin >> cY;


        checkpointsX.emplace_back(cX);
        checkpointsY.emplace_back(cY);

    }


    for(int i = 0; i < studentCount; ++i) {


        int sX = studentsX[i];
        int sY = studentsY[i];


        double minDistance = INT_MAX;

        int checkpointId = 0;

        for(int j = 0; j < checkpointCount; ++j) {


            int cX = checkpointsX[j];
            int cY = checkpointsY[j];


            double currentDistance = abs(sX - cX) + abs(sY - cY);


            if(currentDistance < minDistance) {


                minDistance = currentDistance;


                checkpointId = j + 1;

            }




        }



        cout << checkpointId << endl;


    }


// ------------------------------------------------------------------------------------------









//
//    unsigned long long N;
//    cin >> N;
//
//
//
//    unsigned long long limit = N / 2;
//
//    int minLength = to_string(N).size();
//
//
//    for(int i = 2; i < limit; ++ i) {
//
//
//        if(N % i == 0) {
//
//            unsigned long long rightSide = N / i;
//
//
//            unsigned long long leftSide = i;
//            unsigned long long originalRightSide = rightSide;
//
//            int leftSideLength=0;
//            for(;leftSide;leftSide/=10) leftSideLength++;
//            leftSideLength = leftSideLength==0 ? 1 : leftSideLength;
//
//
//
//
//
//
////            int leftSideLength = intLength(i);
//
//
//
//
//
//            int rightSideLength=0;
//            for(;rightSide;rightSide/=10) rightSideLength++;
//            rightSideLength = rightSideLength==0 ? 1 : rightSideLength;
//
//
//
//
//
//
////            int rightSideLength = intLength(rightSide);
//
//
//
//
//
//
//            int currentMaxLength = max(leftSideLength, rightSideLength);
//
//
//
//            if(currentMaxLength > minLength) {
//
//                break;
//            }
//
//
//            if(currentMaxLength < minLength) {
//
//
//                minLength = currentMaxLength;
//
//            }
//
//
//
//
//
//
//        }
//
//
//
//
//    }
//
//
//
//    cout << minLength;
//
//
//

















    return 0;
}















Compiler output:
a.cc: In function 'int main()':
a.cc:83:30: error: 'INT_MAX' was not declared in this scope
   83 |         double minDistance = INT_MAX;
      |                              ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cmath>
  +++ |+#include <climits>
    4 |