You can process queries of type 3 offline. The trick is not to go forward and adding new element, but go backward and delete element. This can be done in $$$O(N log N^2)$$$, or in $$$O(N log N)$$$ using walk on segment tree.
Query of type 1,2,4 can be processed using segment tree with lazy propagation.
Query of type 2 can be broken down to this : $$$a_p += (p - l + 1)*x \lt = \gt a_p += (p + 1)*x - l*x$$$.
You can use a different segment tree to store the sum of $$$x$$$, then $$$-l*x$$$ can be trivially stored.
But there's still query of type 3 that may potentially affect the sum $$$l..r$$$. So our segment tree shouldn't store the sum of elements from $$$l...r$$$ $$$(a_l + a_{l + 1} + ... + a_r)$$$ , but the sum of the whole range $$$l$$$..$$$r$$$, regardless of whether this whole range has been fully filled with element or not. You will need an additional $$$cnt$$$ array to store the number of added elements, to calculate $$$(p + 1)*x - l*x$$$
For query of type 1, you need an "override" lazy propagation array.
The overall time complexity will be $$$O(N log N)$$$ or $$$O(N log ^2 N)$$$, both can comfortably fit in 1s runtime.
Space complexity $$$O(N log N)$$$