#include <iostream>
#include <algorithm>
#include <vector>
#include <chrono>
using namespace std;
void merge(vector<int> a, int p, int q, int r) {
//defining well named variables
int range = r - p + 1;
int lowHalf = q - p + 1;
int highHalf = r - q;
int rStart = q + 1;
int rEnd = r;
int lStart = p;
int lEnd = q;
//filling temp array
std::vector<int> temp;
for (int i = 0; i < range; i++) {
temp.push_back(a[lStart + i]);
}
//mergin subarrays
int left = lStart;
int right = rStart;
int k = 0; //index
while( (left <= lEnd) && (right <= rEnd)) {
if(a[left] <= a[right]) {
temp[k] = a[left];
left++;
} else {
temp[k] = a[right];
right++;
}
k++;
}
//coping rest of subarrays
while (right <= rEnd) {temp[k++] = a[right++];}
while (left <= rEnd) {temp[k++] = a[left++];}
//coping temp array to origin
for (int i = 0; i < range; i++) {
a[lStart + i] = temp[i];
}
}
void mergeSortRec(vector<int> arr, int l, int r) {
int p;
if(l < r) {
p = (l+r)/2;
mergeSortRec(arr, l, p);
mergeSortRec(arr, p+1, r);
merge(arr, l,p, r);
}
}
void mergeSortIter(vector<int> arr, int l, int r) {
int n = r - l - 1;
int size;
int start;
for (size = 1; size <= n; size *= 2) {
for (start = 0; start < n; start += 2*size) {
//index of left end
int mid = start + size - 1;
//are we out of the bound?
int end = min(start + 2*size - 1, n);
merge(arr, start, mid, end);
}
}
}
void merge_sort_time(vector<int> v) {
auto start = chrono::high_resolution_clock::now();
mergeSortRec(v,0,v.size()-1);
auto end = chrono::high_resolution_clock::now();
chrono::duration<double> elapsed = end - start;
std::cout << elapsed.count() << endl;
}
auto main(int argc, char const *argv[]) -> int
{
ios_base::sync_with_stdio(false);
int x;
vector<int> v;
// getting inputs
while(cin >> x)
{
v.push_back(x);
cin.clear();
cin.sync();
std::cout << "One" << '\n';
}
// vector<int> sorted = selection_sort(v);
// printVector(sorted);
merge_sort_time(v);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}