akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MOD 1000000007
// a^b mod MOD
ll powmod(ll a,ll b){
	ll out=1;
	ll p=a%MOD;
	while(b){
		if(b&1)out=out*p%MOD;
		p=p*p%MOD;
		b>>=1;
	}
	return out;
}
#define M 220001
vector<ll> fact;
void init(){
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// nCr
ll nCr(ll n,ll r){
	if(n<r)return 1;
	if(r<0)return 0;
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%MOD,MOD-2)%MOD;
	return out;
}
int main(){
	init();
    ll n,m,x;
    cin>>n>>m>>x;
    ll out=0;
    for(ll i=0;i<x+1;i++){
        ll t=1;
        (t*=(nCr(n+2*i,i)-nCr(n+2*i,i-1)+MOD)%MOD)%=MOD;
        (t*=(nCr(m+2*(x-i),x-i)-nCr(m+2*(x-i),x-i-1)+MOD)%MOD)%=MOD;
        (t*=nCr(n+m+2*x,n+2*i))%=MOD;
        (out+=t)%=MOD;
    }
    cout<<out<<endl;
}

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

using namespace std;

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

  int largest = A[0];
  int next_largest = A[1];
  if (largest < next_largest) swap(largest, next_largest);

  for (int i = 2; i < N; i++) {
    if (A[i] >= largest) {
      next_largest = largest;
      largest = A[i];
    } else if (A[i] > next_largest) {
      next_largest = A[i];
    }
  }

  for (int i = 0; i < N; i++) {
    if (A[i] == largest) {
      cout << next_largest << endl;
    } else {
      cout << largest << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2432
s = input()
t = input()

min_diff = len(t)

for i in range(len(s) - len(t) + 1):
    sub_s = s[i:i+len(t)]
    num_diff = 0
    for i in range(len(t)):
        num_diff += 0 if sub_s[i] == t[i] else 1

    min_diff = min(min_diff, num_diff)
    
print(min_diff)

Measured memory_bytes: 9124
#include<stdio.h>
#include<math.h>
int main(){
  double r,a,s;
  scanf("%lf",&r);
if(r > 0&&r < 10000){
  a = r * r * M_PI;
  s = 2 * r * M_PI;
  printf("%lf %lf\n",a,s);
}
  return 0;
}

Measured memory_bytes: 1812
import sys
N=int(input())
A=[[],[]]
A[0]=list(map(int,input().split()))
A[1]=list(map(int,input().split()))
testx=[1,0]
testy=[0,1]
queue=[]
queue.insert(0,[1,1])
cand=[[0for i in range(N)]for i in range(2)]
cand[0][0]=A[0][0]
while(len(queue)):
    x,y=queue.pop()
    #print([x,y])
    for i in range(2):
        nx=x+testx[i]
        ny=y+testy[i]
        if(nx<=N and ny<=2 and 0<nx and 0<ny):
            cand[ny-1][nx-1]=max([cand[ny-1][nx-1],cand[y-1][x-1]+A[ny-1][nx-1]])
            queue.insert(0,[nx,ny])

print(cand[1][N-1])
#print(cand)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		int x = 0;
		x = (a-b)%c;
		
		System.out.println(x);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, k,ans=0;
  cin >> n >> k;
  vector<bool> s(n, true);
  REP(i, k) {
    int d;
    cin >> d;
    REP(j, d) {
      int a;
      cin >> a;
      s.at(a-1) = false;
    }
  }
  REP(i,n){
    if (s.at(i)) ans++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
int A[5000];
bool dp[5001][5000];
bool dp2[5001][5000];

bool f(int i) {
  int a = A[i];
  rep(l, K) {
    if (!dp[i][l]) continue;
    //cout<<"l="<<l<<": r in? ["<<K-a-l<<","<<K-l<<")\n";
    for (int r=max(0,K-a-l); r<K-l; r++) {
      if (dp2[N-1-i][r]) {
        //cout<<l<<"+"<<r<<" is in ["<<K-a<<","<< K<<")\n";
        return false;
      }
    }
  }
  return true;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  rep(i, N) cin >> A[i];

  dp[0][0] = true;
  rep(i, N) {
    int a = A[i];
    rep(j, K+1) {
      dp[i+1][j] |= dp[i][j];
      if (j+a <= K) dp[i+1][j+a] |= dp[i][j];
    }
  }
  dp2[0][0] = true;
  rep(i, N) {
    int a = A[N-1-i];
    rep(j, K+1) {
      dp2[i+1][j] |= dp2[i][j];
      if (j+a <= K) dp2[i+1][j+a] |= dp2[i][j];
    }
  }
  int c = 0;
  rep(i, N) {
    // dp[i] - dp2[N-2-i]
    if (f(i)) c++;
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 49152
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,3){
        if(s[i]=='1')ans++;
    }
    cout<<ans<<endl;
}

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

int main(void)
{
    int N, M;
    int A, B;
    
    cin >> N >> M;
    
    vector<pair<long long , long long>> pair(N);
    
    for (int i = 0; i < N; i ++) {
        cin >> A >> B;
        pair[i] = make_pair(A, B);
    }
    
    sort(pair.begin(), pair.end());
    
    long long ans = 0;
    
    for (int i = 0; i < N; i ++) {
        if (pair[i].second <= M) {
            ans += pair[i].first * pair[i].second;
        } else {
            ans += pair[i].first * M;
        }
        
        M -= pair[i].second;
        if (M <= 0) {
            break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()

md1 = inl()
md2 = inl()


def solve():
    return md1[0] < md2[0]


print(1 if solve() else 0)


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly string NA = "NA";

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();

                string head = s.Substring(0, 2);

                switch (head)
                {
                    case ">'":
                        sb.AppendLine(CheckA(s));
                        break;
                    case ">^":
                        sb.AppendLine(CheckB(s));
                        break;
                    default:
                        sb.AppendLine(NA);
                        break;
                }
            }
            Console.Write(sb);
        }

        static string CheckA(string s)
        {
            if (s[s.Length - 1] != '~') return NA;

            string temp = s.Substring(2, s.Length - 3);

            if (!temp.Contains('=')) return NA;

            string[] t = temp.Split('#');

            if (t.Length != 2) return NA;

            if (t[0].Length != t[1].Length) return NA;

            if (!t[0].All(n => n == '=')) return NA;
            if (!t[1].All(n => n == '=')) return NA;

            return "A";
        }

        static string CheckB(string s)
        {
            string tale = s.Substring(s.Length - 2, 2);

            if (tale != "~~") return NA;

            string temp = s.Substring(2, s.Length - 4);

            if (!temp.Contains("Q=")) return NA;

            temp = temp.Replace("Q=", "");

            if (temp.Length != 0) return NA;

            return "B";
        }
    }
}

Measured memory_bytes: 10660
def check(s,t):
	for i in range(0,len(s)):
		tmp = s[len(s)-i::] + s[0:len(s)-i]
		if tmp == t:
			return "Yes"
	return "No"

if __name__ == '__main__':
	s, t = input(), input()
	print(check(s,t))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////

struct xxx{
    ll a,b,s;
};
bool comp(xxx a,xxx b){
    return a.s>b.s;
}


int main(){
    ll n;cin>>n;
    xxx x[n];
    rep(i,0,n-1){
        cin>>x[i].a>>x[i].b;
        x[i].s=x[i].a+x[i].b;
    }
    sort(x,x+n,comp);
    ll ans=0;
    rep(i,0,n-1){
        if(i%2==0){
            ans+=x[i].a;
        }else{
            ans-=x[i].b;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long

int main() {
  int h,w; cin >> h >> w;
  vector<string> st(h);
  for(int i = 0; i < h; ++i) {
    cin >> st.at(i);
  }

  for(int i = 0; i < w+2; ++i) {
    cout << '#';
  }
  cout << endl;

  for(int i = 0; i < h; ++i) {
    cout << '#' << st.at(i) << '#' << "\n";
  }

  for(int i = 0; i < w+2; ++i) {
    cout << '#';
  }
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3, inf = 0x7f7f7f7f;
int n, m, val[N], minp[N], lis[N], id[N], Size; bool used[N];

int fa[N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

inline bool Cmp(const int &a, const int &b) { return val[a] < val[b]; }

long long ans = 0;

int main () {

	File();

	n = read(); m = read(); For (i, 1, n) val[i] = read(), fa[i] = i;
	For (i, 1, m) { int u = read() + 1, v = read() + 1; fa[find(u)] = find(v); }

	val[0] = inf;
	For (i, 1, n) {
		int rt = find(i); if (!id[rt]) id[rt] = ++ Size; rt = id[rt];
		if (val[i] < val[minp[rt]]) minp[rt] = i;
	}
	int need = 2 * (Size - 1);
	if (!need) return puts("0"), 0;
	if (need > n) return puts("Impossible"), 0;

	For (i, 1, Size) ans += val[minp[i]], used[minp[i]] = true;
	need -= Size; Size = 0;

	For (i, 1, n) if (!used[i]) lis[++ Size] = i;
	sort(lis + 1, lis + Size + 1, Cmp);
	For (i, 1, need) ans += val[lis[i]];

	printf ("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2048
<?php

// Scan n
fscanf(STDIN, "%d", $n);
$s = fgets(STDIN);
$a = array_slice(explode(" ", $s), 0, $n);
foreach (range(0, $n - 1) as $i) {
    $a[$i] = (int)$a[$i];
}

$res = 0;
$last_slump = 0;
for ($i = 0; $i <= $n - 1; $i++) {
    if ($a[$i] > $last_slump) {
        $res += $a[$i] - $last_slump;
    }
    $last_slump = $a[$i];
}

echo "$res";


Measured memory_bytes: 3828
n, k = gets.split.map(&:to_i)
gems = gets.split.map(&:to_i)
gems_rev = gems.reverse
ans = []
(0..k).each do |left|
  (0..k).each do |right|
    next if left + right > [n, k].min
    left_gems = gems[0...left]
    right_gems = gems_rev[0...right]
    all_gems = left_gems + right_gems
    all_gems.sort!
    (k - left - right).times do
      break if all_gems.empty?
      all_gems.delete_at(0) if all_gems.first < 0
    end
    ans << all_gems.inject(0) { |res, num| res + num }
  end
end
puts ans.max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MN = 1e5 + 5, LOG=16;
string slime;
int n;
int main() {
    cin >> n;
    cin >> slime;
    int ans = 0;
    for (int i = 0; i<n;i++) {
        if (i == 0) {
            ans += 1;
        }
        if (i != 0) {
            if (slime[i-1] != slime[i]) {
                ans += 1;
            }
        }
    }
    cout << ans << "\n";




}


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,k;
int h[125252], s[125252], p[125252], l[125252];
int m[125];
int children[125][125];

ll arr[125][125252];
ll beg[125252];

ll tmp[125252];

int di[125252];
ll dv[125252];

void lk(int w, ll *v, ll a, ll n, ll *ret){
  int s = 0, t = 0;
  REP(i,w+1){
    ll val = v[i] - i*a;
    while(s<t && dv[t-1] <= val)t--;
    di[t] = i;
    dv[t] = val;
    t++;
    ret[i] = dv[s] + i*a;
    if(di[s] == i-n)s++;
  }
}

void dfs(int p, int w, ll *iv){
  lk(w, iv, s[p], h[p], arr[p]);
  REP(i,m[p]){
    int c = children[p][i];
    dfs(c, w-l[c], iv);
    iv = arr[c];
    ll adv = (ll)l[c] * s[p];
    lk(w, iv, s[p], h[p]-l[c], tmp);
    REP(i,w+1-l[c])CHMAX(arr[p][i+l[c]], tmp[i]+adv);
  }
}

int main(){
  while(true){
    scanf("%d%d", &n, &k);
    if(n==0 && k==0)break;
    REP(i,n)scanf("%d",h+i);
    REP(i,n)scanf("%d",s+i);
    FOR(i,1,n)scanf("%d",p+i), p[i]--;
    FOR(i,1,n)scanf("%d",l+i);
    REP(i,n)m[i] = 0;
    FOR(i,1,n)children[p[i]][m[p[i]]++] = i;
    REP(i,n)sort(children[i], children[i]+m[i], [&](int a,int b){
      return l[a] < l[b];
    });
    dfs(0, k, beg);
    printf("%lld\n", arr[0][k]);
  }
  return 0;
}



Measured memory_bytes: 83764
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void dfs(Graph &g, vector<int> &seen, int v, int sskip, int eskip){
    seen[v] = 1;
    for(auto next : g[v]){
        if(seen[next] == 1) continue;
        if((v == sskip && next == eskip) || (v == eskip && next == sskip)) continue;
        dfs(g, seen, next, sskip, eskip);
    }
}

void solve(){
    int n, m; cin >> n >> m;
    Graph g(n);
    REP(i, m){
        int a, b;
        cin >> a>> b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(auto pr : g[i]){
            vector<int> seen(n, 0); 
            dfs(g, seen, 0, i, pr);
            bool flag = true;
            REP(j, n){
                if(seen[j] == 0) flag = false;
            }
            if(flag == false) cnt++;
        }
    }
    cout << cnt/2 << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b = {};
    int a[20][20] = {};
    for(int i=0;i<m;++i){
        int x;
        cin >> x;
        b.push_back(x);
    }
    int res = 0;
    for(int i=0;i<n;++i){
        int ans = 0;
        for(int j=0;j<m;++j){
            cin >> a[i][j];
            ans += a[i][j]*b[j];
        }
        ans += c;
        if(ans>0)++res;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N, C;
  scanf("%zu %zu", &N, &C);

  std::vector<std::vector<int>> imos(C, std::vector<int>(100001));
  for (size_t i = 0; i < N; ++i) {
    size_t s, t, c;
    scanf("%zu %zu %zu", &s, &t, &c);
    --c;
    ++imos[c][s-1];
    --imos[c][t];
  }

  for (size_t i = 0; i < C; ++i)
    for (size_t j = 1; j <= 100000; ++j)
      imos[i][j] += imos[i][j-1];

  int res = 0;
  for (size_t i = 0; i <= 100000; ++i) {
    int cur = 0;
    for (size_t j = 0; j < C; ++j)
      cur += (imos[j][i]? 1:0);

    res = std::max(res, cur);
  }

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


Measured memory_bytes: 12416
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;   //unsignedを付けることで符号なしを表す。(係数ソートの条件は0以上のため)
    
    int C[VMAX+ 1];
    int n, i, j;
    scanf("%d", &n);
    
    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    
    //count用配列の初期化
    for ( i = 0; i <= VMAX; i++ ) C[i] = 0;
    
    //配列Aを入力、Aで出てきた数字の回数をCに保存
    for ( i = 0; i < n; i++ ) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    
    //Cに保存した数字を足し合わせる
    for ( i =  1; i <= VMAX; i++ ) C[i] = C[i] + C[i -1];
    
    //配列Bにソートした値を格納する
    for ( j = 1; j <= n; j++ ) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for ( i = 1; i <= n; i++ ) {
        if ( i > 1 ) printf(" ");
        printf("%d", B[i]);
    } 
    printf("\n");
    
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<set<ll>> A{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}};
    ll x, y;
    cin >> x >> y;
    rep(i, 3) {
        if(A[i].find(x) != A[i].end()) {
            x = i;
            break;
        }
    }
    rep(i, 3) {
        if(A[i].find(y) != A[i].end()) {
            y = i;
            break;
        }
    }
    if(x == y) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long int
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define pis pair<ll,pll>
#define mex 100005
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
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);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
    
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans;
    cin>>n>>m;
    vll v(n);
    sum  = 0;
    rep(i,0,n)
    {
        cin>>v[i];
        sum+=v[i];
    }
    sort(all(v));
    reverse(all(v));
    if( sum <= 4 * m * v[m-1])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  string ans = "No";
  ll d = c - a - b;
  if (d > 0 and (4*a*b) < (d * d)){
    ans="Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, j, H, K, map[101][101];
	char a[201];
	scanf("%d %d", &H, &K);
	for (i = 0; i < H; i++)
	{
		scanf("%s", a);
		for (j = 0; j < K; j++)
		{
			if (a[j] == 'c')	/*??????????????????????????\??????*/
			{
				map[i][j] = 0;
			}
			else
			{
				map[i][j] = -1;		/*???.??????????????????????????????????????????*/
			}
		}
	}

	for (i = 0; i < H; i++)
	{
		for (j = 1; j < K; j++)
		{
			if (map[i][j] < 0)
			{
				if (map[i][j - 1] >= 0)		/*????????????????????????????????\???????????????????????????*/
				{
					map[i][j] = map[i][j - 1] + 1;	/*?????¨????????????????????????????????????*/
				}
			}
		}
	}

	for (i = 0; i < H; i++)
	{
		for (j = 0; j < K; j++)
		{
			if (j == K - 1)
			{
				printf("%d", map[i][j]);	/*??????????????´????????????????????????????????????*/
			}
			else
			{
				printf("%d ", map[i][j]);	/*???????????????????????????????????????*/
			}
		}
		printf("\n");
	}
	return 0;
}

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

"""
input:
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

output:
Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
"""

import sys


class Node(object):
    def __init__(self):
        # init node as a single leaf node.
        self.parent = -1
        self.children = []
        self.index = -1


def pre_parse(v):
    print(' ' + str(v.index), end='')

    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        pre_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        pre_parse(node_list[right_child_idx])

    return None


def in_parse(v):
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        in_parse(node_list[left_child_idx])

    print(' ' + str(v.index), end='')

    if right_child_idx != -1:
        in_parse(node_list[right_child_idx])

    return None


def post_parse(v):
    left_child_idx = v.children[0]
    right_child_idx = v.children[1]

    if left_child_idx != -1:
        post_parse(node_list[left_child_idx])

    if right_child_idx != -1:
        post_parse(node_list[right_child_idx])

    print(' ' + str(v.index), end='')

    return None


def generate_tree(_array):
    # add info of each node of a ordered tree
    for each in _array:
        idx, *children = [int(x) for x in each]
        # assert len(children) == 2 and idx >= 0
        node_list[idx].index = idx
        node_list[idx].children = children

        for child_idx in children:
            # non-existent node: no parent
            if child_idx == -1:
                continue
            node_list[child_idx].parent = idx

    # find root node
    root_idx = [x.index for x in node_list if x.parent == -1][0]
    root_node = node_list[root_idx]

    # tree walk in 3 ways
    print('Preorder')
    pre_parse(root_node)
    print('\n' + 'Inorder')
    in_parse(root_node)
    print('\n' + 'Postorder')
    post_parse(root_node)
    print('')

    return node_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.split(), _input[1:]))
    # assert len(array) == array_length

    node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array)

Measured memory_bytes: 7884
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::string;

int main()
{
  long long N;
  cin >> N;
  std::array<long long, 5> ct;
  for (size_t i = 0; i < ct.size(); ++i)
  {
    cin >> ct[i];
  }
  // city numbers
  std::array<long long, 6> cn;
  cn.fill(0);
  cn[0] = N;

  long long ctime = 0;
  auto minv = *std::min_element(ct.begin(), ct.end());
  long long ntime = N / minv + (N % minv == 0? 0 : 1);
  // cout << "ntime: " << ntime << "\n";
  ctime = ntime + 4;
  // long long st = 0;
  // long long ed = 1;
  // for (;; )
  // {
  //   ctime++;
  //   for (int i = ed; i >= st; --i)
  //   {
  //     long long pn = 0;
  //     pn = std::min(ct[i], cn[i]);
  //     // cout << i << "]:" << pn << "\n";
  //     cn[i + 1] += pn;
  //     cn[i] -= pn;
  //   }
  //   if (cn.back() == N)
  //   {
  //     break;
  //   }
  //   ed = std::min((long long)(ct.size() -1), ctime+1);
  //   st += (cn[st] == 0) ? 1 : 0;
  // }
  //   // for(const auto& item: cn)
  //   // {
  //   //   cout << item << ", " ;
  //   // }
  //   // cout << "\n";

  cout << ctime << "\n";
  return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(b-c)<=d))){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout <<"No"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<queue>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<cstring>
#include<cmath>
using namespace std;

typedef long long LL;

const int INF = 2147483647;
const LL crz1 = 1e9 + 7;
const LL crz2 = 1e9 + 9;
const LL seed = 163;
const int maxn = 300000;

struct data{
	LL x,y;
}a[maxn],b[maxn];

char s[maxn];
int n,tota,totb;
LL fac1[maxn],fac2[maxn],ans;

inline LL getint()
{
    LL ret = 0,f = 1;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') ret = ret * 10 + c - '0',c = getchar();
    return ret * f;
}

inline void dfs1(int dep,LL sr,LL sb,int now)
{
	if (dep > n) {a[++tota].x = (sr - sb * fac1[n] % crz1 + crz1) % crz1; return;}
	dfs1(dep + 1,(sr + fac1[now] * s[dep] % crz1) % crz1,sb,now + 1);
	dfs1(dep + 1,sr,(sb * seed % crz1 + s[dep]) % crz1,now);
}

inline void dfs2(int dep,LL sr,LL sb,int now)
{
	if (dep == n) {b[++totb].x = (sb - sr * fac1[n] % crz1 + crz1) % crz1; return;}
	dfs2(dep - 1,(sr * seed % crz1 + s[dep]) % crz1,sb,now);
	dfs2(dep - 1,sr,(sb + fac1[now] * s[dep] % crz1) % crz1,now + 1);
}

inline void dfs3(int dep,LL sr,LL sb,int now)
{
	if (dep > n) {a[++tota].y = (sr - sb * fac2[n] % crz2 + crz2) % crz2; return;}
	dfs3(dep + 1,(sr + fac2[now] * s[dep] % crz2) % crz2,sb,now + 1);
	dfs3(dep + 1,sr,(sb * seed % crz2 + s[dep]) % crz2,now);
}

inline void dfs4(int dep,LL sr,LL sb,int now)
{
	if (dep == n) {b[++totb].y = (sb - sr * fac2[n] % crz2 + crz2) % crz2; return;}
	dfs4(dep - 1,(sr * seed % crz2 + s[dep]) % crz2,sb,now);
	dfs4(dep - 1,sr,(sb + fac2[now] * s[dep] % crz2) % crz2,now + 1);
}

inline int cmp(data a,data b)
{
	return a.x < b.x || (a.x == b.x && a.y < b.y);
}

int main()
{
    #ifdef AMC
        freopen("AMC1.txt","r",stdin);
    #endif
    n = getint();
    scanf("%s",s + 1);
    fac1[0] = 1;
    for (int i = 1; i <= 2 * n; i++)
    	fac1[i] = fac1[i - 1] * seed % crz1;
    fac2[0] = 1;
    for (int i = 1; i <= 2 * n; i++)
    	fac2[i] = fac2[i - 1] * seed % crz2;
    
    dfs1(1,0,0,0);
    dfs2(2 * n,0,0,0);
    tota = totb = 0;
    dfs3(1,0,0,0);
    dfs4(2 * n,0,0,0);
    
    sort(a + 1,a + tota + 1,cmp);
    sort(b + 1,b + totb + 1,cmp);
    
    for (int i = 1; i <= tota; i++)
	{
		LL pos2 = upper_bound(b + 1,b + totb + 1,a[i],cmp) - b;
		LL pos1 = lower_bound(b + 1,b + totb + 1,a[i],cmp) - b;
		ans += pos2 - pos1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
int main() {
	//貪欲
	int N, M;
	cin >> N >> M;
	vector<long long>A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	vector<pair<long long,int>> CB(M);
	for (size_t i = 0; i < M; i++)
	{
		cin >> CB.at(i).second >> CB.at(i).first;
	}
	sort(CB.begin(), CB.end());
	int now=M-1;
	for (size_t i = 0; i < N; i++)
	{
		if (CB.at(now).first > A.at(i)) {
			A.at(i) = CB.at(now).first;
			CB.at(now).second--;
			if (CB.at(now).second<=0)
			{
				now--;
			}
			if (now==-1)
			{
				break;
			}
		}
	}
	long long ans=0;
	for (size_t i = 0; i < N; i++)
	{
		//cout << A.at(i) << endl;
		ans += A.at(i);
	}
	cout << ans;
}

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

int main() {
	int a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f, a || b || c || d || e || f) {
		a += d; b += e; c += f;
		int Max = 0;
		for (int i = 0; i <= min(2, min(a, min(b, c))); i++)
			Max = max(Max, (a - i) / 3 + (b - i) / 3 + (c - i) / 3 + i);
		cout << Max << endl;
	}
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int buf[n];
	bool flag = true;
	for(int i = 0; i < n; i++) buf[i] = -1;
	for(int i= 0; i < m; i++){
		int s,c;
		cin >> s >> c;
		if(buf[s-1] == -1 || buf[s-1] == c) buf[s-1] = c;
		else flag = false;
	}

	if(flag){
		for(int i=0;i < n;i++){
			if(buf[i] == -1){
				if(i == 0 && n != 1) buf[i] = 1;
				else buf[i] = 0;
			}
		}
		if(buf[0] == 0 && n != 1){
			cout << "-1" << endl;
		}else{
			int sum=0;
			for(int i=0;i<n;i++){
				sum += buf[i] * (int)pow(10.0, n-1-i);
			}
			cout << sum << endl;
		}
	}else{
		cout << "-1" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>

using namespace std;

int main(){
	string s;
	int n;
	
	cin >> n >> s;
	
	for(int i=0;i<s.size();i++){
		s[i] = (s[i] - 'A' + n)%26 + 'A';
	}
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
const int N=1e5+10;
#define PB push_back
vector<int> graph[N];
int val[N];
bool dfs(int now){
	for(int i:graph[now]){
		if(val[i]==val[now])return true;
		else if(val[i]==0) {
			val[i]=-val[now];
			if(dfs(i))return true;
		}
	}
	return false;
}
int main(){
	int n,m,l,r;
	long long int ans;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)val[i]=0;
	for(int i=0;i<m;i++){
		scanf("%d%d",&l,&r);
		graph[l].PB(r);
		graph[r].PB(l);
	}
	val[1]=1;
	if(dfs(1))ans=(((long long int)n*(long long int)(n-1))>>1)-m;
	else{
		l=r=0;
		for(int i=1;i<=n;i++)if(val[i]==1)l++;
		else r++;
		ans=(long long int)l*(long long int)r-m;
	}
	printf("%lld\n",ans);
}


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

int main(void){
    int N;
    cin>>N;
    ll aok,tkhs;
    cin>>aok>>tkhs;
    if (N==1) {
        cout<<aok+tkhs<<endl;
        return 0;
    }
    for (int i=1;i<N;i++){
        ll a,t;
        cin>>a>>t;
        ll x = (aok+a-1)/a;
        ll y = (tkhs+t-1)/t;
        ll n = max(x,y);
        aok=a*n;
        tkhs=t*n;
        //cout<<aok<<" "<<tkhs<<" "<<a<<" "<<t<<endl;
    }
    cout<<aok+tkhs<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B, class C> A power ( A x, B n, C mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A> A lcm ( A x, A y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A> inline boolean chmax ( A &a, const A &b ) { return b > a ? a = b, true : false; }
    template<class A> inline boolean chmin ( A &a, const A &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    Vector<String> vs;

    signed call_of_Cthulhu( signed datum ) {

        String s;
        read s;
        int k;
        read k;
        int n = s.size();
        for ( int i = 0; i < n; i++ ) {
            String tmp = "";
            for ( int j = 0; j < k; j++ ) {
                if ( i+j >= n ) break;
                tmp += s[i+j];
                vs.bash(tmp);
            }
        }
        bozo_sort(alles(vs));
        vs.erase(std::unique(alles(vs)), vs.end());
        echo vs[k-1] fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 1788
// 基本テンプレート

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

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, K;
int x[60], y[60];
signed main() {
    cin >> N >> K;
    rep(i,0,N) cin >> x[i] >> y[i];
    int ans = (ll)6 * 1e18;
    rep(i,0,N) rep(j,i+1,N) rep(k,0,N) rep(l,k+1,N) {
        int lx = min(x[i], x[j]);
        int rx = max(x[i], x[j]);
        int ly = min(y[k], y[l]);
        int ry = max(y[k], y[l]);

        int cnt = 0;
        rep(p,0,N) {
            if(lx <= x[p] && x[p] <= rx && ly <= y[p] && y[p] <= ry) cnt++;
        }
        if(cnt >= K) chmin(ans, (rx-lx) * (ry-ly));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define N_MAX 100005
using namespace std;

int main()
{
	int N;
    cin >> N;
  	int e = 0;
  	if(N%2 == 0){
    	e = (N-2)*N/2;
      	cout << e << endl;
      	for(int i = 1; i <= N; i++){
        	for(int j = i+1; j <= N; j++){
            	if(j != N+1-i){
                	cout << i << ' ' << j << endl;
                }
            }
        } 
    } else {
     	e = (N-1)*(N-1)/2;
      	cout << e << endl;
      	for(int i = 1; i <= N; i++){
        	for(int j = i+1; j <= N; j++){
            	if(j != N-i){
                	cout << i << ' ' << j << endl;
                }
            }
        } 
    }	
}

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

using namespace std;

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

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

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

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

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  fin(a - b < 0?0:a-b)
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,s=0;
    cin>>a>>b>>c>>k;
    while(a>=b)
    {
        b*=2;
        ++s;
        if(s==k)
            break;
    }
    while(b>=c&&s<k)
    {
        c*=2;
        ++s;

    }
    if(a<b&&b<c)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;

  map<int,bool> dict;
  int sum = 0;
  for(int i = 1;;i++){
    sum += i;
    dict[i] = true;

    if(sum > n){
      dict[sum-n] = false;
      break;
    }
    else if(sum == n)break;
  }

  for(auto p:dict){
    if(p.second)cout << p.first << endl;
  }

}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var ac, bc, cc int
	for _, c := range s {
		if c == 'a' {
			ac++
		}
		if c == 'b' {
			bc++
		}
		if c == 'c' {
			cc++
		}
	}
	if abs(ac-bc) < 2 && abs(bc-cc) < 2 && abs(cc-ac) < 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 2540
def main():
	n, n_truck = map(int, input().split())
	w_list = []

	for _ in range(n):
		w_list.append(int(input()))

	print(b_search(w_list, n_truck))
 
def b_search(w_list, n_truck):
	left = max(w_list)
	right = sum(w_list)
	while left < right:
		mid = int((left+right) / 2)
		if check(w_list, n_truck, mid):
			right = mid
		else:
			mid += 1
			left = mid

	return mid


def check(w_list, n_truck, p):
	truck_count = 1
	tmp_truck = 0

	for w in w_list:
		tmp_truck += w
		if tmp_truck > p:
			truck_count += 1
			tmp_truck = w
		if truck_count > n_truck:
			return False

	return True






if __name__ == '__main__':
    main()

Measured memory_bytes: 11640
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] chs1 = sc.next().toCharArray();
			final char[] chs2 = sc.next().toCharArray();
			
			int cnt = 0;
			for(int i = 0; i < chs1.length; i++) {
				if(chs1[i] == chs2[i]) { cnt++; }
			}
			
			System.out.println(cnt);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

const int N = 1e5 + 100;

typedef pair<int,int> pii;

pii a[N];
int n, cnt;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[i] = pii(x, i);
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (i % 2 != a[i].second % 2)
			cnt++; 	
	}
	return cout << cnt / 2, 0;
}


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

int main(){
  int A, B;
  string S, T, U;
  cin >> S >> T >> A >> B >> U;
  //cin >> A, B;
  //cin >> U;
  if(S == U) A-=1;
  else B-=1;
  cout << A <<" "<< B<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> ans(10);
  rep(i,N){
    string s; cin >> s;
    if(s == "AC") ans[0]++;
    else if(s == "WA") ans[1]++;
    else if(s == "TLE") ans[2]++;
    else ans[3]++;
  }


  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int count = 0;
  int ans_count = 0;
  for(int i=1; i<=N; i=i+2){
    count = 0;
    for(int j=1; j<=i; j=j+2){
      if(i%j==0){
        ++count;
      }
    }
    if(count == 8){
      ++ans_count;
    }
  }

  cout << ans_count << endl;

  return 0;
}


Measured memory_bytes: 256