Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	tbl := []int{600, 800, 1000, 1200, 1400, 1600}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			 break
		}
		fee := 0
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			x, _ := strconv.Atoi(buf[0])
			y, _ := strconv.Atoi(buf[1])
			h, _ := strconv.Atoi(buf[2])
			w, _ := strconv.Atoi(buf[3])
			s := x + y + h
			if s <= 160 && w <= 25 {
				k1, k2 := 0, 0
				if s <= 60 {
					k1 = 0
				} else {
					k1 = (s-61)/20 + 1
				}
				if w <= 2 {
					k2 = 0
				} else {
					k2 = (w-1)/5 + 1
				}
				if k1 < k2 {
					k1 = k2
				}
				fee += tbl[k1]
			}
		}
		fmt.Println(fee)
	}
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;
bool eq(double a, double b)
{
	return abs(a - b) < Eps;
}

using namespace std;

int main()
{
	int Size[] = { 60, 80, 100, 120, 140, 160, 100000 };
	int Weight[] = { 2, 5, 10, 15, 20, 25, 100000 };
	int Fee[] = { 600, 800, 1000, 1200, 1400, 1600, 0 };

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		while (n--)
		{
			int x, y, h, w;
			scanf("%d %d %d %d", &x, &y, &h, &w);
			int i;
			int s = x + y + h;
			for (i = 0; s > Size[i] || w > Weight[i]; ++i)
				;
			ans += Fee[i];
		}
		printf("%d\n", ans);
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int n;
  while(cin>>n,n) {
    int ans = 0;
    while(n--) {
      int x,y,h,w;
      cin >> x >> y >> h >> w;
      int v = max(max(x,y),h);
      if (v<=60&&w<=2)
        ans += 600;
      else if (v<=80&&w<=5)
        ans += 800;
      else if (v<=100&&w<=10)
        ans += 1000;
      else if (v<=120&&w<=15)
        ans += 1200;
      else if (v<=140&&w<=20)
        ans += 1400;
      else if (v<=160&&w<=25)
        ans += 1600;
    }
    cout << ans << endl;
  }
}

C++: #include<iostream>

using namespace std;

int ryou[3][6]={{60,80,100,120,140,160},
				{2,5,10,15,20,25},
				{600,800,1000,1200,1400,1600}};

int main(void){
	int n,sumPrice;
	int x,y,h,w,length;
	while(cin>>n,n){
		sumPrice=0;
		for(int i=0;i<n;i++){
			cin>>x>>y>>h>>w;
			length=x+y+h;
			for(int j=0;j<6;j++){
				if(length<=ryou[0][j] && w<=ryou[1][j]){
					sumPrice=sumPrice+ryou[2][j];
					break;
				}
			}
		}
		cout<<sumPrice<<endl;
	}
}

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

using namespace std;

////typedef
////------------------------------------------
//typedef vector<int> vi;
//typedef vector<vi> vii;
//typedef vector<string> vs;
//typedef vector<bool> vb;
//typedef vector<vb> vbb;
//typedef pair<int, int> pii;
//typedef long long ll;
//typedef unsigned long long ull;
//
////container util
////------------------------------------------
//#define all(a)  (a).begin(),(a).end()
//#define rall(a) (a).rbegin(), (a).rend()
//#define pb push_back
//#define mp make_pair
//#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
//
////repetition
////------------------------------------------
//#define loop(i,a,b) for(int i=(a);i<(b);++i)
//#define rep(i,n)  loop(i,0,n)
//
////constant
////--------------------------------------------
//const double eps = 1e-10;
//const double pi  = acos(-1.0);
//const double inf = (int)1e8;
//
//// output vector
//// ------------------------------------------
//namespace std {
//    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
//        for(auto it=v.begin(); it!=v.end(); ++it){
//            os << *it << (it+1==v.end() ? "" : ",");
//        }
//        return os;
//    }
//}
//
////clear memory
//#define clr(a) memset((a), 0 ,sizeof(a))

int main(){
    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i=0; i < n; i++){
            int x, y, h, w;
            cin >> x >> y >>h >> w;

            int s = x+y+h;
            if(160 < s || 25 < w);
            else if(140 < s || 20 < w) ans += 1600;
            else if(120 < s || 15 < w) ans += 1400;
            else if(100 < s || 10 < w) ans += 1200;
            else if(80 < s || 5 < w) ans += 1000;
            else if(60 < s || 2 < w) ans += 800;
            else ans += 600;
        }
        cout << ans << endl;
    }
}

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

int main(){
	int n,sum,kg,x,y,z;
	while(cin >> n && n){
		sum = 0;
		for(int i=0;i<n;i++){
			cin >> x >> y >> z >> kg;
			x=x+y+z;
			sum += (x>160||kg>25)?0:
				(x>140||kg>20)?1600:
				(x>120||kg>15)?1400:
				(x>100||kg>10)?1200:
				(x>80||kg>5)?1000:
				(x>60||kg>2)?800:
				600;
		}
		cout << sum << endl;
	}
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int f(int x,int y,int z){
	int w=x+y+z;
	if(w<=60)return 600;
	if(w<=80)return 800;
	if(w<=100)return 1000;
	if(w<=120)return 1200;
	if(w<=140)return 1400;
	if(w<=160)return 1600;
	return 0;

}

int g(int w){
	if(w<=2)return 600;
	if(w<=5)return 800;
	if(w<=10)return 1000;
	if(w<=15)return 1200;
	if(w<=20)return 1400;
	if(w<=25)return 1600;
	return 0;
}

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int sum=0;
		rep(i,n){
			int x,y,z,w;
			cin>>x>>y>>z>>w;
			int F=f(x,y,z),G=g(w);
			if(F==0 || G==0)sum+=0;
			else sum+=max(F,G);
		}
		cout<<sum<<endl;
	}
}

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

int main()
{
  const long long int price[] = {600LL, 800LL, 1000LL, 1200LL, 1400LL, 1600LL};

  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<long long int> item(6, 0);
    while (n--) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;

      int s = x+y+h;
      if (s <= 60 && w <= 2)
	++item[0];
      else if (s <= 80 && w <= 5)
	++item[1];
      else if (s <= 100 && w <= 10)
	++item[2];
      else if (s <= 120 && w <= 15)
	++item[3];
      else if (s <= 140 && w <= 20)
	++item[4];
      else if (s <= 160 && w <= 25)
	++item[5];
    }

    long long int ans = 0;
    for (unsigned int i = 0; i < item.size(); ++i)
      ans += item[i] * price[i];

    cout << ans << endl;
  }
  return 0;
}