akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  if(s[0] == s[1] && s[0] == s[2]){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
 
  return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, x; cin >> a >> b >> x;
  YES(a<=x and x<=a+b);
  

    return 0;
}


Measured memory_bytes: 256
#define alphanso                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL)
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main()
{
	alphanso;
	ull n, i, mx;
	cin>>n;
	ull p[n+5], a[n+5], b[n+5], value[n+5];
	for(i=1; i<=n; i++){
		cin>>p[i];
		value[p[i]]=p[i]+i;
	}
	for(i=1; i<=n; i++){
		a[i]=value[i]+n*i;
	}
	mx=n+1;
	for(i=1; i<=n; i++){
		b[i]=mx*(mx-i);
	}
	for(i=1; i<=n; i++) cout<<a[i]<<" ";
	cout<<endl;
	for(i=1; i<=n; i++) cout<<b[i]<<" ";
	return 0;
}


Measured memory_bytes: 4240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[3333][3333];
ll v[3333];

ll solve(int l,int r){
    if(l>r)return 0;
    if(l==r)return v[l];
    if(dp[l][r]!=-ll(1e18))return dp[l][r];
    return (dp[l][r]=max(v[l]-solve(l+1,r),v[r]-solve(l,r-1)));
    
}

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++)cin>>v[i];
    for(int i=0;i<3333;i++)for(int j=0;j<3333;j++)dp[i][j]=-ll(1e18);
    cout<<solve(0,n-1);
    
}

Measured memory_bytes: 87168
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<vector<char>> s(n, vector<char>(2*n+1));
    rep(i, n){
        rep(j, n){
            cin >> s[i][j];
        }
    }
    rep(i, n){
        for(int j = n; j < 2 * n; j++){
            s[i][j] = s[i][j-n];
        }
    }

    int ans = 0;
    rep(i, n){
        bool ok = true;
        for(int h = 0; h < n; h++){
            for(int w = i; w < n + i; w++){
                if(s[h][w] != s[w-i][h+i]){
                    ok = false;
                }
            }
        }

        if(ok){
            ans += n;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i=0; i<M; i++) cin >> a[i] >> b[i];
  vector<bool> memo1(N, false), memo2(N, false); 
  // memo1には「島1と島iとの間に経路が存在するかどうか」を格納
  // memo2には「島iと島Nとの間に経路が存在するかどうか」を格納
  for (int i=0; i<M; i++) {
    if (a[i]==1) memo1[b[i]-1] = true;
    if (b[i]==N) memo2[a[i]-1] = true;
  }
  bool can = false;
  for (int i=0; i<N; i++) {
    if (memo1[i]&&memo2[i]) can = true;
  }
  if (can) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e6+10, maxm=5e4+10, lg=21, mod=998244353, inf=1e18;

ll pwm(ll a,ll b){ll ret=1;for(;b;b>>=1,(a*=a)%=mod)if(b&1)(ret*=a)%=mod;return ret;}
ll n,hh[maxn],cnt[maxn],ans;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	while(n--){ll x;cin>>x;cnt[x]++;}
	for(ll i=maxn-1;i;i--){
		ll sum=0,kk=0;
		for(ll j=i;j<maxn;j+=i) (sum+=j*cnt[j]%mod)%=mod,(kk+=j*j%mod*cnt[j]%mod)%=mod,(hh[i]+=mod-hh[j])%=mod;
		(hh[i]+=(sum*sum-kk+mod)%mod*pwm(2,mod-2)%mod)%=mod;
		(ans+=hh[i]*pwm(i,mod-2)%mod)%=mod;
	}
	cout<<ans;
	
	return 0;
}



 


Measured memory_bytes: 19240
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			boolean[][] cards = new boolean[128][14];
			int N = sc.nextInt();
			for(int i = 0; i < N; i++) {
				String c = sc.next();
				int n = sc.nextInt();
				cards[c.charAt(0)][n] = true;
			}
			for(char c: new char[]{'S', 'H', 'C', 'D'}) {
				for(int n = 1; n <= 13; n++){
					if(!cards[c][n]) {
						System.out.printf("%s %d\n", c, n);
					}
				}
			}
	 	}
	}
}



Measured memory_bytes: 26424
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

bool vis[300010];
int C = 0;
void DFS(vector<int> G[], int v){
      vis[v] = 1;
      for(int u : G[v]){
          if(!vis[u]){
              C++;
              DFS(G, u);
          }
      }
}

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    
   int n, m;
   cin >> n >> m;
   vector<int> G[n + 1];
   for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        G[x].eb(y);
        G[y].eb(x);
   }
   int ans = 0;
   for(int i = 1; i <= n; i++){
         if(!vis[i]){
             C = 1;
             DFS(G, i);
             ans = max(ans, C);
         }
   }
   cout << ans << anal;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 24116
import scala.io.StdIn.readInt
import scala.annotation.tailrec

object Main {
  @tailrec def fib(a:Int, b:Int, c:Int, n:Int):Int = {
    n match {
      case 0 => a
      case n => fib(a+b, a, b, n-1)
    }
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, 0, n))
  }
}

Measured memory_bytes: 43720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;

    cin >> S;

    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

void B() {
    ll N, K;

    cin >> N >> K;

    vi snukes(N, 0);

    R1(K) {
        ll di;
        cin >> di;
        R2(j, di) {
            ll ai;
            cin >> ai;
            snukes[ai-1]++;
        }
    }

    ll tot = 0;
    for(auto e : snukes) {
        if(e == 0) {
            ++tot;
        }
    }

    cout << tot << endl;
}

void C() {
    ll N, M;

    cin >> N >> M;
    vi hi(N);
    vii ri(M);
    vi go(N, 1);

    R1(N)
        cin >> hi[i];

    R1(M) {
        ll s, e;
        cin >> s >> e;
        s-=1;
        e-=1;
        if(hi[s] > hi[e])
            go[e] = 0;
        else if(hi[s] < hi[e])
            go[s] = 0;
        else {
            go[e] = 0;
            go[s] = 0;
        }
    }

    ll tot = 0;
    for(auto e : go) {
        tot += e;
    }

    cout << tot << endl;
}

void D() {
    ll X;

    cin >> X;

    for(ll A = -6207; A < 6207; ++A) {
        for(ll B = -6207; B < 6207; ++B) {
            if((A*A*A*A*A) - (B*B*B*B*B) == X) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }
}

int main()
{
    D();
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<set>
#include<utility>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<cinttypes>
#include<stack>
#include<ctgmath>
using namespace std;

typedef long long ll;


#define ceil(a,b)  ( !(a%b) ? a/b : a/b+1 )
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define endl '\n' 
#define debug(a) cin>>#a>>a;
//vector<ll> primes{ }
template<typename T>
T gcd( T a, T b ) { 
    return !a ? b : gcd( b%a, a); 
}

template<typename T>
T lcm( T a, T b ){
    return (a*b)/gcd(a,b); 
} 

int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    reverse(sa.begin(),sa.end());
    reverse(sb.begin(),sb.end());
    reverse(sc.begin(),sc.end());
    char check = sa.back();
    sa.pop_back();
    if( sa.empty() ){
        std::cout << 'A' << endl;
    } else {
        bool flag = false;
        while(true){
            switch(check){
                case 'a':
                    if( sa.empty() ){
                        cout << 'A' << endl;
                        flag = true;      
                    } else {
                        check = sa.back();
                        sa.pop_back();
                    }
                    break;
                case 'b':
                    if( sb.empty() ){
                        cout << 'B' << endl;
                        flag = true;      
                    } else {
                        check = sb.back();
                        sb.pop_back();
                    }
                    break;
                case 'c':
                    if( sc.empty() ){
                        cout << 'C' << endl;
                        flag = true;      
                    } else {
                        check = sc.back();
                        sc.pop_back();
                    }
                    break;
            }
            if(flag){
                break;
            }
        }
    }
    return 0;
}


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

int main() {
    vector< long long > v(3);
    for (long long& x : v) cin >> x;
    sort(v.begin(), v.end());
    int k;
    cin >> k;
    while(k--) v.back() *= 2;
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
const double eps=0.00000001;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
int main(){
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i]>>B[i];
    sort(all(A));
    sort(all(B));
    if(N%2==0){
        ll A_m=A[N/2]+A[N/2-1],B_m=B[N/2]+B[N/2-1];
        
        cout<<B_m-A_m+1<<endl;
    }
    else{
        //[N/2]
        cout<<B[N/2]-A[N/2]+1<<endl;
    }
}



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

typedef long long ll;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define mset(a,b) memset(a,b,sizeof(a))
#define pb push_back

const int N=1e5+15;
const ll MOD=1e9+7;
int n,x,pa[N];
ll dp[N][2];
vector<int>g[N];

ll dfs(int v,bool c) {
  if(v && g[v].size()==1)return 1;
  if(dp[v][c]!=-1)return dp[v][c];
  ll res=1;
  for(int i:g[v])if(i!=pa[v]) {
    pa[i]=v;
    if(c)res=(res*dfs(i,!c))%MOD;
    else res=(res*((dfs(i,c)+dfs(i,!c))%MOD))%MOD;
  }
  return dp[v][c]=res;
}

int main() {
  ios::sync_with_stdio(false);
  mset(dp,-1);
  cin>>n;
  fore(i,0,n-1) {
    int x,y;
    cin>>x>>y;x--,y--;
    g[x].pb(y);
    g[y].pb(x);
  }
  pa[0]=-1;
  cout<<(dfs(0,1)+dfs(0,0))%MOD<<endl;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double

main(){
	int n;
  cin>>n;
  int count=0;
  rep(i,n){
    int a;
    cin>>a;
    while(1){
      if(a%2!=0) break;
      count++;
      a/=2;
  }
  }
  cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    p = a[i]
    q = a[i+1]
    if p + q > x:
        s = p + q - x
        ans += s
        a[i+1] = max(a[i+1] - s,0)
print(ans)
        


Measured memory_bytes: 14252
def fib(n):
    if n == 0: 
        return 0

    if n == 1: 
        return 1

    def matmul(M1, M2):
        a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0]
        a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1]
        a21 = M1[1][0]*M2[0][0] + M1[1][1]*M2[1][0]
        a22 = M1[1][0]*M2[0][1] + M1[1][1]*M2[1][1]
        return [[a11, a12], [a21, a22]]

    def matPower(mat, p):
        if p == 1: 
            return mat

        m2 = matPower(mat, p//2)
        if p % 2 == 0:
            return matmul(m2, m2)
        else: 
            return matmul(matmul(m2, m2),mat)

    Q = [[1,1],[1,0]]

    q_final = matPower(Q, n-1)
    return q_final[0][0]

N, M = map(int, input().split())
if(M==0):
    print(fib(N+1)%1000000007)
else:
    V = []
    for x in range(M):
        V.append(int(input()))

    result = 1

    for i in range(1, M):
        if(V[i]-V[i-1]==1):
            result = 0

    result *= fib(V[0])

    for x in range(1, M):
        result *= fib(V[x]-V[x-1]-1)

    if(V[M-1]!=N):
        result *= fib(N-V[M-1])

    print(result%1000000007)

Measured memory_bytes: 7100
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

static MOD: u64 = 1_000_000_007;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}

fn prime_factors(n: u64) -> HashMap<u64, u64> {
  let limit = n;
  let mut n = n; 
  let mut prime_numbers: HashMap<u64, u64> = HashMap::new();
  let mut candidate = 2;
  while n > 1 {
      if candidate * candidate > limit {
          prime_numbers.insert(n, 1);
          return prime_numbers;
      }
      while n % candidate == 0 {
          let val = prime_numbers.entry(candidate).or_insert(0);
          *val += 1;
          n /= candidate;
      }
      candidate += 1;
  }
  return prime_numbers;
}

fn inverse_mod(n: u64) -> u64 {
  binary_power(n, MOD-2)
} 

fn calc(lcm_factors: &HashMap<u64, u64>, target_factors: &HashMap<u64, u64>) -> u64 {
  let mut sum = 1;
  for (k, v) in lcm_factors {
    let n = target_factors.get(k).or(Some(&0)).unwrap();
    sum *= binary_power(*k, *v - n);
    sum %= MOD;
  }
  sum
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    // let a_vec = vec![99997;n];
    let mut lcm_factors: HashMap<u64, u64> = HashMap::new();
    for a in &a_vec {
        for (k, v) in prime_factors(*a) {
          let n = lcm_factors.entry(k).or_insert(0);
          if *n < v {
             *n = v;
          }
        }
    }
    let mut lcm = 1;
    for (k, v) in lcm_factors {
      lcm *= binary_power(k, v);
      lcm %= MOD;
    }
    
    let mut sum = 0;
    for a in a_vec {
      sum += lcm * inverse_mod(a);
      sum %= MOD;
    }
    println!("{}", sum);
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int K, X;
    std::cin >> K >> X;
    int l = max(X - K + 1, -1000000);
    int r = min(X + K - 1,  1000000);
    for(int i = l; i <= r; i++) {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    return 0;
}


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

int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    long long res = min(K, A);
    K -= min(K, A);
    K -= min(K, B);
    res -= min(K, C);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K;
    cin >> N >> K;
    YESNO(K * 2 - 1 <= N, "YES", "NO");
    return 0;
}

Measured memory_bytes: 256
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#ifdef ARYANC403
    #include "/home/aryan/codes/PastCodes/template/header.h"
#else
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
    #pragma GCC optimize ("-ffloat-store")
    #include<iostream>
    #include<bits/stdc++.h>
    #define dbg(args...)
#endif

using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    a.clear();a.reserve(n);
    a.pb(0);
    fo(i,n)
    {
        cin>>in;
        a.pb(in+a.back());
    }

    lli ans=INF;
    repA(i,1,n-1)
        ans=min(ans,abs(a[n]-2*a[i]));

    cout<<ans<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n >> MOD;
  vector<vector<int>> g(n);
  REP(i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  vector<mint> sub_counts(n);  // subtree sizes of black nodes.
  auto calc_sub = [&](auto rec, int v, int p) -> mint {
    mint cnt = 1;
    for (auto u : g[v]) {
      if (u != p) {
        cnt *= rec(rec, u, v) + 1;
      }
    }
    return (sub_counts[v] = cnt);
  };
  calc_sub(calc_sub, 0, -1);

  vector<mint> all_counts(n);
  auto calc_all = [&](auto rec, int v, int p, mint pcount) -> void {
    int sz = g[v].size();
    all_counts[v] = sub_counts[v] * (pcount + 1);
    vector<mint> lcum(sz + 1, 1), rcum(sz + 1, 1);
    REP(i, sz) {
      int u = g[v][i];
      lcum[i + 1] = lcum[i] * (u == p ? mint(1) : (sub_counts[u] + 1));
    }
    for (int i = sz - 1; i >= 0; --i) {
      int u = g[v][i];
      rcum[i] = rcum[i + 1] * (u == p ? mint(1) : (sub_counts[u] + 1));
    }
    REP(i, sz) {
      int u = g[v][i];
      if (u != p) {
        rec(rec, u, v, (pcount + 1) * lcum[i] * rcum[i + 1]);
      }
    }
  };
  calc_all(calc_all, 0, -1, mint(0));

  REP(i, n) { cout << all_counts[i] << '\n'; }
}


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

const int mod = 1e9 + 7;

int n, x, y, z;
vector<int> a(3);

int dp[50][1 << 17];
int dfs(int v = 0, int bit = 0) {
  int cnt = 1, sum = 0, idx = 0;
  for (int i = 0; i < 17; ++i) {
    if ((1 << i) & bit) {
      sum += cnt;
      if (a[idx] == sum) {
        idx++;
        sum = 0;
      }
      cnt = 1;
    } else {
      cnt++;
    }
  }

  if (idx == 3) return 0;

  if (v == n) return 1;

  int &res = dp[v][bit];
  if (~res) return res;
  res = 0;

  for (int i = 0; i < 10; i++) {
    res += dfs(v + 1, ((bit << i + 1) + (1 << i) & 0b11111111111111111));
    res %= mod;
  }

  return res;
}

int main() {
  cin >> n >> a[2] >> a[1] >> a[0];

  long long ans = 1;
  for (int i = 0; i < n; ++i) {
    ans = ans * 10 % mod;
  }

  memset(dp, -1, sizeof(dp));

  cout << (ans - dfs() + mod) % mod << endl;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N;
    cin >> N;
    int A[N+10];
    rep1(i,N) cin >> A[i];
    A[0] = 0;
    A[N+1] = 0;
 
    int distance[N+10];
    ll sum = 0;
    rep(i,N+1)
    {
        distance[i] =  max(A[i+1] - A[i], A[i] - A[i+1]);
        sum += distance[i];
    } 
    
    rep1(i,N)
    {
        cout << sum - distance[i-1] - distance[i] + max(A[i-1]-A[i+1], A[i+1]-A[i-1]) << endl;
    }
    
}

Measured memory_bytes: 2048
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(ll x=in;x<n;x+=r)
#define ifr(x,n) for(ll x=0;x<n;x++)
#define dfr(x,n) for(ll x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("/home/srinivas/Desktop/cp/input.txt","r",stdin);
    ll T,a,b,n,x,y;
    // cin>>T;
    // while(T--)
    // {
        
    // }
    cin>>n>>x;
    if(x==1)
        cout<<"0\n";
    else{
        y=n-(x-1);
        cout<<(y-1)<<endl;
    }
    return 0;
}

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

int main()
{

    //cinでファイルから読込
    ifstream in("./input.txt");
    cin.rdbuf(in.rdbuf());

    //cinの高速化
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    bool ans = true;
    int h, next_h;
    cin >> h;
    for (int i = 1; i < N; i++)
    {
        cin >> next_h;
        if (h > next_h)
        {
            ans = false;
            break;
        }
        if (h < next_h)
        {
            next_h--;
        }
        h = next_h;
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int a = fsc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = fsc.nextInt() - a;
        }
        long[][] dp = new long[n][5010];
        int inflation = 2505;
        dp[0][0 + inflation] += 1;
        dp[0][x[0] + inflation] += 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 5010; j++) {
                if (dp[i - 1][j] > 0) {
                    dp[i][j] += dp[i - 1][j];
                    dp[i][j + x[i]] += dp[i - 1][j];
                }
            }
        }
        System.out.println(dp[n - 1][0 + inflation] - 1);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23508
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i=0;i<a.length;i++){
            a[i]=scan.nextInt();
        }
        for(int i=0;i<a.length;i++){
            System.out.print(a[a.length-1-i]);
            if(i<a.length-1){
                System.out.print(" ");
            }
        }
        System.out.println("");
        scan.close();
    }
}


Measured memory_bytes: 26452
import java.lang.Integer.min
import java.util.*

fun readInt(): Int = readLine()!!.toInt()
fun readInts(): List<Int> = readLine()!!.split(" ").map { it.toInt() }

fun parseInt(): Int {
    var digit = System.`in`.read()
    while(digit <= 32) {
        digit = System.`in`.read()
    }

    val negative = digit == '-'.toInt()
    if (negative) {
        digit = System.`in`.read()
    }
    var res = 0
    while (digit in '0'.toInt()..'9'.toInt()) {
        res *= 10
        res += digit - '0'.toInt()
        digit = System.`in`.read()
    }
    return if (negative) -res else res
}

fun gcd(x : Int, y : Int) : Int {
    var a = x
    var b = y
    var r = 0
    while(b > 0) {
        r = a % b
        a = b
        b = r
    }
    return a
}

val dl = intArrayOf(-1, 0, 1, 0)
val dc = intArrayOf(0, 1, 0, -1)

fun calc(i : Int, j : Int, dp : Array<IntArray>, rem : Array<BooleanArray>) : Boolean {
    var newVal = Int.MAX_VALUE
    for(k in 0..3) {
        val x = i + dl[k]
        val y = j + dc[k]
        if(0 <= x && x < dp.size && 0 <= y && y < dp[0].size) {
            newVal = min(newVal, dp[x][y] + 1 - (if(rem[x][y]) 1 else 0))
        } else {
            newVal = 0
        }
    }

    if(newVal == dp[i][j]) return false

    dp[i][j] = newVal
    return true
}

fun main() {
//    val t = readLine()!!.toInt()
    val t = 1

    for(testNumber in 1..t) {
        val n = readInt()
        val p = readInts()
//        val n = 500
//        val p = IntArray(n * n) { i -> i + 1 }

        val dp = Array(n) { i -> IntArray(n) { j -> min(min(min(i, j), n - 1 - i), n - 1 - j) } }
        val rem = Array(n) { BooleanArray(n) { false } }
        val q = Array(n * n) { 0 }

        var ans = 0
        for(x in p) {
            val i = (x - 1) / n
            val j = (x - 1) % n
            ans += dp[i][j]
            rem[i][j] = true

            var l = 0
            var r = 0
            q[0] = i * n + j

            while(l <= r) {
                val it = q[l++]
                val a = it / n
                val b = it % n
                for(k in 0..3) {
                    val c = a + dl[k]
                    val d = b + dc[k]
                    if(0 <= c && c < dp.size && 0 <= d && d < dp[0].size) {
                        val newVal = dp[a][b] + (if(rem[a][b]) 0 else 1)
                        if(newVal < dp[c][d]) {
                            dp[c][d] = newVal
                            q[++r] = c * n + d
                        }
                    }
                }
            }
        }

        println(ans)
    }
}

Measured memory_bytes: 85184
#include<stdio.h>
#include<iostream>
#include<stack>
#include<algorithm>
#define MAX 1400

using namespace std;

struct Rectangle { int height; int pos; };

int getLargestRectangle(int size, int buffer[]) {
	stack<Rectangle> S;
	int maxv = 0;
	buffer[size] = 0;

	for (int i = 0; i <= size; i++) {
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if (S.empty()) {
			S.push(rect);
		}
		else {
			if (S.top().height < rect.height) {
				S.push(rect);
			}
			else if (S.top().height > rect.height) {
				int target = i;
				while (!S.empty() && S.top().height >= rect.height) {
					Rectangle pre = S.top();
					S.pop();
					int area = pre.height*(i - pre.pos);
					maxv = max(maxv, area);
					target = pre.pos;
				}
				rect.pos = target;
				S.push(rect);
			}
		}
	}
	return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle() {
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (buffer[i][j]) {
				T[i][j] = 0;
			}
			else {
				T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
			}
		}
	}

	int maxv = 0;
	for (int i = 0; i < H; i++) {
		maxv = std::max(maxv, getLargestRectangle(W, T[i]));
	}

	return maxv;
}

int main() {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%d", &buffer[i][j]);
		}
	}
	cout << getLargestRectangle() << endl;

	return 0;
}


Measured memory_bytes: 18536
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val eight = sc.nextInt()
    val ten = sc.nextInt()

    val eightLowerBound = (eight.toDouble * 12.5.toDouble).ceil.toInt
    val eightUpperBound = ((eight + 1).toDouble * 12.5.toDouble).ceil.toInt
    val tenLowerBound = ten * 10
    val tenUpperBound = (ten + 1) * 10

    val lowerBound = Math.max(eightLowerBound, tenLowerBound)
    val upperBound = Math.min(eightUpperBound, tenUpperBound)

    val ans = if (lowerBound < upperBound) {
      lowerBound
    } else {
      -1
    }

    println(ans)
  }
}


Measured memory_bytes: 27336
/*input
100 0
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int x, n, i, ret=0, val = 1e9;
	cin >> x >> n;
	set<int> s;
	for(i=0; i<n; i++) {
		int y;
		cin >> y;
		s.insert(y);
	}
	for(i=-1000; i<=1000; i++) {
		if(s.count(i)) continue;
		if(abs(x-i) < val) {
			val = abs(x-i);
			ret = i;
		}
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 3644
n = int(input())
t = [0]*n
for i in range(n):
    p = int(input())-1
    t[p] = i
maxi = 1
c = 1
for i in range(n-1):
  a = t[i]
  b = t[1+i]
  if a < b:
    c += 1
  else:
    maxi = max(c,maxi)
    c = 1
maxi = max(c,maxi)
print(n - maxi)

Measured memory_bytes: 10868
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

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

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
typedef pair<int, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    int N; cin >> N;
    vector<long long> hen(N);
    vector<long long> canUse(114514);
    for (int i = 0; i < N; i++) cin >> hen.at(i);
    sort(hen.begin(), hen.end());
    int sameCount = 1;
    for (int i = 0; i < N-1; i++) {
        if (hen.at(i) == hen.at(i + 1)) {
            sameCount++;
        }
        else sameCount = 1;
        if (sameCount == 2) { 
            canUse.push_back(hen.at(i)); 
            sameCount = 0;
        }
    }
    sort(canUse.begin(), canUse.end());
    reverse(canUse.begin(), canUse.end());

    cout << canUse.at(0) * canUse.at(1) << endl;
}


Measured memory_bytes: 2816
#include <iostream>
 
using namespace std;
 
struct P{
    int x,y;
};
 
int main(){
    int n,m;
    P p[101];
 
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++)
	cin >> p[i].x >> p[i].y;
   
    bool flg = true;
    int d = 1,a = 0;
 
    for(int i = 0 ; i < m ; i++){
	int t = -1;
     
	for(int j = 0 ; j < m ; j++){
	    if(p[j].x <= d){
		t = max(t,p[j].y);
	    }
	}
 
	if(t == -1){
	    flg = false;
	    break;
	}
     
	a++;
	d = t+1;
	if(d > n) break;
    }
 
    if(d > n) cout << a << endl;
    else cout << "Impossible" << endl; 
 
    return 0;
}

Measured memory_bytes: 3088
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static int inf = 0x7ffffff;

    void solve() {
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        if ((x + y) % 3 != 0) {
            System.out.println(0);
        } else {
            int n = (x + y) / 3;
            int r = x - n;
            if (r < 0 || n < r) {
                System.out.println(0);
            } else {
                System.out.println(combinationAndMod(n, r));
            }
        }
    }

    static long combinationAndMod(long n, long r) {
        long x = 1, y = 1;
        for (long i = 1; i <= r; i++) {
            x = x * (n - r + i) % mod;
            y = y * i % mod;
        }
        return x * powAndMod(y, mod - 2) % mod;
    }

    static long powAndMod(long a, long b) {
        return b == 0 ? 1 : b % 2 == 1 ? a * powAndMod(a, b - 1) % mod : powAndMod(a * a % mod, b / 2);
    }

    public static void main(String[]$) throws Exception {
        new Main().solve();
        System.out.flush();
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 22996