akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD 998244353
#define ll long long int
using namespace std;
 ll max(ll a,ll b)
 {
     if(a>=b)
     {
         return a;
     }
     else
     {
         return b;
     }
     
 }
int main() {
string s,t;
cin>>s>>t;
vector<vector<int> >dp(s.length()+1,vector<int> (t.length()+1,0));
int slength=s.length(),tlength=t.length();
for(int i=0;i<s.length();i++)
{
    for(int j=0;j<t.length();j++)
    {
        if(s[i]==t[j])
        {
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
        }
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
    }
}

string ans;
while(slength>0&&tlength>0)
{
    if(s[slength-1]==t[tlength-1])
    {
        ans.push_back(s[slength-1]);
        slength--;
        tlength--;
    }
    else if(dp[slength-1][tlength]>dp[slength][tlength-1])
    {
        slength--;
    }
    else
    {
        tlength--;
    }
    
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}

Measured memory_bytes: 35584
N=int(input())
A=list(map(int,input().split()))
S=sum(A)
X=S
for i in range(1,N-1,2):
    X-=2*A[i]
ans=[X]

for j in range(N-1):
    ans.append(2*A[j]-ans[j])
print(*ans)

Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,a,b;
    vector<LL> h;
    Problem(LL n):n(n),h(n){};
    bool check(LL m){
        LL cnt=0;
        for(int i=0; i<n; ++i){
            cnt+=max((h[i]-b*m+a-b-1)/(a-b),0ll);
        }
        DBG(m,cnt)
        return cnt<=m;
    }
    void solve(){
        cin >> a >> b;
        for(int i=0; i<n; ++i){
            cin >> h[i];
        }
        LL lb=0,ub=2e9;
        while(ub-lb>1){
            LL mid = (lb+ub)/2;
            if(check(mid)) ub=mid;
            else lb=mid;
        }
        cout << ub <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int N = int.Parse(str);

            if(N % 2 != 0)
            {
                N = N * 2;
            }
            Console.WriteLine(N);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  const ll LINF = 1001001001001001;
  int a,b,q; cin >> a >> b >> q;
  vector<ll> s(a),t(b);
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  rep(i,q){
    ll x; cin >> x;
    ll ans = LINF;
    ll temple1 = LINF, temple2 = LINF, shrine1 = LINF, shrine2 = LINF;
    int point1 = upper_bound(all(s),x) - s.begin();
    int point2 = upper_bound(all(t),x) - t.begin();
    if(point1 != 0) shrine1 = s[point1-1];
    if(point1 != s.size()) shrine2 = s[point1];
    if(point2 != 0) temple1 = t[point2-1];
    if(point2 != t.size()) temple2 = t[point2];
    chmin(ans,abs(x-temple1)+abs(temple1-shrine1));
    chmin(ans,abs(x-temple1)+abs(temple1-shrine2));
    chmin(ans,abs(x-temple2)+abs(temple2-shrine1));
    chmin(ans,abs(x-temple2)+abs(temple2-shrine2));
    chmin(ans,abs(x-shrine1)+abs(shrine1-temple1));
    chmin(ans,abs(x-shrine1)+abs(shrine1-temple2));
    chmin(ans,abs(x-shrine2)+abs(shrine2-temple1));
    chmin(ans,abs(x-shrine2)+abs(shrine2-temple2));
    cout << ans << endl;
  }
  // cout << "\n";
  return 0;
}


Measured memory_bytes: 4760
a = []
b = []
for _ in range(3):
  a.append(list(map(int,input().split())))
n = int(input())
for _ in range(n):
  b.append(int(input()))

for i in range(n):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = 0
        
flg = 0
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[i][j] == 0 and j != 2:
          continue
        elif j == 2 and a[i][j]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[j][i] == 0 and j != 2:
          continue
        elif j == 2 and a[j][i]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if a[i][i] == 0 and i != 2:
      continue
    elif a[i][i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  for i in range(3):
    if a[i][2-i] == 0 and i != 2:
      continue
    elif a[i][2-i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  print("No")
else:
  print("Yes")

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REP(n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)

int main() {
    int num,a, b, c, d;
    a = b = c = d = 0;
    string s;
    cin >> a;

    cout << a+a*a+a*a*a << endl;
}
 

Measured memory_bytes: 3596
M,D = map(int,input().split())

count = 0
for m in range(4,M+1):
    day = list(range(22,D+1))
    for d in day:
        D1,D10 =map(int,list(str(d)))
        if D1<=1 or D10 <=1:
            continue
        
        if m==D1*D10:
            count+=1

print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int i,j,k,n,a,b,dice[7],
        side[5] = {2,3,5,4,2};
    char order[7][3] = {"","","N","W","E","S","NN"};
    
    for(i=1;i<7;i++)
        scanf("%d", &dice[i]);
    
    scanf("%d", &n);
    
  //上面を合わせる
    for(i=0;i<n;i++){
        scanf("%d%d",&a,&b);
    
        for(j=1;dice[j]!=a;j++);
        
       //回転  
    
        for(k=0;order[j][k]!='\0';k++){
        
            dice[0] = dice[1];
        
            switch(order[j][k]){
                
                case 'E':
                    dice[1] = dice[4];
                    dice[4] = dice[6];
                    dice[6] = dice[3];
                    dice[3] = dice[0]; 
                    break;
            
                case 'N':
                    dice[1] = dice[2];
                    dice[2] = dice[6];
                    dice[6] = dice[5];
                    dice[5] = dice[0]; 
                    break;
            
                case 'S':
                    dice[1] = dice[5];
                    dice[5] = dice[6];
                    dice[6] = dice[2];
                    dice[2] = dice[0]; 
                    break;
                
                case 'W':
                    dice[1] = dice[3];
                    dice[3] = dice[6];
                    dice[6] = dice[4];
                    dice[4] = dice[0]; 
                    break;

            }
        }
        
        for(j=0;b!=dice[side[j]];j++);
        
        printf("%d\n",dice[side[j+1]]);
        
    }
    
    return 0;
}

Measured memory_bytes: 596
/*
------------------------------|بسم الله الرحمن الرحيم|------------------------------//
------------"IN THE NAME OF ALLAH, THE MOST GRACIUOS, THE MOST MERCIFUL"-------------//
__________________________________ShahnawazShaikh_____________________________________
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int int64_t
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);	
int t;
cin>>t;
if(t)
  cout<<0;
else
  cout<<1;
  
  
return 0;	
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long inf=0x7f7f7f7f7f7f7f7fll;
long long s1=inf,s2,sz[222];
int m;
vector<long long> adj[222];
void dfs(int x,int fa,int d)
{
	long long c=0;
	m=max(m,d);
	for (int i=0;i<adj[x].size();i++)
	{
		if (adj[x][i]==fa) continue;
		c++;
		dfs(adj[x][i],x,d+1);
	}
	sz[d]=max(sz[d],c);
}
int main()
{
	int n,i,j,k,p;
	scanf("%d",&n);
	for (i=1;i<n;i++)
	{
		 int x,y;
		 scanf("%d%d",&x,&y);
		 adj[x].push_back(y);
		 adj[y].push_back(x);
	}
	for (i=1;i<=n;i++) sort(adj[i].begin(),adj[i].end());
	for (i=1;i<=n;i++)
	{
		for (j=i+1;j<=n;j++)
		{
			if (!binary_search(adj[i].begin(),adj[i].end(),j)) continue;
			for (k=1;k<=n;k++) sz[k]=0;
			m=0;
			dfs(i,j,1);dfs(j,i,1);
			if (m<s1)
			{
				s1=m;
				s2=2;
				for (k=1;k<=m-1;k++) s2*=sz[k];
			}
			else if (m==s1)
			{
				long long t=2;
				for (k=1;k<=m-1;k++) t*=sz[k];
				if (t<s2) s2=t;
			}
		}
	}
	for (i=1;i<=n;i++)
	{
		//for (j=i+1;j<=n;j++)
		//{
		//	if (!binary_search(adj[i].begin(),adj[i].end(),j)) continue;
			for (k=1;k<=n;k++) sz[k]=0;
			m=0;
			dfs(i,j,1);//dfs(j,i,1);
			if (m<s1)
			{
				s1=m;
				s2=1;
				for (k=1;k<=m-1;k++) s2*=sz[k];
			}
			else if (m==s1)
			{
				long long t=1;
				for (k=1;k<=m-1;k++) t*=sz[k];
				if (t<s2) s2=t;
			}
		//}
	}
	printf("%lld %lld\n",s1,s2);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
U = 10**18

def main(A):
    a = 1
    for x in A:
        if x == 0:
            return 0
    for x in A:
        a *= x
        if a > U:
            return -1
    return a

print(main(A))
        


Measured memory_bytes: 21788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep0(i, b, s) for(int i=b;i<s;i++)
typedef long long ll;

vector<pair<int, int> > edge[100000];
int ans[100000];

int main(){
    int N; cin >> N;
    queue<pair<int, int> > que;

    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        edge[a-1].push_back(make_pair(b-1,c));
        edge[b-1].push_back(make_pair(a-1,c));
    }

    rep(i, N) ans[i] = 100;
    ans[0] = 0;
    que.push(make_pair(0,0));

    while(!que.empty()){
        int st = que.front().first;
        rep(i, edge[st].size()){
            if (ans[edge[st][i].first] == 100) {
                int dis = que.front().second + edge[st][i].second;
                dis = dis%2;
                ans[edge[st][i].first] = dis;
                que.push(make_pair(edge[st][i].first,dis));
            }
        }
        que.pop();
    }
    rep(i, N) cout << ans[i] << endl;

}


Measured memory_bytes: 6784
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	int x,y;
	cin>>x>>y;
	rep(i,x+1){
		int j=x-i;
		if(i*2+j*4==y){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second&&a.first<b.first);
}

void solve(){
    int k,s;
    cin>>k>>s;
    int cn=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int m=s-i-j;
            if(m>=0&&m<=k)
                cn++;

        }
    }
    cout<<cn;
}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}
































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















Measured memory_bytes: 3628
fun main(args : Array<String>) {
    val (n, q) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val bits = BIT(n)

    aa.forEachIndexed { idx, a ->
        bits.add(idx, a)
    }

    repeat(q) {
        val (t, u, v) = readLine()!!.split(" ").map { it.toInt() }
        if (t == 0) {
            bits.add(u, v)
        } else {
            println(bits.sum(u, v))
        }
    }
}

private data class BIT(val size: Int) {
    private val data = MutableList(this.size){0L}

    fun add(idx: Int, value: Int) {
        var i = idx+1
        while (i <= this.size) {
            this.data[i-1] += value.toLong()
            i += i and -i
        }
    }

    // NOTE: data[rIdx] is not included
    fun sum(rIdx: Int): Long {
        var i = rIdx
        var sum = 0L

        while (i > 0) {
            sum += this.data[i-1]
            i -= i and -i
        }

        return sum
    }

    // NOTE: data[rIdx] is not included
    fun sum(lIdx: Int, rIdx: Int): Long {
        return sum(rIdx)-sum(lIdx)
    }
}

Measured memory_bytes: 128900
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
int n;
void solve() {
	cin >> n;
	cout << (800 * n - 200 * (n / 15));	
}     	

Measured memory_bytes: 256
//102B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int>vec(n, 0);
    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec.back()-vec.front();
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int Maxn = 200100;
const int Mod = 1000000000 + 7;
struct num
{
    int num;
    int cnt;
}a[Maxn];
int n,k,x,ans,cnt,m[Maxn];
int main()
{
    cin>>n>>k;
    cnt = 0;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin>>x;
        if(m[x] == 0)
            cnt++;
        m[x]++;
    }

    if(cnt <= k)
    {
        cout<<"0"<<endl;
        return 0;
    }

    sort(m,m+Maxn);
    // cout<<cnt<<endl;
    // cout<<k<<endl;
    // for (int i = 0; i <= n; i++)
    //     cout<<m[i]<<" ";
    // cout<<endl;
    for (int i = 0; i <= Maxn; i++)
    {
        if(cnt == k)
            break;
        else
            if(m[i] > 0 && k < cnt)
            {
                ans+=m[i];
                cnt--;
            }
    }
    // cout<<cnt<<endl;
    // cout<<k<<endl;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner scanner =new Scanner(System.in);
       int N=scanner.nextInt();
       int D=scanner.nextInt();
       double A,K=0;
        long X,Y,XX,YY;
       int count=0;
       for(int i=0;i<N;i++){
            X=scanner.nextLong();
            Y=scanner.nextLong();
             XX=X*X;
             YY=Y*Y;
            A=Math.sqrt(XX+YY);
           if(A<=D){
               count++;
           }
       }
       System.out.println(count);
    }
}


Measured memory_bytes: 60404
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N,K;
    cin>>N>>K;
    vector<ll> P(N);
    vector<ll> C(N);
    rep(i,N)cin>>P.at(i);
    rep(i,N)cin>>C.at(i);
    ll ans=-10000000000000;
    if(N>=K){
        rep(i,N){
            ll val=0;
            ll k=i;
            rep(j,K){
                val+=C.at(P.at(k)-1);
                k=P.at(k)-1;
                ans=max(ans,val);
            }
        }
    }
    else{
        rep(i,N){
            ll val=0;
            ll k=i;
            ll valmax=-1000000000000;
            ll loop=N;
            ll value=0;
            rep(j,N){
                val+=C.at(k);
                k=P.at(k)-1;
                valmax=max(valmax,val);
                if(k==i){
                    value=val;
                    loop=j+1;
                    break;
                }
            }
            val=0;
            rep(j,loop){
                val+=C.at(k);
                k=P.at(k)-1;
                valmax=max(valmax,val+(K-j-1)/loop*value);
            }
            ans=max(ans,valmax);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3704
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <set> 
using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	cin >> s;
	long long k;
	cin >> k;
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] == 'a') continue;
		if (k >= 26 - (int) (s[i] - 'a')) {
			k -= (26 - (int) (s[i] - 'a'));
			s[i] = 'a';
		}
	}
	if (k != 0) k %= 26;
	s[(int) s.size() - 1] = (char) ((int) s[(int) s.size() - 1] + k);
	cout << s << endl;



	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    string s, t;
    cin >> s >> t;
    int ans = 1 << 30;
    for(int i = 0; i < (sz(s) - sz(t)) + 1; i++) {
        string ss = s.substr(i,sz(t));
        int cnt = 0;
        for(int j = 0; j < sz(t); j++) {
            if(ss[j] != t[j]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> S;
  for(int i = 0; i < n; i++) {
    int s;
    cin >> s;
    S.insert(s);
  }
  // vector<int> S(n);
  // for(auto& v : S) {
  //   cin >> v;
  // }
  int q;
  cin >> q;
  vector<int> T(q);
  for(auto& v : T) {
    cin >> v;
  }

  int C = 0;
  for(auto t : T) {
    for(auto s : S) {
      if(t == s) C++;
    }
  }

  printf("%d\n", C);
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int cnt0 = 0;
    int cnt1 = 0;
    int ans = 0;
    rep(i, n) {
        if (s[i] == '0') {
            if (cnt1 > 0) {
                cnt1--;
                ans += 2;
            } else {
                cnt0++;
            }
        } else {
            if (cnt0 > 0) {
                cnt0--;
                ans += 2;
            } else {
                cnt1++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define pr(x) prev(x.end())
# define mset multiset
# define umap unordered_map
# define gcd __gcd
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mod = 1e9+7;//998244353
const int N = 1e5+5;

ll n,m;

bool check(ll x){
	if(n>=x){
		if(x*2<=m)return 1;
		return 0;
	}
	else{
		ll need=x-n;
		if(x*2<=m-need*2)return 1;
		return 0;
	}
}

void solve(){
	cin>>n>>m;
	ll l=0,r=1e18,ans=0;
	while(l<=r){
		ll m=(l+r)/2;
		if(check(m)){
			ans=m;
			l=m+1;
		}
		else r=m-1;
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> As(N);

    REP(n, N) {
        cin >> As[n];
    }

    int ans = 0;
    if (K == N) {
        ans = 1;
    }
    else {
        int n = N - K;
        ans = 1 + (n + (K - 2)) / (K - 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

uint64_t dp[2010][2010] = {};

int main() {
  uint64_t s;
  cin >> s;
  uint64_t ss = s / 3 + 1;
  const uint64_t mod = 1'000'000'007;
  uint64_t sum = 0;
  dp[0][0] = 1;
  for (uint64_t i = 1; i <= ss; ++i) {
    for (uint64_t j = 3; j <= s; ++ j) {
      dp[i][j] = (dp[i-1][j-3] + dp[i][j-1]) % mod;
    }
    sum = (sum + dp[i][s]) % mod;
  }

  cout << sum << endl;
}


Measured memory_bytes: 13576
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int x,n;
	cin >> x >> n;
	bool a[102] = {0};
  
	int t;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
    	a[t] =1;
	}
  
	int ans = 0;
  
	for (int i = 0; i <= 101; i++)
	{
    	if (a[i] == 0)
		{
    		if(abs(x-i) < abs(x-ans))
			{
        		ans = i;
			}
    	}
	}
         
	cout << ans;
	return 0;
}

Measured memory_bytes: 3580
/*


*/

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

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

#define endl '\n'
#define ld long double
#define ll long long
#define PI acos(-1.0)
#define OO 1e13
#define EPS 1e-12
#define MLOG 20
#define MAX 1* 100 * 1000+5
const int mod = 1e9 + 7;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
#ifndef ONLINE_JUDGE
	freopen("E:\\Competitve\\solving\\input.txt", "r", stdin);
	freopen("E:\\Competitve\\solving\\output.txt", "w", stdout);
#endif
}
int n, k, s;
int w[101], v[101];

ll dp[MAX];
int main(){
	//fast();

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i], s += v[i];

	for (int i = 1; i <= s; i++)
		dp[i] = OO;

	dp[v[0]] = w[0];
	for (int i = 1; i< n; i++){
		for (int j = s; j >= v[i]; j--){
			if (w[i] + dp[j - v[i]] <= k){
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= s; i++){
		if (dp[i] != OO)
			ans = i;
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,a[200001];
long long ans;
int main() {
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i]; a[i]-=(i+1);
    }
    sort(a,a+n);
    for (int i=0; i<n; i++) {
        ans+=abs(a[i]-a[n/2]);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 4356
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int min(int a, int b){
	if(a<b)return a;
	else return b;
}

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


int main(void){
	int n;
	cin>>n;
	ll a[n], l[n-1], r[n-1];
	rep(i,n)cin>>a[i];
	l[0]=a[0];
	r[n-2]=a[n-1];
	rep(i,n-2){
		l[i+1]= gcd(l[i],a[i+1]);
		//cout<<"l["<<i+1<<"]="<<l[i+1]<<endl;
		r[n-3-i]= gcd(r[n-2-i],a[n-2-i]);
		//cout<<"r["<<n-3-i<<"]="<<r[n-3-i]<<endl;
	}
	ll ans=0;
	if(r[0] > ans)ans=r[0];
	if(l[n-2] > ans)ans=l[n-2];
	rep(i,n-2){
		ll tmp=gcd(l[i],r[i+1]);
		//printf("gcd(%lld,%lld)=%lld\n", l[i],r[n-2-i],tmp);
		if(ans<tmp)ans=tmp;
	}

	cout<<ans<<endl;
	return 0;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, bool>> num(10);
	for (int a = 1; a <= 9; a++) {
		int p = 0;
		if (a == 1)p = 2;
		if (a == 7)p = 3;
		if (a == 4)p = 4;
		if (a == 2 || a == 3 || a == 5)p = 5;
		if (a == 6 || a == 9)p = 6;
		if (a == 8)p = 7;
		num[a].first = p;
	}

	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		num[a].second = true;
	}

	vector<int> dp(N + 1, -1000);
	dp[0] = 0;
	int po = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= 9; j++) {
			if (num[j].second && i + num[j].first <= N) {
				dp[i + num[j].first] = max(dp[i + num[j].first], dp[i] + 1);
				if (dp[i + num[j].first] > 0) po = max(po, i + num[j].first);
			}
		}
	}

	//cout << "after dp" << endl;
	vector<int> ans;
	while (po != 0) {
		for (int i = 9; i >= 1; i--) {
			if (po - num[i].first >= 0 && num[i].second && dp[po] - 1 == dp[po - num[i].first]) {
				ans.push_back(i);
				po -= num[i].first;
				break;
			}
		}
		//cout << "po=" << po << endl;
	}

	//reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size() ; i++) {
		cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 3700
m = int(input())
x = m // 1.08
x = int(x)
N = int(x * 1.08)
if N == m:
    print(x)
elif N > m:
    if int((x - 1) * 1.08) == m:
        print(x-1)
    else:
        print(":(")
elif N < m:
    if int((x + 1) * 1.08) == m:
        print(x+1)
    else:
        print(":(")
else:
    print(":(")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int alice = 0;
  int sum = 0;
  for(int i = n-1; i >= 0; i-=2){
    alice+=a[i];
  }
  for(int i = 0; i < n; i++){
    sum+=a[i];
  }
  cout << alice*2-sum << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
   let mut s = String::new();
   std::io::stdin().read_line(&mut s).ok();
   s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
   let s = read::<String>();
   s.split(delimiter)
      .map(|e| e.parse().ok().unwrap())
      .collect::<Vec<T>>()
}

use std::collections::VecDeque;
fn main() {
   let mut K = read::<i32>();
   let mut q = VecDeque::new();
   for i in 1..10 {
      q.push_back(i as i64);
   }

   while K != 1 {
      let x = q.pop_front().unwrap();
      if x % 10 != 0 {
         q.push_back(x * 10 + x % 10 - 1)
      }
      q.push_back(x * 10 + x % 10);
      if x % 10 != 9 {
         q.push_back(x * 10 + x % 10 + 1)
      }
      K -= 1;
   }
   println!("{}", q.pop_front().unwrap());
}


Measured memory_bytes: 6396
import java.util.*;
import java.lang.*;

// 10 3
// 4 5 6
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(solve(inputStr(sc, " "), inputStr(sc, " ")) ? "Yes" : "No");
    }

    private static String[] inputStr(Scanner sc, String... delimiter) {
        return sc.nextLine().split(delimiter == null ? " " : delimiter[0]);
    }

    private static boolean solve(String[]... inputs) {
        int h = Integer.parseInt(inputs[0][0]);
        return h <= Arrays.stream(inputs[1]).reduce(0, (sum, e) -> sum += Integer.parseInt(e),
                (sum1, sum2) -> sum1 + sum2);

    }
}


Measured memory_bytes: 47516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> A(3,vector<int>(3));
  vector<vector<int>> ans(3,vector<int>(3,0));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int N;
  cin >> N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  for(int bnum=0;bnum<N;bnum++){
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(A.at(i).at(j)==b.at(bnum)){
          ans.at(i).at(j)=1;
        }
      }
    }
  }
  bool bingo = false;
  for(int i=0;i<3;i++){
    if(ans.at(i).at(0)+ans.at(i).at(1)+ans.at(i).at(2)==3){
      bingo = true;
    }
    if(ans.at(0).at(i)+ans.at(1).at(i)+ans.at(2).at(i)==3){
      bingo = true;
    }
  }
  if(ans.at(0).at(0)+ans.at(1).at(1)+ans.at(2).at(2)==3){
    bingo = true;
  }
  if(ans.at(0).at(2)+ans.at(1).at(1)+ans.at(2).at(0)==3){
    bingo = true;
  }
  if(bingo){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){
    int a,b,c;

    cin>>a>>b>>c;
    if(a==b && b==c){
        cout<<"1";
    }
    else if(a==b || b==c || c==a){
        cout<<"2";
    }
    else cout<<"3";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#define gec getchar
#define puc putchar
#define File(S) (freopen(S".in","r",stdin),freopen(S".out","w",stdout))
using namespace std;
typedef long long ll;
template <typename T>
inline void read(T&a){
	static char ch;
	static bool sign;
	for(ch=gec(),sign=0;ch<'0'||ch>'9';ch=gec())sign^=(ch=='-');
	for(a=0;ch>='0'&&ch<='9';ch=gec())a=((a+(a<<2))<<1)+(ch^'0');
	if(sign)a=-a;
}
template <typename T>
inline void print(T x){
	static int Buf[30],PS=0,BUF;
    if(x<0)puc('-'),x=-x;
    for(;x>=10;x=BUF){
    	BUF=(x/5)>>1;
    	Buf[++PS]=x-((BUF+(BUF<<2))<<1);
    }
    Buf[++PS]=x;
    while(PS)puc('0'^Buf[PS--]);
}
const int N=2e5+10;
int cnt[N],COUNT[2*N],a[N];
int *Count=COUNT+N; 
int n,Sum,x,y,m;
int main()
{
	read(n);read(m);
	for(int i=1;i<=n;i++)read(a[i]),cnt[a[i]]++;
	for(int i=1;i<=n;i++)
    	for(int j=cnt[i];j;j--)
    	Count[i-j+1]++;
    for(int i=1;i<=n;i++)Sum+=(bool)Count[i];
	while(m--){
		read(x);read(y);
		Sum-=(--Count[a[x]-cnt[a[x]]+1]||(a[x]-cnt[a[x]]<0))?0:1;
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		Sum+=(Count[a[x]-cnt[a[x]]+1]++||(a[x]-cnt[a[x]]<0))?0:1;
		printf("%d\n",n-Sum);
	}
	return 0;
}

Measured memory_bytes: 3840
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<10&&b<10) {
			System.out.println(a*b);
		}
		else {
			System.out.println(-1);
		}
	}	
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  deque<int>dq;
  string s;cin>>s;
  for(auto ch:s){
    if(ch=='0')dq.pb(0);
    else if(ch=='1')dq.pb(1);
    else{
      if(dq.size()>0)dq.pop_back();

    }
  }
  int n=dq.size();
  for(int i=0;i<n;++i)cout<<dq[i];
  cout<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	vector< int > A(3 * N);
	rep(i, 3 * N) cin >> A[i];
	priority_queue< int > C;
	priority_queue< int, vector< int >, greater< int > > B;
	int Bsum = 0,
		Csum = 0;
	rep(i, N) {
		B.push(A[i]);
		Bsum += A[i];
	}
	rep(i, N) {
		C.push(A[i + 2 * N]);
		Csum += A[i + 2 * N];
	}
	vector< int > Bacc(N + 1), Cacc(N + 1);
	Bacc[0] = Bsum;
	Cacc[0] = Csum;
	rep(i, N) {
		Bsum += A[i + N];
		B.push(A[i + N]);
		Bsum -= B.top();
		B.pop();
		Bacc[i + 1] = Bsum;
	}
	rep(i, N) {
		Csum += A[2 * N - 1 - i];
		C.push(A[2 * N - 1 - i]);
		Csum -= C.top();
		C.pop();
		Cacc[i + 1] = Csum;
	}
	int ans = -LINF;
	for (int i = 0; i <= N; i++) {
		chmax(ans, Bacc[i] - Cacc[N - i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

const int MAXN = 200000 + 10;

long long res = 0;
char str[MAXN];

int main() {
    scanf("%s", str + 1);
    int n = strlen(str + 1);
    rep(i, 1, n) {
        res += str[i] - '0';
    }
    puts(res % 9 ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli pre0[MaxN],pre1[MaxN],suf0[MaxN],suf1[MaxN];
	void solve(){
		lli N,i,j,p=0,q=0,res=1e9,negro=0;
		string bin;
		cin>>N;
		cin>>bin;
		bin='0'+bin;
		pre0[0]=pre1[0]=suf0[N+1]=suf1[N+1]=0;
		for(i=1;i<=N;i++){
			p=q=0;
			if(bin[i]=='#'){
				p=1;
			}
			else q=1;
			pre0[i]=pre0[i-1]+q;
			pre1[i]=pre1[i-1]+p;
		}
		for(i=N;i>=1;i--){
			p=q=0;
			if(bin[i]=='#'){
				p=1;
			}
			else q=1;
			suf0[i]=suf0[i+1]+q;
			suf1[i]=suf1[i+1]+p;
		}
		for(i=1;i<=N;i++){
			p=pre1[i]+suf0[i+1];
			res=min(res,p);
		}
		res=min(pre1[N],res);
		res=min(pre0[N],res);
		cout<<res<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 6848
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, M, X;
	cin >> N >> M >> X;

	static int cost[200];
	REP(i, M) {
		int a;
		cin >> a;
		cost[a]++;
	}
	
	int ans1 = 0;
	REPN(i, X, N) {
		ans1 += cost[i];
	}
	int ans2 = 0;
	REP(i, X) {
		ans2 += cost[i];
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  vint a(N);
  rep(i, N) cin >> a[i];
  int ans = inf;
  rep(bit, 1<<N) {
    if(__builtin_popcount(bit) != K) continue;
    int sum = 0;
    int mx = 0;
    rep(i, N) {
      if((bit>>i)&1) {
	if(a[i] <= mx) {
	  mx++;
	  sum += mx-a[i];
	}
      }
      chmax(mx, a[i]);
    }
    chmin(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << a[n-1] << endl;

}



Measured memory_bytes: 256
from copy import deepcopy


def mk_array(init_val, *args):
    args = args[::-1]
    res = [init_val for _ in range(args[0])]
    for arg in args[1:]:
        res = [deepcopy(res) for _ in range(arg)]
    return res


N = int(input())
e = [0 for _ in range(N + 1)]

for i in range(2, N + 1):
    for j in range(2, i + 1):
        while i % j == 0:
            e[j] += 1
            i //= j

counts = list(filter(lambda x: x > 0, e))
prim_count = len(counts)
counts = [0] + counts  # 1-indexed 化
dp = mk_array(0, prim_count + 1, 75 + 1)
dp[0][1] = 1

for i in range(1, prim_count + 1):
    for j in range(1, 75 + 1):
        for k in range(min(counts[i], 75 // j - 1) + 1):
            dp[i][j * (k + 1)] += dp[i - 1][j]

print(dp[prim_count][75])


Measured memory_bytes: 3700
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,a,b,k;
    cin>>n>>a>>b;
    m=(n/(a+b))*a;
    n%=(a+b);
    m+=min(a,n);
    cout<<m<<el;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    vector<int64_t> Dp(N+1,1e6);
    Dp.front()=0;

    rep(i,0,N){
        if(i+1<N+1) Dp.at(i+1)=min(Dp.at(i+1),Dp.at(i)+1);

        int n=6;
        while(n<N+1){
            if(i+n<N+1) Dp.at(i+n)=min(Dp.at(i+n),Dp.at(i)+1);
            n*=6;
        }

        n=9;
        while(n<N+1){
            if(i+n<N+1) Dp.at(i+n)=min(Dp.at(i+n),Dp.at(i)+1);
            n*=9;
        }
    }

    cout<<Dp.at(N)<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i = 0;
		int[] stack = new int[1001];
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				String str = sc.next();
				if(str.charAt(0) == '+') {
					stack[i-2] += stack[i-1];
					i--;
				}
				else if(str.charAt(0) == '-') {
					stack[i-2] -= stack[i-1];
					i--;
				}
				else if(str.charAt(0) == '*') {
					stack[i-2] *= stack[i-1];
					i--;
				}
				else {
					stack[i] = Integer.parseInt(str);
					i++;
				}
			}
		}
        System.out.println(stack[0]);
	}	
}



Measured memory_bytes: 26320