akhauriyash/Code-Regression huggingface dataset:
#define lop(i, n) for (int i = n-1; i >= 0; i--)
#define loop(i, x) for (int i = 0; i < x; i++)
#define loopf(i, x, n) for (int i = x; i < n; i++)
#define loopr(i, x, n) for (int i = x - 1; i >= n; i--)
#define ain(arr, n) for (int i = 0; i < n; i++) cin>>arr[i]
#define aout(arr, n) for (int i = 0; i < n; i++) cout<<arr[i]<<" "
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fe first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef complex<int> ci;

int main()
{
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	s[3] = '8';
	cout<<s<<"\n";
	return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int H_MAX = 500;
const int W_MAX = 500;

int H, W;
char a[H_MAX][W_MAX + 1];
char r[H_MAX][W_MAX + 1];
char b[H_MAX][W_MAX + 1];

void solve() {
  fill(r[0], r[H], '\0');
  fill(b[0], b[H], '\0');
  REP(i, H) REP(j, W) {
    if (a[i][j] == '#') {
      r[i][j] = b[i][j] = '#';
    } else if (j == 0) {
      r[i][j] = '#';
      b[i][j] = '.';
    } else if (j == W - 1) {
      r[i][j] = '.';
      b[i][j] = '#';
    } else if (i % 2 == 0) {
      r[i][j] = '#';
      b[i][j] = '.';
    } else {
      r[i][j] = '.';
      b[i][j] = '#';
    }
  }
  REP(i, H) puts(r[i]);
  puts("");
  REP(i, H) puts(b[i]);
}

void input() {
  scanf("%d%d", &H, &W);
  REP(i, H) scanf("%s", a[i]);
}

int main() {
  input();
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    int digit = n%10;
    if(digit == 3){
        cout << "bon" << endl;
    }
    else if(digit == 0 || digit == 1 || digit == 6 || digit == 8){
        cout << "pon" << endl;
    }
    else cout<< "hon" << endl;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int d, e;
    while(true){
        scanf("%d %d", &d, &e);
        if(d==0)break;
        double ans = 65536.0;
        for(int x = 0; x <= 100; x++){
            for(int y=0;y<=100;y++){
                if(x+y!=d)continue;
                double tmp = (double)e - sqrt(x*x+y*y);
                if(tmp<0)tmp=-tmp;
                ans = min(ans, tmp);
            }
        }
        printf("%.9f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 2576
#include<bits/stdc++.h>
    using namespace std;
    int n;
    char k;
    set <string> s;
    bool b;
    int main(){
    	cin>>n;
    	for(int i=0;i<n;i++){
    		string c;
    		cin>>c;
    		if(s.find(c)!=s.end() || (i!=0 && c[0]!=k))
    			b=true;
    		else
    			s.insert(c);
    		k=c[c.size()-1];
    	}
    	if(b)
    		cout<<"No";
    	else
    		cout<<"Yes";
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using LL=long long;

const int INF = 1'000'000'000;
const long long INFLL = 1'000'000'000'000'000'000;

using Weight=int;
using P=pair<Weight, int>;
struct Edge {
	int to; Weight cost;
	Edge(int _to, Weight _cost) :to(_to), cost(_cost) {}
};
struct Edge2 { int u, v; Weight cost; };
using Graph=vector<vector<Edge>>;

int BipartiteGraph(const Graph& graph) {
	int V = graph.size(), White = 0;
	vector<int> Cr(V);

	function<bool(int, int)> dfs = [&](int v, int c) {
		Cr[v] = c;
		White += c == 1;
		for (auto e : graph[v]) {
			if (Cr[e.to] == c)return false;
			if (Cr[e.to] == 0 && !dfs(e.to, -c))return false;
		}
		return true;
	};

	for (int i = 0; i < V; i++) {
		if (Cr[i] == 0) {
			if (!dfs(i, 1))return -1;
		}
	}
	return White;
}

int main() {
	int n, m; cin >> n >> m;
	Graph g(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b, 1);
		g[b].emplace_back(a, 1);
	}

	int b = BipartiteGraph(g);
	if (b == -1) {
		cout << (LL)n * (LL)(n - 1) / 2LL - (LL)m << endl;
	} else {
		cout << (LL)b * (LL)(n - b) - (LL)m << endl;
	}
}

Measured memory_bytes: 7168
import itertools 
n = int(input())
perms = list(itertools.permutations(list(range(n))))
xy = []
for i in range(n):
    a, b = map(int, input().split())
    xy.append([a, b])
ans = 0
for perm in perms:
    length = len(perm)
    dist = 0;
    for i in range(length-1):
        ind = perm[i]
        ind1 = perm[i+1]
        dist += ((xy[ind][0]-xy[ind1][0])**2 + (xy[ind][1]-xy[ind1][1])**2)**(1/2)
    ans += dist
print(ans/len(perms))


Measured memory_bytes: 8052
N,A,B,C = map(int,input().split(" "))
l = [int(input()) for x in range(N)]

b = []
for x in range(4**N):
    o = []
    s = -30
    for y in range(N):
        o.append((x//(4**y))%4)
    if (0 in o) and (1 in o) and (2 in o):
        a = [A,B,C]
        for y in range(N):
            if o[y] != 3:
                a[o[y]] -= l[y]
                s += 10
        b.append(sum(map(lambda x: x if x > 0 else -x,a))+s)

print(min(b))




Measured memory_bytes: 5000
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int x;
	cin >> x;
	
	long long ans = 0;
	
	for(int i = 1; i<= x; i++){
		for(int j = 1; j <= x;  j++) {
			for (int k = 1; k <= x; k++) {
				ans += gcd(i,gcd(j,k));
			}
		}
	}
	
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll H, W; scanf("%lld %lld", &H, &W);
		if (H == 0 && W == 0) break;
		ll res = 0;
		vector<vector<ll>> vs(H, vector<ll>(W)); for (ll i = 0; i < H; i++) for (ll j = 0; j < W; j++) scanf("%lld", &vs[i][j]);
		for (ll i = 1; i < H - 1; i++) {
			for (ll j = 1; j < W - 1; j++) {
				for (ll k = i + 1; k < H; k++) {
					for (ll l = j + 1; l < W; l++) {
						ll mx = 0;
						ll mn = INF;
						ll tmp = 0;
						for (ll m = i - 1; m <= k; m++) {
							chmin(mn, vs[m][j - 1]);
							chmin(mn, vs[m][l]);
						}
						for (ll n = j - 1; n <= l; n++) {
							chmin(mn, vs[i - 1][n]);
							chmin(mn, vs[k][n]);
						}
						for (ll m = i; m < k; m++) {
							for (ll n = j; n < l; n++) {
								chmax(mx, vs[m][n]);
								tmp += (mn - vs[m][n]);
							}
						}
						//cout << "a: " << mn << " " << mx << endl;
						if (mx < mn) {
							chmax(res, tmp);
						}

					}
				}
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int A[100010], B[100010];
vector<int> G[100010];
int color[100010];

int dfs(int v, int c) {
  color[v] = c;
  for (int i = 0; i < G[v].size(); i++) {
    if (color[G[v][i]] == c) return false;
    if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    G[A[i]].emplace_back(B[i]);
    G[B[i]].emplace_back(A[i]);
  }
  if (dfs(0, 1)) {
    int a = 0, b = 0;
    for (int i = 0; i < N; i++) {
      a += color[i] > 0;
      b += color[i] < 0;
    }
    cout << (ll)a*b - M << endl;
  } else {
    cout << (ll)N*(N-1)/2 - M << endl;
  }

  return 0;
}

Measured memory_bytes: 7296
# -*- coding: utf-8 -*-
import copy

def solve(S):
    res = 0
    for i in range(1<<(len(S)-1)):
        A = []
        A.append(S[0])
        for j in range(len(S)-1):
            if((i>>j)&1):
                A.append("+")
                A.append(S[j+1])
            else:
                A.append(S[j+1])
        res += eval("".join(A))
    print(res)
                
if __name__ == '__main__':
    S = list(input())
    solve(S)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S);
  CIN(w);

  REP(i, S.size()) {
    if ((i) % w == 0) cout << S[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int min(int a, int b) { return a < b ? a : b; }
int main(){
    int n,i,j,cost=2000000,ans=0,x[110]={};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&x[i]);
    }
    for(i=1; i<=100; i++){
        for(j=0; j<n; j++){
            ans+=(x[j]-i)*(x[j]-i);
        }
        cost=min(ans,cost);
        ans=0;
    }
    printf("%d",cost);
    return 0;
}

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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("YES\n")
#define no                 printf("NO\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    faster
    ll n;
    cin>>n;
    ll a[n+2],i,ans=0,sum=0;
    ll mx=1e9+7;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=a[i];
        sum%=mx;
    }
    
    for(i=1; i<=n; i++)
    {
        sum-=a[i];
        if(sum<0)
            sum+=mx;
        
        ans+=a[i]*sum;
        ans%=mx;
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 5176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

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

int main(){
  ll H,W,N;
  cin >> H >> W >> N;
  map<P,int> mp;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        mp[P(a+dx[i],b+dy[j])]++;
      }
    }
  }

  ll cnt[10] = {};
  for(auto it = mp.begin() ; it!=mp.end() ; it++){
    int x = it->first.first;
    int y = it->first.second;
    if(2 <= x && x <= H-1 && 2 <= y && y <= W - 1){
      cnt[it->second]++;
    }
  }

  cnt[0] = (H - 2) * (W - 2);
  for(int i=1;i<10;i++){
    cnt[0] -= cnt[i];
  }

  for(int i=0;i<10;i++){
    cout << cnt[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int K,X;
    
    cin >> K >> X;
    
    for(int i = X-K +1; i < X+K-1; i++)cout << i << " ";
    cout << X+K-1 << endl;
    
}


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

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string s;
    cin >> s;
    int count = 0;
    rep(i, s.size() - 1) {
        if (s.at(i) != s.at(i + 1)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;


int main() {

	int a, b;
	cin >> a >> b;
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

	ll ans = 1;
	if (N == 1) {
		ans = P;
	}
	else {
		ll Q = P;
		FOR(i, 2, sqrt(P)) {
			ll t = 0;
			while (Q%i == 0) {
				t++;
				Q /= i;
			}
			if (t >= N) {
				ll r = t / N;
				ans *= pow(i, r);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
T = []

for i in range(len(S)):
    if ord(S[i])+N <= 90:
        T.append(chr(ord(S[i])+N))
    elif ord(S[i])+N >90:
        T.append(chr(ord(S[i])+N-26))
    
for i in range(len(S)):
    print(T[i], end ='')

Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int dp[3000][3000]; // ans if len of s is x and len of t is y
int choice[3000][3000];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        string s,t; cin >> s >> t;
        int n = s.size(), m = t.size();
        if(s[0] == t[0]) 
            dp[0][0] = 1, choice[0][0] = 2;
        else dp[0][0] = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                // if not picking the current element
                if(i > 0){
                    dp[i][j] = dp[i-1][j];
                    choice[i][j] = 0;
                }

                if(j > 0){
                    //dp[i][j] = max(dp[i][j],dp[i][j-1]);
                    //choice[i][j] = 1;
                    if(dp[i][j-1] > dp[i][j]){
                        choice[i][j] = 1;
                        dp[i][j] = dp[i][j-1];
                    }
                }
                // pick the current element
                if(s[i] == t[j]){
                    int add = 1;
                    if(i > 0 and j > 0)
                        add = 1 + dp[i-1][j-1];
                    if(add > dp[i][j]){
                        choice[i][j] = 2; 
                        dp[i][j] = add;
                    }
                }
            }
        }
        int ans = dp[n-1][m-1];
        string subsequence ;
        int x = n-1, y = m-1;
        while(x >= 0 and y >= 0){
            if(choice[x][y] == 0) x--;
            else if(choice[x][y] == 1) y--;
            else{
                subsequence.pb(s[x]);
                --x; --y;
            }
        }
        reverse(all(subsequence));
        cout << subsequence;
    }       
}

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

namespace _0015
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> answerList = new List<string>();
            for (int i = 0; i < n; ++i)
            {

                BigInteger number1 = BigInteger.Parse(Console.ReadLine());
                BigInteger number2 = BigInteger.Parse(Console.ReadLine());
                BigInteger answer = 0;
                answer = number1 + number2;
                IsOver(answer, answerList);
            }
            foreach (var item in answerList)
            {
                Console.WriteLine(item);
            }

        }

        static void IsOver(BigInteger answer, List<string> list)
        {
            string str = answer.ToString();
            if ((str.Length) > 80)
            {
                list.Add("overflow");
            }
            else
            {
                list.Add(answer.ToString());
            }
        }
    }
}



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

int main() {
	//freopen("test.txt","r",stdin);
	int n;cin>>n;
	for(int i=1;i<10;i++)
	{
		if((n % i) == 0){
			if((n / i) <= 9){
				cout<<"Yes";return 0;
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    string s; cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i] == ',') cout << " ";
        else cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
// 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>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N], has[N];
void noo() {
    cout << "Impossible" << endl;
    exit(0);
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i], has[a[i]]++;
    int mx = 0, mn = 1e9;
    for (int i = 0; i < n; ++i)
        mx = max(mx, a[i]), mn = min(mn, a[i]);
    int cnt = 0, cntmn = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == mx)
            cnt++;
        if (a[i] == mn)
            cntmn++;
    }
    if (cnt == 1) {
        noo();
    }
    if (mx % 2 == 0) {
        if (cntmn != 1) {
            noo();
        }
    }
    if (mx % 2 == 1) {
        if (cntmn != 2) {
            noo();
        }
    }
    for (int i = 0; i < n; ++i)
        if (a[i] < (mx / 2) + (mx % 2)) {
            noo();
        }
    for (int i = 1; i <= n; ++i)
        if (!has[i] && has[i - 1] && has[i + 1])
            noo();

    cout << "Possible" << endl;
    return 0;
}




Measured memory_bytes: 256
def solve():
    Sss = [input().rstrip() for _ in range(3)]

    Sss.sort(key=len, reverse=True)
    As, Bs, Cs = Sss
    lenA, lenB, lenC = len(As), len(Bs), len(Cs)

    def check(Ss, Ts):
        for S, T in zip(Ss, Ts):
            if not (S == T or S == '?' or T == '?'):
                return 0
        return 1

    def getISOKs(Ss, Ts):
        lenS, lenT = len(Ss), len(Ts)
        isOKs = [0] * (lenS+lenT+1)
        for iT in range(-lenT, 0):
            isOKs[iT] = check(Ss[:lenT+iT], Ts[-iT:])
        for iT in range(0, lenS-lenT+1):
            isOKs[iT] = check(Ss[iT:lenT+iT], Ts)
        for iT in range(lenS-lenT+1, lenS+1):
            isOKs[iT] = check(Ss[iT:], Ts[:lenS-iT])
        return isOKs

    isOKABs = getISOKs(As, Bs)
    isOKACs = getISOKs(As, Cs)
    isOKBCs = getISOKs(Bs, Cs)
    isOKBCs = isOKBCs[:lenB+1] + [1]*(lenA+lenB+lenC) + isOKBCs[lenB+1:]

    ans = lenA + lenB + lenC
    for iB in range(-lenB, lenA+1):
        if not isOKABs[iB]: continue
        for iC in range(-lenC, lenA+1):
            if isOKACs[iC] and isOKBCs[iC-iB]:
                L = max(lenA, iB+lenB, iC+lenC) - min(0, iB, iC)
                ans = min(ans, L)
    for iB in range(-lenB, lenA+1):
        if not isOKABs[iB]: continue
        for iC in range(-lenB-lenC, -lenC+1):
            if isOKBCs[iC-iB]:
                L = max(lenA, iB+lenB, iC+lenC) - min(0, iB, iC)
                ans = min(ans, L)
        for iC in range(lenA, lenA+lenB+1):
            if isOKBCs[iC-iB]:
                L = max(lenA, iB+lenB, iC+lenC) - min(0, iB, iC)
                ans = min(ans, L)
    for iC in range(-lenC, lenA+1):
        if not isOKACs[iC]: continue
        for iB in range(-lenB-lenC, -lenB+1):
            if isOKBCs[iC-iB]:
                L = max(lenA, iB+lenB, iC+lenC) - min(0, iB, iC)
                ans = min(ans, L)
        for iB in range(lenA, lenA+lenB+1):
            if isOKBCs[iC-iB]:
                L = max(lenA, iB+lenB, iC+lenC) - min(0, iB, iC)
                ans = min(ans, L)

    print(ans)


solve()


Measured memory_bytes: 61788
def evenOdd(a,b):
    return True if a*b%2==1 or(a%2==0 and b%2==0) else False

x = list(map(int, input().split()))
x = sorted(x)
if evenOdd(x[0],x[1]) and evenOdd(x[1],x[2]) and evenOdd(x[2],x[0]):
    print(int((2*x[2]-x[0]-x[1])/2))
elif evenOdd(x[0],x[1]) and not(evenOdd(x[1],x[2]) and not evenOdd(x[2],x[0])) :
    print(int((x[2]-x[0]-1)/2+(x[2]-x[1]-1)/2 +1))
else:
    print(int((x[2]-x[0])/2)+int((x[2]-x[1])/2)+2)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int n = 0;
        for(int i=0;i<=a;i++){
            for(int j=0;j<=b;j++){
                for(int k=0;k<=c;k++){
                    if(500*i+100*j+50*k==x){
                        n++;
                    }
                }
            }
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 21844
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

#define PI 2*acos(0.0)

void solve()
{
    double r;
    cin >> r;

    double cir = 2 * PI * r;
    printf("%.5lf", cir);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3740
def num(m, b)
  return b.select{|i| i >= m}.length
end

def solve(n)
  a= Array.new(n+1, 1)
  for i in 2..n
    if a[i] == 1
      for j in ((i*2)..n).step(i)
        a[j] = 0
      end
    end
  end
  prime = []
  a.each.with_index do |v, index|
    prime.push(index) if v != 0 && index >= 2
  end

  b= Array.new(n+1, 0)
  for i in 2..n
    if a[i] == 1
      a[i] = 0
      j = i
      while j < n
        b[i] += n / j
        j *= i
      end
    end
  end
  
  return num(74, b) + num(24, b) * (num(2, b) - 1) + num(14, b) * (num(4, b) - 1) + num(4, b) * (num(4 , b) - 1) * (num(2, b) - 2) / 2
end


puts solve(gets.to_i)



Measured memory_bytes: 1788
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int H, W;
string A[MAX_N];
bool noH[MAX_N] = {};
bool noW[MAX_N] = {};

static inline bool isWhite(int y) {
    REP(i, W) { if(A[y][i] == '#') { return false; } }
    return true;
}

static inline bool isWhite2(int x) {
    REP(i, H) { if(A[i][x] == '#') { return false; } }
    return true;
}

signed main()
{
    cin >> H >> W;
    REP(i, H) {
        cin >> A[i];
    }

    REP(i, H) { if(isWhite(i)) { noH[i] = true; } }
    REP(i, W) { if(isWhite2(i)) { noW[i] = true; } }

    REP(i, H) {
        if(noH[i]) { continue; }
        REP(j, W) {
            if(noW[j]) { continue; }
            printf("%c", A[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    cin >> N;
    int score = 0;
    int maxi = 0;
    REPS(i,N){
        score+=i;
        if(score >= N){
            maxi = i;
            break;
        }
    }
    score = N;
    RREPS(i,maxi){
        if(score >= i){
            cout << i << "\n";
            score-=i;
        }
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }
    let start = std::cmp::max(a, c);
    let stop = std::cmp::min(b, d);
    if stop < start {
        println!("0");
    } else {
        println!("{}", stop - start);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<P> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i].fs;
		a[i].sc = i;
	}
	sort(ALL(a),greater<P>());
	vector<vector<ll>> dp(n + 1,vector<ll>(n + 1,0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; i + j < n; j++) {
			dp[i + 1][j] = max(dp[i + 1][j],dp[i][j] + a[i + j].fs * (a[i + j].sc - i));
			dp[i][j + 1] = max(dp[i][j + 1],dp[i][j] + a[i + j].fs * (n - (j + 1) - a[i + j].sc));
		}
	}
	ll ans = 0;
	for(int i = 0; i < n + 1; i++) {
		for(int j = 0; j < n + 1; j++) {
			ans = max(ans,dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34676
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    in_arr(ll, a, n);
    ll sum = 0;
    rep(i, n - 1){
        if(a[i] + a[i + 1] <= x)
            continue;
        ll eat = a[i] + a[i + 1] - x;
        sum += eat;
        if(a[i + 1] <= eat){
            a[i + 1] = 0;
            a[i] = x;
        }else{
            a[i + 1] -= eat;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

struct Vec{
 double x,y;
 Vec(double xx, double yy) : x(xx),y(yy) {}
 Vec operator+() const {return Vec(x,y);}
 Vec operator-() const {return Vec(-x,-y);}
 Vec operator+(const Vec& r) const {return Vec(x+r.x,y+r.y);}
 Vec operator-(const Vec& r) const {return Vec(x-r.x,y-r.y);}
 Vec operator*(double r) const {return Vec(x*r,y*r);}
 Vec operator/(double r) const {return Vec(x/r,y/r);}
 Vec& operator+=(const Vec& r) {*this=*this+r; return *this;}
 Vec& operator-=(const Vec& r) {*this=*this-r; return *this;}
 Vec& operator*=(double r) {*this=*this*r; return *this;}
 Vec& operator/=(double r) {*this=*this/r; return *this;}
 double operator*(const Vec& r) const {return x*r.x+y*r.y;}
 double abs() const {return sqrt(x*x+y*y);}
 double abs_squared() const {return x*x+y*y;}
};

Vec InputVec(){
 double x,y; scanf("%lf%lf",&x,&y);
 return Vec(x,y);
}

void PrintVec(Vec tg){
 printf("%.10f %.10f",tg.x,tg.y);
}

int main() {
 Vec O = InputVec();
 Vec A = InputVec() - O;
 A /= A.abs();
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  Vec X = InputVec() - O;
  PrintVec(O + A * (A*X));
  printf("\n");
 }
 return 0;
}



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

int main() {
  int a;
  cin >> a ;
  if (a==25) cout << "Christmas" << endl;
  else if(a==24) cout<< "Christmas Eve"<<endl;
  else if(a==23) cout<< "Christmas Eve Eve"<<endl;
  else cout<<"Christmas Eve Eve Eve" <<endl;

  return 0;
}//保留

Measured memory_bytes: 256
//00
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
  for(int p,c,w,s;cin>>p>>c>>w>>s,p;){
    cin.ignore();
    vector<string> v;
    for(string t;getline(cin,t),t!="?";){
      if(t.size()==0){
	v.push_back(string(w,'.'));
      }else{
	for(int i=0;i*w<t.size();i++){
	  string ds=t.substr(i*w,w);
	  ds+=string(w-ds.size(),'.');
	  v.push_back(ds);
	}
      }
    }
    while(v.size()%(p*c)){
      v.push_back(string(w,'.'));
    }
    for(int i=0;i*c<v.size();i++){
      for(int j=0;j<c;j++){
	cout<<v[i+(i/p)*p*(c-1)+p*j];
	if((j==c-1)){
	  cout<<endl;
	}else{
	  cout<<string(s,'.');
	}
      }
      if((i+1)%p==0){
	cout<<'#'<<endl;
      }
    }
    cout<<'?'<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string s;
  cin >> s;

  if (s.size() == 2) {
    if (s[0] == s[1]) {
      cout << "1 2\n";
    } else {
      cout << "-1 -1\n";
    }
    return 0;
  }

  for (int i = 0; i + 2 < s.size(); i++) {
    map<char, int> mp;
    for (int j = 0; j < 3; j++) {
      mp[s[i + j]]++;
    }
    for (auto j : mp) {
      if (j.second >= 2) {
        cout << i + 1 << " " << i + 3 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1\n";

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	int cnt = 0;
	for (int i = 0; i < S.size() / 2;i++) {
		if (S[i] != S[S.size() - i - 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


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

#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 MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,q; ll k;
	cin >> n  >>k >>q;
	
	VI a(n,0);
	
	rep(i, q){
		int z; cin >>z;
		a[z-1]++;
	}
	rep(i, n){
		a[i] += k -q;
	}
	for(auto x :a) cout <<(x>0? "Yes": "No") <<"\n";
	return 0;
}


Measured memory_bytes: 1024
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextLong()
    if (N % 2 == 1L) {
        println(0)
        return
    }
    var ans = 0L
    var A = 10L
    while (A <= N) {
        ans += N / A
        A *= 5
    }
    println(ans)
}

Measured memory_bytes: 33460
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> d(n);
    REP(i, n){
        cin >> d.at(i).first >> d.at(i).second;
    }

    for(ll i = 0; i + 2 < n; ++i){
        if(d.at(i).first == d.at(i).second && d.at(i + 1).first == d.at(i + 1).second && d.at(i + 2).first == d.at(i + 2).second){
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
 	int b[n];
  	int c[n-1];
  int ans = 0;
  for(int i = 0;i<n;i++) cin >> a[i];
  for(int i = 0;i<n;i++){
    cin >> b[i];
    ans += b[i];
  }
  for(int i = 0;i<n-1;i++) cin >> c[i];
  for(int i = 1;i<n;i++) {
  	if(a[i] - a[i-1] == 1){
    	ans += c[a[i-1]-1];
    }
  }
  cout << ans;
  
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,i,cnt=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    c%i;
    if(c%i==0){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 596
N=int(input())

alist,blist=[],[]
for _ in range(N):
  a,b=map(int,input().split())
  alist.append(a)
  blist.append(b)
alist.sort()
blist.sort()
#print(ablist,alist,blist)

if N%2==1:
  left=alist[N//2]
  right=blist[-N//2]
  #print(left,right)
  print(right-left+1)
else:
  left1=alist[N//2-1]
  left2=alist[N//2]
  right1=blist[-N//2-1]
  right2=blist[-N//2]
  #print(left1,right1,left2,right2)
  print(right1+right2-left1-left2+1) 

Measured memory_bytes: 99016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll X; int n;
	cin>>X>>n;
	set<ll> s; 
	forn(i,0,n) { ll x; cin>>x; s.insert(x); }
	
	ll ans=INF,ansx=-1;
	for(ll i=X-200;i<=X+200;i++){
		if(s.find(i)==s.end()){
			if(abs(X-i)<ans){
				ans=min(ans, abs(X-i));
				ansx=i;
			}
		}
	}
	cout<<ansx<<'\n';
	
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef queue<ll> ql;
typedef set<ll> sl;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 500010;
ll num, K, M, N, ans=0, count=0, sum=0;
int main() {
    cin >> K >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll DMAX=abs(K+A[0]-A[N-1]);
    rep(i, N-1) DMAX = max(DMAX,abs(A[i+1]-A[i]));
    cout << K-DMAX << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 110
#define ll long long
using namespace std;
int a[200005];
int main()
{
    int n;
    int flag=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            printf("NO\n");
            flag=1;
            break;
        }
    }
    if(flag==0)
        printf("YES\n");
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b,c=map(int,readline().split())
    if c-a-b<=0:
        print("No")
    elif 4*a*b<c**2+a**2+b**2-2*a*c+2*a*b-2*b*c:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin  >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    sort(all(a));
    double ans = (1.0 * a[0] + a[1]) / 2;
    REP(i,2,n) ans = (ans + a[i]) / 2;
    printf("%.6lf\n", ans);
}

int main() {
    solve();
    
    return 0;
}

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

int main() {
    std::set<int> s;
    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t, x;
        std::cin >> t >> x;
        if (t == 0) {
            s.insert(x);
            std::cout << s.size() << std::endl;
        } else if (t == 1){
            std::cout << s.count(x) << std::endl;
        } else {
            s.erase(x);
        }
    }
}



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

using namespace std;

#define MAX_V 334
#define INF 1e9

struct Edge{
    int to,cap,rev;
    Edge(int to,int cap,int rev) :
        to(to),cap(cap),rev(rev) {}
};

vector<Edge> G[MAX_V];
int level[MAX_V],iter[MAX_V];

void add_edge(int from,int to,int cap){
    G[from].push_back(Edge(to,cap,G[to].size()));
    G[to].push_back(Edge(from,0,G[from].size()-1));
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> Q;
    level[s] = 0;
    Q.push(s);
    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        for(int i = 0 ; i < (int)G[v].size() ; i++){
            Edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                Q.push(e.to);
            }
        }
    }
}

int dfs(int v,int t,int f){
    if(v == t) return f;
    for(int &i = iter[v] ; i < (int)G[v].size() ; i++){
        Edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s,int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f = dfs(s,t,INF)) > 0){
            flow += f;
        }
    }
}

int main(){
    int N,M,S,T,a,b;
    int edge[MAX_V][MAX_V];
    memset(edge,-1,sizeof(edge));
    cin >> N >> M;
    for(int i = 0 ; i < M ; i++){
        cin >> a >> b;
        a--; b--;
        add_edge(a,b,1);
        add_edge(b,a,1);
        edge[b][a] = i;
    }
    cin >> S >> T; S--; T--;
    int res = max_flow(S,T);
    cout << res << endl;
    vector<int> v;
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < (int)G[i].size() ; j++){
            int to = G[i][j].to;
            if(edge[i][to] == -1) continue;
            if(G[i][j].cap == 0){
                v.push_back(edge[i][to]);
            }
            edge[i][to] = -1;
        }
    }
    sort(v.begin(),v.end());
    int size = v.size();
    cout << size << endl;
    for(int i = 0 ; i < size ; i++){
        cout << v[i]+1 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
const int maxn = 123456;

char s[255][255];
int mp[255][255];

int T, R, C;
bool go(int x, int y){
    return x>=0 && x<R && y>=0 && y<C;
}

queue<piii>Q;

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


int main(int argc, char const *argv[])
{
    // freopen("input.txt", "r", stdin);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3616