Language: C++

#include <vector>
#include <cstdio>
#include <stack>
#include <string>
#define help cout<<"I don't want to die!"<<endl;
using namespace std;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}
int main(){
    long long marxism = -10000000000000;
    vector<stack<int> > ms;//monotonic stack;
    vector<int> dis;
    vector<long long> cf;//distance between shops,0:0->1;chafenshuzu
    vector< vector<int> > tickets;
    int shop = read(),tic = read();
    /*initialization*/
    cf.assign(shop-1,0);
    tickets.assign(tic,vector<int>());
    ms.assign(tic,stack<int>());
    dis.reserve(shop);
    /*done*/
    for (register int i = 1;i<shop;++i){
        int temp = read();
        dis.push_back(-temp);
    }
    //convert the distance into "chafen" form;
    for (register int i = 0;i<shop;++i){
        for (register int j = 0;j<tic;++j){
            int temp=read();
            tickets[j].push_back(temp);
        }
    }
    //get the tickets'value
    //tickets[i][j]:the value of ticket i in the shop j
    for (register int i = shop-1;i>=0;--i){
	long long result = 0;
        //enumerate start point from tail to head;
        for (register int j = 0;j<ms.size();++j){
            //process the "chafenshuzu" of each ticket.
            int cur = tickets[j][i],prev = 0;//prev is the previous shop,used to determine how large to shrink in the next shop;
            while (!ms[j].empty()){
                if (cur>tickets[j][ms[j].top()]){//the one we have is greater than the top of the stack;
                    cf[ms[j].top()-1] -=(tickets[j][ms[j].top()]-prev);
                    prev = tickets[j][ms[j].top()];
                    ms[j].pop();
                }
                else{
                    cf[ms[j].top()-1] -=(cur-prev);
                    break;
                }
            }
	    result += cur;
	    if (i) cf[i-1] +=cur;
            ms[j].push(i);
        }
	//update the 'chafen' completed;
        marxism = max(marxism,result);
        for (register int j = i;j<shop-1;++j){
            result +=  dis[j];
            result +=  cf[j];
            marxism = max(marxism,result);
        }
    }
    printf("%lld",marxism);
}


Compiler output:
a.cc: In function 'char Get()':
a.cc:9:8: error: 'H' was not declared in this scope
    9 |     if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
      |        ^
a.cc:9:11: error: 'T' was not declared in this scope
    9 |     if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
      |           ^
a.cc:9:19: error: 'buf' was not declared in this scope
    9 |     if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
      |                   ^~~
a.cc:9:36: error: 'S' was not declared in this scope
    9 |     if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
      |                                    ^
a.cc:10:8: error: 'H' was not declared in this scope
   10 |     if(H==T) return -1;return *H++;
      |        ^
a.cc:10:11: error: 'T' was not declared in this scope
   10 |     if(H==T) return -1;return *H++;
      |           ^
a.cc:10:32: error: 'H' was not declared in this scope
   10 |     if(H==T) return -1;return *H++;
      |                                ^
a.cc: In function 'int main()':
a.cc:32:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     for (register int i = 1;i<shop;++i){
      |                       ^
a.cc:37:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |     for (register int i = 0;i<shop;++i){
      |                       ^
a.cc:38:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |         for (register int j = 0;j<tic;++j){
      |                           ^
a.cc:45:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |     for (register int i = shop-1;i>=0;--i){
      |                       ^
a.cc:48:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   48 |         for (register int j = 0;j<ms.size();++j){
      |                           ^
a.cc:68:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   68 |         for (register int j = i;j<shop-1;++j){
      |                           ^