pen = pencil+12 and 10pencil +8pen = 339.
Two equations and two unknowns. Use the first equation to substitute the value of pen in terms of pencils into the second equation and solve it.
10pencil + 8(pencil+12) = 339
10pencil +8pencil + 96 = 339
18pencil = 243
pencil = 13.5
pen = pencil + 12 = 13.5+12 = 25.5