akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            

            // 整数の入力
            long a = long.Parse(Console.ReadLine());

            a = a + a * a + a * a * a;

            long result = a;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27280
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe\n";
    }
    else
        cout<<"safe\n";
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#include <vector>
#define mp make_pair 
#define x first
#define y second
#define ll long long
using namespace std;

ll n,q,ans,ps_o[50005],ps_e[50005],a[100005],ps[100005],l,r,mid,num,p,p2; 
int main(){
	scanf("%lld%lld",&n,&q);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if (i%2 == 0)
		ps_e[i/2]=ps_e[i/2-1]+a[i];
		else
		ps_o[i/2+1]=ps_o[i/2]+a[i]; 
		ps[i]=ps[i-1]+a[i];
	}
	for (int i=1;i<=q;i++){
		scanf("%lld",&num);
		l=0; r=n/2;
		while (l <= r){
			mid=(l+r)/2;
			if (abs(a[n-mid+1]-num) >= abs(num-a[n-mid*2+1]))
			l=mid;
			else
			r=mid;
			if (r-l <= 1){
				if (abs(a[n-r+1]-num) >= abs(num-a[n-r*2+1]))
				p=r;
				else
				p=l;
				break;
			}
		
		}
		ans=ps[n]-ps[n-p];
		if (abs(num-a[n-p]) >= abs(num-a[n-p*2]) && n-p*2 > 0){
			ans+=a[n-p];
			p2=n-p*2-1;
				if (p2%2 == 0)
				ans+=ps_o[p2/2];
				else
				ans+=ps_e[p2/2];
		}
		else
		{ 
			p2=n-p*2;
			if (p2%2 == 0)
			ans+=ps_e[p2/2];
			else
			ans+=ps_o[p2/2+1];
		}
		printf("%lld\n",ans);
	}
	return 0;
}		

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, arr[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    map<int, int>m;
    for(int i = 0; i < n; i++)
        m[arr[i]]++;
    int ans = 0;
    for(int i = n; i >= 0; i--)
    {
        int pw = 1;
        while(pw <= arr[i])pw <<= 1;
        while(true)
        {
            int need = pw - arr[i];
            if(need == arr[i])
            {
                if(m[need] >= 2)
                {
                    m[need] -= 2;
                    ++ans;
                    break;
                }
            }
            else
            {
                if(m.count(need) && m[need] > 0 && m[arr[i]] > 0)
                {
                    m[arr[i]]--;
                    m[need]--;
                    ++ans;
                    break;
                }
            }
            if(pw == (1 << 30))break;
            pw <<= 1;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 10368
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int64_t N;
  cin >> N;

  for (int h = 1; h <= 3500; h++)
    for (int n = h; n <= 3500; n++) {
      int64_t a = 4 * h * n - N * n - N * h, b = N * h * n;
      if (a > 0 && b % a == 0) {
        cout << h << " " << n << " " << b / a << endl;
        return 0;
      }
    }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<vector>
#include<algorithm>

int main(){
    int n,c,k;
    scanf("%d %d %d",&n,&c,&k);
    std::vector<int>t;
    for(int i=0;i<=n-1;i++){
        int x;
        scanf("%d",&x);
        t.push_back(x);
    }
    int x=t[n-1]+1000000001;
    t.push_back(x);
    sort(t.begin(),t.end());
    
    int ans=0,j=0;
    while(j<=n-1){
        int starttime=t[j],startj=j;
        while(t[j]<=starttime+k &&j<startj+c){
            j++;
        }
        ans++;
    }
    printf("%d",ans);
    
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll l, r, d; cin >> l;

	vector<ll> ans(l+1,0);
	for (int x = 1; x*x <= l; x++) for (int y = 1; y * y <= l - x*x; y++) for (int z = 1; z * z <= l - x * x - y*y -x*y; z++) {
	  
		if (x * x + y * y + z * z + z * y + y * x + x * z <= l) ans[x * x + y * y + z * z + z * y + y * x + x * z]++;
	} 

	rep1(i,l) cout << ans[i] << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {

  ll N;
  cin>>N;
  ll ans=0;
  ll b=0;
  ll c=0;
  for(int a=1;a<=N;a++){
 
    for(int b=1;b<=N;b++){
    
      c=N-(a*b);
      if(c<=0)break;
      //cout<<a<<" "<<b<<" "<<c<<endl;
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        if(abs(a-b)>=2)
            cout<<0<<endl;
        else if(a==b){
            long long int sum=1;
            for(int i=1;i<=a;i++){
                sum*=i;
                sum=sum%(1000000000+7);
            }
            sum=sum*sum*2%(1000000000+7);
            cout<<sum<<endl;
        }
        else{
            long long int sum=1;
            long long int summ=1;
            for(int i=1;i<=max(a,b);i++){
                sum*=i;
                sum=sum%(1000000000+7);
            }
            for(int i=1;i<=min(a,b);i++){
                summ*=i;
                summ=summ%(1000000000+7);
            }
            sum=sum*summ%(1000000000+7);
            cout<<sum<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

struct cake {
    int64_t x, y, z;
    int64_t deliciousness;

    cake(int64_t _x, int64_t _y, int64_t _z,
        const vector<int64_t> &A, const vector<int64_t> &B, const vector<int64_t> &C) :
        x(_x), y(_y), z(_z), deliciousness(A[_x] + B[_y] + C[_z]) {}
};

struct cake_order {
    bool operator() (const cake &l, const cake &r) {
        return l.deliciousness < r.deliciousness;
    }
};

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<int64_t> A(X);
    for (auto &Ai: A) {
        cin >> Ai;
    }
    vector<int64_t> B(Y);
    for (auto &Bi: B) {
        cin >> Bi;
    }
    vector<int64_t> C(Z);
    for (auto &Ci: C) {
        cin >> Ci;
    }

    sort(A.begin(), A.end(), greater<int64_t>());
    sort(B.begin(), B.end(), greater<int64_t>());
    sort(C.begin(), C.end(), greater<int64_t>());

    priority_queue<cake, vector<cake>, cake_order> q;
    set<tuple<int, int, int>> seen;


    q.push(cake(0, 0, 0, A, B, C));
    seen.insert(make_tuple<int, int, int>(0, 0, 0));

    for (int i = 0; i < K; ++i) {
        auto t = q.top();
        q.pop();

        cout << t.deliciousness << '\n';

        if (t.x+1 < A.size()) {
            auto tup = make_tuple<int, int, int>(t.x+1, t.y, t.z);
            if (!seen.count(tup)) {
                q.push(cake(t.x+1, t.y, t.z, A, B, C));
                seen.insert(tup);
            }
        }

        if (t.y+1 < B.size()) {
            auto tup = make_tuple<int, int, int>(t.x, t.y+1, t.z);
            if (!seen.count(tup)) {
                q.push(cake(t.x, t.y+1, t.z, A, B, C));
                seen.insert(tup);
            }
        }

        if (t.z+1 < C.size()) {
            auto tup = make_tuple<int, int, int>(t.x, t.y, t.z+1);
            if (!seen.count(tup)) {
                q.push(cake(t.x, t.y, t.z+1, A, B, C));
                seen.insert(tup);
            }
        }
    }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<bitset<10>> f(n);
    for (auto& e : f) {
        for (int i = 0; i < 10; i++) {
            int ff;
            cin >> ff;
            e |= ff << i;
        }
    }

    vector<vector<int>> p(n, vector<int>(11));
    for (auto& e : p) for (auto& f : e) cin >> f;

    int ans = -1e9;
    for (int i = 1; i < 1 << 10; i++) {
        int can = 0;
        for (int j = 0; j < n; j++) can += p[j][(f[j] & bitset<10>(i)).count()];
        ans = max(ans, can);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
let lcs x y =
  let m = String.length x in
  let n = String.length y in
  let dp = Array.make_matrix (m + 1) (n + 1) 0 in
  for i = 1 to m do
    for j = 1 to n do
      dp.(i).(j) <-
        if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1
        else
          let a = dp.(i-1).(j) in
          let b = dp.(i).(j-1) in
          if a > b then a else b;
    done
  done;
  dp.(m).(n)

let () =
  let q = read_int () in
  for _ = 0 to q - 1 do
    let x = read_line () in
    let y = read_line () in
    lcs x y |> print_int;
    print_newline ();
  done

Measured memory_bytes: 18384
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	char s[100];
	int k;
	cin>>s;
	int n=strlen(s);
	cin>>k;
	for(int i=0;i<n;i++){
		if(k>0){
			long long int sum=s[i]-48;
			k=k-pow(sum,5e15);
		}
		if(k<=0){
			cout<<s[i];
			break;
		}	
	}
	
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>

using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

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

  rep(i, s.length()) {
    if ((i + 1) % 2 == 1) cout << s[i];
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n,q;
main()
{
	cin>>n>>q;
	vector<priority_queue<int> >s(n);
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int t,x;cin>>t>>x;
			s[t].push(x);
		}
		else if(c==1)
		{
			int p;cin>>p;
			if(!s[p].empty())cout<<s[p].top()<<endl;
		}
		else
		{
			int t;cin>>t;
			if(!s[t].empty())s[t].pop();
		}
	}
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int n,m;
    cin>>n>>m;
    int a[m];
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<=n)
    {
        cout<<n-sum<<"\n";
    }
    else
    {
        cout<<"-1\n";
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream> 
#include <algorithm> 
using namespace std; 
bool cmp(int a, int b)
{  
	return a>b; 
} 
int main()
{  
	int n,k,x;  
	cin>>n>>k;  
	int a[200000+5]={0}; 
 	for (int i=0;i<n;i++)
	{     
		cin>>x;     
		a[x]++; 
    }          
	sort(a+1,a+200000+1,cmp); 
    int count=0;
	for (int i=k+1;i<=200000;i++) 
	  count += a[i]; 
    cout<<count<<endl;     
	return 0; 
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N,u,v;
  cin>>N>>u>>v,u--,v--;
  vector<int>A(N-1),B(N-1);
  for(int i=0;i<N-1;i++)cin>>A[i]>>B[i],A[i]--,B[i]--;
  vector<vector<int>>G(N);
  for(int i=0;i<N-1;i++){
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  auto Y=[](auto f){
    return [=](auto&&... args){
      return f(f,forward<decltype(args)>(args)...);
    };
  };
  vector<int>t(N,-1),o(N,-1);
  auto tdfs=[&](auto f,int n,int c)->decltype(void()){
    t[n]=c;
    for(auto it:G[n]){
      if(t[it]==-1)f(f,it,c+1);
    }
  };
  auto odfs=[&](auto f,int n,int c)->decltype(void()){
    o[n]=c;
    for(auto it:G[n]){
      if(o[it]==-1)f(f,it,c+1);
    }
  };
  Y(tdfs)(u,0);
  Y(odfs)(v,0);
  vector<int>used(N,false);
  int Max=0;
  auto dfs2=[&](auto f,int n,int c)->decltype(void()){
    used[n]=true;
    Max=max(Max,o[n]);
    for(auto it:G[n]){
      if(!used[it]&&t[it]<o[it])
        f(f,it,c+1);
    }
  };
  Y(dfs2)(u,0);
  cout<<Max-1<<endl;
  return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
int a[525];

bool ok(int x){
    vi v;
    int sum = 0;
    REP(i,n){
        int aa = a[i] % x;
        sum += aa;
        if(aa!=0)v.push_back(aa);
    }
    if(v.size()==0)return true;
    if(sum%x != 0)return false;
    sort(ALL(v));
    deque<int> Q;
    for(int y : v)Q.push_back(y);
    int rest = k;
    while(Q.size()){
        if(Q.size()==1)return false;
        int s = Q.front();
        int t = Q.back();
        int sub = min(s, x-t);
        Q.front() -= sub;
        if(Q.front()==0)Q.pop_front();
        Q.back() += sub;
        if(Q.back()==x)Q.pop_back();
        rest -= sub;
        if(rest < 0)return false;
    }
    return true;
}

int main(){
    scanf("%d%d",&n,&k);
    REP(i,n)scanf("%d",a+i);
    int sum = 0;
    REP(i,n)sum += a[i];

    int ans = 1;
    for(int x=1; x*x<=sum; x++){
        if(ok(x))CHMAX(ans,x);
        if(ok(sum/x))CHMAX(ans,sum/x);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import math
A, B, H, M = [int(x) for x in input().split()]
h = 360 * (H + M/60) / 12
m = 360 * M / 60
cos = math.cos(math.radians(abs(h-m)))
ans = math.sqrt(A*A + B*B - 2*A*B*cos)
print(ans)


Measured memory_bytes: 62504
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;
typedef pair<ll, ll> P;
int main()
{
    ll n, x, l, sum = 0;
    cin >> n;
    vector<P> arm;
    for (int i = 0; i < n; i++) {
        cin >> x >> l;
        arm.push_back(make_pair(x+l, max(ll(0), x-l)));
    }
    sort(arm.begin(), arm.end());

    ll now = -inf;
    for (int i = 0; i < n; i++) {
        if (now <= arm[i].second) {
            sum++;
            now = arm[i].first;
        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 2420
def is_kaibun(s):
    if (s == s[::-1]):
        return True
    else:
        return False


def b():
    S = str(input())
    N = len(S)
    k1 = is_kaibun(S)
    k2 = is_kaibun(S[:int((N-1)/2)])
    k3 = is_kaibun(S[int((N+1)/2):])

    if (k1 and k2 and k3):
        print('Yes')
    else:
        print('No')


##########
if __name__ == "__main__":
    b()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int dp[3005][3005][4];
int mm[3005][3005];

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif    

    int n,m,k;
    cin>>n>>m>>k;
    int x,y,z;
    for(int i=1;i<=k;i++)
    {
        cin>>x>>y>>z;
        mm[x][y]=z;
    }
    dp[1][1][0]=0;
    dp[1][1][1]=mm[1][1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i==1 && j==1)
                continue;
            int mmx=0;
            for(int k=0;k<4;k++)
                mmx=max(mmx,dp[i-1][j][k]);
            for(int k=0;k<4;k++)
            {
                dp[i][j][k]=max(mmx,dp[i][j-1][k]);
                if(k>0)
                    dp[i][j][k]=max({dp[i][j][k],mmx+mm[i][j],dp[i][j-1][k-1]+mm[i][j]});
            }
        }
    }
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            for(int k=0;k<4;k++)
                mx=max(mx,dp[i][j][k]);
        }
    }
    cout<<mx;
}


Measured memory_bytes: 355520
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		sort(arr[i].begin(),arr[i].end());
	}
	sort(arr,arr+n);
	
	long c=0;
	long count=0;
	for(int i=1;i<n;i++)
	{
		if(arr[i]==arr[i-1])
		{
			c++;
		}
		else
		{
			count+=((c)*(c+1))/2;
			c=0;
		}
	}
	count+=(c*(c+1))/2;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    vector<string> S(3);
    rep(i, 3) cin >> S[i];
    int turn = 0;

    while (true) {
        if ((int)S[turn].size() == 0) {
            cout << (char)('A' + turn) << endl;
            break;
        } else {
            int next = (S[turn][0] - 'a');
            S[turn].erase(S[turn].begin());
            turn = next;
        }
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define INF INT_MAX/2

#define HP_MAX 100005

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

int main()
{
	while (1)
	{
		int N; cin >> N;
		if (N == 0) return 0;
		vi HP(N); rep(i, 0, N) cin >> HP[i];

		int M; cin >> M;
		vector<pii> single, all;
		rep(i, 0, M)
		{
			string a, b; int mp, da;
			cin >> a >> mp >> b >> da;
			if (b == "Single")
				single.push_back(pii(mp, da));
			else
				all.push_back(pii(mp, da));
		}

		vi sdp(HP_MAX, INF);
		sdp[0] = 0;
		rep(i, 0, HP_MAX)
		{
			if (sdp[i] == INF) continue;
			for (auto p : single)
			{
				int mp = p.first;
				int da = p.second;

				int ni = i + da;

				if (HP_MAX <= ni) ni = HP_MAX - 1;
				sdp[ni] = min(sdp[ni], sdp[i] + mp);
			}
		}
		int _min = sdp[HP_MAX - 1];
		rrep(i, HP_MAX - 2, 0)
		{
			_min = min(_min, sdp[i]);
			sdp[i] = _min;
		}

		vi adp(HP_MAX, INF);
		adp[0] = 0;
		rep(i, 0, HP_MAX)
		{
			if (adp[i] == INF) continue;
			for (auto p : all)
			{
				int mp = p.first;
				int da = p.second;

				int ni = i + da;

				if (HP_MAX <= ni) ni = HP_MAX - 1;
				adp[ni] = min(adp[ni], adp[i] + mp);
			}
		}
		_min = adp[HP_MAX - 1];
		rrep(i, HP_MAX - 2, 0)
		{
			_min = min(_min, adp[i]);
			adp[i] = _min;
		}

		ll ans = INF;
		rep(i, 0, HP_MAX)
		{
			ll mp = adp[i];
			rep(j, 0, N)
			{
				int d = HP[j] - i;
				if (d < 0) continue;
				mp += sdp[d];
			}
			ans = min(ans, mp);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3592
# C
s = input()

r = ''
for i in range(len(s)-1, -1, -1):
    r = s[i] + r
    if r == 'dream':
        r = ''
    if r == 'dreamer':
        r = ''
    if r == 'erase':
        r = ''
    if r == 'eraser':
        r = ''
        
if r == '':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const int Max_Num=2e5+10;
const LL mod=1e9+7;
int N;
LL F[Max_Num], Finv[Max_Num];
LL C[Max_Num], dp[Max_Num];
vector<int> G[Max_Num];

LL modinv(LL x){
	LL m=mod, u=1, v=0;
	while(m){
		LL t=x/m;
		x-=t*m; swap(x,m);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

void fact(){
	F[0]=1;
	rep(i,Max_Num-1){
		F[i+1]=F[i]*(i+1);
		F[i+1]%=mod;
	}
	rep(i,Max_Num) Finv[i]=modinv(F[i]);
}

LL comb(LL n, LL k){
	LL res=F[n];
	res*=Finv[k]*Finv[n-k]%mod;
	return res%mod;
}

void child(int v, int par=-1){
	int n=G[v].size();
	if(v!=0 && n==1) return;
	LL res=0;
	rep(i,n){
		int next=G[v][i];
		if(next==par) continue;
		child(next, v);
		res+=C[next]+1;
	}
	C[v]=res;
}

void dfs(int v, int par=-1){
	int n=G[v].size();
	if(v!=0 && n==1){
		dp[v]=1;
		return;
	}
	LL res=F[C[v]];
	rep(i,n){
		int next=G[v][i];
		if(next==par) continue;
		dfs(next, v);
		res*=dp[next]*Finv[C[next]+1]%mod;
		res%=mod;
	}
	dp[v]=res%mod;
}

void bfs(int v, int par=-1){
	int n=G[v].size();
	if(par!=-1){
		LL res=dp[par]*modinv(dp[v])%mod;
		res*=modinv(comb(N-1,C[v]+1));
		dp[v]*=res%mod;
		dp[v]%=mod;
	}
	dp[v]*=comb(N-1,N-1-C[v]);
	dp[v]%=mod;
	rep(i,n){
		int next=G[v][i];
		if(next==par) continue;
		bfs(next, v);
	}
}

int main(){
	fact();
	cin >> N;
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	rep(i,N) dp[i]=0, C[i]=0;
	child(0);
	dfs(0);
	bfs(0);
	rep(i,N) cout << dp[i] << endl;

	return 0;
}

Measured memory_bytes: 20212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */


int main(void){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=2; i*i <= n; i++){
        if(n%i != 0) continue;
        ll num = 0;
        while(n%i == 0){
            num++;
            n /= i;
        }
        for(ll j=1; ; j++){
            if(num - j >= 0){
                num -= j;
                ans++;
            }
            else{
                break;
            }
        }
    }
    if(n != 1){
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    class Program
    {
        //メイン関数
        static void Main(string[] args)
        {
            string[] str = Read().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if ((a * b) % 2 == 1) WriteLine("Odd");
            else WriteLine("Even");
        }

        //メインじゃない関数
        private static string Read() { return ReadLine(); }
        private static int ReadI() { return int.Parse(ReadLine()); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W;
	while(1) {
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if((i + j) % 2) cout << ".";
				else cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>

using namespace std;

int main()
{
	int n;
	int d[55];
	long long ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ans += (long long)d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, s);
  rep(i, 0, (int)s.length()) {
    cout << s[i++];
  }
  print("");
}


Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 0;
    stack<pll> sta;
    rep(i,N) {
        int a = i;
        while (!sta.empty() && sta.top().first > A[i]) {
            chmax(ans,sta.top().first*(i-sta.top().second));
            a = sta.top().second;
            sta.pop();
        }
        if (sta.empty() || sta.top().first < A[i]) sta.emplace(A[i],a); 
    }
    while (!sta.empty()) {
        chmax(ans, sta.top().first*(N-sta.top().second));
        sta.pop();
    }

    cout << ans << ln;
}


Measured memory_bytes: 4968
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50;

int n;
bool fail,mat[N];
vector<int> g[N]; 

void dfs(int v,int p){
	for(int d:g[v])if(d!=p){
		dfs(d,v); 
		if(!mat[d]&&!mat[v]){
			mat[v]=true;
			mat[d]=true;
		}else if(!mat[d]&&mat[v]){
			fail=true;
		}
	}
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n); 
	rep(i,1,n-1){
		int u,v; 
		read(u),read(v); 
		g[v].pb(u); 
		g[u].pb(v); 
	}
	dfs(1,0); 
	fail|=!mat[1]; 
	puts(fail?"First":"Second"); 
	return 0;
}


Measured memory_bytes: 5888
def main():
    s = input()
    k = int(input())

    li = []
    same_str_num = 1
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            same_str_num += 1
        else:
            li.append(same_str_num)
            same_str_num = 1
    li.append(same_str_num)

    if len(li) == 1:
        print(li[0]*k//2)
        return

    if s[0] == s[-1]:
        ans = li[0]//2 + li[-1]//2
        ans += ((li.pop(0) + li.pop())//2) * (k-1)
    else:
        ans = 0
    for i in li:
        ans += (i//2)*k
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    int ans = 20000;
    for (int i = 0; i < S.size() - 2; i++) {
        int x = stoi(S.substr(i, 3));
        if (abs(753 - x) < abs(753 - ans)) {
            ans = x;
        }
    }
    cout << abs(753 - ans) << endl;
    return 0;
}


Measured memory_bytes: 3568
n , k , q = map(int, input().split(" "))
score = []
for i in range(0, n):
    score.append(0)
for i in range(0, q):
    a = int(input())
    score[a-1] = score[a-1] + 1
for i in range(0, n):
    if(k > (q - score[i])):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4728
// G++ MACro.cpp -std=c++14
#include <boost/multiprecision/cpp_int.hpp>
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair
int main(){
    SCIN(s);
    V v(4,false);
    FOREACH(ss,s){
        if(ss=='N')v[0]=true;
        if(ss=='W')v[1]=true;
        if(ss=='S')v[2]=true;
        if(ss=='E')v[3]=true;
    }
    Yes(v[0]==v[2]&&v[1]==v[3]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double P,E,T;

double dfs(int k,double L,double R){
  double H=(R+L)/2,PP=H>=T ?1-P:P;
  if(k==0)return abs(H-T)<=E;
  if(abs(L-T)<=E&&abs(R-T)<=E)return 1;
  if(T<R-E||L+E<T)return 0;

  return PP*dfs(k-1,H,R)+(1-PP)*dfs(k-1,L,H);
}

int main(){
  double K,R,L;
  cin>>K>>R>>L>>P>>E>>T;
  printf("%.10f\n",dfs(K,L,R));
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,x,theta;
  cin>>a>>b>>x;
  if(a*a*b>2*x)theta=M_PI/2.0-atan(2*x/(a*b*b));
  else theta=atan(2*(a*a*b-x)/(a*a*a));
  cout<<fixed<<setprecision(10)<<theta*180/(M_PI)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = Console.ReadLine();
            int newText = 0;
            if(text[0] == '1')
            {
                newText += 900;
            }else{
                newText += 100;
            }
            if (text[1] == '1')
            {
                newText += 90;
            }
            else
            {
                newText += 10;
            }
            if (text[2] == '1')
            {
                newText += 9;
            }
            else
            {
                newText += 1;
            }

            Console.WriteLine(newText);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <algorithm>
 
#define ll long long
 
int main(){
	ll n,w;
	std::cin >> n >> w;
	
	std::vector<ll> dp(w+1);
	
	std::set<ll> valid;
	valid.insert(w);
 
	for(int i = 0; i < n; ++i){
		ll weight, value;
		std::cin >> weight >> value;
		std::set<ll> toInsert;
		for(auto itr = valid.begin(); itr != valid.end(); ++itr){
			if((*itr)-weight >= 0 && dp[*itr] + value > dp[(*itr)-weight]){
				dp[(*itr)-weight] = dp[*itr] + value;
				if(valid.count((*itr)-weight) == 0){
					toInsert.insert((*itr)-weight);
				}
			}
		}
 
		for(auto itr = toInsert.begin(); itr != toInsert.end(); ++itr){
			valid.insert(*itr);
		}
 
	}
	
	ll answer = 0;
	for(int i = 0; i < dp.size(); ++i){
		if(dp[i] > answer)
			answer = dp[i];
	}
	std::cout << answer;
}

Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        Collections.reverse(list);
        int allVote = 0;
        for (Integer i : list) {
            allVote += i;
        }

        double limit = allVote / (4.0 * m);
        String answer = "Yes";
        for (int i = 0; i < m; i++) {
            int vote = list.get(i);
            if (vote < limit) {
                answer = "No";
                break;
            }
        }
        System.out.println(answer);
        sc.close();
    }

}


Measured memory_bytes: 35432
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	ss := []rune(s)
	takahashi := 0
	for i := 0; i < len(ss); i++ {
		if ss[i] == '+' {
			takahashi += 1
		} else {
			takahashi -= 1
		}
	}
	fmt.Println(takahashi)
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  bool flag=false;
  ll N,M,K;
  cin>>N>>M>>K;

  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      if(i*M+j*N-i*j*2==K) flag=true;
    }
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, x; scanf("%d%d", &n, &x);
    vector<int> a(n); for(int &i : a) scanf("%d", &i);
    
    long long ans = 0;
    
    for(int i = 0; i+1 < n; i++) {
        if(a[i] + a[i+1] > x) {
            int d = a[i] + a[i+1] - x;
            int e = min(a[i+1], d);
            int f = d - e;
            ans += e + f;
            a[i+1] -= e;
            a[i] -= f;
        }
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int main() {
	int n;
	scanf("%d",&n);
	while (n > 0) {
		int t = n%10;
		n = n/10;
		if (t == 7) {
			printf ("Yes");
			return 0;
		}
	}
	printf ("No");
	return 0;
}

Measured memory_bytes: 1736
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)

typedef long long Int;

int main() {
    Int n, a, b, c, d;
    scanf("%lld %lld %lld %lld %lld ", &n, &a, &b, &c, &d);
    bool *x = (bool *)malloc(sizeof(bool) * (n + 2));
    bool prev = false;
    Int current = 0;
    Int max = 0;
    reps(i, n) {
        x[i] = (getchar() == '.');
        if (i >= a && i <= MAX(c, d) && !prev && !x[i]) {
            puts("No");
            return 0;
        }
        if (i >= b && i <= MIN(c, d)) {
            if (x[i]) {
                current++;
                max = MAX(max, current);
            } else {
                current = 0;
            }
        }
        prev = x[i];
    }
	puts(c < d || max >= 3 || (x[b - 1] && x[b + 1]) || (x[d - 1] && x[d + 1]) ? "Yes" : "No");
}



Measured memory_bytes: 7504
#include <iostream>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define print(x) for(auto& i:x) cout<<i<<" "; cout<<'\n';
#define scan(x) for(auto& i:x) cin>>i;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define pii pair<int, int>
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define d4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define d5(a,b,c,d,e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
ll mod=1e9+7;

void solve(){
	string s; cin>>s;
	int sum=0;
	for(auto c:s){
		sum+=c-'0';
	}
	if((sum%9)==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main() {
//	freopen("test.txt", "r", stdin);
	FAST; int T=1;
	//cin>>T;
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
using mint = modint998244353;

mint ones[200005];

struct S {
  mint a;
  int size;
};
struct F {
  int a, i;
};

S op(S l, S r){
  mint x = mint(10).pow(r.size);
  return S{l.a*x+r.a, l.size+r.size};
}
S e(){
  return S{0,0};
}
S mapping(F l, S r){
  if(l.i == -1) return r;
  return S{ones[r.size] * l.a, r.size};
}
F composition(F l, F r){
  if(l.i < r.i) return r;
  return l;
}
F id(){
  return F{0, -1};
}

int main(){
  {
    mint p(1);
    REP(i,1,200005){
      ones[i] = p;
      p = p*10+1;
    }
  }
  int N, Q;
  cin >> N >> Q;

  vector<S> v;
  rep(i,N){
    v.push_back(S{1,1});
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

  rep(q,Q){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    seg.apply(l, r+1, F{d,q});
    cout << seg.all_prod().a.val() << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 11908
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;

// * XY座標
#define X real()
#define Y imag()

// * 点の表現
typedef complex<double> P;

// * 許容する誤差ε
const double EPS = 1e-10;
// * Infinity
const double INF = 1e12;
// * 円周率
const double PI = acos(-1.0);
// * 
const P INF_P(INF,INF);

// * complex<double> の順序を定義する
namespace std {
	bool operator < (const P& a, const P& b) {
		return (real(a) != real(b))? real(a) < real(b) : imag(a) < imag(b);
	}
}

// * 点座標のデバッグ出力
void print(P p) {
	cout << "point" << p << ";" << endl;
}

// * 2乗する
double sq(double x) {
	return x * x;
}

// * 2点間の距離
double dist(P p1, P p2) {
	return abs(p1 - p2);
}

// * 2つのスカラーが等しいかどうか
bool equal(double a, double b) {
	return ( fabs( a - b ) < EPS );
}
// * 2つのベクトルが等しいかどうか
bool eq_v(P a, P b) {
	return ( equal( a.X, b.X ) && equal( a.Y, b.Y ) );
}

// * 内積 (dot product) : a・b = |a||b|cosΘ
double dot(P a, P b) {
	return real( conj(a) * b );
}

// * 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
	return imag( conj(a) * b ) ;
}

// CCW : 反時計回り (Counter Clock Wise)
// CW : 時計回り (Clock Wise)
enum {CCW=1, CW=-1, ON=0};
// * 3点がどちら回りであるか返す, 3点が1直線に乗っているときは ON を返す
int ccw(const P &a, P b, P c) {
	b-=a, c-=a;
	double rotdir = cross(b,c);
	if( rotdir >  EPS ) return CCW;
	if( rotdir < -EPS ) return CW;
	return ON;
}

// 凸包を求める (flag == true の時は下側, falseのときは上側を求める)
vector<P> convex(vector<P> v, bool flag){
	sort( v.begin() , v.end() );
	if( flag ) reverse( v.begin() , v.end() );
	
	vector<P> ch( v.size() );
    int n = 0;
    for(int i = 0 ; i < v.size() ; i++ ) {
        ch[n++] = v[i];
        while( n >= 3 && ccw( ch[n-3] , ch[n-2] , ch[n-1]) == CCW ) {
            ch[n-2] = ch[n-1];
            n--;
        }
    }
    
    vector<P> result;
    for(int i=0 ; i < n ; i++ ) result.push_back( ch[i] );
    return result;
}

int main(){
	int n;
	while( scanf("%d", &n ), n ){
		// 入力
		vector<P> v;
		for(int i=0 ; i < n ; i++ ){
			int x,y;
			scanf("%d %d", &x, &y );
			v.push_back( P(x,y) );
		}
		
		vector<P> ans;
		ans.push_back( P(0,0) );
		while( true ){
			vector<P> a = convex( v , false );
			for(int i=0 ; i < a.size() ; i++ ){
				if( i != a.size()-1 ) ans.push_back( a[i] );
				v.erase( find( v.begin(), v.end(), a[i] ) );
			}
			if( v.empty() ){
				ans.push_back( a[a.size()-1] );
				break;
			}
			v.push_back( a[a.size()-1] );
			
			a = convex( v , true );
			for(int i=0 ; i < a.size() ; i++ ){
				if( i != a.size()-1 ) ans.push_back( a[i] );
				v.erase( find( v.begin(), v.end(), a[i] ) );
			}
			if( v.empty() ){
				ans.push_back( a[a.size()-1] );
				break;
			}
			v.push_back( a[a.size()-1] );
		}
		double length = 0;
		for(int i=1 ; i < ans.size() ; i++ ){
			length += dist( ans[i-1] , ans[i] );
		}
		printf("%.1f\n", length );
	}
}

Measured memory_bytes: 0
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "

using namespace std;
///check n=1;
///check corner case;

int main()
{
  ll a,b,c;
   set<ll>ara;
   cin>>a>>b>>c;
   ara.insert(a);
   ara.insert(b);
   ara.insert(c);
   if(ara.size()==2)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int num, i = 0, xx, yy, ax, ay, ah = 0, hh;
	cin >> num;
	vector<int> x(num), y(num), h(num);
	for (; i < num; i++)
		scanf("%d%d%d", &x[i], &y[i], &h[i]);
	for (i = 0; i < num; i++) {
		if (h[i] != 0) {
			xx = x[0];
			yy = y[0];
			hh = h[0];
			x[0] = x[i];
			y[0] = y[i];
			h[0] = h[i];
			x[i] = xx;
			y[i] = yy;
			h[i] = hh;
			break;
		}
	}
	for (yy = 0; yy <= 100; yy++) {
		for (xx = 0; xx <= 100; xx++) {
			hh = h[0] + abs(x[0] - xx) + abs(y[0] - yy);
			for (i = 1; i < num; i++) {
				if (h[i] == 0) {
					if (hh > abs(x[i] - xx) + abs(y[i] - yy))
						break;
				}
				else if (hh != h[i] + abs(x[i] - xx) + abs(y[i] - yy))
					break;
			}
			if (i == num && ah <= hh) {
				ax = xx;
				ay = yy;
				ah = hh;
			}
		}
	}
	printf("%d %d %d\n", ax, ay, ah);
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 62)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll n, c0, c1, c2, c3;

int main()
{
    fastio;
    string s;

    cin >> n;
    for1(i, n) {
        cin >> s;
        if(s[0] == 'A')
            c0++;
        else if(s[0] == 'W')
            c1++;
        else if(s[0] == 'T')
            c2++;
        else
            c3++;
    }

    cout << "AC x " << c0 << EL;
    cout << "WA x " << c1 << EL;
    cout << "TLE x " << c2 << EL;
    cout << "RE x " << c3 << EL;

    return 0;
}


Measured memory_bytes: 3656