Language: C++

#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<tuple>
#include<cstdio>
#include<cstdlib>
#include<complex>
#include<iomanip>

using namespace std;

#define MAX 200005
#define ll long long
#define pii pair<int,int>
#define INT_MAX 2147483647

ll arr[MAX]; //opt[MAX];
ll square [10005];
ll added [10005];
//int sum[MAX];
//vector<pii> matriz;
//vector <pii> parentesis;
int n;
int q;
int root;
ll sum;
int l;
int r;
int size;

//int matriz [1405][1405];
//int dist [1405][1405];
//int rigth [1405][1405];
//int lef[1405][1405];
//int temp;
//deque < int > pila;
bool dentro (int le, int ri, int x)
{
	return (x>=le && x <= ri);
}
int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> q;
	root = (int)sqrt((double)n);
	size = n/root;
	for (int i = 0; i < q; i++)
	{
		int a;
		ll d;
		cin >> a >> l >> r;
		l--;
		r--;
		if(a==0) 
		{
			cin >> d;
			for (int i = 0; i <= size; i++)
			{
				if(dentro(l,r,i*root) || dentro (i*root, i*root + root -1,l))
				{
					if(dentro(l,r,i*root) && dentro(l,r,i*root + root -1))
					{
						
						square[i] += root * d;
						added[i] += d;
					}
					else
					{
						
						for (int j = i*root; j < (i+1)*(root); j++)
						{
							
							arr[j] += added[i];
							if(dentro(l,r,j))
							{
								arr[j]+= d;
								square[i] += d;
							}
						}
						added[i] = 0;
					}
				}
			}
		}
		else 
		{
			sum = 0;
			for (int i = 0; i <= size; i++)
			{
				if(dentro(l,r,i*root) || dentro (i*root, i*root + root -1,l))
				{
					if((dentro(l,r,i*root) && dentro(l,r,i*root + root -1)))
					{
						sum += square[i];
					}
					else
					{
						for (int j = i*root; j < i*(root + 1); j++)
						{
							arr[j] += added[i];
							if(dentro(l,r,j))sum += arr[j];
						}
						added[i] = 0;
					}
				}
			}
			cout << sum << '\n';
		}
	}
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:58:9: error: reference to 'size' is ambiguous
   58 |         size = n/root;
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:40:5: note:                 'int size'
   40 | int size;
      |     ^~~~
a.cc:69:46: error: reference to 'size' is ambiguous
   69 |                         for (int i = 0; i <= size; i++)
      |                                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:40:5: note:                 'int size'
   40 | int size;
      |     ^~~~
a.cc:100:46: error: reference to 'size' is ambiguous
  100 |                         for (int i = 0; i <= size; i++)
      |                                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:40:5: note:                 'int size'
   40 | int size;
      |     ^~~~