akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}

/* ここからコード開始 */

int main(){
  kyopro;
  ll N, M;
  cin >> N >> M;
  if(N >= M){
    cout << 0 << rt;
    return 0;
  }
  vector<ll> X(M);
  for(auto&& i : X){
    cin >> i;
  }
  sort(all(X));
  vector<ll> dif(M-1);
  ll ans{};
  rep(i, 0, M-1){
    dif[i] = X[i+1] - X[i];
    ans += dif[i];
  }
  sort(rall(dif));
  rep(i, 0, N-1){
    ans -= dif[i];
  }
  cout << ans << rt;
}

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

int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> a(N);
  int64_t search = 1;
  for (int i = 0; i < N; i++){
    cin >> a[i];
    if (a[i] == search){
      search++;
    }
  }
  if (search == 1){
    cout << -1 << endl;
  }
  else {
    cout << N - search + 1 << endl;
  }
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


typedef struct T{
	int h, m;
	bool operator<(const T &r) {
		if (h < r.h) {
			return true;
		}
		else if (h > r.h) {
			return false;
		}
		else {
			return m < r.m;
		}
	}
	bool operator==(const T &r) {
		return h == r.h && m == r.m;
	}
}T;
int N;
vector<T> v;

bool srh(T t) {
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == t) {
			return true;
		}
	}
	return false;
}

int main(){
	int h, m;
	for (int I = 0; I < 2; I++) {
		scanf("%d", &N);
		for (int i = 0; i < N; i++) {
			scanf("%d%d", &h, &m);
			if (!srh({ h,m }))
				v.push_back({ h,m });
		}
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++) {
		printf("%d:%02d", v[i].h, v[i].m);
		if (i == v.size() - 1) {
			printf("\n");
		}
		else {
			printf(" ");
		}
	}

	return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

signed main() {
    ll N, X, M = INF, I;
    cin >> N;
    vector<ll> A;
    rep(i, N) cin >> X, A.push_back(X);
    ll max_val = *max_element(all(A));
    ll half = (max_val + 1) / 2;
    rep(i, N) {
        if (max_val == A[i]) continue;
        if (M > abs(A[i] - half)) {
            M = abs(A[i] - half);
            I = i;
        }
    }
    cout << max_val << " " << A[I] << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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

//int nm[10001][10001] = {0};

map<pair<int,int>,int> nm;

long long c[10001];

int b[10000];

int main() {
    int n,m;

    cin >> n >> m;

    while(1){
        int s,t,e;
        scanf(" %d %d %d",&s,&t,&e);
        if( (s+t+e) == 0) break;
        //nm[s][t] = e;
        nm[make_pair(s,t)] = e;
    }

    int l;

    cin >> l;

    pair<int,int> tmp;

    while(l--) {

        for(int i=1;i<=m;i++){
            scanf(" %d",&b[i]);
        }

        int i, j;
        for (i = 1; i <= n; i++) {
            c[i] = 0;
            /*for (j = 0; j < m; j++) {
                c[i] = c[i] + nm[i][j+1] * b[j];
            }*/
        }
        for(map<pair<int,int>,int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) {
            tmp = itr->first;
            c[tmp.first] += b[tmp.second] * itr->second;
            //cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << tmp.second << endl;
        }


        for(int i=1;i<=n;i++){
            cout << c[i];
            if(i!=n) cout <<  ' ';
        }
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 6408
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    int ans = 0;
    int pre = 0;
    rep(i, n) {
        cin >> a[i+1];
        //cout << abs(a[i+1]-a[i]) << endl;
        ans += abs(a[i+1]-a[i]);
    }
    a[n+1] = 0;
    ans += abs(a[n+1] - a[n]);
    //cout << ans << endl;
    rep(i, n) {
        //cout << abs(a[i+1] - a[i]) << " " << abs(a[i+2] - a[i]) << endl;
        cout << ans - abs(a[i+1] - a[i]) - abs(a[i+2] - a[i+1]) + abs(a[i+2] - a[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))
seki = 1
if A.count(0) == 0:
    for i in range(N):
        seki = seki*A[i]
        if seki > 10**18:
            seki = -1
            break
else:
    seki = 0
print(seki)

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

// 3つの単語の頭文字を取って略称を返すプログラム
// >> AtCoder Beginner Contest
// ABC
// >> AtCoder Snuke Contest
// ASC
// >> AtCoder X Contest
// AXC
int main() {
    string firstWord, secondWord, thirdWord;

    cin >> firstWord >> secondWord >> thirdWord;

    cout << firstWord.front() << secondWord.front() << thirdWord.front() << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char s[100];int n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	cin>>s[i];
	ans=0;
	for(int i=1;i<=n-2;++i)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
using System;

namespace ForAtCoder
{
    class Program
    {
        static void Main()
        {
            string[] arr = Console.ReadLine().Split(' ');

            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);
            int c = int.Parse(arr[2]);
            int d = int.Parse(arr[3]);

            while (true)
            {
                c = c - b;

                if (c <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }

                a = a - d;

                if (a <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }

        }
    }

}


Measured memory_bytes: 17856
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    ans=0
    for i in range(N,3*N,2):
        ans+=A[i]
    print(ans)
resolve()

Measured memory_bytes: 109968
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); 
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int> >
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull unsigned long long int

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

	BRAHAMASTRA

	ull n;
	cin>>n;
	ull sum=0;
	for(int i=1;i<n;++i)
	{
		sum+=((n-1)/i);
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int,input().split()))

count = 0
flg=True

for i in range(N):
    if A[i]%2==1:
        flg=False
while flg:
    count +=1
    for i in range(N):
        a,b = divmod(A[i],2)
        A[i] = a
        if b != 0:
            count -= 1
            flg=False
            break
print(count)



Measured memory_bytes: 64016
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using std :: vector;

template <typename Tp>Tp Max(const Tp &a, const Tp &b) {return a > b ? a : b;}
template <typename Tp>Tp Min(const Tp &a, const Tp &b) {return a < b ? a : b;}

template <typename Tp>void Read(Tp &x) {
    Tp in = 0, f = 1; char ch = getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f = -1; ch = getchar();}
    while(ch>='0' && ch<='9') {in = in * 10 + ch - '0'; ch = getchar();}
    x = in * f;
}

typedef long long LL;

const int SN = 300000 + 10;

const int MOD = 1000000007;

struct Node {
    LL f[3];
};

struct Edge {
    int v, next;
}E[SN];

vector<Node> dp[SN];

int head[SN], root[SN], num, INV, TIME, n;

void Add_E(int u, int v) {
    E[++num].v = v, E[num].next = head[u], head[u] = num;
}

int merge(int x, int y) {

    if(dp[x].size() < dp[y].size()) std :: swap(x, y);

    int sumx = dp[x].size() - 1, sumy = dp[y].size() - 1;

    int f0 = 0, f1 = 0, f2 = 0;
    
    for(int i = 0; i <= sumy; i++) {
	
	f0 = f1 = f2 = 0;

	f0 = (dp[x][sumx - i].f[0] * dp[y][sumy - i].f[0]) % MOD;

	f1 = (dp[x][sumx - i].f[1] * dp[y][sumy - i].f[0]) % MOD;

	f1 = (f1 + dp[x][sumx - i].f[0] * dp[y][sumy - i].f[1]) % MOD;

	for(int j = 0; j <= 2; j++)
	    for(int k = 2; j + k >= 2; k--) 
		f2 = (f2 + dp[x][sumx - i].f[j] * dp[y][sumy - i].f[k]) % MOD;

	dp[x][sumx - i].f[0] = f0, dp[x][sumx - i].f[1] = f1, dp[x][sumx - i].f[2] = f2;
    }

    dp[y].clear();

    return x;
}

void Dfs(int u) {

    if(!head[u]) root[u] = ++TIME;

    int dep = 0;
    
    for(int i = head[u]; i; i = E[i].next) {
	int to = E[i].v;
	Dfs(to);
	if(!root[u]) root[u] = root[to];
	else dep = Max(dep, (int)Min(dp[root[u]].size(), dp[root[to]].size())),
		 root[u] = merge(root[u], root[to]);
    }
    
    int sumx = dp[root[u]].size() - 1;
    
    int k = root[u];
    
    for(int i = 0; i < dep; i++)
	dp[k][sumx - i].f[0] = (dp[k][sumx - i].f[0] + dp[k][sumx - i].f[2]) % MOD, dp[k][sumx - i].f[2] = 0;

    Node tmp;

    tmp.f[0] = INV, tmp.f[1] = INV, tmp.f[2] = 0;
    
    dp[k].push_back(tmp);
}

LL ksm(LL a, LL b) {

    LL ans = 1, B = a;

    while(b) {
	if(b & 1) ans = (ans * B) % MOD;
	B = (B * B) % MOD;
	b >>= 1;
    }
    
    return ans;
}

int main() {

    int x;
    
    Read(n);

    for(int i = 1; i <= n; i++) Read(x), Add_E(x, i);
    
    INV = ksm(2, MOD - 2);

    Dfs(0);

    int k = root[0];

    int sumx = dp[k].size() - 1;

    int ans = 0;
    
    for(int i = 0; i <= sumx; i++) 
	ans = (ans + dp[k][sumx - i].f[1]) % MOD;

    ans = (1LL * ans * ksm(2, n + 1)) % MOD;

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 33904
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;


int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}



int64_t pow_remdiv(int64_t val, int64_t rem)
{
	return pow_rem(val, rem - 2, rem);
}

int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = pow_remdiv(dividor, rem);
	ret *= divident;
	ret %= rem;

	return ret;
}

int64_t nCr(int64_t n, int64_t r, int64_t rem) {
	if (n == 0) return 0;
	if (r > n) return 0;

	if (n - r < r) r = n - r;

	int64_t ret = 1;
	for (int64_t i = 0; i < r; i++) {
		ret *= (n - i);
		ret %= rem;
		ret = divide_rem(ret, i + 1, rem);
	}

	return ret;
}

int64_t kRem = 1000000007;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, a, b; cin >> n >>  a >> b;

	int64_t total = pow_rem(2, n, kRem) - 1;
	int64_t aval = nCr(n, a, kRem);
	int64_t bval = nCr(n, b, kRem);

	int64_t ans = (total - aval - bval) % kRem;
	if (ans < 0) ans += kRem;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
int main() {
	cin >> n >> m;
	vector<int> xl(n), yl(n), zl(n), xr(n), yr(n), zr(n), xc, yc, zc;
	for (int i = 0; i < n; i++) {
		cin >> xl[i] >> yl[i] >> zl[i] >> xr[i] >> yr[i] >> zr[i];
		xc.push_back(xl[i]);
		yc.push_back(yl[i]);
		zc.push_back(zl[i]);
		xc.push_back(xr[i]);
		yc.push_back(yr[i]);
		zc.push_back(zr[i]);
	}
	sort(xc.begin(), xc.end());
	xc.erase(unique(xc.begin(), xc.end()), xc.end());
	sort(yc.begin(), yc.end());
	yc.erase(unique(yc.begin(), yc.end()), yc.end());
	sort(zc.begin(), zc.end());
	zc.erase(unique(zc.begin(), zc.end()), zc.end());
	for (int i = 0; i < n; i++) {
		xl[i] = lower_bound(xc.begin(), xc.end(), xl[i]) - xc.begin();
		yl[i] = lower_bound(yc.begin(), yc.end(), yl[i]) - yc.begin();
		zl[i] = lower_bound(zc.begin(), zc.end(), zl[i]) - zc.begin();
		xr[i] = lower_bound(xc.begin(), xc.end(), xr[i]) - xc.begin();
		yr[i] = lower_bound(yc.begin(), yc.end(), yr[i]) - yc.begin();
		zr[i] = lower_bound(zc.begin(), zc.end(), zr[i]) - zc.begin();
	}
	vector<vector<vector<int> > > sum(xc.size(), vector<vector<int> >(yc.size(), vector<int>(zc.size())));
	for (int i = 0; i < n; i++) {
		for (int j = xl[i]; j < xr[i]; j++) {
			for (int k = yl[i]; k < yr[i]; k++) {
				for (int l = zl[i]; l < zr[i]; l++) {
					sum[j][k][l]++;
				}
			}
		}
	}
	long long ret = 0;
	for (int i = 0; i < xc.size(); i++) {
		for (int j = 0; j < yc.size(); j++) {
			for (int k = 0; k < zc.size(); k++) {
				if (sum[i][j][k] >= m) ret += 1LL * (xc[i + 1] - xc[i]) * (yc[j + 1] - yc[j]) * (zc[k + 1] - zc[k]);
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 7024
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; } 
//s2>s1;if(not) rtrn -1;

ll maxSubArraySum(ll a[], ll size) 
{ 
   ll max_so_far = a[0]; 
   ll curr_max = a[0]; 
  
   for (ll i = 1; i < size; i++) 
   { 
        curr_max = max(a[i], curr_max+a[i]); 
        max_so_far = max(max_so_far, curr_max); 
   } 
   return max_so_far; 
} 
   
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;

//	   cin>>tt;
	      while(tt--)
{

/*
3
1 2 3/*/
ll n,m,j,l,k,i;
cin>>n;
ll a[n];
ll ans=0;
ll mi=MOD;
fo(i,n)
{
	cin>>a[i];
	ans+=a[i];
}
mi=MOD;
fo(i,n)
{
	ans-=2*a[i];
	mi=min(mi,mdls(ans));
}
ans=mi;
cout<<ans;
ee;
	
}
return 0;
}













Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n);
    REP(i, 0, n) {
        cin >> x[i];
    }
    ll L;
    cin >> L;
    auto dp = make_v(n, 40, 0);
    REP(i, 0, n) {
        dp[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
    }
    REP(i, 1, 40) {
        REP(j, 0, n) {
            dp[j][i] = dp[dp[j][i - 1]][i - 1];
        }
    }
    int Q;
    cin >> Q;
    REP(i, 0, Q) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a > b) {
            swap(a, b);
        }
        ll ans = 1;
        for (int j = 40 - 1; j >= 0; j--) {
            if (dp[a][j] < b) {
                ans += 1LL << j;
                a = dp[a][j];
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 21120
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

char str[101];

int main()
{
    scanf("AtCoder %s Contest",str);
    printf("A%cC",str[0]);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int N=sc.nextInt();
	int[] A=new int[N];
	int max=0;
	int secondMax=0;
	for(int i=0;i<N;i++) {
		A[i]=sc.nextInt();
		if(A[i]>max) {
			secondMax=max;
			max=A[i];
		}else if(A[i]>secondMax) {
			secondMax=A[i];
		}
	}
	for(int i=0;i<N;i++) {
		if(A[i]==max) {
			System.out.println(secondMax);
		}else {
			System.out.println(max);
		}
	}
}
}

Measured memory_bytes: 90600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  private static long MOD = (long)1e9 + 7;

  private static long addModulo(long a, long b, long mod) {
    long sum = a + b;
    if (sum >= mod) {
      sum -= mod;
    }
    return sum;
  }

  private static long multModulo(long a, long b, long mod) {
    return (a * b) % mod;
  }

  /** The solution to the problem. */
  public static void solve() {
    int n = scanner.nextInt();
    List<Integer>[] edges = new ArrayList[n];
    for (int i = 0; i < n; i++) {
      edges[i] = new ArrayList<>();
    }
    for (int i = 0; i < n - 1; i++) {
      int u = scanner.nextInt() - 1;
      int v = scanner.nextInt() - 1;
      edges[u].add(v);
      edges[v].add(u);
    }
    long[] result = recur(edges, 0, -1);
    printer.println(addModulo(result[0], result[1], MOD));
  }

  private static long[] recur(List<Integer>[] edges, int u, int parent) {
    long cntBlack = 1;
    long cntWhite = 1;
    for (int v : edges[u]) {
      if (v == parent) {
        continue;
      }
      long[] res = recur(edges, v, u);
      cntBlack = multModulo(cntBlack, res[0], MOD);
      cntWhite = multModulo(cntWhite, addModulo(res[0], res[1], MOD), MOD);
    }
    return new long[]{cntWhite, cntBlack};
  }

  /**
   * The main method.
   *
   * @param args arguments
   */
  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 73112
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f[2000][2000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	if ((n*m) % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;

	return 0;

}

Measured memory_bytes: 2560
N = int(input())
s = len(input())

mod = 10**9 + 7
dp = [1] + [0]*N
for i in range(N):
    dp = [dp[0] + dp[1]] + [(i + 2*j) % mod for i, j in zip(dp[2:] + [0],dp[:-1])]
print(dp[s]*pow(2**s, mod - 2, mod)%mod)

Measured memory_bytes: 77788
#include <iostream>
#include <cstring>
using namespace std;
const int N_MAX = 10;
const int S_MAX = 330;
int results[N_MAX + 1][S_MAX + 1];
bool used[10 + 1];
int i;

void permutations(int p, int sum) {
	if (p == 0) {
		results[i][sum]++;
	}
	else {
		for (int i = 0; i < 10; i++) {
			if (used[i]) continue;
			used[i] = true;
			permutations(p - 1, sum + i * p);
			used[i] = false;
		}
	}
}

int main () {
	for (i = 1; i <= 10; i++) {
		memset(results, 0, sizeof(0));
		permutations(i, 0);
	}
	int n, s;
	while (cin >> n >> s) {
		if (s > S_MAX) cout << 0 << endl;
		else cout << results[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cctype>
#include <sstream>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(c, it) for (iter(c) it = (c).begin(); it != (c).end(); it++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll sum=1;
  rep(i,n) {
    if(sum<a[i]) break;
    sum+=a[i];
  }
  pr(sum);
  return 0;
}


Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 100, MAX_W = 1E5;
int N, W, w[MAX_N], v[MAX_N];
int64_t dp[MAX_N][MAX_W+1];

void solve() {
	dp[0][w[0]] = v[0];
	for(int i = 0; i < N - 1; i++) for(int j = 0; j <= W; j++) {
		if(j - w[i+1] >= 0) {
			dp[i+1][j] = max(dp[i][j - w[i+1]] + v[i+1],  dp[i][j]);
		} else {
			dp[i+1][j] = dp[i][j];
		}
	}
	int64_t result = 0;
	for (int i = 0; i <= W; i++) if(result < dp[N-1][i]) result = dp[N-1][i];
	cout << result << endl << endl;
}
int main() {
	cin >> N >> W;
	for(int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 77568
#解説参照
#毎日売り買いしてよい

n=int(input())
*a,=map(int, input().split())

yen=1000

for i in range(n-1):
    if a[i]<a[i+1]:
        yen = (yen//a[i])*a[i+1]+yen%a[i]
print(yen)



Measured memory_bytes: 9164
import sys
import heapq
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

n = int(input())
uf = UnionFind(n)
d = {}

for i in range(n):
    x, y = map(int, input().split())
    d[x] = (i, y)
    
q = []
heapq.heapify(q)

for x in range(n):
    i, y = d[x+1]
    ym, im = 0, 0
    while q and q[0][0] < y:
        y2, i2 = heapq.heappop(q)
        if ym == 0:
            ym = y2
            im = i2
        uf.union(i,i2)
    heapq.heappush(q, (y,i))
    if ym:
        heapq.heappush(q, (ym,im))

for i in range(n):
    p = uf.find(i)
    print(-uf.parents[p])


Measured memory_bytes: 106696
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL INF = 0x3f3f3f3f3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

const int pr[4] = {0, 2, 3, 5};
LL cost[4], D;
map<LL, LL> mp;

LL Calc(LL x) {
	if (!x) return 0;
	if (mp.count(x)) return mp[x];
	mp[x] = INF;
	if (mp[x] / x >= D) mp[x] = x * D;
	for (int i = 1; i <= 3; ++i) {
		if (x % pr[i]) {
			cmin(mp[x], Calc(x / pr[i]) + cost[i] + D * (x % pr[i]));
			cmin(mp[x], Calc(x / pr[i] + 1) + cost[i] + D * (pr[i] - x % pr[i]));
		} else {
			cmin(mp[x], Calc(x / pr[i]) + cost[i]);
		}
	}
	return mp[x];
}

void solve() {
	LL n; read(n);
	read(cost[1]); read(cost[2]); read(cost[3]); read(D);
	mp.clear();
	printf("%lld\n", Calc(n));
}

int main() {
	int T; read(T);
	while (T--) {
		solve();
	}
	return 0;
}


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

int main() {
    int k;
    cin >> k;
    
    int ans = 0;
    for(int i = 1; i <= k; i++){
     for(int j = 1; j <= k; j++){
      for(int l = 1; l <= k; l++){
          ans += gcd(i, gcd(j,l));
     }
    }
    }
    
    cout << ans;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll A, B, a, b;
	cin>>A>>B>>a>>b;
	int c = 1e6;
	vector<vector<int>> g(A, vector<int>(B, 0));
	for(int i = 0; i < A; i+=a){
		for(int j = 0; j < B; j+=b){
			g[i][j] = c;
		}
	}
	int a2 = A%a, b2 = B%b;
	if(a2||b2){
		cout<<"Yes"<<endl;
		for(int i = 0; i+a2 < A; i+=a){
			for(int j = 0; j+b2 < B; j+=b){
				g[i+a2][j+b2] = -c-1;
			}
		}
		rep(i, A) cout<<g[i]<<endl;
	} else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

int main() {
  int i, N, K, ans = 1;
  scanf("%d%d", &N, &K);
  for(i = 0; i < N; ++i){
    if(ans * 2 <= ans + K)
      ans *= 2;
    else
      ans += K;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#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 fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

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

    cout<<min(n*a,b)<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

// using
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long long ull;

// assert
template <typename T>
void assert_between(T val, T min, T max)
{
    assert(min <= val && val <= max);
}

// math
// 最大公約数(Gratest Common Divisor)を求める.
template <typename T>
T gcd(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : gcd(num2, mod);
}

// 最小公倍数(Least Common Multiple)を求める.
template <typename T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}

double solve(int n, int k);

double solve(int n, int k)
{
    double probability_sum = 0.0;
    for (int i = 1; i <= n; i++)
    {
        double probability = static_cast<double>(1.0 / n);
        int num = i;
        while (num < k) {
            probability /= 2.0;
            num *= 2;
        }
        // printf("i:%d, p:%lf\n", i, probability);
        probability_sum += probability;
    }
    return probability_sum;
}

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

    int n = INT32_MAX;
    int k = INT32_MAX;
    scanf("%d %d", &n, &k);
    assert(1 <= n && n <= static_cast<int>(pow(10, 5)));
    assert(1 <= k && k <= static_cast<int>(pow(10, 5)));

    double answer = solve(n, k);

    printf("%13.12lf\n", answer);

    return 0;
}


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

int main(){
  
	int N;
  	cin >> N;
  
  	int res = 0;
	for(int i = 9 ; i > 0 ; i--){
      if( N % i == 0 ){
        res = N / i;
        break;
      }
    }
  
  	if( res < 10 ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  	
  
}

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

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

        if (a<b) cout << "a < b" << endl;
        else if (a>b) cout << "a > b" << endl;
        else if (a==b) cout << "a == b" << endl;

        return 0;
}

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

using namespace std;

int num = 6;
int price[] = {100, 101, 102, 103, 104, 105};

int solve(int X) {
    if (X >= 3000 || X % 100 == 0) {
        return 1;
    }
    int min_items = 0;
    min_items += (X % 100) / 5;
    if ((X % 5) != 0) {
        min_items += 1;
    }
    if (min_items <= X / 100) {
        return 1;
    }
    return 0;
}

int main(void) {
    int X;
    cin >> X;
    cout << solve(X) << endl;
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b[ohara],c,d,cmp[ohara],cmpp,m,h,w,x,y,sum=0,pos,even[ohara],cntt=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl[ohara];
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n;
      map<ll,ll> mp;
      map<ll,ll> ac;
      map<ll,ll> wa;
      rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        if(ac[a[i]]==0){
        cmp[cnt++]=a[i];
        ac[a[i]]=1;
        }
      }
      pos=n;
      rep(i,n){
        if(!wa[a[i]]){
        pos-=mp[a[i]]-1;
        wa[a[i]]=1;
        }
      }
      n=pos;
      sort(cmp,cmp+cnt);
      rep(i,cnt){
        if(mp[cmp[i]]%2==0)ans++;
        else even[cntt++]=mp[cmp[i]];
      }
      if(ans%2==1)ans=1;
      else ans=0;
      Cout(n-ans);
     
    
       
return 0;
}


Measured memory_bytes: 25984
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]<s[i+1]:
        k=i
a="z"
for i in range(k+1,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

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

map<string, int> mp;

int f(string a, string b, string c, long long n){
	if(stoll(a+b+c) <= n && mp[a+b+c] == 0){
		mp[a+b+c]++;
		return 1 + f(a+'3', b, c, n) + f(a+'5', b, c, n) + f(a+'7', b, c, n) + 
		f('3'+a, b, c, n) + f('3'+a, b, c, n) + f('3'+a, b, c, n) + 
		f(a, b+'3', c, n) + f(a, b+'5', c, n) + f(a, b+'7', c, n) +
		f(a, '3'+b, c, n) + f(a, '5'+b, c, n) + f(a, '7'+b, c, n) +
		f(a, b, c+'3', n) + f(a, b, c+'5', n) + f(a, b, c+'7', n) + 
		f(a, b, '3'+c, n) + f(a, b, '5'+c, n) + f(a, b, '7'+c, n);
	} else return 0;
}

int main(){
	long long n;
	cin >> n;
	cout << f("3","5","7", n) + f("3","7","5", n) + f("5","3","7", n) + f("5","7","3", n) + f("7","3","5", n) + f("7","5","3", n) << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b){
	return *(int*)a-*(int*)b;	
}

int main(){
	int N;
	scanf("%d",&N);
	int s[N+1];
	for(int i=0;i<N;++i){
		scanf("%d",&s[i]);
	}
	
	qsort(s,N,sizeof(int),compare_int);
	int score=0;
	for (int i=0;i<N;++i){
		score+=s[i];
	}
	for(int j=0;j<N;++j){
		if(score%10!=0){
			break;
		}else if(s[j]%10!=0){
			score -= s[j];
		}
	}
	if(score%10==0)score = 0;
	printf("%d",score);
	return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 1000; i++) {
    int u = i * 8 / 100;
    int v = i * 10 / 100;
    if (u == a && v == b) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,r,rate;
	scanf("%d %d",&n,&r);
	if(n<10){
		rate=r+100*(10-n);
	}else{
		rate=r;
	}
	if(rate<0){
		rate=0;
	}
	printf("%d",rate);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ins insert
#define ll long long
#define Pair pair<int,int>
#define MT make_tuple
#define MP make_pair
#define INF 0x3f3f3f3f
#define lim 1e9
#define Bigint 3e8+1
#define MAX 3e5
#define NL '\n'
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, //for indexed_set
        tree_order_statistics_node_update> indexed_set;

/*ll A,B,X,N,c,key;

ll power(ll ko,ll io)
{
    ll y=ko;
    if(io==0) return 1;
    else{
        io--;
        while(io--)
        {
            ko = ko*y;
        }
        return ko;
    }
}
ll rec(ll l,ll r,ll beta)
{
    ll mid = (l+r)/2,a,b,k;
    a = A*l + beta;
    b = A*mid + beta;
    k = A*r + beta;

    cout << "echo "<< l <<" "<< a <<NL;
    cout << "echo "<< mid <<" "<< b <<NL;
    cout << "echo "<< r <<" "<< k <<NL;

    if(r==l+1)
    {
        if(a<=X) key = l;
        else key = r;
        cout << key <<" "<< a <<" "<< b <<" "<< k << NL;
        return key;
    }
    else if(a<=A && b>=A){
        cout << "L\n";
        return rec(l,mid,beta);
    }
    else if(b<=A && k>=A){
        cout << "R\n";
        return rec(mid,r,beta);
    }

}*/
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //freopen("input.txt","r",stdin);

   /* ll c,p,q,prmx,echo,k,mn,mx,l,r,bet;

    cin >> A >> B >> X;

    prmx = 0;
    for(int i=1 ; i<=18 ; i++){
        c = B*i;
        //cout << "c ="<<c<<" "<<i<<NL;
        p = power(10,i-1);
        q = (power(10,i)-1);
        mn = A*p+c;
        mx = A*q+c;
        //cout << p<<" "<<mn<<" "<<q<<" "<<mx<<NL;
        if( X>prmx && X<mn ){
          //  cout << prmx;
            return 0;
        }
        else if(X>mn && X<mx){
            l = p;
            r = q;
            bet = c;
            //cout << l <<" "<< r <<" "<<c<< NL;
            break;
        }
        else prmx = mx;
    }
    echo = rec(l,r,bet);

    cout << echo;
*/
    ll r;
    cin >> r;
    cout << r*r;

    return 0;
}


Measured memory_bytes: 256
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))

    ans = 0
    for l1 in L:
        for l2 in L:
            diff = abs(l1- l2)
            ans = max(ans, diff)
    print(ans)

Measured memory_bytes: 70124
import itertools as it
dic={}
bing=[[0 for i in range(3)] for j in range(3)]
for i in range(3):
    f=list(map(int,input().split()))
    for each in f:
        dic.update({each:(i,f.index(each))})
n=int(input())
for i in range(n):
    m=int(input())
    if m in dic.keys():
        place=dic[m]
        bing[place[0]][place[1]]=1
flag=False
code="000102101112202122"
code=code+code[::-1]
code=code+"001122021120"

for i in range(8):
    code_sep=code[6*i:6*i+6]
    p=1
    for j in range(3):
        cords=code_sep[2*j:2*j+2]
        p*=bing[int(cords[0])][int(cords[1])]
    if p==1:
        flag=True
        break
    
print("Yes")if flag else print("No")

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll dp[105][4][4][2];

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

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            dp[2][i][j][0] = 1;
        }
    }

    for (int i = 2; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    if (j == 0 && k == 2 && l == 1) continue;
                    if (j == 0 && k == 1 && l == 2) continue;
                    if (j == 2 && k == 0 && l == 1) continue;
                    (dp[i + 1][k][l][j == 0] += dp[i][j][k][0]) %= MOD;
                    if ((j == 2 || k == 2) && l == 1) continue;
                    (dp[i + 1][k][l][j == 0] += dp[i][j][k][1]) %= MOD;
                }
            }
        }
    }
    
    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            (ans += (dp[n][i][j][0] + dp[n][i][j][1]) % MOD) %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"Bad"<<endl;return 0;}
//template

//main
signed main(){
  int N,L;cin>>N>>L;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)v[i]=L+i;
  int m=LINF;
  for(int i=0;i<N;i++){
    if(abs(m)>abs(v[i])){
      m=v[i];
    }
  }

  int sum=0;
  for(int i=0;i<N;i++)sum+=v[i];
  cout<<sum-m<<endl;
}


Measured memory_bytes: 256