Did the Jansenists deny the gratuity of grace? Did the Jansenists deny the gratuity of grace? That is, did they think praying more or doing more works of supererogation could always coerce God into granting them more grace, not that God grants or withholds grace as he pleases?

Ephesians 2:8-10 For by grace you are saved through faith, and that not of yourselves, for it is the gift of God; not of works, that no man may glory. For we are his workmanship, created in Christ Jesus in good works, which God hath prepared that we should walk in them.
No, Jansenists did not deny the gratuity of grace
According to one of the foremost authorities on Jansenism, Dr. Shaun Blanchard, the Jansenists were fighting for the gratuity of grace!

The Augustinians who came to be known as Jansenists thought that this new system [of Molinism] was basically semi-Pelagian. It made humans the authors of their own salvation and sacrificed the total gratuity of grace.
-Are Jansenists Among Us?

Blanchard's extensive writings on the topic include some of the following:

The Synod of Pistoia and Vatican II: Jansenism and the Struggle for Catholic Reform
The Neglect of Catholic Theology From Westphalia (1648) to the Bastille (1789)
Jansenism: A Rough Sketch of a Complex Phenomenon
“Third Party” Catholic Reformers of the Eighteenth-Century: Between Jansenists and the Zelanti
A Quasi-Defense of Gallicanism
Are Jansenists Among Us?
The Long History of Catholic Dissent
The Twists and Turns That Led to the First Vatican Council


Gratuity of Grace
Grace is not gratuitous precisely when it is earned or merited.  One of the basic problems with Jansenism, as seen in the third condemned proposition of Cum Occasione, is that Jansenism makes it impossible for humans to merit.  Therefore for Jansenists nothing can be earned or merited, including grace.  And if grace cannot be merited, then it must be gratuitous.
The doctrine of irresistible grace is very much in keeping with the doctrine of the gratuity of grace, and those who hold to this doctrine often do so in order to safeguard the gratuity of grace.  This was the case with the Jansenists.  If one cannot resist something, then that thing is clearly not under their control.  If one cannot resist grace, then grace is under God's control, not man's.  This is very much in line with Ephesians 2 as quoted by the OP, &quot;...it is the gift of God; not of works, that no man may glory...&quot;
The denial of the gratuity of grace is characteristic of the Molinist Jesuits, who were the opponents of the Jansenists.  The Molinists were accused of denying the gratuity of grace not only by Calvinists and Jansenists, but also by Thomists such as Domingo Báñez.  The Jansenists were accused of denying the freedom of man (which was thought to be a denial of the ability to keep commandments, the ability to merit, the ability to resist grace, and the ability to cooperate with grace, which respectively align with the first four condemned propositions).  This is the same thing that Calvinists and Thomists are often accused of.