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(){
    while (1) {
        int n;
        cin>>n;
        if(n==0)break;
        int x,y,h,w;
        int ans=0;
        for (int i=0; i<n; i++) {
            cin>>x>>y>>h>>w;
            int a=x+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;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main() {
 int n,x,y,z,w,i,a,c;
 while(cin >> n) {
	 if (n==0) break;
 c=0;
 for (;n>0;n--) {
 cin >> x >> y >> z >> w;
	 x=x+y+z;
	 for (i=0;i<6;i++) {
		 a=i==0 ? 2 : i*5;
		 if (w<=a && x<=60+i*20) { c+=600+i*200; break; }
	 }
 }
	 cout << c << endl;
 }
 return 0;
 }

C++: #include<iostream>

typedef long long ll;

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		ll ans = 0;
		while( n-- )
		{
			int x, y, h, w;
			std::cin >> x >> y >> h >> w;

			int sz = x + y + h;

			for( int i = 0; i != 6; ++i )
			{
				if( sz <= 60 + i * 20 && w <= ( i ? i * 5 : 2 ) )
				{
					ans += 600 + i * 200;
					break;
				}
			}
		}

		std::cout << ans << std::endl;
	}

	return 0;
}

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

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct P {
  int s, w;
  P() {}
  P(int s, int w) : s(s), w(w) {}
  bool operator <= (const P& a) {
    return s <= a.s && w <= a.w;
  }
};

const vector<P> v = {{60, 2}, {80, 5}, {100, 10}, {120, 15}, {140, 20}, {160, 25}};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;
      P p(x + y + h, w);
      for (int j = 0; j < 6; j++) {
        if (p <= v[j]) {
          ans += v[j].s * 10;
          break;
        }
      }
    }
    cout << ans << 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;
		while(n--){
			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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
static const int dw[6] = {2,5,10,15,20,25};
static const int dl[6] = {60,80,100,120,140,160};
static const int dm[6] = {600,800,1000,1200,1400,1600};
int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    int ans=0;
    REP(i,n){
      int x,y,h,w,l;
      cin>>x>>y>>h>>w;
      l = x+y+h;
      REP(i,6){
        if(l<=dl[i]&&w<=dw[i]){
          ans+=dm[i];
          break;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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){
		int ans=0;
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			int M=a;
			M=max(M,max(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 <bits/stdc++.h>
using namespace std;

int main() {
  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 s = x + y + h;
      if(s <= 60 && w <= 2) sum += 600;
      else if(s <= 80 && w <= 5) sum += 800;
      else if(s <= 100 && w <= 10) sum += 1000;
      else if(s <= 120 && w <= 15) sum += 1200;
      else if(s <= 140 && w <= 20) sum += 1400;
      else if(s <= 160 && w <= 25) sum += 1600;
    }
    cout << sum << endl;
  }
  return 0;
}

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

int main(){

  int n;

  while(cin >> n, n){
    int ans = 0,a,b,c,d;

    for(long int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
      a += b + c;

      if(a > 160 || d > 25);
      else if(a > 140 || d > 20) ans += 1600;
      else if(a > 120 || d > 15) ans += 1400;
      else if(a > 100 || d > 10) ans += 1200;
      else if(a > 80 || d > 5) ans += 1000;
      else if(a > 60 || d > 2) ans += 800;
      else ans += 600;

    }

    cout << ans << endl;
  }
}