#K83162. Flip Pairs in a String

    ID: 36137 Type: Default 1000ms 256MiB

Flip Pairs in a String

Flip Pairs in a String

You are given a string s. Your task is to flip every pair of consecutive characters in the string. More formally, for every even index \(i\) (0-indexed) where \(0 \le i < n-1\), swap the characters \(s[i]\) and \(s[i+1]\). If the length \(n\) of the string is odd, leave the last character in its original position.

Example:

  • If s = "abcdef", the resulting string after flipping will be "badcfe".
  • If s = "abcde", the result will be "badce".

Write a program that reads a string from the standard input and outputs the modified string to the standard output.

inputFormat

The input consists of a single line containing a non-empty string s. The string may consist of alphabetic characters or other symbols.

outputFormat

Output the modified string after flipping every pair of consecutive characters. If the input string has an odd length, the last character should remain unchanged.

## sample
abcdef
badcfe