akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep0(i, n){
        ll x;
        cin >> x;
        a.push(x);
    }
    rep0(i, m){
        ll x = a.top();
        a.pop();
        a.push(x/2);
    }
    ll ans = 0;
    while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
    pf(ans);
    return 0;
}


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

using namespace std;
typedef long long ll;

ll n, w;
ll dp[100+9][100000+9], maksio=-1;
vector<pair<ll, ll>>a;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>w;
    a.resize(n);
    //for(int i=0; i<=n; i++) fill(dp[i]+1, dp[i]+w+1, -1);
    for(int i=0; i<n; i++) cin>>a[i].second>>a[i].first;
    //sort(a.begin(), a.end());
    for(int i=1; i<=n; i++)
    {
        ll v=a[i-1].first, m=a[i-1].second;
        for(int j=0; j<m; j++) dp[i][j]=dp[i-1][j];
        for(int j=w; j>=m; j--)
        {
            dp[i][j]=max(dp[i-1][j], dp[i-1][j-m]+v);
            maksio=max(dp[i][j], maksio);
        }
    }
    //for(int i=0; i<=w; i++) maksio=max(maksio, dp[n][i]);
    for(int i=0; 0&&i<=n; i++)
    {
        for(int j=0; j<=w; j++) cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 79360
// Problem : C - Digits in Multiplication
// Contest : AtCoder - AtCoder Beginner Contest 057
// URL : https://atcoder.jp/contests/abc057/tasks/abc057_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
inline int dig(ll N)
{
	int c=0;
	while(N!=0)
	{
		N/=10;
		c++;
	}
	return c;
} 
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N;
	cin>>N;
	int mn=dig(N);
	for(ll x=sqrt(N);x>=0;x--)
	{
		if(N%x==0)
		{
			ckmin(mn,max(dig(x),dig(N/x)));
			break;
		}
	}
	cout<<mn<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3560
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll dp[310][310];
ll H[310];

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> H[i];

  ll M = N-K;

  rep( i, N ) rep( j, M+1 ) {
    if( !j )
      dp[i][0] = H[i];
    else
      dp[i][j] = INF;
  }

  rep( i, N ) repi( j, 1, M ) {
    rep( k, i )
      chmin( dp[i][j], dp[k][j-1]+std::max(0ll, H[i]-H[k]) );
  }

  ll ans = INF;

  rep( i, N )
    chmin( ans, dp[i][M-1] );

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 4376
#include <stdio.h>
int main(void){
  int d;
  scanf("%d",&d);
  switch(d){
    case 25:printf("Christmas");  break;
    case 24:printf("Christmas Eve"); break;
    case 23:printf("Christmas Eve Eve"); break;
    case 22:printf("Christmas Eve Eve Eve"); break;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
# B
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(M):
    xx, yy, cc = map(int, input().split())
    x.append(xx)
    y.append(yy)
    c.append(cc)
    
l = []
l.append(min(a)+min(b))

for i in range(M):
    ans = a[x[i]-1] + b[y[i]-1] - c[i]
    l.append(ans)
    
print(min(l))

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  float saturation_diff = 1.0f;
  int saturation_total = 0;
  int saturation_suger = 0;

  float max_ratio = (float)E / (100.f + (float)E);
  float max_water = F / 100;
  float max_suger = F * max_ratio;

  for (int a = 0; a < max_water / A; a++) {
    for (int b = 0; b < max_water / B; b++) {
      for (int c = 0; c < max_suger / C; c++) {
        for (int d = 0; d < max_suger / D; d++) {
          int water = (100 * A) * a + (100 * B) * b;
          int suger = C * c + D * d;
          int total = water + suger;
          if (100 * A > total || total > F || total == 0) continue;

          float ratio = (float)suger / (float)total;
          float diff = max_ratio - ratio;
          if (ratio <= max_ratio && diff < saturation_diff) {
            saturation_diff = diff;
            saturation_total = total;
            saturation_suger = suger;
          }
        }
      }
    }
  }

  cout << saturation_total << ' ' << saturation_suger << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  int n, x, d=0, ans=1;
  cin >> n >> x;
  rep(i, n){
    int l;
    cin >> l;
    d+=l;
    if(d<=x)ans++;
    else break;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
<?php

$nums = str_split(trim(fgets(STDIN)));
$nums = array_map(function($a){
    return (int)$a;
}, $nums);

for($i = 0; $i < 8; $i++){
    $s = $sum = $nums[0];
    for($j = 0; $j < 3; $j++){
       if(decbin($i & (1 << $j))){
           $sum += $nums[$j + 1];
           $s .= '+' .$nums[$j + 1];
       }else{
           $sum -= $nums[$j + 1];
           $s .= '-' .$nums[$j + 1];
       }
    }
    if($sum == 7) {echo $s .= '=7'; break;}
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=306;
int a[N][N], ng[N][N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    REP(i,n) REP(j,n) {
        cin >> a[i][j];
    }

    REP(k,n) REP(i,n) REP(j,n) {
        if ( i==k || j==k || i==j ) continue;
        if ( a[i][k]+a[k][j]<a[i][j] ) {
            cout << -1 << endl;
            return 0;
        }

        if ( a[i][k]+a[k][j]==a[i][j] ) {
            ng[i][j]=1;
        }

    }

    LL ans= 0;
    REP(i,n) REP(j,n) {
        if ( !ng[i][j] ) {
            ans+=a[i][j];
        }
    }
    cout << ans/2 << '\n';
    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


int main() {
	string s;
	cin >> s;

	long long k;
	cin >> k;

	int first = s[0]-'0';
	int second = s[1] - '0';

	int m = 1;
	int ones = 0;
	
	REP(i, s.size()) {
		if (s[i] != '1') {
			m = s[i] - '0';
			break;
		}
		if (s[i] == '1') {
			ones++;
		}
	}


	if (m == 1) {
		ANS(1);
		return 0;
	}

	if (k <= ones) {
		ANS(1);
	}
	else {
		ANS(m);
	}
	



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m; 
char c[2010][2010];
int a[2010][2010][4];
int res;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) scanf("%s",&c[i]);
	for (int i=0;i<n;i++)
	{
		a[i][0][0]=(c[i][0]=='#' ? 0 : -1);
		for (int j=1;j<m;j++)
		    a[i][j][0]=(c[i][j]=='#' ? j : a[i][j-1][0]); 
		a[i][m-1][1]=(c[i][m-1]=='#' ? m-1 : m);
		for (int j=m-2;j>=0;j--)
		    a[i][j][1]=(c[i][j]=='#' ? j : a[i][j+1][1]); 
	}
	for (int j=0;j<m;j++)
	{
		a[0][j][2]=(c[0][j]=='#' ? 0 : -1);
		for (int i=1;i<n;i++)
		    a[i][j][2]=(c[i][j]=='#' ? i : a[i-1][j][2]); 
		a[n-1][j][3]=(c[n-1][j]=='#' ? n-1 : n);
		for (int i=n-2;i>=0;i--)
		    a[i][j][3]=(c[i][j]=='#' ? i : a[i+1][j][3]); 
	}
	/*for (int tr=0;tr<4;tr++)
	{
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<m;j++)
			{
				cout <<a[i][j][tr]<<" "; 
			}
			cout <<"\n";
		}
		cout <<"\n";
	}*/
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#') continue;
			int r=0;
			r+=a[i][j][1]-a[i][j][0]-1;
			r+=a[i][j][3]-a[i][j][2]-1;
			r--;
			res=max(res,r);
		}
	}
	cout <<res;
	return 0;
} 


Measured memory_bytes: 67456
import Text.Printf

main = do
  input_str <- getLine
  let t = stoi input_str
      h = t `div` 3600
      m = (t `div` 60) `mod` 60
      s = t `mod` 60
  printf "%d:%d:%d\n" h m s

stoi :: String -> Int
stoi str = read str :: Int

Measured memory_bytes: 3592
a, b, c, d = (int(x) for x in input().split())
if c%b==0:
    taka = int(c/b)
else:
    taka = c//b+1
if a%d==0:
    ao = int(a/d)
else:
    ao = a//d+1
if taka<=ao:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61820
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int A,B;
  cin>>A>>B;
  
  int mn=min(A,B),mx=max(A,B);
  
  REP(i,mx) cout<<mn;
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int arr[200001];
int main(){
	int N,K;scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++) scanf("%d",arr+i);
	int sum=0;
	for(int i=0;i<K;i++) sum+=arr[i];
	int Max=sum;
	for(int i=K;i<N;i++){
		sum+=arr[i]-arr[i-K];
		if(Max<sum) Max=sum;
	}
	printf("%.15lf",(Max+K)/(double)2);
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(100000000)

def mult(A, B, mod): #行列A, Bの内積を求める。
    D = [[(A[0][0] * B[0][0]) % mod, 0, 0], [0, 1, 0], [0, 0, 1]]
    D[1][0] = (A[1][0] * B[0][0] + A[1][1] * B[1][0]) % mod
    D[2][0] = (A[2][0]*B[0][0]+A[2][1]*B[1][0]+A[2][2]*B[2][0]) % mod
    D[2][1] = (A[2][1]*B[1][1]+A[2][2]*B[2][1]) % mod
    return D

def double(C, mod):
    D = [[pow(C[0][0], 2, mod), 0, 0], [(C[1][0] * C[0][0] + C[1][0]) % mod, 1, 0], [(C[2][0] * C[0][0] + C[2][1] * C[1][0] + C[2][0]) % mod, (C[2][1] * 2) % mod, 1]]
    return D

def Cpow(C, n, mod):
    if n == 1: return C
    else:
        D = double(C, mod)
        if n % 2 == 0:
            return Cpow(D, n // 2, mod)
        else:
            return mult(Cpow(D, n // 2, mod), C, mod)

def solve():
    L, a, b, M = map(int, input().split())
    X = 0
    s = a
    nd = -1
    ne = 0
    for d in range(1, 19):
        ne = min((pow(10, d) - a - 1) // b, L-1)
        if ne < 0: continue
        elif ne == nd: continue
        C = [[pow(10, d, M), 0, 0], [1, 1, 0], [0, b % M, 1]]
        D = Cpow(C, ne - nd, M)
        X = (X * D[0][0] + D[1][0] * s + D[2][0]) % M
        s += D[2][1]
        if ne == L - 1: break
        nd = ne
    print(X)
    return

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3192
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        x_vec: [usize; 5]
    }
    let mut ans = 0;
    for (i, x) in x_vec.into_iter().enumerate() {
        if x == 0 {
            ans = i+1;
            break
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2128
// still some problem in input 3 check in future

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector<int> A(n);
    int mx=0;
    for(int i=0; i<n; ++i){
        cin>>A[i];
        mx = max(mx,A[i]);
    }
    int ans=0;
    int l=1, r=mx;
    while(l<=r){
        int m= l+(r-l)/2;
        long long c=0;
        for(int x: A){
            c+=(x-1)/m;
        }
        if(c<=k){
            ans=m;
            r=m-1;
        }
        else l=m+1;
    }
    cout<<ans<<"\n";

}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=3005;
string s,t;
int n,m;
int dp[MAX_N][MAX_N];
pair<int,int> pre[MAX_N][MAX_N];
int main()
{
	cin>>s>>t;
	n=s.size(),m=t.size();
	s='0'+s;
	t='0'+t;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
		//	if(s[i]==t[j])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		//	dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
			if(s[i]==t[j] && dp[i][j]<dp[i-1][j-1]+1)
			{
				dp[i][j]=dp[i-1][j-1]+1;
				pre[i][j]=make_pair(i-1,j-1);
			}
			if(dp[i][j]<dp[i-1][j])
			{
				dp[i][j]=dp[i-1][j];
				pre[i][j]=make_pair(i-1,j);
			}
			if(dp[i][j]<dp[i][j-1])
			{
				dp[i][j]=dp[i][j-1];
				pre[i][j]=make_pair(i,j-1);
			}
		}
	}
	int nx=n,ny=m;
	string ans;
	while(nx && ny)
	{
		if(s[nx]==t[ny])ans=s[nx]+ans;
		tie(nx,ny)=pre[nx][ny];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 105984
a, b, c, d = gets.split(" ").map(&:to_i)

g = c.gcd(d)
#print("g=#{g}\n")
bl = b / ((c * d) / g)
al = (a-1) / ((c * d) / g)
#print("bl=#{bl}, al=#{al}\n")
bx = b / c

by = b / d

#x, yの具体的な要素のうち重複するものの個数=i
i = b - bx - by + bl
ax = (a-1) / c

ay = (a-1) / d

j = a-1 - ax - ay + al
#print("i=#{i}, j=#{j}\n")

p i - j

Measured memory_bytes: 1788
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 3005;
int dp[N][N];
pii par[N][N];
bool taken[N][N];
string s, t, ans;
void solve(){
	cin >> s >> t;
	int n = sz(s), m = sz(t);
	s = '0' + s;
	t = '0' + t;
	fr(i, 1, n){
		fr(j, 1, m){
			if(s[i] == t[j]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
				taken[i][j] = 1;
				par[i][j] = {i - 1, j - 1};
			}
			else{
				dp[i][j] = dp[i][j - 1];
				par[i][j] = {i, j - 1};
				if(dp[i - 1][j] > dp[i][j]){
					dp[i][j] = dp[i - 1][j];
					par[i][j] = {i - 1, j};
				}
			}
		}
	}
	pii e = {n, m};
	while(e.fi > 0 && e.se > 0){
		if(taken[e.fi][e.se])
			ans += s[e.fi];
		e = par[e.fi][e.se];
	}
	reverse(all(ans));
	cout << ans;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 220672
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i = a;i<=b;++i)
#define For_(i,a,b) for(int i = a;i>=b;--i)
typedef long long LL;
inline int read(){
    int r = 0,f = 1;
    char c = getchar();
    while(c<'0' || c >'9'){
        if(c =='-') f = -1;
        c = getchar();
    }
    while(c>='0' && c<='9'){
        r = (r<<1) + (r<<3) + c - '0';
        c = getchar();
    }
    return r * f;
}
int n;
const int N = 1+5;
int main(){
    LL a = read() , b = read() , c = read() , d = read();
    LL x1 = a*c;
    LL x2 = b*c;
    LL x3 = a*d;
    LL x4 = b*d;
    LL ans = 0;
    ans = max(max(x1,x2),max(x3,x4));
    cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
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;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
// clang++ -std=c++11 -stdlib=libc++

ll a[51], p[51];

ll f(int n, ll x) {
  if (n == 0)
    return x <= 0 ? 0 : 1;
  if (x <= a[n - 1] + 1LL)
    return f(n - 1, x - 1LL);
  if (x == 2 + a[n - 1])
    return p[n - 1] + 1;
  if (x <= 2 * a[n - 1] + 2)
    return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
  return 2 * p[n - 1] + 1;
}

ll N, X;
int main() {
  cin >> N >> X;
  a[0] = 1;
  p[0] = 1;
  rep2(i, 1, N) {
    a[i] = 2 * a[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }
  cout << f(N, X) << endl;
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  bool flag = false;
  
  for(int i = 0; i < S.size(); ++i) {
    if(i % 2 == 0) {
      if(S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D') {
      } else {
        cout << "No" << endl;
        flag = true;
        break;
      }
    } else {
      if(S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D') {
      } else {
        cout << "No" << endl;
        flag = true;
        break;
      }
    }
  }
  
  if(flag == false) {
    cout << "Yes" << endl;
  }
}

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

    using namespace std;

    const int MOD=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,m;
        cin>>n>>m;
        vector<string>s(n);
        for(int i=0;i<n;i++)
            cin>>s[i];
        vector<vector<int>>a(n,vector<int>(m));
        a[0][0]=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(s[i][j]=='#')
                    continue;
                if(i==0 && j==0)
                    continue;
                if(i==0)
                    a[i][j]=a[i][j-1];
                else if(j==0)
                    a[i][j]=a[i-1][j];
                else
                    a[i][j]=(a[i][j]%MOD + a[i-1][j]%MOD + a[i][j-1]%MOD)%MOD;
            }
        }
//        for(int i=0;i<n;i++){
//            for(int j=0;j<m;j++)
//                cout<<a[i][j]<<" ";
//            cout<<"\n";
//        }
        cout<<a[n-1][m-1];
        return 0;
    }


Measured memory_bytes: 5248
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

ans = 0
for i in range(n):
    if (i + 1) % 2 != 0 and a[i] % 2 != 0:
        ans += 1
print(ans)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAX = 1010;

int h, w;
char in[MAX][MAX];
int dist[MAX][MAX];

int main(){
  memset(dist, -1, sizeof dist);

  scanf("%d%d", &h, &w);
  for(int i = 0;i < h;++i)
    scanf("%s", in[i]);

  queue<pii> q;
  for(int i = 0;i < h;++i)
    for(int j = 0;j < w;++j)
      if(in[i][j] == '#'){
        q.push(mp(i, j));
        dist[i][j] = 0;
      }

  vector<pii> dlt = {
    mp(-1, 0), mp(+1, 0),
    mp(0, -1), mp(0, +1)
  };
  while(!q.empty()){
    auto c = q.front();
    q.pop();

    for(const auto& d : dlt){
      int x = c.fi + d.fi;
      int y = c.se + d.se;
      if(x >= 0 && y >= 0 && x < h && y < w){
        if(dist[x][y] == -1){
          dist[x][y] = dist[c.fi][c.se] + 1;
          q.push(mp(x, y));
        }
      }
    }
  }

  int ans = 0;
  for(int i = 0;i < h;++i)
    for(int j = 0;j < w;++j)
      relaxMax(ans, dist[i][j]);

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

  return 0;
}


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

string rotation(string s){
  return s.substr(1)+s[0];
}

int main() {
  string S,T;
  cin>>S>>T;
  
  bool ans=false;
  for(int i=0;i<S.size();++i){
    if(S==T)
      ans=true;
    
    S=rotation(S);
  }
  
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

#define lim 20222

char s[lim];
int n, x, y;
vector<int> v[2];
int dp[2][lim];

bool chk(int f, int dest) {
	int sz = (int)v[f].size(), base = 8888;
	memset(dp, 0, sizeof dp);
	dp[0][base] = true;
	int cur = 0, nxt = 1;
	for(int i=0;i<sz;i++) {
		for(int j=0;j<lim;j++) dp[nxt][j] = false;
		int x = v[f][i];
		for(int j=0;j<lim;j++)
			if (dp[cur][j]) {
				dp[nxt][j-x] = true;
				dp[nxt][j+x] = true;
			}
		swap(cur, nxt);
	}
	return dp[cur][dest+base];
}

int main() {
	scanf("%s%d%d", s, &x, &y);
	n = strlen(s);
	
	int it = 0;
	while(it < n && s[it]=='F') {
		it++; x--;
	}
	if (it == n) {
		if (x==0 && y==0) puts("Yes");
		else puts("No");
		return 0;
	}
	
	int f = 1;
	v[0].clear(); v[1].clear();
	for(;it<n;) {
		it++; // skip a T
		int cnt = 0;
		while(it<n && s[it]=='F') {
			it++; cnt++;
		}
		v[f].push_back(cnt);
		f=1-f;
	}
	
	if (chk(0, x) && chk(1, y)) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 1 ;
	for(int i=2;i*i<=n;i++){
		ll num = 1 ;
		while(num*i<=n) num *= i ;
		ans = max(ans,num) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    d, t, s = LI()
    if t * s >= d:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76816
h, w, k = map(int, input().split())
arr = [input() for _ in range(h)]

cnt = 0
h_dict = {i: 0 for i in range(h)}
w_dict = {i: 0 for i in range(w)}
for i, c in enumerate(arr):
    cnt_h = c.count('#')
    cnt += cnt_h
    h_dict[i] = cnt_h
    for j, c_ in enumerate(c):
        if arr[i][j] == '#':
            w_dict[j] += 1

ans = 0
for bit_h in range(2**h):
    tmp_h = []
    for i in range(h):
        if (bit_h >> i) & 1:
            tmp_h.append(i)
    for bit_w in range(2**w):
        tmp_w = []
        for j in range(w):
            if (bit_w >> j) & 1:
                tmp_w.append(j)
        tmp = 0
        for h_ in tmp_h:
            tmp += h_dict[h_]
        for w_ in tmp_w:
            tmp += w_dict[w_]
        for h_ in tmp_h:
            for w_ in tmp_w:
                if arr[h_][w_] == '#':
                    tmp -= 1

        if cnt - tmp == k:
            ans += 1

print(ans)


Measured memory_bytes: 9176
from sys import stdin
input = stdin.readline


def main():
  N, M, X = list(map(int, input().split()))
  C = []
  A = [[0]*M for _ in range(N)]

  for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

  min_ = float('inf')
  for bit in range(1 << N):
    temp = [0]*M
    cost = 0
    for i in range(N):
      mask = 1 << i
      if bit & mask:
        cost += C[i]
        for j, a in enumerate(A[i]):
          temp[j] += a

    if all(list(map(lambda x: x >= X, temp))):
      min_ = min(min_, cost)

  if min_ == float('inf'):
    print(-1)
  else:
    print(min_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 74496
/*给一棵树，x和y博弈，首先x在u点，y在v点，游戏结束条件是x和y重合，
x先动，x希望游戏更晚结束dist(p,u)要大，y希望游戏更早结束，求y在游戏结束前走的步数

设游戏在p点结束，那么dist(p,u)≤dist(p,v)显然成立，dist(p,u)=dist(p,v) 等同于y等待x
 
dist(p,u)<dist(p,v)等同于x掉头等待y  大于就不会在p点相遇 或者可以讲Y会继续前行等待x 
所以要取满足条件的max(dist(p,v))即可。
*/
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
vector<int>g[100000];
int n, u, v, a, b, ans;
int du[100000], dv[100000];

//Graph ? std::vector<int> v[100]; 100 verices
void dfs(int x, int y, int z) {
	dv[x] = z;
	for (int i = 0; i < g[x].size(); i++) {
		if (g[x][i] != y)dfs(g[x][i], x, z + 1);
	}
}

int main() {
  scanf("%d%d%d", &n, &u, &v);
	u--; v--;
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

dfs(u, -1, 0);
for (int i = 0; i < n; i++)du[i] = dv[i];
dfs(v, -1, 0);
for (int i = 0; i < n; i++) {
  if (dv[i] >= du[i]) {//早走1步 
    if (dv[i] > ans)ans = dv[i];
  }
}
printf("%d\n", ans - 1);

  return 0;
}



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

using namespace std;

int main()
{
    long long l,r,x,y;
    cin>>l>>r;

    if((l-1)/2019 != r/2019) {
        cout << 0 <<endl;
        return 0;
    }
    l=l%2019;r=r%2019;
    int ans = 2018;
    for(int i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC055A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a,x,y;
			x = 0;
			a = int.Parse(Console.ReadLine());
			x = 800 * a;
			y = a / 15 * 200;
			Console.WriteLine(x - y);
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if(A > 9 || B > 9) cout << "-1" << endl;
    else cout << A*B << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    
    int counter = 0;
    for (int i = A; i <= B; i++) {
        string s_num = to_string(i);
        bool yes = true;
        for (unsigned long int j = 0, e = (s_num.length() - 1); j < (s_num.length() / 2); j++,e--) {
            if (s_num[j] != s_num[e]){
                yes = false;
                break;
            }
        }
        if (yes)
            counter++;
    }
    
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Measured memory_bytes: 16216
def bs(A, n):
    l=0
    r=len(A)
    while l<r:
        mid=int((l+r)/2)
        if A[mid]==n:
            return mid
        else:
            if n<A[mid]:
                r=mid
            else:
                l=mid+1

    return -1

S=int(input())
A=[int(i) for i in input().split()]

T=int(input())
B=[int(j) for j in input().split()]

A.sort()

cnt=0
for i in range(T):
    x=bs(A,B[i])
    if x!=(-1):
        cnt=cnt+1

print(cnt)



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) { dat.resize(N, 0); }

  void add(int k, T val) {
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) { return sum(r) - sum(l); }

  T index(int k) { return sum(k+1) - sum(k); }
};


int main() {
  ios_base::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  RangeSumQuery<int> bit(n);

  REP(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      bit.add(x-1, y);
    } else if (com == 1) {
      cout << bit.sum(x-1, y) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1524
#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<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(){
    string inputs;
    cin >> inputs;

    string answer = "";
    repeat (i, inputs.size()) {
        if (inputs[i] == 'B') {
            if (answer.size() != 0) {
                answer.erase(answer.size() - 1, 1);
            }
        } else {
            answer += inputs[i];
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy

import sys
#整数xと長さn
x, n = map(int, input().split())

#入力される整数列 list
list = list(map(int, input().split()))

#入力確認
#print(x, n)
#print(list)

for i in range(101):
    if x - i not in list:
        print(x - i)
        sys.exit()
    elif x + i not in list:
        print(x + i)
        sys.exit()

Measured memory_bytes: 27140
# include <iostream>
using namespace std;
int MinCostPath_2(int * arr,int n)
{

	if (n<=1)
	{
		return 0;
	}
	int * ans=new int [n+1];
	ans[0]=0;
	ans[1]=0;
	ans[2]=abs(arr[0]-arr[1]);

	for (int i=3;i<=n;i++)
	{
		int onePossibleStep=abs(arr[i-1]-arr[i-2]);
		int secondPossibleStep=abs(arr[i-1]-arr[i-3]);

		ans[i]=min(onePossibleStep+ans[i-1],secondPossibleStep+ans[i-2]);
	}

	return ans[n];
}





int main()
{
	int n;
	cin>>n;
	int * arr=new int [n];
	for (int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cout<<MinCostPath_2(arr,n);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,n,p[1005]={};
	int ans=10000,ans1,a;
	cin>>x>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		p[a]=1;
	}
	for(int i=-1000;i<=1000;i++){
		if(i>0){
		if(p[i]!=1 && abs(x-i)<ans){
			ans=abs(x-i);
			ans1=i;
		}
		}
		else{
			if(abs(x-i)<ans){
			ans=abs(x-i);
			ans1=i;
		}
		}
	}
	cout<<ans1<<endl;
return(0);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n&1)
            n=n*2;
        cout<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll M = 1000000007;
const ll max_n = 210100;

vector<ll> fac(max_n); //n!(mod M)
vector<ll> ifac(max_n); //k!^{M-2} (mod M)

ll pow_mod(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb_mod(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
  ll n,k;
  cin >> n >> k;
  //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<max_n; i++){
      fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
      ifac[i+1] = ifac[i]*pow_mod(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  if(k>n-1) k = n-1;
  ll ans = 0;
  for(ll i=0;i<=k;i++){
    ans += comb_mod(n,i) * comb_mod((n-i-1)+i, i);
    ans %= M;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>


using namespace std;


int main() {

    int N;
    cin >> N;

    long sum = 0;
    for (int i = 0; i <= N; ++i) {
        if (i % 3 == 0 and i % 5 == 0) {

        } else if (i % 3 == 0) {

        } else if (i % 5 == 0) {

        } else {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3596
def main():
    H,W = map(int,input().split())
    A = []
    for i in range(H):
        A.append(list(map(int,input().split())))
    


    out = []
    def move(x1,y1,x2,y2):
        A[y1][x1] -= 1
        A[y2][x2] += 1
        out.append('{} {} {} {}'.format(y1+1,x1+1,y2+1,x2+1))
    for i in range(H):
        if i & 1:
            for j in range(W-1):
                if A[i][j] & 1:
                    move(j,i,j+1,i)
            if A[i][W-1] & 1 and i < H-1:
                move(W-1,i,W-1,i+1)
        else:
            for j in range(W-1,0,-1):
                if A[i][j] & 1:
                    move(j,i,j-1,i)
            if A[i][0] & 1 and i < H-1:
                move(0,i,0,i+1)
    print(len(out))
    print('\n'.join(out))








main()

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


#define debug(x) cerr<< #x << ": "<< x << endl;
#define print(x) cerr<< x << endl;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define REP(i,x,y) for(int i=x;i<y;i++)
#define REPIT(it,A) for(typeof(A.begin()) it = (A.begin()); it!=A.end();it++)
#define fst first
#define snd second
#define sqr(x) ((x)*(x))

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define ones(x) __builtin_popcountll(x)
using namespace std;

typedef pair<int,int> ii ;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<ii> vii;

const int MAXN = 10009;
int h, w, a[MAXN], n, res[110][110];

int main(){
   fastio;
   cin >> h >> w >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int c = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int k = i % 2 == 0 ? j : w - j - 1;
			if(a[c] == 0) c++;
			a[c]--;
			res[i][k] = c + 1;
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if(j) cout<<" ";
			cout<<res[i][j];
		}
		cout<<endl;
	}

   return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int aaa(int a, int b, int c){
	if(a*a+b*b==c*c){
		return 1;
	}
	return 0;
}

int main (void){
	int a, b, c, i, n;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d%d%d", &a, &b, &c);
		if(aaa(a, b, c) || aaa(a, c, b) || aaa(c, b, a)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],b[N];
int main(){
	int n,l=N,r=0,w=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(int i=n;i;i--){
		scanf("%d",b+i);
		if(b[i]==a[i]){l=i;if(!r)r=i;}
	}
	for(int i=1;i<=n;i++)if(b[i]!=a[r]&&a[i]!=a[r])w++;
	if(w<r-l+1)return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;i++){
		if(l>r)break;
		if(b[i]!=a[r]&&a[i]!=a[r])swap(b[i],b[l++]);
	}
	for(int i=1;i<=n;i++)printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 5344
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	string s;
	cin >> s;
	int cb = 0;
	ll ans = 0;
	for (char c: s) {
		if (c == 'B') {
			++cb;
		}
		else {
			ans += cb;
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int count=0,n,c,k,in,t;
    vector<int> v;
    cin>>n>>c>>k;
    for(int i=0;i<n;i++){
        cin>>in;
        v.push_back(in);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        count++;
        t=v[i]+k;
        for(in=0;in<c-1&&(i+in+1)<n;in++){
            if(v[i+in+1]>t)break;
        }
        i+=in;

    }
    cout<<count<<endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  int res[N];
  rep(i, N) {
    int a; cin >> a;
    res[a - 1] = i + 1;
  }
  rep(i, N) {
    if (i) cout << " ";
    cout << res[i];
  }
  cout << endl;
}


Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String slist[] = s1.split("");
        if(s1.length()==2){
            System.out.println(s1);
        }
        if(s1.length()==3){
            String s2 = slist[2] + slist[1] + slist[0];
            System.out.println(s2);
        }
    }
}


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

int main(){
    long long int a, b, k;
    cin >> a >> b >> k;
    vector<long long int> v;
    for(int i = a; i < a+k; i++){
        if(i >= a && i <= b)cout << i << endl;
        v.push_back(i);
    }
    bool bo;
    for(int i = b-k+1; i <= b; i++){
        if(i <= b && i >= a){
            bo = false;
            for(int j = 0; j < v.size(); j++){
                if(v[j] == i) bo = true;
            }
            if(!bo)cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256