akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int &v : p) cin >> v;
    reverse(p.begin(), p.end());
    set<int> values;
    for (int v : p) values.insert(v);
    int res = 0;
    for (int v : p) {
        if (v == *values.begin()) {
            ++res;
        }
        values.erase(v);
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{

  vector<pair<int,int> > vec;
  int count = 0;

  while(true)
  {

    int a,b;
    cin>>a>>b;
    if((a == 0)&&(b==0)) break;    
    count++;
    vec.emplace_back(a,b);
  }

  for (int i = 0; i < count; i++)
  {
    if(vec[i].first > vec[i].second)
    cout<<vec[i].second<<" "<<vec[i].first<<endl;
    else
    cout<<vec[i].first<<" "<<vec[i].second<<endl;
  }
  
  
  
  
  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  vector<int> x(5);
  REP(i, 5) {
    cin >> x[i];
  }
  REP(i, 5) {
    if (x[i] == 0) {
      cout << i+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3624
//1 21

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()


int main (){
    string a, b;
    cin >> a >> b;
    a = a + b;
    int A = sqrt(stoi(a));
    int B = stoi(a);
    if((int)pow(A,2)==(int)B)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

int main() {
    llong n;
    llong d_sum = 0;
    llong d = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        llong a, b;

        cin >> a >> b;
        d_sum += a * b;
        d += b;
    }

    cout << d + ((d_sum - 1) / 9) - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>



using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
/*
 execution in cmd of windows: g++ p1.cpp -op1
  
  
  p1
 
 */
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define all(v) v.begin(), v.end()
#define fsort(v) sort(all(v))  
#define rsort(v) sort(v.rbegin(),v.rend())
#define rev(v) reverse(all(v))
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sumv(v,x) accumulate(v.begin(),v.end(),x);
const ll mod = 1000000007;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD=1e9+7;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
#define cs ll t;cin>>t;while(t--)
#define cs1 ll t;t=1;while(t--)

int main()
{
   #ifndef ONLINE_JUDGE
        ifstream cin("in.in");
        ofstream cout("out.out");
    #endif
    
        io;
        //////////////////////////////////
         cs1{
             ll i,j,s=0,c,k,q=0,n,m=0,e;
             cin>>n;
             vll a(n),b(n);
             for(i=0;i<n;i++){
                cin>>a[i]>>b[i];
             }
             for(i=0;i<n-2;i++){
                if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]) s=1;
             }
             if(s==1) cout<<"Yes" nl;
             else cout<<"No" nl;

        }
        //////////////////////////////////
        cer;
}


Measured memory_bytes: 3844
#include<stdio.h>
 
#define N 100
 
 
 
 
int main(){
 
  int i,j,mini,n,t;
  int A[N];
  int count = 0;
 
  scanf("%d",&n);
  for(i =0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
 
  for(i =0;i<=n-1;i++){
     mini =i;
    for(j = i;j<=n-1;j++){
      if(A[j] < A[mini]){
    mini = j;
      }
    }
    if(A[mini]<A[i]) count++;
    t = A[i];
    A[i] = A[mini];
    A[mini] = t;
     
  }
     
 
 
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

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

using namespace std;

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

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

    int ans = 0;
    for(int b = 0; b < n; b++){
        for(int a = 0; a < b; a++){
            int ab = L[a] + L[b];
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = b + 1;
            ans += r - l;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"
#include "string.h"

void main()
{
	int N=0;
	char str[100000][4];
	int AC = 0, WA = 0, TLE = 0, RE = 0;
	int i = 0;

	scanf("%d", &N);

	for (i; i < N; i++)
	{
		scanf("%s", str[i]);

		if (strcmp("AC", str[i])==0) AC++;
		if (strcmp("WA", str[i]) == 0) WA++;
		if (strcmp("TLE", str[i]) == 0) TLE++;
		if (strcmp("RE", str[i]) == 0) RE++;

	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", AC, WA, TLE, RE);


}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int N,i;
    int ans = 0;
    int d[120];
    int num[120]={0};

    cin >> N ;

    for (i=0; i<N; i++){
        cin >> d[i];
        }

    for (i=0; i<N; i++){
        num[d[i]]++;
        }   

    for (i=0; i<101; i++){
        if(num[i]!=0)
            ans++;
        }

   cout << ans << endl;

 }
 


Measured memory_bytes: 384
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    Console.WriteLine(i.ToString() + "x" + j.ToString() + "="+ i*j);
                }
            }

            Console.ReadLine(); 
        }
    }

}

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

int main(){
	int a[4];
	int b[4];
	int hit;
	int blow;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		hit = 0;
		blow = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]) hit++;
			for(int j = 0; j < 4; j++){
				if(a[i] == b[j]){
					blow++;
					if(i == j) blow--;
					break;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define debug(x) cerr << "[" << #x <<": " << (x) <<"]"<< endl
#define pii pair<int,int>
#define clr(a,b) memset((a),b,sizeof(a))
#define rep(i,a,b) for(int i = a;i < b;i ++)
#define pb push_back
#define MP make_pair
#define LL long long
#define ull unsigned LL
#define ls i << 1
#define rs (i << 1) + 1
#define fi first
#define se second
#define ptch putchar
#define CLR(a) while(!(a).empty()) a.pop()

using namespace std;
inline LL read() {
    LL s = 0,w = 1;
    char ch = getchar();
    while(!isdigit(ch)) {
        if(ch == '-')
            w = -1;
        ch = getchar();
    }
    while(isdigit(ch))
        s = s * 10 + ch - '0',ch = getchar();
    return s * w;
}
inline void write(LL x) {
    if(x < 0)
        putchar('-'), x = -x;
    if(x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
#ifndef ONLINE_JUDGE
clock_t prostart = clock();
#endif

int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif

    string s; cin >> s;
    int cnt1 = 0,cnt2 = 0;
    for(int i = 0;i < s.size();++ i)
        if(s[i] == 'A') ++ cnt1;
        else ++ cnt2;
    if(cnt1 && cnt2) cout << "Yes" << endl;
    else cout << "No" << endl;

#ifndef ONLINE_JUDGE
    cerr << "time: " << 1.0 * (clock() - prostart) / CLOCKS_PER_SEC << " s" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 998244353;

#define MAX_N 300005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}

int main() {
  ll N, A, B, K;
  cin >> N >> A >> B >> K;
  make();
  ll ans = 0;
  repl(i, N+1) {
    if((K-A*i)%B) continue;
    ll j = (K-A*i)/B;
    if(j>N || j<0) continue;
    (ans += (comb(N, i) * comb(N, j)) % mod) %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
# https://atcoder.jp/contests/agc034/submissions/5758268
from itertools import accumulate
from operator import itemgetter

inf = float('inf')

N, X = map(int, input().split())

bs = []
ls = []
us = []
values = []

loss = 0
for idx in range(N):
    b, l, u = map(int, input().split())
    value = X * u - b * (u - l)

    bs.append(b)
    ls.append(l)
    us.append(u)
    values.append(value)

    loss += b * l

order = [idx for idx, _ in sorted(enumerate(values), key=itemgetter(1), reverse=True)]

pref = [0] + list(accumulate(values[idx] for idx in order))

ans = inf
for it in range(N):
    i = order[it]
    for coeff in ls[i], us[i]:
        low = 0
        high = N
        while low <= high:
            mid = (low + high) >> 1
            cur = loss
            if coeff == us[i]:
                cur += bs[i] * (us[i] - ls[i])
            can_get = pref[mid]
            vals = mid
            if it < mid:
                can_get -= values[i]
                vals -= 1
            can_get += X * coeff
            if can_get >= cur:
                can_get -= X * coeff
                need = 0
                if can_get < cur:
                    need = (cur - can_get + coeff - 1) // coeff
                ans = min(ans, vals * X + need)
            if low == high:
                break
            if can_get >= cur:
                high = mid
            else:
                low = mid + 1
print(ans)


Measured memory_bytes: 90072
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include <assert.h>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge { int to, cost; };
#define VMAX 100000

int K;
ll N, ans = 0;
ll X[100010], Y[100010];
ll W_[3010][3010], B_[3010][3010];
auto W = W_ + 3;
std::string C[100010];
//yxyx

ll imos(int a, int b, int c, int d, int mode) {
	int res = 0;
	if (a>c || b>d)return 0;
	if (mode == 0) {
		if ((0 <= c && c<2 * K) || (0 <= d && d<2 * K))res += W[c][d];
		if ((0 <= c && c<2 * K) || (0 <= b - 1 && b - 1<2 * K))res -= W[c][b - 1];
		if ((0 <= a - 1 && a - 1<2 * K) || (0 <= d && d<2 * K))res -= W[a - 1][d];
		if ((0 <= a - 1 && a - 1<2 * K) || (0 <= b - 1 && b - 1<2 * K))res += W[a - 1][b - 1];
	}
	return res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N >> K;
	REP(i, N) {
		cin >> X[i] >> Y[i] >> C[i];
		X[i] %= 2 * K, Y[i] %= 2 * K;
		if (C[i] == "W")W[Y[i]][X[i]] += 1;
		else W[Y[i]][(X[i] + K) % (2 * K)] += 1;
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i][j + 1] += W[i][j];
		//B[i][j + 1] += B[i][j];
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i + 1][j] += W[i][j];
		//B[i + 1][j] += B[i][j];
	}

	//for (size_t i = 0; i < 2 * K; i++)
	//{
	//	for (size_t j = 0; j < 2 * K; j++)
	//	{
	//		cout << W[i][j] << ' ';
	//	}
	//	cout << endl;
	//}

	REP(i, K)REP(j, K)REP(k, 2) {
		ll tans = 0;
		tans += imos(0, 0, i - 1, j - 1, (k == 0 ? 0 : 1));
		tans += imos(0, j, i - 1, j + K - 1, (k != 0 ? 0 : 1));
		tans += imos(0, j + K, i - 1, 2 * K - 1, (k == 0 ? 0 : 1));
		tans += imos(i, 0, i + K - 1, j - 1, (k != 0 ? 0 : 1));
		tans += imos(i, j, i + K - 1, j + K - 1, (k == 0 ? 0 : 1));
		tans += imos(i, j + K, i + K - 1, 2 * K - 1, (k != 0 ? 0 : 1));
		tans += imos(K + i, 0, 2 * K - 1, j - 1, (k == 0 ? 0 : 1));
		tans += imos(K + i, j, 2 * K - 1, j + K - 1, (k != 0 ? 0 : 1));
		tans += imos(K + i, j + K, 2 * K - 1, 2 * K - 1, (k == 0 ? 0 : 1));
		ans = max(tans, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<int> a[10];

    int res = 0;
    for (int i = 0; i < 1000; i++) {
        int a[3];
        a[2] = i % 10;
        a[1] = (i % 100) / 10;
        a[0] = (i) / 100;
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] - '0' == a[cnt]) {
                cnt++;
                if (cnt == 3) {
                    res++;
                    break;
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		long N = nextLong();
		HashMap<String,Long> map = new HashMap<>();
		for(int i=1;i<=N;i++){
			int y=i%10;
			int x=i;
			while(x/10!=0) x/=10;
			String s = String.valueOf(x)+":"+String.valueOf(y);
			map.put(s, map.getOrDefault(s, 0L)+1);
		}
		long ans = 0;
		for(String key:map.keySet()){
			StringBuffer sb = new StringBuffer();
			sb.append(key);
			ans+=map.get(key)*map.getOrDefault(sb.reverse().toString(),0L);
		}
		System.out.println(ans);
	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 43032
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
int main()
{
    int n; 
    cin>>n; 
    string str; 
    cin>>str; 
    str.erase(unique(str.begin(),str.end()),str.end());
    cout<<str.size()<<endl; 
}


Measured memory_bytes: 3772
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1;
    if ( key > A[mid] ) left = mid + 1;
    else if ( key < A[mid] ) right = mid;
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 2172
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


s = input().rstrip()
t = input().rstrip()
result = 0
for i in range(len(s)):
    if s[i] != t[i]:
        result += 1
        
print(result)

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

typedef struct
{
    LL a, b;
} ara;

ara arr[mx5];

bool cmp(ara A, ara B)
{
    if(A.a != B.a)
        return A.a < B.a;
    return A.b < B.b;
}

int main()
{
    LL n, k;
    cin >> n >> k;

    for(int i = 1; i <= n; i++)
        cin >> arr[i].a >> arr[i].b;


    sort(arr + 1, arr + n + 1, cmp);

    for(int i = 1; i <= n; i++)
        arr[i].b += arr[i - 1].b;

    for(int i = n - 1; i >= 0; i--){
        if(k > arr[i].b)
            return cout << arr[i + 1].a << '\n', 0;
    }

    return 0;
}


Measured memory_bytes: 5192
using System.Collections.Generic;
using System;

public class Po
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        var d = new Dictionary<string, int> { { "N", 0 }, { "E", 1 }, { "S", 2 }, { "W", 3 } };
        while (true)
        {
            var map = new bool[21, 21];
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                map[int.Parse(line[0]), int.Parse(line[1])] = true;
            }
            var gcount = 0;
            var p = new Po { x = 10, y = 10 };
            if (map[10, 10]) { gcount = 1; map[10, 10] = false; }
            var m = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < m; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                gcount += getGem(map, d, dx, dy, line2[0], int.Parse(line2[1]), p);
            }
            Console.WriteLine(gcount == n ? "Yes" : "No");
        }
    }
    public static int getGem(bool[,] map, Dictionary<string, int> d, int[] dx, int[] dy, string dir, int L, Po p)
    {
        var count = 0;
        for (int i = 0; i < L; i++)
        {
            p.x += dx[d[dir]];
            p.y += dy[d[dir]];
            if (map[p.x, p.y]) { count++; map[p.x, p.y] = false; }
        }
        return count;
    }
}

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,c,i=0;
  cin >> a >> a;
  while(cin >> b >> c){
    if((abs(b) * abs(b)) + (abs(c) * abs(c)) <= abs(a) * abs(a)){
      i++;
    }
  }
  cout << i;
  return 0;
}

Measured memory_bytes: 3628
n = int(input())
inf = 1001001001
lis = [7, 5, 3]
ans = 0
def dfs(i):
    if i > inf:
        return
    else:
        if i <= n and "7" in str(i) and "5" in str(i) and "3" in str(i):
            global ans
            ans += 1
        for j in lis:
            dfs(10*i + j)
dfs(0)
print(ans)

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

string s;

int main(){
  cin >> s;
  string res = "NO";
  int n = s.size();
  for(int left = 0; left < n; left++){
    for(int right = left; right < n; right++){
      string t = s.substr(0, left) + s.substr(right + 1, n - right);
      cerr << t << endl;
      if(t == "keyence"){
        res = "YES";
      }
    }
  }
  if(s == "keyence"){
    res = "YES";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define INF (1<<29)

int N, M, R, d[201][201], r[9], A, B, C, res;
bool used[9];

void dfs(int c, int las, int dist)
{
	if (c == R + 1)
	{
		if (res > dist) res = dist;
		return;
	}
	for (int i = 1; i <= R; i++) if (!used[i])
	{
		used[i] = true;
		if (las == -1) dfs(c + 1, i, 0);
		else dfs(c + 1, i, dist + d[r[las]][r[i]]);
		used[i] = false;
	}
}
int main()
{
	scanf("%d%d%d", &N, &M, &R);
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) if (i != j) d[i][j] = INF;
	for (int i = 1; i <= R; i++) scanf("%d", &r[i]);
	for (int i = 1; i <= M; i++)
	{
		scanf("%d%d%d", &A, &B, &C);
		if (d[A][B] > C) d[A][B] = d[B][A] = C;
	}
	for (int k = 1; k <= N; k++)
		for (int i = 1; i <= N; i++)
			for (int j = 1; j <= N; j++)
				if (d[i][j] > d[i][k] + d[k][j])
					d[i][j] = d[i][k] + d[k][j];
	res = INF;
	dfs(1, -1, 0);
	printf("%d\n ", res);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int p = scan.nextInt();
        int n = scan.nextInt();
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            int i1 = scan.nextInt();
            ar[i] = i1;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < ar.length; i++) {
            int x = i == 0 ? n-1:i-1;
            int y = i+1 == ar.length ? 0:i+1;
            min = Math.min(Math.min(p + (ar[x]-ar[i]),p - ar[y] + ar[i]),min);
        }

        System.out.println(Math.min(ar[n-1]-ar[0],min));
    }
}


Measured memory_bytes: 73588
#include<stdio.h>
int main()
{
  int m,nmin,nmax;
  int gap,result;
  int score,prescore;
  int i;
  while(1)
    {
      scanf("%d%d%d",&m,&nmin,&nmax);
      if((m==0)&&(nmin==0)&&(nmax==0)) break;
      result=nmin;
      gap=0;
      for(i=0;i<m;i++)
	{
	  if(i>0) prescore=score;
	  scanf("%d",&score);
	  if((i>=nmin)&&(i<=nmax))
	    {
	      if(prescore-score>=gap)
		{
		  result=i;
		  gap=prescore-score;
		}
	    }
	}
      printf("%d\n",result);
    }
  return 0;
}

Measured memory_bytes: 600
#define onlycc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

int n;
int a[200000];

int main()
{
    onlycc;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    ll ret = 0;
    for(int i = 1; i < n; i++)
    {
        if(a[i] < a[i-1])
        {
            ret += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }

    cout << ret;

    return 0;
}


Measured memory_bytes: 4348
while n = gets.to_i
  break if n == 0
  table = []
  set = []
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    set << p; set << q; table << [p, q]
  end
  set = set.uniq.sort
  t = [0] * set.size
  table.each do |p, q|
    for i in (set.index(p)...set.index(q))
      t[i] += 1
    end
  end
  p t.max
end

Measured memory_bytes: 10144
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include<algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,res,T,A;
    cin >> N >> T >> A;

    double iMin;
    iMin = 10000000.0;
    double x,tmp;

    REP(i,N)
    {
        cin >> x;
        tmp = T -  x * 0.006;
        if(iMin > abs(tmp- A))
        {
            iMin = abs(tmp- A);
            res = i+1;
        }
    }

    cout << res << endl;

}



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (int(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 333;
const ll INF = LLONG_MAX/3;

ll dp[N][N][N];

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

    vector<ll> h(n);
    vector<ll> uh;
    rep(i,n){
        cin >>h[i];
        uh.pb(h[i]);
    }

    uh.pb(0);
    sort(all(uh));
    uh.erase(unique(all(uh)), uh.end());
    int U = uh.size();

    unordered_map<ll,int> m;
    rep(i,U) m[uh[i]] = i;

    rep(i,N)rep(j,N)rep(k,N) dp[i][j][k] = INF;
    rep(i,U){
        int nj = 1;
        if(uh[i] == h[0]) nj = 0;
        dp[1][nj][i] = uh[i];
    }

    for(int i=1; i<n; ++i)rep(j,x+1)rep(k,U){
        int idx = m[h[i]];

        // uh[k]に揃える
        int nj = j+1;
        if(k == idx) nj = j;
        if(nj<=x) dp[i+1][nj][k] = min(dp[i+1][nj][k], dp[i][j][k]);

        // そのまま
        ll cost = 0;
        if(uh[k] < h[i]) cost = h[i]-uh[k];
        dp[i+1][j][idx] = min(dp[i+1][j][idx], dp[i][j][k]+cost);
    }

    ll ans = INF;
    rep(i,x+1)rep(j,U) ans = min(ans, dp[n][i][j]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 288768
# -*- coding: utf-8 -*-
# input
n = int(input())
# calc
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9+(n-100+1))
elif n < 10000:
    print(909)
elif n < 100000:
    print(909+(n-10000+1))
elif n == 100000:
    print(90909)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define dracarys ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << " Here => " << x 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool ptime;
void inline fileIO(){ 
    ptime=false;
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        ptime=true;
    #endif
        srand((unsigned)time(0));
}

void inline solve(int tc){
    ll n,cnt = 0;
    cin >> n;
    vector<ll> v(n);
    for (int i=0;i<n;i++){
        cin >> v[i];
    }
    ll mxm = v[0];
    for (int i=1;i<n;i++){
        if (v[i] >= mxm){
            mxm = v[i];
        }
        else{
            cnt += (mxm - v[i]);
        }
    }
    cout << cnt << "\n";
}

int main(){
    fileIO();

    dracarys

    int tt=0,t=1;
    //cin >> t;

    while(t--){solve(++tt);}

    if (ptime)
        cerr << "processor time: " << clock() / (double) CLOCKS_PER_SEC << "s    ";


    return 0;
}

Measured memory_bytes: 4776
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long 

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

  int dl[3]={-1,-1,-1},cs,cc;
  for (int i=0;i<m;i++) {
    cin>>cs>>cc;
    cs--;
    if (dl[cs]<0) dl[cs]=cc;
    else if (dl[cs]!=cc) dl[cs]=10;
  }

  int jd = ((dl[0] > 9) || (dl[1] > 9) || (dl[2] > 9)) || (n>1&&dl[0]==0);
  if (jd) cout << "-1" << endl;
  else {
    dl[0] = max(dl[0], (int)(n != 1));
    dl[1] = max(dl[1], 0);
    dl[2] = max(dl[2], 0);
    if (n>1) swap(dl[0],dl[n-1]);
    cout<<(dl[0]+dl[1]*10+dl[2]*100)<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
c = []

for i in range(n):
    s.append(list(map(int, input().split())))
for i in range(m):
    c.append(list(map(int, input().split())))
for i in range(n):
    d_min = 10**17
    for j in range(m):
        mah = abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1])
        if mah < d_min:
            d_min = mah
            ans = j+1
    print(ans)



Measured memory_bytes: 3064
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

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

a,b = map(int, input().split())
print(int(a+b/2))


Measured memory_bytes: 13540
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pii;
int64 dp[2002][2002];
int main(){
	int n; cin >> n;
    vector<pii> A(n);
    for(int64 i = 0; i < n; i++){
    	cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin(), A.end());

    int64 ans = 0;
    //memset(dp, 0, sizeof(dp));
  	for(int64 l = n; l >= 1; l--){
    	for(int64 i = 0; i < n - l + 1; i++){
          int64 j = i + l - 1;
          if(l == 1){
          	  ans = max(ans, dp[i][j] + (int64)A[l - 1].first * abs(A[l - 1].second - i));
          }
          else{
          	  dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A[l - 1].first * abs(A[l - 1].second - i));
              dp[i][j - 1] = max(dp[i][j - 1], dp[i][j] + A[l - 1].first * abs(A[l - 1].second - j));
          }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26252
//   ▄▄▄▄▄▄▄▄▄▄▄  ▄         ▄  ▄▄        ▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄         ▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄ 
//  ▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░▌      ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
//  ▐░█▀▀▀▀▀▀▀█░▌▐░▌       ▐░▌▐░▌░▌     ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌       ▐░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌
//  ▐░▌       ▐░▌▐░▌       ▐░▌▐░▌▐░▌    ▐░▌     ▐░▌     ▐░▌          ▐░▌       ▐░▌▐░▌          ▐░▌       ▐░▌
//  ▐░█▄▄▄▄▄▄▄█░▌▐░▌       ▐░▌▐░▌ ▐░▌   ▐░▌     ▐░▌     ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌
//  ▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░▌  ▐░▌  ▐░▌     ▐░▌     ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
//  ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌       ▐░▌▐░▌   ▐░▌ ▐░▌     ▐░▌      ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀█░█▀▀ 
//  ▐░▌          ▐░▌       ▐░▌▐░▌    ▐░▌▐░▌     ▐░▌               ▐░▌▐░▌       ▐░▌▐░▌          ▐░▌     ▐░▌  
//  ▐░▌          ▐░█▄▄▄▄▄▄▄█░▌▐░▌     ▐░▐░▌ ▄▄▄▄█░█▄▄▄▄  ▄▄▄▄▄▄▄▄▄█░▌▐░▌       ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌      ▐░▌ 
//  ▐░▌          ▐░░░░░░░░░░░▌▐░▌      ▐░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌▐░░░░░░░░░░░▌▐░▌       ▐░▌
//   ▀            ▀▀▀▀▀▀▀▀▀▀▀  ▀        ▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀         ▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀         ▀ 
//                                                                                                          
                                                                    
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define strwspaces(s) getline(cin,s)
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'
#define inp(n) int n;cin>>n;

using namespace std;

int i,j,k,l;

void solve()
{
    inp(n);
    int a[n];
    inparr(a,n);
    int curht=a[0],ans=0;
    rep(i,1,n)
    {
        if(a[i]<curht)
        {
            ans+=curht-a[i];
        }
        else
        {
            curht=a[i];
        }
    }
    cout<<ans<<endl;
    
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 5136
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var output = 3;
  if((input[0] == input[1] && input[0] != input[2]) || 
    (input[0] != input[1] && input[0] == input[2]) || 
    (input[0] != input[1] && input[1] == input[2])){
     output--;
  }else if(input[0] == input[1] && input[0] == input[2]){
     output = 1;
  }
  
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include<stdio.h>

int main(void){
    int n, a, b;
    scanf("%d %d %d",&n ,&a ,&b);
//    printf("%d %d %d\n",n ,a ,b);
    if(n*a > b){
        printf("%d\n",b);
    }
    if(n*a <= b){
        printf("%d\n",n*a);
    }
    return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


vi edge[2010];
vector<pii> es;
int cnt[2010];
int used[2010];

int solve(vi roots, int d) {
    queue<pii> que;
    memset(used, 0, sizeof(used));
    for (auto x: roots) {
        que.push({x, 0});
        used[x] = 1;
    }
    int res(0);
    while (!que.empty()) {
        auto node = que.front();
        que.pop();
        res++;
        auto x = node.first;
        auto deep = node.second;
        used[x] = 1;
        if (deep < d) {
            for (auto y: edge[x]) {
                if (!used[y]) {
                    que.push({y, deep + 1});
                }
            }
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, i, j, x, y, k;
    cin >> n >> k;
    rep(i, n - 1) {
        cin >> x >> y;
        edge[x].pb(y);
        edge[y].pb(x);
        es.pb({x, y});
    }
    auto ans = 0;
    if (k % 2 == 0) {
        xrep(i, 1, n + 1) {
            vi vs(1, i);
            ans = max(ans, solve(vs, k / 2));
        }
    } else {
        for (auto e: es) {
            vi vs;
            vs.pb(e.first);
            vs.pb(e.second);
            ans = max(ans, solve(vs, k / 2));
        }
    }
    cout << n - ans << endl;
}


Measured memory_bytes: 384
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String[] ary = sc.nextLine().split(" ");
			int l = ary.length;
			Deque<Double> stack = new ArrayDeque<Double>();
			for(int i = 0; i < l; i++) {
				String t = ary[i];
				if(t.equals("+")) {
					double a = stack.pop();
					double b = stack.pop();
					double c = b + a;
					stack.push(c);
				}else if(t.equals("-")) {
					double a = stack.pop();
					double b = stack.pop();
					double c = b - a;
					stack.push(c);
				}else if(t.equals("*")) {
					double a = stack.pop();
					double b = stack.pop();
					double c = b * a;
					stack.push(c);
				}else if(t.equals("/")){
					double a = stack.pop();
					double b = stack.pop();
					double c = b / a;
					stack.push(c);
				}else {
					double a = Integer.parseInt(t);
					stack.push(a);
				}
			}
			System.out.println(stack.pop());
		}
		sc.close();
	}
}


Measured memory_bytes: 26212
#include <iostream>
#include <algorithm>

int ls[200];

int main(){
  int N;
  std::cin>>N;
  for(int i=0;i<N*2;i++){
    std::cin>>ls[i];
  }
  std::sort(ls,ls+N*2);
  int cost=0;
  for(int i=0;i<N;i++){
    cost+=ls[i*2];
  }
  std::cout<<cost<<std::endl;
  return 0;
}


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

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

int main()
{
	string ans = "No";
	ll A = 0;
	ll B = 0;
	ll C = 0;

 	cin >> A >> B >> C;
	if ( A + B >= C ) {
		ans = "Yes";
	}
	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

const MOD = int64(1e9 + 7)

func main() {
	var n, m int64
	fmt.Scan(&n, &m)

	if math.Abs(float64(n-m)) > 1 {
		fmt.Println(0)
		return
	}
	ans := (fac(n) * fac(m)) % MOD
	if n == m {
		ans = (ans * 2) % MOD
	}
	fmt.Println(ans)
}

func fac(num int64) int64 {
	if num == 1 {
		return 1
	}
	return (num * fac(num-1)) % MOD
}


Measured memory_bytes: 7040
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << '\n';
    else cout << "No" << '\n';

}

Measured memory_bytes: 3440
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, m; rd(n, m);
  auto g=new int[][](n, 0);
  foreach(_; 0..m){
    int a, b; rd(a, b);
    a--; b--;
    g[a]~=b; g[b]~=a;
  }

  auto c=new int[](n);
  fill(c, -1);
  bool dfs(int i, int w, int p=-1){
    c[i]=w;
    bool ret=true;
    foreach(j; g[i])if(j!=p){
      if(c[j]==-1) ret&=dfs(j, w^1, i);
      if((c[j]^w)==0) ret=false; 
    }
    return ret;
  }

  if(dfs(0, 0)){
    long w=0;
    foreach(e; c)if(e==0) w++;
    auto b=to!long(n)-w;
    writeln(w*b-m);
  }else{
    auto _n=to!long(n);
    writeln(_n*(_n-1)/2-m);
  }

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;

struct re {
    int x, y;
//    const bool operator < (const re &a) const {
//        if (x != a.x) return x < a.x;
//        return y < a.y;
//    }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    ll a, b, res = 1;
    cin >> a >> b;
    if (a > b) swap(a, b);
    ff(i, 2, trunc(sqrt(b)) + 1) {
        if (a % i == 0 && b % i == 0) ++res;
        while (a % i == 0) a /= i;
        while (b % i == 0) b /= i;
    }

    if (a > 1 && b > 1 && a == b) ++res;
    cout << res;
}
//This code belongs to s34vv1nd


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll mypow(ll b, ll i)
{
	return i == 0 ? 1 : i % 2 == 0 ? mypow(b * b, i / 2) : b * mypow(b, i - 1);
}
ll len(ll lv)
{
	return mypow(2, lv + 2) - 3;
}
ll pat(ll lv)
{
	return mypow(2, lv + 1) - 1;
}
ll eatable(ll lv, ll x)
{
	if (x <= 0) {
		return 0;
	} else if (lv == 0) {
		return 1;
	} else {
		ll ret = 0, lv_len_1 = len(lv - 1);
		x -= 1;
		if (x < lv_len_1) {
			ret += eatable(lv - 1, x);
		} else {
			ret += pat(lv - 1);
			x -= lv_len_1;
			if (x > 0) {
				ret += 1;
				x -= 1;
				ret += eatable(lv - 1, x);
			}
		}
		return ret;
	}
}
signed main()
{
	ll lv = in(), x = in();
	cout << eatable(lv, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

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

int main()
{
  bool flag = true;
  int N;
  string s,str[10000];
  cin >> N;
  int A_count=0,B_count=0,AB_count=0;
  for(int i=0;i<N;i++){
    cin >> s;
    int j=0;
    while (j < s.length()-1)
    {
      if(s[j+1] == 'B'){
        if(s[j] == 'A') AB_count++;
        j+=2;
      }else{
        if(s[j+1] == 'A') j++;
        else j+=2;
      }
    }
    if(s[0] == 'B'){
      if(s[s.length()-1] != 'A') flag = false;
      B_count++;
    }
    if(s[s.length()-1] == 'A'){
      if(s[0] != 'B') flag = false;
      A_count++;
    }
  }
  if(flag && (A_count == B_count) && (A_count != 0)) AB_count--;
  cout << AB_count+min(A_count,B_count);
}


Measured memory_bytes: 512