akhauriyash/Code-Regression huggingface dataset:
//なんで遅いんだろ
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char ci[cm];
char* cn = ci + cm;
inline char getcha() {
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	return *cn++;
}

inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

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


	int N;
	N = getint();
	int A[200000];
	ll B[200001], C;
	B[0] = 0;
	C = 0;

	vector<int> V;
	V.pb(0);
	rep(i, N) A[i] = getint();
	ll mae = A[0];
	rep(i, N) {
		ll a = A[i];
		B[i + 1] = B[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				B[i + 1] += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
	}
	V.clear();
	mae = A[N - 1];
	V.pb(0);
	ll kotae = 2 * B[N] + N;
	for (int i = N - 1; i >= 0; i--) {
		ll a = A[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				C += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
		kotae = min(kotae, B[i] + B[i] + C + C + i);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

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

using namespace std;

int n, k;

int a[2000123], ans = 1e9;

int main () {
    cin >> k >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }
    ans = min (a[n] - a[1], k - a[n] + a[n - 1]);
    for (int i = 2;i <= n;i ++) {
        ans = min (ans, k - a[i] + a[i - 1]);
        ans = min (ans, a[i] + k - a[i + 1]);
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;



int main() {long N;
vector<char> s(4);vector<long> n(4);

rep(i, 0, 4) {
    cin >> s[i];
    n[i] = s[i] - '0';
}
vector<char> sign = {'-', '+'};
vector<long> signpos(3);
rep(i, 0, (1 << 3)){
    long tmp = n[0];
    rep(j, 0, 3){
        if(1 & (i >> j)) {
            tmp += n[j+1];
            signpos[j] = 1;
        }
        else {
            tmp -= n[j+1];
            signpos[j] = 0;
        }
    }
    if(tmp == 7){
        cout << n[0] << sign[signpos[0]] << n[1] << sign[signpos[1]]
         << n[2] << sign[signpos[2]] << n[3] << "=7" << endl;
         return 0;
    }
}


  return 0;
 
}



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

int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    else if(a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3096
/*
Created at: 2018 December 22 16:55:07
Created by: metamorphosis00
*/
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int binpow(int a, int n)
{
    int res = 1;
    while(n > 0) {
        if (n & 1) {
            res *= a;
            n--;
        } else {
            a *= a;
            n >>= 1;
        }
    }
    return res;
}
main() {
    int n = readInt(), p = readInt();
    int ans = 1;
    for (int i = 2; i * i <= p; i++) {
        if (p % i == 0) {
            int k = 0;
            while (p % i == 0) {
                p /= i;
                k++;
            }
            ans *= binpow(i, k / n);
        }
    }
    if (p > 1) {
        ans *= binpow(p, 1 / n);
    }
    cout << ans;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(){
 
    int DataSetNum = 0;
    int HouseNum = 0;
    int GeneNum = 0;
    int* HousePos;
    int* CableLength;
    int AllCableLength = 0;
 
    cin >> DataSetNum;
    for (int datanum = 0; datanum < DataSetNum; ++datanum){

        cin >> HouseNum;
        cin >> GeneNum;
        HousePos = new int[HouseNum];
        for (int i = 0; i < HouseNum; ++i){
            cin >> HousePos[i];
        }
        if (HouseNum <= GeneNum){
            cout << 0 << endl;
            continue;
        }
        CableLength = new int[HouseNum - 1];
        for (int i = 0; i < HouseNum - 1; ++i){
            CableLength[i] = HousePos[i + 1] - HousePos[i];
        }
        AllCableLength = HousePos[HouseNum - 1] - HousePos[0];

        sort(&CableLength[0], &CableLength[0]+HouseNum-1);
        for (int i = 0; i < GeneNum - 1; ++i){
            AllCableLength -= CableLength[HouseNum - i - 2];
        }

        cout << AllCableLength << endl;
    }
 
    return 0;
}

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

int main() {
 int M;
 cin >> M;
    int x = M/1.08;
    int y = x*1.08;
    int z = y/1;
    int a = (x+1)*1.08;
    int b = a/1;
    if(z == M) {
      cout << x << endl;
      return 0;
    }
    if(b == M){
      cout << x+1 << endl;
      return 0;
    }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

dx = (1, 0, -1, 0,)
dy = (0, 1, 0, -1,)

inf = 1<<60

def solve():
    h, w, k = map(int, sys.stdin.readline().split())

    si = -1
    sj = -1

    a = [[False]*w for i in range(h)]

    for i in range(h):
        s = sys.stdin.readline().rstrip()

        for j, ch in enumerate(s):
            if ch == '.':
                a[i][j] = True
            elif ch == 'S':
                a[i][j] = True
                si, sj = i, j

    visited = [[False]*w for i in range(h)]
    visited[si][sj] = True

    nxts = deque([(si, sj, 0)])

    ans = inf

    while nxts:
        i, j, d = nxts.popleft()

        ans = min(ans, i, h - 1 - i, j, w - 1 - j)

        if ans == 0:
            print(1)
            return

        for l in range(len(dx)):
            ni = i + dy[l]
            nj = j + dx[l]

            if 0 <= ni < h and 0 <= nj < w and not visited[ni][nj] and a[ni][nj] and d + 1 <= k:
                visited[ni][nj] = True
                nxts.append((ni, nj, d + 1))

    ans = (ans + k - 1) // k + 1

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 13556
#include <iostream>
using namespace std;
int main()
{
   int a,b,c,d,sum=0 ,num=0;
   cin >> a >> b >> c >> d;

   for(int x=0 ; x<=a ;x++)
   {
       for(int y=0 ;y<=b ;y++)
       {
           for(int z=0 ;z<=c ;z++)
           {
               sum=x*500+y*100+z*50;
               if(sum==d)num++;
           }
       }
   }
   cout << num<<endl;
      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int INF = 1e9;
int a[maxn], l[maxn], r[maxn];
ll ans;
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	stack<int> s; s.push(0);
	for(int i = 1; i <= n; ++i)
	{
		while(a[s.top()] > a[i]) s.pop();
		l[i] = s.top();
		s.push(i);
	}
	stack<int>().swap(s); s.push(n + 1);
	for(int i = n; i; --i)
	{
		while(a[s.top()] >= a[i]) s.pop();
		r[i] = s.top();
		s.push(i);
	}
	for(int i = 1; i <= n; ++i)
		ans += 1ll * a[i] * (r[i] - i) * (i - l[i]);
	printf("%lld\n", ans);
	return 0;
}
	

Measured memory_bytes: 6920
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
signed main(){
    int n;
    cin >> n;
    vector<int>a(n+1);
    vector<int>b(n);
    rep(i,n+1){
        cin >> a[i];
    }
    rep(i,n)cin >> b[i];
    int p = 0;
    ll s = 0;
    for(int i=0;i<n+1;i++){
        s += min(p,a[i]);
        a[i] -= min(p,a[i]);
        if(i!=n){
            s += min(b[i],a[i]);
            p = b[i]-min(b[i],a[i]);
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1792
use strict;
use warnings;
use v5.18;

sub my_read {
    chomp( my $hoge = <> );
    split( //, $hoge );
}

my @O = my_read();
my @E = my_read();

# https://stackoverflow.com/questions/38345/is-there-an-elegant-zip-to-interleave-two-lists-in-perl-5
# バグってるやんけ!
sub zip2 {
    @_[ map { $_, $_ + @_ / 2 } 0 .. ( @_ / 2 - 1 ) ];
}

for ( 0 .. $#E ) {
    print "$O[$_]$E[$_]";
}

if ( scalar @E == scalar @O ) {
    print "\n";
}
else {
    print "$O[-1]\n";
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,*h;
	int cnt = 0,max = 0;
	scanf("%d",&n);
	h = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i)	scanf(" %d",&h[i]);
	for (int i = 0; i < n; ++i){
		if(max <= h[i]){
		  ++cnt;
		  max = h[i];
	  }
	}
	printf("%d\n", cnt);
	return 0;
}



Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EHopscotchAddict {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N, M, S, T;
    vector<vector<int>> G;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M;
        G.resize(3 * (N + 1));
        REP(i, M) {
            int u, v;
            cin >> u >> v;
            G[u * 3].push_back(v * 3 + 1);
            G[u * 3 + 1].push_back(v * 3 + 2);
            G[u * 3 + 2].push_back(v * 3);
        }
        cin >> S >> T;

        queue<P> q;
        map<int, bool> used;
        q.push({S * 3, 0});

        int res = INF;
        while (!q.empty()) {
            auto kv = q.front();
            q.pop();
            if (used[kv.first]) continue;
            used[kv.first] = true;
            if (kv.first == T * 3) {
                res = kv.second;
                break;
            }
            REP(i, G[kv.first].size()) {
                int t = G[kv.first][i];
                if (used[t]) continue;
                q.push({t, kv.second + 1});
            }
        }

        if (res == INF) {
            cout << -1 << endl;
            return;
        }
        cout << res / 3 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EHopscotchAddict solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 35584
adjust_list = ((0,1),(0,-1),(1,0),(-1,0))
h, w = [ int(v) for v in input().split() ]
total_block = 0
field = [ list(input()) for i in range(h) ]
for i in field:
    total_block += i.count("#")

start = (0,0)
def bfs(p,t):
    field[p[0]][p[1]] = t
    search_list = [p]
    while search_list != []:
        t += 1
        new_search_list = []
        for i in search_list:
            for j in adjust_list:
                if 0 <= i[0]+j[0] < h and 0 <= i[1]+j[1] < w:
                    if field[i[0]+j[0]][i[1]+j[1]] == ".":
                        field[i[0]+j[0]][i[1]+j[1]] = t
                        new_search_list.append((i[0]+j[0],i[1]+j[1]))
        search_list = new_search_list
    return

bfs(start,1)


if field[-1][-1] == ".":
    print(-1)
else:
    print(h*w - total_block - field[-1][-1])

Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int A,B;cin>>A>>B;
    if(A<=8 and B<=8){
        cout<<"Yay!"<<endl;
        return 0;
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(n - 1, 1, -1):
    l = 0
    r = i - 1
    while l < r:
        if L[i] < L[r] + L[l]:
            count += r - l
            r -= 1
        else:
            l += 1
print(count)

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for (int i = 0; i < H; i++)
        cin >> grid[i];

    vector<vector<int>> L(H, vector<int>(W));
    vector<vector<int>> R(H, vector<int>(W));
    vector<vector<int>> U(H, vector<int>(W));
    vector<vector<int>> D(H, vector<int>(W));

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') cnt = 0;
            else cnt++;
            L[i][j] = cnt;
        }
    }

    for (int i = 0; i < H; i++) {
        int cnt = 0;
        for (int j = W - 1; j >= 0; j--) {
            if (grid[i][j] == '#') cnt = 0;
            else cnt++;
            R[i][j] = cnt;
        }
    }

    for (int j = 0; j < W; j++) {
        int cnt = 0;
        for (int i = 0; i < H; i++) {
            if (grid[i][j] == '#') cnt = 0;
            else cnt++;
            U[i][j] = cnt;
        }
    }

    for (int j = 0; j < W; j++) {
        int cnt = 0;
        for (int i = H - 1; i >= 0; i--) {
            if (grid[i][j] == '#') cnt = 0;
            else cnt++;
            D[i][j] = cnt;
        }
    }

    int res = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++) {
            res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

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

Measured memory_bytes: 67200
#include<iostream>
using namespace std;
bool isPrime(int n){
	if(n==1)return 0;
	if(n==2)return 1;
	int i;
	for(i=3;i*i<=n;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}
int judge(int n){
	//cout<<"n:"<<n<<endl;
	int i;
	int sum=0;
	for(i=1;i<=n/i;i++){
		if(n%i==0){
			if(i==n);
			else if(i==n/i||i==1)sum+=i;
			else sum+=i+(n/i);
			//cout<<"("<<i<<","<<n/i<<") "<<i*(n/i)<<" "<<sum<<endl;
		}
	}
	if(sum==n)return 0;
	else if(sum<n)return 1;
	else if(sum>n)return 2;
}
int main(){
	int n;

	for(;cin>>n&&n;){
		switch(judge(n)){
			case 0:
				cout<<"perfect number"<<endl;
				break;
			case 1:
				cout<<"deficient number"<<endl;
				break;
			case 2:
				cout<<"abundant number"<<endl;
				break;
		}
	}



	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]==s[n-i-1])
        {
            continue;
        }
        else
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int r = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        
        for(int i = 0; i < 10; i++){
            x = r * x - d;
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXA = 1e6;
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> c(MAXA+1, 0), a(N, 0);
  for(int i = 0; i < N; ++i) {
    std::cin >> a[i];
    ++c[a[i]];
  }
  std::vector<int> primes({2, 3, 5, 7, 9, 11, 13, 17, 19, 23, 29, 31});
  {
    primes.reserve(79000);
    int n = primes.size();
    for(int i = primes.back()+1; i <= 1000; ++i) {
      bool ok = true;
      for(int j = 0; j < n; ++j) if(i%primes[j] == 0) {
        ok = false; break;
      }
      if(ok) primes.push_back(i);
    }
    n = primes.size();
    for(int i = primes.back()+1; i <= MAXA; ++i) {
      bool ok = true;
      for(int j = 0; j < n; ++j) if(i%primes[j] == 0) {
        ok = false; break;
      }
      if(ok) primes.push_back(i);
    }
  }
  for(int i: primes) {
    for(int j = 1; j*i <= MAXA; ++j) c[j*i] += c[j];
  }
  int ans = 0;
  for(int Ai: a) if(c[Ai]==1) ++ans;
  fin(ans);
  return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<bool> red(N,false); 
  vector<int> num(N,1);
  red[0]=true;

  REP(i,M){
    int x,y;
    cin >> x >> y;
    x-=1;
    y-=1;
    num[x]-=1;
    num[y]+=1;
    if(red[x]==true) red[y]=true;
    if(num[x]==0) red[x]=false;
  }

  int sum=0;
  REP(i,N) if(red[i]==true) sum++;
  cout << sum << endl;

  return 0;
}




Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {    
      int n;
      cin>>n;
      if(n==1)
      {
          cout<<1;
          return 0;
      }
      int x=1,c=2,sum=0;
      sum+=x;
      while(n)
      {
          sum+=c;
          c=c*2;
          n/=2;
          if(n==1)
          break;
      }
      cout<<sum;
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3616
n = int(input())
s = [x for x in input().split()]

count = 0
if 'P' in s:
    count += 1
if 'W' in s:
    count += 1
if 'G' in s:
    count += 1
if 'Y' in s:
    count += 1

print('Three' if count == 3 else 'Four')

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

using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  ll a[N], b[N];
  for (int i = 0; i < N; i++) scanf("%lld %lld", a + i, b + i);

  vector<PP> v;
  for (int i = 0; i < N; i++) {
    v.push_back(PP(a[i] + b[i], P(a[i], b[i])));
  }
  sort(v.begin(), v.end());

  ll taka, aoki;
  taka = aoki = 0;
  bool flag = true;
  for (int i = N - 1; i >= 0; i--) {
    if (flag) {
      taka += v[i].second.first;
    } else {
      aoki += v[i].second.second;
    }
    flag = !flag;
  }

  cout << taka - aoki << endl;
  return 0;
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    set<int> s;
    rep(i,N){
        int a;
        cin >> a;
        s.insert(a);
    }
    if(int(s.size()) == N) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 9600
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    n = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    #b = list(map(int, input().split()))
    ans = 0
    for i in range(n-1):
        ans += a[(i+1)//2]
    print(ans)



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

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

int N,M; lld ans;
lld fact[100002];

lld mul(lld x,lld y){
	if(y == 0) return 1;
	lld tmp = mul(x,y/2);
	tmp *= tmp; tmp %= MOD;
	if(y%2 == 1) tmp *= x;
	tmp %= MOD;
	return tmp;
}
lld inv(lld x){
	return mul(x,MOD-2);
}
lld comb(lld x,lld y){
	lld tmp = fact[x];
	tmp *= inv(fact[y]); tmp %= MOD;
	tmp *= inv(fact[x-y]); tmp %= MOD;
	return tmp;
}

int main(){
	scanf("%d %d",&N,&M);
	if(N < M) swap(N,M);
	fact[0] = 1;
	for(int i=1; i<=100000; i++) fact[i] = (fact[i-1]*i)%MOD;
	ans = fact[N]*fact[M]; ans %= MOD;
	if(M < N-1) ans = 0;
	else{
		if(M == N) ans *= 2;
		ans %= MOD;
	}
	printf("%lld\n",ans);

	return 0;
}


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

int main() {
  int X,ans=0;
  cin >> X;

  for (int i=1; i<100; i++) {
    for (int j=2; j<100; j++) {
      int n = pow(i,j);
      if (n > X) break;
      ans = max(n,ans);
    }
  }

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

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

  int main() {
  long long x, y;
  cin >> x >> y;
  int count = 1;
  
    while(y / x >= 2) {
      x = x*2;
      count++;
    }
  cout << count << endl;
  return 0;
  }


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int a, b, c;
    rep(i, y / 10000 + 1)
    {
        rep(j, y / 5000 + 1)
        {
            int num = y / 1000 - 10 * i - 5 * j;
            if (0 <= num && num <= y / 1000 && i + j + num == n)
            {
                printf("%d %d %d\n", i, j, num);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 3728
#include<iostream>

using namespace std;

int main(){
  int n,a,b,c;
  int adj[100][100]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>c;
      adj[i][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<' ';
      cout<<adj[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n,m;
cin >> n >> m;

vector<int> l(m),r(m);
rep(i,m) cin >> l[i] >> r[i];

sort(all(l));
sort(all(r));
int ans;
if(r[0] - l[m-1] >= 0)  ans = r[0] - l[m-1] + 1;
else ans = 0;

cout << ans << endl;

return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int N;
long A,B,S;
long ok[2][2];
main()
{
	for(int i=0;i<2;i++)for(int j=0;j<2;j++)ok[i][j]=-1;
	cin>>N>>A>>B;
	for(int i=2;i<N;i++)
	{
		long T;cin>>T;S^=T;
	}
	long uA=A>>20,dA=A&(1<<20)-1;
	long uB=B>>20,dB=B&(1<<20)-1;
	long uS=S>>20,dS=S&(1<<20)-1;
	for(long k=0;k<=uA;k++)
	{
		for(int i=0;i<2;i++)for(int j=0;j<2;j++)
		{
			if(k+i>uA)continue;
			if((uA-k-i^uB+k+j)==uS&&ok[i][j]==-1)ok[i][j]=k;
		}
	}
	long ans=A;
	for(long k=0;k<1<<20;k++)
	{
		if(dA>=k)
		{
			if(((dA-k)^(dB+k)&(1<<20)-1)==dS)
			{
				int j=dB+k>=1<<20;
				if(ok[0][j]!=-1)
				{
					long tmp=ok[0][j]<<20|k;
					if(ans>tmp)ans=tmp;
				}
			}
		}
		else
		{
			if(((dA+(1<<20)-k)^(dB+k)&(1<<20)-1)==dS)
			{
				int j=dB+k>=1<<20;
				if(ok[1][j]!=-1)
				{
					long tmp=ok[1][j]<<20|k;
					if(ans>tmp)ans=tmp;
				}
			}
		}
	}
	if(ans==A)ans=-1;
	cout<<ans<<endl;
}


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

using namespace std;

typedef long long LL;

int main()
{
    int n;
    LL l[105];
    cin>>n;
    for (int i=0;i<n;++i)
        cin>>l[i];
    if (n<3)
    {
        cout<<0;
        return 0;
    }
    int triangles=0;
    for (int i=0;i<n;++i)
        for (int j=i+1;j<n;++j)
            for (int k=j+1;k<n;++k)
                if (l[i]+l[j]>l[k] and
                    l[j]+l[k]>l[i] and
                    l[k]+l[i]>l[j] and
                    l[i]!=l[j] and
                    l[j]!=l[k] and
                    l[k]!=l[i]) ++triangles;
    cout<<triangles;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 100000001
#define inf 1000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define int ll
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

signed main() {
	fast;
	ll r,x,d;
	cin>>r>>d>>x;
	for(int i=1;i<=10;i++) {
		x=r*x-d;
		cout<<x<<"\n";
	}
}

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

#define REP(i, a, b)  for(int i = a, _b = b; i < _b; ++i)
#define FOR(i, a, b)  for(int i = a, _b = b; i <= b; ++i)
#define FORD(i, a, b) for(int i = a, _b = b; i >= b; --i)

#define endl "\n"
#define newline	cout << "\n"
#define puts(x)	cout << x << "\n"

using namespace std;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef long long llong;


const int MN = 2E5;

#define two(x)	(1 << (x))
#define pc(x)	__builtin_popcount(x)

int h[MN], dp[two(26)];
string s;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef Home
   freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
	cin >> s;
	int n = s.length();

	h[0] = two(s[0] - 'a');
	REP(i, 1, n) {
		h[i] = h[i-1]^(two(s[i] - 'a'));
	}
	
	memset(dp, 0x7F, sizeof dp); 
	REP(i, 0, n) {
		if(pc(h[i]) <= 1) dp[h[i]] = 1;
		else {
			REP(j, 0, 26) {
				dp[h[i]] = min(dp[h[i]], dp[h[i]^two(j)]+1);
			}
		}
	}
	puts(dp[h[n-1]]);	
   return 0;
}

Measured memory_bytes: 263504
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        long[] xl = new long[n];
        for(int i = 0; i < n; i++){
            xl[i] = Math.abs(sc.nextLong() - x);
        }
        System.out.println(n == 1 ? xl[0] : gcd(xl));
    }
    
    private static long gcd(long a, long b){
        while (b > 0)
        {
            long temp = b;
            b = a % b; 
            a = temp;
        }
        return a;
    }

    private static long gcd(long[] input){
        long result = input[0];
        for(int i = 1; i < input.length; i++)
        {
            result = gcd(result, input[i]);
        }
        return result;
    }
}


Measured memory_bytes: 46644
#include<bits/stdc++.h>
using namespace std;
bool A[3];
int main(){
    int n, m; cin >> n >> m;
    string ans(n, '0');
    for (int i = 0; i < m; i++){
        int s;
        char c;
        cin >> s >> c;
        if (s == 1 && c == '0' && n != 1)
        {
            cout << -1 << endl;
            return 0;
        }
        
        if (A[s-1] && ans[s-1] != c)
        {
            cout << -1 << endl;
            return 0;
        }
        ans[s-1] = c;
        A[s-1] = true;
    }
    if (ans[0] == '0' && n != 1)
    {
        ans[0] = '1';
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int x,i,j,flag=0;
    scanf("%d",&x);
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            if(x==i*j)
            {
                flag++;
            }
        }
    }
    if(flag!=0)
    {
        printf("Yes");
    }
    else{
        printf("No");
    }
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] a = new int[n][2];
    for(int i=0;i<n;i++){
      a[i][0]=sc.nextInt();
      a[i][1]=sc.nextInt();
    }
    Arrays.sort(a,Comparator.comparingInt(o->o[0]));
    long ans = 0;
    int j = 0;
    PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
    for(int i=1;i<=m;i++){
      while(j<n&&a[j][0]<=i){
        pq.add(a[j][1]);
        j++;
      }
      if(!pq.isEmpty())ans+=(long)pq.poll();
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 96756
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

typedef vector<int> vi;

bool tarjan(vi e[], int x, bool st[], int disc[], int &dn, vi &t) {
    int dmax = -1, dmaxp = -1;
    for (int y : e[x]) {
        if (st[y] && disc[y] > dmax) {
            dmax = disc[y];
            dmaxp = y;
        }
    }

    disc[x] = ++dn;
    st[x] = true;

    if (dmaxp != -1) {
        int y = dmaxp;
        while (y != x) {
            t.push_back(y);

            int dmax = -1, dmaxz = -1;
            for (int z : e[y]) {
                if (st[z] && disc[z] > dmax) {
                    dmax = disc[z];
                    dmaxz = z;
                }
            }
            y = dmaxz;
        }
        t.push_back(x);
        return true;
    }

    for (int y : e[x]) {
        if (!disc[y]) {
            bool f = tarjan(e, y, st, disc, dn, t);
            if (f) {
                return true;
            }
        }
    }

    st[x] = false;
    return false;
}

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vi e[n];
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
    }

    bool st[n];
    memset(st, false, sizeof(st));
    int disc[n];
    memset(disc, 0, sizeof(disc));
    int dn = 0;
    for (int i = 0; i < n; i++) {
        if (!disc[i]) {
            vi t;
            if (tarjan(e, i, st, disc, dn, t)) {
                cout << t.size() << endl;
                for (int x : t) {
                    cout << x + 1 << endl;
                }
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 384
while True:
  m, f, r = map(int, input().split())

  if m == -1 and f == -1 and r == -1:
    break

  if m == -1 or f == -1:
    ans = 'F'
  elif m+f >= 80:
    ans = 'A'
  elif m+f >= 65:
    ans = 'B'
  elif m+f >= 50:
    ans = 'C'
  elif m+f >= 30:
    ans = 'C' if r >= 50 else 'D'
  else:
    ans = 'F'

  print(ans)

Measured memory_bytes: 7660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D; 
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  else if (A+B==C+D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
*A, = map(int, input())
a = A[0]
b = [A[1], -A[1]]
c = [A[2], -A[2]]
d = [A[3], -A[3]]

def f(n):
    if n>=0:
        return '+'+str(n)
    else:
        return str(n)

for bb in b:
    for cc in c:
        for dd in d:
            if a+bb+cc+dd == 7:
                print(a, end='')
                print(f(bb), end='')
                print(f(cc), end='')
                print(f(dd), end='')
                print('=7')
                exit()

Measured memory_bytes: 8876
A,B,M =map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
values = []
for i in range(M):
  x,y,c = map(int,input().split())
  values.append(a[x-1]+b[y-1]-c)
values.append(min(a)+min(b))
print(min(values))

Measured memory_bytes: 18736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> xs(n), ys(n);
    vector<pair<li, li>> xys;

    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> ys[i];
        if (ys[i] < xs[i]) {
            swap(xs[i], ys[i]);
        }
        xys.emplace_back(xs[i], ys[i]);
    }
    sort(xys.begin(), xys.end());

    li x_min = *min_element(xs.begin(), xs.end());
    li x_max = *max_element(xs.begin(), xs.end());
    li y_min = *min_element(ys.begin(), ys.end());
    li y_max = *max_element(ys.begin(), ys.end());

    li ans = (x_max - x_min) * (y_max - y_min);

    multiset<li> x_bag(xs.begin(), xs.end());

    for (auto xy  : xys) {
        const li x = xy.first;
        const li y = xy.second;

        x_bag.erase(x_bag.lower_bound(x));
        x_bag.insert(y);
        ans = min(ans, (*x_bag.rbegin() - *x_bag.begin()) * (y_max - x_min));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16876
/*
cat <<EOF >mistaken-paste
*/

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

#define BIG 2000000007
#define VERYBIG 200000000000007LL

#define MOD 1000000007
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 1000
#define M_MAX 400

typedef struct {
	int32_t a;
	int32_t b;
} hw;

typedef struct {
	sll a;
	sll b;
} hwll;

typedef struct {
	hwll a;
	hwll b;
} linell;


typedef struct {
	ull s;
	ull t;
	int32_t c;
} struct_a;

typedef struct {
	int32_t from;
	int32_t to;
	sll cost;
} struct_b;


ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;


ull solve () {
	sll i, j, ki, l;

	ull minors = (h / vua) * (w / vub);
	// when the way works successfully?
	// (h*w - minors) * X > minors * ((a*b - 1) * X + 1)
	// hwX - mX > m(abX - X + 1)
	// hwX > m(abX + 1)
	// hwX - mabX > m
	// (hw - mab)X > m
	ull hw_mab = h * w - minors * vua * vub;
	// if this is 0, it means "vua | h, vub | w"
	// ---> whole space will be filled with MINOR blocks without any gaps
	// ---> Oops total sum is minor

	if (hw_mab == 0) goto fail;
	
	ull generalnum = (minors + hw_mab) / hw_mab;
	ull minornum = ((vua * vub - 1) * generalnum + 1);

	puts("Yes");
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			char split = ((j == (w - 1)) ? '\n' : ' ');
			if (!((i + 1) % vua) && !((j + 1) % vub)) {
				printf("-%llu%c", minornum, split);
			} else {
				printf("%llu%c", generalnum, split);
			}
		}
	}

	return 0;

	fail:
	puts("No");
	return 1;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%llu%llu", &h, &w);
	scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue);

	solve();

	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    vector<int> a(n); repeat(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int alice = 0, bob = 0;
    repeat (i, n) {
        if (i % 2 == 0) {
            alice += a[i];
        }
        else {
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll N, W; cin >> N >> W;
    vector<pair<ll, ll>> w0, w1, w2, w3;

    ll w00, v00; cin >> w00 >> v00;
    w0.push_back({v00, w00});

    for(int i=1; i<N; i++){
        ll w, v; cin >> w >> v;
        
        if(w == w00) w0.push_back({v, w});
        if(w == w00+1) w1.push_back({v, w});
        if(w == w00+2) w2.push_back({v, w});
        if(w == w00+3) w3.push_back({v, w});
    }

    sort(w0.begin(), w0.end(), greater<pair<ll,ll>>());
    sort(w1.begin(), w1.end(), greater<pair<ll,ll>>());
    sort(w2.begin(), w2.end(), greater<pair<ll,ll>>());
    sort(w3.begin(), w3.end(), greater<pair<ll,ll>>());

    ll ans = 0;
    for(int i=0; i<=w0.size(); i++){
        for(int j=0; j<=w1.size(); j++){
            for(int k=0; k<=w2.size(); k++){
                for(int l=0; l<=w3.size(); l++){
                    ll wht = 0LL;
                    ll val = 0LL;

                    for(int p=0; p<i; p++) wht += w0[p].second, val += w0[p].first;
                    for(int p=0; p<j; p++) wht += w1[p].second, val += w1[p].first;
                    for(int p=0; p<k; p++) wht += w2[p].second, val += w2[p].first;
                    for(int p=0; p<l; p++) wht += w3[p].second, val += w3[p].first;

                    if(wht <= W) ans = max(ans, val);
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    int mn = a[0], mx = a[0];
	for(int i = 1; i < N; i++){
		if(mn > a[i])
		    mn=a[i];
		if(mx<a[i])
			mx=a[i];
	}
	
	cout<<mx-mn<<endl;
}



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

int main() {
    int K,X;
    cin >> K >> X;

    int c;

    for (int i = X - K + 1; i <= X + K - 1; i++) {
        c = i;
        cout << c << " ";

        if (i == X + K - 1) {
            cout << endl;
        }
    }



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[5];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for(int i = 1;i<=n;i++)
		if (s[i] == '7') {
			printf("Yes");
			return 0;
		}
	printf("No");
}

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

int main(void) {
  string S;
  char pre;
  cin >> S;
  pre = S[0];
  for (int i = 1; i < S.length(); i++) {
    if (S[i] == pre) {
      cout << "Bad" << endl;
      return 0;
    }
    pre = S[i];
  }

  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int input1,input2;
  cin >> input1 >> input2;
  int temp = __gcd(input1,input2);
  vector<int> factors;
  for(int i=1;i<=sqrt(temp);i++){
    if(temp%i==0){
      factors.push_back(i);
      if(i*i!=temp){
        factors.push_back(temp/i);
      }
    }
  }
  sort(factors.begin(),factors.end());
  /*for(auto k:factors){
    cout  << k << " ";
  }
  cout << endl;*/
  vector<int> ans;
  for(int i=0;i<factors.size();i++){
    for(int j=0;j<ans.size();j++){
      if(__gcd(factors[i],ans[j])!=1){
        goto cont;
      }
    }
    ans.push_back(factors[i]);
    cont : ;
  }
  /*for(auto k:ans){
    cout << k << " ";
  }
  cout << endl;*/
  cout << ans.size();
}

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


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

  int ans = 0;
  for(int i=0; i<s.size(); ++i){
    if(s[i] =='1') ++ans;
  }

  ans = min(ans, (int)s.size() - ans);
  
  cout << 2*ans << endl;
}


Measured memory_bytes: 512
from itertools import accumulate
from math import ceil

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

if N == 1:
    print(A[0])
    exit()


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N)  # Binaryの先頭の分
lo, hi = -1, 10 ** 9 + 1
while hi - lo > 1:
    # Xは中央値候補
    X = (hi + lo) // 2

    # X以上なら1、X未満なら-1に変換
    Binary = [(1 if a >= X else -1) for a in A]

    # 累積和をとる
    Binary = list(accumulate(Binary))

    # BITを初期化
    BIT.reset()

    # 転倒数っぽいものを数える
    inversion = 0
    Binary_sorted = {b: i for i, b in enumerate(sorted(Binary), start=1)}
    for j, b in enumerate(Binary):
        inversion += BIT.sum(Binary_sorted[b]) + (b >= 0)
        BIT.add(Binary_sorted[b], 1)

    if inversion >= ceil((N * (N + 1) / 2) / 2):
        lo = X
    else:
        hi = X

print(lo)


Measured memory_bytes: 133476