{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eIdentical small balls are located on a straight line and can move along this line only. Each ball moves with a constant velocity, but velocities of different balls may be different. When two balls meet, a perfectly elastic collision occurs. It’s a common-known physical fact, that when two equal-mass physical bodies \u003cstrong\u003eA\u003c/strong\u003e and \u003cstrong\u003eB\u003c/strong\u003e collide perfectly elastically, they swap their velocities, i. e. new \u003cstrong\u003eA\u003c/strong\u003e’s velocity is old \u003cstrong\u003eB\u003c/strong\u003e’s one, and new \u003cstrong\u003eB\u003c/strong\u003e’s is old \u003cstrong\u003eA\u003c/strong\u003e’s.\u003c/p\u003e\n\n\u003cp\u003eYour task is to write a program to find the total number of collisions.\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eThe first line at input contains the number of balls \u003cstrong\u003eN\u003c/strong\u003e (\u003cstrong\u003e3\u003c/strong\u003e ≤ \u003cstrong\u003eN\u003c/strong\u003e ≤ \u003cstrong\u003e200000\u003c/strong\u003e). Each of the following \u003cstrong\u003eN\u003c/strong\u003e lines contains \u003cstrong\u003e2\u003c/strong\u003e space-separated integers --- the starting coordinate and the velocity of corresponding ball. All start coordinates are in range --10\u003cstrong\u003e^11\u003c/strong\u003e \u003c \u003cstrong\u003ex\u003c/strong\u003e \u003c \u003cstrong\u003e10^11\u003c/strong\u003e, all velocities are in range \u003cstrong\u003e--10^8\u003c/strong\u003e \u003c \u003cstrong\u003ev\u003c/strong\u003e \u003c \u003cstrong\u003e10^8\u003c/strong\u003e. All start coordinates are different. It’s guaranteed that each collision involves exactly two balls (none involves three or more balls together).\u003c/p\u003e\n\n\u003cp\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003c/p\u003e\n\n\u003cp\u003eYour program should output exactly one integer number in a single line -- the total number of collisions (or \u003cstrong\u003e987654321987654321\u003c/strong\u003e if the number is infinite).\u003c/p\u003e\n\n"}},{"title":"Example","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n-5 3\n0 -1\n7 -2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}