Problem:
Score : 200 points

Problem Statement

An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.

Determine whether N is a multiple of 9.

Constraints

0 \leq N < 10^{200000}

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

If N is a multiple of 9, print Yes; otherwise, print No.

Sample Input 1

123456789

Sample Output 1

Yes

The sum of these digits is 1+2+3+4+5+6+7+8+9=45, which is a multiple of 9, so 123456789 is a multiple of 9.

Sample Input 2

0

Sample Output 2

Yes

Sample Input 3

31415926535897932384626433832795028841971693993751058209749445923078164062862089986280

Sample Output 3

No

Solution in C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramB a = new ProgramB();
            a.main();//実行する

        }

    }
    //ABC175
    class ProgramA
    {
        public void main()
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long x = long.Parse(s[1]);
            long t = long.Parse(s[2]);
            //30以上ならYes、それ以外はNoを出力
            if(n % x == 0)
                Console.WriteLine(n / x * t);
            else
                Console.WriteLine((n / x+1) * t);


        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力

            string s = Console.ReadLine();

            long count = 0;
            for (int k = 0; k < s.Length; k++)
                count += s[k] - '0';

            //答え出力
            if(count % 9  == 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            long count = 0;
            long min = long.Parse(s[0]);
            for(int i = 1;i < n;i++)
            {
                long temp = long.Parse(s[i]);
                if(temp < min)
                {
                    count += min - temp;
                }
                else
                {
                    min = temp;
                }

            }

            Console.WriteLine(count);


        }
    }

    class ProgramD
    {
        public void main()
        {

            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            string[] p = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');

            long[] flag = new long[n];
            long ans = 0;

            for (int i = 0; i < n; i++)
            {
                if (flag[i] != 0)
                    continue;

                List<long> list = new List<long>();
                int start = int.Parse(p[i]) - 1;
                while (true)
                {
                    flag[start]++;
                    list.Add(long.Parse(c[start]));
                    start = int.Parse(p[start])- 1;
                    if (start == i)
                    {
                        list.Add(long.Parse(c[start]));
                        break;
                    }
                
                }

                if(k > list.Count())
                {
                    long temp = 0;
                    for (int x = 0; x < list.Count(); x++)
                    {
                        temp += list[x];
                    }
                }

                for(int j = 0; j < list.Count();j++)
                {
                    if (k < j + 1)
                        continue;


                    long temp = 0;
                    for (int x = 0;x < j + 1; x++)
                    {
                        temp += list[x];
                    }

                    ans = Math.Max(ans, temp);

                    for(int y = j + 1; y < list.Count();y++)
                    {
                        temp -= list[y - j - 1];
                        temp += list[y];
                        ans = Math.Max(ans, temp);
                    }
                }


            }

            
            Console.WriteLine(ans);
            

        }

    }

    class ProgramE
    {

        public void main()
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);

            long[] a = new long[n];

            string[] t = Console.ReadLine().Split(' ');

            for(int i = 0;i < n;i++)
                a[i] = long.Parse(t[i]);

            long min = 0;//最初を0にすると1に答えができる
            long max = 1000000000;//答候補の最大

            //二分探索（答えを決め打ちして、切る回数を数える。k回以下ならmax,そうでないならmin)
            //小さくした方が回数がかかるので、maxが満たす最小の丸太の長さ
            while(min + 1 != max)
            {
                long temp = (min + max) / 2;
                long cut = 0;
                //切る回数を数える
                for (int i = 0; i < n; i++)
                {
                    //tempが大きいなら切らない
                    if (a[i] < temp)
                        continue;
                    //割り切れるかどうかで回数は変わる
                    if(a[i] % temp == 0)
                        cut += a[i] / temp - 1;
                    else
                        cut += a[i] / temp;
                }

                //k回以下ならmax更新、そうでないならminを更新
                if (cut <= k)
                    max = temp;
                else
                    min = temp;

            }

            //答え出力
            Console.WriteLine(max);

        }


    }

}