akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<int> v(N);
  rep(i,M){
    int x,y;cin >> x >> y;
    ++v[--x];
    ++v[--y];
  }
  rep(i,N)cout << v[i] << endl;
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

#define MAX 1000
#define VMAX 10001

int n,a[MAX],s;
int b[MAX],t[VMAX];

int min(int a,int b){
    if(a<b)return a;
    else return b;
}

int partition(int* a,int p,int r){
    int i,j,x,t;
    x=a[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(a[j]<=x){
            i++;
            t=a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    t=a[i+1];
    a[i+1]=a[r];
    a[r]=t;
    return i+1;
}

void quicksort(int* a,int p,int r){
    int q;
    if(p<r){
        q=partition(a,p,r);
        quicksort(a,p,q-1);
        quicksort(a,q+1,r);
    }
}

int solve(){
    int ans=0,v[MAX];
    for(int i=0;i<n;i++){
        b[i]=a[i];
        v[i]=0;
    }
    quicksort(b,0,n-1);
    for(int i=0;i<n;i++){
        t[b[i]]=i;
    }
    for(int i=0;i<n;i++){
        if(v[i])continue;
        int cur=i;
        int d=0;
        int m=VMAX;
        int an=0;
        while(1){
            v[cur]=1;
            an++;
            int e= a[cur];
            m=min(m,e);
            d+=e;
            cur=t[e];
            if(v[cur])break;
        }
        ans+=min(d+(an-2)*m,m+d+(an+1)*s);
    }
    return ans;
}

int main(void){

    scanf("%d",&n);
    s=VMAX;
    for(int  i=0;i<n;i++){
        scanf("%d",&a[i]);
        s=min(s,a[i]);
    }
    printf("%d\n",solve());

    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int a, b, c, x, ans = 0;
    std::cin >> a >>  b >> c >> x;

    for(int i = 0;i <= a * 500;i = i + 500){
        for(int j = 0;j <= b * 100;j = j + 100){
            for(int k = 0;k <= c * 50;k = k + 50){
                if (i + j + k == x){
                    ans++;
                }
            }
        }
    }

    std::cout << ans;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
INF = 1001001001
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]
H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = 0
for si in range(H):
    for sj in range(W):
        if S[si][sj] == '#': continue
        q = deque([(si, sj)])
        dist = [[INF] * W for _ in range(H)]
        dist[si][sj] = 0
        while q:
            i, j = q.popleft()
            for d in range(4):
                ni = i + di[d]
                nj = j + dj[d]
                if (ni<0 or ni>=H or nj<0 or nj>=W): continue
                if S[ni][nj] == '#': continue
                if dist[ni][nj] != INF: continue
                q.append((ni, nj))
                dist[ni][nj] = dist[i][j] + 1
        for i in range(H):
            for j in range(W):
                if dist[i][j] != INF:
                    ans = max(ans, dist[i][j])
print(ans)


Measured memory_bytes: 3316
N,K=list(map(int,input().split()))
l=[]
for i in range(N):
   l.append(list(map(int,input().split())))
l.sort()
import heapq
X=[]
S=0
ans=0
heapq.heapify(X)
for i in range(1,K+1):
   for j in range(S,N):
      if l[j][0]<=i:
         S+=1
         heapq.heappush(X,l[j][1]*-1)
      else:
         break
   try:
      tmp=heapq.heappop(X)
      ans+=tmp*-1
   except IndexError:
      continue
print(ans)

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

int k,ans=0;

int get_gcd(int a,int b)
{
	if (b==0)  return a;
	else return get_gcd(b,a%b);
}

int gcd(int a,int b)
{
	int x=a,y=b;
	return get_gcd(x,y);
}

signed main()
{
	cin>>k;
	for (int i=1;i<=k;i++)
	{
		for (int j=1;j<=k;j++)
		{
			for (int w=1;w<=k;w++)  ans+=gcd(gcd(i,j),w);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
/*ll get(ll *arr,ll low,ll high,ll n){
	int mid=low+(high-low)/2;
	if((mid==0 or arr[mid-1]<=arr[mid]) and (mid==(n-1) or arr[mid+1]<=arr[mid])){
		return arr[mid];
	}
	else if(mid>0 and arr[mid-1]>arr[mid]){
		return get(arr,low,mid-1,n);
	}
	else{
		return get(arr,mid+1,high,n);
	}
}*/
/*ll get(int *arr,int n,int left,int i){
	if(i==n){return 1;}
	int curr=arr[i];
	int right=get(arr,n,arr[i]*left,i+1);
	arr[i]=left*right;
	return curr*right;
}*/
ll get(str s){
	ll ans=0;
	for(auto i:s){
		ans+=(i-'0');
	}
	return ans;
}
void solve(){
	str n;cin>>n;
	ll c=get(n);
	if(c%9==0){cout<<"Yes";}
	else{cout<<"No";}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case #"<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3784
import java.util.ArrayDeque
import kotlin.math.max

fun main() {
    abc146d()
}

fun abc146d() {
    val n = readLine()!!.toInt()
    val edge = IntArray(n - 1) { 0 }
    val nodes = List(n + 1) { mutableSetOf<Int>() }
    val edgeOfNode = List(n + 1) { mutableSetOf<Int>() }
    var k = 0
    repeat(n - 1) { edgeId ->
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        nodes[a].add(b)
        nodes[b].add(a)
        edgeOfNode[a].add(edgeId)
        edgeOfNode[b].add(edgeId)
        val max_size = max(nodes[a].size, nodes[b].size)
        k = max(k, max_size)
    }
    val colorSet = (1..k).toSet()
    var start = 1
    while (nodes[start].size != 1) start++
    val visited = mutableSetOf<Int>()
    val nextNodes = ArrayDeque<Int>()
    nextNodes.add(start)
    while (visited.size < n) {
        val count = nextNodes.size
        for (i in 0 until count) {
            val from = nextNodes.poll()
            if (from in visited) continue
            visited.add(from)
            nextNodes.addAll(nodes[from])
            val paintEdge = mutableListOf<Int>()
            var usedColor = 0
            for (edgeId in edgeOfNode[from]) {
                if (edge[edgeId] == 0) {
                    paintEdge.add(edgeId)
                } else {
                    usedColor = edge[edgeId]
                }
            }
            for (e in paintEdge) {
                usedColor = nextColor(usedColor, k)
                edge[e] = usedColor
            }
        }
    }
    println(k)
    for (color in edge) {
        println(color)
    }
}

private fun nextColor(current: Int, k: Int): Int {
    val next = current + 1
    return if (next > k) 1 else next
}

Measured memory_bytes: 135608
import re
init = re.compile("([^[]+)\[([^=]+)\]$")
assign = re.compile("([^[]+)\[([^=]+)\]=(.+)$")
def evaluate(s):
    try:
        m = init.match(s)
        if m:
            name, expr = m.groups()
            return dic[name][evaluate(expr)]
        return eval(s)
    except:pass
    return -1
while 1:
    dic = {}
    sz = {}
    ans = 0
    idx = 0
    while 1:
        s = raw_input()
        if s == '.':
            break
        idx += 1
        m = init.match(s)
        if m:
            name, expr = m.groups()
            val = evaluate(expr)
            if val == -1:
                if ans == 0:
                    ans = idx
            else:
                dic[name] = {}
                sz[name] = val
        else:
            m = assign.match(s)
            name, expr, right = m.groups()
            i = evaluate(expr)
            val = evaluate(right)
            if i == -1 or val == -1 or name not in dic or sz[name]-1 < i:
                if ans == 0:
                    ans = idx
            else:
                dic[name][i] = val
    if not dic:
        break
    print ans

Measured memory_bytes: 6532
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<climits>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int
#define vll vector<ll>
#define mii map<ll, ll>
#define debug(x) cerr << #x << " is " << x << "\n";
#define debug1(x, y) cerr << #x << " is " << x << "\n" << #y << " is " << y << "\n";
#define w(x) ll x; cin >> x; while(x--)
#define endl "\n"
#define f first 
#define s second 
#define fo(n) for(ll i = 0LL; i < n; ++i) 
#define setbits(n) __builtin_popcount(n)
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(x.begin(), x.end())
#define pb push_back
#define mk make_pair
#define PERMUTE next_permutation
#define RESET(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
using namespace std;
 
int main(){
    fast
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vll> dp(n + 1, vll(m + 1, 0));
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(s[i - 1] == t[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } 
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    ll size = dp[n][m];
    vector<char> ans(size, ' ');
    while(n > 0 && m > 0) {
        if(s[n - 1] == t[m - 1]) {
            ans[size - 1] = s[n - 1];
            size--;
            n--; m--;
        }
        else if(dp[n - 1][m] > dp[n][m - 1]) {
            n--;
        }
        else {
            m--;
        }
    }
    
    for(char x: ans) 
        cout << x;

    return 0;
}

Measured memory_bytes: 73660
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<int,int>
#define maxn 1000009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    ll ans =0;
    if(a>12)ans=b;
    else if(a>=6 && a<=12)ans=b/2;
    else ans=0;
    cout<<ans<<endl;
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

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

using namespace std;

/*
 綺麗さ：ｂ
 おいしさ：ｄ
 人気度：ｐ
 それぞれ正負の8通りのいずれかで最大。各パターンでソートして上位M個加算でパターン別最大。
 そのうちのMAXが解
*/

typedef long long  ll;
typedef struct {
	ll val[8];
} S;

int Idx;

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

	vector <S> v;
	for (int i = 0; i < N; i++) {
		ll b, d, p;
		S s;
		cin >> b >> d >> p;
		s.val[0] =   b + d + p;
		s.val[1] =   b + d - p;
		s.val[2] =   b - d + p;
		s.val[3] =   b - d - p;
		s.val[4] = - b + d + p;
		s.val[5] = - b + d - p;
		s.val[6] = - b - d + p;
		s.val[7] = - b - d - p;
		v.emplace_back(s);
	}
	ll ans = 0;
	for (Idx = 0; Idx < 8; Idx++) {
		sort(v.begin(), v.end(), [](auto const& lhs, auto const& rhs) {return lhs.val[Idx] > rhs.val[Idx]; });
		ll sum = 0;
		for (int i = 0; i < M; i++) {
			sum += v[i].val[Idx];
		}
		ans = max(ans, sum);
	}
	cout << ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
bool visit[100010];
vector<int> graph[100010];
vector<int> path,path2;
 
void dfs(int t)
{
	visit[t]=true;
	path.push_back(t);
	for(int i=0;i<graph[t].size();i++)
	{
		if(visit[graph[t][i]]==false)
		{
			dfs(graph[t][i]);
			return;
			}
		}
	}	
 
int main()
{
	memset(visit,0,sizeof visit);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		}
	dfs(1);
	swap(path,path2);
	dfs(1);
	printf("%zd\n",path2.size()+path.size()-1);
	for(int i=path2.size()-1;i>=1;i--)
	{
		cout<<path2[i]<<" ";
		}
	for(int i=0;i<path.size();i++)
	{
		cout<<path[i]<<" ";
		}	
	cout<<endl;	
	return 0;
	}

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

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

   bool answered = false;
   for(int i=0;i<=n ;i++)
   {
       for(int j=0 ; j+i <= n ; j++)
       {
           if( y - (i* 10000 + j*5000) >=0 &&  (y == (i* 10000 + j*5000 + (n-i-j)*1000 ) )  )
           {
                cout<<i<<" "<<j <<" "<<n-i-j;
                answered = true;
                break;
           }
       }
       if( answered )
           break;
   }
   if( !answered )
   cout<<-1<<" "<<-1<<" "<<-1;

}

Measured memory_bytes: 3600
L, R = map(int, input().split())
res = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        if i*j%2019 == 0:
            res = 0
            break
        res = min(i*j%2019, res)
    if not res:
        break

print(res)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 100001;
vi g[N];
bool flag;

int dfs(int c, int p) {
  int cnt = 1;
  rep(i,0,g[c].size()) {
    int u = g[c][i];
    if(u != p) {
      cnt += dfs(u, c);
    }
  }
  if(cnt > 2) flag = true;
  return cnt % 2;
}

int main() {
  int n;
  S(n);
  rep(i,0,n-1) {
    int u,v;
    S2(u,v);
    g[u].pb(v);
    g[v].pb(u);
  }
  if(dfs(1,-1) || flag) {
    printf("First\n");
  } else {
    printf("Second\n");
  }
  return 0;
}


Measured memory_bytes: 5760
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

for i in range(36):
  if N < K**i:
    print(i)
    break

Measured memory_bytes: 5148
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);

ll toget(ll a) {
  if(a == 3) return 100000;
  if(a == 2) return 200000;
  if(a == 1) return 300000;
  return 0;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b;
  cin >> a >> b;
  ll ans= toget(a);
  ans+= toget(b);
  if(a == 1 and b == 1) {
    ans+= 400000;
  }
  cout << ans << endl;
  return 0;
} //good night.

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

#define int long long
#define pii pair<int, int>
#define pb push_back
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N){
        ans ++;
        N/=K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;



/////////////////////////////////////////////

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

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

////////////////////////////////

#define int long long


void solve(){

	int n;
	cin>>n;
	vector<double> a(n);

	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];
	double dp[n+2];
	for(int i = 0 ; i <= n ; ++i)
		dp[i] = 0;
	dp[0] = 1;
	for(int i = 0 ; i < n ; ++i){

		for(int j = i+1 ; j > 0 ; --j){

			dp[j] = dp[j-1]*a[i] + dp[j]*(1-a[i]);
		}
		dp[0]=dp[0]*(1-a[i]);
	}
	double ans = 0;
	for(int i = 0 ; i <= n; ++i){

		int t = n - i;

		if(i > t){
			//debug(i);
			//debug(dp[i]);
			ans += dp[i];
		}
	}

	cout<<fixed<<setprecision(15)<<ans<<endl;
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}






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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, m, a, b, c, d, e, cnt = 0, ans = 0, wa, ac;
   string s, v, sv[10010];
   vector<int> x, y, z;
   priority_queue<int> pr;
   priority_queue<int, vector<int>, greater<int>> gpr;

   cin >> n >> m;

   rep(i, n)
   {
      cin >> a;
      x.push_back(a);
   }

   sort(all(x));

   rep(i, (n - m + 1))
   {
      wa = abs(x[i] - x[i + (m - 1)]);
      gpr.push(wa);
   }

   cout << gpr.top() << '\n';
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n,d,ans=0,x,y;
	cin>>n>>d;
	for(int i=0; i<n; i++){
		cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> num(n);
    rep(i,n) cin >> num[i];
    sort(all(num));
    int ans = 1;
    int cnt = 1;
    
    for(int i = 1; i < n; i++){
        if(num[i-1] == num[i]){
            cnt++;
        }
        else{
            if(cnt%2 == 1){
                ans++;
            }
            cnt = 1;
        }
        if(i == n-1 && cnt%2 == 0) ans--;
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int cn = 0;
    int n = N;
    while(n > 0){
        cn += n % 10;
        n /= 10;
    }
    if(N % cn == 0){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int N, M; cin >> N >> M;

  priority_queue<ll> que;
  rep(i, N) {
    //que.pushで入れる
    ll A; cin >> A; que.push(A);
  }
  rep(i, M) {
    //que.pop()で取り除く
    ll t = que.top(); que.pop();
    que.push(t/2);  }
  
  ll res = 0;
  
  //queが空になるまでループを続ける
  while(!que.empty())  res+=que.top(), que.pop();
  cout << res << endl;
}

Measured memory_bytes: 1400
/*It is better to taste failure 
	  than to regret*/
		
            #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        void solve()
        {
        	int n;
        	cin>>n;
        	
        	int ans=0;
        	for(int i=1;i<n;i++)
        	{
        		ans+=(n-1)/i;
        	
			}
			cout<<ans<<endl;
		}
        signed main()
        {
        	//test();
        	solve();
		}

Measured memory_bytes: 3632
#include<stdio.h>
#include<bits/stdc++.h>
#include<iostream>
#define ll long long

using namespace std;
int main()
{
  ll n,k;
  cin>>n>>k;
  ll dp[n+1],h[n+1];
  for(ll i=1;i<n+1;i++)
    cin>>h[i];
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  h[0]=0;
  for(ll i=3;i<n+1;i++)
  {
    ll var=INT_MAX;
    for(ll j=1;j<=min(k,i-1);j++)
    {
      if(dp[i-j]+abs(h[i-j]-h[i])<var)
      {
        dp[i]=dp[i-j]+abs(h[i-j]-h[i]);
        var=dp[i];
      }
    }
  }
  cout<<dp[n];
  return 0;
}

Measured memory_bytes: 5144
S = input()

mae = S[0:2]
ush = S[2:4]

mon = {"01","02","03","04","05","06","07","08","09","10","11","12"}

if (mae in mon) and (ush in mon):
    print("AMBIGUOUS")
if (mae not in mon) and (ush in mon):
    print("YYMM")
if (mae in mon) and (ush not in mon):
    print("MMYY")
if (mae not in mon) and (ush not in mon):
    print("NA")


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

using namespace std;


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

	int a, b, i, j, k;
	string s;
	cin >> a >> b >> s;
	bool valid = true;
	if (s.length() != a + b + 1) valid = false;
	for (i = 0; i < s.length(); i++) {
		if ((i == a) && (s[i] != '-')) valid = false;
		if (((s[i] < '0') || (s[i] > '9')) && (i != a)) valid = false;
	}
	if (valid) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e9
int const MaxSize = 1e5 + 10;
int N, a[MaxSize];

bool good(int maxC) {
	int numUnique = 0;

	LP(i, 0, N)
	{
		if (a[i] == maxC - 1)
			numUnique++;
		else if (a[i] != maxC)
			return false;
	}

	int numDupC = maxC - numUnique;

	if (numDupC < 0)
		return false;

	int dupItems = N - numUnique;

	//cout << dupItems << " " << numDupC << endl;

	if (numDupC)
		return numDupC * 2 <= dupItems;
	else
		return dupItems == 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);

	cin >> N;

	LP(i, 0, N)
		cin >> a[i];

	sort(a, a + N);

	int maxC = a[N - 1];

	if (good(maxC) || good(maxC + 1)) {
		cout << "Yes";
	} else
		cout << "No";

	return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> v(n);
	for (size_t i = 0; i < v.size(); i++) {
		std::cin >> v[i];
	}

	// メモ化する
	// 前からの最大公約数と後ろからの最大公約数
	std::vector<int> gcd_before(n);
	std::vector<int> gcd_after(n);
	gcd_before[0] = v[0];
	gcd_after[n-1] = v[n-1];
	for (size_t i = 1; i < n; i++) {
		gcd_before[i] = gcd(gcd_before[i-1],v[i]);
		gcd_after[n-1-i] = gcd(gcd_after[n-i],v[n-1-i]);
	}

	// ans[i]はi番目の数を除いた場合の最大公約数
	std::vector<int> ans(n);
	ans[0] = gcd_after[1];
	ans[n-1] = gcd_before[n-2];
	for (size_t i = 1; i < ans.size()-1; i++) {
		ans[i] = gcd(gcd_before[i-1], gcd_after[i+1]);
	}

	int max_ans = ans[0];
	for (size_t i = 0; i < ans.size(); i++) {
		max_ans = max(ans[i], max_ans);
	}

	std::cout << max_ans << '\n';
	return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int n, v[100];
  string s;

  while(1) {
    cin >> n;
    if(!n) break;

    int field = 0;
    REP(i, n) v[i] = 0;
    cin >> s;

    REP(i, 100) {
      if(s[i] == 'M') v[i%n]++;
      else if(s[i] == 'S') {
	field += v[i%n] + 1;
	v[i%n] = 0;
      }
      else {
	v[i%n] += field + 1;
	field = 0;
      }
    }
    sort(v, v+n);
    REP(i, n)  cout << v[i] << ' ';
    cout << field << endl;
  }
}

Measured memory_bytes: 1228
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int a,b;

int main(){
	scanf("%d%d",&a,&b);
	if (a+b==15) printf("+\n");
	else if (a*b==15) printf("*\n");
	else printf("x\n");
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int c;
    int sum=0;
    int flag=0;
    for(int i=1;i<n;i++){
        c=0;
        flag=0;
        for(int j=1;j*j<=i;j++){
            if(i%j==0) c++;
            if(j*j==i) flag=1;
        }
        c*=2;
        if(flag) c--;
        sum+=c;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int n, a, b;

int main() {
    scanf("%d%d%d", &n, &a, &b);
    if (n < a + b - 1 || n > LL(a) * b) {
        puts("-1");
        return 0;
    }
    int tot = 0;
    for (int i = 1; i <= a; ++i) {
        int k = min(n - tot - a + i, b);
        for (int j = k; j; --j)
            printf("%d ", tot + j);
        tot += k;
    }
    puts("");
    return 0;
}

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

int main() {
    int n, k;
    int64_t ans = 0;
    priority_queue<int64_t> q;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        q.push(h);
    }
    for (int i = 0; i < k; i++)
        if (!q.empty()) q.pop();
    for (int i = 0; i < (n-k); i++) {
        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
typedef long long int LL;
typedef pair<int,int> P;

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(b >= a*c) cout << c << endl;
	else	cout << (int)b/a << endl;
	return 0;
}

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

main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d) cout<<"Left"<<"\n";
  else if(a+b==c+d)cout<<"Balanced"<<"\n";
  else  cout<<"Right"<<"\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;
ll dp[4][101010];

int main() {
  cin >> S;

  dp[3][0] = 1;

  for (int i = 1; i <= S.size(); ++i) {
    char ch = S[i - 1];
    if (ch == 'A') {
      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += (dp[0][i - 1] + dp[3][i - 1]) % MOD;
      dp[0][i] %= MOD;
      dp[1][i] += dp[1][i - 1];
      dp[1][i] %= MOD;
      dp[2][i] += dp[2][i - 1];
      dp[2][i] %= MOD;
    } else if (ch == 'B') {
      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += dp[0][i - 1];
      dp[0][i] %= MOD;
      dp[1][i] += (dp[1][i - 1] + dp[0][i - 1]) % MOD;
      dp[1][i] %= MOD;
      dp[2][i] += dp[2][i - 1];
      dp[2][i] %= MOD;
    } else if (ch == 'C') {
      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += dp[0][i - 1];
      dp[0][i] %= MOD;
      dp[1][i] += dp[1][i - 1];
      dp[1][i] %= MOD;
      dp[2][i] += (dp[2][i - 1] + dp[1][i - 1]) % MOD;
      dp[2][i] %= MOD;
    } else {
      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += (dp[0][i - 1] + dp[3][i - 1]) % MOD;
      dp[0][i] %= MOD;
      dp[1][i] += dp[1][i - 1];
      dp[1][i] %= MOD;
      dp[2][i] += dp[2][i - 1];
      dp[2][i] %= MOD;

      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += dp[0][i - 1];
      dp[0][i] %= MOD;
      dp[1][i] += (dp[1][i - 1] + dp[0][i - 1]) % MOD;
      dp[1][i] %= MOD;
      dp[2][i] += dp[2][i - 1];
      dp[2][i] %= MOD;

      dp[3][i] += dp[3][i - 1];
      dp[3][i] %= MOD;
      dp[0][i] += dp[0][i - 1];
      dp[0][i] %= MOD;
      dp[1][i] += dp[1][i - 1];
      dp[1][i] %= MOD;
      dp[2][i] += (dp[2][i - 1] + dp[1][i - 1]) % MOD;
      dp[2][i] %= MOD;
    }
  }

  cout << dp[2][S.size()] << endl;
}


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


struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> sizeb;
    vector<int> sizew;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        sizeb = vector<int>(N, 0);
        sizew = vector<int>(N, 0);
        
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            sizeb[x] += sizeb[y];
            sizew[x] += sizew[y];
        }
        else {
            parent[x] = y;
            sizeb[y] += sizeb[x];
            sizew[y] += sizew[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};


int main(){
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    unionfind uf(H*W);
    for (int i = 0; i < H; i++) cin >> grid[i];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++){
            if (grid[i][j] == '.') uf.sizew[W*i+j] = 1;
            else uf.sizeb[W*i+j] = 1;
        }
    }
    
    for (int i = 0; i < H-1; i++) {
        for (int j = 0; j < W; j++){
            if (grid[i][j] != grid[i+1][j]) {
                uf.unite(W*i+j, W*(i+1)+j);
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W-1; j++){
            if (grid[i][j] != grid[i][j+1]) {
                uf.unite(W*i+j, W*i+j+1);
            }
        }
    }
    
    ll ans = 0;
    for (int i = 0; i < H*W; i++) {
        if (uf.root(i) != i) continue;
        ans += (ll)uf.sizeb[i] * uf.sizew[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
const int N=200005;
int n;
long long a[N];
map<pair<int,int>,int>book;
int main()
{
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		double x;
		scanf("%lf",&x);
		a[i]=x*1e9+0.5;
		int cnt2=0,cnt5=0;
		while(a[i]%2==0) cnt2++,a[i]/=2;
		while(a[i]%5==0) cnt5++,a[i]/=5;
		for(auto [x,num]:book)
			if(x.first+cnt2>=18&&x.second+cnt5>=18) ans+=num;
		book[make_pair(cnt2,cnt5)]++;
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
    int n,f(0),ans(1),a(0),x;
    cin >> n;

    int h[n];

    for(int i=0;i<n;i++){
        cin >> x;
        h[i] = x;
    }

    a = h[0];

    for(int i=0;i<n;i++){
        if(a==2){
            cout << ans << endl;
            return 0;
        }else{
            a = h[a-1];
            ++ans;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
         
        int main(){
        	char s[4];
            gets(s);
          
            
          	if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){
            	printf("No");
            }else{
            	if(s[0]==s[1]){
            		if(s[2]==s[3]){
                		printf("Yes");
               		}else{
            			printf("No");
            		}
                }else if(s[0]==s[2]){
                    if(s[1]==s[3]){
                        printf("Yes");
                    }else{
                        printf("No");
                    }
                }else if(s[0]==s[3]){
                    if(s[1]==s[2]){
                        printf("Yes");
                    }else{
                        printf("No");
                    }
            	}else{
            		printf("No");
            	}
            }
            return 0;
        }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 1e5 + 5, MAXM = 3e4 + 5, BOUND = 2e5, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define R register
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, m, a[MAXN], b[MAXN], c[MAXN];
priority_queue<pii> q;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	rep(i, 1, n)cin >> a[i], q.push(pii(-a[i], 1));
	pii x;
	rep(i, 1, m) {
		cin >> b[i] >> c[i];
		int sum = 0;
		while (b[i] && -(q.top().first) < c[i]) {
			x = q.top(); q.pop();
			int y = min(x.second, b[i]);
			sum += y;
			x.second -= y; b[i] -= y;
			if (x.second)q.push(x);
		}
		q.push(pii(-c[i], sum));
	}
	ll ans = 0;
	while (q.size()) {
		x = q.top(); q.pop();
		ans += -(ll)x.first *x.second;
	}
	cout << ans << '\n';
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n, m;
	cin >>n >>m;
	VI h(n);
	rep(i, n) cin >>h[i];
	vector<VI> r(n);
	rep(i, m){
		int a, b;
		cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	int ans =0;
	rep(i, n){
		bool ok=1;
		for(auto w: r[i]) if(h[w] >= h[i]) ok=0;
		ans += ok;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 8724
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e3 + 123;
const int MAX_N = (int)2e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, q, dp[N], fact[MAX_N], inv[MAX_N];
pii r[N];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int C (int n, int k) {
   return mult (fact[n], mult (inv[k], inv[n - k]));
}

inline int calc (int x, int y) {
   return C (x + y, y);
}

inline int binpow (int a, int b) {
   int res = 1;
   while (b) {
      if (b & 1) res = mult (res, a);
      a = mult (a, a);
      b >>= 1;
   }
   return  res;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m >> q;
   n --, m --;
   fact[0] = inv[0] = 1;
   for (int i = 1; i < MAX_N; i ++) fact[i] = mult (fact[i - 1], i), inv[i] = binpow (fact[i], mod - 2);
   for (int i = 1; i <= q; i ++) cin >> r[i].F >> r[i].S, r[i].F --, r[i].S --;
   q ++;
   r[q] = {n, m};
   sort (r + 1, r + q + 1);
   for (int i = 1; i <= q; i ++) {
      dp[i] = calc (r[i].F, r[i].S);
      for (int j = 1; j < i; j ++) {
         if (r[j].F <= r[i].F && r[j].S <= r[i].S)
            dp[i] = add (dp[i], -mult (dp[j], calc (r[i].F - r[j].F, r[i].S - r[j].S)));
      }
   }
   cout << dp[q];
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

ll dig_sum(ll b, ll n) {
	if (b > n) {
		return n;
	}

	return (n%b) + dig_sum(b, n / b);
}


int main() {
	ll n, s;
	cin >> n >> s;
	if (s == n) {
		cout << n + 1 << endl;
	}
	else {
		bool isExist = false;
		for (ll i = 2; i * i <= n;i++) {
			if (dig_sum(i, n) == s) {
				isExist = true;
				cout << i << endl;
				break;
			}
			
		}
		
		if (!isExist && n > s) {
			ll min_b = BIG_NUM;
			for (ll i = 1; i*i < n && i <= n-s;i++) {
				ll b = (n - s) / i + 1;
				if (b < sqrt(n)) {
					break;
				}
				if (dig_sum(b, n) == s) {
					isExist = true;
					min_b = b;
					
				}
			}

			if (isExist) {
				cout << min_b << endl;
			}
			
		}

		if (!isExist) {
			cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,a[55],ans;
void solve(){
	rep(i,0,n-1){
		rep(j,i+1,n-1){
			ans += a[i] * a[j];
		}
	}
	cout << ans << endl;
} 
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,0,n-1) cin >> a[i];
	solve();		
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int a[200010],v1[200010],v2[200010];
int main(){
	n=r;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=1;i<=n;i+=2){
		v1[a[i]]++;
		v2[a[i+1]]++;
	}
	int max1,a1,max2,a2;max1=a1=max2=a2=0;
	for(rt i=1;i<=100000;i++){
		if(v1[i]>max1)max2=max1,a2=a1,max1=v1[i],a1=i;
		else if(v1[i]>max2)max2=v1[i],a2=i;
	}
	int max3,a3,max4,a4;max3=a3=max4=a4=0;
	for(rt i=1;i<=100000;i++){
		if(v2[i]>max3)max4=max3,a4=a3,max3=v2[i],a3=i;
		else if(v2[i]>max2)max4=v2[i],a4=i;
	}
	if(a1!=a3)cout<<n-max1-max3;
	else cout<<n-max(max1+max4,max2+max3);
	return 0;
}


Measured memory_bytes: 1408