Language: C++

#include <vector>
#include <cstdio>
#include <stack>
#include <string>
using namespace std;
const int S = (1<<20)+5;
char buf[S],*H,*T;
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;
}
inline long long relo()
{
    long long 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;
    vector<long long> cf;
    vector< vector<int> > tickets;
    int shop = read(),tic = read();
    cf.reserve(shop-1);
    tickets.assign(tic,vector<int>());
    ms.assign(tic,stack<int>());
    for (register int i = 1;i<shop;++i){
        long long temp = relo();
        cf.push_back(-temp);
    }
    for (register int i = 0;i<shop;++i){
        for (register int j = 0;j<tic;++j){
            int temp=read();
            tickets[j].push_back(temp);
        }
    }
    for (register int i = shop-1;i>=0;--i){
	long long result = 0;
        for (register int j = 0;j<ms.size();++j){
            int cur = tickets[j][i],prev = 0;
            while (!ms[j].empty()){
                if (cur>tickets[j][ms[j].top()]){
                    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);
        }
        marxism = max(marxism,result);
        for (register int j = i;j<shop-1;++j){
            result +=  dis[j];
            marxism = max(marxism,result);
        }
    }
    printf("%lld",marxism);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |     for (register int i = 1;i<shop;++i){
      |                       ^
a.cc:40:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |     for (register int i = 0;i<shop;++i){
      |                       ^
a.cc:41:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         for (register int j = 0;j<tic;++j){
      |                           ^
a.cc:46:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |     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:66:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |         for (register int j = i;j<shop-1;++j){
      |                           ^
a.cc:67:24: error: 'dis' was not declared in this scope; did you mean 'div'?
   67 |             result +=  dis[j];
      |                        ^~~
      |                        div