akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	int i = 1;
	in(ll, a, b);
	if (a <= 0 && 0 <= b)
		cout << "Zero" << endl;
	else if (0 < a)
		cout << "Positive" << endl;
	else {
		if ((b - a) % 2)
			cout << "Positive" << endl;
		else
			cout << "Negative" << endl;
	}
	return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(a - c) <= d) {
        cout << "Yes" << endl;
    }
    else if (abs(b - a) <= d && abs(c - b) <= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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


void solve(long long K){
    vector<int> xs = vector<int>{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << xs[K - 1] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint a,b100;
    string s;
    cin >> a >> s;
    lint x = s[0] - '0', y = s[2] - '0', z = s[3] - '0';
    b100 = x*100+y*10+z*1;
    lint ans=a*b100/100;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
//ll _(){
//
//    ll x,y;
//    cin >> x >> y;
//    ll ans = 1;
//    while(x*2 <= y){
//        ++ans;
//        x *= 2;
//    }
//    return ans;
//}
//
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
ll _(){
    ll x,y;
    cin >> x >> y;
    ll ans = 1;
    while(x*2 <= y){
        ++ans;
        x *= 2;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 256
sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
while True:
    inputed_line = input()
    data_str = inputed_line.split(' ')
    data = [int(i) for i in data_str]
    data.sort()
    if data[-1] < data[0] + data[1]:
        sankaku += 1
        if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
            tyokkaku += 1
        elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
            eikaku += 1
        elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
            donkaku += 1
    else:
        break

answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_list_str = [str(i) for i in answer_list]
answer_str = ' '.join(answer_list_str)
print(answer_str)


Measured memory_bytes: 5608
import java.util.*;

public class Main{
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);


        long s = sc.nextLong();


        long x1 = 0;
        long y1 = 0;

        List<Integer> num = new ArrayList<>();

//        for (int i=(int)Math.sqrt(s); i>=0; i--){
//            if (s%i==0){
//                num.add(i);
//                break;
//            }
//        }


        int sqr = 0;
        if (Math.sqrt(s)==(int)Math.sqrt(s)){
            sqr=(int)Math.sqrt(s);
        }else{
            sqr=(int)Math.sqrt(s)+1;
        }



//        int y2 = 1;
//        int x3 = Math.abs((int)diff/1);

//        for (int i=(int)Math.sqrt(s); i>=0; i--){
//            if (s%i==0){
//                num.add(i);
//                break;
//            }
//        }

        long x2 = (long)sqr;
        long y3 = (long)sqr;

        long diff = Math.abs(x2*y3-s);

        long x3 = 1;
        long y2 = diff;

//        long x2 = num.get(num.size()-1);
//        long y2 = 0;
//
//        long x3 = x2;
//        long y3 = s/x2;


        System.out.println(x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3);

    }
}

Measured memory_bytes: 23764
N = int(input())
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]
reds.sort(key=lambda x: x[1], reverse=True)
blues.sort(key=lambda x: x[0])
ans = 0
for b in blues:
    for i, r in enumerate(reds):
        if b[0] > r[0] and b[1] > r[1]:
            ans += 1
            del reds[i]
            break
print(ans)


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

int main() {
  int N, D, X, A;
  cin >> N >> D >> X;
  while (cin >> A) {
    int tmp = 1, cnt = 1;
    while (tmp + A <= D) tmp += A, cnt++;
    X += cnt;
  }
  cout << X << "\n";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;


int main(){
  ll n; cin >> n;
  vector<ll> ryuka(n+1,0);
  ryuka.at(0) = 2; ryuka.at(1) = 1;
  rep(i,n-1){
    ryuka.at(i+2)=ryuka.at(i+1)+ryuka.at(i);
  }
  
  cout << ryuka.at(n) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
vector<long long> v;
vector<bool> b;
long long num(long long f, long long t) {
  vector<long long> vv;
  while (f <= t) {
    vv.push_back(v[f]);
    f++;
  }
  reverse(vv.begin(), vv.end());
  long long ans = 0;
  for (long long i = 0; i < vv.size(); ++i) {
    ans += vv[i] * pow(10, i);
  }
  return ans;
}

int main() {
  long long c;
  cin >> c;
  while (c != 0) {
    v.push_back(c % 10);
    c /= 10;
  }
  reverse(v.begin(), v.end());
  long long rst = 0;
  long long e = 0;
  for (long long k = 0; k < pow(2, v.size() - 1); ++k) {
    bitset<9> bits(k);
    e = 0;
    for (long long i = 0; i < v.size(); ++i) {
      if (i == v.size() - 1 || bits[i] == 1) {
        rst += num(e, i);
        e = i + 1;
      }
    }
  }
  cout << rst << endl;
  return 0;
}


Measured memory_bytes: 384
// Reading stuff 
// check the modulus 
// for tree case n=1


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

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


int solve(){    
 
int n,m;
cin>>n>>m;
int ans=0;
rep(i,0,m)
{
  int x;
  cin>>x;
  ans+=x;
}
if(ans>n)cout<<-1;
else cout<<n-ans;
return 0;
}

 
signed main()
{    



   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);


int t=1;                                                                                                                  
//cin>>t;
int k=1;

    while(t--)
     {
      //cout<<"Case #"<<k<<": ";
      k++;
      solve();
     }
    return 0;
  }

Measured memory_bytes: 3636
"use strict";
function main(input){
    const lines = input.split('\n');
    const a = parseInt(lines[0],10);
    const b = parseInt(lines[1],10);
    const c = parseInt(lines[2],10);
    const sum = parseInt(lines[3],10);
    let count = 0;
    
    
    for(let aCount = 0; aCount <= a; aCount++){
        for(let bCount = 0; bCount <= b; bCount++){
            for(let cCount = 0; cCount <= c; cCount++){
                if((500*aCount) + (100*bCount) + (50*cCount) === sum){
                    count++;
                }
            }
        }
    }
    console.log(count);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8008
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  ll x, y;
  scanf("%lld %lld", &x, &y);

  ll absx = abs(x), absy = abs(y);

  ll cnt = abs(absx - absy);

  if((x < 0 && y > 0) || (x >= 0 && y <= 0)){
    cnt++;
  } else if((x < 0 && y < 0 && x >= y) || (x >= 0 && y >= 0 && x >= y)){
    cnt += 2;
  }
  printf("%lld\n", cnt);

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

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

int main()
{
   int x, y;
   cin >> x >> y;
   cout << x + y / 2 << endl;

   return 0;
}


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

int main() {
  int n;
  cin >> n;
  map<string, int> count;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    count[s]++;
  }
  int64_t ans=0;
  for (auto x: count) {
    ans += (int64_t)x.second*(x.second-1)/2; //nC2 = n*(n-1)/(2*1)
  }
  cout << ans << endl;
}


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

typedef long long ll;
const int maxn=1e5+10;
int a,b,c,x,y;
ll ans;

int main(){
	cin>>a>>b>>c>>x>>y;
	while(2*c<a+b&&x&&y)
		--x,--y,ans+=2*c;
	if(!y&&2*c<a)
		cout<<ans+2ll*c*x<<endl;
	else if(!x&&2*c<b)
		cout<<ans+2ll*c*y<<endl;
	else
		cout<<ans+(ll)a*x+(ll)b*y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define N 30

int n;
vector<int> v[N][2];
vector<int> a, b;


int bins(vector<int> & v, int bound) {
	if (!v.size()) {
		return 0;
	}
	int l = 0;
	int r = v.size() - 1;
	if (v[l] >= bound) {
		return v.size();
	}
	if (v[r] < bound) {
		return 0;
	}
	while (r - l > 1) {
		int m = (r + l) / 2;
		if (v[m] >= bound) {
			r = m;
		} else {
			l = m;
		}
	}
	return v.size() - r;
}


int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		b.push_back(t);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < N; j++) {
			int cur = b[i] & ((1 << j) - 1);
			if (b[i] & (1 << j)) {
				v[j][1].push_back(cur);
			} else {
				v[j][0].push_back(cur);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 2; j++) {
			sort(v[i][j].begin(), v[i][j].end());
		}
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < N; j++) {
			int ba;
			if (a[i] & (1 << j)) {
				ba = 1;
			} else {
				ba = 0;
			}
			int la = a[i] & ((1 << j) - 1);
			int cnt = 0;
			for (int k = 0; k < 2; k++) {
				// find number of v[j][k] entries: la + v[j][k] >= (1 << j)	
				int bound = (1 << j) - la;
				int nover =  bins(v[j][k], bound);
				int nunder = v[j][k].size() - nover;	
				if (k == ba) {
					cnt += nover;
				} else {
					cnt += nunder;		
				}
			}
			cnt &= 1;
			ret ^= (cnt << j);
		}
	}
	cout << ret << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  string S;
  cin >> S;
  int minn = 99999999;
  for(int i = 0; i < S.size()-2; i++){
    int x = stoi(S.substr(i, 3));
    minn = min(minn, abs(x - 753));
  }
  cout << minn <<endl;
}


Measured memory_bytes: 3632
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    a = list(map(int,input().split()))

    m = INF
    idx_m = -1
    M = -INF
    idx_M = -1
    for i in range(n):
        if M < a[i]:
            idx_M = i
            M = a[i]
        if m > a[i]:
            idx_m = i
            m = a[i]
    
    ans = []
    flag = False
    
    if m == 0 and M == 0:
        print(0)
        exit()
    elif m < 0 and M > 0:
        if abs(m) <= abs(M):
            flag = True
    elif m >= 0:
        flag = True
    
    
    if flag:
        for i in range(n):
            if a[i] < 0:
                a[i] += M
                ans.append((idx_M + 1, i + 1))
        for i in range(n-1):
            if a[i] > a[i+1]:
                a[i+1] += a[i]
                ans.append((i + 1, i + 2))
    else:
        for i in range(n):
            if a[i] > 0:
                a[i] += m
                ans.append((idx_m + 1, i + 1))
        for i in range(n-2,-1,-1):
            if a[i] > a[i + 1]:
                a[i] += a[i+1]
                ans.append((i + 2, i + 1))
    
    l = len(ans)
    print(l)
    for i in range(l):
        print(*ans[i])

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	map <int, int> mp;
	vector <int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		mp[A[i]]++;
	}
	ll total = 0;
	int mx = 0;
	for (auto g : mp) {
		total += (g.ss - 1);
		mx = max(mx, g.ss - 1);
	}
	if (2 * mx > total) {
		ll rem = mx - (total - mx);
		if (rem >= (int) mp.size()) {
			cout << 1;
		}
		else {
			cout << (int) mp.size() - rem;
		}
	}
	else {
		if (total % 2 == 1) {
			cout << (int) mp.size() - 1;
		}
		else {
			cout << (int) mp.size();
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) cout << setfill('0') << setw(len) << right << a << endl;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

bool IsDivisible(int n) {
    for (int a = 0; a <= n / 4; ++a) {
        for (int b = 0; b <= n / 7; ++b) {
            if (4 * a + 7 * b == n) return true;
        }
    }
    return false;
}

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

    for (int a = 0; a <= n / 4; ++a) {
        for (int b = 0; b <= n / 7; ++b) {
            if (4 * a + 7 * b == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/5 22:51
 *
 */
public class Main {

    private static void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            max = Math.max(max, sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            min = Math.min(min, sc.nextInt());
        }
        if (max < min && max < y && min > x) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }
    }

    public static void main(String args[]) {

        solve(new Scanner(System.in));
    }
}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>edge[200005];
vector<int>edge2[200005];
int a,b,n;
P dp[200005];
int lca[200005][18],dist2[200005];
int calc(int x,int y){
	if(dist2[x] > dist2[y]) swap(x,y);
	rep(i,18){
		if((((dist2[y]-dist2[x])>>i)&1)){
			y = lca[y][i];
		}
	}
	for(int i=17;i>=0;i--){
		if(lca[x][i] != lca[y][i]){
			x = lca[x][i];
			y = lca[y][i];
		}
	}
	return (x==y?x:lca[x][0]);
}
bool fe;
int go(int a,int b){
	int c = calc(a,b);
	if(a == c){
		for(int i=0;i<18;i++){
			if((((dist2[b]-dist2[a]-1)>>i)&1)){
				b = lca[b][i];
			}
		}
		return b;
	}
	else{
		return lca[a][0];
	}
}
int ret = 0;
void dfs(int v,int u,int d){
	if(dp[v].fi >= 0){
		ret = max(ret,2*d+dp[v].fi*2);
	}
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		int D = dist2[v]+dist2[edge[v][i]]-2*dist2[calc(v,edge[v][i])];
		//cout << v << " " << edge[v][i] << " " << " " << calc(v,edge[v][i]) << D << endl;
		if(D>=3 && lca[edge[v][i]][0] != dp[v].sc && lca[dp[v].sc][0] != edge[v][i] && edge[v][i] != dp[v].sc){
			
			fe = 1;
		}
		else {
			D = dist2[edge[v][i]]+dist2[dp[v].sc]-2*dist2[calc(edge[v][i],dp[v].sc)];
			if(D<=1){
				dp[edge[v][i]] = max(dp[edge[v][i]],mp(0,edge[v][i]));
			}
			else{
				dp[edge[v][i]] = max(dp[edge[v][i]],mp(D-1,go(dp[v].sc,edge[v][i])));
				dfs(edge[v][i],v,d+1);
			}
		}
	}
}
void dfs2(int v,int u,int d){
	dist2[v] = d; lca[v][0] = u;
	for(int i=0;i<edge2[v].size();i++){
		if(edge2[v][i] == u) continue;
		dfs2(edge2[v][i],v,d+1);
	}
}
int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		edge[x].pb(y);
		edge[y].pb(x);
	}
	for(int i=1;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		edge2[x].pb(y);
		edge2[y].pb(x);
	}
	dfs2(b,-1,0);
	dp[a] = mp(dist2[a],b);
	for(int j=0;j<17;j++) for(int i=1;i<=n;i++){
		if(lca[i][j] == -1) lca[i][j+1] = -1;
		else lca[i][j+1] = lca[lca[i][j]][j];
	}
	dfs(a,-1,0);
	if(fe) puts("-1");
	else cout << ret << endl;
}

Measured memory_bytes: 49916
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

res = 0
for i in range(N):
    tmp1 = sum(A1[:N-i])
    tmp2 = sum(A2[-1-i:])
    res  = max(res,tmp1+tmp2)
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 6 + c[j] * 5.5;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    cout << fixed << setprecision(5);
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << sqrt(pow(x1-x2,2)+pow(y1-y2,2)) << endl;
}


Measured memory_bytes: 3284
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
using namespace std;
int vis[100005];
vector<int>vec[100005];
int bfs(int a)
{
   queue<int>q;
   queue<int>p;
   p.push(0);
   q.push(a);
   int res=0;
   while(!q.empty())
   {
      int u=q.front();
      q.pop();
      int v=p.front();
      p.pop();
      for(int i=0;i<vec[u].size();i++)
      {
         int c=vec[u][i];
         if(vis[c]==-1||v+1<vis[c])
         {
            vis[c]=v+1;
            q.push(c);
            p.push(v+1);
            res++;
         }
      }
   }
   return res;
}
int main()
{
   int n;
   scanf("%d",&n);
   for(int i=0;i<n-1;i++)
   {
      int a,b;
      scanf("%d%d",&a,&b);
      vec[a].push_back(b);
      vec[b].push_back(a);
   }
   memset(vis,-1,sizeof(vis));
   vis[1]=0,vis[n]=0;
   bfs(1);
   int sum=bfs(n);
   //cout<<sum<<endl;
   if(n-sum>sum+2)
      cout<<"Fennec"<<endl;
   else cout<<"Snuke"<<endl;
   return 0;
}


Measured memory_bytes: 6400
a, b = map(int, input().split())
s = input()
if s[a] == "-" :
    try :
        if (isinstance(int(s[:a]),int)) and (isinstance(int(s[a+1:]),int)) :
            print("Yes")
        else :
            print("No")
    except :
        print("No")
else :
    print("No")

Measured memory_bytes: 3060
import bisect

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    ans = 0
    for b in B:
        ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	ll a, b, x;
	cin >> a >> b >> x;
	if(a == 0){
		PrintLn((b / x) + 1);
	}else{
		PrintLn((b / x) - ((a - 1) / x));
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//Lying about Your Age
public class Main{

	int INF = 1<<29;
	
	int f(int x, int b){
		String res = "";
		while(x>0){
			int r = x%b;
			if(10<=r)return INF;
			res = r+res;
			x/=b;
		}
		return Integer.parseInt(res);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[201][17];
		for(int i=1;i<=200;i++)for(int j=2;j<=16;j++)a[i][j]=f(i, j);
		for(;;){
			int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt();
			if(A<0)break;
			int res = INF;
			for(int j=2;j<=16;j++)if(a[A][j]==B)res=B;
			for(int i=A+1;i<=C;i++){
				int next = INF;
				for(int j=2;j<=16;j++)if(res<=a[i][j])next = Math.min(next, a[i][j]);
				res = next;
			}
			System.out.println(res==INF?-1:res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env ruby

T1, T2, A1, A2, B1, B2 = 3.times.collect{gets.chomp.split(/ /).collect(&:to_i)}.flatten
delta1 = T1 * (B1 - A1)
delta2 = T2 * (B2 - A2)
if delta1 * delta2 > 0
  puts(0)
else
  if delta1.abs > delta2.abs
    puts(0)
  elsif delta1.abs == delta2.abs
    puts('infinity')
  else
    delta3 = Rational(-delta1, delta1 + delta2)
    puts(2 * delta3.floor + (delta3.ceil - delta3.floor))
  end
end

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll x;
  cin >> x;
  ll maxi = 0;
  for(int i = 1; i <= x; i++){
    for(int j = 2; j <= 1000; j++){
      if(pow(i, j) <= x) {
        maxi = max(maxi, (ll)pow(i, j));
      }
    }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int,input().split()))
MOD = 1000000007
count = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] > A[j]:
            count += 1
first = (count * K) % 1000000007

count2 = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            count2 += 1

#ans = ((count * K) + (count2 * K * (K-1) // 2)) % MOD
second = (count2 * (K*(K-1)//2)%MOD) % MOD

print(int((first+second)%MOD))
#print(ans)



Measured memory_bytes: 3188
n, k = gets.split(' ').map(&:to_i)
s = gets.chomp
a = []
n.times do |i|
  a << i if (i > 0 && s[i-1] != s[i])
end
if a[2*k].nil?
  puts n-1
else
  sum = 0
  arr = [0, *a[2*k..-1], n]
  arr.count.times do |i|
    next if i == 0
    sum += arr[i] - arr[i-1] - 1
  end
  p sum
end


Measured memory_bytes: 4348
// https://atcoder.jp/contests/abc065/tasks/abc065_d
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

struct edge {
    int from, to, cost;
};

int kruskal(int v, vector<edge> es) {
    sort(es.begin(), es.end(),
         [](edge &a, edge &b) { return a.cost < b.cost; });

    UnionFind uf(v);

    int res = 0;
    for (auto &e : es) {
        if (uf.unite(e.from, e.to)) {
            res += e.cost;
        }
    }

    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y;
    cin >> n;
    vector<P> vx(n), vy(n);
    REP(i, n) {
        cin >> x >> y;
        vx[i] = {x - 1, i};
        vy[i] = {y - 1, i};
    }
    sort(ALL(vx));
    sort(ALL(vy));
    vector<edge> e;
    FOR(i, 1, n) {
        e.push_back(
            {vx[i].second, vx[i - 1].second, vx[i].first - vx[i - 1].first});
        e.push_back(
            {vy[i].second, vy[i - 1].second, vy[i].first - vy[i - 1].first});
    }
    cout << kruskal(n, e) << endl;
    return 0;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define int long long
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define pb push_back
#define eb emplace_back
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

const int INF = 1e16;

struct Obj {
	int v, a, b;

	Obj(int x, int y, int z) {
		v = x, a = y, b = z;
	}

	Obj() {
		v = 0, a = 0, b = 0;
	}
};

int n, m, s, c[55], d[55];
vector<Obj> adj[55];
int dist[56 * 2600];
vector<pair<int, int>> graph[56 * 2600];

int encode(int i, int j) {
	return (i * 2501 + j);
}

bool visited[56 * 2600];

void build(int i, int j) {
	int yeet = encode(i, j);
		
	if (j < 2500) {
		graph[yeet].eb(encode(i, min(2500LL, j + c[i])), d[i]);
	}

	for (auto &p : adj[i]) {
		int c = p.v, cost = p.a, w = p.b;
		if (j >= cost) {
			graph[yeet].eb(encode(c, j - cost), w);
		}
	}
}

void dijkstra(int v) {
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;

	pq.push({0, v});
	dist[v] = 0;

	while (!pq.empty()) {
		int u = pq.top().second; pq.pop();

		if (visited[u]) continue;

		visited[u] = true;

		for (auto &p : graph[u]) {
			int c = p.first, w = p.second;
			if (dist[c] > dist[u] + w) {
				dist[c] = dist[u] + w;
				pq.push({dist[c], c});
			}
		}
	}
}

void solve() {
	cin >> n >> m >> s;

	FOR (i, 1, m) {
		int u, v, a, b; cin >> u >> v >> a >> b;

		adj[u].eb(v, a, b);
		adj[v].eb(u, a, b);
	}

	FOR (i, 1, n) cin >> c[i] >> d[i];

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= 2500; ++j) {
			build(i, j);
		}
	}

	// cerr << "here\n";

	fill(dist, dist + 56 * 2600, INF);

	dijkstra(encode(1, min(2500LL, s)));

	for (int i = 2; i <= n; ++i) {
		int ans = 1e15;
		for (int j = 0; j <= 2500; ++j) {
			ans = min(ans, dist[encode(i, j)]);
		}
		cout << ans << '\n';
	}
}

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

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

Measured memory_bytes: 24340
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int d = n%10;
  if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) {
    COUT("hon");
  } else if (d == 0 || d == 1 || d == 6 || d == 8) {
    COUT("pon");
  } else {
    COUT("bon");
  }

  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int A;
int B;






int main(void){
	
	cin >> N;
	cin >> A;
	cin >> B;
	
	cout << min(A*N,B) ;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = list(map(int,input().split()))
_max = s[0]
maxes = []
for i in s:
  maxes.append(max(_max,i))
  _max = max(_max,i)

if all([ k-j<=1 for j,k in zip(s,maxes)  ]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 65764
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2*1e5;
int n,A[MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	int l=1,r=0,F=0;
	long long ans=0;
	while(r<n)
	{
		while(r<n && !(F&A[r+1]))
		{
			r++;ans+=r-l+1;
			F^=A[r];
		}
		while(l<=r && (F&A[r+1]))
			F^=A[l++];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
n, q = gets.chomp.split.map(&:to_i)
h = {}
l = []
l[0] = nil
n.times do |i|
  h[i+1] = []
  l[i+1] = 0
end
(n-1).times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  h[a] << b
end
q.times do |i|
  pp, x = gets.chomp.split.map(&:to_i)
  l[pp] += x
end
s = [1]
while s != []
  hp = s.shift
  h[hp].each do |hhp|
    s << hhp
    l[hhp] += l[hp]
  end
end
print l[1]
2.upto(n) do |i|
  print " #{l[i]}"
end


Measured memory_bytes: 35380
class weight_union_find(object):
    def __init__(self, n):
        self.par = [-1 for i in range(n)]
        self.weight_diff = [0 for i in range(n)]
    
    def root(self, ind):
        if self.par[ind] < 0:
            return ind
        else:
            r = self.root(self.par[ind])
            self.weight_diff[ind] += self.weight_diff[self.par[ind]]
            self.par[ind] = r
            return r

    def unite(self, ind1, ind2, w):
        root1 = self.root(ind1)
        root2 = self.root(ind2)
        if root1 == root2:
            # 重みが違う==解無し
            # print(root1, root2, self.weight_diff[ind1], self.weight_diff[ind2], w)
            if -(self.weight_diff[ind1] - self.weight_diff[ind2]) == w:
                return True
            else:
                return False
        else:
            #swap
            if self.par[root1] > self.par[root2]:
                root1, root2 = root2, root1
                ind1, ind2 = ind2, ind1
                w *= -1
            self.par[root1] += self.par[root2]
            self.par[root2] = root1
            self.weight_diff[root2] = w + self.weight_diff[ind1] - self.weight_diff[ind2]
            return True



n, m = list(map(int, input().split()))
query = []
for i in range(m):
    query.append(list(map(int, input().split())))
uf = weight_union_find(n)
for l, r, d in query:
    if not uf.unite(l-1, r-1, d):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 57704
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <unordered_map>
#include <cstdint>
using namespace std;

struct v3 {
    int64_t x,y,z;
    
    v3 operator+(const v3& other) const
    {
        return {x + other.x, y + other.y, z + other.z};
    }

    int64_t value() const
    {
        return abs(x) + abs(y) + abs(z);
    }
    
    int64_t value(int flags) const
    {
        return (flags & 1 ? -x : x) + (flags & 2 ? -y : y) + (flags & 4 ? -z : z);
    }

};

int main(){
    size_t n,m;
    cin >> n >> m;
    
    vector<v3> cakes(n);
    for(auto& c : cakes)
    {
        cin >> c.x >> c.y >> c.z;
    }
    
    vector<int64_t> values;
    values.reserve(8);
    
    for(int i = 0; i < 8; ++i)
    {
        sort(begin(cakes), end(cakes), [=](const v3& a, const v3& b)
        {
            return a.value(i) > b.value(i);
        });
        values.push_back(accumulate(begin(cakes), begin(cakes) + m, v3{0,0,0}).value());
    }

    cout << *max_element(begin(values), end(values)) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, f[10005][2][100]; char s[10005];
int main() {
	scanf("%s", s+1), read(m);
	n = (int)strlen(s+1), f[0][1][0] = 1;
	for (int i = 0; i < n; i++) {
		int idx = s[i+1]-'0';
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < idx; k++)
				(f[i+1][0][(j+k)%m] += f[i][0][j]) %= P, 
				(f[i+1][0][(j+k)%m] += f[i][1][j]) %= P;
			(f[i+1][0][(j+idx)%m] += f[i][0][j]) %= P;
			(f[i+1][1][(j+idx)%m] += f[i][1][j]) %= P;
			for (int k = idx+1; k <= 9; k++)
				(f[i+1][0][(j+k)%m] += f[i][0][j]) %= P;
		}
	}
	return printf("%d\n", (f[n][0][0]+f[n][1][0]-1+P)%P), 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 3005
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,mo;
inline int ksm(int x,int y,int mo=::mo)
{
    int a=1;
    while(y)
    {
        if(y&1)a=1ll*a*x%mo;
        x=1ll*x*x%mo;y>>=1;
    }return a;
}
inline void Add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
inline int add(int x,int y){x+=y;return x>=mo?x-mo:x;}
int C[maxn][maxn],S[maxn][maxn];
int main()
{
    n=read(),mo=read();
    reg int i,j;
    for(i=0;i<=n;++i)
        for(C[i][0]=S[i][0]=1,j=1;j<=i;++j)
        {
            C[i][j]=add(C[i-1][j],C[i-1][j-1]);
            S[i][j]=add(S[i-1][j-1],1ll*(j+1)*S[i-1][j]%mo);
        }
    reg int res,ans=0;
    for(i=0;i<=n;++i)
    {
        res=0;
        for(j=0;j<=i;++j)Add(res,1ll*S[i][j]*ksm(ksm(2,n-i),j)%mo);
        res=1ll*res*ksm(2,ksm(2,n-i,mo-1))%mo*C[n][i]%mo;
        if(i&1)Add(ans,mo-res);else Add(ans,res);
    }
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69504
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 11;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	fread(cn, 1, cm, stdin);
	int N = getint(), W = getint();

	ll dp[100001] = {};
	rep(i, N) {
		int w = getint();
		int v = getint();
		rep (j, W - w + 1) {
			chmax(dp[j], dp[j + w] + v);
		}
	}

	printf("%lld", dp[0]);

	Would you please return 0;
}

Measured memory_bytes: 896
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b});
	return 0;
}



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

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int W, H, N;
	
	cin >> W >> H >> N;

	int x[N],y[N],a[N];

	int left_x=0, right_x=W, high_y=H, low_y=0;
	int s = 0;

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

		if (a[i] == 1)
		{
			if (left_x < x[i])
			{
				left_x = x[i];
			}
		}
		if (a[i] == 2)
		{
			if (right_x > x[i])
			{
				right_x = x[i];
			}

		}
		if (a[i] == 3)
		{
			if (low_y < y[i])
			{
				low_y = y[i];
			}
		}
		if (a[i] == 4)
		{
			if (high_y > y[i])
			{
				high_y = y[i];
			}
		}
		
	}

	if ((high_y < low_y) || (right_x < left_x))
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (high_y - low_y) * (right_x - left_x) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().Select(long.Parse).ToArray();
		var x = p[0];
		var k = p[1];
		var d = p[2];
		
		long kaisu = Math.Abs(x) / Math.Abs(d);
		
		if(kaisu <= k)
		{
			if(k%2 == kaisu % 2)
			{
				if(x > 0)
				{
					Console.WriteLine(Math.Abs( x - kaisu * d));
				}
				else
				{
					Console.WriteLine(Math.Abs( x + kaisu * d) );
				}
			}
			else
			{
				Console.WriteLine(Math.Min(Math.Abs( Math.Abs(x) - d*(kaisu-1)), Math.Abs( Math.Abs(x) - d*(kaisu+1))));
			}

			return;
		}
		
		Console.WriteLine(Math.Abs(Math.Abs(x) - k * d));
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


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

int main(){
	int A,B,K;
	cin >> A >> B >> K;
	int count = 0;
	for(int i = min(A,B); i > 0; i--){
		if(A % i == 0 && B % i == 0){
			count++;
		}
		if(count == K){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size()/2; i++)
    {
        if (S.at(i) != S.at(S.size()-i-1))
        {
            ans++;
        }
        
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int m;
    cin >> m;
    cout << 48-m << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl c(n-1),s(n-1),f(n-1);
        rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
        rep(i,n){
            ll t=0;
            rep2(j,i,n-1){
                if(t<s[j])t=s[j];
                else if(t%f[j]!=0)t+=f[j]-t%f[j];
                t+=c[j];
            }
            cout<<t<<endl;
        }
    }

Measured memory_bytes: 3528