// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

#include <time.h>

using namespace std;

const int N = 1000000000;

int main()
{
  time_t t1 = time(NULL);
  int sum = 0;
  for(int i = 0; i < N; i++) {
      sum = ((sum + 1) * 2 + 1) / 2;
  }
  time_t t2 = time(NULL);
  if(sum != N) {
      cout << "Error" << endl;
  } else {
      cout << N << " operations in " << (t2 - t1) << " seconds" << endl;
  }
}
