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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<i64> red(A);
    rep(i, 0, A) cin >> red[i];
    vector<i64> green(B);
    rep(i, 0, B) cin >> green[i];
    vector<i64> cless(C);
    rep(i, 0, C) cin >> cless[i];
    sort(all(red));
    reverse(all(red));
    sort(all(green));
    reverse(all(green));
    sort(all(cless));
    reverse(all(cless));

    priority_queue<i64> que;
    rep(i, 0, X) que.push(red[i]);
    rep(i, 0, Y) que.push(green[i]);
    rep(i, 0, C) que.push(cless[i]);

    i64 ans = 0;
    rep(i, 0, X + Y) {
        auto a = que.top();
        que.pop();
        ans += a;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1000000010;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<int> h;
  for (int i = 0; i < N; i++) {
    int t; cin >> t;
    h.push_back(t);
  }
  sort(h.begin(), h.end());
  int ans = INF32;
  for (int i = 0; i < N-K+1; i++) {
    ans = min(ans, h[i+K-1] - h[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <stdio.h>
int main(void)
{
    int n, l, i, sum=0;

    scanf("%d%d", &n, &l);

    int r[n];
    for(i=0; i<n; i++){
        r[i] = l + (i+1) - 1;
        sum = sum + r[i];
    }

int r2[n];

for(i=0; i<n; i++){
if(r[i]<0){
    r2[i] = r[i]*(-1);
}else{
    r2[i] = r[i];
}
}

int m=0;

    int min = r2[0];
    for(i=1; i<n; i++){
        if(r2[i]<min){
            min = r2[i];
             m = i;
        }
    }

int ans = sum - r[m];
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}
#define MAX_N 500000
int bit_[MAX_N + 1];
int n_; //assign length of sequence

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit_[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= n_) {
    bit_[i] += x;
    i += i & -i;
  }
}
signed main() {
  int N;
  cin >> N;
  while (N != 0) {
    fill(ALL(bit_), 0LL);
    int R;
    cin >> R;
    map<int, int> dict;
    rep(i, N) dict[i + 1] = i + 1;
    rep(i, R) {
      int s, t;
      cin >> s >> t;
      int temp = dict[s];
      dict[s]  = dict[t];
      dict[t]  = temp;
    }
    n_ = N;
    rep(i, N) add(i + 1, 1);
    vector<int> fact_list = {1};
    rep(i, N) {
      fact_list.emplace_back(fact_list[i] * (i + 2) % MOD);
    }
    int ans = 0;
    rep(i, N - 1) {
      ans = (ans + (sum(dict[i + 1]) - 1) * fact_list[N - (i + 2)]) % MOD;
      add(dict[i + 1], -1);
    }
    cout << ans << endl;
    cin >> N;
  }
}



Measured memory_bytes: 14796
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),k=read(),ans=0,a[200005],sum[200005],key[200005],hs[200005],cnt=0;
int bit[200005];
inline void add(int x,int v){
	for(int i=x;i<=200000;i+=(i&(-i)))
		bit[i]+=v;
}
inline int query(int x){
	if(x==0)	return 0;
	int sum=0;
	for(int i=x;i;i-=(i&(-i)))
		sum+=bit[i];
	return sum;
}
signed main(){
	key[0]=-0x3f3f3f3f;
	fz(i,1,n)	a[i]=read();
	fz(i,1,n)	sum[i]=sum[i-1]+a[i];
	fz(i,1,n)	sum[i]-=k*i,key[i]=sum[i];
	sort(key+1,key+n+1);
	fz(i,1,n+1){
		if(key[i]!=key[i-1]){
			hs[++cnt]=key[i];
		}
	}
	add(lower_bound(hs+1,hs+cnt+1,0)-hs,1);
	fz(i,1,n){
//		cout<<sum[i]<<endl;
		int ind=lower_bound(hs+1,hs+cnt+1,sum[i])-hs;
		ans+=query(ind);
		add(ind,1);
	}
	cout<<ans<<endl;
	return 0;
}

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

void solve() {
	int N, K; cin >> N >> K;
	vector<int> A(N);
	rep(i, N) scanf("%d", &A[i]);

	int res = 0;
	int right = 0;
	while (true) {
		if (res == 0) right += K;
		else right += K - 1;
		res++;
		if (right >= N) break;
	}

	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void solve() {
	lli n, m, q, k;
	cin >> n;
	vcL num( n, 0 );
	vcI even( 100000+99, 0 );
	vcI odd( 100000+99, 0 );

	lli _min = INT_MAX, _max = 0;

	for (int i = 0; i < n; ++i) {
		cin >> num[i];
		
		if ( i&1 ) {
			odd[ num[i] ]++ ;
		}
		else {
			even[ num[i] ]++ ;
		}
	}
	
	int odd_max = 0, odd_sec = 0, even_max = 0, even_sec = 0;
	
	for (int i = 1; i <= 100000; ++i) {
		
		if ( odd[i] > odd[odd_sec] ) {
			odd_sec = i;
			
			if ( odd[i] > odd[odd_max] ) {
				swap( odd_sec, odd_max );
			}
		}
		
		if ( even[i] > even[even_sec] ) {
			even_sec = i;
			
			if ( even[i] > even[even_max] ) {
				swap( even_sec, even_max );
			}
		}
	}
	
	if ( odd_max != even_max ) {
		cout << n - ( odd[odd_max] + even[even_max] ) << '\n';
	}
	else {
		cout << n - max( odd[odd_max]+even[even_sec], odd[odd_sec]+even[even_max] ) << '\n';
	}
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
	string S;
	cin >> S;
	int len = S.size();
	int max = 0;
	REP(i,len){
		if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
			int count = 0;
			int j = i;
			while(i<len){
				if(S[i]!='A'&&S[i]!='C'&&S[i]!='G'&&S[i]!='T'){
					break;
				}
				i++;
			}
			count += i-j;
			if(max<count) max=count;
		}
	}
	cout << max << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

int n, m;

vector<int> g[10];

int seen[10] = {0};


int dfs(int now, int counter){
	if(counter >= n - 1){
		return 1;
	}

	seen[now] = 1;

	int ret = 0;

	for(int i = 0; i < g[now].size(); i++){

		int next = g[now][i];
		if(seen[next] == 1) continue;

		ret += dfs(next, counter + 1);

	}
	seen[now] = 0;

	return ret;
}


int main(void){
	cin >> n >> m;

	for(int i = 0; i < m; i++){
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		tmp1--;
		tmp2--;
		g[tmp1].push_back(tmp2);
		g[tmp2].push_back(tmp1);
	}

	cout << dfs(0, 0) << endl;

}



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

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,W;
int w[100010],v[100010];
int dp[111][100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N>>W;
    rep(i,0,N){
        cin>>w[i]>>v[i];
    }
    
    rep(i,0,N){
        rep(j,0,W+1){
            chmax(dp[i+1][j],dp[i][j]);
            if(j<w[i])continue;
            chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout<<dp[N][W]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 81408
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    ll N, M;
    cin >> N >> M;
    if(!(N + 1 == M or M + 1 == N or M == N)){
        puts("0");
        return 0;
    }
    ll sum = 1;
    ll MOD = 1000000007;
    for(ll i = 2; i <= N; i++){
        sum *= i;
        sum %= MOD;
    }
    for(ll i = 2; i <= M; i++){
        sum *= i;
        sum %= MOD;
    }
    if(N + 1 == M or M + 1 == N) cout << sum << endl;
    if(N == M) cout << sum * 2 % MOD << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
cnt = [[0]*3 for i in range(n+1)]
for i,c in enumerate(s):
    if c == 'R':
        cnt[i+1][0] += 1
    if c == 'G':
        cnt[i+1][1] += 1
    if c == 'B':
        cnt[i+1][2] += 1
    for j in range(3):
        cnt[i+1][j] += cnt[i][j]
ans = 0
for i in range(1,n-1):
    if s[i] == 'R':
        ans += cnt[i][1]*(cnt[n][2]-cnt[i][2])
        ans += cnt[i][2]*(cnt[n][1]-cnt[i][1])
    elif s[i] == 'G':
        ans += cnt[i][0]*(cnt[n][2]-cnt[i][2])
        ans += cnt[i][2]*(cnt[n][0]-cnt[i][0])
    else:
        ans += cnt[i][1]*(cnt[n][0]-cnt[i][0])
        ans += cnt[i][0]*(cnt[n][1]-cnt[i][1])
    for j in range(1,min(i+1,n-i)):
        if s[i-j] != s[i] and s[i] != s[i+j] and s[i-j] != s[i+j]:
            ans -= 1
print(ans)

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

int main() {
    int n;
    cin >> n;
    n++;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }

    if(a[0] == 1) {
        if(n==1) {
            cout << 1 << endl;
            return 0;
        } else {
            cout << -1 << endl;
            return 0;
        }
    } else if(a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<long long> vmax(n), vmin(n);
    vmax[n-1] = a[n-1];
    vmin[n-1] = a[n-1];
    for (int i=n-2; i>=0; i--) {
        vmin[i] = max((long long) 1,vmin[i+1]/2) + a[i];
        vmax[i] = vmax[i+1] + a[i];
    }
    vmax[0] = 1;
    vmin[0] = 1;

    // added
    for (int i=1; i<n; i++) {
        //vmin[i] = max(vmin[i], 1+a[i]);
        vmax[i] = min(vmax[i], (vmax[i-1]-a[i-1])*2);
        if(vmax[i] < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        if(i!=(n-1) && (vmax[i]-a[i] < 1)) {
            cout << -1 << endl;
            return 0;
        }
    }

    long long ans = 1;
    long long nprev = 1;
    for (int i=1; i<n; i++) {
        ans += vmax[i];
        //cout << nprev << endl;
    }
    //for (int i=0; i<n; i++) {
        //cout << vmin[i] << " ~ " << vmax[i] << endl;
    //}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1000000007;


int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    vector<ll> v(n), V(n);
    rep(i, n) {
        v[i] = x[i] - y[i];
        V[i] = x[i] + y[i];
    }
    sort(all(v));
    sort(all(V));
    cout << max(v[n - 1] - v[0], V[n - 1] - V[0]) << endl;
    return 0;
}

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

int partition(int n,int A[]){
    int x=A[n-1];//基準
    int p=0,i=p-1;
    for(int j=0;j<n;j++){
        if(A[j]<=x){//A[j]の方が大きいならそのまま
        int tmp=A[j];
        A[j]=A[++i];
        A[i]=tmp;
        if(j==n-1)return i;
        }
    }
    return n-1;//[]で括るために取り出さないと。
}

int main(){
    int n;cin>>n;int A[n];for(int i=0;i<n;i++)cin>>A[i];
    int x=partition(n,A);
    for(int j=0;j<n;j++){
        if(j)cout<<' ';
        if(j==x)cout<<'['<<A[j]<<']';
        else{cout<<A[j];}
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define ll long long
int main(){
	io;
	ll n;
	cin>>n;
	set<string> arr;
	for(ll i = 0; i < n; i++){
		string s;
		cin>>s;
		arr.insert(s);
	}
	cout<<arr.size();
	return 0;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll,int>> factor(ll x) {
        vector<pair<ll,int>> res;
        for (int p : primes) {
            int y = 0;
            while (x%p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p,y);
        }
        if (x != 1) res.emplace_back(x,1);
        return res;
    }
};


int main() {
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a,b);
    Sieve sieve(1e6);
    auto fs = sieve.factor(g);
    int ans = fs.size();
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
   ll n;
   cin >> n;
   ll a[n + 1];
   ll b[n];
   rep(i, n + 1) cin >> a[i];
   rep(i, n) cin >> b[i];

   ll ans = 0;
   rep(i, n) { 
        if(a[i] + a[i + 1] >= b[i]){
            ans += b[i];
            if(b[i] >= a[i])
                a[i + 1] -= b[i] - a[i];
        } else {
            ans += a[i] + a[i + 1];
            a[i + 1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

}


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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int n, d;
    scanf("%d %d", &n, &d);
    int ans = 0;
    if(d+1 > n){
        printf("%d\n", 1);
        return;
    }
    for(int i = d+1; i <= n; i+= 2*d+1){
        ans++;
        if(i + 2*d+1 > n && i + d+1 <= n) ans++;
    }
    printf("%d\n", ans);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
N = int(input())
a = input().split()


for i in range(0,N):
	a[i] = int(a[i])
mi = 0
for i in range(0,N-1):
	for j in range(i+1,N):
		if abs(a[i]-a[j]) > mi:
			mi = abs(a[i]-a[j])
print(mi)

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

Measured memory_bytes: 1596
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[3];

signed main(){
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  cout << a[0] << " "<< a[1] << " "<< a[2] << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>

int main(){
  int N;
  std::cin >> N;
  int Ans=0;
  
  for(int i=1;i<=N;i++){
    for(int j=1;i*j<N;j++){
      if(N - i*j > 0){
		Ans++;
     }
    }
  }

  std::cout << Ans << std::endl;
      
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.txt");
	//ifstream cin ("fileName.txt");

	int ans=-1;
	
	for(int i=0; i<5; ++i) {
		ll n;
		cin >> n;
		if(n==0) ans=i+1;
	}
	
	cout << ans << "\n";
 	
	return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	double t, x;
	cin >> t >> x;

	printd(t / x, 10);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a %mod;
        a=a*a %mod;
        b/=2;
    }
    return res;
}

int main(){
    string s;cin>>s;
    ll ans=0,count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            ans+=power(2,count)*power(3,s.size()-i-1);
            ans%=mod;
            count++;
        }
    }
    ans+=power(2,count);
    cout<<ans%mod;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sort_(a) sort(a.begin(), a.end())
#define sum(a) accumulate(a.begin(), a.end(), 0)
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

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

  int N;
  cin >> N;
  map<string, int> S{};
  string s;
  rep(i, N) {
    cin >> s;
    sort_(s);
    S[s] += 1;
  }

  ll ans = 0;
  ll n = 0;
  for (auto i = S.begin(); i != S.end(); ++i) {
    n = i->second;
    ans += (n * (n - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P


int main(){
	long long N;
	scanf("%lld", &N);

	int f = 0;
	long long n = N;
	while(n>0){
		f += n%10;
		n /= 10;
	}

	if(N%f==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,k; cin>>n>>m>>k;
	vector<int64_t>a(n+1),b(m+1); a.front()=b.front()=0;
	for(int i=1;i<=n;++i)cin>>a.at(i); for(int i=1;i<=m;++i)cin>>b.at(i);
	for(int i=1;i<=n;++i)a.at(i)+=a.at(i-1); for(int i=1;i<=m;++i)b.at(i)+=b.at(i-1);
	int i=0; while(i<n&&a.at(i)<=k)++i;
	int ans=0;
	for(int j=0;i>=0&&j<m;--i){
		while(j<=m&&a.at(i)+b.at(j)<=k)++j;
		if(j>0)--j;
		if(a.at(i)+b.at(j)<=k)ans=max(ans,i+j);
	}
	cout<<ans<<"\n"s;//for(auto&&i:a)cout<<" "s<<i;cout<<"\n"s;for(auto&&i:b)cout<<" "s<<i;cout<<"\n"s;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	int ans = 0;
	for (int i = 1; i <= 31; ++i) {
		for (int j = 2; j <= 9; ++j) {
			int k = pow(i, j);
			if (k <= x) ans = max(ans, k);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;

int a, b, c;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
	for(int i = 1; i < 1000000; i++)
	{
		if((i * a) % b == c)  
    	{
    		printf("YES\n");
    		return 0;
		}
	}
	printf("NO\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



ll n,k;
ll a[200010];

bool ok(ll x) {
    ll count = 0;
    ll cnt = 0;
    rep(i,n){
        ll left = -1, right = n;
        
        if(a[i] > 0){
            while(right - left > 1){
                ll mid = (left + right) / 2;
                if(a[i] * a[mid] <= x) left = mid;
                else right = mid;
            }
            cnt += right;
        }
        else if(a[i] < 0) {
            while(right - left > 1) {
                ll mid = (left + right) / 2;
                if(a[i] * a[mid] <= x) right = mid;
                else left = mid;
            }
            cnt += n - right;

        }
        else if(x >= 0) cnt += n;
        if(a[i] * a[i] <= x) cnt--;
       
        // cout<<i<<" "<<cnt<<", ";
    }
    count += cnt / 2;

    // cout<<x<<" "<<count<<endl;

    if(count < k) return true;
    else return false;
}



void solve() {
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll left = -LLINF, right = LLINF;
    while(right - left > 1) {
        ll mid = (left + right) / 2;
        if( ok(mid) ){
            left = mid;
        }
        else right = mid;
    }

    cout<<right<<endl;

    // ok(7);
    // ok(9);
    // ok(-3);

    // rep(i,(ll)v.size()) cout<<v[i]<<endl;
    // cout<<endl<<endl;;
    // rep(i,(ll)p.size()) cout<<p[i]<<endl;
    // cout<<endl;
    

}








signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int w,h;
	for(;;){
		std::cin >> h>>w;
		if(w==0)exit(0);
		rep(i,h){
			rep(j,w){
				std::cout << "#";
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
}


Measured memory_bytes: 3116
#include<iostream>

using namespace std;

int main(void)
{
  string s; cin>>s;
  string str[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int num;
  
  for(int i=0;i<7;i++){
    if(s==str[i]){num=i; break;}
  }
  
  cout<<7-num<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  string s,t; cin >> s >> t;

  int ans = INT_MAX;

  for(int i=0;i<=s.size()-t.size();i++){
    string x = s.substr(i,t.size());
    int cnt = 0;
    for(int j=0;j<t.size();j++){
      if(x[j]!=t[j]) cnt++;
    }
    ans = min(ans,cnt);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;
  static int a[101010];
  m0(a);
  int all = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] > 0) all += a[i];
  }

  static int p[101010], m[101010];
  m0(p), m0(m);

  for (int i = 1; i <= N; i++) {
    if (a[i] > 0) {
      p[i] = p[i - 1] + a[i];
      m[i] = m[i - 1];
    } else {
      p[i] = p[i - 1];
      m[i] = m[i - 1] + a[i];
    }
  }

  int ans = -INF;
  for (int i = 1; i + K - 1 <= N; i++) {
    int tp = p[i + K - 1] - p[i - 1];
    int tm = m[i + K - 1] - m[i - 1];
    chmax(ans, all - tp + max(0LL, tp + tm));
  }

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


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

using namespace std;

int main(void) {
    string S; cin >> S;
    string T; cin >> T;
    int q; cin >> q;
    vector<vector<int> > abcd(q, vector<int>(4));
    for (int i=0; i<q; i++) {
        cin >> abcd[i][0] >> abcd[i][1] >> abcd[i][2] >> abcd[i][3];
    }

    vector<int> ssum(S.size()+1, 0);
    for (int i=0; i<S.size(); i++) {
        ssum[i+1] = ssum[i] + (S[i]=='A' ? 1 : -1);
    }
    vector<int> tsum(T.size()+1, 0);
    for (int i=0; i<T.size(); i++) {
        tsum[i+1] = tsum[i] + (T[i]=='A' ? 1 : -1);
    }

    for (int i=0; i<q; i++) {
        int sub_s = ssum[abcd[i][1]] - ssum[abcd[i][0]-1];
        int sub_t = tsum[abcd[i][3]] - tsum[abcd[i][2]-1];

        if ((sub_s - sub_t) % 3 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

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

    int a = A.length();
    int b = B.length();

    if (a > b){
        cout << "GREATER" << endl;
    }
    else if (a < b){
        cout << "LESS" << endl;
    }
    else {
        if (A == B){
            cout << "EQUAL" << endl;
        }
        else if(A > B){
            cout << "GREATER" << endl;
        }
        else {
            cout << "LESS" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll P=1e9+7;
const int N=55;
int n; ll c[N][N],f[N][N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n; c[0][0]=1;
	for(int i=1;i<=n;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%P;
	}
	f[1][0]=f[1][1]=n;
	for(int i=1;i<n;i++) for(int j=0;j<=i;j++){
		//printf("i=%d j=%d f=%lld\n",i,j,f[i][j]);
		for(int x=0;x<=n-i;x++) for(int y=0;x+y<=n-i;y++) if(x+y>=max(j,1) && !((x+y-j)&1)){
			(f[i+x+y][abs(j+(x+y-j)/2-x)]+=f[i][j]*c[n-i][x+y]%P*c[x+y][x])%=P;
			//cout<<x<<" "<<y<<" "<<abs(j+(x+y-j)/2-x)<<endl;
		}
	}
	cout<<f[n][0]<<endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
import collections

n, m = map(int, input().split())

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

cnt = 0

for i in itertools.permutations(range(2, n + 1), (n - 1)):
    li = [1] + list(i)
    if sum(list(sorted(edge)) in a for edge in zip(li, li[1:])) == n - 1:
        cnt += 1

print(cnt)


Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w; 
bool ok = false;
vector<string> grid;
void dfs(vector<vector<char>> pass, int y, int x){
    if(y==h-1 && x==w-1){
        pass[y][x] = '#';
        bool fg = true;
        rep(i, h){
            rep(j, w){
                if(pass[i][j] != grid[i][j])fg = false;
            }
        }
        if(fg)ok = true;
        return;
    }
    pass[y][x] = '#';
    if(y<h-1){
        dfs(pass, y+1, x);
    }
    if(x<w-1){
        dfs(pass, y, x+1);
    }
}

int main(){
    cin >> h >> w;
    vector<vector<char>> pass(h, vector<char>(w, '.'));
    grid.resize(h);
    rep(i, h){
        string s; cin >> s;
        grid[i] = s;
    }
    dfs(pass, 0, 0);
    if(ok) cout << "Possible" << ln;
    else cout << "Impossible" << ln;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int a[5], ans=0;
  int m = 10;
  for(int i=0; i<5; i++){
    cin >> a[i];
    if(a[i]%10!=0){
      m = min(m, a[i]%10);
      a[i] /= 10;
      a[i]++;
      a[i] *= 10;
    }
    ans += a[i];
  }
  ans -= (10-m);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<int> solve(int N, const vector<ll>& xs)
{
    vector<int> ans(N, 0);

    for (int i = 0; i < N; ++i)
        ans[0] += (i % 2) ? -xs[i] : xs[i];

    for (int i = 1; i < N; ++i)
        ans[i] = 2*(xs[i - 1] - ans[i - 1]/2);

    return ans;
}

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

    int N;
    cin >> N;

    vector<ll> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    for (int i = 0; i < N; ++i)
        cout << ans[i] << (i + 1 == N ? '\n' : ' ');

    return 0;
}


Measured memory_bytes: 2560
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
mod = 10 ** 9 + 7
class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N * M, mod)
t = f.combi(N * M - 2, K - 2)

res = 0
for d in range(1, M):
  x = N ** 2 % mod * (M - d) % mod
  res += x * d % mod
  res %= mod
  #print(x)
for d in range(1, N):
  y = M ** 2 % mod * (N - d) % mod
  res += y * d % mod
  res %= mod
#print(res, t)
print(res * t % mod)

Measured memory_bytes: 54644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 2e5+10;
const ll P = 1e9+7;
ll fact[maxN],temp[maxN];
ll ksm(ll x,ll y,ll p)
{
    ll ans=1,base=x;
    while(y>0)
    {
        if(y&1)ans=(ans%p)*(base%p)%p;
        base=(base%p)*(base%p)%p;
        y>>=1;
    }
    return ans%p;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    ll gcd=exgcd(b,a%b,x,y);
    ll tempx=x;
    x=y,y=tempx-a/b*y;
    return gcd;
}

ll C(ll n,ll m)
{
    if(n<m)return 0;
    ll a=temp[m];
    ll b=fact[m];
    ///cout<<a<<" "<<b<<endl;
    ll x,y;
    exgcd(b,P,x,y);
    x=(x%P+P)%P;
    return a*x%P;
}
int main()
{
    ll N,a,b;
    cin>>N>>a>>b;
    fact[1]=1;
    for(ll i=2;i<=max(a,b);i++)fact[i]=(fact[i-1]*i)%P;
    temp[1]=N;
    for(ll i=2;i<=max(a,b);i++)temp[i]=(temp[i-1]*(N-i+1))%P;
    ll part1=(ksm(2,N,P)-1)%P;
    ///cout<<part1<<endl;
    ll part2=-C(N,a);
    ///cout<<part2<<endl;
    ll part3=-C(N,b);
    ///cout<<part3<<endl;
    int ans=((part1+part2+part3)%P+P)%P;
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

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





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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(110);
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << "#" << a.at(i) << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    repeat(readLine()?.toInt() ?: 0) {
        val str1 = readLine() ?: ""
        val str2 = readLine() ?: ""
        val matrix = Array(str1.length + 1) {
            IntArray(str2.length + 1)
        }
        for (i in 0 until str1.length) {
            matrix[i][0] = 0
        }
        for (j in 0 until str2.length) {
            matrix[0][j] = 0
        }
        for (i in str1.indices) {
            for (j in str2.indices) {
                matrix[i + 1][j + 1] = if (str1[i] == str2[j]) {
                    matrix[i][j] + 1
                } else if (matrix[i][j + 1] >= matrix[i + 1][j]) {
                    matrix[i][j + 1]
                } else {
                    matrix[i + 1][j]
                }
            }
        }
        println(matrix.flatMap { it.toList() }.max())
    }
}


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

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				cerr<<"yaha aya"<<"\n"
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

const int MAX = 1e5+1;
const int LG = 30+1;

int main(void)
{
	int n;cin>>n;
	int a[n];
	rep(i,0,n-1) cin>>a[i];
	int ans = 0;
	sort(a,a+n);
	rep(i,0,n-1)
	{
		int cur = 0;
		rep(j,i+1,n-1)
		{
			int up = a[i] + a[j];
			// int idx = upper_bound(a,a+n,up) - a;
			while(cur < n and a[cur] < up) cur++;
			cur--;
			// cout<<i<<" "<<j<<"\n";
			ans += cur - j;
		}
	}
	cout<<ans<<"\n";

}

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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

int counter[60];
char slo[N];

int main()
{
	scanf("%s", slo);
	int n = strlen(slo);
	long long wynik = 1;
	for (int i = 0; i < n; i ++) {
		counter[slo[i]] ++;
		wynik -= counter[slo[i]];
		for (int i = 'a'; i <= 'z'; i++) wynik += counter[i];
	}
	printf("%lld\n", wynik);
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	//int ;
	long m,hun,as,kl,o,n,p,k,l;
	String op;
	Scanner sc = new Scanner(System.in);
	public void solve() {	
n=sc.nextInt();
m=sc.nextInt();
m=m*m;
for(o=0;o<n;o++) {
	as=sc.nextInt();
	kl=sc.nextInt();
	if(kl<0) {
		kl=kl*-1;
	}else if(as<0) {
		as=as*-1;
	}
	
	k=as*as;
	l=kl*kl;
	hun=k+l;
	if(m>=hun) {
		p=p+1;
	}
}
System.out.println(p);
	}
	public static void main(String[] args) {
		new Main().solve();
	
	}
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;

  if (B / A > C){
    cout << C << endl;
  }
  else
  {
    cout << B / A << endl;
  }
  
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
priority_queue<ll,vector<ll>,greater<ll> > q;
int k;
int main(){
	k=read();
	for(int i=1;i<=9;++i){
		q.push(i);
	}
	while(k--){
		ll u=q.top();
		q.pop();
		if(!k){
			printf("%lld\n",u);
			break;
		}
		int las=u%10;
		q.push(u*10+las);
		if(las-1>=0)q.push(u*10+las-1);
		if(las+1<=9)q.push(u*10+las+1);
	}
//	getchar();
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

bool graph[55][55];
bool seen[55];

void dfs(int i,int n){
  seen[i] = true;
  for(int j = 0;j < n;j++){
    if(graph[i][j] == false) continue;
    if(seen[j] == true) continue;
    dfs(j,n);
  }
  return;
}

int main(){
  int n,m; cin >> n >> m;
  vector<int> a(m),b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    --a[i];--b[i];
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;
  rep(i,m){
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    rep(j,n) seen[j] = false;
    dfs(0,n);
    rep(j,n) {
      if(!seen[j]) {
        //printf("%d %d\n",a[i],b[i]);
        ans++;
        break;
      }
    }
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632