text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, l, m, n; cin >> n; string s; cin >> s; string ans = ""; set<char> st; st.insert('a'); st.insert('e'); st.insert('i'); st.insert('o'); st.insert('u'); st.insert('y'); j = 0; i = 0; while (i < n) { if (st.find(s[i]) != st.end()) { char ch = s[i]; long long cnt = 0; j = i; while (j < n && ch == s[j]) { j++; cnt++; } if (cnt == 2 && (ch == 'o' || ch == 'e')) { ans += s[i]; ans += s[i]; } else { ans += s[i]; } i = j; } else { ans += s[i]; i++; } } cout << ans << endl; }
#include <bits/stdc++.h> int main() { char s[100001]; int n; scanf("%d%s", &n, &s); for (int i = 0; i < n; ++i) { if (s[i] != 'a' && s[i] != 'e' && s[i] != 'o' && s[i] != 'i' && s[i] != 'u' && s[i] != 'y') { printf("%c", s[i]); continue; } if (s[i] == 'o' || s[i] == 'e') { if (i == 0 && s[i] == s[i + 1] && s[i] != s[i + 2]) { printf("%c%c", s[i], s[i]); i++; continue; } else if (i == n - 2 && s[i] == s[i + 1] && s[i] != s[i - 1]) { printf("%c%c", s[i], s[i]); i++; continue; } else if (i < n - 1 && s[i] == s[i + 1] && s[i] != s[i - 1] && s[i] != s[i + 2]) { printf("%c%c", s[i], s[i]); i++; continue; } } if (s[i] != s[i - 1]) printf("%c", s[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } const long long maxn = (long long)2e3 + 10; const long long maxm = (long long)20; const int LOGN = 20; const long long INF = 1e15 + 10; const long long MOD = 1e9 + 7; const double PI = acos(-1.0); const double EPS = 1e-12; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string s; cin >> n >> s; string ans; int p = 0; char last; vector<int> d(128); d['a'] = d['e'] = d['i'] = d['o'] = d['u'] = d['y'] = 1; while (p < n) { if (!d[s[p]]) { ans += s[p]; ++p; continue; } int q = p; while (q < n && s[p] == s[q]) ++q; auto t = s.substr(p, q - p); if (t == "ee" || t == "oo") { ans += t; } else { ans += s[p]; } p = q; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> long long max(long long a, long long b) { if (a < b) return b; return a; } long long min(long long a, long long b) { if (a < b) return a; return b; } long long isVowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return 1; return 0; } void solve() { long long n; scanf("%lld", &n); char s[n]; scanf("%s", s); char ans[n]; long long ind = 0; for (int i = 0, j = i; i < n; i = j) { if (!isVowel(s[i])) { ans[ind++] = s[j++]; continue; } while (j < n && isVowel(s[j]) && s[i] == s[j]) j++; long long len = j - i; if (len == 2 && (s[i] == 'o' || s[i] == 'e')) { ans[ind++] = s[i]; ans[ind++] = s[i]; continue; } ans[ind++] = s[i]; } for (int i = 0; i < ind; i++) printf("%c", ans[i]); } int main() { solve(); return 0; }
#include <bits/stdc++.h> int main() { int n, tmp, c = 1; scanf("%d", &n); char arr[6] = {'a', 'e', 'i', 'o', 'u', 'y'}, ch, s[n]; scanf("%s", s); int b[n], i, j; for (i = 0; i < n; i++) b[i] = 0; for (i = 0; i < 6; i++) { ch = arr[i], c = 0; for (j = 0; j < n; j++) { if (s[j] == ch) c++; else c = 0; if (c > 1 && ch != 'e' && ch != 'o') b[j] = 1; else if (c > 2 && (ch == 'e' || ch == 'o')) { b[j - 1] = 1; b[j] = 1; } } } for (i = 0; i < n; i++) if (!b[i]) printf("%c", s[i]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; long long n, f = 0, v = 0, a = 0, u = 0, y = 0, k = 0; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == 'e') { f++; if (f > 2) { s[i - 1] = ' '; s[i] = ' '; } } else { f = 0; } if (s[i] == 'o') { v++; if (v > 2) { s[i] = ' '; s[i - 1] = ' '; } } else { v = 0; } if (s[i] == 'a') { a++; if (a > 1) s[i] = ' '; } else { a = 0; } if (s[i] == 'u') { u++; if (u > 1) s[i] = ' '; } else { u = 0; } if (s[i] == 'y') { y++; if (y > 1) s[i] = ' '; } else { y = 0; } if (s[i] == 'i') { k++; if (k > 1) s[i] = ' '; } else { k = 0; } } while (s.find(' ') != -1) { s.erase(s.find(' '), 1); } cout << s; return 0; }
#include <bits/stdc++.h> int main() { int n; char s[100005]; scanf("%d", &n); scanf("%s", &s); for (int i = 0; i < n; i++) { char x = s[i]; printf("%c", x); if (x == 'a' || x == 'e' || x == 'o' || x == 'u' || x == 'y' || x == 'i') { int k = 0; while (s[i] == s[i + 1]) { k++; i++; } if (k == 1 && (x == 'o' || x == 'e')) printf("%c", x); } } }
#include <bits/stdc++.h> using namespace std; bool Vow(char c) { return c == 'a' || c == 'e' || c == 'o' || c == 'y' || c == 'i' || c == 'u'; } int main() { int n, i, j, k; string S, ans; cin >> n >> S; for (i = 0; i < n; ++i) { if (!Vow(S[i])) { ans += S[i]; } else { j = i; k = 0; ++i; ++k; while (i < S.size() && S[i] == S[i - 1]) { ++k; ++i; } if (k == 1) { ans += S[j]; i = j; } else if (k == 2 && (S[j] == 'o' || S[j] == 'e')) { ans += S[j]; ans += S[j]; --i; } else { ans += S[j]; --i; } } } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; string s; cin >> s; for (int i = 1; i < s.size(); i++) { if (s[i] == s[i - 1] && (s[i] == 'a' || s[i] == 'y' || s[i] == 'u' || s[i] == 'i')) { s.erase(i, 1); i--; } else if (s[i] == s[i - 1] && s[i + 1] == s[i] && (s[i] == 'e' || s[i] == 'o')) { int j = i; while (s[j] == s[i - 1]) { s.erase(j, 1); } } } cout << s; return 0; }
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); char str[n]; scanf("%s", str); char res[n]; char c = str[0]; int count = 1; for (int i = 1; i < n; i++) { if (str[i] == c) { count++; } else { if ((c == 'o' || c == 'e') && count <= 2) { for (int j = 0; j < count; j++) { printf("%c", c); } } else if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { printf("%c", c); } else { for (int j = 0; j < count; j++) { printf("%c", c); } } c = str[i]; count = 1; } } if ((c == 'o' || c == 'e') && count <= 2) { for (int j = 0; j < count; j++) { printf("%c", c); } } else if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { printf("%c", c); } else { for (int j = 0; j < count; j++) { printf("%c", c); } } return 0; }
#include <bits/stdc++.h> using namespace std; pair<int, int> operator+(pair<int, int> a, pair<int, int> b) { return {a.first + b.first, a.second + b.second}; } bool vowel(char c) { return (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' || c == 'y'); } int main() { int n; cin >> n; string s; cin >> s; string temp = ""; string ans = ""; for (int i = 0; i < s.size(); i++) { if ((temp.size() == 0 || temp.back() == s[i])) { temp += s[i]; } else { if (!vowel(temp.back()) || temp == "oo" || temp == "ee") ans += temp; else ans += temp.back(); temp = s[i]; } } if (!vowel(temp.back()) || temp == "oo" || temp == "ee") ans += temp; else ans += temp.back(); cout << ans << "\n"; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") using namespace std; const int mod = (int)1e9 + 7; const int N = 6e4 + 10; const long long inf = -1e9; const int maxm = 53; vector<vector<char>> matrix(maxm, vector<char>(maxm)); vector<vector<int>> vt(maxm, vector<int>(maxm)); struct event { int x, y, size; }; int dx[] = {0, 0, 1, -1}; int dy[] = {-1, 1, 0, 0}; struct myComp { constexpr bool operator()(pair<int, int> const& a, pair<int, int> const& b) const noexcept { return a.first < b.first; } }; vector<int> g[N]; vector<char> p = {'a', 'e', 'i', 'o', 'u', 'y'}; bool is_char(char c) { for (auto it : p) if (it == c) return true; return false; } bool ok(char c) { if (c == 'o' || c == 'e') return true; return false; } void solve() { int n; cin >> n; string s; cin >> s; string res; for (int i = 0; i < n; i++) { if (is_char(s[i])) { int k = i; while (k < n && s[k] == s[i]) k++; if (k - i == 2 && ok(s[i])) res += s[i]; i = k - 1; } res += s[i]; } cout << res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#include <bits/stdc++.h> char s[100005]; int is_vowel(char ch) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y') return 1; else return 0; } int main() { int n; scanf("%d", &n); scanf("%s", s); s[n] = '#'; char prev = '-'; int prevn = 0; for (int i = 0; i < n + 1; ++i) { if (is_vowel(s[i]) != 1) { if (prevn != 0) { if ((prevn == 2 && prev == 'o') || (prevn == 2 && prev == 'e')) printf("%c%c", prev, prev); else printf("%c", prev); } if (s[i] == '#') break; printf("%c", s[i]); prev = '-'; prevn = 0; } else { if (prev == s[i]) { ++prevn; } else { if (prevn != 0) { if ((prevn == 2 && prev == 'o') || (prevn == 2 && prev == 'e')) printf("%c%c", prev, prev); else printf("%c", prev); } prevn = 1; prev = s[i]; } } } return 0; }
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b, long long c) { long long res = a + b; return (res >= c ? res - c : res); } long long mod_neg(long long a, long long b, long long c) { long long res; if (abs(a - b) < c) res = a - b; else res = (a - b) % c; return (res < 0 ? res + c : res); } long long mul(long long a, long long b, long long c) { long long res = (long long)a * b; return (res >= c ? res % c : res); } template <typename T> T power(T e, T n) { T x = 1, p = e; while (n) { if (n & 1) x = x * p; p = p * p; n >>= 1; } return x; } template <typename T> T mdpower(T e, T n, T m) { T x = 1, p = e; while (n) { if (n & 1) x = mul(x, p, m); p = mul(p, p, m); n >>= 1; } return x; } template <typename T> T extended_euclid(T a, T b, T &x, T &y) { T xx = 0, yy = 1; y = 0; x = 1; while (b) { T q = a / b, t = b; b = a % b; a = t; t = xx; xx = x - q * xx; x = t; t = yy; yy = y - q * yy; y = t; } return a; } template <typename T> T mod_inverse(T a, T n) { T x, y, z = 0; T d = extended_euclid(a, n, x, y); return (d > 1 ? -1 : mod_neg(x, z, n)); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; char arr[] = {'a', 'e', 'i', 'o', 'u', 'y'}; map<char, long long> mp; mp['a'] = mp['e'] = mp['i'] = mp['o'] = mp['u'] = mp['y'] = 1; string s; cin >> s; string p = ""; for (long long i = 0; i < n;) { if (mp.find(s[i]) == mp.end()) { p += s[i]; i++; } else { long long count = 0; long long j = i; for (; j < n; j++) if (s[j] == s[i]) count++; else break; if (count == 1) p += s[i]; else if (count == 2 and (s[i] == 'e' or s[i] == 'o')) { p += s[i]; p += s[i]; } else if (count >= 2) { p += s[i]; } i = j; } } cout << p << "\n"; cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; }
#include <bits/stdc++.h> using namespace std; long long int em(long long int x, long long int Mod, long long int n) { if (n == 0) return 1ll; else if (n % 2 == 0) return em((x % Mod * x % Mod) % Mod, Mod, n / 2) % Mod; else return (x % Mod * em((x % Mod * x % Mod) % Mod, Mod, (n - 1) / 2)) % Mod; } int32_t main() { std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, i, j, k, l; cin >> n; string str; cin >> str; long long int flag = 0, c = 0; char vow = 'z'; for (char y : str) { if (y != 'a' && y != 'e' && y != 'i' && y != 'o' && y != 'u' && y != 'y') { if (c > 0) { if (vow == 'o' || vow == 'e') { if (c == 2) { if (vow == 'o') cout << "oo"; else cout << "ee"; c = 0; } else { cout << vow; c = 0; } } else { cout << vow; c = 0; } } cout << y; } else { if (vow == y) { c++; } else { if (c > 0) { if (vow == 'o' || vow == 'e') { if (c == 2) { if (vow == 'o') cout << "oo"; else cout << "ee"; c = 0; } else { cout << vow; c = 0; } } else { cout << vow; c = 0; } } c++; vow = y; } } } if (c > 0) { if (vow == 'o' || vow == 'e') { if (c == 2) { if (vow == 'o') cout << "oo"; else cout << "ee"; c = 0; } else { cout << vow; c = 0; } } else { cout << vow; c = 0; } } }
#include <bits/stdc++.h> int sz, n; char lst, c; void write_symb() { int gl = 0, eoro = 0; if (lst == 'a' || lst == 'e' || lst == 'i' || lst == 'o' || lst == 'i' || lst == 'u' || lst == 'y') gl = 1; if (lst == 'e' || lst == 'o') eoro = 1; if (!gl || (gl && eoro && sz == 2)) for (int i = 0; i < sz; i++) printf("%c", lst); else printf("%c", lst); } int main() { scanf("%d", &n); scanf("%c", &c); lst = '$'; for (int i = 0; i < n; i++) { scanf("%c", &c); if (lst != c) { if (lst != '$') write_symb(); sz = 1; lst = c; } else sz++; } write_symb(); return 0; }
#include <bits/stdc++.h> const long long int mod = 9999999999999983; long long int primes[6] = {1125899906842597, 1495921043, 1005985879, 1495921043, 1005985879, 1495921043}; using namespace std; vector<long long int> adj[2000009]; long long int parent[2000009]; long long int vis[2000009]; long long int level[2000009]; long long int dist[2000009]; long long int arr[2000009]; long long int brr[2000009]; long long int crr[2000009]; long long int hashing[2000009]; long long int ar[509][509]; long long int br[509][509]; long long int cr[509][509]; int main() { int start_s = clock(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector<long long int> vect, vt, vct; vector<long long int>::iterator itt; set<long long int> st; set<long long int>::iterator itr; map<long long int, long long int> mp; map<long long int, long long int>::iterator it; string str; long long int i, j, k, n, m, q, t, a, b, c, maxi = INT_MIN, mini = INT_MAX, sum = 0, ans = 0, res = 0, val = 0, ans1 = 0, ans2 = 0, rem = 0, diff = 0, cnt = 0, l, r, flag = 0, e, index, val1 = 0, val2 = 0, x, y, z, h = 0, u, v, mid; cin >> n; cin >> str; long long int has[30] = {0}; for (i = 0; i < str.size(); i++) { if (str[i] == 'a' || str[i] == 'i' || str[i] == 'u' || str[i] == 'y') { has[str[i] - 'a']++; val = str[i] - 'a'; if (has[str[i] - 'a'] > 1) str[i] = '0'; for (j = 0; j <= 25; j++) { if (j != val) has[j] = 0; } } else if (str[i] == 'e' || str[i] == 'o') { has[str[i] - 'a']++; val = str[i] - 'a'; if (has[str[i] - 'a'] > 2) { str[i] = '0'; str[i - 1] = '0'; } for (j = 0; j <= 25; j++) { if (j != val) has[j] = 0; } } else { for (j = 0; j < 26; j++) has[j] = 0; } } for (i = 0; i < str.size(); i++) { if (str[i] != '0') cout << str[i]; } }
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1000000; using namespace std; long long n, i, j; char x1[300000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; srand(time(0)); cin >> n; for (i = 1; i <= n; i++) cin >> x1[i]; long long l1 = 1; while (l1 <= n) { long long h = 0; if (x1[l1] == 'a') { while (x1[l1] == 'a' and l1 <= n) l1++, h++; cout << 'a'; continue; } if (x1[l1] == 'e') { while (x1[l1] == 'e' and l1 <= n) l1++, h++; if (h == 2) cout << "ee"; else cout << 'e'; continue; } if (x1[l1] == 'i') { while (x1[l1] == 'i' and l1 <= n) l1++, h++; cout << 'i'; continue; } if (x1[l1] == 'o') { while (x1[l1] == 'o' and l1 <= n) l1++, h++; if (h == 2) cout << "oo"; else cout << "o"; continue; } if (x1[l1] == 'u') { while (x1[l1] == 'u' and l1 <= n) l1++, h++; cout << "u"; continue; } if (x1[l1] == 'y') { while (x1[l1] == 'y' and l1 <= n) l1++, h++; cout << "y"; continue; } cout << x1[l1]; l1++; } cout << endl; return 0; }
#include <bits/stdc++.h> char s[100009]; int main() { int a, b, c, d, e, f, g, h; while (scanf("%d", &a) == 1) { scanf("%s", s); for (int i = 0; i < a; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'u' || s[i] == 'o' || s[i] == 'i' || s[i] == 'y') { if (s[i + 1] == s[i]) { if (s[i] == 'o' || s[i] == 'e') { if (s[i + 2] != s[i] && (!i || s[i] != s[i - 1])) { printf("%c", s[i]); } } } else { printf("%c", s[i]); } } else { printf("%c", s[i]); } } printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; void citire(); void rez(); string s; int n, cnt = 1; void afis(); int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> s; char k; for (int i = 0; i < n; i++) { cnt = 1; if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { k = s[i]; for (int j = i + 1; j < n; j++) { if (s[j] == k) s[j] = '1'; else break; } } if (s[i] == 'e' || s[i] == 'o') { k = s[i]; for (int j = i + 1; j < n; j++) { if (s[j] == k) { cnt++; s[j] = '1'; } else { if (cnt == 2) { s[j - 1] = k; } cnt = 1; break; } } if (cnt == 2) s[n - 1] = k; } } for (int i = 0; i < n; i++) { if (s[i] != '1') cout << s[i]; } cout << '\n'; }
#include <bits/stdc++.h> char a[100001]; char ans[100001]; int judge(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return 1; return 0; } int main() { int n, i, j, p = 0, l = -1, r = -1; scanf("%d", &n); scanf("%s", a); for (i = 0; i < n; i++) { if (i <= r) continue; if (i == n - 1) { ans[p++] = a[i]; continue; } if (a[i] == a[i + 1] && judge(a[i])) { l = i; r = i + 1; for (j = i + 2; j < n; j++) { if (a[j] == a[i]) r = j; else break; } if (r - l + 1 == 2 && (a[i] == 'e' || a[i] == 'o')) { ans[p++] = a[i]; ans[p++] = a[i]; } else ans[p++] = a[i]; } else { ans[p++] = a[i]; } } printf("%s", ans); return 0; }
#include <bits/stdc++.h> int n; char c; int main() { scanf("%d\n", &n); char tmp = '\0'; int cnt = 1; for (int i = 0; i < n; i++) { scanf("%c", &c); if (tmp != c) { if ((tmp == 'e' || tmp == 'o') && (cnt == 2)) printf("%c", tmp); cnt = 1; printf("%c", c); tmp = c; } else { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { cnt++; if ((i == n - 1) && (tmp == 'e' || tmp == 'o') && (cnt == 2)) printf("%c", tmp); } else printf("%c", c); } } }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; n--; string s; cin >> s; string ans = ""; ans += s[0]; long long i = 1; while (i <= n) { if (s[i] == 'a') { if (s[i - 1] != 'a') ans += s[i]; i++; continue; } else if (s[i] == 'y') { if (s[i - 1] != 'y') ans += s[i]; i++; continue; } else if (s[i] == 'i') { if (s[i - 1] != 'i') ans += s[i]; i++; continue; } else if (s[i] == 'u') { if (s[i - 1] != 'u') ans += s[i]; i++; continue; } else if (s[i] == 'e' || s[i] == 'o') { if (s[i - 1] != s[i]) { ans += s[i]; i++; continue; } if (i == 1) { if (i <= n - 1) { if (s[i + 1] != s[i]) ans += s[i]; } else ans += s[i]; i++; continue; } else if (s[i - 1] == s[i] && s[i - 2] == s[i]) { i++; continue; } else if (s[i - 1] == s[i]) { if (i == n) { ans += s[i]; } else if (s[i + 1] != s[i]) ans += s[i]; i++; continue; } else ans += s[i]; i++; continue; } else ans += s[i]; i++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; bool isvowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; string s; cin >> s; string ans, str; str += s[0]; long long cnt = 1; for (long long i = 1; i < n; ++i) { if (s[i] == s[i - 1]) str += s[i], ++cnt; else { if (isvowel(s[i - 1])) { if (cnt == 2) { if (s[i - 1] == 'e' || s[i - 1] == 'o') ans += str; else ans += s[i - 1]; } else ans += s[i - 1]; } else ans += str; str = ""; str += s[i]; cnt = 1; } } if (cnt > 1) { if (isvowel(s[n - 1])) { if (cnt == 2) { if (s[n - 1] == 'e' || s[n - 1] == 'o') ans += str; else ans += s[n - 1]; } else ans += s[n - 1]; } else ans += str; } else ans += s[n - 1]; cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; char c = s[0]; if (c != 'o' && c != 'e') cout << c; int cnt = 1; for (int i = 1; i < n; ++i) { char c1 = s[i]; if (c1 != c) { if (c == 'o' || c == 'e') { if (cnt == 2) cout << c << c; else cout << c; } cnt = 1; } else { cnt++; } if (c1 == 'a' || c1 == 'y' || c1 == 'u' || c1 == 'i') { if (cnt == 1) cout << c1; } else if (c1 != 'e' && c1 != 'o') { cout << c1; } c = c1; } if (c == 'o' || c == 'e') { if (cnt == 2) cout << c << c; else cout << c; } }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = (int)1e9 + 7; const int N = (int)1e6 + 7; int n; char s[N]; bool check(char c) { char t[] = "aeiouy"; for (int i = 0; t[i]; ++i) if (c == t[i]) return true; return false; } void Init() { scanf("%s", s); } int Solve() { int len = strlen(s); vector<char> ans; for (int pl = 0, pr = 0; pl < n; pl = pr) { while (pr < len && s[pr] == s[pl]) pr++; int cnt = pr - pl; if (check(s[pl])) { if (s[pl] != 'e' && s[pl] != 'o') cnt = 1; else cnt = cnt > 2 ? 1 : cnt; } for (int i = (0); i < (cnt); ++i) ans.push_back(s[pl]); } for (auto x : ans) printf("%c", x); return puts(""); } int main() { while (~scanf("%d", &n)) { Init(); Solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; char s[100005]; int main() { int n; scanf("%d", &n); scanf("%s", s); s[n] = '#'; for (int i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if (s[i] == 'e' || s[i] == 'o') { int same = 1; if (i != n - 1) { if (s[i + 1] == s[i]) same++; } if (same == 2) { if (i != n - 2) { if (s[i + 2] == s[i]) { printf("%c", s[i]); for (int j = i + 2; j <= n; j++) { if (s[j] != s[i]) { i = j - 1; break; } } } else { printf("%c%c", s[i], s[i]); i++; } } else { printf("%c%c", s[i], s[i]); i++; } } else printf("%c", s[i]); } else { printf("%c", s[i]); for (int j = i + 1; j <= n; j++) { if (s[i] != s[j]) { i = j - 1; break; } } } } else printf("%c", s[i]); } }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int inf = 1e9; const int N = 40005; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; string s, res = ""; cin >> s; for (int i = 0; i < s.size(); i++) { int k = 0; char c = s[i]; if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { i++; k++; while (s[i] == s[i - 1]) { k++; i++; } if ((c == 'e' || c == 'o') && k == 2) { res += c; } i--; } res += c; } cout << res << endl; return 0; }
#include <bits/stdc++.h> int main() { int n; char str[100000]; scanf("%d", &n); scanf("%s%n", str, &n); int norm[100000]; for (int i = 0; i < 100000; ++i) norm[i] = 1; for (int i = 0; i < n - 1; ++i) { if (str[i] == str[i + 1]) { if (str[i] == 'a' || str[i] == 'u' || str[i] == 'y' || str[i] == 'i') norm[i] = 0; } } int ind = 0; while (ind < n - 1) { if (str[ind] == str[ind + 1]) { if (str[ind] == 'e' || str[ind] == 'o') { int counter = 0; for (int i = ind; i < n; ++i) { if (str[i] == str[ind]) counter++; else break; } if (counter == 2) ++ind; else { for (int i = 1; i < counter; ++i) norm[ind + i] = 0; ind += counter; } } else { ++ind; } } else { ++ind; } } for (int i = 0; i < n - 1; ++i) if (norm[i] == 1) printf("%c", str[i]); return 0; }
#include <bits/stdc++.h> using namespace std; const long double pi = 3.141592653589793; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, oj = -1, ej = -1; cin >> n; string s; cin >> s; s += '+'; for (long long i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { oj = -1; ej = -1; if (s[i] != s[i + 1]) cout << s[i]; continue; } if (s[i] == 'o') { ej = -1; if (oj == -1) { oj = i; cout << s[i]; continue; } if (s[i + 1] == 'o') continue; if (i == oj + 1) { cout << s[i]; oj = -1; } continue; } if (s[i] == 'e') { oj = -1; if (ej == -1) { ej = i; cout << s[i]; continue; } if (s[i + 1] == 'e') continue; if (i == ej + 1) { cout << s[i]; ej = -1; } continue; } oj = -1; ej = -1; cout << s[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; bool fl = false, fll = false; string ans; int cnt = 0, i, j; for (i = 0; i < n; ++i) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if (s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'y') { char ch = s[i]; bool flag = false; while (i < n && s[i] == ch) { i++; flag = true; } if (flag) --i; ans += s[i]; continue; } else { cnt = 0; char ch = s[i]; bool flag = false; while (i < n && s[i] == ch) { i++; cnt++; flag = true; } if (flag) --i; ans += ch; if (cnt == 2) ans += ch; continue; } } else ans += s[i]; } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; string s; cin >> s; string ans = ""; string c = ""; for (long long int i = 0; i < n; i++) { if (c.size() == 0) { c = c + s[i]; } else if (s[i] == s[i - 1]) { c = c + s[i]; } else { if ((c[0] == 'e' || c[0] == 'o') && c.size() > 2) { c = c[0]; } else if (c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'y') { c = c[0]; } ans = ans + c; c = ""; i--; } } if (c.size() > 0) { if ((c[0] == 'e' || c[0] == 'o') && c.size() > 2) { c = c[0]; } else if (c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'y') { c = c[0]; } ans = ans + c; c = ""; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; vector<pair<char, int>> v; v.push_back(make_pair(s[0], 1)); for (int i = 1; i < n; ++i) { char last = v.back().first; if (last != s[i]) { v.push_back(make_pair(s[i], 1)); } else ++v[v.size() - 1].second; } string gls("aeiouy"); for (int i = 0; i < v.size(); ++i) { char now = v[i].first; if (gls.find(now) != gls.npos) { if (now == 'o' || now == 'e') { if (v[i].second == 2) cout << now << now; else cout << now; } else cout << now; } else for (int j = 0; j < v[i].second; ++j) cout << now; } return 0; }
#include <bits/stdc++.h> using namespace std; int dir8[8][2] = {{1, 2}, {2, 1}, {-1, 2}, {2, -1}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}}; int dir4[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; const int INF = 0x3f3f3f3fLL; const long long LLF = 0x3f3f3f3f3f3f3f3fLL; const int MAXn = 2e5 + 15; const int mod = 1e9 + 7; char v[7] = {'e', 'o', 'a', 'i', 'y', 'u'}, s[MAXn], s1[MAXn]; int p = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, ans = 1, j; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == s[i + 1]) { ans++; } else { for (j = 0; j < 6; j++) { if (s[i] == v[j]) break; } if (j <= 1) { if (ans > 2) s1[p++] = s[i]; else while (ans--) { s1[p++] = s[i]; } } else if (j >= 2 && j < 6) { s1[p++] = s[i]; } else if (j >= 6) while (ans--) { s1[p++] = s[i]; } ans = 1; } } cout << s1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; char x; int n = 0; cin >> n; int m = 0; cin >> s; for (int i = 0; i < s.length(); i++) { x = s[i]; int j = i; while (x == s[j]) { j++; } if ((j - i == 2) && ((x == 'e') || (x == 'o'))) continue; else if ((j - i >= 2) && ((x == 'a') || (x == 'e') || (x == 'i') || (x == 'o') || (x == 'u') || (x == 'y'))) s.erase(i, j - i - 1); } cout << s; }
#include <bits/stdc++.h> char data[110005]; using namespace std; struct { char op; int cnt; } ans[110005]; char tmp[110005]; int main() { int top = 0; int sum = 0; int n; scanf("%d", &n); getchar(); gets(data); for (int i = 0; i < n; i++) { ans[top].op = data[i]; ans[top].cnt = 1; if (data[i] == data[i + 1]) { while (data[i] == data[i + 1] && i + 1 < n) { ans[top].cnt++; i++; } top++; } else top++; } for (int i = 0; i < top; i++) { if (ans[i].op == 'a') { tmp[sum++] = 'a'; } else if (ans[i].op == 'e') { if (ans[i].cnt != 2) { tmp[sum++] = 'e'; } else { tmp[sum++] = 'e'; tmp[sum++] = 'e'; } } else if (ans[i].op == 'o') { if (ans[i].cnt != 2) { tmp[sum++] = 'o'; } else { tmp[sum++] = 'o'; tmp[sum++] = 'o'; } } else if (ans[i].op == 'i' || ans[i].op == 'u' || ans[i].op == 'y') { tmp[sum++] = ans[i].op; } else { for (int j = 0; j < ans[i].cnt; j++) tmp[sum++] = ans[i].op; } } for (int i = 0; i < sum; i++) { printf("%c", tmp[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; long long power(long long a, int n) { if (n == 0) return 1; if ((n % 2) == 0) return power(a * a, n / 2); else return a * power(a * a, n / 2); } bool is_vow(char a) { return ((a == 'a') || (a == 'e') || (a == 'i') || (a == 'o') || (a == 'u') || (a == 'y')); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; string ans; vector<int> v(26); char a = ':'; if (!is_vow(s[0])) { ans += s[0]; } else { v[s[0] - 'a']++; a = s[0]; } for (int i = 1; i < s.size(); i++) { if (is_vow(s[i])) { if (s[i] == a) { v[s[i] - 'a']++; } else { if (a != ':') { if ((a == 'e') || (a == 'o')) { if (v[a - 'a'] == 2) { ans += a; ans += a; } else { ans += a; } } else { ans += a; } v[a - 'a'] = 0; } a = s[i]; v[a - 'a'] = 1; } } else { if (a != ':') { if ((a == 'e') || (a == 'o')) { if (v[a - 'a'] == 2) { ans += a; ans += a; } else { ans += a; } } else { ans += a; } v[a - 'a'] = 0; } a = ':'; ans += s[i]; } } if (a != ':') { if ((a == 'e') || (a == 'o')) { if (v[a - 'a'] == 2) { ans += a; ans += a; } else { ans += a; } } else { ans += a; } v[a - 'a'] = 0; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int n; char a[100007]; set<char> V; int main() { V.insert('a'); V.insert('e'); V.insert('i'); V.insert('o'); V.insert('u'); V.insert('y'); cin >> n; int j = 1; for (int i = 1; i <= n; i++) { cin >> a[i]; } a[n + 1] = '#'; for (int i = 1; i <= n + 1; i++) if (a[i] != a[j]) { if (i - j > 2) { if (V.count(a[j])) cout << a[j]; else for (int t = j; t < i; t++) cout << a[t]; } else if (i - j == 2) { if (a[j] == 'e' || a[j] == 'o' || !V.count(a[j])) cout << a[j] << a[j]; else cout << a[j]; } else { cout << a[j]; } j = i; } }
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9; const long long N = 1e5 + 1; const long long mod = 1e8 + 0; const long double eps = 1E-7; int n; char a[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n;) { if (a[i] == 'a' or a[i] == 'e' or a[i] == 'u' or a[i] == 'i' or a[i] == 'o' or a[i] == 'y') { int p = i + 1; while (a[p] == a[i]) { p++; } if ((a[i] == 'e' or a[i] == 'o') and p - i == 2) { cout << a[i] << a[i]; } else { cout << a[i]; } i = p; } else { cout << a[i]; i = i + 1; } } }
#include <bits/stdc++.h> bool isvowel(char ch) { return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y'; } char ltr = '\0'; int count = 0; void finish() { if (isvowel(ltr)) { if ((ltr == 'e' || ltr == 'o') && count == 2) { putc(ltr, stdout); putc(ltr, stdout); } else { putc(ltr, stdout); } } } int main() { int n; scanf("%d\n", &n); for (int i = 0; i < n; ++i) { char cur = getc(stdin); if (!isvowel(cur)) { finish(); putc(cur, stdout); ltr = '\0'; count = 0; } else if (cur == ltr) { ++count; } else { finish(); ltr = cur; count = 1; } } finish(); putc('\n', stdout); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n; string s, res; string ex = "aoeuyi"; cin >> n >> s; for (int i = 0; i < n; i++) { size_t pos = ex.find(s[i]); if (pos != string::npos) { int cnt = 0, p = i; while (s[i] == s[p++]) cnt++; if ((cnt == 2) && (s[i] == 'e' || s[i] == 'o')) { res += s.substr(i, cnt); i += cnt - 1; } else { res += s[i]; i += cnt - 1; } } else { res += s[i]; } } cout << res << endl; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char a; cin >> a; int cnt = 1; for (int i = 1; i < n; i++) { char b; cin >> b; if (a == b) { cnt++; } else { if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') { if ((a == 'e' || a == 'o') && cnt == 2) { for (int j = 0; j < cnt; j++) cout << a; } else cout << a; } else { for (int j = 0; j < cnt; j++) cout << a; } cnt = 1; } a = b; } if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'y') { if ((a == 'e' || a == 'o') && cnt == 2) { for (int j = 0; j < cnt; j++) cout << a; } else cout << a; } else { for (int j = 0; j < cnt; j++) cout << a; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int len; string a; cin >> len >> a; a += '-'; a += '-'; string v = ""; for (int i = 0; i < int(a.size()) - 2; i++) { if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' || a[i] == 'y') { if (v.empty() || v[v.size() - 1] != a[i]) { if (a[i + 1] == a[i] && a[i] != a[i + 2] && (a[i] == 'e' || a[i] == 'o')) { v += a[i]; v += a[i]; } else { v += a[i]; } } } else { v += a[i]; } } cout << v; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 7; const int INF = 2.1e9; struct ch { char c; int fre; ch(char c, int t) { c = c; fre = t; } ch() {} }; vector<ch> ans; char vowel[] = {'a', 'e', 'i', 'o', 'u', 'y'}; int main() { int n; cin >> n; string s; cin >> s; ch lst; lst.c = s[0]; lst.fre = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == lst.c) { lst.fre++; } else { ans.push_back(lst); lst.c = s[i]; lst.fre = 1; } } ans.push_back(lst); for (int i = 0; i < ans.size(); i++) { if (ans[i].c == 'e' && ans[i].fre == 2) { cout << "ee"; continue; } if (ans[i].c == 'o' && ans[i].fre == 2) { cout << "oo"; continue; } int f = 1; for (int j = 0; j < 6; j++) if (ans[i].c == vowel[j]) { cout << ans[i].c; f = 0; } if (f) { for (int j = 0; j < ans[i].fre; j++) cout << ans[i].c; } } }
#include <bits/stdc++.h> using namespace std; bool vowel(char s) { return (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u' || s == 'y'); } void solve() { int n; cin >> n; string s; cin >> s; string ans; char lastchar = '&'; int i = 0; for (; i + 1 < n; i++) { if (s[i] == 'e' || s[i] == 'o') { ans += s[i]; int ctr = 0; while (i + 1 < n && s[i] == s[i + 1]) { i++; ctr++; } if (ctr == 1) ans += s[i]; lastchar = s[i]; continue; } if (s[i] != lastchar || !vowel(s[i])) { ans += s[i]; } lastchar = s[i]; } if (i < n && (s[i] != lastchar || !vowel(s[i]))) ans += s[i]; cout << ans << "\n"; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string glas = "ayui", all = "eo"; int n; cin >> n; string s, res; cin >> s; res += s[0]; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1] and glas.find(s[i]) != -1) { continue; } else { res += s[i]; } } s = res; res.resize(0); int count = 0; res += s[0]; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1] and all.find(s[i]) != -1) { count++; res += s[i]; } else { if (count >= 2) { while (count-- > 0) res.pop_back(); } count = 0; res += s[i]; } } if (count >= 2) { while (count-- > 0) res.pop_back(); } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char a[100500]; bool gl(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true; else return false; } int main() { int n, sch = 0; scanf("%d%s", &n, a); for (int i = 0; i < n; i++) { if (i > 0 && a[i] != a[i - 1] && gl(a[i - 1])) { if ((a[i - 1] == 'e' || a[i - 1] == 'o') && sch == 2) printf("%c", a[i - 1]); printf("%c", a[i - 1]); sch = 0; } if (!gl(a[i])) printf("%c", a[i]); else sch++; } if (gl(a[n - 1])) { if ((a[n - 1] == 'e' || a[n - 1] == 'o') && sch == 2) printf("%c", a[n - 1]); printf("%c", a[n - 1]); } return 0; }
#include <bits/stdc++.h> using namespace std; bool included(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } int cnt[100100][30]; int main() { int n; string s; cin >> n; cin >> s; s += '#'; int k = 0; for (int i = 0; i < s.size() - 1; i++) { cnt[k][s[i] - 'a']++; if (s[i] != s[i + 1]) k++; } for (int i = 0; i < k; i++) { char id = 'a'; for (int j = 0; j < 26; j++) { if (cnt[i][j] != 0) id = (char)(j + 'a'); } int rep = cnt[i][id - 'a']; if (included(id)) { rep = 1; if ((id == 'e' || id == 'o') && cnt[i][id - 'a'] == 2) rep = cnt[i][id - 'a']; } while (rep--) cout << id; } }
#include <bits/stdc++.h> using namespace std; int t, n, k; int vowel(char x) { if (x - 'a' && x - 'e' && x - 'i' && x - 'o' && x - 'u' && x - 'y') return 1; return 0; } string second; int main() { cin >> n >> second; for (int i = 0; i < n; i++) { if (!vowel(second[i]) && second[i] != second[i + 1]) { cout << second[i]; continue; } if (vowel(second[i])) { cout << second[i]; } else { if (second[i] == second[i + 1]) { if (second[i] - 'e' && second[i] - 'o') { while (second[i] == second[i + 1]) i++; cout << second[i]; } else { if (second[i] == second[i + 1] && second[i + 1] != second[i + 2]) { cout << second[i] << second[i + 1]; i++; } else { while (second[i] == second[i + 1]) { i++; } cout << second[i]; } } } } } }
#include <bits/stdc++.h> long c, n; char val[100005], ar[100005]; long occ[100005]; int main() { scanf("%ld%s", &n, ar); for (long i = 0; i < n; ++i) { if (!c || val[c - 1] != ar[i]) val[c] = ar[i], occ[c] = 1, c++; else occ[c - 1]++; } for (long i = 0; i < c; ++i) { if (val[i] == 'a' || val[i] == 'e' || val[i] == 'i' || val[i] == 'o' || val[i] == 'u' || val[i] == 'y') { if (val[i] == 'e' || val[i] == 'o') { if (occ[i] == 1 || occ[i] > 2) printf("%c", val[i]); else printf("%c%c", val[i], val[i]); } else { printf("%c", val[i]); } } else { for (long j = 0; j < occ[i]; ++j) printf("%c", val[i]); } } }
#include <bits/stdc++.h> using namespace std; long long int __gcd(long long int a, long long int b) { return (a % b) ? __gcd(b, a % b) : b; } bool prime(long long int k) { for (long long int i = 2; i * i <= k; i++) if (k % i == 0) { return false; } return true; } void pdash(int n = 1) { for (int i = 0; i < n; i++) { for (int j = 0; j < 30; j++) { cout << "-"; } cout << "\n"; } } void solve() { int n; string cmp = "aeiouy"; cin >> n; string str; cin >> str; string ans = ""; for (int i = 0, j = 0; i < n && j < n;) { bool iv = 0; for (int k = 0; k < 6; k++) { if (str[i] == cmp[k]) { iv = 1; break; } } if (!iv) { ans += string(str.begin() + i, str.begin() + i + 1); i++; j++; continue; } while (str[i] == str[j] and j < n) { j++; } if (j - i == 2 and (str[i] == 'e' || str[i] == 'o')) { ans += string(str.begin() + i, str.begin() + (i + 2)); } else { ans += string(str.begin() + i, str.begin() + i + 1); } i = j; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; int n, o; string a[100100], s, aux; int main() { cin >> n; cin >> s; for (int i = 0; i < s.length();) { int j = i; aux = ""; while (s[i] == s[j]) { aux += s[j]; j++; } i = j; a[o] = aux; o++; } for (int i = 0; i < o; i++) { if (a[i] == "oo" || a[i] == "ee") cout << a[i]; else { if (a[i][0] == 'a' || a[i][0] == 'e' || a[i][0] == 'i' || a[i][0] == 'o' || a[i][0] == 'u' || a[i][0] == 'y') { cout << a[i][0]; } else cout << a[i]; } } }
#include <bits/stdc++.h> char s; char p; int a; int main() { int n; scanf("%d", &n); scanf("%c", &s); scanf("%c", &s); int i; for (i = 0; i < n;) { p = s; a = 0; for (; s == p; i++, a++, scanf("%c", &s)) ; if (p == 'e' && a == 2) { printf("ee"); } else if (p == 'o' && a == 2) { printf("oo"); } else if (p == 'a' || p == 'e' || p == 'y' || p == 'u' || p == 'i' || p == 'o') { printf("%c", p); } else { int j; for (j = 0; j < a; j++) printf("%c", p); } } }
#include <bits/stdc++.h> using namespace std; int n, fix[100000], x, x1; string s, s1; int main() { cin >> n; cin >> s; s1 = s; for (int i = 1; i <= n; i++) { if (s[i] == s[i - 1]) { x++; } else if (s[i - 1] == 'a' || s[i - 1] == 'e' || s[i - 1] == 'i' || s[i - 1] == 'o' || s[i - 1] == 'u' || s[i - 1] == 'y') { x1 = x; if (x == 1) { if (s[i - 1] == 'e' || s[i - 1] == 'o') { x = 0; continue; } else { s[i - 1] = '1'; } x = 0; } else { for (int a = 1; a <= x1; a++) { s[i - a] = '1'; } } x = 0; } else { x = 0; } } cout << endl; for (int i = 0; i < n; i++) { if (s[i] != '1') { cout << s[i]; } } cout << endl; }
#include <bits/stdc++.h> using namespace std; bool ok(char ch) { return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y'); } int main() { int n; cin >> n; string s; cin >> s; string ans = ""; int i = 0; while (i < n) { if (!ok(s[i])) ans.push_back(s[i]), i++; else { char ch = s[i]; int cnt = 0; while (ch == s[i] && i < n) i++, cnt++; if (ch == 'e' && cnt == 2) ans.push_back(ch), ans.push_back(ch); else if (ch == 'o' && cnt == 2) ans.push_back(ch), ans.push_back(ch); else ans.push_back(ch); } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; bool isVowel(char c) { return (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u' or c == 'y'); } void solve() { int n; cin >> n; string s; cin >> s; char c; for (int i = 0; i < n; i++) { if (isVowel(s[i])) { char c = s[i]; int len = 1; while (++i < n and s[i] == c) len++; if (len == 2 and (c == 'e' or c == 'o')) cout << c << c; else cout << c; i--; } else cout << s[i]; } cout << "\n"; return; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int b[1000000]; char c[1000000]; char a[1000000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int j; j = 0; b[0] = 1; c[0] = a[0]; for (int i = 1; i < n; i++) if (a[i - 1] == a[i]) b[j]++; else { j++; b[j] = 1; c[j] = a[i]; } for (int i = 0; i < n; i++) { if (((b[i] == 2) && (c[i] == 'e')) || ((b[i] == 2) && (c[i] == 'o'))) continue; if (((b[i] > 1) && (c[i] == 'e')) || ((b[i] > 1) && (c[i] == 'y')) || ((b[i] > 1) && (c[i] == 'u')) || ((b[i] > 1) && (c[i] == 'i')) || ((b[i] > 1) && (c[i] == 'o')) || ((b[i] > 1) && (c[i] == 'a'))) b[i] = 1; } for (int i = 0; i < n; i++) for (int j = 0; j < b[i]; j++) cout << c[i]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; string std; cin >> n; int k, i, j; char c; cin >> std; for (i = 0; i < n;) { if (std[i] == 'a' || std[i] == 'i' || std[i] == 'u' || std[i] == 'y') { j = i + 1; cout << std[i]; while (std[j] == std[i]) { j++; } i = j; } else if (std[i] == 'o' || std[i] == 'e') { k = 0; c = std[i]; while (c == std[i]) { i++; k++; } if (k == 1) cout << c; else if (k == 2) cout << c << c; else cout << c; } else { cout << std[i]; i++; } } }
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323846; int rx[8] = {1, 1, 1, -1, -1, -1, 0, 0}; int ry[8] = {0, -1, 1, 0, -1, 1, 1, -1}; int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; double sabc(double a1, double a2, double a3, double b1, double b2, double b3) { double g = ((a1 - a3) * (b2 - b3) - (b1 - b3) * (a2 - a3)) / 2; return abs(g); } int n; string s, h; map<char, bool> w; int main() { ios_base::sync_with_stdio(0); w['a'] = 1; w['e'] = 1; w['i'] = 1; w['o'] = 1; w['u'] = 1; w['y'] = 1; cin >> n >> s; for (int i = 0; i < s.size(); i++) { if (!w[s[i]]) cout << s[i]; else { h.push_back(s[i]); int pos = i + 1; while (h[h.size() - 1] == s[pos] && pos < s.size()) h.push_back(s[pos]), pos++; if (h.size() == 2 && (h[0] == 'e' || h[0] == 'o')) cout << h; else cout << h[0]; h.clear(); if (pos != i + 1) i = pos - 1; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { unsigned int n, k, d; string s; cin >> n; while (s.size() != n) { cin >> s; } for (unsigned int j = 0; j < n - 1; j++) { if (s[j] == 'a' || s[j] == 'y' || s[j] == 'i' || s[j] == 'u' || s[j] == 'e' || s[j] == 'o') { k = j; d = 1; while (s[k] == s[k + 1]) { k++; d++; } if ((s[j] == 'e' || s[j] == 'o') && d == 2) { } else { s.erase(j, d - 1); n = n - (d - 1); } } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; pair<char, int> k; int n; cin >> n >> s; k = {s[0], 1}; for (int i = 1; i < s.size(); ++i) { if (s[i] != s[i - 1]) { if (k.first == 'o' && k.second == 2) cout << "oo", k.first = s[i], k.second = 1; else if (k.first == 'e' && k.second == 2) cout << "ee", k.first = s[i], k.second = 1; else if (k.first != 'a' && k.first != 'i' && k.first != 'u' && k.first != 'y' && k.first != 'e' && k.first != 'o') { for (int j = 0; j < k.second; ++j) cout << k.first; k.first = s[i], k.second = 1; } else cout << k.first, k.first = s[i], k.second = 1; } else k.second++; } if (k.first == 'o' && k.second == 2) cout << "oo"; else if (k.first == 'e' && k.second == 2) cout << "ee"; else if (k.first != 'a' && k.first != 'i' && k.first != 'u' && k.first != 'y' && k.first != 'e' && k.first != 'o') { for (int j = 0; j < k.second; ++j) cout << k.first; } else cout << k.first; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; string s, tmp; cin >> s; char ch; int count = 0; for (int i = 0; i < n; i++) { ch = s[i]; if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y') { while (s[i] == ch) { count++; i++; } i = i - 1; if (count == 2 && (ch == 'e' || ch == 'o')) { tmp.push_back(ch); tmp.push_back(ch); count = 0; continue; } } tmp.push_back(ch); count = 0; } cout << tmp << endl; return 0; }
#include <bits/stdc++.h> char s[100100]; int n; inline int vovel(char zn) { return (zn == 'a' || zn == 'u' || zn == 'e' || zn == 'i' || zn == 'o' || zn == 'y'); } int main() { scanf("%d", &n); scanf("%s", s + 1); for (int i = 1; i <= n; ++i) { if (!vovel(s[i])) printf("%c", s[i]); else { if (s[i - 1] != s[i]) printf("%c", s[i]); else if (s[i] == s[i - 1] && (s[i] == 'e' || s[i] == 'o') && s[i - 2] != s[i] && s[i + 1] != s[i]) printf("%c", s[i]); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, i, j; string st, st1; cin >> n >> st; char pre_ch; map<char, long long> mp; for (i = 0; i < st.size(); i++) { char ch = st[i]; if (i == 0) { mp[ch] = 1; } else { if (ch != pre_ch) { if (pre_ch == 'a' || pre_ch == 'i' || pre_ch == 'u' || pre_ch == 'y') { st1.push_back(pre_ch); } else if (pre_ch == 'e' || pre_ch == 'o') { if (mp[pre_ch] == 2) { st1.push_back(pre_ch); st1.push_back(pre_ch); } else st1.push_back(pre_ch); } else { for (j = 0; j < mp[pre_ch]; j++) st1.push_back(pre_ch); } mp[pre_ch] = 0; mp[ch] = 1; } else { mp[ch]++; } } pre_ch = ch; } if (pre_ch == 'e' || pre_ch == 'o') { if (mp[pre_ch] == 2) { st1.push_back(pre_ch); st1.push_back(pre_ch); } else st1.push_back(pre_ch); } else if (pre_ch == 'a' || pre_ch == 'i' || pre_ch == 'u' || pre_ch == 'y') { st1.push_back(pre_ch); } else { for (j = 0; j < mp[pre_ch]; j++) st1.push_back(pre_ch); } cout << st1 << "\n"; return 0; }
#include <bits/stdc++.h> int main() { int n, j; char s[100010], a[100010]; scanf("%d", &n); scanf("%s", s); for (int i = 0; i < n; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { printf("%c", s[i]); if (s[i] == 'e' || s[i] == 'o') { if ((i == n - 2 && s[i + 1] == s[i]) || (i < n - 2 && s[i + 1] == s[i] && s[i + 2] != s[i])) { printf("%c", s[i]); i++; } else { j = i; while (i < n && s[i] == s[j]) i++; i--; } } else { j = i; while (i < n && s[i] == s[j]) i++; i--; } } else { printf("%c", s[i]); } } }
#include <bits/stdc++.h> using namespace std; bool isvowel(char c) { if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') return true; return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i, j; string s; cin >> n; cin >> s; for (i = 0; i < n; i++) if (isvowel(s[i])) { for (j = i; j < n; j++) if (s[j] != s[i]) break; if (j - i == 2 && (s[i] == 'e' || s[i] == 'o')) cout << s[i] << s[i]; else cout << s[i]; i = j - 1; } else cout << s[i]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; string s, ans; cin >> s; ans.push_back(s[0]); j = 0; for (i = 1; i < n; i++) { char c = s[i]; if (c != 'a' && c != 'i' && c != 'u' && c != 'y') { ans.push_back(c); j++; } else { if (ans[j] != c) { ans.push_back(c); j++; } } } s = ""; string te, to; for (auto v : ans) { if (v == 'e') { int no = to.length(); if (no > 0) { if (no == 2) { s.push_back('o'); s.push_back('o'); } else { s.push_back('o'); } } to = ""; te.push_back(v); } else if (v == 'o') { int ne = te.length(); if (ne > 0) { if (ne == 2) { s.push_back('e'); s.push_back('e'); } else { s.push_back('e'); } } te = ""; to.push_back(v); } else { int no = to.length(), ne = te.length(); if (no > 0) { if (no == 2) { s.push_back('o'); s.push_back('o'); } else { s.push_back('o'); } } to = ""; if (ne > 0) { if (ne == 2) { s.push_back('e'); s.push_back('e'); } else { s.push_back('e'); } } te = ""; s.push_back(v); } } int no = to.length(), ne = te.length(); if (no > 0) { if (no == 2) { s.push_back('o'); s.push_back('o'); } else { s.push_back('o'); } } if (ne > 0) { if (ne == 2) { s.push_back('e'); s.push_back('e'); } else { s.push_back('e'); } } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int len = 1e5 + 5; const long long mod = 1e9 + 7; const unsigned long long seed = 131; int main() { int n; cin >> n; string str; cin >> str; string ans; for (int i = 0; i < str.size(); ++i) { if (str[i] == 'a' || str[i] == 'i' || str[i] == 'u' || str[i] == 'y') { int t = i; while (str[t] == str[i]) t++; i = t - 1; ans.push_back(str[i]); } else if (str[i] == 'e' || str[i] == 'o') { int t = i; while (str[t] == str[i]) t++; if (t - i == 2) ans.push_back(str[i]); i = t - 1; ans.push_back(str[i]); } else ans.push_back(str[i]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; set<char> st = {'a', 'i', 'y', 'u'}; vector<char> v; int n; int main() { cin >> n; string s, t; cin >> s; for (int i = 0; i < n; i++) { if (st.count(s[i])) { v.push_back(s[i]); while (i < n - 1 && s[i + 1] == s[i]) i++; } else if (s[i] == 'o') { if (i < n - 1 && s[i + 1] == 'o') { if (i < n - 2 && s[i + 2] == 'o') { v.push_back(s[i]); while (i < n - 1 && s[i + 1] == s[i]) i++; } else { v.push_back(s[i]); v.push_back(s[i]); while (i < n - 1 && s[i + 1] == s[i]) i++; } } else { v.push_back(s[i]); } } else if (s[i] == 'e') { if (i < n - 1 && s[i + 1] == 'e') { if (i < n - 2 && s[i + 2] == 'e') { v.push_back(s[i]); while (i < n - 1 && s[i + 1] == s[i]) i++; } else { v.push_back(s[i]); v.push_back(s[i]); while (i < n - 1 && s[i + 1] == s[i]) i++; } } else { v.push_back(s[i]); } } else v.push_back(s[i]); } for (auto x : v) cout << x; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; int main() { int n; string s; cin >> n >> s; string ans = ""; int len = 1, flag = 0; if (s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u' || s[0] == 'y') flag = 1; else ans += s[0]; if (s[0] != s[1] && flag) ans += s[0]; for (int i = 1; i < n; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') flag = 1; else flag = 0; if (flag) { if (s[i] == s[i - 1]) len++; if (s[i] != s[i + 1]) { ans += s[i]; if (len == 2 && (s[i - 1] == 'o' || s[i - 1] == 'e')) ans += s[i - 1]; len = 1; } } else { if (len > 1) { if (len == 2 && (s[i - 1] == 'o' || s[i - 1] == 'e')) { ans += s[i - 1]; ans += s[i - 1]; } else ans += s[i - 1]; } ans += s[i]; len = 1; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int n, chk[30]; string word, result; int main() { chk['a' - 'a'] = 1; chk['e' - 'a'] = 1; chk['i' - 'a'] = 1; chk['o' - 'a'] = 1; chk['u' - 'a'] = 1; chk['y' - 'a'] = 1; cin >> n >> word; for (int i = 0; i < n; i++) { int count = 0; if (chk[word[i] - 'a'] == 1) { for (int j = i; j < n; j++) { if (word[i] != word[j]) break; count++; } if (count == 2 && (word[i] == 'e' || word[i] == 'o')) result += word[i]; i += count - 1; } result += word[i]; } cout << result; }
#include <bits/stdc++.h> using namespace std; bool check(char& d, bool flag = 1) { if (flag == 0) { if (d == 'e' || d == 'o') return 1; else return 0; } if (d == 'a' || d == 'e' || d == 'i' || d == 'o' || d == 'u' || d == 'y') return 1; else return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int len; cin >> len; string s; cin >> s; int i = 0; bool karo = 0; while (i < len) { if (check(s[i])) { if (check(s[i], 0)) { int cnt = 0; int j = 0; for (j = i; j < len; j++) { if (s[j] != s[i]) { break; } cnt++; } cout << s[i]; if (cnt == 2) cout << s[i]; i = j; } else { cout << s[i]; i++; while (i < len && s[i] == s[i - 1]) { i++; } } } else { cout << s[i]; i++; } } }
#include <bits/stdc++.h> const int N = 1e6 + 5; int p[1000000], w[1000000]; int find(int x) { if (p[x] == x) return x; else { p[x] = find(p[x]); return p[x]; } } void join(int a, int b) { if ((a = find(a)) == (b = find(b))) return; if (w[a] < w[b]) { int temp = a; a = b; b = temp; } w[a] += w[b]; p[b] = a; } int vowel(char c) { if (c == 'o' || c == 'e') return 2; if (c == 'a' || c == 'u' || c == 'y' || c == 'i') return 1; return 0; } char s[1000000]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { p[i] = i; w[i] = 1; } scanf("%s", s); for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) join(i, i - 1); } for (int i = 0; i < n; i++) { if (find(i) == i) { int k = vowel(s[i]); if (k) { if (k == 2 && w[i] == 2) { printf("%c%c", s[i], s[i]); } else printf("%c", s[i]); } else { for (int j = 0; j < w[i]; j++) { printf("%c", s[i]); } } } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, cnt; char last; string s; int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> s; s.push_back('#'); last = s[0]; for (char c : s) if (c != last) { if ((last == 'e' || last == 'o') && cnt == 2) cnt = 2; else if (last == 'a' || last == 'e' || last == 'i' || last == 'o' || last == 'u' || last == 'y') cnt = 1; while (cnt--) cout << last; last = c; cnt = 1; } else cnt++; return 0; }
#include <bits/stdc++.h> using namespace std; int i, n, t, a[1000001]; string s; int main() { cin >> n >> s; for (i = 0; i < n - 1; i++) { if ((s[i] == 'e' && s[i + 1] == 'e' && s[i - 1] != 'e' && s[i + 2] != 'e') || (s[i] == 'o' && s[i + 1] == 'o' && s[i - 1] != 'o' && s[i + 2] != 'o')) { t++; } else { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if (s[i + 1] == s[i]) { a[i + 1]++; } } } } for (i = 0; i < n; i++) { if (a[i] == 0) cout << s[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; queue<char> ans; for (int k = 0; k < s.size(); k++) { char i = s[k]; if (i == 'a' or i == 'e' or i == 'o' or i == 'u' or i == 'i' or i == 'y') { char j = i; int c = 1; for (int l = k + 1; l < s.size(); l++) if (s[l] == i) c++; else break; if (c == 2 and (i == 'e' or i == 'o')) ans.push(i), ans.push(i); else ans.push(i); k += c - 1; } else ans.push(i); } while (ans.size()) { cout << ans.front(); ans.pop(); } }
#include <bits/stdc++.h> using namespace std; int n, t; string a; char c; int main() { cin >> n; cin >> a; cout << a[0]; c = a[0]; t = 1; for (int i = 1; i < n; i++) { if ((a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' || a[i] == 'y') && a[i] == c) { t++; } else { if ((c == 'e' || c == 'o') && t == 2) { cout << c; } cout << a[i]; c = a[i]; t = 1; } } if ((a[n - 1] == 'e' || a[n - 1] == 'o') && t == 2) { cout << a[n - 1]; } }
#include <bits/stdc++.h> int vowel(char c) { return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); } const int N = 1e5 + 5; int main() { char s[N]; int n, i, j; scanf("%d%s", &n, s); for (i = 0; i < n; i++) { if (vowel(s[i])) { j = 1; while (j + i < n && s[j + i] == s[i]) j++; if (j == 2 && (s[i] == 'e' || s[i] == 'o')) { printf("%c%c", s[i], s[i]); } else printf("%c", s[i]); i += (j - 1); } else printf("%c", s[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> int main() { long n, i = 0, j; scanf("%ld%*c", &n); char s[n + 1]; scanf("%[^\n]", s); while (i < n) { j = i + 1; while (j < n && s[i] == s[j]) j++; if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { if ((s[i] == 'e' || s[i] == 'o') && j - i == 2) printf("%c%c", s[i], s[i]); else printf("%c", s[i]); } else for (int f = i; f < j; f++) printf("%c", s[f]); i = j; } }
#include <bits/stdc++.h> using namespace std; string vowel = "aeiouy"; int n; string s; string result = "012"; int isVowel(char a) { return vowel.find(a) != string::npos; } void solve() { int rep = 0; char crep = 0; for (auto e : s) { if (!isVowel(e)) { result.push_back(e); crep = 0; rep = 0; continue; } if (e == 'e' || e == 'o') { if (e != crep) { rep = 1; crep = e; result.push_back(e); } else { rep++; if (rep > 2) while (result.back() == crep) result.pop_back(); result.push_back(e); } } else { crep = 0; rep = 0; if (result.back() != e) { result.push_back(e); } } } result.erase(result.begin(), result.begin() + 3); cout << result; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; cin >> s; solve(); }
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; char ch; int counter = 0; char pchar; while (a--) { cin >> ch; if (counter == 2 && ch != pchar && pchar == 'e') cout << 'e'; if (counter == 2 && ch != pchar && pchar == 'o') cout << 'o'; if (pchar != ch) counter = 0; if (ch == 'a' || ch == 'i' || ch == 'u' || ch == 'y') { counter++; if (counter > 1 && pchar == ch && (ch != 'o' && ch != 'e')) continue; cout << ch; pchar = ch; } else if (ch == 'e' || ch == 'o') { if (counter == 0) cout << ch; counter++; pchar = ch; } else { cout << ch; counter = 0; pchar = ch; } } if (counter == 2 && ch == pchar && pchar == 'e') cout << 'e'; if (counter == 2 && ch == pchar && pchar == 'o') cout << 'o'; return 0; }
#include <bits/stdc++.h> using namespace std; char s[100005]; vector<pair<char, int> > vec; bool isV(char ch) { if (ch == 'a') return true; if (ch == 'e') return true; if (ch == 'i') return true; if (ch == 'o') return true; if (ch == 'u') return true; if (ch == 'y') return true; return false; } int main() { int n; scanf("%d", &n); scanf("%s", s + 1); char last = '-'; for (int i = 1; i <= n; ++i) { if (s[i] != last) vec.push_back(make_pair(s[i], 1)); else vec.back().second++; last = s[i]; } string s = ""; for (int i = 0; i < (int)vec.size(); ++i) { char ch = vec[i].first; int count = vec[i].second; if (isV(ch)) { if (ch == 'e' || ch == 'o') count = count == 2 ? count : 1; else count = 1; } while (count--) s += ch; } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool isvowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { string s; cin >> s >> s; string ret = ""; string cur = ""; s.push_back('#'); for (int i = 0; i < s.size(); i++) { if (!isvowel(s[i]) || (i && s[i] != s[i - 1])) { if (cur.size()) { if ((cur[0] == 'e' || cur[0] == 'o') && cur.size() == 2) ret += cur, cur.clear(); else ret += cur[0], cur.clear(); } if (!isvowel(s[i])) ret.push_back(s[i]); else cur.push_back(s[i]); } else cur.push_back(s[i]); } ret.pop_back(); cout << ret << endl; }
#include <bits/stdc++.h> char a[100010]; int check(char a) { return a == 'i' || a == 'a' || a == 'u' || a == 'y'; } int ae(char a) { return a == 'e' || a == 'o'; } int main(void) { int n; scanf("%d", &n); scanf("%s", a); int len = strlen(a); int i = 0; for (int i = 0; i < n; i++) { if (check(a[i])) { int j = i + 1; while (j < len && check(a[j]) && a[j] == a[j - 1]) j++; printf("%c", a[j - 1]); fflush(stdout); i = j - 1; } else if (ae(a[i])) { int j = i + 1; while (j < len && ae(a[j]) && a[j] == a[j - 1]) j++; if (j - i == 2) { printf("%c%c", a[i], a[i]); fflush(stdout); } else { printf("%c", a[i]); fflush(stdout); } i = j - 1; } else { printf("%c", a[i]); } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); char s[n]; scanf("%s", s); char cur = s[0]; int cnt = 1; for (int i = 1; i < sizeof(s); i++) { if ((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') && s[i] == cur) { cnt++; } else { if ((cur == 'o' || cur == 'e') && cnt == 2) { printf("%c%c", cur, cur); } else { printf("%c", cur); } cur = s[i]; cnt = 1; } } if ((cur == 'o' || cur == 'e') && cnt == 2) { printf("%c%c", cur, cur); } else { printf("%c", cur); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; for (int i = 0; i < n; ++i) { char cur = s[i]; if (i + 2 < n && s[i] == 'e' && s[i + 1] == 'e' && s[i + 2] != 'e') { cout << s[i] << "e"; ++i; } else if (i + 2 < n && s[i] == 'o' && s[i + 1] == 'o' && s[i + 2] != 'o') { cout << s[i] << "o"; ++i; } else if (i + 2 == n && s[i] == 'e' && s[i + 1] == 'e') { cout << s[i] << "e"; ++i; } else if (i + 2 == n && s[i] == 'o' && s[i + 1] == 'o') { cout << s[i] << "o"; ++i; } else if (s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && s[i] != 'y') cout << s[i]; else { cout << s[i]; while (s[i + 1] == s[i]) ++i; } } return 0; }
#include <bits/stdc++.h> int n, cnt; char ch[100005], tmp; int main() { scanf("%d", &n); scanf("%s", ch + 1); for (int i = 1; i <= n; i++) if (ch[i] != tmp) { if (tmp != 0) { if ((tmp == 'o' || tmp == 'e') && cnt == 2) printf("%c%c", tmp, tmp); else { if (tmp == 'a' || tmp == 'e' || tmp == 'i' || tmp == 'o' || tmp == 'u' || tmp == 'y') printf("%c", tmp); else for (int j = 1; j <= cnt; j++) putchar(tmp); } } tmp = ch[i]; cnt = 1; } else cnt++; if ((tmp == 'o' || tmp == 'e') && cnt == 2) printf("%c%c", tmp, tmp); else { if (tmp == 'a' || tmp == 'e' || tmp == 'i' || tmp == 'o' || tmp == 'u' || tmp == 'y') printf("%c", tmp); else for (int j = 1; j <= cnt; j++) putchar(tmp); } return 0; }
#include <bits/stdc++.h> using namespace std; int n, k, a[1000008], t; string s; int main() { cin >> n; cin >> s; for (k = 0; k < n - 1; k++) if ((s[k] == 'e' && s[k + 1] == 'e' && s[k - 1] != 'e' && s[k + 2] != 'e') || (s[k] == 'o' && s[k + 1] == 'o' && s[k - 1] != 'o' && s[k + 2] != 'o')) t++; else if (s[k] == 'a' || s[k] == 'e' || s[k] == 'i' || s[k] == 'o' || s[k] == 'u' || s[k] == 'y') { if (s[k + 1] == s[k]) a[k + 1]++; } for (k = 0; k < n; k++) if (a[k] == 0) cout << s[k]; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, l, m, n, cnt = 0; cin >> n; string s, t; char ch; cin >> s; i = 0; while (i < n) { cnt = 0; if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') { ch = s[i]; while (s[i] == ch) { cnt++; i++; } if (cnt > 2) t += ch; else if (cnt == 2 && (ch == 'e' || ch == 'o')) t += ch, t += ch; else t += ch; } else { t += s[i]; i++; } } cout << t << endl; }
#include <bits/stdc++.h> const char gl[] = {'a', 'o', 'e', 'u', 'y', 'i'}; char c[100001]; int main() { int t, n = 10, it = 0; char str[100001]; int f; scanf("%d", &t); scanf("%s%n", str, &n); for (int i = 0; i < t; i++) { f = 0; for (int j = 0; j < 6; j++) if (str[i] == gl[j]) f = 1; if (f == 0) { if (i < n) c[it++] = str[i]; continue; } if (str[i] == 'o' || str[i] == 'e') { int j = i; while (j < n - 1 && str[j + 1] == str[i]) j++; if (j == i + 1) { c[it++] = str[i]; c[it++] = str[i]; i = j; continue; } else { c[it++] = str[i]; i = j; continue; } } else { int j = i; while (j < t - 1 && str[j + 1] == str[i]) j++; c[it++] = str[i]; i = j; } } for (int i = 0; i < it; i++) printf("%c", c[i]); }
#include <bits/stdc++.h> using namespace std; int a, b, d; char c; string s; int main() { cin >> a; cin >> s; for (int i = 0; i <= a - 1; i++) { if (s[i] == c) continue; else c = '5'; if (s[i] == 'a') { c = 'a'; cout << c; } else if (s[i] == 'e') { if (s[i + 1] == 'e' && s[i + 2] != 'e') { cout << "ee"; i++; continue; } else { c = 'e'; cout << c; continue; } } else if (s[i] == 'i') { c = 'i'; cout << c; } else if (s[i] == 'o') { if (s[i + 1] == 'o' && s[i + 2] != 'o') { cout << "oo"; i++; continue; } else { c = 'o'; cout << c; continue; } } else if (s[i] == 'u') { c = 'u'; cout << c; } else if (s[i] == 'y') { c = 'y'; cout << c; } else cout << s[i]; } }
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const long long INF = 1e18; const int MX = 1000001; int N, cseg = 0; string s_i; vector<pair<char, int>> segs; int main() { cin.sync_with_stdio(0); cin.tie(0); cin >> N >> s_i; segs.push_back(make_pair(s_i[0], 1)); for (int i = (1); i < (N); ++i) { if (s_i[i] == segs[cseg].first) segs[cseg].second++; else { cseg++; segs.push_back(make_pair(s_i[i], 1)); } } for (int i = (0); i < ((int)segs.size()); ++i) { if (segs[i].first != 'a' && segs[i].first != 'e' && segs[i].first != 'i' && segs[i].first != 'o' && segs[i].first != 'u' && segs[i].first != 'y') { for (int j = (0); j < (segs[i].second); ++j) cout << segs[i].first; } else { if (segs[i].first == 'e' && segs[i].second == 2) { cout << "ee"; } else if (segs[i].first == 'o' && segs[i].second == 2) { cout << "oo"; } else { cout << segs[i].first; } } } return 0; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) const long double EPS = 0.9; const long long INF = 1000000007; using namespace std; int main() { int n; string s; cin >> n; cin >> s; vector<bool> w(n, false); set<char> v; v.insert('i'); v.insert('e'); v.insert('y'); v.insert('u'); v.insert('o'); v.insert('a'); vector<pair<char, int> > a; char lastch = s[0]; int start = 0; for (int i = 1; i < n; i++) { if (s[i] != lastch) { a.push_back(make_pair(lastch, i - start)); start = i; } lastch = s[i]; } a.push_back(make_pair(lastch, n - start)); for (int i = 0; i < a.size(); i++) { if (v.count(a[i].first) == 0) for (int j = 0; j < a[i].second; j++) cout << a[i].first; else { if (a[i].first == 'e' || a[i].first == 'o') { if (a[i].second == 2) for (int j = 0; j < a[i].second; j++) cout << a[i].first; else cout << a[i].first; } else cout << a[i].first; } } }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; clock_t t1, t2; long long binPow(long long a, long long b) { long long x = 1, y = a; while (b) { if (b & 1) x = (x * y) % mod; y = (y * y) % mod; b >>= 1; } return x % mod; } long long inverserEuler(int n) { return binPow(n, mod - 2); } long long C(int k, int n) { vector<long long> f(n + 1, 1); for (int i = 2; i <= n; i++) f[i] = (f[i - 1] * i) % mod; return (f[n] * ((inverserEuler(f[k]) * inverserEuler(f[n - k])) % mod) % mod) % mod; } bool isvowel(char c) { string f = "ueoaiy"; return f.find(c) != string::npos; } void trunghieu() { int n; cin >> n; string s; cin >> s; string ans = ""; int i = 0; while (i < n) { int cnt = 0; ans += s[i]; if (isvowel(s[i])) { while (i + 1 < n && s[i] == s[i + 1]) cnt++, i++; cnt++; if ((ans.back() == 'e' || ans.back() == 'o') && cnt == 2) ans += ans.back(); } i++; } cout << ans; } int main() { cerr << "Program is running" << endl; t1 = clock(); ios::sync_with_stdio(false); cin.tie(); trunghieu(); t2 = clock(); float diff((float)t2 - (float)t1); float seconds = diff / CLOCKS_PER_SEC; cerr << "\nRunning in " << seconds << " seconds" << endl; return 0; }
#include <bits/stdc++.h> const int N = 100010; char a[N], b[N]; int n; int main() { scanf("%d%s", &n, a); int len = strlen(a); for (int i = 0, j = 0; i < len;) { if ((a[i] == 'a' || a[i] == 'i' || a[i] == 'u' || a[i] == 'y') && a[i] == a[i + 1]) { ++i; continue; } if (a[i] == 'e' || a[i] == 'o') { int cnt = 0; while (a[i] == a[i + 1]) { ++cnt, ++i; } if (cnt > 1) { cnt = 0; } for (int k = 0; k <= cnt; ++k) { b[j++] = a[i]; } ++i; continue; } b[j++] = a[i++]; } return printf("%s\n", b), 0; }
#include <bits/stdc++.h> using namespace std; void In_Out() {} int main() { int t = 1; while (t--) { int n; string s; cin >> n >> s; int count = 0; char ch; set<char> v; v.insert('a'); v.insert('e'); v.insert('i'); v.insert('o'); v.insert('u'); v.insert('y'); for (int i = 0; i < n; i++) { if (i == 0) { ch = s[i]; count = 1; } else { if (s[i] == s[i - 1]) { count++; } else { if (v.find(ch) != v.end()) { if (count > 2) { cout << ch; } else { if (ch == 'e' || ch == 'o') while (count--) cout << ch; else cout << ch; } } else { while (count--) cout << ch; } ch = s[i]; count = 1; } } } if (v.find(ch) != v.end()) { if (count > 2) { cout << ch; } else { if (ch == 'e' || ch == 'o') while (count--) cout << ch; else cout << ch; } } else { while (count--) cout << ch; } } }
#include <bits/stdc++.h> char a[100005]; int m, l, i, j; int main() { scanf("%d", &m); scanf("%s", a); l = strlen(a); for (i = 0; i < l; i++) { if (a[i] == 'a' && a[i + 1] == 'a') { a[i + 1] = 0; for (j = i + 2; j < l; j++) { if (a[j] == 'a') a[j] = 0; else break; } } if (a[i] == 'e' && a[i + 1] == 'e' && a[i + 2] == 'e') { a[i + 1] = a[i + 2] = 0; for (j = i + 3; j < l; j++) { if (a[j] == 'e') a[j] = 0; else break; } } if (a[i] == 'i' && a[i + 1] == 'i') { a[i + 1] = 0; for (j = i + 2; j < l; j++) { if (a[j] == 'i') a[j] = 0; else break; } } if (a[i] == 'o' && a[i + 1] == 'o' && a[i + 2] == 'o') { a[i + 1] = a[i + 2] = 0; for (j = i + 3; j < l; j++) { if (a[j] == 'o') a[j] = 0; else break; } } if (a[i] == 'u' && a[i + 1] == 'u') { a[i + 1] = 0; for (j = i + 2; j < l; j++) { if (a[j] == 'u') a[j] = 0; else break; } } if (a[i] == 'y' && a[i + 1] == 'y') { a[i + 1] = 0; for (j = i + 2; j < l; j++) { if (a[j] == 'y') a[j] = 0; else break; } } } for (i = 0; i < l; i++) { if (a[i] != 0) printf("%c", a[i]); } }
#include <bits/stdc++.h> using namespace std; int a[100005], i, n; string s; int main() { cin >> n >> s; s = s + '/'; s = '/' + s; for (i = 1; i <= s.size() - 3; i++) { if (s[i] == s[i + 1] && s[i] != s[i - 1] && s[i] != s[i + 2] && (s[i] == 'o' || s[i] == 'e')) continue; if ((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') && s[i] == s[i + 1]) a[i + 1] = 1; } for (i = 1; i <= s.size() - 2; i++) { if (a[i] == 0) cout << s[i]; } }
#include <bits/stdc++.h> const int MIN = 1e3 + 2; const int MXN = 1e6 + 3; const int INF = 1e9 + 7; const double EPS = 1e-9; const long long LINF = 1e18 + 15; int n; int a[100001]; int b[100001]; char st[100001]; int main() { scanf("%d", &n); scanf("%s", st); for (int i = n - 1; i >= 0; --i) { if (st[i] == st[i + 1]) a[i] = a[i + 1] + 1, b[i] = b[i + 1]; else a[i] = 1, b[i] = i; } for (int i = 0; i < n; i++) { if (st[i] != 'a' && st[i] != 'e' && st[i] != 'i' && st[i] != 'o' && st[i] != 'u' && st[i] != 'y') { printf("%c", st[i]); continue; } if ((st[i] == 'e' || st[i] == 'o') && a[i] == 2) { printf("%c", st[i]); printf("%c", st[i]); } else { printf("%c", st[i]); } i = b[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); string s; int i, n, j; cin >> n >> s; for (i = 0; i < n; i++) { if (s[i] == 'a') { while (s[i] == 'a') if (s[i + 1] == 'a') i++; else break; cout << s[i]; } else if (s[i] == 'i') { while (s[i] == 'i') if (s[i + 1] == 'i') i++; else break; cout << s[i]; } else if (s[i] == 'u') { while (s[i] == 'u') if (s[i + 1] == 'u') i++; else break; cout << s[i]; } else if (s[i] == 'y') { while (s[i] == 'y') if (s[i + 1] == 'y') i++; else break; cout << s[i]; } else if (s[i] == 'e') { if (s[i + 1] == 'e' and s[i + 2] != 'e') cout << "ee", i++; else { while (s[i] == 'e') if (s[i + 1] == 'e') i++; else break; cout << s[i]; } } else if (s[i] == 'o') { if (s[i + 1] == 'o' and s[i + 2] != 'o') cout << "oo", i++; else { while (s[i] == 'o') if (s[i + 1] == 'o') i++; else break; cout << s[i]; } } else cout << s[i]; } return 0; }