Language: C++

#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=200005;
vector<int> v[nmax];
int aib[nmax],best[nmax],b[nmax],cost[nmax];
int n,m,i,j,num,x,y;
void query(int nod,int l,int r)
{
    if(st<=l&&r<=dr)
    {
        ans=min(ans,arb[nod]);
        return;
    }
    int m=(l+r)/2;
    if(st<=m) query(2*nod,l,m);
    if(m<dr) query(2*nod+1,m+1,r);
}
void update(int nod int l,int r)
{
    if(l==r)
    {
        arb[nod]=best[i];
        return;
    }
}
int main()
{
    freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
        if(b[i]==0)
        {
            num++;
            cost[i]=-1;
        }
        else cost[i]=1;
        aib[i]=(1<<30);
    }
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(i=1;i<=n;i++)
        best[i]=(1<<30);
    for(i=1;i<=n;i++)
    {
          for(j=0;j<v[i].size();j++)
        {
            st=i;dr=v[i][j];ans=(1<<30);
            qry(1,1,n);
            if(ans<best[v[i][j]])
            {
                best[v[i][j]]=ans;
                poz=v[i][j];
                update(1,1,n);
            }

        }
        best[i]=min(best[i-1]+cost[i],best[i]);
        update(1,1,n);

    }
    cout<<best[n]+num;
    return 0;
}


Compiler output:
a.cc: In function 'void query(int, int, int)':
a.cc:11:8: error: 'st' was not declared in this scope; did you mean 'std'?
   11 |     if(st<=l&&r<=dr)
      |        ^~
      |        std
a.cc:11:18: error: 'dr' was not declared in this scope; did you mean 'r'?
   11 |     if(st<=l&&r<=dr)
      |                  ^~
      |                  r
a.cc:13:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |         ans=min(ans,arb[nod]);
      |         ^~~
      |         abs
a.cc:13:21: error: 'arb' was not declared in this scope; did you mean 'aib'?
   13 |         ans=min(ans,arb[nod]);
      |                     ^~~
      |                     aib
a.cc:17:8: error: 'st' was not declared in this scope; did you mean 'std'?
   17 |     if(st<=m) query(2*nod,l,m);
      |        ^~
      |        std
a.cc:18:10: error: 'dr' was not declared in this scope; did you mean 'r'?
   18 |     if(m<dr) query(2*nod+1,m+1,r);
      |          ^~
      |          r
a.cc: At global scope:
a.cc:20:21: error: expected ',' or '...' before 'int'
   20 | void update(int nod int l,int r)
      |                     ^~~
a.cc: In function 'void update(int)':
a.cc:22:8: error: 'l' was not declared in this scope
   22 |     if(l==r)
      |        ^
a.cc:22:11: error: 'r' was not declared in this scope
   22 |     if(l==r)
      |           ^
a.cc:24:9: error: 'arb' was not declared in this scope; did you mean 'aib'?
   24 |         arb[nod]=best[i];
      |         ^~~
      |         aib
a.cc: In function 'int main()':
a.cc:55:13: error: 'st' was not declared in this scope; did you mean 'std'?
   55 |             st=i;dr=v[i][j];ans=(1<<30);
      |             ^~
      |             std
a.cc:55:18: error: 'dr' was not declared in this scope
   55 |             st=i;dr=v[i][j];ans=(1<<30);
      |                  ^~
a.cc:55:29: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |             st=i;dr=v[i][j];ans=(1<<30);
      |                             ^~~
      |                             abs
a.cc:56:13: error: 'qry' was not declared in this scope
   56 |             qry(1,1,n);
      |             ^~~
a.cc:60:17: error: 'poz' was not declared in this scope
   60 |                 poz=v[i][j];
      |                 ^~~
a.cc:61:23: error: too many arguments to function 'void update(int)'
   61 |                 update(1,1,n);
      |                 ~~~~~~^~~~~~~
a.cc:20:6: note: declared here
   20 | void update(int nod int l,int r)
      |      ^~~~~~
a.cc:66:15: error: too many arguments to function 'void update(int)'
   66 |         update(1,1,n);
      |         ~~~~~~^~~~~~~
a.cc:20:6: note: declared here
   20 | void update(int nod int l,int r)
      |      ^~~~~~