Reference solution
Time: O(1) · Space: O(1)One correct implementation. Any approach that satisfies the constraints is equally valid.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n;
if (!(cin >> n)) return 0;
if (n > 0) cout << "positive" << '\n';
else if (n < 0) cout << "negative" << '\n';
else cout << "zero" << '\n';
return 0;
}