Language: C++

// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
  
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
  
typedef pair<int, int> pii;
typedef long long ll;
  
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
  
signed main() {
    int N; cin >> N;
    int H, A, D, S; cin >> H >> A >> D >> S;
 
    vector< tuple<int, int, int, int> > enemies;
    for(int i=0; i<N; i++) {
        int h, a, d, s; cin >> h >> a >> d >> s;
 
        // 主人公が攻撃しても意味ない
        if(A - d <= 0) {
            // 敵がつよい
            if(a - D > 0) {
                cout << -1 << endl;
                return 0;
            }
            // 戦闘不能判定に関係ないからいらなさそう
            else {
                continue;
            }
        }
        // 敵が攻撃しても意味ない
        if(a - D <= 0) {
            continue;
        }
         
        enemies.emplace_back(h, a, d, s);
    }
 
    sort(enemies.begin(), enemies.end(), [&](auto x, auto y) {
            int xh, xa, xd, xs; tie(xh, xa, xd, xs) = x;
            int yh, ya, yd, ys; tie(yh, ya, yd, ys) = y;
 
            // 何ターンで死ぬか
            int xdam = A - xd; int xturn = (xh + xdam - 1) / xdam;
            int ydam = A - yd; int yturn = (yh + ydam - 1) / ydam;
 
            // 敵の攻撃はいくつ？
            int xinj = xa - D, yinj = ya - D;
 
            // 何回攻撃するか (x -> y)
            int xatkl = (xs > S ? xturn : xturn - 1);
            int yatkl = (ys > S ? xturn + yturn : xturn + yturn - 1);
 
            // 何回攻撃するか (y -> x)
            int yatkr = (ys > S ? yturn : yturn - 1);
            int xatkr = (xs > S ? xturn + yturn : xturn + yturn - 1);
 
            int suml = xinj * xatkl + yinj * yatkl;
            int sumr = xinj * xatkr + yinj * yatkr;
            return suml < sumr;
        });
 
    int turn_sum = 0, mi = 0;
    for(auto e : enemies) {
        int h, a, d, s; tie(h, a, d, s) = e;
        int dam = A - d, turn = (h + dam - 1) / dam;
        int inj = a - D;
 
        // fprintf(stderr, "dam = %lld, turn = %lld, inj = %lld\n", dam, turn, inj);
        turn_sum += turn;
        int atk = (s > S ? turn_sum : turn_sum - 1);
 
        mi += atk * inj;
        if(mi >= H) {
            cout << -1 << endl;
            return 0;
        ]
    }
 
    if(mi >= H) cout << -1 << endl;
    else cout << mi << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:9: error: expected primary-expression before ']' token
  110 |         ]
      |         ^
a.cc:116:2: error: expected '}' at end of input
  116 | }
      |  ^
a.cc:44:15: note: to match this '{'
   44 | signed main() {
      |               ^