akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N , a[100010];
map<int, int> m;
vector<int> v;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
        m[a[i]]++;
    }

    auto itr = m.begin();
    while(itr != m.end()){
        if((*itr).F > (*itr).S) v.push_back((*itr).S);
        else v.push_back(min(abs((*itr).F - (*itr).S), (*itr).S));
        itr++;
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    int ans = 0;
    REP(i,0,v.size()){
        if(v[i] == 0) break;
        ans += v[i];
    }

    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int res[N];
    for (int i = 0; i < N; i++) {
        res[i] = 0;
    }
    int numAc = 0;
    int numWa = 0;
    int nowI;
    string nowRes;
    for (int i = 0; i < M; i++) {
        cin >> nowI >> nowRes;
        if (res[nowI - 1] == -1) {
            continue;
        }
        if (nowRes == "WA") {
            res[nowI - 1]++;
        } else {
            numAc++;
            numWa += res[nowI - 1];
            res[nowI - 1] = -1;
        }
    }
    cout << numAc << " " << numWa;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll, ll>P;
const ll mod = 1e9 + 7;
const int INF = 1000000;
const double PI = 3.14159265359;


int main() {

	int a, b; cin >> a >> b;

	if (a < b)swap(a, b);

	rep(i, 0, a) {
		cout << b;
	}
	cout << endl;



	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	double L;
	cin >> L;
	L /= 3;
	L = L * L * L;
	cout << L << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
class Node {
public:
	int location;
	int p, L, R;
	Node() {}
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y):id(id), x(x), y(y) {}
	bool operator < (const Point &p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int n;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTtree( int L, int R, int depth) {
	if( L >= R ) return NIL;
	int mid = ( L + R ) / 2;
	int t = np++;
	if( depth % 2 == 0 ) {
		sort(P+L, P+R, lessX);
	} else {
		sort(P + L, P + R, lessY);
	}
    
    T[t].location = mid;
    T[t].L = makeKDTtree(L, mid, depth + 1 );
    T[t].R = makeKDTtree(mid+1, R, depth + 1 );
	return t;
}

void find(int v, int sx, int tx, int sy, int ty,
 int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if( sx <= x && x <= tx && sy <= y && y <= ty) 
		ans.push_back(P[T[v].location]);

	if( depth % 2 == 0) {
		if ( T[v].L != NIL ) {
			if( sx <= x ) find(T[v].L, sx, tx, sy, ty, depth + 1,ans);
		}
		if ( T[v].R != NIL && x <= tx ) find(T[v].R, sx, tx, sy, ty, depth + 1,ans);
		
	} else {
		if ( T[v].L != NIL ) {
			if( sy <= y ) find(T[v].L, sx, tx, sy, ty, depth + 1,ans);
		}
		if ( T[v].R != NIL && y <= ty ) find(T[v].R, sx, tx, sy, ty, depth + 1,ans);
	}
}



int main() {
	
	int x, y;
	
	cin >> n;
	for(int i = 0; i < n; ++i) {
		scanf("%d%d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].L = T[i].R = T[i].p = NIL;
	}

    np = 0;
    int root = makeKDTtree(0, n, 0);
    
    int q;
	cin >> q;
	int sx, tx, sy, ty;
	vector<Point> ans;

	for(int i = 0; i < q; ++i) {
		scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);

		sort(ans.begin(), ans.end());
		for( int j = 0; j < ans.size(); j++) 
			printf("%d\n", ans[j].id );

		
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 16492
#include <stdio.h>
#include <string.h>

#define N 100
#define M 100000

static int w;
static int h;
static int k_operafan[ N ][ N ][ 4 ];

static int
dpFSA (
  int x,
  int y,
  int f
  )
{
  if ( x == w && y == h )     return ( 1 );
  else if ( x > w || y > h )  return ( 0 );
  else if ( ~k_operafan[ x ][ y ][ f ] ) ;
  else
  {
    k_operafan[ x ][ y ][ f ] = 0;

    if ( ( f & 1 ) == 0 || f == 3 )
    {
      k_operafan[ x ][ y ][ f ]
        += dpFSA ( x + 1, y, ( ( f & 1 ) << 1 ) | 0 );
    }
    if ( ( f & 1 ) == 1 || f == 0 )
    {
      k_operafan[ x ][ y ][ f ]
        += dpFSA ( x, y + 1, ( ( f & 1 ) << 1 ) | 1 );
    }

    k_operafan[ x ][ y ][ f ] %= M;
  }

  return ( k_operafan[ x ][ y ][ f ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    scanf ( "%d%d", &w, &h );
    if ( !( w | h ) ) break ;
    --w; --h;

    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    printf ( "%d\n", ( dpFSA ( 1, 0, 0 ) + dpFSA ( 0, 1, 3 ) ) % M );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
constexpr int MOD = 1e9 + 7;
int main()
{
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> a(N, std::vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) { std::cin >> a[i][j]; }
    }
    const int maximum = 1 << N;
    std::vector<std::vector<int>> memo(N, std::vector<int>(maximum, -1));
    auto dp = [&](auto&& self, const int m, const int mask) -> int {
        if (m == N) { return 1LL; }
        if (memo[m][mask] != -1) { return memo[m][mask]; }
        int ans = 0;
        for (int g = 0; g < N; g++) {
            if (not a[m][g] or (mask & 1 << g) == 0) { continue; }
            (ans += self(self, m + 1, mask - (1 << g))) %= MOD;
        }
        return memo[m][mask] = ans;
    };
    std::cout << dp(dp, 0, maximum - 1) << std::endl;
    return 0;
}


Measured memory_bytes: 180608
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
  ll a, b, n;
  cin >> a >> b >> n;
  ll nn = min(n, b - 1);
  cout << (a * nn) / b - a * (nn / b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

ll comb[55][55];
bool done[55][55];

ll c(ll n, ll k){
	if(done[n][k]){
		return comb[n][k];
	}
	done[n][k] = true;
	if(k == 0ll || k == n){
		comb[n][k] = 1ll;
	}else{
		comb[n][k] = c(n-1,k)+c(n-1,k-1);
	}
	return comb[n][k];
}

int main(void){
	ll i,j,n,a,b,sum[55],v[55],cnt[55],m,k,ans,p;
	fill(comb[0],comb[55],false);
	cin >> n >> a >> b; --a; --b;
	for(i=0ll; i<n; ++i){
		cin >> v[i];
	}
	sort(v,v+n,greater<ll>());
	for(i=a; i<=b; ++i){
		sum[i] = 0ll;
		m = 0ll; k = 0ll;
		for(j=0; j<=i; ++j){
			sum[i] += v[j];
			if(v[j] == v[i]){
				++k;
			}
		}
		for(j=0; j<n; ++j){
			if(v[j] == v[i]){
				++m;
			}
		}
		cnt[i] = c(m,k);
	}
	p = b; ans = cnt[b];
	for(i=a; i<b; ++i){
		if(sum[p]*(i+1) < sum[i]*(p+1)){
			p = i;
			ans = cnt[i];
		}else if(sum[p]*(i+1) == sum[i]*(p+1)){
			ans += cnt[i];	
		}
	}
	printf("%.10lf\n",(((double)(sum[p]))/(double)(p+1)));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = n.lcm(m)
g = n.gcd(m)

g.times do |i|
  if s[n / g * i] != t[m / g * i]
    puts "-1"
    exit
  end
end
puts l

Measured memory_bytes: 14540
n,d=map(int,input().split())
w=[]
for i in range(n):
    l=[int(i) for i in input().split()]
    w.append(l)
ans=chk=0
for i in range(n-1):
    for j in range(i+1,n):
        x=0
        for k in range(d):
            x+=(w[i][k]-w[j][k])**2
        ans+=[0,1][x==int(pow(x,0.5))**2]
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL mod = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> t(N+2, -1), a(N+2, -1);
    for(int i = 1;i <= N;i++)    cin >> t[i];
    for(int i = 1;i <= N;i++)    cin >> a[i];
    LL ans = 1;
    bool f = true;
    vector<int> h(N+1, -1);
    for(int i = 1;i <= N;i++){
        if(t[i] > t[i-1])  h[i] = t[i];
    }
    for(int i = N;i >= 1;i--){
        if(a[i] > a[i+1]){
            if(h[i] > 0 && a[i] != t[i])    f = false;
            else    h[i] = a[i];
        }
    }
    for(int i = 1;i <= N;i++){
        LL hm = min(a[i], t[i]);
        if(h[i] < 0)    ans *= hm;
        else if(hm < h[i])  f = false;
        ans %= mod;
    }
    if(!f)  cout << 0 << endl;
    else    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    map<char,int> kosuu;
    char c;
    while (cin >> c)
    {
        kosuu[c]++;
    }
    for (auto &&e : kosuu)
    {
        if (e.second > 1)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Q=1000000007;

int main(){
  while(true){
    int A,B;
    cin >> A >> B;
    if(A*B==0){
      return 0;
    }
    vector<vector<ll>> M(A+1,vector<ll>(B+1,0));
    M[1][1]=1;
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
      int x,y;
      cin >> x >> y;
      M[x][y]=-1;
    }
    for(int x=1;x<=A;x++){
      for(int y=1;y<=B;y++){
        if(M[x][y]==-1){
          M[x][y]=0;
        }else if(x>1||y>1){
          M[x][y]=M[x-1][y]+M[x][y-1];
        }
      }
    }
    cout << M[A][B] << endl;
  }
}


Measured memory_bytes: 3004
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int q, h, s, d;
	cin >> q >> h >> s >> d;

	int n;
	cin >> n;

	int q_liter = 4 * q;
	int h_liter = 2 * h;
	int cheapest = min(min(q_liter, h_liter), s);
	if (d / 2 <= cheapest) {
		cout << (long long) (n / 2) * d + (n % 2) * cheapest << "\n";
	} else {
		cout << (long long) n * cheapest << "\n";
	}

	return 0;

}

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

char invert(char c){
    if(!isalpha(c)) return c;
    return islower(c)?toupper(c):tolower(c); 
}

int main(){
    char c;
    while(true){
        scanf("%c", &c);
        if(c == '\n') break;
        cout << invert(c);
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    // ll N; cin >> N;
    // ll N, M; cin >> N >> M;
    string s; cin >> s;
    string t; cin >> t;
    bool ok = true;
    rep(i,s.size()){
        if(s[i]!=t[i]) ok = false;
    }
    yes(ok);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(void) {
        int a,b;
        char op[100];
        while(1) {
                scanf("%d %s %d", &a, op, &b);
                if(*op=='+') {
                        printf("%d\n", a+b);
                } else if(*op=='-') {
                        printf("%d\n", a-b);
                } else if(*op=='*') {
                        printf("%d\n", a*b);
                } else if(*op=='/') {
                        printf("%d\n", a/b);
                } else if(*op=='?') {
                        break;
                }
        }
        return 0;
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

const int MAXN = 100000 + 10;


int n, m;
int fa[MAXN];

int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}
bool vis[MAXN];
int main () {
	read(n);
	read(m);
	rep(i, 1, n + 1) {
		fa[i] = i;
	}
	rep(i, 1, m + 1) {
		int u, v;
		read(u);
		read(v);
		fa[find(u)] = find(v);
	}
	int k = 0;
	rep(i, 1, n + 1) {
		int u = find(i);
		if (vis[u])
			continue;
		k++;
		vis[u] = 1;
	}
	cout << max(0, k - 1);
	return 0;
}

Measured memory_bytes: 4160
N, Y = gets.split(' ').map(&:to_i)

count = [-1, -1, -1]
is_break = false

(0..N).each do |n_i|
  i = N - n_i
  next if 10000*i + 1000*(N-i) > Y
  
  (0..(N-i)).each do |n_i_j|
    j = N - i - n_i_j
    if 10000*i + 5000*j + 1000*(N-i-j) == Y
      count = [i, j, N-i-j]
      is_break = true
      break
    end
    break if is_break
  end
  break if is_break
end

ans = count[0].to_s + ' ' + count[1].to_s + ' ' + count[2].to_s
print ans


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





public class Main
{

	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);	

	

	public static void main(String[] args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		// long n=Long.parseLong(br.readLine());

		int t=Integer.parseInt(br.readLine());


		String[] s;//=br.readLine().split(" ");

		// int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);

		PriorityQueue<Integer> pqmax=new PriorityQueue<Integer>();
		PriorityQueue<Integer> pqmin=new PriorityQueue<Integer>(new Comparator<Integer>()
			{
				public int compare(Integer x,Integer y) { return y-x; }
			});

		long sumMin=0, sumMax=0, sumb=0;

		int min=0;

		while(t-->0)
		{
			s=br.readLine().split(" ");
			if(s[0].charAt(0)=='2')
			{
				long ans=min;ans*=pqmin.size();
				ans-=sumMin;

				long ans1=min;ans1*=pqmax.size();
				ans1=sumMax-ans1;

				out.println(min+" "+(ans+ans1+sumb));
			}
			else
			{
				int in=Integer.parseInt(s[1]);
				sumb+=Long.parseLong(s[2]);

				if(in>min)
				{
					pqmax.add(in);
					sumMax+=in;
				}
				else
				{
					pqmin.add(in);
					sumMin+=in;
				}

				if(pqmin.size()>pqmax.size())
				{
					sumMax+=pqmin.peek();
					sumMin-=pqmin.peek();
					pqmax.add(pqmin.poll());
				}

				if(pqmin.size()<pqmax.size())
				{
					sumMax-=pqmax.peek();
					sumMin+=pqmax.peek();
					pqmin.add(pqmax.poll());
				}

				min=pqmin.peek();
			}
		}



		
		out.close();

	}
}

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

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int a[n];
  rep(i,n)cin >> a[i];

  int ans=0;
  d--;
  rep(i,n){
    ans+=d/a[i]+1;
  }
  cout << ans+x << endl;
}


Measured memory_bytes: 3624
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	string s;cin>>s;
	int cr=0,cw=0,ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')cr++;
		else cw++;
	}
	for(int i=0;i<cr;i++){
		if(s[i]=='W')ans++;
	}
	for(int i=cr;i<n;i++){
		if(s[i]=='R')ans++;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 3704
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
constexpr i64 MAX = 510000;
constexpr i64 MOD = 1000000007;
 i64 fac[MAX], finv[MAX], inv[MAX];
template <i64 modulus>
class modcal
{
 
public:
    i64 a;
 
    constexpr modcal(const i64 x = 0) noexcept : a(x % modulus) {}
    constexpr i64 &value() noexcept { return a; }
    constexpr const i64 &value() const noexcept { return a; }
    constexpr modcal operator+(const modcal rhs) const noexcept
    {
        return modcal(*this) += rhs;
    }
    constexpr modcal operator-(const modcal rhs) const noexcept
    {
        return modcal(*this) -= rhs;
    }
    constexpr modcal operator*(const modcal rhs) const noexcept
    {
        return modcal(*this) *= rhs;
    }
    constexpr modcal operator/(const modcal rhs) noexcept
    {
        return modcal(*this) /= rhs;
    }
    constexpr modcal &operator+=(const modcal rhs) noexcept
    {
        a += rhs.a;
        if (a >= modulus)
        {
            a -= modulus;
        }
        return *this;
    }
    constexpr modcal &operator-=(const modcal rhs) noexcept
    {
        if (a < rhs.a)
        {
            a += modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modcal &operator*=(const modcal rhs) noexcept
    {
        a = a * rhs.a % modulus;
        return *this;
    }
    constexpr modcal &operator/=(modcal rhs) noexcept
    {
        i64 exp = modulus - 2;
        while (exp)
        {
            if (exp % 2)
            {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    void COMninit()
    {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++)
        {
            fac[i] = fac[i - 1] * i % modulus;
            inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
            finv[i] = finv[i - 1] * inv[i] % modulus;
        }
    }
    i64 COMn(i64 n, i64 k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
    }
    constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n)
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};
using modC = modcal<1000000007>;
int main()
{
    i64 h, w, a, b;
    cin >> h >> w >> a >> b;
    h--;
    w--;
    modC ans = 0;
    ans.COMninit();
    for(int i = 0; i < h - a + 1; i++){
        ans += ans.COMn(b + i - 1, i) * ans.COMn(w - b + h - i, w - b);
    }
    cout << ans.a << endl;
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int a, b; cin >> a >> b;
  int n = b - a;
  int h = 0;
  REP(i,n) {
    h += i;
  }
  cout << h - a << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int A = sc.nextInt();
        
        if(N%500 <= A){
            System.out.println("Yes");
        }else if(N%500 > A){
            System.out.println("No");
        }
    }       
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long l,r,ans=2019,i,j;
  cin >> l >> r;
  if(r-l>=2019) {
    cout << 0 << endl;
  }
  else {
    for(i=l; i<r; i++) {
      for(j=l+1; j<=r; j++) {
        ans=min(ans,((i%2019)*(j%2019))%2019);
      }
    }
    cout << ans << endl;
  }
}


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

int N, A, B, C;
int l[8];
using namespace std;
int calc(int n, int a, int b, int c){
	if (n == N){
		if(a > 0 && b > 0 && c > 0){
			return abs(A - a) + abs(B - b) + abs(C - c) - 30;
		}
		else{
			return 10000000;
		}
	}
	else{
		int res0 = calc(n+1, a, b, c);
		int res1 = calc(n+1, a + l[n], b, c) + 10;
		int res2 = calc(n+1, a, b + l[n], c) + 10;
		int res3 = calc(n+1, a, b, c + l[n]) + 10;
		return min({res0, res1, res2, res3});
	}
}
int main(){
	cin >> N >> A >> B >> C;
	for(int i = 0;i<N;i++){
		cin >> l[i];
	}
	cout << calc(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
l = [0] * n

for i in range(n):
    if t[i] == 'r':
        l[i] = p
    elif t[i] == 's':
        l[i] = r
    else:
        l[i] =s

ans = sum(l)
for i in range(k, n):
    if t[i] == t[i - k]:
        ans -= l[i]
        t[i] = 'o'

print(ans)

Measured memory_bytes: 10468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int e=abs(a-b);
	int f=abs(b-c);
	int g=abs(a-c);
	if((e<=d &&f<=d)||g<=d)cout<<"Yes";
	else cout<<"No";
}

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

using namespace std;
typedef long long ll;

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


int main()
{
  int n;
  cin >> n;
  ll l = 1;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    l = a * (l / gcd(l, a));
  }
  cout << l << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

vector<int> num;
string a; int k;
ll DP[101][4][3];
/// DP[p][c][f] = Number of valid numbers <= b from this state
/// p = current position from left side (zero based)
/// c = number of times we have placed the digit d so far
/// f = the number we are building has already become smaller than b? [0 = no, 1 = yes]

ll call(int pos, int cnt, int f){
    if(cnt > k) return 0;

    if(pos == num.size()){
        if(cnt == k) return 1ll;
        return 0;
    }

    if(DP[pos][cnt][f] != -1) return DP[pos][cnt][f];
    ll res = 0;

    int LMT;

    if(f == 0){
        /// Digits we placed so far matches with the prefix of b
        /// So if we place any digit > num[pos] in the current position, then the number will become greater than b
        LMT = num[pos];
    } else {
        /// The number has already become smaller than b. We can place any digit now.
        LMT = 9;
    }

    /// Try to place all the valid digits such that the number doesn't exceed b
    for(int dgt = 0; dgt<=LMT; dgt++){
        ll nf = f;
        ll ncnt = cnt;
        if(f == 0 && dgt < LMT) nf = 1; /// The number is getting smaller at this position
        if(dgt != 0) ncnt++;
        if(ncnt <= k) res += call(pos+1, ncnt, nf);
    }

    return DP[pos][cnt][f] = res;
}

ll solve(string b){
    num.clear();
    for(int i = 0; i < b.length(); i++) {
      num.push_back(b[i] - '0');
    }
    /// Stored all the digits of b in num for simplicity

    memset(DP, -1, sizeof(DP));
    ll res = call(0, 0, 0);
    return res;
}

int main () {

    cin >> a >> k;
    cout << solve(a) << '\n';

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string n;
  cin >> n;
  char c = n[0];
  int count = 1;
  for(int i = 1; i < 4; i++)
  {
    if(c == n[i]) count++;
    else{
      count = 1;
      c = n[i];
    }
    if(count == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;

}

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

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

  int res=K;
  rep(i,N-1){
    res *= K-1;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int a,b;
	cin>>a>>b;
	int av = b - 2*a;
	int bv = 4*a - b;
	if((av >= 0) && (bv >= 0) && !(av & 1) && !(bv & 1))
	cout<<"Yes\n";
	else cout<<"No\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int idx;
    if(s[0]==s[n-1]) idx=1;
    else idx=0;
    if(idx){
        if(n%2) cout<<"Second";
        else cout<<"First";
    }
    else {
        if(n%2) cout<<"First";
        else cout<<"Second";

    }
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli e, o;
    lli k;
    cin >> k;
    e = k / 2;
    (k % 2 == 0 ? o = k / 2 : o = k / 2 + 1);
    out((o * e));
}

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

using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=k+1;i<=n;i++){
		if(a[i]>a[i-k])cout<<"Yes";
		else cout<<"No";
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 4396
n = int(input())
sp_list = []
for i in range(n):
    l = input().split()
    l.append(str(i))
    sp_list.append(l)

sp_list.sort(reverse=True,key=lambda x:int(x[1]))

sp_list.sort(key=lambda x:x[0])

for i in range(n):
    print(int(sp_list[i][2])+1)

Measured memory_bytes: 3060
s = gets.chomp
k = gets.to_i

counts = []
pre = nil
cnt = 1

s.chars.each do |c|
  if pre == nil    # 文字を一つも取り出していなければ、取り出した値を格納する。
    pre = c
  elsif pre == c   # 1つ前の文字と比較して同じ文字の場合はカウントアップ
    cnt += 1
  else
    counts << cnt  # 同じ文字ではなくなるまでを1つの塊として考える。塊ごとの文字数
    pre = c
    cnt = 1
  end
end
counts << cnt
 
ans = 0

# 全て同じ文字の場合（1つの文字塊しかない場合）
## 文字数/2で変更回数が求まるので、文字数×K倍/2が答え
if counts.size == 1
  ans = counts[0] * k / 2
# 先頭文字と末尾文字が同じ場合
elsif s[0] == s[-1]
  # 先頭と末尾以外の合計値を答えに合算
  counts[1..-2].each { |t| ans += t / 2}
  ans *= k

  # 末尾と先頭で重なる部分を計算し、答えに合算
  ans += (counts[0] + counts[-1]) / 2 * (k - 1)
  
  # 先頭部分の合計値
  ans += counts[0] / 2
  
  # 末尾の合計値
  ans += counts[-1] / 2

# 先頭文字と末尾文字が異なる場合
## 単純に先頭、末尾の塊以外の合計値をk倍するだけ
else
  counts.each { |t| ans += t / 2 }
  ans = ans * k
end
puts ans

Measured memory_bytes: 3836
#include <stdio.h>
#define LL long long
#define maxn 200010
int color[maxn],head[maxn],tot,n,size[maxn],sum[maxn];
LL ans[maxn];
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
LL get_num(LL x){
	return x*(x+1)/2;
}
void dfs(int u,int fa){
	int v,b,c,t,dt;
	LL pre;
	size[u]=1,c=color[u],pre=sum[c];//非u子树已算出的c颜色为根的节点数量
	for(b=head[u];b;b=e[b].next){
		v=e[b].to;
		if(v==fa)continue;
		t=sum[c];
		dfs(v,u);
		dt=sum[c]-t;//遍历了v之后，c颜色对应的变化量
		size[u]+=size[v];
		ans[c]-=get_num(size[v]-dt);//两个c颜色之间的，其他颜色节点数量
	}
	sum[c]=pre+size[u];//总的c颜色为根的节点数量
}
int main(){
	int i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&color[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
	for(i=1;i<=n;i++)ans[i]=get_num(n);
	dfs(1,0);
	for(i=1;i<=n;i++)ans[i]-=get_num(n-sum[i]);//n-sum[i]指离树根最近的i颜色之外的其他颜色(整棵树扣除所有以i颜色为根的子树)数量
	for(i=1;i<=n;i++)printf("%lld\n",ans[i]);
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    cout << ceil((float)N / (D * 2 + 1)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = Integer.parseInt(sc.nextLine());
			if(n == 0 ) break;
			HashMap<Character,ArrayList<Data>> map = new HashMap<Character,ArrayList<Data>>();
			for(int i = 0; i < n; i++) {
				String[] in = sc.nextLine().split(" ");
				for(int j = 0; j < in.length; j++) {
					String tmp = in[j];
					if(map.containsKey(tmp.charAt(0))) {
						ArrayList<Data> x = map.get(tmp.charAt(0));
						boolean flg = false;
						for(int k = 0; k < x.size(); k++) {
							if(x.get(k).in.equals(tmp)) {
								flg = true;
								x.get(k).count++;
								break;
							}
						}
						if(!flg) {
							x.add(new Data(tmp,1));
						}	
					}
					else {
						ArrayList<Data>x = new ArrayList<Data>();
						x.add(new Data(tmp,1));
						map.put(tmp.charAt(0), x);
					}
				}
			}
			String ch = sc.nextLine();
			if(map.containsKey(ch.charAt(0))) {
				ArrayList<Data> x = map.get(ch.charAt(0));
				Collections.sort(x,new MyComp());
				for(int i = 0; i < Math.min(5, x.size()); i++) {
					if(i == 0) {
						System.out.print(x.get(i).in);
					}
					else {
						System.out.print(" " + x.get(i).in);
					}
				}
				System.out.println();
			}
			else {
				System.out.println("NA");
			}
		}
	}
	
	static class Data {
		String in;
		int count;
		Data(String a, int b) {
			in = a;
			count = b;
		}
	}
	
	static class MyComp implements Comparator<Data> {

		@Override
		public int compare(Data o1, Data o2) {
			if(o1.count < o2.count) {
				return 1;
			}
			if(o1.count > o2.count) {
				return -1;
			}
			return o1.in.compareTo(o2.in);
		}
		
	}
}     

Measured memory_bytes: 39336
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	int a[3];
	a[0] = A + B;
	a[1] = A - B;
	a[2] = A*B;
	sort(a, a+3);
	printf("%d\n", a[2]);
	return 0;
}

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

int main(){
  int N; cin >> N;
  int A,two,result=50;
  for(int i=0; i<N; i++){
    cin >> A;
    two=0;
    while(A%2==0){
      A/=2;
      two++;
    }
    result=min(two,result);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n, score, total, max, min, i;

  while(1){
    total = 0;
    max = -1;
    min = 10000;
    
    scanf("%d", &n);
    if(n == 0) break;

    for(i = 0; i < n; i++){
      scanf("%d", &score);
      total += score;

      if(max < score){
	max = score;
      }
      
      if(score < min){
	min = score;
      }
      
    }

    total -= (max + min);
    printf("%d\n", total / (n - 2));

  }
  
  return 0;
  
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>

#define N 16

int w, h;
int map[ N + 1 ][ N + 1 ];
int k_operafan[ N + 1 ][ N + 1 ];

int dpFSA (
  int x,
  int y
  )
{
  if ( map[ x ][ y ] )          return ( 0 );
  else if ( x == w && y == h )  return ( 1 );
  else if ( x > w || y > h )    return ( 0 );
  else if ( k_operafan[ x ][ y ] ) ;
  else
  {
    k_operafan[ x ][ y ] = dpFSA ( x + 1, y )
                         + dpFSA ( x, y + 1 );
  }

  return ( k_operafan[ x ][ y ] );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int n;

    scanf ( "%d%d", &w, &h );
    if ( !( w | h ) ) break ;

    memset ( map, 0, sizeof ( map ) );
    memset ( k_operafan, 0, sizeof ( k_operafan ) );

    scanf ( "%d", &n );
    while ( n-- )
    {
      int x, y;

      scanf ( "%d%d", &x, &y );
      map[ x ][ y ] = 1;
    }

    printf ( "%d\n", dpFSA ( 1, 1 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int batu = 0;
  for(int i = 0; n > i; i++){
    if(i+1!=a[i])batu++;
  }
  if(batu < 3)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	int m1 = a*60 + b, m2 = c*60 + d;
	
	cout << m2 - m1 - k;
}



















Measured memory_bytes: 3656
#include <cstdio>
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#define MAXN 5003
using namespace std;




int main(){
    vector<int> a1;
    vector<int> a2;
    vector<int> a4;
    bool flag=1;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a%4 == 0)
            a4.push_back(a);
        else if(a%2 == 0)
            a2.push_back(a);
        else
            a1.push_back(a);
    }

    if(a4.size() + 1 < a1.size()){
        flag = 0;
    }else if(a4.size() < a1.size()){
        if(a2.size() > 0)
            flag = 0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int main(){
  long k,s,h=0;
  cin >> k >> s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j&&s-i-j<=k)h++;
    }
  }
  cout << h;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,a[150],i,j,sum=0;
    scanf("%d",&N);
    for(i=0; i<N; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<N; i++)
    {
        for(j=i+1; j<N; j++)
        {
 
          sum=sum+a[i]*a[j];
 
        }
 
    }
 
    printf("%d",sum);
    return 0;
}

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

typedef long long LL;
const int MAXN=1e6+5;
const int mod=1e9+7;

LL frac[MAXN];

LL inv(LL a){
    if (a==1) return 1;
    return ((-(mod/a)*inv(mod%a))%mod+mod)%mod;
}

LL C(LL n,LL m){
    m=min(m,n-m);
    LL ans=(frac[n]*inv(frac[m]))%mod;
    ans=(ans*inv(frac[n-m]))%mod;
    return ans;
}

int main(){
    LL h,w,a,b;
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    frac[0]=1;
    for(int i=1;i<=h+w;i++) frac[i]=(frac[i-1]*i)%mod;
    LL ans=C(h+w-2,h-1);
    for(int i=1;i<=b;i++){
        LL temp=(C(h-a+i-2,i-1)*C(w-i+1+a-2,a-1))%mod;
        ans=((ans-temp)%mod+mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
import java.io._
import scala.io.Source

object Main {
  var size = 0
  var count = 0
  val out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileDescriptor.out), "ASCII"), 512)

  def swap(a:Array[Int],i:Int,j:Int,ai:Int,aj:Int) =  {
    a(i) = aj
    a(j) = ai
  }

  def up(a:Array[Int], i:Int):Unit = {
    val j = i >> 1
    if(j>0 && a(j-1) < a(i-1)) { swap(a,j-1,i-1,a(j-1),a(i-1)); up(a,j) }
  }

  def down(a:Array[Int], i:Int, temp:Int):Unit = {
    var largest = i
    val j = (i+1) << 1
    if(j>size) a(i) = temp
    else {
       val max = if(j==size) j-1 else if(a(j-1) >= a(j)) j-1 else j
       if(a(max)>temp) { a(i) = a(max); down(a,max,temp) }
       else a(i) = temp
    }
  }

  def extract(a:Array[Int]):Int = {
    val max = a(0)
    if(size>0) {
      a(0) = a(size-1)
      size -= 1
      down(a,0,a(0))
      a(size) = 0
    }
    max
  }

  def insert(a:Array[Int], n:Int) = {
    a(size) = n
    size += 1
    up(a,size)
  }

  def main(args:Array[String]) = {
    val a = new Array[Int](2000000)
    var s = ""
    Source.stdin.getLines.takeWhile(_!="end").foreach { s =>
      val op = s.split(" ")
      if(op(0) == "insert") {
        insert(a, op(1).toInt)
      } else if(op(0) == "extract") {
        val x = extract(a).toString
        out.write(x)
        out.write("\n")
        if(count<100) count += 1
        else {
         out.flush
         count = 0
        }
      }
    }
    out.flush
  }
}

Measured memory_bytes: 461456
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll p2(int x){
  int xx=1;
  while(x!=0){
    xx*=2;
    x--;
  }
  return xx;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c,k;cin>>a>>b>>c>>k;
  ll maxn=0;
  for(int i=0;i<=k;i++){
    for(int j=0
      ;j<=k;j++){
      if(i+j>k)continue;
      maxn=max(maxn, a*p2(i)+b*p2(j)+c*p2(k-j-i) );
    }
  }
  P(maxn);
  return 0;
}


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

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll fastpow(ll b, ll e){
    ll ans = 1;
    while(e){
        if (e&1) ans *= b;
        e >>= 1;
        b *= b;
    }
    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    ll x; cin >> x;
    unordered_map<ll, ll, custom_hash> um;
    unordered_set<ll, custom_hash> ss;
    for (int i = -4000; i <= 4000; i++){
        ll x = fastpow(i,5);
        ss.insert(x);
        um[x] = i;
    }

    for (auto num : ss){
        if (ss.count(num+x) > 0){
            cout << um[num+x] << " " << um[num] << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 4300