akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define endl '\n'

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

void solve() {
	int n; cin >> n;
	map <string, int> m;
	while (n--) {
		string s; cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;

	return ;
}

int32_t main() {

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

	//int t;cin>>t;while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
while(cin>>xa1){
cin>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2;
if(xa2<xb1){cout<<"NO"<<endl;;continue;}
else if(xb2<xa1){cout<<"NO"<<endl;;continue;}
else if(ya2<yb1){cout<<"NO"<<endl;;continue;}
else if(yb2<ya1){cout<<"NO"<<endl;;continue;}
cout<<"YES"<<endl;
}
return 0;
}

Measured memory_bytes: 1216
import sys


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.p = [i for i in range(n + 5)]
        self.rank = [0 for i in range(n + 5)]

    def find_set(self, x):
        if self.p[x] != x:
            self.p[x] = self.find_set(self.p[x])
        return self.p[x]

    def unite(self, x, y):
        px, py = self.find_set(x), self.find_set(y)
        if px == py:
            return
        if self.rank[px] > self.rank[py]:
            self.p[py] = px
        else:
            self.p[px] = py
            if self.rank[px] == self.rank[py]:
                self.rank[py] += 1


def main():
    sys.setrecursionlimit(int(1e5))
    nvertices, nedges = map(int, input().split())
    E = []
    uf = UnionFind(nvertices)
    for i in range(nedges):
        s, t, w = map(int, input().split())
        E.append((w, s, t))
    E.sort()

    ans = 0
    for w, s, t in E:
        if uf.find_set(s) != uf.find_set(t):
            ans += w
            uf.unite(s, t)

    print(ans)


main()

Measured memory_bytes: 25780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tc = 1;
    //cin >> t;
    while(tc--)
    {
        string s, t;
        cin >> s >> t;
        int sz = s.size();
        bool check = true;
        for(int i = 0; i < sz; ++i){
            if(s[i] != t[i]){
                check = false;
                break;
            }
        }
        if(check)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    li a,b;
    cin>>a>>b;
    if(a<=0&&b>=0) cout<<"Zero\n";
    else if(a>0) cout<<"Positive\n";
    else {
        if((b-a)%2==0) cout<<"Negative\n";
        else cout<<"Positive\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n, m;
    cin >> n >> m;
    ll sum = 0;
    for (ll i = 0; i < m; i++) {
        ll a;
        cin >> a;
        sum += a;
    }
    if (sum > n) {
        cout << -1 << '\n';
    } else {
        cout << n - sum << '\n';
    }


}

Measured memory_bytes: 3624
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int K;
    cin >> K;
    string s;
    cin >> s;
    vector<int> V(K);
    int west = 0;
    int east = 0;
    for (int i = 1; i < s.size(); i++) {
      if (s[i -1] == 'W') {
        west++;
      }
      V[i] = west;
    }
    for (int i = s.size() - 2; i >= 0; i--) {
      if (s[i + 1] == 'E') east++;
      V[i] += east;
    }
    sort(V.begin(), V.end());
    cout << V[0] << endl;
}


Measured memory_bytes: 1796
o=input()
e=input()
n=len(o)
m=len(e)
ans=[]
for i in range(m):
  ans.append(o[i])
  ans.append(e[i])
if n-m==0:
  print(*ans,sep='')
else:
  ans.append(o[n-1])
  print(*ans,sep='')

Measured memory_bytes: 9064
#include <stdio.h>

int main(void)
{
	int W, H, x, y, r;

	W = 0;
	H = 0;
	x = 0;
	y = 0;
	r = 0;

	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);

	
	if ((y + r <= H) && (0 <= y - r) && (x + r <= W) && (0 <= x - r))
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  string SS[N+1];
  
  int S[N+1][M+1];
  int C[N+1][M+1]; // 横に連続する1のマスの総数
  int R[N+1][M+1]; // 縦に連続する1のマスの総数
  int SUM[N+1][M+1]; // 存在する1のマスの総数
  
  for(int i=1; i<=N; ++i){
    cin>>SS[i];
    for(int j=1; j<=M; ++j){
      if(SS[i][j-1]=='0') S[i][j]=0;
      else S[i][j]=1;
    }
  }
  
  for(int i=0; i<=N; ++i){
    for(int j=0; j<=M; ++j){
      if(i*j==0){
        S[i][j]=0;
        C[i][j]=0;
        R[i][j]=0;
        SUM[i][j]=0;
      }
    }
  }
  
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=M; ++j){
      SUM[i][j]=SUM[i-1][j]+SUM[i][j-1]-SUM[i-1][j-1]+S[i][j];
      C[i][j]=C[i-1][j]+C[i][j-1]-C[i-1][j-1]+S[i][j];
      R[i][j]=R[i-1][j]+R[i][j-1]-R[i-1][j-1]+S[i][j];
      if(S[i][j]==1){
        if(S[i][j-1]==0) C[i][j]--;
        if(S[i-1][j]==0) R[i][j]--;
      }
    }
  }
  
  for(int i=1; i<=Q; ++i){
    int X,Y,XX,YY,ans=0;
    cin>>X>>Y>>XX>>YY;
    
    ans+=SUM[XX][YY]+SUM[X-1][Y-1]-SUM[X-1][YY]-SUM[XX][Y-1];
    ans-=R[XX][YY]+R[X][Y-1]-R[XX][Y-1]-R[X][YY];
    ans-=C[XX][YY]+C[X-1][Y]-C[X-1][YY]-C[XX][Y];
    
    co(ans);
  }
  
  return 0;
}

Measured memory_bytes: 69632
package main

import (
	"fmt"
)

func main() {
	n := 0
	f := false
	fmt.Scan(&n)
	for j := 0; j <= n/4; j++ {
		for k := 0; k <= n/7; k++ {
			if 4*j+7*k == n {
				f = true
			}
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
n, o = map(int, input().split())
x, v = [], []
for i in range(n):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)
c = 0

desno, lijevo, y = [], [], []
dd, ll = [0], [0]

tot = 0
for i in range(n):
    if i > 0:
        dd.append(max(dd[-1], desno[-1]))
    tot += v[i]
    desno.append(tot - x[i])

tot = 0
for i in range(n - 1, -1, -1):
    if i < n - 1:
        ll.append(max(ll[-1], lijevo[-1]))
    tot += v[i]
    lijevo.append(tot - (o - x[i]))
    y.append(o - x[i])

#print(desno, dd)
#print(lijevo, ll)

for i in range(n):
    kd = desno[i] - x[i] + ll[n - i - 1]
            #max([lijevo[j] for j in range(n - i - 1)] + [0])
    kl = lijevo[i] - y[i] + dd[n - i - 1]
            #max([desno[j] for j in range(n - i - 1)] + [0])
    #print(kd, kl)
    c = max(c, kd, kl, desno[i], lijevo[i])

print(c)


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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


return 0;
}





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

void quick_sort(int *ary, int begin, int end){
  int i, j, work, pivot;
  pivot = ary[ ( begin + end ) / 2 ];
  i = begin;
  j = end;
  while( 1 ){
    while( ary[i] < pivot ) ++i;
    while( ary[j] > pivot ) --j;
    if( i >= j) break;
    work = ary[i];
    ary[i] = ary[j];
    ary[j] = work;
    i++;
    j--;
  }
  if( begin < i - 1 ) quick_sort(ary, begin, i - 1 );
  if( j + 1 < end ) quick_sort(ary, j + 1, end );
}
int main(){
int n,k,i,sum=0;
scanf("%d %d",&n,&k);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
quick_sort(a,0,n-1);
for(i=0;i<k;i++)
sum+=a[i];
printf("%d",sum);
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here

int main()
{
	IOS;
	string s;
	cin >> s;
	ll temp = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		temp += s[i] - '0';
	}
	if (temp % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3712
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
int main(){	
	ios::sync_with_stdio(false);
	int n; cin>>n; vector<int> b(n);
	for (int i=0;i<n;i++) cin>>b[i];
	vector<int> vans; vans.PB(-1);
	for (int i=0;i<n;i++) {
		int x=b[i];
		if (x>vans.size()) {
			cout<<-1<<endl; return 0;
		}
		vans.insert(vans.begin()+x,x);
		//cout<<x<<":"<<vans.size()<<endl;
	}
	for (int i=1;i<=n;i++) cout<<vans[i]<<endl;

}


Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n = ni()
s = input()
cnt = 0
prev=""
for i in range(n):
    if prev==s[i]:
        pass
    else:
        cnt+=1
    prev=s[i]
print(cnt)


Measured memory_bytes: 9516
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
#define ll long long
using namespace std;

int main(){
    long n;
    cin>>n;
    ll data[n+1];
    for (ll i=1; i<=n; i++) cin>>data[i];
    
    ll ans[n+1];
    
    ll sum=0;
    for (ll i=1; i<=n; i++) sum+=data[i];
    
    ll memo=0;
    for (ll i=2; i<=n-1; i++) {
        if (i%2==0) memo+=data[i];
    }
    
    ans[1]=sum-memo*2;
    
    for (ll i=2; i<=n; i++) ans[i]=data[i-1]*2-ans[i-1];
    
    for (ll i=1; i<=n; i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    cout << t << s << endl;

    return 0;    
}



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

int main()
{
        string S; cin >> S;
        vector<int> A(26, 0);
        for (int i = 0; i < S.length(); ++i) {
                A[S[i] - 'a']++;
        }
        for (int i = 0; i < 26; ++i) {

                if (A[i] == 0) {
                        char c = i + 'a';
                        cout << c << endl;
                        exit(0);
                }

        }
        cout << "None" << endl;


}


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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;

  int A[N] = {0};
  rep(i,0,Q-1) {
    int n;
    cin >> n;
    A[n-1]++;
  }

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

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	map<int, int> a, b;
	for(int i = 0; i < n; i++){
		int in;
		cin >> in;
		if(i % 2 == 0) a[in]++;
		else b[in]++;
	}
	vector<pair<int, int>> c, d;
	for(auto i : a){
		c.push_back(make_pair(i.first, i.second));
	}
	for(auto i : b){
		d.push_back(make_pair(i.first, i.second));
	}
	sort(c.begin(), c.end(), [](pair<int, int> x, pair<int, int> y) -> int{return (x.second > y.second); });
	sort(d.begin(), d.end(), [](pair<int, int> x, pair<int, int> y) -> int{return (x.second > y.second); });
	int s = 0, t = 0;
	while(1){
		if(c[s].first == d[t].first){
			if(s + 1 == c.size()){
				if(t + 1 == d.size()){
					ans += d[t].second;
					break;
				}else{
					t++;
					continue;
				}
			}else if(t + 1 == d.size()){
				s++;
				continue;
			}else{
				if(c[s + 1].second <= d[t + 1].second) t++;
				else s++;
			}
		}else{
			ans = ((n + 1) / 2 - c[s].second) + (n / 2 - d[t].second);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6136
N = int(input())
s = []
for _ in range(N):
    s.append(input())
    
M = int(input())
t = []
for _ in range(M):
    t.append(input())


mine = 0
    
flags = [1] * N

for i in range(N):
    plus = 1
    minus = 0
    
    if flags[i] == 0:
        continue
        
    if flags[i] == 1:
        flags[i] = 0
    
    for j in range(i+1, N):
        if s[i] == s[j]:
            plus += 1
            flags[j] = 0
            
    for k in range(M):
        if s[i] == t[k]:
            minus += 1
            
    mine = max([mine, plus - minus]) 

    
print(mine)

Measured memory_bytes: 3064
/*input
1 + 2
56 - 18
13 * 2
100 / 10
27 + 81
0 ? 0
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.trim().to_string()
}

fn main() {
    let mut v: Vec<String>;
    let mut val: i32;
    loop {
        v = read_line()
            .trim()
            .split_whitespace()
            .map(|x| x.to_string())
            .collect();
        match v[1].chars().next().unwrap() {
            '+' => {
                val = v[0].parse::<i32>().unwrap() + v[2].parse::<i32>().unwrap();
            }
            '-' => {
                val = v[0].parse::<i32>().unwrap() - v[2].parse::<i32>().unwrap();
            }
            '*' => {
                val = v[0].parse::<i32>().unwrap() * v[2].parse::<i32>().unwrap();
            }
            '/' => {
                val = v[0].parse::<i32>().unwrap() / v[2].parse::<i32>().unwrap();
            }
            _ => {
                break;
            }
        }
        println!("{}", val);
    }
}



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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, M;
using pii = pair<int, int>;
pii p [111111];

signed main() {
   cin >> N >> M;
   rep (i, M) {
      cin >> p[i].second >> p[i].first;
   }

   sort(p, p+M);
   rep (i, M) {
      swap(p[i].first, p[i].second);
      // dbg2(p[i].first, p[i].second)
   }

   int last = 0;
   int cnt = 0;
   rep (i, M) {
      if (p[i].first < last && last <= p[i].second) {
      } else {
         // dbg3(p[i].first, p[i].second, last)
         cnt++;
         last = p[i].second;
      }
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 1792
N = int(input())
T, X, Y = 0, 0, 0

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    a = t - T
    b = abs(X - x)
    c = abs(Y - y)

    if a < b + c or a % 2 != (b + c) % 2:
        print('No')
        exit()
    T, X, Y = t, x, y

print('Yes')

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

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    int a = 0;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
            a++;
    }
    cout << n - 1 - max(a - 2 * k, 0) << endl;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int x,n; cin >> x >> n;
  if(n == 0) { 
    cout << x << endl;
    return 0;
  }

  vector<int> p(n); for(int i=0;i<n;i++) { cin >> p[i]; }
  sort(p.begin(),p.end());

  int ans=999999;
  for(int i=0;i<=101;i++) {
    if(find(p.begin(),p.end(),i) != p.end()) { continue; }
    if(abs(x-i) < abs(x-ans)) { ans = i; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
main(){
 int x, y;
 while( cin >> x >> y && x && y ){
int m = x+y;
char ch = 'A';
for ( int i = 1; i < 5; i++ ){
 cin >> x >> y;
 if ( x+y > m ){
m = x+y;
ch = (char)('A' + i);
 }
}
cout << ch << " " << m << endl;
 }
}


Measured memory_bytes: 3096
import collections
n=int(input())
A=list(map(int,input().split()))
A0=[]
A1=[]
for i in range(n):
  if i%2==0:
    A0.append(A[i])
  else:
    A1.append(A[i])
A00=collections.Counter(A0)
A11=collections.Counter(A1)
A000=A00.most_common()
A111=A11.most_common()
A000.append(("-1",0))
A111.append(("-1",0))
if A000[0][0]!=A111[0][0]:
  print(n-A000[0][1]-A111[0][1])
else:
  print(min(n-A000[1][1]-A111[0][1],n-A000[0][1]-A111[1][1]))

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    string s;
    cin>>s;
    ll sum=0,i;
    rep(i,0,sz(s))sum+=s[i]-'0';
    if(sum%9)cout<<"No";
    else cout<<"Yes";
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

long long n,a,m,k,q,b,c=1;
float qq,ww,ff=2,qs;
string ss,s1,s2;
int main(){
    cin>>a>>b;
    if (a>9 or b>9){
        cout<<-1;
    }
    else{
        cout<<a*b;
    }
}


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

int main()
{
    int n,c1 = 0,c2 =0,c3 = 0,c4 =0;
    string s;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s;

        if(s == "AC")
            c1++;
        else if (s =="WA")
            c2++;
        else if (s =="TLE")
            c3++;
        else
            c4++;
}

           cout<<"AC x "<<c1<<endl;
            cout<<"WA x "<<c2<<endl;
            cout<<"TLE x "<<c3<<endl;
            cout<<"RE x "<<c4<<endl;


    return 0;
}


Measured memory_bytes: 3628
def main():
    from math import ceil
    N, A, B = (int(i) for i in input().split())
    h = [int(input()) for i in range(N)]

    def is_ok(h,bomb,N,A,B):
        K = bomb
        cur = 0
        for i in range(N):
            cur += ceil((max(h[i] - B * K,0))/(A - B))
        return (cur <= K)

    def binary_search_meguru(Arr,N,A,B):
        left = -1
        right = 10**10 + 1
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(Arr,mid,N,A,B): right = mid
            else: left = mid
        return right
    
    print(binary_search_meguru(h,N,A,B))

if __name__ == '__main__':
    main()

Measured memory_bytes: 50008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int H = in.nextInt(), A = in.nextInt();
            int res = H % A == 0 ? (H/A) : (H/A) + 1;
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		long []a = new long [n+1];
		long node = 0L;
		
		for(int i = 0 ; i <= n ;i++) {
			a[i] = Long.parseLong(sc.next());
			node += a[i];
		}
		
		long []b = new long[n+1];
		b[0] = 1;
		long sum = b[0];
		
		for(int i = 0 ; i < n ;i++) {
			if(b[i] <= a[i]) {
				System.out.println(-1);
				return;
			}
			
			node -= a[i];
			b[i+1] = Math.min(node, (b[i] - a[i])*2);
			sum += b[i+1];
			
		}
		
		if(b[n] < a[n]) {
			System.out.println(-1);
          	return;
		}
		
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 59740
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		int n = h[0], m = h[1], v = h[2], p = h[3];
		var a = read().OrderBy(x => -x).ToArray();

		var s = new long[n + 1];
		for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

		Console.WriteLine(1 + Last(0, n - 1, i =>
		{
			long x = a[i] + m;
			long v2 = v - p - n + 1 + i;

			if (x < a[p - 1]) return false;
			if (v2 <= 0) return true;
			return s[i] - s[p - 1] + m * v2 <= x * (i - p + 1);
		}));
	}

	static int Last(int l, int r, Func<int, bool> f)
	{
		int m;
		while (l < r) if (f(m = r - (r - l - 1) / 2)) l = m; else r = m - 1;
		return l;
	}
}


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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string ans;
    if (S[N-1]=='s') {
        ans = S + "es";
    }
    else {
        ans = S + 's';
    }
    cout << ans << endl;
}

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

int main() {
  int n, k, sum;
  cin >> n >> k;
  sum = 0;

  // ここにプログラムを追記
  rep (i, n) {
    int x, y;
    cin >> x;
    y = x - k;
    if (y < 0) {
      y = -y;
    }
    if (x < y) {
      sum += x * 2;
    }
    else {
      sum += y * 2;
    }
  }
  cout << sum << endl;
}


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

int main(){
  int n;
  ll k;
  cin>>n>>k;
  int vec[n];
  int visit[n+1];
  int first[n];
  int seen[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
    vec[i]--;
    seen[i]=0;
  }
  visit[0]=0;
  int p,q=0;
  for(int i=1;i<n+1;i++){
    visit[i]=vec[visit[i-1]];
    seen[visit[i]]++;
    if(seen[visit[i]]==1){
      first[visit[i]]=i;
    }
    if(seen[visit[i]]==2){
      q=i-first[visit[i]];
      p=visit[i];
      break;
    }
  }
  int x=0;
  if(k<first[p]){
    for(int i=0;i<k;i++){
      x=vec[x];
    }
    cout<<x+1<<endl;
    return 0;
  }
  k-=first[p];
  k%=q;
  k+=2*q;
  k+=first[p];
  for(int i=0;i<k;i++){
    x=vec[x];
  }
  cout<<x+1<<endl;
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N;
    cin >> N;

    int ans = INF;

    for(int i = 1; i < N; ++i){
        int A = i;
        int B = N - A;
        int sum_A = 0, sum_B = 0;
        while(true){
            sum_A += A % 10;
            if(A < 10) break;
            A = A / 10;
        }
        while(true){
            sum_B += B % 10;
            if(B < 10) break;
            B = B / 10;
        }

        ans = min(ans, sum_A + sum_B);
    }

    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#include <math.h>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair

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

int main(){
    ll N, K, S;
    cin >> N >> K >> S;
    ll a = 0;
  	ll X = S+1;
    if(S == 1e9) X = 1;
    rep(i, N){
        if(a == K) {
            cout << X << " ";
            continue;
        }
        a++;
        cout << S << " ";
    }
    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e6;
int dp[maxn]; VI G[maxn];

bool topsort(const int n)
{
    VI degree(n);
    FOR(u,0,n) FOR_ALL(v,G[u])
        degree[*v]++;
    queue<int> Q;
    FOR(u,0,n) if (!degree[u])
        Q.push(u);
    int m = 0;
    while (Q.size()) {
        const int u = Q.front(); Q.pop();
        FOR_ALL(v,G[u]) if (--degree[*v] == 0)
            Q.push(*v);
        m++;
    }
    return n == m;
}

int dfs(const int u)
{
    int& ans = dp[u];
    if (-1 == ans) {
        ans = 1;
        FOR_ALL(v,G[u])
            ans = max(ans, dfs(*v)+1);
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin >> n) {
        int cnt = 0; map<PII,int> node; const int nmatch = n*(n-1)/2;
        FOR(i,0,nmatch)
            G[i].clear();
        FOR(i,1,n+1) FOR(j,i+1,n+1)
            node[PII(i,j)] = cnt++;
        FOR(i,1,n+1) {
            int u = -1;
            FOR(j,0,n-1) {
                int p = i; int q; cin >> q;
                if (p > q)  
                    swap(p,q);
                const int v = node[PII(p,q)];
                if (u != -1)
                    G[u].push_back(v);
                u = v;
            }
        }
        if (!topsort(nmatch))
            cout << -1 << endl;
        else {
            memset(dp,-1,sizeof(dp));
            int ans = 0;
            FOR(i,0,nmatch)
                ans = max(ans,dfs(i));
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 74464
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
const int maxn=1e5+5;
int a[maxn],b[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++)
        scanf("%d",&a[i]);
    ll ans=0,res=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b[i]);
        res=min(a[i],b[i]);
        b[i]-=res;
        ans+=res;
        res=min(b[i],a[i+1]);
        a[i+1]-=res;
        ans+=res;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <limits>

using namespace std;
using vi = vector<int>;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(N);

  vi A(N);
  REP(i, N) {
    cin >> A[i];
  }
  ll max_k = 2, min_k = 2;
  REP(i, N) {
    int a = A[N-i-1];
    ll q = (min_k+a-1)/a*a;
    if (min_k > max_k/a*a || max_k < (min_k+a-1)/a*a) {
      OUT(-1);
      return 0;
    }
    max_k = max_k / a * a + a - 1;
    min_k = (min_k + a - 1) / a * a;
  }
  OUT(min_k << " " << max_k);

    return 0;
}



Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n);
    makev(a, n);
    vector<PII> b(n);
    for (int i = 0; i < n; ++i) {
        b[i] = {a[i], i};
    }
    sort(ALL(b));
    VVI dp(n, VI(n + 1, -M7 * M7));
    int ans = 0;
    dp[0][n - 1] = 0;
    for (int d = n - 1; d >= 0; --d) {
        for (int i = 0; i + d < n; ++i) {
            int j = i + d;
            ans = max(ans, dp[i][j] + b[d].first * abs(i - b[d].second));
            ans = max(ans, dp[i][j] + b[d].first * abs(j - b[d].second));
            if (i + 1 < n) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + b[d].first * abs(i - b[d].second));
            }
            if (j > 0) {
                dp[i][j - 1] = max(dp[i][j - 1], dp[i][j] + b[d].first * abs(j - b[d].second));
            }
        }
    }
    cout << ans;

    return 0;
}

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

int main(){
    int32_t H, W;
    std::cin >> H >> W;

    std::vector<std::vector<int32_t>> mp_array(10, std::vector<int32_t>(10,0));
    for (auto& rows : mp_array) {
        for (auto& col : rows) {
            std::cin >> col;
        }
    }

    for (int32_t k = 0; k < 10; k++) {
        for (int32_t i = 0; i < 10; i++) {
            for (int32_t j = 0; j < 10; j++) {
                mp_array[i][j] = std::min(mp_array[i][j], mp_array[i][k] + mp_array[k][j]);
            }
        }
    }

    int64_t res = 0;
    for (int32_t i = 0; i < H*W; i++) {
        int32_t tmp = 0;
        std::cin >> tmp;
        if (tmp != -1) {
            res += mp_array[tmp][1];
        }
    }

    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll n,m;
    cin>>n>>m;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    ll cnt = 0,sum = 0;
    sum = sumArr(a);
    rep(i,n)if(a[i] >= sum/ double(4.0*m))cnt++;
    if(cnt >= m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

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

int main() {
	int n;
	cin >> n;
	vector<string> p(n);
	rep(i, n) {
		cin >> p[i];
	}
	rep(i, n) {
		if (p[i] == "Y") {
			cout << "Four\n";
			return 0;
		}
	}
	cout << "Three\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

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

using namespace std;

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

    int A[100010];

    REP(i, N)
    cin >> A[i];

    int B[100010], C[100010];

    REP(i, M)
    cin >> B[i] >> C[i];

    priority_queue<pair<int, int>> q;
    REP(i, N)
    q.push(make_pair(A[i], 1));

    REP(i, M)
    q.push(make_pair(C[i], B[i]));

    long long ans = 0;
    REP(i, N)
    {
        auto p = q.top();
        q.pop();
        ans += p.first;
        if (p.second > 1)
        {
            p.second--;
            q.push(p);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<atcoder/dsu>

using namespace std;
using namespace atcoder;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int n, q;  cin >> n >> q;
  dsu d(n);
  while (q--){
    int tp, u, v; cin >> tp >> u >> v;
    if(tp==0) d.merge(u,v);
    else  cout << d.same(u,v) << "\n";
  }
  return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root =z;
  else if(z->key<y->key) y->left=z;
  else (y->right = z);
}


void inorder(Node u){
  if(u==NIL){ return;}
  
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}

void preorder(Node u){
  if(u==NIL){ return;}
  
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
  
  if ( com[0] == 'i' ){
    scanf("%d", &x);
    insert(x);
  } else if ( com[0] == 'p' ){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
  }
  
  return 0;
}



Measured memory_bytes: 25184
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

    static class Edge {
        int start;
        int end;
        int weight;
        public Edge(int start, int end, int weigth) {
            this.start = start;
            this.end = end;
            this.weight = weigth;
        }
    }

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

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                graph[i][j] = sc.nextInt();
            }
        }

        if (!legitGraph(graph)) {
            System.out.println(-1);
            return;
        } else {
            System.out.println(MST(graph));
            return;
        }


    }

    private static boolean legitGraph(int[][] graph) {
        int N = graph.length;
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (graph[i][j] > graph[i][k] + graph[k][j]) {
                        return false;
                    }
                }
            }
        }

        return true;
    }


    private static long MST(int[][] graph) {
        Set<Edge> edges = new HashSet<>();
        for (int i = 0; i < graph.length; i++) {
            for (int j = i + 1; j < graph.length; j++) {
                edges.add(new Edge(i, j, graph[i][j]));
            }
        }

        long ans = 0;
        for (Edge edge : edges) {
            if (important(graph, edge)) ans += edge.weight;
        }

        return ans;
    }

    private static boolean important(int[][] graph, Edge edge) {
        int a = edge.start;
        int b = edge.end;
        int weigth = edge.weight;
        for (int i = 0; i < graph.length; i++) {
            if (weigth == graph[a][i] + graph[i][b] && a != i && i != b)
                return false;
        }
        return true;
    }
}


Measured memory_bytes: 50504
N,A,B,*H = `dd`.split.map &:to_i
S = H.inject(:+)
D = A - B
p (1..S/B).bsearch{ |n|
  d = n*B
  H.inject(0){ |a,h| v = h-d-1; v = -1 if v < -1; a + (v == -1 ? 0 : v/D+1) } <= n
}


Measured memory_bytes: 9476