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

const long long inf=1000000000000000000ll;
int n,val[61],X,D,fa[61],id[61],ans,Ans,XX;
long long a[61],f[61][180010];

bool cmp(const int &x,const int &y) {return val[x]*a[y]>val[y]*a[x];}

int main()
{
	scanf("%d%d%d%lld",&n,&X,&D,&a[1]),val[1]=1,fa[1]=0;
	for (int i=2; i<=n; i++) scanf("%lld%d",&a[i],&fa[i]),val[i]=1;
	for (int i=n; i; i--) a[fa[i]]+=a[i],val[fa[i]]+=val[i];
	for (int i=0; i<=60; i++)
		for (int j=0; j<=180000; j++) f[i][j]=inf;
	f[0][0]=0;
	for (int i=1,k=0; k<=n; k++)
		for (int j=0; j<=n*n*n-k*val[i]; j++)
			f[i][j+k*val[i]]=min(f[i][j+k*val[i]],f[i-1][j]+k*a[i]);
	for (int i=2,lim=min(D,n); i<=n; i++)
		for (int k=0; k<=lim; k++)
			for (int j=0; j<=n*n*n-k*val[i]; j++)
				f[i][j+k*val[i]]=min(f[i][j+k*val[i]],f[i-1][j]+k*a[i]);
	for (int i=1; i<=n; i++) id[i]=i;
	sort(id+1,id+1+n,cmp),ans=Ans=0,XX=X;
	for (int i=0; i<=n*n*n; i++) if (f[n][i]<=X)
	{
		ans=0;
		for (int J=1,j; J<=n; J++)
		{
			j=id[J];
			if (D<=n&&j!=1) continue;
			int cnt=(j==1?X/a[j]+1:D-n);
			if (cnt>X/a[j]+1) cnt=X/a[j]+1;
			if (cnt*a[j]+f[n][i]>X) cnt=(X-f[n][i])/a[j];
			X-=cnt*a[j],ans+=cnt*val[j],Ans=max(Ans,ans+i);
		}
		X=XX;
	}
	return printf("%d\n",Ans),0;
}

Measured memory_bytes: 86144
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << 0.5 * w * h << " ";
    if (2 * x == w && 2 * y == h) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (size_t i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (size_t i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define INF 1e7

int N;
vector<int> a;

int main()
{
  cin>>N;
  REP(i,N) {
    int tmp;
    cin>>tmp;
    a.push_back(tmp);
  }

  int f = -N, size = a.size();
  REP(i, size) f += a[i];

  cout<<f<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in );

		String str = kb.nextLine();
		int n = Integer.parseInt( str );
		
		boolean[] cards= new boolean[53]; 
		for( int i=0; i<n; i++ ) {
			String pattern = kb.next();
			int num = kb.nextInt();
			if( "S".equals(  pattern ) ) {
				cards[ num-1 ]=true;
			} else if( "H".equals(  pattern ) ) {
				cards[ 12+num ]=true;
			} else if( "C".equals(  pattern ) ) {
				cards[ 25+num ]=true;
			} else if( "D".equals(  pattern ) ) {
				cards[ 38+num ]=true;			
			}
		}

		for( int i=0; i<52; i++ ) {
			if( false == cards[ i ] ) {
				int num = i/13;
				if( 0 == num ) {
					num=(i%13)+1;
					System.out.println( "S "+ num);
				} else if( 1 == num ) {
					num=(i%13)+1;
					System.out.println( "H "+num );
				} else if( 2 == num ) {
					num=(i%13)+1;
					System.out.println( "C "+num );
				} else if( 3 == num ) {
					num=(i%13)+1;
					System.out.println( "D "+num );				
				}
			}
		}
	}
}

Measured memory_bytes: 18064
#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, ans = 1e9;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    sort(h.begin(), h.end());
    rep(i, N - K + 1) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdio.h>
#include <string.h>
int main()
{
     char s[5];
     int i,sum;
     sum=0;
     gets(s);
     for(i=0;i<4;i++)
     {
         if(s[i]=='+')
            sum=sum+1;
         if(s[i]=='-')
            sum=sum-1;

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

}




Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll A[N]; F0R(i, N) cin >> A[i];
    F0R(i, N) {
        if (A[i] == 0) {
            cout << 0 << nl; return 0;
        }
    }
    ld L = 0;
    F0R(i, N) {
        L += log10(A[i]);
    }
    if (L > 18.1) {
        cout << -1 << nl; return 0;
    }
    ll ans = 1; F0R(i, N) ans *= A[i];
    if (ans > 1000000000000000000) {
        cout << -1 << nl; return 0;
    }
    cout << ans << nl;
	
	return 0;
}

Measured memory_bytes: 4612
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using mint = modint;

int main(){
	fastio;
	mint::set_mod(MOD);

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

	scc_graph g(n);

	forn(i,m){
		int a, b; 
		cin>>a>>b;
		g.add_edge(a,b);
	}

	vv32 v = g.scc();
	cout<<v.size()<<ln;
	forstl(r,v){
		cout<<r.size()<<" ";
		forstl(k,r) cout<<k<<" ";
		cout<<ln;
	}

	return 0;
}


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

typedef pair<long long, long long> data_t;

int main(){
  char b;
  cin>>b;
  if(b=='A')
    cout<<'T'<<endl;
  else if(b=='T')
    cout<<'A'<<endl;
  else if(b=='G')
    cout<<'C'<<endl;
  else if(b=='C')
    cout<<'G'<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 201
int main(void)
{
	char n[MAX], nn[MAX]; 
	int m, h, i, j;
	int len;
	while(scanf("%s", n), n[0] != '-'){
		len = strlen(n);
		scanf("%d", &m);
		for(i=0; i<m; i++){
			scanf("%d", &h);
			for(j=0; j<len-h; j++){
				nn[j] = n[h+j];
			}
			for(j=len-h; j<len; j++){
				nn[j] = n[j-(len-h)];
			}
			for(j=0; j<len; j++){
				n[j] = nn[j];
			}
		}
		printf("%s\n", n);
	}
	return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) cout << -1 << endl;
    else cout << A * B << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC061_C___Big_Array
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var N = read[0];
            var K = read[1];

            var numbers = new long[100100];

            for(int i = 0 ; i < N ; i++)
            {
                read = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
                numbers[read[0]] += read[1];
            }

            int result = 0;

            while(K > numbers[result])
            {
                K -= numbers[result];
                result += 1;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 15812
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
int d[101][101];

int main(){
	int n,m,s,g1,g2;
	while(cin >> n >> m >> s >> g1 >> g2){
		if(n==0&&m==0&&s==0&&g1==0&&g2==0) break;
		for(int i=1; i<=n; ++i){
			for(int j=1; j<=n; ++j){
				if(i==j){
					d[i][j]=0;
				} else {
					d[i][j]=INF;
				}
			}
		}
		for(int i=0; i<m; ++i){
			int b1,b2,c;
			cin >> b1 >> b2 >> c;
			d[b1][b2]=c;
			//d[b2][b1]=c;
		}
		for(int k=1; k<=n; ++k){
			for(int i=1; i<=n; ++i){
				for(int j=1; j<=n; ++j){
					d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
				}
			}
		}
		int ans=INF;
		for(int i=1; i<=n; ++i){
			ans=min(ans,d[s][i]+d[i][g1]+d[i][g2]);
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 1204
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main(){
  int n;
  while(cin>>n && n!=0){
    vector<int> vec(n),sum(n);
    rep(i,n) cin>>vec[i];
    sum[0]=vec[0];
    
    for(int i=1;i<n;i++) sum[i]=vec[i]+sum[i-1];
    int ma=-1e9;
    
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        chmax(ma,sum[j]-sum[i]);
      }
    }
    
    rep(i,n) chmax(ma,sum[i]);
 
    cout<<ma<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3132
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
k = list(a_counter.keys())
v = list(a_counter.values())

if len(a_counter) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(a_counter) == 2 and 0 in k and (v[0] == v[1]*2 or v[1] == v[0]*2):
    print("Yes")
elif len(a_counter) == 1 and 0 in k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 3532
#include<stdio.h>

int main(){
	int a,b,i;
	int n,c1,c2;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		a=0;b=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&c1,&c2);
			if(c1>c2)a+=c1+c2;
			else if(c1<c2)b+=c1+c2;
			else a+=c1,b+=c1;
		}
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int solve(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	int total=0;
	for(int i=1;i<=n;i++){
	    int sum= solve(i);
	    if(sum>=a&&sum<=b) total+=i;
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(int argc, char const *argv[])
{
    std::string input;
    std::cin >> input;
    std::vector <int> freq(26, 0);
    for(char c : input){
        ++freq[c - 'a'];
    }
    bool beautiful = true;
    for(int f : freq){
        if(f % 2){
            beautiful = false;
            break;
        }
    }
    if(beautiful){
        std::cout << "Yes\n";
    } else{
        std::cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    int mr = N / R;
    for (int i = 0; i < mr + 1; i++) {
        int mg = (N - i * R) / G;
        for (int j = 0; j < mg + 1; j++) {
            int b = N - i * R - j * G;
            if (b % B == 0) {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
order = [''] * n
st = [''] * n
for i in range(n):
    order[i], st[i] = map(str, input().split())

dic = {}
for i in range(n):
    if order[i] == 'insert':
        dic.setdefault(st[i], 0)
    else:
        if st[i] in dic:
            print('yes')
        else:
            print('no')


Measured memory_bytes: 152816
import itertools

N = int(input())

permu = [i+1 for i in range(N)]
s = 0
flag = False

P = tuple([int(i) for i in input().split(" ")])
Q = tuple([int(i) for i in input().split(" ")])

if P==Q:
    print(s)
else:
    for i, value in enumerate(itertools.permutations(permu)):

        if value == P or value == Q:
            # print(i)
            if flag:
                s -= i
                break
            else:
                s += i
                flag = True

    print(abs(s))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string_view>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void solve()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    map<int, int> mp;
    int pro = 1;
    for (int i = 0; i < k; i++)
    {
        pro *= a[i];
        //pro %= mod;
    }
    int j = 0;
    for (int i = k; i < n; i++)
    {
        if (a[j] < a[i])
            cout << "Yes\n";
        else
            cout << "No\n";
        j++;
    }
}
int32_t main()
{
    AB_BHI_NI_DEGI
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cout.precision(20);
    //cout << fixed;
    int T = 1;
    //cin >> T;
    int cnt = 1;
    while (T--)
    {
        //cout << "Case #" << cnt++ << ":\n";
        solve();
    }
    return 0;
}


Measured memory_bytes: 5204
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,K;
    cin >> N >> K;
    if(K % 2){
        cout << (N / K) * (N / K) * (N / K) << endl;
    }else{
        ll ans = (N / K) * (N / K) * (N / K);
        //2倍してKの倍数になるa
        ll cnt = 0;
        for(int i = 1;i * K <= N * 2;i+=2){
            cnt++;
        }
        ans += cnt * cnt * cnt;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

        if(a >= 1 && a <= 9 && b >= 1 && b <= 9) System.out.println(a * b);
        else System.out.println(-1);

    }

}


Measured memory_bytes: 22608
n, l = gets.split(" ").map(&:to_i)
apples = []
(1..n).each do |num|
  apples << l + num - 1
end

sum = apples.inject(:+)

if apples.include?(0)
  puts sum
elsif sum > 0
  puts sum - apples.first
else
  puts sum - apples.last
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,A,B,C,D,S,T;
    cin>>a>>b>>c>>d;
    cin>>A>>B>>C>>D;
     S=a+b+c+d;
     T=A+B+C+D;
    if(S==T){
        cout<<S;
    }
    else if(S>T){
        cout<<S;
    }
    else if(S<T){
        cout<<T;
    }
    cout<<endl;
}
    



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

void BFS(vector<int> verVal[], vector<bool> &color, list<int> &sortVers, vector<int> &indeg, int subScript) {
	queue<int> bfsQ;
	bfsQ.push(subScript);
	color[subScript] = true;

	while (!bfsQ.empty()) {
		int curVerVal = bfsQ.front(); 
		bfsQ.pop();

		sortVers.push_back(curVerVal);

		for (int i = 0; i < verVal[curVerVal].size(); i++) {
			int outVerVal = verVal[curVerVal][i];
			indeg[outVerVal]--;
			if (indeg[outVerVal] == 0 && !color[outVerVal]) {
				color[outVerVal] = true;
				bfsQ.push(outVerVal);
			}
		}
	}
}

list<int> TopologicalSort(vector<int> verVal[], int verNum) {

	list<int> sortVers;
	vector<bool> color(verNum);
	vector<int> indeg(verNum);

	//Initialie
	for (int i = 0; i < color.size(); i++)
		color[i] = false;
	for (int i = 0; i < indeg.size(); i++)
		indeg[i] = 0;
	for (int first = 0; first < verNum; first++) {
		for (int second = 0; second < verVal[first].size(); second++) {
			int outVerVal = verVal[first][second];
			indeg[outVerVal]++;
		}
	}

	for (int i = 0; i < verNum; i++)
		if (indeg[i] == 0 && !color[i]) {
			BFS(verVal, color, sortVers, indeg, i);
		}

	return sortVers;
}

int main() {

	vector<int> verVal[10000];
	int verNum, edgeNum;
	cin >> verNum >> edgeNum;

	for (int i = 0; i < edgeNum; i++) {
		int first, second;
		cin >> first >> second;
		verVal[first].push_back(second);
	}

    list<int> sortVers = TopologicalSort(verVal, verNum);

	for (list<int>::iterator it = sortVers.begin(); it != sortVers.end(); it++)
		cout << *it << endl;

	return 0;
}

Measured memory_bytes: 4132
#include <stdio.h>

int main(void) {
	long long a[5000];
	long long ask[5001];
	int max;
	int i;
	int j;
	int sign;
	long long saidaiti;
	long long now;
	while(1) {
		scanf("%d",&max);
		if(max==0)break;
		ask[0]=0;
		for(i=0;i<max;i++)scanf("%lld",&a[i]);
		for(i=0,j=0,sign=0;i<max;i++) {
			if(a[i]*sign<=0 && a[i]!=0) {
				sign=(a[i]>0)?1:-1;
				j++;
				ask[j]=0;
			}
			ask[j]+=a[i];
		}
		for(i=1;i<=j;i++) {
			if(ask[i]>=0)break;
		}
		if(i>j) {
			saidaiti=a[0];
			for(i=1;i<max;i++) {
				if(a[i]>saidaiti)saidaiti=a[i];
			}
		} else {
			max=j+1;
			saidaiti=ask[1];
			for(i=1;i<max;i++)ask[i]+=ask[i-1];
			for(i=1;i<=max;i++) {
				for(j=0;j<=max-i;j++) {
					now=ask[j+i]-ask[j];
					if(now>saidaiti)saidaiti=now;
				}
			}
		}
		printf("%lld\n",saidaiti);
	}
	return 0;
}

Measured memory_bytes: 0
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  int n;
  cin >> n;
  vector<int>a(n);
  forn(i,n)cin>>a[i];
  int ans = 0;
  int cnt = 0;
  rep(i,1,n){
    if (a[i-1]>=a[i]) cnt++;
    else {
      setmax(ans, cnt);
      cnt = 0;
    }
  }

  cout << max(ans, cnt);
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

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

const double pi = 3.141592653589793238;
int a, b, h, m;
int main() {
  cin >> a >> b >> h >> m;
  double k = (h + m / 60.0) / 12.0;
  double at = k * 2 * pi;
  double bt = k * 12.0 * 2 * pi;
  double ax = a * cos(at);
  double ay = a * sin(at);
  double bx = b * cos(bt);
  double by = b * sin(bt);
  cout << setprecision(16) << fixed << hypot(bx - ax, by - ay) << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    long long N;

    cin >> N;

    long long m = 1000;

    while(N > 99){
        long long num;

        if(N%1000 > 753){
            num = N%1000 - 753;
        }else{
            num = 753 - N%1000;
        }

        m = min(num, m);
        N /= 10;
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll a, ll n, ll i){
  // (A ^ N)を
  if (n == 0){
    return 1;
  }else if (n % 2 == 0){
    return AN(a * a % i, n / 2, i);
  }else{
    return (a * AN(a *a % i, n / 2, i)) % i;
  }
  

} 

int main(){
  int N; cin >> N;
  vector <int> D(N);

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

  if (D[0] != 0){
    cout << 0 << endl;
  }else{
    sort(D.begin(), D.end());

    if (N == 1){
      cout << 1 << endl;
    }else{
      if (D[1] == 0){
        cout << 0 << endl;
      }else{
        ll ans = 1;
        ll deg = 998244353;
        ll cnt = 1, before = 1;
        for (int i = 1; i < N; i++){
          if (D[i] == D[i - 1]){
            cnt++;
          }else if(D[i] == D[i - 1] + 1){
            ans *= AN(before, cnt, deg);
            ans %= deg;
            before = cnt; cnt = 1;
          }else{
            ans = 0;
            break;
          }
        }
        ans = ans * AN(before, cnt, deg);
        ans %= deg;
        cout << ans << endl;

      }
    }

  }
  
  
  return 0;
}

Measured memory_bytes: 768
def man(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])
n,m=map(int,input().split())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
cd=[]
for j in range(m):
    cd.append(list(map(int,input().split())))
for i in range(n):
    ans=0
    dis=man(ab[i],cd[0])
    for j in range(m):
        if dis >man(ab[i],cd[j]):
            ans = j
            dis = man(ab[i],cd[j])
    print(ans+1)

Measured memory_bytes: 3064
H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(input())

r = 0

for a in A:
    flag = False
    if '#' in a[:r]:
        print('Impossible')
        exit()
    for i in range(r, W):
        if a[i] == '#':
            if flag:
                print('Impossible')
                exit()
            r = i
        else:
            flag = True
            
print('Possible')
        

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int x; cin >> x;
    // エラトステネス
    // 0からmxまでの素数を割り出す
    int mx = 100100;
    vector<bool> is_prime(mx, true);   // すべて素数と初期化
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < mx; i++) {
        // 約数にiをもつ数値をfalseにしていく
        if (!is_prime[i]) continue;
        for (int j = i*2; j < mx; j += i) {
            is_prime[j] = false;
        }
    }
    
    repf(i,x,is_prime.size()) {
        if (is_prime[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
void color(int map[10][10], int x, int y)
{
  if (0 <= x && x <= 9 && 0 <= y && y <= 9){
    map[y][x]++;
  }
}
 
int main(void)
{
  int map[10][10] = {0};
  int x, y, size;
  int i, j;
  int white = 0, darkest = 0;
 
  while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
    map[y][x]++;
    if (size == 3){
      color(map, x + 2, y);
      color(map, x - 2, y);
      color(map, x, y + 2);
      color(map, x, y - 2);
    }
    if (size >= 2){
      color(map, x + 1, y + 1);
      color(map, x - 1, y + 1);
      color(map, x + 1, y - 1);
      color(map, x - 1, y - 1);
    }
    if (size >= 1){
      color(map, x, y + 1);
      color(map, x, y - 1);
      color(map, x + 1, y);
      color(map, x - 1, y);
    }
  }
 
  for (i = 0; i < 10; i++){
    for (j = 0; j < 10; j++){
      if (map[i][j] == 0){
        white++;
      }
      if (darkest < map[i][j]){
        darkest = map[i][j];
      }
    }
  }
 
  printf("%d\n%d\n", white, darkest);
 
  return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int d,f=0;
    for(int i=0;i<s.size();i++)
    {
        d=i+1;
        if(s[i]=='C') 
        {
            f=1;
            break;
        }
        else f=0;
    }
    for(int i=d;i<s.size();i++)
    {
    	if(s[i]=='F') 
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else f=0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {

  char S[10];
  scanf("%s", S);

  int m;
  int n = 0;
  for (int i = 0; i < strlen(S); i++) {
    m = 0;
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      m++;
      for (int j = i + 1; j < strlen(S); j++) {
	if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T') {
	  m++;
	} else {
	  break;
	}
      }
    }
    if (n < m) {
      n = m;
    }
  }

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

  return 0;
}

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

int main(){
  long long n,i,j,k,sum=0;
  cin >> n;
  long long a[3*n+10],ret[n+1]={};
  for(i=0;i<3*n;i++){
    cin >> a[i];
  }
  priority_queue<long long> p,q;
  for(i=0;i<n;i++){
    sum+=a[i];
    p.push(-a[i]);
  }
  ret[0]=sum;
  for(i=n;i<2*n;i++){
    sum+=a[i];
    p.push(-a[i]);
    sum+=p.top();
    p.pop();
    ret[i-n+1]=sum;
  }

  sum=0;
  for(i=0;i<n;i++){
    sum+=a[3*n-i-1];
    q.push(a[3*n-i-1]);
  }
  ret[n]-=sum;
  for(i=2*n-1;i>=n;i--){
    sum+=a[i];
    q.push(a[i]);
    sum-=q.top();
    q.pop();
    ret[i-n]-=sum;
  }
  long long ans=ret[0];
  for(i=0;i<=n;i++){
    ans=max(ans,ret[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5748
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
c=[False]*n
cnt=[0]*n
ac,pena=0,0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if not c[p] and s=="AC":
        pena+=cnt[p]
        c[p]=True
    elif s=="WA":
        cnt[p]+=1

print(c.count(True),pena)

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <numeric>

int main() {
  int N; std::cin >> N;
  std::vector<int> a(N);

  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }

  double sum = std::accumulate(a.begin(), a.end(), 0);
  double avg = sum / a.size();

  double min_dist = 99999999999;
  int index = -1;
  for (int i = 0; i < N; ++i) {
    double dist = (a[i] > avg) ? a[i] - avg : avg - a[i];
    if (dist < min_dist) {
      min_dist = dist;
      index = i;
    }
  }

  std::cout << index << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    while(1){
        int x,y;
        scanf("%d %d\n",&x,&y);
        if(x==0 && y==0){
            break;
        }else{
            if(x<=y){
                printf("%d %d\n",x,y);
            }else{
                 printf("%d %d\n",y,x);
            }
        }
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define N 105
int n,m;char a[N];
int main()
{
	scanf("%s",a+1);n=strlen(a+1);m=n>>1;
	for(int i=1;i<=n;++i) if(a[i]!=a[n-i+1]) {puts("No");return 0;}
	for(int i=1;i<=m;++i) if(a[i]!=a[m-i+1]) {puts("No");return 0;}
	for(int i=1;i<=m;++i) if(a[m+1+i]!=a[n-i+1]) {puts("No");return 0;}
	puts("Yes");return 0;
}


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

int main() {
    int n;
    cin >> n;
    if (n%2==0)
    {
        double a;
        a=(double)(n/2)/n;
        cout <<fixed<<setprecision(7)<<a<<endl;
    }
    else{
        double b;
        b=(double)(n+1)/(2*n);
        cout <<fixed<<setprecision(7)<<b<<endl;
    }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Println(nextInt() + nextInt()/2)
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    while(K > 0 && B <= A) {
        B *= 2;
        --K;
    }

    while(K > 0 && C <= B) {
        C *= 2;
        --K;
    }

    if(A < B && B < C) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3660
import java.util.*;
import java.io.*;

// 
public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int blue = r.ri();
		String[] blues = new String[blue];
		for (int i = 0; i < blues.length; i++)
			blues[i] = r.string();
		
		int red = r.ri();
		String[] reds = new String[red];
		for (int i = 0; i < reds.length; i++)
			reds[i] = r.string();
		
		Map<String,Integer> map = new HashMap<String,Integer>();
		for(String s : blues) {
			map.put(s, map.getOrDefault(s, 0)+1);
		}
		for(String s : reds) {
			map.put(s, map.getOrDefault(s, 0)-1);
		}
		
		int max = 0;
		for(Map.Entry<String,Integer> e : map.entrySet()) {
			max = Math.max(max, e.getValue());
		}
		print(max);		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(string());
		}

		long rl() {
			return Long.parseLong(string());
		}

		double rd() {
			return Double.parseDouble(string());
		}

		String string() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return string().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = string();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(string());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(string());
			return arr;
		}
	}
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin>>a>>b;
	cout<<a*b;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    string s;
    cin>>s;
    ll ssz=(ll)s.size();
    ll sums[ssz];
    
    ll dcheck[ssz];
    rep(i,ssz){
        dcheck[i]=sums[i]=-1;
    }
    ll ctr=0;
    rep(i,ssz){
        if(s[i]=='A'){
            ctr++;
            sums[i]=ctr;
        }
        else if(s[i]=='B'){
            if((i!=ssz-1)&&s[i+1]=='C'){
                sums[i]=ctr;
                dcheck[i]=1;
                ++i;
            }
            else ctr=0;
        }
        else ctr=0;
    }
    ll ans=0;
    rep(i,ssz){
        if(sums[i]==-1)continue;
        if(dcheck[i]==1) ans+=sums[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3716
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            print "Bad"
            return
    print "Good"

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  priority_queue<ll> A;
  REP(i, N) {
    ll a;
    cin >> a;
    A.push(a);
  }
  REP(i, M) {
    ll po = A.top();
    A.pop();
    A.push(po / 2);
  }
  ll ans = 0;
  REP(i, N) {
    ll po = A.top();
    A.pop();
    ans += po;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;


int main(){

int n;
cin>>n;
cout<<n*n<<endl;
	return 0;
}




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

int main() {
    string s;
    cin >> s;
    if(s[1] == 'B'){
    s[1] = 'R';
    }
    else{ 
      s[1] = 'B';
    };
  cout << s << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,count=0;
  cin>> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(a[minj]>a[j])minj=j;
    }
    swap(a[i],a[minj]);
    if(i!=minj)count++;
  }
  for(int i=0;i<n;i++){
    cout <<a[i];
    if(i!=n-1)cout<<' ';
  }
  cout<<endl<<count<<endl;
  return 0;
}
      


Measured memory_bytes: 3092
/*input
2 1 1 3
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld a,b,c,k;
	cin >> a >> b >> c >> k;
	lld ans=min(k,a);
	k=k-min(k,a);
	k=k-min(k,b);
	ans-=min(k,c);
	k-=min(k,c);
	cout << ans << endl; 
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    ll n,k;
    cin>>n>>k;
    int a[n];
    rep(i,n)cin>>a[i];

    int b[n]={};
    int s=0;
    while(true){
        if(b[s]!=0){
            break;
        }
        b[s]++;
        s=a[s]-1;
    }
    int f=0;
    int i=s;
    while(true){
        if(a[i]-1==s){
            f++;
            break;
        }
        else {
            i=a[i]-1;
            f++;
        }
    }
    i=0;
    int ans=0,flag=0;
    while(true){
        if(k==0){
            flag=1;
            ans=i;
            break;
        }
        if(i!=s){
            k--;
            i=a[i]-1;
        }
        else {
            k=k%f;
            break;
        }
    }
    if(flag==0)ans=s;
    i=s;
    while(k>0){
        ans=a[i]-1;
        i = a[i]-1;
        k--;
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 5208
N=int(input())
temp=list(map(int,input().split()))
temp_s=sorted(temp)
min_median=temp_s[N//2-1]
max_median=temp_s[N//2]
if max_median==min_median:
   for i in range(N):
      print(max_median)
   exit()
for i in temp:
   if i <= min_median:
      print(max_median)
   else:
      print(min_median)

Measured memory_bytes: 25620
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a, c[100009];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a, c[a]++;
	int ret = 0;
	for (int i = 0; i <= 100000; i++) ret = max(ret, c[i] + c[i + 1] + c[i + 2]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, n, m;
ll x, k, d, ans;

int main() {
    scanf(" %lld %lld %lld", &x, &k, &d);
    x = abs(x);
    i = floor(x / d);
    if (i >= k) ans = x - k * d;
    else if ((k-i)%2 == 0) ans = abs(x - i*d);
    else ans = abs(x - (i+1)*d);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3776
// abc132d.cpp : Blue and Red Balls
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define oute(x) cout<<(x)<<endl

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while(b){
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if(u<0) u += m;
  return u;
}

int main(){
  int N,K; cin>>N>>K;
  int red = N-K, blue = K;
  ll ai = red + 1;
  oute(ai);
  upto(i,2,blue+1,1){
    ai = (ai *  (red-i+2) * (blue-i+1) % MOD) * modinv(i*(i-1), MOD) % MOD;
    oute(ai);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int n; cin >> n;
    if (n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592