akhauriyash/Code-Regression huggingface dataset:
//by azidoazideazide(c2n14)
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
#define pb push_back

vector<int> adj[100005];
int n,dep[100005], lomo[100005], dp[100005][20];
const int M=17;

void init(){
	for(int i=0;i<n;i++){
		dp[i][0]=lomo[i];
		for(int j=1;j<=M;j++){
			if(dp[i][j-1]==-1) dp[i][j]=-1;
			else dp[i][j]=dp[dp[i][j-1]][j-1];
		}
	}
}

int lca(int a, int b){
	if(dep[a]>dep[b]) swap(a,b);
	for(int j=M-1;j>=0;j--)
		if(dp[b][j]!=-1 && dep[dp[b][j]]>=dep[a]) 
			b=dp[b][j];
	
	if(a==b) return a;
	
	for(int j=M-1;j>=0;j--)
		if(dp[a][j]!=dp[b][j])
			a=dp[a][j], b=dp[b][j];

	return lomo[a];
}

int main(){
	int q;
	cin>>n;
	for(int i=0,k;i<n;i++){
		cin>>k;
		for(int j=0,tt;j<k;j++){
			cin>>tt;
			lomo[tt]=i, dep[tt]=dep[i]+1;
			adj[i].pb(tt);
		}
	}
	
	init();
	
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		cout<<lca(a,b)<<endl;
	}
}


Measured memory_bytes: 17120
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

    int Q;
    cin >> Q;
    while(Q--) {
        int cnt = 0;
        string R; cin >> R;
        string prev = R;
        while(true) {
            if(R.size() == 1 || !(~cnt)) break;
            int maxi = 0;
            for(int i = 1; i < R.size(); i++) {
                int f = atoi(R.substr(0, i).c_str()), s = atoi(R.substr(i, R.size() - i).c_str());
                maxi = max(maxi, f * s);
            }
            R = to_string(maxi);
            if(R == prev) cnt = -1;
            else cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3256
#include <cstdio>
#include <vector>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000, MAX_M = 200000, INF = std::numeric_limits<int>::max()>>2;

struct edge
{ int to, dist; };

int N, M;
int L[MAX_M], R[MAX_M], D[MAX_M];
std::vector<edge> G[MAX_N];
int d[MAX_N];
bool used[MAX_N];
bool fl = true;

void dfs( int v, int prv )
{
  if( used[v] )
    return;

  used[v] = true;

  for( auto &e : G[v] ) if( !used[e.to] )
  {
    d[e.to] = d[v]+e.dist;

    dfs( e.to, v );
  }

  return;
}

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
  {
    scanf( "%d%d%d", L+i, R+i, D+i );
    --L[i]; --R[i];
    G[L[i]].push_back( (edge){ R[i], D[i] } );
    G[R[i]].push_back( (edge){ L[i], -D[i] } );
  }

  std::fill( d, d+N, INF );

  rep( i, N ) if( d[i] == INF )
  {
    d[i] = 0;
    dfs( i, -1 );
  }

  rep( i, M )
    fl &= d[R[i]]-d[L[i]] == D[i];

  puts( fl ? "Yes" : "No" );
  
  return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;
#define M 1000000007
#define pb push_back
#define rep(i, a, b) for(int i = a; i <= b; i++)
ll mod = 998244353;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t; t = 1;
	//cin >> t;
	while(t--)
	{
		ll a, b, n;ll ans = 0;
		cin >> a >> b >> n;
		if(n%b == 0)
		{
			n--;
			ans = (a*n)/b - a*(n/b);
		}
		else
		{
			ll req = n/b;
			if(req >= 1)
				n = (n/b)*b - 1;
			ans = (a*n)/b - a*(n/b);
		}
		cout << ans << endl;
	}
		
}  

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m;
	cin>>n>>m;
	ll s=m*1900+(n-m)*100;
	double ans=0.001;
	double p=pow(0.5,m);
	double P=1;
	//cout << p<<endl;
	for(ll i=0;i<1000;i++){
		ans+=(i+1)*s*P*p;
		//cout << ans<<endl;
		P=P*(1-p);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> in(n);
    int i;
    rep(i, n) {
        cin >> in[i];
    }
    sort(in.begin(), in.end());
    int ans(0);
    rep(i, k) ans += in[i];
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
const ll inf = 1e18;
const int nax = 2e6 + 7;

using namespace std;
string s;
bool ispal(int i , int j){
	while(i < j){
		if(s[i] != s[j]){
			return false;
		}
		i++;
		j--;
	}
	return true;
}
int main(int argc,char ** argv){
	dhoom;
	
	cin >> s;
	int n = s.size();
	bool x = ispal(0,n-1);
	bool y = ispal(0,(n-1)/2 - 1);
	
	bool z = ispal((n+3)/2-1, n-1);
//	cout << x << y << z << endl;
	if(x && y && z)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


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



int main(){

  priority_queue<int> maxq;

  while(1){
    char str[9];
    scanf("%s",str);

    if(str[0] == 'i'){
      int num;
      scanf("%d",&num);
      maxq.push(num);
    }else if(str[1] == 'x'){
      int ans = maxq.top();
      maxq.pop();
      printf("%d\n",ans);
    }else break;
  }


}

Measured memory_bytes: 6196
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
typedef pair<double, double>pdd;
double eps = 1e-10;
bool ccw(pdd a, pdd b, pdd c)
{
	return 0 <= (b.first - a.first)*(c.second - a.second) - (b.second - a.second)*(c.first - a.first);
}
int main()
{
	int num;
	double gen;
	scanf("%d%lf", &num, &gen);
	deque<pdd>now;
	now.push_back(make_pair(0, 0));
	now.push_back(make_pair(gen, 0));
	double sum = 0;
	for (int i = 0; i < num; i++)
	{
		double za, zb;
		scanf("%lf%lf", &za, &zb);
		pdd z = make_pair(now[0].first - zb, now[0].second - za*zb);
		for (;;)
		{
			if (now[now.size()-2].first < z.first + gen + eps)
			{
				pdd a = now[now.size() - 2], b = now[now.size() - 1];
				now.pop_back();
				double s = z.first + gen - a.first, t = b.first - (z.first + gen);
				now.push_back(make_pair((t*a.first + s*b.first) / (s + t), (t*a.second + s*b.second) / (s + t)));
				break;
			}
			else now.pop_back();
		}
		printf("%.20lf\n", (now[now.size() - 1].second - z.second) / gen);
		for (;;)
		{
			if (now.size() <= 1)break;
			pdd a = now[0], b = now[1];
			if (ccw(z, a, b))now.pop_front();
			else break;
		}
		now.push_front(z);
	}
}

Measured memory_bytes: 23700
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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 T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vector<vector<int>> d(n, vector<int>(n));
    rep(i, n) repr(j, i + 1, n) {
        d[i][j] = j - i;
        d[j][i] = j - i;
    }
    d[x][y] = d[y][x]= 1;

    rep(i, n) repr(j, i + 1, n) {
        d[i][j] = d[j][i] = min({
            d[i][j],
            d[i][x] + d[x][y] + d[y][j],
            d[i][y] + d[y][x] + d[x][j],
            d[j][x] + d[x][y] + d[y][i],
            d[j][y] + d[y][x] + d[x][i],
        });
    }

    vector<int> cnt(n);
    rep(i, n) repr(j, i + 1, n) cnt[d[i][j]]++;
    repr(i, 1, n) cout << cnt[i] << endl;
}

Measured memory_bytes: 16000
N=int(input())
c=0
m=[]
s=input()
m.append(s)
for i in range(N-1):
  l=input()
  if l not in m and m[i][-1]==l[0]:
    c+=1
  m.append(l)
if c==N-1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    int N, M, A, B, C;
    string s1, s2, s3;
    cin >> N >> A;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i, A){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main () {
	int d;
	scanf ("%d", &d);
	switch (d) {
		case 25:
			printf ("Christmas\n");
			break;
		case 24:
			printf ("Christmas Eve\n");
			break;
		case 23:
			printf ("Christmas Eve Eve\n");
			break;
		case 22:
			printf ("Christmas Eve Eve Eve\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int h,w;
char a[N][N];
int c[N];
main(){
//	freopen("in.txt","r",stdin);
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	int c1,c2,c4;
	if (h%2 && w%2){
		c1=1;
		c2=h/2+w/2;
		c4=(h*w-c1-c2*2)/4;
		
	}
	else{
		if (!(h%2 || w%2)){
			c1=0;
			c2=0;
			c4=h*w/4;
		}
		else{
			c1=0;
			if(h%2) c2=w/2; else c2=h/2;
			c4=(h*w-c2*2)/4;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			c[a[i][j]-'a']++;
		}
	}
	int a1=0,a2=0,a4=0;
	for(int i=0;i<26;i++){
		   	a4+=c[i]/4;
			a2+=(c[i]-c[i]/4*4)/2;
			a1+=c[i]%2;

		}
	
	//cout<<a1<<" "<<a2<<" "<<a4<<endl;
	//cout<<c1<<" "<<c2<<" "<<c4<<endl;
	bool ans=false;
	if (a4>=c4){
		a2+=(a4-c4)*2;
		if (a2==c2 && c1==a1) ans=true;
	}
	if (ans) puts("Yes"); else puts("No");
	

	
}


Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define lim 300005

ll a[lim][62],b[lim];
ll fastexpo(ll b,ll p){
    ll res=1;
    while(p){
        if(p&1) res = (res * b)%mod;
        p=p>>1ll;
        b=(b*b)%mod;
    }
    return res;
}
int main(){
   ll n,x;
   sfl(n);
   FOR(i,n){
       sfl(x);
       b[i]=x;
       for(ll j=60;j>=0;j--){
           if(CHECK(x,j)){
               a[i][j]=a[i-1][j]+1;
           }
           else{
               a[i][j]=a[i-1][j];
           }
       }
   }
   ll ans=0,tmp;
   for(ll i=n;i>=1;i--){
       for(ll j=60;j>=0;j--){
           if(!CHECK(b[i],j)){
               tmp = (a[i][j]*fastexpo(2,j))%mod;
               ans = (tmp+ans)%mod;
           }
           else{
               tmp = ((i-a[i][j])*fastexpo(2,j))%mod;
               ans = (ans + tmp ) % mod;
           }
       }
   }
   pfl(ans);
   return 0;
}


Measured memory_bytes: 147840
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

void print1d(const vector<int>& vec) {
    for (auto val : vec) {
        cout << val << " ";
    }
    cout << endl;
}

void print2d(const vector<vector<int>>& vec) {
    for (auto row : vec) {
        for (auto val : row) {
            cout << val << " ";
        }
        cout << endl;
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
#endif
    crap;

    int n, k;
    cin >> n >> k;

    map<int, int> mp;
    while (k--) {
        int q;
        cin >> q;

        while (q--) {
            int x;
            cin >> x;

            mp[x]++;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (!mp[i])
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    map<string,int> ma;
    REP(i,n){
        string s;
        cin>>s;
        ma[s]++;
    }
    if(ma.size()==3){
        cout<<"Three"<<endl;
    }else{
        cout<<"Four"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc152/tasks/abc152_e>
 問題文============================================================
 E - Flatten
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}
map<ll,ll> lcms;
void PrimeFact(ll n){
    map<ll,ll> mp;
    while(n!=1){
        if(n == 2 || n == 3){
            mp[n]++; n/=n;
            continue;
        }
        bool prime_flag = false;
        for(ll i = 2;i*i <= n;i++){
            if(n%i==0){
                mp[i]++; n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){mp[n]++; n/= n;}
    }
    for(auto p:mp){
        lcms[p.first] = max(lcms[p.first],p.second);
    }
}
template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;

    for(auto a:A) PrimeFact(a);
    ll _lcm = 1;
    for(auto p:lcms){
        for(int i = 0; i < p.second; i++){
            _lcm *= p.first;
            _lcm %= MOD;
        }
    }

    for(int i = 0; i < N;i++){
        res += _lcm*inversemod(A[i])%MOD;
        res %= MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int N;
deque<int> A[1010];
int step[1010];
int M;
int main(){
  cin>>N;
  REP(i,N){
    REP(j,N-1){
      int x;
	  cin>>x;
	  A[i].push_back(x-1);
    }
  }
  M=N*(N-1)/2;
  
  queue<int> Q;
  REP(i,N) Q.push(i);
  
  int num=0;
  while(Q.size()){
    queue<int> Q2;
    
    while(Q.size()){
      int i=Q.front();
      Q.pop();
      if(step[i]<=num && A[i].size() && A[A[i].front()].front()==i && step[A[i].front()]<=num) {
        step[i]=step[A[i].front()]=num+1;
        Q2.push(i);
        Q2.push(A[i].front());
        A[A[i].front()].pop_front();
        A[i].pop_front();
        M--;
      }
    }
    num++;
    if(M==0) break;
    swap(Q,Q2);
  }
  
  if(M) cout<<-1<<endl;
  else cout<<num<<endl;
}

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

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

int main() {
	int X;
	cin >> X;
	int happiness = 0;
	happiness += (X / 500) * 1000;
	happiness += (X % 500) / 5 * 5;
	cout << happiness << endl;
}

Measured memory_bytes: 256
//https://drken1215.hatenablog.com/entry/2018/09/08/195000
//https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2018/0407_arc094
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int q;
ll solve(ll a,ll b){
   ll ans;
   ll s=ll(sqrt(a*b));
   ans=2*s-1;
   if(s*(s+1)>=a*b)ans--;
   if(s*s==a*b&&a!=b)ans--;

   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>q;
    rep(i,q)
    {
        ll a,b;
        cin>>a>>b;
    cout<<solve(a,b)<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

int N;
char s[101], t[101];

int is_same_(int d){
	for (int i = 0; i < N - d; i++){
		if(s[i+d]!=t[i]){
			return 0;
		}
	}
	return 1;
}

void core(){
	scanf("%d", &N);
	scanf("%s", &s);
	scanf("%s", &t);

	int d = 0;
	for (d = 0; d < N; d++){
		if (is_same_(d)){
			break;
		}
	}

	printf("%d\n", N + d);
}

int main(){
	core();
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;

typedef long double ld;

const int MAX_N = 65;
const ld eps = 0.0000001;

ld X[MAX_N], Y[MAX_N], C[MAX_N], R[MAX_N];
int n, k;

ld dis(int i, int j) {
    return sqrtl(powl(X[i] - X[j], 2) + powl((Y[i] - Y[j]), 2));
}

bool przeciecie(int i, int j) {
    if(dis(i, j) > R[i] + R[j] + eps) {
        return false;
    }
    if(dis(i, j) + R[j] + eps < R[i] || dis(i, j) + R[i] + eps < R[j]) {
        return false;
    }
    return true;
}

bool check() {
    vector<pair<ld, ld> > points;
    
    for(int i = 1; i <= n; i++) {
        points.push_back({X[i], Y[i]});
        for(int j = i + 1; j <= n; j++) {
//             ld r = R[i] + R[j];
//             cout << "(" << i << " " << j << ") " << dis(i, j) << " " << r << endl;
//             if(r - eps <= dis(i, j) && dis(i, j) <= r + eps) {
//                 points.push_back({(X[i] + X[j]) / 2, (Y[i] + Y[j]) / 2});
//                 cout << "HALO"
//                 continue;
//             }
            
            if(!przeciecie(i, j)) {
                continue;
            }
            
//             cout << "Para " << i << " " << j << endl;
            ld x1 = X[i];
            ld y1 = Y[i];
            ld x2 = X[j];
            ld y2 = Y[j];
            ld r1 = R[i];
            ld r2 = R[j];
            ld RR = sqrtl(powl(x1 - x2, 2.0) + powl(y1 - y2, 2.0));
            
            ld w = (powl(r1, 2.0) - powl(r2, 2)) / (2 * powl(RR, 2.0));
            ld xa = 0.5 * (x1 + x2) + w * (x2 - x1);
            ld ya = 0.5 * (y1 + y2) + w * (y2 - y1);
            
            ld aa = 2 * (powl(r1, 2.0) + powl(r2, 2.0)) / powl(RR, 2.0);
            ld bb = powl(powl(r1, 2.0) - powl(r2, 2.0), 2.0) / powl(RR, 4.0);
            
            w = 0.5 * sqrtl(max(0.0L, aa - bb - 1));
            ld xd = w * (y2 - y1);
            ld yd = w * (x1 - x2);

            ld xb = xa - xd;
            ld yb = ya - yd;

            xa += xd;
            ya += yd;

            points.push_back({xa, ya});
            points.push_back({xb, yb});
        }
    }
    
    for(pair<ld, ld> p : points) {
        ld x = p.first;
        ld y = p.second;
//         cout << "Punkt = " << x << " " << y << endl; 
        int ile = 0;
        for(int i = 1; i <= n; i++) {
            if(sqrtl(powl(X[i] - x, 2.0) + powl(Y[i] - y, 2.0)) <= R[i] + eps) {
                ile++;
            }
        }
        if(ile >= k) {
            return true;
        }
//         cout << ile << endl;
    }
    return false;
}

int main() {
    check();
    cin >> n >> k;
    
    for(int i = 1; i <= n; i++) {
        cin >> X[i] >> Y[i] >> C[i];
    }

    ld min_t = 0, max_t = 200000; 
    
    while(max_t - min_t > eps) {
        ld t = (min_t + max_t) / 2.0;
        
        for(int i = 1; i <= n; i++) {
            R[i] = t / C[i];
        }
        
        if(check()) {
            max_t = t;
        } else {
            min_t = t;
        }
    }
    
    cout << fixed << setprecision(10) << min_t;
    
    return 0;
}

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

#define ll long long
#define pb push_back

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

void solve()
{
    ll n,sum=0;
    cin >> n;
    ll a[n];
    vector<ll>cnt(100005,0);
    rep(i,n)
    {
        cin >>a[i];
        cnt[a[i]]++;
        sum+=a[i];
    }

    ll t,b,c,d;
    cin >> t;
    rep(i,t)
    {
        cin >> b >>c;
        d=cnt[b];
        sum+=d*(c-b);
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout << sum << "\n";
    }
}

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

    int tt=1;
    ///cin >> tt;
    while(tt--)
    {
        solve();
    }
}


Measured memory_bytes: 4768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class A01Matrix {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, A, B;
        cin >> H >> W >> A >> B;
        REP(i, H) {
            REP(j, W) {
                if (i < B && j < A) {
                    cout << 1;
                } else if (i >= B && j >= A) {
                    cout << 1;
                } else {
                    cout << 0;
                }
            }
            cout << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    A01Matrix solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1280
def aa
    sn = gets.chomp
    pl = 0
    pl += 1 if sn[0] == '+'
    pl += 1 if sn[1] == '+'
    pl += 1 if sn[2] == '+'
    pl += 1 if sn[3] == '+'

    puts pl*2 - 4
end

aa

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    Int H, W;
    vector<string> A;

    // i, i + 1列目の最適valueを求める
    Int compute(int i) {
        struct DP {
            vector<vector<char>> B;
            vector<vector<Int>> dp; // dp[x][y] := 山の残りがそれぞれx, yのときにかかるコスト
            vector<vector<Int>> cnt;

            DP(vector<vector<char>> B) : B(B),
                                         dp(B[0].size() + 1, vector<Int>(B[0].size() + 1, -1)),
                                         cnt(B[0].size() + 1, vector<Int>(B[0].size() + 1, -1)) {

            }

            // cnt(x,y)を求める
            Int recc(int x, int y) {
                if (x == 0 || y == 0) return 0;
                if (cnt[x][y] != -1) return cnt[x][y];
                Int ret = recc(x - 1, y - 1) + (B[0][x - 1] == B[1][y - 1]);

                return cnt[x][y] = ret;
            }

            // compute dp(x,y)
            Int recd(Int x, Int y) {
                if (x == 0 || y == 0) return 0;
                if (dp[x][y] != -1) return dp[x][y];

                Int tmp1 = recd(x - 1, y) + recc(x, y);
                Int tmp2 = recd(x, y - 1) + recc(x, y);

                Int ret = min(tmp1, tmp2);
                return dp[x][y] = ret;
            }
        };

        vector<vector<char>> B(2, vector<char>(H));
        for (int j = 0; j < H; ++j) {
            B[0][j] = A[j][i];
        }
        for (int j = 0; j < H; ++j) {
            B[1][j] = A[j][i + 1];
        }

        DP dp(B);
        Int ans = dp.recd(H, H);

        return ans;
    }

    void solve() {
        cin >> H >> W;
        A.resize(H);
        for (int i = 0; i < H; ++i) cin >> A[i];

        Int ans = 0;
        for (int i = 0; i + 1 < W; ++i) {
            Int tmp = compute(i);
            ans += tmp;
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1912
def appendedList(arr, val):
    ret = arr.copy()
    ret.append(val)
    return ret

def dfs(cur, target, ret):
    if 0 < len(cur):
        if target < int(''.join(map(str, cur))):
            return 0
    const = 1 if (3 in cur and 5 in cur and 7 in cur) else 0
    ret3 = dfs(appendedList(cur, 3), target, ret)
    ret5 = dfs(appendedList(cur, 5), target, ret)
    ret7 = dfs(appendedList(cur, 7), target, ret)
    return ret + const + ret3 + ret5 + ret7

if __name__ == '__main__':
    N = int(input())
    print(dfs([], N, 0))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int mx=0, mn=1000;
    for(int n=0; n<N; n++) {
        int a;
        cin >> a;
        mx = max(mx, a);
        mn = min(mn, a);
    }
    cout << mx-mn << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n,a,b; cin>>n>>a>>b;
    
    vector <int> h(n); 
    rep(i,n) cin>>h[i];
    int l = -1, r = 1145141919;
    while(abs(r-l)>1){
        int mid = (r+l)/2; //midは回数
        int k = mid; //k回aのダメージを与えるのが許される
        int need = 0;
        rep(i,n){
            int hp = h[i]- b*k;
            //cout<<hp<<endl;
            if(hp>0){
                need += hp/(a-b) + (hp%(a-b)!=0);
            }
        }
        //cout<<need<<endl;
        k -= need;
        if(k>=0) r = mid;
            else l = mid;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g, mn;
vector<int> a, vis;

void dfs(int x, int id) {
  vis[x] = 1;
  mn[id].push_back(a[x]);
  for (auto v : g[x]) {
    if (vis[v]) continue;
    dfs(v, id);
  }
}

int main() {

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

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

  a.resize(n);
  g.resize(n);
  mn.resize(n - m);
  vis.resize(n, 0);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  if (n < 2 * (n - m - 1)) {
    cout << "Impossible\n";
    return 0;
  }
  if (m == n-1) {
    cout << 0 << '\n';
    return 0;
  }

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    g[u].push_back(v);
    g[v].push_back(u);
  }

  long long ans = 0;
  for (int i = 0, cur = 0; i < n; ++i) {
    if (!vis[i]) {
      dfs(i, cur++);
    }
  }

  vector<int> rem; 
  for (int i = 0; i < (int)mn.size(); ++i) {
    sort(mn[i].begin(), mn[i].end());
    for (int j = 1; j < (int)mn[i].size(); ++j) {
      rem.push_back(mn[i][j]);
    }
    ans += mn[i][0];
  }

  sort(rem.begin(), rem.end());
  for (int i = 0; i < n - m - 2; ++i) {
    ans += rem[i];
  }

  cout << ans << '\n';
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>

int main(){
  int K;
  std::string S;
  std::cin >> K;
  std::cin >> S;
  if(S.length() <= K){
    std::cout << S << std::endl;
  }
  else{
    for(int i = 0; i < K; ++i){
      std::cout << S[i];
    }
    std::cout << "..." << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
    int w,a,b,c;
    while(scanf("%d%d%d",&w,&a,&b)==3)
    {
        if(a>=b)
           c=a-w-b;
        else
            c=b-w-a;
        if(c>0)printf("%d\n",c);
           else printf("0\n");
    }
    return 0;
}


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


//This code is written by Sneh Thakkar on 16-12-2019

/*       AUTHOR NAME:

        _/_/_/_/   _/\        _/     _/_/_/_/_/    _/      _/
       _/         _/ _\      _/     _/            _/      _/
      _/_/_/_/   _/   _\    _/     _/_/_/_/_/    _/_/_/_/_/
           _/   _/     _\  _/     _/            _/      _/
    _/_/_/_/   _/       _\_/     _/_/_/_/_/    _/      _/
       
        
*/

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

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


int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    cout<<n*k/gcd(n,k);
}

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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
bool solve(int val){
  int tmp_n = N;
  while (tmp_n > 0){
    if (val <= 0)return false;
    if (tmp_n - val >= 0){
      tmp_n -= val;
    }
    val--;
    //cout << tmp_n << endl;
  }
  return true;
}


int main(){
  cin >> N;

  int left,right;
  left = 1;
  right = N + 1;
  while (right - left > 1){
    int med = (right + left) / 2;
    if (solve(med)){//solve
      right = med;
    }else{
      left = med;
    }
  }
  vector<int> ans;
  while (N > 0){
    if (right <= 0)return false;
    if (N - right >= 0){
      N -= right;
      ans.push_back(right);
    }
    right--;
    
  }
  
  for (int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if ( a > x || a + b < x) {
        cout << "NO" << endl;
        return 0;
    }
    else {
        cout << "YES" << endl;
        return 0;
    }
    
}


Measured memory_bytes: 256
import time
import copy


class Answer:
    """

    """

    def __init__(self, answer, score):
        self.answer = copy.deepcopy(answer)
        self.score = copy.deepcopy(score)


class Problem:
    def __init__(self, num_day, s, c):
        self.d = num_day
        self.s = s
        self.c = c
        self.last_days = [0] * 26
        self.answer = Answer([0] * self.d, 0)
        self.best_answer = Answer([0] * self.d, 0)

    def scoring(self, day, ind) -> int:
        day_score = self.s[day][ind]
        minus_score = 0
        for i in range(26):
            if i != ind:
                minus_score += self.c[i] * (day + 1 - self.last_days[i])
        day_score -= minus_score
        return day_score

    def get_all_scores(self, day):
        """全ての選択肢のscoreを返す"""
        minus_score = 0
        all_scores = [0] * 26
        for i in range(26):
            if i == 0:
                for j in range(1, 26):
                    minus_score += self.c[j] * (day + 1 - self.last_days[j])
                all_scores[0] = self.s[day][0] - minus_score

            else:
                minus_score += self.c[i - 1] * (day + 1 - self.last_days[i - 1])
                minus_score -= self.c[i] * (day + 1 - self.last_days[i])
                all_scores[i] = self.s[day][i] - minus_score
        return all_scores

    def repeat(self):
        self.initialize()
        self.solve()
        self._update_best()

        return copy.deepcopy(self.best_answer)

    def solve(self):

        for day in range(self.d):
            all_scores = self.get_all_scores(day)
            all_scores_with_ind = [[i, all_scores[i]] for i in range(26)]
            all_scores_with_ind.sort(key=lambda x: x[1])
            ind = all_scores_with_ind[-1][0]
            score = self.scoring(day, ind)
            self.last_days[ind] = day + 1
            self.answer.answer[day] = ind
            self.answer.score += score

    def _update_best(self) -> Answer:
        if self.best_answer.score < self.answer.score:
            self.best_answer = copy.deepcopy(self.answer)
        return copy.deepcopy(self.best_answer)

    def initialize(self):
        self.last_days = [0] * 26


def main():
    time_start = time.time()
    limited_time = 2 * 0.90
    D = int(input())
    c = list(map(int, input().split()))
    s = []

    for _ in range(D):
        s.append(list(map(int, input().split())))

    # 初期解
    answer = Answer([0] * D, 0)

    problem = Problem(D, s, c)
    ite = 0
    # while time.time() - time_start < limited_time:
    ite += 1
    problem.repeat()

    for i in range(D):
        print(problem.best_answer.answer[i] + 1)


main()


Measured memory_bytes: 69616
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String n=sc.nextLine(); 
		
		String[] str=n.split("");
		
		int result=0;
		
		for(String value:str) {
			int num=Integer.parseInt(value);
			result=result+num;
		}
		
		if(result%9==0) {
			System.out.println(("Yes"));
		}else {
			System.out.println("No");
		}
	
	}

}


Measured memory_bytes: 65400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) a[i] = -1;
    vector<P> p(n - 1);
    rep(i, n - 1) { 
        int tmp;
        cin >> tmp;
        p[i] = make_pair(tmp, i);
    }
    sort(p.begin(), p.end());

    rep(i,n-1){
        int num = p[i].second;
        if(a[num] == -1) {
            a[num] = p[i].first;
        }
        if(a[num + 1] == -1) {
            a[num + 1] = p[i].first;
        }
    }
    ll sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const W=input[0].split(' ')[0]-0;
  const H=input[0].split(' ')[1]-0;
  const x=input[0].split(' ')[2]-0;
  const y=input[0].split(' ')[3]-0;
  console.log(H*W/2,W===x*2&&H===y*2?1:0);
 
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29912
#include <iostream>
#include <math.h>	
#include <string>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <algorithm>
#include <unordered_set>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main() {
	
	int a, s, d, f;
	cin >> a >> s >> d;
	map<int, int>m;

	for (int t = 0; t < d; t++) {
		cin >> f;
		m[f]++;
	}

	for (int t = 1; t <= a; t++) {
		if ((s - d) + m[t] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001

void check(string A,string B){
	if(A!=B){
		cout<<"No"<<endl;
		exit(0);
	}
}

int main(){
	
	string S;
	cin>>S;
	
	string T = S;
	reverse(T.begin(),T.end());
	
	check(S,T);
	
	string SS = S.substr(0,(S.size())/2);
	string TT = SS;
	reverse(TT.begin(),TT.end());
	
	check(SS,TT);
	
	SS = S.substr(S.size()/2+1);
	TT = SS;
	reverse(TT.begin(),TT.end());
	
	check(SS,TT);
	
	cout<<"Yes"<<endl;
	
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left


def main():
    N, Q, *I = map(int, open(0).read().split())
    STX, D = I[:3 * N], I[3 * N:]

    E = sorted(zip(*[iter(STX)] * 3), key=lambda x: x[2])

    R = [-1] * Q
    ans = [-1] * Q

    for s, t, x in E:
        l = bisect_left(D, s - x)
        r = bisect_left(D, t - x)
        while l < r:
            if R[l] == -1:
                ans[l] = x
                R[l] = r
                l += 1
            else:
                l = R[l]

    print("\n".join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 96292
#include <stdio.h>

#define MAX 100

int n,graph[MAX][MAX];
int aaa[MAX],s[MAX],t[MAX],bb;

void DFSsearch(int);
void DFS();

int main(){
  int i,j,a,b,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++){
      graph[i][j];
    }
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    a--;
    for(j=0;j<b;j++){
      scanf("%d",&c);
      c--;
      graph[a][c]=1;
    }
  }
  DFS();
  return 0;
}
void DFSsearch(int a){
  int c;
  aaa[a]=1;
  s[a]=++bb;
  for(c=0;c<n;c++){
    if(graph[a][c]==0)
      continue;
    if(aaa[c]==0){
      DFSsearch(c);
    }
  }
  aaa[a]=2;
  t[a]=++bb;
}
void DFS(){
  int a;
  for(a=0;a<n;a++)
    aaa[a]=0;
  bb=0;
  for(a=0;a<n;a++){
    if(aaa[a]==0)
      DFSsearch(a);
  }
  for(a=0;a<n;a++){
    printf("%d %d %d\n",a+1,s[a],t[a]);
  }
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    double ans = 0;
    rep(i, 0, N) {
        double x; string u; cin >> x >> u;
        if (u == "BTC") x *= 380000;
        ans += x;
    }
    printf("%.10f\n", ans);
}


Measured memory_bytes: 256
from collections import deque

class Node:
    def __init__(self, val):
        self.val = val
        self.adj = []
        self.pec = 0

n = int(input())
ab = []
nodes = [None] * n
cntMap = {}

def addCount(v1):
    if v1 not in cntMap:
        cntMap[v1] = 1
    else:
        cntMap[v1] += 1

for i in range(n-1):
    v1, v2 = map(int, input().split())
    addCount(v1)
    addCount(v2)
    ab.append([v1, v2])
    nodeAidx = v1-1
    nodeBidx = v2-1
    nodeA = None
    nodeB = None
    if nodes[nodeAidx] is None:
        nodeA = Node(v1)
        nodes[nodeAidx] = nodeA
    else:
        nodeA = nodes[nodeAidx]
    if nodes[nodeBidx] is None:
        nodeB = Node(v2)
        nodes[nodeBidx] = nodeB
    else:
        nodeB = nodes[nodeBidx]
    nodeA.adj.append(nodeB)

#print(ab)
#print(nodes)
root = nodes[0]
nodes[1].pec = 1
q = deque()
q.append(root)

temp = list(cntMap.values())
temp.sort()
maxV = temp[-1]
used = set()
edgeMap = {}

print(maxV)

while q:
    used.clear()
    node = q.popleft()
    pec = node.pec
    used.add(pec)
    prev = 0

    for i in range(len(node.adj)):
        a = node.adj[i]
        for j in range(prev+1, maxV+1):
            if j not in used:
                a.pec = j
                used.add(j)
                prev = j
                break

        edgeMap[(node.val, a.val)] = a.pec
        q.append(a)

for i in range(n-1):
    key = (ab[i][0], ab[i][1])
    print(edgeMap[key])


Measured memory_bytes: 117848