akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int N;
	cin >> N;
	int a[ N ];
	double sum = 0.0;
	REP( i, N )
	{
		cin >> a[ i ];
		sum += a[ i ];
	}
	int t = round( sum / N );
	int ans = 0;
	REP( i, N )
	{
		ans += ( t - a[ i ] ) * ( t - a[ i ] );
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[40][40];
int n,c;
int x;
int cnt[3][40];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c;
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++)
			cin>>d[i][j];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>x;
			cnt[(i+j)%3][x]++;
		}
	}
	int res=1e9;
	for(int x1=1;x1<=c;x1++){
		for(int x2=1;x2<=c;x2++)if(x1!=x2){
			for(int x3=1;x3<=c;x3++)if(x1!=x3&&x2!=x3){
				int cand=0;
				for(int i=1;i<=c;i++)
					cand+=cnt[0][i]*d[i][x1];
				for(int i=1;i<=c;i++)
					cand+=cnt[1][i]*d[i][x2];
				for(int i=1;i<=c;i++)
					cand+=cnt[2][i]*d[i][x3];
				res=min(res,cand);
			}
		}	
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int n, T,h,i,x,y;
bool on = true;
int main() {
    // insert code here...
    scanf("%d %d", &n, &T);
    int c[n],t[n];
    for(h= 0;h<n;h++){
        scanf("%d %d",&c[h], &t[h]);
    }
    for(h= 0;h<n;h++){
        for(i = h;i>=0;i--){
            if(c[i-1]>c[i]&&i>0){
                
                    x = c[i-1];
                    c[i-1] = c[i];
                    c[i] =x;
                    y = t[i-1];
                    t[i-1] = t[i];
                    t[i] =y;
                
            }
        }
    }
    for(h= 0;h<n;h++){
        if(t[h]<= T){
            printf("%d",c[h]);
            on = false;
            break;
        }
    }
    if(on == true) printf("TLE");
    return 0;
}


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

double sum(double x){
  if(x==1) return 1;
  else return sum(x-1)+x;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<double> s(n);
  
  for(int i=0;i<n;i++){
    double a=0;
    cin >> a;
    s[i]=sum(a)/a;
  }
  
  int i=0;
  priority_queue<double> ans;
  double f;
   
  while(i+k-1<n){
    double a;
    if(i==0){
      for(int j=0;j<k;j++){
        a+=s[j];
      }
    }
    else{
      a=f-s[i-1]+s[i+k-1];
    }
    ans.push(a);
    f=a;
    i++;
  }

  cout << fixed << setprecision(7) << ans.top() << endl;
    
  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
 ll n,i,j,k=0;
 cin>>n;
 
 
 for(i=1;i<=n;i++)
 {
     cin>>j;
     if(i&1&&j&1)k++;
 }cout<<k;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a==c-b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
ll inf=1000000007;




int main(){
    //3で割って0,1,2の部分に色iが何個あるか
    int p[3][35]={};
    int N,C;
    cin>>N>>C;
    int D[35][35],c[550][550];
    
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            cin>>D[i][j];
        }
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>c[i][j];
            p[(i+j)%3][c[i][j]-1]++;
        }
    }
    
    int ans=1000000000;
    
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            for(int k=0;k<C;k++){
                if(i!=j&&j!=k&&k!=i){
                    int tmpans=0;
                    for(int l=0;l<C;l++){
                        tmpans+=p[0][l]*D[l][i];
                        tmpans+=p[1][l]*D[l][j];
                        tmpans+=p[2][l]*D[l][k];
                    }
                    ans=min(ans,tmpans);
                    
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s ,t;
	cin >> s >> t;


	int ans = 0;
	rep(i, 3)if (s[i] == t[i])ans++;
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    int n, k,count = 0;
    
    cin >> n >>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    
    
    rep(i, n){
        if(h[i] >= k) count++;
        
    }
    
    cout<<count<<endl;
    return 0;
}


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

int main(void) {
    string str;
    cin >> str;
    deque<string> deq;
    for (auto &&c : str) {
        deq.push_back(string(1, c));
    }
    int q;
    cin >> q;
    int rev = 0;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = 1 - rev;
        }
        else {
            int f;
            cin >> f;
            f--;
            string c;
            cin >> c;
            if (f == rev) {
                deq.push_front(c);
            }
            else {
                deq.push_back(c);
            }
        }
    }
    string ans = "";
    for (auto &&c : deq) {
        ans += c;
    }
    if (rev) {
        reverse(ans.begin(), ans.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13768
import collections

n = int(input())
l = [input() for _ in [0] * n]

counted = collections.Counter(l)
#print(counted)

m = max(counted.values()) # 最頻値

ans = []
for key, value in counted.items():
    if value == m:
        ans.append(key)

print(*sorted(ans),sep='\n')

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

int main() {
    int n, m;
    int A[100][100], b[100], c[100];
    cin >> n >> m;

    for ( int i = 0; i < n; i++) {
        for ( int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    for ( int k = 0; k < m; k++){
        cin >> b[k];
    }

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

    for ( int k = 0; k < n; k++) {
        cout << c[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long elimDups(vector<string>&);


int main() {
	int n,m,add,min,ans,finalans=0;
	long rs;
	vector<string> s,t,reads;
	string load;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> load;
		s.push_back(load);
	}
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> load;
		t.push_back(load);
	}
	reads = s;
	rs=elimDups(reads);
	for (int x = 0; x < rs; x++) {
		add = count(s.begin(), s.end(), reads[x]);
		min = count(t.begin(), t.end(), reads[x]);
		ans = add - min;
		if (ans > finalans) {
			finalans = ans;
		}
	}
	cout << finalans;
	return 0;
	
}
long elimDups(vector<string> &words) {
	sort(words.begin(), words.end());
	auto end_unique = unique(words.begin(), words.end());
	words.erase(end_unique,words.end());
	return words.size();
}

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

typedef long long ll;
using namespace std;

int main() {
	int a[6];
	int q;

	map<int,int> n;

	for (int i = 0;i < 6;i++){
		cin >> a[i];
		n[a[i]] = i;
	}

	int b[6][5] = {{1,2,4,3,1},{5,2,0,3,5},{4,0,1,5,4},{5,1,0,4,5},{0,2,5,3,0},{1,3,4,2,1}};
	
	cin >> q;

	for (int j = 0;j < q;j++){
		int c,d;
		cin >> c >> d;
		for (int i = 0;;i++){
			if(a[b[n[c]][i]] == d){
				cout << a[b[n[c]][i+1]] << endl;
				break;
			}
		}
	}

	return 0;

}


Measured memory_bytes: 3064
v = input().split(" ")
x = int(v[0])
k = int(v[1])
d = int(v[2])

if (x == 0):
    if (k % 2 == 0):
        ans = 0
    else:
        ans = d
else:
    if ((k * d) > abs(x)):
        y = abs(x) // d
        ans = abs(abs(x) - y * d)
        if ((k - y) % 2 == 1):
            ans = abs(d - ans)
    else:
        ans = abs(x) - k * d


print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
int md = 100000;
#define addm(X, Y) ((X) = ((X) + (Y) % md) % md)

int sx, sy, tx, ty;
string ans;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx;
    int h = ty - sy;
    rep(i, w) ans += 'R';
    rep(i, h) ans += 'U';
    rep(i, w) ans += 'L';
    rep(i, h) ans += 'D';
    ans += 'D';
    rep(i, w + 1) ans+= 'R';
    rep(i, h + 1) ans += 'U';
    ans += 'L';
    ans += 'U';
    rep(j, w + 1) ans += 'L';
    rep(j, h + 1) ans += 'D';
    ans += 'R';
    cout << ans << endl;
}


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

int main() {
  int N, red = 0, blue = 0;
  string s;

  cin >> N;
  cin >> s;

  for (int i = 0; i < N; ++i) {
    if (s[i] == 'R') {
      ++red;
    } else {
      ++blue;
    }
  }

  cout << (red > blue ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 888
//***Blessed are the curious for they shall have adventures********

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll n,k,ss=0,c=1;
    cin>>n>>k;

    string s;
    cin>>s;
    for(ll i=0;i<n-1;i++)
        if(s[i]==s[i+1])
            ss++;
        else 
            c++;
    
    ss+=2*min((c-1)/2,k);
    if(c%2==0)
        if(k>(c-1)/2)
        ss++;
    cout<<ss;
}

    

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

int main(){
    int h,w;
    cin >> h >> w;
    int mod=1e9+7;
    vector<vector<char>> maze(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> maze[i][j];
        }
    }
    vector<vi> dp(h,vi(w,0));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i!=h-1){
                if(maze[i+1][j]!='#') dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            } 
            if(j!=w-1){
                if(maze[i][j+1]!='#') dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, cnt= 0, d= 0;

    cin>> n;

    if(n<105)
    {
        cout<< 0;
        nl;
        return 0;
    }

    for(int i=107; i<=n; i+=2)
    {
        d= 0;

        for( int j= 3; j* j<= i; j++)
        {
            if(i% j== 0)
            {
                if(i== j* j)
                    d++;
                else
                    d+= 2;
            }

            if(d> 6)
                break;
        }

        if(d== 6 )
            cnt++;
    }

    cout<< cnt + 1;
    nl;

    return 0;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    string s;
    cin >> s;
    for(i = 0; i < 3; i++){
        x = 0;
        if(s[i] == 'R'){
            for(j = i; j < 3; j++){
                if(s[j] == 'R'){
                    x++;
                }
                else{
                    break;
                }
            }
        }
        m = max(m,x);
    }
    cout << m;

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n,i,ans;
string a[200001];
int main(){
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ans=1;
	for(i=1;i<n;i++){
		if(a[i]!=a[i-1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9852
import {readFileSync} from "fs";

const range = (n: number) => Array.from(Array(n), (_, i) => i);

const getNo = (n: bigint): string => {
  const alphabets = Array.from(Array(26), (_, i) => String.fromCharCode("a".charCodeAt(0) + i));

  const getNo = (n: bigint, l: bigint): string => {
    const m = 26n ** l;

    return n <= m
      ? range(Number(l)).reduce(
          ({ num, str }, _) => ({
            num: num / 26n,
            str: alphabets[Number(num % 26n)] + str,
          }),
          { num: n - 1n, str: "" }
        ).str
      : getNo(n - m, l + 1n);
  };

  return getNo(n, 1n);
};

{
  const input = readFileSync("/dev/stdin", "utf8");
  const N = BigInt(input);
  console.log(getNo(N));
}


Measured memory_bytes: 29616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ld,ld> pi;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
//#define mp make_pair

string s;

int main(){

cin >> s;
s[5]=' ';
s[13]=' ';
cout << s << endl;




return 0;}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define sz(a) int((a).size())

int n, d, x;
int a[105];

signed main()
{
	IOS;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = 1; j <= d; j+=a[i])
			cnt++;
		ans += cnt;
	}
	cout << ans + x << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

toClass w
  | w <= 48.0 = "light fly"
  | w <= 51.0 = "fly"
  | w <= 54.0 = "bantam"
  | w <= 57.0 = "feather"
  | w <= 60.0 = "light"
  | w <= 64.0 = "light welter"
  | w <= 69.0 = "welter"
  | w <= 75.0 = "light middle"
  | w <= 81.0 = "middle"
  | w <= 91.0 = "light heavy"
  | otherwise = "heavy"

main = map (toClass . readDouble) . lines <$> getContents >>= mapM_ putStrLn

Measured memory_bytes: 4112
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;

long long maxi(int l, int r, vector<long long>& mas) {
  if (l == 0) {
    return mas[r];
  }
  return mas[r] - mas[l - 1];
}

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

  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  vector<long long> pre_calc(n);
  vector<long long> pre_calc_max(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > 0 && i > 0) {
      pre_calc_max[i] = pre_calc_max[i - 1] + a[i];
    } else if (i == 0 && a[i] > 0) {
      pre_calc_max[i] = a[i];
    } else if (i != 0) {
      pre_calc_max[i] = pre_calc_max[i - 1];
    }
    if (i > 0) {
      pre_calc[i] = pre_calc[i - 1] + a[i];
    } else {
      pre_calc[i] = a[i];
    }
  }
  long long cur_ans = 0;
  for (int i = 0; i < n - k + 1; ++i) {
    long long local = 0;
    if (maxi(i, i + k - 1, pre_calc) > 0) {
      local += maxi(i, i + k - 1, pre_calc);
    }
    if (i > 0) {
      local += maxi(0, i - 1, pre_calc_max);
    }

    if (i + k < n) {
      local += maxi(i + k, n - 1, pre_calc_max);
    }
    cur_ans = max(local, cur_ans);
  }
  cout << cur_ans << endl;
  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/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; }

const ll mod = 1e9+7;

struct Sieve { // 篩
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;} // 素数判定
  vector<int> factorList(int x) { // 素因数列挙
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) { // 素因数分解(ランレングス圧縮的なもの)
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};


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

  int n;
  cin >> n;
  map<int, ll> mp;
  Sieve s(n);
  REP(i,n+1) {
    vi fl = s.factorList(i);
    for(int x : fl) mp[x]++;
  }
  ll ans = 1;
  for(P p : mp) {
    ans *= p.se+1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
  int n=1,m=1;
  int x[1000];
  int cnt=0;
  int max;

  while(n>0&&m>0){
    max=0;

    std::cin>>n>>m;
    if(n==0&&m==0) max=-1;
    int a[n+1];

    for(int i=1;i<n+1;i++){
      std::cin>>a[i];
    }

    for(int i=1;i<n;i++){
      for(int j=i+1;j<n+1;j++){
	int y=a[i]+a[j];
	if(max<y&&y<=m) max=a[i]+a[j];
      }
    }

    x[cnt]=max;

    cnt++;
  }

  for(int i=0;i<cnt;i++){
    if(x[i]==0){
      std::cout<<"NONE\n";
    }else if(x[i]>0){
      std::cout<<x[i]<<"\n";
    }else{
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2988
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#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 DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 2e3 + 5;

vector<ll>adj[MAXN];
ll vis[MAXN], inv[MAXN], dist[MAXN];

void bfs(ll source)
{
	vis[source] = 1;
	dist[source] = 0;
	queue<ll>q;
	q.push(source);
	while(!q.empty())
	{
		ll p = q.front();
		q.pop();
		for(auto it : adj[p])
		{
			if(vis[it]) continue;
			vis[it] = 1;
			dist[it] = dist[p] + 1;
			q.push(it);
		}
	}
}

int main()
{
	FAST_IO;

 	ll n, x, y;
 	cin >> n >> x >> y;
 	adj[x - 1].pb(y - 1);
 	adj[y - 1].pb(x - 1);
 	for(int i=0;i<n-1;i++) adj[i].pb(i + 1), adj[i + 1].pb(i);
 	for(int i=0;i<n;i++)
 	{
 		for(int j=0;j<n;j++) dist[j] = 0, vis[j] = 0;
 		bfs(i);
 		for(int j=0;j<n;j++) inv[dist[j]] += 1;
 	}
 	for(int i=1;i<n;i++) cout << inv[i] / 2 << endl;
    return 0;
}

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

bool isPal(string x) {
    /*string tmp = x;
    reverse(tmp.begin(), tmp.end());
    return tmp == x;*/
    int i = 0;
    int j = x.size() - 1;

    while (i < j) {
        if (x[i] == x[j]) {
            i++; j--;
        } else {
            break;
        }
    }
    return i >= j;
}


int main() {
    string s;
    cin >> s;
    int n = s.size();

    if (!isPal(s)) {
        cout << "No";
        return 0;
    }

    string l = s.substr(0, n/2);
    string r = s.substr(n/2+1, string::npos);
    if (!isPal(l) || !isPal(r)) {
        cout << "No";
        return 0;
    }

    cout << "Yes";

    return 0;
}


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


int main()
{
    int n;

    cin >> n;
  
    if(n == 7 || n == 5 || n == 3){
        cout << "YES";
    }else{
        cout << "NO";
    }


}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = [a[0]]
for i in range(1,n): b.append(b[-1]+a[i])
b = [0]+b
c,ans = Counter(b),0
for i in c.most_common():
	if i[1]==1: break
	ans += i[1]*(i[1]-1)//2
print(ans)

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

int main(){
  int a, b;
  cin >> a >> b;
  
  if((a %2 == 1) && (b %2 == 1)){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
s = list((map(int, input().split("/"))))

if s[0] == 2019:
    if s[1] == 4:
        if s[2] <=30:
            print("Heisei")  
        else:
            print("TBD")        
    if s[1] > 4:
        print("TBD")     
    if s[1] < 4:   
        print("Heisei")  
        
elif s[0]> 2019:
    print("TBD")     

elif s[0] < 2019:
    print("Heisei")  


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int read()
{
   int x=0,f=1;char ch=getchar();
   while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
   while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
   return x*f;
}
const int N=100005;
int cnt,head[N],a[N],b[N],id[N],u,v,fa[N],n,m,x,vis[N];
ll f[N],bsum[N];
struct node{int to,next;}num[N*2];
void add(int x,int y)
{num[++cnt].to=y;num[cnt].next=head[x];head[x]=cnt;}
bool cmp(int A,int B) {return a[A]<a[B];}
int getfather(int x) {return fa[x]?fa[x]=getfather(fa[x]):x;}
int main()
{
	n=read();m=read();
	for (int i=1;i<=n;i++) a[i]=read(),b[i]=read(),a[i]=max(a[i]-b[i],0),id[i]=i;
	for (int i=1;i<=m;i++) u=read(),v=read(),add(u,v),add(v,u);
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<=n;i++)
	{
		x=id[i];vis[x]=1;f[x]=a[x];bsum[x]=b[x];
		for (int j=head[x];j;j=num[j].next)
		  if (vis[num[j].to])
		  {
		  	  int y=getfather(num[j].to);
		  	  if (x==y) continue;
		  	  fa[y]=x;bsum[x]+=bsum[y];
		  	  f[x]=min(f[x],max(f[y],a[x]-bsum[y]));
		  }
	}
	printf("%lld\n",bsum[id[n]]+f[id[n]]);
   return 0;
}


Measured memory_bytes: 5760
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = K * (int) Math.pow(K - 1, N - 1);
        System.out.println(ans);
    }
}

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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
  // cin t;
   while(t--){
             ll n, k;
             cin >> n >> k;
             ll a[n];
             for(int i =0 ; i < n ; i++)
             cin >> a[i];
             sort(a , a+n);
             ll ans =0 ;
             for(int i =0 ; i < k; i ++)
             ans += a[i];
             cout << ans << endl;
   }
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int n;
	string s;
	cin >> n >> s;
	int tmp = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E') {
			tmp++;
		}
	}
	int ans = tmp;
	int cnt_w = 0;
	int cnt_e = tmp;
	for (int i = 2; i <= n; i++) {
		if (s[i - 1] == 'E') {
			cnt_e--;
		}
		if (s[i - 2] == 'W') {
			cnt_w++;
		}
		ans = min(ans, cnt_e + cnt_w);
	}
	cout << ans << endl;
}

Measured memory_bytes: 900
while True:
    H,W=input().split()
    H,W=[int(H),int(W)]
    if H==0 and W==0:
        break
    a=""
    b=""
    for i in range(0,W):
        if i%2==0:
            a=a+"#"
            b=b+"."
        else :
            a=a+"."
            b=b+"#"
    for i in range(0,H):
        if i%2==0:
            print(a)
        else :
            print(b)
    print()
        


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
const int nmax=100005;
vector<vector<int>> d(nmax,vector<int>(3,-1));
vector<vector<int>> g(nmax);
int n,m,s,t;
long long bfs(){
  d[s][0]=0;
  queue<pair<int,int>> q;
  q.push(make_pair(s,0));
  while(!q.empty()){
    pair<int,int> p=q.front();
    q.pop();
    int u=p.first,v=p.second;
    for(auto x:g[u]){
      if(d[x][(v+1)%3]==-1){
        d[x][(v+1)%3]=d[u][v]+1;
        q.push(make_pair(x,(v+1)%3));
      }
    }
  }
  if(d[t][0]==-1){
    return -1;
  }
  else{
    return d[t][0]/3;
  }
}
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a,b;cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
  }
  cin >> s >> t;
  s--,t--;
  cout << bfs() << endl;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

char buffer[100001];
int main(void)
{
	int length;
	int k;
	int cent;

	scanf("%s", buffer);
	length = strlen(buffer);
	cent = length;
	if (length & 1){
		int p = (length) / 2;
		int i;
		for (i = 1; i <= p; ++i){
			if (buffer[p - i] != buffer[p] || buffer[p + i] != buffer[p]){
				cent = 2 * i - 1;
				break;
			}
		}
	}
	else{
		int p = (length) / 2;
		int i;
		for (i = 0; i < p; ++i){
			if (buffer[p - i - 1] != buffer[p] || buffer[p + i] != buffer[p]){
				cent = 2 * i;
				break;
			}
		}
	}
	printf("%d", ((length - cent) / 2 + cent));
	return 0;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b,k;
    cin>>a>>b>>k;
    set<int> x;
    
    k = min(k,(b-a+1));
    for(int i=a;i<=a+k-1;i++){
        x.insert(i);
    }
    for(int i=b-k+1;i<=b;i++){
        x.insert(i);
    }
    for(auto i:x){
        cout<<i<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	N, Ma, Mb := getInt(), getInt(), getInt()
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N)
	for i := 0; i < N; i++ {
		a[i], b[i], c[i] = getInt(), getInt(), getInt()
	}
	var dp [41][410][410]int
	for i := 0; i <= N; i++ {
		for j := 0; j < 410; j++ {
			for k := 0; k < 410; k++ {
				dp[i][j][k] = math.MaxUint32
			}
		}
	}
	dp[0][0][0] = 0
	for i := 0; i < N; i++ {
		for j := 0; j < 400; j++ {
			for k := 0; k < 400; k++ {
				dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
				dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i])
				//out(i, j, k, " /", j+a[i], j+b[i], dp[i+1][j+a[i]][k+b[i]])
			}
		}
	}

	min := math.MaxInt32
	for i := 1; i < 400; i++ {
		for j := 1; j < 400; j++ {
			if i*Mb != j*Ma {
				continue
			}
			if min > dp[N][i][j] {
				min = dp[N][i][j]
			}

		}
	}
	if min == math.MaxInt32 {
		min = -1
	}
	out(min)
}


Measured memory_bytes: 56192
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


typedef unsigned int uint;
typedef pair<int, uint> iu;

uint encode(const vector<int>& v)
{
	uint res = 0;
	for (int i = (int)v.size() - 1; i >= 0; --i)
		res = (res << 4) + v[i];
	return res;
}
vector<int> decode(uint e)
{
	vector<int> res;
	for ( ; e; e >>= 4)
		res.push_back(e & 0xf);
	return res;
}
int main()
{
	int n, c[16][16];
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			cin >> c[i][j];

	vector<int> ori;
	for (int i = 1; i <= n; ++i)
		ori.push_back(i);
	int ori_e = encode(ori);

	int res = 0;
	map<int, int> dis;
	priority_queue<iu, vector<iu>, greater<iu> > q;
	dis[ori_e] = 0;
	q.push(iu(0, ori_e));
	while (!q.empty())
	{
		iu t = q.top(); q.pop();
		int cost = t.first;
		uint e = t.second;
		if (cost > dis[e])
			continue;

		max_swap(res, cost);

		vector<int> v = decode(e);
		for (int i = 0; i < n; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				swap(v[i], v[j]);
				int nc = cost + c[v[i]][v[j]];
				uint ne = encode(v);
				swap(v[i], v[j]);

				if (!dis.count(ne) || nc < dis[ne])
				{
					dis[ne] = nc;
					q.push(iu(nc, ne));
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 0
#include<stdio.h>

main(){

int i,j,n,x,y;

scanf("%d",&n);

for(i=1;i<=n;i++){
 x = i;
 j = 0;
 y = x;

 while(y > 10){
 y = y / 10;
  if(y % 10 == 3){
  printf(" %d",x);
  j = 1;
  break;
  }
 }
 
 if( j == 0){
 if(x % 3 == 0 || x % 10 == 3 ){
 printf(" %d",x);
 } 
 } 

}
printf("\n");
return 0;

}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){

  int X,N;cin>>X>>N;
  vi p(N);rep(i,N)cin>>p[i];
  sort(all(p));
  
  int ans=1000;
  rep(i,N+1){
    bool ok= false;
    rep(j,N){
      if(X-i==p[j]){
        ok=true;
      }
    }
    if(!ok){ans=X-i;break;}
     
    bool ok2= false;
    rep(j,N){
      if(X+i==p[j]){
        ok2=true;
      }
    }
    if(!ok2){ans=X+i;break;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
using namespace std;
  
#define int long long int 
typedef vector<int> vi;
typedef vector<pair<int, int>> vpi;
typedef vector<vi> vvi;
const int mod = 1e9 + 7; 

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define TC int t; cin >> t; while (t--) 

void Panda() {
    float d, t, s;
    cin >> d >> t >> s;
    if(d / s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
}
  
int32_t main() {
 
    FAST;

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout); 
    
    Panda();

    return 0; 
} 

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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int MOD=1e3;
const int N=1e5+5;
const ll maxn=1e6+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};

ll n,a,b;
void solve()
{
    if(a+b>n+1||a*b<n)///第一个条件很容易知道 第二个条件就写写找找看吧。。
    {
        cout<<-1;
        return ;
    }
    while(n>0)///每轮都是构造一个递增的子序列
    {
        ll x=min(a,n-b+1);///每一轮都取递增数和递减数中较小的那个
        //cout<<"x="<<x<<endl;
        for(ll i=n-x+1;i<=n;i++)
            cout<<i<<" ";
        n-=x;///x 为这一轮构造的递增子序列的个数
        b--;///递减的值 b 每一轮 -1
    }
}
int main()
{
    while(cin>>n>>a>>b)
    {
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0), cin.tie(NULL);
#define bge(s) s.begin(), s.end()
#define endl "\n"
#define int long long
using namespace std;

void lcs(string X, string Y, int m, int n)
{
    int L[m + 1][n + 1];
    int i, j;
    string s = "";
    for (i = 0; i <= m; i++)
    {
        for (j = 0; j <= n; j++)
        {
            if (i == 0 || j == 0)
                L[i][j] = 0;

            else if (X[i - 1] == Y[j - 1])
            {
                L[i][j] = L[i - 1][j - 1] + 1;
            }

            else
                L[i][j] = max(L[i - 1][j], L[i][j - 1]);
        }
    }

    int index = L[m][n];
    char lcs[index + 1];
    lcs[index] = '\0';
    i = m, j = n;
    while (i > 0 && j > 0)
    {
        if (X[i - 1] == Y[j - 1])
        {
            lcs[index - 1] = X[i - 1];
            i--;
            j--;
            index--;
        }

        else if (L[i - 1][j] > L[i][j - 1])
            i--;
        else
            j--;
    }
    cout << lcs << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    IOS
        string a,
        b;
    cin >> a >> b;
    lcs(a, b, a.size(), b.size());

    return 0;
}

Measured memory_bytes: 74004
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char const* argv[]) {
	int N;
	scanf("%d", &N);
	string S;
	cin >> S;
	int x = 0;
	int xMax = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') x++;
		else x--;
		xMax = max(xMax, x);
	}
	printf("%d\n", xMax);
	return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	int a[100];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	reverse(a, a + N);
	int nagasa = 0;
	for (int i = 0; i < K; i++) {
		nagasa += a[i];
	}
	cout << nagasa << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[21];
	char reverse[21];
	int i;
	int len;
	
	scanf("%s", str);
	
	len = strlen(str);
	len--;
	
	for (i = 0; len >= 0; i++){
		reverse[i] = str[len];
		len--;
	}
	len = strlen(str);
	reverse[len] = '\0';
	
	printf("%s\n", reverse);
	
	return (0);
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const long long M = 1000000007;

int n;
long long a[N];

long long ast[60];

long long q[60];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%lld", &a[i]);
    }
    ast[0] = 1;
    for (int i = 1; i < 60; ++i)
        ast[i] = (ast[i - 1] * 2) % M;
    long long ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (long long j = 0; j < 60; ++j)
        {
            if ((a[i] & (1LL << j)))
            {
                ans += (((i - 1) - q[j]) * ast[j]) % M;
                ans %= M;
                ++q[j];
            }
            else
            {
                ans += (q[j] * ast[j]) % M;
                ans %= M;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

string f(string x, string y) {
  int pos = 0;
  while(pos = x.find(y, pos), pos != string::npos) {
    x.replace(pos, y.length(), "0");
    pos = x.find(y, pos + 1);
  }
  return x;
}

int main()
{
  string s;
  const string Dreamer = "dreamer";
  const string Eraser = "eraser";
  const string Dream = "dream";
  const string Erase = "erase";

  cin >> s;

  s = f(s, "eraser");
  s = f(s, "erase");
  s = f(s, "dreamer");
  s = f(s, "dream");

  cout << ( s.find_first_not_of("0") == string::npos ? "YES" : "NO" ) << endl;
}

// better answer


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcount(n)
#define endl '\n'
const ll N=3e4+5,mod=1000000007,bit=60;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,z,k,x,y,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,next,sum=0,flag=1,i1=-1,i2=-1;
    cin>>x;
    for(i=1;i*i<=x;i++)
    {
    	if(x%i==0)
    	{
    		mn=min(mn,(x/i)+i-2);
    	}
    }
    cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , k  ;
    cin >> n >> k ;
    if(k & 1 ){
        ll a = n / k ;
        cout << a * a * a  << el ;
        ro ;
    }
    else {
        ll cnt1  = 0 ;
        ll cnt2  = 0 ;
        forn(i , 1 , n ) {
           if(i % k == 0 ) ++cnt1 ;
           else {
              if((i  -(k/2)) % k == 0 ) ++cnt2 ;
           }
        }
        ll ans = cnt1 * cnt1 * cnt1 + cnt2 * cnt2 * cnt2 ;
        cout << ans << el;
        ro ;
    }
}































Measured memory_bytes: 256