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

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

int main() {
  int N;
  int M;
  int Q;
  cin >> N >> M >>Q;
  int a[Q];
  int b[Q];
  int c[Q];
  int d[Q];
  int aa;
  int bb;
  for(int i=0; i<Q;i++){
   cin >> a[i] >> b[i] >> c[i] >> d[i]; 
  }
  int dp[N];
  dp[0]=1;
  int couho=0;
  int kouho=0;
  for(int i=1;i<N;i++){
    couho=0;
    kouho=0;
   aa= dp[i-1]; 
    for(int j=aa;j<M;j++){
     for(int k=0;k<Q;k++){
      if(b[k]==i){
        bb=a[k];
        if(j-dp[bb]==c[k]){
          kouho=kouho+d[k];
        }
      }
     }//intk
      if(kouho > couho){
        couho=kouho;
      }
      
     }//intj
      dp[i]=couho;
    }//inti
  int ans=0;
  int xx;
  int yy;
  for(int z=0;z<Q;z++){
    xx=a[z];
    yy=b[z];
    if(dp[yy]-dp[xx]==c[z]){
      ans=ans+d[z]
    }
    
   
    
  }//for
    cout<< ans<<endl;
    
   
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:19: error: expected ';' before '}' token
   50 |       ans=ans+d[z]
      |                   ^
      |                   ;
   51 |     }
      |     ~
Language: C++

#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
    int n, m, q, i, j, k;
	vector<int> a, b, c, d;
	int tmpa, tmpb, tmpc, tmpd;
	vector<int> perm;
	ll point = 0;
	ll answer = 0;
	cin >> n >> m >> q;

	for (i = 0; i < q; i++) {
		cin >> tmpa >> tmpb >> tmpc >> tmpd;
		a.push_back(tmpa);
		b.push_back(tmpb);
		c.push_back(tmpc);
		d.push_back(tmpd);
	}

	for (i = 1; i < pow(2, q); i++) {
		bool can = false;
		int tmp = i;
		vector<int> target;
		for (j = 0; j < q; j++) {
			if ((tmp >> j) & 1)
				target.push(j);
		}
		for (j = 0; j < target.size() - 1; j++) {
			can = true;
			for (k = j + 1; k < target.size(); k++) {
				if ((b[j] - a[j] >= b[k] - a[k]) &&
					c[j] < c[k]) {
					can = false;
					break;
				}
			}
		 	if (!can)
	   			break;
		}
					

		if (can) {
			point = 0;
			for (j = 0; j < target.size(); j++)
				point += target[j];
			if (point > answer)
				answer = point;
		}
	}
	cout << answer << endl;
					

	
	
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:38:40: error: 'class std::vector<int>' has no member named 'push'
   38 |                                 target.push(j);
      |                                        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
set<vector<int>>f(int N,int M){
if(N==1){
set<vector<int>>s;
  for(int i=1;i<=M;i++){
     vector<int>A={i};
    s.insert(A);}
  return s;
}else{
set<vector<int>>S=f(N-1,M);
  set<vector<int>>s;
  for(auto x:S){
    for(int i=a;i<=M;i++){
     s.insert(x.push_back(i));
    }
  
  } return s;

}

}
int main(){
int N,M,Q;
  cin>>N>>M>>Q;
  vector<int>a(Q);
  vector<int>b(Q);
  vector<int>c(Q);
  vector<int>d(Q);
  for(int i=0;i<Q;i++){
  cin>>a.at(i); a.at(i)--;
    cin>>b.at(i);b.at(i)--;
    cin>>c.at(i);
    cin>>d.at(i);
  }
  int ans1=0;
  set<int>S=f(N,M);
  for(auto p:S){
    for(int i=0;i<Q;i++){
    if(p.at(b.at(i))-p.at(a.at(i))==c.at(i))
      ans+=d.at(i);
    } if(ans1<ans)
      ans1=ans;
  
  
  }cout<<ans1<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'std::set<std::vector<int> > f(int, int)':
a.cc:14:15: error: 'a' was not declared in this scope
   14 |     for(int i=a;i<=M;i++){
      |               ^
a.cc:15:26: error: invalid use of void expression
   15 |      s.insert(x.push_back(i));
      |               ~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:37:14: error: conversion from 'set<std::vector<int>>' to non-scalar type 'set<int>' requested
   37 |   set<int>S=f(N,M);
      |             ~^~~~~
a.cc:40:10: error: request for member 'at' in 'p', which is of non-class type 'int'
   40 |     if(p.at(b.at(i))-p.at(a.at(i))==c.at(i))
      |          ^~
a.cc:40:24: error: request for member 'at' in 'p', which is of non-class type 'int'
   40 |     if(p.at(b.at(i))-p.at(a.at(i))==c.at(i))
      |                        ^~
a.cc:41:7: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   41 |       ans+=d.at(i);
      |       ^~~
      |       ans1
a.cc:42:15: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   42 |     } if(ans1<ans)
      |               ^~~
      |               ans1
Language: C++

#include<algorithm>
#include<iostream>
using namespace std;
int n,m,o,ans,dp[55],a[55],b[55],c[55],d[55];
int shu() 
{
    int sum=0;
    for(int i=1;i<=o;i++) 
	{
        if(dp[b[i]]-dp[a[i]]==c[i]) 
		{
            sum+=d[i];
        }
    }
    return sum;
}
void dfs(int temp) 
{
    if(temp>n) 
	{
        ans=max(ans,shu());
        return;
    }
    for(int i=dp[temp-1];i<=m;i++) 
	{
        dp[temp]=i;
        dfs(temp+1);
    }
}

int main() 
{
    cin>>n>>m>>o;
    for(int i=1;i<=o;i++) 
	{
        cin>>a[x]>>b[x]>>c[x]>>d[x]);
    }
    dp[0]=1;
    dfs(1);
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:16: error: 'x' was not declared in this scope
   36 |         cin>>a[x]>>b[x]>>c[x]>>d[x]);
      |                ^
Language: C++

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

struct data{
    int a,b,c,d;
};

int main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    vector<data> x(Q);
    vector<int> A(10);
    for(int i=0;i<Q;i++){
        cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
    }
    int ans=0;
    for(int i=0;i<(1<<M);i++){
        bitset<10> k(i);
        if(k.count()==N){
            for(int j=0;j<10;j++){
                if(k.test(j)) A[j]=j;
                else A[j]=-20;
            }
            int ans1=0;
            for(int j=0;j<Q;j++){
                if(A.at(x[j].b-1)-A.at(x[j].a-1)==x[j].c){
                    ans1+=x[j].d;
                }
            }
            ans=max(ans,ans1);
        }
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: template argument 1 is invalid
   11 |     vector<data> x(Q);
      |                ^
a.cc:11:16: error: template argument 2 is invalid
a.cc:14:15: error: invalid types 'int[int]' for array subscript
   14 |         cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
      |               ^
a.cc:14:23: error: invalid types 'int[int]' for array subscript
   14 |         cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
      |                       ^
a.cc:14:31: error: invalid types 'int[int]' for array subscript
   14 |         cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
      |                               ^
a.cc:14:39: error: invalid types 'int[int]' for array subscript
   14 |         cin>>x[i].a>>x[i].b>>x[i].c>>x[i].d;
      |                                       ^
a.cc:26:26: error: invalid types 'int[int]' for array subscript
   26 |                 if(A.at(x[j].b-1)-A.at(x[j].a-1)==x[j].c){
      |                          ^
a.cc:26:41: error: invalid types 'int[int]' for array subscript
   26 |                 if(A.at(x[j].b-1)-A.at(x[j].a-1)==x[j].c){
      |                                         ^
a.cc:26:52: error: invalid types 'int[int]' for array subscript
   26 |                 if(A.at(x[j].b-1)-A.at(x[j].a-1)==x[j].c){
      |                                                    ^
a.cc:27:28: error: invalid types 'int[int]' for array subscript
   27 |                     ans1+=x[j].d;
      |                            ^
Language: C++

#include <vector>
using namespace std;

int main()
{
	int n, m, q, a = 0, ans = 0;
	cin>>n>>m>>q;
	vector<vector<int>> data(4,vector<int>(q));
	for(int i=0;i<q;i++){
		for(int j=0;j<4;j++){
			cin>>data[j][i];
		}
	}
	vector<int> v(3);
	for(int i=1;i<=m;i++){
		for(int j=1;j>=i && j<=m;j++){
			for(int k=1;k>=j && k<=m;k++){
				v = {i, j, k};
				a = 0;
				for(int i=0;i<q;i++){
					if(v[data[1][i]-1] - v[data[0][i]-1] == data[2][i]){
						a += data[3][i];
					}
				}
				if(a >= ans) ans = a;
			}
		}
	}
		
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin>>n>>m>>q;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout<<ans<<endl;
      |   ^~~~
a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:14: error: 'endl' was not declared in this scope
   30 |   cout<<ans<<endl;
      |              ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <vector>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int r[55][4] = {0};
int a[12][11] = {0};
int cnt[12] = {0};
vector<int> edge[12];
int main()
{
    int n, m, q; cin >> n >> m >> q;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < 4; ++j) cin >> r[i][j];
        edge[r[i][0]].push_back(i);
        cnt[r[i][1]]++;
    }
    for (int i = n; i >= 1; --i) {
        for (int j = 1; j <= m; ++j){
            for (auto &k : edge[i])
                if (j + r[k][2] <= m) a[i][j] += a[r[k][1]][j+r[k][2]] + r[k][3];
        }
    }
    ll ans =0;
    for  (int i = 1; i <= n; ++i) {
        if (cnt[i] == 0) {
            int _max = INT_MIN;
            for (int j = 1; j <= m; ++j) _max = max(_max, a[i][j]);
            ans += _max;
        }
    }
    cout << ans << endl;

    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:24: error: 'INT_MIN' was not declared in this scope
   71 |             int _max = INT_MIN;
      |                        ^~~~~~~
a.cc:21:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   20 | #include <map>
  +++ |+#include <climits>
   21 |
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

void dfs(vector<int> e, int N, int Q, int& ans, vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D){
  if(e.size()==N){
    int tmp=0;
    REP(i,Q){
      if(e[B[i]]-e[A[i]]==C[i]){
        tmp+=D[i];
      }
      chmax(ans,tmp);
    }
  }else{
    FOR(i,e[e.size()-1],M+1){
      vector<int> ee=e;
      ee.push_back(i);
      dfs(ee, N,Q, ans, A,B,C,D);
    }
    return;
  }
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<int>A(Q),B(Q),C(Q),D(Q);
  REP(i,Q){
    cin>>A[i]>>B[i]>>C[i]>>D[i];
    A[i]--;B[i]--;
  }
  int ans=0;
  vector<int> e(1);
  FOR(i,1,10){
    e[0]=i;
    dfs(e,N,Q,ans,A,B,C,D);
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'void dfs(std::vector<int>, int, int, int&, std::vector<int>&, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
a.cc:53:25: error: 'M' was not declared in this scope
   53 |     FOR(i,e[e.size()-1],M+1){
      |                         ^
a.cc:40:37: note: in definition of macro 'FOR'
   40 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                     ^
Language: C

int main(void) {
    long long N, M, Q, a[55], b[55], c[55], d[55], i, j;
    long long X, x, q, B, A[15];
    scanf("%lld%lld%lld", &N, &M, &Q);
    for (i=0; i<Q; i++) scanf("%lld%lld%lld%lld", &a[i], &b[i], &c[i], &d[i]);
    q=f(M, N-1); X=0;
    for (i=0; i<q; i++) {
        B=0; x=0;
        for (j=0; j<N; j++) A[j]=i/f(M, N-j-1)%M;
        A[0]=0;
        for (j=1; j<N-1; j++) {
            if (A[j]>A[j+1]) {
                B=1;
                break;
            }
        }
        if (B) continue;
        for (j=0; j<Q; j++) {
            if (A[b[j]-1]-A[a[j]-1]==c[j]) x+=d[j];
        }
        if (x>X) X=x;
    }
    printf("%lld", X);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |     scanf("%lld%lld%lld", &N, &M, &Q);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void) {
main.c:4:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |     scanf("%lld%lld%lld", &N, &M, &Q);
      |     ^~~~~
main.c:4:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:7: error: implicit declaration of function 'f' [-Wimplicit-function-declaration]
    6 |     q=f(M, N-1); X=0;
      |       ^
main.c:23:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   23 |     printf("%lld", X);
      |     ^~~~~~
main.c:23:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:23:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:23:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

#include <iostream>
#include <ctime>

using namespace std;

int main(){
	int n, m, q;
	cin >> n >> m >> q;
	int a[4][q];
	for(int i=0;i<q;i++){
		for(int j=0;j<4;j++){
			cin >> a[j][i];
		}
	}




	int ans = 0;
	int arrey[n];

	int count = 0;
	srand((unsigned int)time(NULL));
	while(count < 10000){
		int sum = 0;
		for(int j=0;j<n;j++){
			arrey[j] = rand()%(m-1) +1;
		}
		sort(arrey, arrey+n);

		for(int i=0;i<q;i++){
			if(arrey[a[1][i]] - arrey[a[0][i]] == a[2][i]){
				sum += a[3][i];
			}
		}

		if(sum > ans){
			ans = sum;
		}
		count++;

	}

	

	cout << ans << endl;
	
	return 0;
}

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

#include <stdio.h>
 
int yee(int nokori,int keta, int n,int* suretsu[10],int* qa[0],int* qb[0],int* qc[0],int* qd[0],int q){
    
    for(int i =0;i<nokori;i++)
    {suretsu[keta]=i+suretsu[keta-1];
    keta++;
    if(keta<n){
    return yee(nokori,keta,n,&suretsu[0],&qa[0],&qb[0],&qc[0],&qd[0],q);
    }
    else{
    int max=0;
    for(int i = 0;i<q;i++){
        int bb=qb[i];
        int aa=qa[i];
        int cc=qc[i];
        int dd=qd[i];
    if(suretsu[bb]-suretsu[aa]==cc){
    max+=dd;
    return max;
    }
    }
    }
}

int main()
{
    int n,m,q;
    scanf("%d %d %d", &n,&m,&q);
    int a,b,c,d;
    int max;
    
for(int i = 0;i<q;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int qa[i]=a;
    int qb[i]=b;
    int qc[i]=c;
    int qd[i]=d;
}
int max;
int suretsu[11];
int nokori = m-1;
int keta = 0;
suretsu[0]=1;
max=yee(nokori,keta,n,&suretsu[0],&qa[0],&qb[0],&qc[0],&qd[0],q);

printf("%d",max);
    return 0;
}

Compiler output:
main.c: In function 'yee':
main.c:14:16: error: initialization of 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   14 |         int bb=qb[i];
      |                ^~
main.c:15:16: error: initialization of 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   15 |         int aa=qa[i];
      |                ^~
main.c:16:16: error: initialization of 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   16 |         int cc=qc[i];
      |                ^~
main.c:17:16: error: initialization of 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   17 |         int dd=qd[i];
      |                ^~
main.c: In function 'main':
main.c:35:15: error: variable-sized object may not be initialized except with an empty initializer
   35 |     int qa[i]=a;
      |               ^
main.c:36:15: error: variable-sized object may not be initialized except with an empty initializer
   36 |     int qb[i]=b;
      |               ^
main.c:37:15: error: variable-sized object may not be initialized except with an empty initializer
   37 |     int qc[i]=c;
      |               ^
main.c:38:15: error: variable-sized object may not be initialized except with an empty initializer
   38 |     int qd[i]=d;
      |               ^
main.c:40:5: error: redeclaration of 'max' with no linkage
   40 | int max;
      |     ^~~
main.c:31:9: note: previous declaration of 'max' with type 'int'
   31 |     int max;
      |         ^~~
main.c:45:23: error: passing argument 4 of 'yee' from incompatible pointer type [-Wincompatible-pointer-types]
   45 | max=yee(nokori,keta,n,&suretsu[0],&qa[0],&qb[0],&qc[0],&qd[0],q);
      |                       ^~~~~~~~~~~
      |                       |
      |                       int *
main.c:3:41: note: expected 'int **' but argument is of type 'int *'
    3 | int yee(int nokori,int keta, int n,int* suretsu[10],int* qa[0],int* qb[0],int* qc[0],int* qd[0],int q){
      |                                    ~~~~~^~~~~~~~~~~
main.c: In function 'yee':
main.c:49:1: error: expected declaration or statement at end of input
   49 | }
      | ^
Language: C

#include <stdio.h>
int main(void){
    //変数定義
    int N;//N文字
    int M;//M種類
    int Q;//フィルターの数
    int point;//現在のポイント
    int maxpoint;//最大のポイント
    scanf("%d %d %d",&N,&M,&Q);//１行目入力
    int f[Q][4];//フィルター格納用配列、0~(Q-1)
    int l[N];//数列格納用配列、0~(N-1)
    //入力プログラム
    for(int i=0;i<Q;i++){//Q回繰り返す
    	scanf("%d %d %d %d",&f[i][0],&f[i][1],&f[i][2],&f[i][2]);//１行読み取り
    }
    //ループ＆数列作成
    //N文字の数列
    //初期化
    for(int i=0;i<N;i++){
    	l[i]=i;
    }
    while(l[0]!=M-N+1){
    	//点数計算処理
    	point = 0;
    	for(int i=0;i<Q;i++){//Q回繰り返す
    		if(l[f[i][1]]-l[f[i][0]]==f[i][2])
    			point += f[i][3];
    	}
    	if(maxpoint<=point)
          	maxpoint = point;
       	
    	//新規数列作成処理
    	//各n文字目について処理
    	i = N-1;
    	for(i=N-1;i>=0;i--){
    		if(i==N-1){
    			if(l[i]<M){//右端の数がMより小さいなら
    			l[i]++;
    			break;
    			}
    		}else{
    			if(l[i]<l[i+1]){//右端の数がMより小さいなら
           			l[i]++;
           			break;
           		}
           	}
    	}
    	
    	printf("%d",maxpoint);
    }
}


Compiler output:
main.c: In function 'main':
main.c:34:9: error: 'i' undeclared (first use in this function)
   34 |         i = N-1;
      |         ^
main.c:34:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
int main(void){
    //変数定義
    int N;//N文字
    int M;//M種類
    int Q;//フィルターの数
    int point;//現在のポイント
    int maxpoint;//最大のポイント
    scanf("%d %d %d",&N,&M,&Q);//１行目入力
    int f[Q][4];//フィルター格納用配列、0~(Q-1)
    int l[N];//数列格納用配列、0~(N-1)
    //入力プログラム
    for(int i=0;i<Q;i++){//Q回繰り返す
    	scanf("%d %d %d %d",&f[i][0],&f[i][1],&f[i][2],&f[i][2]);//１行読み取り
    }
    //ループ＆数列作成
    //N文字の数列
    //初期化
    for(int i=0;i<N;i++){
    	l[i]=i;
    }
    while(l[0]!=M-N+1){
    	//点数計算処理
    	point = 0;
    	for(int i=0;i<Q;i++){//Q回繰り返す
    		if(l[f[i][1]]-l[f[i][0]]==f[i][2])
    			point += f[i][3];
    	}
    	if(maxpoint<=point)
          	maxpoint = point;
       	
    	//新規数列作成処理
    	//各n文字目について処理
    	i = N-1;
    	for(i=N-1;i>=0;i--){
    		if(i==N-1){
    			if(l[i]<M){右端の数がMより小さいなら
    			l[i]++;
    			break;
    			}
    		}else{
    			if(l[i]<l[i+1]){右端の数がMより小さいなら
           			l[i]++;
           			break;
           		}
           	}
    	}
    	
    	printf("%d",maxpoint);
    }
}


Compiler output:
main.c: In function 'main':
main.c:34:9: error: 'i' undeclared (first use in this function)
   34 |         i = N-1;
      |         ^
main.c:34:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:37:36: error: unknown type name '\U000053f3\U00007aef\U0000306e\U00006570\U0000304cM\U00003088\U0000308a\U00005c0f\U00003055\U00003044\U0000306a\U00003089'
   37 |                         if(l[i]<M){右端の数がMより小さいなら
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
main.c:38:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   38 |                         l[i]++;
      |                             ^~
main.c:42:41: error: unknown type name '\U000053f3\U00007aef\U0000306e\U00006570\U0000304cM\U00003088\U0000308a\U00005c0f\U00003055\U00003044\U0000306a\U00003089'
   42 |                         if(l[i]<l[i+1]){右端の数がMより小さいなら
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
main.c:43:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   43 |                                 l[i]++;
      |                                     ^~
Language: C++

#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ull unsigned long long
#define ll long long
#define N 15
using namespace std;

ll n, m, q, ans, a[N];
ull sum;

struct lyj{
	ull a1, a2, a3, a4;
} b[N];

inline ll read(){
	ull s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void dfs(ll x, ll y){
	if (x > m || y > n) return ;
	dfs(x + 1, y);
	a[++y] = x;
	if (y == n){
		sum = 0;
		REP(i, 1, q) sum += a[b[i].a2] - a[b[i].a1] == b[i].a3 ? b[i].a4 : 0;
		ans = max(ans, sum);
	}
	dfs(x, y);
	dfs(x + 1, y);
}

inline void work(){
	n = read(), m = read(), q = read();
	REP(i, 1, q) b[i].a1 = read(), b[i].a2 = read(), b[i].a3 = read(), b[i].a4 = read();
	dfs(1, 0), cout << ans << endl;
}

int main(){
	work();
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:30:26: error: no matching function for call to 'max(long long int&, long long unsigned int&)'
   30 |                 ans = max(ans, sum);
      |                       ~~~^~~~~~~~~~
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:30:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   30 |                 ans = max(ans, sum);
      |                       ~~~^~~~~~~~~~
/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:30:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |                 ans = max(ans, sum);
      |                       ~~~^~~~~~~~~~
Language: C

#include <stdio.h>
int main(void){
    //変数定義
    int N;//N文字
    int M;//M種類
    int Q;//フィルターの数
    int point;//現在のポイント
    int maxpoint;//最大のポイント
    scanf("%d %d %d",&N,&M,&Q);//１行目入力
    int f[Q][4];//フィルター格納用配列、0~(Q-1)
    int l[N];//数列格納用配列、0~(N-1)
    //入力プログラム
    for(int i=0;i<Q;i++){//Q回繰り返す
    	scanf("%d %d %d %d",&f[i][0],&f[i][1],&f[i][2],&f[i][2]);//１行読み取り
    }
    //ループ＆数列作成
    //N文字の数列
    //初期化
    for(int i=0;i<N;i++){
    	l[i]=i;
    }
    while(l[0]!=M-N+1){
    	//点数計算処理
    	point = 0;
    	for(int i=0;i<Q;i++){//Q回繰り返す
    		if(l[f[i][1]]-l[f[i][0]]==f[i][2])
    			point += f[i][3];
    	}
    	if(maxpoint<=point)
          	maxpoint = point;
       	
    	//新規数列作成処理
    	各n文字目について処理
    	i = N-1;
    	for(i=N-1;i>=0;i--){
    		if(i==N-1){
    			if(l[i]<M){右端の数がMより小さいなら
    			l[i]++;
    			break;
    			}
    		}else{
    			if(l[i]<l[i+1]){右端の数がMより小さいなら
           			l[i]++;
           			break;
           		}
           	}
    	}
    	
    	printf("%d",maxpoint);
    }
}


Compiler output:
main.c: In function 'main':
main.c:33:9: error: unknown type name '\U00005404n\U00006587\U00005b57\U000076ee\U0000306b\U00003064\U00003044\U00003066\U000051e6\U00007406'
   33 |         各n文字目について処理
      |         ^~~~~~~~~~~~~~~~~~~~~
main.c:37:36: error: unknown type name '\U000053f3\U00007aef\U0000306e\U00006570\U0000304cM\U00003088\U0000308a\U00005c0f\U00003055\U00003044\U0000306a\U00003089'
   37 |                         if(l[i]<M){右端の数がMより小さいなら
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
main.c:38:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   38 |                         l[i]++;
      |                             ^~
main.c:42:41: error: unknown type name '\U000053f3\U00007aef\U0000306e\U00006570\U0000304cM\U00003088\U0000308a\U00005c0f\U00003055\U00003044\U0000306a\U00003089'
   42 |                         if(l[i]<l[i+1]){右端の数がMより小さいなら
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
main.c:43:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   43 |                                 l[i]++;
      |                                     ^~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  int n,m,q;
  cin >> n >> m >> q;
  vi a(q),b(q),c(q),d(q);
  REP(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vi x(n,-1);
  ll ans=0;
  REP(i,(1<<m)) {
    ll temp=0;
    bool flg=true;
    vpi ch;
    REP(j,m) {
      if(((i>>j)&1)==1) {
        for(int k=a[j]-1;k>=0;k--) {
          if(x[k]!=-1) {
            x[a[j]-1]=x[k];
          } else {
            x[a[j]-1]=1;
          }
        }
        pi che(a[j]-1,b[j]-1);
        if(find(ALL(ch),che)!=ch.end()) {
          flg=false;
          break;
        }
        ch.emplace_back(che);
        x[b[j]-1]=x[a[j]-1]+c[j];
        temp+=d[j];
      }
    }
    int check=1;
    REP(j,n) {
      if(x[j]==-1) break;
      if(x[j]>=check) {
        check=x[j];
      } else {
        flg=false;
      }
    }
    if(flg) {
      cout << 
      ans=max(ans,temp);
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:89:23: error: no match for 'operator=' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'const long long int')
   89 |       ans=max(ans,temp);
      |                       ^
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/ostream:458:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  458 |       operator=(basic_ostream&& __rhs)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:458:33: note:   no known conversion for argument 1 from 'const long long int' to 'std::basic_ostream<char>&&'
  458 |       operator=(basic_ostream&& __rhs)
      |                 ~~~~~~~~~~~~~~~~^~~~~
Language: C

#include<bits/stdc++.h>
#define int unsigned long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 11;
int n,m,q;

int pts[N][N][N];
int dp[N][N];
bool visit[N][N] = {0};

int solve(int x,int y,vector<int> value){
	if(x>=n) return 0;
	if(visit[x][y]) return dp[x][y];
	visit[x][y] = true;
	int ans = 0;
	for(int i=0;i<value.size();i++){
		ans += pts[x][i][y-value[i]];
	}
	value.push_back(y);
	int res = 0;
	for(int i=y;i<=m;i++){
		res = max(res,solve(x+1,i,value));
	}
	dp[x][y] = ans + res;
	return dp[x][y];
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>q;
	memset(pts,0,sizeof(pts));
	memset(visit,0,sizeof(visit));
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		cin>>pts[b][a][c];
	}
	int ans = 0;
	for(int i=1;i<=m;i++){
		vector<int> temp;
		ans = max(ans,solve(0,i,temp));
	}
	cout<<ans<<endl;
	return 0;
}



Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int main()
{
  int N, M, Q;
  cin >> N >> M >> Q;

  int a[Q], b[Q], c[Q], d[Q];
  for (int i = 0; i < Q; i++)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  int A[N], score = 0;

  for (int i = 0; i < Q; i++)
  {
    if (A[b[i] - 1] - A[[a[i] - 1]] == c[i])
    {
      score += d[i];
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: two consecutive '[' shall only introduce an attribute before '[' token
   19 |     if (A[b[i] - 1] - A[[a[i] - 1]] == c[i])
      |                        ^
a.cc:19:24: error: expected ')' before '[' token
   19 |     if (A[b[i] - 1] - A[[a[i] - 1]] == c[i])
      |        ~               ^
      |                        )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair #define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
struct query {
	int x,y,z,w;
};
int v[11];

std::mt19937 mtRand;
int main(void)
{
	int ans = 0;
	int n, m, q; cin >> n >> m >> q;
	vector<query> Q;
	for(int i=0;i<q;i++) {
		int x,y,z,w;
		cin >> x >> y >> z >> w;
		Q.pb({x,y,z,w});
	}
	v[1] = 1;
	for(int k=0;k<5000000;k++){
		for(int i=2;i<=n;i++) {
			v[i] = mtRand() % m + 1;
		}
		sort(v + 2, v + n + 1);
		int tmp = 0;
		for(auto q : Q) {
			if(v[q.y]-v[q.x] == q.z) tmp += q.w;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: 'class std::vector<query>' has no member named 'pb'
   23 |                 Q.pb({x,y,z,w});
      |                   ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair #define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
struct query {
	int x,y,z,w;
};
int v[11];

std::mt19937 mtRand;
int main(void)
{
	int ans = 0;
	int n, m, q; cin >> n >> m >> q;
	vector<query> Q;
	for(int i=0;i<q;i++) {
		int x,y,z,w;
		cin >> x >> y >> z >> w;
		Q.pb({x,y,z,w});
	}
	v[1] = 1;
	for(int k=0;k<1000000;k++){
		for(int i=2;i<=n;i++) {
			v[i] = mtRand() % m + 1;
		}
		sort(v + 2, v + n + 1);
		int tmp = 0;
		for(auto q : Q) {
			if(v[q.y]-v[q.x] == q.z) tmp += q.w;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: 'class std::vector<query>' has no member named 'pb'
   23 |                 Q.pb({x,y,z,w});
      |                   ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
set<int>f(int N,int M){
if(N==1){
set<int>s;
  for(int i=1;i<=M;i++) 
    s.insert(i);
  return s;
}else{
set<int>S=f(N-1,M);
  set<int>s;
  for(auto x:S){
  int a=x%10;
    for(int i=a;i<=M;i++){
     s.insert(10*x+i);
    }
  
  } return s;

}

}
int main(){
int N,M,Q;
  cin>>N>>M>>Q;
  vector<int>a(Q);
  vector<int>b(Q);
  vector<int>c(Q);
  vector<int>d(Q);
  for(int i=0;i<Q;i++){
  cin>>a.at(i); a.at(i)--;
    cin>>b.at(i);b.at(i)--;
    cin>>c.at(i);
    cin>>d.at(i);
  }
  int ans1=0;
  set<int>S=f(N,M);
  for(auto p:S){
    int ans=0;
  string str=to_string(p);
    for(int i=0;i<Q;i++){
    if(str.at(b.at(i))-str.at(a.at(i))==c.at(i))
      ans+=d.at(i);
    } if(ans1<ans)
      ans1=ans;
  
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:10: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   48 |   }cout<<ans<<endl;
      |          ^~~
      |          ans1
Language: C++

#include <bits/stdc++.h>
using namespace std;
int vec_max_num(int n,vector<vector<int>> vec){
  int i=0,max=0,j=0;
  for(i;i<vec.size();i++){
    if(vec.at[i].at[n]>max){j=i;max=vec.at[i].at[n];}
  }
  return j;
}

int main(){
  int n,n,q;
  cin>>n>>m>>q;
  vector<vector<int>> vec(q,vector<int>(4));
  int i,max;
  for(i=0;i<q;i++){
    cin>>vec.at[i].at[0]>>vec.at[i].at[1]>>vec.at[i].at[2]>>vec.at[i].at[3];
  }
  int j=vec_max_num(4,vec);
  max+=vec.at[j].at[4];
   cout<<i<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int vec_max_num(int, std::vector<std::vector<int> >)':
a.cc:6:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    6 |     if(vec.at[i].at[n]>max){j=i;max=vec.at[i].at[n];}
      |              ^
a.cc:6:43: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
    6 |     if(vec.at[i].at[n]>max){j=i;max=vec.at[i].at[n];}
      |                                           ^
a.cc: In function 'int main()':
a.cc:12:9: error: redeclaration of 'int n'
   12 |   int n,n,q;
      |         ^
a.cc:12:7: note: 'int n' previously declared here
   12 |   int n,n,q;
      |       ^
a.cc:13:11: error: 'm' was not declared in this scope
   13 |   cin>>n>>m>>q;
      |           ^
a.cc:17:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   17 |     cin>>vec.at[i].at[0]>>vec.at[i].at[1]>>vec.at[i].at[2]>>vec.at[i].at[3];
      |                ^
a.cc:17:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   17 |     cin>>vec.at[i].at[0]>>vec.at[i].at[1]>>vec.at[i].at[2]>>vec.at[i].at[3];
      |                                 ^
a.cc:17:50: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   17 |     cin>>vec.at[i].at[0]>>vec.at[i].at[1]>>vec.at[i].at[2]>>vec.at[i].at[3];
      |                                                  ^
a.cc:17:67: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   17 |     cin>>vec.at[i].at[0]>>vec.at[i].at[1]>>vec.at[i].at[2]>>vec.at[i].at[3];
      |                                                                   ^
a.cc:20:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   20 |   max+=vec.at[j].at[4];
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
set<int>f(int N,int M){
if(N==1){
set<int>s;
  for(int i=1;i<=M) s.insert(i);
  return s;
}else{
set<int>S=f(N-1,M);
  set<int>s;
  for(auto x:S){
  int a=x%10;
    for(int i=a;i<=M){
     s.insert(10*x+i);
    }
  
  } return s;

}

}
int main(){
int N,M,Q;
  cin>>N>>M>>Q;
  vector<int>a(Q);
  vector<int>b(Q);
  vector<int>c(Q);
  vector<int>d(Q);
  for(int i=0;i<Q;i++){
  cin>>a.at(i); a.at(i)--;
    cin>>b.at(i);b.at(i)--;
    cin>>c.at(i);
    cin>>d.at(i);
  }
  int ans1=0;
  set<int>S=f(N,M);
  for(auto p:S){
    int ans=0;
  string str=to_string(p);
    for(int i=0;i<Q;i++){
    if(str.at(b.at(i))-str.at(a.at(i))==c.at(i))
      ans+=d.at(i);
    } if(ans1<ans)
      ans1=ans;
  
  
  }cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'std::set<int> f(int, int)':
a.cc:6:19: error: expected ';' before ')' token
    6 |   for(int i=1;i<=M) s.insert(i);
      |                   ^
      |                   ;
a.cc:13:21: error: expected ';' before ')' token
   13 |     for(int i=a;i<=M){
      |                     ^
      |                     ;
a.cc: In function 'int main()':
a.cc:47:10: error: 'ans' was not declared in this scope; did you mean 'ans1'?
   47 |   }cout<<ans<<endl;
      |          ^~~
      |          ans1
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

auto calc = [&](const vector<int>& v) -> int {
    int res = 0;
    for (int i = 0; i < q; i++) {
        if (v[b[i]] - v[a[i]] == c[i]) res += d[i];
    }
    return res;
};

void dfs(int i, vector<int>& v) {
    if (i == n) {
        ans = max(ans, calc(v));
        return;
    }

    for (int j = (i == 0 ? 1 : v.back()); j <= m; j++) {
        v.push_back(j);
        dfs(i + 1, v);
        v.pop_back();
    }
};

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

    cin >> n >> m >> q;

    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }

    vector<int> v;
    dfs(0, v);
    cout << ans << newl;
    return 0;
}

Compiler output:
a.cc:13:14: error: non-local lambda expression cannot have a capture-default
   13 | auto calc = [&](const vector<int>& v) -> int {
      |              ^
Language: C++

//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=998244353;
const double pi=acos(-1.0);
ll n,m,q,vv[105],s,ma=-0x3f3f3f3f;
struct node{
    ll a,b,c,d;
}v[105];

bool cmp(node x,node y){
    return x.d>y.d;
}

int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    sc(n),sc(m),sc(q);
    for(int i=1;i<=q;i++){
        sc(v[i].a),sc(v[i].b),sc(v[i].c),sc(v[i].d);
    }
    sort(v+1,v+1+q,cmp);
  	for(int i=1;i<n;i++) vv[i]=1;
  	vv[n]=n;
    
        for(int i=1;i<=q;i++){
            if(vv[v[i].b]-vv[v[i].a]==v[i].c){
                s+=v[i].d;
            }
        }
    }
    printf("%lld\n",s);
    return 0;
}

Compiler output:
a.cc:39:11: error: expected constructor, destructor, or type conversion before '(' token
   39 |     printf("%lld\n",s);
      |           ^
a.cc:40:5: error: expected unqualified-id before 'return'
   40 |     return 0;
      |     ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,q,k,a,b,c,x[50][4],mm;
int main(){
  cin>>n>>m>>q;
  for(;i<q;i++)for(j=0;j<4;j++)cin>>x[i][j];
  for(j=0,i=0;i<n;i++){
    k+=1*pow(10,i);
    j+=m*pow(10,i);
  }
  cout<<k<<" "<<j<<endl;
  
  for(;k<=j;k++){
    reverse(y,y+n);
    for(c=0,i=0;i<q;i++){
      cout<<"yatteru"<<endl;
      int ia=x[i][0];
      int ib=x[i][1];
      int ic=x[i][2];
      int id=x[i][3];
      int bb=k/pow(10,n-ib);
      bb%=10;
      int aa=k/pow(10,n-ia);
      aa%=10;
      if(bb-aa==ic)c+=id;
    }
    mm=max(mm,c);
  }
  cout<<mm;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'y' was not declared in this scope; did you mean 'yn'?
   14 |     reverse(y,y+n);
      |             ^
      |             yn
Language: C

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, q;
    int a[100], b[100], c[100], d[100];
    vector<tuple<int, int, int, int>> v;
    long long int sum = 0;

    cin >> n >> m >> q;

    vector<int> ans(n+1, 0);

    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        v.emplace_back(d[i], a[i], b[i], c[i]);
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    for (auto x: v) {
        if (ans[get<1>(x)] == 0 && ans[get<2>(x)] == 0) {
            ans[get<1>(x)] = 1;
            ans[get<2>(x)] = get<3>(x) + 1;
            sum += get<0>(x);
        }
        else if (ans[get<1>(x)] == 0 && ans[get<2>(x)] != 0) {
            if (ans[get<2>(x)] - get<3>(x) > 0) {
                ans[get<1>(x)] = ans[get<2>(x)] - get<3>(x);
                sum += get<0>(x);
            }
        }
        else if (ans[get<1>(x)] != 0 && ans[get<2>(x)] == 0) {
            if (ans[get<1>(x)] + get<3>(x) <= n) {
                ans[get<2>(x)] = ans[get<1>(x)] + get<3>(x);
                sum += get<0>(x);
            }
        }

    }


    cout << sum << endl;
}


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

#include<bits/stdc++.h>
#define INFTY 1000000001
using namespace std;
void merge(int A[], int left, int mid, int right);
void merge_sort(int A[], int left, int right);

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<tuple<int, int, int, int>> A(q);
  for(int i = 0; i < q; i++) {
    int a, b, c;
    int64_t d;
    cin >> a >> b >> c >> d;
    A.at(i) = make_tuple(d, c, b, a);
  }
  
  for(int i = 1; i < q-1; i++) {
    merge_sort(A[i], A[i-1], A[i+1]);
  }  
  int64_t sum = 0;
  for(int i = 0; i < q; i++) {
    int d, c, b, a;
    tie(d, c, b, a) = A.at(i);
    if(i > 2) {
      if(A.at(i) == A.at(i+1)) continue;
    }
    if(c == b - a) {
      sum += d;
    }
  }
  cout << sum << endl;
} 

void merge(int A[], int left, int mid, int right) {
  int i, j, k;
  int n1, n2;  // 部分列L, Rの要素数決定に利用
  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1+1], R[n2+1];
  
  for (i = 0; i < n1; i++) L[i] = A[left + i];  
  for (i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;

  // sort
  j = 0;
  k = 0;
  for (i = left; i < right; i++) {
    if (L[j] <= R[k]) {
      A[i] = L[j];
      j++;
    } else {
      A[i] = R[k];
      k++;
    }
  }
}

void merge_sort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid;
    mid = (left + right) / 2;
    // devide
    merge_sort(A, left, mid);
    merge_sort(A, mid, right);
    // conquer
    merge(A, left, mid, right);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int, int> >, std::tuple<int, int, int, int> >::value_type' {aka 'std::tuple<int, int, int, int>'} to 'int*'
   19 |     merge_sort(A[i], A[i-1], A[i+1]);
      |     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      |               |
      |               __gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int, int> >, std::tuple<int, int, int, int> >::value_type {aka std::tuple<int, int, int, int>}
a.cc:5:21: note:   initializing argument 1 of 'void merge_sort(int*, int, int)'
    5 | void merge_sort(int A[], int left, int right);
      |                 ~~~~^~~
Language: C++

#include<bits/stdc++.h>
#define INFTY 1000000001
using namespace std;
void merge(int A[], int left, int mid, int right);
void merge_sort(int A[], int left, int right);

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<tuple<int, int, int, int>> A(q);
  for(int i = 0; i < q; i++) {
    int a, b, c;
    int64_t d;
    cin >> a >> b >> c >> d;
    A.at(i) = make_tuple(d, c, b, a);
    if(i>0) merge_sort(A[i], A[i-1], A[i+1]);
  }
  
  int64_t sum = 0;
  for(int i = 0; i < q; i++) {
    int d, c, b, a;
    tie(d, c, b, a) = A.at(i);
    if(i > 2) {
      if(A.at(i) == A.at(i+1)) continue;
    }
    if(c == b - a) {
      sum += d;
    }
  }
  cout << sum << endl;
} 

void merge(int A[], int left, int mid, int right) {
  int i, j, k;
  int n1, n2;  // 部分列L, Rの要素数決定に利用
  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1+1], R[n2+1];
  
  for (i = 0; i < n1; i++) L[i] = A[left + i];  
  for (i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;

  // sort
  j = 0;
  k = 0;
  for (i = left; i < right; i++) {
    if (L[j] <= R[k]) {
      A[i] = L[j];
      j++;
    } else {
      A[i] = R[k];
      k++;
    }
  }
}

void merge_sort(int A[], int left, int right) {
  if (left + 1 < right) {
    int mid;
    mid = (left + right) / 2;
    // devide
    merge_sort(A, left, mid);
    merge_sort(A, mid, right);
    // conquer
    merge(A, left, mid, right);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int, int> >, std::tuple<int, int, int, int> >::value_type' {aka 'std::tuple<int, int, int, int>'} to 'int*'
   16 |     if(i>0) merge_sort(A[i], A[i-1], A[i+1]);
      |             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       __gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int, int> >, std::tuple<int, int, int, int> >::value_type {aka std::tuple<int, int, int, int>}
a.cc:5:21: note:   initializing argument 1 of 'void merge_sort(int*, int, int)'
    5 | void merge_sort(int A[], int left, int right);
      |                 ~~~~^~~