akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <queue>
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstring> 
#include <tuple>

using namespace std;

int point_to[110000];

struct comp {
    bool operator() (const int a, const int ot) const {
        return pair<int,int>(point_to[a], a) > pair<int,int>(point_to[ot], ot);
    }
};

int n;
int forb[110000];
int p[110000];
set<int, comp> pt;
set<int> av;
vector<int> avv;

bool go(int cur, int rem, int proi) {
    if (rem == 0) return true;

    for (int i = 0; i < rem; i++) if (avv[i] != proi) {
        p[cur] = avv[i];
        avv.erase(avv.begin()+i);
        if (go(cur+1, rem-1, forb[p[cur]])) {
            return true;
        }
        avv.insert(avv.begin()+i, p[cur]);
    }
    return false;
}

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

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> forb[i];
        forb[i]--;
        point_to[forb[i]]++;
        av.insert(i);
    }

    for (int i = 0; i < n; i++) {
        pt.insert(i);
    }

    int proi = -1;
    int st = 0;

    for (int i = 0; i < n-10; i++) {
        int big_point = *pt.begin();
        if (point_to[big_point] == (n-i)-1) {
            p[i] = big_point;
        }
        else {
            p[i] = *av.begin();
            if (p[i] == proi) p[i] = *(++av.begin());
        }

        av.erase(p[i]);
        proi = forb[p[i]];
        pt.erase(p[i]);
        
        if (av.count(proi)) {
            pt.erase(proi);
            point_to[proi]--;
            pt.insert(proi);
        }

        st++;
    }

    for (int x : av) avv.push_back(x);
    if (go(st, n-st, proi)) {
        for (int i = 0; i < n; i++) {
            cout << p[i]+1;
            if (i != n-1) cout << ' ';
        }
        cout << endl;
    }
    else cout << -1 << endl;


}




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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

void solve(){
	int a,b;
	cin >> a >> b;
	cout << a*b << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3612
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
v1=Counter(v[::2])
v2=Counter(v[1::2])
v1[0]=0
v2[0]=0
v1_max=v1.most_common()[0]
v2_max=v2.most_common()[0]
v1_second=v1.most_common()[1]
v2_second=v2.most_common()[1]
if v1_max[0]!=v2_max[0]:
    print(n-v1_max[1]-v2_max[1])
else:
    print(min(n-v1_max[1]-v2_second[1],n-v2_max[1]-v1_second[1]))

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

int main()
{
	int a;
	cin >> a;
	
	if (a==1)
	{
		cout << "Yes\n";
		return 0;
	}
	
	if (a%2!=0 and a%3!=0 and a%5!=0 and a%7!=0) cout << "No\n";
	if (a%9==0 and a/9>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%9==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%8==0 and a/8>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%8==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%7==0 and a/7>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%7==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%6==0 and a/6>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%6==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%5==0 and a/5>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%5==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%4==0 and a/4>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%4==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%3==0 and a/3>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%3==0)
	{
		cout << "Yes\n";
		return 0;
	}
	if (a%2==0 and a/2>=10)
	{
		cout << "No\n";
		return 0;
	} 
	else if (a%2==0)
	{
		cout << "Yes\n";
		return 0;
	}
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
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;
}
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;
}
int main(){
    string s;cin >> s;
    ll count=0;
    rep(i,s.size()-1){
        if(s[i]=='h'&&s[i+1]=='i')count++;
    }
    if(count*2==s.size()){
        cout << "Yes" <<endl;
        return 0;
    }
    cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b));


typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<pair<int,int> > x(n);
    rep(i,n){int tem; cin >> tem; x[i] = mp(tem,i);}
    sort(all(x));
    vector<bool> ans(n);
    int med = n/2;
    int le = x[med-1].first, ri = x[med].first; 
    rep(i,n) ans[i] = false;
    rep(i,n/2) ans[x[i].second] = true;
    rep(i,n) cout << ( ans[i] ? ri : le) << endl;
    
 
    return 0;
}

Measured memory_bytes: 3840
n = gets.chomp.to_i
h_arr = gets.chomp.split(" ").map(&:to_i)

# i番目にたどり着くまでのコストの総和の最小値
dp = [0, (h_arr[1] - h_arr[0]).abs]
(2..n-1).each do |i|
  dp[i] = [
    dp[i-2] + (h_arr[i] - h_arr[i-2]).abs,
    dp[i-1] + (h_arr[i] - h_arr[i-1]).abs,
  ].min
end
puts dp[n-1]

Measured memory_bytes: 11908
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

if len(A) == len(set(A)):
    YES()
else:
    NO()


Measured memory_bytes: 28312
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int[] cnt = new int[n];
		int kind = 0;
		Arrays.fill(cnt, Integer.MAX_VALUE);
		for (int i = 0; i < n; i++) {
			if (cnt[a[i] - 1] == Integer.MAX_VALUE) {
				cnt[a[i] - 1] = 1;
				kind++;
			} else {
				cnt[a[i] - 1]++;
			}
		}

		Arrays.sort(cnt);

		int ans = 0;
		for (int i = 0; i < kind - k; i++) {
			ans += cnt[i];
		}

		System.out.println(ans);

		sc.close();
	}
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sq(int x) { return x * x; }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename F> long long discrete_binary_search(long long ok, long long ng, F is_ok) {
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        (is_ok(mid) ? ok : ng) = mid;
    }
    return ok;
}

int N, C;
int h[220000];
int dp[220000];
signed main() {
    cin >> N >> C;
    rep(i, N) { cin >> h[i]; }
    vector<pint> v{{h[0], 0}};
    reps(i, N - 1) {
        int k0 = discrete_binary_search(0, v.size(), [&](int x) { return v[x].first <= h[i]; });
        dp[i] = dp[v[k0].second] + sq(h[i] - h[v[k0].second]) + C;
        int k1 = discrete_binary_search(0, v.size(), [&](int x) {
            return dp[v[x].second] + sq(v[x].first - h[v[x].second]) < dp[i] + sq(v[x].first - h[i]);
        });
        v.erase(v.begin() + k1 + 1, v.end());
        int idx = v[k1].second;
        int x = h[idx] + cdiv(sq(h[i] - h[idx]) + (dp[i] - dp[idx]), 2 * (h[i] - h[idx]));
        v.push_back({x, i});
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 10544
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int n, four, three, two, one;
  
  cin >> n;
  
  four = n / 1000;
  n -= four * 1000;
  
  three = n / 100;
  n -= three * 100;

  two = n / 10;
  n -= two * 10;
  
  one = n;
  
  //cout << four << endl << three << endl << two << endl << one << endl;
  
  if ( three == two && ( two == one || four == three ))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P > T;


int n,m,a;
int amida[110][1010];
bool finish(){
    return (n==0)&&(m==0)&&(a==0);
}

int main(void){
    while(true){
        cin>>n>>m>>a;
        if(finish())break;
        for(int i=0;i<110;i++){
            for(int j=0;j<1010;j++){
                amida[i][j]=0;
            }
        }
        for(int i=0;i<m;i++){
            int h,p,q;
            cin>>h>>p>>q;
            amida[p][h]=q;
            amida[q][h]=p;
        }
        int now = 1000;
        int now1 = a;
        while(true){
            bool flag = false;
            for(int i = now;i>=1;i--){
                if(amida[now1][i]){
                    int tmp = now1;
                    now1 = amida[now1][i];
                    amida[now1][i]=0;
                    amida[tmp][i]=0;
                    now = i;
                    flag = true;
                    break;
                }
            }
            if(!flag)break;
            if(now == 1)break;
        }
        cout<<now1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+10;
const int mod=1e9+7;
map<ll,ll> mp,flag;
ll a[N],cnt[N],b[N];
int k;
int main() {;
  // freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    int t,i,j=0;
    int m,x,n,y;
    cin>>n>>m>>k;
    if(n%m==0){
        cout<<k*(n/m)<<endl;
    }
    else cout<<k*(n/m+1)<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

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

    
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> a[i][j];

    vector<ll> dp(1<<24, 0);
    dp[0]=1;

    for(int S=1; S<1<<n; ++S){
        int i=0;
        for(int j=0; j<n; ++j) if(S&1<<j) ++i;
        for(int j=0; j<n; ++j) if(S&1<<j && a[i-1][j]==1) {
            dp[S] += dp[S^(1<<j)];
            chmod(dp[S]);
        }
    }

    cout << dp[(1<<n)-1] << endl;


	return 0;
}


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

int main() {
  int N; cin >> N;
  for(int i=1; i<=N; i++) {
    if((int)(i*1.08)==N){ 
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;

    string ans="";
    rep(i,gy-sy) ans+="U";
    rep(i,gx-sx) ans+="R";
    rep(i,gy-sy) ans+="D";
    rep(i,gx-sx) ans+="L";
    ans+="L";
    rep(i,gy-sy+1) ans+="U";
    rep(i,gx-sx+1) ans+="R";
    ans+="D";
    ans+="R";
    rep(i,gy-sy+1) ans+="D";
    rep(i,gx-sx+1) ans+="L";
    ans+="U";

    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
const int64_t MOD = 1e+09 + 7;

// K個選ぶときの場合の数
int64_t countK (int64_t N, int64_t K){
    int64_t res,res1,res2;
    res1 = ( 2 * N - K + 1 ) * K / 2;
    res2 = K * ( K - 1 ) / 2;
    res = ( res1 - res2 + 1 ) % MOD;
    return res;
}

int main(){
    int64_t N,K;
    cin >> N >> K;
    int64_t res = 0;
    for ( int64_t i = K; i <= N+1; ++i){
        int64_t part;
        part = countK(N,i);
        res = ( res + part ) % MOD;
        //cout << res << endl;
    }
    cout << res << endl;
    return 0;
}


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

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "Yes" : "No");

		static void Main(string[] args)
		{
			var n = In;
			k = In;
			Console.WriteLine(loop(1, n));
			//Console.ReadLine();
		}

		static int k;

		static int loop(int x,int n)
		{
			if (n == 0) return x;
			else
			{
				return Math.Min(loop(x * 2, n - 1), loop(x + k, n - 1));
			}
		}
		
	}
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<int> tenbo[100005];
int h[100005];
int main()
{
    int n,m;cin >> n >>m;
    rep(i,n)cin >> h[i];
    rep(i,m)
    {
        int a,b;cin >> a >> b;
        --a;--b;
        tenbo[a].push_back(b);
        tenbo[b].push_back(a);
    }
    int counter = 0;
    rep(i,n)
    {
        bool win = true;
        for(auto r: tenbo[i])
        {
            if(h[i]<=h[r])win = false;
        }
        if(win)counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 9100
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
int main() {
	vector<int> v;
	int a1, a2, a3;

	cin >> a1 >> a2 >> a3;
	
	v.push_back(a1);
	v.push_back(a2);
	v.push_back(a3);

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

	int c=0;

	for (int i=0;i<v.size();++i)
	{
		if (i > 0)
		{
			c += v[i] - v[i - 1];
		}
	}



	cout << c << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t >> a >> b >> u;
    if (s == u) cout << a - 1 _ b << endl;
    else cout << a _ b - 1 << endl;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> v(N+1, 1000000);
	int H = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (v[tmp] == 1000000) {
			v[tmp] = 1;
			H++;
		}
		else {
			v[tmp]++;
		}
	}

	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; H-i > K; i++)
	{
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
const long mod=1e9+7;
string s;int d;long dp[10002][102][2];
long dfs(int st,int md,int ck)
{
  if(st>=s.size())return !md;
  if(dp[st][md][ck]!=-1)return dp[st][md][ck];
  int x=s[st]-'0';long now=0;
  if(!ck)
  {
    for(int i=0;i<=9;i++)
      now=(now+dfs(st+1,(md+i)%d,0))%mod;
  }
  else
  {
    for(int i=0;i<x;i++)
      now=(now+dfs(st+1,(md+i)%d,0))%mod;
    now=(now+dfs(st+1,(md+x)%d,1))%mod;
  }
  return dp[st][md][ck]=now;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>s>>d;memset(dp,-1,sizeof(dp));
  cout<<(dfs(0,0,1)-1+mod)%mod<<endl;

  return 0;
}

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

#define int long long int

const int M = 998244353;

int power(int x, int y) {
    if(y == 0)
        return 1ll;
    if(y % 2)
        return x * power(x, y - 1);
    int t = power(x, y / 2);
    return t * t;
}

signed main() {
    int s, w;
    cin >> s >> w;
    if(w >= s) {
        cout << "unsafe";
    }
    else {
        cout << "safe";
    }
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  string S;
  int P;
  vector<pair<string, int>> ps(N);
  for (int i = 0; i < N; ++i) {
    cin >> S >> P;
    ps[i] = make_pair(S, P);
  }
  vector<size_t> indices1(N);

  iota(indices1.begin(), indices1.end(), 0);

  sort(indices1.begin(), indices1.end(), [&ps](size_t i1, size_t i2) {
      if (ps[i1].first == ps[i2].first) {
	return ps[i1].second > ps[i2].second;
      }
					   return ps[i1].first < ps[i2].first;
    });
  for (int i = 0; i < N; ++i) {
    cout << indices1[i] + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
from math import gcd 
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())


def resolve():  
    N=int(input())
    r=range(1,N+1)#スニペットのようなもの
    ans=0
    for a in r:
        for b in r:
            for c in r:
                ans+= gcd(gcd(a,b),c)#3数のGCDを一気にとる
    print(ans)
resolve()




Measured memory_bytes: 67604
#include <iostream>

#include <fstream>

#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#include <algorithm>
#include <iomanip>
#include <cmath>
#include <random>
#include <cstdlib>
#include <ctime>
#include <utility>

using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define F first
#define S second
#define forcin(n, a) for(int i = 0; i < n; ++i) {cin >> a[i];}
#define forcout(n, a) for(int i = 0; i < n; ++i) {cout << a[i] << " ";}
#define PI acos(-1)
#define forup(st, fin) for(int i = st; i < fin; ++i)
#define fordown(st, fin) for(int i = st; i >= fin; --i)
#define reverse_all(v) reverse(v.begin(), v.end())
#define sort_all(v) sort(v.begin(), v.end())
#define sort_allr(v) sort(v.rbegin(), v.rend())

///#define cin in
///#define cout out
///#define int long long

const ll MAXL = 1e18;
const int N = 10005000;

vector<ll> add, h, d;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a < b) swap(a, b);
    if (a < c) swap(a, c);
    a = (a << k);
    cout << a + b + c << "\n";
    return 0;
}
/*
 2 1 1
10 15
6 1

3 0 3
10 8
7 11
5 2
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (int)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    string s;cin>>s;
    int ans=110;

    for (char i = 'a'; i < 'z'+1; i++)
    {
        int left=-1,subans=0;

        for(int j=0;j <= siz(s);j++)
        {
            if(j==siz(s)){
                subans=max(subans,siz(s)-left-1);
            }else if(s[j]==i){
                subans=max(subans,j-left-1);
                left=j;
            }
        }
        ans=min(ans,subans);
    }
    cout<<ans<<endl;
}
    



Measured memory_bytes: 256
#include <cstdio>

long long gcd(long long a, long long b) {
    if (b > a) {
        long long tmp = a;
        a = b;
        b = tmp;
    }
    if (b == 0)
        return a;
    else
        return gcd(b, a%b);
}

int main() {
    int n; 
    long long t[100] = {0};
    long long val;
    scanf("%d", &n);
    scanf(" %lld", &val);
    for (int i=1; i<n; i++) {
        long long tmp;
        scanf(" %lld", &tmp);
        long long r = gcd(val, tmp);
        val = val / r * tmp;
    }
    printf("%lld\n", val);
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N, K; cin >> N >> K;
  vector<ll> x(N); REP(i, N) cin >> x[i];
  ll ans = pow(10, 17);
  for(int i = 0; i + K - 1 < N; ++i) {
    ll left = x[i]; ll right = x[i + K - 1];
    ans = min(ans, min(abs(right), abs(left)) + right - left);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3952
import sys

N = int(input())
H = list(map(int,input().split()))
hight = []
count = []

if N == 1:
    print(0)
    sys.exit()

# lower...1,higher...0
for n in range(N-1):
    if H[n]>=H[n+1]:
        hight.append(1)
    else:
        hight.append(0)

#print(hight)

count.append(hight[0])
for l in range(1,N-1):
    if hight[l]==1:
        count.append(count[l-1]+1)
    else:
        count.append(0)

#print(count)

print(max(count))


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin >> s;
    cin >> t;
    int count=0;
    for(int i=0;i<3;i++)
    {
        if(s[i] == t[i])    count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    if len(C) == 1 and 0 in C:
        print("Yes")
        return
    if N % 3 != 0:
        print("No")
        return
    if 0 in C and len(C) == 2:
        if C[0] * 3 == N:
            print("Yes")
            return
    elif 0 not in C and len(C) == 3:
        for c in C:
            if C[c] * 3 != N:
                print("No")
                return
            X = list(C)
            if X[0] ^ X[1] != X[2]:
                print("No")
                return
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 60784
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();
		
		Long[] a1 = new Long[n1];
		Long[] a2 = new Long[n2];
		Long[] a3 = new Long[n3];
		
		for(int i = 0; i < n1; i++)
			a1[i] = sc.nextLong();
		for(int i = 0; i < n2; i++)
			a2[i] = sc.nextLong();
		for(int i = 0; i < n3; i++)
			a3[i] = sc.nextLong();
		
		Arrays.sort(a1, Collections.reverseOrder());
		Arrays.sort(a2, Collections.reverseOrder());
		Arrays.sort(a3, Collections.reverseOrder());
		
		Long[] inv = new Long[x+y];
		int invn = 0;
		for(int i = 0; i < x; i++)
		{
			inv[invn] = a1[i];
			invn++;
		}
		for(int i = 0; i < y; i++)
		{
			inv[invn] = a2[i];
			invn++;
		}
		Arrays.sort(inv, Collections.reverseOrder());
		int col = 0;
		invn--;
		while(invn >= 0 && col < n3 && a3[col] > inv[invn])
		{
			inv[invn] = a3[col];
			invn--;
			col++;
		}
		
		long sum = 0;
		for(int i = 0; i < x+y; i++)
			sum += inv[i];
		
		System.out.println(sum);
		
		
	}

}


Measured memory_bytes: 102940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int R = scan.nextInt();
			int C = scan.nextInt();
			if (R == 0 && C == 0) {
				scan.close();
				break;
			}
			int a[][] = new int[R][C];
			for (int i = 0; i < R; i++) {
				for (int j = 0; j < C; j++) {
					a[i][j] = scan.nextInt();
				}
			}
			System.out.println(maxSenbei(a, 0, 0, 1));
		}
	}

	private static int maxSenbei(int[][] a, int row, int reverse, int curBit) {
		if (row == a.length) {
			int senbei = 0;
			for (int j = 0; j < a[0].length; j++) {
				int r = reverse;
				int sumZero = 0;
				for (int i = a.length - 1; i >= 0; i--) {
					if ((r & 1) == 1) {
						if (a[i][j] == 1) sumZero++;
					} else {
						if (a[i][j] == 0) sumZero++;						
					}
					r >>= 1;
				}
				if (sumZero <= a.length / 2) sumZero = a.length - sumZero;
				senbei += sumZero;
			}
			return senbei;
		}
		int max1 = maxSenbei(a, row + 1, reverse, curBit << 1);
		int max2 = maxSenbei(a, row + 1, reverse | curBit, curBit << 1);
		return (max1 > max2) ? max1 : max2;
	}

}



Measured memory_bytes: 79248
#C
X, N = list(map(int, input().split()))

result = X

try:
    p = set(map(int, input().split()))
    if X not in p:
        result = X
    else:
        for i in range(1, 101):
            if X - i not in p:
                result = X - i
                break
            elif X + i not in p:
                result = X + i
                break
    print(result)
except:
    print(result)

Measured memory_bytes: 9196
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		String[] str = new String[x];
		
		for(int i = 0; i < x; i++){
			int[] a = new int[2];
			int[] aa = new int[10];
			boolean[] is = new boolean[3];
			boolean xx = true;
			a[0] = 0; 
			a[1] = 0;
			
			for(int s = 0; s < 10; s++)
				aa[s] = sc.nextInt();
			
			for(int u = 0; u < 10; u++){
				is[0] = is[1] = is[2] =true;
				if(a[0] < aa[u]){
					a[0] = aa[u];
					is[0] = false;
				}
				else
					is[1] = false;
				if(a[1] < aa[u] && is[0])
					a[1] = aa[u];
				else
					is[2] = false;
				if(!is[1] && !is[2]){
					str[i] = "NO";
					xx = false;
					break;
				}
			}
			if(xx)
				str[i] = "YES";
		}
		for(int i = 0; i < x; i++)
			System.out.println(str[i]);
	}
}

Measured memory_bytes: 18384
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
 int a[1000],n;
int findmax()
{
    int ans,m=abs(a[0]);
    for(int i=0;i<n;i++)
    {
        if(abs(a[i])>m)
        {
            ans=i;
            m=abs(a[i]);
        }
    }
    return ans;

}
int main()
{
    scanf("%d",&n);
    int total=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int maxnumber=findmax();
    if(a[maxnumber]<0)
    {
        printf("%d\n",2*n-1);
        for(int i=0;i<n;i++)
        {
            printf("%d %d\n",maxnumber+1,i+1);
        }
        for(int i=n-1;i>0;i--)
        {
            printf("%d %d",i+1,i);
            if(i!=1)
                printf("\n");
        }
    }
    else{
        printf("%d\n",2*n-1);
        for(int i=0;i<n;i++)
        {
            printf("%d %d\n",maxnumber+1,i+1);
        }
        for(int i=0;i<n-1;i++)
        {
            printf("%d %d",i+1,i+2);
            if(i!=n-2)
                printf("\n");
        }

    }
    return 0;
}


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

const int MAX_N = (int)100 + 5;

struct point {
  int c;
  int x, y;
};

bool operator < (const point &lhs, const point &rhs) {
  if (lhs.x != rhs.x) return lhs.x < rhs.x;
  else return lhs.y < rhs.y;
}

int n;
vector<point> whlpt;
set<point> cndst;

int ans;

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

  for (int i = 0; i < n; ++i) {
    point tmppoint;
    int tmpx, tmpy;
    scanf("%d %d", &tmpx, &tmpy);
    tmppoint.x = tmpx;
    tmppoint.y = tmpy;
    tmppoint.c = 0;
    whlpt.push_back(tmppoint);
  }

  for (int i = 0; i < n; ++i) {
    point tmppoint;
    int tmpx, tmpy;
    scanf("%d %d", &tmpx, &tmpy);
    tmppoint.x = tmpx;
    tmppoint.y = tmpy;
    tmppoint.c = 1;
    whlpt.push_back(tmppoint);
  }

  sort(whlpt.begin(), whlpt.end(), [](const point &a, const point &b){return a.x < b.x;});

  for (auto cpt: whlpt) {
    if (cpt.c == 0) cndst.insert(cpt);
    else {
      point mxpt; mxpt.y = -1;
      for (auto itr = cndst.begin(); itr != cndst.end(); ++itr) {
        point tpt = *itr;
        if (tpt.y < cpt.y && mxpt.y < tpt.y) {
          mxpt = tpt;
        }
      }
      if (mxpt.y != -1) {
        cndst.erase(mxpt);
        ans += 1;
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll ceil(ll x, ll y) {
	if (x * y >= 0) {
		x = abs(x);
		y = abs(y);
		return (x + y - 1) / y;
	} else {
		return x / y;
	}
}
ll floor(ll x, ll y) {
	if (x * y >= 0) {
		return x / y;
	} else {
		x = abs(x);
		y = abs(y);
		return -(x + y - 1) / y;
	}
}
ll range(ll left, ll right) {
	return left > right ? 0 : right - left + 1;
}
signed main() {
	ll n = in(), k = in(), ans = 0;
	REP1(a, n) {
		ll x = a % k;
		if ((2 * x) % k == 0) ans += range(ceil(1 + x, k), floor(n + x, k)) * range(ceil(1 - x, k), floor(n - x, k));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
  string s,v;
  int x=1,x_x;
  cin >> s >> v;
  s = s+v;
  int a = stoi(s); //文字を数字に変換
  while(a >= x){
    x_x = x * x;
    if(a == x_x) {cout << "Yes" <<endl; return 0;}
    x++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int H, W;
int A[88][88];
int B[88][88];
const int KMAX = 13000;
bool dp[88][88][KMAX + 90];
int C[88][88];
void input() {
  cin >> H >> W;
  rep(i, 1, H) {
    rep(j, 1, W) { cin >> A[i][j]; }
  }
  rep(i, 1, H) {
    rep(j, 1, W) { cin >> B[i][j]; }
  }
}
void solve() {
  rep(i, 1, H) {
    ;
    rep(j, 1, W) { C[i][j] = abs(A[i][j] - B[i][j]); }
  }

  // DP start
  dp[1][1][C[1][1]] = 1;
  rep(i, 1, H) {
    ;
    rep(j, 1, W) {
      ;
      rep(k, 0, KMAX - 1) {
        ;
        dp[i][j][k] |= dp[i][j - 1][k + C[i][j]];
        dp[i][j][k] |= dp[i - 1][j][k + C[i][j]];
        dp[i][j][k] |= dp[i][j - 1][abs(k - C[i][j])];
        dp[i][j][k] |= dp[i - 1][j][abs(k - C[i][j])];
      }
    }
  }
  // int ans = -1;
  rep(k, 0, KMAX) {
    if (dp[H][W][k]) {
      cout << k << endl;
      return;
    }
  }

  // rep(k, 0, 50) { printf("k=%lld .... dp[H][W][k] = %lld.\n", k,
  // dp[H][W][k]); }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 91392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll n,ans=0;
	cin >> n;
	map<string,int> ma;
	FOR(i,0,n){
		string s;
		cin >> s;
		SORT(s);
		ans += ma[s];
		ma[s]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define maxn 10005
using namespace std;
inline int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int n,a[maxn],lst[maxn],b[maxn],c[maxn],ans[maxn],d[maxn];
inline void change(int x,int y,int z){
	for(int i=1;i<x;i++)d[i]=c[i];
	for(int i=1;i<y;i++)c[i]=d[i];c[y]=z;
	for(int i=y+1;i<=x;i++)c[i]=d[i-1];
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(); 
	for(int i=1;i<=n;i++)lst[i]=b[a[i]],b[a[i]]=i;
	for(int i=1;i<=n;i++){
		int j=i;
		for(;j;j--){
			if(!b[j])continue;int tmp=1;
			for(int k=1;k<j;k++)if(c[k]>b[j]){tmp=0;break;}
			for(int k=j+1;k<i;k++)if(c[k]<b[j]){tmp=0;break;}
			if(tmp)break;
		}if(!j){printf("-1\n");return 0;}
		ans[i]=j;change(i,j,b[j]);b[j]=lst[b[j]];
	}
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
// #define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
void solve(){
	ll x , n ;
	cin>> x >> n ;
	set<ll>st;
	ll ans1=0 , ans2=0;
	for(ll i=0;i<n ;i++){
		ll a ;
		cin>> a ; st.insert(a);
	}
	for(ll i=x;i<=101;i++){
		if(st.count(i)==0){
			ans1=i;
			break;
		}
	}
	for(ll i=x-1;i>=0;i--){
		if(st.count(i)==0){
			ans2=i;
			break;
		}
	}
	if(ans1-x>x-ans2){
		cout<<ans2<<endl;
	}
	else if(ans1-x<x-ans2){
		cout<<ans1<<endl;
	}
	else{
		cout<<min(ans1,ans2)<<endl;
	}
}
 
int main(){
	// mahakal(),fast;
	ll t =1 ;
	// cin>> t ;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		long ans = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			ans = ans + a[i] - 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int N;
int x[10],y[10];
double sum = 0;
vi way;
int used[10];

double getDist(int i, int j) {
  ll sq = (x[i] - x[j]) * (x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]);
  double ret = sqrt(sq);
  return ret;
}

void dfs(int d=0) {
  if (d==N) {
    assert(way.size() == N);
    for (int i=0; i<N-1;i++) sum += getDist(way[i], way[i+1]);
    return;
  }
  rep(i,N) {
    if (used[i]) continue;
    way.pb(i);
    used[i] = true;
    dfs(d+1);
    way.pop_back();
    used[i] = false;
  }
}

int main() {
  cin >> N;
  rep(i,N) cin >> x[i] >> y[i];
  dfs();
  ll ways = 1;
  rep(i,N) ways *= i+1; 
  printf("%.10f\n", sum/ways);
  return 0;
}

Measured memory_bytes: 3704
N = int(input())
flag = False
for i in range(N // 4 + 1):
    for j in range(N // 7 + 1):
        if 4 * i + 7 * j == N:
            flag = True
            break
    if flag:
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
import itertools
import math
n = int(input())

list1 = [list(map(int,input().split())) for i in range(n) ]
list2 = list(itertools.permutations(range(n)))
ans = 0.0
count = 0.0
i = 0
while True:
    if i >= math.factorial(n):
        break
    for j in range(n-1):
        try:
            a = (list1[list2[i][j+1]][0] - list1[list2[i][j]][0])**2
        except ZeroDivisionError:
            a = 0
        try:
            b = (list1[list2[i][j+1]][1] - list1[list2[i][j]][1])**2
        except ZeroDivisionError:
            b = 0
        count += math.sqrt(a+b)
    ans += count
    count = 0
    i += 1

print(ans*(n-1)/(math.factorial(n)*(n-1)))

Measured memory_bytes: 47596
import Control.Applicative ((<$>))
import Control.Monad (unless)

main = do
    n <- readLn
    unless (n == 0) $ do
        ss <- map read . words <$> getLine
        print $ sd ss
        main

sd :: [Double] -> Double
sd ss = sqrt . (/n) . sum $ [ (si - m)^2 | si <- ss]
    where
        n = fromIntegral $ length ss
        m = (sum ss) / n

Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,ans=0,count=0;
    cin >> N;
    vector<int>A(N);
    vector<int>B;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int j=0;j<N;j++){
        if(A[j]%2==0){
            count++;
            if(A[j]%3==0||A[j]%5==0){
                ans++;
            }
        }
    }
    if(ans==count)cout << "APPROVED" << endl;
    else cout << "DENIED" <<endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		int len = 3;

		Scanner sc = new Scanner(System.in);
		Set<Integer> number = new HashSet<Integer>();
		int count = 0;
		while (count < len) {
			number.add(sc.nextInt());
			count++;
		}
		if (number.size() == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}



signed main(){
    int N,Q;
    cin>>N>>Q;

    vint qs;
    rep(i,Q){
        int a;cin>>a;
        qs.pb(a);
    }
    reverse(all(qs));
    qs.pb(N);

    map<int,int>mp;
    mp[qs[0]]=1;
    for(int i=1;i<qs.size();i++){
        int q=qs[i];
        while(mp.rbegin()->fi>q){
            pint p=*mp.rbegin();
            mp.erase(p.fi);
            mp[q]+=p.fi/q*p.se;
            if(p.fi%q)mp[p.fi%q]+=p.se;
        }
    }

    vint ans(N);
    for(auto &p:mp)ans[p.fi-1]+=p.se;
    for(int i=N-1;i>0;i--)ans[i-1]+=ans[i];

    rep(i,N)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);loop(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;loop(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define loop(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull aint;

typedef vector<aint> vaint;
typedef list<aint> laint;

aint win(aint x){
	aint ans = 0;
	switch (x)
	{
	case 1: ans = 300000; break;
	case 2: ans = 200000; break;
	case 3: ans = 100000; break;
	default: break;
	}
	return ans;
}

int main(void){
	init(aint, x);
	init(aint, y);
	aint p = win(x) + win(y);
	if (x == 1 && y == 1)p += 400000;

	outl(p);

	return 0;
}

Measured memory_bytes: 256
abcd=str(input())
for i in range(2**4):
    list=[int(abcd[0])]
    symbol=[]
    for j in range(1,4):
        if (i>>j)&1==True:
            list.append(int(abcd[j]))
            symbol.append('+')
        else:
            list.append(int(abcd[j])*(-1))
            symbol.append('-')
    if sum(list)==7:
        print(str(abcd[0])+symbol[0]+str(abcd[1])+symbol[1]+str(abcd[2])+symbol[2]+abcd[3]+"=7")
        break

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

using namespace std;

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

    string L; cin>>L;
    long dp[2][2] = {{0,0},{0,1}};
    const size_t MOD = 1e9+7;
    for (size_t i = 0; i < L.size(); i++) {
        if (L[i] == '0') {
            dp[i%2][0] = dp[(i+1)%2][0] * 3 % MOD; // (0,0), (0,1), (1,0)
            dp[i%2][1] = dp[(i+1)%2][1]; // (0,0)
        } else { // 1
            dp[i%2][0] = (dp[(i+1)%2][0] * 3 + dp[(i+1)%2][1]) % MOD; // (0,0), (0,1), (1,0) | (0,0)
            dp[i%2][1] = dp[(i+1)%2][1] * 2 % MOD; //  (0,1), (1,0)
        }
    }
    auto ans = (dp[(L.size()-1)%2][0] + dp[(L.size()-1)%2][1]) % MOD;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 512