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

#include<iostream>
using namespace std;
int main(){
    int n,d[300000],x=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>d[i];
        if(d[i]<10)x=1,break;
        else if(d[i]>=20)i=i+d[i]/10-1;
    }
    for(int i=n;i>=1;i--){
        if(d[i]<10)x=1,break;
        else if(d[i]>=20)i=i-d[i]/10+1;
    }
    if(x==1)cout<<"no"<<endl;
    else cout<<"yes"<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:24: error: expected primary-expression before 'break'
    8 |         if(d[i]<10)x=1,break;
      |                        ^~~~~
a.cc:12:24: error: expected primary-expression before 'break'
   12 |         if(d[i]<10)x=1,break;
      |                        ^~~~~
Language: C++

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

int main(){
  int N;
  cin >> N;

  int d[300000];
  for(int i=0; i<N; i++){
    cin >> d[i];
  }

  int D = 0;

  for(int i=0; i<N-1; i++){
    D = max(D, d[i]);

    if(D<10){
      cout << "no" << endl;
      return 0;
    }
    D -= 10;
  }

  D = 0;
  for(int i=N-1; i>0; i--){
    D = max(D, d[i]);

    if(D<10){
      cout << "no" << endl;
      return 0;
    }
    D -= 10;
  }
  cout << "yes" << endl;
  return 0;
}



Compiler output:
a.cc:2:9: fatal error: algolithm: No such file or directory
    2 | #include<algolithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int d[300000];

int main(){
	int n,m=1;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	for(int i=1;i<=n;i++){
		if(m < i){
			cout << "no" << endl;
			return 0;
		}
		if(d[i]>=10){
			m=max(i+d[i]/10,m);
		}
	}
	if(m>=i){
		for(int i=n;i>0;i--){
		if(m > i){
			cout << "no" << endl;
			return 0;
		}
		if(d[i]>=10){
			m=min(i-d[i]/10,m);
		}
	}
	}
	cout << "yes" << endl;


	return 0;

}




Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: 'i' was not declared in this scope
   19 |         if(m>=i){
      |               ^
Language: C++

#include <iostream>
using namespace std;

int d[300000];

int main(){
	int n,m=1;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	for(int i=1;i<=n;i++){
		if(m < i){
			cout << "no" << endl;
			return 0;
		}
		if(d[i]>=10){
			m=max(i+d[i]/10,m);
		}
	}
	//d[i]を反転させる処理
	for(int i=1;i<=n/2;i++)swap(d[i],d[n+1-i];
	m = 1;
	for(int i=1;i<=n;i++){
		if(m < i){
			cout << "no" << endl;
			return 0;
		}
		if(d[i]>=10){
			m=max(i+d[i]/10,m);
		}
	}
	
	cout << "yes" << endl;


	return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:50: error: expected ')' before ';' token
   20 |         for(int i=1;i<=n/2;i++)swap(d[i],d[n+1-i];
      |                                    ~             ^
      |                                                  )
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,S,d[20005];
    cin>>N;
    for (int i=0;i<N;i++){
        cin>>d[i];
    }
    int  a;
   for(int i=0;i<N;i++){
       for(a=1;a<i;a++){
       }
       
           
       }
       if(d[i]>=10){
           S=1;
       }else if(d[i-a]>=10*(a+1)){
           S=1;
       }else{
           S=0;
       
       
   }
   if(d[0]>=10&&S*N==N&&d[N-1]>=10){
        cout<<"yes"<<endl;
   }else{
       cout<<"no"<<endl;
   }
       
       
       
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'i' was not declared in this scope
   17 |        if(d[i]>=10){
      |             ^
Language: Java

import java.util.Scanner;
import java.util.stream.IntStream;

public class Solution{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int h=getInt();
		boolean[][]f=new boolean[h][4];
		for(int n=getInt();n>0;--n) {
			int x=getInt(),y=getInt();
			f[y][x]=true;
		}
		//Arrays.stream(f).map(Arrays::toString).forEach(System.err::println);
		/*
		for(int i=0;i<h;++i)
			for(int j=1;j<4;++j)
				if(f[i][j]!=-1)
					f[i][j]=f[i][j-1]+1;
		*/
		int c=0;
		for(int i=1;i<h;++i) {
			for(int j=1;j<4;++j) {
				if(!(f[i-1][j-1]||f[i-1][j]||f[i][j-1]||f[i][j])) {
					f[i][j]=true;
					++c;
				}
			}
		}
		System.out.println(c);
		//Arrays.stream(f).map(Arrays::toString).forEach(System.err::println);
	}
}

Compiler output:
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java
public class Solution{
       ^
1 error
Language: C++

#include <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];
main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
std::fill( next, next+(1<<4), -1 );
for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {//既に有るものパターン(current)
 if ( crt[obstacle] == -1 ) continue;
 for ( int k=0; k<5; ++k ) {//置き方パターン(next)
int check0 = blocked[i] & locate[k];
int check1 = blocked[i+1] & locate[k];
if ( !check0 && !check1 && !(obstacle&locate[k])) {
 int patt = blocked[i+1] | locate[k];
 next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
}
 }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}


Compiler output:
a.cc:9:7: error: extended character “ is not valid in an identifier
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |       ^
a.cc:9:12: error: extended character ” is not valid in an identifier
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |            ^
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:9:7: error: '\U0000201c' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |       ^
a.cc:9:9: error: 'd' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |         ^
a.cc:9:12: error: 'd\U0000201d' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |            ^~
a.cc:23:6: error: 'fill' is not a member of 'std'
   23 | std::fill( next, next+(1<<4), -1 );
      |      ^~~~
a.cc:31:20: error: 'max' is not a member of 'std'
   31 |  next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
      |                    ^~~
Language: C++

#include <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];
main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
std::fill( next, next+(1<<4), -1 );
for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {//既に有るものパターン(current)
 if ( crt[obstacle] == -1 ) continue;
 for ( int k=0; k<5; ++k ) {//置き方パターン(next)
int check0 = blocked[i] & locate[k];
int check1 = blocked[i+1] & locate[k];
if ( !check0 && !check1 && !(obstacle&locate[k])) {
 int patt = blocked[i+1] | locate[k];
 next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
}
 }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}



Compiler output:
a.cc:9:7: error: extended character “ is not valid in an identifier
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |       ^
a.cc:9:12: error: extended character ” is not valid in an identifier
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |            ^
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:9:7: error: '\U0000201c' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |       ^
a.cc:9:9: error: 'd' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |         ^
a.cc:9:12: error: 'd\U0000201d' was not declared in this scope
    9 | scanf(“%d %d”, &x, &y); blocked[y] |= 1<<x;
      |            ^~
a.cc:23:6: error: 'fill' is not a member of 'std'
   23 | std::fill( next, next+(1<<4), -1 );
      |      ^~~~
a.cc:31:20: error: 'max' is not a member of 'std'
   31 |  next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
      |                    ^~~
Language: C++

#include <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];
main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
scanf("%d %d", &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
std::fill( next, next+(1<<4), -1 );
for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {//既に有るものパターン(current)
 if ( crt[obstacle] == -1 ) continue;
 for ( int k=0; k<5; ++k ) {//置き方パターン(next)
int check0 = blocked[i] & locate[k];
int check1 = blocked[i+1] & locate[k];
if ( !check0 && !check1 && !(obstacle&locate[k])) {
 int patt = blocked[i+1] | locate[k];
 next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
}
 }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}



Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:23:6: error: 'fill' is not a member of 'std'
   23 | std::fill( next, next+(1<<4), -1 );
      |      ^~~~
a.cc:31:20: error: 'max' is not a member of 'std'
   31 |  next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
      |                    ^~~
Language: C++

#include <stdio.h>
#define MAX_H 100000
int blocked[MAX_H];
int dp[2][1<<4];

main() {
 int h, n; scanf("%d %d", &h, &n);
 int x, y;
 for ( int i=0; i<n; ++i ) {
  scanf("%d %d", &x, &y); blocked[y] |= 1<<x;
 }
 int locate[5] = { 0x0, 0x3, 0x6, 0xc, 0xf };//置き方パターン
 int add[5] = { 0, 1, 1, 1, 2 };//各置き方パターンで置ける個数

 int* crt = dp[0];
 int* next = dp[1];

 for ( int obstacle=0; obstacle<1<<4; ++obstacle ) {
if ( obstacle&blocked[0] ) crt[obstacle] = -1;
else crt[obstacle] = 0;
 }

 for ( int i=0; i<h-1; ++i ) {
  std::fill( next, next+(1<<4), -1 );
   for ( int obstacle=0; obstacle<1<<4; ++obstacle ) { //既に有るものパターン(current)
     if ( crt[obstacle] == -1 ) continue;
     for ( int k=0; k<5; ++k ) { //置き方パターン(next)
      int check0 = blocked[i] & locate[k];
      int check1 = blocked[i+1] & locate[k];
     if ( !check0 && !check1 && !(obstacle&locate[k])) {
      int patt = blocked[i+1] | locate[k];
      next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
   }
  }
}
int* tmp = crt;
crt = next;
next = tmp;
 }
 int res = 0;
 for ( int i=0; i<1<<4; ++i ) if ( next[i] > res ) res = next[i];
 printf("%d¥n", res );
}



Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:24:8: error: 'fill' is not a member of 'std'
   24 |   std::fill( next, next+(1<<4), -1 );
      |        ^~~~
a.cc:32:25: error: 'max' is not a member of 'std'
   32 |       next[patt] = std::max( crt[obstacle] + add[k], next[patt] );
      |                         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int W, H, N;
    int ymax[100005] = {};

    cin >> W >> H >> N;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        ymax[x] = max(ymax[x], y);
    }
    
    int minv = 1 << 28;
    int mm = 0;
    for(int i = W - 1; i >= 0; i--) {
        minv = min(i + mm, minv);
        mm = max(ymax[i]);
    }

    cout << minv << endl;
    return (0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: no matching function for call to 'max(int&)'
   19 |         mm = max(ymax[i]);
      |              ~~~^~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:19:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |         mm = max(ymax[i]);
      |              ~~~^~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
Language: C++

#include <iostream>
using namespace std;

int xmax[100005];
int main(){
  int w, h, n;
  cin >> w >> h >> n;
  fill(xmax, xmax+h+1, 0);
  for(int i=0; i<n; i++) {    int x, y;
    cin >> x >> y;
    xmax[y]=max(xmax[y], x);
  }
  for(int i=h-2; i>=0; i--){
    xmax[i]=max(xmax[i], xmax[i+1]);
  }
  int ans=INT_MAX;
  for(int i=0; i<h; i++){
    ans=min(ans, i+xmax[i+1]);
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: 'INT_MAX' was not declared in this scope
   16 |   int ans=INT_MAX;
      |           ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int w, h, n;
int seg[131072*2 - 1];
int N;


int p(int i){
	return (int)((i-1) / 2);
}


void update(int i){
	if(i == 0) return;
	if(seg[p(i)] >= seg[i]) return;
	seg[p(i)] = seg[i];
	update(p(i));
}


void init(){
	rep(i, N-1, h+N-1) update(i);
}


int qmax(int a, int b, int k = 0, int l = 0, int r = N){
	if(r <= a || b <= l) return -1;
	if(a <= l && r <= b) return seg[k];

	int vl = qmax(a, b, 2*k+1, l, (l+r)/2);
	int vr = qmax(a, b, 2*k+2, (l+r)/2, r);
	return max(vl, vr);
}


int solve(){
	int c = INT_MAX;
	rep(i, 0, h-1){
		c = min(c, i+qmax(i+1, h));
	}
	c = min(c, h);
	return c;
}


int main(){
	cin >> w >> h >> n;
	N = (int)pow(2, (int)ceil(log2(h)));
	
	rep(i, 0, n){
		int x, y;
		cin >> x >> y;
		seg[y+N-1] = max(seg[y+N-1], x);
	}
	
	init();
	
	cout << solve() << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:42:17: error: 'INT_MAX' was not declared in this scope
   42 |         int c = INT_MAX;
      |                 ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cmath>
  +++ |+#include <climits>
    4 | #define rep(i, a, n) for(int i = a;i < n;i++)
Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int wh[100001] = {};

int main(void) {
	int w, h, n;
	cin >> w >> h >> n;
	int at_most_w=0,at_most_h=0;
	for (int i = 0; i<n; i++) {
		int x, y; 
		scanf("%d%d",&x,&y);
		wh[y] = max(wh[y], x);
		at_most_w=max(x,at_most_w);at_most_h=max(y,at_most_h);
	}
	
	int x_position, y_position, MIN;
    MIN = wh[h - 1] + (h - 1);
    x_position = wh[h - 1];
    y_position = h - 1;
	
	for (int i = 0; i<h - 1; i++) {
		y_position--;
		int a = x_position, b = y_position;
		MIN = min(MIN, a+b);
		
		if (a < wh[b]) {
			x_position = wh[y_position];
			int a = x_position, b = y_position;
			
			MIN = min(MIN, a+b);
		}
	}
		
	cout << #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int wh[100001] = {};

int main(void) {
	int w, h, n;
	cin >> w >> h >> n;
	int at_most_w=0,at_most_h=0;
	for (int i = 0; i<n; i++) {
		int x, y; 
		scanf("%d%d",&x,&y);
		wh[y] = max(wh[y], x);
		at_most_w=max(x,at_most_w);at_most_h=max(y,at_most_h);
	}
	
	int x_position, y_position, MIN;
    MIN = wh[h - 1] + (h - 1);
    x_position = wh[h - 1];
    y_position = h - 1;
	
	for (int i = 0; i<h - 1; i++) {
		y_position--;
		int a = x_position, b = y_position;
		MIN = min(MIN, a+b);
		
		if (a < wh[b]) {
			x_position = wh[y_position];
			int a = x_position, b = y_position;
			
			MIN = min(MIN, a+b);
		}
	}
		
	cout << min(MIN,min(at_most_w,at_most_h)) << endl;

	return 0;
}


Compiler output:
a.cc:37:17: error: stray '#' in program
   37 |         cout << #include <iostream>
      |                 ^
a.cc: In function 'int main()':
a.cc:37:18: error: 'include' was not declared in this scope
   37 |         cout << #include <iostream>
      |                  ^~~~~~~
a.cc:37:35: error: expected primary-expression before '>' token
   37 |         cout << #include <iostream>
      |                                   ^
a.cc:40:1: error: expected primary-expression before 'using'
   40 | using namespace std;
      | ^~~~~
a.cc:44:16: error: a function-definition is not allowed here before '{' token
   44 | int main(void) {
      |                ^
a.cc:76:2: error: expected '}' at end of input
   76 | }
      |  ^
a.cc:8:16: note: to match this '{'
    8 | int main(void) {
      |                ^
Language: C++

#include <iostream>
using namespace std;

int bit[200005];
void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

char str[200005];
int nxt[26];
int main(){
  int k;
  cin >> str >> k;
  fill(bit, bit+200005, 0);
  for(int i=0; i<n; i++) add(i, 1);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<26; i++){
    while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
  }
  int n=strlen(str);
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      int cnt=sum(nxt[j]-1);
      if(cnt<=k){
        cnt-=k;
        add(nxt[j]);
        cout << ('a'+j);
        while(nxt[j]<n && str[nxt[j]]!='a'+i) nxt[j]++;
        break;
      }
    }
  }
  cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:18: error: 'n' was not declared in this scope
   28 |   for(int i=0; i<n; i++) add(i, 1);
      |                  ^
a.cc:31:18: error: 'n' was not declared in this scope
   31 |     while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
      |                  ^
a.cc:33:9: error: 'strlen' was not declared in this scope
   33 |   int n=strlen(str);
      |         ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:39:12: error: too few arguments to function 'void add(int, int)'
   39 |         add(nxt[j]);
      |         ~~~^~~~~~~~
a.cc:5:6: note: declared here
    5 | void add(int i, int x){
      |      ^~~
Language: C++

#include <iostream>
using namespace std;

int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

string str;
int nxt[26];
void gonext(int i){
  while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
}
int main(){
  int k;
  cin >> str >> k;
  int n=str.length();
  fill(bit, bit+200005, 0);
  for(int i=0; i<n; i++) add(i, 1);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<26; i++) gonext(i);
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==n) continue;
      int cnt=sum(nxt[j]-1);
      if(cnt<=k){
        k-=cnt;
        add(nxt[j], -1);
        cout << (char)('a'+j);
        nxt[j]++;
        gonext(j);
        break;
      }
    }
  }
  cout << endl;
}

Compiler output:
a.cc: In function 'void gonext(int)':
a.cc:25:16: error: 'n' was not declared in this scope
   25 |   while(nxt[i]<n && str[nxt[i]]!='a'+i) nxt[i]++;
      |                ^
Language: C++

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

int n, k;
string str;
int nxt[26];
vector<int> v[26];
int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

void gonext(int i){
  
}
int main(){
  cin >> str >> k;
  n=str.length();
  fill(bit, bit+200005, 0);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<n; i++){
    add(i, 1);
    v[str[i]-'a'].push_back(i);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==v[j].size()) continue;
      int cnt=sum(v[nxt[j]]-1);
      if(cnt<=k){
        k-=cnt;
        add(v[nxt[j]], -1);
        cout << (char)('a'+j);
        if(nxt[j]<v[j].size()) nxt[j]++;
        break;
      }
    }
  }
  cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:28: error: no match for 'operator-' (operand types are 'std::vector<int>' and 'int')
   42 |       int cnt=sum(v[nxt[j]]-1);
      |                   ~~~~~~~~~^~
      |                           | |
      |                           | int
      |                           std::vector<int>
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:42:29: note:   'std::vector<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   42 |       int cnt=sum(v[nxt[j]]-1);
      |                             ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:42:29: note:   'std::vector<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   42 |       int cnt=sum(v[nxt[j]]-1);
      |                             ^
a.cc:45:21: error: cannot convert 'std::vector<int>' to 'int'
   45 |         add(v[nxt[j]], -1);
      |             ~~~~~~~~^
      |                     |
      |                     std::vector<int>
a.cc:10:21: note:   initializing argument 1 of 'void add(int, int)'
   10 | inline void add(int i, int x){
      |                 ~~~~^
Language: C++

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

int n, k;
string str;
int nxt[26];
vector<int> v[26];
int bit[200005];
inline void add(int i, int x){
  i++;
  while(i<200005){
    bit[i]+=x;
    i+=i&-i;
  }
}
inline int sum(int i){
  i++;
  int ret=0;
  while(i){
    ret+=bit[i];
    i-=i&-i;
  }
  return ret;
}

void gonext(int i){
  
}
int main(){
  cin >> str >> k;
  n=str.length();
  fill(bit, bit+200005, 0);
  fill(nxt, nxt+26, 0);
  for(int i=0; i<n; i++){
    add(i, 1);
    v[str[i]-'a'].push_back(i);
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      if(nxt[j]==v[j].size()) continue;
      int cnt=sum(v[j][nxt[j]]-1);
      if(cnt<=k){
        k-=cnt;
        add(v[nxt[j]], -1);
        cout << (char)('a'+j);
        if(nxt[j]<v[j].size()) nxt[j]++;
        break;
      }
    }
  }
  cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:21: error: cannot convert 'std::vector<int>' to 'int'
   45 |         add(v[nxt[j]], -1);
      |             ~~~~~~~~^
      |                     |
      |                     std::vector<int>
a.cc:10:21: note:   initializing argument 1 of 'void add(int, int)'
   10 | inline void add(int i, int x){
      |                 ~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
struct BinaryIndexedTree {
  BinaryIndexedTree(int n) : n(n + 1), v(n + 2, 0), r(1 << (31 - __builtin_clz(n + 1))) {}

  vector<int> v;
  int n, r;

  int sum(int i) {
    int ret = 0;
    for (++i; i; i -= i & -i) res += v[i];
    return ret;
  }

  void add(int i, int x) {
    for (++i; i <= n; i += i & -1) v[i] += x;
  }

  int lower_bound(int w) {
    int idx = 0;
    for (int k = r; k > 0; k /= 2) {
      if (idx + k <= n && v[idx + k] < w) {
        w -= v[idx + k];
        idx += k;
      }
    }

    return idx;
  }
};

 
struct segtree {
  segtree() {}
  segtree(int n, vector<char> v) : n(n) { init(v); }
  
  pair<char, int> id = make_pair('{', -1);
  int n;
  vector<pair<char, int>> node;
  
  void init(vector<char> v) {
    int n_ = n;
    n = 1;
    while (n < n_)
      n *= 2;
  
    node.assign(2 * n - 1, id);
    for (int i = 0; i < v.size(); ++i) {
      int idx = i + n - 1;
      node[idx] = make_pair(v[i], i);
    }
    for (int i = n - 2; i >= 0; --i) {
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
  }
  
  pair<char, int> find(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a)
      return id;
    if (a <= l && r <= b)
      return node[k];
  
    return min(find(a, b, 2 * k + 1, l, (l + r) / 2),
               find(a, b, 2 * k + 2, (l + r) / 2, r));
  }
  
  pair<char, int> find(int a, int b) { return find(a, b, 0, 0, n); }
  
  void update(int k) {
    k += n - 1;
    node[k] = id;
    while (k) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }
};
  
int main() {
  string s;
  int k;
  
  cin >> s >> k;
  vector<char> v(s.size());
  for (int i = 0; i < s.size(); ++i)
    v[i] = s[i];
  
  BinaryIndexedTree bit(s.size());
  segtree seg(s.size(), v);
  
  for (int i = 0; i < s.size(); ++i)
    bit.add(i, 1);
  
  string ans;
  for (int i = 0; i < s.size(); ++i) {
    int r = bit.lower_bound(k + 1);
    pair<char, int> c = seg.find(0, r + 1);
    seg.update(c.second);
    bit.add(c.second, -1);
    k -= bit.sum(c.second);
  
    ans.push_back(c.first);
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In member function 'int BinaryIndexedTree::sum(int)':
a.cc:12:31: error: 'res' was not declared in this scope; did you mean 'ret'?
   12 |     for (++i; i; i -= i & -i) res += v[i];
      |                               ^~~
      |                               ret
Language: C++

#include <iostream>
using namespace std;

int n, m;
int s[10005], t[10005];
vector<int> edge[10005], redge[10005];
bool used[10005];
vector<int> ord;
int comp[10005];
int noin[10005], noout[10005];

void dfs1(int a){
  used[a]=true;
  for(int i=0; i<edge.size(); i++){
    int b=edge[a][i];
    if(!used[b]) dfs1(b);
  }
  ord.push_back(a);
}

void dfs2(int a, int c){
  used[a]=true;
  comp[a]=c;
  for(int i=0; i<redge.size(); i++){
    int b=redge[a][i];
    if(!used[b]) dfs2(b);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> s[i] >> t[i];
    edge[s[i]].push_back(t[i]);
    redge[t[i]].push_back(s[i]);
  }
  fill(used, used+n, false);
  for(int i=0; i<n; i++)
    if(!used[i]) dfs1(i);
  int cnt=0;
  fill(used, used+n, false);
  for(int i=n-1; i>=0; i--)
    if(!used[ord[i]]) dfs2(ord[i], cnt++);
  fill(noin, noin+n, 1);
  fill(noout, noout+n, 1);
  for(int i=0; i<m; i++){
    if(comp[s[i]]!=comp[t[i]]){
      noout[s[i]]=0;
      noin[t[i]]=0;
    }
  }
  int ans=0;
  if(cnt>1){
    int noincnt=0, nooutcnt=0;
    for(int i=0; i<cnt; i++) noincnt+=noin[i];
    for(int i=0; i<cnt; i++) nooutcnt+=noout[i]; 
    ans=max(noincnt, nooutcnt);
  }
  cout << ans << endl;
}

Compiler output:
a.cc:6:1: error: 'vector' does not name a type
    6 | vector<int> edge[10005], redge[10005];
      | ^~~~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<int> ord;
      | ^~~~~~
a.cc: In function 'void dfs1(int)':
a.cc:14:18: error: 'edge' was not declared in this scope
   14 |   for(int i=0; i<edge.size(); i++){
      |                  ^~~~
a.cc:18:3: error: 'ord' was not declared in this scope
   18 |   ord.push_back(a);
      |   ^~~
a.cc: In function 'void dfs2(int, int)':
a.cc:24:18: error: 'redge' was not declared in this scope
   24 |   for(int i=0; i<redge.size(); i++){
      |                  ^~~~~
a.cc:26:22: error: too few arguments to function 'void dfs2(int, int)'
   26 |     if(!used[b]) dfs2(b);
      |                  ~~~~^~~
a.cc:21:6: note: declared here
   21 | void dfs2(int a, int c){
      |      ^~~~
a.cc: In function 'int main()':
a.cc:34:5: error: 'edge' was not declared in this scope
   34 |     edge[s[i]].push_back(t[i]);
      |     ^~~~
a.cc:35:5: error: 'redge' was not declared in this scope
   35 |     redge[t[i]].push_back(s[i]);
      |     ^~~~~
a.cc:43:14: error: 'ord' was not declared in this scope
   43 |     if(!used[ord[i]]) dfs2(ord[i], cnt++);
      |              ^~~
Language: C++

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

int n, m;
int s[10005], t[10005];
vector<int> edge[10005], redge[10005];
bool used[10005];
vector<int> ord;
int comp[10005];
int noin[10005], noout[10005];

void dfs1(int a){
  used[a]=true;
  for(int i=0; i<edge.size(); i++){
    int b=edge[a][i];
    if(!used[b]) dfs1(b);
  }
  ord.push_back(a);
}

void dfs2(int a, int c){
  used[a]=true;
  comp[a]=c;
  for(int i=0; i<redge.size(); i++){
    int b=redge[a][i];
    if(!used[b]) dfs2(b);
  }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> s[i] >> t[i];
    edge[s[i]].push_back(t[i]);
    redge[t[i]].push_back(s[i]);
  }
  fill(used, used+n, false);
  for(int i=0; i<n; i++)
    if(!used[i]) dfs1(i);
  int cnt=0;
  fill(used, used+n, false);
  for(int i=n-1; i>=0; i--)
    if(!used[ord[i]]) dfs2(ord[i], cnt++);
  fill(noin, noin+n, 1);
  fill(noout, noout+n, 1);
  for(int i=0; i<m; i++){
    if(comp[s[i]]!=comp[t[i]]){
      noout[s[i]]=0;
      noin[t[i]]=0;
    }
  }
  int ans=0;
  if(cnt>1){
    int noincnt=0, nooutcnt=0;
    for(int i=0; i<cnt; i++) noincnt+=noin[i];
    for(int i=0; i<cnt; i++) nooutcnt+=noout[i]; 
    ans=max(noincnt, nooutcnt);
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'void dfs1(int)':
a.cc:15:23: error: request for member 'size' in 'edge', which is of non-class type 'std::vector<int> [10005]'
   15 |   for(int i=0; i<edge.size(); i++){
      |                       ^~~~
a.cc: In function 'void dfs2(int, int)':
a.cc:25:24: error: request for member 'size' in 'redge', which is of non-class type 'std::vector<int> [10005]'
   25 |   for(int i=0; i<redge.size(); i++){
      |                        ^~~~
a.cc:27:22: error: too few arguments to function 'void dfs2(int, int)'
   27 |     if(!used[b]) dfs2(b);
      |                  ~~~~^~~
a.cc:22:6: note: declared here
   22 | void dfs2(int a, int c){
      |      ^~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

vector<pair<int, ll> > path[100005];
int par[100005];
int dep[100005];
int siz[100005];
ll cst[100005];
int hev[100005];
void dfs(int a){
	siz[a]=1;
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d==par[a]) continue;
		par[d]=a;
		dep[d]=dep[a]+1;
		cst[d]=path[a][i].second;
		dfs(d);
		siz[a]+=siz[d];
		if(!hev[a] || siz[hev[a]]<siz[d])
			hev[a]=d;
	}
}

ll k;
ll add[100005];
ll edgecost(int a){
	ll ret=add[a]+add[par[a]]+cst[a];
	return ret%k?ret:0;
}

int pos[100005];
int hl_par[100005];

ll bit[100005];
void set(int i, ll x){
	x-=sum(i+1)-sum(i);
	i++;
	while(i<100005){
		bit[i]+=x;
		i+=i&-i;
	}
}
ll sum(int i){
	ll ret=0;
	while(i){
		ret+=bit[i];
		i-=i&-i;
	}
	return ret;
}

int lca(int a, int b){
	int p=hl_par[a], q==hl_par[b];
	if(p==q) return dep[a]<dep[b]?a:b;
	if(dep[p]<dep[q]) return lca(par[p], b);
	else return lca(a, par[q]);
}
ll cost(int a){
	ll ret=0;
	while(a){
		int p=hl_par[a];
		ret+=sum(p, a);
		ret+=edgecost(p);
		a=p;
	}
	return ret;
}

int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) hev[i]=0;
	par[0]=dep[0]=cst[0]=0;
	dfs(0);

	for(int i=0; i<n; i++) add[i]=0;

	int cnt=0;
	for(int i=0; i<n; i++) pos[i]=-1;
	for(int i=0; i<n; i++){
		if(pos[i]!=-1) continue;
		int j=i;
		do{
			pos[j]=cnt++;
			hl_par[j]=i;
		}while(j=hev[j]);
	}
	
	for(int i=0; i<100005; i++) bit[i]=0;
	for(int i=0; i<q; i++){
		string s;
		ll a, b;
		cin >> s >> a >> b;
		if(s[0]=='a'){
			add[a]+=b;
			set(pos[a], edgecost(hev[a]));
			if(a) set(pos[a]-1, edgecost(a));
		}else{
			cout << cost(a)+cost(b)-cost(lca(a, b)) << endl;
		}
	}
}

Compiler output:
a.cc: In function 'void set(int, ll)':
a.cc:39:12: error: 'sum' was not declared in this scope
   39 |         x-=sum(i+1)-sum(i);
      |            ^~~
a.cc: In function 'int lca(int, int)':
a.cc:56:27: error: expected initializer before '==' token
   56 |         int p=hl_par[a], q==hl_par[b];
      |                           ^~
a.cc:57:15: error: 'q' was not declared in this scope
   57 |         if(p==q) return dep[a]<dep[b]?a:b;
      |               ^
a.cc:58:23: error: 'q' was not declared in this scope
   58 |         if(dep[p]<dep[q]) return lca(par[p], b);
      |                       ^
a.cc: In function 'll cost(int)':
a.cc:65:25: error: too many arguments to function 'll sum(int)'
   65 |                 ret+=sum(p, a);
      |                      ~~~^~~~~~
a.cc:46:4: note: declared here
   46 | ll sum(int i){
      |    ^~~
a.cc: In function 'int main()':
a.cc:100:24: error: 'q' was not declared in this scope
  100 |         for(int i=0; i<q; i++){
      |                        ^
Language: C++

#include <bits/stdc++.h>
typedef long long L;
using namespace std;
 
#define N 100005
map<L,L> path[N];
L par[N], dep[N], siz[N], hev[N];
L cst[N];
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
   
L k;
L add[N];
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
   
L pos[N];
L hl_par[N];

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++


            pos[a]=c++;
            hl_par[a]=i;

Compiler output:
a.cc:2:13: error: 'pos' does not name a type
    2 |             pos[a]=c++;
      |             ^~~
a.cc:3:13: error: 'hl_par' does not name a type
    3 |             hl_par[a]=i;
      |             ^~~~~~
Language: C++

#include <Bs/stdc++.h>
typedef long long L;
using namespace std;
   
#define U [100005]={}
map<L,L> path U;
L P U,E U,Z U,H U,C U,A U,O U,L U,B U,
k,n,a,b,c,p,r;
char s U;
L D(L a){
    Z[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d-P[a]){
            P[d]=a;
            E[d]=E[a]+1;
            C[d]=I->second;
            D(d);
            Z[a]+=Z[d];
            if(!H[a]|Z[H[a]]<Z[d])
                H[a]=d;
        }
    }
}
     
L G(L a){
    r=A[a]+A[P[a]]+C[a];
    return r%k?r:0;
}
     
L M(L i){
    for(r=0;i;r+=B[i],i-=i&-i);
    return r;
}
L S(L i,L x){
    for(x=G(x)-M(i+1)+M(i++);
        i<100005;B[i]+=x,i+=i&-i);
}
   
main(){
    for(cin>>n>>k;p<n-1;p++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    D(0);
     
    for(c=p=0;p<n;p++)
        if(!p|H[P[p]]-p)
        for(a=p;!c|a;a=H[a])
            O[a]=c++,
            L[a]=p,
            S(O[a],H[a]);
     
    for(cin>>a;cin>>s>>a>>b;)
        if(*s&2){
            for(c=0;p=L[a],n=L[b],p-n;a=P[p])
                E[p]<E[n]?swap(p,n),swap(a,b),0:0,
                c+=M(O[a])-M(O[p])+G(p);
            cout<<c+abs(M(O[a])-M(O[b]))<<endl;
        }else
            A[a]+=b,
            S(O[a],H[a]),
            a?S(O[a]-1,a):0;
}

Compiler output:
a.cc:1:10: fatal error: Bs/stdc++.h: No such file or directory
    1 | #include <Bs/stdc++.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
typedef long long L;
using namespace std;
   
#define U [100005]={}
map<L,L> path U;
L P U,E U,Z U,H U,C U,A U,O U,L U,B U,
k,n,a,b,c,p,r;
char s U;
L D(L a){
    Z[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d-P[a]){
            P[d]=a;
            E[d]=E[a]+1;
            C[d]=I->second;
            D(d);
            Z[a]+=Z[d];
            if(!H[a]|Z[H[a]]<Z[d])
                H[a]=d;
        }
    }
}
     
L G(L a){
    r=A[a]+A[P[a]]+C[a];
    return r%k?r:0;
}
     
L M(L i){
    for(r=0;i;r+=B[i],i-=i&-i);
    return r;
}
L S(L i,L x){
    for(x=G(x)-M(i+1)+M(i++);
        i<100005;B[i]+=x,i+=i&-i);
}
   
main(){
    for(cin>>n>>k;p<n-1;p++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    D(0);
     
    for(c=p=0;p<n;p++)
        if(!p|H[P[p]]-p)
        for(a=p;!c|a;a=H[a])
            O[a]=c++,
            L[a]=p,
            S(O[a],H[a]);
     
    for(cin>>a;cin>>s>>a>>b;)
        if(*s&2){
            for(c=0;p=L[a],n=L[b],p-n;a=P[p])
                E[p]<E[n]?swap(p,n),swap(a,b),0:0,
                c+=M(O[a])-M(O[p])+G(p);
            cout<<c+abs(M(O[a])-M(O[b]))<<endl;
        }else
            A[a]+=b,
            S(O[a],H[a]),
            a?S(O[a]-1,a):0;
}

Compiler output:
a.cc:5:18: error: 'L L [100005]' redeclared as different kind of entity
    5 | #define U [100005]={}
      |                  ^
a.cc:7:33: note: in expansion of macro 'U'
    7 | L P U,E U,Z U,H U,C U,A U,O U,L U,B U,
      |                                 ^
a.cc:2:19: note: previous declaration 'typedef long long int L'
    2 | typedef long long L;
      |                   ^
a.cc: In function 'L D(L)':
a.cc:24:1: warning: no return statement in function returning non-void [-Wreturn-type]
   24 | }
      | ^
a.cc: In function 'L S(L, L)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
a.cc: At global scope:
a.cc:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:50:14: error: expected primary-expression before '[' token
   50 |             L[a]=p,
      |              ^
a.cc:55:24: error: expected primary-expression before '[' token
   55 |             for(c=0;p=L[a],n=L[b],p-n;a=P[p])
      |                        ^
a.cc:55:31: error: expected primary-expression before '[' token
   55 |             for(c=0;p=L[a],n=L[b],p-n;a=P[p])
      |                               ^
Language: C++

#include <Bs/stdc++.h>
typedef long long L;
using namespace std;
   
#define U [100005]={}
map<L,L> path U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,
k,n,a,b,c,p,r;
char s U;
L D(L a){
    Z[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d-P[a]){
            P[d]=a;
            E[d]=E[a]+1;
            C[d]=I->second;
            D(d);
            Z[a]+=Z[d];
            if(!H[a]|Z[H[a]]<Z[d])
                H[a]=d;
        }
    }
}
     
L G(L a){
    r=A[a]+A[P[a]]+C[a];
    return r%k?r:0;
}
     
L M(L i){
    for(r=0;i;r+=B[i],i-=i&-i);
    return r;
}
L S(L i,L x){
    for(x=G(x)-M(i+1)+M(i++);
        i<100005;B[i]+=x,i+=i&-i);
}
   
main(){
    for(cin>>n>>k;p<n-1;p++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    D(0);
     
    for(c=p=0;p<n;p++)
        if(!p|H[P[p]]-p)
        for(a=p;!c|a;a=H[a])
            O[a]=c++,
            X[a]=p,
            S(O[a],H[a]);
     
    for(cin>>a;cin>>s>>a>>b;)
        if(*s&2){
            for(c=0;p=X[a],n=X[b],p-n;a=P[p])
                E[p]<E[n]?swap(p,n),swap(a,b),0:0,
                c+=M(O[a])-M(O[p])+G(p);
            cout<<c+abs(M(O[a])-M(O[b]))<<endl;
        }else
            A[a]+=b,
            S(O[a],H[a]),
            a?S(O[a]-1,a):0;
}

Compiler output:
a.cc:1:10: fatal error: Bs/stdc++.h: No such file or directory
    1 | #include <Bs/stdc++.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Compiler output:
a.cc: In function 'L D(L)':
a.cc:7:95: error: lvalue required as left operand of assignment
    7 |         d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;}
      |                                                                             ~~~~~~~~~~~~~~~~~~^~~~~~
a.cc:7:106: warning: no return statement in function returning non-void [-Wreturn-type]
    7 |         d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]&&H[a]=d:0;}
      |                                                                                                          ^
a.cc: In function 'L S(L, L)':
a.cc:9:59: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
      |                                                           ^
a.cc: At global scope:
a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
      | ^~~~
Language: C++

#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
#define F(x,z)L x(L f){return z;}L y(L
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
F(M,f?B[f]+M(f^f&-f):0,D)
a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S)
x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Compiler output:
a.cc:7:25: error: macro "F" passed 3 arguments, but takes just 2
    7 | F(M,f?B[f]+M(f^f&-f):0,D)
      |                         ^
a.cc:4:9: note: macro "F" defined here
    4 | #define F(x,z)L x(L f){return z;}L y(L
      |         ^
a.cc:10:100: error: macro "F" passed 3 arguments, but takes just 2
   10 | F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S)
      |                                                                                                    ^
a.cc:4:9: note: macro "F" defined here
    4 | #define F(x,z)L x(L f){return z;}L y(L
      |         ^
a.cc:7:1: error: 'F' does not name a type
    7 | F(M,f?B[f]+M(f^f&-f):0,D)
      | ^
a.cc:10:1: error: 'F' does not name a type
   10 | F(K,(a=X[f],n=X[b],a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]))),S)
      | ^
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:13:13: error: 'D' was not declared in this scope
   13 |         for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
      |             ^
a.cc:13:57: error: 'S' was not declared in this scope
   13 |         for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
      |                                                         ^
a.cc:14:44: error: 'K' was not declared in this scope
   14 |         for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
      |                                            ^
a.cc:14:65: error: 'S' was not declared in this scope
   14 |         for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
      |                                                                 ^
Language: C++

#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
               // n++)if(!n|H[P[a=n]]-n)
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Compiler output:
a.cc: In function 'L D(L)':
a.cc:7:107: warning: no return statement in function returning non-void [-Wreturn-type]
    7 |         d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
      |                                                                                                           ^
a.cc: In function 'L S(L, L)':
a.cc:9:59: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}
      |                                                           ^
a.cc: At global scope:
a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:14:37: error: operands to '?:' have different types 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'L' {aka 'long long int'}
   14 |         for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}
      |                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~