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 (GCC 9.2.1) (judge verdict: Accepted)

/*	                           
							 * * 
						   *     * 
						 *	       * 
					   *	         * 
                     *     _ooOoo_     * 
                   *      o8888888o      * 
                 *        88" . "88        * 
                *         (| -_- |)         * 
               *       *  0\  =  /0  *       * 
               *       *__0/`---'\0__*       * 
               *     .'  \\|     |//  `.     * 
                *   /  \\|||  :  |||//  \   * 
                 * /  _||||| -:- |||||-  \ * 
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   佛祖保佑       永无BUG
                        author：Richie 
*/

#include<stdio.h>
#include<string.h>	
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define ll long long
#define FOR(i, a, b) for (int i = (a);i <= (b); i++)
#define ROF(i, a, b) for (int i = (a);i >= (b); i--)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q)) 
#define LOCAL
#define N 500001
#define mod 998244353

int cmp (const void *a, const void *b);//升序排列 
void print_array (int *a, int n);
void read_array (int *a, int n);
void init (void);
double lnchoose (int n, int m);
double choose (int n, int m);
ll fast (ll x);//逆元 费马小定理/欧拉定理 适用范围：一般在mod是个素数的时候用
ll exgcd (ll a, ll b, ll *x, ll *y);
ll getInv (int a);//求a在mod下的逆元，不存在逆元返回-1 
ll gcd (ll a, ll b);


char a[200005];
int main(){
	scanf("%s",a);
	int ans=0;
	for(int i=0;a[i]!='\0';i++){
		ans+=a[i]-'0';
		ans%=9;
	}
	if(ans==0)printf("Yes");
	else printf("No");
	return 0;	
} 








ll gcd (ll a, ll b)
{
	int t;
	while (b != 0){
		t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll fast (ll x)
{									
	int y = mod - 2;
	ll res = 1;
	while (y){
		if (y & 1)res = res * x % mod;
		x = x * x % mod; 
		y >>= 1;
	}
	return res;
}

ll exgcd(ll a,ll b,ll *x,ll *y)					//扩展欧几里得算法 
{
    if(b==0)
    {
        *x = 1,*y = 0;
        return a;
    }
    ll ret = exgcd (b, a % b, y, x);
    *y -= a / b * (*x);
    return ret;
}
ll getInv (int a)								
{
    ll x, y;
    ll d = exgcd (a, mod, &x, &y);
    return d == 1 ? (x % mod + mod) % mod : -1;
}

void init (void)
{
	#ifdef LOCAL
		freopen ("data.txt", "r", stdin);
		freopen ("out.txt", "w", stdout);
	#endif
}

int cmp (const void *a, const void *b)
{
	return *(int*)a - *(int*)b;					
} 

void print_array (int *a, int n)
{
	FOR(i,1,n){
		if (i != n) printf("%d ",a[i]);
		else printf("%d",a[i]);
	}
	printf("\n");
} 

void read_array (int *a, int n)
{
	FOR(i, 1, n)scanf("%d",&a[i]);
}

double lnchoose (int n, int m)
{
	if (m > n){
		return 0;
	}
    if (m < n / 2.0)
    {
        m = n - m;
    }
    double s1 = 0;
    for (int i = m + 1; i <= n; i++)
    {
        s1 += log((double)i);
    }
    double s2 = 0;
    int ub = n - m;
    for (int i = 2; i<= ub; i++)
    {
        s2 += log((double)i);
    }
    return s1-s2;
}
double choose(int n, int m)
{
	if (m > n)
    {
		return 0;
	}
    return exp(lnchoose(n, m));
}