#include <string>
#include <iostream>
#include <iomanip>
#include <chrono>


using namespace std;


int main(int argc, const char * argv[])
{

    string s;
    for(int i = 0; i < 100000; ++i) s += rand()%26+'A';

	{
    	auto start = chrono::high_resolution_clock::now();
    	string d;
    	d.reserve(s.length()*3/2);
    	for(size_t i = 0; i < s.length(); ++i)
    	{
        	d += s[i++];
        	if (i < s.length())
        	{
            	d += s[i];
            	d += '-';
        	}
    	}
    	auto stop = chrono::high_resolution_clock::now();
    	cout << chrono::duration_cast<chrono::nanoseconds>(stop-start).count() << endl;
	}

	{
    	auto start = chrono::high_resolution_clock::now();
    	
   	    string str;
    	str.resize(s.length() * 3/2);
    	size_t size = 0;

    	for (size_t i = 0; i < s.length(); ++i) {
        	str[size++] = s[i++];
        	if (i < s.length()) {
	            str[size++] = s[i];
            	if (i != s.length() - 1)
                	str[size++] = '-';
        	}
    	}
    	// ;-)
    	str.resize(size);
    	
    	auto stop = chrono::high_resolution_clock::now();
    	cout << chrono::duration_cast<chrono::nanoseconds>(stop-start).count() << endl;
	}

 
}
