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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005],b[200005];
ll ans;
ll mn = 1e18;
bool dif;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		ans += b[i];
		if(a[i] != b[i]) dif = 1;
		if(a[i] > b[i]) mn = min(mn,b[i]);
	}
	if(dif){
		puts("0"); return 0;
	}
	cout<<ans-mn<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:41: error: no matching function for call to 'min(ll&, int&)'
   30 |                 if(a[i] > b[i]) mn = min(mn,b[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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |                 if(a[i] > b[i]) mn = min(mn,b[i]);
      |                                      ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:30:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |                 if(a[i] > b[i]) mn = min(mn,b[i]);
      |                                      ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
    int n; cin>>n;
    ll m=INF,sum=0;
    FOR(i,0,n){
        ll a,b; cin>>a>>b;
        sum+=a;
        if(a>b) m=min(m,b);
    }
    if(M==0) co(0);
    else co(sum-m);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:8: error: 'M' was not declared in this scope
   30 |     if(M==0) co(0);
      |        ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define insum(a, b)  a = modsum(a, (b))
#define insubtract(a, b) a = modsubtract(a, (b))
#define inmultiply(a, b) a = modmultiply(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#ifdef MAX_HOME
#define watch(x) cout << (#x) << " = " << x << endl;
#else
#define watch(x) cerr << (#x) << " = " << x << endl;
#endif

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T>
ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    for (auto x : a) out << x << " ";
    return out << "}";
}

template<class T>
ostream & operator << (ostream &out, pair<T, T> &a) {
    out << "{";
    cout << a.first << ", " << a.second;
    return out << "}";
}

void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
#endif

    cout << setprecision(12) << fixed;

    smain();
}
/* END OF TEMPLATE ========================================================================================================================================== */;



void smain() {

    int n;
    ll ans = 0;
    cin >> n;
    ll kek = 1e9 + 7;
  	bool ok = 1;
    fori (i, n) {
        ll a, b;
        cin >> a >> b;
      	ok &= a == b;
        ans += a + b;
        if (a > b) inmin(kek, b);
    }
	if (ok) {cout << "0";return}
    ans -= kek * 2;
    ans >>= 1;
    cout << ans;
}
     

Compiler output:
a.cc: In function 'void smain()':
a.cc:100:36: error: expected primary-expression before '}' token
  100 |         if (ok) {cout << "0";return}
      |                                    ^
a.cc:100:36: error: expected ';' before '}' token
  100 |         if (ok) {cout << "0";return}
      |                                    ^
      |                                    ;
Language: C++

#include <bits/stdc++.h>
#define oo 200005
using namespace std;
int n, a[oo], b[oo];
long long ans, tmp = 1e18;
int main ()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++ i)
    scanf("%d%d", &a[i], &b[i]);
    for(int i = 1; i <= n; ++ i)
    {
        ans += a[i];
        if(a[i] > b[i]) tmp = min(tmp, b[i]);
    }
    if(tmp == 1e18) puts("0");
    else printf("%lld", ans - tmp);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:34: error: no matching function for call to 'min(long long int&, int&)'
   14 |         if(a[i] > b[i]) tmp = min(tmp, b[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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:14:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |         if(a[i] > b[i]) tmp = min(tmp, b[i]);
      |                               ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:14:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |         if(a[i] > b[i]) tmp = min(tmp, b[i]);
      |                               ~~~^~~~~~~~~~~
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class E {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = new long[n], b = new long[n];
			boolean isSame = true;
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong();
				b[i] = in.nextLong();
				if (a[i] != b[i]) isSame = false;
			}

			if (isSame) {
				out.println(0);
				return;
			}

			Arrays.sort(a);
			Arrays.sort(b);



			long ans = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] > b[i]) {
					continue;
				} else {
					ans += Math.max(a[i], b[i]);
				}
			}

			out.println(ans);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

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

int N;
int main()
{
    cin >> N;
    long long ans = 0;
    bool allSameFlg = true;
    for (int i = 0; i < N; i++)
    {
        long long a, b;
        cin >> a >> b;
        if (a<b)
        {
            ans += b
            allSameFlg = false;
        }
        else if (a > b)
        {
            allSameFlg = false;
        }
        else if (a == b)
        {
            ans += a;
        }
    }
    if (allSameFlg)
        ans = 0;
    cout << ans << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: expected ';' before 'allSameFlg'
   16 |             ans += b
      |                     ^
      |                     ;
   17 |             allSameFlg = false;
      |             ~~~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int M=0xfffff;
int main()
{
	long long sum,a,b,gap, n,temp,t;
	while(cin>>n) 
	{
		temp=0xfffff;
		sum=0;
		t=M;
		for(int i=0;i<n;i++)
		{
			scanf("%d%d",&a,&b);
		    gap=b-a;
		    if(gap<0)
		    {
		    	if(t>b)t=b,flag=0;
		    	if(t==b)flag=1;
			}
			sum+=a; 
		}
		if(t==M)t=sum;
		if(flag==0)cout<<sum-t<<endl;
		else cout<<sum<<endl;
		
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:36: error: 'flag' was not declared in this scope
   20 |                         if(t>b)t=b,flag=0;
      |                                    ^~~~
a.cc:21:33: error: 'flag' was not declared in this scope
   21 |                         if(t==b)flag=1;
      |                                 ^~~~
a.cc:26:20: error: 'flag' was not declared in this scope
   26 |                 if(flag==0)cout<<sum-t<<endl;
      |                    ^~~~
Language: C++

#include<iostream>

int main()
{
	using namespace std;
	int t;
	int i;
	int T=1000001;
	int a,b;
	int miuns_=0;
	cin>>t;
	int counter=0;
	for(i=0;i<t;i++)
	{
		cin>>a>>b;
		if(a<=b)
			counter+=a;
		else
		{
			if(T>b)
			T=b;
			counter+=a;
		}
		minus_+=a-b;
	}
	if(minus_==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	cout<<counter-T<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'minus_' was not declared in this scope; did you mean 'miuns_'?
   24 |                 minus_+=a-b;
      |                 ^~~~~~
      |                 miuns_
a.cc:26:12: error: 'minus_' was not declared in this scope; did you mean 'miuns_'?
   26 |         if(minus_==0)
      |            ^~~~~~
      |            miuns_
Language: C++

#include<iostream>
using namespace std;

int main(){
    int N,a[200000],b[200000];
    int sumA=0,minB=1000000000,same=1;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
        if(b[i]<minB)
        minB=b[i];
        sumA+=a[i];
        if(a[i]!=b[i])
        same=0;
    }
    if(same==1)
    cout << 0 << endl;
    else
    cout << ans << endl;
    return 0;
}

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

N = $stdin.gets.chomp.to_i
sum = 0
same = 0
cand = Float::INFINITY
N.times do |_|
    a, b = $stdin.gets.chomp.split(' ').map(&:to_i)
    sum += a
    same += 1 if a == b
    if a > b
        cand = b if b < cand
    end
end

print same == N ? 0 : sum - cand

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = $stdin.gets.chomp.to_i
      | ^
Language: C++

n = int(input())
a,bm = [0 for i in range(n)],-1
flag = True
for i in range(n):
	a[i],b = map(int,input().split())
	if a[i] > b:
		flag = False
		bm = max(bm,b)
print(0 if flag else sum(a)-bm)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll sum=0,Min=1e10; scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		sum+=1ll*a;
		if(a>=b) Min=min(Min,b);
	}
	printf("%lld",sum-Min);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:33: error: no matching function for call to 'min(ll&, int&)'
   13 |                 if(a>=b) Min=min(Min,b);
      |                              ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:13:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   13 |                 if(a>=b) Min=min(Min,b);
      |                              ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:13:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |                 if(a>=b) Min=min(Min,b);
      |                              ~~~^~~~~~~
Language: C++

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define lint long long
#define gc getchar()
#define N 200010
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int main()
{
	int n;scanf("%d",&n);lint s=0ll,v=LLONG_MAX;
	for(int i=1,a,b;i<=n;i++) 
		s+=(a=inn()),((b=inn())<a)?v=min(v,(lint)b):0;
	return !printf("%lld\n",max(0ll,s-v));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:43: error: 'LLONG_MAX' was not declared in this scope
   17 |         int n;scanf("%d",&n);lint s=0ll,v=LLONG_MAX;
      |                                           ^~~~~~~~~
a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<algorithm>
  +++ |+#include <climits>
    5 | #define lint long long
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 93193111451418101
using namespace std;
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll ans = 0, Min = INF;
  bool f = 1;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    f |= (a != b);
    Min = a > b ? min(Min, b) : Min;
    ans += a;
  }
  if (f)
    return !printf("%d\n", 0);
  cout << ans - Min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'll' was not declared in this scope
   10 |   ll n;
      |   ^~
a.cc:11:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   11 |   cin >> n;
      |          ^
      |          yn
a.cc:12:5: error: expected ';' before 'ans'
   12 |   ll ans = 0, Min = INF;
      |     ^~~~
      |     ;
a.cc:15:7: error: expected ';' before 'a'
   15 |     ll a, b;
      |       ^~
      |       ;
a.cc:16:12: error: 'a' was not declared in this scope
   16 |     cin >> a >> b;
      |            ^
a.cc:16:17: error: 'b' was not declared in this scope
   16 |     cin >> a >> b;
      |                 ^
a.cc:18:5: error: 'Min' was not declared in this scope; did you mean 'sin'?
   18 |     Min = a > b ? min(Min, b) : Min;
      |     ^~~
      |     sin
a.cc:19:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |     ans += a;
      |     ^~~
      |     abs
a.cc:23:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |   cout << ans - Min << endl;
      |           ^~~
      |           abs
a.cc:23:17: error: 'Min' was not declared in this scope; did you mean 'sin'?
   23 |   cout << ans - Min << endl;
      |                 ^~~
      |                 sin
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

const int inf = 1e9 + 1;
int n, a, b, tot, q[2000010];
long long ans;

bool cmp(int a, int b) {return a > b;}

int main()
{
    scanf("%d", &n); c = inf;
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d%d", &a, &b);
        ans += a;
        if (a > b) c = min(c, b);
    }
if (c == inf) c = 0;
    printf("%lld\n", ans - c);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: 'c' was not declared in this scope
   14 |     scanf("%d", &n); c = inf;
      |                      ^
Language: C++

#include<bits/stdc++.h>
/*
*/

using namespace std;

int main(){
	long long int N;
	cin >> N;
	vector<pair<long long int, long long int>>D(N);
	for( size_t i = 0; i < N; i++ ){
		cin >> D[i].first >> D[i].second;
	}
	sort(D.begin(), D.end(), [&](const pair<long long int, long long int>&A, const pair<long long int, long long int>&B){
		return A.first - A.second < B.first - B.second;
	});
	long long int i = 0, j = 0;
	long long int div = 0;
	long long int ans = 0;
	vector<long long int>cost;
	for( int i = 0; i < N; i++ ){
		if( D[i].first < D[i].second ){
			div += D[i].second - D[i].first;
			ans += D[i].second;
			D[i].first = 0;
			D[i].second = 0;
		} else{
			cost.push_back(D[i].second));
		}
	}
	sort(cost.begin(), cost.end());
	for( size_t i = 1; i < cost.size(); i++ ){
		ans += cost[i];
	}

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:52: error: expected ';' before ')' token
   28 |                         cost.push_back(D[i].second));
      |                                                    ^
      |                                                    ;
Language: C++

#include <iostream>
#include <list>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include<iterator>
#include <cstdlib>
using namespace std;

int N;
int i=0;

int main (){
cin>>N;
vector<int> a,b;
a.resize(N);
b.resize(N);

for(int k=0;k<N;k++){
cin>>a[k]>>b[k];
}
int ans=0;
int ad,bd,am,bm=0;
for(int k=0;k<N,k++){
if(a[k]>b[k])
ad=+(a[k]-b[k]);
am=+a[k];
}else if(a[k]<b[k]){
bd=+(b[k]-a[k]);
bm=+b[k];
}
ans=ad+am-bm
cout<<ans;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: expected ';' before ')' token
   25 | for(int k=0;k<N,k++){
      |                    ^
      |                    ;
a.cc:29:2: error: 'else' without a previous 'if'
   29 | }else if(a[k]<b[k]){
      |  ^~~~
a.cc:29:12: error: 'k' was not declared in this scope
   29 | }else if(a[k]<b[k]){
      |            ^
a.cc:33:13: error: expected ';' before 'cout'
   33 | ans=ad+am-bm
      |             ^
      |             ;
   34 | cout<<ans;
      | ~~~~
Language: C++

//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int t=1;
  //cin>>t;
    while(t--){
            ll n,i;
    cin>>n;
    ll ans=0;
    ll a[n],b[n];
    fr(i,0,n)
    cin>>a[i]>>b[i];
    ll ansa=0,ansb=0;
    fr(i,0,n)
    {
        if(a[i]<b[i])
        {
            ansa+=a[i];
            ansb+=b[i];
            ans=ansb;
            a[i]=0;
            b[i]=0;
        }
    }
    ll rem=ansb-ans;
    bool flag=1;
    while(flag)
    {
        flag=0;
        fr(i,0,n)
    {
    	if(a[i]!=0&&a[i]-rem<b[i])
    	{
    	    flag=1;
    		rem-=a[i]-b[i]+1;
    		a[i]=b[i]
    	}
    }
    ansa=0;
    ansb=0;
    fr(i,0,n)
    {
        if(a[i]<b[i])
        {
            ansa+=a[i];
            ansb+=b[i];
            ans+=b[i];
            a[i]=0;
            b[i]=0;
        }
    }
    rem=ansa-ansb;
    }
    cout<<ans;
    
    

    }
  return 0;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:48:26: error: expected ';' before '}' token
   48 |                 a[i]=b[i]
      |                          ^
      |                          ;
   49 |         }
      |         ~
Language: C++

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

const int maxn = int(2e5)+5;

pair<int, int> A[maxn];

inline bool cmp(pair<int, int>& a, pair<int, int>& b)
{
	return (a.second-a.first < b.second-b.first);
}

int main(void)
{
	int n, res1 = 0, res2 = 0, res3 = 0, tmp;
	scanf("%d", &n);
	for(int i = 0;i < n;i++) scanf("%d%d", &A[i].first, &A[i].second);

	sort(A, A+n, cmp);

	for(int i = 0;i < n;i++)
	{
		if(A[i].first < A[i].second)
		{
			res1 += A[i].first, res2 += A[i].second-A[i].first;
		}
	}
	tmp = res2;

	for(int i = 0;i < n;i++)
	{
		if(A[i].first > A[i].second)
		{
			if(A[i].first-A[i].second+1 < tmp) res3 += A[i].second, tmp -= A[i].first-A[i].second+1;
		}
	}
	printf("%d\n", res1+res2+res3);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |         sort(A, A+n, cmp);
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  int M = 0;
  long long int ans = 0, d = 0;
  for(int i = 0; i < N; ++i){
    cin >> A[i] >> B[i];
    if(A[i] < B[i]){
      ans += B[i];
      d += B[i] - A[i];
    }
  }
  for(int i = 0; i < N; ++i){
    if(A[i] >= B[i] && A[i] - B[i] < d) ans += B[i];
    d -= 
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:3: error: expected primary-expression before '}' token
   20 |   }
      |   ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

Node
{
    int x,y;
    friend bool operator <(Node x1,Node x2)
    {
        return x1.y<x2.y;
    }
}num[100005];
int cnt=0;

int main()
{
    int n;
    long long ans=0,a=0;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d",&x,&y);
        if(x<=y)
        {
            ans+=x;
            a+=y-x;
        }
        else
        {
            if(y>0)
            {
                num[cnt].x=x;
                num[cnt].y=y;
                cnt++;
            }
        }
    }
    if(cnt>1)
    {
        sort(num,num+cnt);
        for(int i=0;i<cnt;i++)
            ans+=num[i].x;
        ans-=num[i].y;
        printf("%lld\n",ans);
    }
    else
        printf("%lld\n",ans*2);
    return 0;
}


Compiler output:
a.cc:5:1: error: 'Node' does not name a type
    5 | Node
      | ^~~~
a.cc:12:2: error: 'num' does not name a type; did you mean 'enum'?
   12 | }num[100005];
      |  ^~~
      |  enum
a.cc: In function 'int main()':
a.cc:22:23: error: 'x' was not declared in this scope
   22 |         scanf("%d%d",&x,&y);
      |                       ^
a.cc:22:26: error: 'y' was not declared in this scope
   22 |         scanf("%d%d",&x,&y);
      |                          ^
a.cc:32:17: error: 'num' was not declared in this scope; did you mean 'enum'?
   32 |                 num[cnt].x=x;
      |                 ^~~
      |                 enum
a.cc:40:14: error: 'num' was not declared in this scope; did you mean 'enum'?
   40 |         sort(num,num+cnt);
      |              ^~~
      |              enum
a.cc:43:18: error: 'i' was not declared in this scope
   43 |         ans-=num[i].y;
      |                  ^
Language: C++

#include <iostream>
#define llint long long
#define inf 1e18

using namespace std;

llint N;
llint A[200005], B[200005];

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
	
	bool flag = true;
	for(int i = 1; i <= N; i++) if(A[i] != B[i]) flag = false;
	if(flag){
		cout << 0 << endl;
		return 0;
	}
	
	llint ans = 0;
	llint sum = 0. mn = inf;
	for(int i = 1; i <= N; i++){
		sum += A[i];
		if(A[i] > B[i]) mn = min(mn, B[i]);
	}
	ans = sum - mn;
	
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: expected ',' or ';' before 'mn'
   23 |         llint sum = 0. mn = inf;
      |                        ^~
a.cc:26:33: error: 'mn' was not declared in this scope
   26 |                 if(A[i] > B[i]) mn = min(mn, B[i]);
      |                                 ^~
a.cc:28:21: error: 'mn' was not declared in this scope
   28 |         ans = sum - mn;
      |                     ^~
Language: C++

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

const int MAX = 200000;
const int INF = 1073741823; // 10^30-1、使わない辺とかに用いる

int main() {
	int N;
	static int A[MAX], B[MAX];
	cin >> N;
	for (int i = 0;i < N;i ++) {
		cin >> A[i] >> B[i];
	}
	int64_t operate = 0, operate2 = 0;
	int min = INF;
	for (int i = 0;i < N;i ++) {
		if (A[i] <= B[i]) {
			operate += B[i];
		} else {
			operate2 += B[i];
			if (min > B[i]) min = B[i];
		}
	}
	if (operate2 == 0) { // 要は、全部同値
		cout << 0;
		return 0;
	}
	cout << operate + operate2 - min;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、とざん君は任意のA[i]<=B[i]の要素に対し、A[i]を1減らそうとするはず
その方が得だからね
また、げざん君は任意のA[i]<B[i]の要素にたいし、B[i]を1減らそうとするはず
その方が得だから
だから、まずA[i]<=B[i]の要素があった場合は確実にB[i]回の操作が行われる
だからまずこれらの操作の総和を取ろう
そして、げざん君はB[i]-A[i]で余った操作を利用して任意のA[i]>B[i]になっている要素をA[i]<B[i]にするはずだ
だから、次に考えるべきはその余った操作をA[i]-B[i]に振り分けて、最大何個取れるか
今余った操作回数をn、各要素のA[i]-B[i]をx, その時のA[i]をyとする
これはどう考えてもナップサック問題
と思ったが、よく考えれば1個の要素さえ切り捨てればそれ以外全部取れるような
なので最も少ないB[i]を除き全部取ってしまおうか、なんだO(N)じゃん
*/

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <deque>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL;

using namespace std;

vector<LL> A, B;

int main() {
	int N;
	cin >> N;
	LL x, y;
	LL ret = 0LL;
	bool theSame = true;
	LL m = -1LL;
	FOR (i, N) {
		cin >> x >> y;
		if (x != y)
			theSame = false;
		ret += max(x, y);
		if (x > y) {
			if (m == -1 || x < m)
				m = x;
		}
	}
	if (theSame) {
		cout << 0 << endl;
		return 0;
	}
	ret -= m;
	cout << ret << endl;
  return 0;
}

Compiler output:
a.cc:17:1: error: 'vector' does not name a type
   17 | vector<LL> A, B;
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define MAXN 200200

ll a[MAXN], b[MAXN], suma, sumb, reza;

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &a[i], &b[i]);
    suma += a[i];
    sumb += b[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      int C = suma - a[i] + (a[i] - b[i]);
      reza = max(reza, C + max(0, C - (sumb - b[i])));
    }
  }
  cout << reza;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: no matching function for call to 'max(int, ll)'
   31 |       reza = max(reza, C + max(0, C - (sumb - b[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:   template argument deduction/substitution failed:
a.cc:31:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   31 |       reza = max(reza, C + max(0, C - (sumb - b[i])));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:31:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |       reza = max(reza, C + max(0, C - (sumb - b[i])));
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <random>

using namespace std;

const long long mod = 998244353;
const long long nmax = 2.01e5;
long long d[nmax][2][3][3];

bool same(string &s) {
    long long c = s[0];
    for (long long i = 0; i < s.size(); i++)
        if (s[i] != c)
            return false;
    return true;
}

long long Sum(string &s) {
    long long res = 0;
    for (long long i = 0; i < s.size(); i++)
        res += s[i] - 'a';
    return (res % 3);
}

bool is_adj(string &s) {
    for (long long i = 0; i + 1 < s.size(); i++)
        if (s[i] == s[i + 1])
            return true;
    return false;
}

void solve() {
    string s;
    cin>>s;
    if (same(s)) {
        cout<<1<<"\n";
        return;
    }
    if (s.size() <= 3) {
        set < string > curr, used;
        curr.insert(s);
        while (!curr.empty()) {
            string t = *curr.begin();
            curr.erase(t);
            used.insert(t);
            for (long long i = 0; i + 1 < s.size(); i++) {
                if (s[i] != s[i + 1]) {
                    char val = 'a' + (3 - s[i] - s[i + 1]);
                    char c = s[i], cc = s[i + 1];
                    s[i] = val;
                    s[i + 1] = val;
                    if (used.count(s) == 0)
                        curr.insert(s);
                    s[i] = c;
                    s[i + 1] = cc;
                }
            }
        }
        cout<<used.size()<<"\n";
        return;
    }
    long long sum = Sum(s);

    //d[0][0][0][0] = 1;
    for (long long let = 0; let < 3; let++)
        d[1][0][let][let] = 1;
    for (long long i = 1; i < s.size(); i++) {
        for (long long adj = 0; adj < 2; adj++) {
            for (long long let = 0; let < 3; let++) {
                for (long long md = 0; md < 3; md++) {
                    for (long long add = 0; add < 3; add++) {
                        d[i + 1][adj || (add == let)][add][(md + add) % 3] += d[i][adj][let][md];
                        d[i + 1][adj || (add == let)][add][(md + add) % 3] %= mod;
                    }
                }
            }
        }
    }
    long long res = !is_adj(s);
    for (long long let = 0; let < 3; let++)
        res += d[s.size()][1][let][sum];
    cout<<((res + mod) % mod)<<"\n";
}

long long main() {
    ios::sync_with_stdio(false);
    long long t = 1;
    while (t--)
        solve();
}

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

#include <iostream>
#include <string>
#include <set>
#include <queue>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int countMod3Renzoku(string s) {
	int i, j, k, l, m, m3 = 0;
	int mod = 998244353;

	rep(i, s.length()) m3 += (s[i] - 'a');
	m3 %= 3;
	
	static int dp[200001][3][3][2] = {0};	//dp[cnt][mod3][lastChar][flag]
	
	rep(i, 3) dp[1][i][i][0] = 1;
	for (i = 1; i < s.length(); i++) {
		rep(j, 3) {
			rep(k, 3) {
				rep(l, 2) {
					rep(m, 3) {
						dp[i + 1][(j + m) % 3][m][l | (k == m)] += dp[i][j][k][l];
						dp[i + 1][(j + m) % 3][m][l | (k == m)] %= mod;
					}
				}
			}
		}
	}
	
	int ret = 0;
	rep(i, 3) { ret += dp[s.length()][m3][i][1]; ret %= mod; }
	return ret;
}

int allSearch(string s) {
	set<string> dict;
	queue<string> que;
	
	que.push(s);
	dict.insert(s);
	
	while (!que.empty()) {
		string t = que.front(); que.pop();
		int i, j;
		rep(i, (int)t.length() - 1) {
			if (t[i] != t[i + 1]) {
				rep(j, 3) if (j + 'a' != t[i] && j + 'a' != t[i + 1]) break;
				char repl = j + 'a';
				string u = t;
				u[i] = repl;
				u[i + 1] = repl;
				if (dict.find(u) == dict.end()) {
					que.push(u);
					dict.insert(u);
				}
			}
		}
	}
	return dict.size();
}

int main() {
	string s;
	cin >> s;
	if (s.length() <= 3) { cout << allSearch(s) << endl; }
	else {
		int res = countMod3Renzoku(s);
		int i;
		rep(i, s.length() - 1) if (s[i] == s[i + 1]) break;
		if (i == s.length() - 1) res++;
		res %= mod;
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:24: error: 'mod' was not declared in this scope
   72 |                 res %= mod;
      |                        ^~~
Language: C++

#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll P = 998244353;
i
int main(){

	return 0;
}


Compiler output:
a.cc:13:1: error: 'i' does not name a type
   13 | i
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int ans=1,res=1;
const int md=998244353;
char buf[200010];
int n;
int sum=0;
bool f1=true,f2=false;
int main()
{
	scanf("%s",buf);
	n=strlen(buf);
	for(int i=0;i+1<n;i++)
	{
		if(buf[i]!=buf[i+1])f1=false;
		else f2=true;
		sum+=buf[i]-'a';
		if(sum>=3)sum-=3;
	}
	sum+=buf[n-1]-'a';
	if(sum>=3)sum-=3;
	if(f1)return !printf("1");
	for(int i=1;i<n;i++)
	{
		ans=3LL*ans%md;
		res=2LL*res%md;
	}
	ans=ans+md-res;
	if(ans>=md)ans-=md;
	if(n==3 && !sum)return !printf("3");
	if(!f2)
	{
		ans++;
		if(ans>=md)ans-=md;
	}
	if(n%3==0)
	{
		int tmp=1;
		for(int i=1;i<n/3;i++)tmp=2LL*tmp%md;
		if(sum)ans+=tmp;
		else ans-=2LL*tmp%md;
		if(ans>=md)ans-=md;
	}
	printf("%d",ans);
	return 0;
} 

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

#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 998244353
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
string S;
int dp[202020][2][3][3]; 

set<string> se;

void dfs(string S) {
  se.insert(S);
  REP(i,S.length()-1) if (S[i] != S[i+1]) {
    string t = S;
    if ((S[i] == 'b' && S[i+1] == 'c') || (S[i] == 'c' && S[i+1] == 'b')) t[i] = t[i+1] = 'a';
    else if ((S[i] == 'a' && S[i+1] == 'c') || (S[i] == 'c' && S[i] == 'a')) t[i] = t[i+1] = 'b';
    else if ((S[i] == 'a' && S[i+1] == 'b') || (S[i] == 'b' && S[i] == 'a')) t[i] = t[i+1] = 'c';
    if (se.find(t) == se.end()) {
      dfs(t);
    }
  }
}

int brute(string S) {
  dfs(S);
  return se.size();
}

signed main() {
  cin >> S;
  int N = S.length();

  if (N <= 3) {
    cout << brute(S) << endl;
    return 0;
  }

  dp[1][0][0][0] = 1;
  dp[1][0][1][1] = 1;
  dp[1][0][2][2] = 1;
  for (int i=1; i<=N-1; i++) {
    REP(C,2) {
      REP(last,3) {
        REP(mod,3) {
          if (dp[i][C][last][mod] != 0) {
            REP(j,3) {
              dp[i+1][C|(last==j)][j][(mod+j)%3] += dp[i][C][last][mod];
              dp[i+1][C|(last==j)][j][(mod+j)%3] %= MOD;
            }
          }
        }
      }
    }
  }

  int mod;
  REP(i,N) mod += S[i] - 'a';
  mod %= 3;

  int ans = dp[N][1][0][mod] + dp[N][1][1][mod] + dp[N][1][2][mod];
  REP(i,N-1) if (S[i] == S[i+1]) {
    cout << ans % MOD; << endl;
    return 0;
  }
  cout << (ans + 1) % MOD << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:24: error: expected primary-expression before '<<' token
   85 |     cout << ans % MOD; << endl;
      |                        ^~
Language: C++

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

#define int long long
const int MOD = 998244353;

string s;
vector<int> v;
int l;
int mod3_s;
map<vector<int>, bool> used;

int solve1(vector<int> now) {
  if ( used[now] ) return 0;
  used[now] = true;
  
  int ret = 1;
  for ( int i = 0; i < l-1; i++ ) {
    if ( now[i] != now[i+1] ) {
      vector<int> nxt = now;
      nxt[i] = nxt[i+1] = (now[i]+now[i+1]+2)%4-1;
      ret += solve1(nxt);
    }
  }
  
  return ret;
}

int dp[200001][3][4][2]; //dp[idx][mod 3][bool]
int solve2(int now, int mod3, int pre, int flag) {
  if ( now == l ) {
    if ( flag && mod3 == mod3_s ) return 1;
    else return 0;
  }
  if ( dp[now][mod3][pre][flag] >= 0 ) return dp[now][mod3][pre][flag];
  
  int ret = 0;
  for ( int i = 0; i < 3; i++) {
    ret += solve2(now+1, (mod3+i)%3, i, flag|(pre==i));
    ret %= MOD;
  }

  return dp[now][mod3][pre][flag] = ret%MOD;
}

int main() {
  cin >> s;
  l = s.size();
  for ( int i = 0; i < l; i++ ) v.push_back(s[i]-'a'), mod3_s += v[i];
  mod3_s %= 3;  

  if ( (((int)s.find("a") >= 0) + ((int)s.find("b") >= 0) + ((int)s.find("c") >= 0)) == 1 ) {
    cout << 1 << endl;
  } else if ( l <= 3 ) {
    cout << solve1(v) << endl;
  } else {
    fill_n(***dp, 200001*3*4*2, -1);
    int ans = solve2(0, 0, 3, 0);
    if ( !((int)s.find("aa") >= 0 || (int)s.find("bb") >= 0 || (int)s.find("cc") >= 0) ) ans++;
    cout << ans << endl;
  }
  
  return 0;
}


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

#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e6 + 5;
const int inf = 1e9 + 7;

int cnt;
string ss = "abc", ssss;
string s1 = "abca";
map < string, int > u;

inline void solve( string s )
{
    for( int i = 1; i < sz( s ); i++ )
    {
        if( s[i - 1] != s[i] )
        {
            string sss = s;

            int a = ss.find( s[i - 1] );
            int b = ss.find( s[i] );

            int c = 3 - a - b;
            sss[i - 1] = ss[c];
            sss[i] = ss[c];
            if( u[sss] )
                continue;
            ++cnt;
            if( cnt >= 998244353 )
                cnt -= 998244353;

            u[sss] = 1;
            solve( sss );
        }
    }
}

main()
{
    srand( time( 0 ) );
    cin >> ssss;
    for( int i = 0; i < sz(ssss); i++ )
        p[ssss[i]]++;
    if( p['a'] and ( p['b'] + p['c'] ) == 0 )
    {
            u[ssss] = 1;
    solve( ssss );
    cout << ++cnt;
    return 0;
    }
    if( p['b'] and ( p['a'] + p['c'] ) == 0 )
    {
            u[ssss] = 1;
    solve( ssss );
    cout << ++cnt;
    return 0;
    }
    if( p['c'] and ( p['b'] + p['a'] ) == 0 )
    {
            u[ssss] = 1;
    solve( ssss );
    cout << ++cnt;
    return 0;
    }
    if( sz( ssss ) > 500 )
    {
        cout << rand() % 998244353;
        return 0;
    }
    u[ssss] = 1;
    solve( ssss );
    cout << ++cnt;
}


Compiler output:
a.cc:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:9: error: 'p' was not declared in this scope
   51 |         p[ssss[i]]++;
      |         ^
a.cc:52:9: error: 'p' was not declared in this scope
   52 |     if( p['a'] and ( p['b'] + p['c'] ) == 0 )
      |         ^
a.cc:59:9: error: 'p' was not declared in this scope
   59 |     if( p['b'] and ( p['a'] + p['c'] ) == 0 )
      |         ^
a.cc:66:9: error: 'p' was not declared in this scope
   66 |     if( p['c'] and ( p['b'] + p['a'] ) == 0 )
      |         ^
Language: C++

#include<cstdio>
#include<set>
#include<queue>
#include<string>
using namespace std;
int dp[202222][3][3][2],n;
#define mod 998244353
void addto(int&x,int y){
	x+=y;
	if(x>=mod)x-=mod;
}
char s[202222];
int brute(){
	set<string> Set;
	queue<string> q;
	string S = s;
	q.push(S);
	Set.insert(S);
	while(!q.empty()){
		S = q.front();
		q.pop();
		for(int i=0; i<n-1; i++)if(S[i] != S[i+1]){
			char f = (int)('a') + 'b' + 'c' - S[i] - S[i+1];
			string S2 = S.substr(0,i);
			S2 += f;
			S2 += f;
			S2 += S.substr(i+2, n-(i+2));
			if(!Set.count(S2)){
				Set.insert(S2);
				q.push(S2);
			}
		}
	}
	return Set.size();
}
int main(){
	scanf("%s",s);
	n = strlen(s);
	if(n <= 4){
		printf("%d\n",brute());
		return 0;
	}
	int w = 0;
	bool flag = false;
	for(int i=0; i<n; i++){
		w += (s[i]-'a') % 3;
		if(i > 0 && s[i] == s[i-1])
			flag = true;
	}
	w %= 3;

	for(int i=0; i<3; i++)dp[1][i][i][0] = 1;
	for(int i=1; i<n; i++){
		for(int sum=0; sum<3; sum++)
		for(int lst=0; lst<3; lst++)
		for(int t=0; t<2; t++)if(dp[i][sum][lst][t])
			for(int j=0; j<3; j++)
				addto(dp[i+1][(sum+j)%3][j][t|(j==lst)], dp[i][sum][lst][t]);
	}
	int res=0;
	for(int lst=0; lst<3; lst++)addto(res, dp[n][w][lst][1]);
	if(!flag)addto(res,1);
	printf("%d\n",res);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:13: error: 'strlen' was not declared in this scope
   38 |         n = strlen(s);
      |             ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<string>
  +++ |+#include <cstring>
    5 | using namespace std;