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)

#include <bits/stdc++.h>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
using namespace std;

string bigint_to_string(vector<int> digit) {
    int N = digit.size(); // N = (配列 digit の長さ)
    string str = "";
    for(int i = N - 1; i >= 0; --i) {
        str += digit[i] + '0';
    }
    return str;
}

vector<int> string_to_bigint(string S) {
    int N = S.size(); // N = (文字列 S の長さ)
    vector<int> digit(N);
    for(int i = 0; i < N; ++i) {
        digit[i] = S[N - i - 1] - '0'; // 10^i の位の数
    }
    return digit;
}

int main() {
string n;
cin>>n;

int N = n.size(); // N = (文字列 S の長さ)
    vector<int> digit(N);
    for(int i = 0; i < N; ++i) {
        digit[i] = n[N - i - 1] - '0'; // 10^i の位の数
    }

int sum = 0;
int temp;
rep(0,i,N){
    temp = (int)digit.at(i);
    sum += temp;
}
if(sum%9==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}