akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

const int N=1e5+5;
int main()
{
    int n;
    cin>>n;
    vector<int> A(N);

    for(int x=1;x<=105;x++)
    {
        for(int y=1;y<=105;y++)
        {
            for(int z=1;z<=105;z++)
            {
                if(10000>=x*x+y*y+z*z+z*x+z*y+x*y) A[x*x+y*y+z*z+z*x+z*y+x*y]++;
            }
        }
    }

    for(int i=1;i<=n;i++) cout<<A[i]<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> D;
void input(){
    fast_io();
    cin >> N;
    D = fetch_vec<int>(N);
}

int solve(){
    map<int,int> cnt;
    for(auto d:D) cnt[d]++;
    int ans = 0;
    vector<int> time,timeD;;
    for(auto p:cnt){
        if(p.second==1) {
            if(p.first==0){
                cout << 0 << endl;
                return 0;
            }
            time.push_back(p.first);
        }
        else if(p.second==2){
            if(p.first==0){
                cout << 0 << endl;
                return 0;
            }
            timeD.push_back(p.first);
            timeD.push_back(24-p.first);
        }
        else if(p.second>=3){
            cout << 0 << endl;
            return 0;
        }        
    }
    int T = time.size();
    for (int bit = 0; bit < (1<<T); bit++)
    {
        vector<int> time_mod;
        for (int i = 0; i < T; i++)
        {
            if((bit>>i)&1) time_mod.push_back(24-time[i]);
            else time_mod.push_back(time[i]);
        }
        int tmp_ans = 24;
        for(auto timed:timeD) time_mod.push_back(timed);
        for (int i = 0; i < (int)time_mod.size(); i++)
        {
            for (int j = i+1; j < (int)time_mod.size(); j++)
            {
                int d = abs(time_mod[i]-time_mod[j]);
                tmp_ans = min(tmp_ans,min(d,24-d));
            }
            
        }
        for(auto d:D) tmp_ans=min(tmp_ans,d);
        DBG(tmp_ans)
        ans = max(ans,tmp_ans);
    }
    
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3624
import string

n = int(input())
s = input()

count = 0
for i in range(n - 1):
  count1 = 0
  for j in string.ascii_lowercase:
    x = s[:i+1]
    y = s[i+1:]
    if j in x and j in y:
      count1 += 1
  if count1 > count:
    count = count1
print(count)


Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000; 

 int main() {
 int N;
 cin >> N;
 vector<int> X(N);
 rep(i, N) cin >> X[i];
 int ans = inf;
 for(int i = 1; i <= 100; i++) { 
 int cost = 0;
 rep(j, N) cost += (X[j] - i) * (X[j] - i);
 ans = min(ans, cost);
 }
 printf("%d", ans);
 return 0;
 }

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

using namespace std;
#define pb push_back
#define db(x) cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 3123

int n;
ll vals[MAXN];
pll dp[MAXN][MAXN][2];
int vis[MAXN][MAXN][2];

pll solve(int l, int r, int t)
{
    if (l > r)
        return {0, 0};

    if (vis[l][r][t])
        return dp[l][r][t];
    vis[l][r][t] = 1;
    
    if (t)
    {
        pll rec1 = solve(l + 1, r, !t);
        rec1.se += vals[l];
        pll rec2 = solve(l, r - 1, !t);
        rec2.se += vals[r];

        if (rec1.fi - rec1.se < rec2.fi - rec2.se)
            return dp[l][r][t] = rec1;
        else
            return dp[l][r][t] = rec2;
    }
    else
    {
        pll rec1 = solve(l + 1, r, !t);
        rec1.fi += vals[l];
        pll rec2 = solve(l, r - 1, !t);
        rec2.fi += vals[r];

        if (rec1.fi - rec1.se > rec2.fi - rec2.se)
            return dp[l][r][t] = rec1;
        else
            return dp[l][r][t] = rec2;
    }
    
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &vals[i]);
    }
    
    printf("%lld\n", solve(0, n - 1, 0).fi - solve(0, n - 1, 0).se);
}

Measured memory_bytes: 369152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#include <fstream>
#define mp make_pair
#define Debug(...) fprintf(stdout, __VA_ARGS__)

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 4e2 + 7;

inline void proc_status() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int n, m;
int ans = 0;
int fd[MAXN][MAXN];

inline void init() {
	n = read<int>(); m = read<int>();
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) if(i ^ j) {
			fd[i][j] = fd[j][i] = 1;
		}
	}
}

inline void solve() {
	for(int t = 1; t <= m; ++t) {
		int x = read<int>();
		int y = read<int>();
		if(fd[x][y]) {
			fd[x][y] = fd[y][x] = 0;
			for(int i = 1; i <= n; ++i)
				if(!fd[x][i]) fd[y][i] = fd[i][y] = 0;
			for(int i = 1; i <= n; ++i)
				if(!fd[y][i]) fd[x][i] = fd[i][x] = 0;
		}
		else {
			for(int i = 1; i <= n; ++i) fd[i][x] = fd[x][i] = fd[y][i] = fd[i][y] = 0;
		}
	}
	for(int i = 1; i <= n; ++i) 
		for(int j = 1; j < i; ++j) 
			ans += fd[i][j];
	printf("%d\n", ans);
}

int main() {

	init();
	solve();

	return 0;
}



Measured memory_bytes: 1024
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        # B(N-1) | P(N-1)B の真ん中のパティの前までの範囲がわかればいい場合
        # Xから先頭のバンの数を引いて、N-1の先頭からX-1までの数を数えるために再帰で呼び出す
        return f(N-1,X-1)
    else:
        # 真ん中のパティ以上の枚数を数える必要がある場合
        # 一つ前のレベルのパティの数 + 真ん中のパティ + f(レベル-1, この関数呼び出しで知りたいトータルの枚数-2(先頭のバンと真ん中のパティ)-一つ前のレベルのハンバーガーのトータルの枚数)
        # X-2-a[N-1] → X - (B(N-1)P)|ここから後ろの先頭からK枚を数えるために再帰で呼び出す
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N,X))


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main(){
    fastio;
    //clock_t tm = clock();
    ll k;
    cin>>k;
    ll curr=0;
    f(i,1,k+1){
        curr=curr*10+7;
        curr%=k;
        if(curr==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int a,b;
        scanf("%d %d",&a,&b);
        printf("%d %d %.8lf\n",a/b,a%b,a*1.0/b);
        return 0;
}

Measured memory_bytes: 1208
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N, M; cin >> N >> M;
	vector<long> A(M), B(M);
	vector<long> C(M, 0);//bit整数化しておく

	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		for (int j = 0; j < B[i]; j++) {
			long c; cin >> c;
			C[i] += (1 << (c - 1));
		}
	}

	//bit_jにするための金額の最小値
	vector<long> dp((1 << N), INT_MAX); 

	//i = 0のとき
	//for (int j = 0; j < (1 << N); j++) {
	//	if ((j & C[0]) != j) continue;
	//	long bsub = (j & C[0]); // Cの部分集合の列挙
	//	dp[bsub] = A[0];
	//}
	dp[0] = 0;

	for (int i = 0; i < M; i++) {
		for (int k = 0; k < (1 << N); k++) {
			dp[k | C[i]] = min(dp[k | C[i]], dp[k] + A[i]);
		}
	}
	if (dp[(1 << N) - 1] == INT_MAX) { cout << -1 << endl; return 0; }
	cout << dp[(1 << N) - 1] << endl;
}

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

/* 
The read function reads a string according to each one. 
*/
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")
}

//main function
fn main() {
    let mut x: i32 = read();
    let lp = x%100;
    x -= lp;
    x /=100;
    if x*5 >= lp {
	println!("1");
    }else{
	println!("0");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int ans=0;
	bool fl=0;
	for(int i=0;i<s.size();i++,ans++){
		if(!fl&&s[i]==s[i+1]){
			i++;
			fl=1;
		}
		else fl=0;
	}
	cout<<ans;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int mi = 0, ma = n;
  rep(i, m) {
    int l, r;
    cin >> l >> r;

    mi = max(mi, l);
    ma = min(ma, r);
  }

  //max - min + 1だけではダメで、max < minの場合は0であることに注意する
  if (mi <= ma) {
    p(ma - mi + 1);
  } else {
    p(0);
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF 1e9
using namespace std;
int main(){
  int d,l;
  cin>>d>>l;
  int ans=0;
  while(d>=l){
    ans++;
    d-=l;
  }
  while(d>0){
    d--;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int a[12][12];
const int INF=1001001001;
int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m)
            cin >> a[i][j];
    }
    int ans = INF;
    rep(s,1<<n){
        int cost=0;
        vector<int> d(m);
        rep(i,n){
            if(s>>i&1){
                cost +=c[i];
                rep(j,m) d[j]+=a[i][j];
            }
        }
        bool ok=true;
        rep(j,m) if(d[j]<x)ok=false;
        if(ok) ans =min(ans,cost);
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

using namespace std;

const int Nmax = 2e5 + 5;
const int Mod = 1e9 + 7;
const int oo = 2e9;

int s, w;

int main()
{
/**
    #ifndef ONLINE_JUDGE

        ifstream cin("test.in");

    #endif // ONLINE_JUDGE
*/

    cin >> s >> w;

    cout << (w >= s ? "unsafe" : "safe");
    return 0;
}


Measured memory_bytes: 3620
/* ****TCIITB**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define piil         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
                    
                   
using namespace std;


int main()
{
   ll t;
   t=1;
   while(t--)
   { 
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(a-b)<=d && abs(b-c)<=d && (((c>=b && b>=a)) || (c<=b && a<=b))) || abs(a-c)<=d)
    {
       cout<<"Yes";
    }
    else
    {
      cout<<"No";
    }
     

     

   }

  
} 
 


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int cnt = 0;
    map<string,int> k;
    for(int i= 0; i < n; i++){
        if(k.count(s[i])){
            continue;
        }
        else{
            k[s[i]] = 1;
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
	int N;cin>>N;
	int ans=0;
	for(int i=1;i<=N;i++){
		int k=N/i;
		ans+=k*(k+1)/2*i;
	}

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


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 11000000;
int f[maxn];
void run_case()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            f[j]++;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += 1ll * i * f[i];
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 42644
#include <stdio.h>
#include <stdlib.h>

#define MAXSTACKED 100
#define MAXOP 1000000

int g_cnt = 0;

void plus(int stack[]);
void minus(int stack[]);
void times(int stack[]);

int main(void)
{
    int stack[MAXSTACKED];

    char symbol[MAXOP];
    while (scanf("%s", symbol) != EOF) {
        if (symbol[0] == '+') {
            plus(stack);
        } else if (symbol[0] == '-') {
            minus(stack);
        } else if (symbol[0] == '*') {
            times(stack);
        } else {
            stack[g_cnt++] = atoi(symbol);
        }
    }

    printf("%d\n", stack[0]);

    return 0;
}

void plus(int stack[])
{
    int op1 = stack[--g_cnt];
    int op2 = stack[--g_cnt];
    stack[g_cnt++] = op1 + op2;
}

void minus(int stack[])
{
    int op2 = stack[--g_cnt];
    int op1 = stack[--g_cnt];
    stack[g_cnt++] = op1 - op2;
}

void times(int stack[])
{
    int op1 = stack[--g_cnt];
    int op2 = stack[--g_cnt];
    stack[g_cnt++] = op1 * op2;
}

Measured memory_bytes: 556
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#define	MAX	2001
typedef	long	long	ll;
ll	N,	A[MAX];
ll	hash[MAX];
ll	DP[MAX][MAX];

ll	max(ll	x,	ll	y)
{
				if	(x	>	y)
								return	x;
				else
								return	y;
}

void	swap(ll	*	a,	ll	*	b)
{
				ll	buf	=	*a;
				*a	=	*b;
				*b	=	buf;
}

void	solve(ll	x,	ll	y)
{
				//枝刈り	N	+	1以上は詰められない
				if	(x	+	y	>=	N	+	1)
								return;
				//枝刈り	下のDPができてなければやる意味ない
				if	(DP[x][y	-	1]	<	0	||	DP[x	-	1][y]	<	0)
								return;
				DP[x][y]	=
								max(DP[x][y	-	1]	+	A[x	+	y]	*	(hash[x	+	y]	-	y),
												DP[x	-	1][y]	+	A[x	+	y]	*	(N	+	1	-	x	-	hash[x	+	y]));
				//とりま累乗で生成
				solve(x,	y	+	1);
				solve(x	+	1,	y);
}

ll	main()
{
				scanf("%lld",	&N);
				for	(ll	i	=	1;	i	<=	N;	i++)	{
								scanf("%lld",	A	+	i);
								hash[i]	=	i;
				}
				for	(ll	i	=	1;	i	<=	N;	i++)	{
								for	(ll	j	=	1;	j	<	i;	j++)	{
												if	(A[j]	<	A[i])	{
																swap(A	+	i,	A	+	j);
																swap(hash	+	i,	hash	+	j);
												}
								}
				}
				memset(DP,	-1,	sizeof(DP));
				DP[0][0]	=	0;
				for	(ll	i	=	1;	i	<=	N;	i++)	{
								DP[0][i]	=	DP[0][i	-	1]	+	A[i]	*	(hash[i]	-	i);
								DP[i][0]	=	DP[i	-	1][0]	+	A[i]	*	(N	+	1	-	i	-	hash[i]);
				}
				solve(1,	1);
				ll	ans	=	0;
				for	(ll	i	=	0;	i	<=	N;	i++)
								ans	=	max(ans,	DP[i][N	-	i]);
				printf("%lld",	ans);
}


Measured memory_bytes: 33164
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
rd=0
for i in range(N):
    if a[i] < b[i]+rd:
        d = a[i]
        rd = b[i]+rd - a[i]
        rd = rd if rd < b[i] else b[i]
    else:
        d = b[i] + rd
        rd=0
    s+=d
s+=rd if rd < a[N] else a[N]
print(s)


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

int n;
int A[100005], L[100005];

int lis(){
    L[0]=A[0];
    int length=1;

    for(int i=1; i<n; i++){
        if(L[length-1]<A[i]){
            L[length]=A[i]; length++;
        }
        else{
            *lower_bound(L, L+length, A[i])=A[i];
        }
    }

    return length;
}

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

    cout << lis() << endl;
    return 0;
}


Measured memory_bytes: 3716
use proconio::*;
use std::collections::*;

#[fastout]
fn main() {
    input! {
        x: usize,
        n: usize,
        p: [usize; n],
    }

    for i in 0.. {
        let a = x - i;
        let mut found = true;
        for j in 0..n {
            if a == p[j] {
                found = false;
                break;
            }
        }
        if found {
            println!("{}", a);
            return;
        }

        found = true;
        let b = x + i;
        for j in 0..n {
            if b == p[j] {
                found = false;
                break;
            }
        }
        if found {
            println!("{}", b);
            return;
        }
    }
}


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

int main(){

    int N;
    cin >> N;
    int A[N],B[N],C[N-1];

    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (size_t i = 0; i < N-1; i++)
    {
        cin >> C[i];
    }
    
    int ans=0;

    for (size_t i = 0; i < N; i++)
    {
        ans+=B[A[i]-1];
        if(A[i]==A[i+1]-1)ans+=C[A[i]-1];

    }
    
 
    cout << ans <<endl;
 
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
    int R[MAX], i, n;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&R[i]);
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1; i<n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    printf("%d\n",maxv);

    return 0;
}


Measured memory_bytes: 3380
#include <iostream>

int main()
{
  int L,R,d;
  scanf("%d %d %d", &L, &R, &d);

  int num=0;
  for (int i=L; i<=R; i++) {
    if (i%d == 0) num++;
  }

  std::cout << num << std::endl;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

void solve()
{
	vector<vector<int>> a(3,vector<int>(3));
	rep(i,3)rep(j,3)cin >> a[i][j];
	int n; cin >> n;
	rep(k,n)
	{
		int b; cin >> b;
		rep(i,3)rep(j,3)if(a[i][j]==b)a[i][j]=0;
	}
	bool bingo = false;
	int sum_d = 0;
	int sum_d2 = 0;
	rep(i, 3)
	{
		int sum_h = 0;
		int sum_v = 0;
		rep(j, 3)
		{
			sum_h += a[i][j];
			sum_v += a[j][i];
		}
		if(sum_h == 0||sum_v == 0)
		{
			bingo = true;
			break;
		}
		sum_d += a[i][i];
		sum_d2 += a[2-i][i];
	}
	if(sum_d == 0||sum_d2 == 0)
	{
		bingo = true;
	}
	if(bingo)cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

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


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

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

    vector<pair<string, pair<int, int> > > vec;

    string a; int b;
    for(int i = 0;i < n;i++){
        cin >> a >> b;
        vec.push_back(make_pair(a, make_pair(-b, i+1)));
    }

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

    for(int i = 0;i < n;i++){
        cout << vec[i].second.second << endl;
    }

    return 0;
}



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

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		if((str[0] == 'o' && str[1] == 'o' && str[2] == 'o') ||
		   (str[3] == 'o' && str[4] == 'o' && str[5] == 'o') ||
		   (str[6] == 'o' && str[7] == 'o' && str[8] == 'o') ||
		   (str[0] == 'o' && str[3] == 'o' && str[6] == 'o') ||
		   (str[1] == 'o' && str[4] == 'o' && str[7] == 'o') ||
		   (str[2] == 'o' && str[5] == 'o' && str[8] == 'o') ||
		   (str[0] == 'o' && str[4] == 'o' && str[8] == 'o') ||
		   (str[2] == 'o' && str[4] == 'o' && str[6] == 'o'))
		{
			cout << "o" << endl;
		}
		else if((str[0] == 'x' && str[1] == 'x' && str[2] == 'x') ||
			    (str[3] == 'x' && str[4] == 'x' && str[5] == 'x') ||
			    (str[6] == 'x' && str[7] == 'x' && str[8] == 'x') ||
			    (str[0] == 'x' && str[3] == 'x' && str[6] == 'x') ||
			    (str[1] == 'x' && str[4] == 'x' && str[7] == 'x') ||
			    (str[2] == 'x' && str[5] == 'x' && str[8] == 'x') ||
			    (str[0] == 'x' && str[4] == 'x' && str[8] == 'x') ||
			    (str[2] == 'x' && str[4] == 'x' && str[6] == 'x'))
		{
			cout << "x" << endl;
		}
		else
		{
			cout << "d" << endl;
		}
	}
}

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

Measured memory_bytes: 0
import java.util.*;
class Main
{
    static int MOD = 1000000007;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a == 5 || a == 7 || a == 3)
            System.out.println("YES");
            else System.out.println("NO");
    }
}

Measured memory_bytes: 23892
//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
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")};}

// https://beta.atcoder.jp/contests/arc101/tasks/arc101_a

fn main(){
    input!{N:i64,K:i64,x:[i64;N]};
//    let N:i64 = N;
//    let K:i64 = K;
//    let x:Vec<i64> = x;
    let windows = x.windows(K as usize);
    let mut ans = i64::max_value();
    for window in windows{
        let L = window.first().unwrap();
        let R = window.last().unwrap();
        if L*R < 0 {
            ans = std::cmp::min(ans,std::cmp::min(L.abs(),R.abs()) + L.abs() + R.abs());
        }else{
            ans = std::cmp::min(ans,std::cmp::max(L.abs(),R.abs()));
        }
    }
    println!("{}",ans);
}

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

using namespace std;

int main() {
	vector<int> weights;
	vector<int> use;
	weights.push_back(1);
	weights.push_back(2);
	weights.push_back(4);
	weights.push_back(8);
	weights.push_back(16);
	weights.push_back(32);
	weights.push_back(64);
	weights.push_back(128);
	weights.push_back(256);
	weights.push_back(512);
	int w;

	while(cin>>w,!cin.eof()) {
		while(w!=0){
			for(int i=0; i<weights.size(); i++){
				if(w == 0) break;
				if(w >= 512 ){
					w -= 512;
					use.push_back(512);
				}
				else if(weights.at(i) > w){
					w -= weights.at(i-1);
					use.push_back(weights.at(i-1));
					break;
				}
			}
		}
		sort(use.begin(), use.end());
		for(int i=0; i<use.size()-1; i++){
			cout<<use[i]<<" ";
		}
		cout<<use[use.size()-1]<<endl;
		use.clear();
	}
	return 0;
}

Measured memory_bytes: 1216
//逆序数 
#include <iostream>

using namespace std;

typedef long long llong;

llong merge(int *arr,int left,int m,int right) {
	int n1 = m -left;
	int n2 = right -m;
	int *L = new int[n1];
	int *R = new int[n2];
	int index1 = 0,index2  =0;
	llong cnt = 0;
	for (int i = left;i<right;i++) {
		if (i < m) {
			L[index1++] = arr[i];
		} else {
			R[index2++] = arr[i];
		}
	}
	index1 = 0;
	index2 = 0;
	for (int i = left;i<right;i++) {
		if (index1 >= n1) {
			arr[i] = R[index2++];
		} else if (index2 >= n2) {
			arr[i] = L[index1++];
		} else {
			if (L[index1] <= R[index2]) {
				arr[i] = L[index1++];
			} else {
				cnt += n1 - index1; 
				arr[i] = R[index2++];
			}
		}
	}
	return cnt;
}

//包括left但不包括right 
llong mergeSort(int *arr,int left,int right) {
	if (right - left > 1) {
		llong m = (left + right) / 2;
		llong a = mergeSort(arr,left,m);
		llong b = mergeSort(arr,m,right);
		llong c = merge(arr,left,m,right);
		return a +  b + c;
	} else {
		return 0;
	}
	
}
int main() {
	int n;
	cin >> n;
	int *arr = new int[n];
	for (int i=0;i<n;i++) {
		cin >> arr[i];
	}
	llong x = mergeSort(arr,0,n);
	cout << x << endl;
} 


Measured memory_bytes: 26784
n=io.read("*n","*l")
a={}
b={}
for i=1,n do
    a[i]=io.read("*n")
end
for i=1,n do
    b[i]=io.read("*n")
end

counter=0
for i=1,n do
    if a[i]<b[i] then
        counter=counter+(b[i]-a[i])//2
    else
        counter=counter-(a[i]-b[i])
    end
end

if counter<0 then
    print("No")
else
    print("Yes")
end

Measured memory_bytes: 888
N = int(input())
p = [-1] + list(map(float, input().split()))
dp = [[1] * (N+1) for _ in range(N+1)] #i番目のコインまででj枚表が出る確率
dp[1][0] = 1 - p[1]
dp[1][1] = p[1]
for i in range(2, N + 1):
    for j in range(i + 1):
        if j == 0: #表０枚の確率
            dp[i][j] = dp[i-1][j] * (1 - p[i])
        elif j == i:
            dp[i][j] = dp[i-1][j-1] * p[i]
        else:
            dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i]
num = N // 2 + 1
ans = 0
while num <= N:
    ans += dp[N][num]
    num += 1
print(ans)

Measured memory_bytes: 203948
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    ll cnt1=0,cnt2=0,cnt3=0;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n){
        cnt1+=a[i];
        cnt2+=b[i];
        if(a[i]<b[i])cnt3+=(b[i]-a[i]+1)/2;
    }
    ll x=cnt2-cnt1;
    if(x>=cnt3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()

	for i := 0; i < 100000; i++ {
		v := i*b + c
		if v%a == 0 {
			fmt.Println("YES")
			return
		}
	}

	fmt.Println("NO")
	return

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

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

    //good luck kittu!
    int x, y, A, B, C;
    cin>>x>>y>>A>>B>>C;
    vector<ll> a(A), b(B), c(C);
    for(int i = 0; i<A; i++) cin>>a[i];
    for(int i = 0; i<B; i++) cin>>b[i];
    for(int i = 0; i<C; i++) cin>>c[i];

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    
    for(int i = 0; i<x; i++) c.push_back(a[i]);
    for(int i = 0; i<y; i++) c.push_back(b[i]);

    sort(c.rbegin(), c.rend());
    ll ans = 0;
    for(int i = 0; i<x+y; i++) ans += c[i];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 6256
from collections import defaultdict
S = input()
alphabet = "abcdefghijklmnopqrstuvxyz"

if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

dict = defaultdict(int)
for s in S:
    dict[s] += 1

if len(S) < len(alphabet):
    for a in alphabet:
        if dict[a] == 0:
            print(S + a)
            exit()
else:
    for i in range(24, -1, -1):
        for j in range(25, i, -1):
            if S[i] < S[j]:
                print(S[:i] + S[j])
                exit()
print(-1)


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

#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    int n;
    cin>>n;
    int a[n],i,j,k,ans=0;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            rep(k,j+1,n)
            {
                if(a[i]!=a[j]&&a[j]!=a[k])
                {
                    vi v(3);
                    v[0]=a[i];
                    v[1]=a[j];
                    v[2]=a[k];
                    sort(all(v));
                    if(v[0]+v[1]>v[2])ans++;
                }
            }
        }
    }
    cout<<ans;
    //for(auto i:v)cout<<i.F<<" "<<i.S.F<<" "<<i.S.S<<endl;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int D = int.Parse(s[0]);
        int X = int.Parse(s[1]);

        for(int i = 0; i < N; i++)
        {
            int A = int.Parse(Console.ReadLine());
            int Day = 1;
            while(Day <= D)
            {
                X++;
                Day += A;
            }
        }
        Console.WriteLine(X);
    }
}


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

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	for (int i = 1; i <= b; ++i) {
		if (a * i % b == c) {
			printf("YES");
			return 0;
		}
	}
	printf("NO");

	return 0;
}

Measured memory_bytes: 128
MOD=10**9+7
N=int(input())
S1=input()
S2=input()

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

if S1[0]==S2[0]:
  ans=3
  i=1
else:
  ans=6
  i=2

while i<N:
  if S1[i]==S2[i]:
    if S1[i-1]==S2[i-1]:
      ans=ans*2%MOD
    i+=1
  else:
    if S1[i-1]==S2[i-1]:
      ans=ans*2%MOD
    else:
      ans=ans*3%MOD
    i+=2
    
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  ll n,k;
  cin >> n >> k;
  ll q = 0;
  if(k%2==0) {
    q = n/k;
    if(k/2+q*k<=n) q++;
  }
  ll p = n/k;
  cout << p*p*p + q*q*q << endl;
}




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

int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
        return 0;
    }
    else 
    {
        cout << "red" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, x := scanInt(), scanInt()
	a := make([]int, n+2)

	for i := 1; i < n+1; i++ {
		a[i] = scanInt()
	}
	
	ans := int64(0)

	for i := 0; i < n+1; i++ {
		p,q := a[i], a[i+1]
		if p+q <= x {
			continue
		} else {
			over := p+q-x
			if over > q {
				ans+=int64(q)
				a[i+1] = 0
			} else {
				ans+=int64(over)
				a[i+1] -= over
			}
		}
	}

	// fmt.Println(a)

	fmt.Println(ans)

}


Measured memory_bytes: 3072
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

int main() {

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

	string S;
	int K;
	cin >> S >> K;

	for (int i = 0; i <= (int)S.length(); i++) {

		if (K != 1 && S[i] == '1') K--;
		else {
			cout << S[i] << "\n";
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,k;cin>>a>>b>>c>>k;
	int kk=0;
	while(kk!=k && b<=a){
	    b*=2;
	    kk++;
	}
	while(kk!=k && c<=b){
	    c*=2;
	    kk++;
	}
	if(c>b&&b>a){
	    cout<<"Yes"<<endl;
	}else{
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;



int main()
{
	fast;
	cin>>n>>m;
	fs(ar,n);
	fo(i,1,n)
	if(ar[i]>=m)
		sum++;
	cout<<sum;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 1024
S = str(input())

def Main(S):
    ans = 0
    candidate = 0
    flag = False
    for c in S:
        if c == 'A':
            flag = True
        if flag:
            candidate += 1
            if c == 'Z':
                ans = candidate
    return ans
            
    
res = Main(S)
print(res)

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define int long long
const int N=1e5+10;


int32_t main() 
{
   int n,k; cin>>n>>k;
   string s; cin>>s;
   int j=0;
   vector<pair<char,int>>vx;
   for(int i=0;i<n;i=j)
   {
    while(s[j]==s[i] and j<n) j++;
    vx.push_back({s[i],j-i});
   }
  // for(auto i : vx) cout<<i.first<<" "<<i.second<<endl;
   int r=0; int zero=0; int sum=0; int ans=0;
   for(int l=0;l<vx.size();l++)
   {
     if(l>r) r=l;
     while(r<vx.size() and zero<=k)
     {
        if(zero==k and vx[r].first=='0') break;
        sum+=vx[r].second;
        if(vx[r].first=='0') zero++; r++;
     }
     ans=max(ans,sum);
     sum-=vx[l].second;
     if(vx[l].first=='0') zero--;
   }
   cout<<ans; return 0;
}




Measured memory_bytes: 2548
#include <stdio.h>

typedef long long ll;
int N;
int workingtime[100];
int  profit[100][11];

int bitcount(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);    //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);    //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);    //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);    //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);    //  32ビット分を計算
}

int main(){
        scanf("%d",&N);
        for(int i = 0; i < N; i++){
                for(int j = 0; j < 10; j++){
                        int t;
                        scanf("%d", &t);
                        workingtime[i] += t*(1<<j);
                }
        }
        for(int i = 0; i < N; i++){
                for(int j = 0; j < 11; j++) scanf("%d", &(profit[i][j]));
        }

        char initialized = 0;
        ll maxtotalprofit = 0;
        for(int b = 1; b < 1024; b++){
                ll totalprofit = 0;
                for(int i = 0; i < N; i++){
                        totalprofit += profit[i][bitcount(workingtime[i] & b)];
                }
                if(!initialized){
                        maxtotalprofit = totalprofit;
                        initialized = 1;
                }else if(maxtotalprofit < totalprofit) maxtotalprofit = totalprofit;
        }
        printf("%lld\n",maxtotalprofit);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var line = input.Select(s => int.Parse(s)).ToList();
            var count = 0;

            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        if ((line[i] + line[j] > line[k]) && (line[j] + line[k] > line[i]) && (line[k] + line[i] > line[j]))
                        {
                            if (line[i] != line[j] && line[j] != line[k] && line[k] != line[i])
                                count++;
                        }
                    }
                }
            }

            System.Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28304
<?php
list($n, $h, $w) = ints();
$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    list($a, $b) = ints();
    if ($a >= $h && $b >= $w) ++$cnt;
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16276
import numba  # noqa
from numba import njit, b1, i4, i8, f8  # noqa

N = int(input())


@njit((i8, ), cache=True)
def main(N):
    ans = 0
    for j in range(1, N + 1):
        x = N // j
        ans += int(j * x * (x + 1) / 2)
    return ans


print(main(N))


Measured memory_bytes: 109652
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    char X,Y;
    cin>>X>>Y;
    
    if (X<Y) {
        cout<<'<'<<endl;
    }else 
    if (Y<X) {
        cout<<'>'<<endl;
    }
    else
    {
        cout<<'='<<endl;
    }
    
    
    
    return 0;
}

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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a > b;
}

int gcd(int x, int y){
    return x % y == 0 ? y : gcd(y, x % y);
}

int main(){
    int n;
    scanf("%d", &n);
    int p[25];
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    int cnt = 0;
    for (int i = 2; i < n; i++)
        if ((p[i] > p[i - 1] && p[i] < p[i + 1]) ||
            (p[i] < p[i - 1] && p[i] > p[i + 1]))
            cnt++;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 10.05.2020 20:37:56       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC") << '\n';
  return 0;
}


Measured memory_bytes: 3648