akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int a,b;cin >> a >> b;
    for (int i = 1; i <= 1000000; i++) {
        if(8 * i / 100 == a && i / 10 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

typedef long long LL;

const int N=200000;
const LL INF=(1LL<<60)-1;

int n;
LL a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%lld",&a[i]);
	a[i]+=a[i-1];
  }
}

LL ans;

void Get_ans(){
  ans=INF;
  for (int i=1;i<n;++i){
	LL x=a[i],y=a[n]-a[i];
	ans=min(ans,abs(x-y));
  }
}

void work(){
  Get_ans();
}

void outo(){
  printf("%lld\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 5268
using System;

namespace Character
{
    class Toggling_Cases
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().ToCharArray();
            for (int i = 0; i < array.Length; i++)
            {
                if (char.IsUpper(array[i])) array[i]=char.ToLower(array[i]);
                else if (char.IsLower(array[i])) array[i] = char.ToUpper(array[i]);
            }
            Console.WriteLine(array);
        }
    }
}

Measured memory_bytes: 9152
table=[True for i in range(100000+1)]
table[0]=False
table[1]=False
for i in range(2,100000+1):
    for j in range(2,100000//i+1):
        table[i*j]=False
cnt=[0 for _ in range(100000+1)]
for i in range(1,100000+1):
    cnt[i]=cnt[i-1]
    if i%2==1 and table[i]==True and table[(i+1)//2]==True:
        cnt[i]+=1

Q=int(input())
lr=[list(map(int,input().split())) for _ in range(Q)]
for i in range(Q):
    print(cnt[lr[i][1]]-cnt[lr[i][0]-1])


Measured memory_bytes: 29112
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const keys = this.keys;
    const res = keys[0];
    keys[0] = keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys;
    const n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(keys[left]) > Number(keys[largest])) largest = left;
      if (right < n && Number(keys[right]) > Number(keys[largest])) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()|0}\n`; break;
    }
  });
  process.stdout.write(str);
})();




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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define zeroend __builtin_ctz
#define ones __builtin_popcount
#define ends "\n"
#define space ' '
typedef long long ll;
typedef pair<int, int> pii;

/*
void solve(int i, int j, string s){
	if(i==0)
		ans.insert(s2.substr(0, j)+s);
	else if(j==0)
		ans.insert(s1.substr(0, i)+s);
	else if(s1[i-1]==s2[j-1])
		solve(i-1, j-1, s1[i-1]+s);
	else{
		if(dp[i-1][j]<=dp[i][j-1])
			solve(i-1, j, s1[i-1]+s);
		if(dp[i-1][j]>=dp[i][j-1])
			solve(i, j-1, s2[j-1]+s);
	}
}*/


/*
	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	for(int i=1; i<n; ++i){
		for(int j=0; j<i; ++j){
			if(a[j]>a[i]&&low[i]<high[j]+1)
				low[i]=high[j]+1;
			else if(a[j]<a[i]&&high[i]<low[j]+1)
				high[i]=low[j]+1;
		}
		ans=max({ans, low[i], high[i]});
	}

	cout << ans << ends;


*/

const int N = 100, N2=1e5, M = 1e9+7;

bool dp[N2+1];
//array<ll, 3> dp;
//set<string> ans;
//vector<int> low(N, 1), high(N, 1);
ll a[N];

ll n, x;

int main(){
	cin >> n >> x;
	for(int i=0; i<n; ++i)
		cin >> a[i];

	for(int i=1; i<=x; ++i){
		for(int j=0; j<n; ++j){
			if(a[j]<=i)
				dp[i]|=!dp[i-a[j]];
		}
	}

	cout << (dp[x]?"First":"Second") << ends;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	clock_t start = clock();

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1000000007;
	//constexpr ll P = 998244353;

	ll n;
	cin >> n;
	vector<ll> x(n), y(n);
	for (ll i = 0; i < n; i++) cin >> x[i] >> y[i];

	vector<vector<ll>> v(n), w(n);
	for (ll i = 0; i < n; i++) {
		v[i] = {x[i] + y[i], i};
		w[i] = {1000000000 - x[i] + y[i], i};
	}

	sort(ALL(v));
	sort(ALL(w));

	ll ans = v[n - 1][0] - v[0][0], i = w[0][1], j = w[n - 1][1];
	ans = max(ans, abs(x[i] - x[j]) + abs(y[i] - y[j]));
	cout << ans << endl;
}

Measured memory_bytes: 28332
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def vacation(N,act):
    lastact =[]
    dp=[0,max(act[0])]*(N+1) #[i]日目のActivity で得られる最大幸福量
    
    return 0

#input


N,=pin()
S=sorted([int(input()) for i in range(N)])
Smod=[val%10 for val in S]
debug(S)
debug(Smod)
ans=sum(S)
if sum(Smod)==0:#directly includes all element is 10*(something)
    ans=0#corner case
elif sum(Smod)%10==0:
    for i in range(N):
        if Smod[i]!=0:
            ans-=S[i]
            break
print(ans)
    
    
#output
#print(solution(H,N))
#print(["No","Yes"][cond])



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

long long mod = 1e9+7;

long long function1(long long x){
	int i;
	long long y=1;
	for(i=1;i<=x;i++){
		y *= i;
		y %= mod;
	}
	return y;
}
int main(void){
	long long N,M;
	long long A,B;
	scanf("%lld%lld",&N,&M);
	long long ans = 0;
	A = function1(N) % mod;
	B = function1(M) % mod;
	if(N==M){	
		ans = 2*A;
		ans %=mod;
		ans *= B;
		ans %=mod;
	}else if(abs(N-M)==1){
		ans = A*B;
		ans %=mod;
	}else{
		ans = 0;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,N) for(int i = 0; i < (int)(N); ++i)
#define ALL(v) (v).begin(), (v).end()
typedef long long Int;
template<class T> void pv(T a, T b){for(T i=a;i!=b;++i)cout<<*i<<" ";cout<<endl;}

int table[10][12 * 60 * 60 + 10];

int encode(int hh, int mm, int ss) {
        hh /= 5;
        return hh * 3600 + mm * 60 + ss;
}

string decode(int t) {
        static char buf[128];
        int hh = t / 3600; t %= 3600;
        int mm = t / 60;
        int ss = t % 60;
        sprintf(buf, "%02d:%02d:%02d", hh, mm, ss);
        return buf;
}

bool valid(int a[3] ) {
        int hh = a[0];
        int mm = a[1];
        int ss = a[2];
        
        int dm = mm / 12;
        int rh = hh % 5;
        if( dm != rh ) return false;
        return true;
}

void paint(int *array, int a[3]) {
        for(int i = 0; i < 60; i++) {
                if( valid(a) ) {
                        array[encode(a[0], a[1], a[2])] = 1;
                }
                for(int j = 0; j < 3; j++) {
                        a[j]++;
                        if( a[j] == 60 ) a[j] = 0;
                }
        }
}

int main() {
        for(int N; cin >> N, N; ) {
                memset(table, 0, sizeof(table));
                REP(i, N) {
                        int a[3];
                        REP(j, 3) cin >> a[j];
                        sort(a, a + 3);
                        do {
                                paint(table[i], a);
                        } while(next_permutation(a, a + 3));
                }

                
                int beg = 0, end = 12 * 60 * 60 + 10;
                int in[10] = {};
                int count = 0;
                
                int left = 0;
                int right = 0;
                REP(i, N) if( table[i][0] ) {
                        in[i]++;
                        if( in[i] == 1 ) count++;
                }
                while( right < 12 * 60 * 60 ) {
                        if( count == N ) {
                                if( end - beg > right - left ) {
                                        beg = left;
                                        end = right;
                                }
                                REP(i, N) if( table[i][left] ) {
                                        in[i]--;
                                        if( in[i] == 0 ) --count;
                                }
                                ++left;
                        } else {
                                ++right;
                                REP(i, N) if( table[i][right] ) {
                                        if( in[i] == 0 ) count++;
                                        in[i]++;
                                }
                        }
                }
                cout << decode(beg) << ' ' << decode(end) << endl;
        }
        return 0;
}

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

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = a[0];
 
  for (int i = 1; i < n; i++) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3964
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N; cin >> N;
    string s, t; cin >> s >> t;
    REPS(i, N){
        bool okay = true;
        REP(j, N){
            if(i+j >= N) break;
            if(s[i + j] != t[j])
                okay = false;
        }
        if(okay){
            cout << N + i << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

long long f(int n, long long m) {
    map<tuple<int, int, int>, long long> mem;
    function<long long (int, int, int)> calc = [&](int progress, int num, int jumps) {
        if (jumps > n) return 0LL;
        if (num == 3 * n) return 1LL;
        auto p = make_tuple(progress, num, jumps);
        if (mem.find(p) != mem.end()) return mem[p];
        long long answer = 0;
        if (progress > num) {
            answer += calc(progress, num + 1, jumps) * (progress - num);
        }
        for (int i = 1; i <= 3 && progress + i <= 3 * n; ++i) {
            answer += calc(progress + i, num + 1, jumps + (i > 1));
        }
        return mem[p] = answer % m;
    };
    return calc(0, 0, 0);
}

long long g(int n, long long m) {
    vector<vector<long long>> mem(3*n + 1, vector<long long>(6*n + 3, -1LL));
    function<long long (int, int)> h = [&](int s, int d) {
        // s is the sum
        // d is #1 - #2
        if (s < abs(d)) return 0LL;
        if (s == 0) return 1LL;
        if (mem[s][3 * n + 1 + d] != -1) return mem[s][3 * n + 1 + d];
        long long answer = 0;
        answer += h(s - 1, d - 1);
        answer += h(s - 2, d + 1) * (s - 1);
        answer += h(s - 3, d) * (s - 1) % m * (s - 2);
        answer %= m;
        return mem[s][3 * n + 1 + d] = answer;
    };
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += h(3 * n, i);
    }
    total %= m;
    return total;
}

long long h(int n, long long m) {
    vector<vector<long long>> xs(3*n + 1, vector<long long>(6*n + 3, 0LL));
    xs[0][3 * n + 1] = 1LL;
    for (int s = 1; s <= 3 * n; ++s) {
        for (int d = 1; d <= 6 * n + 1; ++d) {
            long long answer = 0;
            answer += xs[s - 1][d - 1];
            if (s >= 2) {
                answer += xs[s - 2][d + 1] * (s - 1);
            }
            if (s >= 3) {
                answer += xs[s - 3][d] * (s - 1) % m * (s - 2);
            }
            answer %= m;
            xs[s][d] = answer;
        }
    }
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += xs[3 * n][3 * n + 1 + i];
    }
    total %= m;
    return total;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long m;
    cin >> n >> m;
    auto t0 = clock();
    // cout << f(n, m) << endl;
    cout << g(n, m) << endl;
    // cout << h(n, m) << endl;
    auto t1 = clock();
    cerr << "Time used: " << t1 - t0 << " ms" << endl;
    return 0;
}


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


using namespace std;

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

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;

void solve(){
	int n,h;
	cin>>n>>h;
	vector<int>a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	sort(all(a));
	sort(all(b));
	ll ans=0,mx=a[n-1];
	while(h>0 && !b.empty()){
		if(b.back()<=mx)break;
		ans++;
		h-=b.back();
		b.pop_back();
	}
	if(h>0)ans+=(h+mx-1)/mx;
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 3960
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int const mod = 1e9+7;

inline int safe_mul(const int x, const int y) {
    return x * 1LL * y % mod;
}

inline void safe_add(int& x, const int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}



bool check(string a) {
    if (a.find("AGC") != string::npos)
        return false;

    for (int i = 0; i < 3; ++i) {
        swap(a[i], a[i + 1]);
        if (a.find("AGC") != string::npos)
            return false;
        swap(a[i], a[i + 1]);
    }
    return true;
}


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    map<string, int> dp = {{"ZZZZ", 1}};

    string chars = "ACGT";
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        map<string, int> ndp;
        for (const auto& pa : dp) {
            for (char c : chars) {
                string ne = pa.first.substr(1, 3);
                ne.push_back(c);
                if (check(ne))
                    safe_add(ndp[ne], pa.second);
            }
        }
        ndp.swap(dp);
    }

    int ans = 0;
    for (const auto& pa : dp)
        safe_add(ans, pa.second);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
vector<string>v;
void permute(string a, int l, int r)  
{  
    // Base case  
    if (l == r)  
         v.push_back(a);
    else
    {  
        // Permutations made  
        for (int i = l; i <= r; i++)  
        {  
  
            // Swapping done  
            swap(a[l], a[i]);  
  
            // Recursion called  
            permute(a, l+1, r);  
  
            //backtrack  
            swap(a[l], a[i]);  
        }  
    }  
}  

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i,count=0;
    cin>>n;
    int a1[n],a2[n];
    string s1,s2,s;
    for(i=0;i<n;i++)
    {
    	s.push_back(i+'a');
	}
    for(i=0;i<n;i++)
    {
    	cin>>a1[i];
    	s1.push_back(a1[i]-1+'a');
	}
	for(i=0;i<n;i++)
	{
		cin>>a2[i];
		s2.push_back(a2[i]-1+'a');
	}
	permute(s,0,n-1);
	sort(v.begin(),v.end());
	int x,y;
	for(i=0;i<v.size();i++)
	{
		if(v[i]==s1)
		x=i;
		if(v[i]==s2)
		y=i;
		
	}
	cout<<abs(x-y);
	
	
	
	
    
}

Measured memory_bytes: 2424
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
void check(int x);
bool ans=false;
int a[12]={0};
int b=0,c=0,sub;
int main(void){

	int n;
	cin>>n;
	for(int q=0;q<n;q++){
	    for(int i=0;i<12;i++){
        a[i]=0;
        }
        ans=false;
        b=0,c=0,sub=0;

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


	check(0);
	if(ans==true)cout<<"YES"<<endl;
	else if(ans==false)cout<<"NO"<<endl;


	}
	return 0;
}
void check(int x){
    if(x==10){
        ans=true;
        return;
    }

    if(a[x]>b&&a[x]>c){
        sub=b;
        b=a[x];
        //cout<<x<<'('<<b<<'.'<<c<<')'<<endl;
        check(x+1);
        b=sub;

        sub=c;
        c=a[x];
        //cout<<x<<'('<<b<<'.'<<c<<')'<<endl;
        check(x+1);
        c=sub;
    }
    else if(a[x]>b){
        sub=b;
        b=a[x];
        //cout<<x<<'('<<b<<'.'<<c<<')'<<endl;
        check(x+1);
        b=sub;

    }
    else if(a[x]>c){
        sub=c;
        c=a[x];
        //cout<<x<<'('<<b<<'.'<<c<<')'<<endl;
        check(x+1);
        c=sub;

    }
    else {

        return;
    }

}

Measured memory_bytes: 1152
class diction:
    def __init__(self):
        self.D = {}
    def insert(self,string):
        self.D[string] = True
    def find(self,string):
        try:
            if self.D[string]:print('yes')
        except KeyError:
            print('no')
            
D = diction()
for _ in range(int(input())):
    command,string = input().split()
    if command == 'insert':
        D.insert(string)
    elif command == 'find':
        D.find(string)


Measured memory_bytes: 33116
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    ll=LI()
    ll.sort(reverse=True)
    print(sum(ll[:k]))
    
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n; i++) {
        if (i == n - 1) {
            cout << 0 << endl;
            break;
        }

        int t = 0;
        for (int j = i; j < n - 1; j++) {
            if (t >= s[j]) {
                if (t % f[j] != 0) t = (t + f[j]) - (t + f[j]) % f[j];
            } else {
                t = s[j];
            }
            t += c[j];
        }

        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1e9
typedef long long ll;

#define PI acos(-1)

int a[110];

int main() {
	
	int n, d, x, sum=0;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++)cin >> a[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 101; j++) {
			if (j*a[i] + 1 > d) {
				sum += j;
				break;
			}
		}
	}
	sum += x;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)

i = n
ca = 0
cb = 0
for i in range(n):
    if i%2 == 1:
        ca += a[i]
    else:
        cb += a[i]

print(abs(ca-cb))
    

Measured memory_bytes: 3060
<?php
while( fscanf( STDIN, "%d", $n ) ){
  $cnt=0;
  for($a=0;$a<10;$a++){
    if($n<$a) break;
    for($b=0;$b<10;$b++){
      $t=$a+$b;
      if($n<$t) break;
      for($c=0;$c<10;$c++){
        $u=$t+$c;
        if($n<$u) break;
        if($n>9+$u) continue;
        ++$cnt;
      }
    }
  }
  printf("%d\n",$cnt);
}

Measured memory_bytes: 15188
from bisect import bisect_left, bisect_right

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_cs = [0] * (n + 1)
b_cs = [0] * (m + 1)

for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[i]
for i in range(m):
    b_cs[i + 1] = b_cs[i] + b[i]

ans = 0
for i in range(n + 1):
    if a_cs[i] <= k:
        cand = i
        cand += bisect_right(b_cs, k - a_cs[i]) - 1
        ans = max(ans, cand)

print(ans)


Measured memory_bytes: 111080
#include <iostream>
#include <vector>
#include <string>
#include <cassert>

using namespace std;

typedef struct _card {
    char suit;
    char value;
} card;

void print_cards(vector<card> C) 
{
    for (int i=0; i<C.size(); i++) {
        cout << C[i].suit << C[i].value;
        if (i==C.size()-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
}

vector<card> swap(vector<card> C, int a, int b)
{
    card tmp = C[a];
    C[a] = C[b];
    C[b] = tmp;

    return C;
}

vector<card> BubbleSort(vector<card> C)
{
    for (int i=0; i<C.size(); i++) {
        for (int j=C.size()-1; j>i; j--) {
            if (C[j].value < C[j-1].value) {
                C = swap(C, j, j-1);
            }
        }
    }

    return C;
}

vector<card> SelectionSort(vector<card> C)
{
    for (int i=0; i<C.size(); i++) {
        int minj = i;
        for (int j=i; j<C.size(); j++) {
            if (C[j].value < C[minj].value) {
                minj = j;
            }
        }
        C = swap(C, i, minj);
    }

    return C;
}

bool isStable(vector<card>C1, vector<card>C2)
{
    assert(C1.size() == C2.size());
    for (int i=0; i<C1.size(); i++) {
        if (C1[i].suit != C2[i].suit)
            return false;
    }

    return true;
}

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

    string str;
    vector<card> C;
    for (int i=0; i<num; i++) {
        cin >> str;
        card tmp;
        tmp.suit = str[0];
        tmp.value = str[1];
        C.push_back(tmp);
    }

    vector<card> C1, C2;
    C1 = BubbleSort(C);
    C2 = SelectionSort(C);

    print_cards(C1);
    cout << "Stable" << endl;
    print_cards(C2);
    if (isStable(C1, C2)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl; 
    }

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
const long long LLINF = 1LL << 62;
const int INF = 1LL << 30;
using namespace std;


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

	vector<int> ruiseki(N + 1);
	for (int i = 1; i <= N; i++)
	{
		cin >> ruiseki[i];
		ruiseki[i] += ruiseki[i - 1];
	}

	int min_abs = INF;
	for (int i = 0; i <= N; i++)
	{
		int tmp = abs(abs(ruiseki[N] - ruiseki[i]) - ruiseki[i]);
		if (tmp < min_abs) {
			min_abs = tmp;
		}
	}

	cout << min_abs << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll x,y,cnt1 = 1e9 + 5,cnt2 = 1e9 + 5,cnt3 = 1e9 + 5,cnt4 = 1e9 + 5;
    cin >> x >> y;
    if(x <= y)cnt1 = y - x;
    if(x * -1 <= y)cnt2 = y - x * -1 + 1;
    if(x * -1 <= y * -1)cnt3 = y * -1 - x * - 1 + 2;
    if(x <= y * -1)cnt4 = y * -1 - x + 1;
    pf(min(min(cnt1, cnt2), min(cnt3, cnt4)))
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[4010][4010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    dp[0][0] = 1;
    ll red = 0, blue = 0;
    rep(i,0,2*N){
        if(i < N){
            if(S[i] == '0'){
                red += 2;
            }else if(S[i] == '1'){
                red++; blue++;
            }else{
                blue += 2;
            }
        }
        rep(j,0,i+1){
            ll r = j;
            ll b = i - j;
            if(r < red){
                dp[i+1][r+1] += dp[i][r];
                dp[i+1][r+1] %= MOD;
            }
            if(b < blue){
                dp[i+1][r] += dp[i][r];
                dp[i+1][r] %= MOD;
            }
        }
    }
    print(dp[2*N][red]);

    
    

}

Measured memory_bytes: 123904
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
 
int main() {
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    count += r - l + 1;
  }
  cout << count << endl;
}
    

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

using ll = long long;

constexpr int INF = 1e9;

using pii = pair<int, int>;
using graph = vector<vector<int>>;

bool rec(int v, graph const& g, vector<int>& dp, vector<int> const& X) {
    if(g[v].size() == 0) {
        dp[v] = 0;
        return true;
    }

    vector<vector<int>> dp2(g[v].size() + 1, vector<int>(X[v] + 1, INF));
    dp2[0][0] = 0;
    for(int i = 0; i < (int)g[v].size(); ++i) {
        int ch = g[v][i];
        if(!rec(ch, g, dp, X)) {
            return false;
        }
        for(int j = 0; j <= X[v]; ++j) {
            if(dp2[i][j] == INF) {
                continue;
            }
            if(j + X[ch] <= X[v]) {
                dp2[i + 1][j + X[ch]] = min(dp2[i + 1][j + X[ch]], dp2[i][j] + dp[ch]);
            }
            if(j + dp[ch] <= X[v]) {
                dp2[i + 1][j + dp[ch]] = min(dp2[i + 1][j + dp[ch]], dp2[i][j] + X[ch]);
            }
        }
    }
    bool check = false;
    for(int i = 0; i <= X[v]; ++i) {
        if(dp2[g[v].size()][i] != INF) {
            dp[v] = min(dp[v], dp2[g[v].size()][i]);
            check = true;
        }
    }
    return check;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    for(int i = 0; i < N - 1; ++i) {
        int p;
        cin >> p;
        g[p - 1].push_back(i + 1);
    }
    vector<int> X(N);
    for(int i = 0; i < N; ++i) {
        cin >> X[i];
    }
    vector<int> dp(N, INF);
    if(rec(0, g, dp, X)) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 13296
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll rcount = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			rcount++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < rcount; i++) {
		if (s[i] != 'R') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

const double PI=(acos(-1));

int main(){
    int n;
    cin>>n;
    vector<int> l(n);
    int lmax=0;
    int sum=0;
    rep(i,n){
        cin>>l[i];
        lmax=max(lmax,l[i]);
        sum+=l[i];
    }
    sum-=lmax;
    if(sum>lmax)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

    

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n,m;
   cin>>n>>m;
   vll v(n);
   
   ll sum = 0;
   for(int i=0;i<n;i++)
   {
           cin>>v[i];
           sum+=v[i];
   }
   
   double req = double(sum)/(4*m);
   ll count = 0;
   for(int i=0;i<n;i++)
   {
           if(v[i]>=req)
           count++;
   }
   
   cout<<(count>=m?"Yes":"No");
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
      
        int n = Integer.parseInt(sc.next());
        TreeMap<String, Integer> map = new TreeMap<>();
        String str;
        Integer count;
        for (int i = 0; i < n; i++) {
            str = sc.next();
            if (map.containsKey(str)) {
                count = map.get(str) + 1;
            } else {
                count = 1;
            }
            map.put(str, count);
        }
        Set<Map.Entry<String, Integer>> set = map.entrySet();
        int max = 0;
        for (Map.Entry<String, Integer> e : set) {
            max = Math.max(e.getValue(), max);
        }
        for (Map.Entry<String, Integer> e : set) {
            if (e.getValue() == max) out.println(e.getKey());
        }

        out.flush();
    }
}

Measured memory_bytes: 76752
#include <stdio.h>

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

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

    int q;
    scanf("%d", &q);

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

    int cnt = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (S[j] == T[i]) {
                cnt++;
                break;
            }
        }
    }

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

    return 0;
}



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


const int N = 100005;

int nxt[N][2], idx, n, dep[N]; bool end[N];
long long l;
std::string s;

void insert(const std::string &s) {
	int p = 0;
	for (char ch : s) {
		int v = ch & 1;
		if (!nxt[p][v])
			nxt[p][v] = ++idx, dep[idx] = dep[p] + 1;
		p = nxt[p][v];
	}
	end[p] = 1;
}

long long lowbit(long long x) {return x & -x;}
long long calc(int d) {return lowbit(l - d + 1);}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> l;
	for (int i = 0; i < n; ++i)
		std::cin >> s, insert(s);
	long long ans = 0;
	for (int i = 0; i <= idx; ++i)
		if (!end[i] && (!nxt[i][0] ^ !nxt[i][1]))
			ans ^= calc(dep[i] + 1);
	std::cout << (ans ? "Alice" : "Bob") << '\n';
	return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;
int main(){
    ios;
	int n; cin >> n;
	vector<int> v(n);
	rep(i,n)
		cin >> v[i];
	ll cnt = 0;
	for(int i = 0; i < n-1; ++i){
		if(v[i+1] < v[i]){
			cnt += (v[i] - v[i+1]);
			v[i+1] += (v[i] - v[i+1]);
		}
		//deb(v[i]); deb(v[i+1]); deb(cnt);
	}
	cout << cnt;
    return 0;
}


Measured memory_bytes: 3992
#include<iostream>
using namespace std;
int main(){
	int n,i;
	scanf("%d",&n);
	long long temp;
	int a1=0,a2=0,a4=0;
	for(i=0;i<n;i++){
		scanf("%lld",&temp);
		if(temp%4==0){
			a4++;
		}else if(temp%2==0){
			a2++; 
		} else{
			a1++;
		}
	}
	if(a4>=a1){
		printf("Yes");
	}else if((a4+1)==a1&&a2==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
	cin>>n;
	int pre,now=1,pa=-1,a;
	vi sum(200100);
	rep(i,n){
		pre=now;
		cin>>a;
		if(pa-a){
			(now+=sum[a])%=1000000007;
			(sum[a]+=pre)%=1000000007;
		}
		pa=a;
	}
	cout<<now<<endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int m,S[3010][3010];
inline int power(int a,int b,int mod)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[3010],inv[3010];
inline int C(int n,int M){return 1LL*fac[n]*inv[M]%m*inv[n-M]%m;}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),ans=0;m=read();
	S[0][0]=1;
	for(int i=1;i<=n+1;i++)
	{
		for(int j=1;j<=i;j++)S[i][j]=(S[i-1][j-1]+1LL*S[i-1][j]*j%m)%m;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=1LL*fac[i-1]*i%m;inv[n]=power(fac[n],m-2,m);
	for(int i=n;i>=1;i--)inv[i-1]=1LL*inv[i]*i%m;
	int id=1;
	for(int i=0;i<=n;i++)
	{
		int uf=power(2,n-i,m),now=1,sum=0;
		for(int j=0;j<=i;j++)sum=(sum+1LL*S[i+1][j+1]*now%m)%m,now=1LL*now*uf%m;
		sum=1LL*sum*C(n,i)%m*power(2,power(2,n-i,m-1),m)%m;
		ans=(ans+(id*sum+m)%m)%m,id=-id;
	}pr2(ans);
	return 0;
}

Measured memory_bytes: 34176
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin>>n;
  cout<<0<<endl;
  string s;
  cin>>s;
  int mid;
  int l=0;
  int r=n;
  int i=0;
  while(i<20){
    i++;
    mid=(l+r)/2;
    cout<<mid<<endl;
    string ans;
    cin>>ans;
    if((mid%2==0&&ans==s)||(mid%2==1&&ans!=s)){
      l=mid;
    }else if(ans=="Vacant"){
      return 0;
    }else{
      r=mid;
    }
  }
}


Measured memory_bytes: 852
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int look_site(int i, int j, int H, int W){
    
    if (i < 0) return 0;
    if (j <0) return 0;
    if (i>=H)return 0;
    if (j >= W) return 0;
    
    return 1;
    
}

int num2of(int temp){
    
    int out = 0;
    
    while(temp%2 == 0){
        out++;
        temp/=2;
    }
    
    return out;
}


int main() {
    
    int N = in();
    
    int ans = 0;
    
    for(auto i = 0; i<N; i++){
        
        int temp;
        cin >> temp;
        
        ans += num2of(temp);
        
    }
    
    cout << ans << endl;
    return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N;
    cin>>N;
    vector<long> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    
    cout<<d.at(N/2)-d.at(N/2 -1)<<endl;
}


Measured memory_bytes: 1024
N = gets.to_i
A, B = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

num = [0, 0, 0]
ps.each do |p|
    if p <= A
        num[0] += 1
    elsif p <= B
        num[1] += 1
    else
        num[2] += 1
    end
end
puts num.min

Measured memory_bytes: 1788
n, m, r = gets.split.map(&:to_i)
g = (0..n-1).map { {} }
m.times do
  i, j, c = gets.split.map(&:to_i)
  g[i][j] = c
end

dist = Hash.new(Float::INFINITY)
dist[r] = 0
(n - 1).times do
  (0..n-1).each do |i|
    g[i].each do |j, c|
      dist[j] = [dist[j], dist[i] + c].min
    end
  end
end

has_negative_cycle = false
catch :exit do
  (0..n-1).each do |i|
    g[i].each do |j, c|
      if dist[i] + c < dist[j]
        has_negative_cycle = true
        throw :exit
      end
    end
  end
end

if has_negative_cycle
  puts 'NEGATIVE CYCLE'
else
  (0..n-1).each do |i|
    puts dist[i] == Float::INFINITY ? 'INF' : dist[i]
  end
end


Measured memory_bytes: 8944
#include<stdio.h>

int shouhi(int n,int m){
	return n*(100+m)/100;
}

int main(){
	int X,Y,s,a,b,i,A=0,B=0;
	for(i=0;i<1000;i++){
		scanf("%d %d %d",&X,&Y,&s);
		A=0;B=0;
		if((X==0)&&(Y==0)&&(s==0)){
			return 0;}
		for(a=1;a<1000;a++){
			for(b=a;b<1000;b++){
				if((shouhi(a,X) + shouhi(b,X) == s) && (shouhi(a,Y) + shouhi(b,Y) >= shouhi(A,Y) + shouhi(B,Y))){
					A = a; B = b;
				}
			}
		}
		printf("%d\n",shouhi(A,Y) + shouhi(B,Y));
	}
					
	return 0;
	}

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

int main() {
    int A, B, C; // 500 100 50

    cin >> A >> B >> C;
    int X;
    cin >> X;

    int sum = 0;
    int count = 0;

    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++) {
                if(500*i + 100*j + 50*k == X) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    for(int i = 0; i < 3; i++){
        int a,b,c;
        cin >> a >> b >> c;
        int in = a*60*60+b*60+c;
        cin >> a >> b >> c;
        int out = a*60*60+b*60+c;
        int ans = out - in;
        cout << ans/(60*60) << " ";
        ans %= 60*60;
        cout << ans/60 << " ";
        ans %= 60;
        cout << ans << endl;
    }
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n, k;
	cin >> n >> k;
	Vec sunuke(n);
	for (int i = 0; i < k; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int a;
			cin >> a;
			(sunuke.at(a - 1))++;
		}
	}
	int c = 0;
	for (auto i = sunuke.begin(); i != sunuke.end(); i++)
	{
		if (*i == 0)
			c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 3632
X, N = map(int, input().split())
p = list(map(int, input().split()))

done = False
curr_diff = 0
while not done:
    curr = []
    if X - curr_diff not in p:
        curr.append(X - curr_diff)
    elif X + curr_diff not in p:
        curr.append(X + curr_diff)
    
    if curr:
        done = True
    curr_diff += 1

print(min(curr))

Measured memory_bytes: 9196
import sys
input = sys.stdin.readline


def main():
    mod = 10**9 + 7
    x = int(input())
    counts = [0] * (x+1)
    counts[0] = 1
    for i in range(x-2):
        for num in range(3, x-i+1):
            counts[i+num] += counts[i]
            counts[i+num] %= mod

    print(counts[x])


if __name__ == "__main__":
    main()


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

int main()
{
    long double n,k,p1=0,p2=0;cin>>n>>k;
    if(k<=n) p1=(n-k+1)/n;
    for (int i = 1; i < min(n+1,k); i++) {
        long double temp=1;
        int j=i;
        while(i<=k-1){
            i=i*2;
            temp=temp/2;
        }
        p2+=temp/n;
        i=j;
    }
    std::cout<<std::fixed<<std::setprecision(10);
    cout<<p1+p2<<endl;
    
    


}


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

int main(){
  const vector<int> data= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;
  K--; // 1-indexed -> 0-indexed

  cout << data.at(K) << endl;
}


Measured memory_bytes: 256
N,Q = map(int,input().split(" "))
S = input()
a = [0] *  N
acc = [0] * N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        a[i] = 1
        acc[i] += a[i]
    acc[i+1] = acc[i]

acc[N-1] = acc[N-2]
for i in range(Q):
    l,r = map(int,input().split(" "))
    if l > 1:
        ans = acc[r-1] - acc[l-2]
    else:
        ans = acc[r-1]
    if a[r-1] == 1:
        ans -= 1
    
    print(ans)

Measured memory_bytes: 6956