#include <iostream>
#include <random>
#include <ctime>


using namespace std;


int main(){
    int hNum, oNum;
    cout << endl;
    cout << "THIS IS A EPIC LEGENDARY BATTLE BETWEEN HUMANS AND ORCS ^-^" << endl << endl;
    cout << "Input the number of humans: "; cin >> hNum;
    cout << "Input the number of orcs: "; cin >> oNum;
    cout << endl;

    mt19937_64 randomGenerator(time(NULL));
    uniform_int_distribution<int> hATK(0, 40);
    uniform_int_distribution<int> oATK(0, 50);

    int hATKp, oATKp;
    int hHP, oHP, HP_lost;
    bool combatEnd;
    while(hNum != 0 && oNum != 0){
        combatEnd = false;
        hHP = 155; oHP = 80;
        while(combatEnd == false){
            hATKp = hATK(randomGenerator);
            oATKp = oATK(randomGenerator);
            if(hATKp > oATKp){
                HP_lost = hATKp - oATKp;
                oHP -= HP_lost;
            }
            if(oATKp > hATKp){
                HP_lost = oATKp - hATKp;
                hHP -= HP_lost;
            }
            if(hHP <= 0){
                hNum--;
                combatEnd = true;
            }
            if(oHP <= 0){
                oNum--;
                combatEnd = true;
            }
        }
    }
    cout << "Battle begin!" << endl;
    if(hNum != 0){
        cout << "Humans win!" << endl;
        cout << hNum << " humans remained" << endl;
    }
    if(oNum != 0){
        cout << "Orcs win!" << endl;
        cout << oNum << " orcs remained" << endl;
    }
    return 0;
}