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 p[7][7] = {
		{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}
};
int d[7][7] = {
		{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}
};

int main () {
	int a, b;
	while (cin >> a, a) {
		int h, m;
		bool half = false;
		cin >> h >> m;
		int s = h * 60 + m;
		if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
		cin >> b;
		cin >> h >> m;
		s = h * 60 + m;
		if (17 * 60 + 30 <= s && s <= 19 * 60 + 30) half = true;
		a--, b--;
		int price = p[a][b];
		int dist = d[a][b];
		if (dist <= 40 && half) price /= 2;
		cout << price + (price % 50) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#define NN 1000
using namespace std;

int main(){
  int aa[7][7]={ {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}};
int bb[7][7]={ {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}};

  int i,j,n,time00,time01,time10,time11,n2,disc,mo;
  int disc2;
  while(1){
    disc2=0;
    disc=0; //flag
    cin >> n;
    if(n == 0)break;
    cin >> time00 >> time01;
    cin >> n2;
    cin >> time10 >> time11;

   
      if(time10 == 19 && time11 <= 30){disc2=1;}
      else if(time10 == 18)disc2=1;
      else if(time10 == 17 && time11>=30)disc2=1;
      if(bb[n2-1][n-1]<=40 && disc2==1)disc=1; //ツ湘ーツ個渉づーツ鳴楪つスツつオツづつ「ツづェツづ仕iscountツフツδ可グON
   

    mo=aa[n-1][n2-1];
    if(disc == 1){
      mo=mo/2;
      disc=0;
      disc2=0;
       if(mo%50 !=0)mo=(mo-(mo%50))+50;
    }
    cout << mo << endl;


    }


}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int start,startt[2],end,endt[2];
	while(1){
		cin>>start;
		if(start==0)break;
		cin>>startt[0]>>startt[1];
		cin>>end>>endt[0]>>endt[1];
		int ans;
		if(start==1){
			if(end==2)ans=300;
			else if(end==3)ans=500;
			else if(end==4)ans=600;
			else if(end==5)ans=700;
			else if(end==6)ans=1350;
			else if(end==7)ans=1650;
		}else if(start==2){
			if(end==3)ans=350;
			else if(end==4)ans=450;
			else if(end==5)ans=600;
			else if(end==6)ans=1150;
			else if(end==7)ans==1500;
		}else if(start==3){
			if(end==4)ans=250;
			else if(end==5)ans=400;
			else if(end==6)ans=1000;
			else if(end==7)ans=1350;
		}else if(start==4){
			if(end==5)ans=250;
			else if(end==6)ans=850;
			else if(end==7)ans=1300;
		}else if(start==5){
			if(end==6)ans=600;
			else if(end==7)ans=1150;
		}else if(start==6){
			if(end==7)ans=500;
		}
		if(((startt[0]*60+startt[1])>=(17*60+30) && (startt[0]*60+startt[1])<=(19*60+30)) || ((endt[0]*60+endt[1])>=(17*60+30) && (endt[0]*60+endt[1])<=(19*60+30))){
			if((start==1 && end==6) || (end==7 &&(start>0 &&start<4))){	
				cout<<ans<<endl;
			}else{
				int reans=ans/2;
				int alt=reans%50;
				if(alt>0){
					reans+=(50-alt);
				}
				cout<<reans<<endl;
			}
		}else{
			cout<<ans<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int mat1[7][7]={{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}};
  int mat2[7][7]={{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}};
  int j,k,d,a,md[10000],hd[10000],ma[10000],ha[10000],fare[10000];
  for(j=0;j>=0;j++){
    cin >> d;
    if(d == 0)
      break;
    cin >> hd[j] >> md[j];
    cin >> a;
    if(a == 0)
      break;
    cin >> ha[j] >> ma[j];
    fare[j] = mat2[d-1][a-1];
    if(100*hd[j]+md[j]<=1930 && 100*hd[j]+md[j]>=1730 || 100*ha[j]+ma[j]<=1930 && 100*ha[j]+ma[j]>=1730){
      if(mat1[d-1][a-1] <=40){
      fare[j] = fare[j]/2;
      if(fare[j]%10 == 5)
	fare[j] += 25;
      }}
  }
  for(k=0;k<=j;k++)
    cout << fare[k] << endl;
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#define S 1050 //1050min = 17:30 //
#define G 1170 //1170min = 19:30 //
using namespace std;
int kiriage(int);
int main(){
	int tmp[7][7]={{0,300,500,600,700,1350},
				{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 sIC,sh,sm,gIC,gh,gm,smin,gmin,cost;
	while(cin >> sIC && sIC){
		cin >> sh >> sm >> gIC >> gh >> gm;
		smin = sh * 60 + sm;
		gmin = gh * 60 + gm;
		if(sIC>gIC)swap(sIC,gIC);
		cout << ((((smin >= S && smin <= G) || (gmin >= S && gmin <= G)) && tmp[gIC-1][sIC-1]<=40) ?
			 		kiriage(tmp[sIC-1][gIC-1]/2) : tmp[sIC-1][gIC-1]) << endl;
	}
}
int kiriage(int cost){
	return (cost%50==0?cost:cost/50*50+50);
}