akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void yoko(int w)
{
    printf("+");
    while (w >= 3){
        printf("-");
        w--;
    }
    printf("+\n");
}

void tate(int w)
{
    printf("|");
    while (w >= 3){
        printf(".");
        w--;
    }
    printf("|\n");
}

void center(int w, char *c)
{
    int i;
    
    printf("|");
    for (i = 0; i < (w - 3) / 2; i++){
        printf(".");
    }
    printf("%s", c);
    for (i = 0; i < (w - 3) / 2; i++){
        printf(".");
    }
    printf("|\n");
}

int main(void)
{
    int W, H;
    char c[2];
    int i;
    
    scanf("%d%d%s", &W, &H, c);
    
    yoko(W);
    for (i = 0; i < (H - 3) / 2; i++){
        tate(W);
    }
    center(W, c);
    for (i = 0; i < (H - 3) / 2; i++){
        tate(W);
    }
    yoko(W);
    
    return (0);
}



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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

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

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e2 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll dp[100010];
ll a[MAXN];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	ll mn = *min_element(a,a +n);
	for(int j =0;j<mn;j++) dp[j] = 1;
	
	for(int i = mn; i <= k; i++){
		dp[i] = 1;
		for(int j = 0;j<n;j++){
			if(a[j] <= i){
				if(dp[i - a[j]] == 1) dp[i] = 0;
			}
		}
	}
	
	cout << (dp[k] == 0 ? "First" : "Second");
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))
ll n,W;
ll w[101],v[101];
ll dp[101][100010];

ll maxValue(ll end, ll totalW)
{
  if(end==0||W==0)
  return 0;
  if(dp[end][totalW]!=-1)
  return dp[end][totalW];
  if(w[end-1]>totalW)
  return dp[end][totalW]=maxValue(end-1,totalW);
  return dp[end][totalW]=max(v[end-1]+maxValue(end-1,totalW-w[end-1]), maxValue(end-1,totalW));
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j;
    cin>>n>>W;
    for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
    mem(dp,-1);
    cout<<maxValue(n,W);
    return 0;
}

Measured memory_bytes: 82604
import numpy as np
from collections import defaultdict
dic = defaultdict(int)

n = int(input())
lis = list(list(map(int, input().split())) for _ in range(n))

ans = n
ant = 0

arrx = np.zeros((n, n))
arry = np.zeros((n, n))

for i in range(n):
    for j in range(n):

        arrx[i][j] = lis[i][0] - lis[j][0]
        arry[i][j] = lis[i][1] - lis[j][1]

        dic[(arrx[i][j], arry[i][j])] += 1

        if i != j:
            if ant < dic[(arrx[i][j], arry[i][j])]:
                ant = dic[(arrx[i][j], arry[i][j])]

ans -= ant

print(ans)

Measured memory_bytes: 12644
#include<bits/stdc++.h>
using namespace std;
#define INF 100000

struct edge { int to, cap, rev; };

vector<edge> G[101];
bool used[101];
int V,E;
int dfs(int v,int t,int f);
void AddEdge(int from,int to,int cap);
int MaxFlow(int s,int t);

int main(){
  cin >> V >> E;
  for(int i=0;i<E;i++){
    int a,b,c;
    cin >> a >> b >> c;
    AddEdge(a,b,c);
  }
  cout << MaxFlow(0,V-1) << endl;
}

void AddEdge(int from,int to,int cap){
  edge tmp;
  tmp.to = to; tmp.cap = cap; tmp.rev = G[to].size();
  G[from].push_back(tmp);
  tmp.to = from; tmp.cap = 0; tmp.rev = G[from].size() - 1;
  G[to].push_back(tmp);
}

int MaxFlow(int s,int t){
  int flow = 0;
  while(1){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int dfs(int v,int t,int f){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!(used[e.to]) && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

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

	vll ft(n, 0);
	auto add = [&ft,n](ll p, ll x) {
		for (ll k = p + 1; k <= n; k += k & -k) {
			ft[k - 1] += x;
		}
	};

	auto sum = [&ft](ll l, ll r) {
		ll ret = 0;
		for (ll k = r ; k > 0; k -= k & -k) {
			ret += ft[k-1];
		}
		for (ll k = l ; k > 0; k -= k & -k) {
			ret -= ft[k-1];
		}
		return ret;
	};


	rep(i,0, n) {
		ll a;
		cin >> a;
		add(i, a);
	}
	rep(i, 0, q) {

		ll t;
		cin >> t;
		if (t) {
			ll l, r;
			cin >> l >> r;
			cout << sum(l, r) << endl;
		}
		else {
			ll p, x;
			cin >> p >> x;
			add(p, x);
		}
	}

	return 0;
}


Measured memory_bytes: 8236
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-28 16:19:15
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

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

  if (any_of(all(d), [](int e){ return e == 0; })) {
    cout << 0 << endl; return 0;
  }
  
  if (n > 23) {
    cout << 0 << endl; return 0;
  }

  map<int, int> mp;

  for (int e : d) ++mp[e];

  if (any_of(mp.begin(), mp.end(), [](auto e){ return e.second >= 3; })) {
    cout << 0 << endl; return 0;
  }

  vector<int> t;
  t.emplace_back(0);

  int flag = 1;

  for (auto e : mp) {
    if (e.second == 1) {
      if (flag) {
        t.emplace_back(e.first);
      } else {
        t.emplace_back(24 - e.first);
      }
      flag ^= 1;
    } else {
      t.emplace_back(e.first);
      t.emplace_back(24 - e.first);
    }
  }

  int ans = (int)1e9;

  sort(all(t));
  debug(t);

  for (int i = 0; i < (int)t.size() - 1; ++i) ans = min(ans, t[i + 1] - t[i]);
  ans = min(ans, 24 - t.back());

  cout << ans << endl;

  return 0;
}


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

int a[5][5];
map<int,bool>mp;
int main()
{
    int n,val;

    for(int i=1; i<=3; i++)
    {
        for(int j=1; j<=3; j++)
            cin>>a[i][j];
    }
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>val;
        mp[val]=true;
    }
    int cnt;
    for(int i=1; i<=3; i++)
    {
        cnt=0;

        for(int j=1; j<=3; j++)
            if(mp[a[i][j]])
                cnt++;
        if(cnt==3)
        {
            puts("Yes");
            return 0;
        }
    }
    for(int i=1; i<=3; i++)
    {
        cnt=0;

        for(int j=1; j<=3; j++)
            if(mp[a[j][i]])
                cnt++;
        if(cnt==3)
        {
            puts("Yes");
            return 0;
        }
    }
    cnt=0;

    for(int i=1; i<=3; i++)
    {
        if(mp[a[i][i]])
            cnt++;
    }
    if(cnt==3)
    {
        puts("Yes");
        return 0;
    }
    cnt=0;
    for(int i=1; i<=3; i++)
    {
        if(mp[a[i][3-i+1]])
            cnt++;
    }
    if(cnt==3)
    {
        puts("Yes");
        return 0;
    }
    puts("No");


}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define MOD 13
#define MOD_ANS 1000000007

int main(void){
    char s[N];
    static unsigned long long int memo[N][13] = {};
    int i,j,ki,n,c,base;
    
    scanf("%s", s);
    
    i = -1;
    while(s[++i] != '\0'){
        //printf("%d %c\n", i, s[i]);
    }
    //printf("n:%d\n", i);
    
    n = i;//nは文字列の長さ
    
    memo[0][0] = 1;
    base = 1;
    for(i = n; i > 0; i--){
        //printf("s[i-1]:%c ", s[i-1]);
        if(s[i-1] == '?'){
            ki = 0;
            for(ki = 0; ki <= 9; ki++){
                for(j = 0; j < MOD; j++){
                    memo[n-i+1][(ki * base + j) % MOD] += memo[n-i][j];
                }
            }
            
        }else{
            c = s[i-1] - '0';
            for(j = 0; j < MOD; j++){
                memo[n-i+1][(c * base + j) % MOD] += memo[n-i][j];
                
            }
        }
        
        //puts("OK");
        base *= 10;
        base %= MOD;
        
        for(j = 0; j < MOD; j++){
            memo[n-i+1][j] %= MOD_ANS;
            //printf("m[%d][%d]:%d ", n-i+1, j, memo[n-i+1][j]);
        }
        //printf("i:%d\n", i);
    }
    
    printf("%llu\n", memo[n][5]);
    
    return 0;
}

Measured memory_bytes: 10368
import math
while(1):
	a=0
	n=int(input())
	if n==0: break;
	s=list(map(int,input().split()))
	m=sum(s)/len(s)
	for i in range(n):
		a=a+pow(s[i]-m,2)
	print(math.sqrt(a/n))

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

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  rep(i,2){
    if (a<b) {
      ans += b;
      b--;
    }else{
      ans += a;
      a--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};
long long N,M;
vector<long long>X(100006,0);
bool isOK(long long time){
	long right=0;
	for(int i=0;i<M;i++){
		if(right>=X[i]-1){
			//go right
			right=X[i]+time;
		}else{
			if(right < X[i]-time-2)return false;
			right=max(X[i],X[i]+(time-(2*(X[i]-right)-1)));
		}
		//cout<<right<<endl;
	}
	if(right<N-1)return false;
	return true;
	
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	vector<bool>ex(N+1,false);
	vector<long long>d(N+1,INF);
	vector<pair<long long,long long>>G[N+1];
	
	for(int i=0;i<N-1;i++){
		long long a,b,w;
		cin>>a>>b>>w;
		G[a].push_back(make_pair(b,w));
		G[b].push_back(make_pair(a,w));
	}
	long long K,Q;
	cin>>Q>>K;
	d[K]=0;
	stack<long long>que;
	que.push(K);
	while(!que.empty()){
		long long u=que.top();
		que.pop();
		long long size=G[u].size();
		ex[u]=true;
		for(int i=0;i<size;i++){
			long long v=G[u][i].first;
			if(ex[v]==false){
				d[v]=d[u]+G[u][i].second;
				que.push(v);
			}
		}
	}
	/*for(int i=1;i<=N;i++)cout<<i<<" "<<d[i]<<endl;*/
	
	for(int q=0;q<Q;q++){
		long long x,y;
		cin>>x>>y;
		cout<<d[x]+d[y]<<endl;
	}
}


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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  ll N;
  cin >> N;
  string ans="No";
  rep(i,9)rep(j,9) if((i+1)*(j+1)==N)ans="Yes";
  
  cout << ans << endl;
  
  return 0;
}


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

int main() {
  int N;
  std::cin >> N;
  std::vector<std::vector<int>> a(N + 3, std::vector<int>(N + 3, 0));
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      std::cin >> a[i][j];

  int mod = 1000000007;

  std::vector<std::vector<long long>> dp(
      N + 3, std::vector<long long>((1 << N) + 3, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k < 1 << N; ++k) {
      int c = 0;
      for (int j = 0; j < N; ++j)
        if (k & (1 << j))
          c += 1;
      if (c != i)
        continue;

      for (int j = 0; j < N; ++j) {
        if (k & (1 << j))
          continue;
        dp[i + 1][k | (1 << j)] += a[i][j] * dp[i][k];
        dp[i + 1][k | (1 << j)] %= mod;
      }
    }
  }
  std::cout << dp[N][(1 << N) - 1] << std::endl;
}


Measured memory_bytes: 409984
#include <stdio.h>
#define H 250
int main() {
  int n,h,i,m,l,z;
  int key[H];
  scanf("%d",&h);
  for(i=1;i<=h;i++)scanf("%d",&key[i]);
  for(i=1;i<=h;i++){
    if(i==1)printf("node 1: key = %d, ",key[i]);
    else printf("node %d: key = %d, parent key = %d, ",i,key[i],key[i/2]);
    if(h/2 >= i)printf("left key = %d, ",key[2*i]);
    if((2*i + 1) <= h)printf("right key = %d, ",key[2*i+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2112
/*
ID: htc9811
LANG: C++
TASK: 
*/

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
#include<stack>
#include<ctime>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<cctype>
#include<bitset>
#include<list>
using namespace std;

int n,ans;
string s[305];

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<n;i++){
		bool ok=true;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				int rj1=(k+n-i)%n,rj2=(j+n-i)%n;
				if(s[j][rj1]!=s[k][rj2]){
//					cout<<i<<" "<<j<<" "<<k<<endl;
					ok=false;
					break;
				}
			}
			if(!ok) break;
		}
		if(ok) ans++;
	}
	cout<<ans*n<<endl;
	return 0;
}

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

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

  ll Li_2 = 2, Li_1 = 1;
  ll Li;
  if(N == 0)
    Li = 2;
  if(N == 1)
    Li = 1;
  for(int i = 2; i <= N; i++){
    
    Li = Li_1 + Li_2;
    Li_2 = Li_1;
    Li_1 = Li;
  }
  cout << Li << endl;
}


Measured memory_bytes: 256
import heapq as hq

n,k = map(int,input().split())
a = list(map(int,input().split()))

cnt = [0]*n

a_sum = sum(a)
for i in range(n):
    cnt[i] = k*a[i]//a_sum

cnt_sum = sum(cnt)
r = k - cnt_sum
l = []

for i in range(n):
    hq.heappush(l, (-a[i]/(cnt[i]+1), i))

for _ in range(r):
    x,i = hq.heappop(l)
    cnt[i] += 1
    hq.heappush(l, (-a[i]/(cnt[i]+1), i))

x,i = hq.heappop(l)
print(int(x // 1 * -1))


Measured memory_bytes: 111776
#include <stdio.h>
#include <string.h>
#define MAX 1500000
#define N -100000
  
int size = 1;

int parent(int i) {
  return i/2;
}
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i + 1;
}
  
void mheapi(int *A, int i) {
  int l = left(i);
  int r = right(i);
  int lar;
  
  if (l <= size && A[l] > A[i]) {
    lar = l;
  } else {
    lar = i;
  }
  if (r <= size && A[r] > A[lar]) {
    lar = r;
  }
  
  if (lar != i) {
    r = A[lar];
    A[lar] = A[i];
    A[i] = r;
  
    mheapi(A, lar);
  }
}
  
void heapkey(int *A, int i, int key) {
  if (key < A[i]) {
    return;
  }
  
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    key = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = key;
    i = parent(i);
  }
}
    
void ins(int *A, int key) {
  size++;
  A[size] = N;
  heapkey(A, size, key);
}

int getM(int *A) {
  if (size < 1) {          
    return -1;
  }
  
  int m = A[1];
  A[1] = A[size];
  size--;
  mheapi(A, 1);
  return m;
}
int main(void) {
  int key;
  int ary[MAX];
  char order[10];
  int m;
  
  while (1) {
    scanf("%s %d", order, &key);
    if (order[0] == 'i') {
      ins(ary, key);
    } else if (order[1] == 'x') {
      m = getM(ary);
      printf("%d\n", m);
    } else {
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4696
#include<stdio.h>

int main(void){
    char str[10];

    scanf("%s", str);

    for (int i = 0; i < 3; i++) {

        if (str[i] == str[i+1]) {
            printf("Bad");
            break;
        } else if (i == 2) {
            printf("Good");
        }

    }

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    string s; cin >> s;
    rep(i,s.size()){
        if(s[i] <= 'Z' - n)s[i] = s[i] + n;
        else s[i] = 'A' + (n - ('Z' - s[i])-1);
    }
    OUT(s);

    return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100+10;
const int inf=0x3f3f3f3f;

int n,a[N];

int main() {
	n=read(); int sum=0;
	for (int i=1;i<=n;++i) a[i]=read(),sum+=a[i];
	if (sum%10) printf("%d\n",sum);
	else {
		int mn=inf;
		for (int i=1;i<=n;++i)
			if (a[i]%10) mn=min(mn,a[i]);
		if (mn==inf) puts("0");
		else printf("%d\n",sum-mn);
	}
	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);

    set < int > st;
    for(int i = 0 ; i < n ; i ++){
            int x; scanf("%d" , &x);
            st.insert(x);
    }

    if(st.size() == n){
            printf("YES\n");
    }
    else {
            printf("NO\n");
    }


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 9600
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int[] max = new int[n];
    max[0]=arr[0];
    for(int i=1;i<n;i++){
      max[i]=Math.max(max[i-1],arr[i]);
    }
    long sum =0;
    for(int i=0;i<n;i++){
      sum+=max[i]-arr[i];
    }
    System.out.println(sum);
  }
}

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

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

    vector<char> ch = {'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'};
    for(char c: S){
        rep(i,ch.size()){
            if(ch.at(i)==c) cout << ch.at((i+N)%ch.size());
        }
    }
    cout << endl;
}   

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

int main(int argc, char **argv)
{
	vector<ll> v(3); cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end(), [](auto &a , auto &b)
							 {
								 return a%2 < b%2;
							 });


	ll res{0};
	if (v[0]%2 == v[1]%2 && v[1]%2 != v[2]%2)
	{
		++v[0], ++v[1];
		++res;
	}
	else if (v[0]%2 != v[1]%2 && v[1]%2 == v[2]%2)
	{
		++v[1], ++v[2];
		++res;
	}

	sort(v.begin(), v.end());
	res += (v[2] - v[1]) / 2;
	res += (v[2] - v[0]) / 2;
	std::cout << res << std::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;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N), A_sum(N + 1);
    A_sum[0] = 0;
    REP(i, N) {
        cin >> A[i];
        A_sum[i + 1] = A_sum[i] + A[i];
    }

    map<int, int> m;
    ll result = 0;
    REP(j, N + 1) {
        result += m[(A_sum[j] - j) % K];
        ++m[(A_sum[j] - j) % K];
        if (j - (K - 1) >= 0) {
            --m[(A_sum[j - (K - 1)] - (j - (K - 1))) % K];
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<math.h>
int main(void){
    int a,b,c,d,e,i;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    if(a<b){
        i=a;
        a=b;
        b=i;
    }
    if(a<c){
        i=a;
        a=c;
        c=i;
    }
    if(a<d){
        i=a;
        a=d;
        d=i;
    }
    if(a<e){
        i=a;
        a=e;
        e=i;
    }
    if(b<c){
        i=b;
        b=c;
        c=i;
    }
    if(b<d){
        i=b;
        b=d;
        d=i;
    }
    if(b<e){
        i=b;
        b=e;
        e=i;
    }
    if(c<d){
        i=c;
        c=d;
        d=i;
    }
    if(c<e){
        i=c;
        c=e;
        e=i;
    }
    if(d<e){
        i=d;
        d=e;
        e=i;
    }
    printf("%d %d %d %d %d\n",a,b,c,d,e);
    return 0;
}

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

using namespace std;

int main()
{
	const int MIN = -1000000;
	const int MAX = 1000000;
	int K, X;
	cin >> K >> X;
	int min = (X-K+1 < MIN) ? MIN : X-K+1;
	int max = (X+K-1 > MAX) ? MAX : X+K-1;
	for (int i=min; i <= max; i++) {
		cout << i << " ";
	}

	return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;
int mod = 1000000007;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    set<string> st;
    char last;
    rep(i, N){
        string S; cin >> S;
        if(i > 0){
            if(S[0] != last){
                cout << "No" << endl;
                return 0;
            }
        }
        last = S.back();
        if(st.count(S) == 1){
            cout << "No" << endl;
            return 0;
        }
        else st.insert(S);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll w=0,r=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            w++;
        }
        else
        {
            r++;
        }
    }
    ll i=0,j=n-1,c=0;
    while(i<j)
    {
        if(s[i]=='W')
        {
            if(s[j]=='R')
            {
                c++;
                // s[j]="W";
                // s[i]="R";
                j--;
                i++;
            }
            else
            {
                j--;
            }
        }
        if(s[i]=='R')
        {
            i++;
        }
    }
    cout<<c;
}
 

Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    vector<int> y;
    for(int i=1;i<=min(A,B);i++){
        if(A%i==0 && B%i==0) y.push_back(i);
    }
    cout<<y[y.size()-K]<<endl;
    return 0;
}

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

using namespace std;

#define ll long long
typedef vector<ll> vi;

ll Len[51],Pat[51];

ll make_bager(ll k, ll x){
    ll ans = 0;
    if(x == Len[k]) return Pat[k];

    // 下のバン
    x--;
    // 下のk-1バーガー
    if(x > 0){
        ll l = min(x, Len[k-1]);
        ans += make_bager(k-1, l);
        x -= l;
    }
    // 真ん中のパティ
    if(x > 0){
        ans++;
        x--;
    }
    // 上のk-1バーガー
    if(x > 0){
        ll l = min(x, Len[k-1]);
        ans += make_bager(k-1, l);
        x -= l;
    }
 
    return ans;
}

int main(){
    ll N, X;
    Len[0] = Pat[0] = 1;

    cin >> N >> X;
    for(ll i = 1; i <= N; i++){
        Len[i] = Len[i-1] * 2 + 3;
        Pat[i] = Pat[i-1] * 2 + 1;
    }

    cout << make_bager(N,X) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    if(N == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << pow(N, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, i;
    int  count = 0;

    scanf("%d %d %d", &a, &b, &c);

    for(i = a; i <= b; i++)
    {
        if(c % i == 0)
        {
            count = count + 1;
        }
    } 

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2728
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
import numpy as np


def read():
    x = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    return x,


def solve(x):
    return np.argmin(x) + 1


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 26916
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 300001;


struct data{
  string s;
  int p,i;
  data():s(""), p(0), i(0){};
  data(string s_, int p_, int i_) : s(s_),p(p_), i(i_){};
  bool operator < (data other) const {
	if(s==other.s)
		return p>other.p;
    return s < other.s;
  }
};


int arr[MAX_N];
data ss[101];
int main()
{
        init_io();
        int n;
        cin>>n;
        rep(i,0,n){
        cin>>ss[i].s>>ss[i].p;
        ss[i].i=i+1;
        }
        sort(ss,ss+n);
        rep(i,0,n)
            cout<<ss[i].i<<endl;
        return 0;
        
}


Measured memory_bytes: 256
def main():
    a, b = input().split()
    a = int(a)
    b = int(b)


    sa = b - a

    lst =[0]

    for i in range(1,1000):
        lst.append(lst[-1]+i)

    print(lst[sa] - b)



if __name__ == "__main__":
        main()


Measured memory_bytes: 3060
#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(){
    string s;
    int k;
    cin>>s>>k;
    int n=s.size();
    s=s+s;
    int cnt1=0,cnt2=0;
    bool same=true;
    rep(i,n-1)if(s[i]!=s[i+1])same=false;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            s[i+1]='.';
            cnt1++;
        }
    }
    for(int i=n-1; i<2*n-1; ++i){
        if(s[i]==s[i+1]){
            s[i+1]='.';
            cnt2++;
        }
    }
    if(!same)cout<<(ll)cnt2*(k-1)+cnt1<<endl;
    else cout<<(ll)n*k/2<<endl;
    return 0;
}

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

struct unknown {};
struct parse_error {};

typedef string::const_iterator Iterator;

map<string,int> env;

int number(Iterator& it, const Iterator& last)
{
  if (!isdigit(*it)) {
    return 1;
  }
  int n = 0;
  while (it != last && isdigit(*it)) {
    n = 10*n + (*it - '0');
    ++it;
  }
  return n;
}

int atom(Iterator& it, const Iterator& last)
{
  if (!isupper(*it)) {
    throw parse_error();
  }
  string name = string(1, *it);
  ++it;
  while (it != last && islower(*it)) {
    name += *it;
    ++it;
  }
  map<string,int>::const_iterator jt = env.find(name);
  if (jt == env.end()) {
    throw unknown();
  } else {
    return jt->second;
  }
}

int molecule(Iterator& it, const Iterator& last)
{
  int ans = 0;
  while (it != last && (*it == '(' || isupper(*it))) {
    if (*it == '(') {
      ++it;
      int r = molecule(it, last);
      if (*it != ')') {
        throw parse_error();
      }
      ++it;
      int n = number(it, last);
      ans += n*r;
    } else {
      int r = atom(it, last);
      if (it != last) {
        int n = number(it, last);
        ans += n*r;
      } else {
        ans += r;
      }
    }
  }
  return ans;
}

int main()
{
  string line;
  while (cin >> line && line != "END_OF_FIRST_PART") {
    int n;
    cin >> n;
    env.insert(make_pair(line, n));
  }

  while (cin >> line && line != "0") {
    try {
      Iterator it = line.begin(), last = line.end();
      cout << molecule(it, last) << endl;
    } catch (const unknown&) {
      cout << "UNKNOWN" << endl;
    }
  }
  return 0;
}

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

int main()
{
	int A, B, C, D;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	if (A > B)
		A = B;

	if (C > D)
		C = D;

	cout << C+A << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll n;
bool isPrime(ll n) {
    if(n == 2)
        return true;

    for(int i = 2;i <= sqrt(n);i++) {
        if(n % i == 0)
            return false;
    }
    return true;
}
int main(){
    cin >> n;

    vector<ll> v;
    ll m = 6;
    while(v.size() < n) {
        if(isPrime(m)) {
            v.pb(m);
        }
        m += 5;
    }
    REP(i,v.size()) {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        x: usize,
        n: usize,
        p: [usize; n],
    }
    let mut dp = vec![true; 103];
    for i in 0..n {
        dp[p[i]] = false;
    }

    for i in 0..102 {
        if i <= x && dp[x - i] {
            println!("{}", x - i);
            break;
        }

        if dp[x + i] {
            println!("{}", x + i);
            break;
        }
    }
}

// #[allow(unused_imports)]
// use proconio::{fastout, input, marker::*};

// #[fastout]
// fn main() {
//     input! {
//         x: usize,
//         n: usize,
//         p: [usize; n],
//     }
//     let mut ans = if n == 0 { x } else { 1000 };

//     for i in (0..x).rev() {
//         if 0 < p.iter().filter(|&&l| l == i).count() {
//             continue;
//         }
//         ans = i;
//         break;
//     }

//     for i in x..101+1 {
//         if 0 < p.iter().filter(|&&l| l == i).count() {
//             continue;
//         }
//         if ans <= x {
//             if x - ans == i - x {
//                 break;
//             }

//             if x - ans < i - x {
//                 break;
//             }
//         }

//         ans = i;
//         break;
//     }

//     println!("{}", ans);
// }


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  for (ll h = 1; h <= 3500; h++) {
    for (ll n = 1; n <= 3500; n++) {
      ll x = 4 * h * n - N * (n + h);
      ll y = N * h * n;
      if (x > 0 && y % x == 0) {
	cout << h << " " << n << " " << y / x << endl;
	return 0;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll long long
#define dl double

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    	cin>>n;
    	ll arr[n];
    for(ll i=0;i<n;i++){
    	cin>>arr[i];
    }
    ll ans=0;
    for(ll i=1;i<n;i++){
    	if(arr[i-1]>=arr[i]){
    		ans+=arr[i-1]-arr[i];
    		ll temp=arr[i-1]-arr[i];
    		arr[i]=arr[i]+temp;
    		temp=0;
    	}
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5172
import sys

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def nC2(n):
    return n * (n-1) // 2

n,k = get_nums_l()
aaa = get_nums_l()

negatives = []
zeros = 0
positives = []

for a in aaa:
    if a == 0:
        zeros += 1
    elif a > 0:
        positives.append(a)
    else:
        negatives.append(a)

# 絶対値小さい順
positives.sort()
negatives.sort(reverse=True)

len_positives = len(positives)
len_negatives = len(negatives)

# 要素の個数から、ペアの積を負,0,正に分けた場合の個数を数える
p_zeros = zeros*(len_negatives+len_positives) + nC2(zeros)
p_positives = nC2(len_positives) + nC2(len_negatives)
p_negatives = len_positives * len_negatives

if p_negatives < k <= (p_negatives+p_zeros):
    # ゼロの場合
    print(0)
    exit()

if k <= p_negatives:
    # 負の場合
    nokori = k

    left = -1 * ((10**9)**2 + 1)
    right = -1

    # 積がcenter未満になるペアがnokori個未満になる最大のcenterを探す
    while left < right:
        center = (left+right+1) // 2

        left2 = len_positives-1
        right2 = len_negatives-1

        count = 0

        # 正の数と負の数を掛けてcenter未満になる個数を数える
        while right2 > 0 and positives[left2] * negatives[right2] < center:
            right2 -= 1

        while 0<=left2<len_positives and 0<=right2<len_negatives:
            if positives[left2] * negatives[right2] < center:
                count += len_negatives - right2
                left2 -= 1
            else:
                right2 += 1

        if count < nokori:
            left = center
        else:
            right = center - 1
    print(left)
    exit()

# 正の場合
nokori = k - p_negatives - p_zeros

left = 1
right = (10**9)**2 + 1

# 積がcenter未満になるペアがnokori個未満になる最大のcenterを探す
while left < right:
    center = (left+right+1) // 2

    left2 = 0
    right2 = len_positives-1

    count = 0

    # 正の数同士で掛けてcenter未満になる個数を数える
    while left2 < right2:
        if positives[left2] * positives[right2] < center:
            count += right2 - left2
            left2 += 1
        else:
            right2 -= 1

    left2 = 0
    right2 = len_negatives-1

    # 負の数同士で掛けてcenter未満になる個数を数える
    while left2 < right2:
        if negatives[left2] * negatives[right2] < center:
            count += right2 - left2
            left2 += 1
        else:
            right2 -= 1

    if count < nokori:
        left = center
    else:
        right = center-1
print(left)


Measured memory_bytes: 95664
#include<iostream>
using namespace std; // 575

int main() {
	int N, M, C, A, B[20], ans = 0;
	cin >> N >> M >> C;
	for (int i = 0;i < M;++ i) cin >> B[i];
	for (int i = 0;i < N;++ i) {
		int sum = C;
		for (int i = 0;i < M;++ i) {
			cin >> A;
			sum += A * B[i];
		}
		if (sum > 0) ++ ans;
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ、ところでこの問題設定ってマラソンマッチか？
*/

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

int main() {
    int N, p, sum = 0;
    cin >> N;

    int maxp = 0;
    for (int i = 0; i < N; i++) {
        cin >> p;
        sum += p;
        if (p > maxp) maxp = p;
    }

    cout << sum - maxp / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,w[105],ans=100000;
main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>w[i];
    for(int i=1;i<n;i++){
        int sum=0,sum2=0;
        for(int j=1;j<=i;j++)sum+=w[j];
        for(int k=i+1;k<=n;k++)sum2+=w[k];
        if(abs(sum-sum2)<ans)ans=abs(sum-sum2);
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int h, w;
	cin >> h >> w;

	for (int i = 0; i <= w + 1; i++)
		cout << "#";
	cout << endl;

	char cell;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j <= w + 1; j++) {
			if (j == 0 || j == w + 1)
				cout << "#";
			else {
				cin >> cell;
				cout << cell;
			}
		}
		cout << endl;
	}
	
	for (int i = 0; i <= w + 1; i++)
		cout << "#";
	cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main(void) {
  int H, W; cin >> H >> W;
  VS board(H); REP(h, H) cin >> board[h];

  int dp[H][W];
  dp[0][0] = board[0][0] == '#';
  FOR(w, 1, W) dp[0][w] = dp[0][w-1] + (board[0][w] == '#' && board[0][w] != board[0][w-1]);
  FOR(h, 1, H) dp[h][0] = dp[h-1][0] + (board[h][0] == '#' && board[h][0] != board[h-1][0]);

  FOR(h, 1, H) FOR(w, 1, W) {
    dp[h][w] = min(
      dp[h][w-1] + (board[h][w] == '#' && board[h][w] != board[h][w-1]),
      dp[h-1][w] + (board[h][w] == '#' && board[h][w] != board[h-1][w])
    );
  }

  cout << dp[H-1][W-1] << endl;

  return 0;
}


Measured memory_bytes: 888
from itertools import accumulate
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] + list(accumulate(A))
    C = Counter(B)
    ans = 0
    for i in C.values():
        ans += i * (i - 1) // 2

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 145240
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;

const int N = 200001;

int n;
int a[N], ans[N];
vector<int>g[N];
vector<int>dp;

void dfs(int u, int p){
    int pos = lower_bound(all(dp), a[u]) - dp.begin();
    int val = dp[pos];
    dp[pos] = a[u];
    ans[u] = lower_bound(all(dp), 1e9) - dp.begin() - 1;
    for(int v:g[u]){
        if(v != p)
            dfs(v, u);
    }
    dp[pos] = val;
}

int main(){
    IOS

    cin >> n;
    FOR(i,1,n){
        cin >> a[i];
    }
    FOR(i,1,n-1){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dp = vector<int>(n+1,1e9);
    dp[0] = 0;
    dfs(1, 0);
    FOR(i,1,n){
        cout << ans[i] << endl;
    }

    return 0;
}

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



int main(){
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == 'C'&&s[j] == 'F') {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3632