input: Write a python function to convert Python code to C++ code.
  assert py2cpp("print('Hello World')") == '#include <iostream>\n\nint main() {\n    std::cout << "Hello World" << std::endl;\n    return 0;\n}'
  assert py2cpp("a = 5\nb = 3\nc = a + b") == 'int a = 5;\nint b = 3;\nint c = a + b;'
  assert py2cpp("for i in range(3):\n    print(i)") == '#include <iostream>\n\nint main() {\n    for (int i = 0; i < 3; ++i) {\n        std::cout << i << std::endl;\n    }\n    return 0;\n}'
output: def py2cpp(py_code):
      lines = py_code.split('\n')
      cpp_code = []
      
      if any("print(" in line for line in lines):
          cpp_code.append('#include <iostream>')
          cpp_code.append('\nint main() {')
          for line in lines:
              if "print(" in line:
                  cpp_code.append('    std::cout << ' + line.split("print(")[1][:-1].replace("'", "\"") + ' << std::endl;')
          cpp_code.append('    return 0;')
          cpp_code.append('}')
      else:
          for line in lines:
              if '=' in line:
                  var, value = line.split('=')
                  var = var.strip()
                  value = value.strip()
                  cpp_code.append(f'int {var} = {value};')
              elif line.startswith('for '):
                  var_name = line.split(' in ')[0].split()[-1]
                  range_vals = line.split('range(')[1].split(')')[0]
                  start, end = 0, int(range_vals)
                  if ',' in range_vals:
                      start, end = map(int, range_vals.split(','))
                  cpp_code.append(f'#include <iostream>')
                  cpp_code.append('\nint main() {')
                  cpp_code.append(f'    for (int {var_name} = {start}; {var_name} < {end}; ++{var_name}) {{')
              elif line.startswith('    '):
                  cpp_code.append('        ' + line.strip().replace("print(", "std::cout << ").replace(")", " << std::endl;"))
                  cpp_code.append('    }')
                  cpp_code.append('    return 0;')
                  cpp_code.append('}')
  
      return '\n'.join(cpp_code)