#include inline double sq(double x) noexcept { return x * x; } template struct Vector { T data[2]; T comp(int x, int y) const { return x*data[0] + y*data[1]; } T norm() const { return std::sqrt(sq(data[0]) + sq(data[1])); } T& operator[](std::size_t i) { return data[i]; } T operator[](std::size_t i) const { return data[i]; } Vector operator*(T scalar) const { return Vector{ data[0] * scalar, data[1] * scalar }; } Vector& operator+=(const Vector& rhs) { data[0] += rhs[0]; data[1] += rhs[1]; return *this; } }; template Vector operator*(T scalar, const Vector& vec) { return Vector{ vec[0] * scalar, vec[1] * scalar }; }