#include <iostream>
#include <chrono>
using namespace std;
const unsigned long long N = 1000000000ULL;
unsigned long long s(unsigned long long n)
{
unsigned long long s = 0;
for (unsigned long long i = 0; i < n; i++)
s += i;
return s;
}
int main()
{
auto t1 = std::chrono::high_resolution_clock::now();
auto x = s(N);
auto t2 = std::chrono::high_resolution_clock::now();
auto t = std::chrono::duration_cast<std::chrono::nanoseconds>(t2 - t1).count();
cout << "Result: " << x << " -- time (ms):" << t/0.1e7 << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y2hyb25vPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IHVuc2lnbmVkIGxvbmcgbG9uZyBOID0gMTAwMDAwMDAwMFVMTDsKCnVuc2lnbmVkIGxvbmcgbG9uZyBzKHVuc2lnbmVkIGxvbmcgbG9uZyBuKQp7CiAgICB1bnNpZ25lZCBsb25nIGxvbmcgcyA9IDA7CgogICAgZm9yICh1bnNpZ25lZCBsb25nIGxvbmcgaSA9IDA7IGkgPCBuOyBpKyspCiAgICAgICAgcyArPSBpOwoKICAgIHJldHVybiBzOwp9CgppbnQgbWFpbigpCnsKICAgIGF1dG8gdDEgPSBzdGQ6OmNocm9ubzo6aGlnaF9yZXNvbHV0aW9uX2Nsb2NrOjpub3coKTsKICAgIAogICAgYXV0byB4ID0gcyhOKTsKCiAgICBhdXRvIHQyID0gc3RkOjpjaHJvbm86OmhpZ2hfcmVzb2x1dGlvbl9jbG9jazo6bm93KCk7CiAgICBhdXRvIHQgPSBzdGQ6OmNocm9ubzo6ZHVyYXRpb25fY2FzdDxzdGQ6OmNocm9ubzo6bmFub3NlY29uZHM+KHQyIC0gdDEpLmNvdW50KCk7CgogICAgY291dCA8PCAiUmVzdWx0OiAiIDw8IHggPDwgIiAtLSB0aW1lIChtcyk6IiA8PCB0LzAuMWU3IDw8IGVuZGw7Cn0=