Problem:
Score : 100 points

Problem Statement

How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Constraints

1≤M≤23

M is an integer.

Input

Input is given from Standard Input in the following format:

M

Output

If we have x hours until New Year at M o'clock on 30th, December, print x.

Sample Input 1

21

Sample Output 1

27

We have 27 hours until New Year at 21 o'clock on 30th, December.

Sample Input 2

12

Sample Output 2

36

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
namespace ino{
    class ABC84c{
        static void Main(){

            int n = int.Parse(Console.ReadLine());
            int[] c = new int[n-1];
            int[] s = new int[n-1];
            int[] f = new int[n-1];
            string[] csf;
            for(int i=0;i<n-1;i++){
                csf = Console.ReadLine().Split(' ');
                c[i] = int.Parse(csf[0]);
                s[i] = int.Parse(csf[1]);
                f[i] = int.Parse(csf[2]);
            }

            for(int i=0;i<n-1;i++){
                int ans = 0;
                for(int j=i;j<n-1;j++){
                    if(ans<=s[j]){
                        ans = s[j];
                        ans += c[j];
                    }else{
                      if(ans%f[j]==0){
                        ans += c[j];
                      }else{
                        ans += f[j] - ans%f[j];
                        ans += c[j];
                      }
                        
                    }
                }
                Console.WriteLine(ans);
            }
            Console.WriteLine(0);
        }
    }
}