akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	double N,K; cin >> N >> K;
	double ans = 0;
	for(double i = 1; i <= N; ++i){
		double sum = 1.0/N;
		double L = i;
		if(i>=K) {
			;
		}
		else{
			while(L<K){
				L*=2.;
				sum /= 2.;
			}
		}
		ans += sum;
	}
	printf("%.15f",ans);
  
    return 0;
}


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

int main() {
	string S;
	cin >> S;
	int flag = 0;
	if (S.at(0) != 'A') {
		flag = 1;
	}

	int cnt = 0;
	for (int i = 2; i < (int)S.size() - 1; i++) {
		if (S.at(i) == 'C') cnt++;
	}
	if (cnt != 1) {
		flag = 1;
	}

	for (int i = 1; i < (int)S.size(); i++) {
		if (S.at(i) == 'C') {
			continue;
		}

		int tmp = 0;
		if ('a' <= S.at(i) && S.at(i) <= 'z') {
			tmp++;
		}
		if (tmp != 1) {
			flag = 1;
		}
	}

	if (flag == 0) {
		cout << "AC" << endl;
	} else {
		cout << "WA" << endl;
	}
}

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

int main() {
	int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0) {
      c-=b;
      if(c<=0) {
        cout<<"Yes\n";
        return 0;
      }
      a-=d;
    }  
    cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7,maximum=-1;;

 int getmax(int n, int ar[][3])
{
  
     int i,j;
    int dp[n+1][3];
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    
     for(i=1;i<n+1;i++)
     {
         
         dp[i][0]=ar[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=ar[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]=ar[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
     }
    i=n;
    for(j=0;j<3;j++)
    {
        if(maximum<dp[i][j])
        maximum=dp[i][j];
    }

 
  
    return maximum;

    

}
int main()
{
     int n,k;
    
    
   
        cin>>n;
         int ar[n][3];
        for( int i=0;i<n;i++)
        for(int j=0;j<3;j++)
        cin>>ar[i][j];
        cout<<getmax(n,ar)<<"\n";
    
}

Measured memory_bytes: 5948
//Created Time:2019年12月22日 星期日 15时38分42秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 600005
#define mod 924844033
#define G 5

using namespace std;

struct edge{
	int to, nxt;
}e[N << 1];

int n, cnt;
int R[N], sz[N], fir[N], fac[N], ifac[N], a[N], b[N];

void init();
int quick_pow(int ,int);
void add(int ,int);
void dfs(int ,int);
void NTT(int *, int ,int);
int C(int ,int);

int main(){
	scanf("%d", &n); init();
	for(int i = 1; i < n; ++i){
		int u, v; scanf("%d%d", &u, &v);
		add(u, v); add(v, u);
	}
	dfs(1, 0); int len = 1, l = 0;
	for(int i = 0; i < n; ++i) a[i] = 1ll * a[i] * fac[i] % mod;
	for(int i = 0; i < n; ++i) b[i] = ifac[i];
	reverse(b, b + n);
	while(len < n * 2) len <<= 1, ++l;
	for(int i = 0; i < len; ++i) R[i] = (R[i >> 1] >> 1) | ((i & 1) << (l - 1));
	NTT(a, len, 1); NTT(b, len, 1);
	for(int i = 0; i < len; ++i) a[i] = 1ll * a[i] * b[i] % mod;
	NTT(a, len, -1); cout << n << endl;
	for(int i = 2; i < n; ++i){
		int ans = (1ll * (n - 1) * C(n, i) % mod + C(n, i)) % mod;
		(ans += mod - 1ll * a[i + n - 1] * ifac[i] % mod) %= mod;
		printf("%d\n", ans);
	}
	cout << n << endl;
	return 0;
}

int quick_pow(int x, int y){
	int sum = 1;
	for(; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) sum = 1ll * sum * x % mod;
	return sum;
}

void init(){
	fac[0] = 1;
	for(int i = 1; i <= n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	ifac[n] = quick_pow(fac[n], mod - 2);
	for(int i = n; i; --i)
		ifac[i - 1] = 1ll * ifac[i] * i % mod;
	return ;
}

void add(int u, int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt;
	return ;
}

void dfs(int u, int fa){
	sz[u] = 1;
	for(int i = fir[u]; i; i = e[i].nxt){
		int v = e[i].to;
		if(v == fa) continue;
		dfs(v, u); sz[u] += sz[v];
	}
	if(fa) ++a[sz[u]], ++a[n - sz[u]];
	return ;
}

void NTT(int *x, int len, int flag){
	for(int i = 0; i < len; ++i)
		if(i < R[i]) swap(x[i], x[R[i]]);
	for(int i = 1; i < len; i <<= 1){
		int wn = quick_pow(G, (mod - 1) / (i << 1));
		if(flag == -1) wn = quick_pow(wn, mod - 2);
		for(int j = 0; j < len; j += i << 1){
			int w = 1;
			for(int k = j; k < i + j; ++k, w = 1ll * w * wn % mod){
				int p = x[k], q = 1ll * w * x[i + k] % mod;
				x[k] = (p + q) % mod; x[i + k] = (p + mod - q) % mod;
			}
		}
	}
	if(flag == 1) return ;
	int inv = quick_pow(len, mod - 2);
	for(int i = 0; i < len; ++i) x[i] = 1ll * x[i] * inv % mod;
	return ;
}

int C(int x, int y){
	return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}


Measured memory_bytes: 30592
#include <stdio.h>
void main(void)
{      
     int K,N,max,i;
 scanf("%d %d",&K,&N);
  
  int A[N+1];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  A[N]=A[0]+K;



     max=A[1]-A[0];
  for(i=0;i<N-1;i++){
   if(max<(A[i+2]-A[i+1]))
     max=A[i+2]-A[i+1];
  }


  
  printf("%d",K-max);
}


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

ll hoge(ll h, ll a){
    if(h <= 0)return 0;
    ll tmp = h / a;
    if(h % a)tmp++;
    return tmp;
}

int main(){
    
    ll N, H;
    cin >> N >> H;
    ll A = 0;
    vector<ll>B(N);
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a >> B[i];
        A = max(A, a);
    }
    ll ans = hoge(H, A);
    sort(B.begin(), B.end(), greater<ll>());
    for(ll i = 0, sum = 0; i < N; i++){
        sum += B[i];
        ans = min(ans, i + 1 + hoge(H - sum, A));
    }
    cout << ans << endl;
    
    return 0;
}


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

int main(){
	int N; cin>>N;
	vector<string> s(1,"a");
	while(--N){
		vector<string>t; swap(s,t);
		for(auto pre:t){
			char mx='a'; for(auto c:pre) mx = max(mx, c); mx++;
			for(char c='a'; c<=mx; ++c) s.push_back(pre + string(1,c));
		}
	}
	for(auto x:s) cout<< x <<endl;
}

Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    cout << max(0, (H2-H1)*60+(M2-M1)-K) << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 3640
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N==1:
    print(0)
else:
    s=0
    d=factorization(N)
    for p in range(len(d)):
        i=1
        while(d[p][1]>0):
            if d[p][1]-i<0:
                d[p][1]=-1
            else:
                d[p][1]=d[p][1]-i
                s=s+1
                i=i+1
    print(s)








Measured memory_bytes: 9504
#include <iostream>
    #include<bits/stdc++.h>
    #include<vector>
    #include<string>
    #define ll long long
    #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define vi vector<ll>
    #define el printf("\n")
    #define N 100001
    #define s second
    #define pb(x) push_back(x)
    #define f first
    using namespace std;

ll pw(ll a, ll n)
{
    ll ans=1;
    while(n>0)
    {
        if (n%2!=0)
        {
            ans=ans*a;
        }
        a=a*a;
        n=n/2;
    }
    return ans;
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.first < b.first);
}

    int main()
    {
        IOS;
        string ch1,ch2;

        cin >> ch1 >> ch2;

        vector<vector<ll>> dp(ch1.size()+1,vector<ll>(ch2.size()+1,0));
        string ch="";
        bool B=true;
        for(int i=0;i<ch1.size();i++)
        {
            for(int j=0;j<ch2.size();j++)
            {
                if(ch1[i]==ch2[j])
                {dp[i+1][j+1]=dp[i][j]+1;
                }

                else
                    dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
            }
        }
        ll i=ch1.size();
        ll j=ch2.size();
        while(i>0&&j>0){
		if(dp[i][j] == dp[i -1][j]){
			i--;
		}
		else if(dp[i][j] ==dp[i][j-1]){
			j--;
		}
		else{
			ch+=ch1[i-1];
			i--;
			j--;
		}
	}
        reverse(ch.begin(),ch.end());
        cout << ch;
       // cout << dp[ch1.size()][ch2.size()];

        return 0;
    }


Measured memory_bytes: 70784
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    
    char s[999];
    
    scanf("%s", s);
    
    for(int i=0; i<100; i++){
        
        if(i%2==0){
            
            if(s[i]=='L'){
                
                printf("No");
                return 0;
                
            }
            
        } else {
            
            if(s[i]=='R'){
                
                printf("No");
                return 0;
                
            }
            
        }
        
    }
    
    /*
    
    if(s[0]=='S'){
        
        printf("Cloudy");
        return 0;
        
    }
    
    if(s[0]=='C'){
        
        printf("Rainy");
        return 0;
        
    }
    
    if(s[0]=='R'){
        
        printf("Sunny");
        return 0;
        
    }
    
    */
    
    printf("Yes");
    
    return 0;
    
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read(),ml=1,mr=n;
    for(int i=1;i<=m;i++)
    {
    	int l=read(),r=read();
    	ml=max(ml,l),mr=min(mr,r);
    }pr2(max(0,mr-ml+1));
   	return 0;
}

Measured memory_bytes: 128
S = list(input())
a = []
for i in range(len(S)):
  if(S[i] == "0" ):
    a.append("0")
  elif(S[i] == "1"):
    a.append("1")
  else:
    if(len(a) != 0):
      del a[-1]

kotae = ""

for i in range(len(a)):
  kotae += a[i]

print(kotae)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
long long int a;
string b; 
cin >> a ; 
cin >> b ; 
  long long int z=b.size();
if(a<z)
{
  
for(long long int i=0; i<a; i++)
  {
  cout << b[i];
} 
  cout << "..." ;
}
  else
  
  {
  
    cout << b ;
  }

}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

class union_find{
	private:
	vector<int> parent,rank;
	int size;
	public:
    int cnt;

    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		cnt=n;
		parent.resize(size);
		rank.resize(size);
		for(int i=0; i<size; ++i){
			parent[i]=i;
			rank[i]=0;
		}
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
		} else {
			parent[y]=x;
			if(rank[x]==rank[y]) ++rank[x];
		}
		--cnt;
	}

	bool is_same(int x,int y){
		return find(x)==find(y);
	}
};

void solve(){
    int n,w,h;
    cin >> n >> w >> h;

    union_find uf(n);
    vector<array<bool,4>> flags;
    map<int,vector<pii>> mp1,mp2;
    rep(i,0,n){
        int x,y;
        cin >> x >> y;
        --x;
        --y;
        mp1[x].emplace_back(make_pair(y,i));
        mp2[y].emplace_back(make_pair(x,i));
        flags.emplace_back(array<bool,4>{x==0,y==0,x==w-1,y==h-1});
    }

    auto update=[](array<bool,4> &a,array<bool,4> &b){
        rep(i,0,4) a[i]|=b[i];
    };
    int cnt_move=0;
    for(auto it=mp1.begin(); it!=mp1.end(); ++it) for(const auto &p:it->second){
        if(uf.is_same(it->second.front().second,p.second)) continue;
        const int x=uf.find(it->second.front().second),y=uf.find(p.second);
        uf.unite(x,y);
        update(flags[uf.find(p.second)],flags[x]);
        update(flags[uf.find(p.second)],flags[y]);
        ++cnt_move;
    }
    for(auto it=mp2.begin(); it!=mp2.end(); ++it) for(const auto &p:it->second){
        if(uf.is_same(it->second.front().second,p.second)) continue;
        const int x=uf.find(it->second.front().second),y=uf.find(p.second);
        uf.unite(x,y);
        update(flags[uf.find(p.second)],flags[x]);
        update(flags[uf.find(p.second)],flags[y]);
        ++cnt_move;
    }

    if(uf.cnt==1){
        cout << cnt_move << endl;
        return;
    }

    int ans=inf;
    set<int> reps;
    rep(i,0,n) reps.insert(uf.find(i));
    rep(i,0,4){
        int cnt=0;
        for(int idx:reps) if(!flags[idx][i]) ++cnt;
        ans=min(ans,cnt_move+cnt);
    }
    ans+=uf.cnt-1;
    cout << ans << endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 11820
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

vector<int>getketa(int n, int c){
  vector<int>ret;
  for(int i=0; i<c; i++){
    ret.push_back(n%2);
    n/=2;
  }
  return ret;
}

int cnt1(vector<int> v){
  int ret=0;
  for(int i: v){
    if(i==1)ret++;
  }
  return ret;
}

int main(){
  int n;
  cin >> n;
  vector<vector<pair<int, int>>>a(n);
  for(int i=0; i<n; i++){
    a[i].push_back(make_pair(i, 1));
    int ai, x, y;
    cin >> ai;
    for(int j=0; j<ai; j++){
      cin >> x >> y;
      a[i].push_back(make_pair(x-1, y));
    }
  }
  
  int ret=0;
  for(int i=0; i<(1<<n); i++){
    bool flag=true;
    vector<int>sh=getketa(i, n);
    vector<int>is(n, -1);
    for(int j=0; j<n; j++){
      if(sh[j]){
        for(pair<int, int>p: a[j]){
          if(is[p.first]<0)is[p.first]=p.second;
          else if(is[p.first]!=p.second){
            flag=false;
            break;
          }
        }
      }
      if(!flag)break;
    }
    for(int j=0; j<n; j++){
      if(is[j]>0 && is[j]!=sh[j]){
        flag=false;
        break;
      }
    }
    if(flag){
      ret = max(ret, cnt1(sh));
    }
  }
  cout << ret;
  return 0;
}
      
            
  
  

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



void outPut(int value){

	stack<int> S;

	for(int loop = 0; loop < 32; loop++){
		if(value & (1 << loop)){

			S.push(1);

		}else{

			S.push(0);
		}
	}

	while(!S.empty()){

		printf("%d",S.top());
		S.pop();
	}

	printf("\n");
}

int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	outPut(A&B);
	outPut(A|B);
	outPut(A^B);

	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string s;
    cin >> s;
    int sum = 0;
    rep(i, s.size() - 1){
        if(s[i] != s[i + 1])
            sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int h,n;
int dp[1001];
int v[4000],cost[4000];
int ans = 1e-9;
/*
int go(int i,int sum){

        if(dp[i][sum]!=-1) return dp[i][sum];

       dp[i][sum] =min(val[i]+go(i+1,W-a[i]),go(i+1,W));
       return dp[i][sum];
}
*/
void go(int i,int x, int y ){

     ans = max(ans,x-y);
    if(i>n){
      return ;
    }
    go(i+1,v[i]+x,cost[i]+y);
    go(i+1,x,y);
    return;
}
 int main()
{
   // fast;

    int n;
    string s;
     cin >> s;
     int need_zero = 0,need_one = 0;
     for(int i = 0; i<s.size(); i+=2){
        if(s[i]=='1') continue;
        need_one++;
     }
     for(int i = 1; i<s.size(); i+=2){
        if(s[i]=='0') continue;
        need_zero++;
     }
     int res = need_one+need_zero;
     need_zero = 0;need_one = 0;
     for(int i = 0; i<s.size(); i+=2){
        if(s[i]=='0') continue;
        need_zero++;
     }
 for(int i = 1; i<s.size(); i+=2){
        if(s[i]=='1') continue;
        need_one++;
     }

     cout << min(res,need_zero+need_one);



   return 0;
}


Measured memory_bytes: 512
// ~maqsat~
/*
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 4e6 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

ll f[N];

inline ll binpow(ll a, ll n) {
	ll res = 1;
	while(n) {
		if(n & 1ll) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1ll;
	}
	return res;
}

signed main() {
    fre("");
    ACCELERATE;

    f[0] = f[1] = 1;
    for(int i = 2; i <= N-100; i++) f[i] = f[i-1] * i % MOD;

    ll x, y;
    cin >> x >> y;

    if((x + y)% 3 != 0) {
    	cout << 0;
    	return 0;
    }

    ll n = (x + y)/ 3;
    ll k = (x - y + n) / 2;

    if(n < 0 || k < 0 || (n - k) < 0) {
    	cout << 0;
    	return 0;
    }

	cout << f[n] * binpow(f[k], MOD-2) % MOD * binpow(f[n-k], MOD-2) % MOD;

    return 0;
}
/*
 
*/


Measured memory_bytes: 31488
#include<stdio.h>
int main(void)
{
	while(1){
		int a[100000]={0},b[100000]={0},i,j,n=0,x,y;
		scanf("%d %d",&x,&y);
		if(x==0 && y==0){
			goto end;
		}
		for(i=1;i<=x;i++){
			scanf("%d",&a[i]);
		}
		for(i=1;i<=x-y+1;i++){
			for(j=1;j<=y;j++){
				b[i]=b[i]+a[j+i-2];
			}
			if(b[i]>n){
				n=b[i];
			}
		}
		printf("%d\n",n);
		
	}
	end:
	return 0;
}


Measured memory_bytes: 2516
# -*- coding: utf-8 -*-

a, b, c = map(int, input().split())

max = max(a, b) + 1
if max > 101:
    max = 101

list = []

for ta in range(max):
    if ta == 0:
        continue
    elif a % ta == 0 and b % ta == 0:
        list.append(ta)

print(list[-c])

Measured memory_bytes: 3060
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
# row = [int(input().rstrip()) for _ in range(n)]

def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c, d = [int(x) for x in input().rstrip()]

    for o1 in [True, False]:
        for o2 in [True, False]:
            for o3 in [True, False]:
                ans = a
                ans += b if o1 else -b
                ans += c if o2 else -c
                ans += d if o3 else -d

                if ans == 7:
                    s = str(a)
                    s += "+" if o1 else "-"
                    s += str(b)
                    s += "+" if o2 else "-"
                    s += str(c)
                    s += "+" if o3 else "-"
                    s += str(d)
                    s += "=7"

                    print(s)
                    return


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61892
using System;

class Program
{
    static void Main()
    {
        var str = Console.ReadLine().Split(' ');
        var x= new int[] { int.Parse(str[0]), int.Parse(str[1]), int.Parse(str[2]) };
        for (var i=0; i<x.Length; i++)
        {
            var ansIndex = i;
            for (var j = x.Length-1; j > i; j--) if (x[ansIndex] > x[j] ) ansIndex =j;
            Swap(ref x[i], ref x[ansIndex]);
        }
        Console.WriteLine("{0} {1} {2}", x[0], x[1], x[2]);
    }
   

    static void Swap(ref int x, ref int y)
    {
        var temp = x;
        x = y;
        y = temp;
    }
}


Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int cnt[2019] = {0};
    cnt[0] = 1;
    int sum = 0;
    for(int i = n - 1; i >= 0; i--) {
        sum = (sum + (s[i] - '0') * beki(10, n - i - 1, 2019)) % 2019;
        cnt[sum]++;
    }
    int ans = 0;
    rep(i, 2019) {
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 3756
#include<iostream>
#include<iomanip>
#include <bits/stdc++.h>

int main(void)
{
    double a;
    std::cin >> a;
    std::cout << std::fixed << std::setprecision(6) << M_PI*a*a << " " << 2*M_PI*a << std::endl;
    return 0;
}


Measured memory_bytes: 3252
def main():
    n, m = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(m)]
    lt = [list(x) for x in zip(*l)]
    if min(lt[1]) - max(lt[0]) >= 0:
        print(min(lt[1]) - max(lt[0]) + 1)
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 36868
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;

long long int euclid( int a, int b ){
 int temp;
 if( a < b ) { temp = a; a = b; b = temp; }
 if( b < 1 ) return -1;

 if( a % b == 0 ) return b;
  return euclid( b, a % b );
}
int main(void){
 int n,m;
 vector<int> A;
 long long int ans=10000000000;
 cin>>n;

 for(int i=0; i<n; i++){
  cin>>m;
  A.push_back(m);
 }

 for(int i=1; i<n; i++){
  ans=min(ans,euclid(A[0],A[i]));
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 892
N = int(input())
A = list(map(int,input().split()))
B = []

if N == 1:
    print(0)
    exit(0)

for k in range(N):
    B.append(A[k]-(k+1))

C = sorted(B)
ans = 0
if N%2==1:
    b = C[N//2]
    for k in B:
        ans += abs(k-b)
else:
    b1 = (C[N//2]+C[-1+N//2])//2
    b2 = 1+(C[N//2]+C[-1+N//2])//2
    ans1 = 0
    ans2 = 0
    for k in B:
        ans1 += abs(k-b1)
        ans2 += abs(k-b2)
    ans = min(ans1,ans2)
print(ans)

Measured memory_bytes: 26016
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],o,p;
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    while(1){
        n-=1;
        c=n%26+97;
        s=c+s;
        n/=26;
        if(n==0){
            break;
        }
    }
    cout<<s;
}

Measured memory_bytes: 10488
<?php
fscanf(STDIN, "%d %d", $n, $m);
$format = join(' ', array_fill(0, $m, '%d'));

$matrix = array();
for ($i = 0; $i < $n; $i++) {
    $matrix[] = fscanf(STDIN, $format);
}

$vector = array();
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, '%d', $d);
    $vector[] = $d;
}

foreach ($matrix as $rows) {
    echo array_sum(array_map(function ($a, $b) { return $a * $b; }, $rows, $vector))."\n";
}

Measured memory_bytes: 8132
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j,flag=0;
    cin>>n;
    for(i=0;i<10;i++){
        for(j=i;j<10;j++)
        {if(i*j==n)
            {
            flag++;
            break;
            }
        }
    }
    if(flag==0)
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }
    
    

    
}

Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<long long> cumsum(N+1);
    for (int i = 1; i < N+1; i++) {
        int a; cin >> a;
        cumsum[i] = cumsum[i-1] + a;
    }

    long long ans = 1LL<<60;
    for (int i = 1; i < N; i++) {
        long long tmp = abs(cumsum[i] - (cumsum[N] - cumsum[i]));
        ans = min(ans, tmp);
    }

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

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

    solve();

    return 0;
}

Measured memory_bytes: 4748
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int R,G,B,N;

int main(){
    cin>>R>>G>>B>>N;

    int ans=0;
    rep(r,3001){
        int x=R*r;
        if(x>N) break;
        rep(g,3001){
            int y=G*g;
            if(x+y>N) break;
            if((N-x-y)%B==0) ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include "cstdio"
using namespace std;
int main()
{
	char str[4]={'\0'};
	int i,count=0;
	scanf("%s",str);
	for(i=0;i<3;i++)
	{
		if(str[i]=='1')
		{
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
} 

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

using namespace std;
typedef long long ll;
ll x;
ll n;
string s;
int main()
{
    cin>>n>>s;
    ll ans=0;
    for(int i=0;i<1000;i++)
    {
        char a=i/100+'0',b=(i/10)%10+'0',c=(i)%10+'0';
        char t[3]={a,b,c};
        int index=-1,j=-1;
        for(index=0;index<3;index++)
        {
            j=j+1;
            while(s[j]!=t[index]&&j<n) j++;
            if(j==n) break;
        }
        if(index==3) ans++;
    }
    cout<<ans<<"\n";

}



Measured memory_bytes: 256
A, B = map(int,input().split())

#偶数×偶数＝偶数、偶数×奇数＝偶数、奇数×奇数＝奇数。
#A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い

if A*B %2 == 0:
    print("No")

#if A*B %2 == 1:

else:
    print("Yes")


Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,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--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

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

    ll A;
    ll ans = 0;

    cin >> A;
    ll high = A;

    for (ll i=1; i<N; i++) {
        cin >> A;
        if (high > A) {
            ans += (high - A);
        }
        else {
            high = A;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	ll abc[3];
	REP(i, 3) cin >> abc[i];
	ll res = abc[0] * abc[1];
	REP(i, 3) {
		ll a = abc[i], b = abc[(i + 1) % 3], c = abc[(i + 2) % 3];
		res = min(res, a % 2 * b * c);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 0;
  rep(i, n) {
    ans += min(x[i], k - x[i]) * 2;
  }
  cout << ans << endl;


  
  return 0;
}

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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	int ch = 0;

	while(a>0 && c>0){
		if(ch==0)
		c -= b;

		else
		a -= d;

		ch++;
		ch = ch %2;
	}
	
	if(c <= 0)
	cout<<"Yes";
	else
	cout<<"No";
	

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

const int non = 100000000;
int N,M,R,r[10],d[10][1<<10],f[202][202];

int main()
{
	scanf ("%d %d %d",&N,&M,&R);
	for (int i=0;i<R;i++) scanf ("%d",&r[i]);
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) f[i][j] = non, f[i][i] = 0;
	for (int i=0;i<M;i++){
		int x,y,c; scanf ("%d %d %d",&x,&y,&c);
		if (f[x][y] > c) f[x][y] = f[y][x] = c;
	}
	for (int k=1;k<=N;k++) for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) if (f[i][j] > f[i][k] + f[k][j]) f[i][j] = f[i][k] + f[k][j];

	for (int i=0;i<R;i++) for (int j=0;j<(1<<R);j++) d[i][j] = non;
	for (int i=0;i<R;i++) d[i][1<<i] = 0;
	for (int b=1;b<(1<<R);b++){
		for (int i=0;i<R;i++) if (b & (1 << i)){
			for (int j=0;j<R;j++) if (~b & (1 << j)){
				int c = d[i][b] + f[r[i]][r[j]];
				if (d[j][b+(1<<j)] > c)
					d[j][b+(1<<j)] = c;
			}
		}
	}

	int ans = non;
	for (int i=0;i<R;i++) if (ans > d[i][(1<<R)-1]) ans = d[i][(1<<R)-1];
	printf ("%d\n",ans);

	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str = br.readLine();
            char ch = str.charAt(0);
            if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
                System.out.println("vowel");
            } else {
                System.out.println("consonant");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define PII pair<int,int>
#define MP make_pair

int ctoi(char c)
{
	if ('0' <= c&&c <= '9')return (c - '0');
	else return -1;
}

char MAP[1000][1000];
char tMAP[1000][1000];
PII D[9];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int H, W, N;
	PII S;
	cin >> H >> W >> N;
	REP(i, H)REP(j, W)
	{
		char temp;
		cin >> temp;
		if (temp == 'S')
		{
			MAP[i][j] = '.';
			S = MP(j, i);
		}
		else if (temp == '.' || temp == 'X')MAP[i][j] = temp;
		else
		{
			int t = ctoi(temp);
			MAP[i][j] = '.';
			D[t - 1] = MP(j, i);
		}
	}
	int sum = 0;
	int index = 0;
	while (1)
	{
		REP(i, H)REP(j, W)tMAP[i][j] = MAP[i][j];
		if (S == D[N - 1])break;
		int timer = 0;
		queue <PII> q;
		queue <int> t;
		q.push(S);
		t.push(timer);
		while (1)
		{
			if (t.front() > timer)timer++;
			if (q.front() == D[index])
			{
				sum += timer;
				S = D[index];
				index++;
				break;
			}
			for (int i = 0; i < 4; i++)
			{
				int tx = q.front().first + dx[i];
				int ty = q.front().second + dy[i];
				if (0 <= tx&&tx <= W - 1 && 0 <= ty&&ty <= H - 1)
				{
					if (tMAP[ty][tx] == '.')
					{
						tMAP[ty][tx] = 'X';
						q.push(MP(tx, ty));
						t.push(timer + 1);
					}
				}
			}
			q.pop();
			t.pop();
		}
	}
	cout << sum << endl;
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int H,W,T;
string s[10];

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  cout << ((N-1)+(K-2))/(K-1) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

string s;
ll k;

int main(){
  cin>>s>>k;
  int n=s.size();
  int cnt=0;
  while(cnt<n&&s[cnt]=='1')cnt++;
  if(k-1<cnt)cout<<1<<endl;
  else cout<<s[cnt]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int n, c4 = 0, c2 = 0, c1 = 0;
  rep(i,0,N-1) {
    cin >> n;
    if (n % 4 == 0) c4++;
    else if (n % 2 == 0) c2++;
    else c1++;
  }

  bool ok = false;
  if (c1 == 0) ok = true;
  else {
    if (0 < c2) c4--;
    if (c1 - 1 <= c4) ok = true;
  }

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  float a[105];
  rep(i, n)cin >> a[i];

  float ans = 0;
  rep(i, n) ans += 1 / a[i];

  cout << 1 / ans << endl;
}


/*





















*/


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

int main(){
	int n, l;
	scanf("%d %d", &n, &l);
	std::vector<std::string> a(0);
	for(int i=0; i<n; i++){
		std::string s;
		std::cin >> s;
		a.push_back(s);
	}
	std::sort(a.begin(), a.end());
	for(int i=0; i<n; i++) std::cout << a[i];
	std::cout << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	ini(n);
	ini(n1);
	int tmp = n1/n;
	int rick = 0;
	for(int i = 1;i*i<=n1 and i<=tmp;i++){
		if(n1%i == 0){
			if((n1-(n-1)*i)%i == 0)rick = max(rick,i);
			if(n1/i<=tmp){
				int x = n1/i;
				if((n1-(n-1)*x)%x == 0)rick = max(rick,x);
			}
		}
	}
	out(rick);














	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	long long x,a,b,n;
	string s;
	cin>>x>>a>>b>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s[0]=='n')x=max(0ll,x+a);
		else if(s[0]=='t')x=max(0ll,x+b);
		else x=0;
	}
	cout<<x<<endl;
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int N;
map<string, int> memo;
int main() {
    cin >> N;
    while (N--)
    {
        string tmp;
        cin >> tmp;
        memo[tmp]++;
    }
    printf("%s x %d\n", "AC", memo["AC"]);
    printf("%s x %d\n", "WA", memo["WA"]);
    printf("%s x %d\n", "TLE", memo["TLE"]);
    printf("%s x %d\n", "RE", memo["RE"]);
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int students [] [] = new int [n] [2];
		int points [] [] = new int [m] [2];
		for (int i = 0 ; i < n ; i++) {
			students [i] [0] = scanner.nextInt();
			students [i] [1] = scanner.nextInt();
		}
		for (int j = 0 ; j < m ; j++) {
			points [j] [0] = scanner.nextInt();
			points [j] [1] = scanner.nextInt();
		}
		
		int [] result = new int [n];
		for (int i = 0 ; i < n ; i++) {
			int minDist = Integer.MAX_VALUE;
			int minIndex = 0;
			for (int j = 0 ; j < m ; j++) {
				int dist = Math.abs(students [i] [0] - points [j] [0]) + Math.abs(students [i] [1] - points [j] [1]);
				if (dist < minDist) {
					minDist = dist;
					minIndex = j;
				}
			}
			result [i]= minIndex + 1;
		}
		for (int i = 0 ; i < n ; i++) {
			System.out.println(result [i]);
		}
	}
} 

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	long long int res = 0;
	vector<int> pre_v1(n, n), pre_v2(n, n);
	vector<int> post_v1(n, -1), post_v2(n, -1);
	vector<int> s1;
	set<pair<int, int>> s2;
	for (int i = 0; i < n; i++) {
		while (s2.size() > 0 && s2.begin()->first < v[i]) {
			pre_v2[s2.begin()->second] = i;
			s2.erase(*s2.begin());
		}
		
		while (s1.size() > 0 && v[s1.back()] < v[i]) {
			pre_v1[s1.back()] = i;
			s2.insert(make_pair(v[s1.back()], s1.back()));
			s1.pop_back();
		}
		s1.push_back(i);
	}
	s1.clear();
	s2.clear();
	for (int i = n - 1; i >= 0; i--) {
		while (s2.size() > 0 && s2.begin()->first < v[i]) {
			post_v2[s2.begin()->second] = i;
			s2.erase(*s2.begin());
		}
		
		while (s1.size() > 0 && v[s1.back()] < v[i]) {
			post_v1[s1.back()] = i;
			s2.insert(make_pair(v[s1.back()], s1.back()));
			s1.pop_back();
		}
		s1.push_back(i);
	}
	for (int i = 0; i < n; i++) {
		// cout << pre_v1[i] << " " << pre_v2[i] << " " << post_v1[i] << " " << post_v2[i] << endl;
		long long int l = (long long int)v[i] * (long long int)(pre_v2[i] - pre_v1[i]) * (i - post_v1[i]);
		long long int r = (long long int)v[i] * (long long int)(pre_v1[i] - i) * (post_v1[i] - post_v2[i]);
		res += l + r;
	}
	cout << res << endl;
}


Measured memory_bytes: 5824
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define um unordered_map
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define che(x) cout << #x << " having " << x << endl 
using namespace std;
typedef long double ld; typedef long long ll;
typedef vector<int> vi; typedef vector<pair<int, int>> vpi; typedef vector<vi> vvi;
typedef vector<ll> vll; typedef vector<pair<ll, ll>> vpll; typedef vector<vll> vvll;
template<class T>bool uin(T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T>bool uax(T &a, T b) {return a < b ? (a = b, true) : false; }
const ll MOD = 1e9+7, INF = 1e18;
/********************************************************************************/
 

 
int32_t main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout.precision(10); cout << fixed;
	
	int n;
	cin>>n;
	int dp[n], h[n];
	forn(i,n) cin >> h[i];
	memset(dp,0,sizeof(dp));
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	for(int i = 2; i < n; i++) {
		
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;
 
signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> t(n);
    rep(i, 0, n) cin >> t[i];
    sort(all(t));
    int ans = 0;
    rep(i, 0, n){
        if(t[i] < a || b <= t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(raw_input())

Mem = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    C = map(int, raw_input().split())
    Mem[C[0]-1][C[1]-1][C[2]-1] += C[3]

for i in range(4):
    for j in range(3):
        output = ""
        for k in range(10):
            output += ' ' + str(Mem[i][j][k])
        print output
    if i != 3: 
        print '#'*20

Measured memory_bytes: 6396
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int x[5];
    int n = 0;
    for(int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0){
            n = i+1;
        }
    }

    cout << n << endl;

}

Measured memory_bytes: 3636