akhauriyash/Code-Regression huggingface dataset:
h,w,m=map(int,input().split())
h=[]
w=[]
for i in range(m):
  h_,w_=map(int,input().split())
  h.append(h_)
  w.append(w_)
from collections import Counter
dic_h=Counter(h)
dic_w=Counter(w)
max_h=max(dic_h.values())
max_w=max(dic_w.values())

h_set=set()
w_set=set()
for i in dic_h:
  if dic_h[i]==max_h:
    h_set.add(i)
for j in dic_w:
  if dic_w[j]==max_w:
    w_set.add(j)

cnt=0
for i in range(m):
  if h[i] in h_set and w[i] in w_set:
    cnt+=1
if len(h_set)*len(w_set)>cnt:
  print(max_h+max_w)
else:
  print(max_h+max_w-1)
  
  


Measured memory_bytes: 79908
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
struct point{
    double x,y;
};
double k(int n,point p1,point p2){
    if(n==0){
        return 0;
    }
    point s,t,u;
    s.x=(2*p1.x+p2.x)/3;
    s.y=(2*p1.y+p2.y)/3;
    t.x=(p1.x+2*p2.x)/3;
    t.y=(p1.y+2*p2.y)/3;
    u.x=(t.x-s.x)/2-(t.y-s.y)*sqrt(3)/2+s.x;
    u.y=(t.x-s.x)*sqrt(3)/2+(t.y-s.y)/2+s.y;
    k(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    k(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    k(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    k(n-1,t,p2);
}
int main(){
    point p1,p2;
    int n;
    cin >>n;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    printf("%.8f %.8f\n",p1.x,p1.y);
    k(n,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);
}


Measured memory_bytes: 3208
#include <iostream>                                   
#include <cmath>                                      
using namespace std;                                  
                                                      
int main(void){                                       
  int n;                                              
  long int ans = 0,max = 0,minnum =1000000000;        
  int sign = 0;                                       
  cin >> n;                                           
  int a[n];                                           
                                                      
  for(int i = 0; i < n;++i){                          
    cin >> a[i];                                      
    if(a[i] < 0) sign++;                              
    if(minnum > abs(a[i])) minnum = abs(a[i]);        
    max += abs(a[i]);                                 
  }                                                   
  //偶数                                                
  if(sign % 2 == 0) cout << max << endl;              
  else cout << max-2*minnum << endl;                  
  return 0;                                           
}                                                     

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
int main()
{
	char a[105];
	scanf("%s",a);
	int n,m=0;
	n=strlen(a);
	for(int i=0;i<n/2;i++)
	{
		if(a[i]!=a[n-1-i])
		m++;
	}
	printf("%d\n",m);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define N 110 
using namespace std;
int A[N], dp[100010][2], n;
int fun(int a, int b){
	if(dp[a][b] != -1)
		return dp[a][b];
	int mk = 0;
	for(int i = 0; i < n; i++){
		if(A[i] <= a){
			if(fun(a - A[i], 1 - b) == b){
				mk = 1;
				break;
			}
		}
	}
	if(mk)
		return dp[a][b] = b;
	else return dp[a][b] = 1 - b;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin >> n >> k;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < n; i++)
		cin >> A[i];
	int r = fun(k, 0);
	if(!r)
		cout << "First\n";
	else cout << "Second\n";


}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<int> v(3);
    for(int i=0; i<3; ++i)
        cin >> v[i];

    int k;
    cin >> k;
    sort(v.rbegin(), v.rend());
    while(--k >= 0)
        v[0] *= 2;

    int ans = accumulate(v.begin(), v.end(), 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int input;
vector<int> nums;

int main() {
	for (int i = 0; i < 5; i++) {
		cin >> input;
		nums.push_back(input);
	}

	sort(nums.begin(), nums.end());
	reverse(nums.begin(), nums.end());

	for (int i = 0; i < 5; i++) {
		cout << nums[i];
		if (i < 4) cout << " ";
	}
	cout << endl;

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if((s[2]=='0' && s[3]>'0'||s[2]=='1' && s[3]<='2') && (s[0]=='0' && s[1]>'0' || s[0]=='1' && s[1]<=2))
    {
        if(s[0]==0 && s[1]>0 || s[0]>0 && s[1]>=0 && s[2]==0 && s[3]>0 || s[2]>0 && s[3]>=0){
            cout<<"AMBIGUOUS"<<endl;}


    }
    else if(s[2]=='0' && s[3]>'0'||s[2]=='1' && s[3]<='2')
    {
        if(s[0]==0 && s[1]>0 || s[0]>0 && s[1]>=0)
        cout<<"YYMM"<<endl;
    }
    else if(s[0]=='0' && s[1]>'0' || s[0]=='1' && s[1]<=2)
    {
        if(s[2]==0 && s[3]>0 || s[2]>0 && s[3]>=0)
            cout<<"MMYY"<<endl;
    }
    else{
            cout<<"NA"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){

    int m,n;
    while(cin>>m>>n,m||n){
        int now = 1;
        int num = m;
        int i;
        bool isDead[10020] = {};
        for(i = 1;i <= n;i++){
            char s[100];
            scanf("%s",s);
            if(strcmp(s,"Fizz") == 0){
                if(i%3 == 0 && i%5 != 0);
                else isDead[now] = true,n--;
                do{
                    now++;
                    if(now == m+1)now = 1;
                }while(isDead[now]);
                if(num == 1){
                    cout<<now<<endl;
                    goto next;
                }
            }
            else if(strcmp(s,"Buzz") == 0){
                if(i%3 != 0 && i%5 == 0);
                else isDead[now] = true,num--;

                do{
                    now++;
                    if(now == m+1)now = 1;
                }while(isDead[now]);
                if(num == 1){
                    cout<<now<<endl;
                    goto next;
                }
            }
            else if(strcmp(s,"FizzBuzz") == 0){
                if(i%3 == 0 && i%5 == 0);
                else isDead[now] = true,num--;

                do{
                    now++;
                    if(now == m+1)now = 1;
                }while(isDead[now]);
                if(num == 1){
                    cout<<now<<endl;
                    goto next;
                }
            }
            else{
                if(atoi(s)!=i || i%3==0 || i%5==0)
                    isDead[now] = true,num--;
                do{
                    now++;
                    if(now == m+1)now = 1;
                }while(isDead[now]);
                if(num == 1){
                    cout<<now<<endl;
                    goto next;
                }
            }

        }
        {
            bool flg = false;
            for(int j = 1;j <= m;j++){
                if(!isDead[j]){
                    if(flg)cout<<" ";
                    cout<<j;
                    flg = true;
                }
            }
            cout<<endl;
        }
        goto kitanai;
        next:;
        for(i++;i <= n;i++){
            string s;
            cin>>s;
        }
        kitanai:;
    }

    return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n;
ll ans;
//string s;
signed main(){
	acc_io;
	ans=0;
	cin>>n;
	ll a;
	rep(i,0,n){
		cin>>a;
		ans+=a-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N,X,Y = map(int,input().split())
cnt = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        min0 = min(j-i,abs(X-i)+1+abs(j-Y))
        cnt[min0] += 1
for num,i in enumerate(cnt):
    if num == 0:continue
    else:print(i)

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

map< ll, ll > prime_factor(ll n) {
    map< ll, ll > ret;
        for(ll i = 2; i * i <= n; i++) {
            while(n % i == 0) {
                ret[i]++;
                n /= i;
            }
        }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main(void){
    ll n;
    cin>>n;
    map<ll, ll> mp = prime_factor(n);
    vector<ll> v(1000005);
    v[1] = 1;
    for(int i = 2;i<=1000000;i++){
        v[i] = v[i-1]+i;
    }
    ll ans = 0;
    for(auto p : mp){
        auto itr = upper_bound(v.begin(), v.end(), p.second);
        ans += (ll)(itr-v.begin())-1LL;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
char c[10][10];
int h,w;
int num = 0;

int dfs(int i,int j,int r,int cnt){
	if(i == h-1 && j == w-1){
		if(cnt == num-1)return 1;
		else return 0;
	}
	
	if(i >= h || j >=w)return 0;

	//cout << i <<  " " << j <<endl;
	
	int a=0,b=0;
	if(c[i-1][j] == '#')if(r != 1)return 0;
	if(c[i][j-1] == '#')if(r != 0)return 0;
	
	if(c[i+1][j] == '#')a = dfs(i+1,j,1,cnt+1);
	if(c[i][j+1] == '#')b = dfs(i,j+1,0,cnt+1);

	return max(a,b);
}
int main(){
	
	cin >> h >> w;
	
	for(int i =0;i<h;i++){
		for(int j =0;j<w;j++){
			cin >> c[i][j];
			if(c[i][j] == '#')num++;
		}
	}

	int ans = dfs(0,0,99,0);

	if(ans ==0)cout <<"Impossible" << endl;
	else cout << "Possible"<< endl;
	

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, s[11000], ans = 0;
int main(){
	cin >> n;
	REP(i, n * 2)cin >> s[i];
	sort(s, s + n * 2,greater<ll>());
	REP(i, n) {
		ans += s[i * 2 + 1];
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli mod = 1e9 + 7;
lli n;
vector<pair<lli, lli>> e;
vector<vector<lli>> v;
vector<array<lli, 2>> dp;

lli dfs(lli n, lli c, lli from) {
  if (dp[n][c] > 0) return dp[n][c];
  lli y = 1;
  if (c == 0) {
    for (lli to : v[n]) 
      if (to != from) y = y * (dfs(to, 0, n) + dfs(to, 1, n)) % mod;
  } else {
    for (lli to : v[n]) 
      if (to != from) y = y * dfs(to, 0, n) % mod;
  }
  return dp[n][c] = y;
}

int main() {
  cin >> n;
  init_n(e, n);
  for (lli i=0; i<n-1; ++i) cin >> e[i].first >> e[i].second;
  init_n(v, n+1);
  for (lli i=0; i<n-1; ++i) {
    v[e[i].first].push_back(e[i].second);
    v[e[i].second].push_back(e[i].first);
  }
  init_n(dp, n + 1);
  lli ans = (dfs(1, 0, 0) + dfs(1, 1, 0)) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 17152
# -*- coding: utf-8 -*-
h,w,k = list(map(int,input().split()))
c = [list(input()) for _ in range(h)]
black_total  = 0
row_black_cnt = []
col_black_cnt = []
for ci in c:
    row_black_cnt.append(ci.count("#"))
    black_total+=ci.count("#")

for cj in zip(*c):
    col_black_cnt.append(cj.count("#"))

cc = []
for i in c:
    tmp = []
    for j in i:
        if j =="#":
            tmp.append(1)
        else:
            tmp.append(0)
    cc.append(tmp)
from itertools import product
row_itrt = list(product([0,1],repeat=h))
col_itrt = list(product([0,1],repeat=w))

ret = 0
for row_ptn in row_itrt:
    row_ptn = [i for i,v in enumerate(row_ptn) if v==1]
    for col_ptn in col_itrt:
        cnt = black_total
        col_ptn = [i for i,v in enumerate(col_ptn) if v==1]
        for r in row_ptn:
            for c in col_ptn:
                cnt += cc[r][c]
        for r in row_ptn:
            cnt -= row_black_cnt[r]
        for c in col_ptn:
            cnt -= col_black_cnt[c]
        if cnt==k:
            ret+=1

print(ret)


Measured memory_bytes: 9276
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int maxn = 1010;
double inf = 10000000000000000000007.0;
using namespace std;
int n, opt[maxn]; bool vis[maxn]; double f[maxn]; 
struct poi { double x, y, r; } a[maxn];
double getdis(poi a, poi b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int main() {
	scanf("%lf%lf%lf%lf", &a[0].x, &a[0].y, &a[1].x, &a[1].y);
	scanf("%d", &n), ++ n, a[0].r = a[1].r = 0; 
	rep(i, 2, n) scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].r);
	int he = 0, ta = 1; opt[1] = 0;
	rep(i, 1, n) f[i] = inf, vis[i] = true; f[0] = 0, vis[0] = false;
	while (he != ta) {
		he = (he + 1) % maxn; int u = opt[he];
		rep(i, 1, n) {
			double ret = max(getdis(a[u], a[i]) - a[u].r - a[i].r, 0.0) + f[u];
			if (ret < f[i]) {
				f[i] = ret;
				if (vis[i]) vis[i] = false, ta = (ta + 1) % maxn, opt[ta] = i;
			}
		}
		vis[u] = true;
	}
	printf("%.12lf", f[1]);
	return 0;
}

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

int n;
using ll = long long;

int main() {
    std::cin >> n;
    std::vector<ll> vec;
    for (int i = 0; i < n; i++) {
        ll p;
        std::cin >> p;
        vec.push_back(p);
    }
    std::sort(vec.begin(), vec.end());
    ll min_diff = 1000000000;
    bool all_same = true;
    for (int i = 0; i < n-1; i++) {
        ll diff = vec[i+1]-vec[i];
        if (diff != 0) {
            all_same = false;
        }
        if (diff <= min_diff && diff != 0) {
            min_diff = diff;
        }
    }
    if (all_same) {
        std::cout << vec[0] << std::endl;
        return 0;
    }
    int x, y;
    if (min_diff <= vec[0]) {
        x = vec[0];
        y = min_diff;
    }
    else {
        x = min_diff;
        y = vec[0];
    }
    while (x % y != 0) {
        int temp = x % y;
        x = y;
        y = temp;

        
    }
    std::cout << y << std::endl;
    

    return 0;
}


Measured memory_bytes: 1400
#define _USE_MATH_DEFINES 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);

int main() {
	ll n, m, a, b, ans = 0;
	cin >> n >> m;
	vector<pair<ll, ll>> v;
	rep(i, n) {
		cin >> a >> b;
		v.push_back(pair<ll, ll>(a, b));
	}
	sort(v.begin(), v.end());
	rep(i, n) {
		ans += v[i].first * min(m, v[i].second);
		m -= v[i].second;
		if (m <= 0) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2548
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val r = readInt()
    println(java.lang.Math.PI * r * 2)
}


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


int main(){
    int L, R; cin >> L >> R;
    int ans = 1e9;
    int probe;
    for (int i = L; i <= min(L + 2019, R); i++) {
        for (int j = i + 1; j <= min(L + 2019, R); j++) {
            probe = (i % 2019) * (j % 2019) % 2019;
            ans = min(ans, probe);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int> > G(N), RG(N);
	vector<int> indeg(N);
	for (int i = 0; i < (N - 1) + M; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		RG[b].push_back(a);
		++indeg[b];
	}
	queue<int> que;
	for (int i = 0; i < N; ++i) {
		if (indeg[i] == 0) {
			que.push(i);
		}
	}
	vector<int> topos; // topological sort order
	while (!que.empty()) {
		int u = que.front(); que.pop();
		topos.push_back(u);
		for (int i : G[u]) {
			--indeg[i];
			if (indeg[i] == 0) {
				que.push(i);
			}
		}
	}
	vector<int> topos_inv(N); // inversion of "topos" permutation
	for (int i = 0; i < N; ++i) {
		topos_inv[topos[i]] = i;
	}
	for (int i = 0; i < N; ++i) {
		int mx = -1;
		for (int j : RG[i]) {
			if (topos_inv[j] > mx) {
				mx = topos_inv[j];
			}
		}
		cout << (mx == -1 ? -1 : topos[mx]) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <string>
#define N 100005
#define INF (1 << 30)
typedef long long ll;
using namespace std;

vector<int> child[N];
int parent[N];
int GetDepth(int idx)
{
	int ret = 0;
	while (parent[idx] != -1)
	{
		++ret;
		idx = parent[idx];
	}
	return ret;
}
const char *str[3] = { "root", "internal node", "leaf" };
int main()
{
	int n;
	scanf("%d", &n);
	fill(parent, parent + n, -1);
	int id, k, c;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d %d", &id, &k);
		for (int j = 0; j < k; ++j)
		{
			scanf("%d", &c);
			parent[c] = id;
			child[id].push_back(c);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int depth = GetDepth(i);
		int status;
		if (depth == 0)
			status = 0;
		else if (child[i].size())
		{
			status = 1;
			sort(child[i].begin(), child[i].end());
		}
		else
			status = 2;
		printf("node %d: parent = %d, depth = %d, %s, ", i, parent[i], depth, str[status]);
		printf("[");
		for (int j = 0; j < child[i].size(); ++j)
		{
			if (j)
				printf(", ");
			printf("%d", child[i][j]);
		}
		printf("]\n");
	}
	return 0;
}

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

int A[200009], B[200009];

int main() {
    int N, ans = 0; scanf("%d",&N);
    for(int i=0; i<N; i++) scanf("%d",&A[i]);
    for(int i=0; i<N; i++) scanf("%d",&B[i]);
    for(int i=0; i<=28; i++) {
        int T = (1 << (i+1));
        sort(A, A+N, [&](int a, int b) { return a % T > b % T; });
        sort(B, B+N, [&](int a, int b) { return a % T < b % T; });
        B[N] = T-1;
        long long s = 0;
        int l = 0, r = -1;
        for(int j=0; j<N; j++) {
            while(r < N && A[j]%T + B[r+1]%T < T) ++r;
            while(l < N && A[j]%T + B[l]%T < T/2) ++l;
            if(l == N) break;
            r = min(r, N-1);
            s += r-l+1;
        }
        l = 0, r = -1;
        for(int j=0; j<N; j++) {
            while(r < N && A[j]%T + B[r+1]%T < 2*T) ++r;
            while(l < N && A[j]%T + B[l]%T < T+T/2) ++l;
            if(l == N) break;
            r = min(r, N-1);
            s += r-l+1;
        }
        if(s % 2) ans += T/2;
    }
    printf("%d",ans);
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > v(n);
    int a;
    for(int i=0;i<n;++i){
        cin >> a;
        v.push_back(make_pair(a,i));
    }
    sort(v.begin(),v.end(),greater<>());
    for(int i=0;i<n;++i){
        if(i!=v[0].second){
            cout << v[0].first << endl;
        }
        else
            cout << v[1].first << endl;
    }
    return 0;
}

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

int main(){
  int N;
  scanf("%d",&N);
  vector<int> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&H[i]);
  }
  if(N==1){
    printf("Yes\n");
    return 0;
  }
  for (int i = N - 2; i >= 0; i--){
    if (H[i] <= H[i + 1]){
      continue;
    }
    else if (H[i] - 1 == H[i + 1]){
      H[i]--;
    }
    else{
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int i=0; i<=N; i++){
        for (int j=0; j<=N; j++){
            int k=N-i-j;
            if (10000*i+5000*j+1000*k==Y && i+j+k==N && k>=0){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


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

using namespace std;


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

    for (int i = 0; i <= N; i++)sum += abs(a[i] - a[i+1]);
    for (int i = 1; i <= N; i++) {
        int res = sum + abs(a[i+1]-a[i-1]) - (abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]));
        cout << res<<endl;
    }
}

Measured memory_bytes: 1664
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  string S;
  LL i,ans=0;
  cin>>S;
  rep(i,S.size()/2)if(S[i]!=S[S.size()-1-i])ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def check(n):

    if n <= P-1:
        return True
    
    if A[n]+M < A[P-1]:
        return False
    
    votes = (P+N-1-n)*M + sum([A[n]+M-A[i] for i in range(P-1,n)])

    if votes < M*V:
        return False
    else:
        return True

N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

right = N-1
left = 0

if check(right):
    print(N)
    exit()

while abs(right-left) > 1:

    mid = (right+left)//2

    if check(mid):
        left = mid
    else:
        right = mid

print(left+1)


Measured memory_bytes: 14964
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a=a-b;
    if(a<=c)
    {
        printf("%d\n",c-a);
        return 0;
    }
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define mo 1000000007ll
#define N 2000010
ll jc[N],ijc[N],r,x[N],y[N];
int t;
ll qp(ll x,ll y){
	ll r=1;
	for(;y;y>>=1,x=x*x%mo)
		if(y&1)r=r*x%mo;
	return r;
}
struct no{
	int x,y,t;
}v[N];
ll cc(ll y,ll x){return jc[y]*ijc[x]%mo*ijc[y-x]%mo;}
ll f(ll a,ll b,ll c,ll d){
	int e=abs(c-a),f=abs(d-b);
	return cc(e+f,f);
}
ll ga(int a,int b,int c,int d,int e,int g){
	int r=0;
	for(int i=x[3];i<=x[4];i++){
		r=(r+f(a,b,i,y[4])*f(i,y[4]+1,c,d)%mo*(i+y[4]+1)%mo)%mo;
		r=(r-f(a,b,i,y[3]-1)*f(i,y[3],c,d)%mo*(i+y[3])%mo+mo)%mo;
	}
	for(int i=y[3];i<=y[4];i++){
		r=(r+f(a,b,x[4],i)*f(x[4]+1,i,c,d)%mo*(x[4]+i+1)%mo)%mo;
		r=(r-f(a,b,x[3]-1,i)*f(x[3],i,c,d)%mo*(x[3]+i)+mo)%mo;
	}
	r*=e*g;
	return r;
}
signed main(){
	jc[0]=ijc[0]=1;
	for(ll i=1;i<N;i++)jc[i]=jc[i-1]*i%mo;
	ijc[N-1]=qp(jc[N-1],mo-2);
	for(ll i=N-2;i;i--)ijc[i]=ijc[i+1]*(i+1ll)%mo;
	for(int i=1;i<7;i++)cin>>x[i];
	for(int i=1;i<7;i++)cin>>y[i];
	v[1]=(no){x[1]-1,y[1]-1,1};
	v[2]=(no){x[2],y[1]-1,-1};
	v[3]=(no){x[1]-1,y[2],-1};
	v[4]=(no){x[2],y[2],1};
	v[5]=(no){x[5],y[5],1};
	v[6]=(no){x[6]+1,y[5],-1};
	v[7]=(no){x[5],y[6]+1,-1};
	v[8]=(no){x[6]+1,y[6]+1,1};
	for(int i=1;i<5;i++)
		for(int j=5;j<9;j++)
			r=(r+ga(v[i].x,v[i].y,v[j].x,v[j].y,v[i].t,v[j].t)+mo)%mo;
	cout<<r;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long 
#define lli long long int
#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


#define int long long 

int ar[100005];
int n;
int dp[100005];
//int ar[200001];

int func(int idx)
{
	if(idx==(n-1)) return 0;


	if(dp[idx]!=-1) return dp[idx];


	int left = abs(ar[idx]-ar[idx+1]) + func(idx+1);

	int right=INT_MAX;

	if(idx+2<n)
		right=abs(ar[idx]-ar[idx+2]) + func(idx+2);

	return dp[idx]=min(left,right);
}
signed main()
{
	//c_p_c();
	memset(dp,-1,sizeof dp);
    //int n;
    cin>>n;
    //int ar[n];
    for(int i=0;i<n;i++)
    {
    	cin>>ar[i];
    }

    cout<<func(0);

}


Measured memory_bytes: 4992
#include<stdio.h>

int main(void){
   int x1,x2,x3,x4,x5;
 


       
       scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5);

      if(x1==0){
         printf("%d\n",1);
      }else if(x2==0){
         printf("%d\n",2);
      }else if(x3==0){
         printf("%d\n",3);
      }else if(x4==0){
         printf("%d\n",4);
      }else if(x5==0){
          printf("%d\n",5);
      }
   return 0;  
}

Measured memory_bytes: 1724
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.S;
		
		Console.WriteLine("{0}",n>=3200?a:"red");
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main(){
    int n,m,i,sumt;
    double mm;
    int k;
    


    sumt=0;
    k=0;
    cin >> n >> m;
    int a[n];
    for (i=1;i<=n;i++){
        cin >> a[i];
        sumt+=a[i];
    }
    mm=sumt/(4.0*m);
    
    for (i=1;i<=n;i++){
        if (a[i]>=mm) k++;
        

    }
    
    if (k>=m){
        wcout << "Yes" << endl;
    }
    else{
        wcout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        q.push(a);
    }
    for(int i=0;i<m;i++){
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=q.top();q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
n, *aa = map(int, open(0).read().split())

d = [0]*n

cur = 1

ans = 0

while 1:
    d[cur-1] = 1
    cur = aa[cur-1]
    ans += 1
    if cur == 2:
        print(ans)
        break
    if d[cur-1]:
        print(-1)
        break

Measured memory_bytes: 20168
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int N,M;
  cin >> N >> M;
  bool DP[N] = {0};
  int counter[N];
  FOR(i,0,N)counter[i]=1;
  DP[0] = 1;
  int x,y;
  FOR(i,0,M){
    cin >> x >> y;
    x--;
    y--;
    if(counter[x] > 1){
      if(DP[x])DP[y]=1;
      counter[x]--;
      counter[y]++;
    }
    else{
      if(DP[x]){
        DP[y] = 1;
        DP[x] = 0;
      }
      counter[x]--;
      counter[y]++;
    }
  }
  int ans = 0;
  FOR(i,0,N)if(DP[i])ans++;
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)){
    cout<<"A"<<endl;
  }else{
    cout<<"B"<<endl;
  }
}


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

using namespace std;

int main()
{
	int k, a, b;
  	
  	cin >> k >> a >> b;
  
 	for (int i = a; i<=b;i++)
      if (i % k == 0)
      {
        cout << "OK\n";
        return 0;
      }
  
  	cout << "NG\n";
      
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int ans;
int frog(int *a, int i, int n,int *dp)
{
  //base condition
  if(i==n-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  if(i+1<=n-1)
  {
    ans = int(abs(a[i]-a[i+1])) + frog(a, i+1, n, dp);
  }
  if(i+2<=n-1)
  {
    ans  = min(ans, int(abs(a[i]-a[i+2])) + frog(a, i+2, n, dp));
  }
  return dp[i] =  ans;
}
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n+1];
  for(int i=0;i<=n;i++)
    dp[i]=-1;
  cout<<frog(a,0,n,dp)<<endl;
}


Measured memory_bytes: 13676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){

ll n;cin >> n;
ll tem=1;
for(ll i=0;i<n;i++){
    if(i*i>n)break;
    else {
        tem=max(tem,i*i);
    }
}
cout << tem << endl;
return 0;
}





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

int main() {
  
  string S;
  cin >> S;
  
  int count = 0;
  for (int i = 0; i < 3; i++){
    for (int j = i+1; j < S.size(); j++){
      if (S[i] == S[j]) count++;    
    }
  }
  
  if (count == 2) cout << "Yes";
  else cout << "No";
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<ll>h(n);
  vector<ll> dp(n+1, INF);
  rep(i,n)cin>>h[i];

  dp[0]=0;
  rep(i, n){
    ll c = h[i];
    rep(j, k)dp[i+j+1] = min<ll>(dp[i+j+1], dp[i] + abs<ll>(h[i+j+1] - c));
  }

  cout<<dp[n-1]<<endl;
//rep(i, n+1)cout<<dp[i]<<' ';cout<<endl;
//rep(i, n)cout<<h[i]<<' ';

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n;vector<int> v[110000];int c[110000],ans[110000];pair<int,int> dig[110000];
int cind,ansM;

void f(int ver){
  //cout << "ver : " << ver << endl;
  vector<int> next;
  for(int nver : v[ver]){
    if(ans[nver] != -1)continue;
  //cout << "nver : " << nver << " " << cind << endl;
    next.push_back(nver);
    ans[nver] = c[cind];
    ansM += c[cind];
    cind++;
  }
  for(int nver : next){
    f(nver);
  }
}

signed main(){  
  int a,b,c,d;cin>>a>>b>>c>>d;
  int ans = b-a+1;
  ans -= (b/c - (a-1)/c);
  ans -= (b/d - (a-1)/d);
  ans += (b/(c*d/__gcd(c,d)) - (a-1)/(c*d/__gcd(c,d)));
  cout << ans << endl;
}


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

int main() {
    int a = 0, b = 0, c= 0;
    cin >> a >> b >> c;

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ull;
    typedef long long ll;
    #define ll long long
    #define dd double
    #define MOD1 1000000007
    #define MOD2 998244353
    #define nl cout<<endl
    #define rt ll Q[100005]={0}
    #define mp make_pair
    #define test() ll t;cin>>t;while(t--)
    #define pb push_back
    #define ff first    
    #define ss second
    #define all(v) v.begin(),v.end()
    #define s(ar,n) sort(ar,ar+n)
    #define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
    #define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
    #define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
    #define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
    #define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
    #define maxa(ar,N) *max_element(ar,ar+N)
    #define mina(ar,N) *min_element(ar,ar+N)
    #define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    typedef pair<ll,ll> pii;
    ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
    ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
    ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
    ll m=1e9;
    int main()
    {
        fastio();
        ll n,m;
        cin>>n;
        ll a[n];
        cn(a,n);
        ll f[n+1]={0};
        for(int i=0;i<n-1;i++)
            f[a[i]]++;
        for(int i=1;i<=n;i++)
            cout<<f[i]<<endl;
    }

Measured memory_bytes: 6744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//宣言文
		//標準入力オブジェクトを生成
		Scanner sc = new Scanner(System.in);
		//標準入力で以下の変数を初期化
		int number = sc.nextInt();
		int[] numArray = new int[number];
		for(int i = 0; i < numArray.length; ++i) {
			numArray[i] = sc.nextInt();
		}
		sc.close();
		//カウント変数
		int countNum = 0;
		boolean flagNum = true;
		
		do {
			for(int i = 0; i < numArray.length; i++) {
				//全て偶数か判定
				if(!(numArray[i]%2 == 0)){
					flagNum = false;
					break;
				}
				//割る２する処理を流す。
				numArray[i] = numArray[i] / 2;
			}
			//全体の処理をカウント
			if(flagNum) {
				countNum++;
			}
		}while(flagNum);//全て偶数なら繰り返す
			//標準出力
			System.out.print(countNum);
	}
}


Measured memory_bytes: 21972
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    vector<int> d;
    int tmp_d;
    int ans=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_d;
        d.push_back(tmp_d);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}


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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1LL; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1LL; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
/*
class Dinic {
public:
  vector<vector<pair<int, int>>> v;
  vector<int> e;

  vector<int> k;
  vector<int> j;

  void init(int n) {
    v = vector<vector<pair<int, int>>>(n);
    e = vector<int>();
    k = vector<int>(n);
    j = vector<int>(n);
  }
  void add_edge(int a, int b, int atob, int btoa = 0) {
    v[a].push_back(make_pair(b, e.size()));
    e.push_back(atob);
    v[b].push_back(make_pair(a, e.size()));
    e.push_back(btoa);
  }
  void dyk(int s) {
    for(auto& i : k) {
      i = inf;
    }
    queue<pair<int, int>> pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()) {
      int w = pq.front().first;
      int b = pq.front().second;
      pq.pop();
      if(k[b] > w) {
        k[b] = w;
        for(auto i : v[b]) {
          if(e[i.second] > 0) {
            pq.push(make_pair(w + 1LL, i.first));
          }
        }
      }
    }
  }
  int dfs(int s, int t, int p, int c) {
    if(p == t) {
      return c;
    }
    int all = 0;
    while(c > all && j[p] < v[p].size()) {
      if(k[v[p][j[p]].first] == k[p] + 1LL) {
        int r = dfs(s, t, v[p][j[p]].first, min(c - all, e[v[p][j[p]].second]));
        e[v[p][j[p]].second] -= r;
        e[v[p][j[p]].second ^ 1LL] += r;
        if(r < c - all) {
          j[p]++;
        }
        all += r;
      }
      else {
        j[p]++;
      }
    }
    return all;
  }
  int solve(int s, int t) {
    int all = 0;
    while(1LL) {
      dyk(s);
      for(auto& i : j) {
        i = 0;
      }
      int r = dfs(s, t, s, inf);
      if(r == 0) {
        return all;
      }
      all += r;
    }
  }
};
*/

int n, a, b;
int d[114514];

bool can(int w) {
  int s = a - b;
  int all = 0;
  rep(i, n) {
    int t = d[i] - w * b;
    if(t > 0) {
      all += (t + s - 1) / s;
    }
  }
  return all <= w;
}

signed main() {
  cin >> n >> a >> b;
  rep(i, n) {
    cin >> d[i];
  }
  int b = -1;
  int e = inf;
  while(b < e - 1) {
    int m = (b + e) / 2;
    if(can(m)) {
      e = m;
    }
    else {
      b = m;
    }
  }
  cout << e << endl;
}


Measured memory_bytes: 1024
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define mod 1000000007
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long
  #define pie 3.1415926535897932384626433832795028

  int arr[N];

int32_t main()
{




    int n,r;
    cin >> n >> r;

     int ans = 0;


    for(int i = r; i <= n+1; i++)
    {
      i %= mod;
      ans +=  (n)*(i) - i*(i-1) + 1 + mod;
      ans %= mod;
    }

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  vector<int64_t> vec(N), A(N);
  for(int i=0; i<N; i++) cin >> vec[i];
  
  int m = 0;
  for(int i=0; i<N; i++){
    if(m < vec[i]) m = vec[i];
    A[i]= m;
  }
  
  int64_t ans = 0;
  for(int i=0; i<N; i++){
    ans += A[i]-vec[i];
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 6416
n = int(input())
a = [int(input()) for i in range(n)]
maxv = max(a)
if a.count(maxv) == 1:
    for i in range(n):
        if a[i] == maxv:
            print(sorted(a, reverse=True)[1])
        else:
            print(maxv)
else:
    for i in range(n):
        print(maxv)




Measured memory_bytes: 68540
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int A, B;
    cin >> A >> B;


    int ans = 0;
    p(A*B);
    

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh submit.sh
*/


Measured memory_bytes: 3652