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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

using uint=unsigned;
using ull=unsigned long long;

const uint mod=998244353;
//const uint mod=1000000007;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/*mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
	}*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};

const int vcmax=(1<<21)+10;
mint fact[vcmax],finv[vcmax],invs[vcmax];
void initfact(){
	fact[0]=1;
	rng(i,1,vcmax){
		fact[i]=fact[i-1]*i;
	}
	finv[vcmax-1]=fact[vcmax-1].inv();
	for(int i=vcmax-2;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	for(int i=vcmax-1;i>=1;i--){
		invs[i]=finv[i]*fact[i-1];
	}
}
mint choose(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}
mint binom(int a,int b){
	return fact[a+b]*finv[a]*finv[b];
}
mint catalan(int n){
	return binom(n,n)-(n-1>=0?binom(n-1,n+1):0);
}

//sum=a
//odd<=b
mint sub(int n,int a,int b){
	chmin(b,n);
	mint ans=0;
	for(int i=a%2;i<=min({n,a,b});i+=2)
		ans+=choose((a-i)/2+n-1,n-1)*choose(n,i);
	return ans;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	initfact();
	
	int n,m;cin>>n>>m;
	mint ans=sub(n,3*m,m);
	ans-=(sub(n,m,m)-sub(n-1,m,m))*n;
	cout<<ans<<endl;
}


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

int main(){
	int N, max = 0;
	map<string, int> m;
	string input;
	cin >> N;
	rep(i, N){
		cin >> input;
		m[input]++;
		if(m[input] > max) max = m[input];
	}
	for(auto p : m){
		if(p.second == max) cout << p.first << endl;
	}
	
	return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	char a[4];
	cin>> a[0] >> a[1] >> a[2] >> a[3];
	if((a[0] == a[1] && a[1] == a[2]) || ((a[1] == a[2])&&a[2] == a[3]))
		cout << "Yes\n";
	else cout << "No\n";	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,p[maxn],q[maxn];
int main(){
	n=read();
	for(int i=1;i<=n;i++)p[i]=read();
	int flag=1;
	for(int i=1;i<=n;i++){
		if(p[i]!=i){
			flag=0;break;
		}
	}
	if(flag){
		puts("YES");
		return 0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i!=j){
				for(int k=1;k<=n;k++)q[k]=p[k];
				swap(q[i],q[j]);
				int flag=1;
				for(int k=1;k<=n;k++){
					if(q[k]!=k){flag=0;break;}
				}
				if(flag){
					puts("YES");
					return 0;
				}
			}
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include<memory>
#include<utility>

class SkewHeap {
 public:
  using Key = int;
  struct Node {
    Key key;
    int index;
    std::unique_ptr<Node> lchild, rchild;
    Node(Key key, int index) : key(key), index(index) {}
  };

  SkewHeap () {}

  std::unique_ptr<Node> make() const {return nullptr;}
  std::unique_ptr<Node> make(Key key, int index) const {return std::move(std::make_unique<Node>(key, index));}

  std::unique_ptr<Node> meld(std::unique_ptr<Node>& lhs, std::unique_ptr<Node>& rhs) const {
    if(!lhs) return std::move(rhs);
    if(!rhs) return std::move(lhs);
    if(lhs->key < rhs->key) std::swap(lhs, rhs);
    lhs->rchild = meld(lhs->rchild, rhs);
    std::swap(lhs->lchild, lhs->rchild);
    return std::move(lhs);
  }

  void push(std::unique_ptr<Node>& root, Key key, int index) const {
    auto n = std::make_unique<Node>(key, index);
    root = meld(root, n);
  }

  Key top(std::unique_ptr<Node>& root) const {return root->key;}

  int pop(std::unique_ptr<Node>& root) const {
    auto index = root->index;
    root = meld(root->lchild, root->rchild);
    return index;
  }
};


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& i: A) cin >> i;

  SkewHeap heap;
  auto root = heap.make();
  for(auto i = 0; i < N; ++i) heap.push(root, A[i], i);

  auto a = heap.pop(root);
  auto b = heap.pop(root);
  for(auto i=0; i<N; ++i) {
    if(i==a) cout << A[b] << endl;
    else     cout << A[a] << endl;
  }
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
   {
       cout<<"Yes";
   }
   else if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])
   {
       cout<<"Yes";
   }
   else if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])
   {
       cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        char[] s = sc.nextLine().toCharArray();
        sc.close();

        int[] wCnt = new int[n];
        int[] eCnt = new int[n];
        for(int i=0; i<n; i++) {
            if(s[i] == 'W') {
                wCnt[i]++;
            } else {
                eCnt[i]++;
            }
            if(i != 0) {
                wCnt[i] += wCnt[i-1];
                eCnt[i] += eCnt[i-1];
            }
        }

        int ans = 0;
        for(int i=0; i<n; i++) {
            if(i == 0) {
                ans = eCnt[n-1] - eCnt[0];
            } else {
                ans = Math.min(ans, wCnt[i-1] + (eCnt[n-1] - eCnt[i]));
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 32428
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val Vector(n, k) = Vector.fill(2)(sc.nextInt)

  val ans = k * pow(k - 1, n - 1)

  def pow(x: Int, y: Int): Int = {
    Range(0, y).fold(1)((acc, _) => acc * x)
  }

  println(ans)
}


Measured memory_bytes: 25548
#include<iostream>
#include<cmath>
#include <string>
#include<vector>
#include<algorithm>
#define INF 10000000

using namespace std;
typedef vector<int > vi;

int main() {
	int n, m;
	cin >> n >> m;
	vi A(m), B(m), C(m);
	for (int i = 0; i < m; i++) {
		cin >> A[i] >> B[i] >> C[i];
		A[i]--; B[i]--;
	}
	vector<vi> X(n, vi(n, INF));
	for (int i = 0; i < n; i++) {
		X[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		X[A[i]][B[i]] = C[i];
		X[B[i]][A[i]] = C[i];
	}
			for (int k = 0; k < n; k++) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
				X[i][j] = min(X[i][j], X[i][k] + X[k][j]);
			}
		}
	}
	int ans = m;
	for (int i = 0; i < m; i++) {
		int a = A[i];
		int b = B[i];
		for (int j = 0; j < n; j++) {
			if (llabs(X[j][a] - X[j][b]) == C[i]) {
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

vector<int> tsort(int v, vector<int> g[], bool zero_index = false) {
  vector<int> ret;

  int start = zero_index ? 0 : 1;
  int end = zero_index ? v : v + 1;
  int degree[end];
  memset(degree, 0, sizeof(degree));

  for (int from = start; from < end; from++) {
    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]++;
    }
  }

  stack<int> root;

  for (int i = start; i < end; i++) {
    if (degree[i] == 0) {
      root.push(i);
    }
  }

  while (!root.empty()) {
    int from = root.top();
    root.pop();

    ret.push_back(from);

    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]--;

      if (degree[to] == 0) {
        root.push(to);
      }
    }
  }

  return ret;
}

int main() {
  int v, e;
  int s, t;
  cin >> v >> e;

  vector<int> g[v];

  for (int i = 0; i < e; i++) {
    cin >> s >> t;

    g[s].push_back(t);
  }

  vector<int> ans = tsort(v, g, true);

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

  return 0;
}



Measured memory_bytes: 3936
import sys
input = sys.stdin.readline
N, K = map(int, input().split())

sushi_array = []

sushi_count = [-1] * N
sushi_kind = 0
for i in range(N):
    t, d = map(int, input().split())
    sushi_array.append([t - 1, d])
    if sushi_count[t - 1] == -1:
        sushi_count[t - 1] = 0
        sushi_kind += 1

sushi_array = sorted(sushi_array, key=lambda x: -x[1])
# print(sushi_array, sushi_kind)

now_kind = 0
kiso = 0
for sushi in sushi_array[:K]:
    kiso += sushi[1]
    if sushi_count[sushi[0]] == 0:
        now_kind += 1
    sushi_count[sushi[0]] += 1

ans = kiso + now_kind * now_kind

add_index = K
remove_index = K - 1

now_kind += 1
while now_kind <= sushi_kind:

    while add_index < N:
        sushi = sushi_array[add_index]
        # print(sushi)
        add_index += 1
        if sushi_count[sushi[0]] == 0:
            kiso += sushi[1]
            sushi_count[sushi[0]] = 1
            break

    else:
        break
    while remove_index >= 0:
        sushi = sushi_array[remove_index]
        # print(sushi)
        remove_index -= 1
        if sushi_count[sushi[0]] > 1:
            kiso -= sushi[1]
            sushi_count[sushi[0]] -= 1
            break
    else:
        break
    # print(ans,kiso,now_kind * now_kind)
    ans = max(ans, kiso + now_kind * now_kind)
    now_kind += 1

print(ans)

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


int main(){
	
	

	int a , b ,c,d ;
	int f, g , k, l ;

	cin >> a >> b >> c >> d;
	while(1)
	{
		c = c- b;
		a = a - d ;
		if(c <= 0)
		{
			cout <<"Yes";
			break;
		}
		if(a <= 0 )
		{
			cout<<"No";
			break;
		}
		
	}

	
	return 0 ;
}

Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <numeric> 
#include <vector> 
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
const int sz = 2e3 + 10;
int n, x, y;
vector <int> G[sz];
int ans[sz];
int dis[sz];
int vis[sz];
queue <int> q;

void bfs(int x, int cs) {
    int u = x;
    q.push(u);
    dis[u] = 0;
    vis[u] = cs;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int v: G[u]) if (vis[v] != cs) {
            vis[v] = cs;
            dis[v] = dis[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; i++) {
        ans[dis[i]]++;
    }    
}
int main() {

    while (cin >> n >> x >> y) {
        for (int i = 0; i <= n; i++) {
            G[i].clear();
        }
        for (int i = 0; i + 1 < n; i++) {
            G[i].push_back(i + 1);
            G[i + 1].push_back(i);
        }
        --x, --y;
        G[x].push_back(y);
        G[y].push_back(x);
        memset(ans, 0, sizeof ans);
        for (int i = 0; i < n; i++) {
            bfs(i, i + 1);
        }
        for (int i = 1; i < n; i++) {
            cout << (ans[i] >> 1) << "\n";
        }
        cerr << "---\n";
    }    
    return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
moves = [0] + list(map(int, input().split()))
points = [0] + list(map(int, input().split()))
INF = 10**10
 
answer = -INF
for start in range(1, N+1):
  circle = [start]
  next = moves[start]
  c_score = points[start]
  while(next != start):
    circle.append(next)
    c_score += points[next]
    next = moves[next]
  m_score = 0
  for i in range(min(len(circle), K)):
    m_score += points[circle[i]]
    loop_cnt = (K-i-1)//len(circle)
    answer = max(answer, m_score + max(0, loop_cnt * c_score))
print(answer)

Measured memory_bytes: 80884
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define pub push_back
#define pii pair<int, int>
#define vi vector<int> 
#define fst first
#define snd second
using namespace std;
string s, ns;
int lft = 0, rg = 0;
vector<pii> v;
priority_queue<pii> pq;
bool actv[1000001] = {};
bool cp(const pii &l, const pii &r)
{
	return make_pair(l.snd, l.fst) < make_pair(r.snd, r.fst);
}
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		for (int j = 0; j < s.size(); j++)
		{
			if (s[j] == '(') {ns.pub('(');}
			else
			{
				if (ns.size() && ns.back() == '(') {ns.pop_back();}
				else {ns.pub(')');}
			}
		}
		if (ns.size())
		{
			int j = 0;
			for (j = 0; j < ns.size() && ns[j] == ')'; j++) {}
			if (j == 0) {lft += ns.size();}
			else if (j == ns.size()) {rg += ns.size();}
			else {v.pub({j, ns.size() - j});}
		}
		ns.clear();
	}
	sort(v.begin(), v.end());
	int j = 0;
	for (; j < v.size(); j++)
	{
		if (v[j].fst <= lft) {pq.push({v[j].snd - v[j].fst, j});}
		else {break;}
	}
	while (pq.size() && pq.top().fst >= 0)
	{
		lft += pq.top().fst; 
		actv[pq.top().snd] = 1;
		pq.pop();
		for (; j < v.size(); j++)
		{
			if (v[j].fst <= lft) {pq.push({v[j].snd - v[j].fst, j});}
			else {break;}
		}
	}
	//sort(v.begin(), v.end(), cp);
	int k;
	for (k = v.size() - 1; k >= 0; k--)
	{
		if (actv[k]) {continue;}
		if (v[k].fst <= lft) {lft += v[k].snd - v[k].fst;}
		else {break;}
	}
	if (k < 0 && lft == rg) {cout << "Yes\n";}
	else {cout << "No\n";}
	return 0;
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,m,q,i,j,nxtx[100005],prex[100005],nxty[100005],prey[100005],x,y,xx,yy,lst1,lst2;
ll dis[75];
string s,t;
char ss[100005];
vector<pair<int,int> > all;
vector<pair<int,int> > bi[75];
void add(int x,int y)
{
	all.push_back(make_pair(x,y));
	if (prex[x]) all.push_back(make_pair(prex[x],y));
	if (nxtx[x]) all.push_back(make_pair(nxtx[x],y));
	if (prey[y]) all.push_back(make_pair(x,prey[y]));
	if (nxty[y]) all.push_back(make_pair(x,nxty[y]));
	if (prex[prex[x]]) all.push_back(make_pair(prex[prex[x]],y));
	if (nxtx[nxtx[x]]) all.push_back(make_pair(nxtx[nxtx[x]],y));
	if (prey[prey[y]]) all.push_back(make_pair(x,prey[prey[y]]));
	if (nxty[nxty[y]]) all.push_back(make_pair(x,nxty[nxty[y]]));
	if (prex[x]&&prey[y]) all.push_back(make_pair(prex[x],prey[y]));
	if (prex[x]&&nxty[y]) all.push_back(make_pair(prex[x],nxty[y]));
	if (nxtx[x]&&prey[y]) all.push_back(make_pair(nxtx[x],prey[y]));
	if (nxtx[x]&&nxty[y]) all.push_back(make_pair(nxtx[x],nxty[y]));
}
ll dijkstra(int x,int y)
{
	memset(dis,18,sizeof(dis));
	dis[x]=0;
	priority_queue<pair<ll,ll> > pq;
	pq.push(make_pair(0,x));
	while (!pq.empty())
	{
		x=pq.top().second;pq.pop();
		foreach(it,bi[x])
		{
			if (dis[it->fi]>dis[x]+it->se)
			{
				dis[it->fi]=dis[x]+it->se;
				pq.push(make_pair(-dis[it->fi],it->fi));
			}
		}
	}
	if (dis[y]==dis[54]) return -1;
	return dis[y];
}
void solve(int x,int y,int xx,int yy)
{
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
//	foreach(it,all) cerr<<it->fi<<' '<<it->se<<endl;
	int i,j,ss,tt;
	for (i=0;i<all.size();i++) if (all[i].first==x&&all[i].second==y) ss=i;
	for (i=0;i<all.size();i++) if (all[i].first==xx&&all[i].second==yy) tt=i;
	for (i=0;i<all.size();i++) bi[i].clear();
	for (i=0;i<all.size();i++) for (j=0;j<all.size();j++) if (i!=j)
	{
		if (all[i].first==all[j].first&&((s[all[i].first]=='E')==(all[i].second<all[j].second)))
		{
			bi[i].push_back(make_pair(j,abs(all[i].second-all[j].second)));
		}
		if (all[i].second==all[j].second&&((t[all[i].second]=='S')==(all[i].first<all[j].first)))
		{
			bi[i].push_back(make_pair(j,abs(all[i].first-all[j].first)));
		}
	}
	printf("%lld\n",dijkstra(ss,tt));
}
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	scanf(" %s",ss);s=ss;s=" "+s;
	scanf(" %s",ss);t=ss;t=" "+t;
	lst1=lst2=0;
	rep(i,n){if (s[i]=='W'){prex[i]=lst2;lst1=i;}else{prex[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep2(i,n){if (s[i]=='W'){nxtx[i]=lst2;lst1=i;}else{nxtx[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep(i,m){if (t[i]=='N'){prey[i]=lst2;lst1=i;}else{prey[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep2(i,m){if (t[i]=='N'){nxty[i]=lst2;lst1=i;}else{nxty[i]=lst1;lst2=i;}}
	while (q--)
	{
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		all.clear();
		add(x,y);add(x,yy);add(xx,y);add(xx,yy);
		solve(x,y,xx,yy);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
  ll n,t,ans=0;cin>>n>>t;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  vector<PL> mn(n,{INF,1ll}),mx(n,{-1ll,1ll});

  mn[0]={a[0],1};
  for(int i=1;i < n;i++)
  {
    mn[i].se=mn[i-1].se;
    if(mn[i-1].fi==a[i])mn[i].se++;
    mn[i].fi=min(mn[i-1].fi,a[i]);
  }

  mx[n-1]={a[n-1],1};
  for(int i=n-2;-1<i;i--)
  {
    mn[i].se=mx[i+1].se;
    if(mx[i+1].fi==a[i])mx[i].se++;
    mx[i].fi=max(mx[i+1].fi,a[i]);
  }
    

  ll mxp=-1;
  for(int i=0;i < n-1;i++)
  {
    mxp=max(mxp,mx[i+1].fi-mn[i].fi);
  }
  

  for(int i=0;i < n-1;i++)
  {
    
    if(mx[i+1].fi-mn[i].fi==mxp){
      ans++;
      ll x=i;
      while(x<n && mx[i+1].fi!=a[x]){
        x++;
      }
      i=x-1;
      
    }
  }

  
  cout<<ans<<endl;

}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    string s;   cin >> s;
    char key[4] = {'A', 'T', 'G', 'C'};
    ll tmp=0, res=0;
    rep(i, s.size()){
        bool flag=false;
        rep(j, 4) if(s[i]==key[j]) flag=true;
        if(flag) tmp += 1;
        else tmp = 0;
        res = max(res, tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    string hoge = to_string(n);
    rep(i, hoge.size())
    {
        sum += hoge[i] - '0';
    }
    if (n % sum == 0)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}

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

#define MAXN 8010
#define mod 1000000007

int n,a[200010],b[200010],f[MAXN>>1][MAXN>>1];
long long fac[MAXN],inv[MAXN];

long long qpow(long long base,long long to)
{
	long long res=1;
	while(to)
	{
		if(to&1)res=res*base%mod;
		base=base*base%mod;
		to>>=1;
	}
	return res;
}

void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[n]=qpow(fac[n],mod-2);
	inv[0]=1;
	for(int i=n-1;i>=1;--i)
		inv[i]=inv[i+1]*(i+1)%mod;
}

inline long long c(long long n,long long m)
{
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

inline int get(int id)
{
	return 2001-id;
}

inline int calc(int id)
{
	return 2001+id;
}

inline void dp()
{
	for(int i=1;i<=4001;++i)
		for(int j=1;j<=4001;++j)
			f[i][j]=((long long)f[i][j]+f[i-1][j]+f[i][j-1])%mod;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d%d",a+i,b+i);
	init(8000);
	for(int i=1;i<=n;++i)++f[get(a[i])][get(b[i])];
	dp();
	long long tot=0;
	for(int i=1;i<=n;++i)
		tot=(tot+f[calc(a[i])][calc(b[i])]-c(a[i]+a[i]+b[i]+b[i],b[i]+b[i])+mod)%mod;
	printf("%d\n",tot*qpow(2,mod-2)%mod);
}

Measured memory_bytes: 64640
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N, C[4];
int m[4], coin[4] = { 10, 50, 100, 500 };

int main(){
  bool first = true;
  while(cin >> N, N){
    REP(i, 0, 4) cin >> C[i];
    REP(i, 0, 4) N -= coin[i] * C[i];
    N *= -1;

    for(int i = 3; i >= 0; i--){
      m[i] = N / coin[i];
      N -= m[i] * coin[i];
    }

    if(first) first = false;
    else cout << endl;
    REP(i, 0, 4) if(C[i] > m[i]) cout << coin[i] << " " << C[i] - m[i] << endl;
  }
}

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

int main() {
  int A,B,C, X,Y;
  cin>>A>>B>>C>>X>>Y;
  vector<int>a(100001);
  for(int i=0;i<=100000;i++){
    a.at(i)=2*i*C+A*max(0,X-i)+B*max(0,Y-i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(0)<< endl;
}

Measured memory_bytes: 640
/*---> 04 May 2020 <--- > 20:12:46 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC\n";
	else
		cout<<"ABC\n";
return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k,x;
    cin >> x;
    ll a=1;
    for(a=1;a*a*a*a*a<=x*x;a++){
        ll b = a*a*a*a*a-x;
        ll ret;
        //cout << a << endl;
        if(b<0)ret=-1,b*=-1;
        else ret=1; 
        for(i=0;i*i*i*i*i<=b;i++){
            if(i*i*i*i*i==b){
                cout << a << " " <<ret*i << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

char s;
void input() { cin >> s; }
void solve() { cout << ((isupper(s)) ? "A" : "a") << endl; }

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


Measured memory_bytes: 3652
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int n, ans = 0;
bool check(LL x) {
	int c3 = 0, c5 = 0, c7 = 0;
	while(x) {
		if(x%10 == 3) c3++;
		else if(x%10 == 5) c5++;
		else c7++;
		x /= 10;
	}
	return c3&&c5&&c7;
}
void dfs(LL x) {
	if(x <= n) {
		if(check(x)) ans++;
	}
	else return ;
	dfs(x*10+3);
	dfs(x*10+5);
	dfs(x*10+7);
}
int main() {
	scanf("%d", &n);
	dfs(0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    ll n, q;
    cin >> n >> q;
    ll now = (n - 2) * (n - 2);
    vector<pll> vp, vp2;
    ll tate = n;
    ll yoko = n;
    while (q--) {
        ll t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < tate) {
                now -= yoko - 2;
                tate = x;
                vp.emplace_back(tate, yoko);
            } else {
                pll target;
                target.first = x;
                target.second = LINF;
                int ng = -1, idx = vp.size();
                while (ng + 1 < idx) {
                    int c = (idx + ng) / 2;
                    if (vp[c].first < x)
                        idx = c;
                    else
                        ng = c;
                }
                now -= vp[idx].second - 2;
            }
        } else {
            if (x < yoko) {
                now -= tate - 2;
                yoko = x;
                vp2.emplace_back(yoko, tate);
            } else {
                pll target;
                target.first = x;
                target.second = LINF;
                int ng = -1, idx = vp2.size();
                while (ng + 1 < idx) {
                    int c = (idx + ng) / 2;
                    if (vp2[c] < target)
                        idx = c;
                    else
                        ng = c;
                }
                now -= vp2[idx].second - 2;
            }
        }
    }
    cout << now << '\n';
}


Measured memory_bytes: 7328
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
res = []
for i in range(x):
    for j in range(y):
        if (i+1) * (j+1) > k:
            break
        for l in range(z):
            if (i+1) * (j+1) * (l+1) > k:
                break
            res.append(a[i]+b[j]+c[l])
res.sort(reverse=True)
for i in range(k):
    print(res[i])



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

using namespace std;

string s1,s2;
int num[30][100010],len[30];
long long int ans;

int main()
{
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	{
		int a=s1[i]-'a'+1;
		num[a][++len[a]]=i;
	}
	int loc=-1;
	int bj=1;
	for(int i=0;i<s2.size();i++)
	{
		int a=s2[i]-'a'+1;
		if(len[a]==0)
		{
			bj=-1;
			break;
		}
		else
		{
			if(loc>=num[a][len[a]])
			{
				ans=ans+s1.size()-loc+num[a][1];
				loc=num[a][1];
			}
			else
			{
				if(loc<num[a][1])
				{
					ans=ans+num[a][1]-loc;
					loc=num[a][1];
				}
				else
				{
					int l1=1,r1=len[a];
			    	while(l1+1<r1)
				    {
					    int mid=((l1+r1)>>1);
					    if(num[a][mid]<=loc)
					        l1=mid;
					    else
					        r1=mid;
			    	}
			    	if(num[a][l1]<=loc)
				        l1=r1;
				    else
				        r1=l1;
				    ans=ans+num[a][l1]-loc;
				    loc=num[a][l1];
				}
			}
		}
		//printf("   %d\n",loc);
	}
	if(bj==-1)
	    printf("-1\n");
	else
	    printf("%lld\n",ans);
	return 0;
}

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

int main(void)
{
    int n, m;
    int a, b;
    cin >> n >> m;

    vector<int> vec(n);
    
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        vec.at(a-1)++;
        vec.at(b-1)++;
    }

    for(int i = 0; i < n; i++) cout << vec.at(i) << endl;

    return 0;
}

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

int main(){
    int n ,i;
    cin>>n>>i;
    cout <<n-i+1 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  int n, k;
  cin >> n >> k;
  vi a(n);
  int tot = 0;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    tot += a[i];
  }
  int res = 1;
  vi t(n);
  for(int i = 1; i * i <= tot; ++i) {
    if(tot % i) continue;
    auto run = [&](int d) {
      int r = 0;
      for(int j = 0; j < n; ++j) {
        t[j] = a[j] % d;
        r += t[j];
      }
      int m = r / d;
      sort(all(t));
      int tt = 0;
      for(int j = 0; j < n - m; ++j) {
        tt += t[j];
      }
      if(tt <= k) {
        res = max(res, d);
      }
    };
    run(i);
    run(tot / i);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main() {
	int a, b;
	scanf ("%d%d", &a, &b);
	if (a <= 0 && b >= 0) return puts ("Zero"), 0;
	if (b > 0) return puts ("Positive"), 0;
	puts ( (b - a) & 1 ? "Positive" : "Negative");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int a[maxn];
int b[maxn];
int n;
ll ans=0;
struct node
{
    int id;
    int sum;
    bool operator<(const node &t) const{
     return sum<t.sum;
    }
};
priority_queue<node>que;
int slove( node no)
{
    int ids=no.id;
    int t1=ids+1;
    int t2=ids-1;
    if(t2==0)
        t2=n;
    if(t1==n+1)
        t1=1;
  int  sum=b[t1]+b[t2];
   if(sum+a[ids]>b[ids])
    return 0;
   ans=ans+(ll)(no.sum-a[ids])/sum;
   no.sum=(no.sum-a[ids])%sum+a[ids];
   b[ids]=no.sum;
   if(no.sum>a[ids])
   {
       que.push(no);
   }
   else if(no.sum<a[ids])
    return 0;
else
    return 1;
}
int main()
{
     scanf("%d",&n);
     for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
     for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
       if(a[i]!=b[i])
       que.push({i,b[i]});
     }
        int flag;
        while(!que.empty())
        {

            if(que.top().sum>a[que.top().id])
            {

                flag=slove(que.top());
                que.pop();
                if(flag==0)
                {
                    puts("-1");
                    return 0;
                }
            }
            else
            {
                 puts("-1");
                  return 0;
            }
        }
        printf("%lld\n",ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n,q;
  cin >> n >> q;
  vector<tuple<ll,ll,ll>> v;
  set<ll> st;
  rep(i,0,n) {
   ll s,t,x;
    cin >> s >> t >> x;
    v.push_back(make_tuple(s-x,1,x));
    v.push_back(make_tuple(t-x,-1,x));
  }

   sort(v.begin(),v.end());
  
   ll index=0;
  rep(i,0,q){
   ll d;
    cin >> d;
    
     while(get<0>(v[index])<=d&&index<v.size()){
       if(get<1>(v[index])==1) st.insert(get<2>(v[index]));
       else st.erase(get<2>(v[index]));
       index++; 
     }
      if(!st.empty()) cout << *st.begin() << endl;
      else cout << -1 << endl;
  }

}


Measured memory_bytes: 21480
#include <iostream>
#include <string>
using namespace std;
int main () {
  int N;
  string S;
  cin >> N >> S;
  if (N % 2) {
    cout << "No" << endl;
    return 0;
  }
  N /= 2;
  for (int i = 0; i < N; i ++) {
    if (S[i] != S[i + N]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
s=input()
t=input()
n=len(s)
l=len(t)
count=l
for j in range(n-l+1):
    sj=s[j:j+l]
    res=0
    for k in range(l):
        if sj[k]!=t[k]:
            res+=1
    if res<count:
        count=res



print(count)


Measured memory_bytes: 67552
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while(true) {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if (H == 0 || W == 0) {
                break;
            }
            for (int i = 0;i < H; i++) {
                for (int j = 0;j < W; j++) {
                    if (i == 0 || i == (H - 1) || j == 0||j == (W - 1)) {
                        sb.append("#");
                    } else {
                        sb.append(".");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }

}

Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N,b;
  cin >> N;
  vector<int> ans;
  for(int i=0; i<N; i++){
    cin >> b;
    if(i+1<b){cout << "-1" << endl; return 0;}
    ans.insert(ans.begin()+b-1,b);
  }
  for(int i=0; i<N; i++){
    cout << ans[i] << endl;   
  }
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
  char s[100005];
  int n,count0=0,count1=0;
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<=n-1;i++){
    if(s[i]=='0') count0++;
    if(s[i]=='1') count1++;
  }
  if(count1>count0){
    printf("%d\n",2*count0);
    return 0;
  }else{
    printf("%d\n",2*count1);
    return 0;
  }
}


Measured memory_bytes: 1804
using System;

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int t = int.Parse(s[0]);
            int a = int.Parse(s[1]);

            int[] h = new int[n];

            float diffMin = 1000000000f;
            int diffMinNum = 0;

            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; ++i)
            {
                float diff = Math.Abs(a - (t - int.Parse(s[i]) * 0.006f));

                if (diff < diffMin)
                {
                    diffMin = diff;
                    diffMinNum = i;
                }
            }

            Console.WriteLine(diffMinNum + 1);
        }
    }
}


Measured memory_bytes: 11164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

    int64_t sum = 0;
    int64_t nodes = 0;
    int64_t thisleaf = 1;
    vector<int> as(n+1);
    rep(i,n+1){
      int64_t a;
      cin >> a;
      as.at(i) = a;
      sum += a;
    }

    rep(i,n+1){
      int64_t a = as.at(i);
      if(a > thisleaf){
        nodes = -1;
        break;
      }

      if(i==n && thisleaf!=a){
        nodes = -1;
        break;
      }
      nodes += thisleaf;

      sum -= a;
      thisleaf = min((thisleaf-a)*2, sum);
    }

    cout << nodes << endl;
}


Measured memory_bytes: 3768
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S1 = sc.next();
        String S2 = sc.next();
        BigInteger a = new BigInteger(S1);
        BigInteger b = new BigInteger(S2);
        System.out.println(judge(a,b));
    }
    static String judge(BigInteger a, BigInteger b){
        int t = a.compareTo(b);
        if(t==0){
            return "EQUAL";
        }else if(t>0){
            return "GREATER";
        }else{
            return "LESS";
        }
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nw = Input.ar;
        var wv = Input.twodim(nw[0]);
        var dp = new long[nw[0] + 1, nw[1] + 1];
        for (var i = 1; i <= nw[0]; i++)
            for (var j = 0; j <= nw[1]; j++)
                if (j - wv[i - 1][0] >= 0)
                    dp[i, j] = Max(dp[i - 1, j], dp[i - 1, j - wv[i - 1][0]] + wv[i - 1][1]);
                else dp[i, j] = dp[i - 1, j];
        var max = 0L;
        for (var i = 0; i <= nw[1]; i++)
            max = Max(max, dp[nw[0], i]);
        WriteLine(max);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

int main(void) {
  int A, B;
  string S;
  cin >> A >> B >> S;

  bool ok = true;
  for (int i = 0; i < A; ++i) {
    if (!isdigit(S[i])) ok = false;
  }
  if (S[A] != '-') ok = false;
  for (int i = A + 1; i < A + B + 1; ++i) {
    if (!isdigit(S[i])) ok = false;
  }

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 string s,a;
 cin>>s>>a;
 int n=s.size();
 if(n!=a.size()-1) cout<<"No";
 string res=a.substr(0,n);
 if(res==s) cout<<"Yes";
 else cout<<"No";
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        string[] X = Console.ReadLine().Split(' ');
        int x = int.Parse(X[0]);
        

        if (x<=599)
        {
            Console.WriteLine("8");
        }
        else if(x>=600&&x<=799)
        {
            Console.WriteLine("7");
        }
        else if (x >= 800 && x <= 999)
        {
            Console.WriteLine("6");
        }
        else if (x >= 1000 && x <= 1199)
        {
            Console.WriteLine("5");
        }
        else if (x >= 1200 && x <= 1399)
        {
            Console.WriteLine("4");
        }
        else if (x >= 1400 && x <= 1599)
        {
            Console.WriteLine("3");
        }
        else if (x >= 1600 && x <= 1799)
        {
            Console.WriteLine("2");
        }
        else if (x >= 1800 && x <= 1999)
        {
            Console.WriteLine("1");
        }

    }

}



Measured memory_bytes: 27452
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

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


Measured memory_bytes: 35712
package main

import "fmt"

func main() {
	var r, c int
	fmt.Scan(&r, &c)

	t := make([]int, c)
	for i := 0; i < r; i++ {
		s := 0
		for j := 0; j < c; j++ {
			var x int
			fmt.Scan(&x)
			fmt.Print(x, " ")
			s += x
			t[j] += x
		}
		fmt.Println(s)
	}
	s := 0
	for i := 0; i < c; i++ {
		fmt.Print(t[i], " ")
		s += t[i]
	}
	fmt.Println(s)
}



Measured memory_bytes: 1864
a = []
a.append(list(input()))
a.append(list(input()))
a.append(list(input()))
x = a[0].pop(0)
while True:
  if x == 'a':
    if len(a[0]) == 0:
      print('A')
      break
    else:
      x = a[0].pop(0)
  elif x == 'b':
    if len(a[1]) == 0:
      print('B')
      break
    else:
      x = a[1].pop(0)
  elif x == 'c':
    if len(a[2]) == 0:
      print('C')
      break
    else:
      x = a[2].pop(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define pbp(a,b) push_back({a,b})
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define INF 0x3f3f3f3f

ll nextPowerOf2(ll n)   
{ 
    n--; 
    n |= n >> 1ll; 
    n |= n >> 2ll; 
    n |= n >> 4ll; 
    n |= n >> 8ll; 
    n |= n >> 16ll; 
    n++; 
    return n; 
}

bool cmp(ll a,ll b)
{
    return (a>b);
}

int main() {
    
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,j,x,y;

    cin>>x>>n;
    map<int,int>m;

    rep(p,0,n)
    {
        cin>>y;
        m[y]=1;
    }

    i=j=x;
    while(m[i] && m[j]){i--;j++;}

    if(!m[i])cout<<i;
    else cout<<j;
    return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,cf="CF";
	int i = 0;
	cin >> s;
	for (auto c : s) {
		if (cf[i] == c && ++i == 2)break;
	}
	cout << (i == 2 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256