All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
If doing so is something that is customarily accepted and the government knows about it and does not prevent it but, rather, sanctions it, then there is nothing wrong with eating from this food because customary approval (permission) is as valid as textual approval.
Allaah says (what means): {There is not upon the blind [any] constraint nor upon the lame constraint nor upon the ill constraint nor upon yourselves when you eat from your [own] houses or the houses of your fathers or the houses of your mothers or the houses of your brothers or the houses of your sisters or the houses of your father's brothers or the houses of your father's sisters or the houses of your mother's brothers or the houses of your mother's sisters or [from houses] whose keys you possess or [from the house] of your friend. There is no blame upon you whether you eat together or separately.} [Quran 24:61]
Al-Qurtubi stated that this verse is not abrogated according to the more correct opinion among the two opinions of the scholars, and he said that a man may eat from the money of his relative, representative, or friend, if he knows that they would approve of it and not object to it.
Ibn Qudaamah said, “The customary permission serves as a real permission.”
However, if the government (or responsible authority) does not authorize this, and if it is expected that if they knew about it, they would prevent it, then the people in charge of those expenses have no right to spend them in other than what they were designated to be spend on, and if they contravene this, then it is not permissible to cooperate with them nor to eat from the food that they took unlawfully.
As regards your saying, "If the food was to be prepared according to the standards of the government, then a lot of food would be wasted and there would be an excess amount of money that would remain in the fund," then this does not make it lawful to dispose of it directly; rather, the excess should be given back to the responsible authority so that they may spend it wherever they wish or authorize the wardens to benefit from it, because the Prophet said, “The Muslims are bound by their conditions.” [Al-Bukhari (reported it as a Mu’allaq hadeeth, i.e. a hadeeth whose whole chain of narrators is omitted), Abu Daawood and At-Tirmithi, who said that it is hasan saheeh (good or sound) - Al-Albaani graded it saheeh (sound)].
Al-Qaasim ibn Muhammad said, “I did not find the people except bound by their conditions in their money and in what they were given.” [Maalik in Al-Muwatta’]
If the responsible authority does not accept returning the food to it and it is known by circumstantial indications that the remaining foodstuff will be damaged in the stores, then there is nothing wrong with disposing of it, because we have been forbidden from wasting money, as it was reported in Al-Bukhari and Muslim from Al-Mugheerah ibn Shu’bah that the Prophet forbade idle talk, asking too many questions (about matters that yield no benefit), and wasting wealth.” [Al-Bukhari and Muslim]
Allaah knows best.