akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll val[109],w[109];
ll dp[109][100009];
ll knapsack(ll n,ll W)
{
    if(dp[n][W]!=-1)
    {
        return dp[n][W];
    }
    if(n==0)
    {
        if(W>=w[n])
        {
            return dp[n][W] = val[n];
        }
        else return dp[n][W] = 0;
    }
    if(W>=w[n])
    {
        return dp[n][W] = max(val[n]+knapsack(n-1,W-w[n]),knapsack(n-1,W));
    }
    else return dp[n][W] = knapsack(n-1,W);
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];;
    }
    memset(dp,-1,sizeof dp);
    cout<<knapsack(n-1,m)<<endl;
    return 0;
}



Measured memory_bytes: 85376
from functools import reduce
from fractions import gcd

N, M, *A = map(int, open(0).read().split())

def lcm(x, y):
    return x * y // gcd(x, y)

def sub_by_2(n):
    cnt = 0
    while n % 2 == 0:
        n //= 2
        cnt += 1
    return cnt

lcm_2 = [sub_by_2(n // 2) for n in A]
if all(lcm_2[0] == v for v in lcm_2):
    num = reduce(lcm, [v // 2 for v in A])
    res = M // num
    print(res // 2 + res % 2)
else:
    print(0)


Measured memory_bytes: 96824
W,H,N = map(int, input().split())
m = [[0]*W]*H
import numpy as np
arr = np.array(m)

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        arr[:,:x] = 1
    if a == 2:
        arr[:, x:] = 1
    if a == 3:
        arr[H - y:,:] = 1
    if a == 4:
        arr[:H-y,:] = 1
print(np.count_nonzero(arr == 0))



Measured memory_bytes: 27228
abc = input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])
# 12
if a > b:
  a, b = b, a
# 13
if a > c:
  a, c = c, a
# 23
if b > c:
  b, c = c, b
print("{0} {1} {2}".format(a, b, c))

Measured memory_bytes: 7640
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string s;
	cin >> s;
	bool b=false;
	if(s[0]==s[3]&&s[1]==s[2]) b=true;
	if(s[0]==s[1]&&s[3]==s[2]) b=true;
	if(s[0]==s[2]&&s[3]==s[1]) b=true;
	if(s[0]==s[1]&&s[0]==s[2]&&s[0]==s[3]) b=false;
	cout << (b ? "Yes" : "No") << endl;
//////////////////////////////////////////////
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))

ans = 0
all_sum = N*(N+1)/2

mod = 10**9+7

for i in range(K,N+2):
    min_val = i*(i-1)/2
    max_val = N*(N+1)/2 - (N-i+1)*(N-i)/2
    ans += (int(max_val) - int(min_val) + 1) % mod

#    print(i, min_val, max_val)                                                                        


print(ans%mod)







Measured memory_bytes: 70968
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n, x;
    cin >> n >> x;
    long long weight = 0;
    long long ans = n;

    vector<long long> m(n);
    for(long long i = 0; i < n; i++){
        cin >> m[i];
        weight += m[i];
    }

    sort(m.begin(), m.end());

    ans += (x-weight)/m[0];

    cout << ans << endl;
    return 0;
}

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

using namespace std;
string s;
int mar[200];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> s;
    if (s.size() == 26) {
        int ok = 0;
        for (int i = 0; i < 26; i++)
            if (s[i] == 'z' - i) ok++;
        if (ok == 26) {
            cout << "-1\n";
            return 0;
        }
    }
    for (int i = 0; i < s.size(); i++) mar[s[i] - 'a'] = 1;
    int mex = -1;
    for (int i = 25; i >= 0; i--)
        if (mar[i] == 0) mex = i;
    if (mex == -1) {
        int fnd = 0;
        for (int j = 25; j >= 0; j--) {
            for (int k = s[j] - 'a' + 1; k <= 25; k++)
            if (mar[k] == 0) {
                s.resize(j + 1);
                s[j] = k + 'a';
                fnd = 1;
                break;
            }
            if (fnd) break;
            mar[s[j] - 'a'] = 0;
        }
        cout << s << "\n";
    }
    else {
        cout << s << (char)(mex + 'a') << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

ll weight[110];
ll value[110];
ll dp[110][100100] = {0};

signed main() {
  ll N, W;
  cin >> N >> W;

  rep(i, N) {
    cin >> weight[i] >> value[i];
  }

  rep(i, N) {
    rep(sum_w, W + 1) {
      // i 番目の品物を選ぶ場合
      if (sum_w - weight[i] >= 0) {
        chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }

      // i 番目の品物を選ばない場合
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }

  COUT(dp[N][W]);
  return 0;
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int SZ=3005;
ll memo[SZ][SZ][4];
ll arr[SZ][SZ];
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(memo,-1,sizeof(memo));
    int n,m,k; cin>>n>>m>>k;
    for(int i=0;i<k;i++){
        int x,y,c; cin>>x>>y>>c;
        arr[x-1][y-1]=c;
    }
    memo[0][0][0]=0;
    if(arr[0][0]>0ll) memo[0][0][1]=arr[0][0];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<4;k++){
                if(i && k==0){
                    ll xx=max(memo[i-1][j][0],max(memo[i-1][j][1],max(memo[i-1][j][2],memo[i-1][j][3])));
                    if(xx!=-1ll) memo[i][j][k]=max(memo[i][j][k],xx);
                    if(arr[i][j]>0ll) memo[i][j][1]=max(memo[i][j][1],xx+arr[i][j]);
                }
                if(j){
                    if(memo[i][j-1][k]!=-1) memo[i][j][k]=max(memo[i][j][k],memo[i][j-1][k]);                    
                    if(k && arr[i][j]>0ll && memo[i][j-1][k-1]!=-1) memo[i][j][k]=max(memo[i][j][k],memo[i][j-1][k-1]+arr[i][j]);
                }
                //debug(memo[i][j][k]);
            }
        }
    }
    cout<<max(memo[n-1][m-1][0],max(memo[n-1][m-1][1],max(memo[n-1][m-1][2],memo[n-1][m-1][3])));
    return 0;
}

Measured memory_bytes: 356016
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, X := nextInt(), nextInt(), []int{}
	for i := 0; i < M; i++ {
		X = append(X, nextInt())
	}

	fmt.Printf("%d\n", ABC117C(N, X))
}

// ABC117C ...
func ABC117C(N int, X []int) int {
	sort.Ints(X)

	if N == 1 {
		return X[len(X)-1] - X[0]
	}

	dists := []int{}
	for i := 0; i < len(X)-1; i++ {
		dists = append(dists, X[i+1]-X[i])
	}
	sort.Ints(dists)

	res := 0
	for i := 0; i < len(dists)-N+1; i++ {
		res += dists[i]
	}

	return res
}



Measured memory_bytes: 7180
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,mid;
	cin >> n;
	mid = n / 2;
	map<int, int>mp;
	vector<int>arr(n),sortarr,tmp;
	rep(i, n) {
		cin >> arr[i];
		mp[arr[i]]++;
	}
	sortarr = arr;
	sort(all(sortarr));
	int one = sortarr[mid - 1], two = sortarr[mid];
	rep(i, n) {
		if (arr[i] <= one)cout << two << endl;
		else cout << one << endl;
	}

	return 0;
}



Measured memory_bytes: 13868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = sc.nextInt();
		int max = min;
		for(int i = 0; i < N-1; i++) {
			int a = sc.nextInt();
			min = Math.min(min, a);
			max = Math.max(max, a);
		}
		System.out.println(max - min);
	}

}


Measured memory_bytes: 21712
#include<iostream>
#include<cstdio>
#include<cmath>
#define maxn 10005
using namespace std;
long long ans=0,num1=0,num2=0;
int n;
pair<long long,long long>p[maxn];
int main()
{
    scanf("%d",&n);
    scanf("%lld%lld",&p[1].first,&p[1].second);
    if(p[1].first==p[1].second)p[1].first=p[1].second=1;
    for(int cnt=2;cnt<=n;cnt++)
    {
        scanf("%lld%lld",&p[cnt].first,&p[cnt].second);
        long long bpeo=max((p[cnt-1].first-1)/p[cnt].first+1,(p[cnt-1].second-1)/p[cnt].second+1);
        p[cnt].first*=bpeo;
        p[cnt].second*=bpeo;
    }
    printf("%lld\n",p[n].first+p[n].second);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

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

	set<char> s;

	for (int i = 0; i < n; i++) {
		char t;
		cin >> t;
		s.insert(t);
	}

	if (s.size() == 3) {
		cout << "Three" << endl;
	} else {
		cout << "Four" << endl;
	}

	return 0;
}


Measured memory_bytes: 888
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n,m;
	cin>>n>>m;

	vector<int> cnt(n);
	for(int i=0;i<m;i++){
		long long a,b;
		cin>>a>>b;
		a--,b--;
		cnt[a]++,cnt[b]++;
	}


	for(int i=0;i<n;i++){
		if(cnt[i]%2){
			cout<<"NO"<<endl;
			return 0;
		}	
	}
 
	cout<<"YES"<<endl;

	return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int a,b,c;cin >> a >> b >> c;cout << max(0,c - (a - b)) << endl;
  return 0;
}


Measured memory_bytes: 256
L=[0 for _ in range(10**5)]
n,k=map(int,input().split())
for i in range(n):
    a,b=map(int,input().split())
    L[a-1]+=b
tmp=0
for j in range(10**5):
    tmp+=L[j]
    if tmp>=k:
        print(j+1)
        break

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

using namespace std;
typedef long long ll;

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<ll> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    int ignore = n - (p - 1);
    while (ignore < n && ignore - 1 >= 0 && a[ignore] == a[ignore - 1])ignore--;
    // ignoreは上位p-1位以内の数相当のうち、最初のindex

    vector<ll> c_sum(n + 1);
    for (int i = 0; i < n; i++)c_sum[i + 1] = c_sum[i] + a[i];

    int first = -1;
    for (int i = 0; i < n; i++) {
        auto itr = upper_bound(a.begin(), a.end(), a[i]);
        if (itr == a.end()) {
            first = i;
            break;
        } else {
            int x = itr - a.begin() - 1; // a[i]と同じで一番最後のindex
            int range = ignore - x - 1; // a[i]が勝てないといけない数の個数
            ll want = c_sum[ignore] - c_sum[x + 1]; // [x+1, ignore-1]
            want -= a[i] * range;
            int maxDiff = a[n - p] - a[i]; // a[i]は少なくともa[n-p]と引き分けにならなければいけない
            if (want <= min(n - v, (ll) range) * m && maxDiff <= m) {
                first = i;
                break;
            }
        }
    }
    cout << n - first << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <vector>


using namespace std;

int main()
{
int i,j,N,Q,count=0,max=0;
vector<char> S;
vector<int> l,r,H;


cin>>N;
cin>>Q;
S = vector <char>(N,0);
H = vector <int>(N,0);
for(i=0;i<N;i++){
	cin>>S[i];
	H[i]=0;
}
l= vector <int>(Q,0);
r= vector <int>(Q,0);
for(i=0;i<Q;i++)
{
	cin>>l[i];
	cin>>r[i];
}

for(i=0;i<N-1;i++){
	if((S[i]=='A')&&(S[i+1]=='C')){
		H[i+1] = H[i] +1;
	}else{H[i+1]=H[i];}
}
for(i=0;i<Q;i++){
	
	max = H[r[i]-1]-H[l[i]-1] ;
	cout<<max<<endl;
}

return 0;
}	


Measured memory_bytes: 2048
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      String line = sc.nextLine();
      int a = line.length();
      char num;
      int Sum=0;
      int i=0;
      while(i<a){
        num = line.charAt(i);
        Sum += (num-'0');
        i++;
      }if(line.charAt(0)=='0'&&a==1) break;
      System.out.println(Sum);
    }
    sc.close();
  }
}


Measured memory_bytes: 26672
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template<class c> typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
		cerr << boolalpha << i; return *this;
	}

	template<class c, int=0> typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
		return *this << range(begin(i), end(i));
	}

sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c&) { ris; }
#endif
};
#define watch(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII > VP;
typedef vector<PLL > VPL;
typedef vector<double> VD;
typedef long double ld;

void solve(int ks) {
	int r, g, b, n;
	scanf("%d %d %d %d", &r, &g, &b, &n);
	int ans = 0;
	for (int i = 0; i * r <= n; i++) {
		for (int j = 0; j * g + i * r <= n; j++) {
			int rem = n - i * r - j * g;
			if (rem % b == 0) ans++;
		}
	}
	printf("%d\n", ans);
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif


	if (0) {
		int T;
		scanf("%d", &T);
		for (int ks = 1; ks <= T; ks++) solve(ks);
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    long double X;
    cin >> X;
    long double A = 100;
    int ans = 0;
    while (true) {
        if (A >= X) {
            cout << ans << endl;
            return 0;
        } else {
            A *= (long double)(1.01);
            A = floor(A);
            ans++;
        }
    }
}


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

#define int long long
#define d7 1000000007


int32_t main(){
    
    
    int n,m;cin>>n>>m;
    
    vector<string> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<vector<int>> dp(n,vector<int>(m));
    
    dp[0][0]=1;
    
    for(int i=0;i<m;i++){
        if(a[0][i]=='.'){
            if(i>0) dp[0][i]=dp[0][i-1];
        }else{
            dp[0][i]=0;
            break;
        }
    }
    for(int i=0;i<n;i++){
         if(a[i][0]=='.'){
             if(i>0) dp[i][0]=dp[i-1][0];
         }else{
             dp[i][0]=0;
             break;
         }
     }
    
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]=='.'){
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%d7;
            }else{
                dp[i][j]=0;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
    
    
    return 0;
}


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

using namespace std;

struct Work {
	int s, t, x, i;
	Work(int s, int t, int x, int i) : s(s - x), t(t - x), x(x), i(i) {}
	void print() {
		printf("s: %d, t: %d, x: %d, i: %d\n", s, t, x, i);	
	}
};

bool cmp(Work w1, Work w2) {
	return w1.s < w2.s;
}

int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	vector<Work> work;
	for (int i = 0; i < n; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		work.push_back(Work(s, t, x, i));
	}
	sort(work.begin(), work.end(), cmp);
	// for (int i = 0; i < n; i++) {
	// 	work[i].print();
	// }
	int now = 0;
	vector<pair<int, int>> t;
	set<pair<int, int>> x;
	while (q--) {
		int d;
		cin >> d;
		// cout << "Doing: " << d << endl;
		while (t.size() && t[0].first <= d) {
			x.erase(make_pair(work[t[0].second].x, work[t[0].second].i));
			pop_heap(t.begin(), t.end(), greater<pair<int, int>>());
			t.pop_back();
		}
		while (now < n && work[now].s <= d) {
			if (work[now].t > d) {
				// cout << "In: " << now << endl;
				x.insert(make_pair(work[now].x, work[now].i));
				t.push_back(make_pair(work[now].t, now));
				push_heap(t.begin(), t.end(), greater<pair<int, int>>());
			}
			now++;
		}
		if (x.size()) {
			cout << x.begin() -> first << endl;
		} else {
			cout << "-1" << endl;
		}
	}
	return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];
    bool exist = true;

    for (int i = 0; i < H; i++) {
       for (int j = 0; j < W; j++) {
            bool canpaint = false;
            if (s[i][j] == '.') continue;
            if (i > 0) if (s[i - 1][j] == '#') canpaint = true;
            if (j > 0) if (s[i][j - 1] == '#') canpaint = true;
            if (i < H - 1) if (s[i + 1][j] == '#') canpaint = true;
            if (j < W - 1) if (s[i][j + 1] == '#') canpaint = true;
            if (!canpaint) {
                //cout << "i " << i << " j " << j << endl;
                exist = false;
                break;
            }
        }
        if (!exist) break;
    }

    if (exist) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3616
# AOJ 0593: Vote
# Python3 2018.6.30 bal4u

n, m = map(int, input().split())
a = []
c = [0]*n
for i in range(n): a.append(int(input()))
for j in range(m):
	b = int(input())
	for i in range(n):
		if a[i] <= b:
			c[i] += 1
			break
print(1+c.index(max(c)))


Measured memory_bytes: 5616
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll nmax=2*100000+1;

int main(){
    vector<ll> vec0,vec1,vec2,vec3;
    ll n,wm,w,v,w0,ct0,ct1,ct2,ct3,tmp,ans;
    cin>>n>>wm;
    ct0=ct1=ct2=ct3=0;
    for(ll i=0;i<n;i++){
        cin>>w>>v;
        if(i==0){
            w0=w;
            vec0.push_back(v);
            ct0++;
            continue;
        }
        if(w==w0){
            vec0.push_back(v);
            ct0++;
        }
        else if(w==w0+1){
            vec1.push_back(v);
            ct1++;
        }
        else if(w==w0+2){
            vec2.push_back(v);
            ct2++;
        }
        else if(w==w0+3){
            vec3.push_back(v);
            ct3++;
        }
    }
    sort(vec0.begin(),vec0.end(),greater<ll>());
    sort(vec1.begin(),vec1.end(),greater<ll>());
    sort(vec2.begin(),vec2.end(),greater<ll>());
    sort(vec3.begin(),vec3.end(),greater<ll>());
    ans=0;
    for(ll i=0;i<=ct0;i++){
        for(ll j=0;j<=ct1;j++){
            for(ll k=0;k<=ct2;k++){
                for(ll l=0;l<=ct3;l++){
                    tmp=0;
                    tmp+=accumulate(vec0.begin(), vec0.begin()+i, 0);
                    tmp+=accumulate(vec1.begin(), vec1.begin()+j, 0);
                    tmp+=accumulate(vec2.begin(), vec2.begin()+k, 0);
                    tmp+=accumulate(vec3.begin(), vec3.begin()+l, 0);
                    if(i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)<=wm&&ans<tmp){
                        ans=tmp;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(int(chrono::steady_clock::now().time_since_epoch().count()));

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    scanf("%d", &N);

    char S[int(1.1e6)];
    scanf(" %s", S);

    int Q;
    scanf("%d", &Q);

    for (int q = 0; q < Q; q++) {
        int K;
        scanf("%d", &K);

        ll d = 0, dm = 0, m = 0, dmc = 0;
        for (int i = 0; i < N; i++) {
            if (i >= K) {
                char r = S[i - K];
                if (r == 'D') { dm -= m; d--; }
                else if (r == 'M') { m--; }
            }
            char c = S[i];
            if (c == 'D') d++;
            else if (c == 'M') { dm += d; m++; }
            else if (c == 'C') dmc += dm;
        }
        printf("%lld\n", dmc);
    }

    return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (i == P[i]) {
      ans++;
      swap(P[i], P[i + 1]);
    }
  }
  if (P[N - 1] == N - 1) {
    ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 640
S = input()
S_1 = S[:2]
S_2 = S[2:]
if int(S_1)>=13 or int(S_1)==0:
    if int(S_2)>=13 or int(S_2)==0:print("NA")
    else:print("YYMM")
else:
    if int(S_2)>=13 or int(S_2)==0:print("MMYY")
    else:print("AMBIGUOUS")

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

int main(){
  int n,i,*a;
  cin>>n;
  a=new int[n];
  for (i=0;i<n;i++)cin>>a[i];
  for (i=n-1;i>=0;i--){
    if (i!=n-1)cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
}




Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define int long long int
using namespace std;

main()
{
int n,k;
cin>>k>>n;
int a[n];
vector<int> v,q;
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
sort(a,a+n);
int s=0;
for(int i=0;i<n-1;i++)
{
	v.push_back(a[i+1]-a[i]);
	s+=(a[i+1]-a[i]);
}
v.push_back(k-a[n-1]+a[0]);
s+=(k-a[n-1]+a[0]);
int r=INT_MAX;
for(int i=0;i<n;i++)
{
	r=min(r,s-v[i]);
}
cout<<r<<endl;

}

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

int main(){
	int A,B;
	
	cin >> A >> B;
	
	if (A > B) swap(A,B);
	
	int l = B - A;
	
	if ( l % 2 == 0) {
		cout << B - l / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	
}

Measured memory_bytes: 256
N = int(input())
p = [float(i) for i in input().split()]


# dp[i][j] : i枚目までで表がj枚の確率

dp = [[0.0 for i in range(N + 1)] for j in range(N + 1)]

for i in range(N + 1):
    dp[0][i] = 0.0
dp[0][0] = 1.0

for i in range(1, N + 1):
    for j in range(0, N + 1):
        if j == 0:
            dp[i][j] = dp[i-1][j] * (1-p[i-1])
        else:
            dp[i][j] = dp[i-1][j-1] * (p[i-1]) + dp[i-1][j] * (1-p[i-1])

res = 0
for i in range(N + 1):
    if i > N // 2:
        res += dp[N][i]

print(res)

Measured memory_bytes: 121692
// -*- coding:utf-8-unix -*-

use proconio::{input, fastout};

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

#[fastout]
fn main() {
    input! {
        n :usize,
        a :usize,
        b :usize,
        h: [usize; n],  // Vec<(i32, i32, i32)>
    }

    // Compute the upper bound
    let mut ubound = 0;
    for i in 0..n {
        ubound += h[i] / a + 1;
    }

    // Binary search
    // For ubound it holds
    // For lbound it doesn't hold
    let mut lbound = 0;
    while ubound - lbound > 1 {
        let center = (lbound + ubound) / 2;
        if annihilatable(n, a, b, &h, center) {
            ubound = center;
        } else {
            lbound = center;
        }
    }

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

fn annihilatable(n :usize, a :usize, b :usize, h :&[usize], count :usize) -> bool {
    let mut count2 = 0;
    for i in 0..n {
        let mut tairyoku = h[i];
        if tairyoku <= b * count {
            continue;
        }
        tairyoku -= b * count;
        let mut kaisuu = tairyoku / (a-b);
        if tairyoku > kaisuu * (a-b) {
            kaisuu += 1;
        }
        count2 += kaisuu;
        if count2 > count {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 3756
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int k=0;k<n;k++){
      if(4*i+7*k==n){
        cout<<"Yes";
        return 0;
      }
    }
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);

		        String S  = sc.nextLine();


		       int A = S.charAt(2);
		       int B = S.charAt(3);
		       int C = S.charAt(4);
		       int D = S.charAt(5);

		        if(A == B) {
		        	if(C == D) {
		        		System.out.println("Yes");
		        	}
		        	else{
		        		System.out.println("No");
		        	}
		        }else {
		        	System.out.println("No");
		        }

	}
}

Measured memory_bytes: 23508
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
 
#define PI (long double)3.14159265358979
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
 	long double a, b, x;
	cin >> a >> b >> x;

	cout.precision(12);
	cout << fixed;

	if (x == a*a*b)
	{
		cout << 0;
		return 0;
	}

	if (a*a*b/2 < x)
		cout << atan2((2 / a) * (a * b - x / a), a) * 180 / PI;
	else
		cout << atan2(b, (2 / b)* (x / a)) * 180 / PI;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int s[10];
char c[10];

int main() {
	int N, M;
	cin >> N >> M;
	string ans="";
	for(int i=0; i<N; ++i) ans += '?';
	for(int i=0; i<M; ++i){
		cin >> s[i] >> c[i];
	}
	for(int i=0; i<M; ++i){
		if(ans[s[i]-1]=='?'){
			if((c[i]=='0') && (N>1) && (s[i]==1)){
				cout << -1 << endl;
				return 0;
			}
			ans[s[i]-1]=c[i];
		}
		else if(ans[s[i]-1]!=c[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=0; i<N; ++i){
		if(ans[i]=='?'){
			if((N==1)||(i>0)) ans[i]='0';
			else ans[i]='1';
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<char>d(k);
  rep(i,k) cin >> d[i];
  
  for(int i=n;i<=1e7;i++){
    string s = to_string(i);
    int sz = s.size(); 
    bool ok = true;
    rep(j,sz){
      for(auto c:d){
        if(s[j] == c) ok = false;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,w;
    cin>>n>>w;
    vector<int> val(n);
    vector<int> wt(n);
    for(int i=0;i<n;i++)
    {
        cin>>wt[i];
        cin>>val[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int j=0;j<=w;j++)
        dp[0][j]=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=wt[i-1])
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int n,mul[2005],ans;
int fpow(int x,int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	int ans=fpow(x,y/2);
	ans=ans*ans%mod;
	if(y&1) ans=ans*x%mod;
	return ans;
}
int C(int x,int y)
{
	y=min(y,x-y);
	return (mul[x]*fpow(mul[x-y],1e9+5)%mod)*fpow(mul[y],1e9+5)%mod;
}
signed main()
{
	cin>>n;
	mul[1]=mul[0]=1;
	for(int i=2;i<=2000;i++) mul[i]=mul[i-1]*i%mod;
	for(int i=1;i*3<=n;i++)
	{
		int tmp=n-i*2;
		ans=(ans+C(tmp-1,i-1))%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var num = new long[(long)1e5 + 1];
            for (var i = 0; i < N; ++i)
            {
                var ab = Sarray();
                var a = ab[0];
                var b = ab[1];
                num[a] += b;
            }
            var acc = 0L;
            for (var i = 0; i < num.Length; ++i) 
            {
                acc += num[i];
                if (K <= acc)
                {
                    WriteLine(i);
                    return;
                }
            }
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 18016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> count(n,0);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        count[a]++;
        count[b]++;
    }
    bool f = true;
    for(int i = 0; i < n; i++) if(count[i] % 2 != 0) f = false;
    cout << (f ? "YES" : "NO") << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main()
{
    string s;
    cin >> s;
    ll n=s.length();
    rep(i,n){
        if(i+1<=n-1 && s[i]==s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        else if(i+2<=n-1 && s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
} 

Measured memory_bytes: 512
/*input
31415926535897932384626433832795028841971693993751058209749445923078164062862089986280
*/
 
 
#include <bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define INTMAX  2147483647
#define INTMIN  -2147483648
#define LLMAX 9223372036854775807
#define LLMIN -9223372036854775808
#define MOD 1000000007
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.1415926535
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr

// cout<<fixed<<setprecision(10)<<(v1+v2+v3)<<endl;
  
struct node{
    ll val;
};


long long int minimum = 100000000000000;

int gcd(long long int a,long long int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

struct ct_s_h {long long int cts, cth, index;};

bool compare(long long int a, long long int b) {
	if(gcd(a,b) < minimum)
		return 1;
	else return 0;
}






int main(){
	string s; cin>>s;
	long long int ans = 0;
	for(int i=0;i<s.size();i++){
		ans += s[i]-'0';
	}
	if(ans%9==0)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;	
}















 

Measured memory_bytes: 3720
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	
	comb=[1]
	for i in range(n-k):
		comb.append((comb[-1]*(k+i)*pow(i+1,mod-2,mod))%mod)
	ans=0
	
	for i in range(n-k+1):
		ans+=((comb[i]*A[k-1+i])-(comb[i]*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 12996
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
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; }
//ミョ(-ω- ?)
int main() {
    int r,g,b;
    cin >> r >> g >> b;
    int num = r*100 + g*10 + b;
    if(num % 4 == 0)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,mx;
long long ans=0ll;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		if(a<mx)ans+=mx-a;
		else mx=max(mx,a);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3232
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
int n,k,a[2020];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

ll calc(ll x) {return (x*(x+1)/2)%maxd;}

int main()
{
	n=read();k=read();
	rep(i,1,n) a[i]=read();
	ll ans=0;
	rep(i,1,n)
	{
		rep(j,i+1,n)
		{
			if (a[i]>a[j])
			{
				ans=(ans+calc(k))%maxd;
			}
			else if (a[i]<a[j]) ans=(ans+calc(k-1))%maxd;
		}
	}
	printf("%lld",ans);
	return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;
    for (int i = 0; i < W-B; i++) {
        ll val;
        ll a = comb(H-A-1+B+i, H-A-1);
        if (i != 0) {
            a -= comb(H-A-1+B+i-1, H-A-1);
        }
        ll b = comb(A+W-B-i-1, A);
        a %= MOD; b %= MOD;
        if (a >= 0) val = a;
        else val = a+MOD;
        val %= MOD;
        
        if (b >= 0) val *= b;
        else val *= b+MOD;
        val %= MOD;

        if (val >= 0) ans += val;
        else ans += val+MOD;
        ans %= MOD;
        if (ans < 0) ans += MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    LL a,b,c,k;
    cin >> a >> b >> c >> k;
    LL ans = 0;
    LL cnt = 0;
    if(a >= k) {
      cout << k << endl;
    } else {
      if(a+b >= k) {
        cout << a << endl;
      } else {
        LL t = k - a - b;
        cout << a - t << endl;
      }
    }
}


Measured memory_bytes: 5984