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<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<utility>
#include<vector>
#include<functional>

using namespace std;



int main(void)
{
	//入力変数
	pair<int, string>h_input[10];
	//いくつ入力するか
	int n = 0;
	//入力変数
	char str_input[100] = {NULL};

	while (cin >> n && n != 0)
	{
		//入力変数
		pair<int , pair<int , int>> tokuten;

		for (int i = 0; i < n; i++)
		{
			cin >> str_input;
			h_input[i].second = str_input;
			cin >> tokuten.first >> tokuten.second.first >> tokuten.second.second;
			//勝ちと負けの分だけ加算
			h_input[i].first = tokuten.first * 3 + tokuten.second.second;
		}

		stable_sort(h_input , h_input + n , greater<pair<int , string> >());

		for (int i = 0; i < n; i++)
		{
			cout << h_input[i].second << "," << h_input[i].first << endl;
		}
	
	}
	
	return 0;
}

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

int N,sum[10],sum2[10];
struct DATA{
	string country;
	int win,lose,drow,sum,flag; 
};
DATA data[10];
int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>data[i].country>>data[i].win>>data[i].lose>>data[i].drow;
		data[i].sum=data[i].win*3+data[i].drow;
		sum[i]=data[i].sum;
	}
	sort(sum,sum+N);
	for(int i=0;i<N;i++){sum2[i]=sum[N-1-i];}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(sum2[i]==data[j].sum && data[j].flag==0){
				cout<<data[j].country<<","<<data[j].sum<<endl;
				data[j].flag=1;
			}
		}
	}
	
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<string>
#include<vector>
using namespace std;
typedef pair<int,string> P;
main(){
  vector<P> ar;
  P p;
  int n,a,b,c,f=0;
  string s;
  while(1){
    cin >> n;
    if(!n)break;
    if(f == 0){
      cout << endl;
      f = 1;
    }
    for(int i=0;i<n;i++){
      cin >> s >> a >> b >> c;
      p.first = (a*3) + (c*1);
      p.second = s;
      ar.push_back( p );
    }
    sort( ar.begin() , ar.end() , greater<P>());
    for(int i=0;i<n;i++){
      cout << ar[i].second << ',' << ar[i].first << endl;
    }
    ar.clear();
  }
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n){
        vector<pii>v;
        vector<string>amausa;
        rep(i,n){
            int gotiusa=0;
            string rabit; cin>>rabit;
            amausa.push_back(rabit);
            int kokoa,rize,tino; cin>>kokoa>>rize>>tino;
            gotiusa+=kokoa*3+tino;
            v.push_back(pii(gotiusa,-i));
        }
        sort(all(v),greater<pii>());
        rep(i,n)cout<<amausa[-1*v[i].second]<<","<<v[i].first<<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main(){
	int n;
	bool next = false;
	int w,l,d=0;
	while(cin>>n && n)
	{
		 if ( next )
        {
            cout << endl;
        }
        next = true;
		multimap< int,string,greater<int> >m;
		for(int i=0; i<n; i++)
		{
			string t;
			cin>>t>>w>>l>>d;
			m.insert( make_pair( w*3+d , t ) );
		}
		for(multimap< int,string,greater<int> >::iterator it=m.begin(); it != m.end(); it++)
			cout<< (*it).second << ',' << (*it).first << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
   
struct data{
   
char name;
int win;
int lose;
int draw;
int score;
   
};
   
int main(){
   
int teamamo;
   
while(true){
   
cin>>teamamo;
   
if(teamamo==0)
break;
   
data teamdata[10];
data comp;
   
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 i=0; i<teamamo-1; i++){
   
if(teamdata[i].score<teamdata[i+1].score){
   
char fout; 
fout=teamdata[i].name;
teamdata[i].name=teamdata[i+1].name;
teamdata[i+1].name=fout;
   
int gout;
gout=teamdata[i].score;
teamdata[i].score=teamdata[i+1].score;
teamdata[i+1].score=gout;
   
    }
   
   
   }
   
for(int i=0; i<teamamo; i++)
cout<<teamdata[i].name<<','<<teamdata[i].score<<endl;
   
   
 }
   
return 0;
   
}

C++: #include<cstdio>
#include<cstring>
using namespace std;

int main(void)
{
	//チームの名前
	char str_name[10][21];
	//点数配列
	int h_point[10] = {0};
	//勝ち、負け、引き分けの入力変数
	int win = 0 , loss = 0 , drow = 0;
	//入力数
	int n = 0;
	int i = 0 , j = 0;
	//１番大きい要素を取り出す
	int index = 0;
	//最大値の設定変数
	int max = 0;
	//入れ替える文字列
	char str_tmp[11];
	int team = 0;
	//アクセス順配列
	int h_zyunban[10] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9};

	while (true)
	{
		//参加チーム
		scanf("%d" , &team);

		if (team == 0)
		{
			return 0;
		}

		for (int i = 0; i < team; i++)
		{
			//名前と得点の読み込み
			scanf("%s %d %d %d", str_name[i] , &win , &loss , &drow);
			h_point[i] = win * 3 + drow;
		}

		//ソート
		for (int i = 0; i < team - 1; i++)
		{
			for (int j = i + 1; j < team; j++)
			{
				if (h_point[i] < h_point[j])
				{
					//交換
					int tmp = h_zyunban[i];
					h_zyunban[i] = h_zyunban[j];
					h_zyunban[j] = tmp;

					tmp = h_point[i];
					h_point[i] = h_point[j];
					h_point[j] = tmp;
				}
			}
		}

		//出力
		for (int i = 0; i < team; i++)
		{
			printf("%s,%d\n" , str_name[h_zyunban[i]] , h_point[i]);
		}

		for (int i = 0; i < 10; i++)
		{
			h_zyunban[i] = i;
		}
	}
}