Language: C

  int n,m,q,a[100],b[100],c[100],d[100],e[100],i,j,f,r;
  long long ans=0;
  char s[100]={};
  scanf("%d %d %d",&n,&m,&q);
  for(i=0;i<q;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
  for(i=0;i<n;i++)s[i]='0';
  for(i=0;i<m;i++)s[i+n]='1';
  s[n+m]=0;
  do{
    for(i=j=r=0;s[i];i++){
      if(s[i]=='1')j++;
      else         e[r++]=j;
    }
    //for(i=0;i<r;i++)printf("%d ",e[i]);printf("\n");
    for(i=f=0;i<q;i++){
      if(e[b[i]-1]-e[a[i]-1]==c[i])f+=d[i];
    }
    if(ans<f)ans=f;
  }while(nxpt(s));
  printf("%lld\n",ans);
  return 0;
}


Compiler output:
main.c:4:9: error: expected declaration specifiers or '...' before string constant
    4 |   scanf("%d %d %d",&n,&m,&q);
      |         ^~~~~~~~~~
main.c:4:20: error: expected declaration specifiers or '...' before '&' token
    4 |   scanf("%d %d %d",&n,&m,&q);
      |                    ^
main.c:4:23: error: expected declaration specifiers or '...' before '&' token
    4 |   scanf("%d %d %d",&n,&m,&q);
      |                       ^
main.c:4:26: error: expected declaration specifiers or '...' before '&' token
    4 |   scanf("%d %d %d",&n,&m,&q);
      |                          ^
main.c:5:3: error: expected identifier or '(' before 'for'
    5 |   for(i=0;i<q;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
      |   ^~~
main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    5 |   for(i=0;i<q;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
      |            ^
main.c:5:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    5 |   for(i=0;i<q;i++)scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
      |                ^~
main.c:6:3: error: expected identifier or '(' before 'for'
    6 |   for(i=0;i<n;i++)s[i]='0';
      |   ^~~
main.c:6:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    6 |   for(i=0;i<n;i++)s[i]='0';
      |            ^
main.c:6:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    6 |   for(i=0;i<n;i++)s[i]='0';
      |                ^~
main.c:7:3: error: expected identifier or '(' before 'for'
    7 |   for(i=0;i<m;i++)s[i+n]='1';
      |   ^~~
main.c:7:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    7 |   for(i=0;i<m;i++)s[i+n]='1';
      |            ^
main.c:7:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    7 |   for(i=0;i<m;i++)s[i+n]='1';
      |                ^~
main.c:8:3: warning: data definition has no type or storage class
    8 |   s[n+m]=0;
      |   ^
main.c:8:3: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:8:3: error: variably modified 's' at file scope
main.c:8:3: error: conflicting types for 's'; have 'int[1]'
main.c:3:8: note: previous definition of 's' with type 'char[100]'
    3 |   char s[100]={};
      |        ^
main.c:8:10: error: invalid initializer
    8 |   s[n+m]=0;
      |          ^
main.c:9:3: error: expected identifier or '(' before 'do'
    9 |   do{
      |   ^~
main.c:19:4: error: expected identifier or '(' before 'while'
   19 |   }while(nxpt(s));
      |    ^~~~~
main.c:20:10: error: expected declaration specifiers or '...' before string constant
   20 |   printf("%lld\n",ans);
      |          ^~~~~~~~
main.c:20:19: error: expected declaration specifiers or '...' before 'ans'
   20 |   printf("%lld\n",ans);
      |                   ^~~
main.c:21:3: error: expected identifier or '(' before 'return'
   21 |   return 0;
      |   ^~~~~~
main.c:22:1: error: expected identifier or '(' before '}' token
   22 | }
      | ^