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++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


int main(){
	int n;
	while(cin>>n,n){
		int ans = 0;
		FOR(i,n){
			int x,y,h,w; cin>>x>>y>>h>>w;
			int len = x+y+h;
			int a = max(0,min((len-1)/20 - 2,6));
			int b = min(6,((w-1)/5+1) * (w>=3));
		  if(max(a,b)!=6)ans += 600+200*max(a,b);
		}
		cout << ans << endl;

	}

	return 0;
}

C++: /*
	0160:Delivery Fee
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int n, sum = 0;
		
		cin >> n;
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			int x, y, h, w;
			int l;
			
			cin >> x >> y >> h >> w;
			
			l = x + y + h;
			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 <= 60 && w <= 25) { sum += 1600; }
		}
		
		cout << sum << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,i,x,y,h,w,s,p;
while(cin>>n){
if(n==0)break;
p=0;
for(i=0;i<n;i++){
cin>>x>>y>>h>>w;
s=x+y+h;
if(s<=60&&w<=2)p+=600;
else if(s<=80&&w<=5)p+=800;
else if(s<=100&&w<=10)p+=1000;
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 <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	const array<int, 6>
		S{60, 80, 100, 120, 140, 160},
		W{2, 5, 10, 15, 20, 25},
		F{600, 800, 1000, 1200, 1400, 1600};
	auto lb {[](auto &o, int n) {return lower_bound(begin(o), end(o), n);}};
	for (int n; (n = in());) {
		int f{};
		while (n--) {
			auto s{lb(S, in() + in() + in())}, w{lb(W, in())};
			if (s != end(S) && w != end(W))
				f += F[max(s - begin(S), w - begin(W))];
		}
		outl(f);
	}
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int ans = 0;
        rep(i,n){
            int x, y, h, w;
            int size = 100, hevy = 100;
            cin >> x >> y >> h >> w;
            rep(i,6){
                int cm = 60 + 20 * i;
                if(x <= cm || y <= cm || h <= cm){
                    size = i;
                    break;
                }
            }
            rep(i,6){
                if(w <= 2){
                    hevy = 0;
                    break;
                }else if(w <= i * 5){
                    hevy = i;
                    break;
                }
            }
            int money = max(size, hevy) ;
            rep(i,6){
                if(money == 100) break;
                if(money == i){
                    ans+= 600 + 200 * i;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

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

C++: #include <iostream>

using namespace std;

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

int main(int argc, char **argv)
{
	long long int w, x, y, z, n, sum;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		sum = 0;
		for(int i = 0; i < n; i++){
			cin >> x >> y >> z >> w;
			
			x = (x > y && x > z)? x : ((y > x && y > z)? y : z);
			if(w > 25 || x > 160){
				continue;
			}
			
			y = z = 0;
			for(int i = 0; i < 6; i++){
				if(x <= sc[i]){
					y = i;
					break;
				}
			}
			
			for(int i = 0; i < 6; i++){
				if(w <= we[i]){
					z = i;
					break;
				}
			}
			
			sum += cost[((y < z)? z : y)];
		}
		cout << sum << endl;
	}
	
	return 0;
}