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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int par[100000];

int find(int x)
{
  if(par[x] == x) return x;
  return par[x] = find(par[x]);
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  
  if(x == y) return;

  par[x] = y;
}

bool same(int x, int y)
{
  return find(x) == find(y);
}

ll cost(int a, int b, int c, int d)
{
  return min(abs(a-c), abs(b-d));
}

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

  vector<tuple<int, int, int> >  xy, yx;
  rep(i, n){
    int x, y;
    cin >> x >> y;
    xy.pb(mt(x, y, i));
    yx.pb(mt(y, x, i));
  }

  sort(all(xy));
  sort(all(yx));

  vector<tuple<ll, int, int> > es;
  rep(i, n-1) es.pb(mt(cost(get<0>(xy[i]), get<1>(xy[i]), get<0>(xy[i+1]), get<1>(xy[i+1])), get<2>(xy[i]), get<2>(xy[i+1])));
  rep(i, n-1) es.pb(mt(cost(get<0>(yx[i]), get<1>(yx[i]), get<0>(yx[i+1]), get<1>(yx[i+1])), get<2>(yx[i]), get<2>(yx[i+1])));

  sort(all(es));

  rep(i, n) par[i] = i;

  ll ans = 0;
  for(auto e : es){
    int x, y, c;
    tie(c, x, y) = e;
    if(!same(x, y)){
      ans += c;
      unite(x, y);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9640
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const double pi=acos(-1);

int main(){
  double a,b,c;
  cin >> a >> b >> c;
  c/=180;
  c*=pi;
  double s,l,h;
  s=a*b*sin(c)/2;
  double d=pow(a,2)+pow(b,2)-2*a*b*cos(c);
  d=sqrt(d);
  l=a+b+d;
  h=2*s/a;
  cout<< fixed << setprecision(10) << s << endl;
  cout<< fixed << setprecision(10) << l << endl;
  cout<< fixed << setprecision(10) << h << endl;
}



Measured memory_bytes: 3468
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
using namespace std;

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

	vector<int> niz(n);

	for (int i = 0; i < n; i++)
		cin >> niz[i];

	double sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += (double)1 / niz[i];
	}

	cout << 1 / sum;
}

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

int main(){
  int n;
  cin >> n;
  int num = 7;
  if(num%2==0){
    cout << "-1" <<endl;
    return 0;
  }
  if(num%10==5){
    cout << "-1" <<endl;
    return 0;
  }
  int cnt=0;
  int l = 7%n;
  int k = 10%n;
  int mod=0;
  while(cnt<n){
    mod = mod*k+l;
    cnt++;
    if(mod%n==0){
      cout<< cnt <<endl;
      return 0;
    }
    mod %= n;
  }
  cout << "-1"<<endl;

}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int read() {
	int ans = 0 , flag = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0') {if(ch == '-') flag = - flag; ch = getchar();}
	while(ch >= '0' && ch <= '9') {ans = ans * 10 + ch - '0'; ch = getchar();}
	return ans * flag;
}
int n;
int v[100010];
int num[2][100010];
int first[2];
int second[2];
int main() {
	n = read();
	for(int i = 1 ; i <= n ; ++ i) ++ num[i % 2][v[i] = read()];
	for(int i = 1 ; i <= 100000 ; ++ i) {
		if(num[0][i] >= num[0][first[0]]) {
			second[0] = first[0];
			first[0] = i;
		}
		else if(num[0][i] > num[0][second[0]])
			second[0] = i;
		if(num[1][i] >= num[1][first[1]]) {
			second[1] = first[1];
			first[1] = i;
		}
		else if(num[1][i] > num[1][second[1]])
			second[1] = i;
	}
	if(first[0] != first[1])
		printf("%d\n" , n - num[0][first[0]] - num[1][first[1]]);
	else
		printf("%d\n" , n - max(num[0][second[0]] + num[1][first[1]] , num[0][first[0]] + num[1][second[1]]));
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


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

	ll ans = 0;
	rep(i, 4) if (S[i] == '2') { ans++; }

	cout << ans;
	

	system("PAUSE");
}


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

int N,M,L,R;
int l,r;
int main() {
    cin>>N>>M;
    l = 1, r = N;
    bool zero = false;
    while(M--) {
        cin>>L>>R;
        if(zero) continue;
        if(r < L || l > R) {
            zero=true;
            continue;
        }
        l = max(l, L);
        r = min(r, R);
    }
    cout<<(zero ? 0 : r-l+1);
}

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

int find(int a[],int n) {
    for(int i=0;i<12;i++) {
        if(n==a[i]) return i;
    }
}

int main() {
    int x,y;
    cin>>x>>y;
    int group[12]={1,3,5,7,8,10,12,4,6,9,11,2};
    int target=find(group,x);
    int own=find(group,y);
    if((target>=0 && target<=6) && (own>=0 && own<=6)) cout<<"Yes"<<endl;
    else if((target>=7 && target<=10) && (own>=7 && own<=10)) cout<<"Yes"<<endl;
    else if(target==11 && own==11) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

struct mint {
  int n;
  mint(int n = 0) : n(n) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

mint pr(char c, char d) {
  if (c == '?') return (mod + 1) / 3;
  if (c == d) return 1;
  return 0;
}

int main() {
  string s;
  cin >> s;
  const int n = s.size();
  const mint third = (mod + 1) / 3;
  mint A = 0, C = 0;
  for (char c : s) C += pr(c, 'C');
  mint E = 0;
  for (char c : s) {
    C -= pr(c, 'C');
    E += A * C * pr(c, 'B');
    A += pr(c, 'A');
  }
  for (char c : s) if (c == '?') E *= 3;
  cout << E << endl;
}

Measured memory_bytes: 512
N = int(input())

v = input().split()

v = [float(i) for i in v]
v.sort()

for i in range(N - 1):
  min1 = v[0]
  min2 = v[1]
  tmp = (min1 + min2) / 2.0
  v.pop(0)
  v.pop(0)
  v.insert(0, tmp)
print(*v)




Measured memory_bytes: 3060
/**
*    author:  souzai32
*    created: 04.08.2020 01:37:27
**/

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

int main() {

    string s;
    cin >> s;
    int n=s.size();
    int count=0;

    rep(i,n-1) if(s.at(i+1)!=s.at(i)) count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;


int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int64_t solve(int64_t val) {
	if (val == 0) return 0;

	static unordered_map<int64_t, int64_t> memo;
	auto it = memo.find(val);
	if (it != memo.end()) {
		return it->second;
	}

	int64_t cnt = 0;
	FOR_LT(i, 0, 32) {
		if (val & (1 << i)) cnt++;
	}
	int64_t nv = val % cnt;
	int64_t ans = solve(nv) + 1;
	memo.insert({ val, ans });
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	string s; cin >> s;

	int cnt = 0;
	FOR_LT(i, 0, s.size()) {
		if (s[i] == '1') cnt++;
	}

	int64_t nu = 0, nd = 0;
	int64_t cntu = cnt + 1;
	int64_t cntd = cnt - 1;
	int64_t vu = 1, vd = 1;
	vector<int64_t> vus(n + 1);
	vector<int64_t> vds(n + 1);
	FOR_DW(i, n - 1, 0) {
		vus[i] = vu;
		vds[i] = vd;
		if (s[i] == '1') {
			nu += vu;
			nd += vd;
		}
		vu *= 2;
		vu %= cntu;
		if (cntd >= 1) {
			vd *= 2;
			vd %= cntd;
		}
	}

	FOR_LT(i, 0, n) {
		if (s[i] == '1') {
			if (cntd <= 0) {
				cout << 0 << endl;
				continue;
			}
			int64_t cv = nd - vds[i];
			cv %= cntd;
			if (cv < 0) cv += cntd;
			//cout << i << " " << nd << " " << cv << " " << cntd << endl;
			cout << solve(cv) + 1 << endl;
		}
		else {
			int64_t cv = nu + vus[i];
			cv %= cntu;
			//cout << i << " " << nu << " " << cv << " " << cntu << endl;
			cout << solve(cv) + 1 << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b){
	if(a==0){
		return b;
	}
	return GCD(b%a,a);
}
int main()
{
    long long a,b;
    while(cin>>a>>b){
       	cout<<GCD(a,b)<<" "<<(a*b)/GCD(a,b)<<endl;
    }
    return 0;
}

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

static const int INF = 1000000000;
int cnt = 0;

void merge(vector<int> &A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INF, R[n2] = INF;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void merge_sort(vector<int> &A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

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

    merge_sort(S, 0, n);

    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6804
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
typedef long long LL;

double s(LL n) {
	LL x = n;
	LL y = 0;
	while (x) {
		y += x % 10;
		x /= 10;
	}
	return (double)n / y;
}

int main() {
	LL K;
	LL n = 1;
	LL x = 1;

	cin >> K;

	for (int i = 0; i < K; i++) {
		cout << n << endl;

		if (s(n + x) > s(n + x * 10))x *= 10;

		n += x;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

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

ll dp[1500][15000];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N, W; scanf("%lld %lld", &N, &W);
	vector<ll> w, v;
	for (ll i = 0; i < N; i++) {
		ll tv, tw, m; scanf("%lld %lld %lld", &tv, &tw, &m);
		ll now = 1;
		ll pl = 1;
		while (now <= m) {
			w.push_back(tw * pl);
			v.push_back(tv * pl);
			pl *= 2;
			if (now + pl <= m) {
				now += pl;
			}
			else {
				w.push_back(tw * (m - now));
				v.push_back(tv * (m - now));
				break;
			}
		}
	}
	N = w.size();
	for (ll i = 0; i <= N; i++)for (ll j = 0; j <= W + 5; j++) dp[i][j] = -1;
	dp[0][0] = 0;
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j <= W; j++) {
			if (dp[i][j] == -1) continue;
			chmax(dp[i + 1][j], dp[i][j]);
			if (j + w[i] <= W) chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
		}
	}
	//for (ll i = 0; i <= W; i++) cout << dp[N][i] << endl;
	cout << *max_element(dp[N], dp[N] + W + 1) << endl;
	return 0;
}



Measured memory_bytes: 118336
import static java.lang.System.out;
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Main test = new Main();
        List<Integer> list = test.makeList();
        Collections.sort(list);
        out.printf("%d %d %d%n", list.get(0), list.get(1), list.get(2));

    }

    public List<Integer> makeList() {
        Scanner scan = new Scanner(System.in);
        List<Integer> nums = new ArrayList<>();
        nums.add(scan.nextInt());
        nums.add(scan.nextInt());
        nums.add(scan.nextInt());

        return nums;
    }                                                                  
}

Measured memory_bytes: 26536
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

bool eq(ld a, ld b){
	return abs(a-b) < EPS;
}

struct PT{
	ld x, y;
	PT (ld x = 0, ld y = 0) : x(x), y(y) {}
	PT operator + (PT ro) const{
		return PT(x+ro.x, y+ro.y);
	}
	PT operator - (PT ro) const{
		return PT(x-ro.x, y-ro.y);
	}
	PT operator * (ld co) const{
		return PT(x*co, y*co);
	}
	PT operator / (ld co) const{
		return PT(x/co, y/co);
	}
	ld operator * (PT ro) const{
		return x*ro.x + y*ro.y;
	}
	ld operator ^ (PT ro) const{
		return x*ro.y - y*ro.x;
	}
};

istream& operator>> (istream &is, PT &p){
	ld val;
	is >> val;
	p.x = val;
	is >> val;
	p.y = val;
	return is;
}

PT operator * (ld co, PT p){
	return p*co;
}

ld len(PT a){
	return sqrt(a*a);
}

PT unit(PT a){
	return a/len(a);
}

PT clrot(PT a){
	return PT(-a.y, a.x);
}

PT proj(PT a, PT b, PT c){
	b = b-a, c = c-a;
	return a + (b*c)/(b*b)*b;
}

PT reflect(PT a, PT b, PT c){
	PT d = c;
	b = b-a, c = c-a;
	return d + (c^b)/len(b)*clrot(unit(b))*2;
}

int sgn(PT a, PT b, PT c){
	ld cr = (b-a)^(c-a);
	return cr > EPS ? 1 : (cr + EPS < 0 ? -1 : 0);
}

bool intersect(PT a, PT b, PT c, PT d){
	int as = sgn(c, d, a),
		bs = sgn(c, d, b),
		cs = sgn(a, b, c),
		ds = sgn(a, b, d);
	if (as && as == bs || cs && cs == ds)
		return false;
	else if (as || bs || cs || ds)
		return true;
	for (int j = 0; j < 2; j++){
		ld mx = min(a.x, b.x),
		   Mx = max(a.x, b.x),
		   my = min(a.y, b.y),
		   My = max(a.y, b.y);
		for (int k = 0; k < 2; k++){
			if (c.x + EPS > mx && c.x < Mx + EPS && c.y + EPS > my && c.y < My + EPS)
				return true;
			swap(c, d);
		}
		swap(a, c);
		swap(b, d);
	}
	return false;
}

int main(){
	for (int i = in(); i; i--){
		PT a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << intersect(a, b, c, d) << '\n';
	}
	return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <inttypes.h>

uint32_t N, A, B;
uint32_t X[114514];

int main(void) {
	uint32_t i;
	uint64_t answer = 0;
	if (scanf("%" SCNu32 "%" SCNu32 "%" SCNu32, &N, &A, &B) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%"  SCNu32, &X[i]) != 1) return 1;
	}
	for (i = 1; i < N; i++) {
		uint64_t c1 = (uint64_t)A * (X[i] - X[i - 1]);
		uint64_t c2 = B;
		answer += c1 <= c2 ? c1 : c2;
	}
	printf("%" PRIu64 "\n", answer);
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<vector<int>> C(N, vector<int>(N));
    for (auto& v : C) for (auto& e : v) cin >> e;
    long long mini = 0ll;
    rep(i, N) rep(j, i) mini += min(C[i][j], C[j][i]);
    cout << mini << endl;
}

Measured memory_bytes: 3176
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


double c(double x)
{
  double X = x;
  X = int(X) % 10;
  return X;
}

int main()
{
  ll a,b;
  cin >> a >> b;
  for(int i = 1;i < 1010;i++)
  {
    if(i*8/100 == a && i*10/100 == b)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 764
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll A;
    string B;

    in2(A, B);


    ll b = 0;
    rep(i, B.size())
    {
        if (B[i] == '.') continue;

        b *= 10;
        b += B[i] - '0';
    }

    outl((A* b) / 100);

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
const int N = 200064, inf = 0xcdcdcdcd;
inline void Max(int &a, int b) {if (a < b) a = b;}

int p[N], f[2][N], t[N], n;
bool h[N];
vector<pair<int*,int>> stk;

void upd(int (&tr)[N], int x, int v) {
	do if (tr[x] < v) {
		stk.emplace_back(tr+x, tr[x]);
		tr[x] = v;
	  }
	while (x &= x-1);
}
int qry(int (&tr)[N], int x) {
	int v = inf-8;
	do Max(v, tr[x]);
	while ((x += x&-x) <= n);
	return v;
}

inline bool chk(int h1, int d) {	// d = c0 - c1 + q;
	return d >= 0 && qry(f[d&1], h1) >= d;
}
inline bool check(int h0, int h1, int d, int q) {	// d = c0 - c1
	return chk(h0, q - d) || chk(h1, q + d);
}

int main() {
	scanf("%d",&n);
	memset(f[1]+1, 0xcc, n<<2);
	int q = 0;
	for (int i = 0, mx = 0; i < n; i++) {
		scanf("%d",p+i);
		if (p[i] > mx) {
			mx = p[i];
			h[i] = true;
			q++;
		}
	}
	for (int i = n, g0, g1; i--;) {
		t[i] = stk.size();
		if (h[i]) {	//w = 2
			g0 = qry(f[0], p[i]) + 2;
			g1 = qry(f[1], p[i]) + 2;
		} else {	//w = 1
			g0 = qry(f[1], p[i]) + 1;
			g1 = qry(f[0], p[i]) + 1;
		}
		if (g0 > inf) upd(f[0], p[i], g0);
		if (g1 > inf) upd(f[1], p[i], g1);
	}
	if (!chk(1, q)) {puts("-1"); return 0;}
	int h0 = 1, h1 = 1, d = 0, top = stk.size();
	for (int i = 0; i < n; i++) {
		q -= h[i];
		while (top > t[i]) {	//undo
			auto &p = stk[--top];
			*p.first = p.second;
		}
		if (h0 <= p[i])
			if (check(p[i], h1, d+1, q)) {
				putchar('0');
				h0 = p[i]; d++;
			} else {
				putchar('1');
				if (h1 <= p[i])
					h1 = p[i], d--;
			}
		else if (check(h0, h1, d, q))
				putchar('0');
			else {
				putchar('1');
				if (h1 <= p[i])
					h1 = p[i], d--;
			}
	}
	return 0;
}


Measured memory_bytes: 37988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll n,a,b,mn,mx;
    cin >> n >> a >> b;
    mn = min(a,b);
    mx = max(a,b);
    if((mx-mn)%2 == 0){
        cout << (mx-mn)/2 << endl;
    }else{
        ll kouho = min(n-mn,mx-1);  // max?
        ll kouho2 = mx-mn;
        kouho2 = (kouho2-1)/2;
        kouho2 += mn;  // 準備分

        ll kouho3 = mn+n-mx+1;
        kouho3 = (n-kouho3)/2;
        kouho3 += (n-mx+1);  // 準備分
        kouho = min(kouho,kouho2);
        kouho = min(kouho,kouho3);

        ll awase1,awasen;
        awase1 = max(mx-1,mn-1);
        awasen = max(n-mx,n-mn);
        awase1 = min(awase1,awasen);
        kouho = min(kouho,awase1);

        cout << kouho << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
check = 1
for i in range(n+1):
  for j in range(n-i+1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n-i-j)
      check = 0
      break
  else:
    continue
  break
if check:
  print(-1, -1, -1)

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

int main(void) {
  string s;
  cin >> s;
  vector<bool> a(26, false);
  
  for(int i = 0; i < s.length(); ++i) {
    int t = s[i] - 'a';
    a[t] = true;
  }
  
  for(int i = 0; i < 26; ++i) {
    if (!a[i]) {
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N, M = MAP()
A = sorted(LIST())
BC = [LIST() for _ in range(M)]

BC.sort(key = lambda x: (-x[1],-x[0]))

i = 0
for b, c in BC:
	for j in range(b):
		if N <= i+j or c <= A[i+j]:
			print(sum(A))
			exit()
		A[i+j] = c
	else:
		i += b
else:
	print(sum(A))

Measured memory_bytes: 47116
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s

int n,a[100005],dp[100005];

int main()
{
	cin >> n;
	REP(i, n) cin >> a[i];
	fill(dp, dp + 100005, INF);
	REP(i, n) *lower_bound(dp, dp + n, a[i]) = a[i];
	cout << lower_bound(dp, dp + n, INF) - dp << endl;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll x, a, b; cin >> x >> a >> b;
  x -= a;
  fin(x-(x/b) * b)
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
if n == 1:
    st = 0
else:
    st = 10**(n-1)

en = 10**n
cond = [list(map(int,input().split())) for _ in range(m)]


for i in range(st,en):
    f = 1
    s = str(i)
    for j in range(m):
        if s[cond[j][0]-1] != str(cond[j][1]):
            f = 0
            break
        else:
            pass
    
    if f:
        print(i)
        break

if not f:
    print(-1)

Measured memory_bytes: 3064
n,k = map(int, input().split())
d = {}
for _ in range(n):
  a,b = map(int, input().split())
  if a not in d: d[a] = b
  else: d[a] += b

t = 0
for i in sorted(d.items(), key=lambda x:x[0]):
  t += i[1]
  if t >= k:
    print(i[0])
    exit()

Measured memory_bytes: 20976
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{

	int N, A, B, C, Max, sumv, sumc;
	int *D;

	cin >> N;

	D = new int[N];

	cin >> A >> B >> C;

	for( int i = 0; i < N; i++ ) cin >> D[i];

	sort( D, D + N, greater< int >() );

	Max  = 0;
	sumv = 0;
	sumc = 0;

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

		sumv  = A + ( i + 1 ) * B;
		sumc += D[i];

		if( Max < ( sumc + C ) / sumv ) Max = ( sumc + C ) / sumv;

	}

	cout << Max << endl;

	return 0;

}

Measured memory_bytes: 1204
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"10
aabbbbaaca"# => r#"5"#,

r#"5
aaaaa"# => r#"1"#,

r#"20
xxzaffeeeeddfkkkkllq"# => r#"10"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        _n: usize,
        mut s: chars,
    }
    s.dedup();

    s.len().to_string()
}

Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] X=new int[n];
		int min=1000000000;
		int max=0;
		for(int i=0;i<n;i++){
			int x=scanner.nextInt();
			min=Math.min(min, x);
			max=Math.max(max, x);
			X[i]=x;
		}
		int p=(min+max)/2;
		int ans = 1000000000;
		for (int j = min; j <= max; j++) {
			int tmp = 0;
			for (int i = 0; i < n; i++) {
				tmp += (X[i] - j) * (X[i] - j);
			}
			ans = Math.min(ans, tmp);
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22740
using System;
using System.Collections.Generic;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long X = arr[0], Y = arr[1];
        var list = new List<long> {X};
        for (int i = 1; list[i - 1] * 2 <= Y; i++) {
            list.Add(list[i - 1] * 2);
        }
        var answer = list.Count;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27856
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
 
ll l;
Vi bit;
struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;
graph g;

typedef ll RUI;//型は適当に合わせて.
RUI rui(ll num,ll k){//num^k
    RUI ans = 1;
    RUI n = num;
    while(k>0){
        if(k&1)ans *= n;
        n *= n;
        k /= 2;
    }
    return ans;
}
vector<tuple<ll,ll,ll>> ans;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>l;l--;
    ll tmp = 1;
    ll sum = 1;
    ll ed = 0;
    ll ve = 0;
    rep(i,l){
        //cout<<i+1<<" "<<i+2<<" "<<tmp<<endl;
        //cout<<i+1<<" "<<i+2<<" "<<0<<endl;
        ans.pb(make_tuple(i+1,i+2,tmp));
        ans.pb(make_tuple(i+1,i+2,0));
        ed += 2;
        chmax(ve,i+2);
        if((sum + tmp*2)>l)break;
        tmp *= 2;
        sum += tmp;
    }
    ll tp = sum;
    while(1){
        if(tp>=l)break;
        tp++;
        rep(i,l){
            if(tp + rui(2,i)-1>l){
                //cout<<i<<" "<<i+1<<" "<<tmp<<endl;
                ans.pb(make_tuple(i,ve,tp));
                ed++;
                sum = tp + rui(2,i-1)-1;
                break;
            }
        }
        tp = sum;
    }
    princ(ve);
    print(ans.size());
    rep(i,ans.size()){
        tuple<ll,ll,ll> tp = ans[i];
        cout<<get<0>(tp)<<" "<<get<1>(tp)<<" "<<get<2>(tp)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int arr1[n],arr2[n],arr3[n],ans1[n],ans2[n],ans3[n],i;
		for(i=0;i<n;i++)
			cin>>arr1[i]>>arr2[i]>>arr3[i];
		ans1[0]=arr1[0];
		ans2[0]=arr2[0];
		ans3[0]=arr3[0];
		for(i=1;i<n;i++)
		{
			ans1[i]=arr1[i]+max(ans2[i-1],ans3[i-1]);
			ans2[i]=arr2[i]+max(ans1[i-1],ans3[i-1]);
			ans3[i]=arr3[i]+max(ans2[i-1],ans1[i-1]);
		}
		cout<<max(max(ans1[n-1],ans2[n-1]),ans3[n-1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int num[100000];
	for (int i = 1; i <= N; i++) {
		cin >> num[i];
		num[i] = num[i] * MOD + i;
	}
	sort(num + 1, num + N + 1);
	for (int i = 1; i <= N; i++) {
		if (i > 1)cout << " ";
		cout << i*N;
	}
	cout << endl;
	for (int i = 1; i <= N; i++) {
		if (i > 1)cout << " ";
		cout << (N - i + 1)*N + num[i] % MOD;
	}
	cout << endl;
	return 0;
}

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

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

constexpr int INF = 1000000000;

enum CYK_TABLE {
  DIGIT,
  LPAR,
  RPAR,
  PLUS,
  MINUS,
  TERM,
  RPEXPR,
  RMEXPR,
  LEXPR,
  EXPR
};

int main(){
  int N = 10;
  string s;
  cin>>s;
  int n = s.size();
  vector<vector<vector<bool>>> cyk(n, vector<vector<bool>>(n+1, vector<bool>(N, false)));
  vector<vector<vector<int>>> mn(n, vector<vector<int>>(n+1, vector<int>(N, INF)));
  vector<vector<vector<int>>> mx(n, vector<vector<int>>(n+1, vector<int>(N, -INF)));
  REP(i,n) {
    if (isdigit(s[i])) {
      cyk[i][1][DIGIT] = true;
      mn[i][1][DIGIT] = s[i] - '0';
      mx[i][1][DIGIT] = s[i] - '0';
    } else {
      switch (s[i]) {
        case '(':
        cyk[i][1][LPAR] = true;
        break;
        case ')':
        cyk[i][1][RPAR] = true;
        break;
        case '+':
        cyk[i][1][PLUS] = true;
        break;
        case '-':
        cyk[i][1][MINUS] = true;
        break;
      }
    }
  }
  vector<pair<int, int>> m = {
    {DIGIT, TERM},
    {EXPR, TERM},
    {EXPR, LEXPR},
    {LEXPR, EXPR}
  };
  map<pair<int,int>, int> m2 = {
    {{PLUS, TERM}, RPEXPR},
    {{TERM, RPEXPR}, EXPR},
    {{MINUS, TERM}, RMEXPR},
    {{TERM, RMEXPR}, EXPR},
    {{LPAR, EXPR}, LEXPR},
    {{LEXPR, RPAR}, EXPR}
  };
  for (int l = 1; l <= n; ++l) {
    REP(i,n) {
      if (i+l > n) continue;
      REP(k,l) {
        if (k == 0) continue;
        for (auto p : m2) {
          int left, right, res;
          pair<int,int> tmp;
          tie(tmp, res) = p;
          tie(left, right) = tmp;
          if (cyk[i][k][left] && cyk[i+k][l-k][right]) {
            cyk[i][l][res] = true;
            if (right == RPEXPR) {
              mn[i][l][res] = min(mn[i][l][res],
                  mn[i][k][left] + mn[i+k][l-k][right]);
              mx[i][l][res] = max(mx[i][l][res],
                  mx[i][k][left] + mx[i+k][l-k][right]);
            } else if (right == RMEXPR) {
              mn[i][l][res] = min(mn[i][l][res],
                  mn[i][k][left] - mx[i+k][l-k][right]);
              mx[i][l][res] = max(mx[i][l][res],
                  mx[i][k][left] - mn[i+k][l-k][right]);
            } else if (right == EXPR || right == TERM) {
              mn[i][l][res] = min(mn[i][l][res], mn[i+k][l-k][right]);
              mx[i][l][res] = max(mx[i][l][res], mx[i+k][l-k][right]);
            } else if (left == LEXPR) {
              mn[i][l][res] = min(mn[i][l][res], mn[i][k][left]);
              mx[i][l][res] = max(mx[i][l][res], mx[i][k][left]);
            }
          }
        }
      }
      while (true) {
      bool update = false;
        for (auto p : m) {
          int src, res;
          tie(src, res) = p;
          if (cyk[i][l][src]) {
            if (!cyk[i][l][res]) update = true;
            cyk[i][l][res] = true;
            mn[i][l][res] = min(mn[i][l][res], mn[i][l][src]);
            mx[i][l][res] = max(mx[i][l][res], mx[i][l][src]);
          }
        }
        if (!update) break;
      }
    }
  }
  cout << mx[0][n][EXPR] << endl;
  return 0;
}

Measured memory_bytes: 11608
for i in $(seq 5); do read a[$i];done
sum=0
res=10
for i in $(seq 5); do $((sum += ((a[i]-1)/10 +1)*10))>/dev/nul;x=a[$i]%10; $(( res=(x !=0 && x<res)? x:res)) >/dev/nul; done 
echo $((sum -10 + res))


Measured memory_bytes: 648
def resolve():
    N, M = [int(i) for i in input().split()]
    aabb = [list(map(int, input().split())) for _ in range(M)]
    to_N, from_1 = set(), set()
    for a, b in aabb:
        if b == N:
            to_N.add(a)
        elif a == 1:
            from_1.add(b)
    if len(to_N & from_1) > 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


resolve()


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) {
    cout << "bust" << endl;
  }else {
    cout << "win" << endl;
  }
}
  

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

int main() {
  int N;
  cin>>N;
 
int sum=0;
  for(int i=0;i<N;i++){
    
    int a,b;
    cin>>a>>b;
 
   sum+=b-a+1;
     
  }
  cout<<sum<<endl;
 
    
  
  }
  

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

int main() {
  string s;
  cin >> s;
  string sum;
  for(int i = 0; i < s.size(); i++){
    if(i % 2 == 0){
      sum += s[i];
    }
  }
  cout << sum << endl;
}

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

int main(){
	int n; cin>>n;
	int flag = 0;
	for(int i=0; i<n; i++) {
		int x; cin>>x;
		if(x%2) flag++;
	}
	if(flag%2==0) cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 384
N = int(input())
K = int(input())

def ev(bi):
    ret = 1
    for b in bi:
        if b == "0":
            ret *= 2
        else:
            ret += K
    return ret

INF = 100000000000000000
ans = INF
for i in range(N):
    bi = list(format(2 ** i - 1, "0{}b".format(N)))
    ans = min(ans, ev(bi))
print(ans)


Measured memory_bytes: 3060
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int64 n, k; cin >> n >> k;

  int64 ans = 0;

  for (int64 b = 1; b <= n; ++b) {
    int64 p = n / b, q = n % b;
    ans += p * max((int64) 0, b - k) + max((int64) 0, q - k + 1);
  }

  print(ans - (k == (int64) 0 ? n : (int64) 0));

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000000

void maxHeapify( int*, int );
void swap( int* ,int* );

int H;

int main() {
  int i, A[MAX];

  scanf("%d",&H);

  for( i = 1 ; i <= H ; i++ ){

    scanf("%d",&A[i]);
  }

  for( i = H/2 ; i > 0 ; i-- ) {
    maxHeapify( A , i );
  }

  for( i = 1 ; i <= H ; i++ ){

    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;

}


void maxHeapify( int* A, int i ){
  int l , r , largest;
  l = 2 * i;
  r = 2 * i + 1;
  largest = i;

  if( A[largest] < A[l] && l <= H ) largest = l; 
  if( A[largest] < A[r] && r <= H ) largest = r; 
    

  if( largest != i ){
      swap( &A[i] ,&A[largest] );
      maxHeapify( A , largest );
    }
  }


void swap( int* x , int* y ) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

}

Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar1[2000000];
int main()
{
    ll test,n,k,i;
    cin>>n;
    ll s=0;
    k=0;
    for(i=1;i<=n;i++)
    {
        cin>>ar1[i];
        s+=ar1[i];
        k=max(k,ar1[i]);
    }
    cout<<s-k/2<<endl;
    return 0;
}


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

using namespace std;

const int N = 2e5 + 10;

int n, m;
int x, y;
vector<int> edge[N];

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (x > y) swap(x, y);
    if (x == 1 || y == n) edge[x].push_back(y);
  }
  for (int v : edge[1]) {
    if (v != n && edge[v].size()) {
      cout << "POSSIBLE" << "\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << "\n";
  return 0;
}

Measured memory_bytes: 8440
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;

    if((B-2*A)%2==0){
        N = (B-2*A)/2;
        M = A - N;
        if(M>=0&&N>=0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }

    

}

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.length(),a[n]={0},b[n],ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            a[i]++;

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

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



Measured memory_bytes: 3732