#include <iostream>
#include <vector>

int main()
{
    const int LOOPS = 100;
    
    std::vector<int> myVector;
    int reallocations = 0;
    
    for(int i = 0; i < LOOPS; ++i)
    {
        size_t oldCapacity = myVector.capacity();
        
        myVector.push_back(i);
        
        size_t newCapacity = myVector.capacity();
        
        if(oldCapacity != newCapacity)
        {
            ++reallocations;
            float percentageGrowth = (float(newCapacity - oldCapacity) / float(oldCapacity)) * 100.0f;
            
            std::cout << "Reallocation occured on pushing element " << (i+1) << ".\n"
                      << "Old capacity: " << oldCapacity << "\n"
                      << "New capacity: " << newCapacity << " (" << percentageGrowth << "% growth)\n" << std::endl;
        }
    }
    
    std::cout << "\n--------------------------------------------------\n"
              << "Total reallocations over " << LOOPS << " elements: " << reallocations << std::endl;
    
    return 0;
}