Implement a function that processes a set of queries and counts how many elements in a sorted list fall within a specified range after manipulations indicated by the queries.
Functionality
Create a new Python file called /app/solution.py and implement the following function:
python
def process_queries_and_count(N, Q, L, R, A, queries):
This function should perform the following:
Sort the list A containing N integers.
For each query in the queries, which contains the format (q, x, s, t), modify an initial variable z based on the query's parameters while ensuring that z remains within the bounds specified by L and R.
Use binary search to determine the maximum value of z that does not exceed R and the minimum value of z that is at least L after applying the queries.
Count how many values in the sorted list A are between the determined minimum and maximum z values.
Input Requirements
N (1 <= N <= 100,000): an integer representing the number of elements in list A.
Q (1 <= Q <= 10,000): an integer representing the number of queries.
L (-10^9 <= L <= 10^9): an integer indicating the lower bound for the count.
R (-10^9 <= R <= 10^9): an integer indicating the upper bound for the count.
A: a list of N integers where each value is in the range (-10^9 to 10^9).
queries: a list of Q queries, where each query is a tuple (q, x, s, t) with:
q (1 or 2): the type of query.
x (-10^9 <= x <= 10^9): a reference value for modifications.
s (-10^9 <= s <= 10^9): a modifier that adjusts z.
t (1 <= t <= 10^9): a factor used to scale z.
Output Requirements
The function should return a single integer: the count of elements in A that are within the calculated bounds.
Make sure your solution is efficient and handles edge cases effectively.