Language: C++

//^
#include<cstring>
#include<cstdio>
#include<vector>
#define min(a<b?a:b)
#define max(a>b?a:b)
using std::vector;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
#define MaN 200005
#define MaI 262144
int n,m,num[MaN],f[MaN],t[MaI*2+5],a[MaN];
vector<int> v[MaN];
inline void rw(int x,int v){for(x+=MaI+1;t[x]=min(t[x],v),x>>=1;);}
inline int query(int l,int r){
    int res=1e9;
    for(l+=N,r+=N+2;l^r^1;l>>=1,r>>=1){
        if(~l&1) res=min(res,t[l+1]);
        if( r&1) res=min(res,t[r-1]);
    }
    return res;
}
int main(){
    n=read();
    for(int i=1;i<=n;++i) num[i]=num[i-1]+1-(a[i]=read()),f[i]=1e9;
    m=read();memset(t,0x3f,sizeof t);
	int l;
    for(int i=1;i<=m;++i) l=read(),v[l-1].push_back(read());
    for(int i=0;i<n;++i){
        f[i+1]=min(f[i+1],f[i]+a[i+1]);
        for(int j=0;j<v[i].size();j++){
            int w=min(f[i]+num[v[i][j]]-num[i],query(i,v[i][j])+num[v[i][j]]);
            f[v[i][j]]=min(f[v[i][j]],w); rw(v[i][j],w-num[v[i][j]]);
        }
    }
    printf("%d\n",f[n]);
}

Compiler output:
a.cc:5:14: error: expected ',' or ')', found "<"
    5 | #define min(a<b?a:b)
      |              ^
a.cc:6:14: error: expected ',' or ')', found ">"
    6 | #define max(a>b?a:b)
      |              ^
a.cc: In function 'void rw(int, int)':
a.cc:18:47: error: 'min' was not declared in this scope; did you mean 'std::min'?
   18 | inline void rw(int x,int v){for(x+=MaI+1;t[x]=min(t[x],v),x>>=1;);}
      |                                               ^~~
      |                                               std::min
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc: In function 'int query(int, int)':
a.cc:21:12: error: 'N' was not declared in this scope
   21 |     for(l+=N,r+=N+2;l^r^1;l>>=1,r>>=1){
      |            ^
a.cc:22:22: error: 'min' was not declared in this scope; did you mean 'std::min'?
   22 |         if(~l&1) res=min(res,t[l+1]);
      |                      ^~~
      |                      std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:23:22: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |         if( r&1) res=min(res,t[r-1]);
      |                      ^~~
      |                      std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:34:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   34 |         f[i+1]=min(f[i+1],f[i]+a[i+1]);
      |                ^~~
      |                std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~