akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;


int main() {
    ll N,K;cin>>N>>K;
    vel A(N);rep0(i,N){cin>>A[i];}
    set<ll> data;
    vector<ll> data2(N+1,0);
    rep0(i,N){
        data.insert(A[i]);
        data2[A[i]]++;
    }
    if(data.size()<=K){cout<<0<<endl;return 0;}
    sort(all(data2));
    ll ans=data.size(),cnt=0;
    rep0(i,data2.size()){
        if(data2[i]==0){continue;}
        ans-=1;cnt+=data2[i];
        if(ans<=K){cout<<cnt<<endl;return 0;}
    }
}


Measured memory_bytes: 12800
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../code-pieces/trace.h"
#else
#define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD) {
	a %= m; ll res = 1; while (b) {if (b & 1)res = res * a % m; a = a * a % m; b >>= 1;}
	return res;
}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a) {return modpow(a, MOD - 2, MOD);}
void graph(vvi &adj, int m) {int x, y; forn(i, m) {cin >> x >> y; adj[x - 1].pb(y - 1); adj[y - 1].pb(x - 1);}}

const int mxN = 2e5 + 5;
void solve() {
	ll a, b, n;
	cin >> a >> b >> n;
	cout << (a*min(b-1, n)/b);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


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

int main() {
  int n,m;cin>>n>>m;
  int ans = (n-1)*(m-1);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>V(3);
  for (int i=0; i<3; i++) cin >> V[i];
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  if (V.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int i,j,n,k,count=0;

  cin >> n >> k;
  vector<int> d(k);
  int flag[n]={0};
  int A;
  //k種類のお菓子
  for(i=0;i<k;i++){
    cin >> d.at(i);
    //kiのお菓子はd人が持っている
    for(j=0;j<d.at(i);j++){
      cin >> A;
      //cout <<"haitta"<< " "<< A<<endl;
      flag[A]=1;
    }
  }
  for(i=0;i<=n;i++){
    if(flag[i]==1){
      //cout << i <<endl;
      count++;
    } 
  }
  cout << n-count <<endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
char s[1010];
char t[1010];
void solve()
{
	cin>>s+1>>t+1;
	int n=strlen(s+1);
	int m=strlen(t+1);
	int ans=m;
	for(int i=1;i<=n-m+1;i++)
	{ 
		int res=0; 
		for(int j=i;j<=i+m-1;j++) 
			if(s[j]!=t[j-i+1])
				res++;
		ans=min(ans,res);
	} 
	cout<<ans<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#define REP(i,n) for (int i=1;i<(n);i++)

using namespace std;

#define N 256

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int a[300000] = { 0 };
	for(int i = 0;i < N;i++){
	for(int j = i;j < N;j++){
	for(int k = j;k < N;k++){
	for(int l = k;l < N;l++){
		++a[i*i + j*j + k*k + l*l];
	}
	}
	}
	}
	int n;
	while(cin >> n,n){
		cout << a[n] << endl;
	}
  return 0;

}

Measured memory_bytes: 4252
def main():
    """
    1 <= N <= 10^5
    2 <= C <= 10^14
    1 <= x1 < x2 < ... < xN < C
    1 <= vi <= 10^9
    """
    N, C = map(int, input().split())
    X, V = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    #part_point(N, C, X, V)
    editorial(N, C, X, V)


def editorial(N, C, X, V):
    rev_V = V[::-1]
    rev_X = tuple(map(lambda x: C-x, X[::-1]))

    a1 = solve_editorial(N, C, X, V)
    a2 = solve_editorial(N, C, rev_X, rev_V)
    ans = max(a1, a2)
    print(ans)


def solve_editorial(N, C, X, V):
    ans = 0
    
    # A側の累積和
    c1 = [0] * N
    c1[0] = V[0]
    for i in range(1, N):
        c1[i] = V[i] + c1[i-1]
    # 初期位置まで戻ったときの獲得カロリー
    d1 = [0] * N
    for i in range(N):
        # 食べた場所からすぐ帰る場合を計算しておく
        ans = max(c1[i] - X[i], ans)
        d1[i] = max(c1[i] - X[i] * 2, 0)
    # 寿司iまでの獲得カロリーの最大値
    e1 = [0] * N
    e1[0] = d1[0]
    for i in range(1, N):
        e1[i] = max(d1[i], e1[i-1])

    # B側の累積和
    rev_V = V[::-1]
    rev_X = tuple(map(lambda x: C-x, X[::-1]))
    c2 = [0] * N
    c2[0] = rev_V[0]
    for i in range(1, N):
        c2[i] = rev_V[i] + c2[i-1]

    # Bまでの獲得カロリーと、その1つ奥の寿司までのA側からの最大カロリー
    for i in range(N-1):
        y = max(c2[i] - rev_X[i], 0)
        ans = max(ans, e1[N-i-2] + y)

    return ans


def part_point(N, C, X, V):
    """
    円周すべてを通るパターンは最適ではない
        xN < C より
    時計回りにある寿司Aまで
    そこから初期位置まで
    最後に反時計回りにBまで
        OA * 2 + OB or
        OB * 2 + OA
    """
    # tupleの方が省memory (sys.getsizeof より)
    rev_V = V[::-1]
    rev_X = tuple(map(lambda x: C-x, X[::-1]))

    # 逆回りを計算し忘れてた
    a1 = solve_p(N, X, V, rev_X, rev_V)
    a2 = solve_p(N, rev_X, rev_V, X, V)

    ans = max(a1, a2)
    print(ans)


def solve_p(N, X, V, rev_X, rev_V):
    ans = 0
    for i in range(0, N):
        # Aまで
        a = sum(V[:i+1]) - X[i]
        ans = max(ans, a)
        # Oまで戻る
        a = max(a - X[i], 0)
        for j in range(N-i-1):
            # Bまで
            b = a + sum(rev_V[:j+1]) - rev_X[j]
            ans = max(ans, b)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 59172
import java.io.*;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		int x = Integer.parseInt(str);

		System.out.println(String.format("%.0f", Math.pow(x, 3)));
	}
}



Measured memory_bytes: 24672
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

from collections import deque

def main():
	n,m=MI()

	G=[[] for _ in range(n+1)]

	for _ in range(m):
		a,b=MI()
		G[a].append(b)
		G[b].append(a)

	ans=[0]*(n+1)

	Q=deque([1])
	sumi=set()

	while Q:
		now=Q.popleft()

		for next in G[now]:
			if next in sumi:
				continue
			else:
				Q.append(next)
				ans[next]=now
				sumi.add(next)

	print("Yes")

	print(*ans[2:],sep="\n")






































if __name__ == "__main__":
	main()


Measured memory_bytes: 113556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i <b; i++)
using pii = pair<int,int>;
#define all(a) a.begin(), a.end()

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

int main(){
    int N, M; cin >> N >> M;
    if(N == M) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
/************************* In the name of Allah *************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef string          str;
typedef pair<ll,ll>     pll;

#define F               first
#define S               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = 1e9 + 7,
         INF = 1e18,
         MAXN = 1e5 + 10;

int main(){
    fast_io
    int n;
    cin >> n;
    cout << n * n * n;
    return 0;
}

/*
 __  __       _         _ _  _____ _           _                __ _
|  \/  |     | |       | (_)/ ____| |         | |              / _(_)
| \  / | __ _| |__   __| |_| (___ | |__   ___ | | _____  _   _| |_ _
| |\/| |/ _` | '_ \ / _` | |\___ \| '_ \ / _ \| |/ / _ \| | | |  _| |
| |  | | (_| | | | | (_| | |____) | | | | (_) |   < (_) | |_| | | | |
|_|  |_|\__,_|_| |_|\__,_|_|_____/|_| |_|\___/|_|\_\___/ \__,_|_| |_|
*/


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    char a;
    scan(a);
    if (a >= 'a')
        writeln("a");
    else
        writeln("A");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main(void) {
    int i, j, N, Q, len, l[100010], r[100010], dp[100010];
    char S[100010];
    scanf("%d%d", &N, &Q);
    scanf("%s", &S);
    for (i=0;i<Q;i++) scanf("%d%d", &l[i], &r[i]);
    len = strlen(S);

    dp[0] = 0;
    for (i=1;i<len;i++) {
        dp[i] = dp[i-1];
        if (S[i-1] == 'A' && S[i] == 'C') dp[i]++;
    }

    for (i=0;i<Q;i++) {
        printf("%d\n", dp[r[i]-1]-dp[l[i]-1]);
    }
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int a, b; cin >> a >> b;
    cout << a * b;   
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 10000000; i++) {
        int A = i * 0.08;
        int B = i * 0.1;
        if (a == A && b == B) {
            cout << i << '\n';
            rr;
        }
    }
    cout << "-1\n";
}


Measured memory_bytes: 3672
#include <stdio.h>
int main()
{
	int x[4],y[4];
	scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
	int disx=x[0]-x[1];
	int disy=y[0]-y[1];
	x[2]=x[1]+disy;
	y[2]=y[1]-disx;
	x[3]=x[0]+disy;
	y[3]=y[0]-disx;
	printf("%d %d %d %d",x[2],y[2],x[3],y[3]);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int overlap(int a, int b, int c, int d){
  if ( d <= a ) return 0;
  if ( b <= c ) return 0;
  return 1;
}

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







Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,len=0;
int a[200005],b[200005],ans[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=n;i>=1;i--)
	{
		int sumv=0;
		for (int j=2*i;j<=n;j+=i)  sumv=(sumv+b[j])%2;
		
		if (sumv==a[i])  b[i]=0;
		else b[i]=1;
	}
	for (int i=1;i<=n;i++)
	{
		if (b[i]==1)  ans[++len]=i;
	}
	cout<<len<<endl;
	for (int i=1;i<=len;i++)  cout<<ans[i]<<' ';
	cout<<endl;
	
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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 trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(int argv, char* argc[])
{
    FASTIO



    int k;
    string s,ans;
    cin>>k>>s;
    int n = s.size();
    if(n<=k)
        cout<<s;
    else
        {
            s.resize(k);
            s+="...";
            cout<<s;
        }









    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

set<int> nums;

int gcd(int a, int b) {
    return (b == 0) ? a : gcd(b, a % b);
}

int main(int argc, const char * argv[]) {
    int n, x, y;
    cin >> n;
    cin >> x;
    for(int i = 1; i <= n; i++) {
        cin >> y;
        nums.insert(abs(y - x));
    }
    set<int>::iterator it;
    int cur = *nums.begin();
    for (it=nums.begin(); it!=nums.end(); ++it) {
        cur = gcd(cur, *it);
    }
    cout << cur << "\n";
    exit(0);
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  vector<int> A(H), B(H);
  for (int i = 0; i < H; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
  }
  map<int, int> M;
  multiset<int> res;
  for (int i = 0; i < W; i++) {
    M[i] = i;
    res.insert(0);
  }
  for (int i = 0; i < H; i++) {
    auto it = M.lower_bound(A[i]);
    int s = -1;
    while (it != M.end() && it->first <= B[i]) {
      int x = it->first - it->second;
      s = max(s, it->second);
      res.erase(res.find(x));
      M.erase(it++);
    }
    if (s != -1 && B[i] < W) {
      M[B[i]] = s;
      res.insert(B[i] - s);
    }
    if (!res.empty()) {
      cout << *res.begin() + i + 1 << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 23520
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

vi bits(1, 0);

void solve(int n, int* a) {
    if(n == 0) return;
    for (int i = n; i > 0 ; --i) {
        if (i > n/2) {
            bits[i] = a[i];
        } else {
            for(int j = (n / i) * i; j > n/2; j -= i)
                a[i] ^= a[j];
        }
    }
    solve(n/2, a); 
}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // ntfreopen("ex.out","w",stdout);
    int n;
    cin >> n;
    int a[n + 1];
    bits.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }    
    solve(n, a);
    int ans = 0;
    for (int i = 1; i < n + 1; i++) 
        ans += bits[i];
    cout << ans << "\n";
    for (int i = 1; i < n + 1; i++)
        if (bits[i] == 1) 
            cout << i << " ";
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int N, sum=0;
  vector<int> v;
  cin >> N;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    if(i!=N-1)sum+=v[i];
    else sum+=v[i]/2;
  }
  cout << sum << endl;
  return 0;
}


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

int comp(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(){
  int n,m,sum = 0;
  scanf("%d%d",&n,&m);
  int x[m],dist[m];
  for(int i = 0;i < m;i++){
    scanf("%d",&x[i]);
  }
  
  if(n < m){
     qsort(x,m,sizeof(int),comp);
     for(int i = 0;i < m-1;i++){  
        dist[i] = x[i+1] - x[i];
     }   
     qsort(dist,m-1,sizeof(int),comp);   
     for(int i = 0;i < m-n ;i++){
        sum += dist[i];
     }
  }
  printf("%d",sum);
}  
  

Measured memory_bytes: 1396
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>


int main() {
    //std::ifstream in("in01.txt");
    //std::cin.rdbuf(in.rdbuf());

    int n;
    std::cin >> n;
    
    std::priority_queue<double, std::vector<double>, std::greater<double>> que;
    
    for (int i = 0; i < n; i++) {
        double a;
        std::cin >> a;
        que.push(a);
    }
    while (que.size() > 1) {
        double v1, v2;
        v1 = que.top();
        que.pop();
        v2 = que.top();
        que.pop();
        que.push(0.5 * (v1 + v2));
    }
    
    double ans = que.top();
    std::cout << ans << std::endl;
    
    return 0;
}


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define MP make_pair
#define PB push_back
#define F first
#define S second
const long long INF = (1ll << 50);
struct graph {
    typedef long long flow_type;
    struct edge {
        int src, dst;
        flow_type capacity, flow;
        size_t rev;
    };
    int n;
    vector<vector<edge>> adj;
    graph(int n) : n(n), adj(n) {}
    void add_edge(int src, int dst, flow_type capacity) {
        adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
        adj[dst].push_back({dst, src, 0, 0, adj[src].size() - 1});
    }
    flow_type max_flow(int s, int t) {
        vector<int> level(n), iter(n);
        function<int(void)> levelize = [&]() { // foward levelize
            level.assign(n, -1);
            level[s] = 0;
            queue<int> Q;
            Q.push(s);
            while (!Q.empty()) {
                int u = Q.front();
                Q.pop();
                if (u == t) break;
                for (auto &e : adj[u]) {
                    if (e.capacity > e.flow && level[e.dst] < 0) {
                        Q.push(e.dst);
                        level[e.dst] = level[u] + 1;
                    }
                }
            }
            return level[t];
        };
        function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
            if (u == t) return cur;
            for (int &i = iter[u]; i < (int)(adj[u].size()); ++i) {
                edge &e = adj[u][i], &r = adj[e.dst][e.rev];
                if (e.capacity > e.flow && level[u] < level[e.dst]) {
                    flow_type f = augment(e.dst, min(cur, e.capacity - e.flow));
                    if (f > 0) {
                        e.flow += f;
                        r.flow -= f;
                        return f;
                    }
                }
            }
            return flow_type(0);
        };
        for (int u = 0; u < n; ++u) // initialize
            for (auto &e : adj[u]) e.flow = 0;

        flow_type flow = 0;
        while (levelize() >= 0) {
            fill(iter.begin(), iter.end(), 0);
            for (flow_type f; (f = augment(s, INF)) > 0;)
                flow += f;
        }
        return flow;
    }
};

int main() {
    int n;
    cin >> n;
    auto g = graph(2 * n + 2);
    auto GOAL = 2 * n + 1;
    vector<pair<int, int>> red, blue;
    reps(i, n) {
        int x, y;
        cin >> x >> y;
        red.PB(MP(x, y));
        g.add_edge(0, i, 1);
    }
    reps(j, n) {
        int x, y;
        cin >> x >> y;
        blue.PB(MP(x, y));
        g.add_edge(j + n, GOAL, 1);
    }
    rep(i, n) {
        rep(j, n) {
            auto p = red[i];
            auto q = blue[j];
            if (p.F < q.F && p.S < q.S) {
                g.add_edge(i + 1, j + 1 + n, 1);
            }
        }
    }
    PUTS(g.max_flow(0, GOAL));
}


Measured memory_bytes: 512
//This is the Property of Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod =998244353;
ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ans+=((m%mod)*(power(m-1,n-1)%mod))%mod;
    ans%=mod;
    ll count = 1;
    for(ll x=1; x<=k; x++){
        count= ((count*(n-x))%mod * power(x,mod-2)%mod )%mod;
        count%=mod;
        //cout<<count<<" ";
        ans+=((((count%mod)*(m%mod))%mod)*(power(m-1,n-1-x)%mod))%mod;
        ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
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
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

string S;

int main(){
    cin>>S;

    int c0=0,c1=0;
    rep(i,S.size()){
        if(S[i]=='0') c0++;
        if(S[i]=='1') c1++;
    }

    int ans=2*min(c0,c1);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 2e5+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
//ll f[maxn],invF[maxn];
//void getF(){
//    f[0] = invF[0] = 1;
//    for(int i = 1;i < maxn;i++)f[i] = f[i-1]*i % modn;
//    invF[maxn-1] = qpow(f[maxn-1],modn-2);
//    for(int i = maxn-2;i >= 1;i--)invF[i] = invF[i+1]*(i+1) % modn;
//}
ll a[maxn];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)scanf("%lld",&a[i]),a[i] -= i;
    if(n == 1){printf("0\n");return 0;}
    sort(a+1,a+n+1);
    ll ans = 1e18;
    for(ll i = n/2;i <= n/2+1;i++){
        ll res = 0;
        for(int j = 1;j <= n;j++)res += max(a[j],a[i]) - min(a[j],a[i]);
        ans = min(ans,res);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	long long x,y;
	long long div;
	int res=0;
	cin>>x>>y;
	div=x;
	while(x<=y)
	{
		res++;
		x*=2;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
x = list(map(int,input().split()))

mint = 1000000000

for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    if l >= 0:
        mint = min(mint,r)
    elif r <= 0:
        mint = min(mint,-l)
    else:
        d = min(-l+2*r,r-2*l)
        mint = min(mint,d)
print(mint)

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = n;i >= 0;--i) for (int j = n-i;j >= 0;--j) {
        if (i+j == n) dp[i][j] = 0;
        else if ((i+j)&1) dp[i][j] = min(dp[i+1][j],dp[i][j+1]);
        else dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j+1]+a[n-1-j]);
    }
    ll sum = 0;
    for (int i = 0;i < n;++i) sum += a[i];
    cout << 2*dp[0][0]-sum << endl;
    return 0;
}

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

#define ll long long

using namespace std;

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

    ll q, x, p, o;
    multiset <ll> ms;

    cin >> q;

    while(q--)
    {
        cin >> x >> p;

        if(x == 0)
        {
            ms.insert(p);
            cout << ms.size() << endl;
        }

        else if(x == 1)
            cout << ms.count(p) << endl;

        else if(x == 2)
            ms.erase(p);

        else
        {
            cin >> o;
            auto it = ms.lower_bound(p);

            for(; it != ms.end() && *it <= o; it++)
                cout << *it << endl;
        }

    }

    return 0;
}



Measured memory_bytes: 12432
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=110;
int a[maxn];
int n;
int main()
{
	cin>>n;
	rep(i,n)
		cin>>a[i];
	int cur=a[0];
	int cnt=0;
	for1(i,1,n)
	{
		if(a[i]==cur)
		{
			cnt++;cur=0;
		}
		else cur=a[i];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=2e5+10;
const LL INF=1e18;
int a[N];
LL dp[N][4];
int main() {
    // O選，X不選
    // O X O X O X O X O 
    // 其中再多插入1，2個X
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    REP(i,n) cin >> a[i];
    int k=1+n%2; // 奇數：插入2個X 偶數：插入1個X
    REP(i,n+1) REP(j,k+1) {
        dp[i][j]=-INF;
    }
    dp[0][0]=0;
    REP(i,n) {
        REP(j,k+1) {
            chmax(dp[i+1][j+1], dp[i][j]); // 不選ai
            LL now=dp[i][j];
            if ( (i+j)%2==0 ) now+=a[i]; 
            chmax(dp[i+1][j], now);
        }
    }
    cout << dp[n][k] << '\n';
    return 0;
}

Measured memory_bytes: 10696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    int n,k; cin>>n>>k;
    vector <int> a(n);
    rep(i,n) cin>>a[i];
    vector <int> dp(214514);
    
    int now = 0;
    rep(i,100002){
        if(dp[i] == 0){
            rep(j,n){
                dp[i + a[j]] = 1;
            }
        }
    }
    
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int a[505][505];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int h = 1; h <= H; ++h) {
        for (int w = 1; w <= W; ++w) {
            cin >> a[h][w];
        }
    }
    vector<string> vs;
    for (int h = 1; h < H; ++h) {
        for (int w = 1; w <= W; ++w) {
            if (a[h][w]%2 == 1) {
                ostringstream oss;
                oss << h << " " << w << " " << h+1 << " " << w;
                vs.push_back(oss.str());
                ++a[h+1][w];
            }
        }
    }
    for (int w = 1; w < W; ++w) {
        if (a[H][w]%2 == 1) {
            ostringstream oss;
            oss << H << " " << w << " " << H << " " << w+1;
            vs.push_back(oss.str());
            ++a[H][w+1];
        }
    }
    int N = vs.size();
    cout << N << "\n";
    for (int n = 0; n < N; ++n) {
        cout << vs[n] << "\n";
    }

    return 0;
}


Measured memory_bytes: 9972
n = int(input())
a = list(map(int, input().split()))
pos, neg = [], []
for num in a:
    if num >= 0:
        pos.append(num)
    else:
        neg.append(num)

def maximizeNeg():
    cur = neg[0]
    for i in range(1, len(neg)):
        ret.append((cur, neg[i]))
        cur -= neg[i]
    return cur

def maximizePos():
    cur = pos[0]
    for i in range(1, len(pos) - 1):
        ret.append((cur, pos[i]))
        cur -= pos[i]
    ret.append((pos[-1], cur))
    cur = pos[-1] - cur
    return cur

pos.sort()
neg.sort(reverse=True)
ret = []
if not neg:
    cur = maximizePos()
elif not pos:
    cur = maximizeNeg()
else:
    curNeg = neg[-1]
    for i in range(len(pos) - 1):
        ret.append((curNeg, pos[i]))
        curNeg -= pos[i]
    curPos = pos[-1]
    for i in range(len(neg) - 1):
        ret.append((curPos, neg[i]))
        curPos -= neg[i]
    ret.append((curPos, curNeg))
    cur = curPos - curNeg

print(cur)
print('\n'.join('%d %d' % (xy[0], xy[1]) for xy in ret))

Measured memory_bytes: 28108
MOD = 10**6+3

def main():
    # preprocess
    fac = [1, 1]
    for i in range(2, MOD+1):
        fac.append((fac[-1] * i) % MOD)

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, input().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * pow(fac[xd-1], MOD-2, MOD) % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 116464
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	int[] a = new int[10];
	int[][] b = new int[10][1000];
	int[] z = new int[10];
	int n, na, i;
	int j, q;
	int kazu;
	int y;
	int kai = 1; 
	
	n = scan.nextInt();
	
	for(i=0; i<n; i++){
		a[i] = scan.nextInt();
	}
	
	for(i=0; i<n; i++){
		na = a[i];
		for(kazu=2; kazu<=a[i]; kazu++){
			if(na%kazu==0){
				b[i][z[i]] = kazu;
				z[i]++;
				na /= kazu;
				kazu--;
			}
		}
	}
	
	for(i=1; i<n; i++){
				
		y = 0;
		for(j=0; j<=z[0]; j++){
			for(q=0; q<=z[i]; q++){
				if(b[0][j]==b[i][q]){
					b[i][q] = 0;
					break;
				}
			}
		}
		for(q=0; q<=z[i]; q++){
			if(b[i][q]!=0){
				b[i][y] = b[i][q];
				y++;
			}
		}
		for(j=0; j<y; j++){
			b[0][z[0]+j] = b[i][j];
		}
		z[0] += y;
	}
	
	for(j=0; j<z[0]; j++){
		kai *= b[0][j];
	}
	
	System.out.println(kai);
}
}


Measured memory_bytes: 26240
n,q=gets.split.map &:to_i
s=gets.chomp
ans=[]
ans[0]=0
sum=0
for i in 0..s.size-2
  if s[i]=="A"
    if s[i+1]=="C"
      ans << sum+=1
      next
    end
  end
  ans << sum
end
x=[]
y=[]
q.times do |i|
  x[i],y[i]=gets.split.map &:to_i
end
q.times do |j|
  puts ans[y[j]-1]-ans[x[j]-1]
end


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

long long n, x, h, l, r, ans;
map <long long, bool> ada;

int main() {
	cin >> x >> n;
	for(int i = 0; i < n; i++){
		cin >> h;
		ada[h] = 1;
	}
	l = r = x;
	while(1){
		if(ada[l])l--;
		else{ans = l; break;}
		if(ada[r])r++;
		else{ans = r; break;}
	}
	cout << ans << '\n';
}
//asldkfjlas

Measured memory_bytes: 3620
import itertools
import math

def diff(xi, xj, yi, yj):
    x = (abs(xi - xj)) ** 2
    y = (abs(yi - yj)) ** 2
    return (x + y) ** 0.5

n = int(input())
x = []
y = []
for _ in range(n):
    tx, ty = map(int, input().split())
    x.append(tx)
    y.append(ty)

total = 0
for p in list(itertools.permutations(range(n), n)):
    length = 0
    for i in range(n-1):
        length += diff(x[p[i]], x[p[i+1]], y[p[i]], y[p[i+1]])
    total += length

print(total / math.factorial(n))

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

int main() {
  int n;
  cin >> n ;
  vector<int> vec(n) ;
  for(int i=0; i<n ;i++){
    cin >> vec.at(i);}
 sort(vec.begin(),vec.end());
    for (int i =0;i<n-1;i++){
      if (vec.at(i)==vec.at(i+1)){
        cout << "NO" << endl;
        return 0;}
    }
  cout << "YES" <<endl;
  
  
}







Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	char x;
	while(true){
		cin >> a >> x >> b;
		if (x == '+')
		{
			cout << a + b << endl;
		}else if (x == '-'){
			cout << a - b << endl;
		}else if(x == '*'){
			cout << a * b << endl;
		}else if (x == '/')
		{
			cout << a / b << endl;
		}else{
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 1;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll L;
    cin >> N >> L;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N - 1; i++) {
        if (A[i] + A[i + 1] < L) continue;
        cout << "Possible" << endl;
        for (int j = 0; j < i; j++) cout << j + 1 << endl;
        for (int j = N - 2; j >= i + 1; j--) cout << j + 1 << endl;
        cout << i + 1 << endl;
        return 0;
    }
    cout << "Impossible" << endl;
    return 0;
}

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

int main() {

int N;
cin >> N;
vector<long long> L(N+1);
L.at(0)=2;
L.at(1)=1;
for(int i=2;i<N+1;i++){
  L.at(i)=L.at(i-1)+L.at(i-2);
} 
cout << L.at(N) << endl; 



  

}


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

using namespace std;

const int maxn = 3e3+10;

int dp[maxn][maxn];

int main(void)
{
	string s, t;
	cin >> s >> t;

	for (int i = 1; i <= s.size(); i++)
	{
		for (int j = 1; j <= t.size(); j++)
		{
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

			if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], 1+dp[i-1][j-1]);
		}
	}

	int b = t.size();
	int add = 0, ans = dp[s.size()][b];

	if (!ans)
	{
		cout << "\n";
		return 0; 
	}

	vector<char> v;

	for (int i = s.size(); i >= 1; i--)
	{
		for (int j = b; j >= 1; j--)
		{
			if (s[i-1] == t[j-1] && dp[i][j]+add == ans)
			{
				add++, v.push_back(s[i-1]);
				b = j-1;
				break;
			}
		}
	}

	reverse(v.begin(), v.end());
	for (auto x: v) cout << x;
	cout << "\n";
}

Measured memory_bytes: 35584
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int min = 300;
    if (p + q < min) {
        min = p + q;
    }
    if (p + r < min) {
        min = p + r;
    }
    if (q + r < min) {
        min = q + r;
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, dist[200010], a, b, c;
vector<pi> e[200010];
bool vis[1000010];
unordered_set<int> inr[200010];

int main()
{
	while(~scanf("%d %d",&N,&M))
	{
		memset(vis, false, sizeof(vis));
		memset(dist, 63, sizeof(dist));
		Forn(i, 200005)
			e[i].clear(), inr[i].clear();
		while(M--)
		{
			a=in(), b=in(), c=in();
			e[a].eb(mp(b, c));
			e[b].eb(mp(a, c));
		}
		priority_queue<pi> q;
		dist[1]=0;
		vis[1]=true;
		q.push(mp(0, 1));
		while(!q.empty())
		{
			int st=q.top().s, cost=-q.top().f;
			q.pop();
			vis[st]=true;
			if(cost>dist[st])
				continue;
			foreach(it, e[st])
			{
				int ed=it->f, c=it->s, d=dist[st]+(!inr[st].count(c));
				if(vis[ed]||dist[ed]<d)
					continue;
				if(dist[ed]>d)
				{
					dist[ed]=d;
					q.push(mp(-d, ed));
					inr[ed].clear();
				}
				inr[ed].insert(c);
			}
		}
		if(dist[N]>INF)
			puts("-1");
		else
			printf("%d\n", dist[N]);
	}
	return 0;
}

Measured memory_bytes: 34036
#include<iostream>
int main()
{
	char place = 'A';
	for (char place1, place2, comma; std::cin >> place1 >> comma >> place2;)
	{
		if (place1 == place)
		{
			place = place2;
		}
		else if(place2==place)
		{
			place = place1;
		}
	}
	std::cout << place << std::endl;
	return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 100006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/
vector<int>g[maxn];
int main()
{
  int n,m;
  cin >> n >> m;
  int a,b;
  set<int>s;
  for(int i=0;i<m;i++)
  {
     cin >> a >> b;
     g[a].pb(i);
     g[b].pb(i);
  }

  int ans=0;
  for(int i=1;i<=n;i++)
  {
     for(int j=0;j<g[i].size();j++)
     {
       if(s.find(g[i][j])!=s.end())
       {
         ans++;
         s.clear();
         break;
       }
     }

     for(int j=0;j<g[i].size();j++)
     {
       s.insert(g[i][j]);
     }
  }
  cout << ans;
}

Measured memory_bytes: 8444