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 "bits/stdc++.h"
using namespace std;

int main(){
    while(1){
        int n, x, y, h, w;
        long p=0;

        cin >> n;
        if(n==0) break;

        for(int i=0; i<n; ++i){
            scanf(" %d %d %d %d", &x, &y, &h, &w);

            int 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;
            else ;
        }

        printf("%ld\n", p);
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int sum=0;
		for(int i = 0; i < n; i++){
			int x,y,h,w;
			cin>>x>>y>>h>>w;
			int 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<=160&&w<=25){
				sum+=1600;
			}
		}
		cout<<sum<<endl;
	}

	return 0;
}

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 + y + 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 howManyCost(int size, int weight) {
    int res = 0;
    if (size <= 60 && weight <= 2) {
        res = 600;
    } else if (size <= 80 && weight <= 5) {
        res = 800;
    } else if (size <= 100 && weight <= 10) {
        res = 1000;
    } else if (size <= 120 && weight <= 15) {
        res = 1200;
    } else if (size <= 140 && weight <= 20) {
        res = 1400;
    } else if (size <= 160 && weight <= 25) {
        res = 1600;
    }
    return res;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            int x, y, h, w;
            cin >> x >> y >> h >> w;
            sum += howManyCost(x + y + h, w);
        }
        cout << sum << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int size[7] = {60, 80, 100, 120, 140, 160, INT_MAX};
int weig[7] = {2,  5,  10,  15,  20,  25,  INT_MAX};
int cost[7] = {600,800,1000,1200,1400,1600,0};

int main(){
  int n;
  while(cin>>n, n){
    int ans = 0;
    REP(i,n){
      int x,y,h,w,s,j=0;
      cin>>x>>y>>h>>w;
      s = x+y+h;
      while(s > size[j]) j++;
      while(w > weig[j]) j++;
      ans += cost[j];
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int fee = 0;
		rep(i, n){
			int x, y, h, w;
			scanf("%d%d%d%d", &x, &y, &h, &w);
			const int length[] = {60, 80, 100, 120, 140, 160};
			const int weights[] = {2, 5, 10, 15, 20, 25};
			const int fees[] = {600, 800, 1000, 1200, 1400, 1600, 0};
			fee += fees[max(lower_bound(length, length+6, x+y+h)-length, lower_bound(weights, weights+6, w)-weights)];
		}
		printf("%d\n", fee);
	}

	return 0;
}

C++: #include <iostream>

int getValue(int size, int w)
{
	int vs;
	if (size <= 60) vs = 0;
	else if (size <= 80) vs = 1;
	else if (size <= 100) vs = 2;
	else if (size <= 120) vs = 3;
	else if (size <= 140) vs = 4;
	else if (size <= 160) vs = 5;
	else vs = 6;
	int vw;
	if (w <= 2) vw =0;
	else if (w <= 5) vw = 1;
	else if (w <= 10) vw = 2;
	else if (w <= 15) vw = 3;
	else if (w <= 20) vw = 4;
	else if (w <= 25) vw = 5;
	else vw = 6;
	int v = std::max(vs, vw);
	switch (v) {
	case 0:
		return 600;
	case 1:
		return 800;
	case 2:
		return 1000;
	case 3:
		return 1200;
	case 4:
		return 1400;
	case 5:
		return 1600;
	default:
		return 0;
	}
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int res = 0;
		for (int i=0; i<n; i++) {
			int x, y, h, w;
			std::cin >> x >> y >> h >> w;
			res += getValue(x+y+h, w);
		}
		std::cout << res << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#define A  600
#define B  800
#define C 1000
#define D 1200
#define E 1400
#define F 1600
#define Z    0

using namespace std;

int rmn_max( int x, int y ){
  return x > y ? x : y;
}

int main(){
  int n;
  while( 1 ){
    cin >> n;
    if( !n ){ return 0; }
    int cost = 0;
    for( int i = 0; i < n; i++ ){
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      int ml = x + y + h;
      
      int lcost = A;
      if( ml > 160 ){
        lcost = Z;
      }else if( ml > 140 ){
        lcost = F;
      }else if( ml > 120 ){
        lcost = E;
      }else if( ml > 100 ){
        lcost = D;
      }else if( ml > 80 ){
        lcost = C;
      }else if( ml > 60 ){
        lcost = B;
      }else{
        lcost = A;
      }
      if( lcost == Z ||  w > 25 ){
        lcost = Z;
      }else if( w > 20 ){
        lcost = rmn_max( F, lcost );
      }else if( w > 15 ){
        lcost = rmn_max( E, lcost );
      }else if( w > 10 ){
        lcost = rmn_max( D, lcost );
      }else if( w > 5 ){
        lcost = rmn_max( C, lcost );
      }else if( w > 2 ){
        lcost = rmn_max( B, lcost );
      }else{
        lcost = rmn_max( A, lcost );
      }
      cost += lcost;
    }
    cout << cost << endl;
  }
}