akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,A[MAXN],B[MAXN];
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n)cin>>A[i]>>B[i];
	bool eq=1; ll ans=LLINF; ll sum=0;
	FOR(i,0,n){
		eq&=(A[i]==B[i]);
		sum+=A[i];
		if(A[i]>B[i])ans=min(ans,B[i]);
	}
	if(eq)cout<<0<<'\n';
	else cout<<sum-ans<<'\n';
}


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

const int MOD=1000000007;

int main() {
  int n,m; cin>>n>>m;
  vector<ll> x(n),y(m);
  rep(i, n) cin>>x[i];
  rep(i, m) cin>>y[i];

  ll X=0,Y=0;
  rep(i, n) {
    X+=x[i]*(2*i+1-n);
    X%=MOD;
  }
  rep(i, m) {
    Y+=y[i]*(2*i+1-m);
    Y%=MOD;
  }
  ll res=X*Y;
  res%=MOD;
  cout<<res<<endl;
}

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

int main()
{
    int N, ans = 0, cu_value = 0;
    string s;
    cin >> N >> s;
    REP(i, N)
    {
        if (s[i] == 'D') cu_value--;
        else cu_value++;
        if (ans < cu_value) ans = cu_value;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
gets
a = gets.split(" ").map(&:to_i)

count = 0
a.size.times do |x|
(a.size - 1).times do |i|
    if a[i] > a[i + 1] then
        a[i], a[i + 1] = a[i + 1], a[i]
        count += 1
    end
end
end

print a.join(" "), "\n"
print count, "\n"




Measured memory_bytes: 6860
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    long long int sum=0;
    for(int i=1;i<=N;i++){
        if(i%3!=0&&i%5!=0)
            sum+=i;
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
#include<math.h>
#define MOD 1001
#define MAX 10001
int fibo[MAX];
int p[MAX];
int getfibo(int n)
{
  if(n<1)return 1;
  if(fibo[n])return fibo[n];
  return fibo[n]=(getfibo(n-1)+getfibo(n-2))%MOD;
}
int root(int a){
  return p[a]<0?a:(p[a]=root(p[a]));
}
int find(int a,int b)
{
  return root(a)==root(b);
}
void merge(int a,int b)
{
  p[root(a)]=root(b);
}
int main(void)
{
  fibo[0]=1;fibo[1]=2;
  int a,d,i,j;
  while(scanf("%d%d",&a,&d)==2){
    memset(p,-1,sizeof(p));
    for(i=1;i<=a;i++){
      for(j=1;j<=a;j++){
        if(abs(getfibo(i)-getfibo(j))<d){
          if(!find(i,j))merge(i,j);
        }
      }
    }
    int b[MAX]={0},res,c=0;
    for(i=1;i<=a;i++){
      res=root(i);
      if(!b[res]){
        b[res]=1;c++;
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 496
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 300500;
const int mod = 1e9 + 7;
long long a[maxn], sum[70][2][maxn];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; ++i)
        cin >> a[i];
    for(int i = n - 1 ; i >= 0 ; --i)
        for(int j = 0 ; j < 61 ; ++j){
            sum[j][0][i] += sum[j][0][i + 1];
            sum[j][1][i] += sum[j][1][i + 1];
            if((1ll << j) & a[i]) sum[j][1][i]++;
            else sum[j][0][i]++; 
        }
    long long ans = 0;
    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < 61 ; ++j)
            if((1ll << j) & a[i]){
                ans += (sum[j][0][i] * ((1ll << j) % mod)) % mod;
                ans %= mod;
            }else{
                ans += (sum[j][1][i] * ((1ll << j) % mod)) % mod;
                ans %= mod;
            }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 290304
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        
        
        int[] dp = new int[100010];
        dp[0] = 0;
        for(int n = 1; n <= 100000; n++)
        {
            dp[n] = 100000;
            
            int power = 1;
            while(power <= n)
            {
                dp[n] = Math.Min(dp[n], 1 + dp[n - power]);
                power *= 6; 
            }
            
            power = 1;
            while(power <= n)
            {
                dp[n] = Math.Min(dp[n], 1 + dp[n - power]);
                power *= 9; 
            }
            
        }
        
        int N = int.Parse(Console.ReadLine());
        Console.WriteLine(dp[N]);
        
        
    }
}

Measured memory_bytes: 13124
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//--------------------------------------------------------------------------

#define MAX 1000

#define INF 111111111111
ll a[MAX][MAX];

void floyd() {
  FOR(k, 0, n) {
	FOR(i, 0, n) {
	  if (a[i][k] == INF) continue;
	  FOR(j, 0, n) {
		if (a[k][j] == INF) continue;
		a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	  }
	}
  }
}

int main(void) {
  ll x;
  vll r;
  cin >> n >> m >> x;

  FOR(i, 0, x) {
	cin >> temp;
	temp--;
	r.push_back(temp);
  }

  FOR(i, 0, n) {
	FOR(j, 0, n) {
	  i == j ? a[i][j] = 0 : a[i][j] = INF;
	}
  }

  ll ai, bi, c;
  FOR(i, 0, m) {
	cin >> ai >> bi >> c;
	ai--;
	bi--;
	a[ai][bi] = c;
	a[bi][ai] = c;
  }

  floyd();

  sort(ALL(r));

  ans = INF;

  do {
	sum = 0;
	FOR(i, 0, r.size() - 1) {
	  sum += a[r[i]][r[i + 1]];
	}
	ans = min(ans, sum);
  } while (next_permutation(ALL(r)));

  cout << ans << endl;

}

Measured memory_bytes: 1408
n = int(input())
h = list(map(int, input().split()))
def gov(n, h):
    ans = 1
    for i in range(1, n):
        cnt = 0
        for j in range(i):
            if h[j] == max(h[i], h[j]) and h[i] != h[j]:
                break
            cnt += 1
        if cnt == i:
            ans += 1
    return ans
print(gov(n, h))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>

namespace dyshizhendeJM
{
	const int N=3030,MOD=1000000007;
	inline void inc(int a,int &b){b+=a;if(b>=MOD)b-=MOD;}

	int f[N][N][2];
	int n,m;

	void dp()
	{
		for(int i=0;i<=n;i++)f[0][i][i==0]=1;

		for(int i=0;i<m;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=1;k++)
				{
					int v=f[i][j][k];
					if(!v)continue;
					
					if(j>0)
					{
						inc(v,f[i+1][j][k|((j-1)==0)]);
						inc(v,f[i+1][j-1][k|((j-1)==0)]);
					}
					if(j<n)
					{
						inc(v,f[i+1][j][k]);
						inc(v,f[i+1][j+1][k]);
					}
				}
	}
	void solve()
	{
		scanf("%d%d",&n,&m);
		dp();
		int ans=0;
		for(int i=0;i<=n;i++)
			inc(f[m][i][1],ans);
		printf("%d\n",ans);

	}
}

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


Measured memory_bytes: 71936
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,t[100010],a[100010],ans=1;
    ll ha[100010],ht[100010];
    bool htt[100010]={},haa[100010]={};
    cin>>n;
    rep(i,n){
        cin>>t[i];
    }
    rep(i,n){
        cin>>a[i];
    }
    ht[0]=t[0];htt[0]=1;
    ha[n-1]=a[n-1];haa[n-1]=1;
    rep2(i,1,n){
        if(t[i]>t[i-1]){
            ht[i]=t[i];
            htt[i]=1;
        }
        else{
            ht[i]=t[i];
        }
    }
    for(ll i=n-2;i>=0;i--){
        if(a[i]>a[i+1]){
            ha[i]=a[i];
            haa[i]=1;
        }
        else{
            ha[i]=a[i];
        }
    }
    rep(i,n){
        // printf("%lld,ht:%lld,htt:%d,ha:%lld,haa:%d\n",i,ht[i],htt[i],ha[i],haa[i]);
        if(haa[i]&&htt[i]&&ht[i]!=ha[i]){
            ans*=0;
        }
        else if(haa[i]&&!htt[i]){
            if(ht[i]<ha[i]) ans*=0;
        }
        else if(!haa[i]&&htt[i]){
            if(ht[i]>ha[i]) ans*=0;
        }
        else if(!haa[i]&&!htt[i]){
            ans*=min(ht[i],ha[i]);
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


int main()
{
    int N;
    cin >> N;
    string res = "APPROVED";

    REP(i,N)
    {
        int a;
        cin >> a;

        if(a % 2 == 0)
        {
            if(a % 3 == 0 || a % 5 == 0)
            {

            }
            else
            {
                res = "DENIED";
            }
            
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#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 a[3];

int main()
{
  cin>>a[0]>>a[1]>>a[2];
  sort(a, a+3);
  cout<<a[2]-a[0]<<endl;

  return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[100001];

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  vector<int> h;
  rep(i, n){
    int x;
    cin >> x;
    h.pb(x);
  }
  FOR(i, 1, n)dp[i] = linf;
  FOR(i, 1, n){
    FOR(j, 1, k + 1){
      if(i - j >= 0)dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1528
#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    string ans = "No";
    if (s < t) {
        ans = "Yes";
    }

    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
using System;

class Program
{
    static void Main()
    {
            int i = 0,c=0,x,y,z,count=0;
            int[] max = new int[256];
            int[] mon = new int[256];
            while (true)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split(' ');
                mon[c] = int.Parse(data[0]);
                max[c] = int.Parse(data[1]);
                if (mon[c] == 0 && max[c] == 0)
                {
                    break;
                }
                c++;//データ数
            }
            for (i=0;i<c;i++)
            {
                for (x = 1; x <= mon[i]; x++)
                {
                    for (y = x + 1; y <= mon[i]; y++)
                    {
                        for (z = y + 1; z <= mon[i]; z++)
                        {
                            if (x + y + z == max[i])
                            {
                                count++;
                            }
                        }
                    }
                }
                Console.WriteLine("{0}", count);
                count = 0;
            }
    }
}


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;
using std::bitset;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

struct Edge {
    int v, u, y;

    Edge(int v, int u, int y) : v(v), u(u), y(y) {}

    bool operator<(const Edge& other) const {
        return y < other.y;
    }
};

int n, m;
vector<Edge> edges;
int x[MAXN];

int comp[MAXN];
int64_t sum[MAXN];

int par[MAXN];
vector<int> g[MAXN];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        par[i] = i;
        sum[i] = x[i];
        comp[i] = i;
        g[i].push_back(i);
    }
    for (int i = 0; i < m; i++) {
        int v, u, y;
        cin >> v >> u >> y;
        edges.emplace_back(--v, --u, y);
    }

    sort(all(edges));

    for (auto& e : edges) {
        if (par[e.v] == par[e.u]) {
            continue;
        }

        vector<int>& a = g[par[e.v]].size() >= g[par[e.u]].size() ? g[par[e.v]] : g[par[e.u]];
        vector<int>& b = g[par[e.v]].size() >= g[par[e.u]].size() ? g[par[e.u]] : g[par[e.v]];
        sum[a[0]] += sum[b[0]];
        for (int v : b) {
            a.push_back(v);
            par[v] = a[0];
        }

        // cerr << e.v << ' ' << e.u << ' ' << e.y << ' ' << s << '\n';

        if (sum[a[0]] < e.y) {
            continue;
        }

        for (int i = (int) a.size() - 1; i >= 0; i--) {
            if (comp[a[i]] == comp[a[0]]) {
                break;
            }
            comp[a[i]] = comp[a[0]];
        }
    }

    memset(sum, 0, sizeof sum);
    for (int i = 0; i < n; i++) {
        sum[comp[i]] += x[i];
        // cerr << comp[i] << ' ';
    }
    // cerr << '\n';

    int ans = 0;
    for (auto& e : edges) {
        if (comp[e.v] == comp[e.u] && e.y <= sum[comp[e.v]]) {
            ans++;
        }
    }

    cout << m - ans << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}


Measured memory_bytes: 12148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int dp[101];

void solve() {
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    int cur = i;
    while (cur % 2 == 0) {
      if (dp[i]) {
        temp += dp[i];
        cur = 1;
      } else {
        temp++;
        cur /= 2;
      }
    }
    dp[i] = temp;
    if (dp[ans] < dp[i]) ans = i;
  }
  cout << ans << endl;
}

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

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back
#define mp make_pair

// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

void solve(){
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC"; 
}

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








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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;
const int maxN = 101;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(all(b));
	if (n % 2) cout << b[n / 2] - a[n / 2] + 1;
	else {
		double two = (double) (b[n / 2] + b[n / 2 - 1]) / 2;
		double one = (double)(a[n / 2] + a[n / 2 - 1]) / 2;
		int ans = (two - one) * 2 + 1;
		cout << ans; 
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define ll long long
#define NMAX 200010
using namespace std;
ll v[NMAX], n, k, nr, rez[NMAX], x, repet, calc;
map <ll, int> m;
int main()
{
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    x=v[1];
    while(m[x]==0 && k>0)
    {
        if(x==v[x])
        {
            cout<<x;
            return 0;
        }
        nr++;
        m[x]=nr;
        rez[nr]=x;
        x=v[x];
        k--;
    }
    if(k==0)
        cout<<rez[nr];
    else
    {
        repet=nr-m[x]+1;
        calc=(k-1)%repet;
        cout<<rez[calc+m[x]];
    }
    return 0;
}


Measured memory_bytes: 16420
import datetime

def main():
    S = input()
    
    year = int(S[0:4])
    month= int(S[5:7])
    day = int(S[8:10])
    diff = datetime.date(2019,4,30)-datetime.date(year,month, day)
    if diff.days >= 0:
        print('Heisei')
    else:
        print('TBD')

if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll h;
        cin >> h;
        if (h >= K) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 888
//Date of submission: 13-06-2020

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 5;

//------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    cout<<s.substr(0,3);
    return 0;
}

//------------------------------------------------------------------------------


Measured memory_bytes: 3576
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod009 = 1000000009;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, t[50], res;
string s[50], X;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i] >> t[i];
	}
	cin >> X;
	for (int i = 0; i < N; i++) {
		if (s[i] == X) {
			for (int j = i + 1; j < N; j++) {
				res += t[j];
			}
			cout << res << endl;
			return 0;
		}
	}
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

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

ll N, H;
VL a, b;

signed main() {
    cin >> N >> H;
    REP(i, N) {
        a.emplace_back(IN());
        b.emplace_back(IN());
    }
    sort(All(b));
    ll slash = *max_element(All(a));
    ll sum = 0, thr = b.end() - upper_bound(All(b), slash), cnt = 0;
    FORR(i, N - 1, N - 1 - thr) {
        H -= b[i];
        cnt++;
        if(H <= 0) eputs(cnt);
    }
    cout << cnt + H / slash + (H % slash ? 1 : 0) << "\n";
}

Measured memory_bytes: 2036
N = int(input())
tes_l = [[-1 for i in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(int(input())):
        target,TFflg = list(map(int,input().split()))
        tes_l[i][target-1] = TFflg 


ans = 0
flg = False
for k in range(2**N):
    tmpans = list(map(int,bin(k)[2:].zfill(N)))
    for i,eachtes in enumerate(tes_l):
        for j,tes in enumerate(eachtes):
            if(tmpans[i]==1):
                if(tes!=-1 and tmpans[j]!=tes):
                    flg = True
            """
            if(tes==0 and tmpans[i]==1):
                if(tmpans[j]==1):
                    continue
            elif(tes==1 and tmpans[i]==1):
                if(tmpans[j]==0):
                    continue
            """
    if(not flg):
        ans = max([sum(tmpans),ans])
    flg = False

print(ans)                


Measured memory_bytes: 43612
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=5e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll arr[MAXN];
int x=0;
void dfs(ll i,ll c)
{
    arr[++x]=i;
    if(c==10)return;
    for(ll j=max(ll(0),(i%10)-1);j<=min(ll(9),(i%10)+1);j++)dfs(i*10+j,c+1);
}
int main()
{
    for(int i=1;i<=9;i++)dfs(i,1);
    sort(arr,arr+x);
    ll k;cin>>k;
    cout<<arr[k]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e8
typedef long long ll;
using namespace std;

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


    string s;
    cin >> s;

    vector<int> dic[10];
    rep(i,s.size()) dic[s[i]-'0'].push_back(i);
    int ans = 0;
    rep(i,10) {
        if(dic[i].size()==0) continue;
        rep(j,10) {
            if(dic[j].size()==0) continue;
            rep(k,10) {
                if(dic[k].size()==0) continue;
                int fst = dic[i][0];
                if(dic[j][dic[j].size()-1]<=fst) continue;
                int snd = *upper_bound(ALL(dic[j]),fst);
                if(dic[k][dic[k].size()-1]<=snd) continue;
                ans++;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 512
program main 
 implicit  none
 integer :: n,k,i
 read *, n,k
  do i=0,100
   if (n>k**i.and.n<k**(i+1)) then
    write(*,'(i0)') i+1
    stop
   else if (n==k**i) then
    write(*,'(i0)') i+1
    stop
   end if
  end do 
end program main

Measured memory_bytes: 384
$%=1e9+7;
<>;
$_[$_]?($m=$n-$_[$_]):($_[$_]=++$n)for glob<>;
@A=1;push@A,$t=$t*$_%$%for++$t..++$u+$n;
$B[$#A]=$u=$u*$u%$%*($%-2>>$_&1?$t:1)%$%for reverse 0..30;
$B[$_-1]=$B[$_]*$_%$%for reverse 1..$#B;
sub nCr{($a,$b)=@_;$a>=$b&&$A[$a]*$B[$b]%$%*$B[$a-$b]%$%}
print+(nCr($n+1,$_)-nCr($n-$m-1,$_-1))%$%,$/for 1..$n+1


Measured memory_bytes: 27692
#include<stdio.h>

int main() {
	int A, B, C;
	int i = 1;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);

	if (A == 7)
		if (B == 5 && C == 5) {
			printf("YES");
			i = 0;
		}
	if (B == 7)
		if (A == 5 && C == 5) {
			printf("YES");
			i = 0;
		}
	if(C==7)
		if (B == 5 && A == 5) {
			printf("YES");
			i = 0;
		}
	if (i != 0) printf("NO");

	return 0;
}

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

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

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

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, k;
	string s;
	cin >> n >> k >> s;

	vii seg;
	int start = -1;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') {
			if (start < 0) start = i;
		}
		else {
			if (start >= 0) {
				seg.emplace_back(start, i);
				start = -1;
			}
		}
	}
	if (start >= 0) seg.emplace_back(start, n);
	//for (ii x : seg) printf("%d %d\n", x.first, x.second);

	int m = seg.size();
	if (m == 0) {
		printf("%d\n", n);
		return 0;
	}

	int answer = 0;
	for (int i = 0; i < m; i++) {
		int a = (i == 0) ? 0 : seg[i-1].second;
		int b = (i + k >= m) ? n : seg[i+k].first;
		answer = max(answer, b - a);
		if (i + k >= m) break;
	}
	printf("%d\n", answer);
}


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

using namespace std;

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

    map <string, int> week;

    week["SUN"] = 7;
    week["MON"] = 6;
    week["TUE"] = 5;
    week["WED"] = 4;
    week["THU"] = 3;
    week["FRI"] = 2;
    week["SAT"] = 1;

    cout << week[day] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).rbegin(),(v).rend()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010

// (n-1)/m=k

ll h(ll n,ll k){
	if(k==1)return 0;
	if(n==1 or n<k)return n;
	while(n%k==0)n/=k;
	return n-k*(n/k);
}
ll hh(ll n){
	set<ll>s;
	ll x=n;
	for(ll i=1;i*i<=x;++i){
		if(x%i==0){
			if(h(x,i)==1)s.insert(i);
			if(i*i!=n)if(h(x,x/i)==1)s.insert(x/i);
		}
	}
	x=n-1;
	for(ll i=1;i*i<=x;++i){
		if(x%i==0){
			if(h(x+1,i)==1)s.insert(i);
			if(i*i!=n)if(h(x+1,x/i)==1)s.insert(x/i);
		}
	}
	return sz(s);
}
int main(){
	IOS;
	tihs;

	ll n;cin>>n;
	cout<<hh(n);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int K,N,A[1<<20],i,x,ans,T;main(){for(scanf("%d%d",&T,&K),N=T;T--;)scanf("%d",&x),A[x]++;std::sort(A+1,A+N+1);for(i=1;i<=N-K;i++)ans+=A[i];printf("%d\n",ans);}

Measured memory_bytes: 1024
fn main(){
  loop {
    let xy: Vec<usize> = read_vec();
    let x = xy[0];
    let y = xy[1];

    if x == 0 && y == 0 { break; }

    let mut fv: Vec<Vec<usize>> = Vec::new();

    for _ in 0 .. y {
      fv.push(read_vec());
    }
    
    let mut dp: Vec<Vec<usize>> = vec![vec![0;x];y];

    for i in 0 .. x {
      if fv[0][i] != 1 { dp[0][i] = 1; }
    }

    for i in 1 .. y {
      for j in 0 .. x {
        if fv[i][j] == 0 {
          if j > 0 && fv[i-1][j-1] == 0 {
            dp[i][j] += dp[i-1][j-1];
          }
          if fv[i-1][j] == 0 {
            dp[i][j] += dp[i-1][j];
          }
          if j + 1 < x && fv[i-1][j+1] == 0 {
            dp[i][j] += dp[i-1][j+1];
          }
          if i > 1 && fv[i-2][j] == 2 {
            dp[i][j] += dp[i-2][j];
          }
        } else if fv[i][j] == 2 {
          if fv[i-1][j] == 0 {
            dp[i][j] += dp[i-1][j];
          }
          if i > 1 && fv[i-2][j] == 2 {
            dp[i][j] += dp[i-2][j];
          }
        }
      }
    }
    
    let mut ans: usize = 0;

    for i in 0 .. x {
      ans += dp[y-1][i];
    }

    if y > 1 {
      for i in 0 .. x {
        if fv[y-2][i] == 2 {
          ans += dp[y-2][i];
        }
      }
    }

    println!("{}", ans);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int k;
    int a;
    int h=1;
    cin >> k;
    for(int i=0;i<n-1;i++){
        cin>>a;
        if(k<=a)h++;
        k=max(k,a);
    }
    cout << h << endl;
    return 0;
}

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

vector<char> s;
int sx, sy, tx, ty;

int main(){
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    //Start
    for(int Px = sx + 1; Px <= tx; Px++){
        printf("R");
        s.push_back('L');
    }
    for(int Py = sy + 1; Py <= ty; Py++){
        printf("U");
        s.push_back('D');
    }
    for(int i = 0; i < s.size(); i++) printf("%c",s[i]);

    //Start second
    s.clear();
    sx--; printf("L"); s.push_back('R');
    for(int Py = sy; Py <= ty; Py++){
        printf("U");
        s.push_back('D');
    }
    for(int Px = sx + 1; Px <= tx; Px++){
        printf("R");
        s.push_back('L');
    }
    printf("D"); s.push_back('U');
    for(int i = 0; i < s.size(); i++) printf("%c",s[i]);
    return 0;
}



Measured memory_bytes: 384
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	fmt.Fprintln(writer, s[0:3])
}


Measured memory_bytes: 1796
x, k, d = [list(map(int, s.split())) for s in open(0)][0]
x = abs(x)

ans = x
if x > k * d:
    ans = x - k * d
else:
    m = x//d
    if m%2 == k%2:
        ans = x - m * d
    else:
        ans = (m+1) * d - x
print(ans)

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

#define ll long long
#define ull unsigned long long

using namespace std;

ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return(b);
  } else {
    return(gcd(b, a % b));
  }
}

int main() {
  ll A, B;
  cin >> A >> B;

  map<ll, ll> divA;
  for (ll ii = 1; ii*ii <= A; ++ii){
      if (A % ii == 0){
          divA[ii] = 1;
          if (A / ii != ii){
            divA[A/ii] = 1;
          }
      }
  }

  map<ll, ll> divB;
  for (ll ii = 1; ii*ii <= B; ++ii){
      if (B % ii == 0){
          divB[ii] = 1;
          if (B/ii != ii){
            divB[B/ii] = 1;
          }
      }
  }

  vector <ll> ans;
  for(auto itr = divA.begin(); itr != divA.end(); ++itr) {
    if (divB[itr->first] != 0){
      bool ok = true;
      for (int jj = 0; jj < ans.size(); ++jj){
        ll val = ans[jj];
        if (gcd(val, itr->first) > 1){
          ok = false;
          break;
        }
      }
      if (ok){
        ans.push_back(itr->first);
      }
    }
  }


	cout << ans.size() << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL; /* 10^9 + 7 */
uint64_t dp[100005][13];

int check(int a, vector<int> &b, int k)
{
    int i = k;
    int sum = 0;
    while (i < b.size()) {
        sum += b[i];
        i += k;
    }
    return (sum % 2 == a);
}

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

    int m = 0;
    vector<int> b(n + 1);
    for (int i = n; i > 0; i--) {
        b[i] = 0;
        if (check(a[i], b, i))
            continue;
        b[i] = 1;
        if (check(a[i], b, i))
            continue;
        cout << "-1" << endl;
        return 0;
    }

    for (int i = 1; i <= n; i++) {
        m += b[i];
    }

    cout << m << endl;
    for (int i = 1; i <= n; i++) {
        if (b[i])
            cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	long long int N;
	cin >> N;
	vector<long long int>A(N);
	int x;
	for (x = 0; x < N; x++) {
		cin >> A[x];
	}
	sort(A.begin(), A.end());
	long long int sum,ans;
	sum = A[0];
	ans = N;
	int i, j, k, l, m;
	for (i = 1; i < N; i++) {
		if (sum * 2 >= A[i]) {
			sum += A[i];
		}
		else {
			ans = N - i;
			sum += A[i];
		
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
using namespace std;
int main()
{
	int w;
	cin>>w;
	string s;
	char a;
	int kg=0;
	set<string>cf;
	for (int i=0;i<w;i++)
	{
		cin>>s;
		if (i && s[0]!=a)  kg=1;
		a=s[sz(s)-1];
		cf.insert(s);
	}
	if (sz(cf)!=w)  kg=1;
	if (kg==0)  cout<<"Yes";
	else  cout<<"No";
	re 0;
}


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

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

Measured memory_bytes: 4400
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  std::string S;
  std::cin >> S;

  // Main
  std::string res = "Good";
  for (int i = 0; i < S.size(); ++i) {
    if (i == 0)
      continue;
    if (S[i] == S[i - 1])
      res = "Bad";
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
_,a,b = gets.chomp.split(' ').map { |e| e.to_i }
xs = gets.chomp.split(' ').map { |e| e.to_i }

distances = []
(1..(xs.length- 1)).each { |i|
  distances << (xs[i] - xs[i - 1])
}

def min(x, y)
  x < y ? x : y
end

p distances.map { |d| min(d * a, b) }.inject :+


Measured memory_bytes: 11140
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

ll dp[100005];
void solve()
{ 
   int n,m; cin>>n>>m;
   int a[m];
   rep(i,0,m) cin>>a[i];
   int idx=0;
   dp[0]=1;
   if(a[idx]==1) dp[1]=0,idx++;
   else dp[1]=1;
   rep(i,2,n+1)
   {
     if(idx!=m)
     {
       if(a[idx] == i) {dp[i]=0; idx++;}
       else dp[i] = (dp[i-1]%lul + dp[i-2]%lul)%lul;
       dp[i]+=lul;
       dp[i]%=lul;
     }
     else{
      dp[i] = (dp[i-1]%lul + dp[i-2]%lul)%lul;
      dp[i]+=lul;
      dp[i]%=lul;
     }
   }
   cout<<dp[n];
} 
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

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





int main() {
  string s;
  cin>>s;
  int n=s.size();

  vector<ll> p(2019);
  p[0]++;
  int now=0;
  ll ju=1;
  for(int i=n-1;i>=0;i--){
    now=now+ju*(s[i]-'0');
    if(now>=2019) now%=2019;
    p[now]++;
    ju*=10;
    if(ju>=2019) ju%=2019;
  }

  ll ans=0;
  rep(i,2019){
    ans+=p[i]*(p[i]-1)/2;
  }


  cout << ans << endl;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int w,h;
int c[101][101];
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,0,1,-1,0,1,-1};
void dfs(int x,int y){
     c[x][y]=0;
     REP(i,8){
         if(c[x+dx[i]][y+dy[i]]==1){
            dfs(x+dx[i],y+dy[i]);
         }
     }
}
int main(){
    while(cin>>w>>h,w,h){
    REP(i,h+1){
        REP(j,w+1){
            c[i][j]=0;
        }
    }
    REP(i,h){
        REP(j,w){
            cin>>c[i+1][j+1];
        }
    }
    int ans=0;
    REP(i,h+1){
        REP(j,w+1){
            if(c[i][j]==1){
               dfs(i,j);
               ans++;
            }
        }
    }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
A,B,C,K = list(map(int, input().split()))
sum = 0

if A <= K:
  sum += A
  K -= A
else:
  sum += K
  K = 0
  
if B < K:
  sum += 0
  K -= B
else:
  sum += 0
  K = 0
  
if K > 0:
  sum -= K
else:
  sum += 0 
  
print(sum)

Measured memory_bytes: 9204