akhauriyash/Code-Regression huggingface dataset:
process.stdin.resume();
process.stdin.setEncoding('utf-8');

function calcBillSheets(num, yen) {
  var billComb = [num, 0, 0];
  var total;

  while ((total = totalSum(billComb)) !== yen) {
    if (billComb[1] === 0) {
      if (billComb[0] > 0) {
        billComb[1]++; billComb[0]--;
      }
      billComb[1] += billComb[2];
      billComb[2] = 0;
    } else {
      billComb[1]--;
      billComb[2]++;
    }

    if (billComb[2] === num) {
      break;
    }
  }

  if (totalSum(billComb) === yen) {
    return billComb;
  } else {
    return [-1, -1, -1];
  }
}

function totalSum(billComb) {
  return billComb[0] * 10000 + billComb[1] * 5000 + billComb[2] * 1000;
}

process.stdin.on('data', function (line) {
  var arg = line.trim().split(' ');
  console.log(calcBillSheets(parseInt(arg[0]), parseInt(arg[1])).join(' '));
  process.exit(0);
});


Measured memory_bytes: 21064
n=int(input())
p=list(map(int,input().split()))
q=[]
for i in range(1,n+1):
    q.append(i)

a=0
for i in range(n):
    if p[i]==q[i]:
        a+=1
    else:
        a+=0

if a==n or a==n-2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e'|| c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }

    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long int> x(N), y(N), h(N);
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }
    int s = 0;
    for (int i = 0; i < N; ++i) {
        if (h[i] > 0) {
            s = i;
            break;
        }
    }
    long int ansX = 0, ansY = 0, ansHeight = 0;
    for (int i = 0; i <= 100; ++i) {
        ansX = i;
        for (int j = 0; j <= 100; ++j) {
            ansY = j;
            bool check = true;
            ansHeight = h[s] + abs(x[s] - ansX) + abs(y[s] - ansY);
            for (int k = 0; k < N; ++k) {
                long int height = max((int)(ansHeight - abs(x[k] - ansX) - abs(y[k] - ansY)), 0);
                if (h[k] != height) {
                    check = false;
                    break;
                }
            }
            if (check) {
                cout << ansX << " " << ansY << " " << ansHeight << endl;
                return 0;
            }
        }
    }
}

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

struct UnionFind
{
  vector<int> par; //par[i]はiの親の番号
  
  UnionFind(int N) : par(N)
  {
    for(int i = 0; i < N; i++) par[i] = i; //最初は全て根として初期化
  }
  
  int root(int x) //データxが属する木の根を再帰で得る root(x)={xの木の根}
  {
    if(par[x] == x) return x;
    return par[x] = root(par[x]); //親を再帰的にたぐり根を探す
  }
  
  void unite(int x, int y) //xとyの木を併合
  {
    int rx = root(x); //xの根
    int ry = root(y); //yの根
    if(rx == ry) return; //xとyの根が同じ(同じ木にある)ならそのまま
    par[rx] = ry; //xとyの根が同じでない(同じ木にない)ならyの根にxの根を付ける
  }
  
  bool same(int x, int y)//2つのデータx,yが同じ木に属するならtrue
  {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  int N, M, A, B;
  cin >> N >> M;
  
  UnionFind tree(N);
  int max = 1;
  vector<int> groop = vector<int>(N, 1);
  
  for(int i = 0; i < M; i++)
  {
    cin >> A >> B;
    A--;
    B--;
    tree.unite(A, B);
  }
  for(int i = 0; i < N; i++)
  {
    if(tree.root(i) != i) groop.at(tree.root(i))++;
  }
  for(int i = 0; i < N; i++)
  {
    if(groop.at(i) > max) max = groop.at(i);
  }
  cout << max << endl;
}

Measured memory_bytes: 11048
#include <cstdio>
#include <cstring>
#include <algorithm>

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)

inline void read( int &x ){
    x = 0 ; int f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

inline void readl( ll &x ){
    x = 0 ; ll f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

using namespace std ;

#define N 100010

char a[ N ] ;
int n , m ; 

int main() {
	scanf( "%s" , a + 1 ) ;
	n = strlen( a + 1 ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		if( a[ i ] == '1' ) a[ i ] = '9' ;
		else if( a[ i ] == '9' ) a[ i ] = '1' ;
	}
	printf( "%s" , a + 1 ) ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>vec;
    while(n--)
    {
        int p;
        cin>>p;
        vec.push_back(p);
    }
    int count=0;
    for(int i=0;i<vec.size();i++)
    {
        if(i%2==0 && vec[i]%2!=0)count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
	int i,a,b,c,n,nmax;
	scanf("%d",&a);
	n=1;
	nmax=1;	
	b=a/1000;
	a=a%1000;
	for(i=100;i>0;i/=10){
		c=a/i;
		a=a%i;
		if(b==c){
			n++;
		}else{
			if(n<3){
				n=1;
			}
		}
		b=c;
	}
	if(n>=3){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

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

	int m, d;
	cin >> m >> d;

	int result = 0;
	for (int i = 1; i <= d; i ++) {
		int x = i % 10;
		int y = i / 10;
		if (x >= 2 and y >= 2 && x * y <= m) result ++;
	}

	cout << result << endl;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    long a[N];
    cins(a, a + N);
    vector<long> sequences;
    for(int i = 0; i < N; i++){
        long sum = 0;
        for(int j = i; j < N; j++){
            sum += a[j];
            sequences.push_back(sum);
        }
    };
    long ans = 0;
    for(int i = 60; i >= 0; i--){
        int count = 0;
        for(long j: sequences){
            if((j >> i) & 1){
                count++;
            }
        }
        if(count >= K){
            ans += (1l << i);
            vector<long> next_sequences;
            for(long j: sequences){
                if((j >> i) & 1){
                    next_sequences.push_back(j);
                }
            }
            sequences = next_sequences;
        }
    }
    cout << ans << endl;
}



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

using namespace std;

const int NMAX = 200000 + 5;

int N, T;
int v[NMAX];

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

    cin >> N >> T;
    for (int i = 1; i <= N; ++ i)
        cin >> v[i];
    sort(v + 1, v + N + 1);

    int ans = 0;
    for (int i = 1; i <= N; ++ i)
        if (i == 1 || v[i - 1] + T <= v[i])
            ans += T;
        else
            ans += v[i] + T - (v[i - 1] + T);

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
change_array = []
m.times { change_array.push(gets.chomp.split.map(&:to_i)) }

a.sort!
change_array.sort_by! { |item| item[1] }

change_number = change_array.pop
result =0
a.each do |a_item|
  if change_number.nil? || change_number[1] < a_item
    result += a_item
  else
    result += change_number[1]
    change_number[0] -= 1
    change_number = change_array.pop if change_number[0] < 1
  end
end
puts result

Measured memory_bytes: 21952
arr=Array.new
while str = STDIN.gets
        op1,op2,op3=str.chomp.split.map{|v|v.to_s}
        break if op2 == '?'
        op1=op1.to_i
        op3=op3.to_i
        case op2
        when '+' then
                arr.push(op1+op3)
        when '-' then
                arr.push(op1-op3)
        when '/' then
                arr.push(op1/op3)
        when '*' then
                arr.push(op1*op3)
        end
end
arr.each do | answer |
        puts answer
end

Measured memory_bytes: 6096
#include <iostream>
using namespace std;
int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int h,m;
    h=h2-h1;
    m=m2-m1;
    if(m<0){
        h-=1;
        m=60+m;
    }
    int x;
    x=h*60;
    x=x+m;
    x=k-x;
    if(x<0){
        x=x*-1;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;

long long n,m;
long long islands[100010];//島名　(親の島の個数)
long long par[100010];//親
long long path[100010][2];
long long ucv[100010];
long long root(long long x){
	if(x==par[x])
		return x;
	return par[x]=root(par[x]);
}
long long unite(long long x,long long y){
	long long tx=root(x);
	long long ty=root(y);
	if(tx==ty)return 0;
	par[tx]=ty;
	islands[ty]+=islands[tx];
	return islands[tx]*(islands[ty]-islands[tx]);
}



int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>path[i][0]>>path[i][1];
	}
	for(int i=1;i<=n;i++)
	{
		islands[i]=1;
		par[i]=i;
	}
	ucv[m]=(n*(n-1))/2;
	for(int i=0;i<m-1;i++)
	{
		ucv[m-i-1]=ucv[m-i]-unite(path[m-1-i][0],path[m-1-i][1]);
	}
	for(int i=1;i<=m;i++)
	{
		cout<<ucv[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <fstream>
using namespace std;

const int INF=1<<30;
class Treap{
public:
  struct node_t{
    int val;// 値
    node_t *lch,*rch;// l,r
    int pri;// 優先度
    int cnt;// 部分木のサイズ
    int sum;// 部分木の値の和
    int minv;// 部分木の最小値
    node_t(int v,int p):val(v),pri(p),cnt(1),sum(v),minv(v){
      lch=rch=NULL;
    }
  };
  node_t* make_node(int val){
    return new node_t(val,rand());
  }
  int count(node_t *t){
    return !t?0:t->cnt;
  }
  int sum(node_t *t){
    return !t?0:t->sum;
  }
  int minimum(node_t *t){
    return !t?INF:t->minv;
  }
  node_t *update(node_t *t){
    t->cnt=count(t->lch)+count(t->rch)+1;
    t->sum=sum(t->lch)+sum(t->rch)+t->val;
    t->minv=min(t->val,min(minimum(t->lch),minimum(t->rch)));
    return t;
  }
  node_t *merge(node_t *l,node_t *r){
    if(!l||!r)return !l?r:l;
    // 優先順位が高い方を上に
    if(l->pri>r->pri){
      l->rch=merge(l->rch,r);
      return update(l);
    }
    else{
      r->lch=merge(l,r->lch);
      return update(r);
    }
  }
  // [0,k),[k,n)
  pair<node_t*,node_t*> split(node_t *t,int k){
    if(!t)return pair<node_t*,node_t*>(NULL,NULL);
    if(k<=count(t->lch)){
      pair<node_t*,node_t*> s=split(t->lch,k);
      t->lch=s.second;
      return make_pair(s.first,update(t));
    }
    else{
      pair<node_t*,node_t*> s=split(t->rch,k-count(t->lch)-1);
      t->rch=s.first;
      return make_pair(update(t),s.second);
    }
  }
  node_t *insert(node_t *root,int pos,int val){
    pair<Treap::node_t*,Treap::node_t*> p1=split(root,pos);
    pair<Treap::node_t*,Treap::node_t*> p2=split(p1.second,1);
    delete p2.first;
    root=merge(p1.first,make_node(val));
    root=merge(root,p2.second);
    return root;
  }
  
  // [l,r)の最小値を計算
  int range_min_value(node_t *t,int l,int r){
    if(r<=l)return INF;
    // 範囲と個数が一致
    if(r-l==count(t))
      return minimum(t);
    // 左の子に完全に含まれる
    else if(count(t->lch)>=r)
      return range_min_value(t->lch,l,r);
    // 右の子に完全に含まれる
    else if(count(t->lch)<l)
      return range_min_value(t->rch,l-(count(t->lch)+1),r-(count(t->lch)+1));
    // 左と右に場合分けする
    return min(t->val,min(range_min_value(t->lch,l,count(t->lch))
                          ,range_min_value(t->rch,0,r-(count(t->lch)+1))));
  }
};

Treap tp;
int main(){
  //ifstream cin("in.txt");
  Treap::node_t *root=NULL;
  int N,Q;
  cin>>N>>Q;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    root=tp.merge(root,tp.make_node(a));
  }
  for(int i=0;i<Q;i++){
    int x,y,z;
    cin>>x>>y>>z;
    if(x==0){
      pair<Treap::node_t*,Treap::node_t*> p1=tp.split(root,y);
      pair<Treap::node_t*,Treap::node_t*> p2=tp.split(p1.second,z-y+1);
      Treap::node_t* a=p1.first;
      Treap::node_t* b=p2.first;
      Treap::node_t* c=p2.second;
      pair<Treap::node_t*,Treap::node_t*> p3=tp.split(b,z-y);
      b=tp.merge(p3.second,p3.first);
      root=tp.merge(tp.merge(a,b),c);
    }
    else if(x==1){
      cout<<tp.range_min_value(root,y,z+1)<<endl;
    }
    else if(x==2){
      root=tp.insert(root,y,z);
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 10576
seconds = gets.chomp.to_i
seconds = gets.chomp.split(' ')
drink_num = gets.chomp.to_i
(0..drink_num-1).each do
  sum = 0
  drink = gets.chomp.split(' ')
  seconds.each_with_index do |s, j|
    sum += s.to_i if j != drink[0].to_i-1
    sum += drink[1].to_i if j == drink[0].to_i-1
  end
  puts sum
end


Measured memory_bytes: 1788
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner cs = new Scanner(System.in);
	String s = cs.nextLine();
    int a,b;

    a = Integer.parseInt(s.substring(0,2));
    b = Integer.parseInt(s.substring(2,4));
    String ans;
    if(0<a&&a<13&&(b==0||b>12)){
      ans = "MMYY";
    }else if((0<b&&b<13&&(a==0||a>12))){
      ans = "YYMM";
    }else if(0<a&&a<13&&0<b&&b<13){
      ans = "AMBIGUOUS";
    }else{
      ans = "NA";
    }
    System.out.println(ans);

    
  }
}

Measured memory_bytes: 23380
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}


int main(void){
    int n;
    cin >>n;
    ll  ans =0; 
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <=i; j++)
        {
            for (int k = 1; k <= i-1; k++)
            {
                if(i == k && i== j)ans += gcd(gcd(i,k),gcd(j,k))*6;
                else ans += gcd(gcd(i,k),gcd(j,k))*3;
            }
            
        }
        
    }
    ans += n*(n+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll s;
	cin >> s;
	ll i = 1;
	set<ll> se;
	while(1){
		if(se.count(s)){
			cout << i << endl;
			return 0;
		}
		se.insert(s);
		auto nexts = [](int s){if(s%2)return 3*s+1;return s/2;};
		s = nexts(s);
		i++;
	}
}


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

using i64 = int64_t;

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    string s, t;
    cin >> s >> t;

    int left = 0, right = w+1;
    int top = 0, bottom = h+1;
    for(int i=n-1;i>=0;--i){
        if(t[i] == 'L'){
            if(right > 1)right = min(w+1, right+1);
        }else if(t[i] == 'R'){
            if(left < w)left = max(0, left-1);
        }else if(t[i] == 'U'){
            if(bottom > 1)bottom = min(h+1, bottom+1);
        }else{
            if(top < h)top = max(0, top-1);
        }
        if(s[i] == 'L'){
            left = min(w, left+1);
        }else if(s[i] == 'R'){
            right = max(1, right-1);
        }else if(s[i] == 'U'){
            top = min(h, top+1);
        }else{
            bottom = max(1, bottom-1);
        }
    }

    bool ok = right <= sc || left >= sc || top >= sr || bottom <= sr;
    cout << (ok ? "NO" : "YES") << endl;

    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  sort(p.begin(), p.end(), greater<pair<ll, ll>>());
  cout << p[0].first + p[0].second << endl;






  

  
  return 0;
}

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

int N;

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

	if (N == 3) {
		printf("2 5 63\n");
		return 0;
	}

	if (N == 4) {
		printf("2 3 4 9\n");
		return 0;
	}

	if (N == 5) {
		printf("2 3 4 6 9\n");
		return 0;
	}

	for (int c = 3; c <= 29999; c += 12) {
		if (N < 6) break;
		N -= 6;
		printf("%d %d %d %d %d %d ", c-1, c, c+1, c+5, c+6, c+7);
	}

	for (int c = 6; N--; c += 6) printf("%d ", c);

	printf("\n");
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;
    vector<int> alphabet(30, 0);

    for(int i = 0; i < 4 ; i++)
    {
        int index = S[i] - 'A';
        alphabet[index] += 1;
    }
    sort(alphabet.rbegin(), alphabet.rend());
    if(alphabet[1] == 2) 
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;  

}

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

int main() {
  int N;
  cin >> N;
  int min = 1000000000;
  int num, counter = 0;
  for(int i = 0; i < N; i++){
      cin >> num;
      counter = 0;
      while(num % 2 == 0){
          counter++;
          num /= 2;
      }
      if(counter < min) min = counter;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    X,Y = map(int,input().split())
    B = Y - 2*X
    if B >= 0 and B%2 == 0 and 2*X - B >= 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N,l;
	cin >> N;
	vector<ll> v;
	for(ll i = 0;i < N;i++){
		cin >> l;
		v.pb(l);
	}

	sort(ALL(v));

	ll ans = 0;
	for (ll i = N - 1;i >= 2;i--){
		for (ll j = i - 1;j >= 1;j--){
			ll key = v[i] - v[j];
			auto ite = upper_bound(v.begin(),v.begin() + j,key);

			if (ite == v.begin() + j){
				ll index = 0;
			}
			else{
				ll index = distance(v.begin(),ite);
				ans += j - index;
			}
		}
	}
	cout <<ans <<endl;

	return 0;
}

Measured memory_bytes: 256
//import java.io.File;
import java.util.Scanner;
import java.util.Stack;

class Main{
  public static void main(String[] args) throws Exception{
    //Scanner scan = new Scanner(new File("in.txt"));
    Scanner scan = new Scanner(System.in);
    //MyScanner scan = new MyScanner();

    int input1 = scan.nextInt();
    Stack<Integer> st = new Stack<>();
    int stc = 0;
    int answer = 0;

    for(int incount = 0; incount < input1; incount++) {
      int input2 = scan.nextInt();
      boolean flag = true;

      try{
        while(st.peek() > input2) {
          st.pop();
          answer++;
          stc--;
        }
        if(st.peek() < input2) {
          st.push(input2);
          stc++;
        }
      }catch(Exception e) {
        stc++;
        st.push(input2);
      }

      /*
      for(int j = 0; j < ite; j++) {
        System.out.print(arr[j]+",");
      }
      System.out.println(" answer -> "+answer);
      */
    }
    System.out.println(answer+stc);
  }
}

Measured memory_bytes: 103936
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] ans = new int[201];
		int i=0;
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ans[i] = Integer.toString(a+b).length();
			i++;
		}
		i=0;
		while(ans[i]!=0){
			System.out.println(ans[i]);
			i++;
		}
	}
}

Measured memory_bytes: 20436
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int r = sc.nextInt();
            if(n == 0 && r == 0) break;
            
            List<Integer> card = new ArrayList<>();
            for(int i = n; i > 0; i--) {
                card.add(i);
            }

            for(int i = 0; i < r; i++) {
                int p = sc.nextInt();
                int c = sc.nextInt();
                List<Integer> v1 = new ArrayList<>();
                List<Integer> v2 = new ArrayList<>();
                List<Integer> v3 = new ArrayList<>();
                for(int j = 0; j < n; j++) {
                    if(j < p - 1) v1.add(card.get(j));
                    else if(j < p - 1 + c) v2.add(card.get(j));
                    else v3.add(card.get(j));
                }
                for(int j = 0; j < v1.size(); j++) {
                    v2.add(v1.get(j));
                }
                for(int j = 0; j < v3.size(); j++) {
                    v2.add(v3.get(j));
                }
                card = v2;
            }

            System.out.println(card.get(0));
        }
    }
}


Measured memory_bytes: 41484
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long int

main() {
	int n;
	cin>>n;
	int ans=0;
	for(int i=1; i<=n; i++){
		ans+=(n-i+1)*(i);
	}
	for(int i=0; i<n-1; i++){
		int u, v;
		cin>>u>>v;
		if(u>v){
			swap(u, v);
		}
		int num=0;
		num=u*(n-v+1);
		ans-=num;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3592
from collections import deque
H,W,K=map(int,input().split())
s=[list(input()) for i in range(H)]
ans=[[0 for j in range(W)] for i in range(H)]
q=deque([])
cnt=1
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            ans[i][j]=cnt
            cnt+=1
            q.appendleft((i,j))
while(len(q)>0):
    x,y=q.popleft()
    if 0<y:
        if ans[x][y-1]==0:
            q.append((x,y-1))
            ans[x][y-1]=ans[x][y]
    if y<W-1:
        if ans[x][y+1]==0:
            q.append((x,y+1))
            ans[x][y+1]=ans[x][y]
for i in range(H):
    if ans[i][0]!=0:
        q.append(i)
while(len(q)>0):
    k=q.popleft()
    if 0<k:
        if ans[k-1][0]==0:
            for j in range(W):
                ans[k-1][j]=ans[k][j]
            q.append(k-1)
    if k<H-1:
        if ans[k+1][0]==0:
            for j in range(W):
                ans[k+1][j]=ans[k][j]
            q.append(k+1)
for line in ans:
    print(*line)

        


Measured memory_bytes: 15084
Module Module1

    Sub Main()

        Dim ab As String
        Dim asd() As String
        Dim A As Integer
        Dim B As Integer

        Dim a1 As Integer
        Dim a2 As Integer
        Dim a3 As Integer

        Dim s As Integer

        ab = Console.ReadLine

        asd = Split(ab, " ")

        A = asd(0)
        B = asd(1)

        a1 = (A + B)

        a2 = (A - B)

        a3 = (A * B)

        If (a1 > a2) Then
            If (a1 > a3) Then
                s = a1
            Else
                s = a3
            End If
        Else
            If (a2 > a3) Then
                s = a2
            Else
                s = a3
            End If
        End If

        Console.WriteLine(s)

    End Sub

End Module


Measured memory_bytes: 13408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,k=MI()
lis=[0 for i in range(10**5)]
for i in range(n):
    a,b=MI()
    lis[a-1]+=b
#print(lis)
sm=0
for i in range(10**5):
    sm+=lis[i]
    #print(sm)
    if sm>=k:
        print(i+1)
        sys.exit()

Measured memory_bytes: 47088
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, m; cin >> n >> m;
	vector<vector<int>> gr(n + 1);

	for (int i = 1; i <= m; i++) {
		int u, v; cin >> u >> v;
		gr[u].push_back(v);
	}

	int s, t; cin >> s >> t;

	vector<array<int, 3>> dist(n + 1, array<int, 3>({INT_MAX, INT_MAX, INT_MAX}));

	dist[s][0] = 0;
	queue<array<int, 2>> q;
	q.push({s, 0});

	while (!q.empty()) {
		array<int, 2> par = q.front(); q.pop();
		for (auto child : gr[par[0]]) {
			if (dist[child][(par[1] + 1) % 3] == INT_MAX) {
				dist[child][(par[1] + 1) % 3] = dist[par[0]][par[1]] + 1;
				q.push({child, (par[1] + 1) % 3});
			}
		}
	}

	cout << ((dist[t][0] == INT_MAX) ? -1 : (dist[t][0] / 3));

	return 0;
}

Measured memory_bytes: 9440
package main

import (
	"fmt"
)

func main() {
	var A, B, V, W, T int
	fmt.Scan(&A, &V, &B, &W, &T)

	A, B = 0, Abs(B-A)
	a := A + T*V
	b := B + T*W
	if a >= b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 1752
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.front() == s.back()){
        if(s.length() % 2 == 0){
            cout << "First" << "\n";
        }else{
            cout << "Second" << "\n";
        }
    }else{
        if(s.length() % 2 == 0){
            cout << "Second" << "\n";
        }else{
            cout << "First" << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 512
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

double dp[3003][3003];

void solve(){
   int n; cin >> n;
   double data[n+5], ans = 0;
   for(int i = 1; i <= n; i++) cin >> data[i];
   
   dp[0][0] = 1;
   for(int i = 1; i <= n; i++){
      dp[i][0] = dp[i-1][0]*(1.0-data[i]);
      for(int j = 1; j <= n; j++){
         dp[i][j] = dp[i-1][j-1]*data[i] + dp[i-1][j]*(1-data[i]);
      }
   }
   
   for(int i = 1; i <= n; i++) {
      if(2*i < n) continue;
        ans += dp[n][i];
   }
   cout << setprecision(12) <<  ans << '\n';

}

signed main(){
  int t = 1; //cin >> t;
  while(t--){      
     solve();
  }
  //cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;      
}


Measured memory_bytes: 70656
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using LL = long long;

class Solution {
public:
	/* time: O(n + m), space: O(n), where n = # of items, m = # of tickets */
	LL powerfulDiscountTickets(const vector<int>& items, int m) {
		priority_queue<int> candidates(items.begin(), items.end());

		for (int i = 0; i < m; ++i) {
			const int worst = candidates.top();
			candidates.pop(), candidates.push(worst / 2);
		}

		LL ans = 0;
		while (!candidates.empty())
			ans += candidates.top(), candidates.pop();
		return ans;
	}
};

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

	vector<int> items(n);
	for (int i = 0; i < n; ++i)
		cin >> items[i];

	Solution sol;
	LL ans = sol.powerfulDiscountTickets(items, m);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <ll Mod>
struct ModInt {
  ll n;

  ModInt(const ll x = 0) : n(x) { while (n < 0) n += Mod; n %= Mod; }
  ModInt operator+(const ModInt r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt r) const { return ModInt(*this) /= r; }
  ModInt &operator+=(const ModInt r) {
    n += r.n;
    if (n >= Mod) n -= Mod;
    return *this;
  }
  ModInt &operator-=(const ModInt r) {
    if (n < r.n) n += Mod;
    n -= r.n;
    return *this;
  }
  ModInt &operator*=(const ModInt r) { n = n * r.n % Mod; return *this; }
  ModInt &operator/=(const ModInt r) { return *this *= r.inv(); }
  ModInt pow(ll x) const {
    ModInt<Mod> ret(1), tmp(*this);
    while (x) {
      if (x&1) ret *= tmp;
      tmp *= tmp;
      x >>= 1;
    }
    return ret;
  }
  ModInt inv() const { return pow(Mod-2); }
  friend ostream& operator<<(ostream& os, const ModInt& obj) { return os << obj.n; }
  friend istream& operator>>(istream& is, ModInt& obj) { ll t; is >> t; obj = ModInt(t); return is; }
};
constexpr ll mod = 1000000007;
using mint = ModInt<mod>;
mint operator"" _mi(unsigned long long n) { return mint(n); }

ll dfs(ll now, ll p, const vector<vl>& g, vl &size) {
  ll cnt = 1;
  for (auto&& i : g[now]) {
    if (i != p) {
      cnt += dfs(i, now, g, size);
    }
  }
  return size[now] = cnt;
}

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

  ll n;
  cin >> n;
  vector<vl> g(n);
  rep(i, n-1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  // size[i] := 頂点iを根とする部分木の頂点数
  vl size(n);
  dfs(0, 0, g, size);

  mint ans(0);
  rep(i, n) {
    mint cnt(0);

    for (auto&& j : g[i]) {
      ll t;
      if (size[j] < size[i]) t = size[j];
      else t = size[0]-size[i];
      cnt += (2_mi).pow(t)-1;
    }

    ans += (2_mi).pow(n-1)-(cnt+1_mi);
  }

  ans /= (2_mi).pow(n);
  cout << ans << endl;
}


Measured memory_bytes: 24192
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;
int[] a;

void main() {
    scan(n);
    a = readln.split.to!(int[]);

    int b1, b2, b3;

    foreach (ai ; a) {
        if (ai & 1) {
            b1++;
        }
        else if (ai & 3) {
            b2++;
        }
        else {
            b3++;
        }
    }

    writeln(b1 <= b3 + !b2 ? "Yes" : "No");
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4276
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int dp[11][11]={};
	int x,y,ss;
	char s;
	while(cin>>x>>s>>y>>s>>ss){
		dp[x][y]++;
		if(ss==1){
			if(y-1>=0) dp[x][y-1]++;
			if(y+1<=9) dp[x][y+1]++;
			if(x-1>=0) dp[x-1][y]++;
			if(x+1<=9) dp[x+1][y]++;
		}
		if(ss==2){
			if(y-1>=0) dp[x][y-1]++;
			if(y+1<=9) dp[x][y+1]++;
			if(x-1>=0) dp[x-1][y]++;
			if(x+1<=9) dp[x+1][y]++;
			if(x-1>=0&&y-1>=0) dp[x-1][y-1]++;
			if(x+1<=9&&y-1>=0) dp[x+1][y-1]++;
			if(x-1>=0&&y+1<=9) dp[x-1][y+1]++;
			if(x+1<=9&&y+1<=9) dp[x+1][y+1]++;
		}
		if(ss==3){
			if(y-1>=0) dp[x][y-1]++;
			if(y+1<=9) dp[x][y+1]++;
			if(x-1>=0) dp[x-1][y]++;
			if(x+1<=9) dp[x+1][y]++;
			if(x-1>=0&&y-1>=0) dp[x-1][y-1]++;
			if(x+1<=9&&y-1>=0) dp[x+1][y-1]++;
			if(x-1>=0&&y+1<=9) dp[x-1][y+1]++;
			if(x+1<=9&&y+1<=9) dp[x+1][y+1]++;
			if(x+2<=9) dp[x+2][y]++;
			if(x-2>=0) dp[x-2][y]++;
			if(y+2<=9) dp[x][y+2]++;
			if(y-2>=0) dp[x][y-2]++;
		}
	}
	int ans=0,max=0;
	for(int a=0;a<10;a++){
		for(int b=0;b<10;b++){
			if(dp[a][b]==0) ans++;
			if(dp[a][b]>=max) max=dp[a][b];
		}
	}
	cout<<ans<<endl;
	cout<<max<<endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mn = INF, d = 0;
    for (int i = 0; i < n; i++) {
        chkmin(mn, a[i]);
        chkmax(d, a[i] - mn);
    }
    set<int> s;
    mn = INF;
    for (int i = 0; i < n; i++) {
        chkmin(mn, a[i]);
        if (a[i] - mn == d) {
            s.insert(mn);
        }
    }
    cout << s.size();
}
/*

*/

Measured memory_bytes: 6388
#include <bits/stdc++.h>
  
using namespace std;
  
#define int long long
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

signed main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    vector<pll> p(n);
    sort(all(a));
    sort(all(b));
    sort(all(c));
    rep(i, n) {
        p[i].fi = b[i];
        p[i].se = lower_bound(all(a), b[i]) - a.begin();
    }
    sort(all(p));
    REP(i, 1, n) p[i].se += p[i-1].se;
    ll ans = 0LL;
    rep(i, n) {
        auto it = lower_bound(all(p), make_pair(c[i], 0LL));
        if(it == p.begin()) continue;
        --it;
        ans += it->se;
    }
    cout << ans << endl;
    // rep(i, n) {
    //     p[i].fi = b[i];
    //     p[i].se = (int)(c.end() - upper_bound(all(c), b[i]));
    //     // cout << b[i] << " " << p[i].se << endl;
    // }
    // sort(all(p));
    // repr(i, n-1) p[i].se += p[i+1].se;

    // ll ans = 0LL;
    // rep(i, n) {
    //     auto it = upper_bound(all(p), make_pair(a[i], INF));
    //     if(it == p.end()) continue;
    //     // cout << a[i] << " " << it->se << endl;
    //     ans += it -> se;
    // }
    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int D;
int main(){
  cin >> D;
  if(D==25){
    cout << "Christmas" << endl;
  }
  else if(D == 24){
    cout << "Christmas Eve" << endl;
  }
  else if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }
  else{
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
	int a, b, c, d, e, f;
	scanf("%d %d %d", &a, &b, &c);
	d = a + b;
	e = b + c;
	f = a + c;
	if (d < e && d < f) {
		printf("%d", d);
	}
	else if (e < d && e < f) {
		printf("%d", e);
	}
	else if (d == e && d == f) {
		printf("%d", d);
	}
	else {
		printf("%d", f);
	}
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int par[MAXN];
pii cost[MAXN];
int sz[MAXN];

int get_par(int a) {
	return par[a] == a ? par[a] : par[a] = get_par(par[a]);
}

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n) {
		scanf("%d", &cost[i]._1);
		cost[i]._2 = i;
		par[i] = i;
	}
	REP(i, 0, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		a = get_par(a);
		b = get_par(b);
		par[a] = b;
	}
	REP(i, 0, n) {
		int p = get_par(i);
		sz[p]++;
	}
	ll sum = 0ll;
	REP(i, 0, n) {
		sum += cost[i]._1;
	}
	sort(cost, cost + n);
	
	if (n == m + 1) {
		printf("0\n");
		return;
	}
	if (n == 2) {
		printf("%d\n", cost[0]._1 + cost[1]._1);
		return;
	}
	
	int cnt = 2 * m + 2 - n;
	if (cnt < 0) {
		printf("Impossible\n");
		return;
	}
	/*REP(i, 0, n) {
		if (i == get_par(i)) {
			printf("%d %d\n", i, sz[i]);
		}
	}*/
	
	for(int i = n - 1, j = 0; j < cnt; i--) {
		int s = cost[i]._2;
		int p = get_par(s);
		if (sz[p] == 1) {
			continue;
		}
		sum -= cost[i]._1;
		sz[p]--;
		j++;
	}
	printf("%lld\n", sum);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

class Dice
{
private:
  int d[6];
public:
  Dice();
  void CreateDice(int n1, int n2, int n3, int n4, int n5, int n6);
  void disp();
  void Roll_The_Dice(int top, int front);
  void compare_dice(Dice dice);
};

Dice::Dice(){
  for(int i = 0; i < 6; i++){
    d[i] = 0;
  }
}

void Dice::CreateDice(int n1, int n2, int n3, int n4, int n5, int n6){
  d[0] = n1;
  d[1] = n2;
  d[2] = n3;
  d[3] = n4;
  d[4] = n5;
  d[5] = n6;
}

void Dice::disp(){
  for(int i = 0; i < 6; i++){
    cout << d[i] << " ";
  }
  cout << endl;
}

void Dice::Roll_The_Dice(int top, int front){
  int tmp;
  int i = 0, count = 0;
  while(true){
    for(i = 0; i < 4; i++){
      if(d[0] == top){
        break;
      }
      tmp  = d[0];
      d[0] = d[4];
      d[4] = d[5];
      d[5] = d[1];
      d[1] = tmp;
    }
    if(d[1] == front && d[0] == top){
      break;
    }
    tmp  = d[3];
    d[3] = d[1];
    d[1] = d[2];
    d[2] = d[4];
    d[4] = tmp;
    i = 0;
    count++;
    if(count >= 3){
      break;
    }
  }
}

void Dice::compare_dice(Dice dice){
  int count = 0;
  for(int i = 0; i < 6; i++){
    if(d[i] == dice.d[i]){
      count++;
    }
  }
  if(count == 6){
    cout << "Yes" << endl;
  } else if(count <= 5){
    cout << "No" << endl;
  }
}

int main(){
  int n[6];
  for(int i = 0; i < 6; i++){
    cin >> n[i];
  }
  Dice dice1;
  dice1.CreateDice(n[0],n[1],n[2],n[3],n[4],n[5]);

  for(int i = 0; i < 6; i++){
    cin >> n[i];
  }
  Dice dice2;
  dice2.CreateDice(n[0],n[1],n[2],n[3],n[4],n[5]);

  for(int i = 0; i < 6; i++){
    if(n[i] != n[i+1]){
      dice1.Roll_The_Dice(n[i],n[i+1]);
      dice2.Roll_The_Dice(n[i],n[i+1]);
    }
  }
  dice1.compare_dice(dice2);
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n, m;
    cin >> n >> m;
    
    if(n%2 == 1) {
        exrep(i, 1, m) {
            cout << i << " " << n-i << "\n";
        }
    }
    else if(n%2 == 0) {
        ll i;
        for(i = 1; i <= m; i++) {
            if(n/2 <= 2*i) {
                break;
            }
            cout << i << " " << n-i << "\n";
        }
        for(; i <= m; i++) {
            cout << i << " " << n-1-i << "\n";
        }
    }
    
    re0;
}

Measured memory_bytes: 3628