akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
vector<int> adj[60];
vector<int> query[60];
vector<int> qx[60];
int mu[60], mv[60];
int lca[60][60];
int head[60];
int cum[60];

int find(int u){
    return head[u] == u ? u : (head[u] = find(head[u]));
}

void dfs(int u, int p){
    head[u] = u;
    for(int v:adj[u]){
        if(v != p){
            dfs(v, u);
            head[v] = u;
        }
    }

    for(int v:qx[u]){
        lca[v][u] = lca[u][v] = find(v);
    }

    for(int v:query[u]){
        qx[v].push_back(u);
    }
}

int cover(int u, int p){
    int cnt = 0;
    for(int v:adj[u]){
        if(v != p){
            cnt += cover(v, u);
            cum[u] += cum[v];
        }
    }

    if(cum[u] > 0){
        cnt++;
    }
    return cnt;
}

int main(){
    int n, m;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u, v;
        cin >>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    cin >>m;
    for(int i = 0;i<m;i++){
        int u, v;
        cin >>u>>v;
        mu[i] = u;
        mv[i] = v;
        query[u].push_back(v);
        query[v].push_back(u);
    }

    dfs(1, 0);

    long long ans = 1;
    for(int i=0;i<n-1;i++)
        ans *=2;

    for(int mask = 1;mask < 1<<m;mask++){
        int sign = 1;
        memset(cum, 0, sizeof(cum));

        for(int i=0;i<m;i++){
            if((1<<i) & mask){
                int u = mu[i];
                int v = mv[i];

                cum[u]++;
                cum[v]++;
                cum[lca[u][v]] -= 2;

                sign *= -1;
            }
        }

        int cnt = cover(1, 0);
        long long col = 1;
        for(int i=0;i<n-1-cnt;i++){
            col *= 2;
        }

        ans += sign * col;
    }

    cout << ans <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


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

  ll N;
  cin >> N;
  cout << N*(N-1)/2 << endl;
  
}


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

#define ll         long long int
#define pb         push_back
#define mk         make_pair
#define vec        vector<int>
#define vp         vector<pair<int , int>>
#define iter       vector<int>:: iterator
#define f(n)       for(int i=0 ; i<n ; i++)
#define sz         size()
#define srtv(v)    sort(v.begin() , v.end())
#define rsrt(v)    sort(v.rbegin() , v.rend())
#define M          1e5+5
#define fast       ios_base::sync_with_stdio(false);cin.tie(NULL)




using namespace std;

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

   int a[n],b[n],c[n];


   f(n){cin>>a[i];}

   b[0]=a[0] , c[n-1]=a[n-1];

   for(int i=1 ; i<n ; i++){
    b[i]=(b[i-1]+a[i]);
   }

   for(int i=n-2 ; i>=0 ; i--){
    c[i]=(c[i+1]+a[i]);
   }

   int mn = 100000;

   for(int i=0 ; i<n-1 ; i++){
    if((abs(b[i]-c[i+1]))<mn)
        mn=abs(b[i]-c[i+1]);
   }
    cout<<mn<<endl;

}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// Criba de Eratostenes ------------------------------------
const int pr=10000;
map<int,int>isp;
void criba(){
    for(int i=0;i<=pr;i++)isp[i]=1;
    isp[0]=isp[1]=-1;
    for(int i=2;i*i<=pr;i++){
        if(isp[i]==1){
        for(int j=i+i;j<=pr;j+=i)
            isp[j]=0;
        }
    }
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);

    int n;
    cin>>n;
    if(n==1){
        cout<<1;
        return 0;
    }
    for(int i=2;i<=1000;i++){
        for(int j=i*i;j<=1000;j*=i){
            isp[j]=1;
        }
    }
    while(isp[n]==0)n--;
    cout<<n<<enl;


    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)

int main() {
	string s; cin >> s;
	ll cnt = 0;
	rep(i, 0, s.size() - 1) {
		if (s[i] != s[i + 1])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
import re

S = input().replace('?', '.')
T = input()

n = len(S)
m = len(T)
j = -1
for i in range(n-m, -1, -1):
    if re.match(S[i:i+m], T):
        j = i
        break

if j == -1:
    print('UNRESTORABLE')
else:
    ans = ''.join(['a' if t == '.' else t for t in S])
    ans = ans[:j] + T + ans[j+m:]
    print(ans)

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int i, count;
  count = 0;
  for (i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3832
n,k=map(int,input().split())

al=[0]*(n+1)
bl=[0]*(n+1)
bl[0]=n
for i in range(1,n+1):
    al[i]=i+al[i-1]
    bl[i]=(n+1-i-1)+bl[i-1]
    
ans=0
for i in range(k,n+2):
    ans+=bl[i-1]-al[i-1]+1
print(ans%(10**9+7))

Measured memory_bytes: 67704
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use num::Integer;
use std::collections::HashMap;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut hm = HashMap::new();
    for _ in 0..n {
        let ai: usize = read!();
        *hm.entry(ai).or_insert(0) += 1;
    }

    let min = hm.iter().map(|m| m.0).min().unwrap();
    let max = hm.iter().map(|m| m.0).max().unwrap();

    let mut b = false;

    if hm[min].is_even() {
        b = b || min * 2 - 1 != *max
    } else {
        b = b || min * 2 != *max
    }

    for i in *min..=*max {
        if hm.get(&i).is_none() {
            b = true;
        }
    }

    let ans = if b { "Impossible" } else { "Possible" };
    println!("{}", ans);
}


Measured memory_bytes: 2172
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b % a ==0) System.out.println(a+b);
		else System.out.println(b-a);
		sc = null;
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    int x;
    cin >> x;
    x /=200;
    cout << 10-x << endl;

    return 0;
}


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


int main() {
  ll a,b,c; cin >> a >> b >> c;
  if(a==b&&b!=c||a==c&&a!=b||b==c&&a!=c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

pair<long long, int> arr[100000];

int main() {
	int n, m;
	scanf("%d %d", &n, &m);

	for (int i = 0;i < n;++i)
		scanf("%lld %d", &arr[i].first, &arr[i].second);

	sort(arr, arr + n);

	long long tot = 0;
	for (int i = 0;i < n && m > 0;++i) {
		if (arr[i].second > m) {
			tot += arr[i].first * m;
			m = 0;
		}
		else {
			tot += arr[i].first * arr[i].second;
			m -= arr[i].second;
		}
	}

	printf("%lld", tot);

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 4e2 + 7;
ll nxt(ll d) { return d / 1000 + (d % 1000) * 1000000000; }
unordered_map<ll, int > cnt;
void chg(ll d, int v) { rep(i, 0, 4) { cnt[d] += v; d = nxt(d); } }

ll v2d(vi v) { ll d = 0; rep(i, 0, 4) d = d * 1000 + v[i]; return d; }
vi d2v(ll d) { vi v(4); per(i, 0, 4) v[i] = d % 1000, d /= 1000; return v; }

int n;
ll c[N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n; 
	rep(i, 0, n) {
		vi v(4); rep(j, 0, 4) cin >> v[j];
		c[i] = v2d(v);
		chg(c[i], 1);
	}
	ll ans = 0, rel = 0;
	rep(i, 0, n) {
		chg(c[i], -1);
		ll ci = c[i];
		vi a = d2v(ci);
		rep(j, 0, n) if (j != i) {
			chg(c[j], -1);
			ll cj = c[j];
			rep(dj, 0, 4) {
				vi b = d2v(cj); cj = nxt(cj);
				ll up = v2d({b[1], b[0], a[1], a[0]});
				ll dn = v2d({a[3], a[2], b[3], b[2]});
				ll lf = v2d({b[1], a[0], a[3], b[2]});
				ll rt = v2d({a[1], b[0], b[3], a[2]});
				ll tmp = 1;
				tmp *= cnt[up]; chg(up, -1);
				tmp *= cnt[dn]; chg(dn, -1);
				tmp *= cnt[lf]; chg(lf, -1);
				tmp *= cnt[rt]; 
				ans += tmp;
				ll q = ans / 6;
				rel += q;
				ans -= q * 6;
				chg(lf, 1);
				chg(dn, 1);
				chg(up, 1);
			}
			chg(c[j], 1);
		}
		chg(c[i], 1);
	}
	cout << rel;
	return 0;
}

Measured memory_bytes: 239576
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem2365 : Memory Leak **/
const int null = -1, error = -2, nin = -3;
string s;
int p;

int ptr, size, maxSize;

vector<int> mem_size;
vector<bool> mem_flg;
int var[26];

int number(), malloc(), expr(), assign(), clone();
bool free(), line();

int number()
{
	int res = 0;
	while (isdigit(s[p])) {
		res*=10;
		res+=s[p]-'0';
		p++;
	}
	return res;
}

int malloc()
{
	p+=7;
	int b = number();
	p++;
	
	if (size+b>maxSize)
		return null;
	
	mem_size.push_back(b);
	mem_flg.push_back(true);
	size += b;
	
	return ptr++;
}

int clone()
{
	p+=6;
	int a = expr();
	if (a==null)
		return null;
	else if (a == error || a == nin || a >= mem_size.size() || !mem_flg[a]) {
		return error;
	}
	
	if (size+mem_size[a]>maxSize)
		return null;
	
	mem_size.push_back(mem_size[a]);
	mem_flg.push_back(true);
	size += mem_size[a];
	
	return ptr++;
}

int assign()
{
	int v = s[p] - 'A';
	p+=2;
	return var[v] = expr();
}

int expr()
{
	if (s[p] == '(') {
		p++;
		int t = expr();
		p++;
		return t;
	} else if (s[p] == 'N' && s[p+1] == 'U') {
		p+=4;
		return null;
	} else if (s[p] == 'm') {
		return malloc();
	} else if (s[p] == 'c') {
		return clone();
	} else if ('A'<=s[p] && s[p]<='Z' && s[p+1]=='=') {
		return assign();
	} else {
		return var[s[p++]-'A'];
	}
}


bool free()
{
	p+=5;
	int a = expr();
	p++;
	
	if (a == null) {
		return true;
	}
	
	
	if (a == nin || a == error || a >= mem_size.size() || !mem_flg[a]) {
		return false;
	}
	
	
	mem_flg[a] = false;
	size -= mem_size[a];
	mem_size[a] = 0;
	
	return true;
}

bool line()
{
	if (s[p] == 'f') {
		return free();
	} else {
		return expr()!=error;
	}
}


int main()
{
	cin>>maxSize;
	ptr=0, size=0;
	fill(var, var+26, nin);
	
	bool eFlg = true;
	while (cin>>s) {
		p=0;
		eFlg &= line();
	}
	
	if (!eFlg)
		cout << "Error" << endl;
	else {
		int ans = 0;
		rep(i, mem_size.size()) {
			if (mem_flg[i]) {
				bool flg=false;
				rep(j, 26) {
					if (i == var[j])
						flg = true;
				}
				if (!flg)
					ans+=mem_size[i];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
#define white 0
#define gray 1
#define black 2
#define NIL -1
#define MAX 2000
#define N 100
#define INFTY (1<<21)

int n,a[N][N];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    
    for(int i = 0;i < n;i++){
        d[i] = INFTY;
        p[i] = NIL;
        color[i] = white;
    }
    
    d[0] = 0;
    
    while(1){
        minv = INFTY;
        u = NIL;
        for(int i = 0;i < n;i++){
            if(minv > d[i]&&color[i] != black){
                u = i;
                minv = d[i];
            }
        }
        if(u == NIL)break;
        color[u] = black;
        for(int v = 0;v < n;v++){
            if(color[v] != black&&a[u][v] != INFTY){
                if(d[v] > a[u][v]){
                    d[v] = a[u][v];
                    p[v] = u;
                    color[v] = gray;
                }
            }
        }
    }
    int sum = 0;
    for(int i = 0;i < n;i++){
        if(p[i] != NIL)sum += a[i][p[i]];
    }
    return sum;
}

int main(){
    cin >> n;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> a[i][j];
            if(a[i][j] == NIL)a[i][j] = INFTY;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}


Measured memory_bytes: 3136
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);i++)
#define ote(x) cout<<(x)<<endl

int main(){
	int H,W; cin>>H>>W;
	vector<string> C(H);
	rp(i,H) cin>>C[i];
	for(auto e:C){
		ote(e);
		ote(e);
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
     int a,b,c,d,y,z;
     scanf("%d %d %d %d",&a,&b,&c,&d);
     if(a>b)
                y=b;
     else
     y=a;
      if(c>d)
      z=d;
     else z=c;
     printf("%d\n",y+z);

    return 0;
}


Measured memory_bytes: 1676
ls = [[] for i in range(3)]
for i in range(3):
    ls[i] = list(map(int,input().split()))


n = int(input())

bs = []
for i in range(n):
    bs.append(int(input()))


ans1 = False
for i in range(3):
    a = True
    for j in range(3):
        if ls[i][j] in bs:
            continue
        else:
            a = False
    if a == True:
        ans1 = True
        break
    else:
        continue

ans4 = False
for i in range(3):
    a = True
    for j in range(3):
        if ls[j][i] in bs:
            continue
        else:
            a = False
    if a == True:
        ans4 = True
        break
    else:
        continue

ans2 = False
if (ls[0][0] in bs) and (ls[1][1] in bs) and (ls[2][2] in bs):
    ans2 = True

ans3 = False
if (ls[2][0] in bs) and (ls[1][1] in bs) and (ls[0][2] in bs):
    ans3 = True


if (ans1 == True) or (ans2 == True) or (ans3 == True) or (ans4 == True):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 10;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
int n, m, ans, kind;
LL xsum, ori[MAXN], tar[MAXN], tot[MAXN];
int a[MAXN], b[MAXN], size[MAXN];
bool vis[MAXN];
int fa[MAXN];
int find(int x)
{
	if (fa[x] != x) fa[x] = find(fa[x]);
	return fa[x];
}
void unite(int x, int y)
{
    int fx = find(x), fy = find(y);
    if (fx == fy) return;
	fa[fy] = fx;
    size[fx] += size[fy];
}
bool cmp(int x, int y)
{
    return ori[x] < ori[y];
}
bool judge()
{
	map <LL, int> cnt;
    for (int i = 1; i <= n+1; i ++)
        cnt[ori[i]] ++;
    for (int i = 1; i <= n; i ++)
    {
        if (cnt[tar[i]] > 0)
	        cnt[tar[i]] --;
	    else 
	        return false;
    }
    return true;
}
void init()
{
	map <LL, int> id; 
    sort(tot + 1, tot + n + 2);
    id[tot[1]] = kind = 1;
    for (int i = 2; i <= n + 1; i ++)
    {
        if (tot[i] != tot[i-1]) kind ++;
        id[tot[i]] = kind;
    }
    for (int i = 1; i <= n+1; i ++)
    {
        a[i] = id[ori[i]];
        b[i] = id[tar[i]];
    }
}
int main()
{
	n = in();
	for (int i = 1; i <= n; i ++) 
    {
        tot[i] = ori[i] = in();
        ori[n + 1] ^= ori[i];
    }
    tot[n + 1] = ori[n + 1];
	for (int i = 1; i <= n; i ++) 
	{
		tar[i] = in();
		tar[n + 1] ^= tar[i];	
	}
    if (judge() == false) 
    {
        printf("-1");
        return 0;
    }
    init();
	for (int i = 1; i <= n + 1; i ++)
	{
		if (a[i] != b[i]) 
		{
			ans ++;
            size[a[i]] ++;
		}
		fa[a[i]] = a[i];
	}
	for (int i = 1; i <= n + 1; i ++)
	{
		if (find(a[i]) == find(b[i])) continue;
		unite(a[i], b[i]);
	}
    for (int i = 1; i <= n + 1; i ++)
    {
        if (fa[a[i]] == a[i] && a[i] != b[i] && !vis[a[i]]) 
		{
            // printf("size[%d]=%d\n", fa[a[i]], size[fa[a[i]]]);
			vis[a[i]] = true;
			ans ++;
		}
    }
	if (a[n+1] != b[n+1]) ans --;
	if (size[fa[a[n+1]]] > 1) ans --;
    cout << ans << endl;
	return 0;
}
/*
 
5
4 1 3 4 2
1 4 2 3 4
 
6
233 2333 666 233 1234 888
666 3117 233 233 888 2333 
 
6
233 2333 666 888 1234 233
666 3117 233 233 888 2333
*/
 


Measured memory_bytes: 12544
#include <stdio.h>

int main(void) {
	int d[10],b,c,i,j,n;

	scanf("%d",&n);
	for(i=0;i<n;i++) {
		b=c=0;
		for(j=0;j<10;j++) {
			scanf("%d",&d[j]);
		}
		for(j=0;j<10;j++) {
			if(d[j]>b)
				b=d[j];
			else if(d[j]>c)
				c=d[j];
			else
				break;

		}
		printf("%s\n",j==10?"YES":"NO");
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    vector<int> vec2;
    vector<int> vec3;
    
    for(int i = 0;i < N;i++){
        cin >> vec.at(i);
        if(vec.at(i) % 2 == 0){
            vec2.push_back(vec.at(i));
        }
    }
    int a = vec2.size();
    for(int i = 0;i < a;i++){
        if(vec2.at(i) % 3 == 0 || vec2.at(i) % 5 ==0){
            vec3.push_back(0);
        } else{
            vec3.push_back(1);
        }
    }
    
    vector<int> vec0(a,0);
    
    if(vec0 == vec3){
        cout <<"APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    
}

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

int main(){
  	long A, B, K;
  	cin >> A >> B >> K;
  	if(A>=K){
    	A-=K;
      	cout << A << " " << B << endl;
    }else{
    	B-= K-A;
      	if(B>=0){
      		cout << 0 << " " << B << endl;
        }else{
        	cout << 0 << " " << 0 << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    vector<int> x(3);rep(i, 3) cin >> x[i];
    sort(x.begin(), x.end());int Ma = x[2];
    rep(i, 2) {
        Ma += i;
        if((3*Ma-x[0]-x[1]-x[2])%2==0) {
            cout << (3*Ma-x[0]-x[1]-x[2])/2;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
 
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define NINF INT_MIN
const double pi=acos(-1); // value of pi


bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second<b.second;
}

// map<ll, list<ll>> m;
map<ll, ll> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    // cin >> t;
    while(t--) {
        ll ans=0;
        ll arr[5];
        for(ll i=0; i<5; i++) {
            cin >> arr[i];
            if(arr[i]==0) {
                ans=i+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
H,W,K=map(int,input().split())
li=[input() for _ in range(H)]
ans=0
for ir in range(1<<H):
  for jr in range(1<<W):
    cnt=0
    for i in range(H):
      if (ir>>i)&1:continue
      for j in range(W):
        if (jr>>j)&1:continue
        cnt+=li[i][j]=="#"
    if cnt==K:
      ans+=1
print(ans)

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

using namespace std;
#define el '\n'
#define ll long long
typedef vector<int> vi;
const int N = 1007;
char arr[N][N];
int dp[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r, c;
    cin >> r >> c;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> arr[i][j];
        }
    }
    bool flag = 1;
    for (int i = 0; i < r; ++i) {
        if(arr[i][0] == '#')
            flag = 0;
        if(flag)
            dp[i][0] = 1;
        else
            dp[i][0] = 0;
    }
    flag = 1;
    for (int j = 0; j < c; ++j) {
        if(arr[0][j] == '#')
            flag = 0;
        if(flag)
            dp[0][j] = 1;
        else
            dp[0][j] = 0;
    }
    for (int i = 1; i < r; ++i) {
        for (int j = 1; j < c; ++j) {
            if(arr[i][j] == '#')
                dp[i][j] = 0;
            else {
                dp[i][j]  = (dp[i - 1][j] + dp[i][j - 1])%1000000007;
            }
        }
    }
    cout<<dp[ r - 1][c - 1]<<el;
    return 0;
}

Measured memory_bytes: 8524
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	ll a, b, c, z=0, d=0;
	
	cin>>a>>b>>c;
	
	while(d<c){
		d+=a;
		z++;
		if(z%7==0) d+=b;
	}
	
	cout<<z<<endl;
}


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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
		cout<<1<<endl;
	else if(b==0)
		cout<<2<<endl;
	else if(c==0)
		cout<<3<<endl;
	else if(d==0)
		cout<<4<<endl;
	else
		cout<<5<<endl;
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> a(m,pair<int,int>(0,0));
  for(int i=0; i<m; i++){
    int x,y;
    cin>>x>>y;
    a[i]=make_pair(x,y);
  }
  
  sort(a.begin(),a.end());
  int l=a[0].first, r=a[0].second;
  int ans=1;
  for(int i=1; i<m; i++){
    if(r<=a[i].first){
      ans++;
      r=a[i].second;
    }else{
      l=max(l, a[i].first);
      r=min(r, a[i].second);
    }
  }

  cout<<ans<<endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
void cmax(int &x,int y){if(x<y)x=y;}
void cmin(int &x,int y){if(x>y)x=y;}
int n,V[25],x[MAX],t;
int L[20][MAX],R[20][MAX],mr[MAX];
int sl[1<<19],sr[1<<19];
int main()
{
	n=read();V[0]=read();
	for(int i=1;i<=n;++i)x[i]=read();
	while(V[t])V[t+1]=V[t]>>1,++t;int S=1<<t;
	for(int i=0;i<=t;++i)
	{
		L[i][1]=1;R[i][n]=n;
		for(int j=2;j<=n;++j)
			if(x[j]-x[j-1]<=V[i])L[i][j]=L[i][j-1];
			else L[i][j]=j;
		for(int j=n-1;~j;--j)
			if(x[j+1]-x[j]<=V[i])R[i][j]=R[i][j+1];
			else R[i][j]=j;
	}
	for(int i=1;i<S;++i)sl[i]=1,sr[i]=n;
	sl[0]=0;sr[0]=n+1;
	for(int i=0;i<S;++i)
		for(int j=1;j<=t;++j)
			if(!(i&(1<<(j-1))))
			{
				cmax(sl[i|(1<<(j-1))],R[j][sl[i]+1]);
				cmin(sr[i|(1<<(j-1))],L[j][sr[i]-1]);
			}
	memset(mr,63,sizeof(mr));
	for(int j=0;j<S;++j)cmin(mr[sl[j]],sr[(S-1)^j]);
	for(int i=n;~i;--i)mr[i]=min(mr[i],mr[i+1]);
	for(int i=1;i<=n;++i)puts(mr[L[0][i]-1]<=R[0][i]+1?"Possible":"Impossible");
	return 0;
}


Measured memory_bytes: 38272
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if(a>b){
    cout << a+(a-1) << endl;
  }
  else if(a<b){
    cout << b+(b-1) << endl; 
  }
  else {
    cout << a+b << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;
	vector<P> AB(N);
	rep (i, N){
		int A, B; cin >> A >> B;
		AB[i].first = A;
		AB[i].second = B;
	} // end rep

	sort(ALL(AB));

	int res = AB[N-1].first + AB[N-1].second;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let nb=readInts()
let n=nb[0]

var i:Double=1
var ans=0

while(i<=Double(n)){
  if(Int(log10(i))%2==0) {ans+=1}
  i+=1
}
print(ans)

Measured memory_bytes: 13772
#include <iostream>
#include <string>
#include <stack>

using namespace std;

bool is_balanced(string str) {
    stack<char> nest;
    for (int i=0; i<(int)str.length(); i++) {
        switch (str[i]) {
            case '(':
                nest.push('(');
                break;
            case '[':
                nest.push('[');
                break;
            case ')':
                if (!nest.empty() && nest.top() == '(') {
                    nest.pop();
                }
                else {
                    return false;
                }
                break;
            case ']':
                if (!nest.empty() && nest.top() == '[') {
                    nest.pop();
                }
                else {
                    return false;
                }
                break;
        }
    }
    return nest.empty();
}

int main() {
    string s;
    while (true) {
        getline(cin, s);
        if (s == ".") {
            return 0;
        }
        if (is_balanced(s)) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 1184
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()

def main():
    N, _, C = map(int, input().split())
    B = tuple(map(int, input().split()))

    ans = 0
    for _ in range(N):
        A = map(int, input().split())
        if sum([i * j for i, j in zip(A, B)]) + C > 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int ans1=a+a-1;
    int ans2=a+b;
    int ans3=b+b-1;
    cout<<max(ans1,max(ans2,ans3))<<endl;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll A = 0;
	ll B = 0;
	string ret = "Odd";// Odd

	cin >> A >> B;
	if( 0 == A * B % 2 ){
		ret = "Even";
	}
	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 256
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
void read(T&);
template<class T>
void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
const int N = 100005;

int a[N];

int main () {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  int now = 1, ans = 0;
  for (int i = 2; i <= n; ++i) {
    if (a[i] <= a[i - 1]) {
      ++now;
    } else {
      ans = max(ans, now - 1);
      now = 1;
    }
  }
  ans = max(ans, now - 1);
  write(ans), EL;
  return 0;
}

template<class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template<class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int x[100005];
int lower(int start,int end,long long int X){
    while(end-start>1){
        if(x[(start+end)/2]<X)start=(start+end)/2;
        else end=(start+end)/2;
    }
    return end;
}
int main(){
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> x[i];

    if(x[0]>=0)cout << x[k-1] << endl;
    else if(x[n-1]<=0)cout << -x[n-k] << endl;
    else{
        int tmp=lower(0,n-1,0LL);
        long long int ans=1e18;
        for(int i=max(0,tmp-k);i<min(tmp+1,n-k+1);i++){
            if(x[i]>0)ans=min(ans,x[i+k-1]);
            else if(x[i+k-1]<0)min(ans,-x[i]);
            else ans=min(ans,x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1])));
        }
        cout << ans << endl; 
    }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    string ansS = "";

    int beginnum = 0;
    int endnum = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == '(') {
            if (endnum > 0) {
                string addS = "";
                for (int j = 0; j < endnum; ++j) {
                    addS += "(";
                }
                ansS = addS + ansS;
                endnum = 0;
            }
            ansS = ansS + "(";
            beginnum++;
        } else {
            ansS = ansS + ")";
            if (beginnum > 0) {
                beginnum--;
            } else {
                endnum++;
            }
        }
        if (i == N - 1) {
            if (beginnum > 0) {
                string addS = "";
                for (int j = 0; j < beginnum; ++j) {
                    addS += ")";
                }
                ansS = ansS + addS;
                beginnum = 0;
            }
            if (endnum > 0) {
                string addS = "";
                for (int j = 0; j < endnum; ++j) {
                    addS += "(";
                }
                ansS = addS + ansS;
            }
        }
    }

    cout << ansS << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n;
	cin>>n;
	ll arr[n+1];
	map<ll,ll> mp1,mp2;
	for(int a=1;a<=n;a++)
	{
		cin>>arr[a];
		mp1[arr[a]+a]++;
		mp2[a-arr[a]]++;
	}
	map<ll,ll>::iterator it;
	ll ans=0;
	for(it=mp1.begin();it!=mp1.end();it++)
	{
		ans+=(it->se)*mp2[it->fi];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 39492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
	unordered_map<ll,int> M;
	vector<vector<ll>> Col(405),Hash(405);
	vector<ll> stand(405);
	auto cal=[&](int a,int b,int c,int d) -> vector<ll>{
		vector<ll>res;
		res.push_back((ll)1e9*a+(ll)1e6*b+(ll)1e3*c+d);
		res.push_back((ll)1e9*b+(ll)1e6*c+(ll)1e3*d+a);
		res.push_back((ll)1e9*c+(ll)1e6*d+(ll)1e3*a+b);
		res.push_back((ll)1e9*d+(ll)1e6*a+(ll)1e3*b+c);
		return res;
	};
	int n;cin>>n;
	for(int i=1;i<=n;i++) {
		vector<ll> tem(4);
		for(int j=0;j<4;j++) cin>>tem[j],Col[i].push_back(tem[j]);
		tem=cal(tem[0],tem[1],tem[2],tem[3]);
		for(auto x:tem) Hash[i].push_back(x);
		sort(tem.begin(),tem.end());
		M[tem[0]]++;stand[i]=tem[0];
	}
	ll ans=0;
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			for(int k=0;k<4;k++) {
				multiset<ll> used;
				ll sum=1;int same;
				used.insert(stand[i]);
				used.insert(stand[j]);
				int a1=Col[i][0],b1=Col[i][1],c1=Col[i][2],d1=Col[i][3];
				int d2=Hash[j][k]%1000,c2=Hash[j][k]/1000%1000,b2=Hash[j][k]/1000/1000%1000,a2=Hash[j][k]/1000/1000/1000%1000;
				

				vector<ll> V1;

				V1=cal(b1,a2,d2,c1);						
				sort(V1.begin(),V1.end());
				same=0;for(int ii=0;ii<4;ii++) if(V1[ii]==V1[0]) same++;
				sum=sum*(M[V1[0]]-used.count(V1[0]))*same;
				used.insert(V1[0]);


				V1=cal(a1,b2,a2,b1);
				sort(V1.begin(),V1.end());
				same=0;for(int ii=0;ii<4;ii++) if(V1[ii]==V1[0]) same++;
				sum=sum*(M[V1[0]]-used.count(V1[0]))*same;
				used.insert(V1[0]);

				V1=cal(d1,c2,b2,a1);
				sort(V1.begin(),V1.end());
				same=0;for(int ii=0;ii<4;ii++) if(V1[ii]==V1[0]) same++;
				sum=sum*(M[V1[0]]-used.count(V1[0]))*same;
				used.insert(V1[0]);

				V1=cal(c1,d2,c2,d1);
				sort(V1.begin(),V1.end());
				same=0;for(int ii=0;ii<4;ii++) if(V1[ii]==V1[0]) same++;
				sum=sum*(M[V1[0]]-used.count(V1[0]))*same;
				used.insert(V1[0]);

				ans+=sum;
			}
		}
		M[stand[i]]--;
	}
	cout<<ans<<endl;
    return 0;
}

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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    a,b = LI()
    if a >= 13:
        return b
    if a < 6:
        return 0

    return b // 2


print(main())



Measured memory_bytes: 7736
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
	char tmp[1000];

	int pattern[10000];
	int cnt=0;
	//1???????¶??????????????????§??????????¨??????°????????\???
	while (fgets(tmp, sizeof(tmp), stdin)) {
		//??????
		int num = atoi(strtok(tmp, " "));
		int sum = atoi(strtok(NULL, " "));
		//0 0????????°??????
		if (num == 0 && sum == 0)break;

		int i,j,k;
		//???????????§?¶?????????????
		for (i = 1; i <= num; i++) {
			for (j = i + 1; j <= num; j++) {
				for (k = i + 2; k <= num; k++) {
					if (i + j + k == sum) {
						//?¢???£???????¬????????????????
						//2???????????°???j???????????§????????¨???????????§?????????????????????????????§?£???°???
						if (j==k)continue;
						if (j > k)break;
						//????????????
						pattern[cnt]++;
					}
				}
			}
		}
		//?¶????????????????????????????

		cnt++;
	}
	//??????????????°????????????????????????
	int l;
	for (l = 0; l < cnt; l++) {
		printf("%d\n",pattern[l]);
	}

	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF = ll(1e18)+5;

void solve(long long X, long long N, std::vector<long long> p){
    set<int> s;
    for(int i=0;i<N;i++){
        s.insert(p[i]);
    }
    ll mV = INF;
    for(int i=-100;i<200;i++){
        if(s.find(i) != s.end()){
            continue;
        }
        mV = min(mV,abs(X-i));
    }
    if(s.find(X-mV) == s.end()){
        cout << X -mV << endl;
    }else{
        cout << X + mV << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int h,w,A,B;
int a[1010][1010];
int main(){
	cin>>h>>w>>A>>B;
	for(register int i=1;i<=h-B;i++){
		for(register int j=1;j<=w-A;j++){
			a[i][j]=1;
		}
	}
	for(register int i=h-B+1;i<=h;i++){
		for(register int j=w-A+1;j<=w;j++){
			a[i][j]=1;
		}
	}	
	for(register int i=1;i<=h;i++){
		for(register int j=1;j<=w;j++){
			cout<<a[i][j];
		}
		cout<<endl;
	}
} 

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 200001
//#define y 20
using namespace std;
typedef long long int ll;
# define f(i, n) for(int i = 0;i < n; ++i)
typedef long long int ll;

void input()
{
    ll n,d;
    cin >> n >> d;
    vector<vector<ll> > a(n, vector<ll>(d));
    f(i, n){
        f(j, d){
            cin >> a[i][j];
        }
    }
    ll ans = 0;
    function<bool(ll, ll) > dist = [&](ll i, ll j){
    ll x = 0;
       f(k, d){
            x += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
       }
       double y = sqrt(x);
       return(y == (ll)y);
    };
    f(i, n){
        for(ll j = i + 1; j < n; ++j){
            if(dist(i, j))++ans;
        }
    }
    cout << ans << endl;
}
int main()
{
    input();
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    int N;
    cin >> N;
    vector<tuple<string,int,int>> SPI;;
    rep(i,N){
        string S;
        int P;
        cin >> S >> P;
        P = -1*P;
        SPI.push_back(make_tuple(S,P,i+1));
    }

    sort(SPI.begin(),SPI.end());

    rep(i,SPI.size()){
        cout << get<2>(SPI[i]) << endl;
    }
}




Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

const int INF=100000001;

int main(void){
  int i,j,k,n,m,chest;
  static int a[1001],b[1001];
  static bool c[1001][12];
  static int dp[1001][20000];

  cin>>n>>m;

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      c[i][j]=0;
    }
  }

  for(i=1;i<=m;i++){
    cin>>a[i]>>b[i];
    
    for(j=0;j<b[i];j++){
      cin>>chest;
      chest--;
      c[i][chest]=1;
    }
  }

  int dpans=1;
  for(i=0;i<n;i++){
    dpans*=2;
  }
  dpans;

  for(i=0;i<=m;i++){
    for(j=0;j<dpans;j++){
      dp[i][j]=INF;
    }
  }

  for(i=0;i<=m;i++){
    dp[i][0]=0;
  }

  int tmp,key;
  for(i=1;i<=m;i++){
    tmp=1;
      key=0;
    for(k=0;k<n;k++){
      if(c[i][k])key+=tmp;
      tmp*=2;
    }
    if(c[i][k])key+=tmp;

    for(j=0;j<dpans;j++){
      dp[i][j]=dp[i-1][j];
      if(dp[i][j]>dp[i-1][j&~key]+a[i]){
        dp[i][j]=dp[i-1][j&~key]+a[i];
      }
    }
  }

  if(dp[m][dpans-1]!=100000001)cout<<dp[m][dpans-1]<<endl;
  else cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 76672
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int main(){
	int n,k;
	cin >> n>>k;
	hei(llint) a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, k, n) {
		if (a[i] > a[i - k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int dp[100000][3][3][2]; // k: 0->left, 1->right

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

    string s;
    while (cin >> s, s[0] != '#') {
        if (s.size() <= 2) {
            cout << 0 << endl;
            continue;
        }

        int N = s.size();
        V a(N);
        rep(i, N) a[i] = (s[i] - '1') % 3;

        const int INF = 1e9;
        rep(i, N) rep(l, 3) rep(r, 3) rep(k, 2) dp[i][l][r][k] = INF;

        if (a[0] <= a[1]) dp[1][a[0]][a[1]][1] = 0;
        if (a[1] <= a[0]) dp[1][a[1]][a[0]][0] = 0;

        rep2(i, 2, N) {
            rep(l, 3) {
                rep(r, 3) {
                    rep(k, 2) {
                        // left
                        if (a[i] <= r) {
                            dp[i][a[i]][r][0] = min(dp[i][a[i]][r][0], dp[i - 1][l][r][k] + (k == 0));
                        }
                        // right
                        if (a[i] >= l) {
                            dp[i][l][a[i]][1] = min(dp[i][l][a[i]][1], dp[i - 1][l][r][k] + (k == 1));
                        }
                    }
                }
            }
        }

        int ans = INF;
        rep(l, 3) rep(r, 3) rep(k, 2) ans = min(ans, dp[N - 1][l][r][k]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 18260