Difference between the two codes? how changes lead to removal of SIGFPE?

#include<bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

lli t; // number of test cases
cin >> t;

lli n, k;

while (t--) {
    cin >> n >> k;

    lli numQuery, totalDays;
    lli queriesLeft = 0;
    bool isQueriesRemaining = true, executeFurther = true;

    for (lli i = 1; i <= n; i++) {
        cin >> numQuery;
        queriesLeft += (numQuery - k);

        if(queriesLeft < 0 && executeFurther) {
            totalDays = i;
            isQueriesRemaining = false;
            executeFurther = false;
        }
    }

    if(isQueriesRemaining) {
        cout << n + (queriesLeft / k) + 1 << endl;
    } else {
        cout << totalDays << endl;
    }
}

return 0;

}

this gives 100 % result

AND

#include<bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

lli t; // number of test cases
cin >> t;

lli n, k;

while (t--) {
    cin >> n >> k;

    lli numQuery, totalDays;
    lli queriesLeft = 0;
    bool isQueriesRemaining = true;

    for (lli i = 1; i <= n; i++) {
        cin >> numQuery;
        queriesLeft += (numQuery - k);

        if(queriesLeft < 0) {
            totalDays = i;
            isQueriesRemaining = false;
            break;
        }
    }

    if(isQueriesRemaining) {
        cout << n + (queriesLeft / k) + 1 << endl;
    } else {
        cout << totalDays << endl;
    }
}

return 0;

}

this gives 80 percent correct result with one testcase having RE(SIGFPE) error .

I think you have to set this condition.
if (queriesLeft < 0 && executeFurther) {
…}

but what is the exact reason that the error SIGFPE vanish using this condition?