akhauriyash/Code-Regression huggingface dataset:
import queue

def bfs(h,w,sx,sy,maze):
    dx = (1,0,-1,0)
    dy = (0,1,0,-1)
    fal = -1
    mx = -1
    #距離の配列の初期化
    d = [[fal for i in range(w)] for j in range(h)]
    que = queue.Queue()
    #初期状態の代入
    que.put((sx,sy))
    d[sx][sy] = 0
    #キューが空になるまでループ
    while que.empty() == False:
        p = que.get()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx and nx < h and 0 <= ny and ny < w:
                if maze[nx][ny] != "#" and d[nx][ny] == fal:
                    que.put((nx,ny))
                    d[nx][ny] = d[p[0]][p[1]] + 1
                    if d[nx][ny] > mx:
                        mx = d[nx][ny]
    return mx

def main():
    h,w = map(int,input().split())
    maze = []
    mx = -1
    for i in range(h):
        maze.append(list(input()))
    for i in range(h):
        for j in range(w):
            if maze[i][j] != "#":
                ans = bfs(h,w,i,j,maze)
                if ans > mx:
                    mx = ans
    print(mx)

if __name__ == "__main__":
    main()


Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n;
	cin>>n;
	string s;
	while(n)
	{
		int x=(n-1)%26;
		char c=x+'a';
		s+=c;
		n=(n-1)/26;
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

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

#define INF 1e7

using namespace std;

const int maxn = 100005;


int main()
{
    int dist[maxn],k,temp,mul_ten,plus_one,ans;
    deque<int> q;

    scanf("%d",&k);
    for (int i=0;i<maxn;i++) dist[i]=INF;
    dist[1]=0;
    q.push_front(1);

    while (!q.empty())
    {
        temp=q.front();
        q.pop_front();

        mul_ten=(temp*10)%k;
        plus_one=(temp+1)%k;

        if (dist[temp]<dist[mul_ten])
        {
            q.push_front(mul_ten);
            dist[mul_ten]=dist[temp];
        }

        if (dist[temp]+1<dist[plus_one])
        {
            q.push_back(plus_one);
            dist[plus_one]=dist[temp]+1;
        }
    }

    ans=dist[0]+1;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 896
#include <cstring>
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
    string word;
    cin>>word;
    int l=word.size(),cnt=0;
    for(register int i=0;i<l;i++)
    {
        if(word[i]=='C'&&!cnt)  cnt++;
        if(word[i]=='F'&&cnt)  
        {
            cnt++;break;
        }
    }
    if(cnt==2)  printf("Yes\n");
    else  printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

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

    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        int h;
        scanf("%d",&h);
        if(h>=k) ans++;
    }
    
    printf("%ld\n", ans);
    return 0;
}


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

int main(){
    int N, K; cin >> N >> K;
    vector<int> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];
    int mintime = 1 << 30;
    for(int left = 0; left + K - 1 < N; left++){
        int right = left + K - 1;
        int tmin = min(abs(x[left]) + abs(x[right]-x[left]), abs(x[right]) + abs(x[right] - x[left]));
        mintime = min(mintime, tmin);
    }
    cout << mintime << endl;
}

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

int main() {
  int n, fx, i;
  fx = 0;
  i = 1;
  cin >> n;
  while(true){
    if(n/i == 0){
      break;
    }
    fx += n/i-n/(10*i)*10;
    i *= 10;
  }
//  cout << fx;
  if(n%fx == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main(){
  char c[1301];
  int i=0,j;
  while(1){
    scanf("%c",&c[i]);
    if(c[i]=='\n'){
      break;
    }
    i++;
  }
  for(j=0; j<i; j++){
    if(c[j]>='A'&&c[j]<='Z')c[j]+=32;
    else if(c[j]>='a'&&c[j]<='z')c[j]-=32;
    printf("%c",c[j]);
    if(j==i-1)printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2088
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector<set<int>> kek(30);
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        kek[s[i] - 'a'].insert(i);
    }
    int q;
    cin >> q;
    int t, l, r;
    char nw;
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> l >> nw;
            l--;
            kek[s[l] - 'a'].erase(l);
            kek[nw - 'a'].insert(l);
            s[l] = nw;
        } else {
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            for (int i = 0; i < 30; i++) {
                auto ptr = kek[i].lower_bound(l);
                if (ptr != kek[i].end() && *ptr <= r) {
                    ans++;
                }
            }
            cout << ans << "\n";
        }
    }
}
/*

*/


Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

vector<pair<int, int> > items;
vector<vector<long long int> > table;
int MAX = 101000;

int choose(int weight){
    int num = items.size();

    table[0][0] = 0;
    table[0][items[0].second] = items[0].first;

    for(int i = 1; i < num; i++){
        auto item = items[i]; 

        for(int value = 0; value < MAX; value++){
            int remain = value - item.second;

            long long int min = LLONG_MAX;
            if((remain >= 0) && (table[i-1][remain] != LLONG_MAX))
                min = item.first + table[i-1][remain];

            if(table[i-1][value] < min)
                min = table[i-1][value];

            table[i][value] = min;
        }
    }

    long long int max = 0;
    for(int value = 0; value < MAX; value++){
        if((table[num-1][value] <= weight) && (value > max))
            max = value;
    }

    return max;
}

int main(){
    int n, w;
    cin >> n >> w;

    items = vector<pair<int, int> >(n);
    for(int i = 0; i < n; i++) 
        cin >> items[i].first >> items[i].second;

    table = vector<vector<long long int>>(n, vector<long long int>(MAX, LLONG_MAX));

    int max = choose(w);
    cout << max << "\n";

    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s(n+1);
  rep(i, n) s[i+1] = s[i]+a[i];
  ll ans = 1e18;
  int l = 0, r = 2;
  for (int i = 2; i < n-1; i++) {
    while (abs(s[i]-2*s[l+1]) < abs(s[i]-2*s[l]))
      l++;
    while (abs(s[n]-2*s[r+1]+s[i]) < abs(s[n]-2*s[r]+s[i]))
      r++;
    ll l1 = s[l], l2 = s[i]-s[l];
    ll r1 = s[r]-s[i], r2 = s[n]-s[r];
    ll mn = min({l1, l2, r1, r2});
    ll mx = max({l1, l2, r1, r2});
    ans=min(ans, mx-mn);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>

int h[100000];
using namespace std;
int main()
{
  int n, k, br=0;
  cin >> n >> k;
  for(int i = 0; i<n ; i++){
      cin >> h[i];
  }
  for(int i = 0; i<n ; i++){
      if (k > h[i]) continue;
      else br++;
  }
  cout << br;
  //cout << "Hello World!";
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a, b;
  cin >> a >> b;

  if(b < a)
    cout << a-1 << endl;
  else
    cout << a << endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> oks(N+1, true);
  for(int i=0; i<N ; i++){
    int a;
    cin >> a;
    oks.at(a) = false;
  }
  
  vector<long long int> dp(N+1);
  dp.at(0) = 1;
  for(int now=0; now<N; now++){
    for(int next=now+1; next<=min(N,now+2);next++){
      if(oks.at(next)){
        dp.at(next) += dp.at(now);
        dp.at(next) %= mod;
      }
    }
  }
  
  cout << dp.at(N) << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  int free = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if(a >= 3200) ++free;
    else ++mp[a/400];
  }
  
  int small = mp.size();
  if(small==0) cout << 1 << " ";
  else cout << small << " ";
  
  int large = small+free;
  cout << large << endl;
  
  return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[20], t[20];
int main() {
	scanf("%s %s", s, t);
	for (int i = 0; s[i]; i++) {
		if (s[i] != t[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 1664
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for d in range(n)]
ans=0
for i in range(n):
    C=c
    for j in range(m):
        C+=a[i][j]*b[j]
    if C>0:
        ans+=1
print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;
ll n;

int main() {
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    string s;

    cin >> s;

    bool yymm = false, mmyy = false;

    if((s[0] == '0' && s[1] != '0') || (s[0] == '1' && s[1] < '3'))mmyy = true;
    if((s[2] == '0' && s[3] != '0') || (s[2] == '1' && s[3] < '3'))yymm = true;

    if(mmyy && yymm)cout << "AMBIGUOUS" << endl;
    else if(mmyy)cout << "MMYY" << endl;
    else if(yymm)cout << "YYMM" << endl;
    else cout << "NA" << endl;

}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr ll MOD = (ll)1e9 + 7;
constexpr ll MOD2 = 998244353;
constexpr ll HIGHINF = (ll)1e18;
constexpr ll LOWINF = (ll)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<ll> A(N);
	for(int i = 0; i < N; ++i) cin >> A[i];
	ll s = 0;
	for(int i = 0; i < N; ++i) s ^= A[i];
	Yn(!s);
	


    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vs vector<string>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define itr ::iterator
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fne(i,a,b) for(ll i=a;i>=b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define all(v) v.begin(),v.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define pi 3.14159265358979323846


int main()
{  
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   IOS;
   
   int T=1;
   //cin>>T;
   f(t,0,T)
    { 
      ll n=0,i=0,j=0,k=0,ans=INT_MIN;
      cin>>n;

      int dp[n][3] = {0};
      int a[n][3];
      
      f(i,0,n)
       cin>>a[i][0]>>a[i][1]>>a[i][2];

      dp[0][0] = a[0][0];
      dp[0][1] = a[0][1];
      dp[0][2] = a[0][2];

      ans = max(dp[0][0],max(dp[0][1],dp[0][2]));

      f(i,0,n-1)
       { 
         f(j,0,3)
          {
            dp[i+1][(j+1)%3] = max(dp[i+1][(j+1)%3],dp[i][j] + a[i+1][(j+1)%3]);
            dp[i+1][(j+2)%3] = max(dp[i+1][(j+2)%3],dp[i][j] + a[i+1][(j+2)%3]);

            ans = max(ans,dp[i+1][(j+1)%3]);
            ans = max(ans,dp[i+1][(j+2)%3]);
          }
       }
      cout<<ans<<endl;
    }
  return 0;
}


Measured memory_bytes: 5920
#include <unordered_set>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <memory>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;


int main()
{
  int n,k;
  scanf("%d%d",&n,&k);
  int a[55];
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  sort(a,a+n,greater<int>());
  int res=0;
  for(int i=0;i<k;i++)
    res+=a[i];
  cout<<res<<endl;
  return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;


int main()
{
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) cin >> a[i];

    vl x(n);
    vl y(n);
    vl h1(2 * n + 1, 0);
    vl h2(2 * n + 1, 0);
    rep(i, n) 
    {
        x[i] = i - a[i];
        if (x[i] <= n && x[i] >= -n) h1[x[i] + n]++;
        y[i] = i + a[i];
        if (y[i] <= n && y[i] >= -n) h2[y[i] + n]++;
    }

    ll count = 0;

    rep(i, n) 
    {
        ll t;
        t = i + a[i];
        if (t <= n && t >= -n) count += h1[t + n];
        t = i - a[i];
        if (t <= n && t >= -n) count += h2[t + n];
    }

    cout << count / 2 << "\n";

    return 0;
}

Measured memory_bytes: 14332
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector <int> a(m);
  int sum = 0;
  rep(i, m){
    cin >> a[i];
    sum += a[i];
  }
  if(sum <= n){
    cout << n - sum;
  }
  else cout << "-1";
return 0;
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int gcd(int x,int y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int lcm(int x, int y)
{
	return (x * y / gcd(x, y));
}
 
signed main(){
	IOS();
	cin>>N;
	vector<pair<int,int>>v(N);
	rep(i,0,N){
		int a,b;
		cin>>a>>b;
		v[i] = {b,a};
	}
	sort(all(v));
	int now = 0;
	rep(i,0,N){
		now+=v[i].se;
		if(now>v[i].fi){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

using namespace std;

typedef long long ll;

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

    int x, y;
    cin >> x >> y;

    if(x*4>=y and x*2<=y){
        if(y%2==0 or y%4==2) cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> v;
    int t;
    for(int i=0;i<N;i++)
    {
        cin>>t;
        v.push_back(t);
    }

    sort(v.begin(),v.end());
    double sum = 0;
    for(int i = 0;i<N;i++)
    {
        if(i==0)
        {
            sum = v[0];
        }
        else
        {
            sum = (v[i]+sum)/2;
        }
    }
    cout<<setprecision(20)<<(double)sum<<endl;
}

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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int lcm(int a, int b){
 return (a*b)/gcd(a,b);
}

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int BC=gcd(B,C);
  int AB=gcd(A,B);
  if(lcm(AB,BC)==BC){
    cout <<  "YES" << endl;
  }
  else cout << "NO" << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;
int main(){
	int N;
	cin>>N;
	vector<int> X(N);
	int min=1000000;
	rep(i,N){
		cin>>X.at(i);
	}
	rep(i,100){
		int sum=0;
		rep(j,N){
			sum+=(i-X.at(j))*(i-X.at(j));
		}
		if(sum<min){
			min=sum;
		}
		
	}
	cout<<min;
	
return 0;}

/*compile
g++ code.cpp
./a.out
run*/


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

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

    vector<long long> A(N);
    vector<long long> B(N);
    vector<long long> C(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long count = 0;
    for (long long b : B) {
        long long a_count = lower_bound(A.begin(), A.end(), b) - A.begin();
        long long c_count = C.end() - upper_bound(C.begin(), C.end(), b);
        count += a_count * c_count;
    }

    cout << count << endl;
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i,n){
        if(s[i] == s[i+1]) cnt++;
    }
    cout << n - cnt << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
import numpy as np

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n, m, x = nm()
li = [np.array(nl()) for _ in range(n)]
ans = 10 ** 10
comp = np.array([x for _ in range(m)])
for i in range(1 << n):
    sum = np.array([0 for _ in range(m + 1)])
    now = i
    for j in range(n):
        di = now % 2
        now = now >> 1
        if di == 1:
            sum += li[j]
    
    if all(sum[1:m+1] >= comp):
        ans = min(ans, sum[0])
if ans == 10 ** 10:
    print(-1)
else:
    print(ans)


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

int main()
{
  int n;
  cin >> n;

  vector<int> first(n, 0);
  vector<int> second(n, 0);
  for(int i=0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    first.at(i) = tmp;
  }
  for(int i=0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    second.at(i) = tmp;
  }

  int max = 0;
  vector<int> ans(n, 0);
  for(int i = 0; i < n; ++i) {
    int tmp_max = 0;
    // first
    for(int j = 0; j <= i; ++j) {
      tmp_max += first.at(j);
    }
    // second
    for(int j = i; j < n; ++j) {
      tmp_max += second.at(j);
    }

    if(tmp_max > max) max = tmp_max;
  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

double calc(pair<int,int> a,pair<int,int> b){
  return sqrt(pow(a.fi - b.fi,2) + pow(a.se - b.se,2));
}
int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<pair<int,int> > a(n);rep(i,n)cin>>a[i].fi>>a[i].se;
  sort(all(a));
  double ans = 0;
  int tmp = 0;
  do{
    rep(i,n){
      if(i == 0)continue;
      ans += calc(a[i],a[i-1]);
    }
    tmp++;
  }while(next_permutation(all(a)));
  printf("%.10lf\n",ans / tmp);
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N, M = map(int, input().split())
arr = [0 for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    arr[A - 1] += 1
    arr[B - 1] += 1
  
for j in arr:
    print (j)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	ll ans = 0;
	int A[3010];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += A[i] - 1;
	}
	cout << ans << endl;
}


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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

#define pb push_back
#define pf push_front
#define mp make_pair
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define VL vector<long long>
#define F first
#define S second

using namespace std;


typedef complex<double> P;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }
inline int gcd(int a, int b) {
    if (b == 0) return a;
    return a < b? gcd(b, a) : gcd(b, a % b);
}
ll mo=1000000007;
const ll INF = 1e18;

void inc(ll &a, ll &b, ll p, ll q) {

    ll dif = b * p - a * q;
    if (dif == 0)
        return;
    else if (dif > 0) {
        ll i = ceil((double) dif / q);
        while(true) {
            ll d = q * i - dif;
            if ( d % p == 0 ) {
                a += i;
                b += d / p;
                break;
            }
            ++i;
        }
    } else {
        inc(b, a, q, p);
    }
}

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll> > ratios(n);

    FO(i, n) {
        cin >> ratios.at(i).fi
            >> ratios.at(i).se;
    }

    ll a = ratios.at(0).fi;
    ll b = ratios.at(0).se;


    FOR(i, 1, n) {
        ll p = ratios.at(i).fi;
        ll q = ratios.at(i).se;

     //   inc(a, b, p, q);

        ll c1 = (a - 1) / p + 1;
        ll c2 = (b - 1) / q + 1;
        ll c = max(c1, c2);

        a = c * p;
        b = c * q;
    }

    cout << (a + b) << endl;

    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
# import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
from collections import Counter

# from operator import mul
# from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random
# import time

n = int(input().strip())
s = list(map(int, input().strip().split()))
Map = Counter()
for i in range(n):
    Map[s[i]] += 1

cnt = 0
for value, number in Map.items():
    if number > value:
        cnt += number - value
    elif number == value:
        pass
    else:  # number < value
        cnt += number
print(cnt)


Measured memory_bytes: 90268
#include<iostream>
#include<algorithm>
using namespace std;
long gcd(long m, long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  long a,b,c,d,m,res;
  cin >> a >> b >> c >> d;
  m=c*d/gcd(c,d);
  res=(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/m-(a-1)/m);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		char[] c=ns().toCharArray();
		int cnt=0;
		for(int i=0;i<3;i++) {
			if(c[i]=='1') {
				cnt++;
			}
		}
		
		out.println(cnt);
	}
	
	
	
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception 
	{ new Main().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try 
			{ lenbuf = is.read(inbuf); } 
			catch (IOException e) 
			{ throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c)
	{ return !(c >= 33 && c <= 126); }
	private int skip() 
	{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() 
	{ return Double.parseDouble(ns()); }
	private char nc()
	{ return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true)
		{
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) 
	{ System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
using namespace std;
int main()
{
    int n,m;

    cin>>n>>m;

    for (int i=0; i<10000; ++i)
    {
        int x=i*0.1,y=i*0.08;

        if (y==n && x==m)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;




}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int a, b, c;
  char s;
  cin >> a >> b >> s >> c;

  cout << a*(b*100+c)/100 << "\n";

  return 0;
}


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

#define maxn 100005
#define INF 0x3f3f3f3f
#define MINF 0x7fffffffffffffff
#define mod 1000000007
#define PI 3.14159365358
typedef long long ll;
using namespace std;

void slove()
{
	double n;
	cin >> n;
	cout  << 2 * n * PI;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef ONLINE_JUDGE
#else
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	slove();

	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

const int max_n=300001;
int bit[max_n+1];
//1-index

int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i -= i & -i;
	}
	return s;
}

//iの値にx加える
void add(int i, int x){
	while(i<=max_n){
		bit[i]+=x;
		i += i & -i;
	}
}


int main(){
    ll n; cin>>n;
    int a[100001];
    FOR(i,0,n) cin>>a[i];
    int st=0,en=INF;
    /**
    if(n==1){
        co(a[0]);
        return;
    }
    **/
    while(st+1<en){
        int mid=(st+en)/2;
        int b[100001]={};
        FOR(i,0,n){
            if(a[i]>=mid) b[i+1]=b[i]+1;
            else b[i+1]=b[i]-1;
        }
        memset(bit,0,sizeof(bit));
        int geta=120000;
        ll c=0;
        FOR(i,0,n+1){
            c+=sum(geta+b[i]);
            add(geta+b[i],1);
        }
        if(2*c>=n*(n+1)/2) st=mid;
        else en=mid;
    }
    co(st);
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
const int MAX = 10005;
int v[105];
int w[105];
int dp[105][MAX];

int main()
{
	int n,W;
	cin >> n >> W;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i <= W; ++i)
	{
		dp[0][i] = 0;
	}

	for (int i = 0; i <= n; ++i)
	{
		dp[i][0] = 0;
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= W; ++j)
		{
			if (j < w[i])
			{
				dp[i+1][j] = dp[i][j];
			}
			else
			{
				dp[i+1][j] = max(dp[i][j],dp[i+1][j - w[i]] + v[i]);
			}
		}
	}

	/*
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= W; ++j)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/

	cout << dp[n][W] <<endl;
	return 0;
}


Measured memory_bytes: 7052
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = IL()
l = []
end = []
ans = []

l = [IL() for i in range(H)]

for j in range(H):
    cnt = 0
    for i in range(W-1):
        if (cnt + l[j][i])%2 != 0:
            ans.append([j+1,i+1,j+1,i+2])
        if l[j][i]%2 != 0:
            cnt += 1

for i in range(H):
    if sum(l[i])%2 != 0:
        end.append(1)
    else:
        end.append(0)

cnt = 0
for i in range(H-1):
    if (cnt + end[i])%2 != 0:
        ans.append([i+1,W,i+2,W])
    if end[i]%2 != 0:
        cnt += 1   

print(len(ans))
for i in ans:
    a = str(i[0])
    for j in range(1,len(i)): 
        a +=" "+str(i[j])
    print(a)


Measured memory_bytes: 40020
N,M=map(int, input().split())
a=[True for _ in range(N+10)]
for _ in range(M):
  a[int(input())]=False
D=1000000007

DP=[0 for _ in range(N+10)]
DP[0]=1
for i in range(N):
  for j in [1,2]:
    if a[i+j]:
      DP[i+j]+=DP[i]
      
print(DP[N]%D)

Measured memory_bytes: 463512
#include <iostream>

int main(void){
    int s, g;
    std::cin >> s >> g;

    if (g == 1){
        std::cout << "0" << std::endl;
        return 0;
    }

    if (s >= g){
        std::cout << "1" << std::endl;
        return 0;
    }

    int i;
    for (i = 1; i < g; i++) {
        if ((s - 1)*(i - 1) + s >= g) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) {
    if (n < m) {
      return 0;
    }
    return f[n] * mod::Inv(f[m] * f[n - m]);
  }

  MInt HCM(int n, int m) { return NCM(n + m - 1, m); }
};

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n + 1), indeces(n + 1, -1);
  int idx1, idx2;
  for (int i = 0; i < n + 1; ++i) {
    cin >> va[i];
    if (indeces[va[i]] < 0) {
      indeces[va[i]] = i;
    } else {
      idx1 = indeces[va[i]];
      idx2 = i;
    }
  }

  int cnt = idx1 + (n - idx2);
  BinCoef bc(n + 1);

  for (int i = 1; i <= n + 1; ++i) {
    MInt ans = bc.NCM(n + 1, i) - bc.NCM(cnt, i - 1);
    cout << ans.Get() << '\n';
  }

  return 0;
}

Measured memory_bytes: 4820
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    string S;
    cin >> S;

    for(int i = 1;i < S.length();i++){
        if(S[i-1] == S[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << 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;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

const double pai = 3.141592653589793238;
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double si = abs((h/12+(m/60)/12) - m/60)*2*pai;
    double ans = a*a + b*b -2*a*b*cos(si);
    
     cout << fixed<< setprecision(11) << sqrt(ans) << endl;
    
    return 0;	
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

bool is_Prime(int x){
    if(x < 2)return false;
    else if(x == 2) return true;
    for(ll i = 2; i*i <= x; i++) if(x%i == 0) return false;
    return true;
}

signed main()
{   
    gearup;
    int n;cin>>n;
    for(int i=n;;i++){
        if(is_Prime(i)){
            out(i);
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// check if it is judged online
int a, b;
int main() {
	cin >> a >> b;
	if (a > 9 || a < 1 || b > 9 || b < 1) puts("-1");
	else cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 256