The answer is 1011+M1.
We can see that CM≥1011+M1 by picking a2i+1=1 and a2i=−1. This way, we get for all k=1,…,M−1,
{Mka1}+{Mka2}+⋯+{Mka2023}=1012⋅Mk+1011⋅MM−k=1011+Mk≥1011+M1.
To show that this is the best possible, let
Pi:=k=1∑M−1{Mkai},Qk=i=1∑2023{Mkai}.
We claim that for any integer a, we have ∑k=1M−1{Mka}≤2(M−1), and equality holds when gcd(a,M)=1. To see this, let d=gcd(a,M). Then clearly
k=1∑M−1{Mka}≤(d−1)⋅M0+d⋅Md+d⋅M2d+⋯+d⋅M(M/d−1)d≤M1[(1+⋯+(d−1))+(d+⋯+2d−1)+⋯+(M−d+⋯+M−1)]=2(M−1),
where the equality holds only when d=1.
Since a is arbitrary, by applying the claim for a=ai, we see Pi≤2M−1 for all i. Thus ∑k=1M−1Qk=∑i=12023Pi≤22023(M−1).
Now if there is some Qk≤1011, then we are already done. Thus we can assume ⌈Qk⌉≥1012 for all k, and so we have
{−Qk}=−Qk−⌊−Qk⌋=⌈Qk⌉−Qk≥1012−Qk.
As a consequence,
k=1∑M−1{−Qk}≥1012(M−1)−22023(M−1)=21(M−1).
Note that
{−Qk}={M−k(a1+⋯+a2023)}.
Apply the claim for a=a1+⋯+a2023, and we get that all equalities should hold. Thus gcd(a,M)=1 by the claim, and ⌈Qk⌉=1012 for all k. In particular, if we choose k to be the inverse of a modulo M, then Qk=1011+M1≤CM, as desired.