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

bool isprime(int p){
	if(p <= 1) return false;
  for(int i=2; i*i<=p; ++i){
		if(p%i == 0) return false;
  }
  return true;
}

int main(){
	int N; cin>>N;
	for(int n=0,p=11; p<=55555 && n<N; p+=10)
		if(isprime(p) && p%5==1){ cout<<p<<" "; n++; }
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);

    ll ans = 1e+15;
    rep(i,n){
        cin>>h[i];
    }

    for(int bit=0;bit<(1<<n);bit++){
        vector<ll> ht(n);
        copy(h.begin(),h.end(),ht.begin());
        
        int t = bit;
        ll mx=0;
        ll cost=0;
        int cnt=0;
        rep(i,n){
            if(t&1){
                if(mx>=ht[i]){
                    cost += mx+1-ht[i];
                    ht[i]=mx+1;
                }
            }
            if(ht[i]>mx){
                mx = ht[i];
                cnt++;
            }
            t>>=1;
        }
        if(cnt>=k){
            ans = min(cost,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
}


Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	final Scanner sc = new Scanner(System.in);
	Integer[] ar=new Integer[10];
	for(int i=0;i<10;i++) ar[i]=sc.nextInt();
	Arrays.sort(ar,Collections.reverseOrder());
	for(int i=0;i<3;i++) System.out.println(ar[i]);
    }
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
using namespace std;
 
#define MAX 100002
 
int n;
vector<int> v;
 
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	long long int cnt = 0;
	for (int i = 0; i + 1 < v.size(); i++){
		cnt += v[i] / 2;
		v[i] %= 2;
		long long int m = min(v[i + 1], v[i]);
		cnt += m;
		v[i + 1] -= m;
	}
	cnt+=v.back()/2;
	printf("%lld\n", cnt);
	//cout << cnt << endl;
	return 0;
}


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

using namespace std;

const int Maxn = 60;

int n;
long long x, ans;
long long s[Maxn], p[Maxn];

int main()
{
    cin >> n >> x;
    s[0] = p[0] = 1;
    for(int i = 1; i <= n; ++i)
    {
        s[i] = s[i-1]*2+3;
        p[i] = p[i-1]*2+1;
    }
    for(int i = n; i >= 0; --i)
    {
        if(s[i] <= x)
        {
            x -= s[i];
            ans += p[i];
            if(x) // the mid P
            {
                x--;
                ans++;
            }
            if(s[i] <= x)
            {
                x -= s[i];
                ans += p[i];
            }
            if(x) x--; // the top B
        }
        else x--; // cut tht B at bottom
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
vi a,b;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N;
	a.resize(N+1);
	b.resize(N+1);
	rep(i,N)cin>>a[i];
	rep(i,N)cin>>b[i];
	int ans = 0;
	rep(i,N){
		int tmp = 0;
		rep(j,i+1)tmp+=a[j];
		REP(j,i,N+1)tmp+=b[j];
		ans = max(ans,tmp);
	}
	P(ans)
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using P = pair<int, int>;
 
int main() {
  int H, W, M;
  cin >> H >> W >> M;
 
  set<P> points;
  rep(i,0,M-1) {
    int h, w;
    cin >> h >> w;
    points.insert(P(h, w));
  }
 
  map<int, int> mp_rows, mp_columns;
  int max_row_cnt = 0;
  int max_column_cnt = 0;
 
  for (P point : points) {
    max_row_cnt = max(max_row_cnt, ++mp_rows[point.first]);
    max_column_cnt = max(max_column_cnt, ++mp_columns[point.second]);
  }
 
  vector<int> max_row_indices;
  for (auto mp_row : mp_rows) {
    if (max_row_cnt == mp_row.second)
      max_row_indices.push_back(mp_row.first);
  }
 
  vector<int> max_column_indices;
  for (auto mp_column: mp_columns) {
    if (max_column_cnt == mp_column.second)
      max_column_indices.push_back(mp_column.first);
  }
 
  int ans = max_row_cnt + max_column_cnt;
  for (auto h : max_row_indices) {
    for (auto w : max_column_indices) {
      if (points.find(P(h, w)) == points.end()) {
        cout << ans << endl;
        return 0;
      }
    }
  }
 
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 49656
#include "bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    vector<bool> flagH(H);
    vector<bool> flagW(W);
    for (int i = 0; i < H; i++) {
        flagH[i] = false;
    }
    for (int i = 0; i < W; i++) {
        flagW[i] = false;
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') {
                flagH[i] = true;
                flagW[j] = true;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        if (flagH[i]) {
            for (int j = 0; j < W; j++) {
                if (flagW[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll p[5500],c[5500];
int main(){
    ll n,k,ans=-1e11;
    cin>>n>>k;
    rep(i,0,n)cin>>p[i+1];
    rep(i,0,n)cin>>c[i+1];
    
    rep(i,1,n+1){
        ll tmp=0;
        ll ans1=-1e11;
        ll pos=i;
        ll cnt=0;
        ll rans=-1e11;
        bool f=false;
        while(!f){
            pos=p[pos];
            tmp+=c[pos];
            cnt++;
            rans=max(rans,tmp);
            if(pos==i)f=true;
        }
        if(tmp<=0){
           // cout<<"#";
            rans=-1e11;
            tmp=0;
            rep(i,0,min(k,cnt)){
                pos=p[pos];
                tmp+=c[pos];
                rans=max(rans,tmp);
                //cout<<tmp<<"&";
            }
            ans1=rans;
           // cout<<rans<<" "<<ans1<<endl;
        }
        else{
            ans1=tmp*(k/cnt);
            ll ct=k%cnt;
            ll tmp2=0;
            ll rans2=0;
            ll pos2=i;
            rep(i2,0,ct){
                pos2=p[pos2];
                tmp2+=c[pos2];
                rans2=max(rans2,tmp2);
            }
            ans1+=rans2;
            ll ans2=0;
           // cout<<ct<<" "<<rans2<<endl;
            if(k>=cnt)ans2=tmp*(k/cnt-1)+rans;
            ans1=max(ans1,ans2);
        }
        ans=max(ans,ans1);
       // cout<<cnt<<" "<<tmp<<" "<<ans1<<endl;
    }
    cout<<ans<<endl;
}




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

int main() {
	int n;
	vector<int> a;

	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int ans = 0;
	int mode = 0;
	bool update = false;
	
	int pre = 0;
	for (int i = 0; i < n; i++) {
		update = false;

		if (mode == 0) {
			if (a[i] < a[pre]) mode = -1;
			if (a[i] > a[pre]) mode = 1;
		}
		else {
			if ((mode == 1 && a[i] < a[pre]) ||
				(mode == -1 && a[i] > a[pre])) {
				mode = 0;
				ans++;
				update = true;
			}
		}

		pre = i;
		if (update) i--;
	}
	ans++;

	cout << ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
int main(){
		char s;
		cin >> s;
		if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u')cout << "vowel" << endl;
		else puts("consonant");
		return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int i=0;
    int j=0;
    int N,count;
    cin >> N;
    count = 0;
    for(int i=0; i<=N/4; i++){
        for(int j=0; j<=N/7; j++){
            if(4*i + 7*j == N && count == 0){
                cout << "Yes";
                count = 1;
                break;
            }
        }
    }

    if(count == 0) cout << "No";
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	//cout << fixed << setprecision(10);
	long long int n, m, res[200] = {}, b[105], memo =0, key,index,ax;
	string str;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> b[i];
		if (i < b[i]) {
			cout << -1;
			return 0;
		}
	}

	for (int i = 1; i <= n; i++) {
		key = 0;
		ax = 0;
		for (int j = 1; j <= n; j++) {
			if (b[j] != -1) {
				key++;
			}
			if (key == b[j]) {
				index = j;
				ax = max(ax, key);
			}
		}
		b[index] = -1;
		res[i] = ax;
	}

	for (int i = n; i >= 1;i--) {
		cout << res[i] << endl;
	}
}

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

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

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

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

int main()
{
    int N, M;
    cin>>N>>M;
    UnionFind UF(N);

    for (int i=0; i<M; i++)
    {
        int x, y, z;
        cin>>x>>y>>z;
        UF.unite(x-1, y-1);
    }

    set<int> S;
    for (int i=0; i<N; i++)
        S.insert(UF.root(i));
    cout<<S.size()<<endl;
}


Measured memory_bytes: 5760
#include<stdio.h>
int main(void){
    int a,b,c,x,A;
    x=0;
    scanf("%d %d %d",&a,&b,&c);
    for(A=a;A<=b;A++){
        if(c%A==0){
            x++;
        }
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
int main()
{
    int n,m,r,i,a=0,b;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&r);
        a=a+r;
    }
    b=n-a;
    if(b>=0)
        printf("%d",b);
    else
        printf("-1");
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;
int x[100001],y[100001];
int table[4001][4001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n>>m;
    for(int i=0;i<n;i++){
        char c;
        cin>>x[i]>>y[i]>>c;
        if(c=='W'){
            x[i]+=m;
        }
        x[i]%=2*m;
        y[i]%=2*m;
    }
    for(int i=0;i<n;i++){
        table[y[i]][x[i]]++;
        table[y[i]+m][x[i]]--;
        table[y[i]][x[i]+m]--;
        table[y[i]+m][x[i]+m]++;
        y[i]+=m;x[i]+=m;
        table[y[i]][x[i]]++;
        table[y[i]+m][x[i]]--;
        table[y[i]][x[i]+m]--;
        table[y[i]+m][x[i]+m]++;
    }
    for(int i=0;i<4001;i++){
        for(int j=1;j<4001;j++){
            table[i][j]+=table[i][j-1];
        }
    }
    for(int i=1;i<4001;i++){
        for(int j=0;j<4001;j++){
            table[i][j]+=table[i-1][j];
        }
    }
    for(int i=0;i<4*m;i++){
        for(int j=0;j<4*m;j++){
            int temp=table[i][j];
            table[i][j]=0;
            table[i%(2*m)][j%(2*m)]+=temp;
        }
    }
    int ans=0;
    for(int i=0;i<2*m;i++){
        for(int j=0;j<2*m;j++){
            ans=max(ans,table[i][j]);
        }
    }
    cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 63616
#include"bits/stdc++.h"
using namespace std;


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int long long int

int dp[100005];
vector<int>arr(100005);
int k, n;
int call(int i)
{
	if (i == n) return 0;
	if (dp[i] != -1) return dp[i];

	int mini = 1e10;

	for (int j = i + 1; j <= min(n, i + k); j++)
	{
		mini = min(mini, abs(arr[i] - arr[j]) + call(j));
	}

	return dp[i] = mini;


}


signed main()
{

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	cin >> n >> k;

	rep(i, n) cin >> arr[i];

	memset(dp, -1, sizeof dp);
	cout << call(1);

}

Measured memory_bytes: 8064
n = int(input())
pt = 0
px, py = 0, 0
f = True
for i in range(n):
    t, x, y = map(int, input().split())
    dis = abs(px-x) + abs(py-y)
    dt = t - pt
    #print("dis{0} dt = {1}".format(dis, dt))
    if dt >= dis and abs(dis - dt) % 2 == 0:
        pass
    else:
        f = False
    pt, px, py = t, x, y
print("Yes" if f else "No")


Measured memory_bytes: 46184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st s;
  cin >> s;
  ll n;
  cin >> n;
  ll x=0;
  st t="";
  while(x<s.size()){
    t+=s[x];
    x+=n;
  }
  cout << t << endl;
}


Measured memory_bytes: 384
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
for i in range(3):
    if s[i]==s[i+1]:
        print("Bad")
        exit()
print("Good")

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int x,a,b;
    cin>>x>>a>>b;
    if (abs(x-a)<abs(x-b)){
        cout<<'A';
    }else cout<<'B';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll Cal(ll,ll);
int main(){
  ll cnt,cnt2,b,cal,p,r;
  char com;
  string str,in;
  while(1){
    cin >> in;
    if(in=="#") break;
    str.clear();
    for(int i=0;i<in.size();i++){
      if(in[i]=='n'||in[i]=='w') str+=in[i];
    }
    reverse(str.begin(),str.end());
    if(str[0]=='n') com='w',cal=0;
    else com='n',cal=90;
    cnt=0;
    int flag=0;
    for(int i=1;i<str.size();i++){
      if(flag==0&&str[i]==com){
    flag=1;
    b=i;
      }
      if(str[i]=='n'||str[i]=='w') cnt++;
    }
    p=(ll)pow(2,cnt);
    if(str[0]=='w') cal=(ll)pow(2,cnt)*90;
    cnt2=0;
    for(int i=1;i<str.size();i++){
      if(str[i]=='n'||str[i]=='w') cnt2++;
      if(i>=b){
    if(str[i]=='n'){
      cal-=(ll)p/pow(2,cnt2)*90;
    }
    else if(str[i]=='w'){
      cal+=(ll)p/pow(2,cnt2)*90;
    }
      }
    }
    if((ll)cal%p!=0){
      r=(ll)Cal(cal,p);
      cout << (ll)cal/r << '/' << (ll)p/r << endl;
    }
    else cout << cal/p << endl;
  }
  return 0;
}
ll Cal(ll a,ll b){
  ll cp;
  if(a<b) swap(a,b);
  while(a%b!=0){
    cp=a;
    a=b;
    b=cp%b;
  }
  return b;
}

Measured memory_bytes: 1232
//g++  5.4.0

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

const int mod = 1e9+7;
const int nax =1e4+10;
int dp[nax][100][2];
signed main()
{
    fast;
    string s;
    cin >> s;
    int n;
    cin >> n;
    int len = (int)(s.size());
    memset( dp,-1,sizeof(dp) );
    
    function< int(int,int,int) > solve = [&](int pos,int m,int f)
    {
        if( pos==len )
            return (int)(m==0);
        if( dp[pos][m][f] != -1) 
            return dp[pos][m][f];
        int &res = dp[pos][m][f];
        res = 0;
        int lim = 9;
        if( !f ) lim = s[pos]-'0';
        
        for(int i=0 ; i<lim ; i++ )
        {
            res += solve( pos+1 , (m+i)%n , 1 );
            res %= mod;
        }
        res += solve( pos+1 , (m+lim)%n , f );
        res %= mod;
        return res;
    };
    
    cout << (solve(0,0,0)-1+mod)%mod;
}





Measured memory_bytes: 17152
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

void chmin(long& x, long y)
{
	if (x > y || x < 0)
		x = y;
}

void core()
{
	size_t N;
	cin >> N;

	string hs_str;
	std::vector<long> hs(N);
	for (size_t i = 0; i < N; ++i)
	{
		cin >> hs_str;
		hs[i] = stoi(hs_str);
		//cout << hs[i] << endl;
	}


	vector<long> dp(N + 1, -1);
	dp[1] = 0;
	chmin(dp[2], dp[1] + std::abs(hs[1] - hs[0]));


	for (size_t i = 3; i <= N; ++i)
	{
		chmin(dp[i], dp[i-1] + std::abs(hs[i - 1] - hs[i - 2]));
		chmin(dp[i], dp[i - 2] + std::abs(hs[i - 1] - hs[i - 3]));
	}

	long ret = dp[N];
	cout << ret;
}

int main()
{
	core();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	vector<int> hash(n);
	for(auto &x : hash)
		cin >> x;
	sort(hash.rbegin(),hash.rend());
	ll sum = hash[0];
	if(n%2==0){
		for(int i = 1 ; i < (n+1)/2 ;i++)
			sum+=hash[i]*2;
	}
	else{
		for(int i = 1 ; i < n/2 ; i++)
			sum+=hash[i]*2;
		sum += hash[n/2];
	}
	cout<<sum<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3988
//By Sho10 aka JuniorMonster
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
using namespace std;
int32_t main(){
ll int s=0,n,a[1000];
cin>>n;
for(ll int i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
for(ll int i=0;i<n-1;i++)
    s=s+a[i];
if(a[n-1]<s){
    cout<<"Yes";
}else cout<<"No";
return 0;}


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

long long int calcModPow(long long int a, long long int n, long long int m) {
	if (n == 0){
		return 1 % m;
	}
    if (n == 1){
        return a % m;
    }

    if (n % 2 == 1){
        return (a * calcModPow(a, n - 1, m)) % m;
    }

    long long int t = calcModPow(a, n / 2, m);
    return (t * t) % m;
}

int main() {
    long long int N, res, mod = 1000000007;
    long long int zero = 1, nine = 1, zn = 0, other = 8;
    cin >> N;

    for(int i=1; i<N; i++){
        zn = (zn*10 + zero + nine)%mod;
        zero = (zero*9 + other)%mod;
        nine = (nine*9 + other)%mod;
        other = other*8 %mod;
    }
    cout << zn;

    return 0;
}

Measured memory_bytes: 3616
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],MOD));
//    ret%=MOD;
//    ret*=modInverse(fact[a-b],MOD);
//    ret%=MOD;
//    return ret;
//}

void solve()
{
    ll w=0,r=0;
    ll n;cin>>n;string s;cin>>s;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')r++;else w++;
        
    }
    string ans;
    for(ll i=0;i<r;i++)ans+='R';
    for(ll i=0;i<w;i++)ans+='W';
    ll as =0;
    for(ll i=0;i<n;i++)as+=((s[i]^ans[i])!=0);
    cout<<(as+1)/2<<endl;
    
}
signed main()
{
   Need_for_speed(activated);
//
//    satisfy
//    {
//        solve();
//    }
//
   
    solve();
    
    return 0;
}
//Concentrate while implementing,,,!!!
 


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
    vector<int> A(N);
  long long count = 0;
  long long k = 0;
  for(int a = 0;a < N;a++){
    cin >> A[a];
    count += A[a];
    if(a % 2 == 1)k += A[a];
  }
  
  cout << count - 2 * k << " "; 
  k = count - 2 * k;
  for(int a = 0;a < N - 1;a++){
   cout << A[a] * 2 - k << " ";
    k = A[a] * 2 - k;
    
  }
  
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

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

const int N= 200001;

void solve() {
        int n, m, q; cin >> n>> m>> q;

        vector<int> v(n+ m), up(n+ m, 1e18), down(n+ m, 1e18);

        map<int, int> mp1, mp2;

        for (int i= 0; i< n; i++) {
                int x; cin >> x;
                v[i]= x;
                mp1[x]++;
        }

        for (int i= 0; i< m; i++) {
                int x; cin >> x;
                v[i+ n]= x;
                mp2[x]++;
        }

        sort(all(v));

        int cnt2= -1, cnt1= -1;

        for (int i= 0; i< n+ m; i++) {
                if (mp1.count(v[i])) {
                        cnt1= v[i];
                        if (cnt2!= -1) {
                                down[i]= v[i]- cnt2;
                        }
                } else {
                        cnt2= v[i];
                        if (cnt1!= -1) {
                                down[i]= v[i]- cnt1;
                        }
                }
        }

        cnt1= cnt2= -1;

        for (int i= n+ m- 1; i>= 0; i--) {
                if (mp1.count(v[i])) {
                        cnt1= v[i];
                        if (cnt2!= -1) {
                                up[i]= cnt2- v[i];
                        }
                } else {
                        cnt2= v[i];
                        if (cnt1!= -1) {
                                up[i]= cnt1- v[i];
                        }
                }
        }

        for (int i= 0; i< n+ m; i++) {
                up[i]= min(up[i], down[i]);
        }
        for (int i= 0; i< q; i++) {
                int x; cin>> x;
                int pos= lower_bound(all(v), x)- v.begin();
                if (pos== n+ m) {
                        pos--;
                        cout << (x- v[pos])+ up[pos]<< "\n";
                } else if (pos== 0){
                        cout << (v[pos]- x)+ up[pos]<< "\n";
                }else {
                        cout << min(v[pos]- x+ up[pos], x- v[pos- 1]+ up[pos- 1])<< "\n";
                }

        }
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

vector<pair<int, int>>ans;

void f(int x){
     for(int i=1;i*i<=x;i++){
          if(x%i==0){
               ans.push_back({i, x/i});
               ans.push_back({x/i, i});
          }
     }
}


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

     int res=1e18;
     for(int i=0;i<ans.size();i++){
          int temp=abs(1-ans[i].first)+abs(1-ans[i].second);
          res=min(res, temp);
     }
     cout<<res;
}

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



int main() {
  int A,B,C,D = 0;
 
  cin >> A >> B >> C >> D;
 
  while(1){
    C -= B;
    if(C<=0){
      cout << "Yes" <<endl;
      break;
    }
    
    A -= D;
      if(A<=0){
        cout << "No" <<endl;
        break;
      }
    
  }
}


Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void print(vector<int> &v) {
  cout << v[0];
  for (auto it = ++v.begin(); it != v.end(); ++it)
    cout << " " << *it;
  cout << endl;
}

int main() {
  int n, x;
  vector<int> A;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    A.push_back(x);
  }
  cin >> n; // skip q
  while (cin >> x)
    cout << binary_search(A.begin(), A.end(), x) << endl;
}


Measured memory_bytes: 3520
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define pb	push_back
#define f	first
#define s	second

using namespace std;

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

const int N = 100007;

int n, A[N], wcnt[N], dep[N];

int main(){
	scanf("%d", &n);
	for(int i=2;i<=n;i++) scanf("%d", &A[i]);
	priority_queue<pii>Q;
	for(int i=2;i<=n;i++)wcnt[A[i]]++;
	repn(i, n){
		if(wcnt[i] == 0){
			Q.push({0, i});
		}
	}
	while(!Q.empty()){
		pii f = Q.top(); Q.pop();
		int u = f.s;
		int part = A[u];
		dep[part] = max(dep[part] + 1, dep[u] + 1);
		wcnt[part] -= 1;
		if(wcnt[part] == 0){
			Q.push({-dep[part], part});
		}
	}
	cout << dep[1] << endl;
	return 0;
}


Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char field[11][11];
bool checked[11][11];

int dfs(int x , int y){ 
  if(x<0 || 10<=x || y<0 || 10<=y || field[x][y]=='x') return 0;
  if(checked[x][y]) return 0;  
  checked[x][y]=true;
  return 1+dfs(x+1,y)+dfs(x-1,y)+dfs(x,y+1)+dfs(x,y-1);
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n ;
  vector<pair<ll,ll>> vec;
  rep(i,n){
    ll a , b; cin>>a>>b;
    vec.push_back(make_pair(b,a));
  }
  sort(vec.begin(),vec.end());
  
  int time=0;
  rep(i,n){
    time+=vec[i].second;
    if(time>vec[i].first){
      cout<<"No"<<endl;
      return 0;
      
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}
  



Measured memory_bytes: 6384
#include <iostream>
#include <string>
using namespace std;

int main() {
  string S;
  int K;
  cin >> S >> K;
  int ichinum = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == '1')
      ++ichinum;
    else
      break;
  }
  if (ichinum >= K)
    cout << 1 << endl;
  else
    cout << S[ichinum] << endl;
}

Measured memory_bytes: 3532
import numpy as np
from sys import exit
N = int(input())
Alist = np.array(list(map(int, input().split())), dtype=np.int64)
Blist = np.array(list(map(int, input().split())), dtype=np.int64)
sbn = Alist - Blist

if sum(sbn) <= 0:
    print(-1)
    exit()

hu = sbn[sbn < 0]
if len(hu) == 0:
    print(0)
    exit()
ans = len(hu)
cost = sum(hu)

sei = np.sort(sbn[sbn > 0])[::-1].cumsum()
# print(cost)
# print(sei)
ind = np.argmax(sei >= abs(cost))
print(ans + ind + 1)


Measured memory_bytes: 23888
N, T = map(int, input().split())
A = list(map(int, input().split()))
minv = A[0]
maxv = -1
L = [0]
for i in range(1, N):
    if A[i] - minv > maxv:
        L = [i]
        maxv = A[i] - minv
    elif A[i] - minv == maxv:
        L.append(i)
    minv = min(minv, A[i])
print(len(L))


Measured memory_bytes: 14252
#include <stdio.h>

int main(void){
  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);
  
  if(h >=w){
    if(n%h == 0){
      printf("%d", n/h);
    }else{
      printf("%d", (n/h)+1);
    }
  }else{
    if(n%w == 0){
      printf("%d", n/w);
    }else{
      printf("%d", (n/w)+1);
    }
  }
  return 0;
}


Measured memory_bytes: 128
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int main()
{
	int i, j;
	int n;
	ll A, B;
	si(n);
	sll(A);
	sll(B);

	ll x = 1;
	ll ans = 0;
	sll(x);
	fl(i,1,n)
	{
		ll y;
		sll(y);
		if( (y - x) * A < B)
			ans += ((y - x) * A);
		else
			ans += B;
		x = y;
	}

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


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,i,c[10000],d[10000],sum[10000],j,fsum=0,h[10000],k;
    scanf("%d %d %d",&n,&a,&b);
    for(i=0; i<n; i++)
    {
        sum[i]=0;
    }
    for(i=0; i<n; i++)
    {
        c[i]=i+1;
    }
    for(i=0; i<n; i++)
    {
        d[i]=c[i];
    }
    for(i=0; i<n; i++)
    {
        while(d[i]!=0)
        {
            sum[i]=sum[i]+d[i]%10;
            d[i]=d[i]/10;
        }
    }
    for(i=0; i<n; i++)
    {
        if(sum[i]>=a && sum[i]<=b)
        {
            fsum=fsum+c[i];
        }
    }
    printf("%d\n",fsum);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Students = list(map(int, input().split()))

list=[]
for i, student in enumerate(Students, 1):
    list.append([i, student])

K=sorted(list, key=lambda x: x[1])

list2=[]
for t in range(N):
        list2.append(K[t][0])

print(*list2)

Measured memory_bytes: 24408
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n,m;
  cin>>n>>m;

  vector<int> p(m);
  vector<int> q(m);
  rep(i,m){
    int b;
    cin>>p[i]>>b;
    bitset<12> x;
    rep(j,b){
      int c;
      cin>>c;
      x.set(c-1);
    }
    int y=0;
    rep(j,12){
      y*=2;
      if(x.test(11-j)) y++;
    }
    q[i]=y;
  }

  vector<ll> ans((1<<n),INF);
  ans[0]=0;
  rep(i,m){
    rep(j,(1<<n)){
      chmin(ans[q[i]|j],ans[j]+p[i]);
    }
  }


  if(ans[(1<<n)-1]==INF) cout << -1 << endl;
  else cout << ans[(1<<n)-1] << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int A[1010];
int main()
{
    int N, D, X;
    scanf("%d%d%d", &N, &D, &X);
    for(int i=0; i<N; ++i)
    {
        int t; scanf("%d", &t);
        X+=(D+t-1)/t;
    }
    cout << X << endl;
}

Measured memory_bytes: 256
k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = [int(digit) for digit in str(num)]
  len_digit = len(digit)
  flag = False
  for i in range(1, len_digit):
    # current_digit = digit[-i]
    # upper_digit = digit[-i-1]
    if digit[-i] == 10:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] > digit[-i-1] + 1:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  if digit[0] == 10:
    num = 10 ** len_digit
  else:
    for i in range(1, len_digit):
      if digit[i] == -1:
        for j in range(i, len_digit):
          digit[j] = max(digit[j-1] - 1, 0)
        break
    num = 0
    for d in digit:
      num = num * 10 + d
print(num)


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

using namespace std;

int op_a(int n, int x, int k);
int op_b(int n, int x, int k);

int op_a(int n, int x, int k){
    int r = x * 2;
    if(n > 1){
	int a, b;
	a = op_a(n-1, r, k);
	b = op_b(n-1, r, k);
	r = a > b ? b : a;
    }
    return r;
}

int op_b(int n, int x, int k){
    int r = x + k;
    if(n > 1){
	int a, b;
	a = op_a(n-1, r, k);
	b = op_b(n-1, r, k);
	r = a > b ? b : a;
    }
    return r;
}

int main(){

    int n, k;
    cin >> n >> k;

    int a, b;
    a = op_a(n, 1, k);
    b = op_b(n, 1, k);
    int r = a > b ? b : a;

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 256
/////////////////////////////////
//                             //
//           /(.^.)\           //
//                             //
/////////////////////////////////

#include <iostream>
using namespace std;

#define BYTE unsigned char
#define DWORD unsigned int
#define QWORD unsigned long long
#define LL long long



//main
int main()
{
    int rtn;
    int n,k;

    cin >> n >> k;

    rtn = 0;
    if (k > 1) 
    {
       rtn = n - k;
    }

    cout << rtn;
    return 0;
    cout << "/(.^.)\\" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const INF = (1 << 31) - 1

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	K := nextInt()
	x := nextIntArray(N)
	res := 0
	for i := 0; i < N; i++ {
		res += min(x[i], K-x[i]) * 2
	}
	fmt.Println(res)
}

// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}

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

func shift(p int) int {
	return 1 << uint(p)
}


Measured memory_bytes: 640
fn main() {
    proconio::input! {
        k: usize,
        mut s: proconio::marker::Bytes,
    }
    if s.len()>k {
        s.truncate(k);
        for _ in 0..3 {
            s.push(b'.');
        }
    }
    println!("{}",String::from_utf8(s).unwrap());
}

Measured memory_bytes: 2184
import sys

S = sys.stdin.read()
alphabet = [chr(i) for i in range(0x61,0x7b)]
cnt = [0] * len(alphabet)

for s in S:
    s = s.lower()
    if s in alphabet:
        cnt[ord(s)-0x61] += 1

for alpha,num in zip(alphabet,cnt):
    print('{} : {}'.format(alpha,num))


Measured memory_bytes: 5568
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  bool flag = false;
  for(int i = 1;i < 10;i++){
    if((n / i) < 10 && n >= i && n % i == 0)
      {
      	flag = true;
      }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	int ma = a[n-1];
	int m1 = ma/2;
	int m2 = m1+1;
	int other = 0; 
	for (int i = 0; i < n; i++)
	{
		if (ma%2 == 0) {
			if (abs(ma/2-a[i]) < abs(ma/2-other)) other = a[i];
		}
		else {
			int now = min(abs(m1-a[i]),abs(m2-a[i]));
			int ot = min(abs(m1-other), abs(m2-other));
			if (now < ot) other = a[i];
		}
	}
	cout << ma << ' ' << other << endl;
	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define lim 1000000000000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(),v.end()
#define mod ((int)1e9+7)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
const int N = (int)1e3+5;

vector<pii> v[N][N];
vector<vector<int>> distance_from_source;
vector<string> grid;

void dijksta(int source_x, int source_y) {
  distance_from_source[source_x][source_y] = 0;
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.push({0,{source_x,source_y}});
  while(!pq.empty()) {
    pii curr_node = pq.top();
    pq.pop();
    int x = curr_node.second.first, y = curr_node.second.second;
    if(distance_from_source[x][y] == curr_node.first) {
      for(auto it: v[x][y]) {
        int _x = it.second.first, _y = it.second.second;
        if(distance_from_source[_x][_y] > distance_from_source[x][y] + it.first) {
          distance_from_source[_x][_y] = distance_from_source[x][y] + it.first;
          pq.push({distance_from_source[_x][_y], {_x, _y}});
        }
      }
    }
  }
}

void solve() {
  int r,c;
  cin >> r >> c;
  distance_from_source = vector<vector<int>>(r,vector<int>(c,1e9));

  int source_x, source_y;
  int destination_x, destination_y;
  cin >> source_x >> source_y;
  cin >> destination_x >> destination_y;
  source_x--, source_y--;
  destination_x--, destination_y--;

  grid = vector<string>(r);
  REP(i,0,r-1) {
    cin>>grid[i];
  }
  REP(i,0,r-1) {
    REP(j,0,c-1) {
      if(grid[i][j]=='.') {
        if(i>0 && grid[i-1][j]=='.') {
          v[i][j].push_back({0,{i-1,j}});
        }
        if(i<r-1 && grid[i+1][j]=='.') {
          v[i][j].push_back({0,{i+1,j}});
        }
        if(j>0 && grid[i][j-1]=='.') {
          v[i][j].push_back({0,{i,j-1}});
        }
        if(j<c-1 && grid[i][j+1]=='.') {
          v[i][j].push_back({0,{i,j+1}});
        }
        REP(k,-2,2) {
          REP(l,-2,2) {
            if(i+k>=0 && i+k<r && j+l>=0 && j+l<c && grid[i+k][j+l]=='.') {
              v[i][j].push_back({1,{i+k,j+l}});
            }
          }
        }
      }
    }
  }
  dijksta(source_x, source_y);
  if(distance_from_source[destination_x][destination_y] == 1e9) {
    distance_from_source[destination_x][destination_y] = -1;
  }
  cout << distance_from_source[destination_x][destination_y];
}

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

  int T=1;
  //cin>>T;
  REP(TC,1,T) {
      //cout<<"Case #"<<TC<<": ";
      solve();
      cout<<"\n";
  }
}


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

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

	int ans=0;
	for(int i=3;i<N;i++){
		ans=max(ans, N/i);
	}
	cout << ans << endl;
}


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

map<int,set<string>> mp;

int main()
{
  int n;
  cin>>n;
  mp[1]={"a"};
  for (int i = 2; i <= n; ++i)
  {
    for(auto&& e: mp[i-1])
    {
      set<char> st;
      for(auto&& f: e) 
      {
        st.insert(f);
      }
      st.insert(*(st.rbegin())+1);
      for(auto&& f: st) 
      {
        mp[i].insert(e+f);
      }
    }
  }
  for(auto&& e: mp[n])
  {
    cout<<e<<endl;
  }
}

Measured memory_bytes: 15232
import math
X = int(input())
if X == 2:
    print(2)
    exit()
X = X-1
while X:
    X += 1
    for j in range(2,int(math.sqrt(X))+1):
        if X%j == 0:
            break
        elif j == int(math.sqrt(X)) and X%j != 0:
            print(X)
            exit()

Measured memory_bytes: 3060
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	std::deque<int> deq;
	REP(i, 0, n){
		int a;
		scanf("%d", &a);
		if(i%2) deq.push_back(a);
		else deq.push_front(a);
	}
	
	if(n%2){
		REP(i, 0, n){
			printf("%d ", deq.front());
			deq.pop_front();
		}
	}else{
		REP(i, 0, n){
			printf("%d ", deq.back());
			deq.pop_back();
		}
	}
	return 0;
}



Measured memory_bytes: 2944