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 <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string const resstr[] = {"Impossible","Possible","No","Yes"};

int const rs[]={60,80,100,120,140,160,int(1e8)}; 
int const rw[]={2,5,10,15,20,25,int(1e8)}; 
int const p[]={600,800,1000,1200,1400,1600,int(1e8)};

int main(){
    int n;
    while(cin>>n,n){
        int ans = 0;
        rep(i,n){
            int x,y,h,w; cin>>x>>y>>h>>w;
            int s=x+y+h;
            int j=0;
            for (j=0;;++j){
                if(s>rs[j]||w>rw[j]) continue;
                else break;
            }
            if(j==6) continue;
            ans += p[j];
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,x,y,h,w,i,s,a;
  while(cin>>n,n){
    for(s=i=0;i<n;i++){
      cin>>x>>y>>h>>w;
      a=x+y+h;
      if(a<=60&&w<=2)s+=600;
      else if(a<=80&&w<=5)s+=800;
      else if(a<=100&&w<=10)s+=1000;
      else if(a<=120&&w<=15)s+=1200;
      else if(a<=140&&w<=20)s+=1400;
      else if(a<=160&&w<=25)s+=1600;
    }
    cout<<s<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main() {

  int n;
  int x,y,h,w;

  int sum;


  while(cin >> n) {

    if(n==0) break;

    sum=0;

    for(int i=0;i<n;i++) {

      cin >> x >> y >> h >> w;

      if(x+y+h>160 || w>25) continue;

      else if(x+y+h>140 || w>20) sum+=1600;

      else if(x+y+h>120 || w>15) sum+=1400;

      else if(x+y+h>100 || w>10) sum+=1200;

      else if(x+y+h>80 || w>5) sum+=1000;

      else if(x+y+h>60 || w>2) sum+=800;

      else sum+=600;

    }

    cout << sum << endl;

  }

}

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

int main()
{
	int n;
	const int length[] = { 60, 80, 100, 120, 140, 160, 100000000 };
	const int weight[] = { 2, 5, 10, 15, 20, 25, 100000000 };
	const int cost[] = { 600, 800, 1000, 1200, 1400, 1600, 0 };

	while( cin >> n && n ){
		int result = 0;
		for( int i = 0; i < n; ++i ){
			int x, y, h, w;
			cin >> x >> y >> h >> w;
			int l = x + y + h;
			int gl = 0, gw = 0;
			while( l > length[ gl ] ){
				++gl;
			}
			while( w > weight[ gw ] ){
				++gw;
			}
			result += cost[ max( gl, gw ) ];
		}
		cout << result << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int mian(void){
	int x,y,z,w,n,i;
	int sum,l;

	while(scanf("%d",&n)!=0){
		sum=0;
		for(i=0;i<n,i++){
		  scanf("%d %d %d %d",&x,&y,&z,&w);
		  l=x+y+z;
		  if(l<=60 && w<=2) sum+=600;
		  else if(l<=80 && w<=5) sum+=800;
		  else if(l<=100 && w<=10) sum+=1000;
		  else if(l<=120 && w<=15) sum+=1200;
		  else if(l<=140 && w<=20) sum+=1400;
		  else if(l<=160 && w<=25) sum+=1600;
		}
		printf("%d\n",sum);
	}
	return 0;
}

C++: //0160.cpp
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	vector<int>l;
	int n;
	int a, b, c, x;
	while (true){
		cin >> n;
		if (n == 0)break;
		int sum = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c >> x;
			a += b;
			a += c;
			if (a <= 60 && x <= 2)
				sum += 600;
			else if (a <= 80 && x <= 5)
				sum += 800;
			else if (a <= 100 && x <= 10)
				sum += 1000;
			else if (a <= 120 && b <= 15)
				sum += 1200;
			else if (a <= 140 && b <= 20)
				sum += 1400;
			else if (a <= 160 && b <= 25)
				sum += 1600;
		}
		l.push_back(sum);
	}
	for (int i : l) {
		cout << i << endl;
	}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	ll ans = 0;
	int m;
	REP(i,n){
	    int x,y,h,w;
	    cin >> x >> y >> h >> w;
	    int s = x + y + h;
	    m = 0;
	    if( s > 160) continue;
	    else if(s > 140) m = 1600;
	    else if(s > 120)  m = 1400;
	    else if(s > 100) m = 1200;
	    else if(s > 80) m = 1000;
	    else if(s > 60) m = 800;
	    else m = 600;

	    if(w > 25) continue;
	    else if(w > 20) m = max(m,1600);
	    else if(w > 15) m = max(m,1400);
	    else if(w > 10) m = max(m,1200);
	    else if(w > 5)  m = max(m,1000);
	    else if(w > 2)  m = max(m,800);
	    else m = max(m,600);
	    ans += m;
	}
	cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

C++: #include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  int n,a[3],b,cnt,j;
  int sum;
  int tmpr[]={600,800,1000,1200,1400,1600,0};
  int tmpb[]={60,80,100,120,140,160,0};
  int tmpw[]={2,5,10,15,20,25,0};
  while(1){
    cin >> n;
    if(n==0)break;
    cnt=0;
    for(int i=0;i<n;i++){
      cin >> a[0] >> a[1] >> a[2] >> b;
      j=0;
      int sum = a[0]+a[1]+a[2];
      for(int flg=0;j<6;j++,flg=0){
	if(tmpb[j]<sum) flg=1;
	if(tmpw[j]<b) flg=1;

	if(flg==0) break;
      }
      cnt += tmpr[j];
    }
    cout << cnt << endl;
  }
}