akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

	int n;
	cin >> n;
	cout << n*n*n << "\n";

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n,k,a[N],I1=-1,I2=-1,J1=-1,J2=-1;
ll ans=1;

void init() {}

int mul(int a, int b) {

    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (1LL*a*b)%mod;

}

ll solve1() {

    for (int i = k-1; ~i ; --i) {
        if(a[i]<0) {
            I1 = i;
            break;
        }
    }

    for (int i = k; i < n; ++i) {
        if(a[i]>=0) {
            J1 = i;
            break;
        }
    }

    if(I1 == -1 || J1 == -1) return -1;

    int ret = a[J1];

    for (int i = 0; i < k; ++i) {
        if(i!=I1) ret = mul(ret, a[i]);
    }

    return ret;

}

ll solve2() {

    for (int i = k-1; ~i ; --i) {
        if(a[i]>=0) {
            I2 = i;
            break;
        }
    }

    for (int i = k; i < n; ++i) {
        if(a[i]<0) {
            J2 = i;
            break;
        }
    }

    if(I2 == -1 || J2 == -1) return -1;

    int ret = a[J2];

    for (int i = 0; i < k; ++i) {
        if(i!=I2) ret = mul(ret, a[i]);
    }

    return ret;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;

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

    sort(a,a+n, [](int a, int b){
        return abs(a)<abs(b);
    });
  	reverse(a , a+n);

    int cnt = 0;

    for (int i = 0; i < k; ++i) {
        cnt += (a[i]<0);
    }

    if(cnt&1) {

        ll a1 = solve1();
        ll a2 = solve2();

        if(a1==-1 && a2==-1) {

            for (int i = n-1; i > n-1-k; --i) {
                ans = mul(ans, a[i]);
            }

            cout << ans << '\n';

        } else if(a1==-1) cout << a2 << '\n';
        else if(a2==-1) cout << a1 << '\n';
        else if(1LL*a[J1]*a[I2]>1LL*a[J2]*a[I1]) cout << a1 << '\n';
        else cout << a2 << '\n';

    } else {
        for (int i = 0; i < k; ++i) {
            ans = mul(ans, a[i]);
        }

        cout << ans << '\n';

    }

    return 0;
}


Measured memory_bytes: 4444
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main(void){
    int N;string s;
    cin>>N>>s;
    REP(i,s.size()){
        s[i]+=N;
        if(s[i]>'Z'){
           s[i]-=26;
           //cout<<s[i]<<endl;
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D;
  char k,d;
  str N,N2;
  vector<int>K(3);
  cin>>A>>k>>B>>d>>C;
  if(B<=4)cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int numH = 0;
		int numW = 0;

		String sel = "#";

		String[] NumWork;

		try {
			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				String line = br.readLine();

				if (line != null) {

					//??°??£?????´??°?????????
					NumWork = line.split(" ", 0);

					//??´??°?????°??????
					ArrayList<Integer> NumList = new ArrayList<Integer>();

					for (int i = 0; i < NumWork.length; i++) {
						NumList.add(Integer.parseInt(NumWork[i]));
					}
					numH = NumList.get(0);
					numW = NumList.get(1);

					//????????¢?????????
					//????????????
					if (numH != 0 || numW != 0) {

						for (int i = 0; i < numH; i++) {
							//
							for (int j = 0; j < numW; j++) {
								System.out.print(sel);
							}
							System.out.println("");
						}
						System.out.println("");
					}else{
						break;
					}
				}else{
					break;
				}

			}
		} catch (IOException e) {
			System.out.println(e);
		}

	}

}

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

int main(){
    int a , b;
    cin >> a >> b;
     cout << max({a+b,a-b,a*b}) << endl;
}


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

int main(){
int N,X;
cin >> N >> X;
vector<int> vec(N);
for(int i=0; i<N; i++){
    cin >> vec.at(i);
}
int ans=0;
for(int i=0; i<N; i++){
    ans += vec.at(i);
}
int Y = X - ans;
sort(vec.begin(),vec.end());
if(vec.at(0)>Y){
    cout << N << endl;
}
else if(vec.at(0)<Y){
    cout << N + Y/vec.at(0) <<endl;
}
}

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

int main()
{
	
	cin >> S;
	N=(int)S.length();
	int g=0;int p=0;
	for(int i=0;i<N;i++){
		if(S[i]=='g'){
			g++;
		}
		else p++;
	}
	printf("%d\n",N/2-p);
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 1000
bool n,s,w,e;
char str[MAXN+5];
int main(){
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]=='N') n=1;
        if(str[i]=='S') s=1;
        if(str[i]=='W') w=1;
        if(str[i]=='E') e=1;
    }
    if(n!=s){
        printf("No");
        return 0;
    }
    if(w!=e){
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    string t;
    cin >> t;
    cout << t << s << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll,ll>> P(N);
    REP(i,0,N) {
        ll a, b;
        cin >> a >> b;
        P[i] = make_pair(b, a);
    }
    
    ASC(P);
    ll sum = 0;
    bool f = true;
    REP(i,0,N) {
        ll a = P[i].second, b = P[i].first;
        sum += a;
        if(sum > b) {
            f = false;
            break;
        } 
    }

    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[100], b[100], c[100];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	REP(i, n) scanf("%d", b+i);
	REP(i, n-1) scanf("%d", c+i);
	int ans = 0;
	REP(j, n){
		int i = a[j] - 1;
		ans += b[i];
		if(j && a[j-1] + 1 == a[j])
			ans += c[i-1];
	}
	printf("%d\n", ans);
}


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

int main() {
  string O, E;
  cin >> O >> E;
  for(int i = 0; i < E.size(); i++){
    cout << O.at(i) << E.at(i);
  }
  if(O.size() > E.size()){
    cout << O.at(O.size() - 1) << endl;
  }
}

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

// バブルソートを行う関数
int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                // 隣接要素を交換する
                swap(A[j], A[j - 1]);
                flag = true;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  string S,T;
  cin >> S >> T;
  
  
  for(int i=0;i<T.length();i++){
    cout << T[i] ;
  }
  for(int i=0;i<S.length();i++){
    cout << S[i];
  }
  
}


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


int main(){
    map<string, int> m;
    string s;
    int n;
    cin >> n;
    rep(i, n)
    {
        cin >> s;
        m[s] = 1;
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL MOD = 1e9+7;
 
int main() {
  LL N;
  cin >> N;
  int answer = 0;
  
  if (N < 10) answer = N;
  else if (N >= 10 && N < 100) answer = 9;
  else if (N >= 100 && N < 1000) answer = (N - 99) + 9;
  else if (N >= 1000 && N < 10000) answer = 900 + 9;
  else if (N >= 10000 && N < 100000) answer = (N - 9999) + 900 + 9;
  else if (N >= 100000) answer += 90000 + 900 + 9;
 
  cout <<  answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	int sum = 0;
	int n = N;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	if (N % sum == 0)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3096
// you should probably see at the bottom ..
#include<bits/stdc++.h>

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int d, t, s;
	cin >> d >> t >> s;
	cout << (d <= (s * t) ? "Yes" : "No") << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 3688
// AGC006_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N;
    string s, t;
    cin >> N >> s >> t;
    
    // calculation
    if (N == 1) {
        if (s == t) {
            cout << 1 << "\n";
        } else {
            cout << 2 << "\n";
        }
    } else {
        ll num_over = N;
        string tmp_s, tmp_t;
        for (ll i = 0; i < N; ++i) {
            tmp_s = s.substr(i, num_over);
            tmp_t = t.substr(0, num_over);
            if (tmp_s == tmp_t) {
                break;
            } else {
                num_over--;
            }
        }
        cout << 2*N - num_over << "\n";
    }
    
    return 0;
}


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

int main()
{
	int N, M, K, A;
	map<int, int> r;
	int ans = 0;

	cin >> N >> M;

	for (int i = 0; i < N; i++)
	{
		cin >> K;
		for (int j = 0; j < K; j++)
		{
			cin >> A;
			if (r.count(A))
			{
				r[A]++;
			}
			else
			{
				r[A] = 1;
			}
		}
	}
	for (auto itr = r.begin(); itr != r.end(); itr++)
	{
		if (itr->second == N)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return(0);
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	cin >> N;
	vector<int>v;

	v.resize(N);

	rep(i, N) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	
	double ans = 0;
	rep1(i, N) {
		if (i == 1) {
			ans = (double)(v[0] + v[1]) / 2;
		}
		else {
			ans = (double)(ans + v[i])/2;
		}
	}
	
	print(ans);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
data = []
for i in range(n):
    for j in range(len(a)):
        if a[len(a) - j - 1] == len(a) - j:
            data.append(a[len(a) - j - 1])
            del a[len(a) - j - 1]
            break
if len(data) == n:
    data.reverse()
    for x in data:
        print(x)
else:
    print(-1)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int s,w;
  char line[10];

  fgets(line,sizeof(line),stdin);
  sscanf(line,"%d%d",&s,&w);

  if(w>=s){
    printf("unsafe");
    return 0;
  }
  printf("safe");
  return 0;
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>pii;typedef vector<int>VI;typedef vector<pii>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=505;
int n,a[N][N],pd[N][N],q[N*N][2],ans;
signed main(){
	memset(a,192,sizeof(a));
	rd(n);
	rep(i,1,n)rep(j,1,n)a[i][j]=min({i-1,j-1,n-i,n-j}),pd[i][j]=1;
	rep(i,1,n*n){
		int k1;rd(k1);
		int x=(k1-1)/n+1,y=(k1-1)%n+1;
		ans+=a[x][y];
		int he=0,ta=1;
		q[1][0]=x,q[1][1]=y;
		pd[x][y]=0;
		while(he!=ta){
			x=q[++he][0],y=q[he][1];
			if(a[x][y-1]>a[x][y]+pd[x][y])q[++ta][0]=x,q[ta][1]=y-1,a[x][y-1]=a[x][y]+pd[x][y];
			if(a[x][y+1]>a[x][y]+pd[x][y])q[++ta][0]=x,q[ta][1]=y+1,a[x][y+1]=a[x][y]+pd[x][y];
			if(a[x-1][y]>a[x][y]+pd[x][y])q[++ta][0]=x-1,q[ta][1]=y,a[x-1][y]=a[x][y]+pd[x][y];
			if(a[x+1][y]>a[x][y]+pd[x][y])q[++ta][0]=x+1,q[ta][1]=y,a[x+1][y]=a[x][y]+pd[x][y];
		}
	}
	pt(ans,'\n');
	return 0;
}

Measured memory_bytes: 11396
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////


int main(){
	int n;
	long h;
	cin >> n >> h;
	long a = 0 ;
	vector<long> b(n);
	rep(i,0,n){
		long t;
		cin >> t >> b[i];
		a = max(t,a);
	}
	
	vsort(b);
	
	long ans=0;
	rrep(i,b.size()-1,0){
		if(b[i]<=a)
			break;
		h -= b[i];
		ans++;
		if(h <= 0)
			break;
	}
	
	if(h > 0){
		ans += h / a;
		if( h % a != 0 )
			ans++;
	}
	
	P(ans);

	ret 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		char c;
		cin>>c;
		if(c>='a')
			cout<<'a'<<endl;
		else
			cout<<"A"<<endl;
	}
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ll> a(n);
	ll c = 0;
	map<ll, ll> count, ans;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
		count[a[i]]++;
	}
	ll ct = 0;
	for(auto i: count)
	{
		if(i.second>=2)
		{
			ct+=(i.second)*(i.second-1)/2;
			// ct++;
		}
	}
	for(int i = 0; i < n; i++)
	{
		c = 0;
		if(count[a[i]]==2)
		{
			c = ct-1;
			cout<<c<<endl;
		}
		else if(count[a[i]] < 2)
		{
			c = ct;
			cout<<c<<endl;
		}
		else 
		{
			c = ct - (count[a[i]])*(count[a[i]]-1)/2 + (count[a[i]]-1)*(count[a[i]]-2)/2;
			cout<<c<<endl;
		}

	}

}

Measured memory_bytes: 11136
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    result = [0] * N

    for i in range(K):
        _ = int(input())
        A = list(map(int, input().split()))
        for a in A:
            result[a - 1] += 1
    print(result.count(0))


if __name__ == "__main__":
    main()


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, T;
  cin >> N >> T;
  VL ts(N);
  REP(i,N) cin >> ts[i];

  LL prv = -1e10, ans = 0;
  for(LL t: ts){
	if(prv <= t){
	  prv = t+T;
	  ans += T;
	}
	else{
	  ans += max(0ll, t+T - prv);
	  maxi(prv, t+T);
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	
	int l = 1, r = N;
	vector<pii> ans;
	REP(i, M) {
		if (N % 2 == 0 && (N / 2 - 1) % 2 == 0 && r - l == N / 2) --r;
		ans.emplace_back(l, r);
		if (N % 2 == 0 && (N / 2 - 1) % 2 == 1 && r - l == N / 2 + 1) --r;
		++l, --r; 
	}
	for (pii cur : ans) printf("%d %d\n", cur.fi, cur.se);
	return 0;
}


Measured memory_bytes: 4192
S = gets.strip.to_s
M = S.size
cnt = 0
if M%2==0 then
  (0..M/2-1).each do |i|
    if S[i]!=S[M-1-i] then
      cnt += 1
    end
  end
  puts cnt
else
  (0..(M-3)/2).each do |i|
    if S[i]!=S[M-1-i] then
      cnt += 1
    end
  end
  puts cnt
end

Measured memory_bytes: 14264
n, m, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))

if x[n - 1] < y[0] and x[n - 1] < Y and X < y[0]:
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int64_t f(int n);
vector <int64_t> memo(87, -1);

int main(){
  int n;
  cin >> n;
  memo[0] = 2;
  memo[1] = 1;
  cout << f(n) << endl;
  return 0;
}

int64_t f(int n){
  if (memo[n] != -1){
    return memo[n];
  }
  memo[n] = f(n - 2) + f(n - 1);
  return memo[n];
}


Measured memory_bytes: 256
result = []
gets.chomp.to_i.times do |inning|
  score = 0
  out = 0
  runner = 0
  while out < 3
    event = gets.chomp
    case event
    when "HIT"
      runner += 1
    when "HOMERUN"
      score += runner + 1
      runner = 0
    when "OUT"
      out += 1
    end
    if runner == 4
      score += 1
      runner = 3
    end
  end
  result[inning] = score
end

puts result

Measured memory_bytes: 8616
// atcoder/abc141/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {

    auto fn = [&] (int len) {
      map<ull, int> m;
      for (int i = 0; i + len <= s.size(); ++i) {
        ull h = 0;
        for (int j = 0; j < len; ++j) {
          h = h * 71 + (s[i + j] - 'a' + 1);
        }
        m[h] = i;
      }
      for (int i = 0; i + len <= s.size(); ++i) {
        ull h = 0;
        for (int j = 0; j < len; ++j) {
          h = h * 71 + (s[i + j] - 'a' + 1);
        }
        if (i + len <= m[h]) {
          return true;
        }
      }
      return false;
    };

    int small = 1;
    int large = 5000 + 5;
    while (small + 1 < large) {
      int mid = (small + large) / 2;
      if (fn(mid)) small = mid;
      else large = mid;
    }
    cout << (fn(small) ? small : 0) << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200005];
signed main(){
	int n;
	cin >> n;
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
	if(a[1] != 0)
	{
		cout << -1;
		return 0;
	}
	for(int i = 2 ; i <= n ; ++i)
	{
		if(a[i] > a[i - 1] + 1)
		{
			cout << -1;
			return 0;
		}
	}
	a[n + 1] = 1e9 + 7;
	int i = 1;
	int ans = 0;
	while(i <= n)
	{
		if(a[i] == 0)
		{
			i++;
			continue;
		}
		int t = a[i];	
		while(a[i + 1] == a[i] + 1)
		{
			i++;
			t++;
		}
		ans += t;
		i++;
	}
	cout << ans;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char prev = s.charAt(0);
        for(int i = 1; i < s.length(); i++) {
            char c = s.charAt(i);
          if(prev == c) {
              System.out.println("Bad");
              return;
          }
          prev = c;
        }
      System.out.println("Good");
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, Y;
	cin >> N >> Y;

	for(int a = 0; 10000 * a <= Y; a++) {
		for(int b = 0; 5000 * b <= Y; b++) {
			if(9 * a + 4 * b + N == (Y / 1000) && N - a - b >= 0) {
				cout << a << " " << b << " " << N - a - b << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
#define LL long long
#define inf 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>

int n,x;
int a[maxn];
map<int,int> p,q;
int ans=100000000;
int m1,m2,s1;

int main(){
	//freopen("test.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		if(i%2) p[a[i]]++;
		else q[a[i]]++;
	}
	for(map<int,int>::iterator it=p.begin();it!=p.end();++it){
		int v=it->second;
		if(v>m1){
			m2=m1;m1=v;s1=it->first;
		}else if(v>m2){
			m2=v;
		}
	}
	for(map<int,int>::iterator it=q.begin();it!=q.end();++it){
		if(it->first!=s1){
			ans=min(ans,n-(m1+it->second));
		}else if(m2!=0){
			ans=min(ans,n-(m2+it->second));
		}else{
			ans=min(ans,n-m1);
		}
	}
	cout<<ans<<endl;
	
	
    return 0;
}

Measured memory_bytes: 5376
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(A==B && B==C && C==A){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

/*[DSU TEMPLATE] int dsu[501], ranks[501];

void resetDSU(){
    for(int i = 0; i < 501; ++i){
        dsu[i] = i; ranks[i] = 0;
    }
}
int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(ranks[a] < ranks[b]){ dsu[a] = b; }
    else if(ranks[a] > ranks[b]){ dsu[b] = a; }
    else { dsu[a] = b; ranks[b]++; }
}*/

vector<pair<long double, long double>> x_p, y_p;

long double get_bound(vector<pair<long double, long double>> p1, vector<pair<long double, long double>> p2, long double mult){

    long double minix =  1e18;
    long double maxix = -1e18;

    long double miniy =  1e18;
    long double maxiy = -1e18;

    for(int i = 0; i < p1.size(); ++i){
        minix = min(minix, mult * p1[i].second + p1[i].first);
        maxix = max(maxix, mult * p1[i].second + p1[i].first);
        miniy = min(miniy, mult * p2[i].second + p2[i].first);
        maxiy = max(maxiy, mult * p2[i].second + p2[i].first);
    }

    return (maxix - minix) * (maxiy - miniy);

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        long double x, y;
        char d;
        cin >> x >> y >> d;
        if(d == 'U'){
            y_p.push_back(make_pair(y, 1));
            x_p.push_back(make_pair(x, 0));
        } else if(d == 'D'){
            y_p.push_back(make_pair(y, -1));
            x_p.push_back(make_pair(x, 0));
        } else if(d == 'R'){
            y_p.push_back(make_pair(y, 0));
            x_p.push_back(make_pair(x, 1));
        } else {
            y_p.push_back(make_pair(y, 0));
            x_p.push_back(make_pair(x, -1));
        }
    }

    long double left = 0, right = 1000000000;

    long double best = -1;

    for(int it = 0; it < 200; ++it){
        long double middle1 = left + (right - left) / 3;
        long double middle2 = right - (right - left) / 3;
        long double bound1 = get_bound(x_p, y_p, middle1);
        long double bound2 = get_bound(x_p, y_p, middle2);
        if(bound1 < bound2){
            right = middle2;
            if(best == -1)
                best = bound1;
            best = min(best, bound1);
        } else {
            left = middle1;
            if(best == -1)
                best = bound2;
            best = min(best, bound2);
        }
    }

    cout << fixed << setprecision(13) << best;

    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){
	lli n;
	cin>>n;

	vector<lli> a(n);

	REP(i,0,n){
		lli t;
		cin>>t;
		a[t-1]=i+1;
	}

	REP(i,0,n)cout<<a[i]<<" ";
	cout<<endl;

	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int k;
	cin >> k;
	string S;
	cin >> S;
	if (S.at(k - 1) == 'A') S.at(k - 1) = 'a';
	else if (S.at(k - 1) == 'B') S.at(k - 1) = 'b';
	else S.at(k - 1) = 'c';
	cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int n,i;
  scanf("%d",&n);
  char a[n];
  char b[n];
  char c[n];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  int ans = 0;
  for(i=0;i<n;i++) {
    if(a[i] == b[i]) {
      if(a[i] == c[i]) {
        ans += 0;
      } else {
        ans += 1;
      }
    } else {
      if(a[i] == c[i]) {
        ans += 1;
      } else {
        if(b[i] == c[i]) {
          ans += 1;
        } else {
          ans += 2;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int C, N, P[1010][1010];
int ok;
//---------------------------------------------------------------------------------------------------
int check(int x, int y) {
    if (P[y][x] == P[N - 1 - y][x] and P[y][x] == P[N - 1 - y][N - 1 - x] and P[y][x] == P[y][N - 1 - x]) return 1;
    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> C >> N;
    rep(y, 0, N) {
        string s; cin >> s;
        rep(x, 0, N) P[y][x] = s[x] - '0';
    }

    rep(y, 0, N / 2) rep(x, 0, N / 2) if (check(x, y)) ok++;
    
    int ans = 0;
    if (ok == N * N / 4) ans++;
    rep(c, 0, C - 1) {
        int D; cin >> D;
        rep(d, 0, D) {
            int r, c; cin >> r >> c;
            r--; c--;

            if (check(c, r)) ok--;
            
            P[r][c] = 1 - P[r][c];

            if (check(c, r)) ok++;
        }
        if (ok == N * N / 4) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7184
n=int(input())
a=list(map(int,input().split()))
b=[]
sum=0
for i in range(n):
    j=i+1-sum
    if a[i]!=j:
        sum+=1
    else:
        b.append(a[i])
def ans():
    if len(b)==0:
        print(-1)
        return
    for i in range(len(b)):
        if b[i]!=i+1:
            print(-1)
            return
    print(sum)
ans()

Measured memory_bytes: 25716
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, k;
int main() {
    cin >> n >> k;
    vector<ll> s(n);
    REP(i,n)cin >>s[i];
    sort(ALL(s));
    ll ans = 0;
    REP(i, k)ans += s[i];
    cout<<ans<<endl;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
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);
        CLowElements solver = new CLowElements();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLowElements {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] p = in.readIntArray(n);

            int answer = 0;
            for (int i = 0, min = Integer.MAX_VALUE; i < n; i++) {
                if (p[i] < min)
                    answer++;

                min = Math.min(min, p[i]);
            }

            out.println(answer);
        }

    }

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

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



Measured memory_bytes: 47892
#include<stdio.h>
#include<limits.h>
 
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int Q[N], M[N][N], color[N], d[N], n, f=1, c=1;
 
void Enqueue(int n){
  Q[f] = n;
  f++;
  if(f == N) f=1;
}
 
int Dequeue(){
  int x = c;
  c++;
  if(c == N) c=1;
  return Q[x];
}
 
void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f != c){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && M[u][i] == 1){
    color[i] = GRAY;
    d[i] = d[u] + 1;
    Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}
 
int main(){
  int i, j, k, x, s, m;
  for(i=1; i < n; i++){
    for(j=1; j < n; j++) M[i][j] = 0;
  }
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &m, &k);
    if(i == 1) s = 1;
    for(j=0; j < k; j++){
      scanf("%d",&x);
      M[m][x] = 1;
    }
  }
  BFS(s);
  for(i=1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using T = ll;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    ll n;
    cin >> n;
    ll res = 0;
    vector<string> s(n);
    rep(i, n)cin >> s[i];
    rep(a, n){
        vector<vector<char>> t(n, vector<char>(n));
        rep(i, n){
            rep(j, n){
                t[(i + a) % n][j] = s[i][j];
            }
        }
        bool f = true;
        rep(i, n){
            rep(j, n){
                if(t[i][j] != t[j][i])f = false;
            }
        }
        if(f)res++;
    }
    cout << res * n << endl;
}



Measured memory_bytes: 3868
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			System.out.println(a - b);
		}
	}
}

Measured memory_bytes: 17184
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int W, B;

signed main(){
    cin >> W >> B;
    W--; B--;
    cout << 100 << " " << 100 << endl;

    rep(i, 50){
        rep(j, 100){
            if(i%2==0 && j%2==0 && W > 0){
                W--;
                cout << ".";
            }
            else cout << "#";
        }
        cout << endl;
    }
    rep(i, 50){
        rep(j, 100){
            if(i%2==1 && j%2==0 && B > 0){
                B--;
                cout << "#";
            }
            else cout << ".";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9+7;

void solve() {
    map < ll , ll > l, r;
    l.clear();r.clear();
    ll n, i, j, k, a[200001], ans=0;
    cin>>n;
    fo(i,n) {
        cin>>a[i];
        r[i-a[i]]++;
    }
    fo(i,n) {
        r[i-a[i]]--;
        ans += r[i+a[i]];
    }
    cout<<ans;
}   

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}


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

int main()
{
  	vector<int> powers;
  	for(int i=0 ; i<=100 ; ++i)
    {
    	powers.push_back(pow(2,i));
    }
  	int n;
  	cin>>n;
  	for(int i=0 ; i<powers.size() ; ++i)
    {
    	if(powers[i]>n)
        {
          	cout<<powers[!i?0:i-1]<<endl;
        	break;
        }
    }
	return 0;
}

Measured memory_bytes: 256