Language: C++

#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


template <class T> struct fen {
    using U = internal::to_unsigned_t<T>;

  public:
    fen() : _n(0) {}
    fen(int n) : _n(n), data(n) {}

    void add(int p, T x) {
        assert(0 <= p && p < _n);
        p++;
        while (p <= _n) {
            data[p - 1] += U(x);
            p += p & -p;
        }
    }

    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        return sum(r) - sum(l);
    }

  private:
    int _n;
    std::vector<U> data;

    U sum(int r) {
        U s = 0;
        while (r > 0) {
            s += data[r - 1];
            r -= r & -r;
        }
        return s;
    }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,q;
  cin>>n>>q;

  fen<ll> f(n);

  rep(i,n){
    ll x;
    cin>>x;
    f.add(i,x);
  }

  rep(i,q){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0) f.add(b,c);
    else cout << f.sum(b,c) << endl;
  }

}


Compiler output:
a.cc:37:15: error: 'internal' does not name a type
   37 |     using U = internal::to_unsigned_t<T>;
      |               ^~~~~~~~
a.cc:59:17: error: 'U' was not declared in this scope
   59 |     std::vector<U> data;
      |                 ^
a.cc:59:18: error: template argument 1 is invalid
   59 |     std::vector<U> data;
      |                  ^
a.cc:59:18: error: template argument 2 is invalid
a.cc:61:5: error: 'U' does not name a type
   61 |     U sum(int r) {
      |     ^
a.cc: In member function 'void fen<T>::add(int, T)':
a.cc:47:17: error: invalid types 'int[int]' for array subscript
   47 |             data[p - 1] += U(x);
      |                 ^
a.cc: In instantiation of 'T fen<T>::sum(int, int) [with T = long long int]':
a.cc:91:23:   required from here
   91 |     else cout << f.sum(b,c) << endl;
      |                  ~~~~~^~~~~
a.cc:54:19: error: no matching function for call to 'fen<long long int>::sum(int&)'
   54 |         return sum(r) - sum(l);
      |                ~~~^~~
a.cc:52:7: note: candidate: 'T fen<T>::sum(int, int) [with T = long long int]'
   52 |     T sum(int l, int r) {
      |       ^~~
a.cc:52:7: note:   candidate expects 2 arguments, 1 provided
a.cc:54:28: error: no matching function for call to 'fen<long long int>::sum(int&)'
   54 |         return sum(r) - sum(l);
      |                         ~~~^~~
a.cc:52:7: note: candidate: 'T fen<T>::sum(int, int) [with T = long long int]'
   52 |     T sum(int l, int r) {
      |       ^~~
a.cc:52:7: note:   candidate expects 2 arguments, 1 provided