This implies that there is only one candidate per ballot. That's not the way it works in the USA. In the USA elections, you vote for the president, the governor, the senators, etc.. on a single ballot. Yes, many people vote along party lines but not everyone so there is no way to sort them into piles.
The vast majority of UK elections are single candidate/party per ballot. If two or more elections are taking place on the same day then multiple ballots are used. Elections tend to be held at different times so it is less likley to have multiple contests on the same day.
For the Scottish Parliament elections, each voter is given two ballots- one for a named candidate, the other for a top up proportional represantation list candidate (where they vote for a single party).
There are some elections where multiple candidates are chosen. Scottish local government elections use multi member single transferable vote so voters rank the candidates in order of preference. The London Mayrol election uses suplimentory vote where the voters put down a first and second preference. The ballots for these elections are paper based and then scanned into a computer system for counting.