akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2e5+10;

ll a[maxn];
ll b[3];

int main() {
    int n; ll k;
    scanf("%d%lld", &n, &k);
    for(int i=1; i<=n; i++)
        scanf("%lld", &a[i]);
    sort(a+1, a+n+1);
    b[0] = a[1]*a[n];
    b[1] = a[1]*a[2];
    b[2] = a[n]*a[n-1];
    sort(b, b+3);
    ll l = b[0], r = b[2];
    while(l<r) {
        ll mid = (l+r)>>1;
        ll cnt = 0;
        for(int i=1; i<n; i++) {
            if(a[i]<0) {
                int jl = i+1;
                int jr = n;
                while(jl<jr) {
                    int m = (jl+jr)>>1;
                    if(a[i]*a[m]<=mid)
                        jr = m;
                    else
                        jl = m+1;
                }
                if(a[i]*a[jl]<=mid)
                    cnt += n-jl+1;
            }
            else if(a[i]==0) {
                if(mid>=0)
                    cnt += n-i;
            }
            else {
                int jl = i+1;
                int jr = n;
                while(jl<jr) {
                    int m = (jl+jr+1)>>1;
                    if(a[i]*a[m]<=mid)
                        jl = m;
                    else
                        jr = m-1;
                }
                if(a[i]*a[jl]<=mid)
                    cnt += jl-i;
            }
        }
        if(cnt>=k)
            r = mid;
        else
            l = mid+1;
    }
    printf("%lld\n", l);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
//ll x[800005],y[800005],z[900005];
ll d1[500005],d2[500005],d3[500005],d4[500005];
ll dp[1000][1000];

int main(){	
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin >> dp[i][j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(dp[i][j]%2==1){			
				if(j!=w-1){
					d1[num] = i;
					d2[num] = j;
					d3[num] = i;
					d4[num] = j+1;
					dp[i][j]--;
					dp[i][j+1]++;
					num++;
				}else if(i!=h-1){
					d1[num] = i;
					d2[num] = j;
					d3[num] = i+1;
					d4[num] = j;
					dp[i][j]--;
					dp[i+1][j]++;
					num++;
				}
			}
		}
	}


				
	//assert(num <= h*w);
	p(num);
	for(i=0;i<num;i++){
		pe(d1[i]+1);pe(d2[i]+1);pe(d3[i]+1);p(d4[i]+1);
	}

	
	return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
// #define mod (int)1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
    int n;
    cin>>n;
    const int mod = 1e9+7;
    if(n==1){cout<<"0";return;}
    // ll res = 1ll*n*(n-1);
    // res %= mod;
    // ll res1 = power(10,n-2,mod);
    // cout << (1ll*res1*res)%mod<<endl;
    cout<<(((power(10,n,mod)-2*power(9,n,mod))%mod+mod)%mod+power(8,n,mod))%mod;
    
    // cout << res <<' '<<res1;

}


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

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<int> l(n);
  vector<int> r(n);

  REP(i, n) cin >> l[i] >> r[i];

  sort(l.begin(), l.end());
  sort(r.begin(), r.end());

  int ans;
  if(n % 2 == 1) {
    int l2 = l[n/2];
    int r2 = r[n/2];
    ans = r2 - l2 + 1;
  } else {
    int l2 = l[n/2 - 1] + l[n/2];
    int r2 = r[n/2 - 1] + r[n/2];
    ans = r2 - l2 + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();

			long resultC = b / c - a / c;
			if (a % c == 0) {
				resultC++;
			}
			long resultD = b / d - a / d;
			if (a % d == 0) {
				resultD++;
			}
			long lcm = lcm(c, d);
			long resultMix = b / lcm - a / lcm;
			if (a % lcm == 0) {
				resultMix++;
			}



			System.out.println(b - a + 1 - resultC - resultD + resultMix);
		}
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define ll    long long
#define F     first
#define S     second
#define pb    push_back
#define mp    make_pair
#define mod   1000000007
#define vlli  vector<ll>
#define vi    vector<int>
#define vs    vector<string>
#define vplli vector< pair< ll, ll> >
#define plli  pair< ll, ll >
#define vps   vector< pair< string, string> >
#define vpi   vector< pair< int, int> >
#define all(x)           x.begin(), x.end()
#define fast  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define forn(i, a, n)    for (ll i = a; i < n; i++)
#define scan(arr, a, n)  for (ll i = (a); i < (n); i++) cin >> (arr)[i];
#define print(arr, a, n) for (ll i = (a); i < (n); i++) cout << (arr)[i] << " ";

ll add(ll x, ll y) {
    ll res = x + y; return (res >= mod ? res - mod : res);
}
ll mul(ll x, ll y) {
    ll res = x * y; return (res >= mod ? res % mod : res);
}
ll sub(ll x, ll y) {
    ll res = x - y; return (res < 0 ? res + mod : res);
}
ll power(ll x, ll y) {
    ll res = 1; x %= mod; while (y) {

        if (y & 1) res = mul(res, x); y >>= 1; x = mul(x, x);
    }
    return res;
}
ll mod_inv(ll x) {
    return power(x, mod - 2);
}


int main(){
    fast;
    ll k;
    cin >> k;
    ll x = 7, ans = 1;

    if (k % 2 == 0) {
        cout << -1;
        return 0;
    }
    map<ll, ll> m;
    while (x % k != 0) {
        x = x % k;
        if (m[x] == 0) m[x]++;
        else if (m[x] > 0) {
            cout << -1;
            return 0;
        }
        ans++;
        x = x * 10 + 7;
    }
    cout << ans << endl;

} // main

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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using dijkstra = priority_queue<T, vector<T>, greater<T>>;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fbo find_by_order  // k th index
#define ook order_of_key   // strictly smaller than k
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define max_ull 18446744073709551615
#define max_ll 9223372036854775807
#define lead_zero(x) __builtin_clzll(x)
#define trail_zero(x) __builtin_ctzll(x)
#define total_1s(x) __builtin_popcountll(x)
#define first_1(x) __builtin_ffsll(x)
#define log2_(x) __builtin_clz(1) - __builtin_clz(x)
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define QUERY           \
    int test;           \
    scanf("%d", &test); \
    for (int _T = 1; _T <= test; _T++)
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define all(v) v.begin(), v.end()
#define reunique(v) v.resize(std::unique(all(v)) - v.begin())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define ff first
#define ss second
#define MERGE(v1, v2, v) merge(all(v1), all(v2), back_inserter(v))
#define MP make_pair
#define EB emplace_back
#define read freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define in_range(v, r, l) upper_bound(all(v), r) - lower_bound(all(v), l)
#define LCM(a, b) (a / __gcd(a, b)) * b;

ll rdn(int y, int m, int d) {
    /* Rata Die day one is 0001-01-01 */
    if (m < 3)
        y--, m += 12;
    return 365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306;
}
/* Direction arrays */
/*int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};                             */  // 4Direction
/*int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1};         */  // 8Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};     */  // KnightDirection
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};                */  // HexagonalDirection
/* int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; */


int main() {
    ll x;
    cin>>x;
    ll ans = 1000LL*(x/500);
    x%=500;
    ans+=5LL*(x/5);
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, x, m;
    cin >> n >> x >> m;
    vb seen(m, false);
    vll hist;
    ll now = x;
    while(true) {
        if(seen[now]) break;
        seen[now] = true;
        hist.push_back(now);
        now = (now * now) % m;
    }
    ll last_idx = 0;
    rep(i, hist.size()) {
        if(hist[i] == now) {
            last_idx = i;
            break;
        }
    }
    ll loop = hist.size() - last_idx;
    ll sum = 0;
    for(int i = last_idx; i < hist.size(); ++i) sum += hist[i];
    ll ans = 0;
    for(int i = 0; i < min(n, last_idx); ++i) ans += hist[i];
    if(n <= last_idx) {
        cout << ans << endl;
        return;
    }
    n -= last_idx;
    ans += sum * (n / loop);
    ll remain = n % loop;
    rep(i, remain) ans += hist[i + last_idx];
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int X = sc.nextInt();
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    
	    X -= A;
	    X = X % B;
	    
    	System.out.println(X);
	}    
}	

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){__
	int n;
	cin >> n;
	vi a;
	map<int,int> cnt;
	for(int i=0; i < n; i++){
		int x;
		cin >> x;
		cnt[x]++;
		if(cnt[x] == 1) a.pb(x);
	}
	int sz = a.size();
	sort(a.begin(),a.end());
	vector<bool> ans(1e6+5,true);
	int maxn = 1e6+5;
	for(int i=0; i < sz; i++){
		int x = a[i];
		if(ans[x]){
			for(int j = x+x; j < maxn; j+=x){
				ans[j] = false;
			}
		}
	}
	int res =0;
	for(int x : a){
		if(ans[x]){
			if(cnt[x] == 1) res++;
		}
	}
	cout<< res << endl;
	return 0;
}


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

void solve(int n) {
	long long arr[n], biggest = LLONG_MIN, best = LLONG_MAX;
	for(long long i = 0; i < n; i++) {
      cin >> arr[i];
      biggest = max(biggest, arr[i]);
    }
	for(long long p = 1; p <= biggest; p++) {
		long long int sum = 0;
		for(long long i = 0; i < n; i++) {
			sum += ((arr[i] - p) * (arr[i] - p));
		}
		best = min(sum, best);
	}
	printf("%Ld\n", best);
}

int main() {
	int n;
	while(cin >> n) solve(n);
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  int p;
  if ((double)x == w/2.0 && (double)y == h/2.0) p = 1;
  else p = 0;
  cout << (double)w * (double)h / 2.0 << ' ' << p << endl;
  
  return 0;
}

Measured memory_bytes: 3788
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for _ in 0..n {
        let s:String = read();
        if s == "AC".to_string() {
            ac += 1
        } else if s == "WA".to_string() {
            wa += 1
        } else if s == "TLE".to_string() {
            tle += 1
        } else if s == "RE".to_string() {
            re += 1
        }
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a,b,c,li[200110]={};
vector<P> vec[35];
 
int main(){
	cin >> n >> m;
	REP(i,0,n){
		cin >> a >> b >> c; c--;
		vec[c].push_back(P(2*a,2*b));
	}
	REP(i,0,m) sort(vec[i].begin(), vec[i].end());
	REP(i,0,m) vec[i].push_back(P(200100,200100));
	REP(i,0,m){
		li[vec[i][0].first-1]++;
		REP(j,0,vec[i].size()-1){
			if(vec[i][j].second==vec[i][j+1].first) continue;
			else li[vec[i][j].second]--, li[vec[i][j+1].first-1]++;
		}
	}
	
	int ma=0;
	REP(i,0,200010){
		li[i+1]+=li[i];
		ma=max(ma,li[i+1]);
	}
	
	cout << ma << endl;
	return 0;
}

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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //ios::sync_with_stdio(false);
    int nb_rows, nb_cols;
    scanf("%d %d", &nb_rows, &nb_cols);
    vector< vector<char> > field(nb_rows, vector<char>(nb_cols));
    for(int i=0; i<nb_rows; i++)
    {
        for(int j=0; j<nb_cols; j++)
        {
            scanf(" %c", &field[i][j]);
        }
    }
    bool possible=true;
    for(int i=0; i<nb_rows; i++)
    {
        for(int j=0; j<nb_cols; j++)
        {
            if(field[i][j] != '#') continue;
            bool can=false;
            for(int k=0; k<4; k++)
            {
                int new_row = i+dirs[k][0];
                int new_col = j+dirs[k][1];
                if(!(0 <= new_row && new_row < nb_rows && 0 <= new_col && new_col < nb_cols)) continue;
                if(field[new_row][new_col]=='#') can=true;
            }
            if(!can) possible=false;
        }
    }
    if(possible) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main() {
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    ll n;
    cin>>n;
    ll x=1000-(n%1000);
    if(x==1000)
    {
        x=0;
    }
    cout<<x<<endl;
    
	return 0;
}


Measured memory_bytes: 3648
# include <bits/stdc++.h>
# define f first
# define s second
# define ll long long
# define pll pair < ll, ll >
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
ll n, m, ans;
priority_queue < pll > pq;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        pq.push({a, 1});
    }
    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        pq.push({b, a});
    }
    while(n --){
        int x = pq.top().f;
        int y = pq.top().s;
        pq.pop();
        ans += x;
        if(y > 1){
            pq.push({x, y - 1});
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
<?php
$s = trim(fgets(STDIN));
$k = trim(fgets(STDIN)) - 1;

for($i = 0; $i < strlen($s); $i++){
    if($s[$i] != "1"){
        echo $s[$i];
        exit;
    }
    if($k  == $i){
        echo $s[$i];
        exit;
    }
}

Measured memory_bytes: 4604
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var points = new Dictionary<string, int>();

            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                if (points.ContainsKey(s))
                {
                    points[s]++;
                }
                else
                {
                    points[s] = 0;
                    points[s]++;
                }
            }

            var m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                var t = Console.ReadLine();
                if (points.ContainsKey(t))
                {
                    points[t]--;
                }
            }
            Console.WriteLine(Math.Max(0, points.Max(d => d.Value)));
        }
    }
}

Measured memory_bytes: 28340
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[1000010];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    n /= 2;
    int ans = a[n] - a[n-1];
    cout << ans;
    return 0;
}

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

int main() {
  int N;
  int A[201];

  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  int res = 0;

  while (1) {
    bool flag = false;
    for (int i=0; i<N; i++) {
      if (A[i]%2==1) flag = true;
      else A[i] /= 2;
    }
    if (flag) break;
    res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int score = 0;
		if (k < a) {
			score = k;
		} else {
			score = a;
			k -= a;
			if (k > b) { // k <= b, do nothing, too.
				k -= b;
				score -= k;
			}
		}
		System.out.println(score);
	}

}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  if(s[0]=='9'||s[1]=='9') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int N, M;
  cin >> N >> M;
  dsu d(N);
  for(int i=0;i<M;i++) {
  	int A,B;
    cin >> A >> B;
    d.merge(A-1, B-1);
  }
  
  cout << d.groups().size() - 1 << endl;
  
}


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

    ll N,M;
    cin >> N >> M;

    vector<int> is_red(N,0);
    vector<int> num(N,1);

    is_red[0] = 1;
    for(int i=0; i<M; i++) {
	int x,y;
	cin >> x >> y;
	x--; y--;
	
	is_red[y] = max(is_red[y],is_red[x]);
	num[x]--; num[y]++;
	if(num[x] == 0)
	    is_red[x] = 0;
    }
    int ans = 0;
    for(int i=0; i<N; i++) {
	ans += is_red[i];
    }
    cout << ans << endl;
	

}


Measured memory_bytes: 1024
K,N = map(int,input().split())

A = list(map(int,input().split()))
A.append(0)
A.append(K)
A = sorted(A)

S = [0]*N
S[0] = A[0]

#一番広い隙間を通らない方法を考える
#A[0]-A[N-1]
for i in range(1,N):
    S[i-1] = A[i+1] - A[i]
S[N-1] = K-A[N]+A[1]
print(K-max(S))



Measured memory_bytes: 26444
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	long long a=0;
	for (int i=0;i<(1 << (s.length()-1));i++) {
		long long b=s[0]-'0';
		for (int j=1;j<s.length();j++) {
			if (i & (1 << (j-1))) {
				a+=b;
				b=s[j]-'0';
			} else {
				b=b*10+s[j]-'0';
			}
		}
		a+=b;
	}
	cout << a << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,b[10];
    cin>>n;
    if(n>81){
        cout<<"No";
    }
    else {
        ll j=0,d=0;
        for(ll i=1;i<10;i++){
            if(n%i==0){
              b[j]=i;
              j++;
            }
        }
        for(ll i=0;i<j;i++){
            for(ll k=0;k<j;k++){
                if(b[i]*b[k]==n){
                   // cout<<"Yes";
                    d=-1;
                    break;
                }
            }
        }
        if(d==0){
            cout<<"No";
        }
        else
        cout<<"Yes";
    }
	return 0;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
abstart=[]
abgoal=[]
for i in range(0,m):
    inp=[int(i) for i in input().split()]
    if inp[0]==1:
        abstart.append(inp[1])
    elif inp[1]==n:
        abgoal.append(inp[0])

start = set(abstart)
goal = set(abgoal)
matched = list(start & goal)

if len(matched)>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 21840
using System;
using System.Collections.Generic;
using System.Linq;

public class Program{
    public static void Main(){
      
      int num = int.Parse(Console.ReadLine());
      //Console.WriteLine(num);
      
      List<string> list = new List<string>();
      string ip = Console.ReadLine();
      list.Add(ip);
      
      for(int i = 1; i < num; i ++)
      {
        ip = Console.ReadLine();

          list.Add(ip);

      }
      
      Console.WriteLine(list.Distinct().Count());
    }
}




Measured memory_bytes: 48032
import fractions
n,x0=map(int,input().split())
d=list(map(lambda a:abs(int(a)-x0),input().split()))
ans=d[0] if len(d)==1 else fractions.gcd(d[0],d[1])
i=1
while i < n-1 and ans !=1:
    ans=min(ans,fractions.gcd(d[i],d[i+1]))
    i+=1
print(ans)



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

int main(){
	int n,t;
	cin >> n;
	for(int i =1;i <=n;++i){
		t = i;
		if(i % 3 == 0){
			cout << " " << i;
		}
		else {
			while(t!=0){
				if(t % 10==3){
					cout << " " << i;
					break;
				}
				t/=10;
			}
		}
	}
	cout <<endl;

	return 0;
}

Measured memory_bytes: 1160
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;
const int _N = 1e5;

int n,m,dist[_N];
ll k;
string s;

int main() {
	cin >> n;

	//dijkstra
	priority_queue<P, vector<P>, greater<P> > pq;
	REP(i, n) dist[i] = INF;
	dist[1] = 0;
	pq.push(P(0, 1));

	while(!pq.empty()){
		int d = pq.top().first, x = pq.top().second;
		pq.pop();
		int g[] = {(x * 10) % n, (x + 1) % n};
		REP(i, 2)if(dist[g[i]] > d + i){
			dist[g[i]] = d + i;
			pq.push(P(d + i, g[i]));
		}
	}

	cout << dist[0] + 1;
	cout << endl;
}


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

typedef unsigned long long ull;

static const ull MOD = 1000000007;

ull pow(ull x, ull n) {
    if (n == 0) return 1;

    ull ret = pow((x*x) % MOD, n/2);
    if (n % 2 != 0) {
        ret = ret*x % MOD;
    }

    return ret;
}

int main(void) {
    ull m, n;
    cin >> m >> n;

    ull ans = pow(m, n);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
void solve(){
    int n;
    cin>>n;
    vector<vector<int>> adj(n);
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        --u;--v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(n==2){
        cout<<"1 2\n";
        return;
    }
    set<int> path;
    vector<int> pathleaves;
    for(int i=0;i<n;i++){
        if(adj[i].size()>1){
            path.insert(i);
        }
    }
    if(path.size()==1){
        vector<int> ans;
        ans.reserve(n);
        ans.pb(1);
        for(int i=3;i<n;i++){
            ans.pb(i);
        }
        ans.pb(2);
        ans.pb(n);
        for(const auto &x : ans){
            cout<<x<<" ";
        }
        cout<<"\n";
        return;
    }
    function<void(int,int)> dfs = [&](int u, int par){
        int cnt = 0;
        for(const auto &v : adj[u]){
            if(v==par){
                continue;
            }
            if(!path.count(v)){
                continue;
            }
            dfs(v, u);
            ++cnt;
        }
        if(par==-1){
            --cnt;
        }
        if(cnt==0){
            pathleaves.pb(u);
        }
        if(cnt>1){
            cout<<"-1\n";
            exit(0);
        }
    };
    dfs(*path.begin(), -1);
    if(pathleaves.size()!=2){
        cout<<"-1\n";
        return;
    }
    function<void(int,int, vector<int>&)> dfs2 = [&](int u, int par, vector<int> &seq){
        if(par==-1){
            seq.pb(0);
        }
        seq.pb(adj[u].size() - 2);
        for(const auto &v : adj[u]){
            if(v==par){
                continue;
            }
            if(path.count(v)==0){
                continue;
            }
            dfs2(v, u, seq);
        }
        if(par!=-1 && (pathleaves[0]==u || pathleaves[1]==u)){
            seq.pb(0);
        }
    };
    auto getperm = [&](const vector<int> &seq){
        vector<int> ans;
        int curr = 1;
        for(const auto &x : seq){
            for(int i=curr+1;i<=curr+x;i++){
                ans.pb(i);
            }
            ans.pb(curr);
            curr+=x+1;
        }
        return ans;
    };
    auto getmin = [&](const vector<int> &seq1, const vector<int> &seq2){
        assert(seq1.size() == seq2.size());
        int n = seq1.size();
        for(int i=0;i<n;i++){
            if(seq1[i]==seq2[i]){
                continue;
            }
            if(seq1[i]<seq2[i]){
                return seq1;
            }
            return seq2;
        }
        return seq1;
    };
    vector<int> perm1;
    dfs2(pathleaves[0], -1, perm1);
    vector<int> perm2;
    dfs2(pathleaves[1], -1, perm2);
    perm1 = getperm(perm1);
    perm2 = getperm(perm2);
    vector<int> ans = getmin(perm1, perm2);
    for(const auto &x : ans){
        cout<<x<<" ";
    }
    cout<<"\n";
    
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 24196
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K, Q;
	
	cin >> N >> K >> Q;

	int a[N];
	/*
	rep(i, N)
	{
		a[i] = K;
	}
	*/
	memset(a, 0, sizeof(a));

	rep(i, Q)
	{
		int tmp;
		cin >> tmp;
		a[tmp-1]++;
	}

	rep(i, N)
	{
		if (K-Q+a[i] > 0)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
		
	}

	
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
int m=0,n=0,l=0,g=0;
while(1){
cin>>m>>n>>l;
g=m+n;
if(m==-1&&n==-1&&l==-1)break;
if(m==-1||n==-1){
    cout<<"F"<<endl;
}
else if(80<=g&&g<=100){
    cout<<"A"<<endl;
}
else if(65<=g&&g<80){
    cout<<"B"<<endl;
}
else if(50<=g&&g<65){
    cout<<"C"<<endl;
}
else if(50<=l){
    cout<<"C"<<endl;
}
else if(30<=g&&g<50){
    cout<<"D"<<endl;
}
else if(g<=30){
    cout<<"F"<<endl;
}
}
}



Measured memory_bytes: 3084
n = int(input())
X = []
Y = []
for i in range(n):
    x,y = map(int, input().split())
    x,y = x-y,x+y
    X.append(x)
    Y.append(y)

a = max(Y) - min(Y)
b = max(X) - min(X)

print(max(a,b))

Measured memory_bytes: 24912
#include<stdio.h>
#include<string.h>
 
struct Node{
  int key;
  struct Node *right,*left,*parent;
};
 
struct Node *root,*NIL;
 
void insert(int k){
  struct Node *x=root;
  struct Node *y=NIL;
  struct Node *z;
 
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while( x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
 
void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
int main(){
  int n,i,x;
  int a=0,b=0;
  char com[10];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",com);
     
    a = strcmp(com,"insert");
      if(a==0){
    scanf("%d",&x);
    insert(x);
      }
 
      b = strcmp(com,"print");
      if(b==0){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
      }
  }
 
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    for(i = n-1;i >= 0;--i){
        for(j = n-1;j > i;--j){
            if(s.at(i) == s.at(j)) chmax(dp.at(i).at(j), dp.at(i+1).at(j+1)+1);
            chmax(ans, min(dp.at(i).at(j), j-i));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 195840
const main = () => {
  const abcx = getParams()
      , a = abcx[0]
      , b = abcx[1]
      , c = abcx[2]
      , x = abcx[3];
  console.log(solve(a, b, c, x));
};

const getParams = () =>
  getStdin().split('\n').map(Number);

const getStdin = () =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = (a, b, c, x) =>
  exactPairs(a, b, c, x).length;

const exactPairs = (a, b, c, x) =>
  allPairs(a, b, c).filter(arr => exact(arr[0], arr[1], arr[2], x));

const allPairs = (a, b, c) =>
  range(a+1).flatMap(ai =>
    range(b+1).flatMap(bi =>
      range(c+1).map(ci =>
        [ai, bi, ci])));

const range = max =>
  [...Array(max).keys()];

const exact = (a, b, c, x) =>
  500 * a + 100 * b + 50 * c === x;

Array.prototype.flatMap = function (f) {
  return this.reduce((acc ,x) => acc.concat(f(x)), []);
};

main();


Measured memory_bytes: 51424
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 100001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair 
#define ll long long
#define ull unsigned ll 
#define pb push_back
#define db double
int read()
{
	int x=0,f=1;char ch=gc;
	while(!isdigit(ch)){ch=gc;if(ch=='-')f=-1;}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int n,a[maxn];
int main()
{  
   n=rd;fo(i,0,n-1)a[i]=rd;
   sort(a,a+n);
   printf("%d\n", a[n / 2] - a[n / 2 - 1]);
	return 0;
}

Measured memory_bytes: 640
t = list(input())
p = list(input())
n = len(t) - len(p) + 1

for i in range(n):
    if p[0] == t[i]:
        for j in range(len(p)):
            flag = True
            if not p[j] == t[i+j]:
                flag = False
                break
        if flag:
            print(i)



Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    while (true) {
        double n;
        cin >> n;
        vector<double> a(n);
        if (n == 0) break;
        double x = 0.0;
        for (Int i = 0; i < n; i++) {
            cin >> a[i];
            x += a[i];
        }
        Int av = x / n;
        sort(a.begin(), a.end());
        Int res = 0;
        for (Int i = 0; i < (Int)n && a[i] <= av; i++) res++;
        dump(res);
    }
    return 0;
} 



Measured memory_bytes: 3388
#!/usr/bin/env python3
import sys
import math
from decimal import *

YES = "Yes" 
NO = "No"  

def solve(a: int, b: int, c: int):
    if a + b + (2 * Decimal(a * b).sqrt()) - c < 0:
        print(YES)
    else:
        print(NO)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)

if __name__ == '__main__':
    main()


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 2000007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int& a, const int& b) {return a > b;}

ll a[maxN], sum[maxN];

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

    fto (i, 1, n) scanf("%lld", &a[i]);
    sort(a+1, a+n+1);

    fto (i, 1, n) sum[i] = sum[i-1]+a[i];

    int ans = 0;
    fdto (i, n, 1) {
        if (2LL*sum[i] >= a[i+1]) ++ans;
        else break;
    }

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


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

#define ll long long

using namespace std;

int main(){
   int n, val;
   ll sum = 0, s_sum = 0, differ, differ2;

   cin >> n;
   vector<int> ve(n);

   for(int i = 0; i < n; i++){
      cin >> val;
      sum += val;
      ve.at(i) = val;
   }

   for(int i = 0; i < n - 1; i++){
      sum -= ve.at(i);
      s_sum += ve.at(i);
      differ2 = abs(sum - s_sum);
      if(i == 0 || differ > differ2) differ = differ2;
   }

   cout << differ << endl;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=3e5+10;
const int mod=998244353;
ll gi() {
    ll x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int fac[N],inv[N],ifac[N];
int n;
ll a,b,k;
int C(int n,int m) {
    if(n<0||m<0||n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    n=gi(),a=gi(),b=gi(),k=gi();
    fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(int i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    ifac[0]=1;for(int i=1;i<=n;i++) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    int ans=0;
    for(int i=0;i<=n;i++) {
        if(a*i<=k&&(k-a*i)%b==0) inc(ans,1ll*C(n,i)*C(n,(k-a*i)/b)%mod);
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main() {
	long long int N, M, Q;
	cin >> N >> M >> Q;

	vector<string>S( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> S[i];
	}

	vector<vector<long long int>>D( N + 1, vector<long long int>( M + 1 ) );
	auto E = D;
	auto F = D;

	for( size_t i = 1; i <= N; i++ ) {
		for( size_t j = 1; j <= M; j++ ) {
			if( S[i - 1][j - 1] == '1' ) {
				D[i][j] = 1;
			}
			D[i][j] += D[i][j - 1];
		}
	}
	for( size_t i = 1; i <= N; i++ ) {
		for( size_t j = 0; j <= M; j++ ) {
			D[i][j] += D[i - 1][j];
		}
	}

	for( size_t i = 0; i < N; i++ ) {
		for( size_t j = 0; j < M; j++ ) {
			if( i ) {
				if( S[i][j] == S[i - 1][j] && S[i][j] == '1' ) {
					E[i + 1][j + 1]++;
				}
			}

			if( j ) {
				if( S[i][j] == S[i][j - 1] && S[i][j] == '1' ) {
					F[i + 1][j + 1]++;
				}
			}
		}
	}

	for( size_t i = 0; i < N; i++ ) {
		for( size_t j = 0; j < M; j++ ) {
			E[i + 1][j + 1] += E[i][j + 1];
			F[i + 1][j + 1] += F[i][j + 1];
		}
	}

	for( size_t i = 0; i < N; i++ ) {
		for( size_t j = 0; j < M; j++ ) {
			E[i + 1][j + 1] += E[i + 1][j];
			F[i + 1][j + 1] += F[i + 1][j];
		}
	}
	for( size_t i = 0; i < Q; i++ ) {
		long long int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;

		long long int num = D[x2][y2] + D[x1 - 1][y1 - 1] - D[x2][y1 - 1] - D[x1 - 1][y2];

		long long int t = F[x2][y2] + F[x1 - 1][y1] - F[x1 - 1][y2] - F[x2][y1];

		long long int y = E[x2][y2] + E[x1][y1 - 1] - E[x1][y2] - E[x2][y1 - 1];

		cout << num - t - y << endl;
	}


	return 0;
}



Measured memory_bytes: 100736
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define ull unsigned long long
using namespace std;
const int maxx = 1007;
const ll mod1 = 1e7;
const ll mod = 1e9 + 7;
const ll base = 311;
const ll base1 = 113;
const ll maxn = 1e6 + 7;
bool check;
ll t, T, n, a[maxn], b[maxn], m1, m, tong, r, ans, mx, k, ma[maxx][maxx], pw[maxx][maxx];
//ll , c[maxx], st1[maxx];
//ll  , pw[maxx];
//string s[maxx], ss[maxx], str, f[maxx][10];
struct dang
{
    ll mn, gcd, val, pos, dd, n1, n2, n3;
};
dang f[maxx][maxx];
string s;
struct les
{
    bool operator()(ll x, ll y)
    {
        return x > y;
    }
};
dang c[maxn];
deque<ll> st;
priority_queue<ll, vector<ll>, les >st1;
map<ll, ll> mp;
vector<ll> adj;
void sol()
{

    cin >> n;
    ans = 0;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    for(int i = 1; i <= n; i ++)
        cin >> b[i];
    for(int i = 1; i <= n; i ++)
    {
        while(!st.empty() && b[st.back()] < b[i])st.pop_back();
        while(!st.empty() && b[st.front()] > a[i])st.pop_front();
        if(a[i] != b[i] && (st.empty() || b[st.back()] != b[i]))
        {
            ++ans;
            st.push_back(i);
        }
    }
    cout << ans;
}

void ntu()
{
    cin >> n >> m;
    for(int i = 1 ;i <= m; i ++)
    {
        cin >> k;
        n -= k;
    }
    if(n < 0)cout << -1;
    else cout << n;
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("Test.INP", "r", stdin);
    ntu();
}
/*
3 4
0 3 -1 2
3 3 3 3
3 1 3 0
*/


Measured memory_bytes: 3604