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 <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

C++: #include <cstdio>
#include <algorithm>

using namespace std;

int getL(int n)
{
	return ((n > 60) + (n > 80) + (n > 100) + (n > 120) + (n > 140) + (n > 160));
}

int getW(int n)
{
	return ((n > 2) + (n > 5) + (n > 10) + (n > 15) + (n > 20) + (n > 25));
}

int main()
{
	int n;
	int a[7] = {600, 800, 1000, 1200, 1400, 1600, 0};
	
	while (scanf("%d", &n) && n){
		int ans = 0;
		for (int i = 0; i < n; i++){
			int x, y, z, w;
			scanf("%d %d %d %d", &x, &y, &z, &w);
			ans += a[max(getL(x + y + z), getW(w))];
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

C++: #include<iostream>
#include<vector>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	vector<int> weight,length;
	long long n;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,n){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			length.push_back(x+y+h);
			weight.push_back(w);
		}
		long long price=0;
		rep(i,weight.size()){
			int nl=length[i],nw=weight[i];
			if(nl>160 || nw>25){}
			else if(nl>140 || nw>20) price+=1600;
			else if(nl>120 || nw>15) price+=1400;
			else if(nl>100 || nw>10) price+=1200;
			else if(nl>80 || nw>5) price+=1000;
			else if(nl>60 || nw>2) price+=800;
			else price+=600;
		}
		cout<<price<<endl;
		while(!weight.empty()){
			weight.pop_back();
			length.pop_back();
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-8;

struct DATA{
	int size;
	int weight;
	int fare;
};

int main(){
	struct DATA data[6] = {
		60,2,600,
		80,5,800,
		100,10,1000,
		120,15,1200,
		140,20,1400,
		160,25,1600,
	};

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int sum=0;
		for(int i=0;i<n;i++){
			int x,y,h,w;
			scanf("%d %d %d %d",&x,&y,&h,&w);
			int size = x+y+h;
			for(int i=0;i<6;i++){
				if(size <= data[i].size
					&& w <= data[i].weight){
						sum += data[i].fare;
						break;
				}
			}
		}
		printf("%d\n",sum);
	}
}

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;
		while(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 <iostream>

using namespace std;

const int MAX_N = 1000;

int main()
{
/*
A TCY	B TCY	C TCY	D TCY	E TCY	F TCY
å«³	60cmÈà	80cmÈà	100cmÈà	120cmÈà	140cmÈà	160cmÈà
d³	2kgÈà	5kgÈà	10kgÈà	15kgÈà	20kgÈà	25kgÈà
¿à	600~	800~	1000~	1200~	1400~	1600~
*/
	const int volume[] = { 0, 60, 80, 100, 120, 140, 160, MAX_N };
	const int wight[]  = { 0,  2,  5,  10,  15,  20,  25, MAX_N };
	const int fee[]    = { 0,600,800,1000,1200,1400,1600 };   
//	cut here before submit 
//	freopen ("testcase.deliveryfee", "r", stdin );
	int n;
	
	while (1){
		cin >> n;
		if (n == 0){
			break;
		} // end if
		
		int i,j,k;
		int res = 0;
		for (i = 0; i < n; ++i){
			int x, y, h, w;
			cin >> x >> y >> h >> w;
			int v = x + y + h;
			int vrange = -1, wrange = -1, range = -1;

			for (j = 1; j < 8; ++j){
				if (volume[j-1] < v && v <= volume[j] ){
					vrange = j;
					break;
				} // end if
			} // end for

			for (k = 1; k < 8; ++k){
				if (wight[k-1] < w && w <= wight[k] ){
					wrange = k;
					break;
				} // end if
			} // end for
			range = max (vrange, wrange );
			
			if (range < 7 ){
				res += fee[range];
			} // end if
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

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

//比較用2次元配列
int wh_hako[6][2] = {{60 , 2},
					{80 , 5},
					{100 , 10},
					{120 , 15},
					{140 , 20},
					{160 , 25},};
//料金配列
int h_ryoukin[6] = {600 , 800 , 1000 , 1200 , 1400 , 1600};

typedef struct struct_data
{
	int tate;
	int yoko;
	int takasa;
	int omosa;
}S_data;

int main(void)
{
	int n = 0;
	//入力構造体
	S_data s_data = {0};

	while (1)
	{
		cin >> n;
		
		//合計金額
		int kane = 0;

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

		for (int i = 0; i < n; i++)
		{
			cin >> s_data.tate >> s_data.yoko >> s_data.takasa >> s_data.omosa;
			//長さの合計
			int length = s_data.tate + s_data.yoko + s_data.takasa;
			for (int j = 0; j < 6; j++)
			{
				//0が長さで1が重さ
				if (wh_hako[j][0] >= length && wh_hako[j][1] >= s_data.omosa)
				{
					kane += h_ryoukin[j];
					break;
				}
			}
		}

		cout << kane << endl;
	}
	return 0;
}

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

      else{
	price = 0;
      }

      total += price;
    }
    cout << total << endl;
    total = 0;
  }
}