akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

class fenwick_tree {
	int n;
	vector<ll> x, y;
	ll getAccum(vector<ll> &BIT, int idx) {
		ll sum = 0;
		while (idx) {
			sum += BIT[idx];
			idx -= (idx & -idx);
		}
		return sum;
	}
	void add(vector<ll> &BIT, int idx, ll val) {
		while (idx <= n) {
			BIT[idx] += val;
			idx += (idx & -idx);
		}
	}
	ll prefix_sum(int idx) {
		return getAccum(x, idx) * idx - getAccum(y, idx);
	}
public:
	fenwick_tree(int n) :
			n(n), x(n + 1), y(n + 1) {
	}
	void update_range(int l, int r, ll val) {
		add(x, l, val);
		add(x, r + 1, -val);
		add(y, l, val * (l - 1));
		add(y, r + 1, -val * r);
	}
	ll range_sum(int l, int r) {
		return prefix_sum(r) - prefix_sum(l - 1);
	}
};

int main() {
	run();
	int n;
	cin >> n;
	vector<vector<int>> adj(n + 1);
	fenwick_tree bit(n);
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		bit.update_range(i, n, 1);
		for (int j : adj[i])
			if (j > i)
				bit.update_range(j, n, -1);
	}
	ll ans = bit.range_sum(1, n);
	for (int i = 1; i < n; i++) {
		bit.update_range(i, n, -1);
		for (int j : adj[i])
			if (j > i)
				bit.update_range(j, n, 1);
		ans += bit.range_sum(1, n);
	}
	cout << ans << endl;

}


Measured memory_bytes: 18144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int a,b;
    cin >> a;
    cin >> b;
    bool use[4] = {};
    use[a] = true;
    use[b] = true;
    for(int i = 1; i <= 3; i++){
        if(!use[i]) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a,b,c;
char cho[100001][5][5][5];
string s[100001];
void output(int N,int A,int B,int C)
{
	if(s[N]=="AB")
	{
		if(cho[N][A][B][C]=='A')
		{
			output(N-1,A-1,B+1,C);
			cout<<'A'<<endl;
		}
		if(cho[N][A][B][C]=='B')
		{
			output(N-1,A+1,B-1,C);
			cout<<'B'<<endl;
		}
	}
	if(s[N]=="AC")
	{
		if(cho[N][A][B][C]=='A')
		{
			output(N-1,A-1,B,C+1);
			cout<<'A'<<endl;
		}
		if(cho[N][A][B][C]=='C')
		{
			output(N-1,A+1,B,C-1);
			cout<<'C'<<endl;
		}
	}
	if(s[N]=="BC")
	{
		if(cho[N][A][B][C]=='B')
		{
			output(N-1,A,B-1,C+1);
			cout<<'B'<<endl;
		}
		if(cho[N][A][B][C]=='C')
		{
			output(N-1,A,B+1,C-1);
			cout<<'C'<<endl;
		}
	}
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>a>>b>>c;
	a=min(2ll,a);
	b=min(2ll,b);
	c=min(2ll,c);
	cho[0][a][b][c]=1;
	for(int i=1;i<=n;++i)
	{
		cin>>s[i];
		if(s[i]=="AB")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(A>0&&cho[i-1][A-1][B+1][C])
						{
							cho[i][A][B][C]='A';
						}
						if(B>0&&cho[i-1][A+1][B-1][C])
						{
							cho[i][A][B][C]='B';
						}
					}
				}
			}
		}
		if(s[i]=="AC")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(A>0&&cho[i-1][A-1][B][C+1])
						{
							cho[i][A][B][C]='A';
						}
						if(C>0&&cho[i-1][A+1][B][C-1])
						{
							cho[i][A][B][C]='C';
						}
					}
				}
			}
		}
		if(s[i]=="BC")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(B>0&&cho[i-1][A][B-1][C+1])
						{
							cho[i][A][B][C]='B';
						}
						if(C>0&&cho[i-1][A][B+1][C-1])
						{
							cho[i][A][B][C]='C';
						}
					}
				}
			}
		}
//		for(int A=0;A<4;++A)
//		{
//			for(int B=0;B<4;++B)
//			{
//				for(int C=0;C<4;++C)
//				{
//					cout<<i<<' '<<A<<' '<<B<<' '<<C<<' '<<cho[i][A][B][C]<<endl;
//				}
//			}
//		}
//		cout<<endl;
	}
	for(int A=0;A<4;++A)
	{
		for(int B=0;B<4;++B)
		{
			for(int C=0;C<4;++C)
			{
//				cout<<n<<' '<<A<<' '<<B<<' '<<C<<' '<<cho[n][A][B][C]<<endl;
				if(cho[n][A][B][C])
				{
					cout<<"Yes"<<endl;
					output(n,A,B,C);
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 28360
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) \
cerr << #v << ": " << (v) << endl

int main() {
    string t;
    cin >> t;
    int n = 0, w = 0, s = 0, e = 0;
    for (int i = 0; i < t.size(); ++i) {
        if (t[i] == 'N') {
            ++n;
        } else if (t[i] == 'W') {
            ++w;
        } else if (t[i] == 'S') {
            ++s;
        } else {
            ++e;
        }
    }
    if ((n != 0) != (s != 0)) {
        cout << "No" << endl;
        return 0;
    }
    if ((w != 0) != (e != 0)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 10000
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int N;
vector<vector<int>> ans;

signed main()
{
  cin >> N;
  ans.push_back(vector<int>());
  int k = 0;
  int mode = 0;
  REP(i,N) {
    if(mode == 0) {
      ans.push_back(vector<int>());
      ans[ans.size()-1].push_back(i+1);
      ans[k].push_back(i+1);
      mode = 1;
      k--;
    } else {
      ans[ans.size()-1].push_back(i+1);
      ans[k].push_back(i+1);
      k--;
    }
    if(k < 0) {
      k = ans.size()-1;
      mode = 0;
    }
  }

  for(const auto& v: ans) {
    if(v.size() != ans[0].size()) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  cout << ans.size() << endl;
  for(const auto& v: ans) {
    cout << v.size();
    for(int vv : v) {
      cout << " " << vv;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> a(N);
    rep(i, 0, N) cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end());
    ll t = 0;
    for (const auto& p : a)
    {
        t += p.second;
        if (t > p.first)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	H, W, S := nextInt(), nextInt(), []string{}
	for i := 0; i < H; i++ {
		S = append(S, nextLine())
	}

	ABC075B(H, W, S)
}

// ABC075B ...
func ABC075B(H, W int, S []string) {
	op := []int{-1, 0, 1}

	var guard string
	for i := 0; i < W; i++ {
		guard += "."
	}
	S = append([]string{guard}, S...)
	S = append(S, guard)

	for i := 0; i < len(S); i++ {
		S[i] = "." + S[i] + "."
	}

	for i := 1; i < H+1; i++ {
		res := ""
		for j := 1; j < W+1; j++ {
			if S[i][j] == '#' {
				res += "#"
			} else {
				num := 0
				for _, dx := range op {
					for _, dy := range op {
						if S[i+dx][j+dy] == '#' {
							num++
						}
					}
				}
				res += strconv.Itoa(num)
			}
		}
		fmt.Println(res)
	}
}


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

const int MAX = 100 + 5;
int a[4] = {1, -1, 0, 0};
int b[4] = {0, 0, -1, 1};
int w, h;
char s[MAX][MAX];

void dfs(int x, int y, char tmp)
{
	for(int i = 0; i < 4; i++)
	{
		int nx = x + a[i];
		int ny = y + b[i];
		if(nx >= 0 && nx < h && ny >= 0 && ny < w && s[nx][ny] == tmp)
		{
			s[nx][ny]='0';
			dfs(nx,ny,tmp);
		}
	}
}

int main()
{
    while(cin >> h >> w)
    {
        if(!w || !h) break;
        for(int i = 0; i < h; ++i)
            for(int j = 0; j < w; ++j)
            {
                cin >> s[i][j];
            }


        int ans = 0;
        for(int j = 0; j < h; ++j)
            for(int k = 0; k < w; ++k)
            {
                if(s[j][k] != '0')
                {
                    char c = s[j][k];
                    s[j][k] = '0';
                    ans++;

                 dfs(j, k, c);
                }
            }
        cout << ans << endl;
    }
    return 0;

}

Measured memory_bytes: 1636
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long count = 0;
    while (true) {
      if (Math.pow(2,count) > H) break;
      count++;
    }
    System.out.println((long)Math.pow(2,count) -1);
  }
}

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

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

  vector<int> mul;
  for (int i = 1; i <= b; i++)
    mul.push_back(a*i);

  for (int i = 0; i < mul.size(); i++)
    if (mul[i] % b == c) {
      cout << "YES" << endl;
      return 0;
    }

  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int n,x;
vector<pair<int,string> > c[1001];
void Put(int p,int len){
	for(int i=0;i<c[p].size();i++){
		for(int j=0;j<len;j++)cout<<".";
		cout<<c[p][i].second<<endl;
		Put(c[p][i].first,len+1);
	}
}
int main(){
	int n;
	cin>>n;
	pair<int,string> s;
	for(int i=0;i<n;i++){
		s.first=i+1;
		cin>>x>>s.second;
		c[x].push_back(s);
	}
	Put(0,0);
	return 0;
}

Measured memory_bytes: 3380
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();


int r[]=new int[6];

r[0]=ans(a,b,c);
r[1]=ans(a,c,b);
r[2]=ans(b,a,c);
r[3]=ans(b,c,a);
r[4]=ans(c,a,b);
r[5]=ans(c,b,a);

System.out.println(haimin(r));


	}

static int ans(int a,int b,int c){
	int ret=0;
	ret+=Math.abs(b-a);
	ret+=Math.abs(c-b);

	return ret;

}
public static int haimin(int a[]) {
	int d;
	d = a[0];
	for (int i = 0; i <= a.length - 1; i++) {
		if (d >= a[i]) {
			d = a[i];
		}

	}
	return d;
}

}

Measured memory_bytes: 21716
n = int(input())
xss = [[int(x)-1 for x in input().split()] for _ in range(n)]

def solve(n, xss):
    yss = [[-1] + list(reversed(xs)) for xs in xss]
    ans = 0
    candidates = range(n)
    while True:
        #print(" ".join(map(str, candidates)))
        ms = list(matches(yss, candidates))
        if len(ms) == 0:
            if all(len(ys)==1 for ys in yss):
                return ans
            else:
                return -1
        ans += 1
        candidates = []
        #print(" ".join(map(str, ms)))
        for x, y in ms:
            yss[x].pop()
            yss[y].pop()
            candidates.append(x)
            candidates.append(y)

def matches(yss, candidates):
    firsts = [yss[i][-1] for i in candidates]
    ans = set()
    for x, y in zip(candidates, firsts):
        if y!=-1 and yss[y][-1] ==x:
            ans.add((min(x, y), max(x, y)))
    return ans

print(solve(n, xss))

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

bool isIntDistance(vector<int> v1, vector<int> v2) {
    double d = 0;
    for (int i = 0; i < v1.size(); ++i) {
        d += (v1[i] - v2[i]) * (v1[i] - v2[i]);
    }

    d = sqrt(d);
    if ((int)d == d) return true;
    return false;
}

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

    vector<vector<int>> points(n);
    for (int i = 0; i < n; ++i) {

        vector<int> point(d);
        for (int j = 0; j < d; ++j) {
            cin >> point[j];
        }
        points[i] = point;
    }

    int res = 0;
    for (int i = 0; i < n; ++i) {
        vector<int> v1 = points[i];
        for (int j = i + 1; j < n; ++j) {
            vector<int> v2 = points[j];
            if (isIntDistance(v1, v2)) res++;
        }
    }

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

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

#define ll long long
using namespace std;

const int N = 21, M = 1e9 + 7;
int n;
int a[N][N];
ll dp[1 << N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    dp[0] = 1;
    for(int mask = 1; mask < (1 << n); mask++) {
        int i = __builtin_popcount(mask) - 1;
        for(int j = 0; j < n; j++) {
            if(((mask >> j) & 1) && a[i][j]) {
                dp[mask] = (dp[mask] + dp[mask - (1 << j)]) % M;
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; cin>>n;
    int w[n];
    int s1=0,s2=0;
    rep(i,n)
    {
        cin>>w[i];
        s2+=w[i];
    }
    int ans=INT_MAX;
    rep(i,n)
    {
        s1+=w[i];
        s2-=w[i];
        ans=min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
res = n
for i in range(n+1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6
    t = n - i
    while t > 0:
        cnt += t % 9
        t //= 9

    res = min(res, cnt)

print(res)


Measured memory_bytes: 40940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        List<Integer> list = new ArrayList<>();
        
        for(int i=0;i<N;i++){
            list.add(sc.nextInt());
        }
        
        Collections.sort(list);
        int sum = 0;
        
        for(int i=0;i<K;i++){
            sum += list.get(i);
        }
        
        System.out.println(sum);
    }
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
bool comp(pair<int,int> p1,pair<int,int> p2)
{
    return p1.second<p2.second;
}
int main()
{
    FAST
int n,m;
cin>>n>>m;
vector< pair<int,int> > v(m);
for(int i=0;i<m;i++)
    cin>>v[i].first>>v[i].second;
sort(v.begin(),v.end(),comp);
	int c = 0;
	int sum = 1;
	for (int i = 1; i<m; i++)
	{
		if (v[i].first >= v[c].second)
		{
			sum++;
			c = i;
		}
	}
	cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<int> > xsel(1 << N, std::vector<int>(N));
	std::vector<std::vector<int> > ysel(1 << N, std::vector<int>(N));
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += 1LL * std::min({ xsel[j][k], ysel[i - j][k] }) * P[k];
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 9768
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 15,maxm = 1005;
char a[maxn][maxm];
int main(int argc, char const *argv[])
{
	int n,m,s;
	scanf("%d%d%d",&n,&m,&s);
	for(int i = 1;i <= n; ++i)
	{
		scanf("%s",a[i] + 1);
	}
	int ans = 0x3f3f3f3f;
	vector<int> pos;
	for(int i = 0;i < (1 << (n - 1)); ++i)
	{
		pos.clear();
		pos.push_back(0);
		for(int j = 1;j < n; ++j)
		{
			if(i & (1 << (j - 1)))
			{
				pos.push_back(j);
			}
		}
		int ok = 1;
		pos.push_back(n);
		int now = pos.size() - 2;
		vector<int> cnt(pos.size() - 1,0);
		for(int j = 1;j <= m; ++j)
		{
			int fg = 1;
			vector<int> cnt0(pos.size() - 1,0);
			for(int k = 0;k < cnt.size(); ++k)
			{
				for(int o = pos[k] + 1;o <= pos[k + 1]; ++o)
				{
					cnt0[k] += (a[o][j] != '0');
				}
				if(cnt0[k] > s)
				{
					ok = 0;
					break;
				}
				if(cnt[k] + cnt0[k] > s)
				{
					fg = 0;
				}
			}
			if(ok == 0)
			{
				break;
			}
			if(fg == 1)
			{
				for(int k = 0;k < cnt.size(); ++k)
				{
					cnt[k] += cnt0[k];
				}
			}
			else if(fg == 0)
			{
				++now,cnt = cnt0;
			}
		}
		if(ok != 0)
		{
			ans = min(ans,now);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    double pai=3.141592653589,da,db;
    int a,b;
    scanf("%d %d",&a,&b);
    da=static_cast<double>(a);
    db=static_cast<double>(b);
    printf("%d %d %.8lf\n",a/b,a%b,da/db);
    return 0;
}


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

#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

class mint{
public:
  ll x;
  mint(ll x=0) : x(x%mod){}
  mint& operator+=(const mint rhs){
    x += rhs.x;
    while(x >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint rhs){
    x -= rhs.x;
    while(x < 0) x += mod;
    return *this;
  }
  mint & operator*=(const mint rhs){
    (x *= rhs.x) %= mod;
    return *this;
  }
  mint operator+(const mint rhs) const {
    mint res(*this);
    return res += rhs;
  }
  mint operator-(const mint rhs) const {
    mint res(*this);
    return res -= rhs;
  }
  mint operator*(const mint rhs) const {
    mint res(*this);
    return res *= rhs;
  }
  friend ostream& operator<<(ostream& os,const mint rhs){
    os << rhs.x;
    return os;
  }
};

#define rep(index,num) for(int index=0;index<num;++index)

int main(){
  int n;
  std::cin >> n;
  int d[n];
  rep(i,n) cin >> d[i];
  sort(d,d+n);
  if(n%2==1) cout << 0 << endl;
  else{
    cout << d[n/2] -  d[n/2-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <vector>
#define f first
#define s second
#define fore(i,a,b) for(lli i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
    lli n;
    cin >> n;
    lli res=0;
    vector<lli> v(n);
    fore(i,0,n)
    {
      cin >> v[i];
    }
    fore(i,1,n)
    {
      if(v[i-1]>v[i])
      {
        res+=v[i-1]-v[i];
        v[i]=v[i-1];
      }
    }
    cout << res <<ENDL;
    return 0;
}


Measured memory_bytes: 4716
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K-1])

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

import sys

def prod_mat_vec(A, vec):
    ret = [0 for i in xrange(3)]
    for i in xrange(3):
        for j in xrange(3):
            ret[i] += A[i][j] * vec[j]
    return ret


def changerow(A, i1, i2):
    for j in xrange(3):
        buf = A[i1][j]
        A[i1][j] = A[i2][j]
        A[i2][j] = buf
    return A


def MatrixInverse3x3(A_src):
    A = [ [A_src[i][j] for j in xrange(3)] for i in xrange(3) ] # deepcopy A_src -> A
    B = [ [1, 0, 0], \
          [0, 1, 0], \
          [0, 0, 1]  ]
    
    for i in xrange(3):
        if A[i][i] == 0:
            for k in xrange(i+1, 3):
                if A[k][k] != 0:
                    A = changerow(A, i, k)
                    B = changerow(B, i, k)
        a = A[i][i]

        for j in xrange(3):
            A[i][j] /= a
            B[i][j] /= a

        for k in xrange(3):
            if i == k: continue
            a = A[k][i]
            for j in xrange(3):
                A[k][j] -= A[i][j] * a
                B[k][j] -= B[i][j] * a
    return B


def output3x3(A):
    for i in xrange(3):
        print "%7.3f %7.3f %7.3f" % (A[i][0], A[i][1], A[i][2])
    return


#for line in ["0.0 3.0 -1.0 0.0 -3.0 4.0"]: # expected [-2.000, 2.000, 2.236]
for line in sys.stdin.readlines():
    List = map(float, line.strip().split())
    if len(List) == 1: continue
    [x1, y1, x2, y2, x3, y3] = List

    A = [ [x1, y1, 1.0] ,\
          [x2, y2, 1.0] ,\
          [x3, y3, 1.0]  ]
    vec = [x1**2+y1**2, x2**2+y2**2, x3**2+y3**2]

    B = MatrixInverse3x3(A)
    lmn = prod_mat_vec(B, vec)

    ans = [0.5*lmn[0], 0.5*lmn[1], (lmn[2]+0.25*lmn[0]**2+0.25*lmn[1]**2)**0.5]
    print "%.3f %.3f %.3f" % (ans[0], ans[1], ans[2])
    
    
    

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

int main()
{
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int count = 0;
 
  rep(i,N)
  {
    //同じならスキップ
    while(i+1 < N && A[i] == A[i+1]) i++;
    //増加
    if(i+1 < N && A[i] <= A[i+1]){
      while(i+1 < N && A[i] <= A[i+1]) i++;
    }
    //減少
    else if(i+1 < N && A[i] > A[i+1]){
      while(i+1 < N && A[i] >= A[i+1]) i++;
    }
    count++;
  }
  cout << count << endl;
}

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

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;

    int pre, x;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if (i > 0 && x < pre)
        {
            sum += pre - x;
            x = pre;
        }
        pre = x;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
string S, T;
int main() {
    cin >> S >> T;

    bool ans = false;

    for(int i = 0; i < S.length(); ++i) {
        if(S == T) {
            ans = true;
            break;
        }

        S = S.back() + S.substr(0, S.length() - 1);
    }

    if(ans) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char &c : s)
        cout << char((c-'A'+n)%26+'A');

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int cnt =0;
vector<int> adj[N];
int visited[N];
void dfs(int node)
{
   if (adj[node].size() ==0) visited[node]=1;
   for (int child: adj[node]){
    if ( visited[child] ==0){
       dfs(child);
       }
       if (visited[child]+1 > visited[node]) visited[node] = visited[child]+1;
       if ( visited[child]+1 > cnt) cnt = visited[child]+1;
}
}
int main()
{
   int n,m, x, y, ans=0;
   cin >> n >> m;
   while (m--)
   {
       cin >> x >> y;
       adj[x].push_back(y);
   }
   for ( int i=1; i<=n; i++){
        cnt = 0;
    if (visited[i] ==0) dfs(i);
   if ( cnt > ans) ans= cnt;
   }
   cout <<ans-1;
   return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
int main(void){
    int n,i,cnt=0;
    char s[51];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            cnt++;
            i+=2;
        }
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll N;
  cin >> N;
  map<string,ll> mp;
  for(ll i = 0;i < N;i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }

  ll ans = 0;

  for(auto itr = mp.begin();itr != mp.end();itr++){
    ans += (itr->second)*(itr->second - 1)/2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans=0;
  for(int i=a; i<=b; i++){
    if(c%i==0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3104
N = int(input())

takahashi,aoki = 1,1

for _ in range(N):
    a,b = map(int,input().split())
    c = max((takahashi-1)//a+1,(aoki-1)//b+1)
    takahashi = c*a
    aoki = c*b

print(takahashi+aoki)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];*/
int main()
{
	fast;
	ll n,m;
	cin>>n>>m;
	scan(m);
	ll sum=0;
	for(ll i=0;i<m;i++)
	{
		sum+=a[i];
	}
	if(sum<=n)
	{
		cout<<n-sum;
	}
	else
		cout<<"-1";
	return 0;
}


Measured memory_bytes: 3724
def examB():
    N = I()
    T = LI()
    totalT = sum(T)
    M = I()
    ans = []
    for i in range(M):
        P, X =LI()
        ans.append(totalT + X - T[P-1])
    for v in ans:
        print(v)



import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
 
	
const ll oo = 1e15;
const int maxn  = 1e6;
int N,K;
void test_case(){
	cin >> N >> K;
	vector<int> v(N);
	for(int & el :v)
		cin >> el;
	vector<ll> dp(maxn,oo);
	dp[0] = 0;
	for(int i = 0;i<N;++i){
		for(int j = i+1;j<=i+K;++j)
			dp[j] = min(dp[j],dp[i] + (ll)abs(v[j] - v[i]));
	}
	cout << dp[N-1] << endl;
}
 
	
 
 
 
 
 
int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 11336
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i, 0, n) cin >> x[i];
  rep(i, 0, m) cin >> y[i];

  int x_max = *max_element(x.begin(), x.end());
  int y_min = *min_element(y.begin(), y.end());
  if (X < y_min && y_min <= Y && x_max < y_min)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


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

ll MOD = 1e9+7;



int main(){
    string S; cin >> S;
    ll ans = 0;
    for(auto c : S) {
        if(c == '+') ans++;
        else ans--;
    }
    cout << ans << endl;


}

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

using namespace std;

int main()
{
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	
	int inp[n];
	for(int i = 0; i < n; i++)
		scanf("%d", &inp[i]);
	
	int ans[h][w];
	int color = 0, cnt = 0, col = 0;
	for(int i = 0; i < h;) {
		if(cnt < inp[color])
			ans[i][col] = color + 1;
		if(i % 2 == 0) {
			col++;
		} else {
			col--;
		}
		
		cnt++;
		if(cnt == inp[color]) {
			cnt = 0;
			color++;
		}
		
		if(col < 0) {
			col = 0;
			i++;
		}
		if(col == w) {
			col = w - 1;
			i++;
		}

	}

	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			printf("%d%c", ans[i][j], j == w - 1 ? '\n' : ' ');

	return 0;
}


Measured memory_bytes: 384
a = input()
add =['dreamer','eraser','erase','dream']
t = ''
i = len(a)-1
while(i<len(a)):
    p=0
    for v in add:
        s = i-len(v)+1;
        if s>=0:
            if a[s:i+1]==v:
                t=a[s:i+1]+t
                i=s-1
                p=1
    if p==0:
        break
print('YES' if t==a else 'NO')


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

ll d[101][101];// d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする) 
ll V;// 頂点数
void warshall_floyd() {
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0;j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
	ll e;cin>>V>>e;
	for(int i = 0; i < V; i++) {
		for(int j =  0; j < V; j++) {
			if (i != j){
				d[i][j] = LINF;
			}
		}
	}
	for(int i = 0; i < e; i++) {
		ll s,t,D;cin>>s>>t>>D;
		d[s][t] = D;
	}
	warshall_floyd();

	for(int i = 0; i < V; i++) {
		if (d[i][i] < 0){
				cout << "NEGATIVE CYCLE" << endl;
				return 0;
		}	
	}
	for(int i = 0; i < V; i++) {
		for(int j = 0; j < V; j++) {
			if (d[i][j] < (1LL<<50)){
				cout << d[i][j];
			}
			else{
				cout << "INF";
			}
			if (j != V - 1){
				cout << ' ';
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
n=int(input())
a=list(map(int,input().split()))
a.sort()
l=[a[0]]
r=[a[-1]]
for i in range(1,n-1):
    if a[i]<=0:
        r.append(a[i])
    else:
        l.append(a[i])
r.sort()
l.sort()
if len(r)==1:
    X=r[0]
    p=[]
else:
    p=[[r[-1],r[-2]]]
    for i in range(len(r)-3,-1,-1):
        p.append([p[-1][0]-p[-1][1],r[i]])
    X=p[-1][0]-p[-1][1]
if len(l)==1:
    Y=l[0]
    q=[]
else:
    q=[[l[0],l[1]]]
    for i in range(2,len(l)):
        q.append([q[-1][0]-q[-1][1],l[i]])
    Y=q[-1][0]-q[-1][1]
print(X-Y)
if p and q:
    for i in range(len(p)):
        print(*p[i])
    for i in range(len(q)):
        print(*q[i])
    print(X,Y)
elif p:
    for i in range(len(p)):
        print(*p[i])
    print(X,Y)
elif q:
    for i in range(len(q)):
        print(*q[i])
    print(X,Y)
else:
    print(X,Y)

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    ll n,x;
    cin>>n>>x;
    vll a(n);
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n){
        if(a[i]>x){
            ans+=a[i]-x;
            a[i]-=a[i]-x;
        }
        
    }
    
    rep(i,n-1){
        ll bet=a[i]+a[i+1];
        if(bet>x){
            ans+=bet-x;
            a[i+1]-=(bet-x);
        }
        
    
    
    }
   
    cout<<ans<<endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>
int main()
{
    int K;
    std::cin >> K;
    int a = K % 2;
    int b = K / 2;
    if (a == 0) {
        std::cout << b * b << std::endl;
    } else {
        std::cout << b * (b + 1) << std::endl;
    }
    return 0;
}

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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


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

    string n;
    cin >> n;
    int l = n.back() - '0';
    if (l == 0 || l == 1 || l == 6 || l == 8) {
        cout << "pon";
    } else if (l == 3) {
        cout << "bon";
    } else {
        cout << "hon";
    }
    return 0;


}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int yyyy = Integer.parseInt(s.substring(0, 4));
		int mm = Integer.parseInt(s.substring(5, 7));
		int dd = Integer.parseInt(s.substring(8, 10));
		if (yyyy <= 2019 && mm <= 4) {
			if (mm == 4 && dd > 30) {
				System.out.println("TBD");
			} else {
				System.out.println("Heisei");
			}
			
			return;
		}
		
		System.out.println("TBD");
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define INF (1<<30)+100
using namespace std;
ifstream fin("");
ofstream fout("");
 
ll n, k, x, y, z;

int main() {
	cin>>n>>k;
	ll minn = n;
	n = n%k;
	if(minn > n)
		minn = n;
	n = abs(n-k);
	if(minn > n)
			minn = n;
	
	cout<<minn<<'\n';
	
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))

count = 0
flag = True
while True:
    for i in range(N):
        if A_list[i] % 2 != 0:
            flag = False
            break
    if flag == False:
        break
    A_list = [A/2 for A in A_list]
    count+=1

print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define llrep(i, a, b) for(ll i = (a); i < (b); ++i )
#define llrrep(i, a, b) for(ll i = (a); i > (b); --i )
#define llREP(i, a, b) for(ll i = (a); i <= (b); ++i )
#define llRREP(i, a, b) for(ll i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )



int D, N;
int A[110];

int main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    cout << *std::max_element(A, A+N) - *std::min_element(A, A+N) << endl;
}

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

main(){
    vector<int> N(3);
    cin >> N[0] >> N[1] >> N[2];
    
    sort(N.begin(),N.end());
    
    cout << N[0] <<" "<< N[1] <<" "<< N[2] << endl;
}


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

    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 10000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;  
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    const double PI=acos(-1.0);

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

        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int n;
            cin>>n;
            int freq[n+1]={};
            rep(i,1,n){
                int x;
                cin>>x;
                freq[x]++;
            }
            rep(i,1,n+1) cout<<freq[i]<<endl;
        }  
        return 0;       
    }       


    // First, solve the problem. Then, write the code. 
    

Measured memory_bytes: 4432
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if(N == 1){
        print(1);
        print(0);
    }else if(N == 2){
        print(2);
        print(0);
        print(11);
    }else{
        print(N-1);
        rep(i,0,N-1){
            rep(j,0,i+2){
                if(j == 0 || j == i+1){
                    cout << 1;
                }else{
                    cout << 0;
                }
            }
            cout << endl;
        }
    }


    

}


Measured memory_bytes: 3184
S = input()
YYMM = MMYY = False
A = int(S[:2:])
B = int(S[2::])

if 1 <= B <= 12:
    YYMM = True

if 1 <= A <= 12:
    MMYY = True

if YYMM and MMYY:
    print('AMBIGUOUS')
elif YYMM:
    print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const b = h(n);
    const c = m(n);
    const d = s(n);
    console.log(`${b}:${c}:${d}`);
});
function h(n){
    const hour = n/3600;
    const hourr = Math.floor(hour);
    return hourr;
}
function m(n){
    const mminutes = n%3600;
    const minutes = mminutes/60;
    const minutess = Math.floor(minutes);
    return minutess;
}
function s(n){
    const second1 = n%3600;
    const second2 = second1%60;
    const second = Math.floor(second2);
    return second;
}


Measured memory_bytes: 15260
N = int(input())
K = input()
K = "".join(K).split(" ")
K = [int(s) for s in K]
K.sort()
ans=0
for s in range(N):
	if int(K[-1])> int(K[-2]):
		ans+=int(K[-2])
	else:
		ans+=int(K[-1])
	del K[-2:]

print(ans)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MRINF = 5000000000000000;

ll N, K;
vector<ll> A;
ll f(ll k){
  ll now = 0;
  REP(i, N){
     now += (A[i]-1)/k;
  }

  return now <= K;

}

int main() {

  cin >> N >> K;
  // vector<ll> A(N);
  REP(i, N){
    ll a; cin >> a;
    A.push_back(a);
  }

  ll s = 0;
  ll t = 1e10;
  ll ng = s, ok = t;
  while (ok - ng > 1) {
      ll mid = (ng + ok) / 2;
      if(f(mid)) ok=mid;
      else ng=mid;
      // (f(A, mid) ? ok : ng) = mid;
  }

  cout << ok << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll a, b, c;

int main(){
    cin >> a >> b >> c;

    if(a + b + c < 22){
        cout << "win\n";
    } else {
        cout << "bust\n";
    }
    return 0;
}























Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
const int kInf = (1<<30);
const int kMaxN = 1e5+10;
typedef long long int64;
 
int maxv, X, Y, Z;
int a[kMaxN], b[kMaxN], c[kMaxN], y[kMaxN], z[kMaxN];
 
bool eq(double a, double b) {
	return fabs(a - b) < 1e-9;
}
 
pair<int64, int64> check(double incY) {
	int64 ans = 0, usedY = 0, usedZ = 0;
	vector<double> v(X + Y + Z);
	for (int i = 0; i < X + Y + Z; ++i) {
		v[i] = z[i+1] - max(0.0, y[i+1] + incY);
	}

	nth_element(v.begin(), v.begin() + v.size() - Z, v.end());
	double pivot = v[v.size() - Z];
	for (int i = 0; i < X + Y + Z; ++i) {
		double val = z[i+1] - max(0.0, y[i+1] + incY);
		if (!eq(val, pivot)) {
			if (val > pivot) {
				ans += z[i+1];
				++usedZ;
			} else {
				if (fabs(y[i+1] + incY) < 1e-9) {
					if (usedY < Y) {
						ans += y[i+1];
						usedY++;
					}
				}
				else if (y[i+1] + incY > 0) {
					ans += y[i+1];
					usedY++;
				}
			}
		}
	}

	for (int i = 0; i < X + Y + Z; ++i) {
		double val = z[i+1] - max(0.0, y[i+1] + incY);
		if (eq(val, pivot)) {
			if (usedZ < Z) {
				ans += z[i+1];
				++usedZ;
			} else {
				if (fabs(y[i+1] + incY) < 1e-9) {
					if (usedY < Y) {
						ans += y[i+1];
						usedY++;
					}
				}
				else if (y[i+1] + incY > 0) {
					ans += y[i+1];
					usedY++;
				}
			}
		}
	}

	return make_pair(ans, usedY);
}

void Solve() {
	cin >> X >> Y >> Z;
 
	maxv = 0;
	for (int i = 1; i <= X+Y+Z; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		maxv = max(maxv, max(a[i], max(b[i], c[i])));
	}
 
	int64 ans = 0;
	for (int i = 1; i <= X+Y+Z; ++i) {
		y[i] = b[i] - a[i];
		z[i] = c[i] - a[i];
		ans += a[i];
	}
 
	double lo = -1e9 - 10, hi = 1e9 + 10;
	int times = 60;
 
	while (times) {
		double mid = (lo + hi) * 0.5;
		if (check(mid).second < Y)
			lo = mid;
		else hi = mid;
		--times;
	}
 
	// scerr << hi << " " << get<1>(check(hi-0.00001)) << "\n";
	// cerr << ans << "\n";
	ans += check(hi).first;
	cout << ans << "\n";
}
 
int main() {
 
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
 
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(void)
{
	int x;
	scanf("%d",&x);
	if(x==4||x==11||x==18||x==25)			printf("mon\n");
	else if(x==5||x==12||x==19||x==26)		printf("tue\n");
	else if(x==6||x==13||x==20||x==27)		printf("wed\n");
	else if(x==7||x==14||x==21||x==28)		printf("thu\n");
	else if(x==1||x==8||x==15||x==22||x==29)		printf("fri\n");
	else if(x==2||x==9||x==16||x==23||x==30)		printf("sat\n");
	else if(x==3||x==10||x==17||x==24)		printf("sun\n");
	return 0;
}


Measured memory_bytes: 2688