According to Roman Catholic Doctrine, does everyone spend time in purgatory? As I understand it, the Roman Catholic Church teaches that there is place of suffering called Purgatory where people spend time being purged of the sins they committed on earth.  However, it seems that in the Confessional, a priest absolves people of their sins.

So, does Catholic teaching indicate that everyone goes to purgatory, including priests and cardinals and popes, or do some people avoid purgatory altogether?  Would someone who dies immediately after leaving the confessional avoid purgatory completely?
Anyone who dies in sin, but not Mortal Sin, goes to Purgatory. This would include Priests and Bishops (the Pope is the Bishop of Rome).
There are specific cases that the Church says the person will go straight to heaven. We say Mary was assumed into heaven; she did not go to Purgatory. Martyrs are also said to go straight to heaven according to religion facts.:

If a person is martyred for the faith, miracles are not necessary to be declared a saint. As mentioned above, the purpose of canonization is to verify that the person is now in heaven, and all those who die as martyrs are believed to go straight to heaven.

From the Catechism of the Catholic Church:

1030    All who die in God’s grace and friendship, but still imperfectly purified, are indeed assured of their eternal salvation; but after death they undergo purification, so as to achieve the holiness necessary to enter the joy of heaven.
1472    To understand this doctrine and practice of the Church, it is necessary to understand that sin has a double consequence. Grave sin deprives us of communion with God and therefore makes us incapable of eternal life, the privation of which is called the “eternal punishment” of sin. On the other hand every sin, even venial, entails an unhealthy attachment to creatures, which must be purified either here on earth, or after death in the state called Purgatory. This purification frees one from what is called the “temporal punishment” of sin. These two punishments must not be conceived of as a kind of vengeance inflicted by God from without, but as following from the very nature of sin. A conversion which proceeds from a fervent charity can attain the complete purification of the sinner in such a way that no punishment would remain.84 (1861, 1031)