akhauriyash/Code-Regression huggingface dataset:
n,m=map(int, input().split())
ball=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
    x, y=map(int, input().split())
    x-=1
    y-=1
    ball[x]-=1
    ball[y]+=1
    if red[x]:
        red[y]=True
        if ball[x]==0:
            red[x]=False

print(red.count(True))

Measured memory_bytes: 10132
use std::cmp;

fn main(){
  loop {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];

    if n == 0 && k == 0 { break; }

    let mut cv: Vec<bool> = vec![false; n+1];

    for _ in 0 .. k {
      let c: usize = read();
      cv[c] = true;
    }

    let mut mxl: usize = 1;
    let mut av: Vec<usize> = vec![0; n+1];
    
    if cv[0] {
      for i in 1 .. n+1 {
        if cv[i] {
          if cv[i-1] {
            av[i] = av[i-1] + 1;
          } else {
            av[i] = 1;
          }
        }
      }
      
      let mut mv: Vec<usize> = vec![0; n+1];

      mv[n] = av[n];
      
      for i in (1 .. n).rev() {
        if av[i] > 0 {
          if av[i+1] > 0 {
            mv[i] = mv[i+1];
          } else {
            mv[i] = av[i];
          }
        }
      }

      for i in 1 .. n+1 {
        if !cv[i] {
          let s = 1 +
                  if i > 1 { mv[i-1] } else { 0 } +
                  if i < n { mv[i+1] } else { 0 };
          mxl = cmp::max(mxl, s);
        }
      }
    } else {
      for i in 1 .. n+1 {
        if cv[i] {
          if cv[i-1] {
            av[i] = av[i-1] + 1;
            mxl = cmp::max(mxl, av[i]);
          } else {
            av[i] = 1;
          }
        }
      }
    }
    
    println!("{}", mxl);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

int main(){
    int a,b;
    cin>>a>>b;
    int A[a][b],B[b],C[a];
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin>>A[i][j];
        }
    }
    for(int k=0;k<b;k++){
        cin>>B[k];
    }
    for(int p=0;p<a;p++){
        C[p]=0;
    }
    for(int m=0;m<a;m++){
        for(int n=0;n<b;n++){
            C[m]+=A[m][n]*B[n];
        }
    }
    for(int o=0;o<a;o++){
        cout<<C[o]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d+1, 0);
  vector<int> c(d+1, 0);
  for(int i=1; i<=d; i++) cin >> p[i] >> c[i];

  int ans = 1e9;
  for(int i=0; i<(1<<d); i++){
    int s = 0, num = 0, tmp = 0;
    for(int j=0; j<d; j++){
      if( i >> j & 1 ){
        s += 100*(j+1) * p[j+1] + c[j+1];
        num += p[j+1];
      }else{
        tmp = j+1;
      }
    }
    if( s < g ){
      int t = 100 * tmp;
      int a = (g - s + t - 1) / t;
      if( a >= p[tmp] ) continue;
      num += a;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;

  return 0;
}




//


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

#define mod 1000000007

typedef long long ll;

using namespace std;

// http://www.tbasic.org/reference/old/ExEuclid.html
// https://qiita.com/rintaromasuda/items/be6510090af04bad833d

ll modpow(ll x, ll y, ll m) {
    ll p;
    if (y == 0) {
        return 1;
    }
    p = modpow(x, y / 2, m) % m;
    p = (p * p) % m;
    return (y % 2 == 0) ? p : (x * p) % m;
}

ll modinverse(ll a, ll m) {
    return modpow(a, m - 2, m);
}

ll combination(int n, int r) {
    int i;
    ll u, d, inverse;

    u = 1;
    for (i = n; i > n - r; i--) {
        u = (u * i) % mod;
    }
    d = u;
    for (i = r; i > 1; i--) {
        inverse = modinverse(i, mod);
        d = (d * inverse) % mod;
    }
    return d;
}

int main() {
    int N, M;
    int i;
    int num;
    ll ans;
    int count;
    vector <int> prime = {2};
    bool f;

    cin >> N >> M;

    count = 0;
    for (i = 3; i <= sqrt(M); i += 2) {
        f = true;
        for (int x : prime) {
            if (i % x == 0) {
                f = false;
                break;
            }
        }
        if (f) {
            prime.push_back(i);
        }
    }

    vector <int> c(prime.size(), 0);
    num = M;
    for (i = 0; i < prime.size(); i++) {
        while (num % prime[i] == 0) {
            c[i]++;
            num = num / prime[i];
        }
    }
    if (num != 1) {
        prime.push_back(num);
        c.push_back(1);
    }

    // for (i = 0; i < prime.size(); i++) {
    //     if (c[i] != 0) {
    //         cout << prime[i] << " " << c[i] << endl;
    //     }
    // }

    ans = 1;
    for (i = 0; i < prime.size(); i++) {
        if (c[i] != 0) {
            ans *= combination(c[i] + N - 1, c[i]);
            ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string b;
    map<string, string> mp;
    mp["A"] = "T";
    mp["T"] = "A";
    mp["C"] = "G";
    mp["G"] = "C";
    cin >> b;
    cout << mp[b] << endl;
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll cn = x / d;
    cn = min(cn, k);
    k -= cn;
    x -= cn * d;
    if (k & 1) cout << d - x << '\n';
    else cout << x << '\n';
    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static char? Find(Dictionary<char, int> dic, char c0, char c1)
        {
            foreach (var pair in dic.Where(pair => pair.Value > 0).OrderByDescending(pair => pair.Value))
            {
                char c = pair.Key;
                if (c != c0 && c != c1) { return c; }
            }
            return null;
        }

        private static bool Solve(string S)
        {
            var dic = new Dictionary<char, int>();
            for (char c = 'a'; c <= 'z'; ++c) { dic[c] = 0; }
            foreach (char c in S) { ++dic[c]; }
            char c0 = ' ';
            char c1 = ' ';
            for (int i = 0; i < S.Length; ++i)
            {
                var c = Find(dic, c0, c1);
                if (c.HasValue)
                {
                    --dic[c.Value];
                    c0 = c1;
                    c1 = c.Value;
                }
                else
                {
                    return false;
                }
            }
            return true;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 17888
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	string s;
	cin >> s;
	int n = s.length();
	
	vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
	dp[0][0] = 1;
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < 2; i++) {
			if(i) {
				dp[k + 1][i] += 3 * dp[k][i];
			} else {
				if(s[k] == '0') {
					dp[k + 1][i] += dp[k][i];
				} else {
					dp[k + 1][i + 1] += dp[k][i];
					dp[k + 1][i] += 2 * dp[k][i];
				}
			}
			
			dp[k + 1][i] %= P;
			dp[k + 1][i + 1] %= P;
		}
	}
	
	cout << (dp[n][0] + dp[n][1]) % P << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 8796
#include<stdio.h>

int
main(int argc, char *argv[])
{
        int n;
        char buf[5];
        int table[10][10][10][10];
        int i,j,k,l;
        int cnt;

        for (i = 0; i < 10; i++)
                for (j = 0; j < 10; j++)
                        for (k = 0; k < 10; k++)
                                for (l = 0; l < 10; l++)
                                        table[i][j][k][l] = i + j + k + l;
        while (fgets(buf, 5, stdin)) {
                sscanf(buf, "%d", &n);
                if (n > 36) {
                        printf("0\n");
                        continue;
                }
                cnt = 0;
                for (i = 0; i < 10; i++)
                        for (j = 0; j < 10; j++)
                                for (k = 0; k < 10; k++)
                                        for (l = 0; l < 10; l++)
                                                if (table[i][j][k][l] == n) cnt++;
                printf("%d\n", cnt);
        }
        return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<ll> x,a,len;
vector<ll> sum;

bool ok(ll X){
  vector<ll> rs(n+1,0);
  rep(i,n){
    ll add=-(sum[i]-X);
    if(add<=0){
      rs[0]++;
      rs[n]--;
      continue;
    }
    if(add>a[m-1])return false;
    ll lb=0,ub=n+1;
    while(ub-lb>1){
      ll mid=(lb+ub)/2;
      if(add<=a[m-1]-mid*mid) lb=mid;
      else ub=mid;
    }
    ll l=max(0LL,i-lb);
    ll r=min(n-1LL,i+lb);
    rs[l]++;
    rs[r+1]--;
  }
  rep(i,n)rs[i+1]+=rs[i];
  rep(i,n)if(rs[i]==n)return true;
  return false;
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    x.resize(m); a.resize(m); len.resize(m);
    rep(i,m-1){
      cin>>a[i]>>x[i];
      ll lb=0,ub=n+1;
      while(ub-lb>1){
        ll mid=(lb+ub)/2;
        if(a[i]-mid*mid>=0) lb=mid;
        else ub=mid;
      }
      len[i]=lb;
    }
    cin>>a[m-1];

    vector<ll> imos[2];
    ll l=0,r=n+1;
    {
      imos[0].resize(n+2);
      imos[1].resize(n+2);
      rep(i,n+2)imos[0][i]=imos[1][i]=0;
      rep(i,m-1){
        imos[0][min(r,x[i]+2)]+=-2;
        imos[0][min(r,x[i]+len[i]+1)]+=+2;
        imos[1][max(l,x[i]-2)]+=-2;
        imos[1][max(l,x[i]-len[i]-1)]+=+2;
      }
      rep(i,r-1)imos[0][i+1]+=imos[0][i];
      rep(i,r-1)imos[1][r-1-i]+=imos[1][r-i];
      rep(i,m-1){
        imos[0][min(r,x[i]+1)]+=-1;
        imos[0][min(r,x[i]+len[i]+1)]+=2*(len[i]-1)+1;
        imos[1][max(l,x[i]-1)]+=-1;
        imos[1][max(l,x[i]-len[i]-1)]+=2*(len[i]-1)+1;
      }
      rep(i,r-1)imos[0][i+1]+=imos[0][i];
      rep(i,r-1)imos[1][r-1-i]+=imos[1][r-i];
      rep(i,m-1){
        imos[0][min(r,x[i]+1)]+=a[i];
        imos[0][min(r,x[i]+len[i]+1)]+=len[i]*len[i]-a[i];
        imos[1][max(l,x[i]-1)]+=a[i];
        imos[1][max(l,x[i]-len[i]-1)]+=len[i]*len[i]-a[i];
      }
      rep(i,r-1)imos[0][i+1]+=imos[0][i];
      rep(i,r-1)imos[1][r-1-i]+=imos[1][r-i];
      rep(i,m-1)imos[0][x[i]]+=a[i];
    }

    sum.resize(n);
    repl(i,1,n+1)sum[i-1]=imos[0][i]+imos[1][i];
    ll lb=0,ub=1e18;
    while(ub-lb>1){
      ll mid=(lb+ub)/2;
      if(ok(mid)) lb=mid;
      else ub=mid;
    }
    cout<<lb<<endl;
  }
  return 0;
}



Measured memory_bytes: 39668
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
using ll = long long;
using namespace std;

const ll MOD = 1000000007;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i,n) cin >> a[i];
    
    vector<vector<ll>> ans(n+1,vector<ll>(k+1,0));
    ans[0][0] = 1;
    rep(i,n){
        // 累積和
        vector<ll> sum(k+2,0);
        rep(j,k+1) sum[j+1] = (ans[i][j] + sum[j]) % MOD;
        // DP遷移
        rep(j,k+1) ans[i+1][j] = (sum[j+1] - sum[max(0,j-a[i])] + MOD) % MOD;
    }
    cout << ans[n][k] << endl;
    return 0;
}

Measured memory_bytes: 83104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    string S;
    cin >> S;
    int c0 = count(all(S),'0');
    int c1 = count(all(S),'1');
    int cm=min(c0,c1);
    
    cout << 2*cm << endl;
} 


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (B < C || D < A) cout << 0 << endl;
  else cout << min(B, D) - max(A, C) << endl;
}


Measured memory_bytes: 3608
use proconio::*;

fn main() {
    input! {
        n: i128,
    };

    let mut v = vec![];
    for _ in 0..n {
        input! { a: i128 };
        v.push(a);
    }

    if v.contains(&0) {
        println!("0");
        return;
    }

    let mut ans: i128 = 1;
    let limit: i128 = 1000000000000000000;
    for value in v {
        ans *= value;
        if ans > limit {
            println!("-1");
            return;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 5656
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[n + 1][n * 1000 + 1];
  dp[0][0] = 0;
  FOR(i, 1, n * 1000 + 1) {
    dp[0][i] = LINF;
  }
  rep(i, n) {
    rep(j, n * 1000 + 1) {
      if(j < v[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
    }
  }
  ll res = 0;
  rep(i, n * 1000 + 1) {
    if(dp[n][i] <= W) {
      res = i;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
using namespace std;

int n, l;
string s[111];

int cmp(const string &a, const string &b) {
	return a+b < b+a;
}

int main() {
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n, cmp);
	for(int i=0;i<n;i++)
		cout<<s[i];
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;

int main(){
    ld a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    ld L = -1;
    ld R = e+1;
    Pll ans;
    rep(i,200){
        ld X = (L+R)/2;
        ld xx = X/100;

        rep(na,32){
            rep(nb,32){
                if(a*na*100 + b*nb*100 > f)break;
                rep(nc,3001){
                    if(a*na*100 + b*nb*100 + c*nc > f)break;
                    rep(nd, 3001){
                        if(a*na*100 + b*nb*100 + c*nc + d*nd > f)break;
                        ld sum = (a*ld(na*100) + b*ld(nb*100) + c*ld(nc) + d*ld(nd));
                        ld sugar = c*ld(nc) + d*ld(nd);
                        //cout << xx << endl;
                        if(sum != 0 && sugar >= xx*sum && sugar <= e*(a*ld(na*100) + b*ld(nb*100))/ld(100)){
                            L = X;
                            ans.fi = sum;
                            ans.se = sugar;
                            goto gt;
                        }                        
                    }
                }
            }
        }
        R = X;
        gt:
        continue;
    }
    cout << ans.fi << " " << ans.se << endl;
}

Measured memory_bytes: 3728
fun main() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    val dp = IntArray(n) { Int.MAX_VALUE }

    dp[0] = 0
    dp[1] = Math.abs(h[0] - h[1])

    var count = 2
    while (count < n) {
        for (i in 1..k) {
            if (count < i) break
            dp[count] = Math.min(dp[count], dp[count - i] + Math.abs(h[count] - h[count - i]))
        }
        count++
    }
    println(dp[n - 1])
}

Measured memory_bytes: 51492
#include<iostream>
using namespace std;
int main()
{
	int n,sj,so;
	sj=0;
	so=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			so=so+a[i];
		}
		else
		{
			sj=sj+a[i];
		}
	}
	if(so%2==sj%2)
	{
		printf("%s","YES");
	}
	else
	{
		printf("%s","NO");
	}
}

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

using namespace std;

int main(void){

    int card[3][3];
    bool flag[3][3];

    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> card[i][j];
            flag[i][j] = false;
        }
    }

    int n;
    int ans = 0;
    cin >> n;

    for (int i = 0; i < n; i++){
        int x; cin >> x;

        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if(x == card[i][j]) flag[i][j] = true;
            }
        }
    }

    for (int i = 0; i < 3; i++){
        if(flag[i][0] && flag[i][1] && flag[i][2] && flag[i][0] == true) ans = 1;
        if(flag[0][i] && flag[1][i] && flag[2][i] && flag[0][i] == true) ans = 1;
    }

    if(flag[0][0] && flag[1][1] && flag[2][2] && flag[0][0] == true) ans = 1;
    if(flag[0][2] && flag[1][1] && flag[2][0] && flag[0][2] == true) ans = 1;
    
    cout << (ans == 1 ? "Yes" : "No") << endl;


    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int now = 1;
  while (now * 2 <= n)
    now *= 2;
  cout<<now<<'\n';
  return 0;
}

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

using namespace std;
const int INF = 1001001001;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n + 1, INF);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i=2;i<=n;++i) {
        for (int j=1;j<=k;++j) {
            if (i - j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            else break;
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){
    ll x;
    cin >> x;
    
    ll cnt = 0;
    cnt += x / 11;
    x -= 11 * cnt;
    cnt *= 2;
    
    if(x > 6){
        cnt += 2;
    }
    else if(x == 0){
        cout << cnt << endl;
        return 0;
    }
    else{
        cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        exawizards2019_a solver = new exawizards2019_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class exawizards2019_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            if (A == B && B == C) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 21968
arr = []
ar = [0]
5.times do 
    i = gets.chomp.to_i
    iti = i % 10
    moku = 0
    if iti != 0
    moku = 10 - iti
    ar << moku
    end
    arr << i + moku
end
ar = ar.sort
puts arr.inject(:+) - ar.pop


Measured memory_bytes: 14236
//The Balance of the World
#include<bits/stdc++.h>
using namespace std;

int main(){
  while(true){
    string s;
    getline(cin, s);
    if(s==".")break;
    bool flag=true;
    stack<char> st;
    for(int i=0; i<s.length(); i++){
      if(s[i]=='(' || s[i]=='[')st.push(s[i]);
      else if(s[i]==')'){
        if(st.size()==0){flag=false; break;}
        if(st.top()=='(')st.pop();
        else{flag=false; break;}
      }
      else if(s[i]==']'){
        if(st.size()==0){flag=false; break;}
        if(st.top()=='[')st.pop();
        else{flag=false; break;}
      }
    }
    if(st.size()!=0)flag=false;
    if(flag)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int k;
  int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << v[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

// 初期時読み込み
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

const int INF = 2002002002;

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    map<ll, ll> city;
    REP(i, N + 1)
        city.insert(make_pair(i, 0));
    REP(i, M) {
        city[a[i]]++;
        city[b[i]]++;
    }
    REP(i, N + 1) {
        if (i == 0) continue ;
        print(city.at(i));
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

#include <bitset>


class C {
	int n;
	const int mask{ 0b1111111111 };
	vi shops;
	vvi val;
public:
	C()
	{
		cin >> n;
		shops.resize(n);
		val.resize(n, vi(11));

		REP(i, n)
		{
			int shop{ 0 };
			REP(j, 10)
			{
				int x;
				cin >> x;
				if (x)
					shop |= (1 << j);
			}
			shops[i] = shop;

		}

		REP(i, n)
			REP(j, 11)
			cin >> val[i][j];
		
	}

	void solve()
	{
		int ans{ -INTMAX };

		REP1C(me, mask)
		{
			int tmp{ 0 };
			REP(u, n)
			{
				int cnt{ 0 };
				int chk{ me & shops[u] };
				for (int bit{ 0 }; bit < 10; bit++)
					if (chk & (1 << bit))
						cnt++;
				tmp += val[u][cnt];
			}

			chmax(ans, tmp);
		}

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll a[100010];

ll dp[60][2];

int main () {

    ll n,k;cin>>n>>k;

    rep(i,n) cin>>a[i];

    memset(dp,-1,sizeof(dp));

    dp[0][0]=0;

    rep(i,50) {
        ll mask = 1LL<<(50-i-1);
        ll cnt=0;
        rep(j,n) if(a[j]&mask) cnt++;
        ll del0 = cnt*mask;
        ll del1 = (n-cnt)*mask;
        if (dp[i][0]!=-1) {
            if (k&mask) {
                dp[i+1][0]=max(dp[i+1][0],dp[i][0]+del1);
                dp[i+1][1]=max(dp[i+1][1],dp[i][0]+del0);
            } else {
                dp[i+1][0]=max(dp[i+1][0],dp[i][0]+del0);
            }
        }
        if (dp[i][1]!=-1) {
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]+max(del0,del1));
        }
    }

    cout<<max(dp[50][0],dp[50][1])<<endl;

}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;

int main(){
    string S;
    cin >> S;
    if (S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]) cout <<"Yes";
    else if(S[0]==S[2] && S[0]!=S[1] && S[1]==S[3]) cout <<"Yes";
    else if(S[0]==S[3] && S[0]!=S[1] && S[1]==S[2]) cout <<"Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int m, f, r;

	while (1) {
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1) break;

		if (m == -1 || f == -1) {
			cout << "F" << endl;
			continue;
		}

		int sum = m + f;

		if (sum >= 80) {
			cout << "A" << endl;
			continue;
		}
		else if (sum >= 65) {
			cout << "B" << endl;
			continue;
		}
		else if (sum >= 50) {
			cout << "C" << endl;
			continue;
		}
		else if (sum >= 30 && r >= 50) {
			cout << "C" << endl;
			continue;
		}
		else if (sum >= 30 && r < 50) {
			cout << "D" << endl;
			continue;
		}
		else {
			cout << "F" << endl;
			continue;
		}

	}

	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;

int main(){
	int n,ans;

	while( cin >> n ){
		ans = 0;
		if(n<=36){
			for(int a=0 ; a<=9 ; a++){
				for(int b=0 ; b<=9 ; b++){
					for(int c=0 ; c<=9 ; c++){
						for(int d=0 ; d<=9 ; d++){
							if((a+b+c+d)==n){
								ans++;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
} 

Measured memory_bytes: 0
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]
tmp = [1 for i in range(N)]
res = X

for i in range(1, D+1):
    for j in range(N):
        if tmp[j] == i:
            res += 1
            tmp[j] += A[j]
    
print(res)



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

main(){
  int i,j=0;
  char b[21],a[21];
  scanf("%s",b);
  j=strlen(b);
   for(i=0;i<j;i++){
     a[i]=b[j-i-1];
}
   a[j]='\0';
   printf("%s\n",a);
return 0; 
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    v_int a(n);

    bool one = false;
    irep(i, n) {
        cin >> a[i];
        if(a[i] == 1) {
            one = true;
        }
    }
    
    if(one == false) {
        cout << -1 << endl;
        return 0;
    }

    int j = 1;
    irep(i, n) {
        if(a[i] == j) {
            j++;
        }
    }

    cout << n - (j-1) << endl; 

    return 0;
}
/** atcodr **/


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;

string solve() {
  string res = "";
  for (int i = 0; i < str.size() / 2; ++i) {
	string a = str.substr(0, i);
	string b = str.substr(i, i);
	if (a == b) res = a;
  }
  return res;
}

int main() {
  while (cin >> str) {
	cout << solve().size()*2 << endl;
  }
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int64_t> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  int64_t mi=1e18;
  for(int i=0;i<N-K+1;i++){
    int64_t l=v.at(i);
    int64_t r=v.at(i+K-1);
    int64_t res=abs(l-r)+min(abs(l),abs(r));
    if(mi>res){
      mi=res;
    }
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int I;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    int n,k;
    double ans=0,m=0;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    m=k;
    for(int i=0;i<k;i++){
        m+=a[i];
    }
    ans=m;
    for(int i=k;i<n;i++){
        m+=a[i]-a[i-k];
        ans=max(ans,m);
    }
    ans = double(ans);
    cout<<fixed;
    cout<<setprecision(8)<<ans/2.0<<endl;



    return 0;
} //カモンAC

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int mv=0;
	while(b<=a)
	{
		b*=2;
		mv++;
	}
	while(c<=b)
	{
		c*=2;
		mv++;
	}
	if(mv<=k) cout<<"Yes\n";
	else cout<<"No\n";
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3636
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	ll sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
#define inf 9999998
#define GC getchar()
#define g(a,b,c,d) g[a][b][c][d]
using namespace std;
inline void min(int &a,int b){
	a=(a<b?a:b);
}
int n,m,f[45][45][45][45],xx,yy,sum[45][45],g[45][45][45][45];
bool mk[45][45][45][45];
char mp[45][45];
//inline int g(int xa,int ya,int xb,int yb){
//	return sum[xb][yb]-sum[xb][ya-1]-sum[xa-1][yb]+sum[xa-1][ya-1];
//}
inline bool is(int xa,int ya,int xb,int yb){
	if(xa>xx||xb<xx||ya>yy||yb<yy)return 0;
	return 1;
}
void dfs(int xa,int ya,int xb,int yb){
	if(mk[xa][ya][xb][yb])return;
	if(!mk[xa][ya][xb][yb])mk[xa][ya][xb][yb]=1;
	for(int i=xa;i<xb;i++){
		for(int j=ya;j<yb;j++){
			//if(g(xa,j+1,i,yb)>0||g(i+1,ya,xb,j)>0)continue;
			if(is(xa,ya,i,j)){
				dfs(xa,ya,i,j);min(f[xa][ya][i][j],f[xa][ya][xb][yb]+g(xa,j+1,i,yb)+g(i+1,ya,xb,j));
			}
			if(is(i+1,j+1,xb,yb)){
				dfs(i+1,j+1,xb,yb);min(f[i+1][j+1][xb][yb],f[xa][ya][xb][yb]+g(xa,j+1,i,yb)+g(i+1,ya,xb,j));
			}
			if(is(i+1,ya,xb,j)){
				dfs(i+1,ya,xb,j);min(f[i+1][ya][xb][j],f[xa][ya][xb][yb]+g(xa,ya,i,j)+g(i+1,j+1,xb,yb));
			}
			if(is(xa,j+1,i,yb)){
				dfs(xa,j+1,i,yb);min(f[xa][j+1][i][yb],f[xa][ya][xb][yb]+g(xa,ya,i,j)+g(i+1,j+1,xb,yb));
			}
		}
	}//printf("%d %d %d %d %d\n",xa,ya,xb,yb,f[xa][ya][xb][yb]);
}
int main(){
	//freopen("haner3.in","r",stdin);
	//freopen("haner.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char ch=GC;
			while(ch!='+'&&ch!='#'&&ch!='P')ch=GC;
			mp[i][j]=ch;if(ch=='P')xx=i,yy=j;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(mp[i][j]=='#');
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			for(int ii=i;ii<=n;ii++){
				for(int jj=j;jj<=m;jj++){
					f[i][j][ii][jj]=inf;g[i][j][ii][jj]=sum[ii][jj]-sum[ii][j-1]-sum[i-1][jj]+sum[i-1][j-1];
				}
			}
		}
	}
	f[1][1][n][m]=0;
	for(int xa=1;xa<=n;xa++){
		for(int ya=1;ya<=m;ya++){
			for(int xb=n;xb>=xa;xb--){
				for(int yb=m;yb>=ya;yb--){
					for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			//if(g(xa,j+1,i,yb)>0||g(i+1,ya,xb,j)>0)continue;
			if(is(xa,ya,i,j)){
				dfs(xa,ya,i,j);min(f[xa][ya][i][j],f[xa][ya][xb][yb]+g(xa,j+1,i,yb)+g(i+1,ya,xb,j));
			}
			if(is(i+1,j+1,xb,yb)){
				dfs(i+1,j+1,xb,yb);min(f[i+1][j+1][xb][yb],f[xa][ya][xb][yb]+g(xa,j+1,i,yb)+g(i+1,ya,xb,j));
			}
			if(is(i+1,ya,xb,j)){
				dfs(i+1,ya,xb,j);min(f[i+1][ya][xb][j],f[xa][ya][xb][yb]+g(xa,ya,i,j)+g(i+1,j+1,xb,yb));
			}
			if(is(xa,j+1,i,yb)){
				dfs(xa,j+1,i,yb);min(f[xa][j+1][i][yb],f[xa][ya][xb][yb]+g(xa,ya,i,j)+g(i+1,j+1,xb,yb));
			}
		}
	}//printf("%d %d %d %d %d\n",xa,ya,xb,yb,f[xa][ya][xb][yb]);
				}
			}
		}
	}
	int ans=inf;
	for(int i=1;i<=xx;i++){
		for(int j=1;j<=yy;j++){
			for(int ii=xx;ii<=n;ii++){
				for(int jj=yy;jj<=m;jj++){
					min(ans,f[i][j][ii][jj]+g(i,j,xx,yy));
					min(ans,f[i][j][ii][jj]+g(xx,j,ii,yy));
					min(ans,f[i][j][ii][jj]+g(i,yy,xx,jj));
					min(ans,f[i][j][ii][jj]+g(xx,yy,ii,jj));
				}
			}
		}
	}
	printf("%d",ans);
}

/*
2 3
#H#
###
*/

Measured memory_bytes: 34304
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll ok = 1;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i ++) {
    	if (i % 2 == 0) {
    		if (s[i] != 'h') ok = 0;
		}
		else {
			if (s[i] !='i') ok = 0;
		}
	}
	if (s.size() & 1) ok =0;
	if (ok) cout << "Yes";
	else cout << "No";
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const long long INF=(long long)0x3f3f3f3f3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    //freopen("output.txt","w+",stdout);
    //freopen("input.txt","r+",stdin);
    int n,d,ans=1;
    cin>>d>>n;
    for(int i=0;i<d;i++)
        ans*=100;
    cout<<(n!=100?n*ans:101*ans);
    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int N,K; cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    for(int loop=1; loop<=min(K,41); ++loop){
        vector<int> B(N, 0);
        REP(i,N){
            int left = max(0, i-A[i]);
            int right = min(N-1, i+A[i]);
            B[left]++;
            if(right+1<N) B[right+1]--;
        }
        REP(i,N) if(0<i) B[i] += B[i-1];
        REP(i,N) A[i] = min(N,B[i]);
    }

    REP(i,N) cout << A[i] << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 4824
#include <iostream>
using namespace std;

int main(){
  int n;

  while(cin >> n ,n){
    string str;
    int d[] = {1,2,3,4,5,6};

    for(int i = 0 ; i < n ; i++){
      cin >> str;

      int tmp = d[0];

      if(str == "north"){
	d[0] = d[4];
	d[4] = d[5];
	d[5] = d[1];
	d[1] = tmp;
      }
      else if(str == "east"){
	d[0] = d[2];
	d[2] = d[5];
	d[5] = d[3];
	d[3] = tmp;
      }
      else if(str == "west"){
	d[0] = d[3];
	d[3] = d[5];
	d[5] = d[2];
	d[2] = tmp;
      }
      else{
	d[0] = d[1];
	d[1] = d[5];
	d[5] = d[4];
	d[4] = tmp;
      }
    }
    cout << d[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <vector>
#include <algorithm>
#define absf std::abs
#define maxf std::max
#define minf std::min
typedef long long ll;
typedef long double ld;
const int _MAXN = 103;

int N;

int plansza[3][_MAXN];

int main() {
    scanf("%d", &N);
    for(int j = 1; j <= 2; ++j)
        for(int i = 1; i <= N; ++i)
            scanf("%d", &plansza[j][i]);


    // for(int j = 1; j <= 2; ++j) {
        // for(int i = 1; i <= N; ++i) {
            // printf("%d ", plansza[j][i]);
        // }
        // printf("\n");
    // }
    
    // printf("\n");
    for(int j = 1; j <= 2; ++j) {
        for(int i = 1; i <= N; ++i) {
            plansza[j][i] += maxf(plansza[j - 1][i], plansza[j][i - 1]);
            // printf("%d ", plansza[j][i]);
        }
        // printf("\n");
    }

    printf("%d\n", plansza[2][N]);
    return 0;
}



Measured memory_bytes: 128