akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n, k, count = 0, ans = 0;
    cin >> n >> k;
    int a_, a[n] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> a_;
        a[a_-1]--;
    }
    sort(a, a+n);
    for(int i = 0; i < n; ++i) {
        if(a[i] != 0) {
            count++;
        }
        if(count > k) {
            ans += a[i];
        }
    }
    cout << -ans << endl;
    return 0;
}

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

int main() {
  long N;
  cin>>N;
long sum=0;
for(int i=0;i<=N;i++){
sum+=i;
if(sum==N){
  //cout<<"A"<<endl;
  for(int j=1;j<=i;j++) cout<<j<<endl;
  return 0;
}
if(sum>N){
  //cout<<"B"<<endl;
  long res=sum-N;
  for(int j=1;j<=i;j++){
    if(res==j) continue;
    else cout<<j<<endl;

  }
  return 0;
}
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    string s;
    cin>>s;
    int ans=0;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        ans=3;
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
        ans=2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        ans=1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using namespace std;

signed main () {
  int N,i ;
  cin>>N>>i;
  cout<<N-i+1<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

long double n, m, d;

int main()
{
	in >> n >> m >> d;
	out << std::fixed << std::setprecision(10);
	if (d == 0) out << n * (m - 1) / (n*n) << std::endl;
	else out << 2 * (n - d)*(m - 1) / (n*n) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int n;
    cin >> n;
    int a[100002] = {};
    int tmp;
    rep(i, n) { 
        cin >> tmp;
        a[tmp]++;
    }
    int ans = 0;
    for(int i = 1; i < 100000; i++)
        ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
for i in range(k):
    cur += (a[i]+1)/2
maximum = cur

for i in range(1, n-k+1):
    cur -= (a[i-1]+1)/2
    cur += (a[i+k-1]+1)/2
    maximum = max(maximum, cur)

print(maximum)

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

using namespace std;

    int w,h;
    int c[55][55];
    vector<vector<bool> > seen;
    int mx[8] = {-1,1,0,-1,1,-1,0,1};
    int my[8] = {0,0,1,1,1,-1,-1,-1};
    
    void dfs(int x,int y){
    	::seen[x][y] = true;
    	
    	for(int i = 0; i < 8; i++){
			int nx = x + mx[i];
			int ny = y + my[i];
			
			if(nx < 0 || nx >= h || ny < 0 || ny >= w)	continue;
			if(::seen[nx][ny])	continue;
			if(c[nx][ny] == 0)	continue;
			
			dfs(nx,ny);
		}
    }
int main(){
	while(true){
	cin >> w >> h;
	if(w == 0 && h == 0) break;
	::seen.assign(55,vector<bool>(55,false)); //initilaization
	
	
	int count = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> c[i][j];
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(::seen[i][j])	continue;
			if(c[i][j] == 0)	continue;
			
			dfs(i,j);
			count++;
		}
	}
	cout << count << endl;
	}
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 998244353;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
string s, t;
void print(int l, int r, int ans, vector<vector<int>>& dp){
    if(!ans){
        return;
    }
    if(l < 0 || r < 0){
        return;
    }
    int prev = (!l || !r) ? 0 : dp[l-1][r-1];
    if(s[l] == t[r] && (1 + prev) == ans){
        print(l-1, r-1, ans-1, dp);
        cout << s[l];
    }else if(l > 0&& dp[l-1][r] == ans){
        print(l-1, r, ans, dp);
    }else if (r > 0 ){
        print(l, r-1, ans, dp);
    }
}
int main() {
    IO;
    cin >> s >> t;
    vector<vector<int>> dp(s.size(), vector<int>(t.size()));
    bool flag = 0;
    bool flag2 = 0;
    for(int i = 0; i < t.size(); i++){
        if(s[0] == t[i]){
            flag = 1;
        }
        dp[0][i] = flag;
    }
    for(int i = 0; i < s.size(); i++){
        if(t[0] == s[i]){
            flag2 = 1;
        }
        dp[i][0] = flag2;
    }
    for(int i = 1; i < s.size(); i++){
        for(int j = 1; j < t.size(); j++){
            dp[i][j] = (s[i] == t[j]) + dp[i-1][j-1];
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
        }
    }
    print(s.size()-1, t.size()-1, dp[s.size()-1][t.size()-1], dp);


    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
const int N = 2e5 + 5;
int n;
int a[N];
void solve() {  
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += a[i / 2];
    }
    cout << ans;
}       

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PIII pair<PII,int>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int R,C,n,cnt;

PIII has[maxn];

int s[maxn],top;

int calc(PII x){
	if(x.fi==0)return x.se;
	if(x.se==C)return C+x.fi;
	if(x.fi==R)return C+R+C-x.se;
	return C+R+C+R-x.fi;
}

bool cmp(PIII x,PIII y){
	return calc(x.fi)<calc(y.fi);
}

bool Is(int x,int y){
	return x==0||y==0||x==R||y==C;
}

void Work(){
	sort(has+1,has+cnt+1,cmp);
//	REP(i,1,cnt)cout<<has[i].se<<' '<<has[i].fi.fi<<' '<<has[i].fi.se<<' '<<calc(has[i].fi)<<endl;cout<<endl;
	REP(i,1,cnt){
		if(top&&s[top]==has[i].se)top--;
		else s[++top]=has[i].se;
	}
	if(top)puts("NO");else puts("YES");
}

void Init(){
	read(R,C,n);
	REP(i,1,n){
		int x1,y1,x2,y2;
		read(x1,y1,x2,y2);
		if(Is(x1,y1)&&Is(x2,y2)){
			has[++cnt]=MP(MP(x1,y1),i);
			has[++cnt]=MP(MP(x2,y2),i);
		}
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main(){
  int i = 0;
  int j = 0;
  char s[100000];
  scanf("%s", s);
  for(i = 0; s[i] != '\0'; i++){}
  for(j = 0; j < i; j++){
    if(j % 2 == 0){
      printf("%c", s[j]);
    }
  }
  return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

signed main() {
  ll M, n = 0, s = 0;
  cin >> M;
  rep(i, M) {
    ll d, c;
    cin >> d >> c;
    n += c;
    s += d * c;
  }
  ll C = (n-1) * 9 + (s-1);
  cout << C/9 << endl;
  return 0;
}


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

int main(){
    int A,B,C,D,pow,min;
    cin>>A>>B>>C>>D;
    //AB CD, AC BD, AD BC
    min=A+B-C-D;
    if(min<0) min=-min;
    pow=A+C-B-D;
    if(pow<0) pow=-pow;
    if(min>pow) min=pow;
    pow=A+D-B-C;
    if(pow<0) pow=-pow;
    if(min>pow) min=pow;
    cout<<min<<endl;
}


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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}


int main() {
	int n, o;
	cin >> n >> o;

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

	int dif[n];
	for(int i=0;i<n;i++) {
		dif[i] = abs(x[i]-o);
	}

	int g;

	if(n>1) {
		g = gcd(dif[0],dif[1]);
		for(int i=0;i<n;i++) {
			g = gcd(g,dif[i]);
		}
	} else {
		g = dif[0];
	}

	cout << g << endl;
}

Measured memory_bytes: 1024
#include <cstdio>

void search(int (*A)[101], int *dis, int *found, int n){
    int hoge;
    int time=0;
    for(int k=1;k<n;k++){
        hoge = 1;
        for(int i=1;i<=n;i++){
            if(dis[i]==time){
                for(int j=1;j<=n;j++){
                    if(A[i][j]&&found[j]==0){
                        found[j]=1;
                        dis[j]=time+1;
                        hoge=0;
                    }
                }
            }
        }
        time++;
        if(hoge)return;
    }
}

int main(){
    int i, j, n, u, k, v;
    scanf("%d",&n);
    int found[n+1];
    int dis[n+1];
    dis[1]=0;
    found[1]=1;
    for(i=2;i<=n;i++){
        dis[i]=-1;
        found[i]=0;
    }
    int A[101][101];
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            A[i][j]=0;
        }
    }
    for(i=1;i<=n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            A[u][v]=1;
        }
    }
    search(A,dis,found,n);
    for(i=1;i<=n;i++)printf("%d %d\n",i,dis[i]);
    return 0;
}



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

using lli = int64_t;
using vi = vector<lli>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vi v(3 * n);

    for(int i = 0; i < 3 * n; i++) cin >> v[i];

    vi l(3 * n, LLONG_MAX);
    vi r(3 * n, LLONG_MAX);

    lli s = 0;
    multiset<lli> st;

    for(int i = 0; i < 3 * n; i++)
    {
        s += v[i];

        st.insert(v[i]);

        if(lli(st.size()) > n)
        {
            s -= *begin(st);
            st.erase(begin(st));
        }

        if(lli(st.size()) == n) l[i] = s;
    }

    s = 0;
    st.clear();

    for(int i = 3 * n - 1; i >= 0; i--)
    {
        s += v[i];

        st.insert(v[i]);

        if(lli(st.size()) > n)
        {
            s -= *prev(end(st));
            st.erase(prev(end(st)));
        }

        if(lli(st.size()) == n) r[i] = s;
    }

    lli diff = LLONG_MIN;

    for(int i = 0; i < 3 * n - 1; i++)
    if(l[i] != LLONG_MAX && r[i + 1] != LLONG_MAX)
        diff = max(diff, l[i] - r[i + 1]);

    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    int n, k;
    cin >> k >> n;
    vi a(n);
    rep (i, n) {
        cin >> a[i];
    }
    int ma = 0;
    rep (i, n) {
        chmax(ma, (a[(i + 1) % n] + k - a[i]) % k);
    }
    cout << k - ma << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n],s[100005],maxi=-1;
	for (int i=0;i<100005;i++)
	{
		s[i]=0;
	}
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]==0)
		{
			s[a[i]]++;
			s[a[i]+1]++;
		}
		else if (a[i]==n-1)
		{
			s[a[i]]++;
			s[a[i]-1]++;
		}
		else
		{
			s[a[i]+1]++;
			s[a[i]]++;
			s[a[i]-1]++;
		}
	}
	for (int i=0;i<100005;i++)
	{
		if (s[i]>maxi) maxi=s[i];
	}
	cout << maxi;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
	cin >> n;
	vector<int> a(n);
	for (int &e : a) cin >> e;
	
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		int id = a[i] - 1;
		ans[id] = i + 1;
	}
	
	for (int &e : ans) cout << e << ' ';
	return 0;
}

Measured memory_bytes: 1536
a,b,c = map(int,input().split())
k = int(input())

ans_red = 0
ans_green = 0
ans_blue = 0
for red in range(k):
    for green in range(k-red):
        blue = k - red- green
        ans_red = a * 2 ** red
        ans_green = b * 2 ** green
        ans_blue = c * 2 ** blue
        if ans_red < ans_green < ans_blue:
            print('Yes')
            exit()
        ans_red = 0
        ans_green = 0
        ans_blue = 0
print('No')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    while(a>=b && k>0){
        k--;
        b=2*b;
    }
    while(b>=c && k>0){
        k--;
        c*=2;
    }
        if(a<b && b<c && k>=0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
     
    }

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << a[n-1];

}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
public class Main {
    public static void insertSort(int[] arr){
        int i,j;
        for(i=1; i<arr.length; i++){
            int tmp = arr[i];
            for(j= i-1; j>=0; j--){
                if(arr[j] < tmp){
                    break;
                }
                arr[j+1] = arr[j];
            }
            arr[j+1] = tmp;
            for(int l=0; l<arr.length-1; l++){
                System.out.print(arr[l] + " ");
            }
            System.out.println(arr[arr.length-1]);
        }
    }
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();
		int[] data = new int[n];
		StringTokenizer tokenizer = new StringTokenizer(str, " ");
	    int i = 0;
	    while (tokenizer.hasMoreElements()) {
	    	data[i++] = Integer.parseInt((String) tokenizer.nextElement());
	    }
        for(i=0; i<data.length-1; i++){
            System.out.print(data[i] + " ");
        }
        System.out.println(data[data.length-1]);
	    insertSort(data);
	}

}

Measured memory_bytes: 23776
#include<iostream>
using namespace std;
int main()
{
    int a, b , c;
    cin>>a>>b>>c;
    if(a+b==c || a+c==b || b+c==a)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int b[110]={};

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

	vector<int> ans;
	int sub[110]={};
	int ar[110]={};

	for(int i=1;i<=N;i++)
	{
		sub[i]=i-b[i];
		if(sub[i]<0)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=1;i<=N;i++)
		ar[i]=i-1;

	for(int i=1;i<=N;i++)
	{
		bool ok=false;
		for(int j=N;j>0;j--)
		{
			if(sub[j]==ar[j])
			{
				if(b[j]>i)continue;
				ok=true;
				ans.push_back(b[j]);
				ar[j]=-1;
				for(int k=j+1;k<=N;k++)
					ar[k]--;
				break;
			}
		}
		if(!ok)
		{
			cout << -1 << endl;
			return 0;
		}
	}


	for(int i=0;i<ans.size();i++)
		cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const ll MOD = 1e9+7;

int main()
{
	int n,m;
	ll ans=0;
	priority_queue<P,vector<P>,less<P>> que;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		que.push(P(a,1));
	}

	for(int i=0;i<m;i++)
	{
		int b;
		ll c;
		cin>>b>>c;
		que.push(P(c,b));
	}
	
	int cnt=0;
	while(cnt!=n)
	{
		P p=que.top();
		que.pop();
		//cerr<<p.first<<" "<<p.second<<endl;
		cnt+=p.second;
		ans+=(ll)p.second*p.first;
		if(cnt>n)
		{
			ans-=(ll)(cnt-n)*p.first;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int shift;
    cin >> shift;
    string message;
    cin >> message;
    for (int i = 0; i < message.size(); i++)
    {
        if (message[i] != '\0')
        {
            message[i] = message[i] + shift;
            if (message[i] > 90)
            {
                message[i] -= 26;
            }
        }
    }
    cout << message << endl;
    return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll dp[2005][2005];

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	VecP b(n);
	rep(i, n) b[i] = {a[i], i};
	sort(all(b));
	reverse(all(b));

	fill(dp[0], dp[2005], -LINF);
	dp[0][0] = 0;

	rep(i, n){
		rep(j, n){
			chmax(dp[i + 1][j + 1], dp[i][j] + b[i].fs * abs(b[i].sc - j));
			chmax(dp[i + 1][j], dp[i][j] + b[i].fs * abs(n - 1 - i + j - b[i].sc));
		}
	}
	
	ll ans = 0;
	rep(i, n) chmax(ans, dp[n][i]);
	co(ans);

	return 0;
}


Measured memory_bytes: 35088
<?php
	while( "-" != ($cards = trim( fgets( STDIN ) )) ) {
		$m = trim( fgets( STDIN ) );
		while( $m-- ) {
			$h = trim( fgets( STDIN ) );
			$cards = substr( $cards, $h ).substr( $cards, 0, $h );
		}
		print $cards.PHP_EOL;
	}

Measured memory_bytes: 15268
import java.util.*
fun main(){
	fun I()=readLine()!!.split(" ").map{it.toInt()}
	var (n,m)=I()
	val con=Array(n){mutableListOf<Int>()}
	val par=IntArray(n){-1}
	par[0]=0
	for(t in 1..m){
		val (a,b)=I()
		con[a-1].add(b-1)
		con[b-1].add(a-1)
	}
	val q=ArrayDeque<Int>()
	q.add(0)
	while(!q.isEmpty()){
		val cur=q.poll()
		for(nxt in con[cur]){
			if(par[nxt]<0){
				q.add(nxt)
				par[nxt]=cur
			}
		}
	}
	println("Yes")
	n--
	for(i in 1..n){println(par[i]+1)}
}

Measured memory_bytes: 78748
def check_line(start, dxy):
    x, y = start
    dx, dy = dxy
    flg = bingo[x][y]
    for _ in range(2):
        x += dx
        y += dy
        flg &= bingo[x][y]
    return flg

Alist = [list(map(int, input().split())) for _ in range(3)]
Aset = set()
for line in Alist:
    Aset |= set(line)
bingo = [[False] * 3 for i in range(3)]
N = int(input())
br = False
for _ in range(N):
    b = int(input())
    if b in Aset:
        for x in range(3):
            for y in range(3):
                if Alist[x][y] == b:
                    bingo[x][y] = True

ans = False
for i in range(3):
    ans |= check_line((0, i), (1, 0))
    ans |= check_line((i, 0), (0, 1))
ans |= check_line((0, 0), (1, 1))
ans |= check_line((0, 2), (1, -1))
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#高速化heapqダイクストラ
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()


def BFS(point,d):
    cost=[1e7]*(n+1)
    cost[point]=0
    Q=[]
    heappush(Q,(0,point))
    
    while Q:
        c,p=heappop(Q)
        for np in d[p]:
            if cost[np]==1e7:
                cost[np]=c+1
                heappush(Q,(c+1,np))
    return cost

n=int(input())
d={}
for i in range(n-1):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a].append(b)
    else:
        d[a]=[b]
    if b in d.keys():
        d[b].append(a)
    else:
        d[b]=[a]
        
x=BFS(1,d)[1:]
y=BFS(n,d)[1:]

#print(x,y)

F=0
S=0

for s,t in zip(x,y):
    if s<=t:
        F+=1
    else:
        S+=1

if F<=S:
    print("Snuke")
else:
    print("Fennec")

Measured memory_bytes: 35472
n=int(input())
a_list = list(map(int, input().split()))

count=0
for i in range(n-2) :
  for j in range(i+1,n-1) :
    for k in range(j+1,n) :
      a=a_list[i]
      b=a_list[j]
      c=a_list[k]
      if a+b>c and b+c>a and a+c>b and a!=b and b!=c and c!=a :
        count+=1
       
print(count)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)
bool flg[1001][1001][1001];
struct elem
{
    LL val;
    int i, j, k;
};

void solve()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int K;
    cin >> K;

    vector<LL> A(X);
    REP0 (i, X)
    {
        cin >> A[i];
    }

    vector<LL> B(Y);
    REP0 (i, Y)
    {
        cin >> B[i];
    }

    vector<LL> C(Z);
    REP0 (i, Z)
    {
        cin >> C[i];
    }

    // priority-queue

    sort(A.begin(), A.end(), [](LL a, LL b) { return a > b; });
    sort(B.begin(), B.end(), [](LL a, LL b) { return a > b; });
    sort(C.begin(), C.end(), [](LL a, LL b) { return a > b; });

    auto comp = [](elem a, elem b) { return a.val < b.val; };
    priority_queue<elem, vector<elem>, decltype(comp)> PQ{comp};
    
    PQ.push(elem{A[0] + B[0] + C[0], 0, 0, 0});
    flg[0][0][0] = true;
    REP0 (_, K)
    {
        elem e = PQ.top();
        cout << e.val << endl;
        int i = e.i;
        int j = e.j;
        int k = e.k;
        PQ.pop();

        if (i + 1 < X and !flg[i + 1][j][k])
        {
            flg[i + 1][j][k] = true;
            PQ.push(elem{A[i + 1] + B[j] + C[k], i + 1, j, k});
        }

        if (j + 1 < Y and !flg[i][j + 1][k])
        {
            flg[i][j + 1][k] = true;
            PQ.push(elem{A[i] + B[j + 1] + C[k], i, j + 1, k});
        }

        if (k + 1 < Z and !flg[i][j][k + 1])
        {
            flg[i][j][k + 1] = true;
            PQ.push(elem{A[i] + B[j] + C[k + 1], i, j, k + 1});
        }
    }

    // vector<LL> E;
    // REP0 (i, X)
    // {
    //     REP0 (j, Y)
    //     {
    //         E.push_back(A[i] + B[j]);
    //     }
    // }

    // sort(E.begin(), E.end(), [](LL a, LL b) { return a > b; });
    // sort(C.begin(), C.end(), [](LL a, LL b) { return a > b; });

    // vector<LL> ans;

    // REP0 (i, min(X * Y, K))
    // {
    //     REP0 (j, min(Z, K))
    //     {
    //         ans.push_back(E[i] + C[j]);
    //     }
    // }

    // sort(ans.begin(), ans.end(), [](LL a, LL b) { return a > b; });

    // REP0 (i, K)
    // {
    //     cout << ans[i] << endl;
    // }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 977408
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string a;
    int b,p,o;
    while(n--, n>=0){
        b = p = o = 0;
        while( cin >> a){
            if (a=="HIT"){
                b += 1;
                if (b >= 4){
                    b = 3;
                    p += 1;
                }
            } else if (a=="OUT"){
                o += 1;
                if (o >= 3) {
                    printf("%d\n",p);
                    break;
                }
            } else if (a=="HOMERUN"){
                p += b+1;
                b = 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3164
import math
def prim(x):
  for i in range(2,math.floor(math.sqrt(x))):
    if not x%i:
      return 0
  return 1

def np(x):
  while(1):
    if prim(x):
      return x
    else:
      x+=1
      
print(np(int(input())))

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

int main(){
    
    long long n;
    cin >> n;
    
    if(n&1){
        cout << 0 << endl;
        return 0;
    }
    
    long long res = 0;
    long long deno = 10;
    while(deno <= n){
        res += n/(deno);
        deno *= 5;
        //idx += 1;
    }
    
    cout << res << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 3572
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif

int main(void)
{
	ll n, l; cin >> n >> l;

	vector<ll> apple(n);

	rep(i, 0, n)
		apple[i] = l + (i+1) - 1;
	
	ll sum = accumulate(all(apple), 0LL);
	ll eat = LLONG_MAX;
	rep(i, 0, n)
	{
		if (abs(apple[i]) < abs(eat))
			eat = apple[i];
	}

	cout << sum - eat;	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define OUT(x) cout << #x << " = " << x << endl; 
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
int in[30], out[30];
bool dot[30];
string s[100010];
vector<int> G[30];

bool hantei(void){
	rep(i, 26)if(in[i] != out[i])return false;
	return true;
}

bool memo[30];
void dfs(int u, int p){
	memo[u] = true;
	for(auto v : G[u]){
		if(v == p) continue;
		if(memo[v]) continue;
		dfs(v, u);
	}
}

void init(void){
	rep(i, 30) in[i] = out[i] = dot[i] = memo[i] = 0;
	rep(i, 30) G[i].clear();
}

int main(void){
	while(1){
		cin >> n;
		if(n == 0) return 0;
		rep(i, n) cin >> s[i];
		init();
		rep(i, n){
			int u = s[i][0] - 'a', v = s[i].back() - 'a';
			out[v]++, in[u]++;
			dot[u] = dot[v] = true;
			G[u].pb(v);
		}
		bool flag = true;
		if(!hantei()) flag = false;

		int start = s[0][0] - 'a';
		dfs(start, -1);

		rep(i, 26)if(dot[i] != memo[i]) flag = false;
		if(flag) printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 4692
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll a[5],k,sum = 0;
    ll tmp =10;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    for(int i = 0; i < 5; i++){ 
        if(a[i]%10 < tmp && a[i]%10 != 0){
            tmp = a[i] % 10; 
            // cout << tmp << endl;
        } 
        if(a[i]%10 == 0)sum += a[i]; 
        else sum += a[i] + (10 - a[i]%10);
    }
    // cout << sum<<tmp;;
    if(tmp != 10){
        cout << sum - (10 - tmp) << endl;
    }else{
        cout << sum << endl;   
    }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int X; cin >> X;
    if (X == 7 or X == 5 or X == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

long long combination(long long a,long long b){
    long long s=1;
    long long t=1;
    long long u =1;
    for(int i=a;i>(a-b);i--){
        s*=i;
    }
    for(int i=1;i<=b;i++){
        t*=i;
    }
    return s/(t*u);
}

long long recurcice(string N,long long K){
    cerr<<N<<"K="<<K<<endl;
  
    if(K==0){
        return 0;
    }
    int degree = N.length();
    if(K>degree){
        return 0;
    }
    if(degree==1){
        return stoi(N);
    }
    long long ans = 0;
    ans += combination(degree-1,K)*pow(9,K);
    ans += combination(degree-1,K-1)*pow(9,K-1)*(N[0]-'1');
    cerr<< "degree="<< degree<< endl;
    cerr<<N<<"ans="<< ans<<endl;
    if(K==1){
        ans++;
    }
    for(int i=1;i<degree;i++){
        if(N[i] != '0'){
            cerr<<N[i]<<endl;
            ans += recurcice(N.substr(i),K-1);
            break;
        }
    }
    return ans;
}

void solve(string N, long long K){
    cout << recurcice(N,K)<<endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string N;
    cin >> N;
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
int a,b,c;
int count;
double rec;
scanf("%d %d",&a,&b);
rec=(double)(a+b)/2.0;
  //printf("%lf\n",rec);
  count=rec;
  if(fmod(rec,1.0)!=0.0){
count=(int)rec+1;}
printf("%d\n",count);
}

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

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int b=1; b<=n; ++b){
        ans+=max(0,b-k)*(n/b);
        ans+=max(0,n%b-k+1);
    }
    if(k==0)ans-=n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
A,B = map(int,input().split())
S = tuple(input())

for n in range(len(S)):
    if n is A:
        if S[n] is not '-':
            print('No')
            sys.exit()
    else:
        if S[n] not in ['0','1','2','3','4','5','6','7','8','9']:
            print('No')
            sys.exit()
print('Yes')



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

string s[2];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
	cin >> s[0];
	cin >> s[0] >> s[1];
	for (int i = 0; i < 2 * s[0].size(); i++)
		cout << s[i & 1][i >> 1];
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; ll k;
    cin >> n >> k;
    ll num[100001] = {0};
    REP(i, n){
        int a, b; cin >> a >> b;
        num[a] += b;
    }
  
    ll cnt = 0;
    REP(i, 100001){
        cnt += num[i];
        if(cnt >= k){
            cout << i << "\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}

int main()
{
	int n, k;
	int x;
	cin >> n >> k;
	int sum = 0;
	FOR(i, 0, n) {
		cin >> x;
		if (x > k - x) {
			sum += 2 * (k - x);
		}
		else sum += 2 * x;
	}
	cout << sum << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
typedef long long ll;
const ll N=100000000;
using namespace std;
ll x[N];
int main()
{
	ll ans=0;
	ll n,a,b;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		if(i!=1)
		{
			int d=x[i]-x[i-1];
			if(d*a<b)
				ans+=d*a;
			else ans+=b;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main()
{
    int n,m,x,t,left=0,right=0;
    int a[105]={ };

    scanf("%d %d %d",&n,&m,&x);
    for(int i=0;i<m;i++){
        scanf("%d",&t);
        a[t]=1;
    }

    for(int i=x;i>=0;i--){
        left+=a[i];
    }
    for(int i=x;i<n;i++){
        right+=a[i];
    }

    if(left>right){
         printf("%d\n",right);
    }else{
        printf("%d\n",left);
    }
    
    return 0;
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll N, A, B, k, l;

void solve(){
    k = N / (A+B);
    l = N % (A+B);

    cout << A*k + min(l, A) << endl;
}

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

    solve();
}


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

#define loop(s, e, i) for (int i=s; i<e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  while(b != 0) {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return a;
}

int main() {
  ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
  ll L, R;
  cin >> L >> R;
  ll m = 99999999;

  ll limit = min(L+2019, R);
  for(ll i=L; i<=limit; i++) {
    for (ll j=i+1; j<=limit; j++){
      m = min(i*j%2019, m);
    }
  }
  print(m);
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {

    int n;
    cin >> n;
    int cnt = 0;
    REP(i,0,n){
        int tmp;
        cin >> tmp;
        if(tmp % 2 == 0){
            cnt++;
        }
    }

    cout << (ll)pow(3,n) - (ll)pow(2,cnt) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    vector<int> A(26);
    for(int i = 0; i < S.size(); i++){
        A.at(S.at(i) - 'a')++;
    }
    for(int i = 0; i < 26; i++){
        if(A.at(i) == 0){
            cout << char(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3768
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll factorial[2000100];
ll invfactorial[2000100];

ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD; 
	return ret;
}
int main(void){
    factorial[0] = 1;

    for (int i = 1; i < 2000100; i++){
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    for (int i = 0; i < 2000100; i++){
        ll x, y;
        ll g = extGCD(factorial[i], MOD, x, y);
        while (x < 0) x += MOD;
        x %= MOD;
        invfactorial[i] = x;
    }

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    ll total = 0;

    for(ll i = 0; i <= r2; i++){
        total += nCrM(c2 + i, i);
        total %= MOD;
    }
    
    for(ll i = 0; i <= c2; i++){
        total += nCrM(r2 + i, i);
        total %= MOD;
    }

    //cout << total << endl;

    ll minus = 0;
    for(ll i = 0; i <= r2; i++){
        minus += nCrM(c1 - 1 + i, i);
        minus %= MOD;
    }
    for(ll i = 0; i < c1; i++){
        minus += nCrM(r2 + i, i);
        minus %= MOD;
    }
    //cout << minus << endl;
    for(ll i = 0; i <= c2; i++){
        minus += nCrM(r1 - 1 + i, i);
        minus %= MOD;
    }
    for(ll i = 0; i < r1; i++){
        minus += nCrM(c2 + i, i);
        minus %= MOD;
    }


    //cout << minus << endl;

    ll plus = 0;
    for(ll i = 0; i < r1; i++){
        plus += nCrM(c1 - 1 + i, i);
        plus %= MOD;
    }

    for(ll i = 0; i < c1; i++){
        plus += nCrM(r1 - 1 + i, i);
        plus %= MOD;
    }
    
    //cout << plus << endl;
    ll ans = (total + plus) % MOD - minus;
    if(ans < 0) ans += MOD;
    cout << ans << endl;
}

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

int N, M;

int main() {
  int i;

  cin >> N >> M;
  int res = 1;

  for(i = 1; i*i <= M; i++) {
    if( M % i == 0 && i >= N ) {
      res = M / i;
      goto RET;
    }
  }

  for(;i >= 1; i--) {
    if( M % i == 0 && M / i >= N ) {
      res = i;
      goto RET;
    }
  }

  RET:
    cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x,y;
    x = sc.nextInt();
    y = sc.nextInt();
    if(x>8||y>8){
      System.out.println(":(");
    }
    else{
      System.out.println("Yay!");
    }
    
  }

}

Measured memory_bytes: 23764