akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    int ans = 0;
    bool flag = false;

    for(int i = 0; i < N.size(); i++){
        int number = (int)(N[i] - '0');
        if(number == 4){
            if(!flag){
                ans += number;
            }else{
                if(i + 1 < N.size() && N[i+1] > '4'){
                    ans += (9 - number);
                }else{
                    ans += number;
                    if(flag){
                        ans++;
                        flag = false;
                    }
                }
            }
        }else if(number == 5){
            if(flag){
                ans += (9 - number);
            }else{
                if(i + 1 < N.size() && N[i+1] > '4'){
                    ans += (9 - number);
                    if(!flag){
                        flag = true;
                        ans++;
                    }
                }else{
                    ans += number;
                }
            }
        }else if(number < 4){
            ans += number;
            if(flag){
                ans++;
                flag = false;
            }
        }else{
            ans += (9 - number);
            if(!flag){
                flag = true;
                ans++;
            }
        }
    }

    if(flag){
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  ll ans = 0;
  int k;
  ll r = 0, g = 0, b = 0;
  vector<char> S(N+1);
  FOR(i,1,N+1){
    cin >> S[i];
    if(S[i] == 'R') r++;
    if(S[i] == 'G') g++;
    if(S[i] == 'B') b++;
  }
  ans = r * g * b;
  FOR(i,1,N-1){
    FOR(j,i+1,N){
      k = 2 * j - i;
      if(k > N) break;
      if(S[i] != S[j] && S[i] != S[k] && S[k] != S[j])
        ans--;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    unsigned int x;
    cin >> x;
    bitset<32> b(x);

    cout << b << endl;
    cout << ~b << endl;
    cout << (b << 1) << endl;
    cout << (b >> 1) << endl;

    return 0;
}



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

int main(){
  double w,h,x,y,c;
  double s;
 
  cin>>w>>h>>x>>y;
  
  
  if(x==w/2 && y==h/2) c=1;
  else c=0;
  
  s=(double)w*h/2.0;
  
  cout<<s<<' ';
  cout<<c<<endl;
  
  

 return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string pre="#";
int ans=0;
int main(){
	string s,now="";
	cin>>s;
	for(char c:s){
		now.push_back(c);
		if(now!=pre){
			pre=now;
			ans++;
			now="";
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  string s;
  cin >> s;
  if(s=="ABC")cout << "ARC";
  if(s=="ARC")cout << "ABC";
}

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 +7;

string str;

ll dfs(ll a, ll b, ll c){
    if(str.size() == c){
        return a + b;
    }else{
        ll m = dfs(a, b*10 + str[c] - '0', c+1);
        ll n = dfs(a + b, str[c] - '0', c+1);
        return m + n;
    }
}

int main(){
    cin >> str;
    ll ans = dfs(0, str[0] - '0', 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p){return (p.x!=x)?p.x<x:p.y<y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};


struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  Point project(Point p){
    Point base=b-a;
    Real t=(p-a).dot(base)/base.dot(base);
    return a+base*t;
  }
  
  Point symmetry(Point Q){
    return Q+(project(Q)-Q)*2;
  }
};

int main(void){

  Line l;
  Point Q;
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf"
	       ,&l.a.x,&l.a.y,&l.b.x,&l.b.y,&Q.x,&Q.y)){
    Point R=l.symmetry(Q);
    printf("%.8f %.8f",R.x,R.y);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "["; for (int i=0; i<(int)v.size(); i++) cout << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p>>=1;){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

int N,a[500100],dp[500100][3];
int c[500100],K;

int get_ans(int l, int r){
    int i,j,cr=0;
    K=0;

    for (i=l; i<=r; i++)
        if (a[i]==1) cr++;
        else c[++K]=cr,cr=0;

    c[++K]=cr;
    dp[K+1][2]=-2*N;
    dp[K+1][0]=dp[K+1][1]=0;
    for (i=K; i>0; i--){
        for (j=0; j<3; j++)
            dp[i][j]=0;

        dp[i][0]=max(dp[i+1][1],c[i]+dp[i+1][2]);

        if (c[i]==1){
            dp[i][2]=dp[i+1][0];
            dp[i][1]=max(1+dp[i+1][0],dp[i][0]);
        }
        else{
            dp[i][2]=max(c[i]-1+dp[i+1][2],dp[i+1][1]);
             dp[i][1]=max({c[i]-1+dp[i+1][1],c[i]+dp[i+1][0],dp[i][0]});
        }
    }

    return dp[1][0];
}

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

    int i,j;
    for (i=1; i<=N; i++){
        char c;
        cin >> c;
        a[i]=c-'0';
    }

    int res=0;
    for (i=1; i<=N;){
        if (a[i]!=0){
            j=i;
            while (j<=N && (a[j]!=0 || a[j-1]!=0))
                j++;

            while (j>N || a[j]==0)
                j--;

            res+=get_ans(i,j);
            i=j+1;
        }
        else i++;
    }

    cout << res << "\n";
	return 0;
}
/*

10
1011011011
*/


Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
"""
http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    worst_rank = -1
    worst_score = float('inf')

    N = int(input())
    for _ in range(N):
        r, s = map(int, input().split(' '))
        if r > worst_rank:
            worst_rank = r
            worst_score = s

    print(worst_rank + worst_score)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<string>s(N);
	for (auto &i : s)cin >> i;
	int num = 0;
	int aed = 0;
	int bst = 0;
	int ab = 0;
	for (auto i : s) {
		for (int j = 0; j < i.size() - 1; j++) {
			if (i[j] == 'A'&&i[j + 1] == 'B')num++;
		}
		if (i.back() == 'A')aed++;
		if (i.front() == 'B')bst++;
		if (i.back() == 'A'&&i.front() == 'B')ab++;
	}
	int add = min(aed, bst);
	if (max(aed,bst) == ab&&ab)add--;
	cout << num + add << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,sm=0;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    unordered_map<ll,ll> mp;
    
    for (int i = 0; i < n; i++)
    {
        if(mp.find(a[i])==mp.end())
        {
            mp.insert(make_pair(a[i],1LL));
        }
        else
        {
            mp[a[i]]++;
        }
    }

    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        ll tmp = it->second;
        sm+=tmp*(tmp-1)/2;
    }
    for (int i = 0; i < n; i++)
    {
        ll tmp = mp.at(a[i]);
        ll ans = sm- tmp*(tmp-1)/2 + (tmp-1)*(tmp-2)/2;
        cout<<ans<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 9160
#import numpy as np
import sys
import heapq #優先度付きキュー
input = sys.stdin.readline
n,m = (int(i) for i in input().split())
a = [int(i)*(-1) for i in input().split()] #各要素*(-1)
heapq.heapify(a)
for i in range(m):
    """
    k = np.argmax(a)
    if a[k] == 0:
        break
    a[k] = int(a[k]/2)
    """
    tmp = heapq.heappop(a) #最小値を抜き取る(最大値*(-1)を抜き取る）
    heapq.heappush(a, (-1)*(-tmp//2)) #要素を追加
ans = -sum(a)
print(ans)


Measured memory_bytes: 14204
#include <cstdio>

int main(){
    char b, B[] = {'A', 'C', 'T', 'G'};
    scanf("%c", &b);
    int i=0;
    for(; i<4; i++){
        if(b==B[i]) break;
    }
    printf("%c\n", B[(i+2)%4]);
    return 0;
}

Measured memory_bytes: 128
arr = []
5.times do |i|
    a = gets.chomp.to_i
    arr << a
end
k = gets.chomp.to_i
kkk = []
arr.each do |f|
    arr.each do |k|
       kkk << (f - k).abs 
    end
end

until kkk == []
    aaa = kkk.pop
    if aaa > k
        puts ":("
        exit
    end
end
puts "Yay!"

Measured memory_bytes: 14384
S = input()
def f(S):
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            return "{} {}".format(i+1, i+2)
        elif i < len(S)-2 and S[i] == S[i+2]:
            return "{} {}".format(i+1, i+3)
        else:
            pass
    return "-1 -1"
print(f(S))

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int j = -1;
  int cur = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    while (j < n - 1 && cur + a[j + 1] == (cur ^ a[j + 1])) {
      cur += a[++j];
    }
    ans += j + 1 - i;
    cur -= a[i];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
def main():
    h,w=map(int,input().split())
    s=[]
    for _ in range(h):
        a=list(input())
        s.append(a)

    t=0
    b=0
    l=0
    r=0
    cntw=0
    si=[[-1 for _ in range(w)]for _ in range(h)]
    before=0
    after=0
    # print(si)
    si[0][0]=0

    tempw=0

    # print(si)
    for i in range(0,h):
        for j in range(0,w):
            if s[i][j]=='.':
                tempw+=1


    before=1
    temps=0
    flag=1
    while flag==1:
        # print(si)
        flag=0
        for i in range(0,h):
            for j in range(0,w):

                if i==0 and j ==0:
                    j=1

                if s[i][j]=='.' :
                    cntw+=1
                    if i==0 or s[i-1][j]=='#' or si[i-1][j]<0:
                        t=10000
                    else:
                        t=si[i-1][j]
                    if j ==0 or s[i][j-1]=='#' or si[i][j-1]<0:
                        # print(i)
                        # print(j)
                        # print(s[i][j-1])
                        # print(si[i][j-1])
                        l=10000
                    else:
                        l=si[i][j-1]
                    if i==h-1 or s[i+1][j] =='#' or si[i+1][j]<0:
                        b=10000
                    else:
                        b=si[i+1][j]
                    if j==w-1 or s[i][j+1]=='#' or si[i][j+1]<0:
                        r=10000
                    else:
                        r=si[i][j+1]
                    temps=min(t,l,b,r)+1
                    # print(temps)
                    if temps<si[i][j] or (si[i][j]==-1 and temps!=10001):
                        si[i][j]=temps
                        flag=1
                        # print(si)
                        # print(i)
                        # print(j)


    if si[-1][-1]<0:
        print(-1)
        return
    else:
        print(tempw-si[-1][-1]-1)





if __name__=='__main__':
    main()


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    int absmax = 0;
    int pos = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(absmax < abs(a[i]-0))
        {
            pos = i;
            absmax = abs(a[i]-0);
        }
    }

    int cand = a[pos];
    cout << 2*n-1 << endl;
    if(cand >= 0)
    {
        for(int i = 0; i < n; i++)
        {
            a[i] += cand;
            cout << pos+1 << " " << i+1 << endl;
        }
        for(int i = 0; i < n-1; i++)
        {
            a[i+1] += a[i];
            cout << i+1 << " " << i+2 << endl;
        }
    }
    else
    {
        for(int i = 0; i < n; i++)
        {
            a[i] += cand;
            cout << pos+1 << " " << i+1 << endl;
        }
        for(int i = n-1; i >= 1; i--)
        {
            a[i-1] += a[i];
            cout << i+1 << " " << i << endl;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	ll n;
	cin >> n;
	ll k = 26;
	string s;
	
	while (n > 0)
	{
		s += char('a' + (n-1) % 26);
		n = (n-1) / 26;
	}
	reverse(all(s));

	cout << s;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("luigi.in", "r", stdin);
	//freopen("luigi.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let n = s.len();
    let t: Vec<char> = "keyence".chars().collect();
    let mut ch = 0;
    let mut ct = 0;
    for i in 0..7 {
        if s[i] == t[i] {
            ch += 1;
        } else {
            break;
        }
    }
    for i in 0..7 {
        if s[n - 1 - i] == t[6 - i] {
            ct += 1;
        } else {
            break;
        }
    }
    println!("{}", if ch + ct >= 7 {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int S[1000];
int top;
void push(int x){
  top ++;
  S[top]=x;
}
int pop(){
  top--;
  return S[top+1];
}

int main(){
  char s[100];
  int c,b,a,top=0;
  while(scanf("%s",s)!= EOF){
    if(s[0]=='+')
      {
	a=pop();
	b= pop();
	push(a+b);

	  }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else push(atoi(s));
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2108
def main():
    n = int(input())

    i = 0
    ans = 1
    while 2**i < n:
        i += 1
    if 2**i == n:
        ans = 2**i
    else:
        ans = 2**(i-1)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
      int inputK,inputN,firstRow[3],secondRow[3],thirdRow[3];
      
      // Create a array for every row in a bingo and fill it with values
      scanf("%d%d%d",&firstRow[0],&firstRow[1],&firstRow[2]);
    
      scanf("%d%d%d",&secondRow[0],&secondRow[1],&secondRow[2]);
    
      scanf("%d%d%d",&thirdRow[0],&thirdRow[1],&thirdRow[2]);
      
      // Check if values in bingo are the same with the input
      // If input value and value in the bingo is the same, then makes it '-1'
      scanf("%d",&inputN);
      for(int i=0;i<inputN;i++)
      {
        scanf("%d",&inputK);
          
        for(int j=0;j<3;j++)
        {
          if(firstRow[j] == inputK)
          {
              firstRow[j]= -1;
          }
        }
        for(int j=0;j<3;j++)
        {
          if(secondRow[j] == inputK)
          {
            secondRow[j]= -1;
          }
        }
        for(int j=0;j<3;j++)
        {
          if(thirdRow[j]==inputK)
          {
            thirdRow[j]= -1;
          }
        }
          
      }
      
      // Print 'Yes' if you have bingo, 'No' if there are no same values in rows
      if((firstRow[0]== -1 && firstRow[1]== -1 && firstRow[2]== -1 ) || (secondRow[0]== -1 && secondRow[1]== -1 && secondRow[2]== -1) || (thirdRow[0]== -1 && thirdRow[1]== -1 && thirdRow[2]== -1))
      {
          printf("Yes\n");
      }
      // Print 'Yes' if you have bingo, 'No' if there are no same values in columns
      else if((firstRow[0]== -1 && secondRow[0]== -1 && thirdRow[0]== -1) || (firstRow[1]== -1 && secondRow[1]== -1 && thirdRow[1]== -1) || (firstRow[2]== -1 && secondRow[2]== -1 && thirdRow[2]== -1))
      {
          printf("Yes\n");
      }
      // Print 'Yes' if you have bingo, 'No' if there are no same values in diagonall
      else if((firstRow[0]== -1 && secondRow[1]== -1 && thirdRow[2]== -1) || (firstRow[2]== -1 && secondRow[1]== -1 && thirdRow[0]== -1))
      {
         printf("Yes\n");
      }
      else
      {
         printf("No\n");
      }
      return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut a = read::<String>().chars().collect::<Vec<char>>();

    let mut b = Vec::new();
    b.push(a[0]);
    for i in 1..n {
        if a[i] == a[i-1] {
            continue;
        }
        b.push(a[i]);
    }

    println!("{}", b.len());
}

Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

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

		final int n = sc.nextInt();
		final int m = sc.nextInt();

		int[] dist = new int[n];
		dist[0] = 0;
		for (int i = 1; i < n; i++) {
			dist[i] = dist[i - 1] + sc.nextInt();
		}

		int d = 0;
		int state = 0;
		for (int i = 0; i < m; i++) {
			int pos = sc.nextInt();

			d += Math.abs(dist[state] - dist[state + pos]);
			state += pos;

			d %= 100000;
		}

		System.out.println(d);
	}

}

Measured memory_bytes: 13000
#include<stdio.h>

int calc(int h, int m){
	return h*60+m;
}

int main(){
	int time,time2,a,b,e,f,i,N,M,h[500],m[500], count=0;
	scanf("%d",&N);
	
	for(a=0;a<N;a++){
		scanf("%d %d",&h[a],&m[a]);
	}
	
	scanf("%d",&M);
	
	for(b=0;b<M;b++){
		scanf("%d %d",&h[b+a],&m[b+a]);
	}
	
	for(e=0;e<N+M;e++){
		for(f=e+1;f<N+M;f++){
			/*
			if(h[e]>h[f]){
				i=h[e];
				h[e]=h[f];
				h[f]=i;
				i=m[e];
				m[e]=m[f];
				m[f]=i;
			}else if(h[e]==h[f]){
				if(m[e]>m[f]){
					i=m[e];
					m[e]=m[f];
					m[f]=i;
				}
			}
			*/
			if(calc(h[e], m[e]) > calc(h[f], m[f])){
				i=h[e];
				h[e]=h[f];
				h[f]=i;
				i=m[e];
				m[e]=m[f];
				m[f]=i;
			}
		}
	}
	
	
	for(e=0;e<N+M;e++){
		if(!e || h[e]!=h[e-1]||m[e]!=m[e-1]){
			if(count!=0){
				printf(" ");
			}
			count++;
			printf("%d:%02d",h[e],m[e]);
		}
	}
	printf("\n");
	
return 0;
}

Measured memory_bytes: 620
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll N;
ll A[300000];

int main()
{
	cin>>N;
	ll v=-1;
	ll b;
	rep(i,N){
		cin>>A[i];
		if(v<A[i]){
			b=i;
			v=A[i];
		}
	}
	ll ans=-1;
	ll x,id;
	rep(i,N){
		if(i==b) continue; 
		x=A[i];
		if(x*2LL>v) x=v-x;
		if(ans<x){
			id=i;
			ans=x;
		}
	}
	cout<<v<<" "<<A[id]<<endl;
}

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

public class Main {

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

		Integer sum = 0;

		Integer numTypeDonuts= new Integer(scanner.next());
		Integer donutsMaterials = new Integer(scanner.next());

		ArrayList<Integer> materialAmount = new ArrayList<Integer>();
		for(int i = 0; i < numTypeDonuts;i++) {
			materialAmount.add(new Integer(scanner.next()));
			sum += materialAmount.get(i);

		}
		Integer output = (donutsMaterials - sum) / Collections.min(materialAmount) + numTypeDonuts;

		System.out.println(output);

		 scanner.close();
	}

}


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


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt() / 1000;
        int a = -1;
        int b = -1;
        int c = -1;
        out: for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                if (10 * i + 5 * j + (n - i - j) == y) {
                    a = i;
                    b = j;
                    c = n - i - j;
                    break out;
                }
            }
        }
        System.out.println(a + " " + b + " " + c);
    }
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[])
{
  int m,n,count=0;
  n = h2(getKey(str));
  for(m = h1(getKey(str)) ; count < M ; m+=n)
    {
      if(m >= M) m = m - M;
      if(strcmp(H[m],str) == 0) return 1;
      if(H[m][0] == '\0') return 0;
      count++;
    }
  return 0;
}

int insert(char str[])
{
  int m,n;
  
  n = h2(getKey(str));
  
  for(m = h1(getKey(str)) ; 1 ; m+=n)
    {
      if(m >= M) m = m - M;
      if(strcmp(H[m],str) == 0) break;
      if(H[m][0] == '\0')
	{
	  strcpy(H[m],str);
	  break;
	}
    }
  return 1;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ )
    {
      scanf("%s %s", com, str);
	
      if ( com[0] == 'i' )
	{
	  insert(str);
	}
      else
	{
	  if (find(str))
	    {
	      printf("yes\n");
	    }
	  else
	    {
	      printf("no\n");
	    }
	}
    }

  return 0;
}



Measured memory_bytes: 15396
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,k,h,w,ans,dx[]={0,1,0,-1},dy[]={-1,0,1,0};
string s;

main(){
	int a[10]={};
	rep(i,4){
		cin>>n;
		a[n]++;
	}
	if(a[1]&&a[7]&&a[9]&&a[4])dump("YES");
	else dump("NO");
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    cin>>N;
    int a=0,w=0,t=0,r=0;
    for(int i=0;i<N;i++){
        string in;
        cin>>in;
        if(in=="AC") a++;
        else if(in=="WA") w++;
        else if(in=="TLE") t++;
        else r++;
    }

    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
    cout<<"TLE x "<<t<<endl;
    cout<<"RE x "<<r<<endl;
}



Measured memory_bytes: 3164
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

A = np.array(A)

cnt = 0

while 1:
    for i in range(N):
        if A[i]%2:
            print(cnt)
            exit()

    A = A/2
    cnt+=1




Measured memory_bytes: 12424
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 3e6+10;
int n,m,pw[N];
char s[N];

int cnt,son[N][3],p[N];
inline void dfs(int u,int dep,int x){
	if (dep==n) return p[u]=x,void(0);
	son[u][0]=++cnt,dfs(son[u][0],dep+1,x);
	son[u][1]=++cnt,dfs(son[u][1],dep+1,x+pw[dep]);
	son[u][2]=++cnt,dfs(son[u][2],dep+1,x+2*pw[dep]);
}

int tag[N];
inline void upd(int u){
	swap(son[u][1],son[u][2]),tag[u]^=1;
}
inline void push_down(int u){
	if (!tag[u]) return;
	FOR(i,0,3) upd(son[u][i]);
	tag[u]=0;
}
inline void dfs(int u,int dep){
	if (dep==n) return;
	push_down(u);
	int tmp=son[u][2];
	son[u][2]=son[u][1],son[u][1]=son[u][0],son[u][0]=tmp;
	dfs(son[u][0],dep+1);
}

int ans[N];
inline void print(int u,int dep,int x){
	if (dep==n) return ans[p[u]]=x,void(0);
	push_down(u);
	print(son[u][0],dep+1,x);
	print(son[u][1],dep+1,x+pw[dep]);
	print(son[u][2],dep+1,x+2*pw[dep]);
}

int main(){
	n=read(),scanf("%s",s+1),m=strlen(s+1);
	pw[0]=1;
	For(i,1,n) pw[i]=pw[i-1]*3;
	dfs(0,0,0);
	For(i,1,m){
		if (s[i]=='S') upd(0);
			else dfs(0,0);
	}
	print(0,0,0);
	FOR(i,0,pw[n]) printf("%d ",ans[i]);
}

Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  ll S,ans=0;
  cin>>S;
  while(S!=4){
    if(S==1||S==2){
      break;
    }
    else if(S%2==0){
      S/=2;
      ans++;
    }
    else{
      S=S*3+1;
      ans++;
    }
  }
  cout<<ans+4;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			try{
				double a = in.nextDouble();
				if(a <= 48.00){
					System.out.println("light fly");
				}else if(a > 48.00 && a <= 51.00){
					System.out.println("fly");
				}else if(a > 51.00 && a <= 54.00){
					System.out.println("bantam");
				}else if(a > 54.00 && a <= 57.00){
					System.out.println("feather");
				}else if(a > 57.00 && a <= 60.00){
					System.out.println("light");
				}else if(a > 60.00 && a <= 64.00){
					System.out.println("light welter");
				}else if(a > 64.00 && a <= 69.00){
					System.out.println("welter");
				}else if(a > 69.00 && a <= 75.00){
					System.out.println("light middle");
				}else if(a > 75.00 && a <= 81.00){
					System.out.println("middle");
				}else if(a > 81.00 && a <= 91.00){
					System.out.println("light heavy");
				}else if(a > 91.00){
					System.out.println("heavy");
				}
			}catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define fastio ios::sync_with_stdio(false)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;



ll  Solve(vector<ll>& nums, int N)
{
    if(nums.back() == 0) return -1;
    
    ll nodeCount = 0;
    ll currentNodes = 1;
    std::vector<ll> maxNodeCount(N, 0);
    std::partial_sum(nums.rbegin(), nums.rend(), maxNodeCount.rbegin());
    maxNodeCount.push_back(0);

    for(int i = 0; i < N; i++)
    {
    	int foliage = nums[i];

	currentNodes = min(currentNodes, maxNodeCount[i]);
    	nodeCount += currentNodes;
    	if(foliage > currentNodes) return -1;
	if(currentNodes <= 0 && i != N-1) return -1;

    	currentNodes -= foliage;
    	currentNodes *= 2;
    }

    
    
    return nodeCount;
}


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

    int N;
    cin >> N;
    std::vector<ll> nums(N+1, 0);

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

    if(nums[0])
    {
	if(N == 0 && nums[0] == 1)
	    std::cout << 1 << "\n";
	else
	    std::cout << -1 << "\n";
	return 0;
    }

    ll result = Solve(nums, N+1);
    std::cout << result << "\n";

    return 0;
}


Measured memory_bytes: 5572
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  REP(i, m) {
    int k;
    cin >> k;
    vector<int> s(k);
    REP(j, k) {
      cin >> s[j];
    }
    a[i] = s;
  }
  vector<int> p(m);
  REP(i, m) {
    cin >> p[i];
  }

  int ans = 0;

  for (int bit = 0; bit < (1<<n); ++bit) {
    vector<int> bits;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) {
        bits.push_back(i+1);
      }
    }

    int allcnt = 0;
    REP(i, m) {
      int cnt = 0;
      REP(j, a[i].size()) {
        REP(k, bits.size()) {
          if(bits[k] == a[i][j]) {
            cnt++;
          }
        }
      }
      if(cnt%2 == p[i]) {
        allcnt++;
      }
    }

    if(allcnt == m) {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t=s;
  int ans=1e9;
  vector<int> c(26);
  vector<bool> e(26);
  for(int i=0;i<s.size();i++){
    e[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!e[i]){
      continue;
    }
    s=t;
    bool all=false;
    while(!all){
      all=true;
      for(int j=0;j<s.size();j++){
        if(s[j]!='a'+i){
          all=false;
        }
      }
      for(int j=0;j<s.size()-1;j++){
        if(s[j]=='a'+i||s[j+1]=='a'+i){
          s[j]='a'+i;
        }
      }
      s=s.substr(0,s.size()-1);
      c[i]++;
    }
    ans=min(ans,c[i]-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define Q 500

int main(){
  int n,q,i,j,count=0;
  int S[N],T[Q];

 
  scanf("%d",&n); 
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0 ; i<q ;i++){
    scanf("%d",&T[i]);
  }

  for(i=0 ; i<q ;i++){
    for(j=0 ; j<n ; j++){
      if(S[j]==T[i]){count++; break;}
    }
  }
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 640
N,K=list(map(int,input().split()))
l=[]
for i in range(N):
 a,b=list(map(int,input().split()))
 l.append((a,b))  
l.sort()
s = 0
for a,b in l:
    s += b
    if K <= s:
        print(a)
        break

Measured memory_bytes: 17004
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long double in,ans=0;
  string h;
  for(int i=0;i<n;++i){
    cin>>in>>h;
    if(h=="BTC"){in*=380000.0;}
    ans+=in;
  }
  cout<<setprecision(20)<<ans<<endl;
}

Measured memory_bytes: 256
#n = int(input())
#s = input()
a,b= map(int,input().split())
#da = list(map(int,input().split()))
#a = [int(input()) for i in range(n)]

ans = -1
for i in range(1,2000):
    if int(i*0.08) == a and int(i*0.1) == b:
        ans = i
        break
print(ans)


Measured memory_bytes: 2940
def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)

N=int(input())
A=[int(i) for i in input().split()]
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])
Z=[gcd(X[i],Y[i]) for i in range(N)]
print(max(Z))


Measured memory_bytes: 14400
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    C = []
    for _ in range(5):
        C.append(int(input()))

    print(4 + ceil(N, min(C)))


if __name__ == '__main__':
    main()


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

int main(){
  string s; cin >> s;
  int n = s.size();
  
  bool can = true;
  rep(i, (n+1)/4){
    if(s[i]!=s[(n-3)/2-i] || s[i]!=s[(n+1)/2+i] || s[i]!=s[n-1-i]) can = false;
  }
  
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define P pair<ll,ll>
#define fs first
#define sc second

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n] = {};
    rep(i,0,n) cin >> a[i];

    map<ll,ll> m;
    vector<ll> vec;
    ll memo = 1,roopcnt = 0;

    while(1){
        if(m.count(memo)) break;

        m[memo] = roopcnt++;
        vec.push_back(memo);
        memo = a[memo-1];
    }

    ll cnt = k-m[memo]+1;
    ll roop_size = vec.size() - m[memo];
    if(vec.size() > k) cout << vec[k] << endl;
    else if(cnt % roop_size == 0) cout << vec[vec.size()-1] << endl;
    else cout << vec[m[memo] + (cnt % roop_size) - 1] << endl;

    //cout << cnt << " " << roop_size << " " << cnt % roop_size << " " << m[memo] + (cnt % roop_size) - 1 << endl; 
    return 0;
}

Measured memory_bytes: 18684
/* Simplicity and Goodness */

#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;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 3e6+2;

int me(int x, ll n) 
{
   int res = 1;
   while(n) {
      if(n & 1) 
         res = (1LL * res * x) % mod;
      x = (1LL * x * x) % mod;
      n >>= 1;
   }
   return res;
}

int main()
{
   ll n;
   lscn(n);

   if(n <= 1) {
      prin(0);
      exit(0);
   }

   ll ans = me(10, n);

   ans = (ans - me(9, n) + mod) % mod;

   ans = (ans - me(9, n) + mod) % mod;

   ans = (ans + me(8, n)) % mod;

   lprin(ans);

   return 0;
}

Measured memory_bytes: 3824
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;


const int SZ = 5003;
int N;
ll A[SZ];
vector<int> adj[SZ];
vector<int> children[SZ];
int tsz[SZ];

void readInput() {
	//freopen("input.txt", "r", stdin);
	cin >> N;
	for (int i=1; i<=N; i++) cin >> A[i];
	for (int z=0; z<N-1; z++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs(int p, int u) {
	tsz[u] += 1;
	for (int v : adj[u]) if (v != p) {
		dfs(u, v);
		children[u].push_back(v);
		tsz[u] += tsz[v];
	}
}


ll D[SZ][SZ];
bool P[SZ][SZ];
void solve(int u) {
	D[u][0] = A[u];
	P[u][0] = A[u] > 0;
	if (children[u].empty()) return;
	for (int v : children[u]) solve(v);

	int sz = 1;
	for (int v : children[u]) {
		static ll DD[SZ];
		static bool PP[SZ];
		memset(DD, 1, sizeof(DD));
		memset(PP, 0, sizeof(PP));

		for (int a=0; a<sz; a++) for (int b=0; b<tsz[v]; b++) {
			DD[a+b] = min(DD[a+b], D[u][a]+D[v][b]);
			if (D[v][b] < 0) DD[a+b+1] = min(DD[a+b+1], D[u][a]);
			if (P[v][b]) DD[a+b+1] = min(DD[a+b+1], D[u][a]);
		}
		if (A[u]>0) for (int a=0; a<sz; a++) for (int b=0; b<tsz[v]; b++) {
			if (A[v]>0) PP[a+b] = PP[a+b] || (P[u][a] && P[v][b]);
			if (D[v][b] < 0) PP[a+b+1] = PP[a+b+1] || P[u][a];
			if (P[v][b]) PP[a+b+1] = PP[a+b+1] || P[u][a];
		}

		sz += tsz[v];
		for (int k=0; k<sz; k++) {
			D[u][k] = DD[k];
			P[u][k] = PP[k];
		}
	}

	/*
	printf("[debug]\n");
	for (int k=0; k<sz; k++) cout << D[u][k] << " ";
	cout << endl;
	for (int k=0; k<sz; k++) cout << P[u][k] << " ";
	cout << endl;
	cout << endl;
	*/
}



int main() {
	readInput();
	dfs(-123, 1);
	solve(1);

	int ans = 1e9;
	for (int k=0; k<N; k++) {
		if (D[1][k] < 0) ans = min(ans, k);
		if (P[1][k]) ans = min(ans, k);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 221056