// Bai 1: Vi tri xau #include using namespace std; int main() { string s; int n; cin >> s >> n; vector requests(n); cin.ignore(); for (int i = 0; i < n; i++) getline(cin, requests[i]); for (const string &req : requests) { if (req[0] == '1') { string t = req.substr(2, req.size() - 4); int pos = req[req.size() - 1] - '0'; s.insert(pos, t); } else if (req[0] == '2') { int pos = req[2] - '0'; int len = req[4] - '0'; s.erase(pos, len); } cout << s << endl; } return 0; } // Bai 2: Chuan hoa xau #include using namespace std; string chuanHoa(string s) { stringstream ss(s); string word, result; while (ss >> word) { word[0] = toupper(word[0]); for (int i = 1; i < word.size(); i++) { word[i] = tolower(word[i]); } result += word + " "; } if (!result.empty()) result.pop_back(); return result; } int main() { string s; getline(cin, s); cout << chuanHoa(s) << endl; return 0; } // Bai 3: Tinh tong cac so ghi trong xau #include using namespace std; int main() { string s; getline(cin, s); int sum = 0, num = 0; for (char c : s) { if (isdigit(c)) { num = num * 10 + (c - '0'); } else { sum += num; num = 0; } } sum += num; cout << sum << endl; return 0; } // Bai 4: Tim vi tri xuat hien trong xau #include using namespace std; int main() { string x, v; cin >> x >> v; size_t pos = x.find(v); cout << (pos == string::npos ? -1 : pos) << endl; return 0; } // Bai 5: Xau con khong lien tiep #include using namespace std; bool isSubsequence(const string &x, const string &y) { size_t j = 0; for (char c : y) { if (c == x[j]) j++; if (j == x.size()) return true; } return false; } int main() { string x, y; cin >> x >> y; cout << (isSubsequence(x, y) ? "YES" : "NO") << endl; return 0; } // Bai 6: So lon nhat #include using namespace std; int main() { string a; cin >> a; size_t zeroPos = a.find('0'); if (zeroPos != string::npos) a.erase(zeroPos, 1); else a.erase(0, 1); cout << a << endl; return 0; } // Bai 7: Bong da #include using namespace std; int main() { string s; cin >> s; cout << (s.find("0000000") != string::npos || s.find("1111111") != string::npos ? "YES" : "NO") << endl; return 0; } // Bai 8: Petya va Chuoi #include using namespace std; int main() { string a, b; cin >> a >> b; for (char &c : a) c = tolower(c); for (char &c : b) c = tolower(c); cout << (a < b ? -1 : (a > b ? 1 : 0)) << endl; return 0; } // Bai 9: String Task #include using namespace std; int main() { string s; cin >> s; string vowels = "aoyeuiAOYEUI", result; for (char c : s) { if (vowels.find(c) == string::npos) { result += '.'; result += tolower(c); } } cout << result << endl; return 0; } // Bai 10: NKLETTER #include using namespace std; int main() { string sb, se; cin >> sb >> se; size_t overlap = 0; for (size_t i = 1; i <= sb.size(); i++) { if (se.substr(0, i) == sb.substr(sb.size() - i)) { overlap = i; } } cout << sb.size() + se.size() - overlap << endl; return 0; }