akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




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

	int n5max, n4max, n5min, n4min,num,count=0;
	n5min = n / 10000;
	n5max = k / 10000;
	n4min = (n - n5min * 10000) / 1000;
	n4max = (k - n5max * 10000) / 1000;


	for (int i = n5min; i <= n5max; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int l = 0; l < 10; l++) {
				num = i * 10000 + j * 1000 + l * 100 + j * 10 + i;
				//cout << num << endl;
				if ((num >= n)&& (num <= k)) count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
def C():
    N = int(input())
    ans = [0]*N
    seen = set()
    def helper(factors):
        x, y, z = factors
        seen.add((x, y, z))
        res = x*x + y*y + z*z + x*y + y*z + z*x
        if res > N:
            return
        ans[res-1] += 1
        if (x+1, y, z) not in seen:
            helper((x+1, y, z))
        if (x, y+1, z) not in seen:
            helper((x, y+1, z))
        if (x, y, z+1) not in seen:
            helper((x, y, z+1))

    helper([1, 1, 1])
    for i in range(N):
        print(ans[i])

C()


Measured memory_bytes: 33688
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	int res = 1e9;
	for (int len = 0; len <= n; ++len) {
		for (int ch = 'a'; ch <= 'z'; ++ch) {
			int flag = 1;
			for (int st = 0; st < n - len; ++st) {
				int cnt = 0;
				for (int j = st; j < st + len + 1; ++j) {
					cnt += (s[j] == ch);	
				}
				if (!cnt) flag = 0;
			}
			if (flag) {
				cout << len << endl;
				return 0;
			}
		}
	}
}



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

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++)  cin >> A[i];

  sort(A, A+N);
  
  int repitition = 0;
  for(int i = 1; i < N; i++)  if(A[i-1] == A[i])  repitition++;
  int numberOfDelete = 0;
  while(numberOfDelete < repitition) numberOfDelete += 2;

  cout << N-numberOfDelete << "\n";
  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

	//Program Start	
	int x;
	cin >> x;

	if(30 <= x) {
		cout << "Yes" << endl;
	} else {
		cout << "No" <<endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("read -p 'Press enter'");
#endif // !DEBUG

	return 0;
}

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

int main() {  
  int a, b;
  cin >> a >> b;
  
  if((max(a,b)-min(a,b))%2 == 1) {
  	cout << "IMPOSSIBLE" << endl;
  }
  else {
  	cout << (max(a,b)-((max(a,b) - min(a,b)) / 2 ))<< endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

bool is_prime(int n){
  if (n==1) return false;
  if (n==2) return true; 
  for (int i=2;i<=(int)sqrt(n);i++){
    if (n%i==0) return false;
  }
  return true;
}

int main(){
  int N; cin >> N;
  vector<int> p;

  int i = 2,cnt=0;
  while(cnt<N){
    if (is_prime(i) && i%5==2){
      p.push_back(i);
      cnt++;
    }
    i++;
  }

  rep(i,N) {
    cout << p[i];
    if (i!=N-1) cout << " ";
  }
  cout << endl;




  return 0;
}

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

using namespace std;
typedef long long int lld;
#define INF 1000000000000000000
#define MOD 1000000007
int n;
vector<int> nei[1000000];
lld DP[1000000][2];
bool done[1000000];
void compute(int node){
	done[node]=true;
	int cnt=0;
	DP[node][0]=1;
	DP[node][1]=1;
	for(int i=0;i<nei[node].size();i++){
		int v=nei[node][i];
		if(!done[v]){
			compute(v);
			cnt++;
			DP[node][0]*=DP[v][1];
			DP[node][1]*=(DP[v][1]+DP[v][0]);	
		
	
	
	
	DP[node][0]%=MOD;
	DP[node][1]%=MOD;
          }}
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++)done[i]=false;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	compute(0);
	//for(int i=0;i<n;i++)cout<<DP[i][0]<<" "<<DP[i][1]<<endl;
	cout<<(DP[0][0]+DP[0][1])%MOD<<endl;
	return 0;
}


Measured memory_bytes: 35840
INF  = float("inf") # 正の無限大

N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

H = list( map(int, input().split()) )	# 1 2 3 4 5 ...

C = [INF]*(N)
C[0] = 0

for i in range(N):
	for k in range(1, K+1):
		j = i + k
		if N<=j: break
		c = abs(H[i] - H[j])
		C[j] = min(C[j], C[i]+c)

print(C[-1])


Measured memory_bytes: 55040
#include <iostream>

using namespace std;

int main() {
	int a, b, c, i, numDi;
	numDi = 0;

	cin >> a >> b >> c;

	for (i = a; i <= b; i++) {
		if ((c % i) == 0) {
			numDi++;
		}
	}

	cout << numDi << endl;
	return 0;
}


Measured memory_bytes: 3100
def read():
	return [int(i) for i in input().split(" ")]
def maxInx(L, pre):
	tempM = [0, 0]
	for i in range(len(L)):
		if(L[i] > tempM[1] and i != pre):
			tempM = [i, L[i]] 
	return tempM[0] if tempM != [0, 0] else pre

(K, T) = read()
A = read()
pre = -1
sameDay = 0
for i in range(K):
	inx = maxInx(A, pre) 
	if(inx == pre):
		sameDay += 1
	A[inx] -= 1
	pre = inx
print(sameDay)

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

int main(){
  int n;
  cin >> n;
  vector<long long> x(n), y(n), h(n);
  int p;
  for(int i = 0; i < n; ++i){
    cin >> x.at(i) >> y.at(i) >> h.at(i);
    if(h.at(i) > 0) p = i;
  }
  
  long long ax, ay, ah;
  for(int i = 0; i <= 100; ++i){
    for(int j = 0; j <= 100; ++j){
      long long hi = h.at(p) + abs(i-x.at(p)) + abs(j-y.at(p));
      bool ok = true;
      for(int k = 0; k < n; ++k){
        long long t = h.at(k) + abs(i-x.at(k)) + abs(j-y.at(k));
        if(h.at(k) > 0){
          if(t != hi) ok = false;
        }
        else{
          if(t < hi) ok = false;
        }
      }
      if(ok) ax = i, ay = j, ah = hi;
    }
  }
  
  cout << ax << ' ' << ay << ' ' << ah << endl; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner( System.in );
        int len = scanner.nextInt();
        int[] arr = new int[100001];
        long total = 0;
        for (int count = 0; count < len; count++) {
            int num = scanner.nextInt();
            arr[num]++;
            total += num;
        }

        int queries = scanner.nextInt();
        for (int count = 0; count < queries; count++) {
            int num = scanner.nextInt();
            int replace = scanner.nextInt();
            if( arr[num] != 0 ){
                arr[replace] += arr[num];
                total += ( replace - num ) *  arr[num];
                arr[num] = 0;
            }
            System.out.println(total);
        }
        scanner.close();
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  double sum = 0;
  rep(i, N){
    double a;
    cin >> a;
    sum += 1 / a;
  }
  cout << (1 / sum) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <functional>

struct Node {
	std::vector<int> edgesDest;
	std::vector<int> edgesCost[2];

	bool done = false;
	int cost = -1;

	bool operator < (const Node& n) {
		return cost < n.cost;
	}
};

int main() {
	int n, m;
	std::vector<Node> nodes;
	using Pair = std::pair<int, int>;

	while (std::cin >> n >> m) {
		if (n == 0 && m == 0)
			break;

		nodes.clear();
		nodes.resize(m);
		for (int i = 0; i < n; ++i) {
			int a, b, c, t;
			std::cin >> a >> b >> c >> t;

			nodes[a - 1].edgesDest.push_back(b - 1);
			nodes[a - 1].edgesCost[0].push_back(c);
			nodes[a - 1].edgesCost[1].push_back(t);

			nodes[b - 1].edgesDest.push_back(a - 1);
			nodes[b - 1].edgesCost[0].push_back(c);
			nodes[b - 1].edgesCost[1].push_back(t);
		}

		int k;
		std::cin >> k;
		for (int i = 0; i < k; ++i) {
			for (int j = 0; j < nodes.size(); ++j)
				nodes[j].done = false, nodes[j].cost = -1;

			int p, q, r;
			std::cin >> p >> q >> r;
			--p, --q;

			nodes[p].cost = 0;

			std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair>> queue;
			queue.push(Pair(0, p));
			while (!queue.empty()) {
				const Pair& qtop = queue.top();
				Node& node = nodes[qtop.second];

				if (node.done) {
					queue.pop();
					continue;
				}
				if (qtop.second == q) {
					std::cout << node.cost << std::endl;
					break;
				}
				queue.pop();

				node.done = true;
				for (int j = 0; j < node.edgesDest.size(); ++j) {
					int dest = node.edgesDest[j];
					int cost = node.cost + node.edgesCost[r][j];

					if (nodes[dest].cost < 0 || cost < nodes[dest].cost) {
						nodes[dest].cost = cost;
						queue.push(Pair(cost, dest));
					}
				}
			}
		}
	}

	return 0;
}

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

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

  unordered_set<ll> st;
  
  bool doubled = false;
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    if(st.find(a) != st.end()){
      doubled = true;
      break;
    }
    st.insert(a);
  }
    

  cout << (doubled ? "NO" : "YES") << endl;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n = s.size();
    int f=0;
    int ans=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i] == 'R'){
            f=1;
            cnt++;
        }
        else{
            ans = max(ans,cnt);
            cnt=0;
            f=0;
        }
    }
    ans = max(ans,cnt);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/
char a[1000000];
int main(){
    ss(a)
    int lena = len(a);
    //pc(a[0]) pn pc(a[lena-1]) pn
    if(a[0] == a[lena-1]){
        //p123
        if(lena &1){
            puts("Second");
        }else{
            puts("First");

        }

    }else{
        if(lena & 1){
            puts("First");
        }else{
            puts("Second");
        }
    }

    return 0;

}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
  long long A,B;
  cin>>A>>B;
  cout<<A*B/gcd(A,B)<<endl;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

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

    long long int n,t,k;

    cin>>n>>k>>t;

    if(n%k==0){
    	cout<<(n/k)*t<<endl;
    }else{
    	cout<<((n/k)+1)*t<<endl;
    }

    return 0;
  }

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	vector<int> dp(n,INF);//足場iまでたどり着く最小値
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	rep2(i,2,n){
		dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
		dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
	}
	out(dp[n-1]);
}




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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

const ll mod = 1e9 + 7;

int main(){
    vector<ll> lis(1e6, 0);
    lis[0] = 1;
    REP(i, 1, 1e6){
        lis[i] = (lis[i-1] * 10) % 13;
    }
    string s; cin >> s;
    reverse(ALL(s));
    vector<vector<ll> > dp(s.size()+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    REP(i, 0, s.size()){
        int key = lis[i];
        if(s[i] != '?'){
            int to = (key * (s[i]-'0')) % 13;
            REP(l, 0, 13){
                dp[i+1][(l+to)%13] = (dp[i+1][(l+to)%13] + dp[i][l])%mod;
            }
        }else{
            REP(l, 0, 10){
                int to = (key * l)%13;
                REP(k, 0, 13){
                    dp[i+1][(k+to)%13] = (dp[i+1][(k+to)%13] + dp[i][k])%mod;
                }
            }
        }
    }
    cout << dp[s.size()][5] % mod << endl;
}

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

typedef long long ll;

int main(void) {
	int N;
	ll A, B, C, D, b_max, b_min;
	
	cin >> N >> A >> B >> C >> D;
	string ans = "NO";
	for (int k = 0; k <= N - 1; ++k) {
		b_max = A + D * k - C * (N - 1 - k);
		b_min = A + C * k - D * (N - 1 - k);
		if (b_min <= B && B <= b_max) {
			ans = "YES";
			break;
		}
	}

	cout << ans << '\n';
	return 0;
}


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

using namespace std;

long long gauss(long long a, long long b){
    long long ans = a / b;
    if (a % b != 0){
        ans ++;
    }
    return ans;
}

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

    vector <long long> T(N), A(N);
    for (int i = 0; i < N; i++){
        cin >> T[i] >> A[i];
    }

    long long t = T[0], a = A[0];

    for (int i = 1; i < N; i++){
        long long N = max(gauss(t, T[i]), gauss(a, A[i]));
        t = N * T[i];
        a = N * A[i];
    }

    cout << t + a << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll d[51];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>d[i];

    ll sum=0;
    REP(i, 0, n){
        REP(j, i+1, n){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
	//変数の宣言
	int x,y;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	long int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&x,&y);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
//	printf("計算部分終了\n");
	//出力
	
	if(abs(x-y)<=1){
		printf("Brown");
	}else{
		printf("Alice");
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int n,spec,i;
    long long move = 0;
    cin >> n >> spec;
    long *mons = new long[n];
    for(i=0;i<n;i++)
        cin >> mons[i];
    sort(mons,mons+n);
    for(i=0;i<n-spec;i++){
        move+=mons[i];
    }
    cout << move;
    return 0;
}

Measured memory_bytes: 1792
def swap(a, b):
    dummy = a
    a = b
    b = dummy
    return a, b


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

if l[0] > l[1]:
    l[0], l[1] = swap(l[0], l[1])

if l[1] > l[2]:
    l[1], l[2] = swap(l[1], l[2])

if l[0] > l[1]:
    l[0], l[1] = swap(l[0], l[1])

for n, i in enumerate(l):
    if n != 0:
        print(" ", end="")
    print(i, end="")
    
    if n == 2:
        print()



Measured memory_bytes: 5600
//--------------------------------------//
#include <bits/stdc++.h>
//-------------------------------------//
#define faster  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define cs(i) printf("Case %d: ", i);
#define test int t; cin >>t; while(t--)
#define forI(n) for(i=0; i<n; i++)
#define eofstr string s; while(cin >>s)
#define eof int n; while(cin>>n)
#define Y cout <<"YES" <<endl;
#define N cout <<"NO" <<endl;
#define cube(x) (x*x*x)
#define sqr(x) (x*x)
#define pi acos(-1)

//-------------------------------------//
typedef unsigned long long ull;
typedef long long int lld;
typedef long double ld;
using namespace std;
//------------------------------------//
lld i, j, f, k, p;

int main()
{
    faster;
    lld n;
    cin >>n;
    if(n%1000==0)
    {
        cout <<0 <<endl;
    }
    else
    {
        cout <<1000-n%1000 <<endl;
    }
    return 0;
}



Measured memory_bytes: 3592
#include<cstdio>
using namespace std;
int n,m,cnt[200005],in[200005],to[200005],ans,A,B;
int main()
{
	scanf("%d%d",&n,&m);for(int i=1;i<=n;++i) to[i]=i+1;
	for(int i=1;i<=n;++i) {scanf("%d",&in[i]);cnt[--to[in[i]]]++;}
	for(int i=1;i<=n;++i) if(!cnt[i]) ++ans;
	while(m--) {
		scanf("%d%d",&A,&B);
		if(to[in[A]]>0) {if(!(--cnt[to[in[A]]++])) ++ans;} else to[in[A]]++;
		if(to[B]>1) {if(!(cnt[--to[B]]++)) --ans;} else to[B]--;
		in[A]=B;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#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 vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll sum = 0;
  vl count(n,0); vl num(n);
  
  rep(i,n){
    ll x; cin >> x;
    num.at(i) = x-1;
    count.at(x-1)++;
  }
  
  rep(i,n){
    sum += (count.at(i))*(count.at(i)-1)/2;
  }
  
  
  rep(i,n){
    cout << sum - (count.at(num.at(i)) - 1) << endl;
  }
}
    

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<bitset>
#include<utility>

using namespace std;

vector<int> G[123456];
int c[123456];

pair<int,int> color(int v,int cc){
  if(c[v]){
    if(cc!=c[v])throw 0;
    return make_pair(0,0);
  }else{
    c[v]=cc;
    pair<int,int> p(cc==1,cc==-1);
    for(auto e:G[v]){
      auto r=color(e,cc*-1);
      p.first+=r.first;
      p.second+=r.second;
    }
    return p;
  }
}

int main(){
  int V,E;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bitset<123456> dp(1);
  try{
    for(int i=1;i<=V;i++){
      if(!c[i]){
	auto r=color(i,1);
	dp=dp<<r.first|dp<<r.second;
      }
    }
    long long ans=0;
    for(int i=0;i<=V;i++){
      if(dp[i]){
	ans=max(ans,1LL*i*(V-i)-E);
      }
    }
    cout<<ans<<endl;
  }catch(...){
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	vector<int>A(n);
	map<int,long long>cnt;
	for(i=0;i<n;i++)
	{
		cin>>A[i];
		cnt[A[i]]++;
	}
	long long ret=0;
	map<int,long long>::iterator p;
	for(p=cnt.begin();p!=cnt.end();p++)
    	ret+=(p->second-1)*p->second/2;
	for(int k=0; k<n; ++k) 
	{
    	long long n=cnt[A[k]];
        long long tmp=ret-(n-1)*n/2+(n-2)*(n-1)/2;
        cout<<tmp<<"\n";
    }
	return 0;
}

Measured memory_bytes: 11392
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let k: usize = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();

    if k * 500 >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}


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


void solve(std::string S, std::string T, long long A, long long B, std::string U){
    if(S == U){
        cout << A - 1 << ' ' << B << endl;
    }else{
        cout << A << ' ' << B - 1 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    solve(S, T, A, B, U);
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  int result = 0;
  int current = 0;
  rep(i, n) {
    current += l[i];
    result++;
    if (current > x) {
      break;
    }
  }
  if (current <= x) {
    result++;
  }

  cout << result << endl;

  return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

int main(){
  
  int L; string S;
  while(cin >> S >> L, L) {
    while(S.size() < L) S = "0" + S;
    vector< int > used(1000000, -1);
    for(int i = 0; ; i++) {
      if(~used[atoi(S.c_str())]) {
        cout << used[atoi(S.c_str())] << " " << atoi(S.c_str()) << " " <<  i - used[atoi(S.c_str())] << endl;
        break;
      }
      used[atoi(S.c_str())] = i;
      sort(S.begin(), S.end());
      int mini = atoi(S.c_str());
      reverse(S.begin(), S.end());
      int maxi = atoi(S.c_str());
      stringstream sss;
      sss << maxi - mini;
      S = sss.str();
      while(S.size() < L) S = "0" + S;
    }
  }
}

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

using namespace std;

int main(){
    long long a,b;
    cin>>a>>b;
    a--;
    long long aa=((a+1)/2)%2;
    long long f1=((a+1)%2 == 0 ? aa : aa^a);
    long long bb=((b+1)/2)%2;
    long long f2=((b+1)%2 == 0 ? bb : bb^b);
    cout<<(f1^f2);
}

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

long long n;
long long p[22];

int main(){
	cin >> n;
	for(long long i = 0; i < n; i++){
		cin >> p[i];
	}

	long long count = 0;
	for(long long i = 1; i < n - 1; i++){
		if((p[i-1] < p[i] || p[i+1] < p[i]) && (p[i-1] > p[i] || p[i+1] > p[i])){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0501?year=2006

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;

    while (cin >> n, n) {
        int head = 1, front = 2, right = 3;
        int ans = head;

        for (int i = 0; i < n; ++i) {
            int h = head, f = front, r = right;

            string op;
            cin >> op;

            if (op == "North") {
                head = f;
                front = 7 - h;
            } else if (op == "East") {
                head = 7 - r;
                right = h;
            } else if (op == "West") {
                head = r;
                right = 7 - h;
            } else if (op == "South") {
                head = 7 - f;
                front = h;
            } else if (op == "Right") {
                front = r;
                right = 7 - f;
            } else if (op == "Left") {
                front = 7 - r;
                right = f;
            }
            ans += head;
        }
        cout << ans << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3168
# Graph I - Graph
n = int(input())
for _ in range(n):
    ss = list(map(int, input().split()))
    u = ss[0] - 1
    row = [0 for _ in range(n)]
    for i in range(ss[1]):
        idx = 2 + i
        row[ss[idx]-1] = 1
    print(*row)


Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    cin>>n;
    if(n>=400 && n<=599)
        cout<<8<<endl;
    else if(n>=600 && n<=799)
        cout<<7<<endl;
    else if(n>=800 && n<=999)
        cout<<6<<endl;
    else if(n>=1000 && n<=1199)
        cout<<5<<endl;
    else if(n>=1200 && n<=1399)
        cout<<4<<endl;
    else if(n>=1400 && n<=1599)
        cout<<3<<endl;
    else if(n>=1600 && n<=1799)
        cout<<2<<endl;
    else if(n>=1800 && n<=1999)
        cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;


int main() {
	int N; cin >> N;
	int* a = new int[N+1];
	a[0] = 0;

	long ans = 0;
	for (int i = 0; i < N; i++) {
		int n; cin >> n;
		a[n] = i + 1;
	}

	set<int> st;

	st.insert(0);
	st.insert(N + 1);

	for (int i = 1; i <= N; i++) {
		int k = a[i];
		auto itr1 = st.lower_bound(k);
		auto itr2 = itr1; itr2--;

		long x = k - *itr2;
		long y = *itr1 - k;

		ans += x * y * (long)i;
		st.insert(k);
	}

	cout << ans << endl;
	
	return 0;
}

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

int main() {
    long long N;
    cin >> N;
    string res = "";
    while (N) {
        --N;
        res += (char)('a' + (N % 26));
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}
 

Measured memory_bytes: 3620
n = int(input())
l = []
t = x = y = 0
for _ in range(n):
    a,b,c = map(int,input().split())
    t_delta = a - t
    x_delta = abs(b - x)
    y_delta = abs(c - y)

    if (x_delta+y_delta <= t_delta) and (t_delta%2 == (x_delta+y_delta)%2):
            pass
    else:
        print ("No")
        exit ()

    t = a
    x = b
    y = c

print ("Yes")


Measured memory_bytes: 3060
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var alist = nextIntArray();
	var blist = nextIntArray();
	var output = 0;
	for(var i = 0; i < N; i++){
		if(alist[i] <= blist[i]){
			output += alist[i];
			blist[i] -= alist[i];
			output += Math.min(alist[i + 1], blist[i]);
			alist[i + 1] -= blist[i];
			if(alist[i + 1] < 0){
				alist[i + 1] = 0;
			}
		}else{
			output += blist[i];
		}
	}
	myout(output);
}


Measured memory_bytes: 49616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <climits>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

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

int N;

signed main()
{
	cin >> N;
	vector<pair<int, int>> P;
	rep(i, N) {
		int x, y; cin >> x >> y;
		P.push_back(make_pair(x, y));
	}

	sort(begin(P), end(P));

	double sum = 0;

	do {
		rep(i, N - 1) {
			int X = P[i].first - P[i+1].first;
			int Y = P[i].second - P[i+1].second;
			sum += sqrt(X * X + Y * Y);
		}
	} while (next_permutation(begin(P), end(P)));

	int d = 1;
	for (int i = 1; i <= N; ++i) d *= i;

	printf("%.10f\n", sum / d);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,x,y;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    x=a+b;
    y=c+d;
    if(x>y){
        printf("Left");
    }
    else if(y>x){
        printf("Right");
    }
    else{
        printf("Balanced");
    }
    return 0;
}


Measured memory_bytes: 128
function main(input) {
  var args = input.split('\n');
  var n = parseInt(args[0]);
  var an = args[1].split(' ');
  var on = [];
  var en = [];
  for(var i = 0; i < n; i++){
    if(i % 2 == 0) en.push(parseInt(an[i]));
    else on.push(parseInt(an[i]));
  }
  en.sort();
  on.sort();

  //最頻値と次の値を求める
  //出力を(x,n) (x2,n2)とする
  Array.prototype.mode2 = function () {
    var arr = [];
    var prevValue;
    this.forEach(function(element,index){
      if(element != prevValue){
        arr.unshift([element,1]);
        prevValue = element;
      }else{
        arr[0][1] += 1;
      }
    })
    
    arr.sort(function(a,b){
      return b[1] - a[1];
    })

    if(!arr[1]){
      arr.push([null,0]);
    }
    return [[arr[0][0],arr[0][1]],[arr[1][0],arr[1][1]]];
  }
  var evModes = en.mode2();
  var odModes = on.mode2();
  var ans = 0;

  if(evModes[0][0] != odModes[0][0]){
    ans = n - (evModes[0][1] + odModes[0][1]);
  }else{
    ans = n - Math.max(evModes[1][1] + odModes[0][1], evModes[0][1] + odModes[1][1]);
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28716
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//virtual participate
int main() {
    int n;
    cin >> n;
    if(n%1000 != 0)cout << 1000 - n%1000 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3624
import sys

n, a, b, *x = map(int, sys.stdin.read().split())

def main():
    border = (b + a - 1) // a

    res = 0
    for i in range(n-1):
        d = x[i+1] - x[i]
        if d >= border:
            res += b
        else:
            res += a * d

    return res

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

Measured memory_bytes: 14052
using System;
 
namespace ABC102a
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int Ans;
            if (N % 2 == 1)
                Ans = 2 * N;
            else
                Ans = N;
            Console.WriteLine(Ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
string s; 
int i=0;
int main()
{    
    cin>>s; 
    while(i<s.length())
    {
        if(s[i]!='0'&&s[i]!='1') 
        {
        	if(i>0) 
		 		s.erase(i-1,2),i--;
        	else 
				s.erase(i,1);
    	}
    	else 
			i++;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll c5=0,c7=0,a[3];
    rep(0,i,3)cin>>a[i];
    rep(0,i,3){
        if(a[i]==7)++c7;
        if(a[i]==5)++c5;
    }
    if(c7==1&&c5==2)cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

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

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int n; cin >>n;
  vector<int> dp(300010, INF);
  dp[0] = 0;

  for (int i=0; i<n; i++){
    chmin(dp[i+1], dp[i] + 1);
    int buf = 6;
    while(i + buf <= n){
      chmin(dp[i+buf], dp[i] + 1);
      buf *= 6;
    }
    buf = 9;
    while(i + buf <= n){
      chmin(dp[i+buf], dp[i] + 1);
      buf *= 9;
    }
  }
  cout <<dp[n] <<endl;
  
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n ,x;
	cin >>n >>x;
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	
	auto v=a;
	ll ans = accumulate(all(a),0LL);
	rep2(i,1,n){
		rep(j,n){
			v[j] = min(v[j], a[(j+n-i)%n]);
		}
		ll w = x*i + accumulate(all(v), 0LL);
		ans = min(ans, w);
	}
	
	cout << ans << endl;
	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		char[][] a = new char[H][];
		for(int i=0;i<H;i++){
			a[i] = new char[W];
			for(int j=0;j<W;j++) a[i][j] = '0';
		}
		for(int i=0;i<B;i++){
			for(int j=0;j<A;j++){
				a[i][j] = '1';
			}
		}
		for(int i=B;i<H;i++){
			for(int j=A;j<W;j++){
				a[i][j] = '1';
			}
		}
		for(int i=0;i<H;i++){
			Console.WriteLine(new String(a[i]));
		}
		
		
	}
	int H,W,A,B;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; A = d[2]; B = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18496
n = int(input())
ps = []
cur = -10 ** 18
ans = n
for i in range(n):
    x, l = map(int, input().split())
    ps.append([x - l, x + l])

ps = sorted(ps, key=lambda x: x[1])

for i in range(n):
    if ps[i][0] >= cur:
        cur = ps[i][1]
    else:
        ans -= 1
print(ans)


Measured memory_bytes: 22104
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
int a[101];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,n;
    cin>>x>>n;
    int p;
    for(int i=0;i<n;i++)
        {
            cin>>p;
            a[p]=1;
        }
    for(int i=0;i<=101;i++)
    {
        int l = x-i;
        if(!a[l])
        {
            cout<<l<<endl;
            return 0;
        }
        int  r = x+i;
        if(!a[r])
        {
            cout<<r<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[404][404],pfs[404],x;
int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)    cin >> x , pfs[i] = pfs[i-1] + x;

    for(int len = 2,i,j,k ; len <= n ; len ++)
        for(i = 1 , j = i + len - 1 ; j <= n ; j++, i++)
            for(dp[i][j] = 1e17,k = i ; k < j ; k++)
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + pfs[j] - pfs[i-1]);

    cout << dp[1][n] << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef map<char, int> MAP;

string s;

int main()
{
    cin >> s;
    int n = s.size();
    for(int i = 1; i < n; i++){
        if(s[i] == s[i - 1]){
            printf("%d %d\n", i, i + 1);
            return 0;
        }
    }
    for(int i = 2; i < n; i++){
        if(s[i] == s[i - 2]){
            printf("%d %d\n", i - 1, i + 1);
            return 0;
        }
    }
    
    printf("-1 -1\n");


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


struct Node {
    PII index;
    LL d;
    Node(PII index_, LL d_) : index(index_), d(d_) {}
};

vector<PII> directions{MP(-1, 0), MP(1, 0), MP(0, -1), MP(0, 1)};

int main() {
    LL H, W;
    cin >> H >> W;
    VVI visited(H, VI(W));
    queue<Node> q;
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, SZ(s)) {
            if (s[j] == '#') {
                visited[i][j] = 1;
                q.push(Node(MP(i, j), 0));
            }
        }
    }
    LL ans;
    while (!q.empty()) {
        Node n = q.front();
        q.pop();
        ans = n.d;
        EACH(d, directions) {
            LL i = n.index.first + d.first, j = n.index.second + d.second;
            if (0 <= i && i < H && 0 <= j && j < W && visited[i][j] == 0) {
                visited[i][j] = 1;
                q.push(Node(MP(i, j), n.d + 1));
            }
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 32308
<?php
$buildings = array();

for ($b = 0; $b < 4; $b++) {
    $building = array();

    for ($i = 0; $i < 3; $i++) {
        $building[] = array_fill(0, 10, 0);
    }

    $buildings[] = $building;
}

fscanf(STDIN, "%d", $n);

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d %d %d", $b, $f, $r, $v);
    $buildings[$b-1][$f-1][$r-1] += $v;
}

foreach ($buildings as $b => $building) {
    if ($b > 0) {
        echo "####################\n";
    }

    foreach ($building as $f => $rooms) {
        echo ' '.join(' ', $rooms)."\n";
    }
}

Measured memory_bytes: 6620
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

use std::collections::HashMap;

fn main() {
    let v: Vec<u32> = read_vec();
    let (n, m) = (v[0], v[1]);
    let mut map = HashMap::new();
    for _ in 0..m {
        let v2: Vec<u32> = read_vec();
        let (s, c) = (v2[0], v2[1]);

        if map.contains_key(&s) {
            if map.get(&s).unwrap() != &c {
                println!("{}", -1);
                return;
            }
        } else {
            map.insert(s, c);
        }
    }

    if n == 3 {
        for i in 100..1000 {
            if let Some(d1) = map.get(&3) {
                if i % 10 != *d1 {
                    continue;
                }
            }
            if let Some(d2) = map.get(&2) {
                if (i % 100) / 10 != *d2 {
                    continue;
                }
            }
            if let Some(d3) = map.get(&1) {
                if i / 100 != *d3 || *d3 == 0 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    if n == 2 {
        for i in 10..100 {
            if let Some(d1) = map.get(&2) {
                if i % 10 != *d1 {
                    continue;
                }
            }
            if let Some(d2) = map.get(&1) {
                if i / 10 != *d2 || *d2 == 0 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    if n == 1 {
        for i in 0..10 {
            if let Some(d1) = map.get(&1) {
                if i != *d1 {
                    continue;
                }
            }
            println!("{}", i);
            return;
        }
    }

    println!("{}", -1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

// struct IoSetup {
//     IoSetup() {
//         cin.tie(0);
//         ios::sync_with_stdio(false);
//         cout <<fixed<<setprecision(12);
//         cerr <<fixed<<setprecision(12);
//     }
// }IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, k;
int v[100];
int s[100];
int ds[100];
int r[100];
int dr[100];

signed main() {

    cin >> n >> k;
    vector<int> sx(n+5), rx(n+5);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }

    for(int i = 0; i < n; i++) {
        s[i+1] = s[i] + v[i];
        if(v[i] < 0) {
            sx[i+1] = (v[i]);
        }
    }

    for(int i = n-1; i >= 0; i--) {
        r[n - i] = r[n - i - 1] + v[i];
        if(v[i] < 0) {
            rx[n - i] = (v[i]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= min(n, k); i++) {
        for(int j = 0; j <= min(n, k) - i; j++) {

            int tmp = s[i] + r[j];

            vector<int> d;
            for(int l = 0; l < i; l++)
                d.bash(sx[l]);
            for(int l = 0; l < j; l++)
                d.bash(rx[l]);
            sort(ALL(d));
            
            for(int l = 0; l < min(k - i - j, (int)d.size()); l++){
                tmp -= d[l];
            }
            chmax(ans, tmp);
        }
    }

    cout << ans << endl;
  
    return 0;
}



Measured memory_bytes: 256