criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] v = new long[n];
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextLong();
    }
    long[][] left = new long[n + 1][n + 1];
    long[][] right = new long[n + 1][n + 1];
    HashMap<Integer, ArrayList<Long>> leftmap = new HashMap<Integer, ArrayList<Long>>();
    HashMap<Integer, ArrayList<Long>> rightmap = new HashMap<Integer, ArrayList<Long>>();
    ArrayList<Long> leftlist = new ArrayList<Long>();
    ArrayList<Long> rightlist = new ArrayList<Long>();
    for(int i = 0; i < n; i++) {
      leftlist.add(v[i]);
      Collections.sort(leftlist);
      leftmap.put(i + 1, leftlist);
    }
    for(int i = n - 1; i >= 0; i--) {
      rightlist.add(v[i]);
      Collections.sort(rightlist);
      rightmap.put(n - i, rightlist);
    }
    for(int i = 1; i <= n; i++) {
      ArrayList<Long> list = leftmap.get(i);
      long t = 0;
      for(int j = 1; j <= i; j++) {
        t += list.get(i - j);
        left[i][j] = t;
      }
    }
    for(int i = 1; i <= n; i++) {
      ArrayList<Long> list = rightmap.get(i);
      long t = 0;
      for(int j = 1; j <= i; j++) {
        t += list.get(i - j);
        right[i][j] = t;
      }
    }
    // iから高々j取るときの最大値
    long[][] rightmax = new long[n + 1][n + 1];
    for(int i = 1; i <= n; i++) {
      rightmax[i][0] = 0;
      long t = 0;
      for(int j = 1; j <= i; j++) 
        rightmax[i][j] = Math.max(rightmax[i][j - 1], right[i][j]);
      }
    }
    long ans = 0;
    for(int i = 0; i <= Math.min(n, k); i++) {
      for(int j = 0; j <= Math.min(n - i, k - i); j++) {
        for(int i2 = 0; i2 <= Math.min(i, k - i - j); i2++) {
          long t = left[i][i2] + rightmax[j][k - i - j - i2];
          ans = Math.max(ans, t);
        }
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:54: error: illegal start of type
    for(int i = 0; i <= Math.min(n, k); i++) {
    ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= Math.min(n, k); i++) {
                    ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= Math.min(n, k); i++) {
                                ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= Math.min(n, k); i++) {
                                  ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= Math.min(n, k); i++) {
                                     ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= Math.min(n, k); i++) {
                                         ^
Main.java:62: error: <identifier> expected
    System.out.println(ans);
                      ^
Main.java:62: error: <identifier> expected
    System.out.println(ans);
                          ^
Main.java:64: error: class, interface, enum, or record expected
}
^
9 errors
Language: C++

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

int main()
{
    int n, k;
    cin >> n >> k;
    int v[51];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int ans = 0;
    for(int l = 0; l <= n; l++){
        for(int r = n - 1; r >= l - 1; r--){
            if(l + n - 1 - r > k) continue;
            if(l == 0 && r == n - 1) continue;
            vector<int> vec;
            for(int i = 0; i < l; i++){
                vec.push_back(v[i]);
            }
            for(int i = n - 1; i > r; i--){
                vec.push_back(v[i]);
            }
            sort(vec.begin(), vec.end(), greater<int>());
            int nok = k - (l + n - 1 - r);
            int nag = vec.size();
            for(int i = 0; i < nag; i++){
//                cout << vec[i] << " ";
            }
//            cout << "     ";
            int i = nag - 1;
            while(vec[i] < 0 && nok > 0){
                vec.pop_back();
                i--;
                nok--;
            }
            nag = vec.size();
            for(int i = 0; i < nag; i++){
//                cout << vec[i] << " ";
            }
//            cout << "     ";
            int sum = 0;
            for(int i = 0; i < nag; i++){
                sum += vec[i];
            }
//            cout << l << " " << r << " " << sum << endl;
            ans = max(sum, ans);
        }
    }
    cout << ans << endl;
}

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

#include<cstdio>
#include<iostream>
using namespace std;
const int maxn=111;
int dp[maxn][maxn][maxn],A[maxn];
int main()
{
	int N,K;scanf("%d%d",&N,&K);
	for(int i=1;i<=N;++i) scanf("%d",A+i);
	for(int k=1;k<=K;++k)
	{
		memcpy(dp[k],dp[k-1],sizeof(dp[k]));
		for(int i=N;i;--i)
		{
			for(int l=1,r=i;r<=N;++l,++r)
			{
				dp[k][l][r]=max(dp[k][l][r],max(dp[k][l][r-1]+A[r],dp[k][l+1][r]+A[l]));
				if(k>1) dp[k][l][r]=max(dp[k][l][r],max(dp[k-2][l][r-1],dp[k-2][l+1][r]));
//				printf("dp[%d][%d][%d] : %d\n",k,l,r,dp[k][l][r]);
			}
		}
	}
	printf("%d",dp[K][1][N]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'memcpy' was not declared in this scope
   12 |                 memcpy(dp[k],dp[k-1],sizeof(dp[k]));
      |                 ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {

            int n = sc.nextInt();
            int k = sc.nextInt();
            int v[] = new int[n];
            for (int i = 0; i < n; i++) {
                v[i] = sc.nextInt();
            }
            int former[] = new int[n];
            int latter[] = new int[n];

            former[0] = v[0];
            latter[0] = v[n-1];
            for (int i = 1; i < n; i++) {
                former[i] = former[i-1] + v[i];
            }
            for (int i = 1; i < n; i++) {
          

Compiler output:
Main.java:31: error: reached end of file while parsing
            for (int i = 1; i < n; i++) {
                                         ^
Main.java:15: error: 'try' without 'catch', 'finally' or resource declarations
        try {
        ^
2 errors
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) x.begin(),x.end()
#define len(x) (int)(x).size()
//#define endl "\n"
#define m_p make_pair
#define int long long


using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ld,ld> pari;

ld PI = 3.14159265358979323846;


struct Point{
    string a;
    int x,ind;
};

typedef tree<int, null_type, less<int >,
    rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cout << fixed;
}


int n,k;
const int N = 1e6+7;
const int alphabet = 256;
const int INF = 1e18;
const ll MOD = 1e9+7;
const ld eps = 1e-10;
const int L = 30;

int m1 = 137*137*137*137*13;
int m2 = 1e9+9;
//int p = 347;

int mas[N];

void input(){
    cin >> n >> k;
    for(int i = 0;i < n;i++)
        cin >> mas[i];
}

int used[100][100][100];
int dp[100][100][100];

multiset<int> d;

int DP(int l,int r,int cnt){
    if(cnt == 0 || l > r)
        return 0;
    if(!used[l][r][cnt]){

        int m = 0;
        if(cnt <= len(d)){
            int sum = 0;
            int c = 0;
            for(auto i : d){
                sum -= i;
                c++;
                if(c == cnt) break;
            }
            m = max(m,sum);
        }

        if(mas[l] < 0) d.insert(mas[l]);
        m = max(m,DP(l+1,r,cnt-1)+mas[l]);
        if(mas[l] < 0) d.erase(st.find(mas[l]));

        if(mas[r] < 0) d.insert(mas[r]);
        m = max(m,DP(l,r-1,cnt-1)+mas[r]);
        if(mas[r] < 0) d.erase(st.find(mas[r]));

        dp[l][r][cnt] = m;
        used[l][r][cnt] = 1;
        //cout << l << ' ' << ' ' << r << ' ' << dp[l][r][cnt] << endl;
    }
    return dp[l][r][cnt];
}

void solve(){
    cout << DP(0,n-1,k);
}

signed main(){
    volodya22();
    input();
    solve();
}


Compiler output:
a.cc:50:25: warning: integer overflow in expression of type 'int' results in '284612397' [-Woverflow]
   50 | int m1 = 137*137*137*137*13;
      |          ~~~~~~~~~~~~~~~^~~
a.cc: In function 'long long int DP(long long int, long long int, long long int)':
a.cc:86:32: error: 'st' was not declared in this scope; did you mean 'std'?
   86 |         if(mas[l] < 0) d.erase(st.find(mas[l]));
      |                                ^~
      |                                std
a.cc:90:32: error: 'st' was not declared in this scope; did you mean 'std'?
   90 |         if(mas[r] < 0) d.erase(st.find(mas[r]));
      |                                ^~
      |                                std
Language: C++

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n)#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
#define cat(p) cout<<p<<endl
#define catA(p,n) for(int i=0;i<n;i++)cout<<p[i]<<((i==n-1)?"\n":" ")

ll n,k;
ll v[1111];


int main(){ 
  cin>>n>>k;
  rep(i,n)cin>>v[i];

  ll ans=0;


  for(ll ku=0;ku<=k;ku++){
    ll cnt=0;
    vector<ll>ju;
    ju.clear();

    for(ll lef=0;lef<=ku;lef++){
      ll tmp=0;
      vector<ll>tmp_ju;
      tmp_ju.clear();

      bool have[1111];
      rep(i,n)have[i]=0;

      for(int i=0;i<min(n,lef);i++){
        if(!have[i]){tmp+=v[i];tmp_ju.pb(v[i]);have[i]=1;}
      }

      for(int i=0;i<min(n,ku-lef);i++){
        if(!have[n-i-1]){tmp+=v[n-1-i];tmp_ju.pb(v[n-1-i]);have[n-1-i]=1;}
      }


      //cout<<ku<<" "<<lef<<" "<<tmp<<endl;
      //cout<<cnt<<endl;
      sort(tmp_ju.begin(),tmp_ju.end());
      int ss=tmp_ju.size();
      for(int i=0;i<k-ku;i++)if(i<ss&&tmp_ju[i]<0)tmp-=tmp_ju[i];
     //cout<<cnt<<endl;
      ans=max(ans,tmp);
    }


  }


  cout<<ans<<endl;
  return 0;
}

ll v[1111];


int main(){ 
  cin>>n>>k;
  rep(i,n)cin>>v[i];

  ll ans=0;


  for(ll ku=0;ku<=k;ku++){
    ll cnt=0;
    vector<ll>ju;
    ju.clear();

    for(ll lef=0;lef<=ku;lef++){
      ll tmp=0;
      vector<ll>tmp_ju;
      tmp_ju.clear();

      bool have[1111];
      rep(i,n)have[i]=0;

      for(int i=0;i<min(n,lef);i++){
        if(!have[i]){tmp+=v[i];tmp_ju.pb(v[i]);have[i]=1;}
      }

      for(int i=0;i<min(n,ku-lef);i++){
        if(!have[n-i-1]){tmp+=v[n-1-i];tmp_ju.pb(v[n-1-i]);have[n-1-i]=1;}
      }


      //cout<<ku<<" "<<lef<<" "<<tmp<<endl;
      //cout<<cnt<<endl;
      sort(tmp_ju.begin(),tmp_ju.end());
      int ss=tmp_ju.size();
      for(int i=0;i<k-ku;i++)if(i<ss)tmp-=tmp_ju[i];
     //cout<<cnt<<endl;
      ans=max(ans,tmp);
    }


  }


  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc:18:17: error: '#' is not followed by a macro parameter
   18 | #define catA(p,n)#include <iostream>
      |                 ^
a.cc:87:4: error: redefinition of 'long long int v [1111]'
   87 | ll v[1111];
      |    ^
a.cc:38:4: note: 'long long int v [1111]' previously declared here
   38 | ll v[1111];
      |    ^
a.cc:90:5: error: redefinition of 'int main()'
   90 | int main(){
      |     ^~~~
a.cc:41:5: note: 'int main()' previously defined here
   41 | int main(){
      |     ^~~~
Language: C++

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll V[60];

int main()
{
    ll N, K;
    cin >> N >> K;
    REP(i, N)
    {
        cin >> V[i];
    }

    ll max = 0;
    for (int n = 0; n <= std::min(N, K), n++)
    {
        priority_queue<ll, vector<ll>, function<bool(ll, ll)>> q([](ll a, ll b) { return a > b; });
        //! nことる
        for (int l = 0; l <= n; ++l)
        {
            ll sum = 0;
            ll r = n - l;
            REP(i, l)
            {
                sum += V[i];
                if (V[i] < 0)
                    q.push(V[i]);
            }
            REP(i, r)
            {
                sum += V[N - 1 - i];
                if (V[N - 1 - i] < 0)
                    q.push(V[N - 1 - i]);
            }

            REP(i, K - n)
            {
                if (q.empty())
                    break;
                sum -= q.top();
                q.pop();
            }
            max = std::max(max, sum);
        }
    }

    cout << max << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:45: error: expected ';' before ')' token
   26 |     for (int n = 0; n <= std::min(N, K), n++)
      |                                             ^
      |                                             ;
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi V(n);
  for(auto &a:V)cin>>a;
  ll ma=0;
  for(int i=0;i<=n;i++){
    if(i==n){
      ll nokori=k-i;
      ll cost=0;
      for(int j=0;j<n;j++)cost+=V[j];
      while(nokori>0&&!que.empty()&&que.top()<0){
	cost-=que.top();
	que.pop();
	nokori--;
      }
      // cout<<cost<<" "<<i<<" "<<j<<" "<<i+n-j<<endl;
      ma=max(ma,cost);
    }
    for(int j=n;j>i;j--){
      if(k<i+(n-j))continue;
      ll cost=0;
      priority_queue<ll,vi,greater<>>que;
      for(int ii=0;ii<i;ii++){
	cost+=V[ii];
	que.push(V[ii]);
      }
      for(int ii=n-1;ii>=j;ii--){
	cost+=V[ii];
	que.push(V[ii]);
      }
      ll nokori=k-(i+n-j);
      while(nokori>0&&!que.empty()&&que.top()<0){
	cost-=que.top();
	que.pop();
	nokori--;
      }
      // cout<<cost<<" "<<i<<" "<<j<<" "<<i+n-j<<endl;
      ma=max(ma,cost);
    }
  }
  cout<<ma<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:24: error: 'que' was not declared in this scope
   33 |       while(nokori>0&&!que.empty()&&que.top()<0){
      |                        ^~~
Language: C++

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

int v[50];
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> v[i];

    int ans = 0;
    for(int l = 0; l < n; l++) {
        for(int r = l; r <= n; r++) {
            vector<int> g;
            for(int i = 0; i < l; i++) g.push_back(v[i]);
            for(int i = r; i < n; i++) g.push_back(v[i]);
            if(g.size() > k) continue;

            sort(g.begin(), g.end());
            int p = 0;
            for(p = 0; p < min(g.size(), k - g.size()); p++) {
                if(g[p] >= 0) break;
            }

            int s = 0;
            for(int i = p; i < g.size(); i++) s += g[i];
            ans = max(ans, s);
        }
    }

    printf("%d\n", ans);
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,q;cin>>n>>q;
    int S,T,X;
    vector<tuple<int,int,int>> ban(n);
    rep(i,n){
        cin>>S>>T>>X;
        ban[i]=make_tuple(X,S-X,T-X);
    }
    sort(all(ban));
    map<int,int> num;
    set<int> time;
    vin d(q);
    rep(i,q){
        cin>>d[i];
        time.insert(d[i]);
        num[d[i]]=i;
    }
    time.inser(inf);
    vin ans(q,-1);
    //s[i]<=d<t[i]なるdをxが小さい順に見つけていく
    int x,s,t,m,M,l,r,start,end;
    rep(i,n){
        x=get<0>(ban[i]);
        s=get<1>(ban[i]);
        t=get<2>(ban[i]);
        m=*(time.lower_bound(0));
        M=*(--time.lower_bound(inf));
        if(M<s||t<=m)continue;
        l=*(time.lower_bound(s));
        //if(l==*(time.lower_bound(t)))continue;
        if(M<t)r=M;
        else r=*(--time.lower_bound(t));
        start=lower_bound(all(d),l)-d.begin();
        end=upper_bound(all(d),r)-d.begin();
        rep2(j,start,end){
            ans[num[d[j]]]=x;
            time.erase(d[j]);
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:10: error: 'class std::set<int>' has no member named 'inser'; did you mean 'insert'?
   41 |     time.inser(inf);
      |          ^~~~~
      |          insert
Language: C++

#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 100000000000009;

int main()
{
    int n, q;
    cin >> n >> q;
    PP p[200005];
    for(int i = 0; i < n; i++){
        ll s, t, x;
        cin >> s >> t >> x;
        p[i] = PP(x, P(s - x, t - 1 - x));
    }
    sort(p, p + n);
    set<PP> st;
    for(int i = 0; i < n; i++){
        ll l = p[i].second.first, r = p[i].second.second, x = p[i].first;
        auto itr = st.upper_bound(PP(l, P(INF, INF)));
        if(itr != st.begin()){
            auto itr2 = itr;
            itr2--;
            l = max(itr2->second.first + 1, l);
        }
        while(itr != st.end()){
            if(l < min(r, itr->first - 1)) st.insert(PP(l, P(min(r, itr->first - 1), x)));
            l = itr->second.first + 1;
            if(r < l) break;
            itr++;
        }
        if(r >= l) st.insert(PP(l, P(r, x)));
    }
    while(q--){
        ll d;
        cin >> d;
        auto itr = st.upper_bound(PP(d, P(INF, INF)));
        itr--;
        if(d > itr->second.first) cout << -1 << endl;
        else cout << itr->second.second << endl;
    }
}


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

#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int INF = 1000000009;

int main()
{
    int n, q;
    cin >> n >> q;
    PP p[200005];
    for(int i = 0; i < n; i++){
        int s, t, x;
        cin >> s >> t >> x;
        p[i] = PP(x, P(s - x, t - 1 - x));
    }
    sort(p, p + n);
    set<PP> st;
    st.insert(PP(p[0].second.first, P(p[0].second.second, p[0].first)));
    for(int i = 1; i < n; i++){
        int l = p[i].second.first, r = p[i].second.second, x = p[i].first;
        auto itr = st.upper_bound(PP(l, P(INF, INF)));
        if(itr != st.begin()){
            auto itr2 = itr;
            itr2--;
            l = max(itr2->second.first + 1, l);
        }
        while(itr != st.end()){
            if(l < min(r, itr->first - 1)) st.insert(PP(l, P(min(r, itr->first - 1), x)));
            l = itr->second.first + 1;
            if(r < l) break;
            itr++;
        }
        if(r >= l) st.insert(PP(l, P(r, x)));
    }
    while(q--){
        int d;
        cin >> d;
        auto itr = st.upper_bound(PP(d, P(INF, INF)));
        itr--;
        if(d > itr->second.first) cout << -1 << endl;
        else cout << itr->second.second << endl;
    }
}


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

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

//最後のところの処理がいい加減になっていた、こういう詰めの甘い実装がダメなんだよカス
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,q;cin>>n>>q;

    vector<vector<ll>> xst(n);
    REP(i,n){
        ll s,t,x;cin>>s>>t>>x;
        xst[i]={x,s,t};
    }
    sort(ALL(xst));

    vector<ll> d(q);
    REP(i,q)cin>>d[i];

    vector<deque<ll>> ans_sectl(q);
    vector<deque<ll>> ans_sectr(q);
    REP(i,n){
        ll s,t,x;x=xst[i][0];s=xst[i][1];t=xst[i][2];
        ll L=(lower_bound(ALL(d),s-x)-d.begin());
        ll R=(upper_bound(ALL(d),t-x-1)-d.begin())-1;
        //lower,upper気を付ける
        //2RE
        if(L<=R){ans_sectl[L].PB(i);ans_sectr[R].PB(i);}
        //cout << L << " " << R << endl;
    }

    //複数存在しないので、map
    set<ll> ans;
    REP(i,q){
        ll sl=SIZE(ans_sectl[i]);
        ll sr=SIZE(ans_sectr[i]);
        REP(_,sl){
            ans.insert(*(ans_sectl[i].begin()));
            ans_sectl[i].pop_front();
        }
        if(ans.empty()){
            cout<<-1<<"\n";
        }else{
            cout<<xst[*ans.begin()][0]<<"\n";
        }
        REP(_,sr){
            ans.erase(*(ans_sectr[i].begin()));
            if(ans[*(ans_sectr[i].begin())]==0)ans.erase(*(ans_sectr[i].begin()));
            ans_sectr[i].pop_front();
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:19: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'long long int')
   92 |             if(ans[*(ans_sectr[i].begin())]==0)ans.erase(*(ans_sectr[i].begin()));
      |                   ^
Language: Java


import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main2 main = new Main2();
		main.run();
	}

	class Ev implements Comparable<Ev>{
		int x;
		int time;
		int kind;

		public Ev(int x, int time, int kind) {
			this.x=x;
			this.time=time;
			this.kind=kind;
		}

		@Override
		public int compareTo(Ev arg0) {
			return Integer.compare(this.x, arg0.x);
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();

		ArrayList<Ev> ev = new ArrayList<>();
		for(int i=0; i<N; i++) {
			int s=sc.nextInt();
			int t=sc.nextInt();
			int x=sc.nextInt();
			ev.add(new Ev(x, s-x, 1));
			ev.add(new Ev(x, t-x, -1));
		}

		Collections.sort(ev);

		ArrayList<Integer> D = new ArrayList<>();
		for(int i=0; i<Q; i++) {
			D.add(sc.nextInt());
		}

		TreeSet<Integer> set = new TreeSet<>();

		int ans[] = new int[Q];
		Arrays.fill(ans, -1);
		int didx = 0;

		for(Ev e : ev) {

			//アクティブイベントに対してDがぶつかるかテスト
			while(didx<D.size() && D.get(didx) < e.time) {
				if(set.isEmpty()) {
					ans[didx] = -1;
				}else {
					ans[didx] = set.first();
				}
				didx++;
			}

			//アクティブイベント更新
			if(e.kind==1) {
				set.add(e.x);
			} else {
				set.remove(e.x);
			}
		}

		for(int i=0; i<Q; i++) {
			System.out.println(ans[i]);
		}

		sc.close();
	}
}


Compiler output:
Main.java:6: error: cannot find symbol
		Main2 main = new Main2();
		^
  symbol:   class Main2
  location: class Main
Main.java:6: error: cannot find symbol
		Main2 main = new Main2();
		                 ^
  symbol:   class Main2
  location: class Main
2 errors
Language: Java


import java.util.*;

public class Main2 {
	public static void main(String[] args) {
		Main2 main = new Main2();
		main.run();
	}

	class Ev implements Comparable<Ev>{
		int x;
		int time;
		int kind;

		public Ev(int x, int time, int kind) {
			this.x=x;
			this.time=time;
			this.kind=kind;
		}

		@Override
		public int compareTo(Ev arg0) {
			return Integer.compare(this.x, arg0.x);
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();

		ArrayList<Ev> ev = new ArrayList<>();
		for(int i=0; i<N; i++) {
			int s=sc.nextInt();
			int t=sc.nextInt();
			int x=sc.nextInt();
			ev.add(new Ev(x, s-x, 1));
			ev.add(new Ev(x, t-x, -1));
		}

		Collections.sort(ev);

		ArrayList<Integer> D = new ArrayList<>();
		for(int i=0; i<Q; i++) {
			D.add(sc.nextInt());
		}

		TreeSet<Integer> set = new TreeSet<>();

		int ans[] = new int[Q];
		Arrays.fill(ans, -1);
		int didx = 0;

		for(Ev e : ev) {

			//アクティブイベントに対してDがぶつかるかテスト
			while(didx<D.size() && D.get(didx) < e.time) {
				if(set.isEmpty()) {
					ans[didx] = -1;
				}else {
					ans[didx] = set.first();
				}
				didx++;
			}

			//アクティブイベント更新
			if(e.kind==1) {
				set.add(e.x);
			} else {
				set.remove(e.x);
			}
		}

		for(int i=0; i<Q; i++) {
			System.out.println(ans[i]);
		}

		sc.close();
	}
}


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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define int long long

struct Stop {
    int s;
    int t;
    int x;
    Stop(int s, int t, int x): s(s), t(t), x(x) {}
};

signed main(){
    int n, q;
    cin >> n >> q;
    vector<Stop> stop;
    rep(i, n) {
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        stop.emplace_back(s, t, x);
    }
    auto comp1 = [](Stop a, Stop b) {
        return a.s < b.s;
    };
    sort(whole(stop), comp1);
    auto comp2 = [](Stop a, Stop b) {
        return a.x > b.x;
    };
    priority_queue<Stop, vector<Stop>, decltype(comp2)> que{comp2};
    int id = 0;
    
    rep(i, q) {
        int d;
        cin >> d;
        while (id<n && stop[id].s<=d) {
            if (stop[id].t<=d) {
                id++;
            }
            else {
                que.push(stop[id]);
                id++;
            }
        }
        int ans = -1;
        while (!que.empty()) {
            auto now = que.top();
            que.pop();
            if (now.s<=d && now.t>d) {
                ans = now.x;
                q.push(now);
                break;
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:19: error: request for member 'push' in 'q', which is of non-class type 'long long int'
   63 |                 q.push(now);
      |                   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,q,ans[200010];
	vector<ll>d,f;
	vector<tuple<ll,ll,ll>>ch;
	cin>>n>>q;
	for(ll i=0;i<n;i++){
		ll S,T,X;
		cin>>S>>T>>X;
		T--;
		S-=X;
		T-=X;
		ch.push_back(make_tuple(X,S,T));
	}
	sort(ch.begin(),ch.end());
	for(ll i=0;i<q;i++){
		ll now;
		cin>>now;
		d.push_back(now);
		f.push_back(i);
	}
	for(ll i=0;i<n;i++){
		ll now1=get<1>(ch[i]);
		ll now2=get<2>(ch[i]);
		ll now3=get<0>(ch[i]);
		auto itr=lower_bound(d.begin(),d.end(),now1);
		while(now2>=*itr{
			ll next=itr-d.begin();
			ans[f[next]]=now3;
			d.erase(itr);
			f.erase(f.begin()+next);
			if(d.size()==0){
				break;
			}
		}
	}
	for(auto itr=d.begin();itr!=d.end();itr++){
		ll next=itr-d.begin();
		ans[f[next]]=-1;
	}
	for(ll i=0;i<q;i++){
		cout <<ans[i]<<endl;
	}
	// your code goes here
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:33: error: expected ')' before '{' token
   32 |                 while(now2>=*itr{
      |                      ~          ^
      |                                 )
Language: C++

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

struct event{
    ll t,type,val;
    bool operator<(const event& a){
        return t<a.t;
    }
}

int main(){
    ll N,Q; cin>>Q>>N;
    vector<event> eves;
    vector<ll> D(N);
    rep(i,Q){
        ll s,t,q;
        cin>>s>>t>>q;
        eves.push_back({s-q,1,q});
        eves.push_back({t-q,-1,q})
    }
    rep(i,N){
        cin>>D[i];
    }

    sort(ALL(eves));
    int k=0;
    multiset<ll> st;
    rep(i,N){
        while(k<eves.size()&&eves[k].t<=D[i]){
            if(eves[k].type==1){
                st.insert(eves[k].val);
            }
            else{
                st.erase(st.find(eves[k].val));
            }
            k++;
        }
    }

    if(st.empty()){
        cout<<-1<<endl;
    }
    else{
        cout<<*st.begin()<<endl;
    }
    return 0;
}

Compiler output:
a.cc:13:2: error: expected ';' after struct definition
   13 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:23:35: error: expected ';' before '}' token
   23 |         eves.push_back({t-q,-1,q})
      |                                   ^
      |                                   ;
   24 |     }
      |     ~                              
a.cc:29:10: error: 'ALL' was not declared in this scope
   29 |     sort(ALL(eves));
      |          ^~~
Language: C++

import sys;input=sys.stdin.readline
N, Q = map(int, input().split())
X = []
for _ in range(N):
    s, t, x = map(int, input().split())
    X.append((2*s-2*x-1, 0, x))
    X.append((2*t-2*x-1, 1, x))

inf = 10**18
X.append((-inf, 0, inf))
X.append((inf, 1, inf))

X.sort(key=lambda x: x[0])

from heapq import *
from collections import defaultdict
#print(X[1:-1])
j = 0
ll = []
vs = set()
d = defaultdict(int)
for _ in range(Q):
    q = int(input())
    while 1:
        u, f, x = X[j]
        if u > 2*q:
            break
        if f:
            d[x] += 1
        else:
            heappush(ll, x)
        j += 1
    while 1:
        x = heappop(ll)
        if d[x] > 0:
            d[x] -= 1
            continue
        heappush(ll, x)
        if x == inf:
            print(-1)
        else:
            print(x)
        break


Compiler output:
a.cc:17:2: error: invalid preprocessing directive #print
   17 | #print(X[1:-1])
      |  ^~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys;input=sys.stdin.readline
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:1:12: error: 'input' does not name a type; did you mean 'int'?
    1 | import sys;input=sys.stdin.readline
      |            ^~~~~
      |            int
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>

constexpr int MAX = 2*1e5+10;

using P = std::tuple<int, int, int>;
using Q = std::pair<int, int>;

int n,q;

std::vector<P> tm;
std::vector<Q> cand;

int dis[MAX];

int ans[MAX];

void add(int index){
	cand.insert(std::lower_bound(std::begin(cand),std::end(cand),Q(dis[index],index)),Q(dis[index],index));
}


void erase(int index){
	cand.erase(std::lower_bound(std::begin(cand),std::end(cand),Q(dis[index],index)));
}

int main(){
	
	std::cin.tie(0);
	std::ios::sync_with_studio(0);

	int n,q;

	std::cin>>n>>q;

	for(int i=0;i<n;++i){
		int s,t,x;
		std::cin>>s>>t>>x;
		tm.emplace_back(s-x,0,i);
		tm.emplace_back(t-x,1,i);
		dis[i]=x;
	}

	for(int i=0;i<q;++i){
		int d;
		std::cin>>d;
		tm.emplace_back(d,2,i);
	}

	std::sort(std::begin(tm),std::end(tm));

	for(auto&& p : tm){
		int type, index;
		std::tie(std::ignore, type, index) = p;
		if(type == 0)
			add(index);
		else if(type == 1)
			erase(index);
		else if(!cand.empty())
			ans[index]=cand[0].first;
		else
			ans[index]=-1;
		/*std::cerr<<"DEBUG "<<type<<' '<<index<<std::endl;
		for(Q x : cand)
			std::cerr<<x.second<<' ';
		std::cerr<<std::endl;*/
	}

	for(int i=0;i<q;++i)
		std::cout<<ans[i]<<"¥n";
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:33:19: error: 'sync_with_studio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   33 |         std::ios::sync_with_studio(0);
      |                   ^~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define st first.first
#define nd first.second
#define rd second

using namespace std;
int mx1[200200],mx2[200200];
pair<pair<int,int>,int> X[200200];
int main()
{
  int N,Q;
  cin>>N>>Q;
  for(int i=0;i<N;i++)
    cin>>X[i].st>>X[i].nd>>X[i].rd;
  sort(X,X+N);
  int tmp1=-1,tmp2=1000000000;
  for(int i=0;i<N;i++)
  {
    if(X[i].nd>tmp1||tmp1==X[i].nd&&tmp2>X[i].rd)
    {
      tmp1=X[i].nd;
      tmp2=X[i].rd;
    }
    mx1[i]=tmp1;
    mx2[i]=tmp2;
  }
  while(Q--)
  {
    int Time;
    cin>>Time;
    int pos=lower_bound(X,X+N,{{Time+1,-1},-1})-X-1;
    if(pos=-1)
    {
      puts("-1");
      continue;
    }
    if(mx1[pos]<=Time)
    {
      puts("-1");
      continue;
    }
    cout<<mx2[pos]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:24: error: no matching function for call to 'lower_bound(std::pair<std::pair<int, int>, int> [200200], std::pair<std::pair<int, int>, int>*, <brace-enclosed initializer list>)'
   31 |     int pos=lower_bound(X,X+N,{{Time+1,-1},-1})-X-1;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   template argument deduction/substitution failed:
a.cc:31:24: note:   couldn't deduce template parameter '_Tp'
   31 |     int pos=lower_bound(X,X+N,{{Time+1,-1},-1})-X-1;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 3 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
void debug(set<int>& s){
    cerr<<"set: ";
    for(auto x:s){
        cerr<<x<<" ";
    }
    cerr<<endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,Q;
    cin>>N>>Q;
    vector<pair<int, pair<int, int>>> stx(N);
    rep(i,N){
        cin>>stx[i].second.first>>stx[i].second.second>>stx[i].first;
    }
    //xでソート
    sort(all(stx));
    vector<int> S(N), T(N), X(N);
    rep(i,N){
        S[i] = stx[i].second.first;
        T[i] = stx[i].second.second;
        X[i] = stx[i].first;
    }
    vector<int> D(Q), ans(Q, -1);
    set<int> set;
    map<int, int> idx;
    rep(i,Q){
        cin>>D[i];
        idx[D[i]] = i;
        set.insert(D[i]);
    }

    rep(i,N){

        auto l_itr = set.lower_bound(S[i] - X[i]);
        auto r_itr = set.upper_bound(T[i] - X[i]);
        /*
        while(l_itr != r_itr){
            ans[idx[*l_itr]] = X[i];
            l_itr = set.erase(l_itr);
        }*/
        while(l_itr != set.end()){
            if(*l_itr >= T[i] - X[i])break;
            ans[idx[*l_itr]] = X[i];
            set.erase(l_itr++);
        }
    }
    rep(i,Q){
        cout<<ans[i]<<endl;
    }
}

/*

set: 0 1 2 3 5 8 
set: 2 3 5 8 
set: 3 5 8 
set: 5 8 

set: 0 1 2 3 5 8 
set: 1 2 3 5 8 
set: 2 3 5 8 
set: 3 5 8 



Compiler output:
a.cc:78:1: error: unterminated comment
   78 | /*
      | ^
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
#include <unordered_map>
#include <tuple>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n,q; cin >> n >> q;
    vector<tuple<int,int,int>> w(n);
    rep(i,n){
        int s,t,x;
        cin >> s >> t >> x;
        w[i] = make_tuple(x,s-x,t-x);
    }
    sort(all(w));
    vector<int> ans(q); rep(i,q) ans[i] = -1;
    set<pair<int,int>> s;
    rep(i,q){
            int t; cin >> t;
            s.insert(mp(t, i));
    }
    rep(i,n){
        int st = get<1>(w[i]),t = get<2>(w[i]),x = get<0>(w[i]);
        auto litr = lower_bound(all(s), mp(st,-1)); 
        auto ritr = lower_bound(all(s), mp(t,-1));
        if(litr == s.end()) continue;
        while(litr != s.end()){
            if((*litr).first >= r) break;
            ans[(*litr).second] = x;
            s.erase(*litr++);
        }
    }
    for(auto x: ans) cout << x << " ";
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:33: error: 'r' was not declared in this scope
   55 |             if((*litr).first >= r) break;
      |                                 ^
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <pair>

using namespace std;

int main()
{
	long long int n, q;
  
	cin >> n >> q;
  
	long long int s[200010],t[200010],x[200010],d[200010];
  
  for(int i=0;i<n;i++){
    
	 cin >> s[i] >> t[i] >> x[i];
  }
  
  for(int i=0;i<q;i++){
	cin >> d[i];
  }

    pair<pair<long long int, long long int>, long long int> events;
  
	set<long long int>bye;
	for(int i=0;i<n;i++)
	{
		events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
		events.insert(make_pair(make_pair(t[i] - x[i], x[i]), 0));
	}
  
	for(int i=0;i<q;i++)
	{
		if (!events.empty())
		{
			while ((*events.begin()).first.first <= d[i])
			{
				if ((*events.begin()).second == 1) bye.insert((*events.begin()).first.second);
				else bye.erase(bye.find((*events.begin()).first.second));
				events.erase(events.begin());
				if (events.empty()) break;
			}
		}

		long long int ans;
		if (bye.empty()) ans = -1;
      
		else ans = *bye.begin();
      
		cout << ans << endl;
	}
}


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

#include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long long int n, q;
  
	cin >> n >> q;
  
	long long int s[200010],t[200010],x[200010],d[200010];
  
  for(int i=0;i<n;i++){
    
	 cin >> s[i] >> t[i] >> x[i];
  }
  
  for(int i=0;i<q;i++){
	cin >> d[i];
  }

    pair<pair<long long int, long long int>, long long int>> events;
  
	set<long long int>bye;
	for(int i=0;i<n;i++)
	{
		events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
		events.insert(make_pair(make_pair(t[i] - x[i], x[i]), 0));
	}
  
	for(int i=0;i<q;i++)
	{
		if (!events.empty())
		{
			while ((*events.begin()).first.first <= d[i])
			{
				if ((*events.begin()).second == 1) bye.insert((*events.begin()).first.second);
				else bye.erase(bye.find((*events.begin()).first.second));
				events.erase(events.begin());
				if (events.empty()) break;
			}
		}

		long long int ans;
		if (bye.empty()) ans = -1;
      
		else ans = *bye.begin();
      
		cout << ans << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:59: error: expected unqualified-id before '>' token
   24 |     pair<pair<long long int, long long int>, long long int>> events;
      |                                                           ^~
a.cc:29:17: error: 'events' was not declared in this scope
   29 |                 events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
      |                 ^~~~~~
a.cc:35:22: error: 'events' was not declared in this scope
   35 |                 if (!events.empty())
      |                      ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
	long long int N, Q;
  
	cin >> n >> q;
  
	long long int s[200010],t[200010],x[200010],d[200010];
  
  for(int i=0;i<n;i++){
    
	 cin >> s[i] >> t[i] >> x[i];
  }
  
  for(int i=0;i<q;i++){
	cin >> d[i];
  }

    pair<pair<long long int, long long int>, long long int>>events;
  
	set<long long int>bye;
	for(int i=0;i<n;i++)
	{
		events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
		events.insert(make_pair(make_pair(t[i] - x[i], x[i]), 0));
	}
  
	for(int i=0;i<q;i++)
	{
		if (!events.empty())
		{
			while ((*events.begin()).first.first <= d[i])
			{
				if ((*events.begin()).second == 1) bye.insert((*events.begin()).first.second);
				else bye.erase(bye.find((*events.begin()).first.second));
				events.erase(events.begin());
				if (events.empty()) break;
			}
		}

		long long int ans;
		if (bye.empty()) ans = -1;
      
		else ans = *bye.begin();
      
		cout << ans << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: 'n' was not declared in this scope
    9 |         cin >> n >> q;
      |                ^
a.cc:9:21: error: 'q' was not declared in this scope
    9 |         cin >> n >> q;
      |                     ^
a.cc:22:59: error: expected unqualified-id before '>' token
   22 |     pair<pair<long long int, long long int>, long long int>>events;
      |                                                           ^~
a.cc:27:17: error: 'events' was not declared in this scope
   27 |                 events.insert(make_pair(make_pair(s[i] - x[i], x[i]), 1));
      |                 ^~~~~~
a.cc:33:22: error: 'events' was not declared in this scope
   33 |                 if (!events.empty())
      |                      ^~~~~~
Language: Java

til.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int N = fs.nextInt(), Q = fs.nextInt();
		int stop[][] = new int[N][3];
		for(int i=0;i<N;i++) {
			int s = fs.nextInt(), t = fs.nextInt(), x = fs.nextInt();
			stop[i][0] = s;
			stop[i][1] = t; //通行止は[s,t)と解釈して良い。
			stop[i][2] = x;			
		}
		int D[] = new int[Q];
		for(int i=0;i<Q;i++)D[i] = fs.nextInt();
		
		TreeMap<Integer,Integer> tm = new TreeMap<>(); 
		
		for(int i=0;i<N;i++) {
			int s = stop[i][0];
			int t = stop[i][1];
			int x = stop[i][2];
			tm.put(s-x,x);
			tm.put(t-1-x, x);
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<Q;i++) {
			int q = D[i];
			if(tm.floorKey(q)==null || tm.ceilingKey(q)==null) {
				sb.append(-1 + "\n");
				continue;
			}
			int low = tm.floorKey(q);
			int hi = tm.ceilingKey(q);
			
			if(low!=hi) {
				sb.append(-1 + "\n");
				continue;
			}
			sb.append(tm.get(low)+ "\n");
		}
		System.out.println(sb.toString());
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
til.*;
^
Main.java:2: error: class, interface, enum, or record expected
import java.io.*;
^
2 errors