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<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int C = 6;

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

int main()
{
    int n;
    int x, y, h , w, c;
    while(cin >> n && n)
    {
        long long ans = 0;
        REP(n)
        {
            cin >> x >> y >> h >> w;
            c = 0;
            h = h + x + y;
            rep(j,C)if( h <= sl[j] && w <= wl[j]){ c = cost[j]; break;}

            ans += c;
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

enum size{
    A,B,C,D,E,F,X
};
typedef long long ll;
ll solve(int n){
    ll some = 0;
    for(int i=0;i<n;i++){
        int x,y,h,w;
        size sis = X;
        size siw = X;
        cin >> x >> y >> h >> w;
        int s = x+y+h;
        if(s <= 160) sis = F;
        if(s <= 140) sis = E;
        if(s <= 120) sis = D;
        if(s <= 100) sis = C;
        if(s <= 80) sis = B;
        if(s <= 60) sis = A;

        if(w <= 25) siw = F;
        if(w <= 20) siw = E;
        if(w <= 15) siw = D;
        if(w <= 10) siw = C;
        if(w <= 5) siw = B;
        if(w <= 2) siw = A;

        size sss = max(siw,sis);
        switch(sss){
        case X:
            break;
        case F:
            some += 1600;
            break;
        case E:
            some += 1400;
            break;
        case D:
            some += 1200;
            break;
        case C:
            some += 1000;
            break;
        case B:
            some += 800;
            break;
        case A:
            some += 600;
            break;
        }
    }
    return some;
}

int main(){
    int n;
    while(cin >> n && n != 0) cout << solve(n) << endl;
}

C++: #include <iostream>

using namespace std;

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

int main(int argc, char **argv)
{
	int w, x, y, z, n, sum;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		sum = 0;
		for(int i = 0; i < n; i++){
			cin >> x >> y >> z >> w;
			
			x = (x > y && x > z)? x : ((y > x && y > z)? y : z);
			if(w > 25 || x > 160){
				continue;
			}
			
			y = z = 0;
			for(int i = 0; i < 6; i++){
				if(x <= sc[i]){
					y = i;
					break;
				}
			}
			
			for(int i = 0; i < 6; i++){
				if(w <= we[i]){
					z = i;
					break;
				}
			}
			
			sum += cost[((y < z)? z : y)];
		}
		cout << sum << endl;
	}
	
	return 0;
}

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

int delivery_fee(int x, int y, int h, int w){
	if((x+y+h <= 60) && (w <= 2))
		return 600;
	else if((x+y+h <= 80) && (w <= 5))
		return 800;
	else if((x+y+h <= 100) && (w <= 10))
		return 1000;
	else if((x+y+h <= 120) && (w <= 15))
		return 1200;
	else if((x+y+h <= 140) && (w <= 20))
		return 1400;
	else if((x+y+h <= 160) && (w <= 25))
		return 1600;
	else
		return 0;
}

int main(){
	while(1){
		int n, x, y, h, w, price = 0;
		cin>>n;

		if(n == 0)
			break;

		for(int i=0;i<n;i++){
			cin>>x>>y>>h>>w;
			price += delivery_fee(x, y, h, w);
		}

		cout<<price<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  int n,a[3],b,cnt,j;
  int sum;
  int tmpr[]={600,800,1000,1200,1400,1600,0};
  int tmpb[]={60,80,100,120,140,160,0};
  int tmpw[]={2,5,10,15,20,25,0};
  while(1){
    cin >> n;
    if(n==0)break;
    cnt=0;
    for(int i=0;i<n;i++){
      cin >> a[0] >> a[1] >> a[2] >> b;
      j=0;
      for(int flg=0;j<6;j++,flg=0){
	for(int k=0;k<3;k++){
	  if(tmpb[j]<a[k]){
	    flg=1;
	  }
	}
	if(tmpw[j]<b) flg=1;

	if(flg==0) break;
      }
      cnt += tmpr[j];
    }
    cout << cnt << endl;
  }
}

C++: #include<stdio.h>

int mian(void){
	int x,y,z,w,n,i;
	int sum,l;

	while(scanf("%d",&n)!=0){
		sum=0;
		for(i=0;i<n;i++){
		  scanf("%d %d %d %d",&x,&y,&z,&w);
		  l=x+y+z;
		  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;
		}
		printf("%d\n",sum);
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int C[] = { 600,800,1000,1200,1400,1600 };
	int XYH[] = { 60,80,100,120,140,160 };
	int W[] = { 2,5,10,15,20,25 };
	for (int n; cin >> n&&n;) {
		int ans = 0;
		rep(i, 0, n) {
			int x, y, h, w; cin >> x >> y >> h >> w;
			rep(j, 0, 6) {
				if (XYH[j] >= x + y + h&&W[j] >= w) {
					ans += C[j];
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int cost[] = {600, 800, 1000, 1200, 1400, 1600};

int main()
{
    int n;

    while (cin >> n, n) {
        int size[6];
        int x, y, h, w;
        long long ans = 0;


        for (int i = 0; i < 6; i++)
            size[i] = 0;

        for (int i = 0; i < n; i++) {
            cin >> x >> y >> h >> w;
            
            x += y + h;
            if (x <= 60 && w <= 2)
                size[0]++;
            else if (x <= 80 && w <= 5)
                size[1]++;
            else if (x <= 100 && w <= 10)
                size[2]++;
            else if (x <= 120 && w <= 15)
                size[3]++;
            else if (x <= 140 && w <= 20)
                size[4]++;
            else if (x <= 160 && w <= 25)
                size[5]++;
        }
        for (int i = 0; i < 6; i++)
            ans += cost[i] * size[i];
        cout << ans << endl;
    }
    
    return 0;
}