#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

#define VD	void
#define U4	unsigned int
#define S4	int
#define U1	unsigned char
#define MAX_INPUT_ROW	(100)
#define MAX_INPUT_COLUMN	(100)	

#define	TRUE	(1)
#define FALSE	(0)

S4 s4_d_inputNode(S4 s4_ap_arrInputNode[MAX_INPUT_COLUMN][MAX_INPUT_ROW]);
S4 s4_d_calcNodeCost(S4 s4_ap_arrInputNode[MAX_INPUT_COLUMN][MAX_INPUT_ROW], S4 s4_a_numColumn);

S4 main()
{
	/* ?????¢????????????????§???£?????¨????????????????????????????????????????????§???????????? */
	S4 s4_tp_arrInputNode[MAX_INPUT_COLUMN][MAX_INPUT_ROW] = { 0 };		/* ??\??????????????????????????´??°???????´????????????? */
	S4 s4_t_cntColumn;
	S4 s4_t_maxCost;

	/* ??????????????´??°??\??? */
	s4_t_cntColumn = s4_d_inputNode(s4_tp_arrInputNode);

	/* ???????????????????????§?????§??????????¨???? */
	s4_t_maxCost = s4_d_calcNodeCost(s4_tp_arrInputNode, s4_t_cntColumn);

	/* ???????????? */
	printf("%d\n", s4_t_maxCost);

	return((S4)0);
}


/* ??????????????´??°??\?????¢??° */
/* ??\??????????????°??????????????£??????????????¨?????? */
/* ?????????????????° */
S4 s4_d_inputNode(S4 s4_ap_arrInputNode[MAX_INPUT_COLUMN][MAX_INPUT_ROW])
{
	U4 u4_t_inputNum;
	U4 u4_t_cntColumn;
	U4 u4_t_cntRow;
	U1 u1_t_mark;	/* ,???\n??????????????? */
	U4 u4_t_cntCompleteInput;	/* ??°??????1?????????????????????2?????\????????????????????\????????? */
	U4 u4_t_isCompleteInput;

	u4_t_cntColumn = (U4)0;
	u4_t_cntRow = (U4)0;
	u4_t_cntCompleteInput = (U4)0;
	u4_t_isCompleteInput = (U4)FALSE;

	while (u4_t_isCompleteInput != (U4)TRUE)
	{
		scanf("%d%c", &u4_t_inputNum, &u1_t_mark);
		s4_ap_arrInputNode[u4_t_cntColumn][u4_t_cntRow] = u4_t_inputNum;
		u4_t_cntRow++;
		/* ???????????\??£???????¬??????? */
		if (u1_t_mark == '\n')
		{
			/* ??°??????1?????????????????????2?????\????????????????????\????????? */
			if (u4_t_cntRow == 1)
			{
				u4_t_cntCompleteInput++;
				if (u4_t_cntCompleteInput >= 2)
				{
					u4_t_isCompleteInput = (U4)TRUE;
				}
			}
			u4_t_cntRow = (U4)0;
			u4_t_cntColumn++;
		}
	}

	return(u4_t_cntColumn);
}

/* ??????????????????????¨??????¢??° */
/* ?????????????????§????????? */
/* ?????°?????¬???????????????????????¢??°??§?????? */
S4 s4_d_calcNodeCost(S4 s4_ap_arrInputNode[MAX_INPUT_COLUMN][MAX_INPUT_ROW], S4 s4_a_numColumn)
{
	/* ??¨??????0?§?????????§???????????? */
	S4 s4_t_numNode;		/* ????????????????????????????????° */
	S4 s4_t_addCost;
	S4 s4_t_cntRow;
	S4 s4_t_cntColumn;

	/* ????????¢??????????????¨???????????§1?????????????????£??????????????????????????????????????? */
	S4 s4_t_backNode;
	U1 u1_t_isUpperHalf;

	/* ???????????????????????§???????????????????????????????¨???? */
	for (s4_t_cntColumn = (S4)1; s4_t_cntColumn <= s4_a_numColumn; s4_t_cntColumn++)
	{
		/* ????????????????????????????????°????¨???? */
		/* ????????¢???????????? */
		if (s4_t_cntColumn < (s4_a_numColumn + 1) / 2)
		{
			s4_t_numNode = s4_t_cntColumn;					/* ?????¨????????°??¨???????????°????????????*/
			s4_t_backNode = (S4)-1;
			u1_t_isUpperHalf = (U1)TRUE;
		}
		/* ????????¢???????????? */
		else
		{
			s4_t_numNode = s4_a_numColumn - s4_t_cntColumn - 1;
			s4_t_backNode = (S4)1;
			u1_t_isUpperHalf = (U1)FALSE;
		}

		/* ??????????¨???? */
		for (s4_t_cntRow = (S4)0; s4_t_cntRow <= s4_t_numNode; s4_t_cntRow++)
		{
			/* ????????¢???????????????????????????????????? = 1????????????????????????????????????*/
			if ((s4_t_cntRow == (S4)0) &&
				(u1_t_isUpperHalf == (U1)TRUE))
			{
				s4_t_addCost = s4_ap_arrInputNode[s4_t_cntColumn - 1][0];
			}
			/* ????????¢???????????????????????????????????? = 1???????????????????????????????????? */
			else if ((s4_t_cntRow == s4_t_numNode) &&
					(u1_t_isUpperHalf == (U1)TRUE))
			{
				s4_t_addCost = s4_ap_arrInputNode[s4_t_cntColumn - 1][s4_t_cntRow - 1];
			}
			/* ????????\??????????????? = ???????????????????????£??????????????????????????????????????§?????????????????????????????? */
			else
			{
				if (s4_ap_arrInputNode[s4_t_cntColumn - 1][s4_t_cntRow + s4_t_backNode] > s4_ap_arrInputNode[s4_t_cntColumn - 1][s4_t_cntRow])
				{
					s4_t_addCost = s4_ap_arrInputNode[s4_t_cntColumn - 1][s4_t_cntRow + s4_t_backNode];
				}
				else
				{
					s4_t_addCost = s4_ap_arrInputNode[s4_t_cntColumn - 1][s4_t_cntRow];
				}
			}
			s4_ap_arrInputNode[s4_t_cntColumn][s4_t_cntRow] += s4_t_addCost;
		}
	}

	/* ?????§????????????????????¢???????????????????????????????´???????????????? */

	return(s4_ap_arrInputNode[s4_a_numColumn - 1][0]);
}

Measured memory_bytes: 648