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 <string>
#include <vector>
using namespace std;

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

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

int size(int x){
    if(x > 160) return 6;
    if(x > 140) return 5;
    if(x > 120) return 4;
    if(x > 100) return 3;
    if(x > 80) return 2;
    if(x > 60) return 1;
    return 0;
}

int weight(int x){
    if(x > 25) return 6;
    if(x > 20) return 5;
    if(x > 15) return 4;
    if(x > 10) return 3;
    if(x > 5) return 2;
    if(x > 2) return 1;
    return 0;
}

int price[7] = {600, 800, 1000, 1200, 1400, 1600, 0};

int main(){
    while(1){
        int n, x, y, h, w;
        cin >> n;

        if(n == 0)  break;

        int sum = 0;
        for(int i = 0; i < n; i++){
            cin >> x >> y >> h >> w;
            sum += price[max(size(x+y+h), weight(w))];
        }

        cout << sum << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n,i,j;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		
		int ans=0;
		
		for(i=0;i<n;i++)
		{
			int size=0,weight;
			for(j=0;j<3;j++)
			{
				int a;
				cin >> a;
				size+=a;
			}
			cin >> weight;
			if(size<=160 && weight<=25)
			{
				if(size>140 || weight>20)
				{
					ans+=1600;
				}
				else if(size>120 || weight>15)
				{
					ans+=1400;
				}
				else if(size>100 || weight>10)
				{
					ans+=1200;
				}
				else if(size>80 || weight>5)
				{
					ans+=1000;
				}
				else if(size>60 || weight>2)
				{
					ans+=800;
				}
				else
				{
					ans+=600;
				}
			}
		}
		cout << ans << endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	vector<int>hs{ 60,80,100,120,140,160 };
	vector<int>ws{ 2,5,10,15,20,25 };
	vector<int>ms{ 600,800,1000,1200,1400,1600 };
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			int x, y, h, w; cin >> x >> y >> h >> w;
			int l = x + y + h;
			auto it = lower_bound(hs.begin(), hs.end(), l);
			auto jt = lower_bound(ws.begin(), ws.end(),w);
			int num = max(it - hs.begin(), jt - ws.begin());
			if (num == 6)continue;
			else ans += *(ms.begin() + num);
		}
		cout << ans << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>

int main(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++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(void){ 
  int n;
  int s[] = {60,80,100,120,140,160};
  int we[] = {2,5,10,15,20,25};
  int f[] = {600,800,1000,1200,1400,1600};

  while(cin>>n,n){
    int x,y,h,w;
    int sum = 0;
    while(n--){
      cin>>x>>y>>h>>w;
      int nn = x+y+h;
      bool ok1=true,ok2=true;
      int i = 0;
      if(nn >=160)continue;
      if(w >= 25)continue;
      for(i = 0 ; i < 5 ; i ++){
	//cout<<i<<" "<<f[i]<<endl;
	if(s[i] >= nn)ok1 = false;
	if(we[i] >= w)ok2 = false;
	if(!ok1&&!ok2)break;
      }
      //cout<<x<<y<<h<<w<<" "<<f[i]<<endl;
      sum+= f[i];
    }
    cout<<sum<<endl;
    //cout<<endl;
  }
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(i=a;i<n;++i)
#define R(i,a,n) for(int i=a;i>=n;i--)
using namespace std;
int main(){
	long int n,a,b,c,s,w;
	while(cin>>n,n){
		long int p=0;
		r(i,0,n){
		cin>>a>>b>>c>>w;
		s=a+b+c;
		if(s<=60&&w<=2)p+=600;
		else if(s<=80&&w<=5)p+=800;
		else if(s<=120&&w<=15)p+=1200;
		else if(s<=140&&w<=20)p+=1400;
		else if(s<=160&&w<=25)p+=1600;
	    }
	    cout<<p<<endl;
	}
	return 0;
}

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(cin>>n,n){
		int sum = 0;
		for(int j = 0;j < n;j++){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			int v =x+y+h;
			int va = -1;
			int wa =-1;
			for(int i =60;i <=160;i+=20){
				if(v <=i){
					va =i;
					break;
				}
			}
			if(va==-1)continue;
			if(w<=2){
				wa =60;
			}else if(w<=5){
				wa =80;
			}else if(w <=10){
				wa =100;
			}else if(w <=15){
				wa =120;
			}else if(w <=20){
				wa =140;
			}else if(w <=25){
				wa =160;
			}
			if(wa==-1)continue;
			//cout <<wa<<" "<<va<<endl;
			sum +=max(wa,va)*10;
		}
		cout <<sum<<endl;
	}
	return 0;
}

C++: #include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;

/** Problem0160 : Delivery Fee **/
int main()
{
	int size[6] = {60, 80, 100, 120, 140, 160};
	int weight[6] = {2, 5, 10, 15, 20, 25};
	int fee[6] = {600, 800, 1000, 1200, 1400, 1600};
	
	int n;
	
	while (cin>>n, n!=0) {
		int a, b, c, d, sum=0;
		rep(k, n) {
			cin >> a >> b >> c >> d;
			rep(i, 6) {
				if (d <= weight[i] && a+b+c <= size[i]) {
					sum+=fee[i];
					break;
				}
			}
		}
		cout << sum << endl;
	}
}