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 <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int SIZE = 1000000;
int X[SIZE], Y[SIZE], H[SIZE], W[SIZE];
int n;

long long solve() {
    long long res = 0;
    for ( int i = 0; i < n; ++ i ) {
        int s = X[i] + Y[i] + H[i];
        if ( s <= 60 && W[i] <= 2 ) {
            res += 600;
        } else if ( s <= 80 && W[i] <= 5 ) {
            res += 800;
        } else if ( s <= 100 && W[i] <= 10 ) {
            res += 1000;
        } else if ( s <= 120 && W[i] <= 15 ) {
            res += 1200;
        } else if ( s <= 140 && W[i] <= 20 ) {
            res += 1400;
        } else if ( s <= 160 && W[i] <= 25 ) {
            res += 1600;
        }
    }
    return res;
}

int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < n; ++ i ) {
            cin >> X[i] >> Y[i] >> H[i] >> W[i];
        }
        cout << solve() << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    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 large = x + y + h;
            if(large <= 60 and w <= 2) sum += 600;
            else if(large <= 80 and w <= 5) sum += 800;
            else if(large <= 100 and w <= 10) sum += 1000;
            else if(large <= 120 and w <= 15) sum += 1200;
            else if(large <= 140 and w <= 20) sum += 1400;
            else if(large <= 160 and w <= 25) sum += 1600;
        }
        cout << sum << endl;
    }
    return 0;
}

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;
	int 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 = 1400;
	    else if(s > 120) m = 1200;
	    else if(s > 100) m = 1000;
	    else if(s > 80) 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<stdio.h>
int main(void)
{
	int n,x[10000],y[10000],h[10000],w[10000],i,a;
	long long z;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		z=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&x[i],&y[i],&h[i],&w[i]);
			a=x[i]+y[i]+h[i];
			if(w[i]<3 && a<61) z=z+600;
			else if(w[i]<6 && a<81) z=z+800;
			else if(w[i]<11 && a<101) z=z+1000;
			else if(w[i]<16 && a<121) z=z+1200;
			else if(w[i]<21 && a<141) z=z+1400;
			else if(w[i]<26 && a<161) z=z+1600;
		}
		printf("%lld\n",z);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int t[6]={60,80,100,120,140,160};
int u[6]={2,5,10,15,20,25};
int v[7]={600,800,1000,1200,1400,1600,0};
int n;
int x,y,h,w;

int check_t(int x){
  for(int i=0;i<6;i++){
    if(x<=t[i])return i;
  }
  return 6;
}
int check_u(int x){
  for(int i=0;i<6;i++){
    if(x<=u[i])return i;
  }
  return 6;
}




int main(){
  int sum;
  while(cin>>n&&n){
    sum=0;
    for(int i=0;i<n;i++){
      cin>>x>>y>>h>>w;
      sum+=v[max(check_t(x+y+h),check_u(w))];
    }
    cout<<sum<<endl;
  }
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, x, y, h, w;

  while(1) {
    cin >> n;
    if(!n) break;

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

C++: //32
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int ans=0;
    while(n--){
      int s[]={60,80,100,120,140,160};
      int wt[]={2,5,10,15,20,25};
      int p[]={600,800,1000,1200,1400,1600,0};
      int x,y,h,w;
      cin>>x>>y>>h>>w;
      ans+=p[max(lower_bound(s,s+6,x+h+w)-s,lower_bound(wt,wt+6,w)-wt)];
    }
    cout<<ans<<endl;
  }
  return 0;
}