For carbon dioxide there are #6+6+4=16" valence electrons"#, i.e. 8 electron pairs. There are 2 lone pairs around each oxygen atom, and with the 8 electrons involved in the double bonds, this accounts for the 16 electrons.
For carbon monoxide, there are #6+4=10" valence electrons"#. A representation of #""^+:O-=C:^-# is typical. This involves formal charge separation, but inorganic chemists tend to like this representation in that carbon monoxide typically coordinates thru the carbon.