CodeforcesApr 24, 2025

3 Palindrome

Hazrat Ali

Codeforces

He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a', 'b' or 'c', with no palindromes of length 3 appearing in the string as a substring. For example, the strings "abc" and "abca" suit him, while the string "aba" doesn't. He also want the number of letters 'c' in his string to be as little as possible.

Input

The first line contains single integer n (1 ≤ n ≤ 2·105) — the length of the string.

Output

Print the string that satisfies all the constraints.

If there are multiple answers, print any of them.

Examples
Input
2
Output
aa
Input
3
Output
bba

Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  string ans;
  for (int i = 0; i < n; i++) {
    ans += 'a';
  }
  for (int i = 2; i < n; i += 4) {
    ans[i] = 'b';
    if (i + 1 < n) {
      ans[i + 1] = 'b';
    }
  }
  cout << ans << endl;
  return 0;
}
 



Comments