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 <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

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

int main() {
	for(int N; scanf("%d", &N), N;) {
		long long 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;
			int index_size = lower_bound(size_list, size_list + 6, size) - size_list;
			int index_weight = lower_bound(size_weight, size_weight + 6, w) - size_weight;
			int index = max(index_size, index_weight);
			if(index < 6) sum += cost[index];
		}

		printf("%lld\n", sum);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;++i)
#define R(i,a,n) for(int i=a;i>=n;i--)
using namespace std;
int main(){
    int n,a,b,c,w;
	while(cin>>n,n){
		long int p=0;
		r(i,0,n){
		cin>>a>>b>>c>>w;
		int 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;else;
	    }
	    cout<<p<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y,h,w,a;
	while(cin>>n,n){
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>x>>y>>h>>w;
			int a=max(x,max(y,h));
			if(a<=60&&w<=2)ans+=600;
			else if(a<=80&&w<=5)ans+=800;
			else if(a<=100&&w<=10)ans+=1000;
			else if(a<=120&&w<=15)ans+=1200;
			else if(a<=140&&w<=20)ans+=1400;
			else if(a<=160&&w<=25)ans+=1600;
		}
		cout<<ans<<endl;
	}
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        int ans=0;
        rep(i,n){
            int rize,syaro,tiya,tino;
            cin>>rize>>syaro>>tiya>>tino;
            tiya+=rize+syaro;
            if(tiya<=60&&tino<=2)
                ans+=600;
            else if(tiya<=80&&tino<=5)
                ans+=800;
            else if(tiya<=100&&tino<=10)
                ans+=1000;
            else if(tiya<=120&&tino<=15)
                ans+=1200;
            else if(tiya<=140&&tino<=20)
                ans+=1400;
            else if(tiya<=160&&tino<=25)
                ans+=1600;
        }
        cout<<ans<<endl;
    }
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int x) {
  return (x > 60) + (x > 80) + (x > 100) + (x > 120) + (x > 140) + (x > 160);
}

int g(int x) {
  return (x > 2) + (x > 5) + (x > 10) + (x > 15) + (x > 20) + (x > 25);
}

void solve() {
  int n;
  while (cin >> n, n) {
    int c = 0;
    rep(i, n) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      int r = max(f(x + y + h), g(w));
      if (r <= 5) c += r * 200 + 600;
    }
    cout << c << endl;
  }
}

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

int main(){
  int i,j,k,l,m,n,x,y,h,w,sum;
  int ans;
 

  
  while(1){
    ans=0;
    sum=0;
    cin >> n;
    if(n == 0)break;

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

	
	 if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
 else if(w<=25){



	if(sum<=160)ans+=1600;
	else ans+=0;
      }




    }
    cout << ans << endl;



  }