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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// ??????g????????????????????\?????????
void insertionSort(int A[], int n, 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 -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellsort(int A[], int n) {
	for (int h = 1; ;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}

	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	cnt = 0;

	shellsort(A, n);

	cout << G.size() << "\n";
	for (int i = G.size() - 1; i >= 0; i--) {
		cout << G[i];
		if (i) cout << " ";
	}
	cout << "\n";
	cout << cnt << "\n";
	for (int i = 0; i < n; i++) cout << A[i] << "\n";

	return 0;
}

Measured memory_bytes: 6972
def main():
  n = int(input())
  s = input()
  memo = []
  for i in range(10):
    for j in range(10):
      for k in range(10):
        memo.append(str(i) + str(j) + str(k))
  ans = 0
  for i in memo:
    x = 0
    for j in range(n):
      if i[x] == s[j]:
        x += 1
        if x == 3:
          ans += 1
          break

  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[22][22];
long long dp[(1<<22)];
int mod = 1000000007;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>arr[i][j];
		}
	}
	dp[0] = 1;
	for(int i=1;i<(1<<n);i++){
		int num = 0;
		for(int j=0;j<n;j++){
			if((i&(1<<j)) > 0)num++;
		}
		for(int j=0;j<n;j++){
			if((i&(1<<j)) == 0)continue;
			if(arr[j][num-1] == 0)continue;
			int mask = i - (1<<j);
			dp[i] = (dp[i] + dp[mask])%mod;
		}
	}
	cout<<dp[(1<<n)-1]<<endl;

}


Measured memory_bytes: 18688
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String args[]) throws Exception {
 
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();
        Arrays.sort(s);
 
        char[] t = sc.nextLine().toCharArray();
        Arrays.sort(t);
 
        int result = new String(s).compareTo(new StringBuilder(new String(t)).reverse().toString());
        System.out.println(result < 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000
#define INF 100000000000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);

int main(){
  int n;
  cin >> n;
  vint A(n);
  vint ans(n);
  int key = 0;
  rep(i,n) cin >> A[i];
  if(n % 2 == 0){
    for(int i = n-1;i>=1;i-=2){
      ans[key] = A[i];
      key++;
    }
    for(int i = 0;i<n-1;i+=2){
      ans[key] = A[i];
      key++;
    }
  }
  else{
    for(int i = n-1;i>=0;i-=2){
      ans[key] = A[i];
      key++;
    }
    for(int i = 1;i<=n-1;i+=2){
      ans[key] = A[i];
      key++;
    }
  }
  rep(i,n) cout << ans[i] << " ";
}

Measured memory_bytes: 3840
#include <cmath>
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    double ans = 0;
    scanf("%d %d", &n, &k);

    for(int i=1; i<=n; i++)
    {
        if(k < i)
        {
            ans = ans + (n-k);
            break;
        }
        double p = ceil(log2(double(k)/double(i)));
        ans += pow(0.5, p);
    }
    ans /= n;

    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=n-1;i>0;i--)
    {
        if(a[i]<a[i-1])
        {
            a[i-1]-=1;
            if(a[i]<a[i-1])
            {
                cout<<"No";
                return 0;
            }

        }
    }

    cout<<"Yes";
    return 0;

}


Measured memory_bytes: 640
N, M = map(int, input().split())
A = list(map(int, input().split()))

flg = False
A.sort(reverse=True)
for i in range(M):
    if sum(A) / 4 / M <= A[i]:
        flg = True
    else:
        flg = False

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
long long a,b,cm;
long long cmmmc(long long x,long long y)
{
    int r=x%y;
    long long p=x*y;
    while(r)
    {
        x=y;y=r;r=x%y;
    }
    p=p/y;
    return p;
}
int main()
{
    cin>>a>>b;
    cm=cmmmc(a,b);
    cout<<cm<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	string str;
	while(getline(cin, str))
	{
		string word;
		int n = str.size();
		for(int j = 0; j < 26; ++j)
		{
			word.clear();
			for(int i = 0; i < n; ++i)
			{
				if('a' <= str[i] && str[i] <= 'z')
				{
					word += (str[i] + j -'a') % 26 + 'a';
				}
				else
				{
					word += str[i];
				}
			}
			if(word.find("this") != -1 || word.find("the") != -1 || word.find("that") != -1)
			{
				cout << word << endl;
			}
		}
	}
}

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

Measured memory_bytes: 0
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}
bool is(string s1,string s2){
	if(sz(s1)!=sz(s2))return false;
	rep0(i,sz(s1)){
		if(s1[i]!='.'){
			if(s1[i]!=s2[i]){
				return false;
			}
		}
	}
	return true;
}
void solve()
{
 	 ll n,cnt=0,i=1;cin>>n;
 	 while(n>0){
 	 	n-=i;
 	 	cnt++;
 	 	i++;
	  }
	  cout << cnt ;
}
int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";
		  solve();
	//}
	
	return 0;
}

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

int d, dp[10004][102][3];
string n;
const int mod = 1e9 + 7;

int solve(int i, int cur, int small)
{
	  if (i == n.size())
	      return small > 1 && cur == 0? -1: 0;
	  if (dp[i][cur][small] != -1)
	      return dp[i][cur][small];
	  int ans = 0;
	  for (int j = 0 + (i == 0); j < 10; j++)
	  {
	      int sum = (j + cur) % d, newsmall = small, num = n[i] - '0';
	      if (small == 1)
	      {
	      	  if (j > num)
	      	      newsmall = 2;
	      	  else
	      	      newsmall = j == num? 1: 0;
	      }
	      ans = (ans + solve(i + 1, sum, newsmall) + (sum == 0)) % mod;
	  }
	  return dp[i][cur][small] = ans;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n >> d;
    cout << solve(0, 0, 1);
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>  
using namespace std;  
int main() {  
	long long a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c){
		if(a<=c)
			cout<<0<<" "<<a+b-c;
		else
			cout<<a-c<<" "<<b;
	}
		
	else
		cout<<0<<" "<<0;
    return 0;  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P){return os << "(" << P.first << "," << P.second << ")";}
#ifndef ONLINE_JUDGE
#define TRACE
#endif

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << endl; }
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...) 1
#endif
#define mp make_pair
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define I insert
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
const int N = 1e5+5;
ll h[N], dp[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<setprecision(25);
    ll n,k; cin>>n>>k;
    for(ll i=0;i<n;i++) cin>>h[i];
	dp[1] = abs(h[1]-h[0]);
	for(ll i=2;i<n;i++){
		dp[i] = 1e12;
		for(ll j=i-1;j >= max(0ll,i-k);j--) dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
		// trace(dp[i],i);
	}
	cout<<dp[n-1];
}

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

using namespace std;

int in[100005], dp[100005];
vector <int> edge[100005];

int main() {
    int n, m;

    scanf("%d%d", &n, &m);

    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        edge[x].push_back(y);
        in[y]++;
    }

    queue <int> que;

    for (int i = 1; i <= n; i++) {
        if (in[i] == 0) que.push(i);
    }

    int res = 0;

    while (que.size()) {
        int cur = que.front();
        que.pop();

        for (int i = 0; i < edge[cur].size(); i++) {
            int to = edge[cur][i];
            dp[to] = max(dp[to], dp[cur] + 1);
            in[to]--;
            if (in[to] == 0) que.push(to);
        }

        res = max(res, dp[cur]);
    }

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


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=4e3+3;
const ll mod=1e2+7;
vi a(MAX);
ll dp[MAX][MAX];
ll fun(ll i,ll j)
{
    if(i>j)
        return 0;
        if(dp[i][j]!=-1)
            return dp[i][j];
            ll x,y;
    x=a[i]+min(fun(i+2,j),fun(i+1,j-1));
    y=a[j]+min(fun(i+1,j-1),fun(i,j-2));
    dp[i][j]=max(x,y);
    return dp[i][j];

}
int main()
{
   FASTIO
   int t=1;
   //cin>>t;
   while(t--)
  {
        ll n,c;cin>>n;
        ll sum=0;
        rep(i,0,n)
        {
            cin>>a[i];
            sum+=a[i];
        }
        memset(dp,-1,sizeof(dp));
        ll ans=fun(0,n-1);
        ans=2*ans-sum;
        cout<<ans;
   }
 return 0;
}


Measured memory_bytes: 125568
#include<stdio.h>
#include<math.h>
int main(){
  int n,a[10000],cnt=0,i,j,k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    k=0;
    if(a[i]==2){
      cnt+=1;
      continue;
    }
    if(a[i]%2==0){continue;}
    j=3;
    while(j<=sqrt((double)a[i])){
      if(a[i]%j==0){
	k=1;
	break;}
      j=j+2;}
    if(k==0){
      cnt+=1;}
    
  }
   printf("%d\n",cnt);

  return 0;
}

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

int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if (S == U){
    cout << A-1 << ' ' << B << endl;
  }
  else if (T == U){
    cout << A << ' ' <<B-1 << endl;
  }
  else{
    cout << A << ' ' <<B << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int maxn=1e6+10;

int main()
{
	int n,k,s[55],a[110][2],cnt;
	while(~scanf("%d",&n))
	{
		int m=-1,pos=0;
		cnt=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&s[i]);
			if(abs(s[i])>m)
			{
				m=abs(s[i]);
				pos=i;
			}
		}
		int cnt=0;
		if(m==0)
		printf("0\n");
		else
		{
			for(int i=1;i<=n;i++)
			{
				s[i]+=s[pos];
				a[cnt][0]=pos;
				a[cnt][1]=i;
				cnt++;
			}
			if(s[pos]>0)
			{
				for(int i=2;i<=n;i++)
				{
					s[i]+=s[i-1];
					a[cnt][0]=i-1;
					a[cnt][1]=i;
					cnt++;
				}
			}
			else
			{
				for(int i=n;i>=2;i--)
				{
					s[i-1]+=s[i];
					a[cnt][0]=i;
					a[cnt][1]=i-1;
					cnt++;
				}
			}
			printf("%d\n",cnt);
			for(int i=0;i<cnt;i++)
			printf("%d %d\n",a[i][0],a[i][1]);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 100;
int dp[max_n][max_n];
int n,m;
int main(){
  ll x; cin >>x;
  ll k = x/11;
  ll cnt = 0;
  cnt += 2 * k;
  x -= 11 *k;
  if(x>0){
    cnt += x/7 +1;
  }
  cout << cnt << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

int main(){
    
    int n;
    cin >> n;
    V<ll> a(n);
    rep(i,n) cin >> a[i];

    V<ll> sums(n+1);
    rep(i,n) {
        sums[i+1] = sums[i] + a[i];
        sums[i+1] %= mod;
    }

    int ans = 0;
    rep(i,n) {
        ll tmp = sums[i] * a[i] % mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6424
import sys
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j, n in enumerate(A[:-1]):
        if n <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

_ = int(input())
nums = list(map(int, input().split(" ")))
p = partition(nums, 0, len(nums)-1)
nums[p] = "[{}]".format(nums[p])
sys.stdout.write(str(nums[0]))
for n in nums[1:]:
    sys.stdout.write(" {}".format(n))
sys.stdout.write("\n")


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

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

    for (char & i : s) i = 'x';
    print(s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
#define def infl
template<class V, int NV> struct SegTree { //[l,r)
	V comp(V& l, V& r) { return min(l, r); };

	vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
	V get(int x, int y, int l = 0, int r = NV, int k = 1) {
		if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
		auto a = get(x, y, l, (l + r) / 2, k * 2);
		auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
		return comp(a, b);
	}
	void update(int i, V v) {
		i += NV; val[i] = v;
		while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
	}
	void add(int i, V v) { update(i, val[i + NV] + v); }
	V operator[](int x) { return get(x, x + 1); }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













int N, M;
vector<pair<int, int>> Q[101010];
SegTree<ll, 1 << 17> st;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int l, r, c; cin >> l >> r >> c;
		Q[r].push_back({ l, c });
	}

	st.update(1, 0);
	rep(r, 1, N + 1) {
		fore(p, Q[r]) {
			int l = p.first;
			int c = p.second;
			st.update(r, min(st[r], st.get(l, r) + c));
		}
	}
	ll ans = st[N];
	if (ans == infl) ans = -1;
	cout << ans << endl;
}



Measured memory_bytes: 7680
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());

		String[] temp = sc.nextLine().split(" ");
		int[] list = new int[n];
		int count = 0;
		int ans = 0;

		for(int i = 0; i < n; i ++) {

			list[i] = Integer.parseInt(temp[i]);

		}

		for(int i = 0; i < n; i ++) {

			int j = i;

				while(j + 1 < n && list[j] >= list[j + 1]) {

					count++;
					j++;

				}

			ans = Math.max(count, ans);
			count = 0;
			i = j;
			
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 46852
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

class Combination
  def initialize(n, mod)
    @mod = mod
    @fac, @finv, @inv = Array.new(3) { [] }
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    i = 2
    while i <= n
      @fac[i] = @fac[i - 1] * i % @mod
      @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * @inv[i] % @mod
      i += 1
    end
  end

  def nCk(n, k)
    return 0 if (n < k) || (n < 0 || k < 0)

    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

N, M = get_ints
A = []
M.times do |i|
  A[i] = get_int
end
MOD = 10**9 + 7

ax = A + [N+1]

if ax.each_cons(2).any? { |a, b| b - a == 1}
  puts 0
else
  sum = 1
  cur = 0
  max_n = (ax.each_cons(2).map { |a, b| b - a - 2 } + [ax.first-1]).max
  combination = Combination.new(max_n, MOD)

  ax.each do |a|
    x = a - cur - 1
    if x <= 0
      cur = a + 1
      next
    end

    stock = 0
    i = x
    while i > x / 2
      stock += combination.nCk(i, x - (x-i) * 2)
      i -= 1
    end
    if x % 2 == 0
      stock += 1
    end
    sum = sum * stock % MOD
    cur = a + 1
  end
  puts sum
end


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

int a[200050];
int cnt[1000050];


int main(){

    int n;
    cin >> n;


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

    int ans = 0;
    for(int i=0;i<n;i++){
        bool val = true;
        for(int j=1;j*j<=a[i];j++){
            if(a[i]%j==0){
                int r = j;
                int s = a[i]/j;

                if((a[i]==r && cnt[r]>1) || (a[i]!=r && cnt[r]>0)){
                    val = false;
                    break;
                }
                if((a[i]==s && cnt[s]>1) || (a[i]!=s && cnt[s]>0)){
                    val = false;
                    break;
                }
                /*if((a[i]==r && cnt[r]>1) || (a[i]==s && cnt[s]>1) || (a[i]!=r && a[i]!=s && (cnt[r]>0 || cnt[s]>0))){
                    val =  false;
                    break;
                }*/
            }
        }
        if(val)
            ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 8096
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip> 
using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vll X;
vll Y;

ll ltmp;
string stmp;
double dtmp;

int main(){

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


    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        X.push_back(ltmp);
        cin >> ltmp;
        Y.push_back(ltmp);
    }    

    double sum = 0;
    double cnt = 0;
    double NN;
    NN = 1;
    ltmp = N;
    while(ltmp>0){
        NN = NN * N ;
        ltmp--;
    }

    ll basecnt = NN / (N-1);
    rep(ni,N){
        rep(nii,N){
            if(ni!=nii){
                double d = pow(X[ni]-X[nii],2.0)+pow(Y[ni]-Y[nii],2.0);
                d = pow(d,0.5);
                sum += d;
                cnt += 1;
            }
        }
    }
    cout << std::fixed << std::setprecision(15) << sum/cnt*(N-1) << endl;

}

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

    ll dp[3][110] = {0};
    dp[0][0] = a[0][0];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            if(i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[i][j]);
            if(j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1] + a[i][j]);
            //cout << dp[i][j] << " " << i << " " << j << endl;
        }
    }
    cout << dp[1][n - 1] << endl;
}   

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

int main() {
  int long long a = 2;
  int long long b = 1;
  int long long c = 1;
  int long long N; cin >> N;
  for( int i = 1; i < N; i++ ) {
    c = b;
    b += a;
    a = c;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double theta;
	if(x>=a*b/2*a){
		theta = atan((a*b*a-x)*2/a/a/a);
		//a*b*a - x = a*a*a*tan(theta)/2;
	}else{
		theta = atan(x/(b*a*b)*2) - M_PI/2;
		//x = b*a*b*tan(90-theta)/2;
	}
	printf("%.8f",abs(theta*360/(2*M_PI)));
	return 0;
}


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

int main() {
  vector<pair<double, double>> p;
  double price;
  rep(i, 4) {
    cin >> price;
    double volume = 0.25 * (1 << i);
    p.emplace_back(price / volume, volume);
  }
  sort(p.begin(), p.end());
  // rep(i, 4) cerr << p[i].first << ' ' << p[i].second << endl;

  double n;
  cin >> n;
  ll total = 0;
  rep(i, 4) {
    ll price = p[i].first * p[i].second;
    ll num = n / p[i].second;
    total += price * num;
    n -= p[i].second * num;
    // cerr << n << endl;
    if (n == 0) break;
  }
  cout << total << endl;
}


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

lst = [0] * (N + 1)
def calc(N):
    if lst[N] != 0:
        return lst[N]
    if N == 0:
        lst[N] = 2
        return 2
    if N == 1:
        lst[N] = 1
        return 1
    ans = calc(N-1) + calc(N-2)
    lst[N] = ans
    return ans

print (calc(N))

Measured memory_bytes: 3060
#include<string>
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(all(c)),c.end())
#define pb push_back
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int h,w;
vector<char> c;
map<char,PP> mp;
bool ret(vector<string> s,int bit,int now){
	PP p=mp[c[now]];
	for(int i=p.first.first;i<=p.first.second;i++){
		for(int j=p.second.first;j<=p.second.second;j++){
			if(s[i][j]==c[now]||s[i][j]=='*'){
				s[i][j]='*';
			}else{
				return false;
			}
		}
	}
	if(bit==(1<<c.size())-1)
		return true;
	
	for(int i=0;i<c.size();i++){
		if(!((1<<i)&bit)&&ret(s,bit|(1<<i),i))
		return true;
	}
	return false;
	
}
int main(){
	int n;
	cin>>n;
	while(n--){
		cin>>h>>w;
		vector<string> s(h);
		c.clear();
		for(int i=0;i<h;i++){
			cin>>s[i];
			for(int j=0;j<w;j++){
				if(find(all(c),s[i][j])==c.end()){
					c.pb(s[i][j]);
					mp[s[i][j]]=PP(P(i,i),P(j,j));
				}else{
					mp[s[i][j]]=PP(P(min(i,mp[s[i][j]].first.first),max(i,mp[s[i][j]].first.second)),P(min(j,mp[s[i][j]].second.first),max(j,mp[s[i][j]].second.second)));
				}
			}
		}
		sort(all(c));
		bool flag=false;
		for(int i=0;i<c.size();i++){
			if(ret(s,1<<i,i)){
				cout<<"SAFE"<<endl;
				flag=true;
				break;
			}
		}
		if(!flag)
		cout<<"SUSPICIOUS"<<endl;
		
	}
	return 0;
}

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

int main() {
	char str[1000000];
	int flag = 0;
	int count = 0;
	int len_str;
	char pre_str[1000000], post_str[1000000];

	scanf("%s", str);

	int i;

	len_str = strlen(str);

	while (flag == 0 && len_str > 1) {
		count = 0;
		len_str--;
		if (len_str % 2 == 0)
			for (i = 0; i <= (len_str / 2 - 1); i++) {
				if(str[i] == str[len_str / 2 + i]) {
					flag = 1;
					count++;
				} else {
					flag = 0;
					break;
				}
			}
	}

	if (flag == 1) {
		printf("%d\n", count * 2);
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;
}


Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int,input().split()))
l = []
r = []
for i in range(0,n//2):
    l.append(v[2*i])
    r.append(v[2*i+1])
       

lc = collections.Counter(l).most_common()
rc = collections.Counter(r).most_common()

if lc[0][0] == rc[0][0]:
    if len(lc)==1:
        print(n//2)
    else:
        print(n-max(lc[0][1]+rc[1][1],lc[1][1]+rc[0][1]))
else:
    print(n-lc[0][1]-rc[0][1])

Measured memory_bytes: 21084
#include<iostream>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int xmin = 0, xmax = W, ymin = 0, ymax = H;
  REP(i, 0, N) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      xmin = max(xmin, x);
    } else if (a == 2) {
      xmax = min(xmax, x);
    } else if (a == 3) {
      ymin = max(ymin, y);
    } else {
      ymax = min(ymax, y);
    }
  }
  int ans = 0;
  if (xmin < xmax && ymin < ymax) ans = (xmax - xmin) * (ymax - ymin);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long lint;

using namespace std;
lint N;


int main()
{

	cin >> N;
	vector<int> yen;
	vector<double> btc;
	vector<bool> u(N); // true: jpy, false: btc
	string tmp_v;
	string tmp;

	double ans = 0;
	rep(i,N) {
		cin >> tmp_v >> tmp;
		if (tmp[0] == 'J') {
			yen.push_back(stoi(tmp_v));
	

		}
		else {
			btc.push_back(stod(tmp_v));

	}
	}

	for (auto i : yen) {
		ans += i;
	}
	for (auto i : btc) {
		ans += i*(380000.0);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
// #include<bits/stdc++.h>
// #define lli long long int
// #define MOD 1000000007
// #define KING 1000000002
// #define queen 1000002
// #define fi first
// #define se second
// #define se second
// #define lsb(i) (i & -i)
// #define nl cout<<'\n'
// #define TEST cout<<"TEST",nl
// #define pr pair<lli,lli>
// #define pb push_back
// #define eb emplace_back
// #define mp make_pair
// #define vi vector<lli>
// #define vpi vector<pr> 
// #define P pair<lli,pr>
// #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
// #define NA(i,s,n) for(lli i=s;i<n;i++)
// using namespace std;

// void solve(){
//     lli n; cin>>n;
//     vi a(n+1), b(n+1, 0), c(n+1, 0);
//     set<lli> s1, s2;
//     NA(i,1,n+1) {
//         cin>>a[i];
//         s1.insert(a[i]);
//         if(*(s1.rbegin()) == i && s1.size()==i) b[i] = 1;
//     }
//     for(lli i=n; i>0; --i){
//         s2.insert(a[i]); 
//         if(*(s2.rbegin()) == (n-i+1) && s2.size()==(n-i+1)) c[i]=1;
//     }
//     lli res = 0; vi ans;
//     NA(i,1,n) if(b[i] && b[i]==c[i+1]) ++res, ans.pb(i);
//     cout<<res; nl;
//     for(lli i:ans) cout<<i<<' '<<n-i<<'\n';
//     return; 
// }
// int main(){
//     fastIO;
//     lli t = 1; cin>>t; 
//     NA(i,0,t) {
//         // cout<<"Case #"<<(i+1)<<": ";
//         solve();
//     }
//     return 0;
// }


#include<bits/stdc++.h>
#define NA(i,s,n) for(int i=s; i<n; ++i)
#define lli long long int
using namespace std;

int main(){

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

    lli x,k,ans; cin>>x>>k;
    if(k>x) cout<<min(x, k-x)<<'\n';
    else if(k==x) cout<<0<<'\n';
    else {
        lli p = x / k;
        x -= (p*k);
        cout<<min(x, k-x)<<'\n';
    }
    return 0;
}

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


int main() {
    int N, A, B;
    while (cin >> N >> A >> B) {
        int num[3] = {0};
        for (int i = 0; i < N; ++i) {
            int p; cin >> p;
            if (p <= A) num[0]++;
            else if (p <= B) num[1]++;
            else num[2]++;
        }
        cout << min(num[0], min(num[1], num[2])) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll n;
    cin>>n;
    n--;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=n/i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(void)
{
    int b;
    int a[4];
    char c[4];
    gets(c);
    a[0]=c[0]-'0';
    a[1]=c[1]-'0';
    a[2]=c[2]-'0';
    a[3]=c[3]-'0';
    if(a[0]+a[1]+a[2]+a[3]==7)
        printf("%d+%d+%d+%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]+a[1]+a[2]-a[3]==7)
        printf("%d+%d+%d-%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]+a[1]-a[2]+a[3]==7)
        printf("%d+%d-%d+%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]+a[1]-a[2]-a[3]==7)
        printf("%d+%d-%d-%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]-a[1]+a[2]+a[3]==7)
        printf("%d-%d+%d+%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]-a[1]+a[2]-a[3]==7)
        printf("%d-%d+%d-%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]-a[1]-a[2]+a[3]==7)
        printf("%d-%d-%d+%d=7\n",a[0],a[1],a[2],a[3],a[4]);
    else if(a[0]-a[1]-a[2]-a[3]==7)
        printf("%d-%d-%d-%d=7\n",a[0],a[1],a[2],a[3],a[4]);
}




Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> adjlist[n+1];
	ll x;
	for(ll i=1; i<n; i++){
		cin >> x;
		--x;
		adjlist[x].emplace_back(i);
	}
	for(ll i=0; i<n ;i++)
		cout << adjlist[i].size() << "\n";
	return 0;
}

Measured memory_bytes: 14588
#pragma GCC target (*sse4.2*)
#pragma GCC optimization ("O3")
#pragma GCC optimize ("Ofast")
#define mod 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define S second
#define debug(x) cout<<("#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define INF (1<<31)-1

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef long long ll;
typedef unsigned long long ull;
typedef long double d64;


int main(){
fast
read(n);
if(n%1000==0)cout<<0;
else{for(int i=1000;i<=10000;i+=1000){
    if(i>n){
        cout<<i-n;
        i+=10001;
    }
}
}


return 0;
}


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

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  int as=0;
  for(int i=0;i<max(a,b);i++){
    as+=min(a,b)*pow(10,i);
  }
  cout << as << endl;
}
  
  

Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(N);
  for (size_t i=0; i<N; ++i)
    scanf("%d", &a[i]);

  std::sort(a.begin(), a.end());
  std::vector<intmax_t> s(N+1);
  for (size_t i=1; i<=N; ++i)
    s[i] = s[i-1] + a[i-1];

  size_t t=0;
  for (size_t i=N; i--;) {
    if (2*s[i] < a[i]) {
      t = i;
      break;
    }
  }

  printf("%zu\n", N-t);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n,k;cin>>n>>k;
    vl sum(n+2,0);
    rep(i,n+1){
        if(i==0)continue;
        sum[i]=sum[i-1]+(ll)i;
    }
    ll ans=0;
    rep2(i,k,n+1){
        ans+=(sum[n]-sum[n-i])-(sum[i-1])+1;
        ans%=mod;
    }
    ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), s(n), red(n);
  rep(i, n) cin >> a[i];
  s[0] = a[0];
  red[0] = a[0] - 1;
  REP(i, 1, n) {
    s[i] = s[i - 1] + a[i];
    red[i] = red[i - 1] + a[i] - 1;
  }

  ll sum = s[n - 1];
  // cerr << sum << endl;
  vl cnt(n - 1, 0);
  rep(i, n - 1) {
    ll tmp = sum;
    ll cur = s[i];

    if (cur < sum - cur) {
      cnt[i] = (sum - 2 * cur);
    } else if (cur > sum - cur) {
      cnt[i] = 2 * cur - sum;
    } else {
      cnt[i] = 0;
    }
    // cerr << cnt[i] << " ";
  }
  // cerr << endl;
  ll ans = 1LL << 60;
  rep(i, n - 1) {
    if (cnt[i] >= 0) {
      ans = min(ans, cnt[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int p[1001];
int main(void){
    int N,K;
    cin >> N >> K;
    for(int i=0;i<N;i++)cin >> p[i];
    sort(p,p+N);
    int ans=0;
    for(int i=0;i<K;i++){
        ans += p[i];
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 3612
#include<stdio.h>
int main(){
    int array[4][13]={0},
        i,
        x,
        n,
        j;
    char card;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf(" %c %d",&card, &x);
        if(card=='S'){
            array[0][x-1]=1;
        }
        if(card=='H'){
            array[1][x-1]=1;
        }
        if(card=='C'){
            array[2][x-1]=1;
        }
        if(card=='D'){
            array[3][x-1]=1;            
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(i == 0 && array[0][j]==0)printf("S %d\n",j+1);
            if(i == 1 && array[1][j]==0)printf("H %d\n",j+1);
            if(i == 2 && array[2][j]==0)printf("C %d\n",j+1);
            if(i == 3 && array[3][j]==0)printf("D %d\n",j+1);
        }
    }
    return 0;
}

Measured memory_bytes: 1800
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int N;
	int Min = INT_MAX;
	int Max = INT_MIN;

	cin >> N;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		Min = min(a,Min);
		Max = max(a,Max);
	}

	printf("%d\n",Max-Min);

	return 0;
}

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

int main(){
	// a( n + 1 ) = a( n ) * 2
	// a( n + 1 ) = a( n ) / 3
	double input;
	while ( cin >> input ){
		double sum = input;
		for ( int i = 0; i < 9; ++i ){
			if( !( i % 2 ) ) input *= 2;
			else input /= 3;
			sum += input;
		}
		cout << setprecision( 8 ) << setiosflags( ios::fixed );
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
    int re=100001;
    int n;
    cin >> n;
    if (n%2==1) {cout << 0 << endl;return 0;}
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    a.push_back(0);
    int t=0,ans=0,k=0,q=0;
    for (int i=1;i<re;i++){
        while (true){
            if (i==a.at(k)){
                t++;k++;
                if (q==1) q=0;
                if (k==n/2) q=1;
                continue;
            }
            break;
        }
        if (q==1) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
    long N, A, B;
    cin >> N >> A >> B;
    long X[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    long long minFatigueLevel = 0;
    for (int i = 0; i < N-1; i++) {
        minFatigueLevel += min((X[i+1]-X[i]) * A, B);
    }
    cout << minFatigueLevel << endl;
}


Measured memory_bytes: 4392
import sys
def main(N, K, A):
    for k in range(min(50, K)):
        C = [0] * (N + 1)
        for i in range(N):
            a = A[i]
            C[max(0, i - a)] += 1
            C[min(N, i + a + 1)] -= 1
        A[0] = C[0]
        for i in range(1, N):
            A[i] = A[i - 1] + C[i]
    return A

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    print(*main(N, K, A))


Measured memory_bytes: 171560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a % b == 0 ? 0 : 1);
    }
}

Measured memory_bytes: 23252
from statistics import median

A, B, C = [int(x) for x in input().split()]

low = min(A, B, C)
mid = median([A, B, C])
huge = max(A, B, C)

if huge % 2 == 0:
    print(0)
else:
    red = low*mid*(huge//2)
    blue = low*mid*(huge//2+1)

    print(blue-red)


Measured memory_bytes: 10788
//
//  main.cpp
//  AOJ
//
//  Created by 佐々木勇星 on 2018/09/29.
//  Copyright © 2018年 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

long long int Min, Max, sum, num;


int main(int argc, const char * argv[]) {

    
    cin >> num;
    
    vector<int> a(num);
    Min = 1000001;
    Max = -1000001;

    for(int i = 0; i < num; i++){
        cin >> a[i];
    
        
        sum = sum + a[i];
        if(a[i] < Min){
            Min = a[i];
        }
        if(a[i] > Max){
            Max = a[i];
        }
    }
    
    cout << Min << " " << Max << " " << sum << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scanner.nextInt();
        int B= scanner.nextInt();
        int C = scanner.nextInt();
        if(A == B && B == C){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21840
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let k: u32 = read();

    let mut abc = [a, b, c];
    abc.sort();
    println!("{}", abc[0] + abc[1] + abc[2] * 2i32.pow(k));
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

double heikinn(int a){
    int ans=0;
    for(int i=1;i<=a;i++){
        ans+=i;
    }
    double creat=0;
    creat=(double)ans/a;
    return creat;
}
int main(){
    int n,a,k;
    cin >> n >> k;
    vector<int> q(n);
    vector<double> an(n);
   for (int i=0;i<n;i++){
       cin >> q.at(i);
       an.at(i)=heikinn(q.at(i));
    }
    double ans=0;
    for(int i=0;i<k;i++){
      ans+=an.at(i);
    }
    double ma=ans;
    a=0;
    for(int i=k;i<n;i++){
        ans+=an.at(i);
        ans-=an.at(a);
        a++;
        ma=max(ma,ans);
    }

    cout << fixed << ma << endl;
}

Measured memory_bytes: 2560