
#include <iostream>
using namespace std;

//insignificant showoff of namespaces
namespace ns
{
int asd;
}

//easily usable vector
struct vector {
	float x, y, z;

	//returning vector& assures that multi-assignment like a=b=c=d=vector(0,0,0) works
	vector& operator= (const vector &a) {
		x = a.x;
		y = a.y;
		z = a.z;
		return *this;
	}
	//note that = is right-associative, i.e. a=b=c is a=(b=c)

	//this enables:
	//vector a(1,2,3)
	//b = vector(1,2,3)
	vector (float a, float b, float c) {
		x = a;
		y = b;
		z = c;
	}

	//2x const for the left&right side of + that stay the same
	vector operator+ (const vector& a) const {
		return vector (x + a.x, y + a.y, z + a.z);
	}

	//unary minus, binary would be: vector operator-(const vector&) {...}
	vector operator-() const {
		return vector (-x, -y, -z);
	}

	//multiply by scalar, e.g. v*5
	vector operator* (float f) {
		return vector (x * f, y * f, z * f);
	}
};

//multiply by scalar from the other side (5*v)
vector operator* (float f, vector &v)
{
	return v * f;
}

//C++ i/o works by operator overloading
ostream& operator<< (ostream&o, const vector&v)
{
	o << '[' <<
	  v.x << ',' <<
	  v.y << ',' <<
	  v.z << ']';
	return o;
	//we must return the reference because of successive outputs:
	//cout << a << b << c
	//gets evaluated as
	// ((cout << a) << b) << c
}

//same thing for input (notice the vector parameter isn't const)
istream& operator>> (istream&i, vector&v)
{
	i >> v.x >> v.y >> v.z;
	return i;
}

int main()
{
	vector x (1, 2, 3), y (5, 6, 7);

	//now we can handle the vectors just like integers
	cin >> x;
	cout << ( (x + vector (1, 2, 3)) * 5 + - (vector (1, 2, 3) + 3 * vector (3, 1, 3))) << endl;
	return 0;
}
