criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

// greaterが通らないので定義
template<class _Ty>
	struct greater
		: public binary_function<_Ty, _Ty, bool>
	{	// functor for operator<
	bool operator()(const _Ty& _Left, const _Ty& _Right) const
		{	// apply operator< to operands
		return (_Left > _Right);
		}
	};

int a[100001];
long long b[100001];
long long s[100001];

int main()
{
	int N;
	cin >> N;

	priority_queue <int>  big_que;
	priority_queue <int, vector<int>, greater<int> > small_que; // 小さい順で取り出す


	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		b[0] += a;
		small_que.push(a);
	}
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= N; i++) {
		int a;
		cin >> a;
		s[N+1] += a;
		big_que.push(a);
	}

	for (int pos = 1; pos <= N; pos++) {
		small_que.push(a[pos]);
		int s = small_que.top();
		small_que.pop();
		b[pos] = b[pos-1] + a[pos] - s;
	}

	for (int pos = N; pos > 0; pos--) {
		big_que.push(a[pos]);
		int b = big_que.top();
		big_que.pop();
		s[pos] = s[pos+1] + a[pos] - b;
	}

	long long max_dif = b[0] - s[N];
	for (int pos = 0; pos <= N; pos++) { // どこで分割するか？
		max_dif = std::max(max_dif, b[pos]-s[pos+1]);
	}

	cout << max_dif << endl;
	return 0;
}


Compiler output:
a.cc:10:26: warning: 'template<class _Arg1, class _Arg2, class _Result> struct std::binary_function' is deprecated [-Wdeprecated-declarations]
   10 |                 : public binary_function<_Ty, _Ty, bool>
      |                          ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
                 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_function.h:131:12: note: declared here
  131 |     struct binary_function
      |            ^~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:56: error: template argument 3 is invalid
   28 |         priority_queue <int, vector<int>, greater<int> > small_que; // 小さい順で取り出す
      |                                                        ^
a.cc:35:27: error: request for member 'push' in 'small_que', which is of non-class type 'int'
   35 |                 small_que.push(a);
      |                           ^~~~
a.cc:48:27: error: request for member 'push' in 'small_que', which is of non-class type 'int'
   48 |                 small_que.push(a[pos]);
      |                           ^~~~
a.cc:49:35: error: request for member 'top' in 'small_que', which is of non-class type 'int'
   49 |                 int s = small_que.top();
      |                                   ^~~
a.cc:50:27: error: request for member 'pop' in 'small_que', which is of non-class type 'int'
   50 |                 small_que.pop();
      |                           ^~~
Language: C++

#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll num[300001],l[300001],r[300001],ans=LLONG_MIN;
priority_queue<int,vector<int>,greater<int>/**/> le;
priority_queue<ll> ri;
int n,i,j;
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
		l[n]+=num[i];
		le.push(num[i]);
	}
	for (i=n+1;i<=n*2;i++)
	{
		cin>>num[i];
	}
	for (i=n*2+1;i<=n*3;i++)
	{
		cin>>num[i];
		r[2*n+1]+=num[i];
		ri.push(num[i]);
	}
	for (i=n+1;i<=n*2;i++)
	{
		if (le.top()<num[i])
		{
			l[i]=l[i-1]+num[i]-le.top();
			le.push(num[i]);
			le.pop();
		}
		else
		{
			l[i]=l[i-1];
		}
	}
	for (i=2*n;i>n;i--)
	{
		if (ri.top()>num[i])
		{
			r[i]=r[i+1]+num[i]-ri.top();
			ri.push(num[i]);
			ri.pop();
		}
		else
		{
			r[i]=r[i+1];
		}
	}
	for (i=n;i<=2*n;i++)
	{
		if (ans<l[i]-r[i+1]) ans=l[i]-r[i+1];
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:23:40: error: 'LLONG_MIN' was not declared in this scope
   23 | ll num[300001],l[300001],r[300001],ans=LLONG_MIN;
      |                                        ^~~~~~~~~
a.cc:20:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   19 | #include<iomanip>
  +++ |+#include <climits>
   20 | #define sqr(x) (x)*(x)
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[M];
struct cmp1
{
    int x;
    cmp1(int x):x(x) {}
    bool operator < (const cmp1 &a) const
    {
        return x > a.x;
    }
};
struct cmp2
{
    int x;
    cmp2(int x):x(x) {}
    bool operator < (const cmp2 &a) const
    {
        return x < a.x;
    }
};
ll dpf[1000001] , dpe[1000001];
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i <= 3 * n ; i++)
    {
        cin>>a[i];
    }
    priority_queue<cmp1> st;
    memset(dpf , 0 , sizeof(dpf));
    memset(dpe , 0 , sizeof(dpe));
    for(int i = 1 ; i <= n ; i++)
    {
        st.push(cmp1(a[i]));
        dpf[n] += (ll)a[i];
    }
    for(int i = n + 1 ; i <= 2 * n ; i++)
    {
        int gg = st.top().x;
        if(gg < a[i])
        {
            st.pop();
            st.push(cmp1(a[i]));
            dpf[i] = dpf[i - 1] - (ll)gg + (ll)a[i];
        }
        else dpf[i] = dpf[i - 1];
    }
    priority_queue<cmp2> ed;
    for(int i = 2 * n + 1 ; i <= 3 * n ; i++)
    {
        ed.push(cmp2(a[i]));
        dpe[2 * n + 1] += (ll)a[i];
    }
    for(int i = 2 * n ; i >= n ; i--)
    {
        int gg = ed.top().x;
        if(gg > a[i])
        {
            ed.pop();
            ed.push(cmp2(a[i]));
            dpe[i] = dpe[i + 1] - (ll)gg + (ll)a[i];
        }
        else dpe[i] = dpe[i + 1];
    }
    ll ans =LONG_LONG_MIN;
    for(int i = n ; i <= 2 * n ; i++)
    {
        ans = max(ans , dpf[i] - dpe[i + 1]);
    }
    cout<<ans;
}


Compiler output:
a.cc:4:7: error: 'M' was not declared in this scope
    4 | int a[M];
      |       ^
a.cc: In function 'int main()':
a.cc:30:14: error: 'a' was not declared in this scope
   30 |         cin>>a[i];
      |              ^
a.cc:37:22: error: 'a' was not declared in this scope
   37 |         st.push(cmp1(a[i]));
      |                      ^
a.cc:43:17: error: 'a' was not declared in this scope
   43 |         if(gg < a[i])
      |                 ^
a.cc:54:22: error: 'a' was not declared in this scope
   54 |         ed.push(cmp2(a[i]));
      |                      ^
a.cc:60:17: error: 'a' was not declared in this scope
   60 |         if(gg > a[i])
      |                 ^
Language: C++

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#include<limits.h>
#include<set>
#define int long long
using namespace std;

int c[300000];
vector<int>X, Y;
signed main() {
	priority_queue<int, vector<int>, greater<int>>Q;
	int a; cin >> a;
if(N<=1000)return 0;
	for (int b = 0; b < 3 * a; b++) {
		scanf("%lld", &c[b]);
	}
	int sum = 0;
	for (int i = 0; i < 2 * a; i++) {
		Q.push(c[i]);
		sum += c[i];
		if (Q.size() == a + 1) {
			sum -= Q.top();
			Q.pop();
		}
		if (Q.size() == a) {
			X.push_back(sum);
		}
	}
	priority_queue<int>P;
	sum = 0;
	for (int i = 3 * a - 1; i >= a; i--) {
		P.push(c[i]);
		sum += c[i];
		if (P.size() == a + 1) {
			sum -= P.top(); P.pop();
		}
		if (P.size() == a) {
			Y.push_back(sum);
		}
	}
	reverse(Y.begin(), Y.end());
	int ans = LLONG_MIN;
	for (int i = 0; i <= a; i++) {
		ans = max(ans, X[i] - Y[i]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:4: error: 'N' was not declared in this scope
   23 | if(N<=1000)return 0;
      |    ^
Language: C++

#include <iostream>
#include <queue>
#include <type_traits>
#include <functional>
#include <algorithm>

using ll=long long int;

constexpr int MAX_N=(int)1e5;

constexpr ll INF=-(int)1e15;

template<bool B>
using Q = std::priority_queue<int,std::vector<int>,std::conditional_t<B,std::greater<>,std::less<>>>;

Q<true> firstHalf;
Q<false> secondHalf;

ll f[MAX_N*3],s[MAX_N*3];

int n;

int a[MAX_N*3];

int main() {

    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    std::cin>>n;

    for(int i=0;i<n*3;++i)
        std::cin>>a[i];

    ll res = 0;

    for(int i=0;i<n*3;++i){
        if(i<n){
            firstHalf.emplace(a[i]);
            res+=a[i];
        }
        else if(firstHalf.top()<a[i]){
            res+=a[i]-firstHalf.top();
            firstHalf.emplace(a[i]);
            firstHalf.pop();
        }
        f[i]=res;
    }

    res=0;

    for(int i=n*3-1;i>=0;--i){
        if(i>=n*2){
            secondHalf.emplace(a[i]);
            res+=a[i];
        }
        else if(secondHalf.top()>a[i]){
            res+=a[i]-secondHalf.top();
            secondHalf.emplace(a[i]);
            secondHalf.pop();
        }
        s[i]=res;
    }

    ll ans=INF;

    for(int i=n-1;i<n*2;++i){
        ans=std::max(ans,f[i]-s[i+1]);
    }

    std::cout<<ans<<std::endl;

    return 0;
}

Compiler output:
a.cc:11:18: error: overflow in constant expression [-fpermissive]
   11 | constexpr ll INF=-(int)1e15;
      |                  ^~~~~~~~~~
a.cc:11:24: error: overflow in constant expression [-fpermissive]
   11 | constexpr ll INF=-(int)1e15;
      |                        ^~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <cstring>

using namespace std;

int main()
{
	long long n = 0;
	cin >> n;
	long long* a = new long long [3*n];
	
	for(long long i = 0; i < 3*n; i++){
		
		cin >> a[i];
	}
	
	long long compare = 0;
	
	for(long long i = 0; i < 2*n){
		
		for(long long ii = i + 1; ii < 2*n; ii++){
			
			for(long long iii = ii + 1; iii < 2*n; iii++){
				
				for(long long j = iii + 1; j < 3*n; j++){
					
					for(long long jj = j + 1; jj < 3*n; jj++){
						
						for(long long jjj = jj + 1; jjj < 3*n; jjj++){
							
							if(i + ii + iii - j - jj - jjj > compare){
								
								compare = i + ii + iii - j - jj - jjj;
							}
						}
					}
				}
			}
		}
	}
	
	cout << compare;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:37: error: expected ';' before ')' token
   20 |         for(long long i = 0; i < 2*n){
      |                                     ^
      |                                     ;
Language: C++

#import<bits/stdc++.h>
using namespace std;

typedef priority_queue<int> P;
int i, N, a[300000];
long long d[100000], m;
P q;
main(){
    cin >> N;
    for(; i < N * 3; ++i){
        cin >> a[i];
        q.push(-a[i]);
        m += a[i];
        if(i ^ N - 1){
            *d = m;
        }
        if(N <= i && i < N * 2){
            m -= q.top();
            q.pop();
            d[i - N + 1] = m;
        }
    }
    q = P();
    m = 0;
    for(i=N*3; --i+1;){
        q.push(a[i]);
        m += a[i];
        if(i == N * 2){
            p[i - N] = m;
        }
        if((N <= i) && (i < N * 2)){
            m += q.top();
            q.pop();
            p[i - N] = m;
        }
    }
    cout << *max_element(d, d + N + 1) << endl;
}


Compiler output:
a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import<bits/stdc++.h>
      |  ^~~~~~
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:13: error: 'p' was not declared in this scope
   29 |             p[i - N] = m;
      |             ^
a.cc:34:13: error: 'p' was not declared in this scope
   34 |             p[i - N] = m;
      |             ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>

using namespace std;

int main() {
	cout << nn << endl;
	long long int n;
	cin >> n;
	vector<long long int> a(3 * n);
	vector<long long int> b, c;
	priority_queue<long long int, vector<long long int>, greater<long long int> > pqb;
	long long int bb = 0;
	for (long long int i = 0; i < 3 * n; i++) {
		cin >> a[i];
		if (i < n) {
			pqb.push(a[i]);
			bb += a[i];
		}
		else {
			c.push_back(a[i]);
		}
	}
	sort(c.begin(), c.end());
	long long int cc = 0;
	priority_queue<long long int, vector<long long int>, greater<long long int> > pqc;
	for (long long int i = 0; i < 2 * n; i++) {
		if (i < n) {
			cc += c[i];
		}
		else {
			pqc.push(c[i]);
		}
	}
	long long int ans = bb - cc;
	map<long long int, long long int> mp;
	for (long long int i = n; i < 2 * n; i++) {
		if (a[i] > pqb.top()) {
			bb -= pqb.top();
			pqb.pop();
			bb += a[i];
			pqb.push(a[i]);
		}
		if (a[i] <= pqc.top()) {
			cc -= a[i];
			cc += pqc.top();
			pqc.pop();
			while (!pqc.empty()) {
				if (mp[pqc.top()] > 0) {
					mp[pqc.top()]--;
					pqc.pop();
				}
				else {
					break;
				}
			}
		}
		else {
			mp[a[i]]++;
		}
		ans = max(ans, bb - cc);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'nn' was not declared in this scope
   11 |         cout << nn << endl;
      |                 ^~
Language: C++

#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int N;
llong nums[100100];
llong l[100100];
llong r[100100];

int main()
{
    while (cin >> N)
    {
        FO (i, N)
            cin >> nums[i];
        priority_queue<llong, greater<llong> > ql;
        llong lsum = 0, rsum = 0;
        FO (i, N)
            lsum += nums[i];
        l[0] = lsum;
        FO (i, N)
        {
            lsum += nums[N + i];
            ql.push(nums[N + i]);
            llong pp = ql.top();
            ql.pop();
            lsum -= pp;
            l[i + 1] = lsum;
        }
        priority_queue<llong> qr;
        FO (i, N)
            rsum += nums[3 * N - 1 - i];
        r[N] = rsum;
        FO (i, N)
        {
            rsum += nums[2 * N - 1 - i];
            qr.push(nums[2 * N - 1 - i]);
            llong pp = qr.top();
            rsum -= pp;
            r[N - 1 - i] = rsum;
        }
        llong res = INT_MIN;
        FO (i, N + 1)
            res = max(res, lsum[i] - rsum[i]);
        cout << res << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:46: error: no type named 'value_type' in 'struct std::greater<long long int>'
   39 |         priority_queue<llong, greater<llong> > ql;
      |                                              ^
a.cc:39:46: error: template argument 3 is invalid
a.cc:47:16: error: request for member 'push' in 'ql', which is of non-class type 'int'
   47 |             ql.push(nums[N + i]);
      |                ^~~~
a.cc:48:27: error: request for member 'top' in 'ql', which is of non-class type 'int'
   48 |             llong pp = ql.top();
      |                           ^~~
a.cc:49:16: error: request for member 'pop' in 'ql', which is of non-class type 'int'
   49 |             ql.pop();
      |                ^~~
a.cc:67:32: error: invalid types 'llong {aka long long int}[int]' for array subscript
   67 |             res = max(res, lsum[i] - rsum[i]);
      |                                ^
a.cc:67:42: error: invalid types 'llong {aka long long int}[int]' for array subscript
   67 |             res = max(res, lsum[i] - rsum[i]);
      |                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;

int main(void){
	int N,res=0;
	cin>>N;
	vector<int> a(3*N);
	rep(i,3*N)cin>>a[i];
	for(int M=N;M<2*N;M++){
		priority_queue<int,vector<int>,greater<int>> lq;
		priority_queue<int> rq;
		rep(i,N){
			if(i<M)lq.push(a[i]);
			else rq.push(a[i]);
		}
		while(lq.size()>N)lq.pop();
		while(rq.size()>N)rq.pop();
		ll suml=0,sumr=0;
		rep(i,N)suml+=lq.top(),lq.pop();
		rep(i,N)sumr+=rq.top(),rq.pop();
		res=max(res,suml-sumr);
	}
	cout<<res<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: no matching function for call to 'max(int&, ll)'
   23 |                 res=max(res,suml-sumr);
      |                     ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:23:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   23 |                 res=max(res,suml-sumr);
      |                     ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:23:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   23 |                 res=max(res,suml-sumr);
      |                     ~~~^~~~~~~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<lli, lli> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

struct SEGTREE{
	vector<lli> v; int size;
	SEGTREE(vector<lli> a){
		size = 1;
		while(1<<size < a.size()) size++;
		v.assign(1<<(size+1), LINF);
		rep(i, a.size()) v[(1<<size)+i] = a[i];
		init(1);
	}
	lli init(int i){
		if(i >= (1<<size)) return v[i];
		else{
			lli p1 = init(i*2);
			lli p2 = init(i*2+1);
			return v[i] = min(p1, p2);
		}
	}
	lli update(int r){
		int rr = r + (1<<size);
		lli mi = v[rr];
		while(true){
			if(rr%2 == 1) rr /= 2;
			else rr = rr/2 - 1;
			mi = min(mi, v[rr]);
			if((rr&(rr-1)) == 0) break;
		}
		int pl = 1;
		while(true){
			if(mi == v[pl*2]) pl = pl*2;
			else pl = pl*2 + 1;
			if(pl >= (1<<size)) break;
		}
		v[pl] = LINF;
		while(pl != 1){
			pl/=2;
			v[pl] = min(v[pl*2], v[pl*2+1]);
		}
		
		return mi;
	}
};

int main(void){
	int n; cin >> n;
	vector<lli> t1(n*3), t2(n*3);
	rep(i, n*3){
		cin >> t1[i];
		t2[n*3-1-i] = -t1[i];
	}
	
	SEGTREE st1(t1); SEGTREE st2(t2);

	vector<lli> s1(n+1), s2(n+1);
	
	s1[0] = accumulate(t1.begin(), t1.begin() + n, 0ll);
	rep(i, n) s1[i+1] = s1[i] - st1.update(n+i) + t1[n+i];
	
	s2[0] = accumulate(t2.begin(), t2.begin() + n, 0ll);
	rep(i, n) s2[i+1] = s2[i] - st2.update(n+i) + t2[n+i];
	
	reverse(s2.begin(), s2.end());
		
	lli ans = -LINF;
	rep(i, n+1) ans = max(ans, s1[i] + s2[i]);
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:17: error: 'accumulate' was not declared in this scope
   81 |         s1[0] = accumulate(t1.begin(), t1.begin() + n, 0ll);
      |                 ^~~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

vector<ll> ab;
int n;

int main()
{
	cin >> n;
	for (int i = 0;i < 3 * n;i++) {
		ll tmp;
		cin >> tmp;
		ab.push_back(tmp);
	}

	ll ans = -LONG_MAX;
	
	for (int i = 0;i <= n;i++) {
		vector<ll> a = ab;
		//for (int k = 0;k < 3 * n;k++) a[k] = ab[k];
		sort(a.begin(), a.begin() + n + i);
		sort(a.begin()+ n + i, a.end());

		ll l = 0;
		ll r = 0;

		for (int j = i;j < n + i;j++) l += a[j];
		for (int j = n + i;j < 2 * n + i;j++) r += a[j];

		//cout << i << ":" << l << "-" << r << endl;

		ans = max(ans, l - r);
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:19: error: 'LONG_MAX' was not declared in this scope
   36 |         ll ans = -LONG_MAX;
      |                   ^~~~~~~~
a.cc:16:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include <functional>
  +++ |+#include <climits>
   16 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
pair<long long ,long long > arr[4001];
int main(){
    int n; cin>>n;
    int t=3*n;
    for(int i=1;i<=t;i++){
        cin>>arr[i].first;
        arr[i].second=i;
    }
    sort(arr+1,arr+t+1);
    long long ans=-2e18;
    for(int L=n;L<=2*n;L++){
        long long mx=0;
        long long mn=0;
        long long mxcnt=0;
        long long mncnt=0;
        for(int j=t;j>=1;j--){
            if(arr[j].second >= 1 && arr[j].second <= L && mxcnt!=n){
                mxcnt++; mx+=arr[j].first;
            }
           
        }
        for(int j=1;j<=t;j++){
            if(arr[j].second >= L+1 && arr[j].second<=t && mncnt!=n){
                mncnt++; mn+=arr[j].first;
            }
            
        }
        
         ans=max(ans,mx-mn);
    }
    cout<<ans;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(arr+1,arr+t+1);
      |     ^~~~
      |     short
Language: C++

a#include<bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long
#define ld double

using namespace std ;

const int MAXN = 101 * 1001 ; 

int a[MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; 
	cin >> n ; 
	n *= 3 ; 
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] ; 
	int ans = -1e18 ; 
	multiset<int> s1 , s2 , s3 ; 
	int m = n / 3 ; 
	int sum1 = 0 , sum2 = 0 ; 
	for(int i = 0 ; i < n ; i ++ ) s2.insert(a[i]) , sum2 += a[i] ; 
	while(s2.size()>m)
	{
		sum2 -= *s2.rbegin() ;
		s3.insert(*s2.rbegin()) ; 
		s2.erase(s2.find(*s2.rbegin())) ; 
	}
	for(int i = 0 ; i < 2 * m ; i ++ ) 
	{
		s1.insert(a[i]) ; 
		sum1 += a[i] ; 
	//	cout <<'*'<< sum1 << ' ' << i << endl ; 
		if(s3.find(a[i])!=s3.end()) s3.erase(s3.find(a[i])) ; 
		else s2.erase(s2.find(a[i])) , sum2 -= a[i] ; 	
		while(s1.size()>m)
		{
			sum1 -= *s1.begin() ; 
			s1.erase(s1.find(*s1.begin())) ; 
		}
	//	cout << sum1<< endl ; 
		while(s2.size()<m)
		{
			sum2 += *s3.begin() ; 
			s2.insert(*s3.begin()) ; 
			s3.erase(s3.find(*s3.begin())) ; 
		}
		if(s1.size()>=m)
		{
	//		cout << sum2 << ' ' << sum1 << endl ; 
			ans = max(ans,sum1-sum2) ; 
		}
	}
	cout << ans << endl ; 
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | a#include<bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'a' does not name a type
    1 | a#include<bits/stdc++.h>
      | ^
a.cc:16:1: error: 'int32_t' does not name a type
   16 | int32_t main()
      | ^~~~~~~
a.cc:1:1: note: 'int32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | a#include<bits/stdc++.h>
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7; //insane bug

ll dp[303][8];

struct ev {
	ll l, r, k;
};

vector<vector<ev>> scan;
vector<vector<ll>> er;

vector<ll> c = { 0, 1, 1, 2, 1, 2, 2, 3 };

int main()
{
	fastInp;

	ll n, m;
	cin >> n >> m;

	scan.resize(n);
	er.resize(n);
	for (int i = 0; i < m; i++) {
		ll l, r, k;
		cin >> l >> r >> k;
		l--; r--;
		scan[l].push_back({ l, r, k });
		er[r].push_back(k);
	}

	dp[0][0] = 1;

	ll pr = 3;
	multiset<ll> s;
	//s.insert(3);

	for (int i = 0; i < n; i++) {
		for (auto cur : scan[i]) {
			s.insert(cur.k);
		}
		ll cur = *(s.begin());
		if (cur >= pr) {
			for (int j = 0; j < 8; j++) {
				for (int t = 0; t <= 2; t++) {
					ll bt = (1ll << t);
					dp[i + 1][bt] += dp[i][j];
				}
			}
		}
		else if (cur < pr) {
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					for (int t = 0; t <= 2; t++) {
						ll bt = (1ll << t);
						if ((j | k) == j && (k | bt) == k) {
							dp[i + 1][(j | bt)] += dp[i][j];
						}
					}
				}
			}
		}

		for (int j = 0; j < 8; j++) {
			if (c[j] > cur) {
				dp[i + 1][j] = 0;
			}
		}

		for (int j = 0; j < 8; j++) dp[i][j] %= MOD;
		pr = *(s.begin());
		for (auto cur : er[i]) {
			for (int j = 0; j < 8; j++) {
				if (cnt[j] != cur) dp[i + 1][j] = 0;
			}
			s.erase(s.find(cur));
		}
	}

	ll sm = 0;
	for (int i = 0; i < 8; i++) sm += dp[n][i];

	cout << sm;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:91:37: error: 'cnt' was not declared in this scope; did you mean 'int'?
   91 |                                 if (cnt[j] != cur) dp[i + 1][j] = 0;
      |                                     ^~~
      |                                     int
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> PP;

const ll MOD = 1000000007;

ll dp[2][304][304];

int main()
{
    int n, m;
    cin >> n >> m;
    PP p[304];
    for(int i = 0; i < m; i++){
        int l, r, x;
        cin >> l >> r >> x;
        p[i] = PP(P(r, l), x);
    }
    sort(p, p + m);
    int l = 0;
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < i; j++){
            for(int k = 0; k < j; k++){
                dp[i % 2][j][k] = dp[(i + 1) % 2][j][k];
            }
        }
        for(int j_ = 0; j_ < i; j_++){
            for(int k = 0; k < j_; k++){
                dp[i % 2][i - 1][k] = (dp[i % 2][i - 1][k] + dp[(i + 1) % 2][j_][k]) % MOD;
            }
        }
        for(int k = 0; k < i; k++){
            for(int k_ = 0; k_ < k; k_++){
                dp[i % 2][i - 1][k] = (dp[i % 2][i - 1][k] + dp[(i + 1) % 2][k][k_]) % MOD;
            }
        }
        if(i != 1){
            dp[i % 2][i - 1][0] = (dp[i % 2][i - 1][0] + dp[(i + 1) % 2][0][0] * 2) % MOD;
            dp[i % 2][0][0] = dp[(i + 1) % 2][0][0];
        }
        else dp[i][0][0] = 3;
        while(p[l].first.first == i){
            if(p[l].second == 1){
                for(int j = 0; j <= i; j++){
                    for(int k = 0; k <= j; k++){
                        if(j >= p[l].first.second) dp[i % 2][j][k] = 0;
                    }
                }
            }
            else if(p[l].second == 2){
                for(int j = 0; j <= i; j++){
                    for(int k = 0; k <= j; k++){
                        if(j < p[l].first.second || k >= p[l].first.second) dp[i % 2][j][k] = 0;
                    }
                }
            }
            else{
                for(int j = 0; j <= i; j++){
                    for(int k = 0; k <= j; k++){
                        if(k < p[l].first.second){
                            dp[i % 2][j][k] = 0;
                        }
                    }
                }
            }
            l++;
        }
    }
    ll ans = 0;
    for(int j = 0; j < n; j++){
        for(int k = 0; k < j; k++) ans = (ans + dp[n % 2][j][k]) % MOD;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |     sort(p, p + m);
      |     ^~~~
      |     short
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y,w;
}a[1010];
const int p=1e9+7;
vector<int>zh[1010];
int n,m,i,j,x,sz,k,l,ans,f[302][302][302];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
		zh[a[i].y].push_back(i);
	}
	f[1][0][0]=3;
	for(i=1;i<=n;i++){
	 for(j=1;j<i;j++)
	  for(k=0;k<j;k++){
	  	for(l=0;l<zh[i].size();l++){
	  		x=zh[i][l];
	  		sz=1;
	  		if(a[x].x<=j)sz++;
	  		if(a[x].x<=k)sz++;
	  		if(sz!=a[x].w)f[i][j][k]=0;
	  	}
	  	if(!f[i][j][k])continue;
	  	(f[i+1][j][k]+=f[i][j][k])%=p;
	  	(f[i+1][i][k]+=f[i][j][k])%=p;
	  	(f[i+1][i][j]+=f[i][j][k])%=p;
	  }
	  for(l=0;l<zh[i].size();l++){
	  	x=zh[i][l];
	  	if(a[x].w!=1)f[i][0][0]=0;
	  }
	(f[i+1][0][0]+=f[i][0][0])%=p;
	 (f[i+1][i][0]+=f[i][0][0]*2%p)%=p;
  }
  for(j=0;j<n;j++)
   for(k=0;k<=j;k++)ans=(ans+f[n][j][k])%=p;
  printf("%d",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:29: error: lvalue required as left operand of assignment
   40 |    for(k=0;k<=j;k++)ans=(ans+f[n][j][k])%=p;
      |                         ~~~~^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb emplace_back
#define f first
#define s second
#define MOD 1e9+7
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 310
ll MOD = 1e9+7;

int N,M,a,b,c;
vpi V[MAXN];
int dp[MAXN][MAXN][MAXN];

int ask(int n, int a, int b){
	if (dp[n][a][b] != -1)return dp[n][a][b];
	if (n == N){
		// cout<<"1 way "<<n<<' '<<a<<' '<<b<<'\n';
		// Exactly 1 way
		return dp[n][a][b] = 1;
	}
	if(a!=b)return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a) + ask(n+1,n,b))%MOD;
	else return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a))%MOD;
}

int main(){
	cin>>N>>M;
	int samework = 1;
	for (int i=0;i<M;++i){
		cin>>a>>b>>c;
		if (c>1)samework = 0;
		V[b].pb(a,c);
	}
	memset(dp,-1,sizeof(dp));
	for (int b=0;b<=N;++b){
		for (int a=b;a<=N;++a){
			for (int i=a+1;i<=N;++i){
				for (auto v:V[i]){
					int has_b = (b >= v.f);
					int has_a = (a>=v.f);
					int t = has_a+has_b+1;
					if (t != v.s){dp[i][a][b] = 0;break;}
				}
			}
		}
	}
	int ans = ask(1,0,0)*6%MOD;
	if (samework)ans = (ans-3+MOD)%MOD;
	cout<<ans;
	// for (int i=0;i<=N;++i){
	// 	for (int j=0;j<=N;++j){
	// 		for (int k=0;k<=N;++k)cout<<dp[i][j][k]<<' ';cout<<'\n';
	// 	}
	// 	cout<<'\n';
	// }
}

Compiler output:
a.cc:12:13: error: expected unqualified-id before numeric constant
   12 | #define MOD 1e9+7
      |             ^~~
a.cc:20:4: note: in expansion of macro 'MOD'
   20 | ll MOD = 1e9+7;
      |    ^~~
a.cc: In function 'int ask(int, int, int)':
a.cc:33:82: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   33 |         if(a!=b)return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a) + ask(n+1,n,b))%MOD;
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      |                                                                   |
      |                                                                   int
a.cc:34:64: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   34 |         else return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a))%MOD;
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      |                                                 |
      |                                                 int
a.cc: In function 'int main()':
a.cc:58:31: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   58 |         int ans = ask(1,0,0)*6%MOD;
      |                   ~~~~~~~~~~~~^
      |                             |
      |                             int
a.cc:59:39: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   59 |         if (samework)ans = (ans-3+MOD)%MOD;
      |                            ~~~~~~~~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb emplace_back
#define f first
#define s second
#define MOD 1e9+7
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 310

int N,M,a,b,c;
vpi V[MAXN];
int dp[MAXN][MAXN][MAXN];

int ask(int n, int a, int b){
	if (dp[n][a][b] != -1)return dp[n][a][b];
	if (n == N){
		// cout<<"1 way "<<n<<' '<<a<<' '<<b<<'\n';
		// Exactly 1 way
		return dp[n][a][b] = 1;
	}
	if(a!=b)return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a) + ask(n+1,n,b))%MOD;
	else return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a))%MOD;
}

int main(){
	cin>>N>>M;
	int samework = 1;
	for (int i=0;i<M;++i){
		cin>>a>>b>>c;
		if (c>1)samework = 0;
		V[b].pb(a,c);
	}
	memset(dp,-1,sizeof(dp));
	for (int b=0;b<=N;++b){
		for (int a=b;a<=N;++a){
			for (int i=a+1;i<=N;++i){
				for (auto v:V[i]){
					int has_b = (b >= v.f);
					int has_a = (a>=v.f);
					int t = has_a+has_b+1;
					if (t != v.s){dp[i][a][b] = 0;break;}
				}
			}
		}
	}
	int ans = ask(1,0,0)*6%MOD;
	if (samework)ans = (ans-3+MOD)%MOD;
	cout<<ans;
	// for (int i=0;i<=N;++i){
	// 	for (int j=0;j<=N;++j){
	// 		for (int k=0;k<=N;++k)cout<<dp[i][j][k]<<' ';cout<<'\n';
	// 	}
	// 	cout<<'\n';
	// }
}

Compiler output:
a.cc: In function 'int ask(int, int, int)':
a.cc:32:82: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   32 |         if(a!=b)return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a) + ask(n+1,n,b))%MOD;
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      |                                                                   |
      |                                                                   int
a.cc:33:64: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   33 |         else return dp[n][a][b] = (ask(n+1,a,b) + ask(n+1,n,a))%MOD;
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      |                                                 |
      |                                                 int
a.cc: In function 'int main()':
a.cc:57:31: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   57 |         int ans = ask(1,0,0)*6%MOD;
      |                   ~~~~~~~~~~~~^
      |                             |
      |                             int
a.cc:58:39: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   58 |         if (samework)ans = (ans-3+MOD)%MOD;
      |                            ~~~~~~~~~~~^
Language: C++

				dp[r][ma+1][b] += dp[r][g][b];
				dp[r][g][ma+1] += dp[r][g][b];
				dp[ma+1][g][b] %= mod;
				dp[r][ma+1][b] %= mod;
				dp[r][g][ma+1] %= mod;
			}
		}
	}


	ll ans = 0;
	for (int r = 0; r <= N; r++) {
		for (int g = 0; g <= N; g++) {
			for (int b = 0; b <= N; b++) {
				if (max(max(r, g), b) == N) {
					ans += dp[r][g][b];
				}
				ans %= mod;
			}
		}
	}
	puts(ans);

	return 0;
}

Compiler output:
a.cc:1:33: error: 'dp' does not name a type
    1 |                                 dp[r][ma+1][b] += dp[r][g][b];
      |                                 ^~
a.cc:2:33: error: 'dp' does not name a type
    2 |                                 dp[r][g][ma+1] += dp[r][g][b];
      |                                 ^~
a.cc:3:33: error: 'dp' does not name a type
    3 |                                 dp[ma+1][g][b] %= mod;
      |                                 ^~
a.cc:4:33: error: 'dp' does not name a type
    4 |                                 dp[r][ma+1][b] %= mod;
      |                                 ^~
a.cc:5:33: error: 'dp' does not name a type
    5 |                                 dp[r][g][ma+1] %= mod;
      |                                 ^~
a.cc:6:25: error: expected declaration before '}' token
    6 |                         }
      |                         ^
a.cc:7:17: error: expected declaration before '}' token
    7 |                 }
      |                 ^
a.cc:8:9: error: expected declaration before '}' token
    8 |         }
      |         ^
a.cc:11:9: error: 'll' does not name a type
   11 |         ll ans = 0;
      |         ^~
a.cc:12:9: error: expected unqualified-id before 'for'
   12 |         for (int r = 0; r <= N; r++) {
      |         ^~~
a.cc:12:25: error: 'r' does not name a type
   12 |         for (int r = 0; r <= N; r++) {
      |                         ^
a.cc:12:33: error: 'r' does not name a type
   12 |         for (int r = 0; r <= N; r++) {
      |                                 ^
a.cc:22:13: error: expected constructor, destructor, or type conversion before '(' token
   22 |         puts(ans);
      |             ^
a.cc:24:9: error: expected unqualified-id before 'return'
   24 |         return 0;
      |         ^~~~~~
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long intl;
struct query{
    int ini,fin,X;
    void Leer()
    {
        scanf("%d %d %d",&ini,&fin,&X);
    }
};
bool Cumple(query q, int r, int g, int b)
{
    int x = 0;
    if(q.ini<=r && r<=q.fin)
        x++;
    if(q.ini<=b && b<=q.fin)
        x++;
    if(q.ini<=g && g<=q.fin)
        x++;
    return x == q.X;
}
intl MOD = 1e9 + 7;
intl DP[320][320][320]; /// r g b
vector<query> Q[320];
int main()
{
    memset(DP,0,sizeof(DP));
    int N,M;
    cin>>N>>M;
    for(int i = 0;i<M;i++)
    {
        query q;
        q.Leer();
        Q[q.fin].push_back(q);
    }
    DP[1][0][0] = 1;
    DP[0][1][0] = 1;
    DP[0][0][1] = 1;

    intl R = 0;
    for(int i = 1;i<=N;i++)
    {
        for(int g = 0;g<i;g++)
            for(int b = 0;b<i;b++)
            {
                if(b!=g || b == 0 || g == 0)
                {
                    for(auto q : Q[i])
                        if(!Cumple(q,i,g,b))
                            DP[i][g][b] = 0;
 //                   cout<<i<<" - "<<g<<" - "<<g<<" : "<<DP[i][g][b]<<endl;
                    DP[i+1][g][b] = (DP[i+1][g][b] + DP[i][g][b])%MOD;
                    DP[i][i+1][b] = (DP[i][i+1][b] + DP[i][g][b])%MOD;
                    DP[i][g][i+1] = (DP[i][g][i+1] + DP[i][g][b])%MOD;
                    if(i == N)
                        R = (R+DP[i][g][b])%MOD;
                }
            }

        for(int r = 0;r<i;r++)
            for(int b = 0;b<i;b++)
            {
                if(b!=r || r == 0 || b == 0)
                {
                    for(auto q : Q[i])
                        if(!Cumple(q,r,i,b))
                            DP[r][i][b] = 0;
                    DP[i+1][i][b] = (DP[i+1][i][b] + DP[r][i][b])%MOD;
                    DP[r][i+1][b] = (DP[r][i+1][b] + DP[r][i][b])%MOD;
                    DP[r][i][i+1] = (DP[r][i][i+1] + DP[r][i][b])%MOD;
                    if(i == N)
                        R = (R+DP[r][i][b])%MOD;

                }
            }

        for(int r = 0;r<i;r++)
            for(int g = 0;g<i;g++)
            {
                if(g!=r || r == 0 || g == 0)
                {
                    for(auto q : Q[i])
                        if(!Cumple(q,r,g,i))
                            DP[r][g][i] = 0;
                    DP[i+1][g][i] = (DP[i+1][g][i] + DP[r][g][i])%MOD;
                    DP[r][i+1][i] = (DP[r][i+1][i] + DP[r][g][i])%MOD;
                    DP[r][g][i+1] = (DP[r][g][i+1] + DP[r][g][i])%MOD;
                    if(i == N)
                        R = (R+DP[r][g][i])%MOD;

                }
            }
    }
    cout<<R<<endl;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<cstring>
#include<algorithm>
#include<vector>
#define mod 1000000007
using namespace std;
int dp[310][310][310];
bool visited[310][310][310];
int n, m;
int ma(int x, int y, int z) {
	return max(max(x, y), z);
}
int func(int x, int y, int z) {
	int &ret = dp[x][y][z];
	if (ret != -1)return ret;
	if (ma(x, y, z) == n)return 1;
	ret = 0;
	int ch = ma(x, y, z);
	ret += func(ch+1, y, z);
	ret %= mod;
	ret += func(x, ch+1, z);
	ret %= mod;
	ret += func(x, y, ch+1);
	ret %= mod;
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%d %d", &n, &m);
	while(m--){
		int q, w, e;
		scanf("%d %d %d", &q, &w, &e);
		if (e == 1) {
			for (int i = 0; i <= w; i++) {
				for (int y = 0; y <= w; y++) {
					if (i < q&&y < q)continue;
					dp[w][i][y] = 0;
					dp[i][w][y] = 0;
					dp[i][y][w] = 0;
				}
			}
		}
		else if (e==2)
		{
			for(int i = 0; i <= w; i++) {
				for (int y = 0; y <= w; y++) {
					if ((i >= q && y < q) || (i < q&&y >= q))continue;
					dp[w][i][y] = 0;
					dp[y][w][i] = 0;
					dp[y][i][w] = 0;
				}
			}
		}
		else {
			for (int i = 0; i <=w; i++) {
				for (int y = 0; y <= w; y++) {
					if (i >= q && y >= q)continue;
					dp[w][i][y] = 0;
					dp[i][w][y] = 0;
					dp[i][y][w] = 0;
				}
			}
		}
	}
	printf("%d\n", func(0, 0, 0));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'scanf' was not declared in this scope
   29 |         scanf("%d %d", &n, &m);
      |         ^~~~~
a.cc:65:9: error: 'printf' was not declared in this scope
   65 |         printf("%d\n", func(0, 0, 0));
      |         ^~~~~~
a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    3 | #include<vector>
  +++ |+#include <cstdio>
    4 | #define mod 1000000007
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007)
#define l_ength size

void mul_mod(int& a, int b){
	a *= b;
	a %= MOD;
}

void add_mod(int& a, int b){
	b += MOD;
	a += b;
	a %= MOD;
}

struct edge{
	int l, x;
};

vector<edge> g[334];
int dp[334][334][334];

int main(void){
	int n,m,i,j,k,t,l,r,x;
	ll ans=0;
	edge e;
	cin >> n >> m;
	for(t=0; t<m; ++t){
		cin >> l >> r >> x;
		e.l = l; e.x = x;
		g[r].push_back(e);
	}
	dp[0][0][0] = 1;
	for(i=0; i<=n; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<=n; ++k){
				r = max(i,max(j,k));
				l = min(i,min(j,k));
				m = (i+j+k)-(l+r);
				if(l && (l == m || m == r)){
					continue;
				}
				for(t=(g[r].l_ength()-1); t>=0; --t){
					e = g[r][t];
					switch(e.x){
						case 3:
							if(!(e.l<=l)){
								dp[i][j][k] = 0;
							}
							break;
						case 2:
							if(!(l<e.l && e.l<=m)){
								dp[i][j][k] = 0;
							}
							break;
						case 1:
							if(!(m<e.l)){
								dp[i][j][k] = 0;
							}
							break;
					}
				}
				if(r==n){
					add_mod(ans,dp[i][j][k]);
					continue;
				}
				add_mod(dp[r+1][j][k],dp[i][j][k]);
				add_mod(dp[i][r+1][k],dp[i][j][k]);
				add_mod(dp[i][j][r+1],dp[i][j][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:49: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   70 |                                         add_mod(ans,dp[i][j][k]);
      |                                                 ^~~
a.cc:16:19: note:   initializing argument 1 of 'void add_mod(int&, int)'
   16 | void add_mod(int& a, int b){
      |              ~~~~~^
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

struct edge{
	int l, x;
};

vector<edge> g[334];
int dp[334][334][334];

int main(void){
	int n,m,i,j,k,t,l,r,x;
	ll ans=0ll;
	edge e;
	cin >> n >> m;
	for(t=0; t<m; ++t){
		cin >> l >> r >> x;
		e.l = l; e.x = x;
		g[r].push_back(e);
	}
	dp[0][0][0] = 1;
	for(i=0; i<=n; ++i){
		for(j=0; j<=n; ++j){
			for(k=0; k<=n; ++k){
				r = max(i,max(j,k));
				l = min(i,min(j,k));
				m = (i+j+k)-(l+r);
				if(l && (l == m || m == r)){
					continue;
				}
				for(t=(g[r].l_ength()-1); t>=0; --t){
					e = g[r][t];
					switch(e.x){
						case 3:
							if(!(e.l<=l)){
								dp[i][j][k] = 0ll;
							}
							break;
						case 2:
							if(!(l<e.l && e.l<=m)){
								dp[i][j][k] = 0ll;
							}
							break;
						case 1:
							if(!(m<e.l)){
								dp[i][j][k] = 0ll;
							}
							break;
					}
				}
				if(r==n){
					add_mod(ans,dp[i][j][k]);
					continue;
				}
				add_mod(dp[r+1][j][k],dp[i][j][k]);
				add_mod(dp[i][r+1][k],dp[i][j][k]);
				add_mod(dp[i][j][r+1],dp[i][j][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:53: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int'
   73 |                                 add_mod(dp[r+1][j][k],dp[i][j][k]);
      |                                         ~~~~~~~~~~~~^
a.cc:16:18: note:   initializing argument 1 of 'void add_mod(ll&, ll)'
   16 | void add_mod(ll& a, ll b){
      |              ~~~~^
a.cc:74:53: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int'
   74 |                                 add_mod(dp[i][r+1][k],dp[i][j][k]);
      |                                         ~~~~~~~~~~~~^
a.cc:16:18: note:   initializing argument 1 of 'void add_mod(ll&, ll)'
   16 | void add_mod(ll& a, ll b){
      |              ~~~~^
a.cc:75:53: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int'
   75 |                                 add_mod(dp[i][j][r+1],dp[i][j][k]);
      |                                         ~~~~~~~~~~~~^
a.cc:16:18: note:   initializing argument 1 of 'void add_mod(ll&, ll)'
   16 | void add_mod(ll& a, ll b){
      |              ~~~~^