akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <algorithm>
#include <bitset>
#define MOD 1000000007
 
using ii = std::pair<int, int>;
 
long long int facto[200001];
 
//(x^m) % p
long long int mul(long long int x, long long int m, long long int p)
{
	long long int ans = 1;
 
	while (m > 0)
	{
		if (m % 2 != 0)
		{
			ans *= x;
			ans %= p;
		}
 
		x *= x;
		x %= p;
		m /= 2;
	}
	return ans;
}
 
//(w+h)!/(w!*h!) % mod
long long int count(long long int w, long long int h)
{
	long long int up = facto[w + h - 2];
	long long int down = (facto[w - 1] * facto[h - 1]) % MOD;
 
	return (up * mul(down, MOD - 2, MOD)) % MOD;
}
 
int main()
{
	int h, w, a, b;
	scanf("%d %d %d %d", &h, &w, &a, &b);
 
	facto[0] = 1;
 
	for (int i = 1; i <= h + w; i++)
		facto[i] = (facto[i - 1] * i) % MOD;
 
	long long int total = 0;
 
	for (int k = 1; k <= h-a; k++)
	{
		long long int f = (count(b, k) * count(w - b, h - k + 1) % MOD);
		total = (total + f) % MOD;
	}
 
	printf("%lld", total);
 
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;
 
static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}
 
class Magatro
{
    private int N;
    private int[] A;
    private int cnt;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }
    }
    private void InsertionSort(int g)
    {
        for (int i = g; i < N; i++)
        {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v)
            {
                A[j + g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j + g] = v;
        }
    }
 
    public void Solve()
    {
        Scan();
        cnt = 0;
        List<int> g = new List<int>();
        g.Add(1);
        for(int i=1; ; i++)
        {
            int next = g[i - 1] * 3 + 1;
            if (next > N)
            {
                break;
            }
            g.Add(next);
        }
        g.Reverse();
        foreach(int i in g)
        {
            InsertionSort(i);
        }
   
        Console.WriteLine(g.Count);
        Console.WriteLine(string.Join(" ", g.Select(i => i.ToString()).ToArray()));
        Console.WriteLine(cnt);
        Console.WriteLine(string.Join("\n", A.Select(i => i.ToString()).ToArray()));
    }
}

Measured memory_bytes: 97200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> Vs(N);
  vector<int> Cs(N);
  for (int i = 0; i < N; i++) { cin >> Vs.at(i); }
  for (int i = 0; i < N; i++) { cin >> Cs.at(i); }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (Vs.at(i) > Cs.at(i)) { sum += Vs.at(i) - Cs.at(i); }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
S=input()

if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
  print('Yes')
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
  print('Yes')
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int d= int.Parse(Console.ReadLine());
            var c = new int[26];
            c = ReadArray(26);
            int sumc = c.Sum();
            var lastd = new int[26];


            for(int i = 0; i < d; i++)
            {
                string[] str = Console.ReadLine().Split(' ');

                int max = -sumc*i;
                int maxn = 0;
                for(int j = 0; j < 26; j++)
                {
                    int temp = int.Parse(str[j]) + c[j] * (i - lastd[j]);
                    if (max < temp)
                    {
                        max = temp;
                        maxn = j;
                    }

                }
                Cout(maxn+1);
                lastd[maxn] = i;
            }



            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int MOD = pow(10,9)+7;

    int H, W, K; cin>>H>>W>>K;
    if(W==1){
        cout<<1<<endl;
        return 0;
    }


    // 一列における棒の組み合わせをbit全探索で先に作っておく
    // [[],[0],[1],[0,2],...]
    // これの意味は0: 0-1の間, 1: 1-2の間に棒をおく、という感じである。
    
    vector<vector<int>> combi_list;
    for(int i=0;i< (1<<(W-1));i++){
        bitset<7> s(i);
        vec_int temp_combi;
        for(int i=0;i<W-1;i++){
            if(s[i]==1){
                temp_combi.push_back(i);
            }
        }
        // 作ったものが合法かをチェックする
        int prev=-100;
        int flag = 0;
        for(auto a: temp_combi){
            if(a-prev==1){
                flag=1;
                break;
            }
            prev=a;
        }
        if(flag==1)continue;

        combi_list.push_back(temp_combi);

    }
    /*
    for(auto aa: combi_list){
        cout<<"aa"<<endl;
        for(auto bb: aa){
            cout<<bb<<endl;
        }
    }
    */


    int DP[H+1][W];
    rep(i,H+1){
        rep(j,W){
            DP[i][j]=0;
        }
    }
    DP[0][0] = 1;

    for(int i=1;i<H+1;i++){
        for(int j=0;j<W;j++){
            // 最初にそのまま落ちてくるパターン
            int pattern = 0;
            for(auto aa: combi_list){
                int flag = 1;
                for(auto bb: aa){
                    if(bb==j||bb==j-1){
                        flag=0;
                        break;
                    }
                }
                if(flag==0)continue;
                pattern++;
            }
            DP[i][j] += DP[i-1][j]*pattern;

            // 一個左の棒から落ちてくるパターン
            pattern = 0;
            for(auto aa: combi_list){
                int flag = 0;
                for(auto bb: aa){
                    if(bb==j-1){
                        flag=1;
                        break;
                    }
                }
                if(flag==0)continue;
                pattern++;
            }
            if(j>0){
                DP[i][j] += DP[i-1][j-1]*pattern;
            }
            // 一個右の棒から落ちてくるパターン
            pattern = 0;
            for(auto aa: combi_list){
                int flag = 0;
                for(auto bb: aa){
                    if(bb==j){
                        flag=1;
                        break;
                    }
                }
                if(flag==0)continue;
                pattern++;
            }
            if(j<W-1){
                DP[i][j] += DP[i-1][j+1]*pattern;
            }

            DP[i][j] = DP[i][j]%MOD;
        }
    }

    cout<<DP[H][K-1]<<endl;





    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  vector<long> a(3);
  rep (i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] + a[1] == a[2]) puts("Yes"); else puts("No");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n,m;
 
   cin >> n >> m;
  
  if(n<=10){
   int as = 100*(10-n);
  
   cout << m+as << endl;
  }else{
    cout << m << endl;
  }
   
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	string s,t;
	cin >> s >> t;
	int n = (int)s.length();
	int m = (int)t.length();
	
	int dp[n+1][m+1];
	for(int i = 0; i <= n; ++i)dp[i][0] = 0;
	for(int j = 1; j <= m; ++j)dp[0][j] = 0;
	
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			if(s[i-1] == t[j-1])dp[i][j] = 1 + dp[i-1][j-1];
			else dp[i][j] = max( dp[i-1][j] , dp[i][j-1]);
		}
	}
	
	string ans = "";
	int i = n, j = m;
	while(i > 0 and j > 0){
		if(s[i-1] == t[j-1]){
			ans = s[i-1] + ans;
			i--;
			j--;
		}else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}else j--;
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }

    int l[101];
    for (int i=0; i<n; i++) cin >> l[i];
    int ans = 0;
    sort(l, l+n);
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            if (l[i] == l[j]) continue;
            for (int k = j+1; k < n; k++) {
                if (l[j] == l[k]) continue;
                if (l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 2010
#define mod 924844033
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,k;
int a[maxn],vis[maxn];
int tot;
int f[maxn][maxn][2][2];
int fac[maxn];
int main()
{
    n=read();k=read();
    for(int i=1;i<=n;i++)
    {
        if(vis[i])  continue;
        for(int j=i;j<=n;j+=k)
        {
            a[++tot]=j;
            vis[j]=1;
        }
    }

    f[0][0][0][0]=1;
    a[0]=-k-1;
    a[n+1]=k-1;
    for(int i=1;i<=n;i++)
    {
        f[i][0][0][0]=1;
        for(int j=1;j<=i;j++)
        {
            f[i][j][0][0]=((f[i-1][j][1][0]+f[i-1][j][0][0])%mod+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%mod;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*((f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%mod)%mod;
            f[i][j][1][0]=((f[i-1][j][0][1]+f[i-1][j][1][1])%mod+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%mod;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*((f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%mod)%mod;
        }
    }
    fac[0]=1;
    for(int i=1;i<=n;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        int tmp=(((f[n][i][0][0]+f[n][i][0][1])%mod+f[n][i][1][0])%mod+f[n][i][1][1])%mod;
        if(i&1)  ans=(ans-1ll*tmp*fac[n-i]%mod+mod)%mod;
        else     ans=(ans+1ll*fac[n-i]*tmp%mod)%mod;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 61312
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int MOD = 1e9 + 7;

vector<vll> matrixMult(const vector<vll> &a, const vector<vll> &b) {
	int n = a.size();
	vector<vll> r(n, vll(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				r[i][j] = (r[i][j] + a[i][k] * b[k][j]) % MOD;
	return r;
}

vector<vll> matrixPower(vector<vll> a, ll n) {
	if (n == 1) return a;
	vector<vll> r = matrixPower(a, n/2);
	r = matrixMult(r, r);
	if (n&1) r = matrixMult(r, a);
	return r;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	vector<vll> a(n, vll(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) scanf("%lld", &a[i][j]);

	a = matrixPower(a, k);
	ll answer = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) answer = (answer + a[i][j]) % MOD;
	printf("%lld\n", answer);
}


Measured memory_bytes: 1536
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int32_t main()
{
	prep();
	int n;
	cin>>n;
	int cost;
	int r=n/500;
	int y=n%500;
	int h=y/5;
	cost=r*1000+h*5;
	cout<<cost;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;



void solve()
{
	int a[5], k;
	for (int i = 0; i < 5; ++i)
	{
		cin >> a[i];
	}
	cin >> k;
	bool flag = true;
	for (int i = 0; i < 5; ++i)
	{
		for (int j = 0; j < 5; ++j)
		{
			if (a[i] - a[j] > k)
			{
				flag = false;
			}
		}
	}
	if (flag)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int n, c;
int a[30], b[31];
int dp[31][1<<16];

int bitCount( int bits )
{
	int ret = 0;
	while( bits > 0 )
	{
		ret += bits&1;
		bits >>= 1;
	}

	return ret;
}

int main()
{
	while( scanf( "%d%d", &n, &c ), n|c )
	{
		memset( a, 0, sizeof( a ) );
		memset( b, 0, sizeof( b ) );
		memset( dp, -1, sizeof( dp ) );

		rep( i, n )
		{
			rep( j, 16 )
			{
				int t;
				scanf( "%d", &t );
				if( t )
					a[i] |= 1<<j;
			}
		}

		rep( i, c )
		{
			rep( j, 16 )
			{
				int t;
				scanf( "%d", &t );
				if( t )
					b[i] |= 1<<j;
			}
		}

		dp[0][0] = 0;

		rep( i, n ) rep( j, 1<<16 )
		{
			if( dp[i][j] < 0 )
				continue;

			int x = j|a[i];
			rep( k, c+1 )
				dp[i+1][x^(x&b[k])] = std::max( dp[i+1][x^(x&b[k])], dp[i][j]+bitCount( x&b[k] ) );
		}

		printf( "%d\n", *std::max_element( dp[n], dp[n+1] ) );
	}

	return 0;
}

Measured memory_bytes: 8976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n));
    vector<vector<bool>> need(n, vector<bool>(n, true));
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(a[i][j] > a[i][k] + a[k][j]){
                    puts("-1");
                    return 0;
                }
                if(a[i][j] == a[i][k] + a[k][j] && a[i][k] > 0 && a[k][j] > 0) need[i][j] = false;
            }
        }
    }

    ll ans = 0;
    rep(i,n){
        rep(j,n){
            if(need[i][j]) ans += a[i][j];
        }
    }
    ans /= 2LL;
    cout << ans << endl;
}

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

int N;
int a[20];

int main(){

    cin >> N;
    REP(i,N){
    cin >> a[i];
    }
    sort(a,a+N);
    int ans = 0;
    REP(i,N-1){
        ans += a[i];
    }
    
    cout << ans + a[N-1]/2 << endl;
    



    
    
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    N = Number(input[0]);
    AB = input[1].split(" ");
    A = Number(AB[0]);
    B = Number(AB[1]);
    points = input[2].split(" ");
    P_under_A = [];
    P_under_B = [];
    P_Not_AB = [];
    for(i = 0; i < N; i++){
        points[i] = Number(points[i]);
    }
    points.sort(function(a,b){
        if( a < b ) return -1;
        if( a > b ) return 1;
        return 0;
    });
    for(i = 0; i < N; i++){
        if(points[i] <= A) P_under_A.push(points[i]);
        else if(points[i] <= B) P_under_B.push(points[i]);
        else P_Not_AB.push(points[i]);
    }
    console.log(Math.min(P_under_A.length, P_under_B.length, P_Not_AB.length));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
li =[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]
a=int(input())
a-=1
print(li[a])


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

int main(){
  long A,B;
  cin >> A >> B;
  long i=1,j=1;
  while(i<=B){
    i*=2;
  }
  i/=2;
  while(j<A){
    j*=2;
  }
  long x,y;
  x=(B-i+1)%4;
  y=(j-A)%4;
  long ans=0;
  for(int k=0; k<x; k++){
    ans^=B-k;
  }
  for(int l=0; l<y; l++){
    ans^=A+l;
  }
  if(A<4){
    for(int s=3; A<=s; s--){
      ans^=s;
    }
  }
  cout << ans << endl;
}

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

int main() {

	char a, b;

	cin >> a >> b;

	if ((a=='H'&&b=='H')||(a=='D'&&b=='D')) {
		cout << "H" << endl;
	}

	else {
		cout << "D" << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n, k;
	cin >> n >> k;
	long ans = 0;
	
	while(n >= k) {
		n /= k;
		ans += 1;
	}

	cout << ans + 1 << endl;
	return 0;

}



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

int main(){
  int n;
  cin >> n;
  std::vector<int> vec(n);
  rep(i,n) cin >> vec.at(i);
  int cnt = 0,ans = 0;
  rep(i,n-1) {
    if (vec.at(i) >= vec.at(i+1)) {
      cnt++;
      ans = max(ans,cnt);
      continue;
    }
    cnt = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3696
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  int A[110], N, cnt=0;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	int v=A[j];
	A[j]=A[j-1];
	A[j-1]=v;
	cnt += 1;
      }
    }
  }
  for(int i=0;i<N-1;i++) cout<<A[i]<<" ";
  cout<<A[N-1]<<endl;
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3096
! permとfactの前計算は ~/repos/contest/atcoder_ojt/abc156_e/fortran.f08 参照
program main
  implicit none
  integer(8) :: n, k, i, res
  integer(8), parameter :: m = 10 ** 9 + 7
  integer(8), allocatable :: a(:)
  integer(8), allocatable :: fact(:), ifact(:)
  read *, n, k
  allocate (a(n), fact(0:n), ifact(0:n))
  read *, a
  call quicksort(a)
  call calc_fact

  res = 0

  ! Add sum(max(s)) to res
  do i = 1, n
    res = res + modulo(a(i) * combi(i - 1, k - 1), m)
    res = modulo(res, m)
  end do

  ! Subtract sum(min(s)) from res
  do i = 1, n
    res = res - modulo(a(i) * combi(n - i, k - 1), m)
    res = modulo(res, m)
  end do

  print "(i0)", res
  contains

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(8) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1_8, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort

  integer(8) function combi(n, k)
    integer(8), intent(in) :: n, k
    if (n < k) then
      combi = 0
      return
    end if
    combi = fact(n)
    combi = combi * ifact(k)
    combi = modulo(combi, m)
    combi = combi * ifact(n - k)
    combi = modulo(combi, m)
  end function combi

  subroutine calc_fact()
    integer(8) :: i
    fact(0) = 1
    ifact(0) = inv(1_8)
    do i = 1, n
      fact(i) = modulo(fact(i - 1) * i, m)
      ifact(i) = inv(fact(i))
    end do
  end subroutine calc_fact

  function inv(n)
    integer(8), intent(in) :: n
    integer(8) :: inv
    inv = pow(n, m - 2)
  end function inv

  recursive function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (modulo(p, 2_8) == 0) then
      res = modulo(pow(n, p / 2) ** 2, m)
    else
      res = modulo(pow(n, p - 1) * n, m)
    end if
  end function pow
end program main


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>
#include <queue>
#include <functional>
#include <unordered_map>
#include <random>
#include <iomanip>
#include <cstdlib>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

int main()
{
    int height, width;
    cin >> height >> width;
    for (int row = 0; row < height; row++) for (int col = 0; col < width; col++)
    {
        string s;
        cin >> s;
        if (s == "snuke") cout << string(1,'A' + col) << row + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    map<ll, ll> count;
    REP(i, n){
        ll ai;
        cin >> ai;
        ans += count[i - ai];
        count[i + ai]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26244
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
    if i+1 > K:
        break
for i in sorted(s):
    print(i)

Measured memory_bytes: 38384
main = do
  n <- getLine
  as1 <- getLine >>= return . map read . words :: IO [Int]
  as2 <- getLine >>= return . map read . words :: IO [Int]

  let
    as1' = scanl1 (+) as1
    s = sum as2
    as2' = init $ map (\x -> s - x) (scanl (+) 0 as2)

  print $ maximum $ zipWith (+) as1' as2'
  


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

int main()
{
  int a,b,c;
  cin >> a>>b>>c;
  cout << min(a*b,c) << endl;
  return 0;
}

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

using namespace std;

int main()
{
    #define ll long long
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    char ch;
    int temp;
    string str;
    cin>>str;
    int sze = str.size();
    for(int i=0;i<sze;i++)
    {
        ch = str[i];
        temp = ch - 'A' + n;
        if(temp>=26)temp = temp-26 ;
        temp = temp+65;
        cout<<char(temp);
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,sum=0;
    cin>>a>>b>>c>>d;
    if(a>b)sum=sum+b;
    else sum=sum+a;
    if(c>d)sum=sum+d;
    else sum=sum+c;
    cout<<sum<<endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long ans{0}, now{0};
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        ans += now - min(now, a);
        now = max(a, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>

int main(void){
  int i,a,b,flag=0,k;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);

  for(i=a;i<=b;i++){
    if(i%k==0)flag=1;
  }
  if(flag==1)printf("OK");
  else printf("NG");




  return 0;
}

Measured memory_bytes: 1736
import sys
import math

def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    for i in range(3,int(math.sqrt(x))+1,2):
        if x%i == 0:
            return False
    return True

if __name__ == '__main__':
    a = []
    for tmp_line in sys.stdin:
        n = (int)(tmp_line)
        a.append(n)
    primes = []
    for x in range(2,max(a)+1):
        if isPrime(x):
            primes.append(x)
    for y in a:
        print(len([x for x in primes if x <= y]))

Measured memory_bytes: 11524
using System;
 
public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ans = 0L;
        for (int i = 1; i <= n; i++)
            ans += i * fn(n / i);
        Console.WriteLine(ans);
    }
    static long fn(int n) => (long)n * (n + 1) / 2;
}

Measured memory_bytes: 27524
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n;
    cin>>n;
    vvi a(2,vi(n));
    vvi dp(2,vi(n,0));
    rep(i,2)rep(j,n)cin>>a[i][j];
    dp[0][0]=a[0][0];
    rep(i,2){
        rep(j,n){
            if(i+1<2){
                chmax(dp[i+1][j],dp[i][j]+a[i+1][j]);
            }
            if(j+1<n){
                chmax(dp[i][j+1],dp[i][j]+a[i][j+1]);
            }
        }
    }
    fin(dp[1][n-1]);
}

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

class Observatory
{
public:
  int height;						//高さ
  vector<int> neighbors;			//隣接する展望台
  
  void AddNeighbor(int neighbor)
  {
     neighbors.push_back(neighbor);
  }
  
  void printNeighbor()
  {
    for(int i = 0; i < (int)neighbors.size(); i++)
    {
        cout << neighbors[i] << "  ";
    }
    cout << endl;
  }
};

int main(void)
{
  int N, M;
  
  cin >> N >> M;
  vector<Observatory> obs(N);
  
  //高さの入力
  for(int i = 0; i < N; i++)
  {
      cin >> obs[i].height;
  }
  
  //道(隣接する展望台)の入力
  for(int i = 0; i < M; i++)
  {
      int path_s, path_e;
      cin >> path_s >> path_e;
      obs[path_s-1].AddNeighbor(path_e-1);
      obs[path_e-1].AddNeighbor(path_s-1);
  }
  
  /*
  for(int i = 0; i < N; i++)
  {
    cout << "Obs[" << i << "] neighbors：";
    obs[i].printNeighbor();
  }
  */
  
  //良い展望台か判断する
  int goodObservatories = 0;
  for(int i = 0; i < N; i++)
  {
      int isgoodcnt = 0;
      
      for(int j = 0; j < (int)obs[i].neighbors.size(); j++)
      {
          if( obs[i].height > obs[ obs[i].neighbors[j] ].height )
          {
              isgoodcnt++;
          }
      }
    
      if(isgoodcnt == (int)obs[i].neighbors.size() )
      {
      	  goodObservatories++;
      }
  }
  
  cout << goodObservatories << endl;
  return 0;
}


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

#define REPN(i, n) for(int (i) = 0; (i)<n; (i)++)

const int MAX (1010);
const int oo (2000000010);

int cs[MAX], ts[MAX];

void solve(int n, int t){
    int ans = oo;

    //Escolhe dentre as rotas, o maior custo cujo tempo é menor ou igual a T
    REPN(i, n)
        if(ts[i] <= t)
            ans = min(ans, cs[i]);

    if(ans==oo)
        cout<<"TLE\n";
    else
        cout<<ans<<endl;
}

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

    REPN(i,n)
        cin>>cs[i]>>ts[i];

    solve(n, t);

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

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

	rep(loop, q) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		c--, d--;

		const ll total = a + b;
		const ll num = max(a, b);
		const ll den = min(a, b) + 1;
		const ll k = (num + den - 1) / den;

		ll low = 0, high = a + 1;
		while (high - low > 1) {
			const ll mid = (low + high) / 2;
			const ll na = a - mid;
			const ll nb = b - (mid - 1) / k;

			if (na >= 0 and nb >= 0 and nb <= (na + 1) * k)
				low = mid;
			else
				high = mid;
		}

		const ll border = low + (low - 1) / k;
		//cerr << low << endl;

		string ans = "";
		for (ll i = c; i <= d; ++i) {
			if (i < border) {
				if (i % (k + 1) != k)
					ans += 'A';
				else
					ans += 'B';
			} else {
				if ((total - 1 - i) % (k + 1) != k)
					ans += 'B';
				else
					ans += 'A';
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 384
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;

int a[30];
int m[205];

int main(){
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];
	int q;
	cin >> q;
	rep(i,q) cin >> m[i];



	set<int> s;
	rep(i,1<<n){
		int mtmp = 0;
		rep(tmp,n){
			if((i&1<<tmp)){
				mtmp+=a[tmp];
			}
		}
		s.insert(mtmp);
	}

	rep(i,q){
		decltype(s)::iterator it = s.find(m[i]);
		if(it!=s.end()){printf("yes\n");}
		else{printf("no\n");}
	}

	return 0;
}



Measured memory_bytes: 3088
s = int(input())


def f(n):
    return int(n/2) if 0 == n % 2 else 3 * n + 1

a = set()
a.add(s)
m = 1
while True:
    s = f(s)
    m += 1
    if s in a:
        break
    else:
        a.add(s)
print(m)

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e5 + 5;

vi adj[N];
int vis[N];

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(vis, -1, sizeof(vis));
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;

        adj[x].pb(y);
        adj[y].pb(x);
    }

    queue<int> q;
    q.push(1);

    vis[1] = 0;

    int cnt = 0;
    while(!q.empty()) {
        int nd = q.front(); q.pop();

        for(auto ch : adj[nd]) {
            if(vis[ch] == -1) {
                cnt++;
                vis[ch] = nd;
                q.push(ch);
            }
        }
    }

    if(cnt != n - 1) cout << "No";
    else {
        cout << "Yes\n";
        for(int i = 2; i <= n; i++) cout << vis[i] << "\n";

    }

}








Measured memory_bytes: 10608
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  while(true){
    int m,f,r;
    cin >> m >> f >> r;
    if(m==-1 && f==-1 && r==-1) break;    
    if(m==-1 || f==-1) cout << 'F' << endl;
    else if(m+f >= 80) cout << 'A' << endl;
    else if(65 <= m+f && m+f < 80) cout << 'B' << endl;
    else if(50 <= m+f && m+f < 65) cout << 'C' << endl;
    else if((30 <= m+f && m+f < 50) && 50 <= r) cout << 'C' << endl;    
    else if(30 <= m+f && m+f < 50) cout << 'D' << endl;
    else if(m+f < 30) cout << 'F' << endl;
  }
}



Measured memory_bytes: 3084
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	int cnt = 1;
	ull sum = 0;
	rep(i, n) {
		if (i == n - 1 || a[i] != a[i + 1]) {
			if (a[i] <= cnt) {
				sum += cnt - a[i];
			}
			else {
				sum += cnt;
			}
			cnt = 1;
		}
		else {
			cnt++;
		}
	}
	cout << sum << endl;
	return 0;
}





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

int main(){
	while(1){
		int n;
		cin >>n;
		if(n==0)
			break;
		
		unsigned sum=0;
		for(int i=0; i<n; i++){
			int p;
			cin >> p;

			sum+=(unsigned)p;
		}
		
		int j[n-1];
		for(int i=0; i<n-1; i++){
			cin >>j[i];
		}

		sort(j,j+(n-1));

		unsigned sal_max=(unsigned)n*sum;

		for(int i=n-1; i>=1; i--){
			sum+=(unsigned)j[i-1];

			sal_max=max(sal_max,(unsigned)i*sum);
		}

		cout <<sal_max <<endl;
	}
	return 0;
}

		

	

Measured memory_bytes: 1428
#include <iostream>
#include <algorithm>
#include <string>
#define fflush(stdout) flush
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main(void) {
	int n, i, j, k;
	ll ln[5] = {}, ans;
	string s;
	const string cs = "MARCH";

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; j < 5; j++) {
			if (cs[j] == s[0]) {
				ln[j]++;
				break;
			}
		}
	}

	ans = 0;
	for (i = 0; i < 3; i++) for (j = i + 1; j < 4; j++) for (k = j + 1; k < 5; k++) {
		ans += ln[i] * ln[j] * ln[k];
	}

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

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	ans := make([]byte, 0)
	for i := 0; i < len(s); i++ {
		if s[i] == '0' || s[i] == '1' {
			ans = append(ans, s[i])
		} else if len(ans) > 0 {
			ans = ans[:len(ans)-1]
		}
	}
	fmt.Println(string(ans))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fort(i,n) for (int i = 1; i <= n; i++)
#define ll long long
#define sz size()
#define er erase
#define fr first
#define sc second
using namespace std;

string s;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    int n=s.sz;
    if (n==2) cout << s;
    else cout << s[2] << s[1] << s[0];
}


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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli n, sum = 0;
	cin >> n;

	vcL num( n, 0 );

	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		sum += num[i] - 1;
	}

	cout << sum << '\n';
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, resp=1;
    string atual;
    cin >> n >> atual;
    char past=atual[0];
    for(int i=1; i<n; i++){
        if(atual[i]!=past){
            resp++;
        }
        past=atual[i];
    }
    cout << resp << endl;
    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  string S;
  cin >> S;
  if (S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#!usr/bin/env python3
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]

#A
"""
s = S()
if s[0] != "A":
    print("WA")
else:
    count = []
    for i in range(2,len(s)-1):
        if s[i] == "C": count.append(i)
    if len(count) != 1:
        print("WA")
    else:
        for i in range(1,len(s)):
            if i not in count:
                if s[i] == s[i].upper():
                    print("WA")
                    quit()
        print("AC")
"""

#B
"""
n,m,k = LI()
for i in range((n+1)//2):
    if (k - m*i) % (n - 2*i) == 0 and (k-m*i)//(n-2*i) >= 0 and (k-m*i)//(n-2*i) <= m:
        print("Yes")
        quit()
print("No")
"""

#C
"""
from collections import defaultdict
n,k = LI()
d = defaultdict(int)
for i in range(n):
    a,b = LI()
    d[a] += b
s = list(d.items())
s.sort(key = lambda x:x[0])
su = 0
for i in range(len(s)):
    su += s[i][1]
    if su >= k:
        print(s[i][0])
        break
"""

#D
"""
n,k = LI()
d = LI()
lis = [0,1,2,3,4,5,6,7,8,9]
for i in d:
    if i in lis:
        lis.remove(i)
n = list(str(n))
i = 0
while i < len(n):
    while int(n[i]) not in lis and n[i] != "10":
        n[i] = str(int(n[i])+1)
    if n[i] == "10":
        if i == 0:
            n[i] = "0"
            n.insert(i,"1")
        else:
            n[i-1] = str(int(n[i-1])+1)
            n[i] = "0"
            i -= 1
        i -= 1
    i += 1
for i in n:
    print(i,end = "")
print()
"""
#E
n = II()
a = LI()
ans = float("inf")
for i in range(min(a),max(a)+1):
    cos = 0
    for j in a:
        cos += (i-j)**2
    ans = min(ans, cos)
print(ans)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
  N = int(raw_input())
  A = map(lambda s: int(s) - N + 1, raw_input().split())
  K = 0
  while True:
    c = []
    for i in xrange(N):
      if A[i] > 0:
        c.append(i)
    if not c:
      break
    s = 0
    for i in c:
      k = (A[i] + (N - 1)) / N
      A[i] -= k * (N + 1)
      s += k
    for i in xrange(N):
      A[i] += s
    K += s
  print K

main()

Measured memory_bytes: 32620
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${5PL2kn!5WHLRAEt*Sc1xnT$EfZ{QXc?Aiev-A^w7S(i%nyvdjV!=XLlAI+=#&ld75G{_6BK2??S|=#!1Dp(1{?w<EOJH&jTL@HQY%)aC=jklvR4;?)gb_s~ORZjk+vkuQcd-eLbh>;LBp^Q+bAC!>}aqjLG~crz;}Y^;(EQ@m_@lgV(U`W`;{yfWm0_EAQ}z^94c0uVBHK)Qq=(wdqwaiA+n#riW!1890MrFbt7Fmc{I(I_&yge_+@XXFrmPb^(T}@+K-OoQG<gI?wg5kYx8Fx996n97i-67Aq_^Fd5`{Y9X@l*7Q3aqT3`=MAG4pQ0gciq0}v|&@A`T&U#x^bc@>E@Z#6j>-vxWYSJk30!ifgSr*IRrv-diT7V=sza4$2?E")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9724
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

int main(){
    ll h, w;
    cin >> h >> w;
    
    ll ch, dh, cw, dw;
    cin >> ch >> dh;
    cin >> cw >> dw;
    ch--, dh--, cw--, dw--;

    vector<string> maiz(1000);
    rep(i, h)cin >> maiz[i];

    //小さい順に取り出す
    priority_queue<pll, vector<pll>, greater<pll>> que;
    que.push(make_pair(ch, dh));

    ll cost[h][w];
    rep(i, h)rep(j, w) cost[i][j] = INF;
    cost[ch][dh] = 0;

    while(!que.empty()){
        pll pos = que.top();
        que.pop();

        ll cost_pos = cost[pos.first][pos.second];
        ll f = pos.first;
        ll s = pos.second;

        // up down left right
        rep(i, 4){
            if(f + dy[i] >= 0 && f + dy[i] < h && s + dx[i] >= 0 && s + dx[i] < w){
                if(maiz[f+dy[i]][s+dx[i]] == '.' && cost_pos < cost[f+dy[i]][s+dx[i]]){
                    cost[f+dy[i]][s+dx[i]] = cost_pos;
                    que.push(make_pair(f+dy[i], s+dx[i]));
                }
            }
        }

        for(ll i = -2; i <= 2; ++i)for(ll j = -2; j <= 2; ++j){
            if(f + i >= 0 && f + i < h && s + j >= 0 && s + j < w){
                if(maiz[f+i][s+j] == '.' && cost_pos + 1 < cost[f+i][s+j]){
                    cost[f+i][s+j] = cost_pos + 1;
                    que.push(make_pair(f+i, s+j));
                }
            }
        } 
    }

    if(cost[cw][dw] >= INF)cout << -1 << endl;
    else cout << cost[cw][dw] << endl;
}

Measured memory_bytes: 13448