akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    print(max(C-(A-B), 0))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
m = int(input())
for i in range(m):
    s = input()
    if s not in d:
        continue
    else:
        d[s] -= 1
print(max(max(d.values()),0))

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

int main()
{
    long long N;
    std::cin >> N;
    std::vector<long long> A(N);
    std::vector<long long> map(N+1, 0);

    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
        map[A[i]]++;
    }

    long long total = 0;
    for (int k = 1; k <= N; k++)
        total += map[k] * (map[k]-1) / 2;

    for (int k = 1; k <= N; k++)
        std::cout << total - (map[A[k-1]] - 1) << std::endl;

    return 0;
}

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

int main(){
int h,w;cin>>h>>w;
string s[205];
for(int i=0;i<h;i++){
	string x;cin>>x;
 s[2*i]=x;s[2*i+1]=x;
}
for(int i=0;i<2*h;i++)cout<<s[i]<<endl;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007 , __ = _<<1;
const char *YES = "Yes" , *NO = "No";

int to[__],ne[__],he[_]={0},du[_]={0},ecnt=1;
inline void adde(int a,int b){du[a]++,to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,m;

inline void dfs(int x,int ff,int tar,int ban)
{
	if(ff && x==tar){puts(YES);exit(0);}
	if(x==ban)return;
	for(int i=he[x];i;i=ne[i])if(to[i]!=ff)dfs(to[i],x,tar,ban);
}

int main()
{
	n=ty(),m=ty();
	for(int i=1,a,b;i<=m;i++)a=ty(),b=ty(),addde(a,b);

	int dfa=0,dfb=0,dfc=0,dsx=0;
	for(int i=1;i<=n;i++)
	{
		if(du[i]&1){puts(NO);return 0;}
		if(du[i]>=6)dsx=1;
		if(du[i]==4){dfc++;if(dfc==1)dfa=i;else dfb=i;}
	}

	if(dsx || dfc>=3){puts(YES);return 0;}
	if(dfc<=1){puts(NO);return 0;}
	dfs(dfa,0,dfa,dfb);
	puts(NO);

	return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

int main(){
  int N,M,i;
  int a_i;
  int b_i;
  int bs;
  int flag=0;
     
  scanf("%d %d",&N,&M);
  bs=N+1;
  
  if(N%2==1){
    for(i=1;i<=M;i++){
      a_i=i;
      b_i=bs-1;
      bs=bs-1;
    printf("%d %d\n",a_i,b_i);
    }
  } else {
      for(i=1;i<=M;i++){
	  a_i=i;
        if(i==(M+3)/2 && flag==0){
          bs=bs-1;
          flag=1;
        }
      b_i=bs-1;
      bs=bs-1;
    printf("%d %d\n",a_i,b_i);
    }
  }
  
 return 0; 
}

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

#define MAX 1000

int LCS(int [][MAX + 1],char [],char []);

int main(){
  int c[MAX + 1][MAX + 1],q;
  char X[MAX + 1],Y[MAX + 1];
  int i;
  int ans;

  scanf("%d",&q);

  for (i = 0;i < q;i++){
    scanf("%s %s",&X[1],&Y[1]);
    ans = LCS(c,X,Y);

    printf("%d\n",ans);
  }

  return 0;
}

int LCS(int c[][MAX + 1],char X[],char Y[]){
  int m,n;
  int i,j;
  
  m = strlen(&X[1]);
  n = strlen(&Y[1]);

  for (i = 0;i <= m;i++)
    c[i][0] = 0;

  for (j = 1;j <= n;j++)
    c[0][j] = 0;

  for (i = 1;i <= m;i++)
    for (j = 1;j <= n;j++){
      if (X[i] == Y[j])
	c[i][j] = c[i - 1][j - 1] + 1;

      else if (c[i - 1][j] >= c[i][j - 1])
	c[i][j] = c[i - 1][j];

      else
	c[i][j] = c[i][j - 1];
    }

  return c[m][n];
}



Measured memory_bytes: 5616
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  int n, tmp;
  scanf("%d", &n);
  int L[n], length = 0;
  rep(i, n){
    scanf("%d", &tmp);
    if(i == 0){
      L[0] = tmp;
    }else{
      if(L[length] < tmp){
        length++;
        L[length] = tmp;
      }else{
        rep(k, length+1){
          if(L[k] >= tmp){
            L[k] = tmp;
            break;
          }
        }
      }
    }
  }

  printf("%d\n",length+1);

  return 0;







}


Measured memory_bytes: 3544
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	LL q, h, s, d;
	LL n;
	LL x;
	for (int i = 0; i < 3; i++) {
		LL a;
		scanf("%lld", &a);
		LL temp;
		if (i == 0) temp = a * 4;
		else if (i == 1) temp = a * 2;
		else temp = a;
		if (i == 0) x = temp;
		else x = MIN(x, temp);
	}
	scanf("%lld", &d);
	scanf("%lld", &n);

	LL ans = 0;
	if (d < 2 * x) {
		ans = (n / 2)*d + (n % 2)*x;
	}
	else {
		ans = n * x;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<ll> h(n);
    set<ll> G[n];

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

    for (int i = 0; i < m; i++)
    {
        int a, b;

        cin >> a >> b;
        a--;
        b--;

        G[a].insert(b);
        G[b].insert(a);
    }

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        bool flag = true;

        if (G[i].size())
        {
            for (auto x : G[i])
            {
                if (h[i] <= h[x])
                {
                    flag = false;
                }
            }

            if (flag)
            {
                ans++;
            }
        }
        else
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 18044
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B, M;
	cin >> A >> B >> M;

	vector<int> av(A), bv(B);
	rep(i, 0, A)
	{
		cin >> av[i];
	}
	rep(i, 0, B)
	{
		cin >> bv[i];
	}

	int x, y, c;
	int ans = INF;
	rep(i, 0, M)
	{
		cin >> x >> y >> c;
		x--, y--;
		chmin(ans, av[x] + bv[y] - c);
	}

	sort(all(av));
	sort(all(bv));
	chmin(ans, av[0] + bv[0]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAXN=200000;
int n,R[MAXN+5];
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>R[i];
    int maxv=-2000000000;
    int minv=R[0];
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3920
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

bool isPrime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}


void solve()
{
    ll n;
    cin>>n;
    if(n%2==0 or n%5==0){
        cout<<-1<<endl;
        return;
    }
    else{
        ll num=7,cnt=1;
        while(1){
            if(num%n==0){
                cout<<cnt<<endl;
                break;
            }
            num=(num%n)*10+7;
            cnt++;
        }
    }
    
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s_1, s_2, s_3, s;
  cin >> s;
  s_1 = s/100;
  s_2 = s/10%10;
  s_3 = s%10;
  cout << s_1+s_2+s_3 <<endl;
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;


#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)


#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define MAX                     1e9 + 9

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


int main()
{
    taratari

    int n;
    cin>>n;

    int a[n];

    int odd=0;
    //int even=0;

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

        if(a[i]%2==1)
            odd++;

    }

    if(odd%2==0)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }


    return 0;

}



Measured memory_bytes: 4004
#include <string>
#include <iostream>
using namespace std;
int main(){
	int r, g, b;
	cin >> r >> g >> b;
	if((g * 10 + b) % 4 == 0){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  var output = 0;
  var now = 1;
  for(var i = 0; i < N; i++){
    if(list[i] == now){
      now++;
    }else{
      output++;
    }
  }
  myout((output == N) ? -1 : output);
}


Measured memory_bytes: 46040
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int n,q; cin >> n >> q;
    string s; cin >> s;
    int si = (int)s.size();
    vector<int> cnt(si+1); cnt[0] = 0; cnt[1] = 0;
    for(int i = 1; i < si; i++){
        cnt[i+1] = cnt[i];
        if(s[i-1] == 'A' && s[i] == 'C') cnt[i+1]++;
    }
    vector<int> ans(q);
    rep(i,q){
        int x,y; cin >> x >> y;
        ans[i] = cnt[y]-cnt[x];
    }
    for(int i: ans) cout << i << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
 string s;
 cin>>s;
 int ans=0;
 rep(i,0,s.length()-1)
 {
 	 if(s[i]-'0'+s[i+1]-'0'==1)
 	 continue;
 	 if(s[i]=='0')s[i+1]='1';
 	 else s[i+1]='0';
 	 ans++;
 }
 cout<<ans;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MP make_pair
#define PB emplace_back
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
	x=0;int f=0;char ch=getchar();
	while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar();
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x=f?-x:x;
}
const int N=20+5;
int L,i,j,m,POW[N];
vector<pair<int,int> >G[N];
int main(){
	read(L);
	int x=1,n=1;
	for (;x<L;x*=2) n++;
	if (x>L) n--;
	for (POW[0]=1,i=1;i<=20;i++) POW[i]=POW[i-1]*2;
	for (int i=1;i<n;i++){
		G[i].PB(MP(i+1,0));
		G[i].PB(MP(i+1,POW[i-1]));
		m+=2;
	}
	if (L>POW[n-1]){
		int tmp=L-1;
		for (i=0;i<n-1;i++){
			if ((L-1)&(1<<i)){
				tmp^=(1<<i);
				G[i+1].PB(MP(n,tmp));
				m++;
			}
		}
		G[1].PB(MP(n,L-1)),m++;
	}
	printf("%d %d\n",n,m);
	for (i=1;i<=n;i++){
		for (j=0;j<(int)G[i].size();j++){
			int v=G[i][j].first,w=G[i][j].second;
			printf("%d %d %d\n",i,v,w);
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> map = new TreeMap<>();
        for(int i = 1; i < N+1; i++) {
            int key = sc.nextInt();
            map.put(key, i);
        }
        for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
            int val = entry.getValue();
            System.out.print(val + " ");
        }
    }
}


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

#define N 100000

int main(void){
    bool prime[N+1];
    prime[0]=prime[1]=!false;
    for (size_t i = 2; i*i <= N; i++)
    {
        if (!prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=!false;
            }
        }
    }
    int likeCnt[N+1];
    for (size_t i = 3; i <= N; i+=2)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&!prime[i]&&!prime[(i+1)/2]) likeCnt[i]++;
        likeCnt[i+1]=likeCnt[i];
    }
    /**************************************/
    int q;
    scanf("%d", &q);
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", likeCnt[r] - likeCnt[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
x = [list(map(str, input().split())) for _ in range(N)]
x_new = []

for i in range(N):
  x_new.append([i+1, x[i][0], int(x[i][1])])
  
x_new.sort(key=lambda x: x[2], reverse=True)
x_new.sort(key=lambda x: x[1])

for j in x_new:
  print(j[0])

Measured memory_bytes: 3064
from collections import deque
 
# 1から初めて、xがあるとき10x、x+1のいずれかが行えるとしてqueue
 
K = int(input())
q = deque()
q.append((1,1)) # 各桁の和、modulo K
visited = [False]*K
 
ans = 0
 
while ans == 0:
  s,x = q.popleft()
  if visited[x]:
    continue
  visited[x] = True
  if x == 0:
    ans = s
    break
  q.appendleft((s,(10*x)%K))
  q.append((s+1,(x+1)%K))
 
print(ans)

Measured memory_bytes: 14444
s = list(input())
k = int(input())
ls = list("abcdefghijklmnopqrstuvwxyz")
ls.sort(reverse=True)
ls = ["a"] + ls[:-1]
for i in range(len(s)):
    if i != len(s)-1:
        if k >= ls.index(s[i]):
            k -= ls.index(s[i])
            s[i] = "a"
        else:
            continue
    else:
        k %= 26
        s[-1] = ls[(ls.index(s[-1])-k)%26]
print("".join(s))

Measured memory_bytes: 9876
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int n,k;LL ans;
int find(int v)
{
	int l=1,r=n*2/k+1;
	while(l<r)
	{
		int mid=l+r>>1;
		if(1ll*k*mid<1ll*v)l=mid+1;
		else r=mid;
	}
	return l*k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int val=find(i*2)-i,tot;tot=(n-val)/k+1;
		if(val*2%k)continue;if(n-val<0)continue;
		if(val!=i)ans+=1ll*tot*3+1ll*(tot-1)*tot/2*6;
		else ans+=1ll+1ll*(tot-1)*2*3+1ll*(tot-1)*(tot-2)/2*6;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> mp;
    string S[100010];
    rep(i, N) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        mp[S[i]]++;
    }
    ll ans = 0;
    rep(i, N) {
        ans += (mp[S[i]] - 1);
    }
    cout << ans / 2 << endl;


    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K;
  string S;
  cin>>N>>K>>S;
  for(int i=0;i<N;i++){
    if(i==K-1)cout<<(char)(S[i]-'A'+'a');
    else cout<<S[i];
  }
  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for A in range(a+1):
  for B in range(b+1):
    for C in range(c+1):
      if 500*A + 100*B + 50*C == x:
        cnt = cnt + 1

if cnt > 0 :
  print(cnt)
else:
  print(0)

Measured memory_bytes: 3064
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int h, w;
    cin >> h >> w;
    vector a_s(h, vector(w, 0)), c_s(h, vector(w, 0));
    rep(y, h)
    {
        rep(x, w)
        {
            cin >> a_s[y][x];
        }
    }
    rep(y, h)
    {
        rep(x, w)
        {
            cin >> c_s[y][x];
            c_s[y][x] = abs(c_s[y][x] - a_s[y][x]);
        }
    }

    constexpr int dmax = 81 * 81;
    // dp[y][x][d] = 偏りをdにできるか?
    vector dp(h, vector(w, vector(dmax, false)));
    dp[0][0][c_s[0][0]] = true;
    rep(y, h)
    {
        rep(x, w)
        {
            rep(d, dmax)
            {
                if (not dp[y][x][d])
                {
                    continue;
                }
                if (y + 1 < h)
                {
                    int c = c_s[y + 1][x];
                    if (c + d < dmax)
                    {
                        dp[y + 1][x][c + d] = true;
                    }
                    dp[y + 1][x][abs(c - d)] = true;
                }
                if (x + 1 < w)
                {
                    int c = c_s[y][x + 1];
                    if (c + d < dmax)
                    {
                        dp[y][x + 1][c + d] = true;
                    }
                    dp[y][x + 1][abs(c - d)] = true;
                }
            }
        }
    }
    int ans = dmax;
    rep(d, dmax)
    {
        if (dp[h - 1][w - 1][d])
        {
            chmin(ans, d);
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ok = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') ok++;
    }
    cout << (8 <= 15 - s.size() + ok ? "YES" : "NO") << endl;
    return 0;
}

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

int main() {
	int N, ans;
	double T, A, H[1000], min = DBL_MAX;
	cin >> N >> T >> A;
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
		H[i] = T - H[i] * .006;
		if (fabs(A - H[i]) < min) {
			min = fabs(A - H[i]);
			ans = i + 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int qq = 2e5 + 10;
int a[qq], b[qq];

int main(){
	int n;	scanf("%d", &n);
	REP(i, 1, n){
		scanf("%d", a + i);
	}
	int l = 1, r = n;
	int cnt = 1, p = n;
	for(int i = n; i >= 1; --i){
		if(cnt & 1)	b[l++] = a[p--];
		else	b[r--] = a[p--];
		cnt++;
	}
	REP(i, 1, n - 1){
		printf("%d ", b[i]);
	}
	printf("%d\n", b[n]);
	return 0;
}

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

int N;
int a[100005];

int main() {
	
	cin>>N; 
	
	int Mx=0,Mn=1234567;
	
	for(int i=0; i<N; i++){
		cin>>a[i];
		Mx=max(Mx,a[i]);
		Mn=min(Mn,a[i]);
		
	}
	
	if(Mx-Mn>=2){
		cout<<"No"<<endl;
	}
	
	if(Mx-Mn==0){
		if(a[0]==N-1||2*a[0]<=N) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	if(Mx-Mn==1){
		
		int cnt=0;
		
		for(int i=0; i<N; i++){
			if(a[i]==Mn) cnt++;
		}
		
		if(2*Mx-cnt<=N&&Mx-cnt>=1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
if max(l) <= min(r):
    print(min(r)-max(l)+1)
else:
    print(0)

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

using namespace std;


int main(){
map<string,int> m;
m.insert(pair<string,int>("AC",0));
m.insert(pair<string,int>("WA",0));
m.insert(pair<string,int>("TLE",0));
m.insert(pair<string,int>("RE",0));
int n;cin>>n;
for(int i=0;i<n;i++){
	string s;cin>>s;
	m[s]++;
	
}

	printf("AC x %d\n",m["AC"]);
	printf("WA x %d\n",m["WA"]);
	printf("TLE x %d\n",m["TLE"]);
	printf("RE x %d\n",m["RE"]);

	return 0;
}




Measured memory_bytes: 3704
s = input().split()
a = int(s[0])
b = int(s[1])
k = int(s[2])

if a > b:
  l = range(a,0,-1)
else:
  l = range(b,0,-1)

count = 0
for i in l:
  if a % i == 0 and b % i == 0:
    count += 1
    
  if count == k:
    print(i)
    break

Measured memory_bytes: 3064
use proconio::*;

fn main() {
    input!{
        n: usize,
    }

    println!("{}", match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => "aaa",
    });
}


Measured memory_bytes: 2140
Scanf.scanf "%d %d" (fun d g ->
    let pc = Array.init d (fun _ -> Scanf.scanf " %d %d" (fun p c -> p, c)) in

    let rec loop bits mi =
        let rec loop2 j bits score count =
            if bits = 0 then score, count else
                let p,c = pc.(j) in
                if bits land 1 = 1 then loop2 (j + 1) (bits lsr 1) (score + 100 * (j + 1) * p + c) (count + p)
                                   else loop2 (j + 1) (bits lsr 1) score count
        in
        let rec find_bits i =
            if i < 0 then i else
                if (1 lsl i) land bits = 0 then i else find_bits (i - 1)
        in
        if bits < 0 then mi else
            let score, count = loop2 0 bits 0 0 in
            let mi = if score >= g then min mi count else
                let k = find_bits (d - 1) in
                if k < 0 then mi else
                    let p, _ = pc.(k) in
                    let kk = (k + 1) * 100 in
                    let q = (g - score + kk - 1) / kk in
                    if q < p then min mi (count + q) else mi
            in
            loop (bits - 1) mi
    in
    loop ((1 lsl d) - 1) max_int |> Printf.printf "%d\n"
)

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


using namespace std;

#define N 1005

int k, n;

inline int read();

int main() {
	k = read(), n = read();
	for(int i = n - k + 1; i <= n + k - 1; ++i) printf("%d ", i);
	return 0;
}

inline int read() {
	int x = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9') (ch == '-') && (t = -1), ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
	return x * t;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n, b;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n-1; i++){
    cin >> b;
    a[b-1]+=1;
  }
  for(int i=0; i<n; i++)
    cout << a[i] << endl;
  return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, s,maxn=1000000000;
	cin >> n >> k >> s;
	if (s == maxn)
		maxn -= 1;
	int first = 1;
	for (int i = 0; i < k; i++)
	{
		if (first == 1)
		{
			cout << s;
			first = 0;
		}
		else
			cout << ' ' << s;
	}
	for (int i = 0; i < n - k; i++)
	{
		if (first == 1)
		{
			cout << maxn;
			first = 0;
		}
		else
			cout << ' ' << maxn;
	}
}

Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
using namespace std;
long long a,b;
int main(){
	scanf("%lld%lld",&a,&b);
	if(a<=0&&b>=0)printf("Zero\n");
	else if(a>0)printf("Positive\n");
	else if(b<0){
		if((b-a+1)%2)printf("Negative\n");
		else printf("Positive\n");
	}
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 20001


typedef struct stack{
  int f;
  int s;
} Sta;

void push(int S[], int x, int *top){
  S[(*top)++] = x;
}

int pop(int S[], int *top){
  (*top)--;
  return S[*top];
}

void push2(Sta S[], int x, int y, int *top){
  S[*top].f = x;
  S[(*top)++].s = y;
}

void uni(Sta S[], int *top){
  int i;

  for( i = (*top)-1 ; i > 0 ; i-- ){
    if( S[i].f < S[i-1].f ){
      (*top)--;
      S[i-1].f = S[i].f;
      S[i-1].s += S[i].s;
    }
  }
}


int main(){
  int top1=0, top2=0;
  int S1[MAX];
  Sta S2[MAX];
  int i, j, x, sum=0, cnt=0;
  char s[MAX];

  scanf("%s",s);

  for( i = 0 ; i < strlen(s) ; i++ ){
    if( s[i] == '\\' ){
      push(S1, i, &top1);
      continue;
    }
    else if( s[i] == '/' ){
      if( top1 == 0 ) continue;
      x = pop(S1, &top1);
      sum += (i - x);
      push2(S2, x, i-x, &top2);
      uni(S2, &top2);
      continue;
    }
  }


  printf("%d\n",sum);
  if( top2 == 0 ) printf("%d\n", top2);
  else{
    cnt = top2;
    printf("%d ",cnt);
    for( i = 0 ; i < top2 - 1 ; i++ ){
      printf("%d ", S2[i].s);
    }
    printf("%d\n", S2[top2-1].s);
  }

  return 0;
}



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


int main() {
    string a, b;
    cin >> a >> b;
    if(a[0] == b[2] && a[2] == b[0] && a[1] == b[1]){
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    cout << endl;    
}


Measured memory_bytes: 256
while True:
  t=int(input())
  if t==0:
    break
  n=int(input())
  c=0
  for i in range(n):
    a,b=map(int,input().split())
    c+=(b-a)
  if t<=c:
    print("OK")
  else:
    print(t-c)


Measured memory_bytes: 5596
#include<cstdio>
#include<cctype>
#define RI register int
#define g (p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=1e5+10,size=N<<2;
char buf[size],*p1=buf,*p2=buf;
void qr(int &x) {
	char c=g;x=0;
	while(!isdigit(c))c=g;
	while(isdigit(c))x=x*10+c-'0',c=g;
}
int n; ll ans;
int a[N],deg[N],vis[N],footL[N],sum[N],f[N];
bool cir[N];
inline int qm(int x) {return x>=mod?x-mod:x;}
void workcir(int x) {
	int now=0,fr=0,frL=0,ed=0;
	//now是当前环的长度，fr是第一个有脚点的位置,frL是位置对应的脚长,ed为上一个有脚点的位置。 
	while(cir[x]) {
		++now; cir[x]=0;
		if(footL[x]) {
			if(!fr) ed=fr=now,frL=footL[x];
			else {
				ans=ans*((footL[x]<now-ed)+(footL[x]<=now-ed))%mod;//脚的放法 
				ed=now;
			}
		}
		x=a[x];
	}
	if(!ed) ++sum[now];
	else ans=ans*((frL<now-ed+fr)+(frL<=now-ed+fr))%mod;
}
void work() {
	for(RI i=1;i<=n;i++) {//脚对环上交接点贡献 
		if(deg[i]) continue;
		int x=i,len=0; while(!cir[x])x=a[x],++len;
		footL[x]=len;//脚长 
	}
	ans=f[0]=1;
	for(RI i=1;i<=n;i++) if(cir[i]) workcir(i);//以环为基准计算基环内向树的情况 
	for(RI i=1;i<=n&&ans;i++) {//计算简单环 
		for(RI j=1;j<=sum[i];j++) {
			if(i>1&&(i&1)) f[j]=qm(f[j-1]<<1);
			else f[j]=f[j-1];
			if(j>1) f[j]=qm(f[j]+(ll)f[j-2]*(j-1)%mod*i%mod);
		}
		ans=ans*f[sum[i]]%mod;
	}
}
int main() {
	qr(n);
	for(RI i=1;i<=n;i++) qr(a[i]),++deg[a[i]];
	for(RI i=1;i<=n;i++) if(!vis[i]) {
		int x=i;while(!vis[x]) vis[x]=i,x=a[x];
		if(vis[x]!=i) continue;//脚 
		while(!cir[x]) cir[x]=1,x=a[x];//标记环上点 
	}
	for(RI i=1;i<=n;i++)
		if((cir[i]&&deg[i]>2)||(!cir[i]&&deg[i]>1)) return puts("0"),0;//开叉就不行 
	work(); printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 2176
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
Mn = A.count(M)
if Mn == N:
    m = 0
else:
    m = max([i for i in A if i!=M])

for i in range(N):
    if Mn >= 2:
        print(M)
    else:
        if A[i] == M:
            print(m)
        else:
            print(M)



Measured memory_bytes: 71000
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    int A,B;
    string S,T,U;
    
    cin >> S >> T >> A >> B >> U;
    
    if( S == U ){
        cout << A - 1 << ' ' << B << endl;
    }
        else if( T == U ){
            cout << A << ' ' << B - 1 << endl;
        }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,i,s=0;
        scanf("%d",&n);
        int l[n],r[n];
        for(i=0;i<n;i++)
                scanf("%d%d",&l[i],&r[i]);

        for(i=0;i<n;i++)
                s+=(r[i]-l[i])+1;

        printf("%d\n",s);
        return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	int b[n];
	int c[n - 1];
	int sat = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for(int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	for(int i = 0; i < n; i++){
		sat += b[a[i] - 1];
		if(a[i] + 1 == a[i + 1]) {
			sat += c[a[i] - 1];
		}
	}
	cout << sat << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int N, M, K[31], A[31][31], i, j, count[31], ans=0;

    cin >> N >> M;

    for(i=1; i<=M; i++){
        count[i] = 0;
    }

    for(i=1; i<=N; i++){
        cin >> K[i];

        for(j=1; j<=K[i]; j++){
            cin >> A[i][j];

            count[A[i][j]]++;
        }
    }

    for(i=1; i<=M; i++){
        if(count[i] == N){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

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

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

int MOD;

inline int fpm(int x, int y, int M = MOD)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % M) if(y & 1) res = (LL) res * x % M;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

namespace MATH
{
	const int n = (int) 3e3;

	int fac[n + 5], ifac[n + 5];
	int S2[n + 5][n + 5];

	inline void init()
	{
		fac[0] =1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = inv(fac[n]);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;

		S2[0][0] = 1;
		for(int i = 1; i <= n; ++i)
			for(int j = 1; j <= i; ++j)
				S2[i][j] = (S2[i - 1][j - 1] + (i == j ? 0 : (LL) S2[i - 1][j] * j % MOD)) % MOD;
	}

	inline int C(int N, int M) { return N < 0 || M < 0 || N < M ? 0 : (LL) fac[N] * ifac[N - M] % MOD * ifac[M] % MOD; }
}
using MATH::C;
using MATH::S2;

const int MAXN = (int) 3e3;

int n;

inline void input()
{
	n = read<int>(), MOD = read<int>();
}

inline void solve()
{
	static int D[MAXN + 5][MAXN + 5];

	for(int k = 0; k <= n; ++k)
		for(int j = 0; j <= k; ++j)
			D[k][j] = ((LL) S2[k][j + 1] * (j + 1) % MOD + S2[k][j]) % MOD;

	int ans = 0;
	for(int k = 0; k <= n; ++k)
	{
		static int pw[MAXN + 5];

		pw[0] = 1;
		for(int pw2 = fpm(2, n - k), i = 1; i <= k; ++i) pw[i] = (LL) pw[i - 1] * pw2 % MOD;

		int res = 0;
		for(int j = 0; j <= k; ++j) (res += (LL) D[k][j] * pw[j] % MOD) %= MOD;
		res = (LL) res * fpm(2, fpm(2, n - k, MOD - 1)) % MOD;
		(ans += (LL) (k & 1 ? -1 : +1) * C(n, k) * res % MOD) %= MOD;
	}
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	MATH::init();
	solve();

	return 0;
}




Measured memory_bytes: 69504
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, ans = 0;
    in >> n >> m;
    if(n == m){
        // n! * m! * 2
        ll base = 1;
        REP(i, n) base = (base * (i+1)) % MOD;
        REP(i, m) base = (base * (i+1)) % MOD;
        ans = (base * 2) % MOD;
    }else if(abs(n - m) == 1){
        // n! * m!
        ll base = 1;
        REP(i, n) base = (base * (i+1)) % MOD;
        REP(i, m) base = (base * (i+1)) % MOD;
        ans = base;
    }

    out << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 9223372036854775807
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}


func main() {
	n:=goint()
	s := "0" + gostring()
	check := 0
	for i:=0;i<n-1;i++{
		s = s[1:]
		ls := z_algorithm(s)
		for j,v := range ls {
			check = max(check,min(j,v))
		}
	}
	fmt.Println(check)
}

func z_algorithm(s string) []int {
	c := 0;n := len(s)
	ls := make([]int,n)
	for i:=1;i<n;i++{
		l := i - c
		if ls[l] + i < c + ls[c]{
			ls[i] = ls[l]
		} else {
			j := max(0,c + ls[c] - i)
			for ;i + j < n && s[j] == s[j+i];{
				j ++
			}
			ls[i] = j
			c = i
		}
	}
	ls[0] = n
	return ls
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

Measured memory_bytes: 8704
#include<iostream>
 using namespace std; 
int main() { 	
    
    int a,b,t;
    int ans=0;
    
    cin >> a >> b >> t;
   // t = t + 1;
    
    ans = (t / a) * b;
    
    
    cout << ans << endl; 
    	return 0; 
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
	ll N,K;
	cin>>N>>K;
	ll ans=0;
	FOR(i,1,N+1){
		ans+=(N/i)*max(0LL,i-K);
		ans+=max(0LL,(N-N/i*i)-K+1);
	}
	if(K==0){
		cout<<ans-N<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
#define MOD 1000000007
int x[MN+5],y[MN+5],c[MN+5],cn,s[MN+5],p[MN+5],pn;
vector< pair<int,int> > V;
inline void add(int x,int y){for(++x;x<=MN+1;x+=x&-x)s[x]=(s[x]+y)%MOD;}
inline int sum(int x){int r=0;for(++x;x;x-=x&-x)r=(r+s[x])%MOD;return r;}
int main()
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",&x[i]);
	for(i=1;i<=m;++i)scanf("%d",&y[i]);
	for(i=1;i<=n;++i)
	{
		int t=lower_bound(y+1,y+m+1,x[i])-y;
		if(t>=2&&t<=m)V.push_back(make_pair(x[i]-y[t-1],y[t]-x[i]));
	}
	sort(V.begin(),V.end());
	for(i=0;i<V.size();++i)c[++cn]=V[i].second;
	sort(c+1,c+cn+1);cn=unique(c+1,c+cn+1)-c-1;add(0,1);
	for(i=0;i<V.size();i=j)
	{
		for(j=i,pn=0;j<V.size()&&V[i].first==V[j].first;++j)p[++pn]=V[j].second;
		pn=unique(p+1,p+pn+1)-p-1;
		for(i=pn;i;--i)p[i]=lower_bound(c+1,c+cn+1,p[i])-c,add(p[i],sum(p[i]-1));
	}
	printf("%d",sum(cn));
}

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

signed main(){
  string s="MARCH";
  int c[5]={0};
  int n;
  cin >> n;
  for (int i=0;i<n;++i){
    string t;
    cin >> t;
    for (int j=0;j<5;++j){
      if (t[0]==s[j]){
        c[j]++;
      }
    }
  }
  int ans=0;
  for (int i=0;i<5;++i){
    for (int j=i+1;j<5;++j){
      for (int k=j+1;k<5;++k){
        ans+=c[i]*c[j]*c[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll lcm = n * m / __gcd(n, m);
    ll ln = lcm / n, lm = lcm / m;
    ll llcm = ln * lm / __gcd(ln, lm);
    bool flag = true;
    for (ll i = 0; i < lcm; i += llcm) {
        if (s[i / ln] != t[i / lm]) flag = false;
    }
    if (flag) printf("%lld\n", lcm);
    else puts("-1");
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){  
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

  priority_queue<pair<int, int>> pq;

  bitset<200000> bs = 0;
  int finished = 0;
  
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }

  for(int i = 0; i < n; ++i){
    cin >> b[i];
    pq.push({b[i], i});
    if(a[i] == b[i]){
      bs[i] = 1;
      finished++;
    }
    if(a[i] > b[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll cnt = 0;
  while(!pq.empty()){
    if(finished == n){
      cout << cnt << endl;
      return 0;
    }
    while(!pq.empty() && bs[pq.top().second] == 1){
      pq.pop();
    }
    if(pq.empty()){
      cout << cnt << endl;
      return 0;
    }
    int val, pos;
    tie(val, pos) = pq.top();
    pq.pop();
    int r = pos + 1, l = pos - 1;
    if(l < 0) l += n;
    if(r >= n) r -= n;

    int mns = b[r] + b[l];
    int div = (b[pos] - a[pos]) / mns;
    if(div == 0){
      cout << -1 << endl;
      return 0;
    }
    cnt = (cnt + div);
    b[pos] -= div*mns;
    
    if(b[pos] < a[pos]){
      cout << -1 << endl;
      return 0;
    } else if(b[pos] == a[pos]){
      bs[pos] = 1;
      finished++;
    } else {
      pq.push({b[pos], pos});
    }
    
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3956