#C13494. Square Integers in Mixed List

    ID: 43038 Type: Default 1000ms 256MiB

Square Integers in Mixed List

Square Integers in Mixed List

You are given a list containing a mix of integers and strings. Your task is to square every integer in the list while leaving the strings unchanged. The order of the elements should be preserved in the output.

Note: An integer is any token that can be parsed as an integer (which may include a preceding '-' sign), and any token that is not a valid integer should be treated as a string.

Input/Output Specification: The input is provided via standard input and the output must be printed to standard output.

Example: If the input list is [1, 'a', 3, 'b'], then the output should be [1, 'a', 9, 'b'].

inputFormat

The input consists of two lines:

  • The first line contains a single integer N representing the number of elements in the list.
  • The second line contains N space-separated tokens. Each token is either an integer or a string. A token should be interpreted as an integer if it can be parsed as such (including negative numbers), otherwise it is a string.

outputFormat

Output the transformed list on a single line. The elements should be space-separated. For integer tokens, output their squared value; for strings, output them unchanged. If the list is empty, output nothing.

## sample
4
1 a 3 b
1 a 9 b