Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	distance_table := [][]int{
		{0, 6, 13, 18, 23, 43, 58},
		{6, 0, 7, 12, 17, 37, 52},
		{13, 7, 0, 5, 10, 30, 45},
		{18, 12, 5, 0, 5, 25, 40},
		{23, 17, 10, 5, 0, 20, 35},
		{43, 37, 30, 25, 20, 0, 15},
		{58, 52, 45, 40, 35, 15, 0},
	}
	toll_table := [][]int{
		{0, 300, 500, 600, 700, 1350, 1650},
		{300, 0, 350, 450, 600, 1150, 1500},
		{500, 350, 0, 250, 400, 1000, 1350},
		{600, 450, 250, 0, 250, 850, 1300},
		{700, 600, 400, 250, 0, 600, 1150},
		{1350, 1150, 1000, 850, 600, 0, 500},
		{1650, 1500, 1350, 1300, 1150, 500, 0},
	}
	for scanner.Scan() {
		d, _ := strconv.Atoi(scanner.Text())
		if d == 0 {
			break
		}
		d--
		scanner.Scan()
		dbuf := strings.Split(scanner.Text(), " ")
		dh, _ := strconv.Atoi(dbuf[0])
		dm, _ := strconv.Atoi(dbuf[1])
		dtime := 100*dh+dm
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		a--
		scanner.Scan()
		abuf := strings.Split(scanner.Text(), " ")
		ah, _ := strconv.Atoi(abuf[0])
		am, _ := strconv.Atoi(abuf[1])
		atime := 100*ah+am
		toll := toll_table[d][a]
		if distance_table[d][a] <= 40 &&
			1730 <= dtime && dtime <= 1930 ||
			1730 <= atime && atime <= 1930 {
				toll = ((toll/2-1)/50+1)*50
		}
		fmt.Println(toll)
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int discount[2]={17*60+30,19*60+30};
	int D[7]={0,6,13,18,23,43,58};
	int C[7][7]={
		{0,300,500,600,700,1350,1650},
		{0,0,350,450,600,1150,1500},
		{0,0,0,250,400,1000,1350},
		{0,0,0,0,250,850,1300},
		{0,0,0,0,0,600,1150},
		{0,0,0,0,0,0,500},
	};
	int in,out;
	while(cin>>in,in){
		int h1,m1,h2,m2,fare;
		cin>>h1>>m1;
		cin>>out;
		cin>>h2>>m2;
		if(in>out){
			int tmp=in;
			in=out;
			in=tmp;
		}
		int d=D[out-1]-D[in-1];
		int min1=h1*60+m1;
		int min2=h2*60+m2;
		if((discount[0]<=min1&&min1<=discount[1])||(discount[0]<=min2&&min2<=discount[1])&&d<=40) fare=(C[in-1][out-1]/2+25)/50*50;
		else fare=C[in-1][out-1];
		cout<<fare<<endl;
	}
	return 0;
}

C++: #include <iostream>
#define rng(z) (1050 <= z && z <= 1170)
using namespace std;
int a, b, t1, t2, p, q;
int x[7][7] = {
	{0, 300, 500, 600, 700, 1350, 1650},
	{6, 0, 350, 450, 600, 1150, 1500},
	{13, 7, 0, 250, 400, 1000, 1350},
	{18, 12, 5, 0, 250, 850, 1300},
	{23, 17, 10, 5, 0, 600, 1150},
	{43, 37, 30, 25, 20, 0, 500},
	{58, 52, 45, 40, 35, 15, 0}
};
int main() {
	while (cin >> a, a) {
		cin >> p >> q; t1 = p * 60 + q; a--;
		cin >> b >> p >> q; t2 = p * 60 + q; b--;
		if (a > b) swap(a, b);
		int cost = x[a][b], dist = x[b][a];
		if (dist <= 40 && (rng(t1) || rng(t2))) cost /= 2;
		cost = (cost + 49) / 50 * 50;
		cout << cost << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
	int start,finish;
	while(cin>>start,start){
		int time[2][2];
		for(int i=0;i<2;i++)cin>>time[0][i];
		cin>>finish;
		for(int i=0;i<2;i++)cin>>time[1][i];
		int num=0,distance[]={6,7,5,5,20,15},money[6][6]={{300,500,600,700,1350,1650},{350,450,600,1150,1500},{250,400,1000,1350},{250,850,1300},{600,1150},{500}};
		for(int i=start-1;i<finish;i++)num+=distance[i];
		bool kawa=0;
		for(int i=0;i<2&&!kawa&&num<41;i++)if(time[i][0]==18||time[i][0]==17&&time[i][1]>29||time[i][0]==19&&time[i][1]<31)kawa=1;
		num=money[start-1][finish-start-1];
		if(kawa){
			num/=2;
			if(num%100==25)num+=25;
		}
		cout<<num<<endl;
	}
}

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

#define MAX 1000000

int main()
{
	int i, j, k;
	vector< vector<int> > distance(8, vector<int>(8));
	vector< vector<int> > fee(8, vector<int>(8));
	fee[1][2] = 200;
	fee[1][3] = 500;
	fee[1][4] = 600;
	fee[1][5] = 700;
	fee[1][6] = 1350;
	fee[1][7] = 1650;
	fee[2][3] = 350;
	fee[2][4] = 450;
	fee[2][5] = 600;
	fee[2][6] = 1150;
	fee[2][7] = 1500;
	fee[3][4] = 250;
	fee[3][5] = 400;
	fee[3][6] = 1000;
	fee[3][7] = 1350;
	fee[4][5] = 250;
	fee[4][6] = 850;
	fee[4][7] = 1300;
	fee[5][6] = 600;
	fee[5][7] = 1150;
	fee[6][7] = 500;
	distance[1][2] = 6;
	distance[1][3] = 13;
	distance[1][4] = 18;
	distance[1][5] = 23;
	distance[1][6] = 42;
	distance[1][7] = 58;
	distance[2][3] = 7;
	distance[2][4] = 12;
	distance[2][5] = 17;
	distance[2][6] = 37;
	distance[2][7] = 52;
	distance[3][4] = 5;
	distance[3][5] = 10;
	distance[3][6] = 30;
	distance[3][7] = 40;
	distance[4][5] = 5;
	distance[4][6] = 25;
	distance[4][7] = 40;
	distance[5][6] = 20;
	distance[5][7] = 35;
	distance[6][7] = 15;

	int s, e, h, m;
	int timeStart = 17*60+30;
	int timeEnd = 19*60+30;
	int r;
	bool f;
	while (cin>>s, s) {
		f = false;
		cin>>h>>m;
		if (timeStart <= h*60+m && h*60+m <= timeEnd) f = true;
		cin>>e>>h>>m;
		if (timeStart <= h*60+m && h*60+m <= timeEnd) f = true;
		r = fee[s][e];
		if (f && distance[s][e]<=40) {
			r /= 2;
			if (r%50) {
				r += 25;
				r /= 50;
				r *= 50;
			}
		}
		cout<<r<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int dist[7][7] = { {0,0,0,0,0,0,0},{6,0,0,0,0,0,0},{13,7,0,0,0,0,0},{18,12,5,0,0,0,0},{23,17,10,5,0,0,0},{43,37,30,25,20,0,0},{58,52,45,40,35,15,0} };
int money[7][7] = { {0,300,500,600,700,1350,1650},{0,0,300,450,600,1150,1500},{0,0,0,250,400,1000,1350},{0,0,0,0,250,850,1300},{0,0,0,0,0,600,1150},{0,0,0,0,0,0,500} };
int a, b, c, d, e, f;
int main() {
	while (true) {
		cin >> a; if (a == 0) { break; }cin >> b >> c >> d >> e >> f; b = b * 60 + c; e = e * 60 + f; a--; d--;
		for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (dist[i][j] == 0) { dist[i][j] = dist[j][i]; }if (money[i][j] == 0) { money[i][j] = money[j][i]; } } }
		if (((b >= 1050 && b <= 1170) || (e >= 1050 && e <= 1170)) && dist[a][d] <= 40) { if (money[a][d] % 100 == 0) { cout << money[a][d] / 2 << endl; } else { cout << money[a][d] / 2 + 25 << endl; } }
		else { cout << money[a][d] << endl; }
	}
}

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

double h(int h, int m) {
  return h + (double)m / 60;
}

int main() {
  int base[8][8] = {{0,0,0,0,0,0,0,0},
		    {0,0, 300,500,600,700,1350,1650},
		    {0,6, 0,  350,450,600,1150,1500},
		    {0,13,7,  0,  250,400,1000,1350},
		    {0,18,12, 5,  0,  250,850, 1300},
		    {0,23,17, 10, 5,  0,  600, 1150},
		    {0,43,37, 30, 25, 20, 0,   500},
		    {0,58,52, 45, 40, 35, 15,  0}};


  while(1) {
    int s, g;
    int sh, sm;
    int gh, gm;
    cin >> s;
    if(s == 0) break;
    cin >> sh >> sm;
    cin >> g;
    cin >> gh >> gm;

    if(s > g) {
      int temp = s;
      s = g;
      g = temp;
    }
    bool half = false;
    if(h(sh,sm) >= h(17,30) && h(sh,sm) <= h(19,30) && base[g][s] <= 40) {
      half = true;
    }
    else if(h(gh,gm) >= h(17,30) && h(gh,gm) <= h(19,30) && base[g][s] <= 40) {
      half = true;
    }
    if(half) {
      int tmp = (base[s][g] / 2 +50) / 50 * 50;
      cout << tmp << endl;
    } else {
      cout << base[s][g] << endl;
    }
  }
  return 0;
}