Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define rad 334
using namespace std;
int R[100005];
int K;
int X,T,A,time;
int Q;
int sens=-1;
int ind=0;
pair<int,int> a,b;
int main()
{
    cin>>X>>K;
    a.first=b.first=0;
    a.second=b.second=X;
    for(int i=1;i<=K;i++)cin>>R[i];
    cin>>Q;
    for(int i=1;i<=Q;i++)
    {
        cin>>T>>A;
        while(ind<K&&R[ind+1]<T)
        {
            a.first+=sens*(R[ind+1]-time);
            a.second+=sens*(R[ind+1]-time);
            b.first+=max(0,-a.first);
            b.second-=max(0,a.second-X);
            a.first=max(0,a.first);a.first=min(X,a.first);
            a.second=max(0,a.second);a.second=min(X,a.second);
            sens*=-1;
            time=R[ind+1];
            ind++;
        }
        a.first+=sens*(T-time);
        a.second+=sens*(T-time);
        b.first+=max(0,-a.first);
        b.second-=max(0,a.second-X);
        b.first=min(b.first,b.second);
        a.first=max(0,a.first);a.first=min(X,a.first);
        a.second=max(0,a.second);a.second=min(X,a.second);
        time=T;
        cout<<min(max(A,b.first),b.second)-b.first+a.first;
        cout<<"\n";
    }
    return 0;
}


Compiler output:
a.cc:8:11: error: 'int time' redeclared as different kind of entity
    8 | int X,T,A,time;
      |           ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:25:36: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator-'
   25 |             a.first+=sens*(R[ind+1]-time);
      |                            ~~~~~~~~^~~~~
      |                                   | |
      |                                   | time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                                   int
a.cc:26:37: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator-'
   26 |             a.second+=sens*(R[ind+1]-time);
      |                             ~~~~~~~~^~~~~
      |                                    | |
      |                                    | time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                                    int
a.cc:32:17: error: assignment of function 'time_t time(time_t*)'
   32 |             time=R[ind+1];
      |             ~~~~^~~~~~~~~
a.cc:35:25: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator-'
   35 |         a.first+=sens*(T-time);
      |                        ~^~~~~
      |                        | |
      |                        | time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                        int
a.cc:36:26: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator-'
   36 |         a.second+=sens*(T-time);
      |                         ~^~~~~
      |                         | |
      |                         | time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                         int
a.cc:42:13: error: assignment of function 'time_t time(time_t*)'
   42 |         time=T;
      |         ~~~~^~