Go: package main

import (
	"bufio"
	"fmt"
	"os"
		"strconv"
	"strings"
	"sort"
	)

var scanner = bufio.NewScanner(os.Stdin)

type Country struct {
	Name  string
	Score int
}

func (c Country) String() string {
	return fmt.Sprintf("%s,%d", c.Name, c.Score)
}

type ByScore []Country

func (a ByScore) Len() int           { return len(a) }
func (a ByScore) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByScore) Less(i, j int) bool { return a[i].Score > a[j].Score }

func main() {
	// countries := []Country{
	// 	{"japan", 3},
	// 	{"america", 4},
	// 	{"canada", 2},
	// }
	// sort.Sort(ByScore(countries))
	// fmt.Println(countries)
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		countries := make([]Country, n)
		for i := range countries {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			tmp := new(Country)
			tmp.Name = input[0]
			var x int
			for j := 1; j < 4; j++ {
				switch j {
				case 1:
					x, _ = strconv.Atoi(input[j])
				case 2:
					x = 0
				case 3:
					x, _ = strconv.Atoi(input[j])
					x *= 3
				}
				tmp.Score += x
			}
			countries[i] = *tmp
		}
		sort.Sort(ByScore(countries))
		for _, v := range countries {
			fmt.Println(v)
		}
		fmt.Println()
	}
}

Python: def main():
    while True:
        n = int(input())
        if n == 0: break

        teams = []
        for i in range(n):
            row = input().split()
            teams.append([row[0], 0])
            s_t = 0
            for e, p in zip(row[1:], [3, 0, 1]):
                s_t += int(e) * p
            teams[i][1] = s_t
        
        for t in sorted(teams, key=lambda x: x[1], reverse=True):
            print("{},{}".format(t[0], t[1]))
        print()



if __name__ == "__main__":
    main()

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0124
"""
import sys
from operator import itemgetter


def solve(data):
    result = []
    for name, win, lose, draw in data:
        score = win * 3 + draw * 1
        result.append([name, score])
    result.sort(key=itemgetter(1), reverse=True)
    return result


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = []
        for _ in range(n):
            name, win, lose, draw = input().split()
            data.append([name, int(win), int(lose), int(draw)])
        result = solve(data)
        for r in result:
            print(','.join(map(str, r)))
        print()


if __name__ == '__main__':
    main(sys.argv[1:])

Python: f = True
while True:
    n = int(input())
    if n == 0:
        break
    T = []
    for i in range(n):
        name,w,l,d = list(input().split())
        T.append((name,i,int(w)*3+int(d)))
    if f: f = False
    else: print()
    for i in sorted(T, key = lambda x:(-x[2],x[1])):
        print(i[0],",",i[2],sep="")

Python: first = False
while 1:
    n = int(input())
    if n == 0:
        break

    if first:
        print()
    else:
        first = True

    data = []
    for _ in range(n):
        country, win, lose, draw = map(str, input().split())
        point = int(win) * 3 + int(draw)
        data.append([country, point])

    data.sort(key=lambda item: -item[1])

    for country, point in data:
        print(country + "," + str(point))

Python: b = False
while True:
    n = int(input())
    if n == 0:
        break
    dataset = []
    if b:
        print()
    b = True
    for _ in range(n):
        name, w, l, d = input().split()
        dataset.append((name, 3*int(w) + int(d), n-len(dataset)))
    for name, score, _ in sorted(dataset, key=lambda x: (x[1], x[2]))[::-1]:
        print(name + "," + str(score))

Python: import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_name,arg_index,arg_value):
        self.name = arg_name
        self.index = arg_index
        self.value = arg_value

    def __lt__(self,another):
        if self.value != another.value:
            return self.value > another.value
        else:
            return self.index < another.index

is_First = True

while True:
    N = int(input())
    if N == 0:
        break

    if is_First == False:
        print()

    table = []

    for i in range(N):
        tmp_name,win,lose,draw = map(str,input().split())
        table.append(Info(tmp_name,i,3*int(win)+int(draw)))

    table.sort()
    for i in range(N):
        print("%s,%d"%(table[i].name,table[i].value))


    is_First = False

C++: #include<cstdio>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int,string>P;
bool F(P a,P b)
{return a.first>b.first;};
int main()
{
	int n,a,b,c,i,x=0;
	while(scanf("%d",&n),n)
	{
		char s[99];
		pair<int,string>p[10];
		for(i=0;i<n;++i)
			scanf("%s%d%d%d",s,&a,&b,&c),p[i].second=s,p[i].first=3*a+c;
		stable_sort(p,p+n,F);
		printf("%s",(x++?"\n":""));
		for(i=0;i<n;++i)
			printf("%s,%d\n",p[i].second.c_str(),p[i].first);
	}
	return 0;
}

C++: #include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int a,b,n,f=0;
  string s;
  for(;cin>>n,n;){
    if(f)cout<<endl;
    vector<pair<int,string> >v;
    for(f=0;f<n;v.push_back(make_pair(a*3+b,s)),f++)
      cin>>s>>a>>b>>b;
    for(a=0;a<n-1;a++)
      for(b=a+1;b<n;b++)
        if(v[a].first<v[b].first)iter_swap(v.begin()+a,v.begin()+b);
    for(a=0;a<n;a++)
      cout<<v[a].second<<','<<v[a].first<<endl;
    f=1;
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, string> T;

int main()
{
    int n;
    bool fst = true;
    while(cin >> n && n) {
        if(fst) {
            fst = false;
        } else {
            cout << endl;
        }
        vector<T> vt;
        string name;
        int a,b,c;
        while(n--) {
            cin >> name >> a >> b >> c;
            vt.push_back(T(a * 3 + c, name));
        }
        
        stable_sort(vt.begin(), vt.end());
        for(int i = vt.size() - 1; i >= 0; i--) {
            cout << vt[i].second << "," << vt[i].first << endl;
        }
    }
}

C++: #include <iostream>
#include <string.h>
using namespace std;

struct data{

	char name[20];
	int win;
	int lose;
	int draw;
	int score;

};

int main(){

	int teamamo;

	while (true){

		cin >> teamamo;

		if (teamamo == 0)
			break;

		data teamdata[10];
		

		for (int i = 0; i<teamamo; i++)
			cin >> teamdata[i].name >> teamdata[i].win >> teamdata[i].lose >> teamdata[i].draw;

		for (int i = 0; i<teamamo; i++)
			teamdata[i].score = teamdata[i].win * 3 + teamdata[i].draw;


		for (int j = 0; j < teamamo - 1; j++){
			for (int i = 0; i < teamamo - 1; i++){

				if (teamdata[i].score < teamdata[i + 1].score){

					data t = teamdata[i];
					teamdata[i] = teamdata[i + 1];
					teamdata[i + 1] = t;

				}

			}


		}

		for (int i = 0; i<teamamo; i++)
			cout << teamdata[i].name << "," << teamdata[i].score << endl;

		cout << endl;
		


	}

	return 0;

}

C++: #include<vector>
#include<iostream>
#include<string>
using namespace std;
int main(){
  int g=0,h,i;
  int n;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    vector<int> p;
    vector<string> s;
    for(i=0;i<n;i++){
      string str;
      int k,m,h;
      cin>>str>>k>>m>>h;
      s.push_back(str);
      p.push_back(k*3+h);
    }
    do{
      h=0;
      for(i=1;i<n;i++){
	if(p[i-1]<p[i]){
	  swap(p[i-1],p[i]);
	  swap(s[i-1],s[i]);
	  h=1;
	}
      }
    }while(h);
    if(g)
      cout<<endl;
    g=1;
    for(i=0;i<n;i++)
      cout<<s[i]<<","<<p[i]<<endl;
  }
  return 0;
}