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

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MAX_N = (1e+5)+10;
using pa = pair<int,int>;
vector<vector<pa> > G(MAX_N,vector<pa>(0));//0-indexed
vec dp(MAX_N*2+1,-1);//edgeの行先が「黒のとき」、そこからの場合の数
bool used[MAX_N];

ll solve(ll start, ll now, ll edge){ //nowが白の場合も含めた場合の数
    //if(dp.at(edge) != -1) return dp.at(edge);
    used[now] = true;
    if(dp.at(edge) != -1) return dp.at(edge);
    ll ans=1;
    for(auto e : G.at(now)) {
        if(!used[e.fi]) (ans *= solve(start,e.fi,e.se))%=M;
    }
    if(start != now) (++ans)%=M;
    if(edge != MAX_N*2) dp.at(edge) = ans;
    used[now] = false;
    return ans;
}

int main() {
    cin>>N>>M;
    //scanf("%d %d", &V, &E);
    for(int i = 0; i < N-1; i++) {
        // sからtへの辺を張る
        int s,t;
        scanf("%d %d", &s, &t);
        G.at(s-1).emplace_back(t-1,i*2);
        G.at(t-1).emplace_back(s-1,i*2+1);// 無向グラフの場合
    }
    rep(i,N){
        bool used[MAX_N] = false; 
        ll ans = solve(i,i,MAX_N*2);//edgeにひっかからないように
        printf("%lld\n",ans);
    }
    //rep(i,N*2) cout<<dp.at(i)<<endl;
    /*rep(i,N){
        for(auto e: G.at(i)){
            cout<<i<<' '<<e.fi<<' '<<e.se<<endl;
        }
    }*/
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:28: error: array must be initialized with a brace-enclosed initializer
   47 |         bool used[MAX_N] = false;
      |                            ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MAX_N = (1e+5)+10;
using pa = pair<int,int>;
vector<vector<pa> > G(MAX_N,vector<pa>(0));//0-indexed
vec dp(MAX_N*2+1,-1);//edgeの行先が「黒のとき」、そこからの場合の数
vector<int> used(MAX_N,false);

ll solve(ll start, ll now, ll edge){ //nowが白の場合も含めた場合の数
    //if(dp.at(edge) != -1) return dp.at(edge);
    used.at(now) = 1;
    if(dp.at(edge) != -1) return dp.at(edge);
    ll ans=1;
    for(auto e : G.at(now)) {
        if(!used.at(e.fi)) (ans *= solve(start,e.fi,e.se))%=M;
    }
    if(start != now) (++ans)%=M;
    if(edge != MAX_N*2) dp.at(edge) = ans;
    used.at(now) = 0;
    return ans;
}

int main() {
    cin>>N>>M;
    //scanf("%d %d", &V, &E);
    for(int i = 0; i < N-1; i++) {
        // sからtへの辺を張る
        int s,t;
        scanf("%d %d", &s, &t);
        G.at(s-1).emplace_back(t-1,i*2);
        G.at(t-1).emplace_back(s-1,i*2+1);// 無向グラフの場合
    }
    rep(i,N){
        memset(used,0,sizeof(used)); 
        ll ans = solve(i,i,MAX_N*2);//edgeにひっかからないように
        printf("%lld\n",ans);
    }
    //rep(i,N*2) cout<<dp.at(i)<<endl;
    /*rep(i,N){
        for(auto e: G.at(i)){
            cout<<i<<' '<<e.fi<<' '<<e.se<<endl;
        }
    }*/
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:16: error: cannot convert 'std::vector<int>' to 'void*'
   47 |         memset(used,0,sizeof(used));
      |                ^~~~
      |                |
      |                std::vector<int>
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MAX_N = (1e+5)+10;
using pa = pair<int,int>;
vector<vector<pa> > G(MAX_N,vector<pa>(0));//0-indexed
vec dp(MAX_N*2+1,-1);//edgeの行先が「黒のとき」、そこからの場合の数
vector<bool> used(MAX_N,false);

ll solve(ll start, ll now, ll edge){ //nowが白の場合も含めた場合の数
    //if(dp.at(edge) != -1) return dp.at(edge);
    used.at(now) = true;
    if(dp.at(edge) != -1) return dp.at(edge);
    ll ans=1;
    for(auto e : G.at(now)) {
        if(!used.at(e.fi)) (ans *= solve(start,e.fi,e.se))%=M;
    }
    if(start != now) (++ans)%=M;
    if(edge != MAX_N*2) dp.at(edge) = ans;
    used.at(now) = false;
    return ans;
}

int main() {
    cin>>N>>M;
    //scanf("%d %d", &V, &E);
    for(int i = 0; i < N-1; i++) {
        // sからtへの辺を張る
        int s,t;
        scanf("%d %d", &s, &t);
        G.at(s-1).emplace_back(t-1,i*2);
        G.at(t-1).emplace_back(s-1,i*2+1);// 無向グラフの場合
    }
    rep(i,N){
        memset(used,0,sizeof(used)); 
        ll ans = solve(i,i,MAX_N*2);//edgeにひっかからないように
        printf("%lld\n",ans);
    }
    //rep(i,N*2) cout<<dp.at(i)<<endl;
    /*rep(i,N){
        for(auto e: G.at(i)){
            cout<<i<<' '<<e.fi<<' '<<e.se<<endl;
        }
    }*/
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:16: error: cannot convert 'std::vector<bool>' to 'void*'
   47 |         memset(used,0,sizeof(used));
      |                ^~~~
      |                |
      |                std::vector<bool>
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long f[100009], ef[100009], depe[100009], pas[100009];
vector<long long> ve[123456];
long long M;
void deefes(long long x){
    ef[x] = 1;
    depe[x] =1;
    for(auto y : ve[x]){
        if(ef[y]) continue;
        deefes(y);
        depe[x] = depe[x] * depe[y] % M;
    }
    depe[x] ++;
}
void dfs(long long x, long long ze){
    f[x] = 1;
    pas[x] = ze;
    vector<pair<long long,long long> > v;
    for(auto y : ve[x]){
        if(f[y]) continue;
        v.push_back({y, depe[y]});
        pas[x] = pas[x] * depe[y] % M;
    }
    if(v.size() == 0) return;
    v.push_back({-1, ze});
    vector<long long> pre(v.size()+2);
    vector<long long> suf(v.size()+2);
    pre[0] = 1;
    for(long long i = 0; i < v.size(); i++)
        pre[i+1] = pre[i] * v[i].second % M;
    suf[v.size() + 1] = 1;
    for(long long i = v.size(); i >= 1; i--)
        suf[i] = suf[i + 1] * v[i - 1].second % M;
    for(long long i =0 ; i < v.size() - 1; i++){
        dfs(v[i].first, (pre[i] * suf[i + 2]  + 1) % M);
    }

}
pair<long long,long long> x[100009];
long long main(){
    long long n;
    cin >> n >> M;
    for(long long i = 0; i < n - 1; i ++){
        long long a, b;
        cin >> a >> b;
        ve[a].push_back(b);
        ve[b].push_back(a);
    }
    deefes(1);
    dfs(1, 1);
    for(long long i = 1; i <= n; i++)
        cout << pas[i] << endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long f[100009], ef[100009], depe[100009], pas[100009];
vector<long long> ve[123456];
long long M;
void deefes(long long x){
    ef[x] = 1;
    depe[x] =1;
    for(auto y : ve[x]){
        if(ef[y]) continue;
        deefes(y);
        depe[x] = depe[x] * depe[y] % M;
    }
    depe[x] ++;
}
void dfs(long long x, long long ze){
    f[x] = 1;
    pas[x] = ze;
    vector<pair<long long,long long> > v;
    vector<long long> pre(v.size()+2);
    vector<long long> suf(v.size()+2);
    for(auto y : ve[x]){
        if(f[y]) continue;
        v.push_back({y, depe[y]});
        pas[x] = pas[x] * depe[y] % M;
    }
    if(v.size() == 0) return;
    v.push_back({-1, ze});
    pre[0] = 1;
    for(long long i = 0; i < v.size(); i++)
        pre[i+1] = pre[i] * v[i].second % M;
    suf[v.size() + 1] = 1;
    for(long long i = v.size(); i >= 1; i--)
        suf[i] = suf[i + 1] * v[i - 1].second % M;
    for(long long i =0 ; i < v.size() - 1; i++){
        dfs(v[i].first, (pre[i] * suf[i + 2]  + 1) % M);
    }

}
pair<long long,long long> x[100009];
long long main(){
    long long n;
    cin >> n >> M;
    for(long long i = 0; i < n - 1; i ++){
        long long a, b;
        cin >> a >> b;
        ve[a].push_back(b);
        ve[b].push_back(a);
    }
    deefes(1);
    dfs(1, 1);
    for(long long i = 1; i <= n; i++)
        cout << pas[i] << endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++


//#include "stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define int long long

int dp[100001][2],phi;vector<int> adj[100001];int m;
int inverse(int y)
{
    return power(y,phi-1,m);
}
int eulertotient(int x)
{
    int ans=x;int cnt=0;
    for(int i=2;i<=sqrt(x);i++)
    {
        cnt=0;
        while((x%i)==0)
        {
            x=x/i;
            cnt++;
        }
        if(cnt)
            ans=(ans*(i-1))/i;
    }
    if(x>1)
    {
        ans=(ans*(x-1))/x;
    }
    return ans;
}
void dfs1(int u,int p)
{
    int v,y;
    for(int i=0;i<adj[u].size();i++)
    {
        v=adj[u][i];
        if(v!=p)
        {
            y=dp[v][0]%m;
            dp[v][0]=(dp[v][0]%m*dp[u][0]%m)%m;
            if((dp[v][0]%((y+1)%m)==0)
            dp[v][0]=(dp[v][0]/(y+1))%m;
            else
                dp[v][0]=(dp[v][0]*inverse((y+1)%m))%m;
            dp[v][0]=(dp[v][0]%m+y%m)%m;
            dfs1(v,u);
        }
    }
}
void dfs(int u,int p)
{
    int v;
    dp[u][0]=1;
    dp[u][1]=0;
    for(int i=0;i<adj[u].size();i++)
    {
        v=adj[u][i];
        if(v!=p)
        {
            dfs(v,u);
            dp[u][0]=(dp[u][0]%m*(dp[v][0]+1)%m)%m;
            dp[u][1]=(dp[u][1]%m+dp[v][0]%m)%m;
            dp[u][1]=(dp[u][1]%m+dp[v][1]%m)%m;
        }
    }
}
int32_t main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");/*
    int n;int u,v;
    cin>>n>>m;
    phi=eulertotient(m);
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,0);
   // for(int i=1;i<=n;i++)
     //   cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    dfs1(1,0);
    for(int i=1;i<=n;i++)
        cout<<dp[i][0]<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'void dfs1(long long int, long long int)':
a.cc:52:39: error: expected ';' before 'dp'
   52 |             if((dp[v][0]%((y+1)%m)==0)
      |                                       ^
      |                                       ;
   53 |             dp[v][0]=(dp[v][0]/(y+1))%m;
      |             ~~                         
a.cc:54:13: error: expected primary-expression before 'else'
   54 |             else
      |             ^~~~
a.cc:53:41: error: expected ')' before 'else'
   53 |             dp[v][0]=(dp[v][0]/(y+1))%m;
      |                                         ^
      |                                         )
   54 |             else
      |             ~~~~                         
a.cc:52:15: note: to match this '('
   52 |             if((dp[v][0]%((y+1)%m)==0)
      |               ^
Language: Java

import java.util.*;
import java.io.*;

public class Main
{
  	int n;
  	long mod;
  	int[][] sz;
  	long[] ans;
  	ArrayList[] G;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      mod = in.nextLong();
      G = new ArrayList[n];
      for (int i = 0; i < n; i++)
        G[i] = new ArrayList<>();
      for (int i = 0; i < n; i++)
      {
        int u = in.nextInt();
        int v = in.nextInt();
        G[u].add(v); G[v].add(u);
      }
      
      sz = new int[n];
      for (int i = 0; i < n; i++)
        sz[i] = new int[G[i].size()];
      dfs(0, 0);
      ans = new long[n];
      Arrays.fill(ans, 1L);
      for (int i = 0; i < n; i++)
        for (int j = 0; j < sz[i].length; j++)
        {
          ans *= (1+sz[i][j]);
          ans %= mod;
        }
      for (int i : ans)
        out.println(i);
    }
  
  	int dfs(int at, int p)
    {
      int e = 0;
      for (int to : G[at])
      {
        if (to == p) continue;
        sz[at][e++] += dfs(to, at);
      }
      
      sz[at][e] = n-1;
      for (int i = e; i >=0; i--)
        sz[at][e] -= sz[at][i];
      
      return 1;
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}

Compiler output:
Main.java:26: error: incompatible types: int[] cannot be converted to int[][]
      sz = new int[n];
           ^
Main.java:35: error: bad operand types for binary operator '*'
          ans *= (1+sz[i][j]);
              ^
  first type:  long[]
  second type: int
Main.java:36: error: bad operand types for binary operator '%'
          ans %= mod;
              ^
  first type:  long[]
  second type: long
Main.java:38: error: incompatible types: possible lossy conversion from long to int
      for (int i : ans)
                   ^
Main.java:45: error: incompatible types: Object cannot be converted to int
      for (int to : G[at])
                     ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int n; 
ll m;
vector<int> graph[100001];
ll dp[100001][100001];
ll ans[100001];
ll pi[100001];

ll dfs(int v, int p=-1) {
    ll ret = 1LL;
    for(int i=0;i<graph[v].size();++i) {
        int u = graph[v][i];
        if(u == p) {
            pi[v] = i;
            continue;
        }
        dp[v][i] = dfs(u, v);
        ret *= dp[v][i] + 1LL;
        ret %= m;
    }
    return ret;
}

void bfs(int v, ll res_p=0, int p=-1) {
    if(p != -1) {
        dp[v][pi[v]] = res_p;
    }
    vector<ll> dpl(graph[v].size()+1, 1LL);
    for(int i=0;i<graph[v].size();++i) {
        dpl[i+1] = dpl[i] * (dp[v][i]+1LL) % m;
    }
    vector<ll> dpr(graph[v].size()+1, 1LL);
    for(int i=graph[v].size()-1;i>=0;--i) {
        dpr[i] = dpr[i+1] * (dp[v][i]+1LL) % m;
    }
    ans[v] = dpr[0];
    for(int i=0;i<graph[v].size();++i) {
        int u = graph[v][i];
        if(u == p) continue;
        bfs(u, dpl[i]*dpr[i+1]%m, v);
    }
}

int main() {
    cin >> n >> m;
    int a, b;
    for(int i=0;i<n-1;++i) {
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(0);
    bfs(0);

    for(int i=0;i<n;++i) {
        cout << ans[i] << endl;
    }
}

Compiler output:
/tmp/cctqTjrY.o: in function `dfs(int, int)':
a.cc:(.text+0x73): relocation truncated to fit: R_X86_64_PC32 against symbol `pi' defined in .bss section in /tmp/cctqTjrY.o
/tmp/cctqTjrY.o: in function `bfs(int, long long, int)':
a.cc:(.text+0x186): relocation truncated to fit: R_X86_64_PC32 against symbol `pi' defined in .bss section in /tmp/cctqTjrY.o
a.cc:(.text+0x429): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cctqTjrY.o
/tmp/cctqTjrY.o: in function `main':
a.cc:(.text+0x6bb): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cctqTjrY.o
collect2: error: ld returned 1 exit status
Language: C++

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;
    
    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 100005;

int n, m, used[100005];
ll down[N], up[N];
vector <int> e[N];

void dfsDown(int v);
void dfsUp(int v);

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

	cin >> n >> m;

	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}

    dfsDown(1);
    fill(used, used + N, 0);
    up[1] = 1;
    dfsUp(1);

    for (int i = 1; i <= n; i++)
        cout << down[i] * 1LL * up[i] % m << endl;

    cout << endl << endl;

    return 0;
}

void dfsDown(int v) {
	used[v] = 1;
    down[v] = 1;

	for (auto it : e[v]) {
		if (!used[it]) {
			dfsDown(it);
            down[v] = down[v] * (down[it] + 1) % m;
		}
	}
}

void dfsUp(int v) {
    vector <int> pref(e[v].size() + 2), suff(e[v].size() + 2);
    pref[0] = up[v];
    suff[suff.size() - 1] = 1;
    used[v] = 1;

    for (int i = 0; i < e[v].size(); i++)
        pref[i + 1] = pref[i] * 1LL * (used[e[v][i]] ? 1 : (down[e[v][i]] + 1)) % m;

    for (int i = e[v].size() - 1; i > -1; i--)
        suff[i + 1] = suff[i + 2] * 1LL * (used[e[v][i]] ? 1 : (down[e[v][i]] + 1)) % m;

    for (int i = 0; i < e[v].size(); i++) {
        if (!used[e[v][i]]) {
            up[e[v][i]] = (1 + pref[i] * 1LL * suff[i + 2]) % m;
            dfsUp(e[v][i]);
        }
    }
}

Compiler output:
a.cc: In function 'void modadd(T1&, const T2&)':
a.cc:31:14: error: 'mod' was not declared in this scope; did you mean 'modf'?
   31 |     if (a >= mod)
      |              ^~~
      |              modf
Language: C

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

int dfs(vector< vector<int> > &G, vector<int> &C, int v, int p, int M){
    int ret = 1;
    for(size_t i = 0; i < G[v].size(); ++i){
        int v_ = G[v][i];
        if(v_ == p) continue;
        ret *= dfs(G,C,v_,v,M) + 1;
        ret %= M;
    }
    C[v] = ret;
    return ret;
}

int dfs2(vector< vector<int> > &G, vector<int> &A, vector<int> &C, int v, int p, int M){


int main(){
    int N, M;
    cin >> N >> M;
    vector< vector<int> > G(N);
    for(int i = 0; i < M; ++i){
        int u, v;
        cin >> u >> v;
        --u,--v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<int> C(N,0), A(N,0);
    dfs(G,C,0,-1,M);
    dfs2(G,A,C,0,-1,M);
    for(int i = 0; i < N; ++i){
        cout << A[i] << endl;
    }
}


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

#include <iostream>
#include <vector>
using namespace std;
const long long MAXN = 100100;
const long long MOD = 1e9+7;
vector<long long> v1[MAXN];
    long long n,m;
    long long up[MAXN];
    long long down[MAXN];
    long long pref[MAXN][MAXN];
    long long suff[MAXN][MAXN];
void dfs(long long curr,long long par){
    down[curr] = 1;
    for(auto x:v1[curr]){
        if(x == par){
            continue;
        }
        dfs(x,curr);
        down[curr] *= (down[x]+1);
        down[curr]%=m;
    }
    pref[curr][0] = suff[curr][v1[curr].size()] = 1;
    for(long long i=0;i<v1[curr].size();i++){
        pref[curr][i+1] = pref[curr][i]*(1+down[v1[curr][i]]);
        pref[curr][i+1]%=m;
    }
    for(long long i=v1[curr].size()-1;i>=0;i--){
        suff[curr][i] = suff[curr][i+1]*(1+down[v1[curr][i]]);
        suff[curr][i]%=m;
    }
}
void dfs2(long long curr,long long par){
    
    for(long long i=0;i<v1[curr].size();i++){
        
        long long now = v1[curr][i];
        if(now == par){
            continue;
        }
        up[now] = up[curr] *  (pref[curr][i] * suff[curr][i+1]);
        up[now] +=1;
        up[now] %= m;
        dfs2(now,curr);
    }
}
int main(){

    cin>>n>>m;
    for(long long i=1;i<n;i++){
        long long x,y;
        cin>>x>>y;
        v1[x].push_back(y);
        v1[y].push_back(x);
    }
    up[1] = 1;
    dfs(1,1);
    dfs2(1,1);
    for(long long i=1;i<=n;i++){
       // cout<<up[i]<<" "<<down[i]<<" ";
        cout<<(up[i]*down[i])%m<<endl;
    }
}

Compiler output:
/tmp/ccphddmz.o: in function `dfs(long long, long long)':
a.cc:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
a.cc:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
a.cc:(.text+0x366): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
a.cc:(.text+0x3d3): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
a.cc:(.text+0x3f8): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
a.cc:(.text+0x42c): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
/tmp/ccphddmz.o: in function `dfs2(long long, long long)':
a.cc:(.text+0x505): relocation truncated to fit: R_X86_64_PC32 against symbol `suff' defined in .bss section in /tmp/ccphddmz.o
collect2: error: ld returned 1 exit status
Language: C++

#include <cstdio>
#include <vector>

using namespace std;

const int MAX_N = 100005;

int n,m,easy[MAX_N],res[MAX_N];
vector<int> adjl[MAX_N];
vector<int> pre[MAX_N],suf[MAX_N];

int f(int i, int par)
{
	int p=1;
	for (int x : adjl[i])
		if (x!=par)
			p=(p*1LL*f(x,i))%m;
	pre[i].push_back(1);
	for (int x : adjl[i])
		if (x!=par)
			pre[i].push_back((pre[i].back()*1LL*easy[x])%m);
		else
			pre[i].push_back(pre[i].back());
	suf[i].push_back(1);
	for (int z=adjl[i].size()-1; z>=0; z--)
	{
		int x=adjl[i][z];
		if (x!=par)
			suf[i].push_back((suf[i].back()*1LL*easy[x])%m);
		else
			suf[i].push_back(suf[i].back());
	}
	reverse(suf[i].begin(),suf[i].end());
	return easy[i]=(1+p)%m;
}

void g(int i, int fp, int par)
{
	res[i]=((easy[i]-1+m)*1LL*fp+1)%m;
	for (int z=0; z<adjl[i].size(); z++)
	{
		int x=adjl[i][z];
		if (x!=par)
		{
			int nfp=(fp*1LL*pre[i][z])%m;
			nfp=(nfp*1LL*suf[i][z+1])%m;
			g(x,(1+nfp)%m,i);
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		adjl[a].push_back(b);
		adjl[b].push_back(a);
	}
	f(1,0);
	g(1,1,0);
	for (int i=1; i<=n; i++)
		printf("%d\n",(res[i]-1+m)%m);
	return 0;
}


Compiler output:
a.cc: In function 'int f(int, int)':
a.cc:33:9: error: 'reverse' was not declared in this scope
   33 |         reverse(suf[i].begin(),suf[i].end());
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5+10;

int n, m;
vector<int> graph[maxn];
int dp[maxn];

int dfs1(int pos, int parr) {
	dp[pos] = 1;
	for (int i = 0; i < graph[pos].size(); i++) {
		int tren = graph[pos][i];
		if (tren == parr) continue;
		dp[pos] *= (dfs1(tren) + 1);
	}
	return dp[pos];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	dfs1(1);
	return 0;
}

Compiler output:
a.cc: In function 'int dfs1(int, int)':
a.cc:15:33: error: too few arguments to function 'int dfs1(int, int)'
   15 |                 dp[pos] *= (dfs1(tren) + 1);
      |                             ~~~~^~~~~~
a.cc:10:5: note: declared here
   10 | int dfs1(int pos, int parr) {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:30:13: error: too few arguments to function 'int dfs1(int, int)'
   30 |         dfs1(1);
      |         ~~~~^~~
a.cc:10:5: note: declared here
   10 | int dfs1(int pos, int parr) {
      |     ^~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m, dp[MAXN], reall[MAXN], ans[MAXN];
vector <ll> v[MAXN];
void dfs(ll x, ll p)
{
	dp[x] = 1;
	for(auto i : v[x])
	{
		if(i==p) continue;
		dfs(i, x);
		dp[x] = (dp[x] * (dp[i]+1))%m;
	}
	// cout << x << ' ' << dp[x] << '\n';
	return;
}
ll divi(ll x, ll y)
{
	while(x < y&&x!=0) { x *= m; }
	return x/y;
}
ll gett(ll x, ll p)
{
	ll reall = 1;
	for(auto i : v[x])
	{
		if(i==p) { reall *= (gett(i, x) + 1)%m; reall[x] %= m; continue; }
		reall = (reall * (dp[i]+1))%m;
	}
	return reall%m;
}
void real_calc(ll x, ll p)
{
	reall[x] = 1;
	for(auto i : v[x])
	{
		if(i==p) { reall[x] *= ((gett(i, x) + 1)%m); reall[x] %= m; continue; }
		reall[x] = (reall[x] * (dp[i]+1))%m;
	}
	for(auto i : v[x])
	{
		if(i==p) continue;
		real_calc(i, x); 
	}
	return;
}
int main()
{
  FAST
	cin >> n >> m; // m = LLINF;
	FOR(i,1,n)
	{
		ll a, b;
		cin >> a >> b; 
		// a = i, b = a+1; // cout << a << ' ' << b << '\n';
		v[a].pb(b);
		v[b].pb(a);
	}
	// cout << n << "\n";
	dfs(1, -1);
	real_calc(1, -1);
	FOR(i,1,n+1) cout << reall[i]%m << '\n';
}


Compiler output:
a.cc: In function 'long long int gett(long long int, long long int)':
a.cc:64:62: error: invalid types 'long long int[long long int]' for array subscript
   64 |                 if(i==p) { reall *= (gett(i, x) + 1)%m; reall[x] %= m; continue; }
      |                                                              ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m, dp[MAXN], reall[MAXN], ans[MAXN];
vector <ll> v[MAXN];
void dfs(ll x, ll p)
{
	dp[x] = 1;
	for(auto i : v[x])
	{
		if(i==p) continue;
		dfs(i, x);
		dp[x] = (dp[x] * (dp[i]+1))%m;
	}
	// cout << x << ' ' << dp[x] << '\n';
	return;
}
ll divi(ll x, ll y)
{
	while(x < y&&x!=0) { x *= m; }
	return x/y;
}
ll gett(ll x, ll p)
{
	ll reall = 1;
	for(auto i : v[x])
	{
		if(i==p) { reall *= (gett(i, x) + 1)%m; reall[x] % m; continue; }
		reall = (reall * (dp[i]+1))%m;
	}
	return reall%m;
}
void real_calc(ll x, ll p)
{
	reall[x] = 1;
	for(auto i : v[x])
	{
		if(i==p) { reall[x] *= ((gett(i, x) + 1)%m); reall[x] %= m; continue; }
		reall[x] = (reall[x] * (dp[i]+1))%m;
	}
	for(auto i : v[x])
	{
		if(i==p) continue;
		real_calc(i, x); 
	}
	return;
}
int main()
{
	cin >> n >> m; // m = LLINF;
	FOR(i,1,n)
	{
		ll a, b;
		cin >> a >> b; 
		// a = i, b = a+1; // cout << a << ' ' << b << '\n';
		v[a].pb(b);
		v[b].pb(a);
	}
	// cout << n << "\n";
	dfs(1, -1);
	real_calc(1, -1);
	FOR(i,1,n+1) cout << reall[i]%m << '\n';
}


Compiler output:
a.cc: In function 'long long int gett(long long int, long long int)':
a.cc:64:62: error: invalid types 'long long int[long long int]' for array subscript
   64 |                 if(i==p) { reall *= (gett(i, x) + 1)%m; reall[x] % m; continue; }
      |                                                              ^
Language: C++

# from https://atcoder.jp/contests/dp/submissions/11261467
#include<bits/stdc++.h>

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)
#define rrep1(i,n) for(ll i = (n); i > 0; i--)

#define ll long long
#define pi pair<ll, ll>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct Seg{
  vector<ll> sum;
  vector<ll> mx;
  Seg(){
    sum.resize(1<<19, 0);
    mx.resize(1<<19, 0);
  }

  void add_val(ll l, ll r, ll val, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <=r){
      sum[pos] += val;
      return ;
    }
    if(r<=bottom || l>=top)return ;

    ll mid = (bottom + top)/2;
    add_val(l, r, val, bottom, mid, pos*2);
    add_val(l, r, val, mid, top, pos*2+1);
    mx[pos] = max<ll>(mx[pos*2] + sum[pos*2],  mx[pos*2+1] + sum[pos*2+1]);
  }

  ll max_val(ll l, ll r, ll bottom=0, ll top=1<<18, ll pos=1){
    if(l <= bottom && top <= r) return sum[pos] + mx[pos];
    if(r <= bottom || l>=top)return -INF;

    ll mid = (bottom+top)/2;
    return max<ll>(
      max_val(l, r, bottom, mid, pos*2),
      max_val(l, r, mid, top, pos*2+1)
    )+sum[pos];
  }
};

int main(){
  ll n,m;cin>>n>>m;
  vector<pi> its[n+1];
  rep(i, m){
    ll l,r,a;cin>>l>>r>>a;
    its[r].push_back({l, a});
  }

  Seg seg;
  rep1(i, n){
    ll mx = seg.max_val(0, i);
    seg.add_val(i, i+1, mx);
    for(auto p:its[i]){
      ll l = p.first;
      ll a = p.second;
      seg.add_val(l, i+1, a);
    }
  }

  cout<<seg.max_val(0, n+1)<<endl;
  

  return 0;
}


Compiler output:
a.cc:1:3: error: invalid preprocessing directive #from
    1 | # from https://atcoder.jp/contests/dp/submissions/11261467
      |   ^~~~
Language: C++

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

typedef long long ll;
#define int ll

const int N=2e5+5;
int t[4*N]={0},lazy[4*N]={0};

void push(int node)
{
  for(auto child:{2*node,2*node+1})
  {
    t[child]+=lazy[node];
    lazy[child]+=lazy[node];
  }
  lazy[node]=0;
}

void update(int node, int tl, int tr, int l, int r, int add)
{
  if(l>r)
    return;
  if(tl==l&&tr==r)
  {
    t[node]+=add;
    lazy[node]+=add;
  }
  else
  {
    push(node);
    int tm=(tl+tr)>>1;
    update(2*node,tl,tm,l,min(r,tm),add);
    update(2*node+1,tm+1,tr,max(l,tm+1),r,add);
    t[node]=min(t[2*node],t[2*node+1]);
  }
}

int query(int node, int tl, int tr, int l, int r)
{
  if(l>r)
    return 0;
  if(tl==l&&tr==r)
    return t[node];
  push(node);
  int tm=(tl+tr)>>1;
  return min(query(2*node,tl,tm,l,min(r,tm)),query(2*node+1,tm+1,tr,max(l,tm+1),r));
  
}


int main()
{
  ll n,m,tot=0,l,r,x;
  cin>>n>>m;
  vector<pair<ll,ll>> en[n+1];
  for(int i=0;i<m;i++)
  {
    cin>>l>>r>>x;
    tot+=x;
    en[r].push_back({l,x});
  }
  ll best=tot;
  
  for(int i=1;i<=n+1;i++)
  {
    for(auto p:en[i-1])
    {
      l=p.first;
      x=p.second;
      update(1,0,N-1,0,l-1,x);
    }
    best=query(1,0,N-1,0,i-1);
    update(1,0,N-1,i,i,best);
  }
  cout<<tot-best;
  return 0;
  
}

Compiler output:
a.cc:5:13: error: '::main' must return 'int'
    5 | #define int ll
      |             ^~
a.cc:52:1: note: in expansion of macro 'int'
   52 | int main()
      | ^~~
Language: C++

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

typedef long long ll;
#define int ll

const int N=2e5+5;
int t[4*N]={0},lazy[4*N]={0};

void push(int node)
{
  for(auto child:{2*node,2*node+1})
  {
    t[child]+=lazy[node];
    lazy[child]+=lazy[node];
  }
  lazy[node]=0;
}

void update(int node, int tl, int tr, int l, int r, int add)
{
  if(l>r)
    return;
  if(tl==l&&tr==r)
  {
    t[node]+=add;
    lazy[node]+=add;
  }
  else
  {
    push(node);
    int tm=(tl+tr)>>1;
    update(2*node,tl,tm,l,min(r,tm),add);
    update(2*node+1,tm+1,tr,max(l,tm+1),r,add);
    t[node]=min(t[2*node],t[2*node+1]);
  }
}

int query(int node, int tl, int tr, int l, int r)
{
  if(l>r)
    return 0;
  if(tl==l&&tr==r)
    return t[node];
  push(node);
  int tm=(tl+tr)>>1;
  return min(query(2*node,tl,tm,l,min(r,tm)),query(2*node+1,tm+1,tr,max(l,tm+1),r));
  
}


int main()
{
  ll n,m,tot=0,l,r,x;
  cin>>n>>m;
  vector<pair<ll,ll>> en[n+1];
  for(int i=0;i<m;i++)
  {
    cin>>l>>r>>x;
    tot+=x;
    en[r].push_back({l,x});
  }
  ll best=tot;
  
  for(int i=1;i<=n+1;i++)
  {
    for(auto p:en[i-1])
    {
      l=p.first;
      x=p.second;
      update(1,0,N-1,0,l-1,x);
    }
    best=query(1,0,N-1,0,i-1);
    update(1,0,N-1,i,i,best);
  }
  cout<<tot-best;
  
  
}

Compiler output:
a.cc:5:13: error: '::main' must return 'int'
    5 | #define int ll
      |             ^~
a.cc:52:1: note: in expansion of macro 'int'
   52 | int main()
      | ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e18L+5;
const int nax= 2e5+30;
vector<ll> dp(nax,inf);
vector<ll> tree(4*nax);
vector<ll> lazy(4*nax);
void build(int v,int tl,int tr) 
{
    if(tl>tr) return;
    if(tl==tr)
    {
        tree[v]=dp[tl];
        return;
    }
    int tm=(tl+tr)/2;
    build(2*v,tl,tm);
    build(2*v+1,tm+1,tr);
    tree[v]=min(tree[2*v],tree[2*v+1]);
}
void push(int v)
{
    tree[2*v]+=lazy[v];
    tree[2*v+1]+=lazy[v];
    lazy[2*v]+=lazy[v];
    lazy[2*v+1]+=lazy[v];
    lazy[v]=0;
}
void add(int v,int tl,int tr,int l,int r,int sum)
{
    int tm=(tl+tr)/2;
    if(l>r) return;
    if(tl>=l&&tr<=r)
    {
        lazy[v]+=sum;
        tree[v]+=sum;
        return;

    }
    else
    {
        push(v);
        add(2*v,tl,tm,l,min(tm,r),sum);
        add(2*v+1,tm+1,tr,max(l,tm+1),r,sum);
        tree[v]=min(tree[2*v],tree[2*v+1]);
    }
    

}
ll get_min(int v,int tl,int tr,int l,int r)
{
    if(l>r) return inf;
    if(tl>=l&&tr<=r)
    {
        return tree[v];
    }
    else
    {
        push(v);
        int tm=(tl+tr)/2;
        return(min(get_min(2*v,tl,tm,l,min(tm,r)),get_min(2*v+1,tm+1,tr,max(l,tm+1),r)));
    }
    
}
void update(int v,int tl,int tr,int pos,int val)
{
    if(tl==tr)
    {
        tree[v]=val;
        return;
    }
    int tm=(tl+tr)/2;
     push(v);
    if(pos<=tm)
    {
       
        update(2*v,tl,tm,pos,val);
    }
    else {update(2*v+1,tm+1,tr,pos,val);
    tree[v]=min(tree[2*v],tree[2*v+1]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,ll>  > > vec(n+1);
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        int l,r;ll a;
        cin>>l>>r>>a;
        sum+=a;
        vec[r].push_back({l,a});
    }
    dp[0]=0;
    build(1,0,n+1);
    for(int i=1;i<=n+1;i++)
    {
        for(auto it:vec[i-1])
        {
           // if(it.first>=1)
        //    if(it.first==1)
        //    {
        //        update(1,0,n+1,0,)
        //    }
            add(1,0,n+1,0,it.first-1,it.second);
            // for(int j=1;j<it.first;j++)
            // {
            //     dp[j]+=it.second;
            //     //dp[i]=max(dp[i],dp[j]+)
            // }
        }
        dp[i]=get_min(1,0,n+1,0,i-1);
        update(1,0,n+1,i,dp[i]);



    }
    ll ans=sum-dp[n+1];
   // cout<<tree[0]<<endl;
   // for(auto it=0;it<=n+1;it++) cout<<dp[it]<<" ";
 //   cout<<endl;
    // for(int i=1;i<=n+1;i++)
    // {
    //     ans=min(ans,dp[i]);

    // }

    cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'void update(int, int, int, int, int)':
a.cc:83:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   83 | int main()
      |         ^~
a.cc:83:9: note: remove parentheses to default-initialize a variable
   83 | int main()
      |         ^~
      |         --
a.cc:83:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:84:1: error: a function-definition is not allowed here before '{' token
   84 | {
      | ^
a.cc:132:2: error: expected '}' at end of input
  132 | }
      |  ^
a.cc:67:1: note: to match this '{'
   67 | {
      | ^
Language: C++

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

#include "SegmentTree.h"

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

#if 0
  SegmentTree<i64> st(10);
  F0R(i, 10) {
    st.SetValue(i + 1, i);
  }
  cout << st.GetMax(0, 5) << newl;
  cout << st.GetMax(5, 10) << newl;
  cout << st.GetSum(0, 5) << newl;
  cout << st.GetSum(5, 10) << newl;
  return 0;
#endif

  int N, M;
  cin >> N >> M;

  // i で終わる区間のスコアの和
  //unordered_map<int, int> sumR;

  // sums[i][j] := j で始まり i で終わる区間のスコアの和
  unordered_map<int, unordered_map<int, i64>> sums;

  //vector<int> l(M), r(M), a(M);
  F0R(i, M) {
    int l, r, a;
    cin >> l >> r >> a;
    //l--; r--;

    //sumR[r] += a;
    sums[r][l] += a;
    //debug(sums[r][l]);
  }

  // n 文字目まで処理するとき、スコアはn文字までに終わる区間のもののみ考える
  // dp[i][j] = i文字目まで決めたとき、最後の1がj文字目のときの最大スコア
  // dp[i-1][j] + j を含み i で終わる区間のスコアの和 (j < i)
  // max(dp[i-1][0] ~ dp[i-1][j]) + i で終わる区間のスコアの和 (j == i)

  // dp[i]だけ持てばいい。
  // j を含み i で終わる区間のスコアの和 = [j ~ i, i] のスコアの和

  vector<i64> dp(N + 1);
  
  FOR(i, 1, N + 1) {
    i64 max = 0, sum = 0;
    FOR(j, 1, i) {
      //debug(sums[i][j]);

      if (sums.find(i) != sums.end() && sums[i].find(j) != sums[i].end())
        sum += sums[i][j];
      chmax(max, dp[j]);
      dp[j] += sum;
    }
    //debug(sums[i][i]);
    dp[i] = max + sum;

    if (sums.find(i) != sums.end() && sums[i].find(i) != sums[i].end())
      dp[i] += sums[i][i];

    //Print(dp);
  }
  i64 result = 0;
  F0R(i, N + 1) {
    chmax(result, dp[i]);
  }
  cout << result;
}
#endif


Compiler output:
a.cc:34:10: fatal error: SegmentTree.h: No such file or directory
   34 | #include "SegmentTree.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;
static const int MAX_SIZE = 1 << 18;
typedef long long Int;

Int segMax[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];

void add(int a, int b, int x, int k = 0, int l = 0, int r = MAX_SIZE)
{
	if (r <= a || b <= l) return;
	
	if (a <= l && r <= b) {
		segAdd[k] += x;
		return;
	}
	
	add(a, b, x, k * 2 + 1, l, (l + r) / 2);
	add(a, b, x, k * 2 + 2, (l + r) / 2, r);

	segMax[k] = max(segMax[k * 2 + 1] + segAdd[k * 2 + 1], segMax[k * 2 + 2] + segAdd[k * 2 + 2]);
}

Int getMax(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
	if (r <= a || b <= l) return (LLONG_MIN);
	
	if (a <= l && r <= b) return (segMax[k] + segAdd[k]);
	
	Int left = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
	Int right = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
  
	return (max(left, right) + segAdd[k]);
}

int main()
{
  int n, m;
  
  scanf("%d %d", &n, &m);
  
  vector< pair<pair<int, int>, int> > v;
  
  long long tot = 0;
  for (int i = 0; i < m; i++) {
    int l, r, a;
    scanf("%d %d %d", &l, &r, &a);
    tot += a;
    v.push_back(make_pair(make_pair(r, l), a));
  }
  sort(v.begin(), v.end());
  int p = 0;
  
  for (int i = 1; i <= n; i++) {
    add(i, i + 1, getMax(0, i));
    while (p < m && v[p].first.first == i) {
      add(0, v[p].first.second, -v[p].second);
      p++;
    }
    white[i] = getMax(0, i);
  }
  
  printf("%lld\n", tot + getMax(0, n + 1));
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:5: error: 'white' was not declared in this scope; did you mean 'write'?
   60 |     white[i] = getMax(0, i);
      |     ^~~~~
      |     write
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;

struct Line {
    ll a, b;
    ll value(ll x){
        return a * x + b;
    }
    pair<ll, ll> inter(const Line& he) const {
        ll one = he.b - b;
        ll two = a - he.a;
        if(two < 0){
            one *= -1;
            two *= -1;
        }
        return {one, two};
    }
};

ll square(ll a){
    return a * a;
}


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    int n;
    ll C;
    cin >> n >> C;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    
    vector<Line> lines;
    int start = 0;
    for(int i = 0; i < n; i++){
        
        while(start <= (int) lines.size() - 2){
            Line A = lines[start];
            Line B = lines[start + 1];
            if(A.value(h[i]) >= B.value(h[i])){
                start++;
            }
            else{
                break;
            }
        }
        ll best = 0; //dp[i]
        if(i != 0){
            best = lines[start].value(h[i]) + square(h[i]) + C;
        }
        Line line{-2 * h[i], best + square(h[i])};
        
        while(start <= (int) lines.size() - 2){
            Line A = lines.end()[-2];
            Line B = lines.end()[-1];
            pair<ll, ll> one = A.inter(B);
            pair<ll, ll> two = B.inter(line);
            
            if((_int128) one.first * two.second >= (_int128) one.second * two.first){
                lines.pop_back();
            }
            else{
                break;
            }
        }
        lines.push_back(line);
        if(i == n - 1){
            cout << best;
        }
    }
    
    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:72:17: error: '_int128' was not declared in this scope; did you mean '__int128'?
   72 |             if((_int128) one.first * two.second >= (_int128) one.second * two.first){
      |                 ^~~~~~~
      |                 __int128
a.cc:72:25: error: expected ')' before 'one'
   72 |             if((_int128) one.first * two.second >= (_int128) one.second * two.first){
      |               ~         ^~~~
      |                         )
Language: C++

#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;


int n, m, dp[maxn], s, ans = inf * inf;
vpii g[maxn], gr[maxn];
int t[4 * maxn], lz[4 * maxn];
void push(int v, int tl, int tr){
	if(!lz[v]) return;
	t[v] += lz[v];
	if(tl != tr)
		lz[v + v] += lz[v], lz[v + v + 1] += lz[v];
	lz[v] = 0;
}
void upd(int l, int r, int x, int v = 1, int tl = 0, int tr = n){
	push(v, tl, tr);
	if(l > r || tr < l || tl > r)
		return;
	if(l <= tl && tr <= r){
		lz[v] += x;
		push(v, tl, tr);
		return;
	}
	int tm = (tl + tr) >> 1;
	upd(l, r, x, v + v, tl, tm);
	upd(l, r, x, v + v + 1, tm + 1, tr);
	t[v] = min(t[v + v], t[v + v + 1]);
}                        
int get(int l, int r, int v = 1, int tl = 0, int tr = n){
	push(v, tl, tr);
	if(l > r || tr < l || tl > r)
		return inf * inf;
	if(l <= tl && tr <= r){
		return t[v];
	}
	int tm = (tl + tr) >> 1;
	return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
}
main () {
	cin >> n >> m;
	forn(i, 1, m){
		int l, r, a;
		cin >> l >> r >> a;
		s += a;
		g[r].pb(mp(l, a));
	}
	forn(i, 1, n)
		upd(i, inf * inf);
	forn(i, 1, n + 1){
		for(auto x : g[i - 1]){
			upd(0, x.f - 1, x.s);
		}
		dp[i] = get(0, i - 1);
		upd(i, i, dp[i]);
		ans = min(ans, dp[i]);
	}
	cout << s - ans;
}

Compiler output:
a.cc:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main () {
      | ^~~~
a.cc: In function 'int main()':
a.cc:76:20: error: too few arguments to function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)'
   76 |                 upd(i, inf * inf);
      |                 ~~~^~~~~~~~~~~~~~
a.cc:43:6: note: declared here
   43 | void upd(int l, int r, int x, int v = 1, int tl = 0, int tr = n){
      |      ^~~