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()
	}
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k,x,n,setcnt,ff;
	int win,lose,drow,mx=-1;
	char kuni[11][21];
	int tokuten[11];
	char team[21];
	setcnt=0;
	while(1) {
		cin>>n;
		if(n==0) break;
		else if(setcnt!=0)cout<<endl;
		for(i=0;i<n;i++) {
			cin>>kuni[i]>>win>>lose>>drow;
			tokuten[i]=win*3+drow;
		}
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				if(mx<tokuten[j] && tokuten[j]!=-1) {
					mx=tokuten[j];
					ff=j;
					strcpy(team,kuni[j]);
				}
			}
			cout<<team<<","<<mx<<endl;
			tokuten[ff]=-1;mx=-1;
		}
		setcnt++;
	}
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <map>
#include <cstdlib>
using namespace std;

struct T{
    char team[22];
    int score;
} ;

bool operator==(const T& left, const T& right)
{
    return left.score == right.score;
}
bool operator<(const T& left, const T& right)
{
    return left.score > right.score;
}
bool operator>(const T& left, const T& right)
{
    return left.score < right.score;
}


int main(void)
{
    int w, l, d = -1;
    
    while (1){
        int n;
        scanf("%d", &n);
        if (!n) break;
        if (d != -1) printf("\n");
        
        struct T set[n];
        
        for (int i = 0; i < n; i++){
            scanf("%s %d %d %d", set[i].team, &w, &l, &d);
            set[i].score = (w * 3) + (d * 1);
        }
        
        stable_sort(set, set + n);
        
        for (int i = 0; i < n; i++){
            printf("%s,%d\n", set[i].team, set[i].score);
        }
    }
    
    return (0);
}

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


int main(void){
	int n;
	int cnt = 0 ;
	while(cin>>n,n){
		if(cnt ++ > 0)cout<<endl;
		string name[n];
		int sum[n],point;
		int rank[n];
		for(int i = 0 ; i < n ; i ++){
			cin>>name[i];
			cin>>point; //win
			sum[i]=point*3;
			cin>>point;	//lose;
			cin>>point; //drow
			sum[i]+=point;
			rank[i]=i;			
		}
		for(int i = 0 ; i < n ; i ++)
			for(int j = 0 ; j < n ; j ++){
				if(sum[rank[i]]>sum[rank[j]]){
					int t = rank[i];
					rank[i] = rank[j];
					rank[j] = t;
				}
			}
		for(int i = 0 ; i < n ; i ++)
			cout<<name[rank[i]]<<","<<sum[rank[i]]<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    //    vector<pair<string,int> > s;
    vector<vector<string> > anspo(1000);
    for(int i=0;i<n;i++){
      string str;cin>>str;
      int w,l,d;cin>>w>>l>>d;
      //s.push_back(make_pair(str,w*3+d));
      anspo[w*3+d].push_back(str);
    }
    for(int i=999;i>=0;i--){
      for(int j=0;j<anspo[i].size();j++){
      cout<<anspo[i][j]<<","<<i<<endl;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	bool flag = true;
	int n,i,win,draw,lose,point[10];
	string str[10];
	while(cin >> n && n){
		for(i=0;i<n;i++){
			cin >> str[i] >> win >> lose >> draw;
			point[i] = (win*3)+(draw*1);
		}
		if(flag == false) cout << "\n";
		for(i=0;i<n-1;i++){
			for(int j=n-1;i<j;j--){
				if(point[j-1] < point[j]){
					swap(str[j-1],str[j]);
					swap(point[j-1],point[j]);
				}
			}
		}
		for(i=0;i<n;i++){
			cout << str[i] << "," << point[i] << endl;
		}
		flag = false;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    
    int n;
    int flag=0;
    while(cin >> n && n)
    {
    	string str;
    	int a,b,c;
    	vector<string>list;
    	int num[1000]={};
    	int count=0;

    	if(flag)cout << endl;
    	while(n--)
    	{
    		cin >> str >> a >> b >> c;
    		num[count]=a*3+c;
    		list.push_back(str);
    		count++;
    	}

    	for(int i=0;i<count;i++)
    	{
    		for(int j=i;j<count;j++)
    		{
    			if(num[i]<num[j])
    			{
    				swap(num[i],num[j]);
    				swap(list[i],list[j]);
    			}
    		}
    	}
    	for(int i=0;i<count;i++)
    	{
    		cout << list[i] << "," << num[i] << endl;
    	}
    	flag=1;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

void insertion_sort(pair<int, string> p[], int n) {
    for (int i = 1; i < n; i++) {
        pair<int, string> k = p[i];
        int j = i - 1;
        while (j >= 0 && p[j].first < k.first) {
            p[j + 1] = p[j];
            j--;
        }
        p[j + 1] = k;
    }
    return;
}

int main() {
    bool flag = false;
    int n;
    while (cin >> n && n) {
        if (flag) cout << endl;
        flag = true;
        string s;
        int w, l, d;
        pair<int, string> p[n];
        for (int i = 0; i < n; i++) {
            cin >> s >> w >> l >> d;
            p[i] = { 3 * w + d, s };
        }
        insertion_sort(p, n);
        for (int i = 0; i < n; i++) {
            cout << p[i].second << ',' << p[i].first << endl;
        }
    }
}

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

int main() {
    bool lb = false;
    int n;
    while (cin >> n, n) {
        vector<pair<int,pair<int,string>>> v(n);
        string name;
        int win, lose, draw;
        for (int i=0; i<n; ++i) {
            cin >> name >> win >> lose >> draw;
            v[i] = make_pair(-win*3-draw, make_pair(i, name));
        }
        sort(v.begin(), v.end());
        if (lb) {
            cout << endl;
        } else {
            lb = true;
        }
        for (int i=0; i<n; ++i) {
            cout << v[i].second.second << "," << -v[i].first << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<unordered_set>
using namespace std;
typedef unordered_set<string> US;

int main() {
	int n;
	int lp = 0;
	while (cin >> n, n) {
		US u[30];
		if (lp != 0)cout << endl;

		for (int i = 0;i < n;i++) {
			string s;
			int a, b, c;
			cin >> s >> a >> b >> c;
			int p = 3 * a + c;
			u[p].insert(s);
		}

		for (int i = 29;i > -1;i--) {
			for (auto itr = u[i].begin();itr != u[i].end();itr++) {
				cout << *itr << ',' << i << endl;
			}
		}
		lp++;
	}
	return 0;
}