akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint n;
    cin>>n;
    vec h(n),dp(n,INF);
    rep(i,n)cin>>h[i];
    lint ans=0,a=0;
    rep(i,n-1){
        if(h[i]>=h[i+1])a++;
        else{
            ans=max(ans,a);
            a=0;
        }
    }
    ans=max(ans,a);
    cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll H, W, K;
	std::cin >> H >> W >> K;
	vector<string> S(H);
	rep(i, 0, H) {
		std::cin >> S[i];
	}

	vector<vll> cnt(H, vll(W + 1, 0));
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (S[i][j] == '1') {
				cnt[i][j + 1] = cnt[i][j] + 1;
			}
			else {
				cnt[i][j + 1] = cnt[i][j];
			}
		}
	}

	vll m(1LL << (H - 1),0),t(1LL << (H - 1),0);

	repeq(i, 1, W) {
		rep(j, 0, (1LL<<(H-1))) {
			ll tmp = 0;
			rep(k, 0, H) {
				tmp += cnt[k][i] - cnt[k][m[j]];
				if (tmp > K) {
					m[j] = i-1;
					t[j]++;
				}
				if (j & (1LL << k)) {
					tmp = 0;
				}
			}
		}
	}

	ll ans = 9999999;
	rep(j, 0, (1LL << (H - 1))) {
		rep(k, 0, H) {
			if (j & (1LL << k)) {
				t[j]++;
			}
		}
		ans = min(ans, t[j]);
	}


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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n,ans,m;
priority_queue<double>q;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)q.push(1.0*read());
	while(m--)
	{
		double u=q.top();q.pop();
		u=1.0*u/2.0;
		q.push(u);
	}
	for(int i=1;i<=n;i++)
	{
//		printf("%.2lf\n",q.top());
		ans+=(int)(q.top());q.pop();
	}
	cout<<ans;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

int main(){
    string s; cin >> s;
    int n=s.size();
    if(s[0]==s[n-1]){
        if(n%2==0){
            cout << "First" << endl;
        }else{
            cout << "Second" << endl;
        }
    }else{
        if(n%2==0){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
    }
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;

const ll inf=1000000000000000000ll;

int a,b,c,x,y;
ll ans,sum;

int main(){
	int i,j;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if (x<y) swap(x,y),swap(a,b);
	ans=inf;
	for (i=0;i<=x;i++){
		j=max(y-(x-i),0);
		sum=1ll*i*a+1ll*j*b+2ll*(x-i)*c;
		ans=min(ans,sum);
	}
	printf("%lld\n",ans);
	return 0;
}

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

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
const ll M = 1e9 + 7;
using namespace std;  
int main() 
{
	FAST
	ll n;
  	cin>>n;
  	cout<<n*n;
	return 0;
}

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

using namespace std;

struct Point {
    int x, y;
    Point(int x, int y) : x(x), y(y) {}
    Point() {}
};

Point operator-(const Point &a, const Point &b)
{
    return Point(a.x - b.x, a.y - b.y);
}

struct Poly_line {
    int m;
    bool right[11];
    int len[11];
    Poly_line() { m = 0; }
};

inline int Length(Point p1, Point p2)
{
    if (p1.y == p2.y)
        return abs(p1.x - p2.x);
    return abs(p1.y - p2.y);
}

inline bool Right(Point p1, Point p2)
{
    if (p1.x * p2.y - p1.y * p2.x < 0)
        return true;
    else
        return false;
}

void Input(Poly_line &pl)
{
    cin >> pl.m;
    vector<Point> p(pl.m);

    for (int i = 0; i < pl.m; ++i)
        cin >> p[i].x >> p[i].y;
    --pl.m;
    for (int i = 0; i < pl.m; ++i) {
        pl.len[i] = Length(p[i], p[i + 1]);
        if (i == 0)
            pl.right[i] = true;
        else {
            if (Right(p[i] - p[i - 1], p[i + 1] - p[i]))
                pl.right[i] = true;
            else
                pl.right[i] = false;
        }
    }
}

bool Match(const Poly_line &a, const Poly_line &b)
{
    bool foward = true, back = true;

    if (a.m != b.m)
        return false;

    for (int i = 0; i < a.m; ++i) {
        if ((a.len[i] != b.len[i]) || (a.right[i] != b.right[i])) {
            foward = false;
            break;
        }
    }
    if (foward)
        return true;

    if (a.len[0] != b.len[a.m - 1])
        return false;
    for (int i = 1; i < a.m; ++i) {
        if ((a.len[i] != b.len[a.m - i - 1]) || (a.right[i] == b.right[a.m - i])) {
            back = false;
            break;
        }
    }
    if (back)
        return true;
    else
        return false;
}

int main()
{
    int n;

    while (cin >> n, n) {
        vector<int> ans;
        Poly_line origin;

        Input(origin);
        for (int i = 1; i <= n; ++i) {
            Poly_line cmp;
            Input(cmp);
            if (Match(origin, cmp))
                ans.push_back(i);
        }

        for (int i = 0; i < ans.size(); ++i)
            cout << ans[i] << endl;
        cout << "+++++\n";
    }

    return 0;
}

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

int main(){
	int a,b,c,n;
	cin >> a >> b >> c;
	if(a > b){
		n = a;
		a = b;
		b = n;
	}
	if(b > c){
		n = b;
		b = c;
		c = n;
	}
	if(a > b){
		n = a;
		a = b;
		b = n;
	}
	cout << a << " " << b << " " << c << endl;
	
	return 0; 
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

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

const long long MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

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

    const int INF = 1000;
    vector<vector<int>> dp(1 << n, vector<int>(n + 1, INF));
    dp[0][n] = 0;
    rep(bit, 1 << n) {
        int cnt = popcnt(bit);
        
        rep(i, n + 1) rep(j, n) {
            if (bit >> j & 1) continue;

            int last_num = 0;
            if (i < n) last_num = x[abs(cnt - 1 - i) % 2][i];
            int new_num = x[abs(cnt - j) % 2][j];
            if (last_num <= new_num) {
                int rev = 0;
                repr(k, j, n) if (bit >> k & 1) rev++;
                chmin(dp[bit | (1 << j)][j], dp[bit][i] + rev);
            }
        }
    }

    int ans = INF;
    rep(i, n) chmin(ans, dp[(1 << n) - 1][i]);
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main() {
  int N, count = 1;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int j = 0; j < N - 1; j++) {
    if (vec.at(j) != vec.at(j + 1)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 11.01.2020 14:10:07       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  string f;
  cin >> f;
  int ans = 0;
  int flag = 0;
  for (int i = 0; i < n; i++) {
    ans += flag * t[i];
    flag |= f == s[i];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LLI n,i;cin>>n;
      LLI a[n];
      fo(i,0,n) cin>>a[i];
      sort(a,a+n);
      LLI p=1,x=1e18;
      fo(i,0,n){
        if(p==0) {i=n;break;}
        if(x/p<a[i]) break;
        p*=a[i];
      }
      if(i<n) cout<<-1;
      else cout<<p;
    }
    return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    string ans = "No";
    if (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
        ans = "Yes";
    }
    if (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        ans = "Yes";
    }
    if (s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
        ans = "Yes";
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int ss,s,a,b,i;
	scanf("%d",&b);
	while(b!=0) {
		s=0;
		for(i=0;i<9;i++){
			scanf("%d",&a);
			s+=a;
		}	
		ss=b-s;
		printf("%d\n",ss);
		scanf("%d",&b);
	}
	return 0;
}

Measured memory_bytes: 1028
n, m = map(int, input().split())
l = set()
r = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l.add(b)
    if b == n:
        r.add(a)
for x in l:
    if x in r:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 18936
#include <stdio.h>

int abs(int num)
{
	if(num >= 0)
		return num;
	else
		return -num;
}

int main(void)
{
	int x, y;
	int out = 0;
	
	scanf("%d %d", &x, &y);
	
	if( abs(x) > abs(y) && x > 0 || abs(x) < abs(y) && x < 0){
		x *= -1;
		out++;
	}
	
	while( abs(x) != abs(y) ){
		x++;
		out++;
	}
	
	if(x != y)
		out++;
	
	printf("%d", out);
	
	
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { lint to, cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }


int main() {
	int x, y, ans = 0;
	cin >> x >> y;
	ans += max((4 - x),0) * 100000;
	ans += max((4 - y),0) * 100000;
	if (x == y && x == 1) ans += 400000;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl shop = vv(n, 10, 0, ll), point = vv(n, 11, 0, ll);
  re(i, n) re(j, 10) std::cin >> shop[i][j];
  re(i, n) re(j, 11) std::cin >> point[i][j];
  ll ans = -100000000000000000;
  rep(i, 1, 1<<10){
    ll tmp_ans = 0;
    re(j, n){
      ll tmp = 0;
      re(k, 10) if(shop[j][k]>0&&(i&(1<<k))>0) tmp++;
      tmp_ans+=point[j][tmp];
    }
    //std::cout << tmp_ans << '\n';
    ans = max(ans, tmp_ans);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 504
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    long n = sc.nextLong();
    
    long ans = 9223372036854775807L;
    
    for(long i = 1; i <= Math.sqrt(n); i++) {
      if(n%i==0) {
        long a = i + (n/i) -2;
        if(a < ans) {
          ans = a;
        }
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<math.h>
int main()
{
int N;
double x,sum,cou,ave,w,W;
double n[1001]={};
while(1){
sum=0;cou=0;ave=0;w=0;W=0;
scanf("%d",&N);if(N==0)break;
for(int i=0;i<N;i++){
scanf("%lf",&x);n[i]=x;sum+=x;cou++;
}

ave=sum/cou;

for(int i=0;i<N;i++){
w+=(n[i]-ave)*(n[i]-ave);
}
w=w/N;
W=sqrt(w);
printf("%lf\n",W);
}
return 0;
}

Measured memory_bytes: 1092
main :: IO ()
main = do
  s <- getLine
  print $ min (f p01 s) (f p10 s)

f :: String -> String -> Int
f xs ys = length . filter (== False) $ zipWith (==) xs ys

p01 :: String
p01 = cycle "01"

p10 :: String
p10 = cycle "10"


Measured memory_bytes: 7164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin >> n;
    rep(i,n){
        string a,b;
        cin >> a >> b;
        int n1 = a.size();
        int n2 = b.size();
        int dp[n1+1][n2+1];
        rep(i,n1+1)rep(j,n2+1)dp[i][j] = 0;
        rep(i,n1)rep(j,n2){
            if(a[i] == b[j]&&dp[i+1][j] == dp[i][j+1]&&dp[i][j] ==dp[i+1][j])dp[i+1][j+1] = dp[i+1][j]+1;
            else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
        cout << dp[n1][n2] << endl;
    }
    return 0;
}


Measured memory_bytes: 7048
#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;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const ll Max=1e18+100;
const int sz=1e5+100;
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx,n;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>k)
    {
        l=0,r=1e18+100;
        ll ans=Max;
        ll ara[n],bara[n];
        for(i=0;i<n;i++) cin>>ara[i];
        for(i=0;i<n;i++)  cin>>bara[i];
        sort(ara,ara+n);
        sort(bara,bara+n,greater<int>());
        while(l<=r)
        {
            ll mid=(l+r)/2;
            bool bl=true;
            ll sum=0;
            for(i=0;i<n;i++){
                ll p;
                p=mid/bara[i];
                if(ara[i]>p) sum+=ara[i]-p;
                if(sum>k){
                    bl=false;
                    break;
                }
            }
            if(bl) ans=min(ans,mid),r=mid-1;
            else l=mid+1;
        }

        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3456
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i]&&b[i]==c[i])
			continue;
		int t=0;
		if(a[i]!=b[i]) t++;
		if(a[i]!=c[i]) t++;
		if(b[i]!=c[i]) t++;
		if(t==2)
			ans+=1;
		else
			ans+=2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
constexpr ll amari= 998244353;

void solve(){
    int n;
    cin>>n;
    vector<ll>d(n);
    map<ll,ll>mp;
    rep(i,n){
        cin>>d[i];
        mp[d[i]]++;
        if(d[0]!=0){
            cout<<"0\n";
            return;
        }
        if(mp[0]>1){
            cout<<"0\n";
            return;
        }
    }
    ll ans=1;
    ll cnt=0;
    for(auto x:mp){
        if(x.first!=cnt++){
            cout<<"0\n";
            return;
        }
        if(x.first>0){
            ans*=mod_pow(mp[x.first-1],mp[x.first],amari);
            ans%=amari;
        }
    }
    cout<<ans<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) {
        cout << -1 << endl;
    } else {
        cout << (A*B) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll a, b; cin >> a >> b;
  bool flag = 1;
  rep(i, a) {
    char c; cin >> c;
    ll tmp = c - '0';
    if (!(0<=tmp && tmp<=9)) flag = 0;
  }
  char c; cin >> c;
  if (c != '-') flag = 0;
  rep(i, b) {
    cin >> c;
    ll tmp = c - '0';
    if (!(0<=tmp && tmp<=9)) flag = 0;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
// atcoder/abc086/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s, t;
  while (cin >> s >> t) {
    s += t;
    int n;
    sscanf(s.c_str(), "%d", &n);
    bool f = false;
    for (int i = 0; i * i <= n; ++i) {
      f = f || (i * i == n);
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc102/tasks/arc100_a
# C - Linear Approximation

N = int(input().split()[0])
a_list = list(map(int, input().split()))
min_b = float('inf')
max_a = max(a_list)

work_list = [a - (i + 1) for i, a in enumerate(a_list)]
w = sorted(work_list)[int(N / 2)]
ans = sum([abs(x - w) for x in work_list])
print(ans)


Measured memory_bytes: 27588
#include <cstdio>

using namespace std;
int main()
{
    int i;
    int N, K;
    int ans;

    //input
    scanf(" %d", &N);
    scanf(" %d", &K);

    // 掲示板の係数をXとすると
    //  X<=KのときA
    //  X>KのときB
    // 結果が小さくなる

    ans = 1;
    for(i=0;i<N;i++){
        if(ans>K) ans+=K;
        else ans*=2;
    }

    //output
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;
    ll leng = 0;

    vll A(N);
    REP(i,N){cin >> A[i]; leng += A[i];}


    //本文
    ll minx = leng, sum = 0;
    REP(i,N){
        sum += A[i];
        minx = min(minx,abs(sum-(leng-sum)));
    }
    //出力
    cout << minx << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int X, Y;
    cin >> X >> Y;
    cout << (abs(Y - X) <= 1 ? "Brown" : "Alice") << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    if a < b:
        if b + (w * t) <= a + (v * t):
            print('YES')
        else:
            print('NO')
    else:
        if b + -(w * t) >= a + -(v * t):
            print('YES')
        else:
            print('NO')

if __name__ == '__main__':
    main()

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

    int N = S.size();
    int W = 0, B = 0;
    vector<int> place(N);
    rep(i, N) {
        if (S[i] == 'W') {
            place[i] = W;
            ++W;
        }
    }
    ll ans = 0;
    rep(i, N) {
        if (S[i] == 'W') ans += i - place[i];
    }
    cout << ans << endl;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 200005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

vector<ll> nextto[ARRAY];
vector<ll> point(ARRAY, 0);
vector<ll> score(ARRAY, 0);

ll N = 0;
ll Q;
ll ret = 0;

void setScore(ll v, ll prev) {
  if (v != 1) {
    score[v] = score[prev] + point[v];
  }
  FOREACH(u, nextto[v]) {
    if (u != prev) {
      setScore(u, v);
    }
  }
}

void input() {
  IN(N);
  IN(Q);
  ll tmp;
  REP(i, N-1) {
    ll a, b;
    IN(a);
    IN(b);
    nextto[a].pb(b);
    nextto[b].pb(a);
  }
  REP(i, Q) {
    ll p, x;
    IN(p);
    IN(x);
    point[p] += x;
  }
}

void solve() {
  score[1] = point[1];
  setScore(1, -1);
  FOR(i, 1, N+1) {
    cout << score[i] << " ";
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 25856
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

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

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> F(N);
    repeat(i, N) cin >> A[i];
    repeat(i, N) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    auto f = [&](long long mid) -> bool {
        long long x = 0;
        repeat(i, N) {
            x += max(0LL, (long long)A[i] - mid / F[i]);
        }
        return x <= K;
    };

    long long ng = -1, ok = 1e12 + 1000;
    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <stdio.h>

int  main(void) {
	int H, W, i, j;

	while (1) 
	{
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0)
		{
			break;//終了
		}
		else
		{
			for (i = 1; i <= H; i++)
			{
				for (j = 1; j <= W; j++) 
				{
					if ((i + j) % 2 == 0)//記号の判定
					{
						printf("#");//0のとき
					}
					else
					{
						printf(".");//1のとき
					}
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2044
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string s; cin>>s;
    vector<int> a(4,0);
    rep(i,4) a[i]=s[i]-'0';
    rep(i,8){
        int cnt=a[0];
        rep(j,3){
            if(i&(1<<j)) cnt+=a[j+1];
            else cnt-=a[j+1];
        }
        if(cnt==7){
            rep(j,3){
                cout<<a[j];
                cout<<((i&1<<j) ? "+" : "-");
            }
            break;
        }
    }
    cout<<a[3]<<"=7"<<endl;
}

Measured memory_bytes: 256
def cnt(S):
  S = [s for s in S]
  count = 0

  for i in range(1,len(S)):
    if S[i-1] == S[i]:
      if S[i-1] == '0':
        S[i] = '1'
      else:
        S[i] = '0'
      count += 1
  print(count)
  
S = input()
if len(S) <= 1:
  print(0)
else:
  cnt(S)



Measured memory_bytes: 3956
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
		A[i] /= 2
	}

	t := A[0]
	pow := countTwo(A[0])
	for i := 1; i < N; i++ {
		a := A[i]
		c := countTwo(a)
		if pow != c {
			fmt.Println(0)
			return
		}
		a = A[i]
		t = lcm(a, t)
	}

	fmt.Println((M/t + 1) / 2)
}

func countTwo(x int) int {
	c := 0
	for x > 0 && x%2 == 0 {
		x /= 2
		c++
	}
	return c
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}


Measured memory_bytes: 4276
R,G,B,N=map(int,input().split())
cnt=0
for r in range(0,N+1):#N//R+1):
    for g in range(0,N+1):#(N-r*R)//G+1):
        bunshi=N-r*R-g*G
        q,m=divmod(bunshi,B)
        if q<0:continue
        if m==0:cnt+=1
            
print(cnt)

Measured memory_bytes: 40940
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from bisect import bisect_left

def main():
  x, n = map(int, input().split())
  if n == 0:
    print(x)
    return
  
  lp = sorted(list(map(int, input().split())))
  cands = numpy.array(list(set(range(0, 102)) - set(lp))) - x
  i = bisect_left(cands, 0)
  a, b = cands[:i][::-1][0], cands[i:][0]
  if abs(a) > abs(b):
    print(x+b)
  else:
    print(x+a)

if __name__=='__main__':
  main()



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

int n,k;
int a[2010],b[2010],c[2010];
unsigned long long ans,nxs,mod=1e9+7;

void msort(int x[],int l,int r)
{
	if(l>=r) return;
	int mid=(l+r)>>1;
	msort(x,l,mid);
	msort(x,mid+1,r);
	int i=l,j=mid+1,p=l;
	while(i<=mid&&j<=r)
	{
		if(x[i]<=x[j])
		{
			c[p]=x[i];
			i++;
			p++;
		}
		else
		{
			nxs+=mid-i+1;
			c[p]=x[j];
			j++;
			p++;
		}
	}
	while(i<=mid)
	{
		c[p]=x[i];
		p++;
		i++;
	}
	while(j<=r)
	{
		c[p]=x[j];
		p++;
		j++;
	}
	for(int i=l;i<=r;i++)
		x[i]=c[i];
	return;
}

int main()
{
	cin >> n >> k;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		b[i]=a[i];
	}
	msort(b,1,n);
	ans=(nxs*k)%mod;
	nxs=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]>a[j]) nxs++;
		}
	}
	nxs%=mod;
	ans=(ans+(((k%mod)*((k-1)%mod)/2)%mod*nxs)%mod)%mod;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

vector<int> v(105);
ll dp[105][100010]; //dp[child #][number of candies left] = possibilities up to this point

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> v[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        dp[i][0] = 1;
        for(int j=1; j<=100000; j++)
        {
            if(j>v[i]) dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-v[i]-1]+mod)%mod;
            else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    cout << dp[n][k];
}


Measured memory_bytes: 79360
#include<stdio.h>

int main(void)
{
  char word[6];
  
  scanf("%s",word);
  
  if(word[2]==word[3]){
    if(word[4]==word[5]){
      printf("Yes\n");
    }
    else
      printf("No\n");
  }
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long;
using vl = vector<ll>; using vll = vector<vl>;
ll MOD = 998244353;
int main() {
	ll N, S;
	cin >> N >> S;
	vl A(N);
	for (ll i = 0; i < N; i++) cin >> A[i];
	vll dp(N + 1, vl(S + 1, 0));
	// 「0個目まで見て和が0」のみ1
	dp[0][0] = 1;
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j <= S; j++) {
			// 遷移【1】：i+1番目の数を使わない場合
			(dp[i + 1][j] += dp[i][j] * 2) %= MOD;
			// 遷移【2】：i+1番目の数を使う場合
			if (j + A[i] <= S) (dp[i + 1][j + A[i]] += dp[i][j]) %= MOD;
		}
	}
	cout << dp[N][S];
}

Measured memory_bytes: 73720
def match(y, x):
    ret = True
    for i in range(M):
        for j in range(M):
            if A[y + i][x + j] != B[i][j]:
                ret = False
    return ret
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(input()))
B = []
for i in range(M):
    B.append(list(input()))
flg = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        if match(i, j):
            flg = True
print("Yes" if flg else "No")

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

int main(){
  int n;
  int a[110];
  
  cin>>n;
  for(int i=0;i<n; i++)cin>>a[i];
  
  sort(a,a+n,greater<int>());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<n;++i){
    if(i%2==0){
      Alice += a[i];
    }
    else{
      Bob += a[i];
    }
  }
  cout<<Alice-Bob<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX_H 101
#define MAX_W 101
using namespace std;

char grid[MAX_H][MAX_W];
bool tate[MAX_W], yoko[MAX_H];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    for (int i = 0; i < H; i++) yoko[i] = false;
    for (int i = 0; i < W; i++) tate[i] = false;
    for (int i = 0; i < H; i++) {
        bool flag = true;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') flag = false;
        }
        if (flag) yoko[i] = true;
    }
    for (int i = 0; i < W; i++) {
        bool flag = true;
        for (int j = 0; j < H; j++) {
            if (grid[j][i] == '#') flag = false;
        }
        if (flag) tate[i] = true;
    }
    for (int i = 0; i < H; i++) {
        if (yoko[i]) continue;
        for (int j = 0; j < W; j++) {
            if (tate[j]) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	int a,b,c;
  cin >> a >> b >> c;
  if (a==7 && b==5 && c==5){
    cout << "YES";
  }else if (a==5 && b==7 && c==5){
    cout << "YES";
  }else if (a==5 && b==5 && c==7){
    cout << "YES";
  }else{
	cout <<"NO";
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

double snuke(ll a)
{
  ll sum=0,aa=a;
  while(a>0)
  {
    sum+=a%10;
    a/=10;
  }
  return (double)aa/sum;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;
  cin>>k;
  vector<ll>ans;
  rep(i,13)
  {
    ll num=pow(10,i)-1;
  //  cout<<num<<endl;
    rep(j,1000)
    {
      ll tnum=num+j*pow(10,i);
      ans.push_back(tnum);
      //cout<<tnum<<endl;
    }
  }
  sort(all(ans));
  ans.erase(unique(all(ans)),ans.end());
  double min=1e16;
  rep(i,ans.size())
  {
    int id=(int)ans.size()-i-1;
  //  cout<<ans[id]<<endl;
    if(min<snuke(ans[id]))
    {
      ans[id]=0;
    }
    else min=snuke(ans[id]);
    //cout<<ans[id]<<endl;
  }
  int cnt=0;
  rep(i,ans.size())
  {
    if(ans[i]>0){cout<<ans[i]<<endl;cnt++;}
    if(cnt==k)return 0;
  }


  return 0;

}


Measured memory_bytes: 512
#include <stdio.h>
#pragma warning(disable:4996)

int main(void){
	int x[100];
	int n = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}

	for (int i = 0; i < n / 2; i++){
		int temp = x[i];
		x[i] = x[n - 1 - i];
		x[n - 1 - i] = temp;
	}

	for (int i = 0; i < n; i++){
		if (i)	printf(" ");
		printf("%d", x[i]);
	}

	printf("\n");
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll K;

ll dfs(int j, vector<ll> a){

  ll n = a.size();
  if(n < K){
    return 0;
  }

  vector<ll> a0, a1;

  rep(i, n){
    if(a[i] & (1LL<<j)){
      a1.push_back(a[i]);
    }else{
      a0.push_back(a[i]);
    }
  }

  if(j == 0){
    if(a1.size() >= K){
      return 1;
    }else{
      return 0;
    }
  }else{

    if(a1.size() >= K){
      ll ans;
      ll ret_a1 = dfs(j-1, a1);
      ans = (1LL << j);
      ans += ret_a1;
      return ans;
    }else{
      return dfs(j-1, a);
    }
  }
}

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

  int N;
  cin >> N >> K;

  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  vector<ll> asum;

  for(int i = 0; i < N; i++){
    
    ll sum = a[i];
    asum.push_back(sum);
    for(int j = i+1; j < N; j++){
      sum += a[j];
      asum.push_back(sum);
    }
  }

  ll ans = 0;
  rep(i, 60){
    chmax(ans, dfs(i, asum));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 203144
import java.util.Scanner;

public class Main {
	 public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int r=sc.nextInt();
		 int c=sc.nextInt();
		 
		 int [][] h=new int [r+1][c+1];
		 
		 for(int i=0;i<r;i++) {
			 int rsum=0;
			 for(int j=0;j<c;j++) {
				 int tmp=sc.nextInt() ;
				 rsum +=tmp;
				 h[i][j]=tmp;
			 }
			 h[i][c]=rsum;
			 
		 }
		 for(int i=0;i<c+1;i++) {
			 int rsum =0;
			 for(int j=0;j<r;j++) {
			 rsum +=h[j][i];
			 }
			 h[r][i]=rsum;
		 }
	        for(int i = 0; i < r+1; i++) {
	            for(int j = 0; j < c; j++) {
	                System.out.print(h[i][j] + " ");
	            }
	            System.out.println(h[i][c]);
	        }
		 sc.close();
	 }
}



Measured memory_bytes: 42840
#include <stdio.h>
#include <math.h>

int main(void){
  double x, x3;
  int q;

  scanf("%d", &q);
  while(q != -1){
    x = q / 2.0;
    x3 = x*x*x;
    while(fabs(x3-q) >= 0.00001 * q){
      x = x - (x3-q)/(3*x*x);
      x3 = x*x*x;
    }
    printf("%f\n", x);
    scanf("%d", &q);
  }
  return 0;
}

Measured memory_bytes: 632