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);
string name;
int age;
if (!(cin >> name >> age)) return 0;
cout << name << " is " << age << " years old" << '\n';
return 0;
}