// competitive-verifier: PROBLEM https://www.hackerrank.com/contests/magic-lines-july-2015/challenges/run-length-encoding
#include "String/run_length_encode.hpp"
#include <bits/stdc++.h>
using namespace std;
int main()
{
string S;
cin >> S;
auto rle = run_length_encode(S);
string ans;
for (auto [c, n] : rle)
{
ans += c + to_string(n);
}
cout << ans;
return 0;
}
#line 1 "test/String/run_length_encode/hackerrank-run-length-encoding.cpp"
// competitive-verifier: PROBLEM https://www.hackerrank.com/contests/magic-lines-july-2015/challenges/run-length-encoding
#line 1 "String/run_length_encode.hpp"
#include <bits/stdc++.h>
using namespace std;
template <typename Container>
vector<pair<typename Container::value_type, int>> run_length_encode(const Container &v)
{
using T = typename Container::value_type;
vector<pair<T, int>> result;
for (const auto &n : v)
{
if (result.empty() || result.back().first != n)
{
result.push_back({n, 0});
}
result.back().second++;
}
return result;
}
#line 5 "test/String/run_length_encode/hackerrank-run-length-encoding.cpp"
using namespace std;
int main()
{
string S;
cin >> S;
auto rle = run_length_encode(S);
string ans;
for (auto [c, n] : rle)
{
ans += c + to_string(n);
}
cout << ans;
return 0;
}