akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n, k;
  cin >> n >> k;
  vector<i64> left, right;
  right.push_back(0ll);
  rep(i, 0, n) {
    i64 x;
    cin >> x;
    if(x < 0) left.push_back(abs(x));
    else right.push_back(x);
  }
  left.push_back(0ll);
  reverse(all(left));

  i64 ans = 1e18;
  rep(i, 0, left.size()) {
    if(k - i < right.size()) {
      i64 res = left[i] * 2 + right[k - i];
      ans = min(ans, res);
    } 
  }
  rep(i, 0, right.size()) {
	if(k - i < left.size()) {
      i64 res = right[i] * 2 + left[k - i];
      ans = min(ans, res);
    }
  }
  cout << ans << endl;
}


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

int main() {
    //
    int w, h, num;
    int tmpW, tmpH, que;
    int cnt = 0;
    cin >> w >> h >> num;

    vector<vector<int>> data(w, vector<int>(h));

    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) data.at(i).at(j) = 0;
    }

    for (int i = 0; i < num; i++) {
        //
        cin >> tmpW >> tmpH >> que;
        if (que == 1) {
            for (int i = 0; i < tmpW; i++) {
                //
                for (int j = 0; j < h; j++) {
                    //
                    data.at(i).at(j) = 1;
                }
            }
        } else if (que == 2) {
            for (int i = tmpW; i < w; i++) {
                //
                for (int j = 0; j < h; j++) {
                    //
                    data.at(i).at(j) = 1;
                }
            }
        } else if (que == 3) {
            for (int i = 0; i < w; i++) {
                //
                for (int j = 0; j < tmpH; j++) {
                    //
                    data.at(i).at(j) = 1;
                }
            }
        } else if (que == 4) {
            for (int i = 0; i < w; i++) {
                //
                for (int j = tmpH; j < h; j++) {
                    //
                    data.at(i).at(j) = 1;
                }
            }
        }
    }

    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (data.at(i).at(j) == 0) cnt++;
        }
    }

    cout << cnt;
    //
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の標準入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		// 入力した整数の積が偶数かどうか
		if(a * b % 2 == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();
	}
}

Measured memory_bytes: 23636
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        long A = scanner.nextLong();

        List<List<Long>> list = new ArrayList<>();
        long min = 0;
        long max = 0;
        for (int i = 0; i < 40; i++) {
            long v = (long)Math.pow(-2, i);
            if (v > 0) {
                max += v;
            } else {
                min += v;
            }
            List<Long> l = new ArrayList<>();
            l.add(min);
            l.add(max);
            list.add(l);
        }

        StringBuilder sb = new StringBuilder();
        for (int i = list.size() - 1; i >= 0; i--) {
            if (i == 0) {
                if (A == 0) {
                    sb.append("0");
                } else {
                    sb.append("1");
                }
            } else {
                List<Long> current = list.get(i);
                List<Long> prev = list.get(i-1);
                if (current.get(0) <= A
                    && current.get(1) >= A
                    && !(prev.get(0) <= A &&
                         prev.get(1) >= A)) {
                    sb.append("1");
                    A -= (long)Math.pow(-2, i);
                } else {
                    if (sb.length() != 0) {
                        sb.append("0");
                    }
                }
            }
        }
        System.out.println(sb);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int mn=INT_MAX;
  int ans=n;
  for(int i=0;i<n;i++){
    int p;cin>>p;
    mn=min(mn,p);
    if(mn<p){
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == s[i + 1])
            score++;
    }
    int ans = min(score + 2 * k, n - 1);
    cout << ans << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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


int h[ 110 ];
int N;

int Counter( int A )
{
int i;
int iCnt;
int iFlag;

	iFlag = 0;
	iCnt = 0;
	for( i = 0; i < N; i++ )
	{
		if( h[ i ] > A )
		{
			if( iFlag == 0 )
			{
				iCnt++;
				iFlag = 1;
			}
		}
		else
			iFlag = 0;
	}

	return iCnt;
}

int main()
{
int i;
int j;

int iCnt;


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

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

	i = 0;
	iCnt = 0;
	while( true )
	{
		j = Counter( i );
		if( j <= 0 ) break;

		iCnt += j;
		i++;
	}

	cout << iCnt << endl;

	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const double EPS = 1e-10;

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

    int ans = INF;
    int cnt;
    for (int i = 0; i < S.length() - T.length() + 1; i++)
    {
        cnt = 0;
        for (int j = 0; j < T.length(); j++)
        {
            if (S[i + j] != T[j])
            {
                cnt++;
            }
        }
        // printf("cnt = %d\n", cnt);
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        // assume that n > 0 && n <= N
        map<int, int> factors(int n) {
            // assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (is_prime(i)) {
                    p.push_back(i);
                }
            }
        }

        // assume that n > 0 && n <= N
        bool is_prime(const int n) {
            // assert(n > 0 && n <= N);
            return numbers[n] == n;
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

const int MAX_A = 60000;

EratosthenesSieve *sieve;

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

    sieve = new EratosthenesSieve(MAX_A);
    vector<int> ps;
    sieve->primes(ps);

    // nearly 6000
    // printf("%ld\n", ps.size());

    vector<int> ans;
    for (auto p : ps) {
        if (p % 5 == 2) {
            ans.push_back(p);
            if ((int) ans.size() == N) {
                break;
            }
        }
    }

    printf("%d", ans[0]);
    for (int i = 1; i < N; i++) {
        printf(" %d", ans[i]);
    }
    printf("\n");

    delete sieve;
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,p,q,sum=0,ans=-LINF;
	cin>>n>>p>>q;
	vl c(n),val(n);
	rep(i,n){
		cin>>c[i];
		sum+=c[i];
		val[i]=(p*i+c[i]);
	}
	sort(all(val));
	rep(i,n-1)val[i+1]+=val[i];
	ans=sum;
	rep(i,n){
		chmax(ans,sum+(i+1)*p*(i+q)-val[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 10736
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// DIGNUM
std::vector<ll> dignum(ll x) {
  if (x == 0) return {0};
  std::vector<ll> res;
  while (x) {
    res.push_back(x % 10);
    x /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  ll A, B, N;
  std::cin >> A >> B >> N;

  ll x = std::min(N, B - 1);
  ll res = (A * x) / B - A * (ll)(x / B);
  print(res);

  return 0;
}


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

int main() {
  constexpr int c[] = {1, 5, 10, 50, 100, 500};
  int sum = 0;
  for (int i = 0; i < 6; i++) {
    int t;
    cin >> t;
    sum += t * c[i];
  }
  cout << (sum / 1000 ? 1 : 0) << "\n";
}


Measured memory_bytes: 3100
package main

import (
    "fmt"
)

func main() {
    var n int
    h := map[int]int{}
    
    fmt.Scanf("%d", &n)

    for i := 0; i < n; i++ {
        var s int
        _, err := fmt.Scanf("%d", &s)
        if (nil != err) {
            break;
        }
        
        h[s] = i+1
    }
    
    for i := 0; i < n; i++ {
        fmt.Print(h[i+1], " ")
    }
}

Measured memory_bytes: 8576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        PowerfulDiscountTickets solver = new PowerfulDiscountTickets();
        solver.solve(1, in, out);
        out.close();
    }

    static class PowerfulDiscountTickets {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            PriorityQueue<Integer> pq = new PriorityQueue<>(n, (o1, o2) -> Integer.compare(o2, o1));
            for (int i = 0; i < n; i++) {
                pq.add(in.nextInt());
            }
            while (m > 0) {
                Integer max = pq.poll();
                max /= 2;
                m--;
                pq.add(max);
            }
            long result = 0;
            for (Integer integer : pq) {
                result += integer;
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 61208
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

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

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ull a[100];

int main() {
	//PLAY();
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i < 100; i++)
		a[i] = a[i - 1] + a[i - 2];
	int n;
	cin >> n;
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main() {
    
    int X,Y,Z;
    cin >> X >> Y >> Z;
    
    swap(X, Y);
    swap(X, Z);
    
    cout << X << " " << Y << " " << Z << endl;

}

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

typedef pair<int, int> P;
struct edge{int to, cost;};

static const int MAX_N = 3000;
static const int INF = 1 << 30;

int N, M, K;
vector<edge> G[MAX_N];
int dist[MAX_N];

int main(){
	scanf("%d %d %d", &N, &M, &K);
	for(int i = 0; i < M; i++){
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		a--; b--;
		G[a].push_back((edge){b, l});
		G[b].push_back((edge){a, l});
	}
	fill(dist, dist + N, INF);
	for(int i = 0; i < K; i++){
		int s;
		scanf("%d", &s);
		s--;
		dist[s] = 0;
		priority_queue<P, vector<P>, greater<P> > pqa;
		pqa.push(P(0, s));
		while(!pqa.empty()){
			P p = pqa.top(); pqa.pop();
			int d = p.first;
			int u = p.second;
			if(dist[u] < d) continue;
			for(int j = 0; j < G[u].size(); j++){
				edge e = G[u][j];
				if(dist[e.to] > dist[u] + e.cost){
					dist[e.to] = dist[u] + e.cost;
					pqa.push(P(dist[e.to], e.to));
				}
			}
		}
	}
	int res = 0;
	for(int i = 0; i < N; i++) res = max(res, dist[i]);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < G[i].size(); j++){
			if(G[i][j].cost < abs(dist[i] - dist[G[i][j].to])) continue;
			int mid_dist = dist[i] + dist[G[i][j].to] + G[i][j].cost;
			mid_dist = (mid_dist % 2 == 0 ? mid_dist / 2 : mid_dist / 2 + 1);
			res = max(res, mid_dist);
		}
	}
	printf("%d\n", res);
	return 0;
}



Measured memory_bytes: 5616
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, L: "List[int]"):
    D = 0
    count = 1
    for i in range(N):
        D = D + L[i]
        if D <= X:
            count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    L = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=int(input())
dp=[[[[0]*4 for i in range(4)] for j in range(4)] for k in range(n)]
mod=10**9+7
for i in range(4):
  for j in range(4):
    for k in range(4):
      if (i,j,k) in ((1,2,3),(1,3,2),(2,1,3)):
        continue
      dp[2][i][j][k]+=1
#t→0 a→1 g→2 c→3
for i in range(1,n):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        for m in range(4):
          if (k,l,m) in ((1,2,3),(2,1,3),(1,3,2)):
            continue
          if (j,l,m)==(1,2,3) or (j,k,m)==(1,2,3):
            continue
          dp[i][k][l][m]+=dp[i-1][j][k][l]
          dp[i][k][l][m]%=mod
ans=0
#print(dp)
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans+=dp[n-1][i][j][k]
      ans%=mod
print(ans)

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	int K;
	cin >>S >>K;
	int N=S.size();
	vector<int> A;
	A.push_back(0);
	Rep0(i, N)
		A.push_back(S.at(i)-'0');
	N++;
	vector<vector<int>>	DPOK(N, vector<int> (K+1, 0));
	vector<vector<int>>	DPUK(N, vector<int> (K+1, 0));
	DPUK.at(0).at(K)=1;
	Rep0(i, N-1) {
		Rep0(k, K+1) {
			// for DPOK
			DPOK.at(i+1).at(k) +=DPOK.at(i).at(k);			// next 0
			if (k>0)
				DPOK.at(i+1).at(k-1) +=DPOK.at(i).at(k)*9;	// next 1-9
			// for DPUK
			if (0==A.at(i+1)) {
				DPUK.at(i+1).at(k) +=DPUK.at(i).at(k);		// next =0, still unknown
			} else { // 0<A.at(i+1)
				DPOK.at(i+1).at(k) +=DPUK.at(i).at(k);		// next =0, OK
				if (k>0) {
					DPOK.at(i+1).at(k-1) +=DPUK.at(i).at(k)*(A.at(i+1)-1);	// next =1 - A(i+1)-1, OK
					DPUK.at(i+1).at(k-1) +=DPUK.at(i).at(k);	// next =A(i+1), unknown
				}
			}
		}
	}
	int SS=DPOK.at(N-1).at(0)+DPUK.at(N-1).at(0);
	cout <<SS <<endl;
	return 0;
}



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

int main(){
  int N ,ans=0;
  cin>>N;
  int tmp=N;
  while(tmp!=0){
    ans+=tmp%10;
    tmp/=10;
  }
  if(N%ans==0){
    cout<<"Yes"<<endl;
  }else {
    cout<<"No"<<endl;
  }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  string S, T; cin >> S >> T;
  cout << T << S << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int[] a = r.ii();
        Arrays.sort(a);
        println(a[0]+a[1]);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21204
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [0]
    for i in range(1, 50000):
        a.append(a[-1] + i)

    t = bisect.bisect_left(a, n)
    r = [1] * t + [0] * t
    for i in range(t):
        ai = a[t-i]
        ti = t + i
        # print(n,ai,ti,''.join(map(lambda x: '()'[x], r)))
        if n < ai:
            ts = min(t, ai-n)
            r[ti],r[ti-ts] = r[ti-ts],r[ti]
            n -= t - ts
        else:
            break

    return ''.join(map(lambda x: '()'[x], r))




print(main())



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


/*  
    
*/

void test_case(){
    int n, k; cin >> n >> k;
    
    vector < int > l(k), r(k);
    for(int i = 0; i < k ; i++){
        cin >> l[i] >> r[i];
    }
     
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());    
    ll mod = 998244353;
    vector < ll > res(n, 0);
    res[0] = 1;
    
    vector < ll > sd(k, 0);
    for(int i = 1; i < n; i++){
        for(int j = 0; j < k; j++){
            if(  i - l[j] < 0 )
                continue;
                
            if( i - r[j] > 0){
                sd[j] += res[i-l[j]];
                sd[j] -= res[i-r[j]-1];
                
            }    
            else{
                sd[j] += res[i-l[j]];
            }
            //if( i == 1 && j == 
            
            sd[j] += mod;
            sd[j] %= mod;
            res[i] += sd[j];
            res[i] %= mod;
        }
    }
    
    cout << res[n-1] << endl;
}

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

    int t; t = 1;
    //cin >> t;
    while(t--)
        test_case();
    return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	double k, n;
	double ans = 0, cnt = 1;
	cin >> n >> k;
	int z = k;
	int xyz = n;
	bool bou = true;
	while (1) {
		if (n == 0) break;
		if (n >= k) {
			int x = floor(k);
			if (bou) x--;
			ans += ((n - x) * cnt) / xyz;
			n = x;
		}
		if (z % 2 == 1) {
			bou = false;
		}
		z /= 2;
		k /= 2;
		cnt /= 2;
	}
	printf("%.12lf\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e6+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve() {
    int n, k;
    cin >> n >> k;
    vector< int > v(n+1) , vis(n+1 , 0);
    for(int i=1;  i<=n ; i++){
        cin >> v[i];
    }
    int start = 1, cnt = 0;
    while(vis[start]==0){
        vis[start] = ++cnt;
        start = v[start];
        k--;
        if(k == 0){
            cout << start << endl;
            return;
        }
    }
//    cout << cnt << " " << vis[start] << endl;
    int cylce_contains = cnt - vis[start]+1;
    k = k%cylce_contains;
    while(k--){
        start= v[start];
    }
    cout << start << endl;


}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

int digit_sum(int a){

  string s;
  s = to_string(a);

  int ret = 0;
  rep(i, s.length()){
    ret += int(s[i]-'0');
  }

  return ret;

}

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

  int n;
  cin >> n;

  int ans = 1e8;

  for(int i = 1; i <= n-1; i++){
    chmin(ans, digit_sum(i) + digit_sum(n-i));
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
/* C */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

#define MOD 1000000007

int main(){
	long long int n, m;
	cin >> n >> m;
	std::vector<long long int> a(n+1);
	std::vector<long long int> v(n+1, 0);
	
	long long int k;
	for (long long int i = 0; i < m; ++i)
	{
		cin >> k;
		v[k] = 1;
	}

	a[0] = 1;
	if (v[1] == 1){
		a[1] = 0;
	}else{
		a[1] = 1;
    }

	for (long long int i = 1; i < n; ++i)
	{
		if(v[i+1] == 0){
			a[i+1] = (a[i] + a[i-1]) % MOD;
		}else{
			a[i+1] = 0;
		}
	}

	cout << a[n] << endl;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int x[110][110];

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

  int n,d;
  string s;

  cin >> n >> d;
  REP(i, n) REP(j, d) cin >> x[i][j];
  int cnt = 0;
  REP(i, n) {
    FOR(j,i+1,n) {
      ll sum = 0LL;
      REP(k, d){
	sum += pow(x[i][k]-x[j][k],2);
      }
      int ssum = sqrt(sum);
      //cerr << ssum << endl;
      if((int)(ssum*ssum) == sum) cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
N =int(input())
L = list(map(int, input().split()))

import itertools
comb = itertools.combinations(L, 3)
ans = 0
for c in comb:
  if len(set(c)) !=3:
    continue
  tmp = sorted(c)
  if tmp[2] < tmp[1] + tmp[0]:
    ans +=1
print(ans)

Measured memory_bytes: 9184
#include<cstdio>
#include<iostream>
using namespace std;
int dp[101][10001], v[101], w[101];
int Max(int a, int b){
	return a >= b ? a : b;
}
int main(){
	int N, W;
	cin >> N >> W;
	for (int i = 1; i <= N; i++){
		cin >> v[i] >> w[i];
	}
	for (int j = 0; j <= W; j++){
		dp[0][j] = 0;
	}
	for (int i = 1; i <= N; i++)
		for (int j = 0; j <= W; j++){
			if (j < w[i])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = Max(dp[i][j - w[i]] + v[i], Max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]));
		}
	cout << dp[N][W] << endl;
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> vec = {a,b,c};
  sort(vec.begin(),vec.end());
  cout << vec.at(1)-vec.at(0) + vec.at(2) - vec.at(1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int X, A, B;
    cin >> X >> A >> B;

    cout << (X - A) % B << endl;
    return 0;
}


Measured memory_bytes: 892
using System;

using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int ocha = int.Parse(s[0]);
            int mizu = int.Parse(s[1]);
            int cola = int.Parse(s[2]);

            if (ocha > mizu)
            {
                int n = mizu;
                mizu = ocha;
                ocha = n;
            }

            if (mizu > cola)
            {
                int n = mizu;
                mizu = cola;
                cola = n;
            }

            if (ocha > mizu)
            {
                int n = mizu;
                mizu = ocha;
                ocha = n;
            }
            Console.WriteLine(ocha + " " + mizu + " " + cola);



            //if(a<b&&b<c)    // ??????
            //{
            //    Console.WriteLine("Yes");

            //}
            //else
            //{
            //    Console.WriteLine("No");

            //}

            //if(a<b||b<c)    // ?????????
            //{

            //}
            //else
            //{ 
            //}






            //int a = int.Parse(s[0]);
            //int b = int.Parse(s[1]);

            //if (a < b)
            //{
            //    Console.WriteLine("a < b");

            //}

            //else if (a >b)
            //{
            //    Console.WriteLine("a > b");

            //}
            //else if (a == b)
            //{
            //    Console.WriteLine("a == b");
            //}




            //int n = int.Parse(s);

            //int h = n / 3600;
            //int m = (n - h * 3600) / 60;
            //int s2 = n % 60;


            //Console.WriteLine(h+":"+m+":"+s2);



            //int tate = int.Parse(s[0]);
            //int yoko = int.Parse(s[1]);

            //int area = tate * yoko;
            //int rect = (tate + yoko )* 2;

            //Console.WriteLine(area + " "+rect);

        }
    }
}

Measured memory_bytes: 17900
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	ans := 0
	switch S {
	case "SUN":
		ans = 7
	case "MON":
		ans = 6
	case "TUE":
		ans = 5
	case "WED":
		ans = 4
	case "THU":
		ans = 3
	case "FRI":
		ans = 2
	case "SAT":
		ans = 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
X, N = map(int, input().split())

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

if N == 0:
    print(X)
    exit()

diff = 0
high = low = None
while True:
    if X + diff not in P:
        high = X + diff
    if X - diff not in P:
        low = X - diff
    if high is None and low is None:
        diff += 1
        continue

    if high == low:
        print(low)
    elif low is None:
        print(high)
    else:
        print(low)
    break


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  Int n;
  cin>>n;
  vector<string> ts(n),as(n),ds(n);
  for(Int i=0;i<n;i++) cin>>ts[i]>>as[i]>>ds[i];

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    if(i) cout<<endl;
    string a,b,c,d;
    cin>>a>>b>>c>>d;
    for(Int j=0;j<n;j++){
      Int flg=1;
      if(a!="*"){
	flg&=ts[j].find(a)!=string::npos;
      }
      if(b!="*"){
	flg&=as[j].find(b)!=string::npos;
      }
      if(c!="*"){
	flg&=ds[j]>=c;
      }
      if(d!="*"){
	flg&=ds[j]<=d;
      }
      
      if(flg) cout<<ts[j]<<endl;
    }
  }
    
  return 0;
}



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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if (n == 0) {
        cout << 2;
    } else if (n == 1) {
        cout << 1;
    } else {
        long long l2 = 2;
        long long l1 = 1;
        long long a = 3;
        while (n >= 2) {
            a = l1 + l2;
            l2 = l1;
            l1 = a;
            n--;
        }
        cout << a;
    }
    cout << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    long[] L=new long[90];
	    L[0]=2;
	    L[1]=1;
	    int i=2;
	    while(i<=n) {
	    	L[i]=L[i-1]+L[i-2];
	    	i++;
	    }
	    System.out.print(L[n]);
//	    if (a+b==15) {
//	    	System.out.print("+");
//	    }else if(a*b==15) {
//	    	System.out.print("*");
//	    } else {
//	    	System.out.print("x");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35532
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int n8 = sc.nextInt();
        int n10 = sc.nextInt();
        for(int i = 1; i <= 1000; i++){
        	if((int)(i * 0.08) == n8 && (int)(i * 0.1) == n10){
            	System.out.println(i);
                return;
            }
        }
        System.out.println("-1");
    }
} 

Measured memory_bytes: 35744
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[110];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    ll cnt[10] = {};
    ll tt = 0;
    rep(i,0,N){
        ll v = a[i]/400;
        if(v >= 8){
            tt++;
        }else{
           cnt[v]++; 
        }
    }
    ll vv = 0;
    rep(i,0,8){
        if(cnt[i] != 0){
            vv++;
        }
    }
    cout << (ll)max(1LL,vv) << " ";
    cout << vv + tt << endl;

}


Measured memory_bytes: 256