#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    vector<double> data;
    double x;

    ifstream infile("data_1.txt");
    while (infile >> x) { //>> takes things from an input and saves as x
        data.push_back(x); //saves each x in data
    }
    infile.close();
    
    int n = data.size();

    double minVal = *min_element(data.begin(), data.end());
    double maxVal = *max_element(data.begin(), data.end());

    double sum = 0.0, logSum = 0.0, recipSum = 0.0;
    for (int i = 0; i < n; ++i) { //for (initialization; condition; update)
        sum += data[i];
        logSum += log(data[i]);
        recipSum += 1.0 / data[i];
    }
    double arith = sum / n;
    double geom  = exp(logSum / n);
    double harm  = n / recipSum;

    // standard deviation
    double variance = 0.0;
    for (int i = 0; i < n; ++i) {
        variance += (data[i] - arith) * (data[i] - arith);
    }
    double stdev = sqrt(variance / n);

    ofstream outfile("out_1.txt");
    outfile << "Minimum: " << minVal << endl;
    outfile << "Maximum: " << maxVal << endl;
    outfile << "Arithmetic mean: " << arith << endl;
    outfile << "Geometric mean:  " << geom << endl;
    outfile << "Harmonic mean:   " << harm << endl;
    outfile << "Standard deviation: " << stdev << endl;
    outfile.close();

    return 0;
}
