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>

using namespace std;

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

	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a[7]={160,140,120,100,80,60,0};
int b[7]={25,20,15,10,5,2,0};
int c[7]={0,1600,1400,1200,1000,800,600};
int n;
while(cin>>n,n){
int sum=0;
rep(i,n){
int x,y,h,w;
cin>>x>>y>>h>>w;
rep(j,7)if(x+y+h>a[j]||w>b[j]){sum+=c[j];break;}
}
cout<<sum<<endl;
}
}

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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int sum=0;
      for(int i=0;i<n;i++)
	{
	  int x,y,h,w;
	  cin>>x>>y>>h>>w;
	  int size=x+y+h;
	  if(size<61&&w<3)
	    sum+=600;
	  else if(size<81&&w<6)
	    sum+=800;
	  else if(size<101&&w<11)
	    sum+=1000;
	  else if(size<121&&w<16)
	    sum+=1200;
	  else if(size<141&&w<21)
	    sum+=1400;
	  else if(size<161&&w<25)
	    sum+=1600;
	}
      cout<<sum<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int x, y, h, w, n, sum, z;
int a[7] = { 60,80,100,120,140,160,1000000000 };
int b[7] = { 2,5,10,15,20,25,1000000000 };
int c[7] = { 600,800,1000,1200,1400,1600,0 };
int main() {
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		sum = 0;
		for (int i = 0; i < n; i++){
			cin >> x >> y >> h >> w;
			z = x + y + h;
			for (int j = 0; j < 7; j++) {
				if (z <= a[j] && w <= b[j]) { sum += c[j]; break; }
			}
		}
		cout << sum << endl;
	}
}

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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		ll ans=0;
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			int M=a+b+c;
			if(160<M||d>25) continue;
			if(140<M||d>20) ans+=1600;
			else if(120<M||d>15) ans+=1400;
			else if(100<M||d>10) ans+=1200;
			else if(80<M||d>5) ans+=1000;
			else if(60<M||d>2) ans+=800;
			else ans+=600;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main(){
	while(true){
		int n,x,y,h,w,ans=0;
		cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			cin >> x >> y >> h >> w;
			x += y+h;
			ans += 600;
			if(x>60 || w>2)
				ans += 200;
			if(x>80 || w>5)
				ans += 200;
			if(x>100 || w>10)
				ans += 200;
			if(x>120 || w>15)
				ans += 200;
			if(x>140 || w>20)
				ans += 200;
			if(x>160 || w>25)
				ans -= 1600;
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

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

int main() {
	while (true) {
		int n, ans = 0;
		cin >> n;
		if (n == 0) break;

		REP(i, n) {
			int x, y, h, w;
			scanf("%d %d %d %d", &x, &y, &h, &w);

			int s = x + y + h;
			int size1 = ceil((s - 60) / 20.0);
			if (size1 > 5) continue;
			if (size1 < 0) size1 = 0;

			int dw[] = {2, 5, 10, 15, 20, 25};
			int size2 = 0;
			REP(i, 6) if (w > dw[i]) size2++;
			if (size2 > 5) continue;

			ans += 600 + 200*max(size1, size2);
		}
		cout << ans << endl;
	}
	return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		long long ans = 0;
		int x,y,h,w;

		rep(i,n)
		{
			cin >> x >> y >> h >> w;

			int a = x + y + h;

			if(20 < w && w <= 25 && a <= 160) ans += 1600;
			else if(15 < w && a <= 140) ans += 1400;
			else if(10 < w && a <= 120) ans += 1200;
			else if(5 < w && a <= 100) ans += 1000;
			else if(2 < w && a <= 80) ans += 800;
			else if(a <= 60) ans += 600;
		}

		cout << ans << endl;
	}
	return 0;
}

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

C++: #include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n;
  while (cin >> n, n) {
    int x, y, h, w, l;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> h >> w;
      l = x + y + h;

      if (l <= 60 && w <= 2) ans += 600;
      else if (l <= 80 && w <= 5) ans += 800;
      else if (l <= 100 && w <= 10) ans += 1000;
      else if (l <= 120 && w <= 15) ans += 1200;
      else if (l <= 140 && w <= 20) ans += 1400;
      else if (l <= 160 && w <= 25) ans += 1600;
    }

    cout << ans << endl;
  }

  return 0;
}