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

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  string t="";
  cin>>s;
  int n=s.size();
  int index=0;
  vector<string> ss;
  while(index<n){
    if(s[index]=='A'){
      t += "A";
      index++;
    }else if(index+1<n && s[index]=='B' && s[index+1]=='C'){
      t += "D";
      index += 2;
    }else{
      index++;
      if(t != ""){
        ss.push_back(t);
        t = "";
      }
    }
  }
  int cnt = ss.size();
  long long ans=0;
  long long temp;
  long long en;
  bool flag=false;
  queue<long long> q;
  REP(i,cnt){
    en=ss[i].size()-1;
    for(long long j=en;j>=0;j--){
      if(ss[i][j]=='A'){
        if(!q.empty()){
          ans += q.front()-j;
          q.pop();
        }
      }else{
        q.push(j);
      }
    }
    queue<long long>().swap(q)
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:129:31: error: expected ';' before '}' token
  129 |     queue<long long>().swap(q)
      |                               ^
      |                               ;
  130 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  string t="";
  cin>>s;
  int n=s.size();
  int index=0;
  vector<string> ss;
  while(index<n){
    if(s[index]=='A'){
      t += "A";
      index++;
    }else if(index+1<n && s[index]=='B' && s[index+1]=='C'){
      t += "D";
      index += 2;
    }else{
      index++;
      if(t != ""){
        ss.push_back(t);
        t = "";
      }
    }
  }
  int cnt = ss.size();
  long long ans=0;
  long long temp;
  long long en;
  bool flag=false;
  queue<long long> q;
  REP(i,cnt){
    en=ss[i].size()-1;
    for(long long j=en;j>=0;j--){
      if(ss[i][j]=='A'){
        if(!q.empty){
          ans += q.front()-j;
          q.pop();
        }
      }else{
        q.push(j);
      }
    }
    queue<long long>().swap(q)
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:121:15: error: cannot convert 'std::queue<long long int>::empty' from type 'bool (std::queue<long long int>::)() const' to type 'bool'
  121 |         if(!q.empty){
      |               ^~~~~
a.cc:121:15: error: in argument to unary !
  121 |         if(!q.empty){
      |             ~~^~~~~
a.cc:129:31: error: expected ';' before '}' token
  129 |     queue<long long>().swap(q)
      |                               ^
      |                               ;
  130 |   }
      |   ~
Language: C++

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


string s;

void solve(){
	reverse(s.begin(), s.end());
	char prev = '#';
	int ans = 0;
	int count = 0;

	for(int i=0;i<s.length();i++){
		if(prev == '#'){
			if(s[i] == 'C') prev = 'C';
		}else if(prev == 'C'){
			if(s[i] == 'B'){
				count++; 
				prev = 'B';
			}else{
				count = 0;
				prev = '#';
			}
		}else if(prev == 'B'){
			if(s[i] == 'A'){
				ans += count;
			}else if(s[i] == 'C'){
				prev = 'C';
			}else{
				count = 0;
				prev = '#';
			}
		}
	}

	cout << ans << endl;

}

int main(){
	cin >> s;
	solve();
	return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:9:9: error: 'reverse' was not declared in this scope
    9 |         reverse(s.begin(), s.end());
      |         ^~~~~~~
Language: C++

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

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    int cnt = 1;
    int max = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '.' && s[i+1] == '#'){
            max = max(max, cnt);
            cnt = 1;
        }else if(s[i] == '.' && s[i+1] == '.') cnt++;
        else if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            break;
        }
    }
    if(s[c-1] == '#' || s[d-1] == '#') cout << "No" << endl;
    else if(max <= 2 && c < d) cout << "Yes" << endl;
    else if(max >= 3) cout << "Yes" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: 'max' cannot be used as a function
   13 |             max = max(max, cnt);
      |                   ~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>

int main()
{
    char s[200001];
    scanf("%s", s);

    int i = 0;
    int mode = 2;
    int countA = 0;
    int countBC = 0;
    int sum = 0;
    int len = strlen(s);
    while(i <= len){
        switch(mode){
            case 0: //A
                if(s[i] == 'A'){
                    countA++;
                    i++;
                }
                else mode = 1;
                break;
            case 1: //BC
                if(i < len - 1 && s[i] == 'B' && s[i+1] == 'C'){
                    countBC++;
                    i += 2;
                }
                else{
                    sum += countA * countBC;
                    countBC = 0;
                    if(s[i] == 'A'){
                        mode = 0;
                    }
                    else{
                        countA = 0;
                        mode = 2;
                    }
                }
                break;
            case 2:
                if(s[i] == 'A') mode = 0;
                else i++;
                break;
        }
    }
    printf("%d\n", sum);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'strlen' was not declared in this scope
   14 |     int len = strlen(s);
      |               ^~~~~~
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 | #include <string>
Language: C++

#include <iostream>
using namespace std;

int main()
{
	char s[400000];
	int i=0,c=0;
	cin >> s;

	while(i < strlen(s)
		) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B') {
				if (s[i + 2] == 'C') {
					s[i] = 'B';
					s[i + 1] = 'C';
					s[i + 2] = 'A';
					i = 0;
					c++;
				}
			}
		}
		i++;
	}
	cout << c << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'strlen' was not declared in this scope
   10 |         while(i < strlen(s)
      |                   ^~~~~~
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;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0,cnt=0;
    int flag=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            if(flag)
                cnt++;
            else
            {
                flag=1;
                cnt=1;
            }
        }
        else if(i<n-1 && s[i]=='B' && s[i+1]=='C')
        {
            if(flag)
            {
                ans+=cnt;
                i=i+1;
            }
        }
        else
        {
            flag=0;
        }
    }
    cout<<ans<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:19: error: 'n' was not declared in this scope
   21 |         else if(i<n-1 && s[i]=='B' && s[i+1]=='C')
      |                   ^
Language: C++

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

int main() {
  string S;
  cin >> S;
  
  bool a = false;
  for(int i = 0; i < S.size() - 2; i++){
   if(S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) =='C'){
   a = true;
   }
  }

  int j = 0, shun = 0;
  while(a && j < S.size() - 2){
    
   if(S.at(j) == 'A' && S.at(j + 1) == 'B' && S.at(j + 2) == 'C'){
     S.at(j) == 'B'; S.at(j + 1) == 'C'; S.at(j + 2) == 'A';
    shun++;
   }
   }
   for(int i = 0; i < S.size() - 2; i++){
   if(S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C'){
   a = true;
   }
   else{
   a = false;
   }
  }
  j++;
  }
  cout << shun <<endl;
    

}

Compiler output:
a.cc:34:3: error: 'cout' does not name a type
   34 |   cout << shun <<endl;
      |   ^~~~
a.cc:37:1: error: expected declaration before '}' token
   37 | }
      | ^
Language: C++

for(ll i=a+1;i<=c;i++)
		if(s[i]==s[i-1]&&s[i]=='#')
		{
			cout<<"No";
			return 0;
		}

	for(ll i=b+1;i<=d;i++)
		if(s[i]==s[i-1]&&s[i]=='#')
		{
			cout<<"No";
			return 0;
		}
	if(d>c)
	{
		cout<<"Yes";
		return 0;
	}
	for(ll i=b;i<=d;i++)
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
		{
			cout<<"Yes";
			return 0;
		}
	cout<<"No";

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'for'
    1 | for(ll i=a+1;i<=c;i++)
      | ^~~
a.cc:1:14: error: 'i' does not name a type
    1 | for(ll i=a+1;i<=c;i++)
      |              ^
a.cc:1:19: error: 'i' does not name a type
    1 | for(ll i=a+1;i<=c;i++)
      |                   ^
a.cc:8:9: error: expected unqualified-id before 'for'
    8 |         for(ll i=b+1;i<=d;i++)
      |         ^~~
a.cc:8:22: error: 'i' does not name a type
    8 |         for(ll i=b+1;i<=d;i++)
      |                      ^
a.cc:8:27: error: 'i' does not name a type
    8 |         for(ll i=b+1;i<=d;i++)
      |                           ^
a.cc:14:9: error: expected unqualified-id before 'if'
   14 |         if(d>c)
      |         ^~
a.cc:19:9: error: expected unqualified-id before 'for'
   19 |         for(ll i=b;i<=d;i++)
      |         ^~~
a.cc:19:20: error: 'i' does not name a type
   19 |         for(ll i=b;i<=d;i++)
      |                    ^
a.cc:19:25: error: 'i' does not name a type
   19 |         for(ll i=b;i<=d;i++)
      |                         ^
a.cc:25:9: error: 'cout' does not name a type
   25 |         cout<<"No";
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
char s[200005];
int main()
{
    int num1=0;
    int num2=0;
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(num1!=0&&s[i]=='B'&&s[i+1]=='C'&&i<n)
        {
            i++;
            ans+=num1;
            num1=1;
        }
        else if(s[i]=='A')
        {
            num1++;
        }
        else
        {
            num1=0;
        }
    }
    printf("%d\n",ans);
}


//记录前缀a的数量 后缀bc的数量
ACCBABCBCAABCB


Compiler output:
a.cc:33:1: error: 'ACCBABCBCAABCB' does not name a type
   33 | ACCBABCBCAABCB
      | ^~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(void){
  string str;
  cin >> str;
  int count = 0;
  int length = str.length();
  for(int i=0;i<length-2;i++){
    if(str[i+2] == 'C'){
      if(str[i+1] == 'B'({
        if(str[i] == 'A'){
          str[i] = 'B';
          str[i+1] = 'C';
          str[i+2] = 'A';
          count++;
          if(i == 0){
            //
          }else{
            i -= 2;
          }
        }else{
          //なし
        }
      }else{
        i++;
      }
    }else{
      i += 2;
    }
  }
  cout << count;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before 'if'
   12 |         if(str[i] == 'A'){
      |         ^~
a.cc:12:9: error: expected '}' before 'if'
a.cc:11:26: note: to match this '{'
   11 |       if(str[i+1] == 'B'({
      |                          ^
a.cc:11:27: error: expected ')' before 'if'
   11 |       if(str[i+1] == 'B'({
      |                         ~ ^
      |                           )
   12 |         if(str[i] == 'A'){
      |         ~~                 
a.cc:24:10: error: expected ')' before '}' token
   24 |         }
      |          ^
      |          )
   25 |       }else{
      |       ~   
a.cc:11:9: note: to match this '('
   11 |       if(str[i+1] == 'B'({
      |         ^
a.cc:25:7: error: expected primary-expression before '}' token
   25 |       }else{
      |       ^
a.cc:28:6: error: 'else' without a previous 'if'
   28 |     }else{
      |      ^~~~
a.cc:29:7: error: 'i' was not declared in this scope
   29 |       i += 2;
      |       ^
a.cc: At global scope:
a.cc:32:3: error: 'cout' does not name a type
   32 |   cout << count;
      |   ^~~~
a.cc:33:3: error: expected unqualified-id before 'return'
   33 |   return 0;
      |   ^~~~~~
a.cc:34:1: error: expected declaration before '}' token
   34 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
	using namespace std;
#define lol long long

	int main()
	{
		string S;
		cin >> S;
		int ans = 0;
		S = S + "...";
		for (int i = 0; i < (S.size - 3); i++) {
			if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
				S[i] = (char)(S[i] + 1);
				S[i + 1] = (char)(S[i + 1] + 1);
				S[i + 2] = (char)(S[i + 2] - 2);
				i -= 2;
				ans++;
			    
			}
		}
		cout << ans << endl;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   17 |                 for (int i = 0; i < (S.size - 3); i++) {
      |                                      ~~^~~~
      |                                            ()
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[200001], n = 0, ans = 0;
char c;
int main() {
	for (c = getchar(); c<'A' || c>'C'; c = getchar());
	for (n = 0; c <= 'C'&&c >= 'A'; c = getchar(), n++) a[n] = c - 'A';
	for (int i = n - 1ll, sumb = 0ll; i >= 0ll; i--) {
		if (!a[i]) {
			ans += sumb;
			continue;
		}
		if (a[i] == 2ll && a[i - 1] == 1ll) {
			sumb++; i--; 
			continue;
		}
		sumb = 0;
	}
	printf("%lld\n", ans);
	return 0;
}#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long a[200001], n = 0, ans = 0;
char c;
int main() {
	for (c = getchar(); c<'A' || c>'C'; c = getchar());
	for (n = 0; c <= 'C'&&c >= 'A'; c = getchar(), n++) a[n] = c - 'A';
	for (int i = n - 1ll, sumb = 0ll; i >= 0ll; i--) {
		if (!a[i]) {
			ans += sumb;
			continue;
		}
		if (a[i] == 2ll && a[i - 1] == 1ll) {
			sumb++; i--; 
			continue;
		}
		sumb = 0;
	}
	printf("%lld\n", ans);
	return 0;
}

Compiler output:
a.cc:23:2: error: stray '#' in program
   23 | }#include<iostream>
      |  ^
a.cc:23:3: error: 'include' does not name a type
   23 | }#include<iostream>
      |   ^~~~~~~
a.cc:27:11: error: redefinition of 'long long int a [200001]'
   27 | long long a[200001], n = 0, ans = 0;
      |           ^
a.cc:5:11: note: 'long long int a [200001]' previously declared here
    5 | long long a[200001], n = 0, ans = 0;
      |           ^
a.cc:27:22: error: redefinition of 'long long int n'
   27 | long long a[200001], n = 0, ans = 0;
      |                      ^
a.cc:5:22: note: 'long long int n' previously defined here
    5 | long long a[200001], n = 0, ans = 0;
      |                      ^
a.cc:27:29: error: redefinition of 'long long int ans'
   27 | long long a[200001], n = 0, ans = 0;
      |                             ^~~
a.cc:5:29: note: 'long long int ans' previously defined here
    5 | long long a[200001], n = 0, ans = 0;
      |                             ^~~
a.cc:28:6: error: redefinition of 'char c'
   28 | char c;
      |      ^
a.cc:6:6: note: 'char c' previously declared here
    6 | char c;
      |      ^
a.cc:29:5: error: redefinition of 'int main()'
   29 | int main() {
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main() {
      |     ^~~~
Language: C++

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

std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}

std::string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const unsigned int pos = replacedStr.find(from);
    const int len = from.length();
 
    if (pos == std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}
  
int main() {
  string str;
  cin >> str;
  
  string subStr = "ABC";
  int ans = 0;
  (int)(str.length());
  
  for(int i=0; i<str.length();i++){
    vector<int> findVec = find_all(str, subStr);
    for (const auto &pos:findVec) {
      ans ++;
    }
    replaceOtherStr(str, subStr, "BCA");
   
  
  cout << ans <<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:31:12: note: to match this '{'
   31 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

    string s;
    int n;

int func(string ss, ll count, ll a){
    //cout << "func("<<ss<<", "<<count << ", "<<a<<")" <<endl;
    ll max = count;
    for(int i=a; i<n-2; i++){
        if(ss[i]=='A' && ss[i+1]=='B' && ss[i+2]=='C'){
            int ans1=func(ss,count,i+1);
            if(max<ans1) max = ans1;
            ss[i]='B';
            ss[i+1]='C';
            ss[i+2]='A';
            int ans2=func(ss,count+1,i+1);
            if(max<ans2) max = ans2;
            int ans3=func(ss,count+1,max(0,i-2));
            if(max<ans3) max = ans3;
        }
    }
    return max;
}


int main() {

    cin >> s;
    n = (int)s.length();
    ll max = func(s,0,0);
    cout << max;


  return 0;
}


Compiler output:
a.cc: In function 'int func(std::string, ll, ll)':
a.cc:21:41: error: 'max' cannot be used as a function
   21 |             int ans3=func(ss,count+1,max(0,i-2));
      |                                      ~~~^~~~~~~
Language: C++

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

int main() {
	string S;
	cin >> S;
	int ss = S.size();
	ll aj = 0, ll ans = 0;
	for (int i = 0;i < ss - 2;i++) {
		if (S[i] == 'A')
			aj++;
		else
			aj = 0;
		if (S[i] == 'A'&&S[i + 1] == 'B'&&S[i + 2] == 'C') {
			ans += aj;
			S[i + 2] = 'A';
			aj--;
			i++;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:12: error: expected unqualified-id before 'long'
    3 | #define ll long long
      |            ^~~~
a.cc:9:20: note: in expansion of macro 'll'
    9 |         ll aj = 0, ll ans = 0;
      |                    ^~
a.cc:16:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |                         ans += aj;
      |                         ^~~
      |                         abs
a.cc:22:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include<iostream>
#include<string>
#include<<algorithm>
using namespace std;
int main(void){
  string str;
  cin >> str;
  reverse(str.begin(), str.end());
  int count = 0;
  int change = 0;
  int length = str.length();
  for(int i=0;;i++){
    if(i == length-1){
      if(change == 1){
        i = 0;
        change = 0;
      }else{
        break;
      }
    }
    if(str[i] == 'C' && str[i+1] == 'B' && str[i+2] == 'A'){
      str[i] = 'A';
      str[i+1] = 'C';
      str[i+2] = 'B';
      change = 1;
      count++;
    }
  }
  cout << count;
  return 0;
}
  


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

#include<iostream>
#include<string>
using namespace std;
int main(void){
  string str;
  cin >> str;
  reverse(str.begin(), str.end());
  int count = 0;
  int change = 0;
  int length = str.length();
  for(int i=0;;i++){
    if(i == length-1){
      if(change == 1){
        i = 0;
        change = 0;
      }else{
        break;
      }
    }
    if(str[i] == 'C' && str[i+1] == 'B' && str[i+2] == 'A'){
      str[i] = 'A';
      str[i+1] = 'C';
      str[i+2] = 'B';
      change = 1;
      count++;
    }
  }
  cout << count;
  return 0;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'reverse' was not declared in this scope
    7 |   reverse(str.begin(), str.end());
      |   ^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
    char s[200001];
    while(gets(s)!=NULL)
    {
        int i,flag=1,cnt=0;
        while(flag)
        {
            flag=0;
            for(i=0; s[i+2]; i++)
                if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
                {
                    cnt++;
                    s[i]='B';
                    s[i+1]='C';
                    s[i+2]='A';
                    flag=1;
                }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
    8 |     while(gets(s)!=NULL)
      |           ^~~~
      |           getw
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}
#include <iostream>
#include <string>
 
std::string replaceAll(std::string &replacedStr, std::string from, std::string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != std::string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int main() {
  string str;
  cin >> str;
  
  string subStr = "ABC";
  int ans = 0;
  (int)(str.length());
  
  for(int i=0; i<str.length(),i++){
    vector<int> findVec = find_all(str, subStr);
  	for (const auto &pos:findVec) {
    	ans++;
  	}
  	replaceAll(str, "ABC", "BCA");
  }
  
  cout << ans <<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:34: error: expected ';' before ')' token
   45 |   for(int i=0; i<str.length(),i++){
      |                                  ^
      |                                  ;
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}
#include <iostream>
#include <string>
 
std::string replaceAll(std::string &replacedStr, std::string from, std::string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != std::string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int main() {
  string str;
  cin >> str;
  
  string subStr = "ABC";
  int ans = 0;
  (int)(str.length())
  
  for(int i=0; i<str.length(),i++){
    vector<int> findVec = find_all(str, subStr);
  	for (const auto &pos:findVec) {
    	ans++;
  	}
  	replaceAll(str, "ABC", "BCA");
  }
  
  cout << ans <<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:22: error: expected ';' before 'for'
   43 |   (int)(str.length())
      |                      ^
      |                      ;
   44 | 
   45 |   for(int i=0; i<str.length(),i++){
      |   ~~~                 
a.cc:45:16: error: 'i' was not declared in this scope
   45 |   for(int i=0; i<str.length(),i++){
      |                ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
    int cnt=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            f=1;
            int k=i;
            while(1){
                if(k==0||s[k-1]!='A')break;
                k--;
            }
            cnt+=(i-k+1);
            s[k]='B';s[k+1]='C';
            for(int j=k+2;j<=i+2;j++)s[j]='A';
            i=k+1;
        }
    }
    cout<<cnt<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'f' was not declared in this scope
   13 |             f=1;
      |             ^
Language: C++

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


char str[200050];

int main(){
	int n=0,l=0,i=0,j=0;
	long long sum=0,itr=0;
	scanf("%s",str+1);
	l=strlen(str+1);
	i=l;
	while(i>=1){
		if(str[i]=='A') sum+=itr,i--;
		else if(str[i]=='C'&&str[i-1]=='B') itr++,i-=2;
		else itr=0,i--;
	}
	printf("%lld\n",sum);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'strlen' was not declared in this scope
   13 |         l=strlen(str+1);
      |           ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<cstdio>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C

#include <iostream>
#include <string>

int main(){
  std::string str;
  std::cin >> str;

  int basyoa;
  int basyob;
  int i = 0;

  while (1){
  basyoa = str.find("AABC");
  if (basyoa == std::string::npos){break;}
  str.replace(basyoa,4,"ABCA");
  i++;
  }
  while (1){
  basyob = str.find("ABC");
  if (basyob == std::string::npos){break;}
  str.replace(basyob,3,"BCA");
  i++;
  }

  std::cout << i << std::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<string>
using namespace std;
int main(void){
  string str;
  cin >> str;
  int count = 0;
  int change = 0;
  int length = str.length()
  for(int i=0;;i++){
    if(i == length-2){
      if(change == 1){
        i = -1;
        change = 0;
      }else{
        break;
      }
    if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C'){
      str[i] = 'B';
      str[i+1] = 'C';
      str[i+2] = 'A';
      change = 1;
      count++;
    }
  }
  cout << count;
  return 0;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: expected ',' or ';' before 'for'
   10 |   for(int i=0;;i++){
      |   ^~~
a.cc:10:16: error: 'i' was not declared in this scope
   10 |   for(int i=0;;i++){
      |                ^
a.cc:28:2: error: expected '}' at end of input
   28 | }
      |  ^
a.cc:4:15: note: to match this '{'
    4 | int main(void){
      |               ^
Language: C++



#include <algorithm>
#include <cmath>

typedef long long ll;

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
using namespace std;
ll n;
string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    for (int i = s.size() - 3; i >= 0; i--)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    for (int i = s.size() - 3; i >= 0; i--)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    for (int i = s.size() - 3; i >= 0; i--)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            ans++;
        }
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |             ans++;
      |             ^~~
      |             abs
a.cc:44:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |             ans++;
      |             ^~~
      |             abs
a.cc:54:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   54 |             ans++;
      |             ^~~
      |             abs
a.cc:64:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |             ans++;
      |             ^~~
      |             abs
a.cc:74:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |             ans++;
      |             ^~~
      |             abs
a.cc:84:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   84 |             ans++;
      |             ^~~
      |             abs
a.cc:87:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   87 |     cout << ans;
      |             ^~~
      |             abs
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}
 
int main() {
  string str;
  cin >> str;
  
  string subStr = "abc";
  int ans = 0;
  
  vector<int> findVec = find_all(str, subStr);
  for (const auto &pos:findVec) {
    ans++;
  }
  vector<int> findVec = find_all(str, subStr);
  for (const auto &pos:findVec) {
    ans++;
  }
  cout << ans <<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: redeclaration of 'std::vector<int> findVec'
   31 |   vector<int> findVec = find_all(str, subStr);
      |               ^~~~~~~
a.cc:27:15: note: 'std::vector<int> findVec' previously declared here
   27 |   vector<int> findVec = find_all(str, subStr);
      |               ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}
 
int main() {
  std::string str,
  std::cin >> str;
  
  string subStr = "abc";
  int ans = 0;
  
  std::vector<int> findVec = find_all(str, subStr);
  for (const auto &pos:findVec) {
    ans++;
    }
 
    std::cout << ans <<"\n";
 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: qualified-id in declaration before '>>' token
   22 |   std::cin >> str;
      |            ^~
Language: C++

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

int main(){
  string s; cin>>s;
  int ans=0;
  while(true){
    int count=0;
    for(int i=0;i<s.size()-2;i++){
      string t = s.substr(i,3);
      if(t = "ABC"){
        s[i] = 'B';
        s[i+1] = 'C';
        s[i+2] = 'A';
        count++;
      }
    }
    ans += count;
    if(count==0){
      break;
    }
  }
  cout<<ans<<endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"ABC"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   11 |       if(t = "ABC"){
      |          ~~^~~~~~~
      |            |
      |            std::__cxx11::basic_string<char>
Language: C++

#include <iostream>
#include <string>
#include <vector>
 
std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}
 
int main() {
  std::string str,
  cin >> str;
  
  subStr = "abc";
  int ans = 0;
  
  std::vector<int> findVec = find_all(str, subStr);
  for (const auto &pos:findVec) {
    ans++;
    }
 
    std::cout << ans <<"\n";
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: expected initializer before '>>' token
   21 |   cin >> str;
      |       ^~
a.cc:23:3: error: 'subStr' was not declared in this scope
   23 |   subStr = "abc";
      |   ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll int
int main(){
	string s;
 	cin>>s;
	ll c=0,l=strlen(s);
  if(l<3){cout<<0;return 0;}
  ll ans=0;
  	while(1){	
      c=0;
    	for(ll i=0;i<l-2;i++){
        	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
               s[i]='B';s[i+1]='C';s[i+2]='A';
               c++;
             }
        }
      if(c==0)break;
      ans+=c;
    }
cout<<c;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:25: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
    7 |         ll c=0,l=strlen(s);
      |                         ^
      |                         |
      |                         std::string {aka std::__cxx11::basic_string<char>}
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:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll int
int main(){
	string s;
 	cin>>s;
	ll c=0,l=strlen(s);
  if(l<3){cout<<0;return 0;}
  ll ans=0;
  	while(1){	
      c=0;
    	for(ll i=0;i<l-2;i++){
        	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
               s[i]='B';s[i+1]='C';s[i+2]='A'
               c++;
             }
        }
      if(c==0)break;
      ans+=c;
    }
cout<<c;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:25: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
    7 |         ll c=0,l=strlen(s);
      |                         ^
      |                         |
      |                         std::string {aka std::__cxx11::basic_string<char>}
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:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:14:46: error: expected ';' before 'c'
   14 |                s[i]='B';s[i+1]='C';s[i+2]='A'
      |                                              ^
      |                                              ;
   15 |                c++;
      |                ~
Language: C++

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

int main(){
  string s; cin>>s;
  bool ok = true;
  int ans=0,l=s.size()-2;
  while(ok){
    for(int i=0;i<s.size()-2;i++){
      int count=0;
      string k = s.substr(i,3);
      if(k == "ABC"){
        s[i] = 'B';
        s[i+1] = 'C';
        s[i+2] = 'A';
        ans++;
      }
      if(k != "ABC"){
        count++;
      }
    }
    if(count == l){
      ok = false;
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator=='
   22 |     if(count == l){
      |        ~~~~~~^~~~
Language: C++

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

int main(){
  string s; cin>>s;
  bool ok = true;
  int ans=0;
  while(ok){
    for(int i=0;i<s.size()-2;i++){
      int count=0;
      string k = s.substr(i,3);
      if(k == "ABC"){
        s[i] = 'B';
        s[i+1] = 'C';
        s[i+2] = 'A';
        ans++;
      }
      if(k != "ABC"){
        count++;
      }
    }
    if(count == (s.size()-2)){
      ok = false;
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: invalid operands of types '<unresolved overloaded function type>' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to binary 'operator=='
   22 |     if(count == (s.size()-2)){
      |        ~~~~~~^~~~~~~~~~~~~~~
Language: C++

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

int main(){
  string s; cin>>s;
  bool ok = true;
  int ans=0;
  while(ok){
    for(int i=0;i<s.size()-2;i++){
      int count=0;
      string k = s.substr(i,3);
      if(k == "ABC"){
        s[i] = 'B';
        s[i+1] = 'C';
        s[i+2] = 'A';
        ans++;
      }
      if(k != "ABC"){
        count++;
      }
    }
    if(count == s.size()-2){
      ok = false;
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: invalid operands of types '<unresolved overloaded function type>' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to binary 'operator=='
   22 |     if(count == s.size()-2){
      |        ~~~~~~^~~~~~~~~~~~~
Language: C++

#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;

long long PRIME = 1000000007;


struct info{
    long long b;
    long long l;
    long long u;
    long long d_max;
};


bool comp(const info& l, const info& r){
    return l.d_max > r.d_max;
}


vector<info> info_vec;
vector<long long> sum_vec;
long long X;
long long N;


int checkX(long long S){
    long long num = S / X;
    long long rest = S % X;

    if(ret == 0){
        return sum_vec[num];
    }

    long long ret = -1;

    for(int i = 0; i < N; ++i){
        long long val;

        if(i < num){
            val = sum_vec[num + 1];
            val -= info_vec[i].d_max;
        }
        else{
            val = sum_vec[num];
        }

        if(rest < info_vec[i].b){
            val += info_vec[i].l * rest;
        }
        else{
            val += info_vec[i].l * info_vec[i].b + info_vec[i].u * (rest - info_vec[i].b);
        }

        ret = max(ret, val);
    }

    return ret;
}


int main(int argc, char* argv[]){
    cin >> N >> X;

    info_vec.resize(N);
    sum_vec.resize(N + 1);

    int b;
    int l;
    int u;

    long long cost_zero = 0;

    for(int i = 0; i < N; ++i){
        cin >> b >> l >> u;

        info_vec[i].b = b;
        info_vec[i].u = u;
        info_vec[i].l = l;
        info_vec[i].d_max = (X - b) * u + b * l;

        cost_zero -= l * b;
    }

    std::sort(info_vec.begin(), info_vec.end(), comp);

    sum_vec[0] = cost_zero;
    for(int i = 1; i <= N; ++i){
        sum_vec[i] = sum_vec[i-1] +info_vec[i-1].d_max;
    }

    long long min_X = 0;
    long long max_X = X * N;
    long long mid_X;
    long long cost;

    while(max_X - min_X > 1){
        mid_X = (min_X + max_X) / 2;

        cost = checkX(mid_X);

        if(cost < 0){
            min_X = mid_X;
        }
        else{
            max_X = mid_X;
        }
    }

    cout << max_X;

}


Compiler output:
a.cc: In function 'int checkX(long long int)':
a.cc:39:8: error: 'ret' was not declared in this scope; did you mean 'rest'?
   39 |     if(ret == 0){
      |        ^~~
      |        rest
Language: C++


		UL N; LL X; cin >> N >> X;
		LL leaved = 0;
		vector<pair<LL, pair<LL, LL>>> Test;
		vector<pair<LL, UL>> Best;
		rep(i, N) {
			LL b, l, u; cin >> b >> l >> u;
			leaved += b * l;
			Test.push_back({ b, {l, u} });
			Best.push_back({ b * l + (X - b) * u, i });
		}
		LL ans = 0;
		sort(Best.begin(), Best.end());
		while (leaved > 0) {
			LL pt = Best.back().first;
			UL i = Best.back().second;
			if (leaved <= pt) break;
			leaved -= pt;
			Best.pop_back();
			ans += X;
		}
		LL tmp = X;
		rep(i, Best.size()) {
			LL pt = Best.back().first;
			UL p = Best.back().second;
			if (leaved > pt) continue;
			LL t = 0;
			LL b, l, u;
			b = Test[p].first;
			l = Test[p].second.first;
			u = Test[p].second.second;
			if (leaved == 0) {}
			else if (b * l >= leaved) {
				t = (leaved + l - 1) / l;
			}
			else {
				LL nleaved = leaved - b * l;
				t += b;
				t += (nleaved + u - 1) / u;
			}
			tmp = min(tmp, t);
		}
		ans += tmp;
		cout << ans << endl;

Compiler output:
a.cc:2:17: error: 'UL' does not name a type
    2 |                 UL N; LL X; cin >> N >> X;
      |                 ^~
a.cc:2:23: error: 'LL' does not name a type
    2 |                 UL N; LL X; cin >> N >> X;
      |                       ^~
a.cc:2:29: error: 'cin' does not name a type
    2 |                 UL N; LL X; cin >> N >> X;
      |                             ^~~
a.cc:3:17: error: 'LL' does not name a type
    3 |                 LL leaved = 0;
      |                 ^~
a.cc:4:17: error: 'vector' does not name a type
    4 |                 vector<pair<LL, pair<LL, LL>>> Test;
      |                 ^~~~~~
a.cc:5:17: error: 'vector' does not name a type
    5 |                 vector<pair<LL, UL>> Best;
      |                 ^~~~~~
a.cc:6:20: error: expected constructor, destructor, or type conversion before '(' token
    6 |                 rep(i, N) {
      |                    ^
a.cc:12:17: error: 'LL' does not name a type
   12 |                 LL ans = 0;
      |                 ^~
a.cc:13:21: error: expected constructor, destructor, or type conversion before '(' token
   13 |                 sort(Best.begin(), Best.end());
      |                     ^
a.cc:14:17: error: expected unqualified-id before 'while'
   14 |                 while (leaved > 0) {
      |                 ^~~~~
a.cc:22:17: error: 'LL' does not name a type
   22 |                 LL tmp = X;
      |                 ^~
a.cc:23:20: error: expected constructor, destructor, or type conversion before '(' token
   23 |                 rep(i, Best.size()) {
      |                    ^
a.cc:43:17: error: 'ans' does not name a type
   43 |                 ans += tmp;
      |                 ^~~
a.cc:44:17: error: 'cout' does not name a type
   44 |                 cout << ans << endl;
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<ll> b(n), l(n), u(n);
    vector<pair<ll, int>> s(n);
    ll d = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i] >> l[i] >> u[i];
        d -= b[i] * l[i];
        s[i] = {b[i] * l[i] + (x - b[i]) * u[i], i};
    }
    debug(d);
    sort(s.rbegin(), s.rend());
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        v[i] += s[i].first;
        if (i) v[i] += v[i - 1];
    }
    debug(s, v);
    ll lb = 0, ub = x * n + 1;
    while (ub - lb > 1) {
        ll t = (ub + lb) / 2;
        ll q = t / x;
        ll r = t % x;
        ll sum = 0;
        if (q) sum += v[q - 1];
        ll tmp = 0;
        for (int i = q; i < n; i++) {
            int j = s[i].second;
            ll ss = 0;
            if (r <= b[j]) {
                ss = r * l[j];
            } else {
                ss = b[j] * l[j] + (r - b[j]) * u[j];
            }
            tmp = max(tmp, ss);
        }
        sum += tmp;
        if (sum + d < 0)
            lb = t;
        else
            ub = t;
    }
    cout << rb << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:13: error: 'rb' was not declared in this scope; did you mean 'ub'?
   56 |     cout << rb << endl;
      |             ^~
      |             ub