akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
string::iterator end;
string::iterator begin;
bool perseExpression(string::iterator & it, int * result);

//
bool perseNumber(string::iterator & it, int * result){
  if(*it!='0' && *it!='1') return false;
  while(*it=='0') ++it;

  *result = 0;
  int max_length = 10;
  int length = 0;
  while(true){
    if(it+length==end || (*(it+length)!='0' && *(it+length)!='1')) break;
    *result += (*(it+length) - '0') << (max_length-length);
    ++length;
  }
  if(length > max_length) return false;
  
  *result >>= max_length-length + 1;
  it += length;
  return true;
}

// ( )
bool perseValue(string::iterator & it, int * result){
  if(*it!='(') return perseNumber(it, result);
  ++it;
  
  string::iterator temp = it;
  if(!perseExpression(it, result)) return false;
  
  int v;
  perseValue(temp, &v);
  if(*temp!='*' && *temp!='-' && *temp!='+') return false;
  
  if(*it!=')') return false;

  ++it;
  return true;
}

// *
bool perseTerm(string::iterator & it, int * result){
  if(!perseValue(it, result)) return false;
  
  unsigned long long lv = *result;
  while(true){
    if(it==end || *it!='*') break;
    ++it;
    int rv;
    if(!perseValue(it, &rv)) return false;
    lv *= rv;
    if(lv >= 1024) return false;
  }
  *result = lv;
  return true;
}

// + -
bool perseExpression(string::iterator & it, int * result){
  if(!perseTerm(it, result)) return false;
  
  while(true){
    if(it==end) break;
    char op = *it;
    if(op!='+' && op!='-') break;
    ++it;
    int rv;
    if(!perseTerm(it, &rv)) return false;
    *result += (op=='+') ? rv : -rv;
    if(*result<0 || *result >= 1024) return false;
  }
  return true;
}

int main(){
  string str;
  cin >> str;
  std::size_t l1Pos = str.find(".");
  std::size_t l2Pos = l1Pos!=string::npos ? str.find(".", l1Pos+1) : string::npos;
  std::size_t l3Pos = l2Pos!=string::npos ? str.find(".", l2Pos+1) : string::npos;
  std::size_t l4Pos = l3Pos!=string::npos ? str.find(".", l3Pos+1) : string::npos;
  std::size_t l5Pos = l4Pos!=string::npos ? str.find(".", l4Pos+1) : string::npos;
  
  string list[7] = {"0", "1", "+", "-", "*", "(", ")"};
  
  int max_val = -1;
  for(string * l1=list; l1!=list+7; ++l1){
    for(string * l2=list; l2!=list+7; ++l2){
      for(string * l3=list; l3!=list+7; ++l3){
        for(string * l4=list; l4!=list+7; ++l4){
          for(string * l5=list; l5!=list+7; ++l5){
            string temp = str;
            if(l1Pos!=string::npos) str.replace(l1Pos, 1, *l1);
            if(l2Pos!=string::npos) str.replace(l2Pos, 1, *l2);
            if(l3Pos!=string::npos) str.replace(l3Pos, 1, *l3);
            if(l4Pos!=string::npos) str.replace(l4Pos, 1, *l4);
            if(l5Pos!=string::npos) str.replace(l5Pos, 1, *l5);
            
            end = str.end();
            begin = str.begin();
            string::iterator it = begin;
            int val = 0;
            if(perseExpression(it, &val)){
              if(it==end) max_val = max(max_val, val);
            }
            str = temp;
          }
        }
      }
    }
  }
  cout << max_val << endl;
  return 0;
}

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

int main(){
	int n,m;
	cin >> n >>m;
	int x[m];
	for(int i=0;i<m;i++){
		cin >>x[i];
	}
	if(n>=m){
		cout <<  0 <<endl;
	}
	else{
		sort(x,x+m);
		for(int i=0;i<m-1;i++){
			x[i]=x[i+1]-x[i];
		}
		sort(x,x+m-1);
		int l=m-n;
		int sum=0;
		for(int i=0;i<l;i++){
			sum+=x[i];
		}
		cout << sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
import numpy as np
N,K = map(int,input().split())
Alist = np.array(list(map(int,input().split())))
counter = 0
for i,A in enumerate(Alist,0):
    fir_tenti = np.count_nonzero(A>Alist[i:])
    counter += (K*fir_tenti*(K+1))//2
    second_tenti = np.count_nonzero(A>Alist[:i+1])
    counter += (second_tenti*K**2-second_tenti*K)//2

print(int(counter%1000000007))

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


int main() {

int n;cin>>n;
int a[n];
unordered_map<int,int> m;
for(int i=0;i<n;i++){
	cin>>a[i];
	m[a[i]]++;
}
if(m[1]>0){
	if(m[1]==1) cout<<1;
	else cout<<0;
	return 0;
}
int c=0;
for(int i=0;i<n;i++){
	int x=a[i];
	if(m[a[i]]>1) continue;
	int f=0;
	for(int j=2;j<=sqrt(x);j++){
		if(x%j==0){
			if(m[j]>0){
				f=1;break;
			}
			if(x/j!=j){
				if(m[x/j]>0){
					f=1;break;
				}
			}
 		}
	}
	if(f==0) c++;
}
cout<<c;
}


Measured memory_bytes: 32428
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    vector<long long> rui(N+1);
    for(int i = 0;i<N;i++){
        rui.at(i+1) += rui.at(i)+retu.at(i);
    }
    int ans = 1;
    //一番大きいやつは確定で選べる
    for(int i = N-1;i>=0;i--){
        if(rui.at(i)*2 >= retu.at(i)) ans++;
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4768
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
abcde = [ni() for _ in range(5)]

print(5 + -(-n//min(abcde)) - 1)

Measured memory_bytes: 3064
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*
/*
ll prf(ll n)
{
    ll c=0,i;
    while(n%2==0)
    {
        n=n/2;
        c++;
    }
    for(i=3;i*i<=n;i++)
    {
        while(n%i==0)
    }
    
    
    
}
*/

int main()
{
     fast
     
     
     ll n,k;
     cin>>n>>k;
     ll a[n],i;
     f(i,n)
     {
         cin>>a[i];
     }
     sort(a,a+n);
     
     ll s=0;
     
     f(i,k)
     {
         s+=a[i];
     }
     
     o(s)
     
      
       
     
   
    re
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;cin>>k>>a>>b;
  if(a%k==0 or b%k==0)cout<<"OK"<<endl;
  else if(a/k==b/k)cout<<"NG"<<endl;
  else cout<<"OK"<<endl;
}


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

int main() {
	// your code goes here
	int n,m,amax,i;
	char s[500];
	cin >> n;
	cin >> s;
	m=n;
	n=0;
	amax=n;
	for(i=0;i<m;i++){
		if(s[i]=='I') n++;
		else n--;
		amax=max(amax,n);
	}
	cout << amax << endl;
	return 0;
}

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

int main()
{
    int64_t x, k, d, tmp, ans;
    cin >> x >> k >> d;
    x = abs(x);
    tmp = x / d;

    if(x/d < k)
    {
        ans = x - (x/d)*d;

        if((k-(x/d)) % 2 != 0)
        {
            ans -= d;
        }

    }
    else
    {
        ans = x - k * d;
    }

    cout << abs(ans) << endl;
}

Measured memory_bytes: 3648
main = interact $ unlines.map solve.lines

solve :: String -> String
solve pvals = yesOrNo $ and [s+t < 1, s >0, t >0]
    where
        [vert1,vert2,vert3,p] = makePairs.map read.words $ pvals :: [[Double]]
        vectA = zipWith (-) vert2 vert1
        vectB = zipWith (-) vert3 vert1
        vectP = zipWith (-) p     vert1
        [s,t] = solveSimul vectA vectB vectP
makePairs []       = []
makePairs (x:y:ps) = [x,y] : makePairs ps

yesOrNo s = if s then "YES" else "NO"

solveSimul [a,d] [b,e] [c,f] = [s,t]
    where
        s = (c*e-b*f)/(a*e-b*d)
        t = (a*f-c*d)/(a*e-b*d)

Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

signed main()
{
    
    speed
    int s,w;cin>>s>>w;
    if(w>=s){
      cout<<"unsafe"<<endl;
    }
    else{
      cout<<"safe"<<endl;
    }

 
 
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
struct Node{
    Node *parent,*left,*right;
    int key;
};
Node *root=NULL,*NIL=NULL;
void insert(int k){
    Node* x_parent=NIL;//xの親
    Node* x=root;//挿入する場所
    Node* node=NIL;//新しく挿入するノード
    node=(Node*)malloc(sizeof(Node));
    node->key=k;
    node->right=NIL;
    node->left=NIL;
    while(x!=NIL){
        x_parent=x;
        if(node->key<x->key) x=x->left;
        else x=x->right;
    }
    node->parent=x_parent;
    if(x_parent==NIL) root=node;//木が空の場合
    else{
        if(node->key<x_parent->key) x_parent->left=node;
        else x_parent->right=node;
    }
}
void pre(Node* u){
    if(u==NIL) return;
    printf(" %d",u->key);
    pre(u->left);
    pre(u->right);
}
void in(Node* u){
    if(u==NIL) return;
    in(u->left);
    printf(" %d",u->key);
    in(u->right);
}
Node* find(Node* u,int k){
    while(u!=NIL&&u->key!=k){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}
int main(){
    int m,k;
    scanf("%d",&m);
    string com;
    for(int i=0;i<m;++i){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&k);
            insert(k);
        }else if(com=="print"){
            in(root);
            putchar('\n');
            pre(root);
            putchar('\n');
        }else if(com=="find"){
            scanf("%d",&k);
            printf("%s\n",find(root,k)!=NIL?"yes":"no");
        }
    }
    return 0;
}

Measured memory_bytes: 21928
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a*n,b)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m)
    {
        cout<<m/3<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){

  int A, B, M;
 cin >> A >> B >> M;
 vector<int> a(A);
 vector<int> b(B);
 for (int i = 0; i < A; i++)cin >> a[i];
 for (int i = 0; i < B; i++)cin >> b[i];
 int minA = *min_element(a.begin(), a.end());
 int minB = *min_element(b.begin(), b.end());
 int ans = minA+minB;
 for (int i = 0; i < M; i++) {
 int x, y, c;
 cin >> x >> y >> c; x--; y--;
 ans = min(ans, a[x] + b[y] - c);
 }
 cout << ans << endl;

  
  
}



Measured memory_bytes: 1024
S = input()
N = len(S)
abc = list('abcdefghijklmnopqrstuvwxyz')
if N < 26:
    for c in abc:
        if c not in S:
            print(S + c)
            exit()


def dfs(s):
    if s > S:
        print(s)
        exit()
    elif s == S[:len(s)]:
        for c in abc:
            if c not in s:
                dfs(s + c)


dfs('')
print(-1)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int S = sc.nextInt();
        final int W = sc.nextInt();
        if (W >= S) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}


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

int main()
{
    int m,s;
    char h[200]={},box;
    while(1)
    {
        scanf("%s",h);
        if(h[0] == '-') break;
        scanf("%d",&m);
        for(int i=0;i<m;i++)
        {
            scanf("%d",&s);
            for(int j=0;j<s;j++){
                box = h[0];
                for(int b=0;b<strlen(h)-1;b++){
                    h[b] = h[b+1];                }
                h[strlen(h)-1] = box;
            }
        }
        for(int i=0;i<strlen(h);i++){
            printf("%c",h[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  string s; cin>>s;
  int l = 0, r = n-1;
  int ans = 0;
  while (l<r) {
    while (l<r and s[l] != 'W') l++;
    while (l<r and s[r] != 'R') r--;
    if (l<r) {
      ans++;
      l++;
      r--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    map<char, int> smp, tmp;
    for(int i=0; i<S.size(); i++) {
        smp[S[i]]++;
        tmp[T[i]]++;
    }
    bool flag=true;
    for(int i=0; i<S.size(); i++) {
        if(smp[S[i]]!=tmp[T[i]]) {
            flag=false;
            break;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int H=0;
        int W=0;
        int x=0;
        int y=0;
        
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
            
            if(H==0 && W ==0)break;
            for(x = 0; x < H; x++){
            for(y = 0; y < W; y++){
                if(x%2 == 0 && y%2 == 0){
                System.out.print("#");
            	}else if(x%2 == 1 && y%2 == 1){
            		System.out.print("#");
            	}else{
                    System.out.print(".");
                }
            }
            System.out.println("");
                
            }
            System.out.println("");
        }
    }
}



Measured memory_bytes: 36092
inf = float("inf")
x = int(input())
if (x - x // 100 * 100) % 5 == 0:
    a = x // 100 >= (x - x // 100 * 100) // 5
else:
    a = x // 100 >= (x - x // 100 * 100) // 5 + 1
print(int(a))


Measured memory_bytes: 38384
aN =int(input())
s = list(map(int,input().split()))

S = sum(s)
S_ = 0
prev_S = 0
for _s in s:
  S_ += _s
  #print( abs(S-2*S_) , abs(S-2*prev_S))
  if abs(S-2*S_) > abs(S-2*prev_S):
    print(abs(S-2*prev_S))
    quit()
  prev_S = S_


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
   int x;
  char s[3];
  gets(s);
  char s1[]="MON",s2[]="TUE",s3[]="WED",s4[]="THU",s5[]="FRI",s6[]="SAT",s7[]="SUN";
  if(strcmp(s,s1)==0)
  {
    printf("6");
  }
  if(strcmp(s,s2)==0)
  {
    printf("5");
  }
  if(strcmp(s,s3)==0)
  {
    printf("4");
  }
  if(strcmp(s,s4)==0)
  {
    printf("3");
  }
  if(strcmp(s,s5)==0)
  {
    printf("2");
  }
  if(strcmp(s,s6)==0)
  {
    printf("1");
  }
  if(strcmp(s,s7)==0)
  {
    printf("7");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	int x, y;
	scanf("%d%d", &x, &y);
	if (x < y) {
		printf("%d\n", x);
	} else if (x == y) {
		printf("-1\n");
	} else {
		if (x % y == 0) {
			printf("-1\n");
		} else {
			printf("%d\n", x);
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 3005;

ll add(ll a,ll b)
{
	a%=MOD; b%=MOD;
	a+=b;a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	a%=MOD; b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int a,b,c,d;
ll dp[MAXN][MAXN];

bool DEBUG=0;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>a>>b>>c>>d;
	dp[a][b]=1;
	for(int i=a;i<=c;i++){
		for(int j=b;j<=d;j++){
			ll inc=0;
			if(i>a && j>b){
				inc=add(inc,add(dp[i][j-1]*(i-1),dp[i-1][j]*(j-1)));
				if(DEBUG) cout<<"("<<i<<","<<j<<") "<<(dp[i][j-1]*(i-1))<<" "<<(dp[i-1][j]*(j-1))<<'\n';
				
				inc=add(inc,add(dp[i-1][j],dp[i][j-1]));
				inc=add(inc,-mult(dp[i-1][j-1],(i-1)*(j-1)));
			}
			else inc=add(inc,dp[i][j-1]*i+dp[i-1][j]*j);
			
			dp[i][j]=add(dp[i][j],inc);
		}
	}
	
	if(DEBUG){
		for(int i=1;i<=c;i++){
			for(int j=1;j<=d;j++){
				cout<<dp[i][j]<<" ";
			}
			cout<<'\n';
		}
	}
	
	cout<<dp[c][d]<<'\n';
	
	return 0;
}


Measured memory_bytes: 73976
#include <algorithm>
#include <iostream>

constexpr int MOD = 2019;

int main() {
  int L, R;
  std::cin >> L >> R;
  if (R - L > MOD + 10) {
    R = L + MOD + 10;
  }
  int min = MOD;
  for (int i = L; i <= R; ++i) {
    for (int j = i + 1; j <= R; ++j) {
      int r = ((i % MOD) * (j % MOD)) % MOD;
      min = std::min(min, r);
    }
  }
  std::cout << min << std::endl;
  return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int k, n; cin >> k >> n;
    vector<int> a(2*n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = n; i < 2*n; i++)
        a[i] = a[i-n] + k;

    int ans = 0x3f3f3f3f;
    for (int i = 0; i < n; i++)
        ans = min(a[i+n-1] - a[i], ans);

    cout << ans << endl;

    return 0;
%>

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


int main() {
   int k, x;cin >> k >> x;
   for(int i = max(-1000000, x-k+1); i < min(1000000, x+k);i++ ) {
     cout << i << " ";
   }
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
#define MAXN 300002
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
ll arr[200002];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    ll sum=0;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(i=0;i<n;i++){
        if(i and i<n-1) sum+=abs(arr[i]);
    }
    sum-=arr[0];
    sum+=arr[n-1];
    cout<<sum<<'\n';
    for(i=1;i<n-1;i++){
        if(arr[i]>0)  {
            cout<<arr[0]<<' '<<arr[i]<<'\n';
            arr[0]-=arr[i];
          }
        else {
            cout<<arr[n-1]<<" "<<arr[i]<<'\n';
                arr[n-1]-=arr[i];
            }
     }
    cout<<arr[n-1]<<" "<<arr[0];
}


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


int main()
{
    int n;
    cin>>n;
    int t=n/100;
    t=t*100+t*10+t;
    if(t>=n)
    {
        cout<<t<<endl;
    }
    else
    {
        cout<<t+111<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e5;

int main()
{
  int N,C;
  cin >> N >> C;
  vector<int> s(N),t(N),c(N);
  for(int i = 0; i < N; i++){
    cin >> s[i] >> t[i] >> c[i];
  }

  int cam[MAXN*2+20] = {0};
  for(int i = 1; i <= C; i++){
    int rec[MAXN*2+20] = {0};
    for(int j = 0; j < N; j++){
      if(c[j] == i){
        rec[s[j]*2-1]++;
        rec[t[j]*2]--;
      }
    }
    for(int j = 1; j < MAXN*2+20; j++){
      rec[j] += rec[j-1];
    }
    for(int j = 0; j < MAXN*2+20; j++){
      if(rec[j]>0) cam[j]++;
    }
  }

  int ans = 0;
  for(int i = 0; i < MAXN*2+2; i++){
    ans = max(ans,cam[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007
#define endl "\n"
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int K=1;K<=k;K++){
                ans+=__gcd(__gcd(i,j),K);
            }
        }
    }
    cout<<ans<<"\n";

    return 0;
}

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

int main(){
  long long n;	cin >> n;
  vector<long long>	A(n+1);
  vector<long long> p(n+1,0);
  rep(i,n){
    cin >> A[i+1];
    p[A[i+1]]++;
  }
  
  long long sum=0;
  for(long long i=1;i<=n;i++){
    long long num=p[i];
    sum+=num*(num-1)/2;
  }
  
  for(long long i=1;i<=n;i++){
    cout << sum-(p[A[i]]-1) << endl;
  }
  
}

Measured memory_bytes: 6388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_Challenge
{
    class _012_B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            var graph = new List<int>[n];
            for(int i = 0; i < n; i++)
            {
                graph[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                int[] ab = ReadInts();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }
            int q = ReadInt();
            int[][] vdcs = new int[q][];
            for(int i =0; i < q; i++)
            {
                vdcs[i] = ReadInts();
            }
            var coloredTimes = new int[n, 11];
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < 11; j++)
                {
                    coloredTimes[i, j] = -1;
                }
            }
            for(int i = q - 1; i >= 0; i--)
            {
                int v = vdcs[i][0] - 1;
                int d = vdcs[i][1];
                Queue<int[]> queue = new Queue<int[]>();
                queue.Enqueue(new int[2] { v, d });
                while (queue.Count > 0)
                {
                    int[] val = queue.Dequeue();
                    if (coloredTimes[val[0], val[1]] != -1) continue;

                    for(int j = val[1]; j >= 0; j--)
                    {
                        if (coloredTimes[val[0], j] != -1) break;
                        coloredTimes[val[0], j] = i;
                    }
                    if (val[1] == 0) continue;

                    for(int j = 0; j < graph[val[0]].Count; j++)
                    {
                        queue.Enqueue(new int[2] {
                            graph[val[0]][j] , val[1] - 1 });
                    }
                }
            }
            for(int i = 0; i < n; i++)
            {
                if (coloredTimes[i, 0] == -1)
                {
                    WriteLine(0);
                }
                else
                {
                    WriteLine(vdcs[coloredTimes[i, 0]][2]);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;

    int mx= 0, c=0;

    for(int i=0; i<s.size(); i++)
    {
        if( s[i]== 'C' || s[i]== 'T' || s[i]== 'A' || s[i]== 'G')
            c++;

        else
        {
            mx= max(mx, c);
            c= 0;
        }
    }

    cout << max ( mx, c);
    nl;

    return 0;
}




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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }

  return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


int a[200000], b[200000];
P p[200000];
signed main(){
  // 入力
  int n, l;
  cin >> n >> l;
  rep(i,n){
    int x, y;cin >> x >> y;
    p[i] = P(x, y);
  }
  sort(p, p+n);
  rep(i,n){a[i] = p[i].fi;b[i] = p[i].se;}
  a[n] = l+1;b[n] = 1;
  n++;
  
  int last = 0;   // 左の塊の一番右の位置
  int ans = 0;    // 得点
  int pos = 0;
  int right = 0;    // 右向きの駒の数
  int left = 0;    // 左向きの駒の数
  rep(i,n){
    ans += (right-left)*(a[i]-pos-1);
    if(b[i] == 1)right++;
    else left++;
    if(right <= left){
      ans += (left-right)*((a[i]-(left+right-1))-last-1);
      last += left+right;
      left = right = 0;
    }
    pos = a[i];
  }
  cout << ans << endl;
  return 0;
}







Measured memory_bytes: 6204
#include <bits/stdc++.h>
using namespace std;
typedef pair <string, string> pss;
typedef pair <int, int> pii;

#define int long long

const int N = 18 + 1, base = 31, mod = 1e17 + 7, bbase = 17;
int n, ans;
string s1, s2, s;
map <pii, int> mp;

int get_hs(string &ss) {
	int res = 0;
	for (char c : ss)
		res = ((base * res) + (c - 'a')) + 1;
	return res;
}

void solve(int msk) {
	string tmp1, tmp2;
	for (int i = n - 1; i >= 0; i--)
		if (msk & (1LL << i))
			tmp1 += s[n + i];
		else
			tmp2 += s[n + i];
	
	mp[pii(get_hs(tmp1), get_hs(tmp2))]++;
}

void solve2(int msk) {
	string tmp1, tmp2;
	for (int i = 0; i < n; i++)
		if (msk & (1LL << i))
			tmp1 += s[i];
		else
			tmp2 += s[i];
	
	ans += mp[pii(get_hs(tmp1), get_hs(tmp2))];
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		s1 += s[i];
	for (int i = n; i < n; i++)
		s2 += s[i];
	
	for (int msk = 0; msk < (1LL << n); msk++)
		solve(msk);
	
	for (int msk = 0; msk < (1LL << n); msk++)
		solve2(msk);
	cout << ans;
}

Measured memory_bytes: 33024
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 1000000

map<long long, int> PrimeFactor(long long n) {
    map<long long, int> mp;
    for (int i = 2; (long long)i * i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    bool visited[MAX + 1] = {};
    bool flag = true;
    rep(i, n) {
        auto pf = PrimeFactor(a[i]);
        for (auto p : pf) {
            if (visited[p.first]) {
                flag = false;
                goto fin;
            }
            visited[p.first] = true;
        }
    }
fin:;
    if (flag) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int g = a[0];
    rep(i, n) {
        g = gcd(g, a[i]);
    }
    if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    return 0;
}

Measured memory_bytes: 8484
#include <stdio.h>

int main() {
	int n, a, b, c, max, i;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		scanf("%d", &b);
		scanf("%d", &c);

		if (((a*a == b*b + c*c)||(b*b == c*c + a*a))||(c*c==a*a+b*b)) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 580
N, W = map(int, input().split())

v = [0]* N
w = [0]* N

dp = [[-1 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    v[i],w[i] = map(int, input().split())

def rec(i,j):
    if dp[i][j] != -1:
        return dp[i][j]
        
    if i == N:
        res = 0
    elif j < w[i]:
        res = rec(i+1, j)
    else:
        res = max(rec(i+1, j), rec(i+1, j-w[i])+v[i])
    
    dp[i][j] = res
    
    return dp[i][j]
    
print(rec(0,W))

Measured memory_bytes: 26084
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

int calc(int[] xs) {
    int ans = 0;
    for (int i = 0; i + 1 < xs.length; i++) {
        if (xs[i] == i + 1) { 
            ans++;
            swap(xs[i], xs[i + 1]);
        }
    }

    if (xs[$ - 1] == xs.length)
        ans++;

    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


Measured memory_bytes: 4412
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;

// watch this
//using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 3010;

long long md;
long long pow_mod(long long base, long long power) {
	long long res = 1;
	while (power) {
		if (power & 1)
			res = res * base % md;
		base = base * base % md;
		power >>= 1;
	}
	return res;
}

long long st[mxN][mxN];
long long NcR[mxN][mxN];
long long p2[mxN], p2e[mxN];

void init() {
	NcR[0][0] = 1;
	st[0][0] = 1;
	p2[0] = p2e[0] = 1;
	for (int i = 1; i < mxN; i++) {
		NcR[i][0] = 1;
		st[i][0] = 1;
		p2[i] = (p2[i - 1] << 1) % md;
		p2e[i] = (p2e[i - 1] << 1) % (md - 1);
		for (int j = 1; j <= i; j++) {
			NcR[i][j] = (NcR[i - 1][j] + NcR[i - 1][j - 1]) % md;
			st[i][j] = ((j + 1) * st[i - 1][j] + st[i - 1][j - 1]) % md;
		}
	}
}

long long get(long long N, long long ch) {
	long long num = NcR[N][ch];
	long long ac = 0;
	for (int i = 0; i <= ch; i++) {
		ac = (ac
				+ (st[ch][i] * pow_mod(p2[N - ch], i) % md)
						* pow_mod(2, p2e[N - ch])) % md;
	}
	return num * ac % md;
}

int main(int argc, char** argv) {
	//#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//#endif

	int N;
	cin >> N >> md;
	init();
	long long res = 0;
	for (int i = 0; i <= N; i++) {
		res = (res + md + (i & 1 ? -1 : 1) * get(N, i)) % md;
//		cerr << (i & 1 ? -1 : 1) * get(N, i) << '\n';
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 140288
N,Q = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
C = [0]*N
for _ in range(Q):
    p,x = map(int, input().split())
    C[p-1] += x

from collections import deque
q = deque()
q.append((0, C[0]))
ans = [-1]*N
ans[0] = C[0]
while q:
    temp = q.pop()
    u = temp[0]
    c = temp[1]
    for v in E[u]:
        if ans[v] == -1:
            ans[v] = c+C[v]
            q.append((v, c+C[v]))

print(*ans)

Measured memory_bytes: 75340
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

#define INF INT_MAX / 2 - 1
#define PI 2*acos(0.0)
#define ll long long

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int n, a, len;
	cin >> n >> a;
	int dp[100000];
	fill_n(dp, 100000, INF);
	dp[0] = a;
	len = 1;
	FOR(i, 1, n) {
		cin >> a;
		if (dp[len-1] < a)
			dp[len++] = a;
		else {
			int j = len;
			for ( ; j >= 0; j--)
				if (dp[j] < a)
					break;
			dp[j+1] = a;
		}
	}
	cout << len << endl;
	return 0;
}

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


int main() {
    int a, b;
    cin >> a >> b; 
    if(a*b%2 == 0){
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
P = tuple(map(int, input().split(' ')))

i = 0
ans = 0
while i < N:
    if P[i] == i + 1:
        if i < N - 1 and P[i + 1] == i + 2:
            ans += 1
            i += 1
        else:
            ans += 1
    i += 1

print(ans)


Measured memory_bytes: 20904
#include<stdio.h>
#include<math.h>
int main(){
	int i,j,k;
	scanf("%d%d%d",&i,&j,&k);
	int s1,s2,s3;
	s1=fabs(i-j);
	s2=fabs(j-k);
	s3=fabs(k-i);
	int max=s1;
	if(max<s2)
		max=s2;
	if(max<s3)
		max=s3;
		printf("%d\n",s1+s2+s3-max);
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int w[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        sum += w[i];
    }   
    int s1 = 0;
    int ans;
    //  
    for (int i = 0; i < n; i++) {
        s1 += w[i];
        if (s1 > sum / 2) {
            ans = 2 * s1 - sum;
            if (2 * s1 - sum > sum - 2 * s1 + 2 * w[i]) {
                ans = sum - 2 * s1 + 2 * w[i];
            }
            break;
        }
    }   
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int ma = a[N - 1];
    int cnt = 0;
    for (int i = N - 1; i >= 0; i--) {
        if (b[i] > ma) {
            cnt++;
            H -= b[i];
        } else {
            break;
        }
        if (H <= 0) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << cnt + (H + ma - 1) / ma << endl;
    return 0;
}


Measured memory_bytes: 3996
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int x[3],ans=0,i;
	rep(i,3)x[i]=in();
	sort(x,3);
	ans=x[2]-x[1];
	x[0]+=ans;
	if((x[2]-x[0])%2)x[2]++,ans++;
	ans+=(x[2]-x[0])/2;
	print(ans);
	return 0;
}

Measured memory_bytes: 128