P7662 [COCI 2014/2015 #5] ZGODAN

Description

Define a Handsome number: in this positive integer, the parity of any two adjacent digits is different. Given a positive integer $n$, find the Handsome number closest to $n$. If there are multiple answers, output them in increasing order.

Input Format

A positive integer $n$.

Output Format

The Handsome number(s) closest to $n$.

Explanation/Hint

For $100\%$ of the testdata, $1 \leq n \leq 10^{1000}$. Translated from [COCI 2014/2015 CONTEST #5](https://hsin.hr/coci/archive/2014_2015/contest5_tasks.pdf). Translated by ChatGPT 5