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

#include <stdio.h>
#include <math>

struct vertex{
	int x;
	int y;
};

double areaTriangle(vertex p1, vertex p2, vertex p3)
{
	double vec1_x = p2.x - p1.x, vec1_y = p2.y - p1.y;
	double vec2_x = p3.x - p1.x, vec2_y = p3.y - p1.y;
	
	return (vec1_x * vec2_y - vec1_y * vec2_x) / 2;
}

int main(void)
{
	int cnt = 0;
	int n;
	vertex p[50];
	
	double area;
	
	while(1){
		scanf("%d", &n);
		if(n == 0) break;
		
		for(int i = 0; i < n; i++){
			scanf("%d %d", &p[i].x, &p[i].y);
		}
		
		area = 0;
		for(int i = 1; i+1 < n; i++){
			area += areaTriangle(p[0], p[i], p[i+1]);
		}
		area = fabs(area);
		
		cnt++;
		printf("%d %.1f\n", cnt, area);
	}
	
	return 0;
}

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

import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		int n;
		int cnt=0;
		Scanner sc=new Scanner(System.in);
		while (true){
			n=sc.nextInt();
			if (n==0) break;
			double s=0.0;
			int [][] ver=new int[n][2];
			for (int i=0;i<n;i++){
				ver[i][0]=sc.nextInt();
				ver[i][1]=sc.nextInt();
				if(i>1){
					s+=cal(ver[i],ver[i-1],ver[0]);
				}
			}
			cnt++;
			System.out.println(cnt+" "+Math.abs(s/2));
		}
	}
	private static double cal(int [] a,int [] b,int [] o){
		a[0]=a[0]-o[0];
		a[1]=a[1]-o[1];
		b[0]=b[0]-o[0];
		b[1]=b[1]-o[1];
		return(a[0]*b[1]-a[1]*b[0]);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class Main {
      | ^~~~~~
Language: C++

#include <vector>
#include <complex>
using namespace std;
typedef complex<double> P;

double area(vector<P> polygon)
{
  const int N = polygon.size();
  double s = 0.0;
  for (int i = 0; i < N; i++) {
    s += polygon[i].real()*polygon[(i+1)%N].imag() - polygon[i].imag()*polygon[(i+1)%N].real();
  }
  return abs(s)/2.0;
}

int main()
{
  int c = 1;
  int n;
  while (cin >> n && n != 0) {
    vector<P> polygon(n);
    for (int i = 0; i < n; i++) {
      cin >> polygon[i].real() >> polygon[i].imag();
    }
    
    printf("%d %.1f\n", c, area(polygon));
    c++;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: 'cin' was not declared in this scope
   20 |   while (cin >> n && n != 0) {
      |          ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <complex>
  +++ |+#include <iostream>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <math>
#include <string>

using namespace std;

int main()
{
	int n;
	int c=1;
	double x[100] = {0};
	double y[100] = {0};

	while( cin >> n , n)
	{
		
		double out = 0;
		
		for( int i = 0; i < n; i++)
		{
			cin >> x[i] >> y[i];
		}
		
		for( int i = 0; i < n - 1 ; i++)
		{
			out += x[i]*y[i+1] - x[i+1]*y[i];
		}
		
		cout << c << " " << (float)abs(0.5*out) <<endl;
		
		c++;
		
		for( int i = 0; i < 100; i++)
		{
			x[i] = 0;
			y[i] = 0;
		}
	}
	
	return 0;
}

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

#include <iostream>
#include <math>

using namespace std;

int main()
{
	int n;
	int c=1;
	double x[100] = {0};
	double y[100] = {0};

	while( cin >> n , n)
	{
		double out = 0;
		
		for( int i = 0; i < n; i++)
		{
			cin >> x[i] >> y[i];
		}
		
		for( int i = 0; i < n - 1 ; i++)
		{
			out += x[i]*y[i+1] - x[i+1]*y[i];
		}
		
		cout << c++ << " " << 0.5*abs(out) <<endl;
		
		for( int i = 0; i < 100; i++)
		{
			x[i] = 0;
			y[i] = 0;
		}
	}
	
	return 0;
}

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

#include <vector>
#include <cmath>

using namespace std;
/*
double area(double x1,double y1,
        double x2,double y2,
        double x3,double y3){
    double vx1 = x2-x1;
    double vy1 = y2-y1;

    double vx2 = x3-x1;
    double vy2 = y3-y1;

    return (abs(vx1*vy2)+abs(vy1*vx2))/2.0;
}*/

int main(){

    int count=0;
    while(true){
        ++count;
        int n;
        double ans = 0.0;
        vector<double> vx;
        vector<double> vy;

        cin >> n;
        if(n==0)return 0;
        for(int i=0;i<n;i++){
            double x,y;
            cin >> x >> y;
            vx.push_back(x);
            vy.push_back(y);
        }
        for(int i =0;i<vx.size();i++){
            if(i==vx.size()-1){
                ans+=(vx[i]-vx[0])*(vy[i]+vy[0]);
                break;
            }
            ans+=(vx[i]-vx[i+1])*(vy[i]+vy[i+1]);
        }
        cout << count << " " << abs(ans/2.0) << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'cin' was not declared in this scope
   28 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cmath>
  +++ |+#include <iostream>
    3 | 
a.cc:43:9: error: 'cout' was not declared in this scope
   43 |         cout << count << " " << abs(ans/2.0) << endl;
      |         ^~~~
a.cc:43:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:49: error: 'endl' was not declared in this scope
   43 |         cout << count << " " << abs(ans/2.0) << endl;
      |                                                 ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cmath>
  +++ |+#include <ostream>
    3 |
Language: C++

import java.util.*;


public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int c = 0;

	    while(true){
		c++;
		int n = sc.nextInt();
		if(n==0) break;
		double a[][] = new double[n][2];
		for(int i=0 ;i<n ;i++){
		    a[i][0] = sc.nextDouble(); //x
		    a[i][1] = sc.nextDouble(); //y
		}
		double s = 0;
		for(int i=0;i<n-1;i++){
		    //    s += ((a[i][0]-a[i+1][0])*(a[i][1]+a[i+1][1]))/2;
		    s += (a[i][0]*a[i+1][1]-a[i][1]*a[i+1][0])/2;
		}
		s += (a[n-1][0]*a[0][1]-a[n-1][1]*a[0][0])/2;
	
		if(s<0){
		    s*=-1;
		}
		//System.out.print("%d %.1f",c,s);
		System.out.println(c+" "+s);
	    }
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main{
      | ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    #define cin in
    ifstream in("input.txt");
#endif // ONLINE_JUDGE
    int nb_points;
    int cas = 1;
    while(cin>>nb_points)
    {
        if(nb_points == 0) break;
        cout<<cas<<" ";
        cas++;
        vector<Point> points(nb_points);
        for(int c=0;c<nb_points;c++)
        {
            cin>>points[c].x>>points[c].y;
        }
        double res = 0;
        int deb = 0;
        for(int c=0;c<nb_points;c++)
        {
            res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
        }
        cout<<fixed<<setprecision(1)<<(res>0?res:-res)/2.<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:16: error: 'Point' was not declared in this scope
   33 |         vector<Point> points(nb_points);
      |                ^~~~~
a.cc:33:21: error: template argument 1 is invalid
   33 |         vector<Point> points(nb_points);
      |                     ^
a.cc:33:21: error: template argument 2 is invalid
a.cc:36:24: error: invalid types 'int[int]' for array subscript
   36 |             cin>>points[c].x>>points[c].y;
      |                        ^
a.cc:36:37: error: invalid types 'int[int]' for array subscript
   36 |             cin>>points[c].x>>points[c].y;
      |                                     ^
a.cc:42:25: error: invalid types 'int[int]' for array subscript
   42 |             res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
      |                         ^
a.cc:42:37: error: invalid types 'int[int]' for array subscript
   42 |             res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
      |                                     ^
a.cc:42:65: error: invalid types 'int[int]' for array subscript
   42 |             res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
      |                                                                 ^
a.cc:42:79: error: invalid types 'int[int]' for array subscript
   42 |             res+=(points[c].x+points[(c+1)%nb_points].x)*(points[(c)].y-points[(c+1)%nb_points].y);
      |                                                                               ^
Language: Java

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.math.BigDecimal;
      
public class Main{
  
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int MAX=10000;
static char[] str=new char[MAX+1];
  
public static void main(String[] args) throws IOException{
  Scanner sc=new Scanner(in);
  int n=sc.nextInt(); sc.nextLine();
  while(n-->0){
    String line=sc.nextLine();
    int cur=0;
    Arrays.fill(str,'-');
    for(int i=0;i<line.length();i++) str[i]=line.charAt(i);
    int m=sc.nextInt(); sc.nextLine();
    while(m-->0){
      String com0=sc.next();
      String com1=sc.next();
      if("forward".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-') cur++;
        }
        else{
          while(str[cur]==' ') cur++;
          while(str[cur]!=' '&&str[cur]!='-') cur++;
        }
      }
      else if("backward".equals(com0)){
        if("char".equals(com1)){
          if(cur>0) cur--;
        }
        else{
          while(cur>0&&str[cur-1]==' ') cur--;
          while(cur>0&&str[cur-1]!=' ') cur--;
        }
      }
      else if("insert".equals(com0)){
        if(com1.length()>2){
          String insertionStr=com1.substring(1,com1.length()-1);
          for(int i=MAX-insertionStr.length();i>=cur;i--){
            if(str[i]!='-') str[i+insertionStr.length()]=str[i];
          }
          for(int i=0;i<insertionStr.length();i++){
            str[cur+i]=insertionStr.charAt(i);
          }
          cur+=insertionStr.length();
        }
      }
      else if("delete".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-'){
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i+1];
            }
          }
        }
        else{
          int cnt=cur;
          while(str[cnt]==' ') cnt++;
          if(str[cnt]!='-'){
            while(str[cnt]!=' '&&str[cnt]!='-') cnt++;
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i-cur+cnt];
            }
          }
        }
      }
    }
    StringBuilder sb=new StringBuilder();
    for(int i=0;;i++){
      if(i==cur) sb.append("^");
      if(str[i]=='-') break;
      sb.append(String.valueOf(str[i]));
    }
    out.println(sb);
  }
out.flush();
}
}

Compiler output:
Main.java:29: error: cannot find symbol
  Scanner sc=new Scanner(in);
  ^
  symbol:   class Scanner
  location: class Main
Main.java:29: error: cannot find symbol
  Scanner sc=new Scanner(in);
                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.math.BigDecimal;
       
public class Main{
   
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int MAX=1000;
static char[] str=new char[MAX+1];
   
public static void main(String[] args) throws IOException{
  BufferedReader br=new BufferedReader(new InputStreamReader(in));
  int n=Integer.parseInt(br.readLine());
  while(n-->0){
    String line=br.readLine();
    int cur=0;
    Arrays.fill(str,'-');
    for(int i=0;i<line.length();i++) str[i]=line.charAt(i);
    int m=Integer.parseInt(br.readLine());
    while(m-->0){
      String com=br.readLine();
      String com0=com.split(" ")[0];
      String com1=com.split(" ")[1];
      if("forward".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-') cur++;
        }
        else if("word".equals(com1)){
          while(str[cur]==' ') cur++;
          while(str[cur]!=' '&&str[cur]!='-') cur++;
        }
      }
      else if("backward".equals(com0)){
        if("char".equals(com1)){
          if(cur>0) cur--;
        }
        else if("word".equals(com1)){
          while(cur>0&&str[cur-1]==' ') cur--;
          while(cur>0&&str[cur-1]!=' ') cur--;
        }
      }
      else if("insert".equals(com0)){
        String insertionStr="=com.substring(8,(com.length()-1));
        for(int i=MAX-insertionStr.length();i>=cur;i--){
          if(str[i]!='-') str[i+insertionStr.length()]=str[i];
        }
        for(int i=0;i<insertionStr.length();i++){
          str[cur+i]=insertionStr.charAt(i);
        }
        cur+=insertionStr.length();
      }
      else if("delete".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-'){
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i+1];
            }
          }
        }
        else if("word".equals(com1)){
          int cnt=cur;
          while(str[cnt]==' ') cnt++;
          if(str[cnt]!='-'){
            while(str[cnt]!=' '&&str[cnt]!='-') cnt++;
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i-cur+cnt];
            }
          }
        }
      }
    }
    StringBuilder sb=new StringBuilder();
    for(int i=0;;i++){
      if(i==cur) sb.append("^");
      if(str[i]=='-') break;
      sb.append(String.valueOf(str[i]));
    }
    out.println(sb);
    out.flush();
  }
}
}

Compiler output:
Main.java:60: error: unclosed string literal
        String insertionStr="=com.substring(8,(com.length()-1));
                            ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.math.BigDecimal;
       
public class Main{
   
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;
static int MAX=1000;
static char[] str=new char[MAX+1];
   
public static void main(String[] args) throws IOException{
  BufferedReader br=new BufferedReader(new InputStreamReader(in));
  int n=Integer.parseInt(br.readLine());
  while(n-->0){
    String line=br.readLine();
    int cur=0;
    Arrays.fill(str,'-');
    for(int i=0;i<line.length();i++) str[i]=line.charAt(i);
    int m=Integer.parseInt(br.readLine());
    while(m-->0){
      String com=br.readLine();
      String com0=com.split(" ")[0];
      String com1=com.split(" ")[1];
      if("forward".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-') cur++;
        }
        else if("word".equals(com1)){
          while(str[cur]==' ') cur++;
          while(str[cur]!=' '&&str[cur]!='-') cur++;
        }
      }
      else if("backward".equals(com0)){
        if("char".equals(com1)){
          if(cur>0) cur--;
        }
        else if("word".equals(com1)){
          while(cur>0&&str[cur-1]==' ') cur--;
          while(cur>0&&str[cur-1]!=' ') cur--;
        }
      }
      else if("insert".equals(com0)){
        String insertionStr="=com.substring(8,com.length()-1);
        for(int i=MAX-insertionStr.length();i>=cur;i--){
          if(str[i]!='-') str[i+insertionStr.length()]=str[i];
        }
        for(int i=0;i<insertionStr.length();i++){
          str[cur+i]=insertionStr.charAt(i);
        }
        cur+=insertionStr.length();
      }
      else if("delete".equals(com0)){
        if("char".equals(com1)){
          if(str[cur]!='-'){
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i+1];
            }
          }
        }
        else if("word".equals(com1)){
          int cnt=cur;
          while(str[cnt]==' ') cnt++;
          if(str[cnt]!='-'){
            while(str[cnt]!=' '&&str[cnt]!='-') cnt++;
            for(int i=cur;;i++){
              if(str[i]=='-') break;
              str[i]=str[i-cur+cnt];
            }
          }
        }
      }
    }
    StringBuilder sb=new StringBuilder();
    for(int i=0;;i++){
      if(i==cur) sb.append("^");
      if(str[i]=='-') break;
      sb.append(String.valueOf(str[i]));
    }
    out.println(sb);
    out.flush();
  }
}
}

Compiler output:
Main.java:60: error: unclosed string literal
        String insertionStr="=com.substring(8,com.length()-1);
                            ^
1 error
Language: C

#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

using namespace std;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  char buf[ 256 ];
  int n;

  fgets ( buf, sizeof ( buf ), stdin );
  sscanf ( buf, "%d", &n );
  while ( n-- )
  {
    string res;
    int m;
    int p = 0;

    fgets ( buf, sizeof ( buf ), stdin );
    *( strchr ( buf, '\n' ) ) = '\0';
    res.assign ( buf );

    fgets ( buf, sizeof ( buf ), stdin );
    sscanf ( buf, "%d", &m );

    while ( m-- )
    {
      fgets ( buf, sizeof ( buf ), stdin );

      if ( !strncmp ( buf, "forward char", 12 ) )
      {
        ++p;
        p = MIN( p, res.size ( ) );
        continue ;
      }
      if ( !strncmp ( buf, "backward char", 13 ) )
      {
        --p;
        p = MAX( p, 0 );
        continue ;
      }
      if ( !strncmp ( buf, "forward word", 12 ) )
      {
        while ( p < res.size ( ) && isspace ( res[ p ] ) ) ++p;
        while ( p < res.size ( ) && !isspace ( res[ p ] ) ) ++p;
        continue ;
      }
      if ( !strncmp ( buf, "backward word", 13 ) )
      {
        while ( p > 0 && isspace ( res[ p - 1 ] ) ) --p;
        while ( p > 0 && !isspace ( res[ p - 1 ] ) ) --p;
        continue ;
      }
      if ( !strncmp ( buf, "insert", 6 ) )
      {
        *( strrchr ( buf, '\"' ) ) = '\0';
        res.insert ( p, strchr ( buf, '\"' ) + 1 );
        p += strlen ( strchr ( buf, '\"' ) + 1 );

        continue ;
      }
      if ( !strncmp ( buf, "delete char", 11 ) )
      {
        if ( p < res.size ( ) ) res.erase ( p, 1 );

        continue ;
      }
      if ( !strncmp ( buf, "delete word", 11 ) )
      {
        int q = p;

        while ( q < res.size ( ) && isspace ( res[ q ] ) ) ++q;
        while ( q < res.size ( ) && !isspace ( res[ q ] ) ) ++q;
        res.erase ( p, q - p );

        continue ;
      }
    }

    printf ( "%s^%s\n"
           , res.substr ( 0, p ).c_str ( )
           , res.substr ( p, res.size ( ) - p ).c_str ( ) );
  }

  return ( 0 );
}

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

3
A sample input
9
forward word
delete char
forward word
delete char
forward word
delete char
backward word
backward word
forward word
Hallow, Word.
7
forward char
delete word
insert "ello, "
forward word
backward char
backward char
insert "l"

3
forward word
backward word
delete word

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3
      | ^
Language: C++

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

int main()
{
	int N,n,c;
	string str,cmd;

	getline(cin,cmd);
	N=atoi(cmd.c_str());
	while(N--)
	{
		c=0;
		getline(cin,str);
		getline(cin,cmd);
		n=atoi(cmd.c_str());
		while(n--)
		{
			getline(cin,cmd);
			if(cmd=="forward char")
			{
				if(c<str.size()) c++;
			}
			else if(cmd=="forward word")
			{
				bool ws = false;
				while(c<str.size())
				{
					if(str[c]!=' ') 
					{
						ws=true;
					}
					else if(ws)
					{
						break;
					}
					c++;
				}
			}
			else if(cmd=="backward char")
			{
				if(0<c) c--;
			}
			else if(cmd=="backward word")
			{
				bool ws = false;
				while(0<c)
				{
					if(str[c]!=' ') 
					{
						ws=true;
					}
					else if(ws)
					{
						break;
					}
					c--;
				}
			}
			else if(cmd=="delete char")
			{
				if(c<str.size())
				str.erase(str.begin()+c);
			}
			else if(cmd=="delete word")
			{
				int t=c; bool ws=false;
				while(t<str.size())
				{
					if(str[t]!=' ') 
					{
						ws=true;
					}
					else if(ws)
					{
						break;
					}
					t++;
				}
				
				if(ws)
				{
					str.erase(str.begin()+c,str.begin()+t);
				}

			}
			else
			{
				cmd.erase(0,8);
				cmd.erase(cmd.end()-1);
				str.insert(c,cmd);
				c += cmd.size();
			}
		}

		str.insert(c,"^");
		cout << str << endl;
	}
}

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

#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(){    
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        char b[1009];
        gets(b);

        gets(b);
        string buf(b);
        //cout << "buf is " << buf << endl;
        int pos=0;
        int cn;
        cin>>cn;
        for(int k=0;k<cn;k++){
            string command;
            cin >> command;
            if(command=="forward"){
                cin >> command;
                if(command=="char"){
                    if(!buf.empty())
                    pos = min(pos+1,(int)buf.size());
                }else{
                    // word
                    while(buf[pos]==' ' && pos < buf.size())pos++;
                    while(buf[pos]!=' ' && pos < buf.size())pos++;
                }
            }else if(command=="backward"){
                cin >> command;
                if(command=="char"){
                    if(!buf.empty())
                    pos = max(pos-1,0);
                }else{
                    // word
                    while(buf[pos]==' ' && pos > 0)pos--;
                    while(buf[pos]!=' ' && pos > 0)pos--;
                }
            }else if(command=="insert"){
                getline(cin,command);
                string text;
                bool f= false;
                for(int i=0;i<command.size();i++){
                    if(f&&command[i]=='\"')break;
                    if(f)text.push_back(command[i]);
                    if(command[i]=='\"')f=true;
                }
                buf.insert(pos,text);
                pos+= text.size();
            }else {//delete
                cin >> command;
                if(command== "char"){
                    if(!buf.empty()&&pos!=buf.size()){
                        buf.erase(pos,1);
                        pos = min(pos,(int)buf.size());
                    }

                }else{
                    if(!buf.empty()){
                        int t=pos;
                        while(t<buf.size() && buf[t]!=' ')t++;
                        while(t<buf.size() && buf[t]==' ')t++;

                        buf.erase(pos,t-pos);
                    }
                }
            }
        }
        //cout << buf << "****" << endl;
        if(buf.empty()){
            printf("^\n");
        }else{
        for(int p=0;p<buf.size();p++){
            if(pos==p)printf("^");
            printf("%c",buf[p]);
        }

        if(pos==buf.size())printf("^");
        printf("\n");}
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |         gets(b);
      |         ^~~~
      |         getw
Language: C++

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

int main()
{
    string bla = "bla";
    cout<<bla.substr(3)<<endl;
    int nb_cas;
    cin>>nb_cas;
    cin.ignore();
    while(nb_cas--)
    {
        string texte;
        getline(cin,texte);
        int nb_op;
        cin>>nb_op;
        int curseur = 0;
        for(int c=0;c<nb_op;c++)
        {
            string s1,s2;
            cin>>s1;
            cin.ignore();
            getline(cin,s2);
            if(s1=="forward"||s1=="backward")
            {
                int d = (s1=="forward"?1:-1);
                if(s2=="char") curseur+=d;
                else if(s2=="word")
                {
                    while(curseur>= 0 && curseur<=texte.size()&&(curseur == texte.size()||texte[curseur]==' ')) curseur+=d;
                    while(curseur>=-0&&curseur<=texte.size()&&(curseur==texte.size()||texte[curseur]!=' '))
                    {
                        curseur += d;
                    }
                }
                curseur = max(curseur,0);
                curseur = min(curseur,(int)texte.size());
            }
            else if(s1=="delete")
            {
                if(s2=="char"&&curseur<texte.size())
                {
                    texte = texte.substr(0,curseur)+texte.substr(curseur+1);
                }
                else if(s2=="word")
                {
                    int finMot = curseur;
                    while(finMot<texte.size()&&texte[finMot]==' ') finMot++;
                    if(finMot == texte.size()) continue;
                    while(finMot<texte.size()&&texte[finMot]!=' ')
                    {
                        finMot ++;
                    }
                    texte = texte.substr(0,curseur)+(finMot < texte.size()?texte.substr(finMot):"");
                }
            }
            else
            {
                while(s2[0]!="\"") s2=s2.substr(1);
                while(s2[s2.size()-1]!="\"") s2 = s2.substr(s2.size()-1);
                s2 = s2.substr(1,s2.size()-2);
                texte = texte.substr(0,curseur)+s2+(curseur<(int)texte.size()?texte.substr(curseur):"");
                curseur += s2.size();
            }
        }
        cout<<texte.substr(0,curseur)+"^"+(curseur<(int)texte.size()?texte.substr(curseur):"")<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   62 |                 while(s2[0]!="\"") s2=s2.substr(1);
a.cc:63:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   63 |                 while(s2[s2.size()-1]!="\"") s2 = s2.substr(s2.size()-1);
Language: C++

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

int main(){
  int n;
  cin >>n;
  cin.ignore();
  for(int i=0;i<n;i++){
    string str;
    int cn,pos;
    if(!getline(cin,str)){
      str = "";
    }
    cin >> cn;
    pos = 0;
    for(int j=0;j<cn;j++){
      string command,target;
      char ch;
      cin >> command;
      getline(cin,target);
      target.erase(0,1);
      if(command == "forward"){
        if(pos<str.size()){
          if(target == "word"){
            int temp = pos;
            int judge = 0;
            while(temp<str.size()){
              if(str[temp]!=' '){
                judge = 1;
                break;
              }
              temp++;
            }
            if(judge==1){
              do{
                pos++;
              }while(pos<str.size()&&str[pos]!=' ');
            }
          }else{
            pos++;
          }
        }
      }else if(command == "delete"){
        if(str.size()!=0&&pos!=str.size()){
          if(target == "word"){
            int stage = 0;
            while(pos<str.size()){
              if(stage==0){
                if(str[temp]!=" "){
                  stage = 1;
                }
              }else{
                if(str[temp]==" "){
                  break;
                }
              }
              str.erase(pos,1);
            }
            while(pos<str.size()&&str[pos]!=' '){
              str.erase(pos,1);
            }
          }else{
            str.erase(pos,1);
          }
        }
      }else if(command == "backward"){
        if(pos>0){
          if(target == "word"){
            int temp = pos;
            int judge = 0;
            while(temp>=0){
              if(str[temp]!=' '){
                judge = 1;
                break;
              }
              temp--;
            }
            if(judge==1){
              do{
                pos--;
              }while(pos>0&&str[pos]!=' ');
            }
          }else{
            pos--;
          }
        }
      }else if(command == "insert"){
        target = target.substr(1,target.size()-2);
        str.insert(pos,target);
        pos += target.size();
      }
    }
    str.insert(pos,"^");
    cout << str << endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:24: error: 'temp' was not declared in this scope; did you mean 'tm'?
   51 |                 if(str[temp]!=" "){
      |                        ^~~~
      |                        tm
a.cc:55:24: error: 'temp' was not declared in this scope; did you mean 'tm'?
   55 |                 if(str[temp]==" "){
      |                        ^~~~
      |                        tm
Language: C++

#include<iostream>
#include<string>
#include<complex>
using namespace std;
typedef complex<int> ci;
string expr;bool of;
ci prs(int s,int t){
	int d=0,mi=t,pmi=t;
	for(int i=s;i<t;i++){
		char c=expr[i];
		if(c=='(')d++;
		if(c==')')d--;
		if(d==0&&c=='*')mi=i;
		if(d==0&&(c=='+'||c=='-'))pmi=i;
	}
	ci r;
	if(pmi<t)r=prs(s,pmi)+(expr[pmi]=='+'?ci(1,0):ci(-1,0))*prs(pmi+1,t);
	else if(mi<t)r=prs(s,mi)*prs(mi+1,t);
	else if(expr[s]=='(')r=prs(s+1,t-1);
	else{
		if(expr[s]=='i')r.imag()=1;
		else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0';
	}
	if(abs(r.real())>10000||abs(r.imag())>10000)of=1;
	return r;
}
int main(){
	while(cin>>expr){
		of=0;
		ci ans=prs(0,expr.size());
		if(of)cout<<"overflow";
		else{
			if(ans==0)cout<<0;
			if(ans.real()!=0)cout<<ans.real();
			if(ans.imag()!=0){
				cout<<(ans.real()!=0&&ans.imag()>0?"+":"");
				if(abs(ans.imag())!=1)cout<<ans.imag();
				cout<<"i";
			}
		}
		cout<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'ci prs(int, int)':
a.cc:21:39: error: lvalue required as left operand of assignment
   21 |                 if(expr[s]=='i')r.imag()=1;
      |                                 ~~~~~~^~
a.cc:22:48: error: lvalue required as left operand of assignment
   22 |                 else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0';
      |                                          ~~~~~~^~
a.cc:22:61: error: lvalue required as left operand of assignment
   22 |                 else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0';
      |                                                       ~~~~~~^~
Language: C++

#include <iostream>
#include <complex>
#include <map>
#include <stack>
#include <string>
#include <cctype>
#include <cstdlib>
using namespace std;

typedef complex<int> C;

int p;
string expr;
bool err;

int parseInt()
{
	int ret=0;
	while(isdigit(expr[p]))
	{
		ret*=10;
		ret+=expr[p]-'0';
		p++;
	}
	
	return ret;
}

char parseChr()
{
	char ret=expr[p];
	p++;
	
	return ret;
}

bool check(C& c)
{
	if(abs(c.real()) > 10000) return true;
	if(abs(c.imag()) > 10000) return true;
	return false;
}

C calc(stack<C>& num, stack<char>& sta)
{
	C r=num.top(); num.pop();
	C l=num.top(); num.pop();
	if(check(r)) err=1;
	if(check(l)) err=1;

	char e=sta.top(); sta.pop();
	
	if(e=='+') return l+r;
	if(e=='-') return l-r;
	if(e=='*') return l*r;
	
	return l/r;
}

int main()
{
	
	map<char, int> tab;
	tab.insert(make_pair('+',1));
	tab.insert(make_pair('-',1));
	tab.insert(make_pair('*',2));
	tab.insert(make_pair('/',2));
	tab.insert(make_pair('(',3));
	tab.insert(make_pair(')',-3));
	
	while(cin >>  expr)
	{	
		err=false;
		p=0;
		expr+="=";
		
		int nc=0;
		stack<char> sta;
		stack<int> cnt;
		stack<C> num;
		while(expr[p]!='=')
		{
			if(isdigit(expr[p]))
			{
				num.push(C(parseInt(),0));
			}
			else
			{
				char c=parseChr();
				if(c=='('||c==')') nc+=tab[c];
				else if(c=='i')
				{
					num.push(C(0,1));
				}
				else
				{
					while(!sta.empty())
					{
						if(cnt.top()+tab[sta.top()] >= nc+tab[c])
						{
							C ret=calc(num,sta);
							if(check(ret)) err=true;
							num.push(ret);
							cnt.pop();
						}
						else break;
					}
					
					sta.push(c);
					cnt.push(nc);
				}
			}
		}
		
		while(!sta.empty())
		{
			C ret=calc(num,sta);
			if(check(ret)) err=true;
			num.push(ret);
		}

		if(check(num.top()) err=1;

		if(err) cout << "overflow" << endl;
		else
		{
			C ans=num.top();
			if(ans.real() == 0 && ans.imag() == 0)
				cout << 0 << endl;
			else
			{
				if(ans.real() != 0) 
				{
					cout << ans.real();
					if(ans.imag() > 0) cout << "+";
				}
				if(ans.imag() != 0) cout << ans.imag() << "i" << endl;
				else cout << endl;
			}
		}
	}
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:122:36: error: expected ';' before 'err'
  122 |                 if(check(num.top()) err=1;
      |                                    ^~~~
      |                                    ;
a.cc:124:17: error: expected primary-expression before 'if'
  124 |                 if(err) cout << "overflow" << endl;
      |                 ^~
a.cc:122:43: error: expected ')' before 'if'
  122 |                 if(check(num.top()) err=1;
      |                   ~                       ^
      |                                           )
  123 | 
  124 |                 if(err) cout << "overflow" << endl;
      |                 ~~
Language: C++

#include <iostream>
#include <complex>

using namespace std;

#define COMP complex<long long>
#define abs(a) (a<0?-a:a)

char *p, buf[150];

COMP expr();

COMP fact(){
	COMP ret;
	if(*p == '('){
		p++;
		ret=expr();
		p++;
	}else if(*p == 'i'){
		ret=COMP(0,1);
		p++;
	}else{
		while(isdigit(*p)){
			ret = ret * 10 + int(*p - '0');
			p ++;
			if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
		}
	}
	
	return ret;
}

COMP term(){
	COMP ret = fact();
	while(*p=='*'){
		p++;
		ret *= fact();
		if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
	}
	return ret;
}

COMP expr(){
	COMP ret = term();
	while(*p=='+' || *p=='-'){
		char ope = *p++;
		if(ope=='+') ret += term();
		if(ope=='-') ret -= term();
		if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
	}
	return ret;
}

int main(){
	COMP ret;
	while(cin>>buf){
		p = buf;
		try{
			ret = expr();
			if(ret.real() || !ret.imag()) cout << ret.real();
			if(ret.imag()>0 && ret.real()) cout << '+';
			if(ret.imag()) cout<<ret.imag()<<"i";
			cout << endl;
		}catch(...){
			cout<<"overflow"<<endl;
		}
	}
}

Compiler output:
a.cc: In function 'std::complex<long long int> fact()':
a.cc:24:35: error: no match for 'operator*' (operand types are 'std::complex<long long int>' and 'int')
   24 |                         ret = ret * 10 + int(*p - '0');
      |                               ~~~ ^ ~~
      |                               |     |
      |                               |     int
      |                               std::complex<long long int>
In file included from a.cc:2:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
  400 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:400:5: note:   template argument deduction/substitution failed:
a.cc:24:37: note:   mismatched types 'const std::complex<_Tp>' and 'int'
   24 |                         ret = ret * 10 + int(*p - '0');
      |                                     ^~
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
  409 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:409:5: note:   template argument deduction/substitution failed:
a.cc:24:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |                         ret = ret * 10 + int(*p - '0');
      |                                     ^~
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
  418 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/complex:418:5: note:   template argument deduction/substitution failed:
a.cc:24:37: note:   mismatched types 'const std::complex<_Tp>' and 'int'
   24 |                         ret = ret * 10 + int(*p - '0');
      |                                     ^~
Language: C++

#include <iostream>
#include <complex>

using namespace std;

#define COMP complex<int>
int abs(int a) {return (a<0) ?-a:a}

char *p, buf[11000];

COMP expr();

COMP fact(){
	COMP ret;
	if(*p == '('){
		p++;
		ret=expr();
		p++;
	}else if(*p == 'i'){
		ret=COMP(0,1);
		p++;
	}else{
		while(isdigit(*p)){
			ret = ret * 10 + int(*p - '0');
			p ++;
			if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
		}
	}
	
	return ret;
}

COMP term(){
	COMP ret = fact();
	while(*p=='*'){
		p++;
		ret *= fact();
		if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
	}
	return ret;
}

COMP expr(){
	COMP ret = term();
	while(*p=='+' || *p=='-'){
		char ope = *p++;
		if(ope=='+') ret += term();
		if(ope=='-') ret -= term();
		if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0;
	}
	return ret;
}

int main(){
	COMP ret;
	while(cin>>buf){
		p = buf;
		try{
			ret = expr();
			if(ret.real() || !ret.imag()) cout << ret.real();
			if(ret.imag()>0 && ret.real()) cout << '+';
			if(ret.imag()) cout<<ret.imag()<<"i";
			cout << endl;
		}catch(...){
			cout<<"overflow"<<endl;
		}
	}
}

Compiler output:
a.cc: In function 'int abs(int)':
a.cc:7:35: error: expected ';' before '}' token
    7 | int abs(int a) {return (a<0) ?-a:a}
      |                                   ^
      |                                   ;
Language: C++

#include <iostream>
#include <string>
#include <complex>
#include <cstdlib>
#include <cctype>
using namespace std;

int p;
string str;
bool v;

complex<int> expr();
complex<int> factor();
complex<int> term();

bool isValid(complex<int>& c)
{
	if(abs(c.real()) > 10000 || abs(c.imag()) > 10000) return false;
	return true;
}

complex<int> parseInt()
{
	int res = 0;
	while(isdigit(str[p])) {
		res *= 10;
		res += str[p] - '0';
		p++;

		v &= isValid(complex<int>(res, 0));
	}

	return complex<int>(res, 0);
}

complex<int> expr()
{
	complex<int> l = factor();
	while(str[p] == '+' || str[p] == '-') {
		char op = str[p++];

		complex<int> r = factor();
		if(op == '+') l += r;
		if(op == '-') l -= r;

		v &= isValid(l);
	}

	return l;
}


complex<int> factor()
{
	complex<int> l = term();
	while(str[p] == '*') {
		p++;

		complex<int> r = term();

		l *= r;
		v &= isValid(l);
	}

	return l;
}

complex<int> term()
{
	complex<int> l;
	if(str[p] == '(') {
		p++;
		l = expr();
		p++;
	}
	else if(str[p] == 'i') {
		l = complex<int>(0, 1);
		p++;
	}
	else {
		l = parseInt();
	}

	v &= isValid(l);

	return l;
}



int main()
{
	while(cin >> str) {
		v = true;
		str += '$';
		p = 0;

		complex<int> res = expr();

		if(v == false) cout << "overflow" << endl;
		else {
			if(res.real() == 0 && res.imag() == 0) {
				cout << res.real() << endl;
			}
			else if(res.real() == 0) {
				cout << res.imag() << "i" << endl;
			}
			else if(res.imag() == 0) {
				cout << res.real() << endl;
			}
			else {
				cout << res.real() << (res.imag() > 0 ? "+" : "-") << abs(res.imag()) << "i" << endl;
			}
		}
	}
}

Compiler output:
a.cc: In function 'std::complex<int> parseInt()':
a.cc:30:30: error: cannot bind non-const lvalue reference of type 'std::complex<int>&' to an rvalue of type 'std::complex<int>'
   30 |                 v &= isValid(complex<int>(res, 0));
      |                              ^~~~~~~~~~~~~~~~~~~~
a.cc:16:28: note:   initializing argument 1 of 'bool isValid(std::complex<int>&)'
   16 | bool isValid(complex<int>& c)
      |              ~~~~~~~~~~~~~~^
Language: C++

#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

typedef complex<int> P;

bool er;

void is_error(P& p){
	er |= !(abs(p.real()) <= 10000 && abs(p.imag()) <= 10000);
}

P expr(const char *& s);
 
P val(const char *& s){
    if(*s == '('){
        s++;
        P ret = expr(s);
        s++;
        return ret;
    }
	if(*s == 'i'){
		s++;
		return P(0,1);
	}
    int v = 0;
    while(*s >= '0' && *s <= '9'){
        v *= 10;
        v += *s - '0';
        s++;
		is_error(P(v,0));
    }
    P ret = P(v,0);
	return ret;
}
 
P pri(const char *& s){
	if(*s == '-'){
		s++;
		return -1 * pri(s);
	}
    P l = val(s);
    while(true){
        char ope = *s;
        if(ope != '*' && ope != '/')
            return l;
        s++;
        P r = val(s);

        if(ope == '*')
            l *= r;
        else
            l /= r;
		is_error(l);
    }
}
 
P expr(const char *& s){
    P l = pri(s);
    while(true){
        char ope = *s;
        if(ope != '+' && ope != '-')
            return l;
        s++;
        P r = pri(s);
        if(ope == '+')
            l+=r;
        else
            l-=r;

		is_error(l);
    }
}

int main(){
 
	string s;
    while(cin>>s){
		const char *p = s.c_str();
		er = false;
		P ans = expr(p);
		if(er){
			puts("overflow");
		}else{
			if(ans.imag() == 0)
				printf("%d\n",ans.real());
			else if(ans.real() == 0){
				printf("%di\n",ans.imag());
			} else {
				printf("%d%+di\n",ans.real(),ans.imag());
			}
		}

	}
    return 0;
}

Compiler output:
a.cc: In function 'P val(const char*&)':
a.cc:66:26: error: cannot bind non-const lvalue reference of type 'P&' {aka 'std::complex<int>&'} to an rvalue of type 'P' {aka 'std::complex<int>'}
   66 |                 is_error(P(v,0));
      |                          ^~~~~~
a.cc:44:18: note:   initializing argument 1 of 'void is_error(P&)'
   44 | void is_error(P& p){
      |               ~~~^
Language: C++

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

struct complex{
	int re, im;
	complex(int r, int i): re(r), im(i){
		if(abs(r) > 10000 || abs(i) > 10000)
			throw 0;
	}

	complex operator+ (const complex &c) const{
		return complex(re + c.re, im + c.im);
	}
	
	complex operator- (const complex &c) const{
		return complex(re - c.re, im - c.im);
	}
	
	complex operator* (const complex &c) const{
		int r = re * c.re - im * c.im;
		int i = re * c.im + im * c.re;
		return complex(r, i);
	}
};

const char *p;

complex expr();

complex factor(){
	if(*p == '+'){
		++p;
		return factor();
	}
	if(*p == '-'){
		++p;
		return complex(0, 0) - factor();
	}
	if(*p == '('){
		++p;
		complex c = expr();
		++p;
		return c;
	}
	if(*p == 'i'){
		++p;
		return complex(0, 1);
	}

	char *endp;
	int r = strtol(p, &endp, 10);
	p = endp;
	return complex(r, 0);
}

complex term(){
	complex c = factor();
	while(*p == '*'){
		++p;
		c = c * factor();
	}
	return c;
}

complex expr(){
	complex c = term();
	while(1){
		if(*p == '+'){
			++p;
			c = c + term();
		}
		else if(*p == '-'){
			++p;
			c = c - term();
		}
		else{
			break;
		}
	}
	return c;
}

int main(){
	string s;
	while(cin >> s){
		p = s.c_str();
		try{
			complex c = expr();

			if(c.re != 0){
				printf("%d", c.re);
				if(c.im != 0){
					printf("%+di", c.im);
				}
			}
			else{
				if(c.im == 0){
					printf("0");
				}
				else{
					printf("%di", c.im);
				}
			}
			puts("");
		} catch(...){
			puts("overflow");
		}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:111:2: error: expected '}' at end of input
  111 | }
      |  ^
a.cc:86:11: note: to match this '{'
   86 | int main(){
      |           ^