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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, d[50], b[13];

int main() {
	cin >> n;
	inc(i, n) { cin >> d[i]; }
	
	b[0]++;
	inc(i, n) { b[d[i]]++; }
	
	int ans = 0;
	inc(i, 1 << 13) {
		vector<int> v;
		inc(j, 13) {
			if(b[j] >= 3) { v.PB(0); v.PB(0); }
			if(b[j] == 2) { v.PB(j); v.PB((24 - j) % 24); }
			if(b[j] == 1) { v.PB(((i >> j) & 1) ? j : (24 - j) % 24); }
		}
		int mi = 100;
		int w = v.size();
		inc(j, w) {
		inc(k, w) {
			if(j == k) { continue; }
			setmin(mi, min(abs(v[j] - v[k]), 24 - abs(v[j] - v[k])));
		}
		}
		setmax(ans, mi);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;

using namespace std;
int n;
char A[301][601];
bool ser(int i)
{
    bool fl=true;
    int x=0;
    while(fl&&x<n*n)
    {
        if(A[x/n][x%n+i]==A[x%n][x/n+i])
        {}
        else fl=false;
        x++;
    }
    return fl;
    
}
int main()
{
    cin>>n;
    char c;
    rep(i,n)
    {
        rep(j,n)
        {
            cin>>c;
            A[i][j]=c;
            A[i][j+n]=c;
        }
    }
    int ans=0;
    rep(i,n)
    {
        if(ser(i))
        {
            ans++;
        }
        else{}
    }
    W(ans*n);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    string S, T;
    cin >> S;
    cin >> T;
    int def;

    int ans = T.size();

    for(int temp = 0; temp <= S.size() - T.size(); temp++)
    {
        def = 0;
        for(int i =0; i < T.size(); i++)
        {
            if(T[i] != S[temp + i])
                def++;
        }
        ans = min(ans, def);
    }

    cout << ans << "\n";
}

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

int main(){
  int a=0;
  int ans=0;
  int n;
  cin >>n;
  int x[15][15];
  int y[15][15];
  int c[15];
  for(int i=0;i<n;i++){
    int a[i];
    cin >> a[i];
    c[i] = a[i];
    for(int j=0;j<a[i];j++){
      cin >> x[i][j];
      cin >> y[i][j];
    }
  }


for(int bit=0;bit<(1<<n);bit++){
  bool b = true;
  for(int i=0;i<n;i++){
    int p = c[i];
    for(int j=0;j<p;j++){
      if(bit & (1<<i) && y[i][j] == 1 && !(bit&(1<<x[i][j]-1))) b=false;
      if(bit & (1<<i) && y[i][j] == 0 &&   bit&(1<<x[i][j]-1))  b=false;
    }
  }
  if(b && ans <=__builtin_popcount(bit)) ans = __builtin_popcount(bit);
}

cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        String s1 = sc.next();
        String s2 = sc.next();
        int ret = n*2;
        for (int i = 0;i < n;i++) {
            String tmp1 = s1.substring(i, n);
            String tmp2 = s2.substring(0, n-i);
            if (tmp1.equals(tmp2)) {
                ret = n+i;
                break;
            }
        }
        
        System.out.println(ret);
    }
}


Measured memory_bytes: 9808
s = input().split()

n = int(s[0])
m = int(s[1])

citys = []
for i in range(n):
    citys.append(0)


for i in range(m):
    p = input().split()
    x = int(p[0])
    y = int(p[1])
    citys[x - 1] += 1
    citys[y - 1] += 1

for i in range(len(citys)):
    print(citys[i])


Measured memory_bytes: 9156
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N = 1e5;

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, a, b;cin >> n >> a >> b;
	int ans = 0;
	while(n--){
		int x; cin >> x;
		if(x >= a && x < b)continue;
		ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
vector<bool> used,ok;
vi dp;
ll n,m;
ll dfs(ll i){
    if(dp[i]!=-1)return dp[i];
    if(used[i])return -1;
    used[i]=true;
    ll k=dfs((i+m)%n);
    if(k==-1)return -1;
    dp[i]=k+1;
    return k+1;
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return (a*modpow(a,b-1))%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    string s,t;cin>>s>>t;
    while(s.size()<t.size())s+=s;
    n=s.size()*2;m=t.size();
    ll k=107;
    dp=vi(n,-1);
    used=vector<bool>(n,false);
    ok=used;
    s+=s;
    s+=s;
    ll r=0,rh=0;
    rep(i,m){
        rh+=s[n-1+m-i]-'a';
        if(i<m-1)rh*=k;
        rh%=mod;
    }
    rep(i,m){
        r+=t[m-i-1]-'a';
        if(i<m-1)r*=k;
        r%=mod;
    }
    //if(rh!=r)dp[0]=0;
    ll ans=0;
    ll f=modpow(k,m-1);
    for(ll i=n;i>0;i--){
        rh-=(s[i+m-1]-'a')*f%mod;
        rh=(rh+mod)%mod;
        rh*=k;
        rh+=s[i-1]-'a';
        if(rh%mod!=r)dp[i-1]=0;
    }
        rep(i,n){
            ll u=dfs(i);
            if(u==-1){
                cout<<-1<<endl;
                return 0;
            }
            chmax(ans,u);
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 42056
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> vv(n);

	int ma = -1;
	for(int i=0;i<n;++i){
		cin >> v[i];
		vv[i] = v[i];
		ma = max(v[i],ma);
	}
	sort(vv.begin(),vv.end());
	
	for(int i=0;i<n;++i){
		if(v[i] == ma) cout << vv[n-2] << endl;
		else cout << ma << endl;
	}


	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define READ1(n1) scanf("%d", &(n1))
#define READ2(n1, n2) scanf("%d%d", &(n1), &(n2))
#define READ3(n1, n2, n3) scanf("%d%d%d", &(n1), &(n2), &(n3))
#define P1(n1) printf("%d\n", (n1))
#define P2(n1, n2) printf("%d, %d\n", (n1), (n2))
#define P3(n1, n2, n3) printf("%d, %d, %d\n", (n1), (n2), (n3))
#define CLEAR(p) memset((p), 0, sizeof((p)))
#define MAX_COLUMN 101
#define MAX_ROW 1001

char bars[MAX_COLUMN][MAX_ROW];

main()
{
	while(1) {
		int i;
		int vbar_num, hbar_num, x, y;

		CLEAR(bars);

		READ3(vbar_num, hbar_num, x);

		if(vbar_num == 0) break;

		REP(i, hbar_num) {
			int height, left, right;

			READ3(height, left, right);

			bars[left][height] = 1;
		}

		for(y = 1000; y > 0; y--) {
			if(bars[x][y]) {
				x++;
			} else if(bars[x-1][y]) {
				x--;
			}
		}

		P1(x);
	}
	return 0;
}

Measured memory_bytes: 704
import java.util.*;

class Main {

  public static void main(String[] args) {

    String[] motValide = new String[]{"eraser", "erase", "dreamer", "dream"};

    Scanner scan = new Scanner(System.in);
    String chaine = scan.nextLine();

    for(int i = 0; i < motValide.length; i++)
      chaine = chaine.replace(motValide[i], ".");


      int compteur = 0;

      for (int k = 0; k < chaine.length(); k++){
        if (chaine.charAt(k) == '.'){
          compteur = compteur+1;
        }
      }


    if (chaine.length() == compteur)
      System.out.println("YES");
    else
      System.out.println("NO");

  }

}


Measured memory_bytes: 16452
#include<stdio.h>

int main(void){

int l,a,b,c,d,j,m,z;

scanf("%d",&l);
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);

if(a%c==0){
j=a/c;
}
else{
j=a/c+1;
}
if(b%d==0){
m=b/d;
}
else{
m=b/d+1;
}

if(j>=m){
z=l-j;
}
else if(j<m){
z=l-m;
}

printf("%d\n",z);

return 0;
}


Measured memory_bytes: 2116
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    c = True
    for k in range(m):
      if a[i+k][j:j+m] != b[k]:
        c = False
    if c:
      print("Yes")
      exit()

print("No")

Measured memory_bytes: 3060
d = [[-1,0],[0,1],[1,0],[0,-1]]
while True:
    n = int(input())
    if not(n): break
    # l = [[1,1]]
    w,h = [1],[1]
    for i in range(n-1):
        l = list(map(int,input().split()))
        w.append(w[l[0]]+d[l[1]][0])
        h.append(h[l[0]]+d[l[1]][1])
    print(max(w)-min(w)+1,max(h)-min(h)+1)

Measured memory_bytes: 7556
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int n,m;
int solve(vector<vector<int> >in,int a){
  int j=0;
  while(a){
    if(a&1)rep(i,m)in[j][i]^=1;
    a>>=1;
    j++;
  }
  int sum=0;
  rep(i,m){
    int co=0;
    rep(j,n)if(in[j][i])co++;
    co=max(co,n-co);
    sum+=co;
  }
  return sum;
}
int main(){
  while(cin>>n>>m,n||m){
    vector<vector<int> >in(n,vector<int>(m));
    rep(i,n)rep(j,m)cin>>in[i][j];
    int out=0;
    rep(i,1<<n){
      out=max(out,solve(in,i));
    }
    cout<<out<<endl;
  }
}

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

using namespace std;
using int64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

void fastin(int64 &num) {
  bool negative = false;
  int64 c;
  num = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

void fastout(int64 &n) {
  int64 N = n, rev, count = 0;
  rev = N;
  if (N == 0) { 
    putchar('0');
    putchar('\n');
    return;
  }
  while ((rev % 10) == 0) { 
    ++count; rev /= 10;
  }
  rev = 0;
  while (N != 0) { 
    rev = (rev << 3) + (rev << 1) + N % 10;
    N /= 10;
  }
  while (rev != 0) { 
    putchar(rev % 10 + '0');
    rev /= 10;
  }
  while (count--) putchar('0');
  putchar('\n');
}

int main(){
    int64 n, m; fastin(n); fastin(m);
    int64 x[m];
    rep(i, m) fastin(x[i]);

    sort(x, x + m);

    int64 diff[m - 1];
    rep(i, m - 1){
        diff[i] = x[i + 1] - x[i];
    }

    sort(diff, diff + m - 1);

    int64 ans = 0;

    for (int i = 0; i < (m - n); ++i){
        ans += diff[i];
    }

    fastout(ans);
    
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#include <stack>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using ll = long long;
using P = std::pair<ll, ll>;

ll N, M;
std::vector<ll> G[100010], ord;
ll deg[100010], dep[100010], ans[100010];

int main()
{
  std::cin >> N >> M;

  rep( i, N-1+M )
  {
    ll A, B;
    std::cin >> A >> B;

    --A; --B;

    G[A].emplace_back( B );
    ++deg[B];
  }

  std::stack<int> st;

  rep( i, N ) if( !deg[i] )
    st.push( i );

  while( !st.empty() )
  {
    ll v = st.top(); st.pop();

    ord.emplace_back( v );

    for( auto &u : G[v] )
    {
      --deg[u];

      if( !deg[u] )
        st.push( u );
    }
  }

  for( auto i : ord ) for( auto j : G[i] )
    chmax( dep[j], dep[i]+1 );

  ll root = ord[0];
  ans[root] = -1;

  rep( i, N ) for( auto j : G[i] ) if( dep[i]+1 == dep[j] )
    ans[j] = i;

  rep( i, N )
    std::cout << ans[i]+1 << std::endl;

  return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


vector<pii> graph[6000];
int graph2[310][310];

int dist[6010];
int dist2[310][2010];

int station[310];

typedef tuple<int,int,int> state;

inline bool update(int c,int v,int g){
	if(g>=0&&(dist2[v][g]==-1||dist2[v][g]>c)){
		dist2[v][g]=c;
		return true;
	}
	return false;
}

void dijkstra(int s,int m){
	clr(dist,-1);
	int src=station[s];
	dist[src]=0;
	priority_queue<state,vector<state>,greater<state>> q;
	state init(0,src,-1);
	q.push(init);
	while(!q.empty()){
		state cur=q.top();q.pop();
		int c,v,g;
		tie(c,v,g)=cur;

		if(dist[v]<c)
			continue;

		for(auto &v2:graph[v]){
			int nc=c+v2.second;
			if(dist[v2.first]==-1||dist[v2.first]>nc){
				dist[v2.first]=nc;
				state next(nc,v2.first,-1);
				q.push(next);
			}
		}
	}
	rep(i,m) graph2[s][i]=dist[station[i]];
	return;
}


int dijkstra2(int cap,int m){
	clr(dist2,-1);
	dist2[0][cap]=0;
	priority_queue<state,vector<state>,greater<state>> q;
	state init(0,0,cap);
	q.push(init);
	while(!q.empty()){
		state cur=q.top();q.pop();
		int c,v,g;
		tie(c,v,g)=cur;

		if(v==1) return c;

		if(dist2[v][g]<c)
			continue;

		if(v>=2) g=cap;

		for(int i=0;i<m;++i){
			int nc=c+graph2[v][i];
			int ng=g-graph2[v][i];
			if(update(nc,i,ng)){
				state next(nc,i,ng);
				q.push(next);
			}
		}
	}
	return -1;
}

int main(void){
	int n,m,cap;
	while(cin >> n >> m >> cap){
		if(n==0&&m==0&&cap==0)
			break;

		map<string,int> con;

		int nmax=0;
		string src,dest;
		cin >> src >> dest;
		con[src]=nmax++,con[dest]=nmax++;
		rep(i,n){
			string a,b;
			cin >> a >> b;
			if(con.find(a)==con.end()) con[a]=nmax++;
			if(con.find(b)==con.end()) con[b]=nmax++;
			int aa,bb,c; cin >> c;
			aa=con[a],bb=con[b];
			pii in(bb,c);graph[aa].pb(in);
			in.first=aa,graph[bb].pb(in);
		}

		m+=2;
		clr(station,-1);
		station[0]=con[src],station[1]=con[dest];
		for(int i=2;i<m;++i){
			string s;
			cin >> s;
			station[i]=con[s];
		}
		rep(i,m) dijkstra(i,m);

		cap*=10;
		int ans=dijkstra2(cap,m);
		cout << ans << endl;

		rep(i,nmax) graph[i].clear();

	}
	return 0;
}

Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){co("OK");return 0;}
    }
    co("NG");
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x=1e9+7;
ll a[20000],bq[20000],bl[20000];
int main()
{
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sizeof(bq,0,sizeof(bq));
	sizeof(bl,0,sizeof(bl));
	for(int i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			if(a[j]<a[i]&&i>j)
			bq[i]++;
			else if(a[j]<a[i]&&i<j)
			bl[i]++;
		}
	}
	ll sum1=(k-1)*k/2;
	sum1=sum1%x;
	long long sum3=0;
	for(ll i=0;i<n;i++)
	{
		
		sum3+=bq[i]*sum1;
		sum3=sum3%x;
		sum3+=bl[i]*(sum1+k);
		sum3=sum3%x;
	}
	cout<<sum3%x<<endl;
 } 

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    static int containsInts(int[] arr, int[] queries) {
    	
        int i, j;
        int counter = 0;
        int total = 0;
        
        for(i = 0; i < queries.length; i++){
            for(j = 0; j < arr.length; j++){
                if (queries[i] == arr[j]){
                    counter = 1;
                }
            }
            total += counter;
            counter = 0;
        }
        return total;
    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        int arrSize = scanner.nextInt();

        int[] arr = new int[arrSize];

        for (int i = 0; i < arrSize; i++) {
            int x = scanner.nextInt();
            arr[i] = x;
        }

        int queriesSize = scanner.nextInt();

        int[] queries = new int[queriesSize];

        for (int i = 0; i < queriesSize; i++) {
            int query = scanner.nextInt();
            queries[i] = query;
        }

        scanner.close();

        int res = containsInts(arr, queries);

        System.out.println(res);
    }
}



Measured memory_bytes: 40012
from collections import deque

def main():
    k = int(input())

    lunluns = deque(range(1, 10))

    lunlun = -1

    for _ in range(k):
        lunlun = lunluns.popleft()

        ones_place = lunlun % 10
        if ones_place > 0:
            lunluns.append(lunlun * 10 + ones_place -1)
        lunluns.append(lunlun * 10 + ones_place)
        if ones_place < 9:
            lunluns.append(lunlun * 10 + ones_place + 1)
    return lunlun

print(main())


Measured memory_bytes: 11956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
    int n; cin >> n;
    int a, x, y;
    vector< vector<pair<int, int>> > v(n);
    rep(i, 0, n) {
        cin >> a;
        rep(j, 0, a) {
            cin >> x >> y;
            v[i].push_back({--x, y});
        }
    }

    vector<int> g(n);

    int ans = 0;
    rep(i, 0, (1<<n)) {
        bool flag = true;
        int cnt = 0;
        rep(j, 0, n) g[j] = (i>>j&1);
        rep(j, 0, n) {
            if (g[j]) {
                cnt++;
                rep(k, 0, v[j].size()) {
                    if (g[v[j][k].first] != v[j][k].second) {
                        flag = false;
                        break;
                    }
                }
            }
        }
        if (flag) ans = max(ans, cnt);
    }

    cout << ans << endl;
}


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










const long int INF = 1e9+5;

int main()
{
    int n,w;
    cin >> n >> w;
    vector <long long> m(w+1,0);
    for (int i=0; i<n; i++)
    {
        long long int cm,cw;
        cin >> cm >> cw;
        for (int i=w; i>=cm; i--)
            if ((m[i-cm]!=0 && i-cm!=0) || (i-cm==0))
        {
            m[i] = max(m[i-cm] + cw,m[i]);
        }
    }
    long long int mx=0;
    for (int i=0; i<w+1; i++)
        mx=max(mx,m[i]);
    cout << mx ;
}

/*
10
10 3
1 2 3 4 5 6 7 8 9 10
3 3 4
*/



Measured memory_bytes: 3996
A = input()
B = input()
flag = True
if len(A) > len(B):
  print("GREATER")
  flag = False
elif len(A) < len(B):
  print("LESS")
  flag = False
elif len(A) == len(B):
  for i in range(len(A)):
    if int(A[i]) > int(B[i]):
      print("GREATER")
      flag = False
      break
    elif int(A[i]) < int(B[i]):
      print("LESS")
      flag = False
      break

  
if flag:
  print("EQUAL")



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

using namespace std;

int tab[107];

int main()
{
    int n, i, j, k, w=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> tab[i];
    }
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            for(k=j+1; k<n; k++){
                if(((tab[i]+tab[j]>tab[k])&&((tab[i]+tab[k]>tab[j])&&(tab[k]+tab[j]>tab[i])))&&((tab[i]!=tab[j])&&((tab[i]!=tab[k])&&(tab[j]!=tab[k])))){
                    w++;
                }
            }
        }
    }
    cout << w << '\n';
    return 0;
}


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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r, k;
        std::cin >> l >> r >> k;
        std::cout << std::count(v.begin() + l, v.begin() + r, k) << std::endl;
    }
}


Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
//LLONG_MIN

struct edge {ll u,v,cost;};



int main(void){
	ll R,C;
	int N;
	ll x1,y1,x2,y2;
	stack<int> ST;
	map<ll,int>MP;
	cin>>R>>C>>N;
	rep(i,N){
		cin>>x1>>y1>>x2>>y2;
		if((x1==0 || x1==R || y1==0 || y1==C)&&(x2==0 || x2==R || y2==0 || y2==C)){
			ll d=0;
			if(x1==0){
				d=2*R+2*C-y1;
			}else if(x1==R){
				d=R+y1;
			}else if(y1==0){
				d=x1;
			}else{
				d=R*2+C-x1;
			}
			MP[d]=i;
			if(x2==0){
				d=2*R+2*C-y2;
			}else if(x2==R){
				d=R+y2;
			}else if(y2==0){
				d=x2;
			}else{
				d=R*2+C-x2;
			}
			MP[d]=i;
		}
	}
	for (map<ll,int>::iterator p=MP.begin();p!=MP.end();++p) {
		if(ST.size()!=0){
			if(ST.top()==p->second){
				ST.pop();
			}else{
				ST.push(p->second);
			}
		}else{
			ST.push(p->second);//サイズが０の時は無条件で入れる（これを忘れていた）
		}
		// cout<<p->first<<","<<p->second<<endl;
	}
	if(ST.size()!=0){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}

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

void solve()
{
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=100;i++)
    {
        int a=x-i;
        if(a>=0)
        {
            if(i*2+a*4==y){
                cout<<"Yes"<<endl;
                return;
            }
        }
    }
    cout<<"No"<<endl;
    return;
}

int main()
{
    solve();
}


Measured memory_bytes: 3584
n, m, c = map(int, input().split())

b = list(map(int, input().split()))

a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    if sum(map(lambda x, y: x * y, a[i], b)) + c > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int m=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            if(m==-1 && f==-1 && r==-1)break;
            if(m==-1 || f==-1 || (m+f)<30)System.out.println("F");
            else if((m+f)>=80)System.out.println("A");
            else if((m+f)>=65)System.out.println("B");
            else if((m+f)>=50)System.out.println("C");
            else if((m+f)>=30 && r<50)System.out.println("D");
            else System.out.println("C");
        }
    } 
}


Measured memory_bytes: 26184
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#define MAX 10001

using namespace std;

int c[MAX][MAX]; 
int n, m;
int maxlengh;

int lcs(string A, string B) {
	maxlengh = 0;
	A = ' ' + A;
	B = ' ' + B;
	n = A.size();
	m = B.size();

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i == 0 || j == 0) {
				c[i][j] = 0;
			}else if(A[i] == B[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}else{
				c[i][j] = max(c[i][j - 1], c[i - 1][j]);
			}maxlengh = max(maxlengh, c[i][j]);
		}
	}
	return maxlengh;
}

int main() {
	int q;
	cin >> q;
	string a, b;
	
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		cout << lcs(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 11056
//インクルード文
#include <iostream>
#include <stack>
#include <vector>
#include <stdlib.h>
#include <cstdio>
#include <string>
//#include <assert.h>

//:std省略
using namespace std;

//グローバル変数
int f[1000][1000];

//マクロ指定
#define fc f[x + j][y + l] = c

//深さ優先探索( dfs = Depth - First Search )
void dfs(int a, int b, int c) {

	if (f[a][b] == c) {


		f[a][b] = 10;
		dfs(a + 1, b, c);
		dfs(a - 1, b, c);
		dfs(a, b + 1, c);
		dfs(a, b - 1, c);


	}

//	else return;

}

//メイン文
int main(){

	int w=0, h=0, n = 0;
	int i, j, l;
	int xs, ys; 
	int xg, yg;

	

	for (;;) {
		cin >> w >> h;

		const int cnt = w + h;
		
		if ( cnt == 0) break;
		
		for (i = 1; i <= h; ++i) {
			for (j = 1; j <= w; ++j) {
				f[i][j] = -1;
			}
		}

		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;

		for (i = 0; i < n; ++i) {
			int c, d, x, y;

			cin >> c >> d;
			cin >> x >> y;

			if (d == 0) {
				for (j = 0; j < 4; ++j) {
					for (l = 0; l < 2; ++l) {
						fc;
					}
				}
			}

			else {//d==1

				

				for (j = 0; j < 2; ++j) {
					for (l= 0; l < 4; ++l) {
						fc;
					}
				}
			}
		}
/*

			if (d == 0) {
				for (j = 0; j < 2; ++j) {
					for (l = 0; l < 4; ++l) {
						f[x + j][y + l] = c;
					}
				}
			}

			else {
				for (j = 0; j < 4; ++j) {
					for (l= 0; l < 2; ++l) {
						f[x + j][y + l] = c;
					}
				}
			}	
		}

*/


		dfs(xs, ys, f[xs][ys]);


//		char gg = 'OK';
//		char ggwp = 'NG';


		

		if (f[xg][yg] == 10) printf("OK\n");

		else 		         printf("NG\n");



			//			assert(i == 10);
			//			assert(i = 9);
			//			assert(i = 8);
			//			assert(i = 7);
			//			assert(i = 6);
			//			assert(i = 5);
			//			assert(i = 4);
			//			assert(i = 3);
			//			assert(i = 2);
			//			assert(i = 1);

		


	}
	return 0;
}

/*


20 20
1 1
9 9
7
2 0 1 1
5 1 1 3
2 1 3 3
1 1 5 2
5 1 7 3
2 0 2 7
2 0 6 8
20 20
9 9
1 1
6
2 0 1 1
1 0 5 1
2 1 1 3
5 0 1 7
3 1 5 5
4 1 8 5
0 0


*/


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int d=a*100+b*10+c;
  if(d%4==0){
    printf("YES");
  }else{
    printf("NO");
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	ll n;
	while (cin >> n, n) {
		int cnt = 0;
		bitset<52> b = 0;
		string s; cin >> s;
		rep(i,52)if (s[i] == '1')b[51-i] = 1;
		bitset<52> x = 0;
		x = b;
		cnt++; n--;
		while (n > 0) {
			if (cnt > 52)break;
			//cout << cnt << " " << n << " " << x << endl;
			bitset<52> c = b; c >>= cnt; 
			if (cnt)c[52-cnt] = 1;
			if (c == 0)break;
			ll le = 0, ri = INF;
			while (ri - le > 1) {
				ll mid = (ri + le) / 2;
				ll s = 0;
				rep(i, 52) {
					if (x[i]) {
						s++;
					}
					if (c[i]) {
						s += mid;
					}
					s /= 2;
				}
				if (s > 0)ri = mid;
				else le = mid;
			}
			if (n < ri) {
				ll s = 0;
				rep(i, 52) {
					if (x[i])s++;
					if (c[i])s += n;
					if (s % 2)x[i] = 1;
					else x[i] = 0;
					s /= 2;
				}
				break;
			}
			else {
				n -= ri;
				ll s = 0;
				rep(i, 52) {
					if (x[i])s++;
					if (c[i])s += ri;
					if (s % 2)x[i] = 1;
					else x[i] = 0;
					s /= 2;
				}
				cnt++; x >>= 1;
				if (cnt == 1)x[51] = 1;
			}
		}
		string ans;
		rep(i, 12) {
			if (cnt&(1 << (11-i))) {
				ans.push_back('1');
			}
			else ans.push_back('0');
		}
		per(i, 52) {
			if (x[i])ans.push_back('1');
			else ans.push_back('0');
		}
		cout << ans << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3076
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)


Measured memory_bytes: 19936
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
vector<int> G[100010];
int d[2][100010];
void dfs(int x, int c, int p = -1, int depth = 0) {
    d[c][x] = depth;
    for(auto to: G[x]) {
        if(to == p) continue;
        if(c == 0)
            dfs(to, c, x, depth + 1);
        else if(d[0][x] >= depth + 1) {
            dfs(to, c, x, depth + 1);
        }
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;
    rep(i, N) d[1][i] = INF;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
   dfs(v, 0); dfs(u, 1); 
    int ans = 0;
    rep(i, N) {
        //cout << "*" << d[0][i] << " " << d[1][i] << endl;
        if(d[1][i] != INF) ans = max(ans, d[0][i] - 1);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 12928
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 3 + 10, INF = 1e9 * 1000;
vector<vector<ll>> gr;
ll n, dist[SIZE], ans = 0;
bool used[SIZE];

bool dfs(int v, int par = -1) {
    used[v] = 1;

    ll cnt = 0;
    for (auto to : gr[v]) {
        if (!used[to]) {
            if(dfs(to)) cnt++;
        }
    }

    if (gr[v].size() == 1) return 0;

    ll needed = ll(gr[v].size() - 2) - cnt;


    ans += max(needed, 0ll);

    if (cnt + max(needed, 0ll) > 0) {
        return 1;
    } else {
        return 0;
    }
}

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

    gr.resize(n);
    for (int i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;

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

    queue<ll> q;
    q.push(0);
    used[0] = 1;

    while (!q.empty()) {
        ll v = q.front();
        q.pop();

        for (auto to : gr[v]) {
            if (!used[to]) {
                used[to] = 1;
                dist[to] = dist[v] + 1;
                q.push(to);
            }
        }
    }

    pair<ll, ll> mx = {-1, -1};
    for (int i = 0; i < n; i++) {
        mx = max(mx, {dist[i], i});
        used[i] = 0;
    }

    dfs(mx.second);
    
    cout << ans + 1;
    return 0;
}


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

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

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

    int n;
    cin >> n;

    int h[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];

    int dp[n];
    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 - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }

    cout << dp[n - 1] << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int nodemin[200005<<2],nodemax[200005<<2];
int a[200005];
void built(int v,int l,int r){
	if(l==r) {
		nodemin[v]=nodemax[v]=a[l];
		return;
	}
	int mid=l+r>>1;
	built(v<<1,l,mid);
	built(v<<1|1,mid+1,r);
	nodemin[v]=min(nodemin[v<<1],nodemin[v<<1|1]);
	nodemax[v]=max(nodemax[v<<1],nodemax[v<<1|1]);
}
pair<int,int> query(int v,int l,int r,int ql,int qr){
	if(ql<=l&&qr>=r) return make_pair(nodemin[v],nodemax[v]);
	int mid=l+r>>1;
	pair<int,int> tmp=make_pair(1e9,-1);
	if(mid>=ql) tmp=query(v<<1,l,mid,ql,qr);
	if(mid<qr){
		pair<int,int> tmp2=query(v<<1|1,mid+1,r,ql,qr);
		tmp.first=min(tmp.first,tmp2.first);
		tmp.second=max(tmp.second,tmp2.second);
	}
	return tmp;
}
bool had[200005];
int lest[200005];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	built(1,0,n-1);
	int ma=1,now=1;
	int cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]>a[i-1]) now++; else now=1;
		if(ma>=k) had[i]=1;
		if(now>ma){
			ma=now;
		}
		
		lest[i]=now;//if(lest[i]>=k) cnt=1;
	}
	cnt=1;
//	if(lest[k-1]>=k) cnt--;
//	cout<<cnt<<"md\n";
	for(int i=1;i+k-1<n;i++){
		if(!(a[i-1]<query(1,0,n-1,i,i+k-2).first&&a[i+k-1]>query(1,0,n-1,i,i+k-2).second)&&(lest[i+k-1]<k||!had[i+k-1])) cnt++;
//		if(!(a[i-1]<query(1,0,n-1,i,i+k-2).first&&a[i+k-1]>query(1,0,n-1,i,i+k-2).second)) cout<<i<<"~"<<i+k-1<<" "<<a[i-1]<<" "<<query(1,0,n-1,i,i+k-2).first<<" "<<query(1,0,n-1,i,i+k-2).second<<" "<<lest[i+k-1]<<" "<<had[i]<<endl;
	}
	cout<<cnt;
}

Measured memory_bytes: 7168
S = str(input())
N = len(S)
cut1 = S[0:int((N-1)/2)]
cut2 = S[int((N+3)/2-1):N]
if S==S[::-1] and cut1==cut1[::-1] and cut2==cut2[::-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38512
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readUint64() uint64 {
	i, err := strconv.ParseUint(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------
var (
	memoB = make(map[int]int64)
	memoP = make(map[int]int64)
)

func calcP(L int) int64 {
	if L == 0 {
		return 1
	}
	v, ok := memoP[L]
	if ok {
		return v
	}
	v = 2*calcP(L-1) + 1
	memoP[L] = v
	return v
}

func calcB(L int) int64 {
	if L == 0 {
		return 0
	}
	v, ok := memoB[L]
	if ok {
		return v
	}
	v = 2*calcB(L-1) + 2
	memoB[L] = v
	return v
}

func calcSum(L int) int64 {
	return calcB(L) + calcP(L)
}

func main() {
	defer stdout.Flush()

	N := readInt()
	X := readInt64()
	println(calc(N, X))
}

func calc(L int, X int64) int64 {
	if X <= 0 {
		return 0
	}
	N := calcSum(L)
	if N < X {
		panic(fmt.Sprintln(L, N, X))
	}
	if N == X {
		return calcP(L)
	}
	M := (N-3)/2 + 2
	if M <= X {
		res := 1 + calcP(L-1)
		if M < X {
			res += calc(L-1, X-M)
		}
		return res
	}
	// X < M
	return calc(L-1, X-1)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
  string a; cin>>a;
  bool count=false;
  int ans=0;
  int ansm=0;
  
  rep(i, a.size()){
    if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G'){
      count=true;
      ans++;
      ansm=max(ans,ansm);
      }
    else{
      if(count){count=false;
                ansm=max(ans,ansm);
                ans=0;}
    }
  }
  
  cout<<ansm<<endl;

}



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

p = [int(input()) for _ in range(n)]


# 連続している最大値を求める

lengths = {}
for pn in p:
    if pn in lengths:
        lengths[pn+1] = lengths[pn] + 1
    else:
        lengths[pn+1] = 1
    
max_count = max(lengths.values())
print(n-max_count)


Measured memory_bytes: 40480
#include <bits/stdc++.h>
using namespace std;
static const long int MOD = 1000000007;
 
int main() {
  int H, W;
  cin >> H >> W;
  char grid[H + 1][W + 1];
  long int d[H + 1][W + 1];
  for (int i = 0; i <= H; i++)
    for (int j = 0; j <= W; j++)
      d[i][j] = 0;
  for (int i = 1; i <= H; i++)
    for (int j = 1; j <= W; j++)
      cin >> grid[i][j];
  d[1][1] = 1;
  for (int i = 1; i <= H; i++)
    for (int j = 1; j <= W; j++) {
      if (i * j == 1 || grid[i][j] == '#') continue;
      d[i][j] = (d[i - 1][j] + d[i][j - 1]) % MOD;
    }
  cout << d[H][W] << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i=0; i<3*N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  long long ans = 0;
  for(int i=N; i<3*N; i+=2){
    ans += a.at(i);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
int main(){
ll n;
cin>>n;
vector<ll>a;
ll ruiseki=1;
while(1){
    if(n%abs(ruiseki*2)!=0){
        a.push_back(1);
        n=n-ruiseki;
    }else{
        a.push_back(0);
    }
    if(n/abs(ruiseki*2)==0){
        break;
    }
        ruiseki*=(-2);
}

for(int i=a.size()-1;i>=0;i--){
    cout<<a[i];
}
}







Measured memory_bytes: 256
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let k: usize = sc.read();

    if k == 0 {
        println!("{}", n * n);
        return;
    }

    let mut ans = 0;
    for b in (k + 1)..(n + 1) {
        let unit = b - 1 - k + 1;

        let max = (n + 1) / b;
        ans += unit * max;
        if max * b + k <= n {
            ans += n - (max * b + k) + 1;
        }
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(void) {
  double a, b;
  double rad, PI;
  double S, L, h;
  int C;
  scanf("%lf %lf %d", &a, &b, &C);

  PI = acos(-1);
  rad = C * PI / 180;

  S = 0.5 * a * b * sin(rad);
  L = a + b + (sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad)));
  h = S / (0.5 * a);

  printf("%f\n%f\n%f\n", S, L, h);

  return 0;
}



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

int main(){
    int count=0;
    string str;
    cin >> str;

    for(int i=0;i<((str.size()-2)/2);++i){
        for(int j=0;j<((str.size()-2*(i+1))/2);++j){
            if(str.at(j)==str.at((str.size()-2*(i+1))/2+j)){
                count += 1;
            }
        }

        if(count == (str.size()-2*(i+1))/2){
            cout << 2*count << endl;
            return 0;
        }
        count =0;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A;//500yen
    int B;//100yen
    int C;//50yen
    int X;
    int i,j,k;
    int count;
    cin >> A >> B >> C >> X ;
    count = 0;
    for (i = 0; i <= A; i++){
        for (j = 0; j <= B; j++){
            for (k = 0; k <= C; k++){
                if(500*i+100*j+50*k == X){
                    count++;
                }
            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
class program
{
  static void Main(string[] args)
  {
    int N = int.Parse(Console.ReadLine());
    string[] s_wk = Console.ReadLine().Split(' ');
    List<int> i_lst = new List<int>();
    foreach(string st in s_wk)
    {
      i_lst.Add(int.Parse(st));
    }
    int result = 1;
    int highest = i_lst[0];
    for( int i = 1 ; i < i_lst.Count ; i++ )
    {
      if( i_lst[i] >= highest )
      {
        highest = i_lst[i];
        result++;
      }
    }
    Console.WriteLine(result);
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=i+1;j<s.size();j++){
      if(s[i]==s[j]){
     cout<<"no"<<endl;
      return 0;
      }
    }
  }
  cout<<"yes"<<endl;
  return 0;
}

Measured memory_bytes: 256