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

#include <bits/stdc++.h>
#define N 100011
#define MAX_V 100010
#define MAX_LOG_V 20
#define INF (1e9)
using namespace std;
vector<int> G[MAX_V];
int root;
int parent[MAX_LOG_V][MAX_V];
int depth[MAX_V];
 
void dfs(int v,int p,int d){
  parent[0][v]=p;
  depth[v]=d;
  for(int i=0;i<G[v].size();i++) if(G[v][i] != p)dfs(G[v][i],v,d+1);
}
 
void init(int V){
  dfs(root,-1,0);
  for(int k=0; k+1<MAX_LOG_V ;k++)
    for(int v=0; v<V ;v++)
      if(parent[k][v] < 0)parent[k+1][v] = -1;
      else parent[k+1][v] = parent[k][parent[k][v]];
}
 
int lca(int u,int v){
  if(depth[u]>depth[v]) swap(u,v);
  for(int k=0; k<MAX_LOG_V ;k++)
    if((depth[v]-depth[u])>>k&1)v=parent[k][v];
  if(u==v) return u;
 
  for(int k=MAX_LOG_V-1; k>=0 ;k--)
    if(parent[k][u] != parent[k][v]){
      u=parent[k][u];
      v=parent[k][v];
    }
  return parent[0][u];
}
 
typedef long long ll;
struct edge{int to,cost,idx;};
typedef pair<int,int> P;
typedef pair<ll,P> PP;
vector<edge> g[N];
int MST[N]={};
map<P,int> M;
int n,m;
 
void add_edge(int a,int b,int cost,int idx){
  g[a].push_back((edge){b,cost,idx});
  g[b].push_back((edge){a,cost,idx});
}
 
ll prim(){
  memset(MST,-1,sizeof(MST));
  ll res=0;
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(0,P(0,0)));
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    ll cost=t.first;
    int pos=t.second.first,pre=t.second.second;
    if(MST[pos]!=-1)continue;
    MST[pos] = pre;
    res+=cost;   
    for(int i=0;i<g[pos].size();i++){
      int to=g[pos][i].to;
      int cost=g[pos][i].cost;
      if(MST[to]!=-1)continue;
      Q.push(PP(cost,P(to,pos)));
    }
  }
  return res;
}
 
 
typedef priority_queue<P,vector<P>,greater<P> > PQ;
int ans[200001],dep=0,pos[N],pre[N];

PQ dfs(){
  PQ res;
  res.push(P(INF,-1));
  for(int i=0;i<g[pos[dep]].size();i++){
    int LCA=lca(pos[dep],g[pos[dep]][i].to);
    if(LCA==pos[dep]||g[pos[dep]][i].to==pre[dep])continue;
    res.push(P(g[pos[dep]][i].cost,LCA));
  }
   
  for(int i=0;i<G[pos[dep]].size();i++){
    dep++;
    pos[dep] = G[pos[dep-1]][i];
    pre[dep] = pos[dep-1];
    PQ t =  dfs();
    dep--;
    while(!t.empty()){
      P r = t.top();t.pop();
      if(r.second!=pos[dep])res.push(r);
    }
  }
  assert(res.size()<m+100)
  if(pos[dep])ans[M[P(pos[dep],pre[dep])]] = res.top().first;
  return res;
}
 
int main(){
  cin>>n>>m;
  vector<PP> e(m);
  for(int i=0,a,b,c;i<m;i++){
    scanf("%d%d%d",&a,&b,&c);
    a--,b--;
    e[i]=PP(c,P(a,b));
    M[P(a,b)]=M[P(b,a)]=i;
    add_edge(a,b,c,i);
  }
 
  ll mncost=prim();
  int used[200011]={},flg=0;
  for(int i=1;i<n;i++){
    flg|=MST[i]==-1;
    if(MST[i]==-1)continue;
    G[MST[i]].push_back(i);
    used[M[P(i,MST[i])]]=1;
  }
  init(n);
  pos[0]=0,pre[0]=-1;
  dfs();
  for(int i=0;i<m;i++){
    if(!used[i]&&!flg) printf("%lld\n",mncost);
    else if(ans[i]>=INF)printf("-1\n");
    else printf("%lld\n",mncost-e[i].first+ans[i]);
  }
  return 0;
}

Compiler output:
a.cc: In function 'PQ dfs()':
a.cc:101:3: error: expected ';' before 'if'
  101 |   if(pos[dep])ans[M[P(pos[dep],pre[dep])]] = res.top().first;
      |   ^~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;

typedef double D;
typedef complex<D> P;
D pi=acos(-1);
void FFT(vector<P>& a,int N,double t){
	for(int m=N;m>=2;m/=2){
		int mh=m/2;
		rep(i,mh){
			P w=polar(1.0,t*i);
			for(int j=i;j<N;j+=m){
				int k=j+mh;
				P x=a[j]-a[k];
				a[j]+=a[k];
				a[k]=w*x;
			}
		}
		t*=2;
	}
	int i=0;
	rep1(j,N-2){
		for(int k=N/2;k>(i^=k);k/=2);
		if(j<i) swap(a[i],a[j]);
	}
}
vector<P> conv(vector<P> a,vector<P> b){
	int n=a.size()+b.size();
	int N=1;
	while(N<n) N*=2;
	a.resize(N);
	b.resize(N);
	FFT(a,N,2*pi/N);
	FFT(b,N,2*pi/N);
	rep(i,N) a[i]*=b[i];
	FFT(a,N,-2*pi/N);
	rep(i,N) a[i]/=N;
	return a;
}
inline fix(P x){
	return round(x.real());
}
int main(){
	int N;
	cin>>N;
	vector<P> A(N*N*2),B;
	rep(i,N) rep(j,N){
		cin>>A[i*2*N+j];
	}
	B=A;
	reverse(all(B));
	auto C=conv(A,B);
	vector<long long> mp(1<<21);
	rep(i,N) for(int j=-N+1;j<=N-1;j++){
		if(i==0&&j<=0) continue;
		mp[i*i+j*j]+=fix(C[2*N*N-1-i*2*N+j]);
	}
	rep(i,N) rep(j,N){
		int x=fix(A[i*2*N+j]);
		mp[0]+=x*(x-1)/2;
	}
	long long sum=0;
	double ave=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		ave+=sqrt(i)*mp[i];
		sum+=mp[i];
	}
	printf("%.12f\n",ave/sum);
	int c=0;
	rep(i,N*N*2){
		if(mp[i]==0) continue;
		printf("%d %lld\n",i,mp[i]);
		c++;
		if(c==10000) break;
	}
}

Compiler output:
a.cc:49:8: error: ISO C++ forbids declaration of 'fix' with no type [-fpermissive]
   49 | inline fix(P x){
      |        ^~~
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Rings {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double[] c1 = new double[3];// center
		double[] v11 = new double[3];
		double[] v12 = new double[3];
		double[] c2 = new double[3];
		double[] v21 = new double[3];
		double[] v22 = new double[3];
		for (int i = 0; i < 3; ++i)
			c1[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i)
			v11[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i)
			v12[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i)
			c2[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i)
			v21[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i)
			v22[i] = sc.nextDouble();
		for (int i = 0; i < 3; ++i) {
			c2[i] -= c1[i];
		}
		for (int i = 0; i < 3; ++i) {
			c1[i] -= c1[i];
		}
		double[] v13 = new double[3];
		for (int i = 0; i < 3; ++i) {
			v13[i] = v11[(i + 1) % 3] * v12[(i + 2) % 3] - v11[(i + 2) % 3] * v12[(i + 2) % 3];
		}

		double norm = 0;
		for (int i = 0; i < 3; ++i) {
			norm += v11[i] * v11[i];
		}
		norm = Math.sqrt(norm);

		for (int i = 0; i < 3; ++i) {
			v13[i] /= norm;
		}

		v21 = convert(v11, v12, v13, norm, v21);
		v22 = convert(v11, v12, v13, norm, v22);
		c2 = convert(v11, v12, v13, norm, c2);

		ArrayList<Double> o = new ArrayList<>();
		ArrayList<Double> dist = new ArrayList<>();
		for (double i = 0; i < 2 * Math.PI; i += 2 * Math.PI / 1000000) {
			double[] v = new double[3];
			for (int j = 0; j < 3; ++j) {
				v[j] = v21[j] * Math.cos(i) + v22[j] * Math.sin(i) + c2[j];
			}
			if (Math.abs(v[2]) < 0.0001) {
				o.add(i);
				dist.add(Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
			}
		}
		int over = 0, less = 0;
		for (double d : dist) {
			if (d > 1)
				++over;
			else
				++less;
		}
		if (over >= 1 && less >= 1) {
			System.out.println("YES");
			return;
		}
		System.out.println("NO");

	}

	static double[] convert(double[] v1, double[] v2, double[] v3, double norm, double[] subject) {
		double[] ret = new double[3];
		for (int i = 0; i < 3; ++i) {
			ret[0] += v1[i] * subject[i];
			ret[1] += v2[i] * subject[i];
			ret[2] += v3[i] * subject[i];
		}

		for (int i = 0; i < 3; ++i) {
			ret[i] /= norm;
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#define INF -2000000000
using namespace std;
vector <int> s;
int check(int x){
  for(int i=1;i<s.size()-1;i++){
    int ima = s[i],nx = s[i+1],mae = s[i-1];
    if(ima == INF) ima = x;
    if(nx == INF) nx = x;
    if(mae == INF) mae = x;
    
    if(i%2 == 0 && (ima >= mae || ima>= nx)) 
      if(s[i] == INF)return -1;
      else return 1;

    else if(i%2==1 &&(mae >= ima||nx >= ima)) 
      if(s[i] == INF)  return 1;
      else return -1;
  }

  if(s.size() == 2) {
    int ima = s[0],nx = s[1];
    if(s[0] == INF) ima = x;
    if(s[1] == INF) nx  = x;
    if(ima >= nx) 
      if(s[0] == INF) return -1;
      else return 1;
  }
  return 0;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    s.clear();
    for(int i=0;i<n;i++) {
      string str;
      cin >> str;
      if(str == "x") s.push_back(INF);
      else s.push_back(atoi(str));
    }
  
    int R = 1000000010,L=-1000000011,M,ans = INF,cnt = 0;
    while(L < R) {
      cnt ++;
      int t = M;
      M = (L+R)/2;
      if(M == t) L--,R++,M=(L+R)/2;
      if(cnt > 35) break;
      int res = check(M);
      if(res == -1) R = M;
      else if(res == 1) L=M+1;
      else if(res == 0) {
	ans = M;
	break;
      }
    }

    if(ans == INF) cout << "none"<<endl;
    else if(check(ans+1) == 0 || check(ans-1) == 0) cout << "ambiguous"<<endl;
    else cout << ans <<endl;
  }
  return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:29: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   45 |       else s.push_back(atoi(str));
      |                             ^~~
      |                             |
      |                             std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

#define int long long

int N;
int x[1000];

int toint(string &s){
    stringstream ss(s);
    int ret;
    ss>>ret;
    return ret;
}


int main(){
    while(cin>>N,N){
        rep(i,N){
            string s;cin>>s;
            if(s[0]=='x')x[i]=-1;
            else x[i]=toint(s);
        }

        bool ok=true;
        rep(i,N-1){
            if(x[i]==-1&&x[i+1]==-1)ok=false;
        }

        rep(i,N-1){
            if(x[i]==-1)continue;
            if(x[i+1]==-1)continue;

            if(i&1){
                if(x[i+1]>=x[i])ok=false;
            }
            else{
                if(x[i+1]<=x[i])ok=false;
            }
        }

        if(!ok){
            cout<<"none"<<endl;
            continue;
        }

        int l=-1001001001,u=1001001001;

        rep(i,N){
            if(x[i]!=-1)continue;
            if(i&1){
                if(i)chmax(l,x[i-1]+1);
                if(i+1<N)chmax(l,x[i+1]+1);
            }
            else{
                if(i)chmin(u,x[i-1]-1);
                if(i+1<N)chmin(u,x[i+1]-1);
            }
        }

        if(l>u)cout<<"none"<<endl;
        else if(l==u)cout<<l<<endl;
        else cout<<"ambiguous"<<endl;
    }
    return 0;
}

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

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9 + 2;

int stoi(string s){
    int res = 0;
    REP(i,s.length()){
        res = 10*res + s[i]-'0';
    }
    return res;
}

int main() {
    int n;
    while (cin >> n && n){
        VI a(n+2), c(n+2);
        FOR(i,1,n){
            string s;
            cin >> s;
            if (s == "x") {
                c[i] = 1;
                if (i % 2 == 1)
                    a[i] = -INF;
                else
                    a[i] = INF;
            }
            else a[i] = stoi(s);
        }
        a[0] = INF;
        if (n % 2 == 1) a[n+1] = INF;
        else a[n+1] = -INF;
        bool d = 0;
        FOR(i,1,n-1) if (c[i] & c[i+1]) d = 1;
        FOR(i,1,n){
            if (i % 2 == 1 && (a[i] >= a[i-1] || a[i] >= a[i+1])) d = 1;
            if (i % 2 == 0 && (a[i] <= a[i-1] || a[i] <= a[i+1])) d = 1;
        }
        if (d) {
            cout << "none" << endl;
            continue;
        }

        int mi = -INF, ma = INF;
        FOR(i,1,n){
            if (c[i] && i % 2 == 1)
                ma = min({ma, a[i-1]-1, a[i+1]-1});
            else if (c[i] && i % 2 == 0)
                mi = max({mi, a[i-1]+1, a[i+1]+1});
        }

        if (mi == ma) cout << mi << endl;
        else if (mi < ma) cout << "ambiguous" << endl;
        else cout << "none" << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:29: error: call of overloaded 'stoi(std::string&)' is ambiguous
   51 |             else a[i] = stoi(s);
      |                         ~~~~^~~
a.cc:29:5: note: candidate: 'int stoi(std::string)'
   29 | int stoi(string s){
      |     ^~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long
#define BIG 1000000000

int solve(vector<int> &vec){
  int n=vec.size();
  // check
  rep(i,n-1){
    if(vec[i]==INF && vec[i+1]==INF) return -INF;
    if(vec[i]!=INF && vec[i+1]!=INF){
      if(i%2==0) if(vec[i] > vec[i+1]) return -INF;
      if(i%2==1) if(vec[i] < vec[i+1]) return INF;
    }
  }
  int lb=-BIG, ub=BIG;
  repl(i,1,n-1) if(vec[i]==INF){
    if(i%2==0){
      ub = min(ub, min(vec[i-1], vec[i+1])-1);
    } else {
      lb = max(lb, max(vec[i-1], vec[i+1])+1);
    }
  }
  if(vec[0]==INF) lb = max(lb, vec[1]+1);
  if(vec[n-1]==INF){
    if(n%2==1) ub = min(ub, vec[n-2]-1);

Compiler output:
a.cc: In function 'int solve(std::vector<int>&)':
a.cc:51:41: error: expected '}' at end of input
   51 |     if(n%2==1) ub = min(ub, vec[n-2]-1);
      |                                         ^
a.cc:50:20: note: to match this '{'
   50 |   if(vec[n-1]==INF){
      |                    ^
a.cc:51:41: error: expected '}' at end of input
   51 |     if(n%2==1) ub = min(ub, vec[n-2]-1);
      |                                         ^
a.cc:31:28: note: to match this '{'
   31 | int solve(vector<int> &vec){
      |                            ^
a.cc:51:41: warning: control reaches end of non-void function [-Wreturn-type]
   51 |     if(n%2==1) ub = min(ub, vec[n-2]-1);
      |                                         ^
Language: C++

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long
#define BIG 1000000000

int solve(vector<int> &vec){
  int n=vec.size();
  // check
  rep(i,n-1){
    if(vec[i]==INF && vec[i+1]==INF) return -INF;
    if(vec[i]!=INF && vec[i+1]!=INF){
      if(i%2==0) if(vec[i] >= vec[i+1]) return -INF;
      if(i%2==1) if(vec[i] <= vec[i+1]) return INF;
    }
  }
  int lb=-BIG, ub=BIG;
  repl(i,1,n-1) if(vec[i]==INF){
    if(i%2==0){
      ub = min(ub, min(vec[i-1], vec[i+1])-1);
    } else {
      lb = max(lb, max(vec[i-1], vec[i+1])+1);
    }
  }
  if(vec[0]==INF) ub = mix(lb, vec[1]-1);
  if(vec[n-1]==INF){
    if(n%2==1) ub = min(ub, vec[n-2]-1);
    else lb = max(lb, vec[n-2]+1);
  }
  if(lb==ub) return lb;
  else if(lb<ub) return INF;
  else return -INF;
}

int main(){
  int n;
  while(cin>>n, n){
    char tmp[15];
    vector<int> vec(n);
    rep(i,n){
      scanf("%s", tmp);
      if(tmp[0]=='x') vec[i]=INF;
      else vec[i] = atoi(tmp);
    }
    int ret = solve(vec);
    if(ret==INF) cout<<"ambiguous"<<endl;
    else if(ret==-INF) cout<<"none"<<endl;
    else cout<<ret<<endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int solve(std::vector<int>&)':
a.cc:49:24: error: 'mix' was not declared in this scope
   49 |   if(vec[0]==INF) ub = mix(lb, vec[1]-1);
      |                        ^~~
Language: C++

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (int N; cin >> N&&N;) {
		vector<string> v(N); rep(i, 0, N) { cin >> v[i]; }
		rep(i, 1, N) {
			if (v[i] == "x"&&v[i - 1] == "x")
				goto NONE;
			if (v[i - 1] != "x"&&v[i] != "x") {
				if (i & 1) {
					if (v[i - 1] >= v[i])goto NONE;
				}
				else {
					if (v[i - 1] <= v[i])goto NONE;
				}
			}
		}
		int l = -INF, r = INF;
		rep(i, 0, N) {
			if (v[i] != "x") continue;
			if (i & 1) {
				if (i != 0)l = max(l, stoi(v[i - 1]) + 1);
				if (i != N - 1)l = max(l, stoi(v[i + 1]) + 1);
			}
			else {
				if (i != 0)r = min(r, stoi(v[i - 1]) - 1);
				if (i != N - 1)r = min(r, stoi(v[i + 1]) - 1);
			}
		}
		if (l == r) {
			cout << l << endl;
		}
		else if (l < r) {
			cout << "ambiguous" << endl;
		}
		else {
		NONE:
			cout << "none" << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: jump to label 'NONE'
   48 |                 NONE:
      |                 ^~~~
a.cc:19:38: note:   from here
   19 |                                 goto NONE;
      |                                      ^~~~
a.cc:29:31: note:   crosses initialization of 'int r'
   29 |                 int l = -INF, r = INF;
      |                               ^
a.cc:29:21: note:   crosses initialization of 'int l'
   29 |                 int l = -INF, r = INF;
      |                     ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
#define mod 1000000007
string A, B, C; long long dp[60][3];
int main() {
	while (true) {
		cin >> A; if (A == "0")break;
		cin >> B >> C;
		for (int i = 0; i < 180; i++)dp[i / 3][i % 3] = 0;
		reverse(A.begin(), A.end()); int A1 = A.size();
		reverse(B.begin(), B.end()); int B1 = B.size();
		reverse(C.begin(), C.end()); int C1 = C.size();
		while (A.size() < 50)A = A + '0';
		while (B.size() < 50)B = B + '0';
		while (C.size() < 50)C = C + '0';
		dp[0][0] = 1;
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 3; j++) {
				int a = 0, b = 0, c = 0;
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						int m = j + k + l;
						if ((k != (int)(A[i] - '0') && A[i] != '?') || (i == A1 - 1 && k == 0))continue;
						if ((l != (int)(B[i] - '0') && B[i] != '?') || (i == B1 - 1 && l == 0))continue;
						if ((m % 10 != (int)(C[i] - '0') && C[i] != '?') || (i == C1 - 1 && m % 10 == 0))continue;
						if (m >= 0 && m < 10)a++;
						if (m >= 10 && m < 20)b++;
						if (m >= 20 && m < 30)c++;
					}
				}
				dp[i + 1][0] += dp[i][j] * a; dp[i + 1][0] %= mod;
				dp[i + 1][1] += dp[i][j] * b; dp[i + 1][1] %= mod;
				dp[i + 1][2] += dp[i][j] * c; dp[i + 1][2] %= mod;
			}
		}
		cout << (dp[50][0] + dp[50][1] + dp[50][2]) % mod << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'reverse' was not declared in this scope
   11 |                 reverse(A.begin(), A.end()); int A1 = A.size();
      |                 ^~~~~~~
Language: C++

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

#define all(c) begin(c), end(c)

const int MOD = 1e9 + 7;
string A, B, C;
int a[55], b[55], c[55];

int main() {
    while (cin >> A >> B >> C && A != "0") {
        reverse(all(A));
        reverse(all(B));
        reverse(all(C));
        int n = A.size();
        for (size_t i = 0; i < n; i++) {
            a[i] = isdigit(A[i]) ? A[i] - '0' : -1;
            b[i] = isdigit(B[i]) ? B[i] - '0' : -1;
            c[i] = isdigit(C[i]) ? C[i] - '0' : -1;
        }
        
        int dp[55][2] = {};
        dp[0][0] = 1;
        for (size_t i = 0; i < n; i++) {
            for (size_t j = 0; j < 2; j++) {
                for (size_t ia = 0; ia < 10; ia++) {
                    for (size_t ib = 0; ib < 10; ib++) {
                        for (size_t ic = 0; ic < 10; ic++) {
                            if (a[i] != -1 && ia != a[i]) continue;
                            if (b[i] != -1 && ib != b[i]) continue;
                            if (c[i] != -1 && ic != c[i]) continue;
                            if (i == n - 1 && (ia == 0 || ib == 0 || ic == 0)) continue;
                            int dig = ia + ib + j;
                            if (dig % 10 != ic) continue;
                            (dp[i + 1][dig >= 10] += dp[i][j]) %= MOD;
                        }
                    }
                }

            }
        }
        cout << dp[n][0] << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'reverse' was not declared in this scope
   15 |         reverse(all(A));
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);
string A, B, C;

int N;
ll dp[51][2][2];

int main(){
    while(cin >> A, A != "0"){
        cin >> B >> C;
        reverse(A.begin(), A.end());
        reverse(B.begin(), B.end());
        reverse(C.begin(), C.end());

        N = A.size();
        memset(dp, 0, sizeof dp);
        int sle = 1;
        dp[0][0][sle] = 1;
        for(int i = 0; i < N; i++){
            for(int c = 0; c < 2; c++){
                for(int le = 0; le < 2; le++){
                    //cerr << i << " " << c << " " << le << " " << dp[i][c][le] << endl;

                    if(dp[i][c][le] == 0) continue;

                    int fixa = -1, fixb = -1;
                    if(isdigit(A[i])) fixa = A[i] - '0';
                    if(isdigit(B[i])) fixb = B[i] - '0';
                    for(int a = 0; a < 10; a++){
                        if(fixa != -1 && a != fixa) continue;
                        if(i == N - 1 && a == 0) continue;
                        for(int b = 0; b < 10; b++){
                            if(fixb != -1 && b != fixb) continue;
                            if(i == N - 1 && b == 0) continue;

                            int s = a + b + c;
                            int x = s % 10;

                            //cerr << "\t" <<  a << " " << b << " " << x << endl;
                            if(isdigit(C[i]) && C[i] - '0' != x) continue;
                            int cc = isdigit(C[i]) ? C[i] - '0' : 9;

                            int ncarry = s / 10;
                            int nle = 0;
                            if(le){
                                nle = (x <= cc);
                            }
                            else{
                                nle = (x < cc);
                            }
                            

                            dp[i + 1][ncarry][nle] += dp[i][c][le];
                            dp[i + 1][ncarry][nle] %= MOD;
                        }
                    }
                }
            }
        }

        cout << dp[N][0][1] << endl;
        //return 0;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'reverse' was not declared in this scope
   15 |         reverse(A.begin(), A.end());
      |         ^~~~~~~
a.cc:20:9: error: 'memset' was not declared in this scope
   20 |         memset(dp, 0, sizeof dp);
      |         ^~~~~~
a.cc:2:1: note: 'memset' 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>
#include <string>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);
string A, B, C;

int N;
ll dp[51][2][2];

int main(){
    while(cin >> A, A != "0"){
        cin >> B >> C;
        reverse(A.begin(), A.end());
        reverse(B.begin(), B.end());
        reverse(C.begin(), C.end());

        N = A.size();
        memset(dp, 0, sizeof dp);
        int sle = 1;
        dp[0][0][sle] = 1;
        for(int i = 0; i < N; i++){
            for(int c = 0; c < 2; c++){
                for(int le = 0; le < 2; le++){
                    //cerr << i << " " << c << " " << le << " " << dp[i][c][le] << endl;

                    if(dp[i][c][le] == 0) continue;

                    int fixa = -1, fixb = -1;
                    if(isdigit(A[i])) fixa = A[i] - '0';
                    if(isdigit(B[i])) fixb = B[i] - '0';
                    for(int a = 0; a < 10; a++){
                        if(fixa != -1 && a != fixa) continue;
                        if(i == N - 1 && a == 0) continue;
                        for(int b = 0; b < 10; b++){
                            if(fixb != -1 && b != fixb) continue;
                            if(i == N - 1 && b == 0) continue;

                            int s = a + b + c;
                            int x = s % 10;

                            //cerr << "\t" <<  a << " " << b << " " << x << endl;
                            if(isdigit(C[i]) && C[i] - '0' != x) continue;
                            int cc = isdigit(C[i]) ? C[i] - '0' : 9;

                            int ncarry = s / 10;
                            int nle = 0;
                            if(le){
                                nle = (x <= cc);
                            }
                            else{
                                nle = (x < cc);
                            }
                            

                            dp[i + 1][ncarry][nle] += dp[i][c][le];
                            dp[i + 1][ncarry][nle] %= MOD;
                        }
                    }
                }
            }
        }

        cout << dp[N][0][1] << endl;
        //return 0;
    }
    return 0;
}

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


#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  const int INF = 1e9;
  int n, m, l, s, t;
  int dp[1 << 16][17];
  
  while (cin >> n >> m >> l >> s >> t && n ){
    vector<vector<pair<int, int> > > G(n);
    
    REP(i, m){
      int a, b, c;
      cin >> a >> b >> c; a--, b--;
      G[a].push_back(make_pair(b, c));
      G[b].push_back(make_pair(a, c));
    }
    
    vector<int> S(l + 1);
    vector<int> E(l + 1);
    vector<vector<int> >C(l + 1, vector<int>(l + 1));
    
    REP(i, l){
      cin >> S[i] >> E[i]; S[i]--;
    }
    
    S[l] = s - 1;
    E[l] = 0;

    REP(i, l + 1){
      typedef pair<int, int> P;
      
      vector<int> D(n, INF);
      priority_queue<P, vector<P>, greater<P>> que;
      
      que.push(P(0, S[i]));
      D[S[i]] = 0;

      while (!que.empty()){
        int v = que.top().second;
        int c = que.top().first;
        que.pop();

        if (D[v] < c) continue;

        REP(i, G[v].size()){
          int to = G[v][i].first;
          int nc = c + G[v][i].second;

          if (D[to] > nc){
            D[to] = nc;
            que.push(P(nc, to));
          }
        }
      }
      
      REP(j, l + 1) C[i][j] = D[S[j]];
    }

    fill(&dp[0][0], &dp[0][0] + 17 * (1 << 16), INF);
    dp[0][l] = 0;
    
    int res = 0;
    
    REP(mask, 1 << l) REP(u, l + 1) if (dp[mask][u] < INF){

      if (dp[mask][u] + C[u][l] <= t){
        res = max(res, __builtin_popcount(mask));
      } else {
        continue;
      }
      
      REP(v, l + 1){
        int nc = dp[mask][u] + C[u][v] + E[v];
        int nm = v == l ? mask : (mask | (1 << v));

        if (dp[nm][v] == -1 || dp[nm][v] > nc){
          dp[nm][v] = nc;
        }
      }
    }
    
    cout << res << endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:3: error: 'ios' has not been declared
   17 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:23:10: error: 'cin' was not declared in this scope
   23 |   while (cin >> n >> m >> l >> s >> t && n ){
      |          ^~~
a.cc:9:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    8 | #include <unordered_set>
  +++ |+#include <iostream>
    9 | using namespace std;
a.cc:97:5: error: 'cout' was not declared in this scope
   97 |     cout << res << endl;
      |     ^~~~
a.cc:97:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:97:20: error: 'endl' was not declared in this scope
   97 |     cout << res << endl;
      |                    ^~~~
a.cc:9:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    8 | #include <unordered_set>
  +++ |+#include <ostream>
    9 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#define inf 1e9
using namespace std;
typedef pair<int,int> ii;
vector< vector<int> > g;
vector< vector<int> > adj;
vector<ii> v1;
int re,n,m,l,s,dp[1<<19][20];

int f(int i1,int t,int xz){
if(dp[i1][xz]!=-1) return dp[i1][xz];
else if(xz==0) return 0;
else{
    num++;
    if(t-v1[xz].second<0){
        dp[i1][xz]=0;
        return dp[i1][xz];
    }
    t=t-v1[xz].second;
    int i2=i1;
    i2|=(1<<xz);
    if(t-adj[xz][0]<0){
        dp[i1][xz]=0;
        return dp[i1][xz];
    }
    dp[i1][xz]=f(i2,num,t-adj[xz][0],0);
    for(int j1=1;j1<=l;j1++){
        if(!(i2&(1<<j1))){
            if(t-adj[xz][j1]>=0) dp[i1][xz]=max(f(i2,t-adj[xz][j1],j1),dp[i1][xz]);
        }
    }
    dp[i1][xz]++;
    return dp[i1][xz];
}
}

int main(){
int t,x,y,z;
cin>>n>>m>>l>>s>>t;
while(n||m||l||s||t){
v1.clear();
g.assign(n+1,vector<int>(n+1,inf));
memset(dp,-1,sizeof(dp));
for(int i=0;i<m;i++){
    cin>>x>>y>>z;
    g[x][y]=min(z,g[x][y]);
    g[y][x]=min(z,g[y][x]);
}
v1.push_back(ii(s,0));
for(int i=0;i<l;i++){
    cin>>x>>y;
    v1.push_back(ii(x,y));
}
for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
        }
    }
}
adj.clear();
for(int i=0;i<v1.size();i++){
    vector<int> vv;
    for(int j=0;j<v1.size();j++) vv.push_back(g[v1[i].first][v1[j].first]);
    adj.push_back(vv);
}
re=0;
for(int i=1;i<=l;i++){
    if(adj[0][i]<=t){
        re=max(f(1,t-adj[0][i],i),re);
    }
}
cout<<re<<endl;
cin>>n>>m>>l>>s>>t;
}
return 0;
}

Compiler output:
a.cc: In function 'int f(int, int, int)':
a.cc:14:5: error: 'num' was not declared in this scope; did you mean 'enum'?
   14 |     num++;
      |     ^~~
      |     enum
Language: C++

#include<iostream>
#include<queue>

using namespace std;

struct edge{
  int v,c;
};

struct S{
  int v,t,b;
  bool operator<(S s)const{
    return t>s.t;
  }
};

bool u[323][1<<16];

int main(){
  for(int n,m,l,s,t;cin>>n>>m>>l>>s>>t,n|m|l|s|t;){
    vector<edge> G[323];
    for(int i=0;i<m;i++){
      int a,b,c;
      cin>>a>>b>>c;
      G[a].push_back({b,c});
      G[b].push_back({a,c});
    }
    int idx[323],e[323];
    fill(begin(idx),end(idx),-1);
    for(int i=0;i<l;i++){
      int j;
      cin>>j;
      idx[j]=i;
      cin>>e[j];
    }
    priority_queue<S> que;
    que.push({s,0,0});
    int ans=0;
    fill(*begin(u),*end(u),false);
    while(!que.empty()){
      auto c=que.top();
      if(c.t>t)break;
      que.pop();
      if(u[c.v][c.b]++)continue;
      if(c.v==s){
	ans=max(ans,__builtin_popcount(c.b));
      }
      for(auto e:G[c.v]){
	que.push({e.v,c.t+e.c,c.b});
      }
      if(idx[c.v]>=0){
	que.push({c.v,c.t+e[c.v],c.b|1<<idx[c.v]});
      }
    }
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:20: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   44 |       if(u[c.v][c.b]++)continue;
      |          ~~~~~~~~~~^
Language: C++

#include<iostream>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
 
ll pow(ll a, ll n){
  ll res = 1;
  while(n){
    if(n&1)(res *= a) %= mod;
    (a *= a) %= mod; n>>=1;
  }
  return res;
}
 
int n,m,a,b;
 
int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
 
  while(cin >> n >> m, n){
    ll ans = pow(2,g.size());
    if(m>0)ans++, ans%=mod;
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:20: error: 'g' was not declared in this scope
   24 |     ll ans = pow(2,g.size());
      |                    ^
Language: C++

#include<iostream>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
 
int uf[100100], r[100100];
 
void init(int n){
  rep(i,n)uf[i] = i, r[i] = 0;
}
 
int find(int a){
  if(uf[a] == a)return a;
  return uf[a] = find(uf[a]);
}
 
void unite(int a,int b){
  a = find(a); b = find(b);
  if(a==b)return;
  if(r[a] < r[b])uf[a] = b;
  else{
    uf[b] = a;
    if(r[a] == r[b])r[b]++;
  }
}
 
ll pow(ll a, ll n){
  ll res = 1;
  while(n){
    if(n&1)(res *= a) %= mod;
    (a *= a) %= mod; n>>=1;
  }
  return res;
}
 
int n,m,a,b;
 
int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
 
  while(cin >> n >> m, n){
    init(n);
 
    rep(i,m){
      cin >> a >> b; a--; b--;
      unite(a,b);
    }
 
    map<int,int> g;
    rep(i,n)g[find(i)]++;
     
    ll ans = pow(2,g.size());
    if(m>0)ans++, ans%=mod;
    cout << ans << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:58:4: error: expected '}' at end of input
   58 |   }
      |    ^
a.cc:40:11: note: to match this '{'
   40 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
 
int uf[100100], r[100100];
 
void init(int n){
  rep(i,n)uf[i] = i, r[i] = 0;
}
 
int find(int a){
  if(uf[a] == a)return a;
  return uf[a] = find(uf[a]);
}
 
void unite(int a,int b){
  a = find(a); b = find(b);
  if(a==b)return;
  if(r[a] < r[b])uf[a] = b;
  else{
    uf[b] = a;
    if(r[a] == r[b])r[b]++;
  }
}
 
ll pow(ll a, ll n){
  ll res = 1;
  while(n){
    if(n&1)(res *= a) %= mod;
    (a *= a) %= mod; n>>=1;
  }
  return res;
}
 
int n,m,a,b;
 
int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
 
  while(cin >> n >> m, n){
    init(n);
 
    rep(i,m){
      cin >> a >> b; a--; b--;
      unite(a,b);
    }
 
    map<int,int> g;
    rep(i,n)g[find(i)]++;
     
    ll ans = pow(2,g.size());
    if(m>0)ans++;
    cout << ans%mod << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:58:4: error: expected '}' at end of input
   58 |   }
      |    ^
a.cc:40:11: note: to match this '{'
   40 | int main(){
      |           ^
Language: C++

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

class union_find{
	private:
	vector<int> parent,rank;
	int size;
	public:
    int cnt;

    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		cnt=n;
		parent.resize(size);
		rank.resize(size);
		for(int i=0; i<size; ++i){
			parent[i]=i;
			rank[i]=0;
		}
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
		} else {
			parent[y]=x;
			if(rank[x]==rank[y]) ++rank[x];
		}
		--cnt;
	}

	bool is_same(int x,int y){
		return find(x)==find(y);
	}
};

void solve(){
    const ll mod=1000000007;
    while(true){
        ll n,m;
        cin >> n >> m;
        if(n==0 and m==0) break;

        if(m==0){
            cout << mod_pow(2,n) << endl;
            continue;
        }

        union_find uf(n);

        set<int> s;
        rep(i,0,m){
            int a,b;
            cin >> a >> b;
            --a;
            --b;
            uf.unite(a,b);
            s.insert(a);
            s.insert(b);
        }
        ll ans=1;
        rep(i,0,n){
            if(s.find(i)!=s.end()) continue;
            ans=ans*2%mod;
        }
        ans=(ans+n-uf.cnt)%mod;
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:84:21: error: 'mod_pow' was not declared in this scope
   84 |             cout << mod_pow(2,n) << endl;
      |                     ^~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<cstdlib>
#include<sstream>
#define mod 1000000007
using namespace std;

typedef long long ll;

string f1(string a){
  ll x=(ll)atoi(a.c_str());
  x=(x*x)%mod;
  ostringstream os;
  os<<x;
  return os.str();
}

string f2(string a,string b){
  ll x=atoi(a.c_str()),y=atoi(b.c_str()),c=1;
  for(int i=0;i<y;i++){
    c*=2;
    if(x<c)return "0";
  }
  x=x/c;
  ostringstream os;
  os<<x;
  return os.str();
}

string rec(vector<string> a){
  for(int i=0;i<a.size();i++){
    if(a[i]=="S<"){
      int l=1,r=0;
      vector<string> b;
      for(int j=i+1;j<a.size();j++){
	if(a[j]=="S<")l++;
	if(a[j]==">")r++;
	if(l==r){
	  a[j-1]=rec(b);
	  i=j-1;
	  break;
	}
        b.push_back(a[j]);
      }
    }
    else if(a[i]==">>"){
      a[i+1]=f2(a[i-1],a[i+1]);
    }
    else if(a[i]==">")a[i]=f1(a[i-1]);
  }
  return a[a.size()-1];
}

int main()
{
  while(1){
    string s,t;
    vector<string> a,b;
    t="";
    getline(cin,s);
    if(s[0]=='#')break;
    for(int i=0;i<s.length();i++)if(s[i]!=' ')t+=s[i];
    string tmp="";
    for(int i=0;i<t.length();i++){
      if(t[i]=='S'){
	a.push_back("S<");
	i++;
      }
      else if(t[i]=='>'){
	if(tmp!="")a.push_back(tmp);
	tmp="";
	a.push_back(">");
      }
      else tmp+=t[i];
      if(i==t.length()-1 && tmp!="")a.push_back(tmp);
    }
    for(int i=a.size()-1;0<i;i--){
      if(a[i]!=">" && a[i]!="S<"){
	b.push_back(a[i]);
	if(a[i-1]==">"){
	  i-=2;
	  b.push_back(">>");
	}
      }
      else b.push_back(a[i]);
    }
    b.push_back(a[0]);
    reverse(b.begin(),b.end());
    cout<<rec(b)<<endl;
  }
  return 0;
}

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

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll
const ll MOD = 1e9+7;
typedef string::const_iterator state;

string t;
int expr(state &end);

ll power(ll a,ll b/*,ll mod*/){
    ll ret=1;
    if(b>0){
        ret = power(a,b/2/*,mod*/);
        if(b%2==0)ret = (ret*ret)/*%mod*/;
        else ret = (((ret*ret)/*%mod*/)*a)/*%mod*/;
    }
    return ret;
}

int number(state &end){
    string str="";
    while(isnumber(*end)){
        str+=*end;
        end--;
    }
    reverse(all(str));
    
    int ret = 0;
    rep(i,str.size()){
        ret*=10;
        ret+=str[i]-'0';
    }
    return ret;
}

int term(state &end){
    if(*end=='>'){
        end--;
        int res = expr(end);
        end-=2;
        return (res*res)%MOD;
    }else if(isnumber(*end)){
        int res = number(end);
        return res;
    }else{
        throw"impossible";
        return -1;
    }
}

int expr(state &end){
    if(end+1==t.begin())throw "empty";
    
    vector<int> res;
    res.pb( term(end) );
    
    while(end+1!=t.begin()&&*end!='<'){
        end-=2;
        res.pb( term(end) );
    }
    
    reverse(all(res));
    int tmp = res[0];
    
    for(int i=1;i<res.size();i++){
        rep(j,res[i]){
            if(tmp==0)break;
            tmp/=2;
        }
    }
    
    return tmp;
}

signed main(){
    string s;
    while(getline(cin,s)&&s!="#"){
        t = "";
        rep(i,s.size())if(s[i]!=' ')t+=s[i];
        
        state st = t.end()-1;
        int ans;
        try{
            ans = expr(st);
        }catch(char const* e){
            cout<<"error"<<e<<endl;
            exit(-1);
        }
        cout<<ans<<endl;
    }
}

Compiler output:
a.cc: In function 'll number(state&)':
a.cc:30:11: error: 'isnumber' was not declared in this scope; did you mean 'number'?
   30 |     while(isnumber(*end)){
      |           ^~~~~~~~
      |           number
a.cc: In function 'll term(state&)':
a.cc:50:14: error: 'isnumber' was not declared in this scope; did you mean 'number'?
   50 |     }else if(isnumber(*end)){
      |              ^~~~~~~~
      |              number
a.cc:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef pair<int, int> p;

int main(){
    int n;
    while(cin >> n && n > 0){
        if(n == 1){
            cout << 0 << endl;
            continue;
        }
        if(n == 2) {
            int p1, t1, p2, t2;
            cin >> p1 >> t1 >> p2 >> t2;
            cout << abs(p1 - p2) << endl;
            continue;
        }
        vector<long long> p1;
        vector<long long> p2;
        vector<p> pv;
        rep(i, n) {
            int p, t;
            cin >> p >> t;
            if(t == 1){
                p1.push_back(p);
            }else{
                pv.push_back(p(p, t - 2));
            }
        }

        sort(pv.begin(), pv.end());
        if(pv.size() > 1) {
            pv[0].second ++;
            pv[pv.size() - 1].second ++;
        }
        rep(i, pv.size()){
            rep(_, pv[i].second){
                p2.push_back(pv[i].first);
            }
        }

        int n1 = p1.size();
        int n2 = p2.size();

        if(n1 > n2) {
            cout << -1 << endl;
            continue;
        }

        sort(p1.begin(), p1.end());
        sort(p2.begin(), p2.end());

        long long ans = *max_element(p2.begin(), p2.end()) - *min_element(p2.begin(), p2.end());
        // cout << ans << endl;
        // cout << "p1 : "; rep(i, p1.size()) cout << p1[i] << " "; cout << endl;
        // cout << "p2 : "; rep(i, p2.size()) cout << p2[i] << " "; cout << endl;

        vector<long long> dp(2 * n1 + 1, 0);
        int last_base2 = -1;
        for(int i1 = 0; i1 < n1; i1++){
            vector<long long> next(2 * n1, llong_max);
            int base2 = lower_bound(p2.begin(), p2.end(), p1[i1]) - p2.begin();
            for(int di = 0; di < 2 * n1; di++){
                int i2 = di - n1 + base2;
                if(i2 >= i1 && i2 < n2){
                    // lastdi - n1 + last_base2 == (i2 - 1)
                    int lastdi = (i2 - 1) - last_base2 + n1;
                    assert(lastdi >= 0);
                    long long last = (lastdi < 2 * n1 ? dp[lastdi] : dp.back());
                    if(last == llong_max) continue;
                    next[di] = last + abs(p1[i1] - p2[i2]);
                    // printf("i1 = %d i2 = %d di = %d base = %d lastdi = %d last = %lld next[%d] <- %lld + %lld = %lld\n", i1, i2, di, base2, lastdi, last, di, last, abs(p1[i1] - p2[i2]), next[di]);
                }
            }
            for(int j = 1; j < 2 * n1; j++){
                next[j] = min(next[j], next[j - 1]);
            }
            last_base2 = base2;
            dp.swap(next);
        }

        cout << ans + dp.back() << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:31: error: 'p' cannot be used as a function
   29 |                 pv.push_back(p(p, t - 2));
      |                              ~^~~~~~~~~~
a.cc:63:44: error: 'llong_max' was not declared in this scope
   63 |             vector<long long> next(2 * n1, llong_max);
      |                                            ^~~~~~~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long double ld;
const ld pi=3.1415926535897932384626, eps=1e-9;
int main(){
	cout << setprecision(9);
	while(true){
		ld w,h,a,b,ab,a_c,b_c;
		cin >> w >> h >> a >> b >> ab;
		if(w<eps) break;
		a_c=a;b_c=b;
		if(a>b) swap(a,b);
		ld ra=sqrt(a/pi);
		ld rb=sqrt(b/pi);
		ld ub=pi,lb=0;
		int cnt=0;
		ld mid,phi;
		while(cnt<80){
			cnt++;
			mid=(ub+lb)/2;
			phi=asin( ra*sin(mid)/rb );
			if(ra*ra*mid-ra*ra*cos(mid)*sin(mid)+rb*rb*phi-rb*rb*cos(phi)*sin(phi)>ab) ub=mid;
			else lb=mid;
		}
		ld dis=ra*cos(mid)+rb*cos(phi);
//		cout << "    " << mid << "    " << dis << endl;
		if(2*rb>h || 2*rb>w){		//そもそもでかい円が入らない
			cout << "impossible" << endl;
			continue;
		}
		if(h-ra-rb>=dis){		//上にかなり広い
			if(a_c<b_c) cout << rb << " " << rb+dis << " " << ra << " " << rb << " " << rb << " " << rb << endl;
			else 		cout << rb << " " << rb << " " << rb << " " << rb << " " << rb+dis << " " << ra << endl;
			continue;
		}
		ld theta=asin( (h-ra-rb)/dis );			//(0<=()<=1   0<=theta<=pi/2)
		if(ra+rb+dis*cos(theta)>w){
			cout << "impossible" << endl;
			continue;
		}
		if(a_c<b_c) cout << rb+dis*cos(theta) << " " << h-ra << " " << ra << " " << rb << " " << rb << " " << rb << endl;
		else 		cout << rb << " " << rb << " " << rb << " " << rb+dis*cos(theta) << " " << h-ra << " " << ra << endl;
	}
	return 0;
}}

Compiler output:
a.cc:47:2: error: expected declaration before '}' token
   47 | }}
      |  ^