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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    vll s1(n + 1, 0), s2(n + 1, 0);
    rep(i, n)
    {
        s1[i + 1] = s1[i] + a[i];
        s2[i + 1] = s2[i] + a[n - i - 1];
    }

    ll ans = LINF;
    rep(i, n - 1)
    {
        ll l = s1[i + 1] - s1[0];
        ll r = s2[n - i - 1] - s2[0];

        ans = min(ans, abs(l - r));
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int c[3];
  c[0] = a + b;
  c[1] = a - b;
  c[2] = a * b;
  sort(c, c + 3);
  cout << c[2] << "\n";
}
  

Measured memory_bytes: 3612
#include<cstdio>
#define maxn 100050
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
struct enode{
	int nxt,y;
}e[maxn];
int ans=0,tot=0;
int n,m;
int q[maxn],dp[maxn],first[maxn],goin[maxn];
void adde(int x,int y){
	e[tot].nxt=first[x];
	e[tot].y=y;
	first[x]=tot++;
	goin[y]++;
}
void tupu(){
	int head=1,tail=0;
	for (int i=1;i<=n;i++)
	if (!goin[i]) q[++tail]=i;
	while (head<=tail){
		int x=q[head++];
		if (dp[x]>ans) ans=dp[x];
		for (int i=first[x];i>=0;i=e[i].nxt){
			int y=e[i].y;
			goin[y]--;
			dp[y]=max(dp[x]+1,dp[y]);
			if (!goin[y]) q[++tail]=y;
		}
	}
}
int main(){

	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	first[i]=-1;
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		adde(x,y);
	}
	tupu();
	printf("%d\n",ans);
}

Measured memory_bytes: 2560
def gcd(a, b):
    if b > a:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def main():
    N, X = map(int, input().split())
    dif = list(map(lambda x: abs(int(x) - X), input().split()))

    ans = dif[0]
    for i in range(1, N):
        ans = gcd(ans, dif[i])
    print(ans)

main()


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

int main(){
  int X,Y;
  cin >> X >> Y;
  if(4*X >= Y && Y>= 2*X && Y % 2==0){
    cout << "Yes" << endl;
  }else{cout << "No" << endl;
       }
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int main()
{
    int i,j,k,l,m,n;
    cin>>n;
    int a[n+10];

    for(i=0;i<n;i++)cin>>a[i];
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }

    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

bool is_prime(const unsigned num);

int main() {
    int x, output;

    do {
        cin >> x;
    } while(x < 2 || x > pow(10, 5));

    output = x;
    while(!is_prime(output)) {
        output++;
    }
    cout << output << endl;

    return 0;
}

bool is_prime(const unsigned n){
    int output;

    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    
    return true;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

#define WA 0
#define AC 1

int main(){

    int n, m;
    cin >> n >> m;
    vector<vector<int>> S(n, vector<int>(2));
    for(int i = 0; i < m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA"){
            if(S[p-1][AC] == 0){
                S[p-1][WA]++;
            }
        }
        else if(s == "AC"){
            S[p-1][AC]++;
        }
    }
    int sum_ac = 0;
    int sum_wa = 0;
    for(int i = 1; i <= n; i++){
        if(S[i-1][AC] > 0){
            sum_ac++;
            sum_wa += S[i-1][WA];
        }
    }
    cout << sum_ac << " " << sum_wa << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    int n, k;
    cin >> n >> k;
    int r = 1;
    while(n/k>0){
        n/=k;
        r++;
    }
    cout << r << endl;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


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

#define INF 1e9
using namespace std;

int main() {

    int N, T; cin >> N >> T;
    int min_cost = INF;

    for (int i = 0; i < N; ++i) {
        int c, t;
        cin >> c >> t;

        if (t <= T) {
            min_cost = min(min_cost, c);
        }
    }

    if (min_cost == INF) {
        cout << "TLE" << endl;
    } else {
        cout << min_cost << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

vi prime(int N){
    vi prime(N+1,0);
    rep2(i,2,ceil(sqrt(N))+1){
        if(prime[i]==0){
            rep2(j,2,N/i+1){
                prime[i*j]= 1;
            }
        }
        
    }
    return prime;
}

int pown(int n,int N){
    int ans=0;
    while(N>0){
        N = N/n;
        ans++;
    }
    return ans-1;
}

int main(){
    int N;
    cin >>N;
    vi div;
    vi divpow(N+2);
    ll ans=1;
    if(N>1){
        vi p(N+2);
        p = prime(N+1);
        rep2(i,2,N+2){
            if(p[i]==0) div.PB(i);
        }
        for(int value:div){
            divpow[value] = pown(value,N);
            int kai=0;
            rep2(i,1,divpow[value]+1){
                kai += floor(N/pow(value,i));
            }
            ans = ans*((kai+1)%mod)%mod;
        }
        cout <<ans<<endl;;
    }
    else cout <<1<<endl;

}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = True
for i in range(N):
    while a[i]%2 == 0:
        if flag:
            flag = False
        a[i] = a[i]//2
        cnt += 1
if flag:
    print(0)
else:
    print(cnt)

Measured memory_bytes: 40688
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n, k,ans;
	cin >> n >> k;
	for(int i=1; i<=k; i++) {
		ans = 0;
		if (i == 1) {
			ans = -1;
		}
		ans += com(n - k - 1, i) * com(k - 1, i - 1);
		ans %= mod;
		ans += 2 * com(n - k - 1, i - 1) * com(k - 1, i - 1);
		ans %= mod;
		ans += com(n - k - 1, i - 2) * com(k - 1, i - 1);
		ans %= mod;
		cout << max(ans,0ll) << endl;
	}
}




Measured memory_bytes: 256
A=[]
B=[]
for i in range(4):
    a=int(input())
    A.append(a)
AA=sorted(A)
del AA[0]

for i in range(2):
    b=int(input())
    B.append(b)
BB=sorted(B)
del BB[0]

print(sum(AA)+sum(BB))


Measured memory_bytes: 5600
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

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

    sort(A.begin(), A.end());

    int MINUS = A[0];
    int PLUS = A[N - 1];

    vvi ans(0);

    for (int i = 1; i < N - 1; i++) {
        if (A[i] > 0) {
            ans.push_back({MINUS, A[i]});
            MINUS -= A[i];
        } else {
            ans.push_back({PLUS, A[i]});
            PLUS -= A[i];
        }
    }
    ans.push_back({PLUS, MINUS});

    cout << PLUS - MINUS << endl;
    for (int i = 0; i < N - 1; i++) {
        cout << ans[i][0] << ' ' << ans[i][1] << endl;
    }

    return 0;
}


Measured memory_bytes: 8240
#pragma GCC optimize(2)
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define sc(z) scanf("%d", &(z))
#define _ff(i, a, b) for (int i = (a); i <= (b); ++i)
#define _f(i, a, b) for (int i = (a); i < (b); ++i)
#define _rr(i, a, b) for (int i = (a); i >= (b); --i)
#define _r(i, a, b) for (int i = (a); i > (b); --i)
const int inf = 0x3f3f3f3f;
const int maxn = 105;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    if (x == 0) {
        if (k&1) cout << d << endl;
        else cout << 0 << endl;
        return 0;
    }
    ll p = x / d;
    if (x % d) {
        if (k <= p) cout << x - k * d << endl;
        else {
            ll res = p - k;
            ll p1 = x - p * d, p2 = abs(x - (p + 1) * d);
            if (p1 == p2) cout << p1 << endl;
            else {
                if (res&1) cout << p2 << endl;
                else cout << p1 << endl;
            }
        }
    } else {
        if (k <= p) cout << x - k * d << endl;
        else {
            ll res = p - k;
            if (res&1) cout << d << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int s0 = (int) s[0]-48;
  int s1 = (int) s[1]-48;
  int s2 = (int) s[2]-48;
  int s3 = (int) s[3]-48;
  int t0 = 10*s0+s1;
  int t1 = 10*s2+s3;
  if(t0>=1 && t0<=12){
    if(t1>=1&&t1<=12){
      cout<<"AMBIGUOUS";
    }else{
      cout<<"MMYY";
    }
  } else{
    if(t1>=1&&t1<=12){
      cout<<"YYMM";
    }else{
      cout<<"NA";
    }
  }
}


Measured memory_bytes: 256
using System.Linq;
using System;


public class hello
{
    public static void Main()
    {
        var moji = Console.ReadLine().Trim();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a =int.Parse( line[1]);
            var b = int.Parse(line[2]);
            switch (line[0])
            {
                case "print":
                    var buf = moji.Substring(a , b - a + 1);
                    Console.WriteLine(buf);
                    break;
                case "reverse":
                    var buf1 = moji.Substring(0, a);
                    var buf2 = moji.Substring(a, b - a + 1);
                    var buf3 = moji.Substring(b +1);
                    buf1 += new string(buf2.Reverse().ToArray()) + buf3;
                    moji = buf1;
                    break;
                default:  //replace
                    var p = line[3];
                    var buf4 = moji.Substring(0, a);
                    var buf5 = moji.Substring(b +1);
                    buf4 += p + buf5;
                    moji = buf4;
                    break;
            }
        }
    }
}

Measured memory_bytes: 9576
#include<stdio.h>
int main()
{
	int N,L,d,S;
	scanf("%d %d",&N,&L);
	if(L>=0){d=L;}
	else if(L+N-1<0){d=L+N-1;}
	else {d=0;}
	S=(N*(L+N+L-1))/2-d;
	printf("%d\n",S);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

main()

{
    int N, i, mehrab=0;
    scanf("%d",&N);

    int p[N];

    for(i=1; i<=N; i++)
    {
        scanf("%d",&p[i]);
    }

    for(i=1; i<=N; i++)
    {
        if(p[i] != i)
        {
            mehrab++;
        }
    }

    if(mehrab <= 2)
    {
        printf("YES\n");
    }
    else
        printf("NO\n");

    return 0;

}

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

const int MX = 100005;

int main() {
  int n;
  cin >> n;
  vector<ll> cnt(MX);
  rep(i,n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll tot = 0;
  rep(i,MX) tot += i*cnt[i];

  int q;
  cin >> q;
  rep(i,q) {
    int b, c;
    cin >> b >> c;
    tot -= b*cnt[b];
    tot -= c*cnt[c];
    cnt[c] += cnt[b]; cnt[b] = 0;
    tot += b*cnt[b];
    tot += c*cnt[c];
    cout << tot << endl;
  }
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int r,d,x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++){
    int ans = r*x-d;
    cout << ans << endl;
    x = ans;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 1e4+10;

int N;
set<int> adj[MAX];
vi C;

void solve() {
    sort(ALL(C));
    ll sm = 0;
    REP (i, N-1) sm += C[i];
    cout << sm << endl;

    vi ret(N);
    queue<int> que;
    REP (i, N) if (adj[i].size() == 1) que.push(i);
    REP (i_c, N) {
        int i = que.front();
        que.pop();
        ret[i] = C[i_c];
        if (i_c == N-1) break;
        int next = *adj[i].begin();
        adj[i].erase(adj[i].begin());
        adj[next].erase(adj[next].find(i));
        if (adj[next].size() == 1) que.push(next);
    }
    FORE (x, ret) cout << x << " ";
    cout << endl;
}

int main() {
    cin >> N;
    REP (i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].insert(b);
        adj[b].insert(a);
    }
    C = vi(N);
    REP (i, N) cin >> C[i];
    solve();
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>

using namespace std;

const int Nmax = 1e5 + 1;
int N,X;

struct el
{
    int student,poz;
} a[Nmax];

inline bool cmp(el a, el b)
{
    return a.student < b.student;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
    {
        cin >> X;
        a[i].poz = i,a[i].student = X;
    }
    sort(a + 1, a + N + 1,cmp);
    for(int i = 1; i <= N; ++i)
        cout << a[i].poz << " ";
    return 0;
}


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

answer = N
for i in range(N+1):
    count = 0
    t = i
    # i円を6円で払い、残りを9円で払う
    while t:
        count += t%6
        t //= 6
    t = N-i
    while t:
        count += t%9
        t //= 9
    answer = min(answer, count)
print(answer)



Measured memory_bytes: 3060
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

string s,t="2019/04/30";

main(){
	cin>>s;
	if(s<=t)dump("Heisei");
	else dump("TBD");
}






Measured memory_bytes: 256
def resolve():
    all_string = input()
    target_string = input()
    all_length = len(all_string)
    target_length = len(target_string)
    max_count = 0
    for i in range(all_length - target_length + 1):
        count = 0
        part_string = all_string[i:i+target_length]
        for s1, s2 in zip(part_string, target_string):
            if s1 == s2:
                count +=1
        if count>max_count:
            max_count = count
    print(target_length - max_count)

resolve()

Measured memory_bytes: 67876
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = "" 

while True:
    try:
        lines += input().lower()
    except EOFError:
        break
        
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
        
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 8096
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a[3],k;
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
  }
  cin>>k;
  int j=0;
  //int cards
  
  long long int cards=0;
  
  while(k)
  {
    if(k-a[j]>0)
    {
      if(j==0)
        cards+=a[j] ;
      if(j==2)
         cards-=a[j];
        
      k-=a[j];  
      
      j++;
    }
      
      else
      {
        if(j==0)
          cards+=k;
        if(j==2)
          cards-=k;
          
        k=0;
      }
        
  }
  
  cout<<cards;
  
  return 0;
}

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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a != b) {
    cout << max(a, b) + max(a, b) - 1 << '\n';
  } else {
    cout << a + b << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)
            


Measured memory_bytes: 4936
#include<stdio.h>
int main()
{
    char A[1000],B[1000],C[1000];
    int i,j,k;
    scanf("%s %s %s",A,B,C);
    for(i=0;A[i]!='\0';i++)
    {

    }
    for(j=0;B[j]!='\0';j++)
    {

    }
    if(A[i-1]==B[0] && B[j-1]==C[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pf push_front
#define pb push_back
using namespace std;
using ll = long long; using ld = long double;
using pii = pair<int,int>; using pil = pair<int,ll>;
using pli = pair<ll,int>; using pll = pair<ll,ll>;
const int MOD = 1000000007, MOD2 = 998244353;
const int INF = 0x3f3f3f3f, INF2 = 0x3f3f3f37;
const ll LINF = 0x3f3f3f3f3f3f3f3f, LINF2 = 0x3f3f3f3f3f3f3f3d;
const int N = 200005;

int n, k, q;
int f[N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k >> q;
    for (int i = 0; i < q; ++i) {
        int a; cin >> a;
        ++f[a];
    }
    for (int i = 1; i <= n;++i)
        cout << (k - q + f[i] > 0 ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;
int main() {
	queue<int>que;
	int n, m, c[1000] = { 0 }, i, j;
	cin >> n >> m;
	for (i = 1; i <= 2 * n; i++) {
		c[i] = i;
	}
	for (i = 0; i < m; i++) {
		int num;
		cin >> num;
		if (num == 0) {
			for (j = 1; j <= n; j++) {
				que.push(c[j]);
				que.push(c[n + j]);
			}
		}
		else {
			for (j = num + 1; j <= 2 * n; j++) {
				que.push(c[j]);
			}
			for (j = 1; j <= num; j++) {
				que.push(c[j]);
			}
		}
		for (j = 1; j <= 2 * n; j++) {
			c[j] = que.front();
			que.pop();
		}
	}
	for (i = 1; i <= 2 * n; i++) {
		cout << c[i] << endl;
	}
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n;
    cin >> n;
    vector <double> x(n), y(n);
    vector <int> used(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                if (used[j]) continue;
                //cout << i+1 << " " << j+1 << endl;
                sum += sqrt(abs(x[i]-x[j])*abs(x[i]-x[j]) + abs(y[i]-y[j])*abs(y[i]-y[j]))*2;
                //cout << sum << endl;
            }
            used[i] = 1;
        }
    }
    int tmp1 = 1, tmp2 = 1;
    for (int i = 1; i <= n; i++) tmp1 *= i;
    for (int i = 1; i <= n-1; i++) tmp2 *= i;
    cout << setprecision(10) << (sum*tmp2) / tmp1<< endl;
    return 0;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: i64, b: i64, x: i64
    }
    let k = if a == 0 {0} else {(a-1)/x+1};
    println!("{}", (b/x+1) - k);
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> c(m), results(n+1);
	
	for (int i = 0; i < m; ++i)
		cin >> c[i];

	results[0] = 0;
	for (int i = 1; i <= n; ++i)
	{
		results[i] = n + 1;
		for (int j = 0; j < m; ++j)
		{
			if (i >= c[j])
			{
				int tmpCoins = results[i - c[j]] + 1;
				if (tmpCoins < results[i])
					results[i] = tmpCoins;
			}
		}
	}
	cout << results[n] << endl;
}

Measured memory_bytes: 1288
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

class taskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a, b;
		in >> a >> b;
		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
			out << "Possible" << endl;
		else
			out << "Impossible" << endl;
	}
};


int main() {
	taskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

const int INF = (int)1e5;

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

    int N, C;
    scanf("%d %d", &N, &C);

    int p[C][INF];
    memset(p, 0, sizeof(p));
    int tmp_s, tmp_t, tmp_c;
    for (int i = 0; i < N; ++i) {
        scanf("%d %d %d", &tmp_s, &tmp_t, &tmp_c);
        for (int j = tmp_s - 1; j < tmp_t; ++j) {
            p[tmp_c - 1][j] = 1;
        }
    }

    int max_count = 0;
    for (int j = 0; j < INF; ++j) {
        int count = 0;
        for (int i = 0; i < C; ++i) {
            count += p[i][j];
        }
        max_count = max(max_count, count);
    }

    cout << max_count << '\n';

    return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
#define N 100010
set<int> s;
set<int>::iterator it,tmp;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,a[N],pos[N],mx,mn;
ll ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		pos[a[i]]=i;
	}
	s.insert(pos[n]);
	mx=mn=pos[n];
	//cout<<" "<<pos[n]<<endl;
	for(int i=n-1;i>=1;i--){
		it=s.lower_bound(pos[i]);
		int l=0,r=n+1,x=0,y=n+1;
		//cout<<pos[i]<<" "<<(*it)<<endl;
		if(pos[i]<mx){
			//cout<<"tt"<<endl;
			r=(*it);
			if(r!=mx){
				tmp=s.lower_bound(r);
				tmp++;
				y=(*tmp);
			}
		}
		if(pos[i]>mn){
			l=(*--it);
			if(l!=mn){
				tmp=(s.lower_bound(l));
				x=(*--tmp);
			}
		}
		//cout<<l<<" "<<r<<" "<<x<<" "<<y<<endl;
		ans+=(ll)i*(y-r)*(pos[i]-l)+(ll)i*(l-x)*(r-pos[i]);
		s.insert(pos[i]);
		mx=max(pos[i],mx);
		mn=min(pos[i],mn);
		//cout<<" "<<pos[i]<<endl;
		//cout<<endl<<endl;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std; 
typedef long long ll; 
map<int, int> app; 
int main()
{
	// freopen("ARC087-C.in", "r", stdin); 
	int n, ans = 0; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		int x; 
		scanf("%d", &x); 
		app[x]++;
	}
	for (auto it : app)
		ans += it.second >= it.first ? it.second - it.first : it.second; 
	printf("%d\n", ans);
	return 0; 
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_S 3010

string S, T;

// 文字列 s と t の最長共通部分列(LCS)を求める
// O(2|s||t|)
string lcs(string s, string t) {
    // まず DP で長さを求める
    // S の [0, i] と、 T の [0, j] を使った時の LCS の長さ
    vector< vector<ll> > dp(s.length()+1, vector<ll>(t.length()+1, 0));
    for(int i = 1; i <= s.length(); ++i) {
        for(int j = 1; j <= t.length(); ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(S[i-1] == T[j-1]) { dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1); }
        }
    }
    // この時点で dp[s.length()][t.length()] に LCS の長さが入る
    // ここから経路復元
    string ret = "";
    int s_ind = s.length(), t_ind = t.length();
    while(ret.length() < dp[s.length()][t.length()]) {
        if(dp[s_ind][t_ind] == dp[s_ind-1][t_ind]) { s_ind--; }     // 同じならこの s_ind は使われていない
        else if(dp[s_ind][t_ind] == dp[s_ind][t_ind-1]) { t_ind--; }
        else {
            s_ind--;
            t_ind--;
            ret += S[s_ind];
        }
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

signed main()
{
    cin >> S >> T;
    printf("%s\n", lcs(S, T).c_str());
    return 0;
}


Measured memory_bytes: 70912
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int a=0,b=0,c=0,d=0;
  for(int i=0;i<4;++i){
    int tmp;
    cin>>tmp;
    if(tmp==1){
      a=1;
    }
    if(tmp==7){
      b=1;
    }if(tmp==9){
      c=1;
    }if(tmp==4){
      d=1;
    }
  }
  if(a+b+c+d==4){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();
		int N = scan.nextInt();
		int[] A = new int[N];

		for(int i=0; i < N; i++) A[i] = scan.nextInt();

		(new Solve(A, N)).solve();
	}
}
class Solve {
	private final int[] A;
	private final int N;

	public Solve(final int[] A, final int N)
	{
		this.A = A;
		this.N = N;
	}

	public void solve()
	{
		int count = 0;
		boolean cont = true;

		int[] sorted = new int[N];

		for(int i=0; i < N; i++) sorted[i] = A[i];

		while(cont)
		{
			cont = false;

			for(int i=N-1; i >= 1; i--)
			{
				if(sorted[i-1] > sorted[i])
				{
					int e = sorted[i];
					sorted[i] = sorted[i-1];
					sorted[i-1] = e;
					count++;
					cont = true;
				}
			}
		}

		for(int i=0; i < N; i++)
		{
			if(i > 0) System.out.print(" ");
			System.out.print(sorted[i]);
		}
		System.out.println("");
		System.out.println(count);
	}
}
class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

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

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}

Measured memory_bytes: 24460
import sys
N, Y = map(int, input().split())
for i in range(N + 1):
    if 10000 * i > Y:
        break
    for j in range(N + 1 - i):
        if 10000 * i + 5000 * j > Y:
            break
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k > Y:
            break
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print('{0} {1} {2}'.format(i, j, k))
            sys.exit()
print('-1 -1 -1')

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

int main()
{
	priority_queue< int,vector<int>,less<int> > que;
	int in;

	for(int i = 0; i < 10; i++){
		cin >> in;
		que.push(in);
	}


	for(int j = 0; j < 3; j++){
		cout << que.top() << '\n';
		que.pop();
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> mp;
int a[200005];
ll cnt[200005];
ll sum;
int main()
{
    int n;  cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        ll t = it->second;
        sum+=t*(t-1)/2;
    }
    for(int i=0;i<n;i++)
    {
        ll ans=sum-(ll)mp[a[i]]+1;
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    int n,b,c;
    cin>>n;
    vector<int>v(n);
    vector<int>v2(n);
    vector<int>v3(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>v2[i];
    }
    for(int i=0;i<n;i++){
        v3[i]=v[i]-v2[i];
    }
    int s=0;
    for(int i=0;i<n;i++){
        if(v3[i]>0)s+=v3[i];
    }
   cout<<s;
}


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

using namespace std;

typedef long long int ll;

struct pr{
    int x,y ;
};

typedef struct pr pp ;

bool compareble(pp a,pp b){
    
    return (a.x+a.y)<(b.y+b.x);
    
}

bool compareblee(pp a,pp b){
    
    return abs(a.x-a.y)<abs(b.x-b.y) ;
}

int main() {
	
	int n , maxy=1 , index ;
	
	ll maxdist=0 , u  , v ;
	
	cin>>n;
	
	pp ar[n];
	
	for(int i=0;i<n;i++) cin>>ar[i].x>>ar[i].y ;
	
	sort(ar,ar+n,compareble) ;
	
	for(int i=0;i<n;i++)
	{
	    if(ar[i].y>maxy)
	    {
	        maxy=ar[i].y ;
	        index=i ;
	    }
	}
	
	for(int i=0;i<n;i++)
	{
	    u=abs(ar[i].y-ar[0].y);
	    
	    u+=abs(ar[i].x-ar[0].x);
	    
	    v=abs(ar[i].y-ar[n-1].y);
	    
	    v+=abs(ar[i].x-ar[n-1].x);
	    
	    maxdist=max(max(u,v),maxdist);
	}
	
	sort(ar,ar+n,compareblee);
	
	for(int i=0;i<n;i++)
	{
	    u=abs(ar[i].y-ar[0].y);
	    
	    u+=abs(ar[i].x-ar[0].x);
	    
	    v=abs(ar[i].y-ar[n-1].y);
	    
	    v+=abs(ar[i].x-ar[n-1].x);
	    
	    maxdist=max(max(u,v),maxdist);
	}
	
	sort(ar,ar+n,compareblee);
	
	cout<<maxdist ;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    bool flag = true;
    int cnt = 0, n = -1;
    if(s[0] == 'A'){
        for (int i = 2; i < s.length() - 1; i++) {
            if (s[i] == 'C') {
                cnt++;
                n = i;
            }
        }
        if(cnt == 1){
            for (int i = 1; i < s.length(); i++) {
                if(i != n){
                    if (!(s[i] >= 97 && s[i] <= 122)) {
                        flag = false;
                        break;
                    }
                }
            }
        }else{
            flag = false;
        }
    }else{
        flag = false;
    }
    if (flag) {
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  int h,w;
  cin>>h>>w;
  vector<string> A;
  rep(i,h){
    string a;cin>>a;
    A.push_back(a + ".");
  }
  A.push_back("");
  rep(i,w){
    A[h].push_back('.');
  }

  int x = 0, y=0;
  while(true){
    A[y][x] = '.';
    if(y==h-1 && x==w-1){
      break;
    }
    if(A[y+1][x] == '#'){
      y++;
    }else if(A[y][x+1] == '#'){
      x++;
    }else{
      break;
    }
  }
  rep(i,h){
    rep(j,w){
      if(A[i][j] == '#'){
        cout<<"Impossible"<<endl;
        return 0;
      }
    }
  }
  cout<<"Possible"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    double ans = a[0];
    rep(i,n) ans = (ans + a[i]) / 2;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+1,mod),b(m+1,mod),A(n+1),B(m+1);
    rep(i,n) cin >> a[i];
    rep(j,m) cin >> b[j];
    rep(i,n) A[i+1] = A[i] + a[i];
    rep(j,m) B[j+1] = B[j] + b[j];
    ll ans = 0,j = m;
    rep(i,n+1) {
        if(A[i] > k) break;
        while(B[j] > k - A[i]) {
            if(j == 0) break;
            j -= 1;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
//#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e9, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int ans[N], us[N];

int32_t main() {
	use_fast;
	int n, x;
	cin >> n >> x;
	if(x == 1 || x ==  2 * n - 1)
		return cout << "No" << endl, 0;
	ans[n - 1]=x;
	us[x] = true;
	int l = 1, d = 1, r = 2 * n - 1;
 	cout << "Yes" << endl;
    for(int i = 1 ; i < n; i++){
       	while(us[l])
			l++;
        while(us[r])
			r--;
        us[l] = true;
        us[r] = true;
        ans[n -1 + i * d] = l;
         ans[n -1 - i * d] = r;
    	d *= -1;
	}
   	for(int i = 0; i < 2 * n - 1; i++)
    	cout << ans[i]<< endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 5172
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))

char s[200010];
int x;
int ans;

int main(){
	scanf("%s" , s);
	for(int i = 0 ; s[i] != 0 ; ++i){
		if(s[i] == 'S'){
			++x;
		} else {
			if(x == 0) ++ans;
			else --x;
		}
	}
	printf("%d\n" , ans * 2);
	return 0;
}


Measured memory_bytes: 384