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

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
vector <int> ami[100][100];
int hi[1000];
int n,m,a,mh;


int kuji(int x,int h) {
  //cout << "start kuji()"<<endl;
  int t;
  int fl = 0;
  int i;
  // cout << "h = "<< h << endl;
  // cout << "x = " << x << endl;
  mh = -1;
  fl == 0;
  
  if(x > 0)
    for(i =0;i<ami[x][x-1].size();i++){
      if(h>= ami[x][x-1][i] && ami[x][x-1][i] > mh){
	fl = 1;
	mh = ami[x][x-1][i];
	t = i;
      }
    }

  
  if(x < n-1) {
    for(i=0;i<ami[x][x+1].size();i++) {
      if(h >= ami[x][x+1][i] && ami[x][x+1][i] > mh) {
	mh = ami[x][x+1][i];
	fl = 2;
	t = i;
      }
    }
  }

  if(fl == 1) {
    ami[x][x-1][t] = h+1;
    ami[x-1][x][t] = h+1;
  }else if(fl == 2)  {
    ami[x][x+1][t] = h+1;
    ami[x+1][x][t] = h+1;
  }
  if(mh == -1) return x;
  // printf("mh = %d\n",mh);
  if(mh != x && fl == 1) kuji(x-1,mh);
  else if(mh !=x && fl == 2) kuji(x+1,mh);
  
  
}	



int main() {
  

  while(scanf("%d %d %d",&n,&m,&a) != EOF) {
   
    mh = -1;  
    while(1) {
      int h,p,q;
      cin >> h >> p >> q;
      if(h == 0 && p == 0 && q ==0) break;
      ami[p-1][q-1].push_back(h);
      ami[q-1][p-1].push_back(h);
      //    cout << ami[q-1][p-1].back() << endl;
      if(mh < h) mh = h;
    }

   
    int ans = 0;
    ans = kuji(a-1,mh);
  
    cout << ans+1 << endl;

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	ami[i][j].clear();
  }
  
  return 0;
  
}
[j].clear();
    
  }
  
  return 0;
  
}

Compiler output:
a.cc:87:1: error: expected unqualified-id before '[' token
   87 | [j].clear();
      | ^
a.cc:89:3: error: expected declaration before '}' token
   89 |   }
      |   ^
a.cc:91:3: error: expected unqualified-id before 'return'
   91 |   return 0;
      |   ^~~~~~
a.cc:93:1: error: expected declaration before '}' token
   93 | }
      | ^
a.cc: In function 'int kuji(int, int)':
a.cc:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^
Language: C++

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

int main(){
    int n,m,a,h,p,q;
    while(cin>>n>>m>>a,n){
        
        vector<pair<int, int> > v;
        vector<vector<pair<int,int> > > vec;
        for(int i=0;i<n+2;i++)vec.push_back(v);
        for(int i=0;i<m;i++){
            cin>>h>>p>>q;
            vec[p].push_back(make_pair(h,q));
            vec[q].push_back(make_pair(h,p));
        }
        for(int i=0;i<n;i++){
            sort(vec[i].begin(),vec[i].end());
        }
        int mh=1001;
        vector<int>::iterator it;
        while(mh>0){
            for(long i=vec[a].size()-1;i>=0;i--){
                if(vec[a][i].first==mh){
                    a=vec[a][i].second;
                }
                else if(vec[a][i].first<mh){
                    break;
                }
            }
            mh--;
        }
        cout<<a<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |             sort(vec[i].begin(),vec[i].end());
      |             ^~~~
      |             short
Language: C++

#include <stdio.h>
#include <tchar.h>
#include<iostream>
using namespace std;

int main()
{
	int n, m, a;
	while (cin >> n >> m >> a && n != 0 && m != 0 && a != 0)
	{
		int line[1000 + 10][100 + 10] = {};
		int h, p, q;
		for (int i = 0; i < m; i++)
		{
			cin >> h >> p >> q;
			line[m - h + 1][p] = 1;
			line[m - h + 1][q] = -1;
		}
		int x = a;
		for (int y = 1; y <= m; y++)
		{
			//cout << "x :" << x << " y :" << y << endl;
			x += line[y][x];
		}
		cout << x << endl;
	}
	return 0;
}

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

#include<algorithm>
using namespace std;
int x[1180][118][118],n,m,p,a,b,c;
int main(){
	while(true){
		memset(x,0,sizeof(x));
		cin>>n>>m>>p;if(!n){break;}
		for(int i=0;i<m;i++){
			cin>>a>>b>>c;
			x[a][b][c]=1;x[a][c][b]=1;
		}
		for(int i=1000;i>0;i--){
			for(int j=1;j<=n;j++){
				if(x[i][p][j]==1){
					p=j;
					break;
				}
			}
		}
		cout<<p<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:17: error: 'memset' was not declared in this scope
    6 |                 memset(x,0,sizeof(x));
      |                 ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<algorithm>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:7:17: error: 'cin' was not declared in this scope
    7 |                 cin>>n>>m>>p;if(!n){break;}
      |                 ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<algorithm>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:20:17: error: 'cout' was not declared in this scope
   20 |                 cout<<p<<endl;
      |                 ^~~~
a.cc:20:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:26: error: 'endl' was not declared in this scope
   20 |                 cout<<p<<endl;
      |                          ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<algorithm>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;
struct aa {
	int h;
	int p;
	int q;
};
int main() {
	int N, M, A; cin >> N >> > M >> A;
	vector<aa>aas;
	for (int i = 0; i < M; ++i) {
		int h, p, q; cin >> h >> p >> q;
		p--; q--;
		aas.push_back(aa{ h,p,q });
	}
	sort(aas.begin(), aas.end(), [](const aa&l, const aa&r) {return l.h < r.h; });
	int now = 0;
	for (int i = 0; i < M; ++i) {
		if (aas[i].p == now) {
			now = aas[i].q;
		}else if (aas[i].q == now) {
			now = aas[i].p;
		}
	}
	now++;
	cout << now << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:34: error: expected primary-expression before '>' token
   14 |         int N, M, A; cin >> N >> > M >> A;
      |                                  ^
Language: C++

int main(){
	int n,m,a;
	while(cin>>n>>m>>a){
		if(n==0) break;
		int ys[3][m],hmax;
		for(int i=0;i<m;i++){
			cin>>ys[0][i]>>ys[1][i]>>ys[2][i];
			hmax=max(hmax,ys[0][i]);
		}
		for(int i=hmax;i>0;i--){
			for(int j=0;j<m;j++){
				if(ys[0][j]==i){
					if(ys[1][j]==a){
						a=ys[2][j];
						goto end;
					}
					else if(ys[2][j]==a){
						a=ys[1][j];
						goto end;
					}
				}
			}
			end:;
		}
		cout<<a<<endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:15: error: 'cin' was not declared in this scope
    3 |         while(cin>>n>>m>>a){
      |               ^~~
a.cc:8:30: error: 'max' was not declared in this scope; did you mean 'hmax'?
    8 |                         hmax=max(hmax,ys[0][i]);
      |                              ^~~
      |                              hmax
a.cc:25:17: error: 'cout' was not declared in this scope
   25 |                 cout<<a<<endl;
      |                 ^~~~
a.cc:25:26: error: 'endl' was not declared in this scope
   25 |                 cout<<a<<endl;
      |                          ^~~~
Language: C++

#include <iostream>

using namespace std;

int main(){
  while(1){
	int n,m,a;

	cin >> n >> m >> a;

	if(n==0&&m==0&&a==0) break;

	int i=0;
	pair<int, pair<int,int> > line[1001];
	for(i=0;i<m;i++){
	  int h,p,q;
	  cin >> h >> p >> q;
	  line[i] = make_pair(h, make_pair(p,q));
	}

	sort(line,line+m,greater<pair<int, pair<int,int> > >());


	for(int j=0; j<m; j++){
	  // cout << line[j].first <<" " << line[j].second.first <<" " <<line[j].second.second <<" "  << endl;
	  if(line[j].second.first == a){
		// cout << "yes" << endl;
		a = line[j].second.second;
	  }else if(line[j].second.second == a){
		// cout << "yes" << endl;
		a = line[j].second.first;
	  }
	}
	cout << a << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |         sort(line,line+m,greater<pair<int, pair<int,int> > >());
      |         ^~~~
      |         short
Language: C++

#include<queue>
#include<map>
using namespace std;
int main(){
  while(1){
    int n,m,a,ans,max=0;
    priority_queue<pair<int,pair<int,int > > > b;
    cin>>n>>m>>a;
    if(n+m+a==0)break;
    for(int i=0;i<m;i++){
      int h,p,q;
      cin>>h>>p>>q;
      b.push(make_pair(h,make_pair(p,q)));
      if(h>max)max=h;
    }
    while(!b.empty()){
      if(b.top().first==max&&(b.top().second.first==a||b.top().second.second==a)){
	if(b.top().second.first==a){
	  a=b.top().second.second;
	  max--;
	}else{
	  a=b.top().second.first;
	  max--;
	}
      }else b.pop();
    }
    cout<<a<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin>>n>>m>>a;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<map>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:27:5: error: 'cout' was not declared in this scope
   27 |     cout<<a<<endl;
      |     ^~~~
a.cc:27:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:14: error: 'endl' was not declared in this scope
   27 |     cout<<a<<endl;
      |              ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<map>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

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

int main() {
    int field[1111][111];
    while (true) {
        int n, m, a;
        scanf("%d %d %d",&n,&m,&a);
        if (n==0 && m==0 && a==0) {
            break;
        }
        memset(field,0,sizeof(field));
        int st=0;
        for (int i=0; i<m; i++) {
            int h, p, q;
            scanf("%d %d %d",&h,&p,&q);
            field[h][p]=q;
            field[h][q]=p;
            st=max(st,h);
        }
        int P=a;
        for (int i=st+1; i>0; i--) {
            if (field[i][P]!=0) {
                P=field[i][P];
            }
        }
        printf("%d\n",P);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'memset' was not declared in this scope
   13 |         memset(field,0,sizeof(field));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdio>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

int main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);

while(cin>>n>>m>>a,n|m|a)
{
    a--;
    int num[105];
    REP(i,n) num[i]=i;

    vector<P> v;
    REP(i,m){
        int h,p,q;
        cin>>h>>p>>q;
        p--;
        v.pb(P(h,p));
    }
    sort(v.rbegin(),v.rend());
    
    REP(i,m){
        int pos=v[i].second;
        swap(num[pos],num[pos+1]);
    }

    REP(i,n){
        if(num[i]==a) cout<<i+1<<endl;
    }
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   19 | while(cin>>n>>m>>a,n|m|a)
      |            ^
      |            yn
a.cc:19:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   19 | while(cin>>n>>m>>a,n|m|a)
      |               ^
      |               tm
a.cc:19:18: error: 'a' was not declared in this scope
   19 | while(cin>>n>>m>>a,n|m|a)
      |                  ^
a.cc:42:2: error: expected '}' at end of input
   42 | }
      |  ^
a.cc:15:1: note: to match this '{'
   15 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

void search(int n,int m,int a){
  vector<P> b[2000];

  rep(i,m){
    int h,p,q;
    cin>>h>>p>>q;
    b[h].push_back(P(p,q));
  }

  rrep(i,h){
    rep(j,b[i].size()){
      if(a==b[i][j].first){
        a = b[i][j].second;
        break;
      }
      if(a==b[i][j].second){
        a = b[i][j].first;
        break;
      }
    }
  }

  cout<<a<<endl;
}


int main(){

  int n,m,a;
  while(1){
    cin>>n>>m>>a;
    if(n==0) break;
    search(n,m,a);
  }

  return 0;
}



Compiler output:
a.cc: In function 'void search(int, int, int)':
a.cc:26:10: error: 'h' was not declared in this scope
   26 |   rrep(i,h){
      |          ^
a.cc:10:31: note: in definition of macro 'RFOR'
   10 | #define RFOR(i,m,n) for(int i=m;i>=n;i--)
      |                               ^
a.cc:26:3: note: in expansion of macro 'rrep'
   26 |   rrep(i,h){
      |   ^~~~
Language: C++




import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException{
		// インプットデータ取得
		Scanner sc = new Scanner(System.in);

        while(true) {

        int n_tatesen = sc.nextInt();//2
        int m_yokosen = sc.nextInt();//1
        int a_selected = sc.nextInt();//2

        if(n_tatesen==0&&m_yokosen==0&&a_selected==0) {
        	break;}

        int height, p_tatesen, q_tatesen;
        int[][] map = new int[1001][n_tatesen+1];
        for(int i=0;i<m_yokosen;i++) {
        	//横線がわたる高さと縦線番号を取得
        	height=sc.nextInt();//1
        	p_tatesen=sc.nextInt();//1
        	q_tatesen=sc.nextInt();//2
        	//高さが決まるとき、小さい側の縦線が3番だったら
        	//3から4か4から3のどちらかになるが、それは自分の現在地次第
        	map[height][p_tatesen]=q_tatesen;//2
        	map[height][q_tatesen]=p_tatesen;//1
        }

        //現在地がaなので、3番にいるときの行先がmapの値に入っている
        //高い順でループを回す
        for(int i=1000;i>0;i--) {
        	if(map[i][a_selected]!=0) {
        		a_selected=map[i][a_selected];
        	}
        }
        System.out.println(a_selected);

	}
}
	 public static void ScanYokosen(){
		 //横線のデータを取得する

	 }

	 public static void SelectYokosen(){
		 //選んだ縦線から必要な線だけ抜き出して、高さ順に並べる
	 }

}



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

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<int,int> P;

int main(){
  int n,m,a;
  while(cin >> n >> m >> a,n){
    a--;
    int h,p,q;
　　vector<P> v[1000];
    rep(i,m){
      cin >> h >> p >> q;
      v[h-1].push_back(P(p-1,q-1));
    }
    rep(i,1000){
      int j=999-i;
      rep(k,v[j].size()){
        if(v[j][k].first==a) a=v[j][k].second;
        else if(v[j][k].second==a) a=v[j][k].first;
      }
    }
    cout << a+1 << endl;
  }
  return 0;
}



Compiler output:
a.cc:11:1: error: extended character 　 is not valid in an identifier
   11 | 　　vector<P> v[1000];
      | ^
a.cc:11:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:11:1: error: '\U00003000\U00003000vector' was not declared in this scope
   11 | 　　vector<P> v[1000];
      | ^~~~~~~~~~
a.cc:11:13: error: expected primary-expression before '>' token
   11 | 　　vector<P> v[1000];
      |             ^
a.cc:11:15: error: 'v' was not declared in this scope
   11 | 　　vector<P> v[1000];
      |               ^
Language: C++

#include <iostream>
#include <stdio.h>

using namespace std;

struct HL{
	int h,p,q;
}hl[1001];

int main(){
	int n, m ,a;
	
	while(1){
		memset( hl , 0 , sizeof(hl) );
		cin >> n >> m >> a;
		if(n==0 && m==0 && a==0) break;

		for(int i=0 ; i<m ; i++){
			cin >> hl[i].h >> hl[i].p >> hl[i].q;
		}

		for(int h=1000 ; h>0 ; h--){
			for(int i=0 ; i<m ; i++){
				if(hl[i].h==h && hl[i].p==a){
					a++;
				}
				else if(hl[i].h==h && hl[i].q==a){
					a--;
				}
			}
		}
		cout << a << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'memset' was not declared in this scope
   14 |                 memset( hl , 0 , sizeof(hl) );
      |                 ^~~~~~
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 <stdio.h>
Language: C++

/*
 * 2001.cpp
 *
 *  Created on: 2012/06/24
 *      Author: shimomire
 */
#include <iostream>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <map>
#include <hash_map.h>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPr(i,b,n) for(int i=n-1;i>=b;i--)
#define REP0(i,n)   REP(i,0,n)
#define REPr0(i,n)   REPr(i,0,n)
#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
typedef complex<double> P;
bool operator <(const P& a, const P& b) {
	return abs(a) < abs(b);
}

int n,m,a;


int main(){
	while(true){
		cin >> n>> m>> a;

		if(n==0 && m==0 && a==0){
			break;
		}
		hash_map<pair<int,int>,int> nodes;
		REP0(i,n){
			int h,p,q;
			cin >> h>> p>> q;
			nodes.insert(pair<pair<int,int>,int>(pair<int,int>(h,p),q));
			nodes.insert(pair<pair<int,int>,int>(pair<int,int>(h,q),p));
		}
		int now=a;
		REPr0(h,1000){
			int nxt= nodes[pair<int,int>(h,now)];
			if(nxt>0)
				now=nxt;
		}
		cout << now <<endl;
	}
}

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

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

class Line{
public:
	int h,p,q;
	friend istream& operator>>(istream &in,Line &a){
		in>>a.h>>a.p>>a.q;
		return in;
	}
};
bool greater(Line a,Line b){
	return b.h<a.h;
}
int main(){
	int n,m,a;
	Line line[1000];
	while(cin>>n>>m>>a,n|m|a){
		for(int i=0;i<m;i++)cin>>line[i];
		sort(line,line+m,greater);
		for(int i=0;i<m;i++){
			if(line[i].p==a)a=line[i].q;
			else if(line[i].q==a)a=line[i].p;
		}
		cout<<a<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:34: error: reference to 'greater' is ambiguous
   21 |                 sort(line,line+m,greater);
      |                                  ^~~~~~~
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:353:12: note: candidates are: 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~
a.cc:13:6: note:                 'bool greater(Line, Line)'
   13 | bool greater(Line a,Line b){
      |      ^~~~~~~
Language: C++

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

struct Line{
	int h,p,q;
	Line(){}
	Line(int h,int p,int q):h(h),p(p),q(q){}
	bool operator <(Line x)const{return h>x.h;}
};
int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n|m|a){
		vector<Line> line;
		for(int i=0;i<m;i++){
			int h,p,q;
			cin>>h>>p>>q;
			line.push_back(Line(h,p,q));
		}
		sort(line.begin(),line.end());
		for(int i=0;i<line.size();i++){
			if(a==line[i].p)a=line[i].q;
			else if(a==line[i].q)a=line[i].p;
		}
		cout<<a<<endl;
	}
	return 0;
}

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

#include <iostream>
using namespace std;
int main(){
	while( 1 ){
		int n, m, a;
		int lottery[1001][101];
		memset( lottery, 0, sizeof(lottery) );
		cin >> n >> m >> a;
		if( n == 0 ) break;
		while( m-- > 0 ){
			int h, p, q;
			cin >> h >> p >> q;
			lottery[1000-h][p] = q;
			lottery[1000-h][q] = p;
		}
		for( int i = 1; i <= 1000; i++ ){
			for( int j = 1; j <= 100; j++ ){
				if( lottery[i][j] && a == j ){
					a = lottery[i][j];
					break;
				}
			}
		}
		cout << a << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'memset' was not declared in this scope
    7 |                 memset( lottery, 0, sizeof(lottery) );
      |                 ^~~~~~
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 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	while( 1 ){
		int n, m, a;
		int lottery[1001][101];
		memset( lottery, 0, sizeof(lottery) );
		cin >> n >> m >> a;
		if( n == 0 ) break;
		while( m-- > 0 ){
			int h, p, q;
			cin >> h >> p >> q;
			lottery[1000-h][p] = q;
			lottery[1000-h][q] = p;
		}
		for( int i = 1; i <= 1000; i++ ){
			for( int j = 1; j <= 100; j++ ){
				if( lottery[i][j] && a == j ){
					a = lottery[i][j];
					break;
				}
			}
		}
		cout << a << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'memset' was not declared in this scope
    8 |                 memset( lottery, 0, sizeof(lottery) );
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> PII;
typedef pair<int, PII> P;
typedef vector<P> VP;

int main ( void )
{
  int n, m, a
  while (cin >> n >> m >> a, n|m|a) {
    VP line(m), result(n);
    rep (i, n) { result[i] = i+1; }
    rep (i, m) {
      cin >> line[i].X >> line[i].Y.X >> line[i].Y.Y;
    }
    sort(line.begin(), line.end());
    rep (i, m) {
      swap(result[line[i].Y.X-1], result[line[i].Y.Y-1]);
    }
    rep (i, n) if (result[i] == a) {
      cout << i+1 << endl;
      break;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: expected initializer before 'while'
   18 |   while (cin >> n >> m >> a, n|m|a) {
      |   ^~~~~
Language: C++

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			if(n==0 && m==0 && a==0) break;

			int[][] line = new int[m+1][n+1];
			/*
			for(int i=0; i < m+1; i++){
				for(int j=0; j < n+1; j++){
					line[i][j] = 0;
				}
			}
			*/
			
			for(int i=0; i < n; i++){
				int h = sc.nextInt(); 
				int p = sc.nextInt(); 
				int q = sc.nextInt();
				line[h][p] = q;
				line[h][q] = p;
			}
			
			for(int i=line.length-1; i >= 0; i--){
				if(line[i][a]!=0){
					a = line[i][a];
				}
			}
			ans.add(a);
		}	
		
		for(int i=0; i < ans.size(); i++){
			System.out.println(ans.get(i));
		}
		sc.close();
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2: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 <map>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 50;

class State{
public:
  int mx, my, Mx, My;
  State() {}
  State(int mx, int my, int Mx, int My) : mx(mx), my(my), Mx(Mx), My(My) {}
};

int h, w, col, mx, my, Mx, My, A[7], dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
State state[7];
char data[N][N];
bool used[N][N], ans;
map<char, int> number;
map<int, char> material;

main(){
  int t;
  cin >> t;
  while(t--){
    set<int> upper[7];
    number.clear();
    material.clear();
    cin >> h >> w;
    col = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> data[i][j];
        if(data[i][j] != '.' && number.find(data[i][j]) == number.end()){
          number[data[i][j]] = col;
          material[col++] = data[i][j];
        }
      }
    }
    for(int k=0;k<col;k++){
      state[k] = State(N, N, 0, 0);
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(data[i][j] == material[k]){
            state[k].mx = min(state[k].mx, j);
            state[k].my = min(state[k].my, i);
            state[k].Mx = max(state[k].Mx, j);
            state[k].My = max(state[k].My, i);
          }
        }
      }
    }
    for(int k=0;k<col;k++){
      for(int i=state[k].my;i<=state[k].My;i++){
        for(int j=state[k].mx;j<=state[k].Mx;j++){
          if(data[i][j] == '.'){
            cout << "SUSPICIOUS" << endl;
            goto CONT;
          }
          else if(data[i][j] != material[k]) upper[k].insert(number[data[i][j]]);
        }
      }
    }
    for(int i=0;i<col;i++) A[i] = i;
    ans = false;
    do{
      for(int i=0;i<col;i++){
        for(set<int>::iterator j=upper[i].begin();j!=upper[i].end();j++){
          if(A[i] < A[*j]) goto FAILD;
        }
      }
      ans = true;
      FAILD:;
    }while(next_permutation(A, A+col));
    if(ans || !col) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
    CONT:;
  }
}

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

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

vector<string> v;
bool ngchars[256];

bool check(int y, int x, int Y, int X, char C) {
	bool out;
	bool in;
	Y++; X++;
	for(int i = y; i < Y; i++) {
		for(int j = x; j < X; j++) {
			if(ngchars[v[i][j]]) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	for(int iter = 0; iter < n; iter++) {
		int w, h;
		vector<char> cs;
		cin >> h >> w;
		v.clear();
		v.resize(h);
		for(int i = 0; i < h; i++)
			cin >> v[i];
		for(int i = 0; i < 256; i++)
			ngchars[i] = false;
		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v[i].size(); j++) {
				if(v[i][j] != '.') {
					cs.push_back(v[i][j]);
				}
			}
		}
		int x[30], y[30], X[30], Y[30];
		for(int i = 0; i < 30; i++) {
			x[i] = y[i] = 100;
			X[i] = Y[i] = -1;
		}
		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v[i].size(); j++) {
				if(v[i][j] == '.') continue;
				int c;
				c = v[i][j] - 'A';
				x[c] = min(x[c], j);
				X[c] = max(X[c], j);
				y[c] = min(y[c], i);
				Y[c] = max(Y[c], i);
			}
		}

		bool res = false;
		sort(cs.begin(), cs.end());
		cs.erase(unique(cs.begin(), cs.end()), cs.end());
		do {
			for(int i = 0; i < cs.size(); i++)
				ngchars[cs[i]] = true;
			ngchars['.'] = true;
			bool f = true;
			for(int i = 0; i < cs.size(); i++) {
				ngchars[cs[i]] = false;
				int c = cs[i] - 'A';
				if(!check(y[c],x[c],Y[c],X[c],'A'+c)) {
					f = false;
				}
			}
			if(f)
				res = true;
		} while(next_permutation(cs.begin(), cs.end()));
		if(res)
			cout << "SAFE" << endl;
		else
			cout << "SUSPICIOUS" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   61 |                 sort(cs.begin(), cs.end());
      |                 ^~~~
      |                 short
a.cc:62:26: error: 'unique' was not declared in this scope
   62 |                 cs.erase(unique(cs.begin(), cs.end()), cs.end());
      |                          ^~~~~~
a.cc:77:25: error: 'next_permutation' was not declared in this scope
   77 |                 } while(next_permutation(cs.begin(), cs.end()));
      |                         ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <set>
#include <map>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

struct rect { int ly, ry, lx, rx; };

int T, H, W;
char S[55][55];

int main(void) {
  cin >> T;
  while(T--) {
    cin >> H >> W;
    REP(i, 0, H) cin >> S[i];

    set<char> st;
    REP(i, 0, H) REP(j, 0, W) if(S[i][j] != '.') st.insert(S[i][j]);
    map<char, int> ctoi;
    for(char i : st) ctoi[i] = ctoi.size();

    int a[7];
    REP(i, 0, 7) a[i] = i;

    int ans = false;
    do {
      map<char, rect> p;
      REP(i, 0, H) REP(j, 0, W) if(S[i][j] != '.') p[S[i][j]] = (rect) { i, i, j, j };

      REP(i, 0, H) REP(j, 0, W) {
        if(S[i][j] != '.') {
          p[S[i][j]].ly = min(p[S[i][j]].ly, i);
          p[S[i][j]].ry = max(p[S[i][j]].ry, i);
          p[S[i][j]].lx = min(p[S[i][j]].lx, j);
          p[S[i][j]].rx = max(p[S[i][j]].rx, j);
        }
      }

      bool f = true;
      for(pair<char, rect> r : p) {
        char c = r.first;
        rect q = r.second;
        REP(i, q.ly, q.ry + 1) REP(j, q.lx, q.rx + 1) {
          if(S[i][j] == '.' || a[ctoi[c]] < a[ctoi[S[i][j]]]) f = false;
        }
      }
      ans = ans || f;
    } while(next_permutation(a, a + st.size()));

    cout << (ans ? "SAFE" : "SUSPICIOUS") << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:13: error: 'next_permutation' was not declared in this scope
   49 |     } while(next_permutation(a, a + st.size()));
      |             ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;

int h, w;
char field[50][50];
bool used[50][50];
bool per[8];
char ma[8];
map<char, int> mp;
int c;

bool dfs(int n, int rest){
	if(n == 0) {
		return rest == 0 ? true : false;
	}
	bool res = false;
	for(int i = 1; i < c; i++){
		if(per[i]) continue;
		else{
			per[i] = true;
			int ymax = 0;
			int ymin = INF;
			int xmax = 0;
			int xmin = INF;
			bool f = true;
			int cnt = 0;
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if(mp[field[j][k]] == i){
						ymax = max(ymax, j);
						ymin = min(ymin, j);
						xmax = max(xmax, k);
						xmin = min(xmin, k);
					}
				}
			}
			for(int j = ymin; j <= ymax; j++){
				for(int k = xmin; k <= xmax; k++){
					if(per[mp[field[j][k]]]){
						if(mp[field[j][k]] == i) cnt++;
					}else f = false;
				}
			}
			if(f){
				res |= dfs(n-1, rest - cnt);
				per[i] = false;
			}else{
				per[i] = false;
			}
		}
	}
	return res;
}

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

if(A[z]==-1){
    int a=49,b=0,c=0,d=49;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(t[i][j]==ch){
	  a=min(a,i);
	  b=max(b,j);
	  c=max(c,i);
	  d=min(d,j);
	}
      }
    }
    A[z]=a;  B[z]=b;  C[z]=c;  D[z]=d;
  }

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'if'
    1 | if(A[z]==-1){
      | ^~
Language: C++

#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;

int N, n;
int H,W;

char m[50][50];
bool used[26];
int U[26],D[26],L[26],R[26];


bool check(char ch){
  int z = ch-'A';
  for(int i=U[z]; i<D[z]; ++i){
    for(int j=L[z]; j<R[z]; ++j){
      if(m[i][j] != '.' && used[z] == false) continue;
      if(m[i][j]!=ch) return false;
    }
  }
  return true;
}
void input(){
  int x;
  string str;
  cin >> H >> W;
  rep(i,H){
    cin>>str;
    rep(j,W){
      m[i][j] = str[j];
      if(m[i][j]=='.')continue;
      x=m[i][j]-'A';
      used[x] = true;
      U[x]=min(U[x],i);
      D[x]=max(D[x],i);
      L[x]=min(L[x],j);
      R[x]=max(R[x],j);
    }
  }
}

void init(){
  rep(i,26){
    U[i] = 50;
    D[i] = 0;
    L[i] = 50;
    R[i] = 0;
    used[i] = false;
  }
}
int main(){
  cin >> N;
  while(N--){
    init();
    input();
    while(1){
      bool flag = false;
      rep(i,26){
        if(used[i]==false)continue;
        if(check(i+'A')==true){
          used[i] = false;
          flag = true;
          break;
        }
        
      }
      flag = false;
      rep(i,26) flag |= used[i];
      cout <<flag ? "SUSPICIOUS" : "SAFE" << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:43: error: invalid operands of types 'const char [5]' and '<unresolved overloaded function type>' to binary 'operator<<'
   76 |       cout <<flag ? "SUSPICIOUS" : "SAFE" << endl;
      |                                    ~~~~~~~^~~~~~~
Language: Java

import java.util.*;
import java.awt.geom.Line2D;

public class Main{
    int n;
    int xa,ya,xb,yb;
    int xs,ys,xt,yt,o,l;
    Line2D a,b;
    Intersection[] inter;

    class Intersection{
	double dist;
	int owner,height;
	public Intersection(double dist,int owner,int height){
	    this.dist = dist;
	    this.owner = owner;
	    this.height = height;
	}
    }

    void solve(){
	Scanner sc = new Scanner(System.in);
	int T = sc.nextInt();
	while(T--!=0){
	    xa = sc.nextInt(); ya = sc.nextInt();
	    xb = sc.nextInt(); yb = sc.nextInt();
	    n = sc.nextInt();

	    inter = new Intersection[n];
	    a = new Line2D.Double(xa,ya,xb,yb);
	    for(int i=0; i<n; i++){
		xs = sc.nextInt(); ys = sc.nextInt();
		xt = sc.nextInt(); yt = sc.nextInt();
		o = sc.nextInt(); l = sc.nextInt();
		b = new Line2D.Double(xs,ys,xt,yt);
		if(a.intersectsLine(b)){
		    double d = calcDist(xa,ya,xb,yb,xs,ys,xt,yt);
		    inter[i] = new Intersection(d,o,l);
		}else{
		    inter[i] = new Intersection(-1,-1,-1);
		}
	    }

	    Comparator<Intersection> cmp = new Comparator<Intersection>(){
		public int compare(Intersection i1, Intersection i2){
		    if(i1.dist<i2.dist) return -1;
		    if(i1.dist>i2.dist) return 1;
		    return 0;
		}
	    };
	    Arrays.sort(inter, cmp);

	    int ans = Math.min(countGate(0),countGate(1))
	    
	    System.out.println(ans);
	}
    }
    
    double calcDist(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){
	double bx = x4-x3;
	double by = y4-y3;
	double d1 = Math.abs(bx*(y1-y3)-by*(x1-x3));
	double d2 = Math.abs(bx*(y2-y3)-by*(x2-x3));
	double t = d1/(d1+d2);	
	double x = x1+(x2-x1)*t;
	double y = y1+(y2-y1)*t;
	
	return (xa-x)*(xa-x)+(ya-y)*(ya-y);
    }
    
    int countGate(int nowHeight){
	int count = 0;
	for(int i=0; i<n; i++){
	    if(inter[i].dist==-1)continue;
	    if(inter[i].owner==0){
		if(inter[i].height==nowHeight){
		    nowHeight = 1 - nowHeight;
		    count++;
		}
	    }else{
		if(inter[i].height!=nowHeight){
		    nowHeight = 1 - nowHeight;
		    count++;
		}
	    }
	}
	return count;
    }
    
    public static void main(String[] args){
	new Main().solve();
    }
}

Compiler output:
Main.java:53: error: ';' expected
	    int ans = Math.min(countGate(0),countGate(1))
	                                                 ^
1 error
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int crs(double x1, double y1, double x2, double y2) {
    double z = x1*y2-y1*x2;
    return (0 < z ? 1 : (z < 0 ? -1 : 0));
}

bool intersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
    if (0 <= crs(x2-x1, y2-y1, x3-x1, y3-y1) * crs(x2-x1, y2-y1, x4-x1, y4-y1)) return false;
    if (0 <= crs(x4-x3, y4-y3, x1-x3, y1-y3) * crs(x4-x3, y4-y3, x2-x3, y2-y3)) return false;
    return true;
}

pair<double,double> intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
    if (x3 == x4) {
        swap(x1, x3); swap(y1, y3); swap(x2, x4); swap(y2, y4);
    }
    double x, y, a, b, c, d;
    if (x1 == x2) {
        c = (y4-y3)/(x4-x3);
        d = y3-c*x3;
        x = x1;
        y = c*x+d;
    } else {
        a = (y2-y1)/(x2-x1);
        b = y1-a*x1;
        c = (y4-y3)/(x4-x3);
        d = y3-c*x3;
        x = (d-b)/(a-c);
        y = a*x+b;
    }
    return make_pair(x,y);
}

int main() {
    int N;
    cin >> N;
    while (N--) {
        double xa, ya, xb, yb;
        int n;
        cin >> xa >> ya >> xb >> yb >> n;
        bool vertical = fabs(xa-xb) < fabs(ya-yb);

        double xs, ys, xt, yt;
        int o, l;
        vector<pair<double,int> > levels;
        for (int i=0; i<n; ++i) {
            cin >> xs >> ys >> xt >> yt >> o >> l;
            if (intersect(xa, ya, xb, yb, xs, ys, xt, yt)) {
                if (vertical) {
                    double y = intersection(xa, ya, xb, yb, xs, ys, xt, yt).second;
                    levels.push_back(make_pair(y, o==1 ? l : 1-l));
                } else {
                    double x = intersection(xa, ya, xb, yb, xs, ys, xt, yt).first;
                    levels.push_back(make_pair(x, o==1 ? l : 1-l));
                }
            }
        }

        sort(levels.begin(), levels.end());
        int res = 0;
        for (int i=1; i<(int)levels.size(); ++i) {
            if (levels[i].second != levels[i-1].second) {
                res ++;
            }
        }

        cout << res << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:25: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   50 |         bool vertical = fabs(xa-xb) < fabs(ya-yb);
      |                         ^~~~
      |                         labs
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef pair<double, int> pdi;

struct point { double x, y; };
struct line { point p, q; };

int T, N, O[110], L[110];
line A, S[110];

bool intersect(line l1, line l2) {
  double ax = l1.p.x, ay = l1.p.y;
  double bx = l1.q.x, by = l1.q.y;
  double cx = l2.p.x, cy = l2.p.y;
  double dx = l2.q.x, dy = l2.q.y;
  double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
  return tc * td < 0 && ta * tb < 0;
}

double distance(line l, point p) {
  double ux = l.q.x - l.p.x;
  double uy = l.q.y - l.p.y;
  double vx = p.x - l.p.x;
  double vy = p.y - l.p.y;
  double cross = abs(ux * vy - uy * vx);
  double ul = sqrt(ux * ux + uy * uy);
  return cross / ul;
}

int main(void) {
  cin >> T;
  while(T--) {
    cin >> A.p.x >> A.p.y >> A.q.x >> A.q.y;
    cin >> N;
    REP(i, 0, N) cin >> S[i].p.x >> S[i].p.y >> S[i].q.x >> S[i].q.y >> O[i] >> L[i];

    double d = sqrt((A.p.x - A.q.x) * (A.p.x - A.q.x) + (A.p.y - A.q.y) * (A.p.y - A.q.y));

    vector<pdi> E;
    REP(i, 0, N) if(intersect(A, S[i])) {
      double da = distance(S[i], A.p);
      double db = distance(S[i], A.q);
      double dx = d * da / (da + db);
      E.push_back(pdi(dx, i));
    }

    sort(E.begin(), E.end());

    vector<int> g;
    REP(i, 0, E.size()) {
      int k = E[i].second;
      g.push_back(O[k] == 1 ? L[k] : (L[k] ^ 1));
    }

    int ans = 0;
    REP(i, 0, g.size() - 1) if(g[i] != g[i + 1]) ans++;
    cout << ans << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   53 |     sort(E.begin(), E.end());
      |     ^~~~
      |     sqrt
Language: C++

#include <iostream>
#include <complex>
#include <vector>
#include <utility>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

double dot(P a, P b){return a.X * b.X + a.Y * b.Y;}

double cross(P a, P b){return a.X * b.Y - a.Y * b.X;}


P intersection(L a, L b){
  //??´???a??¨??´???b?????????
  return a.first + cross(b.second-b.first,a.first-b.first)/(-cross(b.second-b.first,a.second-b.first)+cross(b.second-b.first,a.first-b.first))*(a.second-a.first);
}

  
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < 0 ) return +2;
  if( abs(b-a) + EPS < abs(c-a) ) return -2;
  return 0;
}

bool is_cross(L a, L b){
  if(ccw(a.first,a.second,b.first)*ccw(a.first,a.second,b.second) <= 0 &&
     ccw(b.first,b.second,a.first)*ccw(b.first,b.second,a.second) <= 0) return true;
  return false;
}


int main(){
  int N;
  cin >> N;
  double x_s, y_s, x_t, y_t;
  for(int i = 0; i < N; ++i){
    cin >> x_s >> y_s >> x_t >> y_t;
    P a = P(x_s,y_s), b = P(x_t, y_t);
    L S = L(a,b);
    int n, o, l;
    cin >> n;
    vector<pair<P,int> > cp;
    for(int i = 0; i < n; ++i){
      cin >> x_s >> y_s >> x_t >> y_t >> o >> l;
      L T = L(P(x_s,y_s),P(x_t,y_t));
      if(is_cross(S,T))
	cp.push_back(make_pair(intersection(S,T),o^l));
    }
    sort(cp.begin(),cp.end());
    int t = cp[0].second, ans = 0;
    for(int i = 1; i < (int)cp.size(); ++i){
      if(t != cp[i].second){
	++ans;
	t = cp[i].second;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   62 |     sort(cp.begin(),cp.end());
      |     ^~~~
      |     sqrt
Language: C++

#include<iostream>
#include<vector>

using namespace std;

class Road
{
public:
    Road(int _xs, int _ys, int _xt, int _yt, bool _l)
    {
        xs = _xs;
        ys = _ys;
        xt = _xt;
        yt = _yt;
        l = _l;
    }

    int xs, ys, xt, yt;

    //l : true??§?????¶
    bool l;

};

//https://qiita.com/ykob/items/ab7f30c43a0ed52d16f2
bool crossed(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy) 
{
  int ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  int tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  int tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  int td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);

  return tc * td < 0 && ta * tb < 0;
  // return tc * td <= 0 && ta * tb <= 0; // ?????????????????´???
};
int main()
{
    auto data_num = 0;
    cin >> data_num;
    for(auto i = 0; i < data_num; i++)
    {
        int xa, ya, xb, yb;
        cin >> xa >> ya >> xb >> yb;

        int n;
        cin >> n;
        vector<Road> roads;
        roads.reserve(n);

        vector< pair<float, bool> > crossPoints{};

        for(int j = 0; j < n; j++)
        {

            int xs, ys, xt, yt;
            bool o, l;

            cin >> xs >> ys >> xt >> yt >> o >> l;

            //???????????¢?????????
            roads.push_back( Road(xs, ys, xt, yt, !(o ^ l) ) );
        }

        for(const auto& r : roads)
        {
            if(crossed(xa, ya, xb, yb, r.xs, r.ys, r.xt, r.yt))
            {
                float cross_x = ((r.ys * r.xt - r.xs * r.yt) * (xb - xa) - (ya * xb - xa * yb) * (r.xt - r.xs)) / (float)((yb - ya) * (r.xt - r.xs) - (xb - xa) * (r.yt - r.ys)); 
                float cross_y = ((r.ys * r.xt - r.xs * r.yt) * (yb - ya) - (ya * xb - xa * yb) * (r.yt - r.ys)) / (float)((yb - ya) * (r.xt - r.xs) - (xb - xa) * (r.yt - r.ys)); 
                float differ_x = xa - cross_x;
                float differ_y = ya - cross_y;
                float dist = differ_x * differ_x + differ_y * differ_y;

                crossPoints.push_back( make_pair(dist, r.l) );
            }
        }
        sort(crossPoints.begin(), crossPoints.end());



        auto ans = 0;
        bool nowHeight = crossPoints[0].second;
        for(const auto& cp : crossPoints)
        {
            if(nowHeight != cp.second)
            {
                nowHeight = cp.second;
                ans++;
            }
        }


        cout << ans << endl;
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   77 |         sort(crossPoints.begin(), crossPoints.end());
      |         ^~~~
      |         short
Language: Java

import java.io.IOException;
import java.util.Scanner;

public class Water {

	public static void main(String[] args) throws IOException{
		
		while(true){
		int num=0;
		int[] cc= new int[5];
		int n, m, s, g1, g2;
		
		Scanner sc = new Scanner(System.in);
		while(num<5){
			cc[num]=sc.nextInt();
			num++;
        }
		n=cc[0];
		m=cc[1];
		s=cc[2];
		g1=cc[3];
		g2=cc[4];
		
		if(n==0 && m==0){
			if(s==0 && g1==0){
				if(g2==0){break;}
			}
		}
		
		int[][] road= new int[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				road[i][j]=10000;
			}
		}
		

		num=0;
		while(num<m){
			int i=sc.nextInt();
			int j=sc.nextInt();
			int cost=sc.nextInt();
			road[i-1][j-1]=cost;
			road[j-1][i-1]=cost;
			num++;
		}

		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(road[i][j]>road[i][k]+road[k][j]){
						road[i][j]=road[i][k]+road[k][j];
					}
				}
			}
		}
		int r=10000;
		for(int k=0;k<n;k++){
			if(r>road[k][s-1]+road[k][g1-1]+road[k][g2-1]){
				r=road[k][s-1]+road[k][g1-1]+road[k][g2-1];
			}
		}
		System.out.println(r);
		}
	}

}

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

import java.io.IOException;
import java.util.Scanner;

public class Water {

	public static void main(String[] args) throws IOException{
		
		while(true){
		int num=0;
		int[] cc= new int[5];
		int n, m, s, g1, g2;
		
		Scanner sc = new Scanner(System.in);
		while(num<5){
			cc[num]=sc.nextInt();
			num++;
        }
		n=cc[0];
		m=cc[1];
		s=cc[2];
		g1=cc[3];
		g2=cc[4];
		
		if(n==0 && m==0){
			if(s==0 && g1==0){
				if(g2==0){break;}
			}
		}
		
		int[][] road= new int[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				road[i][j]=10000;
			}
		}
		

		num=0;
		while(num<m){
			int i=sc.nextInt();
			int j=sc.nextInt();
			int cost=sc.nextInt();
			road[i-1][j-1]=cost;
			road[j-1][i-1]=cost;
			num++;
		}

		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(road[i][j]>road[i][k]+road[k][j]){
						road[i][j]=road[i][k]+road[k][j];
					}
				}
			}
		}
		int r=1000000;
		for(int k=0;k<n;k++){
			if(r>road[k][s-1]+road[k][g1-1]+road[k][g2-1]){
				r=road[k][s-1]+road[k][g1-1]+road[k][g2-1];
			}
		}
		System.out.println(r);
		}
	}

}

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