Problem p02924 (C++)

Buggy submission (status: Runtime Error):
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n);
double absolute(double n);
void input(vector<int> &vec);
void print(vector<int> vec);
void print(vector<double> vec);
int sum(vector<int> vec);
ll sum(vector<ll> vec);
double sum(vector<double> vec);
void upsort(vector<int> &vec);
void downsort(vector<int> &vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (ll i = 0; i < n; ++i) {
    v.at(i) = i;
  }
  cout << sum(v) << endl;
  return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n) {
  if (n < 0) {
    return (-n);
  }
  return n;
}

double absolute(double n) {
  if (n < 0) {
    return (-n);
  }
  return n;
}

void input(vector<int> &vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cin >> vec.at(i);
  }
}

void print(vector<int> vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cout << vec.at(i) << " ";
  }
  cout << endl;
}

void print(vector<double> vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cout << vec.at(i) << " ";
  }
  cout << endl;
}

int sum(vector<int> vec) {
  int s = accumulate(vec.begin(), vec.end(), 0);
  return s;
}

ll sum(vector<ll> vec) {
  ll s = accumulate(vec.begin(), vec.end(), 0);
  return s;
}

double sum(vector<double> vec) {
  double s = accumulate(vec.begin(), vec.end(), 0.0);
  return s;
}

void upsort(vector<int> &vec) { sort(vec.begin(), vec.end()); }

void downsort(vector<int> &vec) {
  sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec) {
  int m = vec.at(0);
  for (size_t i = 0; i < vec.size(); ++i) {
    m = max(m, vec.at(i));
  }
  return m;
}

int minvec(vector<int> vec) {
  int m = vec.at(0);
  for (size_t i = 0; i < vec.size(); ++i) {
    m = min(m, vec.at(i));
  }
  return m;
}
///////////////////////////////////////////////////////////

Fixed submission:
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n);
double absolute(double n);
void input(vector<int> &vec);
void print(vector<int> vec);
void print(vector<double> vec);
int sum(vector<int> vec);
ll sum(vector<ll> vec);
double sum(vector<double> vec);
void upsort(vector<int> &vec);
void downsort(vector<int> &vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main() {
  ll n;
  cin >> n;
  ll sum = n * (n - 1) / 2;
  cout << sum << endl;
  return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n) {
  if (n < 0) {
    return (-n);
  }
  return n;
}

double absolute(double n) {
  if (n < 0) {
    return (-n);
  }
  return n;
}

void input(vector<int> &vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cin >> vec.at(i);
  }
}

void print(vector<int> vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cout << vec.at(i) << " ";
  }
  cout << endl;
}

void print(vector<double> vec) {
  for (size_t i = 0; i < vec.size(); ++i) {
    cout << vec.at(i) << " ";
  }
  cout << endl;
}

int sum(vector<int> vec) {
  int s = accumulate(vec.begin(), vec.end(), 0);
  return s;
}

ll sum(vector<ll> vec) {
  ll s = accumulate(vec.begin(), vec.end(), 0);
  return s;
}

double sum(vector<double> vec) {
  double s = accumulate(vec.begin(), vec.end(), 0.0);
  return s;
}

void upsort(vector<int> &vec) { sort(vec.begin(), vec.end()); }

void downsort(vector<int> &vec) {
  sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec) {
  int m = vec.at(0);
  for (size_t i = 0; i < vec.size(); ++i) {
    m = max(m, vec.at(i));
  }
  return m;
}

int minvec(vector<int> vec) {
  int m = vec.at(0);
  for (size_t i = 0; i < vec.size(); ++i) {
    m = min(m, vec.at(i));
  }
  return m;
}
///////////////////////////////////////////////////////////