akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll H, ll W) {
  int ans = (N-H+1)*(N-W+1);
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  ll H;
  cin >> H;
  ll W;
  cin >> W;
  solve(N, H, W);
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_smaller(const pii& left, const pii& right) {
    return left.second < right.second;
}
#endif


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

    int N; cin >> N;
    vi x(N), y(N), h(N); 
    int XMIN=INF, XMAX=-INF, YMIN=INF, YMAX=-INF;
    REP(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        XMIN = min(XMIN, x[i]);
        XMAX = max(XMAX, x[i]);
        YMIN = min(YMIN, y[i]);
        YMAX = max(YMAX, y[i]);
    }

    vector<pii> dh;

    const int CMAX = 100;
    FOR(cx, XMIN, XMAX+1) {
        FOR(cy, YMIN, YMAX+1) {
            REP(i,N){
                dh.push_back(pii(i, abs(x[i] - cx) + abs(y[i] - cy)));
            }
            sort(dh.begin(), dh.end(), second_smaller);

            int H = INF;
            REP(i,N){
                H = min(H, h[dh[i].first] + dh[i].second);
            }

            bool ok = true;
            REP(i,N-1){
               if (h[dh[i].first] + min(dh[i].second,H) != h[dh[i+1].first] + min(dh[i+1].second,H)) {
                   ok = false;
                   break;
               }
            }

            if (H >= 1 && ok) {
                cout << cx << ' ' << cy << ' ' << H << endl;
                return 0;
            }
            dh.clear();
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int w,h;
    char c;
    cin >> w >> h >> c;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if((i==0||i==h-1)&&(j==0||j==w-1)){
                cout << "+";
            }else if(j==0||j==w-1){
                cout << "|";
            }else if(i==0||i==h-1){
                cout << "-";
            }else if(i==h/2&&j==w/2){
                cout << c;
            }else{
                cout << ".";
            }
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <array>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

int s;
int MOD=1000000007;
int64 f[2001];

int main() {
	//freopen("test.in","r",stdin);
	cin >> s;
	f[0]=1;
	FOR (n,1,s) {
		f[n]=0;
		FOR (x,3,n) {
			f[n]+=f[n-x];
		}
		f[n]%=MOD;
	}
	cout << f[s] << endl;
	return 0;
}


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

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int a[123456];
int flag[123456];
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++)
	{
		int t;
		cin>>t;
		a[t]++;
	}
	for(int i=1;i<=n;i++)
	{
		flag[i]=k;
	}
	for(int i=1;i<=n;i++)
	{
		flag[i]=flag[i]-q+a[i];	
		if(flag[i]<=0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	} 
	return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int q=a+b;
    int w=a-b;
    int e=a*b;
    int r=max({q,w,e});
    cout<<r<<endl;
    return(0);
}

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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
#define N		1000001
ll A[N];
void solve(){
	ll n, x;
	cin>>n>>x;
	rep(i,0,n)
	cin>>A[i];
	sort(A, A+n);
	ll ans = abs(A[0]-x);
	rep(i, 1, n)
		ans = gcd(A[i]- A[0], ans);
	cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 1e9+7;




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll>p(n),c(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n)cin >> c[i];
    ll ans = -1e18;

    rep(i,n){
        ll val = -1e18,score=0,cnt = 0;
        ll t = p[i];
        bool flag = true;
        vector<ll>vals;
        vals.clear();
        vals.pb(0);
        while(t != i){
            score += c[t];
            t = p[t];
            val = max(val,score);
            vals.pb(val);
            cnt++;
            if(cnt == k){
                flag = false;
                break;
            }
        }
        if(flag){
            score += c[i];
            val = max(val,score);
            vals.pb(val);
            cnt++;
        }
        if(cnt < k){
            ll mod = k/cnt;
            val = max(val,max((mod-1)*score + val,mod*score+vals[k%cnt]));
            
        }

        ans = max(val,ans);


    }

    cout << ans << endl;
    return 0;


}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    Int res = s.size() + t.size();
    for (Int i = 1; i <= (Int)min(s.size(), t.size()); i++) {
        bool check = true;
        for (Int j = 0; j < i; j++) {
            if (s[s.size() - i + j] != t[j]) {
                check = false;
            }
        }
        if (check) {
            res = min(res, (Int)(s.size() + t.size()) - i);
        }
    }
    print(res);
    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;

int main()
{
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ans = (x / 500) * 1000;
    x %= 500;
    ans +=  (x / 5) * 5;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def fib_memo(n):
    memo = [0] * (n+1)
    memo[0] = 1
    if n < 1:
        return memo
    memo[1] = 1
    for i in range(2, n+1):
        memo[i] = memo[i-1] + memo[i-2]
    return memo

def main():
    N, M = i2nn()
    A = ii2nn(M)
    MOD = int(1e+9) + 7
    D = [0] * (M+1)
    if M == 0:
        D[0] = N
    else:
        D[0] = A[0] - 1
        for i in range(1, M):
            t = A[i] - A[i-1] - 2
            if t <= -1:
                print(0)
                return
            D[i] = t
        D[M] = N - A[M-1] - 1
    n = 1
    memo = fib_memo(max(D))
    for d in D:
        n = (n * memo[d]) % MOD
    print(n)

main()


Measured memory_bytes: 471544
/* Atcoder abc146a
 * See tasks at: https://atcoder.jp/contests/abc146/tasks/abc146_a
 */
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;

    map<string, int> table = {
        { "SUN", 7 },
        { "MON", 6 },
        { "TUE", 5 },
        { "WED", 4 },
        { "THU", 3 },
        { "FRI", 2 },
        { "SAT", 1 },
    };
    
    cout << table.at(s) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int dsum(int x){
    int re=0,d=100000,xbuf=x;
    REPI(6){
        re+=xbuf/d;
        xbuf%=d;
        d/=10;
    }
        
    return re;
}


int main(){
    int N;
    int res,buf;
    scanf("%d",&N);

    res = dsum(N-1)+1;

    for(int i=2;i<=N/2;i++){
        buf = dsum(i)+dsum(N-i);
        if(buf<res) res = buf;
    }

    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D;
    cin >> D;
    vector<int>c(26);
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector<vector<int>>s(D,vector<int>(26));
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int>t(D);
    for(int i = 0; i < D; i++) {
        t[i] = rand()%26+1;
    }
    int ans = 0;
    vector<int>Last(26);
    for(int i = 0; i < D; i++) {
        ans+=s[i][t[i]-1];
        Last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            ans-=c[j]*(i+1-Last[j]);
        }
    }
    int M = 300000;
    vector<P>horyuu;
    int cnt = 0;
    for(int i = 0; i < M; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans > ord) {
            ord = ans;
            cnt++;
            horyuu.push_back({d,q});
        }
        else {
            ans = ord;
        }
        if(cnt == 4) {
            cnt = 0;
            t[horyuu[3].first-1] = horyuu[3].second;
            horyuu = {};
        }
    }
    for(int i = 0; i < D; i++) {
        cout << t[i] << "\n";
    }
}

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

using namespace std;
bool vis[100005];
int wac[100005];
int main()
{
    int n,m;
    cin >> n >> m;
    int accnt=0,wacnt=0;
    for(int i=0;i<m;i++)
    {
        int t;
        string str;
        cin >> t >> str;
        if(str=="AC")
        {
            vis[t]=1;
        }
        if(str=="WA")
        {
            if(!vis[t])
                wac[t]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
        {
            accnt++;
            wacnt+=wac[i];
        }

    }
    cout << accnt << " " << wacnt;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>

int main()
{
    using namespace std;
    int N;
    cin >> N;

    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);

    vector<vector<int>> DP(N, vector<int>(3));

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

    DP[0][0] = a[0];
    DP[0][1] = b[0];
    DP[0][2] = c[0];

    for (int i = 1; i < N; i++)
    {
        DP[i][0] = max(DP[i - 1][1] + a[i], DP[i - 1][2] + a[i]);
        DP[i][1] = max(DP[i - 1][0] + b[i], DP[i - 1][2] + b[i]);
        DP[i][2] = max(DP[i - 1][0] + c[i], DP[i - 1][1] + c[i]);
    }

    int ans = max(DP[N - 1][0], max(DP[N - 1][1], DP[N - 1][2]));
    cout << ans << endl;
}

Measured memory_bytes: 9860
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long p[100005];
long anc[100005];
long n, q, ans;
long query[100005][2];
std::set<long> st;

long root(long a){
	if(anc[a] == a){
		return a;
	}else{
		long ret = root(anc[a]);
		anc[a] = ret;
		return ret;
	}
}

void solve(){
	ans = 0;
	anc[1] = p[1] = 1;
	for(int i = 2; i <= n; i++){
		scanf("%ld", p+i);
		anc[i] = p[i];
	}
	long vis = 0;
	for(int i = 0; i < q; i++){
		std::string s;
		long a;
		std::cin >> s >> a;
		if(s == "M"){
			if(!st.count(a)){
				query[vis][0] = 0;
				anc[a] = a;
				query[vis][1] = a;
				vis++;
				st.insert(a);
			}
		}else{
			query[vis][0] = 1;
			query[vis][1] = a;
			vis++;
		}
	}
	/*
	for(int i = 0; i < q; i++){
		printf("%ld %ld\n", query[i][0], query[i][1]);
	}
	//*/
	std::deque<long> deq;
	for(int i = vis-1; i >= 0; i--){
		if(query[i][0] == 0){
			anc[query[i][1]] = p[query[i][1]];
		}else{
			ans += root(query[i][1]);
			deq.push_front(root(query[i][1]));
		}
	}
	
/*
	for(auto it = deq.begin(); it != deq.end(); it++){
		printf("%ld\n", *it);
	}
	//*/
	printf("%ld\n", ans);
}

int main(){
	while(1){
		scanf("%ld%ld", &n, &q);
		if(n == 0){
			return 0;
		}
		st.clear();
		solve();
	}
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    ll a[7];
    rep(i, 7) cin >> a[i];
    ll a0 = a[1], a1 = a[1];
    ll x = min(a[0], min(a[3], a[4]));
    a0 += x * 3;
    a0 += (a[0] - x) / 2 * 2;
    a0 += (a[3] - x) / 2 * 2;
    a0 += (a[4] - x) / 2 * 2;
    if (x > 0) {
        x--;
        a1 += x * 3;
        a1 += (a[0] - x) / 2 * 2;
        a1 += (a[3] - x) / 2 * 2;
        a1 += (a[4] - x) / 2 * 2;
    }
    cout << max(a0, a1) << endl;
}

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

using namespace std;

int n;
int dp[100002];
int h[100010];
int k;

int get(int i) {
    if (i <= 0) {
        return 0;
    }
    if (dp[i] != INT_MAX) {
        return dp[i];
    }
    // cout<<"for i " <<i<<endl;
    // dp[i] = min(i - 1 >= 0 ? (abs(h[i] - h[i-1]) + get(i-1)) : INT_MAX, i - 2 >= 0 ? (abs(h[i] - h[i-2]) + get(i-2)) : INT_MAX);

    for (int j = 1; j <= k; ++j) {
        if (i - j >= 0) {
            dp[i] = min(abs(h[i] - h[i-j]) + get(i-j), dp[i]);
        }
    }

    // cout<<"calc: "<<i<<" "<<dp[i]<<endl;
    return dp[i];
}

int main(void) {
    cin>>n>>k;
    for(int i = 0; i < n; ++i) {
        cin>>h[i];
        dp[i] = INT_MAX;
    }

    cout<<get(n-1);
    // cout<<endl;
    // for (int i = 0; i < n; ++i) {
        // cout<<"i: "<<dp[i]<< " ";
    // }
    return 0;
}

Measured memory_bytes: 5760
import copy
n=int(input())

#a=[int(input() for _ in range(n))]
a = [int(input()) for i in range(n)]

b=[]
b = copy.deepcopy(a)
b.sort(reverse=True)
#print(b)
#print(a)
#print(a[1])
for i in range(n):
    if a[i]==b[0]:
        print(b[1])
    else:
        print(b[0])



Measured memory_bytes: 14684
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define datatype pos
#define inf ((int)(1e18) * 4 + 1)

typedef struct {
	int x;
	int y;
}pos;

//比較関数
int compare(datatype a, datatype b){
	return a.x - b.x;
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

signed main(){
	int K, N, i, j, k, H, W, ans = inf;
	scanf("%lld%lld", &N, &K);
	pos *p = (pos *)malloc(sizeof(pos) * N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &p[i].x, &p[i].y);
	}
	pos *h = (pos *)malloc(sizeof(pos) * N);
	sort(p, N);
	for(i = 0; i + K <= N; i++){
		for(j = i + K; j <= N; j++){
			W = p[j - 1].x - p[i].x;
//			printf("W = %lld\n", W);
			for(k = i; k < j; k++){
				h[k - i].x = p[k].y;
			}
			sort(h, j - i);
			for(k = 0; k + K <= j - i; k++){
				H = h[k + K - 1].x - h[k].x;
				ans = min(ans, W * H);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int

	fmt.Scan(&N)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	fmt.Println(a[len(a)-1] - a[0])
}


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

int main()
{
	int H, W;
	int i,j,count;
	char S[50][51] = {};
	char tempS[52][52] = {};
	
	scanf("%d %d", &H, &W);
	for(i = 0; i < H; i++)
	{
		scanf("%s", S[i]);
		sprintf(tempS[i+1]," %s",S[i]);
	}
	
	for(i = 1; i < H+1; i++)
	{
		
		for(j = 1; j < W+1; j++)
		{
			count = 0;
			if(tempS[i][j] == '#') S[i-1][j-1] = '#';
			else{
			if(tempS[i-1][j-1] == '#') count++;
			if(tempS[i-1][j] == '#') count++;
			if(tempS[i-1][j+1] == '#') count++;
			if(tempS[i][j-1] == '#') count++;
			if(tempS[i][j+1] == '#') count++;
			if(tempS[i+1][j-1] == '#') count++;
			if(tempS[i+1][j] == '#') count++;
			if(tempS[i+1][j+1] == '#') count++;
			S[i-1][j-1] = count+48;
			}
		}
	}
	
	for(i=0;i<H;i++)
	{
		printf("%s\n",S[i]);
	}
	
	return 0;
}



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

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

  int a = 0;
  int b = 0;
  rep(i, s.length()) {
    if (s[i] == 'A') {
      a++;
    } else {
      b++;
    }
  }

  if (a > 0 && b > 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   string s;
   cin >> n >> s;
   vector<int> c1(n+1),c2(n+1),c3(n+1);
   for(int i = n-1;i>=0;i--){
      c1[i] = c1[i+1]+(s[i] == 'R');
      c2[i] = c2[i+1]+(s[i] == 'G');
      c3[i] = c3[i+1]+(s[i] == 'B');
   }
   int ans = 0;
   f(i,0,n){
      f(j,i+1,n){
         if(s[i] == s[j]) continue;
         int d = j-i;
         for(char c : {'R','G','B'}){
            if(c == s[i] or c == s[j]) continue;
            if(c == 'R'){
               ans += c1[j+1];
            }else if(c == 'G'){
               ans += c2[j+1];
            }else{
               ans += c3[j+1];
            }
            if(j+d<n){
               ans -= (s[j+d]==c);
            }
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 


Measured memory_bytes: 3676
import sys
input = sys.stdin.readline
n,m = input().split()
n = int(n)
m = int(m)
l = 0
r = n+1
for i in range(m):
    l2,r2 = input().split()
    l2 = int(l2)
    r2 = int(r2)
    if l2 > l:
        l = l2
    if r2 < r:
        r = r2
if (r - l + 1) >= 0:
    print(r-l+1)
else:
    print("0")

Measured memory_bytes: 3064
#include <iostream>

int main(void)
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;
	if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		ArrayList<Integer> takoList = new ArrayList<Integer>();
		for (int i = 1; i <= n; i++) {
			takoList.add(scanner.nextInt());
		}
		scanner.close();
		int sum = 0;
		for (int i = 0; i < takoList.size(); i++) {
			for (int j = i + 1; j < takoList.size(); j++) {
				sum = sum + takoList.get(i) * takoList.get(j);
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23124
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
struct P{
    ll x,y;
};
ll dist(P p1,P p2){
    return abs(p1.x-p2.x)+abs(p1.y-p2.y);
}
int main(void){
    ll N,M;cin>>N>>M;
    vector<P> v(N);
    REP(i,N){
        ll a,b;cin>>a>>b;
        v[i]={a,b};
    }
    vector<P> v2(M);
    REP(i,M){
        ll c,d;cin>>c>>d;
        v2[i]={c,d};
    }
    ll idx[N];
    REP(i,N){

        ll m=INF;
        REP(j,M){
            ll d=dist(v[i],v2[j]);
            if(m>d){
                m=d;
                idx[i]=j+1;
            }
        }

    }
    REP(i,N){
        cout<<idx[i]<<"\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  using M = Mint<int, 998244353>;
  M ans(0);
  for(int i=0;i<n;i++)
    ans+=M(as[i])*M(1+as[i]).pow(i)*M(2).pow(n-(i+1));

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



Measured memory_bytes: 6608
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int x,xx,y,yy;
    cin>>x>>y>>xx>>yy;
    int a,aa,b,bb;
    int diffx=xx-x,diffy=yy-y;
    a=xx-diffy;
    b=yy+diffx;
    aa=a-diffx;
    bb=b-diffy;
    cout<<a<<" "<<b<<" "<<aa<<" "<<bb<<endl;



    
}


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

constexpr long long INF = (1ll << 50);

void bfs(int sx, int sy, const vector<string> &field, vector<vector<long long>> &dist) {
	typedef pair<int, int> point;

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

	queue<point> que;

	que.push({sx, sy});
	dist[sy][sx] = 0;

	while(!que.empty()) {
		const int x = que.front().first;
		const int y = que.front().second;
		que.pop();

		for(int d = 0; d < 4; ++d) {
			const int nx = x + dx[d];
			const int ny = y + dy[d];

			if(field[ny][nx] == '.' && dist[ny][nx] > dist[y][x] + 1) {
				dist[ny][nx] = dist[y][x] + 1;
				que.push({nx, ny});
			}
		}
	}
}

double calc(double E, const vector<pair<long long, long long>> &values) {
	double sum = 0.0;
	for(const auto &e : values) {
		sum += min<double>(e.first, e.second + E);
	}
	return sum / values.size();
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(12);

	int w, h;
	cin >> w >> h;

	vector<string> field(h);
	for(auto &e : field) cin >> e;

	int sx, sy;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 's') {
				sx = j;
				sy = i;
				field[i][j] = '.';
				goto bfs_phase;
			}
		}
	}

bfs_phase:;

	vector<vector<long long>> from_goal(h, vector<long long>(w, INF));
	vector<vector<long long>> from_spring(h, vector<long long>(w, INF));

	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 'g') {
				bfs(j, i, field, from_goal);
			}
			else if(field[i][j] == '*') {
				bfs(j, i, field, from_spring);
			}
		}
	}

	vector<pair<long long, long long>> values;
	values.reserve(h * w);

	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == '.') {
				values.emplace_back(from_goal[i][j], from_spring[i][j]);
			}
		}
	}

	double L = 0.0, R = INF;
	for(int i = 0; i < 100; ++i) {
		const double M = (L + R) / 2.0;
		if(calc(M, values) < M) {
			R = M;
		}
		else {
			L = M;
		}
	}

	cout << min<double>(from_goal[sy][sx], from_spring[sy][sx] + L) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 9372
// Ver19.03
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int k, x;
  scanf("%d%d", &k, &x);
  for (int i = x - k + 1; i < x + k; i++)
    printf("%d ", i);
  puts("");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)



int main(){
    int ans=0,a,ma=0;
    rep(i,3){
        cin>>a;
        ans+=a;
        ma=max(ma,a);
    }
    cout<<ans-ma<<endl;
}

Measured memory_bytes: 256
al1 = list(map(int, input().split()))
al2 = list(map(int, input().split()))
al3 = list(map(int, input().split()))

N = int(input())
bl = []
for i in range(N):
    bl.append(int(input()))

for b in bl:
    if b in al1:
        al1[al1.index(b)] = -1
    if b in al2:
        al2[al2.index(b)] = -1
    if b in al3:
        al3[al3.index(b)] = -1

if sum(al1) == -3 or sum(al2) == -3 or sum(al3) == -3:
    print('Yes')
    exit()
if al1[0] + al2[1] + al3[2] == -3 or al1[2] + al2[1] + al3[0] == -3:
    print('Yes')
    exit()

for i in range(3):
    if al1[i] + al2[i] + al3[i] == -3:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9144
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

a = [i+1 for i in range(n)]
l = list(itertools.permutations(a))
count = 0
for i in l:
    if p == list(i):
        p_num = count
    if q == list(i):
        q_num = count
    count+=1
if p_num >= q_num:
    print(p_num-q_num)
else:
    print(q_num-p_num)


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

#define MAPSIZE 1048576

int cmpmin(int a, int b) {
	return a-b;
}

int cmpmax(int a, int b) {
	return b-a;
}

typedef struct {
	int n, arr[200000];
	int (*cmp)(int, int);
} heap;

void hpush(heap *h, int x) {
	int i = h->n++;
	h->arr[i] = x;

	while (i > 0) {
		int p = (i-1)/2;
		if (h->cmp(h->arr[p], h->arr[i]) > 0) {
			int t = h->arr[p];
			h->arr[p] = h->arr[i];
			h->arr[i] = t;
			i = p;
		} else break;
	}
}

int hpop(heap *h) {
	int ret = h->arr[0];
	h->arr[0] = h->arr[--h->n];

	int i = 0, c;
	while ((c = i*2 + 1) < h->n) {
		if (c+1 < h->n && h->cmp(h->arr[c], h->arr[c+1]) > 0) {
			c++;
		}

		if (h->cmp(h->arr[i], h->arr[c]) > 0) {
			int t = h->arr[c];
			h->arr[c] = h->arr[i];
			h->arr[i] = t;
			i = c;
		} else break;
	}

	return ret;
}

int hpeek(const heap *h) {
	return h->arr[0];
}

heap left = {.n = 0, .cmp = cmpmax}, right = {.n = 0, .cmp = cmpmin};

int main(void) {
	int q;
	scanf("%d", &q);

	long long int y = 0, d = 0;

	while (q--) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			int a, b;
			scanf("%d%d", &a, &b);
			int px = hpeek(&left);
			y += abs(px-a);
			d += b;

			if (a < px) hpush(&left, a);
			else hpush(&right, a);

			int diff = left.n - right.n;
			if (diff == 2) hpush(&right, hpop(&left));
			else if (diff == -1) hpush(&left, hpop(&right));

			int x = hpeek(&left);
			if (x != px) {
				int lc = left.n;
				int rc = right.n;
				if (x > px) rc += 2;
				y += (long long int) (x - px) * (lc - rc);
			}
		} else {
			printf("%d %lld\n", hpeek(&left), y+d);
		}
	}
}


Measured memory_bytes: 3200
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        m: usize,
        a: [(usize, u32); m],
    }
    let mut b = Vec::with_capacity(m);
    for (i, a) in a.iter().enumerate() {
        b.push((a.1, a.0, i));
    }
    b.sort();
    let mut cnt = vec![0; n + 1];
    let mut ans = Vec::with_capacity(n);
    for (_, p, i) in b {
        cnt[p] += 1;
        let x = cnt[p];
        let s = format!("{:06}{:06}", p, x);
        ans.push((i, s));
    }
    ans.sort();
    for (_, s) in ans {
        writeln!(out, "{}", s).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 21752
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n, m;
	cin >> n >> m;
	vll v(m);
	ll sum = 0;
	for(ll i = 0; i < m; i++)
		cin >> v[i], sum += v[i];
	ll ans;
	if(sum > n)
		ans = -1;
	else ans = n - sum;
	cout << ans << endl;
}

Measured memory_bytes: 3668
#include<stdio.h>

int main(){
	int N,H,W,ans=0;
	scanf("%d%d%d",&N,&H,&W);
	for(int i=0;i<N;i++){
		int A,B;
		scanf("%d%d",&A,&B);
		if(A>=H && B>=W)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	sort( A.begin(), A.end() );
	long  long sum = 0;
	int t = -1;
	for( int i = 0; i < N - 1; i++ ) {
		sum += A[i];
		if( sum * 2 < A[i + 1] ) t = i + 1;
	}
	int ans = N;
	if( t >= 0 ) ans = N - t;

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

#define TAX(a, t) (int) (a*(100+t)/100)

int tax_sum(int a, int b, int t) {
    return TAX(a,t) + TAX(b,t);
}

int main() {
    int x, y, s;
    while (cin >> x >> y >> s) {
        if (x == 0) {
            break;
        }
        int ans = 0;
        for (int i = 1; i < s; i++) {
            for (int j = i; j < s; j++) {
                if (tax_sum(i,j,x) == s) {
                    ans = max(ans, tax_sum(i,j,y));
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 256
p=[input() for i in range(3)]
col=list(map(str, p[0].split()))
cnt=list(map(int, p[1].split()))
c_del=p[2]
if c_del in col:
    ball=cnt[col.index(c_del)]
    del cnt[col.index(c_del)]
    ball-=1
    cnt.insert(col.index(c_del),ball)
print(' '.join(map(str,cnt)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

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

  prt((n+1)*n/2);
}


Measured memory_bytes: 256
from collections import deque
def bfs(y,x):
    q = deque()
    q.append((y,x))
    bfs_map[y][x] = 0
    res = 0
    su = 1
    while q:
        y,x = q.popleft()
        for dy,dx in d:
            y_ = y+dy
            x_ = x+dx
            if 0 <= y_ < h and 0 <= x_ < w:
                res |= f[s[y_][x_]]
                if bfs_map[y_][x_]:
                    bfs_map[y_][x_] = 0
                    if not f[s[y_][x_]]:
                        q.append((y_,x_))
                        su += 1
    return res,su
d = [(1,0),(-1,0),(0,1),(0,-1)]
while 1:
    w,h = map(int, input().split())
    if w == h == 0:
        break
    s = [input() for i in range(h)]
    bfs_map = [[1 for j in range(w)] for i in range(h)]
    f = {".":0, "B":1, "W":2}
    ans = [0,0,0,0]
    for y in range(h):
        for x in range(w):
            if bfs_map[y][x] and s[y][x] == ".":
                k,su = bfs(y,x)
                ans[k] += su
    print(*ans[1:3])



Measured memory_bytes: 6076
import java.util.Scanner;

class Main {

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

	int N = sc.nextInt();
	int H[] = new int[N];
	for (int i = 0; i < N; i++)
	    H[i] = sc.nextInt();

	int max = 0;
	int count = 0;
	for (int i = 0; i < N - 1; i++) {
	    if (H[i] >= H[i + 1])
		count++;
	    else
		count = 0;

	    if (count > max)
		max = count;
	}

	System.out.println(max);
    }
}

Measured memory_bytes: 51992
from sys import stdin

n = input()
inp = stdin.readlines()

score = [[0, 0, 0] for i in xrange(n)]
dp = [[-1 for i in xrange(3)] for j in xrange(n)]

i = 0
for line in inp:
    score[i] = map(int, line.strip().split())

    if i == 0:
        dp[0] = score[0]
    else:
        for j in xrange(3):
            for k in xrange(1, 3): dp[i][j] = max(dp[i][j], dp[i - 1][(j + k) % 3])
            dp[i][j] += score[i][j]
    i += 1

print max(dp[n - 1])

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

int main(void){
    int P,Q,R;
    cin >> P >> Q >> R;
    
    int A = P + Q;
    int B = Q + R;
    int C = R + P;
    
    int ans = min({A,B,C});
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int diffx = x2 - x1;
    int diffy = y2 - y1;
    int y3 = y2 + diffx;
    int y4 = y1 + diffx;
    int x3 = x2 - diffy;
    int x4 = x1 - diffy;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4;
    return 0;
}


Measured memory_bytes: 256