Language: C++

#include <iostream>
#include <string>
using namespace std;
int a_list[200000];
int main(){
  int n, q, a0, b;
  cin >> n;
  cin >> q >> a >> b;
  a_list[0] = a
  int min_x = a;
  int max_x = a;
  int min = b;
  
  for( int i=1; i< n; i++){
    cin >> q;
    if (q == 1){
      cin >> _a >> _b;
      a_list[i] = _a;
      b += _b;
	  int min_a_sub = abs(min_x - _a);
      int max_a_sub = abs(max_x - _a);
      int a_cand, min_cand1;
      int min_cand2 = b;
           
	  if( min_a_sub < max_a_sub ){
      	min_cand_1 = min + _b + min_a_sub;
        a_cand = min_x;
      }
      else{
        min_cand_1 = min + _b + max_a_sub;
        a_cand = max_x;
      }
 
      for (int j=0; j < i; j++){
	      min_cand_2 += abs(a_list[j] - a_list[i]);
      }
      
      if (min_cand_1 < min_cand_2){
          min = min_cand_1;
          min_x = a_cand;
          max_x = a_cand;
      }
      
      else if (min_cand_1 == min_cand_2){
      	  min = min_cand_1;
      	  if (_a < a_cand){
            min_x = _a;
            max_x = a_cand;
          }
          else if (_a > a_cand) {
          	min_x = a_cand;
            max_x = _a;
          }
          else {
			min_x = _a;
            max_x = _a;
          }
      }
      
      else ( min_cand_2 < min_cand_1){
          min = min_cand_2;
          min_x = _a;
          max_x = _a;
     }
     
     else{
	     if (min_x == max_x){
    	 	cout << min << endl;
	     }
         else{
         	cout << min_x << endl;
         }
     }
   }  
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: 'a' was not declared in this scope
    8 |   cin >> q >> a >> b;
      |               ^
a.cc:17:14: error: '_a' was not declared in this scope
   17 |       cin >> _a >> _b;
      |              ^~
a.cc:17:20: error: '_b' was not declared in this scope; did you mean 'b'?
   17 |       cin >> _a >> _b;
      |                    ^~
      |                    b
a.cc:20:31: error: 'min_x' was not declared in this scope; did you mean 'min'?
   20 |           int min_a_sub = abs(min_x - _a);
      |                               ^~~~~
      |                               min
a.cc:26:9: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   26 |         min_cand_1 = min + _b + min_a_sub;
      |         ^~~~~~~~~~
      |         min_cand1
a.cc:30:9: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   30 |         min_cand_1 = min + _b + max_a_sub;
      |         ^~~~~~~~~~
      |         min_cand1
a.cc:35:15: error: 'min_cand_2' was not declared in this scope; did you mean 'min_cand2'?
   35 |               min_cand_2 += abs(a_list[j] - a_list[i]);
      |               ^~~~~~~~~~
      |               min_cand2
a.cc:38:11: error: 'min_cand_1' was not declared in this scope; did you mean 'min_cand1'?
   38 |       if (min_cand_1 < min_cand_2){
      |           ^~~~~~~~~~
      |           min_cand1
a.cc:38:24: error: 'min_cand_2' was not declared in this scope; did you mean 'min_cand2'?
   38 |       if (min_cand_1 < min_cand_2){
      |                        ^~~~~~~~~~
      |                        min_cand2
a.cc:66:6: error: expected '}' before 'else'
   66 |      else{
      |      ^~~~
a.cc:16:16: note: to match this '{'
   16 |     if (q == 1){
      |                ^
a.cc:67:18: error: 'min_x' was not declared in this scope; did you mean 'min'?
   67 |              if (min_x == max_x){
      |                  ^~~~~
      |                  min