akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool solvable(const vi& b)
{
	int n=b.size();
	rep(i,n)
		if(b[i]>i)
			return false;
	return true;
}

bool ok(const vi& b,int i,const vi& used)
{
	if(used[i])
		return false;
	return count(begin(used),begin(used)+i,1)>=b[i];
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi b(n);
		rep(i,n) cin>>b[i],b[i]--;

		if(!solvable(b)){
			cout<<-1<<endl;
			continue;
		}

		vi used(n);
		vi res;
		rep(_,n){
			per(i,n) if(ok(b,i,used)){
				res.push_back(b[i]);
				used[i]=1;
				break;
			}
		}
		rep(i,n) cout<<res[i]+1<<endl;
	}
}


Measured memory_bytes: 256
# 3 N numbers
import heapq
N = int(input())
a = list(map(int, input().split()))
S = sum(a[:N])
b = a[:N]
heapq.heapify(b)
dpmax = [S for i in range(N+1)]
# dpmax[x] = 前半　ｘ + N このうちmax N　このわを記録
for i in range(N, 2*N):
    heapq.heappush(b, a[i])
    d = heapq.heappop(b)
    S += a[i]-d
    dpmax[i-N+1] = S

c = a[-N:]
for i in range(N):
    c[i] = -c[i]
T = sum(c)
heapq.heapify(c)
dpmin = [-T for i in range(N+1)]

# dpmin[x]= 後半　x + N このうち　min Nこのわを記録する
for i in range(N, 2*N):
    heapq.heappush(c, -a[-1-i])
    d = heapq.heappop(c)
    T += -a[-1-i]-d
    dpmin[i+1-N] = -T

ans = -1000000000000000000000000000000
for i in range(N+1):
    ans = max(ans, dpmax[i]-dpmin[N-i])
print(ans)

Measured memory_bytes: 38292
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
#define pii pair <int ,int >
#define bug(x)  cout<<"passed "<<x<<endl;
long long const inf = 1e18, linf = 2e9, mod = 1e9+7;
int const mxn = 4e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}


int main(){
	int a , b , c ; 
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;

const string YES = "Yes";

const string NO = "No";

const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;
string num = "0123456789";
bool solve(long long A, long long B, std::string S) {

    debug(0);
    rep(i, A) {
        if (S[i] == '-') return false;
    }

    debug(1);
    if (S[A] != '-') {
        debug(A);
        return false;
    }
    debug(2);
    reps(i, A + 1, A + B + 1) {
        debug(i);
        if (S[i] == '-') return false;
    }
    return true;
}
signed main() {
    long long A;
    cin >> A;
    long long B;
    cin >> B;
    std::string S;
    std::cin >> S;
    if (solve(A, B, S)) {
        print(YES);
    } else {
        print(NO);
    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;
    if(t.substr(0,s.length())==s) cout<<"Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

const int MAX_V = 300;

/*---全点対最短路問題（ワーシャルフロイド法）P98---*/
int d[MAX_V][MAX_V];  //d[u][v]は辺e=(u,v)のコスト（存在しない場合はINF、ただしd[i][i]=0)
int d2[MAX_V][MAX_V];  //d[u][v]は辺e=(u,v)のコスト（存在しない場合はINF、ただしd[i][i]=0)

int V; //頂点数

void warshall_floyd(){
  rep(k, 0, V-1)rep(i, 0, V-1)rep(j, 0, V-1)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
void warshall_floyd2(){
  rep(k, 0, V-1)rep(i, 0, V-1)rep(j, 0, V-1)d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
}


int main(){
    int n,m,l,q,a,b,c;
    cin >> n >> m >> l;
    V = n;
    rep(i,0,V-1)rep(j,0,V-1){d[i][j] = i == j ? 0 : INF;d2[i][j] = i == j ? 0 : INF;}
    rep(i,0,m-1){
        cin >> a >> b >> c;
        --a;--b;
        if(c<=l){
            d[a][b] = c;
            d[b][a] = c;
        }
    }
    cin >> q;
    vector<int> s(q),t(q);
    rep(i,0,q-1){
        cin >> s[i] >> t[i];
        --s[i];--t[i];
    }
    // matprint(d,V,V);
    warshall_floyd();
    // matprint(d,V,V);
    rep(i,0,V-1)rep(j,0,V-1){
        if(i==j)continue;
        if(d[i][j] <= l){
            d2[i][j] = 1;
        }
    }
    warshall_floyd2();
    // matprint(d,V,V);
    // matprint(d2,V,V);

    rep(i,0,q-1){
        int ans = d2[s[i]][t[i]] == INF ? 0 : d2[s[i]][t[i]];
        cout << --ans << endl;
    }



   // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int base;
    cin >> base;

    vector<int> opt(N);
    for (auto& i : opt) cin >> i;

    vector<vector<int> > dp(N + 1, vector<int>(N + 1));
    dp[0][0] = base;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + opt[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        ans = max(dp[N][i] / (A + i * B), ans);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int x,a;cin>>x>>a;
  if(x<a){cout<<0;}
  else{cout<<10;}
}
      

Measured memory_bytes: 256
#実装が200点としては重い
h,w = map(int, input().split( ))

a_ = []

for i in range(h):
    ai = input()
    if ai!='.'*w:
        a_.append(ai)
#print(a_)
h = len(a_)

a = [[a_[i][j] for j in range(w)] for i in range(h)]
#print(a)
rmv = set()
for j in range(w):
    flag = True
    for i in range(h):
        if a[i][j] =="#":
            flag = False
            break
    if flag:
        rmv.add(j)
#print(rmv)
for i in range(h):
    rem = []
    for j in range(w):
        if j not in rmv:
            rem.append(a[i][j])
    print("".join(rem))



Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n, m;
int a[224514], b[224514];
int na[224514], nb[224514];
signed main() {
	cin >> n >> m;
	rep(i, m)cin >> a[i] >> b[i];
	rep(i, m) {
		if (a[i] == 1)na[b[i]]++;
		else if (b[i] == n)nb[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		if (na[i] >= 1 && nb[i] >= 1) {
			puts("POSSIBLE");
			ggr
		}
	}
	puts("IMPOSSIBLE");
	ggr
}


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

int main()
{
    int N, tmp;
    cin >> N;
    vector<int> A(N);
    double ans=0.0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        ans+=1.0/A[i];
    };

    ans=1/ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n,m,arr[MAXN];
vector<int>add[MAXN],rem[MAXN];
int go(int x,int y){
	return (y-x+m)%m;
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",arr+i);
	ll ans=0,fav=0;	
	for(int i=1;i<n;i++){
		int c=go(arr[i],arr[i+1]);
		if(c>=2){
			int to=arr[i+1];
			int nd=(to-(c-2)+m)%m;
			if(!nd)
				nd=m;
			//~ cout<<nd<<" "<<to<<endl;	
			if(nd<=to){
				ans+=c;
				add[nd].pb(-c+1+go(nd,to));
				rem[to].pb(+c-1);
			}
			else{
				ans+=go(1,to)+1;fav++;
				rem[to].pb(+c-1);
				add[nd].pb(-c+1+go(nd,to));
			}
		}
		else
			ans+=c;
	}ll mn=LONG_MAX;
	for(int i=1;i<=m;i++){
		tr(it,add[i])
			ans+=*it,fav++;
		umin(mn,ans);
		tr(it,rem[i])
			ans+=*it,fav--;
		ans-=fav;	
	}
	printf("%lld\n",mn);
	return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

vector<vvb> dp(80,vvb(80,vb(6401,false)));
int h,w;

void dfs(vvi &d,int x,int y,int now){
  if(x >= h || y >= w) return;
  if(x == h-1 && y == w-1){
    cout << "now:" << now << endl;
    dp.at(x).at(y).at(now) = true;
    return;
  }
  int w = d.at(x).at(y);
  //if(dp.at(x).at(y).at(now)) return;
  
  if(abs(now + w) <= 6400) dfs(d,x+1,y,abs(now + w));
  if(abs(now - w) <= 6400) dfs(d,x+1,y,abs(now - w));
  if(abs(now + w) <= 6400) dfs(d,x,y+1,abs(now + w));
  if(abs(now - w) <= 6400) dfs(d,x,y+1,abs(now - w));
}

int main(){
  int h,w;
  cin >> h >> w;
  vvi a(h,vi(w));
  vvi b(h,vi(w));
  vvi d(h,vi(w));
  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  rep(i,h){
    rep(j,w){
      cin >> b.at(i).at(j);
    }
  }
  rep(i,h){
    rep(j,w){
      d.at(i).at(j) = abs(b.at(i).at(j) - a.at(i).at(j));
      //cout << d.at(i).at(j) << endl;
    }
  }
  
  //cout << 1 << endl;
  vector<vvb> dp(h,vvb(w,vb(8000,false)));
  dp.at(0).at(0).at(d.at(0).at(0)) = true;
  rep(i,h+w-1){
    if(i==0) continue;
    for(int j=0;j<=i;j++){
      if(j >= h || i-j >= w) continue;
      int v = d.at(j).at(i-j);
      //cout << v << endl;
      rep(k,6400){
        //cout << i << " " << j << " " << k << " " << endl; 
        if(j == 0){
          dp[j][i-j][k] = (dp[j][i-j-1][abs(k-v)] | dp[j][i-j-1][k+v]);
        }else if(i-j == 0){
          dp[j][i-j][k] = (dp[j-1][i-j][abs(k-v)] | dp[j-1][i-j][k+v]);
        }else{
          dp[j][i-j][k] = (dp[j-1][i-j][abs(k-v)] | dp[j-1][i-j][k+v] | dp[j][i-j-1][abs(k-v)] | dp[j][i-j-1][k+v]);
        }
        if(dp[j][i-j][k]) continue;
        //if(i==2&&j==1&&k==0) cout << "p" << endl;
        /*if(k-v >= 0){
          if(j == 0) dp[j][i-j][k] = (dp[j][i-j-1][k-v] | dp[j][i-j-1][abs(-k-v)]);
          else if(i-j == 0) dp[j][i-j][k] = (dp[j-1][i-j][k-v] | dp[j][i-j-1][abs(-k-v)]);
          else dp[j][i-j][k] = (dp[j-1][i-j][k-v] | dp[j][i-j-1][k-v] | dp[j-1][i-j][abs(-k-v)] | dp[j][i-j-1][abs(-k-v)]);
        }
        //if(i==2&&j==1&&k==0) cout << "s" << endl;
        if(dp[j][i-j][k]) continue;
        if(k+v < 12800){
          if(j == 0) dp[j][i-j][k] = (dp[j-1][i-j][k+v] | dp[j-1][i-j][abs(-k+v)]);
          else if(i-j == 0) (dp[j][i-j-1][k+v] | dp[j][i-j-1][abs(-k+v)]);
          else dp[j][i-j][k] = (dp[j-1][i-j][k+v] | dp[j][i-j-1][k+v] | dp[j-1][i-j][abs(-k+v)] | dp[j][i-j-1][abs(-k+v)] );
        }*/
        //if(i==2&&j==1&&k==0) cout << "a" << endl;
      }
    }
  }
  rep(i,12800){
    if(dp[h-1][w-1][i]){
      cout << i << endl;
      return 0;
    }
  }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

ll f( ll b, ll n ){
    ll sum = 0;
    while( n ){
        sum += n%b;
        n = n/b;
    }
    return sum;
}

int main() {

    ll n,s,b = 1e13;
    Scll2(n,s);

    if( n < s ){
        b = -1;
    }else if( n == s ){
        b = n+1;
    }else{
        ll nn = sqrt(n)+1;
        Repe(i,nn,2){
            // printf ("%lld = %lld\n", i, f(i,n) );
            if( f(i,n) == s ){
                b = min(b,i);
            }
        }
        Repe(i,nn,1){
            ll r = n/i; ll l = n/(i+1); ll c;
            // (l,r]
            // printf ("i=%lld (%lld,%lld]\n", i, l, r );
            while( r-l>1 ){
                c = (r+l)/2;
                if( f(c,n) <= s ) r = c;
                else l = c;
            }
            if( f(r,n) == s ) b = min(b,r);
        }
        if( b == 1e13 ) b = -1;
    }

    printf ("%lld\n", b );

    // Repe(i,n+3,2){
    //     if( f(i,n) == s ) {
    //         printf ("ans = %lld\n", i);
    //         break;
    //     }
    // }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,x,pos;
vector<int>v;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    int pos=0;
    for(int i=0;i<n;i++){
        if(v[i]==1)
        {
            pos=i;
            break;

        }
    }
   int pos1=0;
   int ans=0;
   if(k>=n){
    cout<<1;
    return 0;
   }
   pos1=0;
   //cout<<pos1<<k<<endl;
   while(pos1+(k-1)<=pos){
  //         cout<<pos1<<" ";
    pos1+=(k-1);


    ans++;
   }
   if(pos1<n-1  && pos!=pos){
      //  cout<<pos1<<" ";
    pos1+=k;
    ans++;
}
   while(pos1<n-1){
    pos1+=(k-1);
  //  cout<<pos1<<" ";
    ans++;
   }
   cout<<ans<<endl;
   return 0;

}


Measured memory_bytes: 892
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#p = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
dif = 1000
ans = 1000
for i in range(-101, 110):
    if not(i in p):
        if abs(i-x) < dif:
            dif = abs(i-x)
            ans = i
        elif abs(i-x) == dif:
            if ans > i:
                ans = i

print(ans)


Measured memory_bytes: 9192
import sys
import numpy as np

N = int(sys.stdin.readline().strip())
s = int(N / 2)
x = np.array(list(map(lambda x: int(x), sys.stdin.readline().strip().split(" "))))
index_list = np.argsort(x)

array_x = sorted(x)

a = array_x[s]

for i in range(N):
    if x[i] < a:
        print(array_x[s])
    else:
        print(array_x[s-1])


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

int main()
{
    string S;
    cin >> S;
    string bw, wb;
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            bw += '0';
            wb += '1';
        }
        else
        {
            bw += '1';
            wb += '0';
        }
    }
    int cntbw = 0, cntwb = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == bw[i])
        {
            cntwb++;
        }
        else
        {
            cntbw++;
        }
    }
    cout << min(cntbw, cntwb) << endl;
}

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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i < n - 1; i++) {
    int64_t b;
    cin >> b;
    a.at(b - 1)++;
  }
  for (int i = 0; i < n; i++) {
    cout << a.at(i) << endl;
  }
}

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

#define check cout<<"-------"<<endl;
#define debug(x) cout<<x<<endl;

void buildMaxHeap(int *);
void maxheapify(int *, int);

int N;

int main() {

  cin>>N;

  int a[N];
  for(int i = 1; i <= N; i++) cin>>a[i];

  buildMaxHeap(a);


  for(int i = 1; i <= N; i++) cout<<' '<<a[i];
  cout<<endl;

  return 0;
}

void maxHeapify(int *a, int i) {

  int l = i*2;
  int r = i*2+1;

  int largest;
  if( l <= N && a[l] > a[i])  largest = l;
  else largest = i;

  if(r <= N && a[r] > a[largest]) largest = r;

  if(largest != i) {
    int s = a[i];
    a[i] = a[largest];
    a[largest] = s;
    maxHeapify(a, largest);
  }
}

void buildMaxHeap(int *a) {
  for(int i = N/2; i > 0; i--) maxHeapify(a, i);
}



Measured memory_bytes: 5024
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


const int MX = 3100;

int n;
ll MOD;
ll cnk[MX][MX];
ll dp[MX][MX];

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> MOD;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= n; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
		}
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (j + 1)) % MOD;
			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
		}
	}
	ll ans = 0;
	for (int k = 0; k <= n; ++k) {
		ll now = 0;
		ll cur = 1;
		--MOD;
		ll av = pw(2, n - k);
		++MOD;
		ll p = pw(2, av) * cnk[n][k] % MOD;
		av = pw(2, n - k);
		for (int j = 0; j <= k; ++j) {
			now = (now + cur * dp[k][j]) % MOD;
			cur = (cur * av) % MOD;
		}
		now = (now * p) % MOD;
		if (k % 2 == 0)
			ans = (ans + now) % MOD;
		else
			ans = (ans - now + MOD) % MOD;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 149760
n,m,x,y = map(int,input().split())
l = list(map(int,input().split()))
r = list(map(int,input().split()))

for i in range(-100,101):
  if x<i and i<=y and max(l)<i and min(r) >= i:
    print("No War")
    exit()
print("War")

Measured memory_bytes: 8840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
      cout << "vowel" << endl;
    }
 else{
cout << "consonant"<< endl;
 
}
 
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n,a[101],i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);
  int cnt=0;
  for(i=0; i<n; i++) {
    for(j=n-1; j>i; j--) {
      if(a[j]<a[j-1]) {
	int tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	cnt++;
      }
    }
  }
  for(i=0; i<n; i++) {
    if(i) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);
  return 0;
}


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

def prime_factorize(n):
    prime_list = []
    tmp = n
    if n == 1:
        return []
    for i in range(2,int(n**0.5)+1):
        if tmp % i == 0:
            while tmp % i == 0:
                tmp = tmp // i
                prime_list.append(i)
                
    if tmp != 1:
        prime_list.append(tmp)
        
    if len(prime_list) == 0:
        return [n]
    else:
        return prime_list


import collections
c = collections.Counter(prime_factorize(N))

tmp = []
for i in range(1,40):
    tmp.append((1+i)*i//2)
import bisect
ans = 0
for i in list(c.values()):
    ans += bisect.bisect_right(tmp,i)
print(ans)

Measured memory_bytes: 9604
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
ans = 0
d = defaultdict(int)

for i in A:
    d[i] += 1

for v in d.values():
    ans += v*(v-1)//2

for i in A:
    print(ans - (d[i] - 1))

Measured memory_bytes: 26780
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-3)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

double w,h,v,t,x,y,p,q,r;

ull count(double W){
  if(r-(W-x)<-eps)return 0;
  double H=sqrt(r*r-(W-x)*(W-x));
  ull res=0;
  res+=(int)((y+H-q)/h)-(int)((y-H-q)/h);
  res+=(int)((y+H+q)/h)-(int)((y-H+q)/h);
  if(y-H<=q && q<=y+H)res++;
  if(y-H<=-q && -q<=y+H)res++;

  return res;
}

ull solve(){
  ull res=0;
  r=v*t;w*=2.0;h*=2.0;
  for(double i=p;i-x-r<eps;i+=w)res+=count(i);
  for(double i=-p;i-x-r<eps;i+=w)res+=count(i);
  for(double i=p-w;x-r-i<eps;i-=w)res+=count(i);
  for(double i=-p-w;x-r-i<eps;i-=w)res+=count(i);
  return res;
}

int main()
{
  cin>>w>>h>>v>>t>>x>>y>>p>>q;
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 3336
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

ll func(string s,ll k){
	ll ret=0;
	if(k==0)return 1;
	ll n=s.size();
	if(s.empty())return 0;	
	ll d=(s[0]-'0');
	string s2;
	for(int i=1;i<n;i++)s2.push_back(s[i]);
	if(d==0){
		return func(s2,k);
	}else{
		//zero
		ret+=binomial<ll>(n-1,k)*pow(9,k);
		ret+=(d-1)*binomial<ll>(n-1,k-1)*pow(9,k-1);
		ret+=func(s2,k-1);
	}
	return ret;
}

int main(){
	string n;ll k;cin>>n>>k;
	cout<<func(n,k)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
int INF=pow(10,9);

int main(){
    int N,Ma,Mb;cin>>N>>Ma>>Mb;
    vector<vector<vector<int>>> dp(50,mat(410,vec(410,INF)));
    dp[0][0][0]=0;
    for(int i=1;i<=N;i++){
        int a,b,c;cin>>a>>b>>c;
        for(int j=0;j<=400;j++){
            for(int k=0;k<=400;k++){
                if(j>=a && k>=b)
                    dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c);
                else 
                    dp[i][j][k]=dp[i-1][j][k];
            }
        }
    }
    int i=1,ans=INF;
    while(Ma*i<=400 && Mb*i<=400){
        ans=min(ans,dp[N][Ma*i][Mb*i]);
        i++;
    }
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 34560
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int h = h2 - h1;
	int m = m2 - m1;

	if (m < 0) {
		h--;
		m += 60;
	}

	int ans = h * 60 + m - k;
	
	cout << max(0, ans) << endl;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<functional>
#include<vector>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<bitset>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){return a=min(a,b);}
template<typename T> T chmax(T &a,T b){return a=max(a,b);}

void a(){
    string s,t; 
    cin >> s >> t;
    if(s==t.substr(0,t.size()-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

void b(){
    ll a,b,c,k; 
    cin >> a >> b >> c >> k;
    ll count=0;

  	rep(i,a){
      	if(k<=0) break;
        k--;
        count++;
    }
  
    rep(i,b){
      	if(k<=0) break;
        k--;
    }
  
    rep(i,c){
      	if(k<=0) break;
        k--;
        count--;
    }

  	cout << count << endl;

}

void c(){
    ll N,M,X; cin >> N >> M >> X;
    auto C = v<>(N,0); 
    auto A = vv<>(N,v<>(M,0));
    rep(i,N) {
        cin >> C[i];
        rep(j,M) cin >> A[i][j];
    }
  
    ll _min = INF;
    rep(i,1<<N){
      	v<> count(M,0);
      	ll cc=0;
        for(ll ii=0;(1<<ii)<=i;ii++){
            if((i>>ii)&1) {
            	rep(j,M) count[j]+=A[ii][j];
            	cc+=C[ii];
            }
        }
        bool f=true;
      	rep(j,M) if(count[j]<X) f=false;
      	if(f) {
          chmin(_min,cc);
        }
    }
    cout << (_min==INF?-1:_min) << endl;
}

void d(){

}

int main(){
    c();
    return 0;
}


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

using namespace std;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  vector<int64_t> a(n);
  vector<int64_t> am(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  am[0] = a[n-1];
  am[0] %= MOD;
  for (int i = 1; i < n; ++i) {
      am[i] = am[i-1] + a[n-i-1];
      am[i] %= MOD;
  }

  int64_t ans = 0;

  for (int i = 0; i < n-1; ++i) {
    ans += (am[n-i-2] * a[i]);
    ans %= MOD;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 6340
N = int(input())
List = [list(map(int, input().split())) for _ in range(N)]

import itertools
import collections

if N==1:
    print(1)
    
else:
    arr = list(itertools.combinations(List, 2))
    vec1 = []
    vec2 = []
    for i in range(len(arr)):
        vec1.append([arr[i][1][0]-arr[i][0][0], arr[i][1][1]-arr[i][0][1]])
        vec2.append([arr[i][0][0]-arr[i][1][0], arr[i][0][1]-arr[i][1][1]])
        
    vec = vec1+vec2
    counter = collections.Counter(map(tuple, vec))
    
    v =  counter.most_common(1)[0][0]
    num = counter.most_common(1)[0][1]
    
    print(N-num)

Measured memory_bytes: 4192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll X, A, B;
    scanf("%lld %lld %lld", &X, &A, &B);
    A = B-A;
    if(A<=0) printf("delicious\n");
    else if(A<=X) printf("safe\n");
    else printf("dangerous\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M  = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
UF = UnionFind(N)

for ab in AB:
    UF.Unite(ab[0]-1, ab[1]-1)

li = [0 for i in range(N)]
for i in range(N):
    mm = UF.Find_Root(i)
    li[mm] += 1

ans = 0
for i in range(N):
    if li[i]>=1:
        ans += 1
print(ans-1)







Measured memory_bytes: 97224
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	ll l, r;

	cin >> l;
	cin >> r;
	
	int ret = 2020;

	for (ll i = l; i < r; ++i) {
		for (ll j = i + 1; j < r + 1; ++j) {
			if (i * j % 2019 < ret) {
				ret = i * j % 2019;
			}
			if (ret == 0) break;
		}
		if (ret == 0) break;
	}

	cout << ret << endl;
	
	return 0;
}

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

signed main(){
	string S; cin>>S;
	int Q; cin>>Q;
	int p=0;
	for(int i=0;i<Q;i++){
		int T; cin>>T;
		if(T==1)p++;
		else if(T==2){
			int F; string C; cin>>F>>C;
			if(p%2==1){
				if(F==1)S+=C;
				else {
					S.insert(0,C);
				}
			}
			else {
				if(F==1){
					S.insert(0,C);
				}
				else S+=C;
			}
		}
	}
    string ans=S;

	if(p%2==1){
       reverse(ans.begin(),ans.end());
    }

	cout<<ans<<endl;
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=0;
	rep(i,n) ans+=a.at(i)-1;
	cout << ans << endl;
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    map< int, int > used;
    while(n--) {
        int a; cin >> a;
        used[a]++;
    }
    for(auto p: used) {
        if(p.second % 2) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int a,b;
int main(){
  cin>>a>>b;
  if(a+b>=10)
    cout<<"error\n";
  else
    cout<<a+b<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		int K=stdIn.nextInt();
		int ans=0;
		if(A>=K)
			System.out.println(K);
		else{
			K-=A;ans+=A;
			K-=B;
			if(K>0)
				ans-=K;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 35908
#include<iostream>
#include<string>

using namespace std;

int main() {
	string w;
	cin >> w;
	bool ans = true;

	for (char c = 'a'; c <= 'z'; c++) {
		int con = 0;
	  for (int i = 0; i < w.size(); i++) {
		  if (w[i] == c)con++;
		}
	  if (con % 2 != 0)ans = false;
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
long long n,cnt,k,num;
pair<long long,long long> p[100100];
long long ans,sum;
bool use[100100];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	reverse(p,p+n);
	for(int i=0;i<n;i++)swap(p[i].first,p[i].second);
	for(int i=0;i<n;i++)
	{
		if(cnt<k)
		{
			if(use[p[i].first])
				v.push_back(p[i].second);
			else
				num++,use[p[i].first]=true;
			sum+=p[i].second;
			ans=max(ans,sum+num*num);
			cnt++;
		}
		else
		{
			if(v.empty())break;
			if(use[p[i].first])continue;
			use[p[i].first]=true;
			num++;
			sum-=v.back();
			sum+=p[i].second;
			v.pop_back();
			ans=max(ans,sum+num*num);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

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

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

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

    if(min(a, b) < c && c < max(a, b)) co << "Yes" << en;
    else co << "No" << en;
    
    return 0;
}


Measured memory_bytes: 256
def code_for_A(test=None):

    if test:
        pass
    else:
        S = input()

    continuous = 0
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            continuous += 1

    if continuous > 0:
        answer = 'Bad'
    else:
        answer = 'Good'

    print(answer)


def code_for_B(test=None):

    if test:
        N, L = test
    else:
        N, L = map(int, input().split())

    _sum = int(L * N - N + N * (N + 1) / 2)

    if L <= 0:
        ate = min(0, L + N - 1)
    else:
        ate = max(0, L)

    print(_sum - ate)


def code_for_C(test=None):

    if test:
        A, B, C, D = test
    else:
        A, B, C, D = map(int, input().split())

    def divisible_num(A, B, num):
        result = B // num - (A-1) // num
        return result

    n_C_can_devide = divisible_num(A, B, C)
    n_D_can_devide = divisible_num(A, B, D)

    def gcd(a, b):
        while b != 0:
            a, b = b, a % b
        return a

    lcm = int(C * D / gcd(C, D))

    n_CD_can_devide = divisible_num(A, B, lcm)

    print(B - A + 1 - n_C_can_devide - n_D_can_devide + n_CD_can_devide)


def main():
    code_for_C()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, c, i, j, k, x, y, ans, p;
	cin >> a >> b >> c >> x >> y;
	ans = 1LL << 61;
	for (i = 0; i <= max(x, y) * 3; i+=2) {
		p = i * c + max(0LL, x - i / 2) * a + max(0LL, y - i / 2) * b;
		ans = min(ans, p);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
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
#include <stdio.h>

int dp[50];

int fib(int);

int main(){
  int n, i;

  for(i = 0;i < 50;i++) dp[i] = -1;
  scanf("%d", &n);
  printf("%d\n", fib(n));
  return 0;
}

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n-1) + fib(n-2);
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

int stage[1000];

int main(){
	int N,M;
	while(~scanf("%d %d",&N,&M)){
		if(N==M && M==0) break;
		for(int i=0;i<N;i++){
			int v;
			scanf("%d",&v);
			stage[i] = v;
		}

		int pos=0;
		int res=INF;
		for(int i=0;i<M;i++){
			int v;
			scanf("%d",&v);
			if(pos+v >= N-1){
				res = min(i+1,res);
				continue;
			}

			pos = (pos+v) + stage[(pos+v)];

			if(pos >= N-1){
				res = min(i+1,res);
				continue;
			}
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
import math
N = int(input())
ans = []

def digits(n):
    count = 1
    while n // 10 != 0:
        n = n // 10
        count += 1
    return count

for a in range(1, int(math.sqrt(N)) + 1):
    if N % a == 0:
        b = N // a
        ans.append(max(digits(a), digits(b)))

print(min(ans))



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

using namespace std;

typedef long long int lli;

lli gcd(lli a, lli b) {
    if(a < b) return gcd(b, a);
    int r;
    
    while ((r=a%b)) {
        a = b;
        b = r;
    }

    return b;
}

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

    int n;
    lli a[100], lcm = 1, sum = 0;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        lcm = lcm*a[i] / gcd(lcm, a[i]);
    }

    for (int i=0; i<n; i++) {
        sum += lcm/a[i];
    }

    printf("%.10f\n", (double)lcm / sum);

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1])
for b,c in bc[::-1]:
  a.extend([c]*b)
  if len(a)>2*n:
    break
a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 34756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>  // abs() for integer

using namespace std;

int main() {
	int n;
	vector<int> t, x, y;
	cin >> n;
	t.resize(n + 1);
	x.resize(n + 1);
	y.resize(n + 1);

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	for (int i = 0; i < n; i++) {
		int d_p = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		int d_t = t[i + 1] - t[i];
		//cout << d_p << " " << d_t << endl;
		if (d_t < d_p) {
			cout << "No" << endl;
			return 0;
		}
		if ((d_t - d_p) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1408
A, B, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = min(A)+min(B)
for _ in range(M):
  a, b, c = map(int, input().split())
  total = A[a-1]+B[b-1]-c
  ans = min(ans, total)
print(ans)

Measured memory_bytes: 70492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),m = obj.nextInt(),sum = 0,arr[] = new int[n];
        for(int i=0;i<n;i++){arr[i] = obj.nextInt();sum+=arr[i];}
        int count = 0;
        for(int i=0;i<n;i++)
            if(arr[i]>=(double)sum/(4*m))
                count++;
        System.out.println((count>=m)?"Yes":"No");
    }
}


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

int main(){
    i64 a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}


Measured memory_bytes: 256