Language: C++

#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

const int MOD = INF+7;

int main(){
    int n,m,q;cin >> n >> m >> q;
    Graph G(n);
    rep(i,m){
        int a,b;cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    rep(i,n){
        if(!G[i].empty())sort(ALL(G[i]));
    }

    int l,r;
    while(cin >> l >> r){
        ll res = 0;
        l--;r--;
        REP(i,l,r){
            if(G[i].empty())continue;

            if(lower_bound(r == *lower_bound( ALL(G[i]) , r ) ){
                res += (upper_bound( ALL(G[i]) , r) - G[i].begin() + 1);
            }
            else res += lower_bound( ALL(G[i]) , r) - G[i].begin();
        }
        cout<<res<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:27: error: no matching function for call to 'lower_bound(bool)'
   70 |             if(lower_bound(r == *lower_bound( ALL(G[i]) , r ) ){
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 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/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 1 provided
a.cc:73:13: error: expected primary-expression before 'else'
   73 |             else res += lower_bound( ALL(G[i]) , r) - G[i].begin();
      |             ^~~~
a.cc:72:14: error: expected ')' before 'else'
   72 |             }
      |              ^
      |              )
   73 |             else res += lower_bound( ALL(G[i]) , r) - G[i].begin();
      |             ~~~~
a.cc:70:15: note: to match this '('
   70 |             if(lower_bound(r == *lower_bound( ALL(G[i]) , r ) ){
      |               ^