Recall (with proof) two well-known facts:
Lemma 1. The series ∑i=1+∞i1 is divergent. In other words for each c∈R there exists m such that ∑i=1mi1≥c.
Proof. Note that ∑i=22a+1i1≥∑i=22a+12a+11=21. Grouping the terms this way we obtain that ∑i=12ti1≥1+2t which can be sufficiently large.
Lemma 2. Order all prime numbers in ascending order: p1<p2<…. Then the product ∏i=1+∞1−pi11 is divergent. In other words for each c∈R there exists m such that ∏i=1m1−pi11≥c.
Proof. By Lemma 1 for each c∈R there exists m0 such that ∑j=1m0j1≥c. Let all prime divisors of numbers between 1 and m0 be among p1,p2,…,pm and the maximal exponent of these primes equal ℓ. Then each integer j from 1 to m0 has the unique representation p1α1p2α2…pmαm, 0≤αi≤ℓ, i=1,…,m. Hence,
i=1∏m1−pi11≥i=1∏m(1+pi1+pi21+⋯+piℓ1)≥j=1∑m0j1≥c.
Solution of the problem. Choose an arbitrary q∈(c,1). Lemma 2 implies that there exists L such that ∏i=1Lpipi−1<1−q. Denote T=Ap1p2…pL where A is an arbitrary even number.
Consider the set UT of all integers between 1 and T which are divisible by at least one number from p1,p2,…,pL. The cardinality of UT is
i∑piT−i=j∑pipjT+⋯=T−T(1−p11)…(1−pL1)≥T−T(1−q)≥qT.
We will show that UT is good. Denote the sum of all elements of UT by S. The condition gcd(ai,S−ai)>1 is equivalent to gcd(ai,S)>1. Hence it suffices to show that S is divisible by p1p2…pL.
Note that if x∈UT then T−x∈UT and their sum is divisible by p1p2…pL. The numbers T/2 and T are divisible by p1p2…pL (since A is even) so S is divisible by p1p2…pL as well.
Suppose we are given K≥2p1p2…pL. By taking an appropriate A choose T to be the maximal integer such that T≤K and 2p1p2…pL∣T. All elements of the good set UT doesn't exceed T and, moreover, K. The cardinality of UT is not less than qT>q(K−2p1p2…pL)=qK−D where D=2qp1p2…pL doesn't depend on K. Therefore for K≥D/(q−c) we obtain the inequality qT≥cK which implies that UT is the required good set.
Consequently M=⌊D/(q−c)⌋ satisfies the problem condition.