akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

void solve()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int dp[n][n];
    for(int len=1;len<=n;len++)
    {
        for(int i=0;i<n;i++)
        {
            int j=i+len-1;
            if(j>=n)
                break;
            if(i==j)
            {
                dp[i][j]=arr[i];
                continue;
            }
            dp[i][j]=max(arr[i]-dp[i+1][j], arr[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1]<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 49712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  vector<ll> s(n + 1, 0);
  REP(i, n) { s[i + 1] = s[i] + a[i]; }

  // a[i] + a[j] >= x となる (i,j)がm組以上ある最大のxは？
  ll ok = 0, ng = 1e18;
  while (ok + 1 < ng) {
    ll x = (ok + ng) / 2;
    ll cnt = 0;
    REP(i, n) {
      // a[j] >= x-a[i]を満たすjの個数は？
      ll t = a.end() - lower_bound(ALL(a), x - a[i]);
      cnt += t;
    }
    (cnt >= m ? ok : ng) = x;
  }
  ll ans = 0, cnt = 0;
  REP(i,n){
    ll t = a.end() - lower_bound(ALL(a),ok-a[i]);
    cnt += t;
    ans += t*a[i] + s[n]-s[n-t];
  }
  ans -= ok*max(0LL,cnt-m);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  if((2*K)>((N-1)*(N-2))){
    cout << -1 << endl;
  }
  else{
    int p = (N-1)*(N-2)/2-K;
    int M = N-1+p;
    cout << M << endl;
    for(int i = 2;i<=N;i++){
      cout << 1 << " " << i << endl;
    }
    for(int i = 2;i<=N;i++){
      for(int k = i+1;k<=N;k++){
        if(p == 0){
          i = N;
          k = N;
          break;
        }
        cout << i << " " << k << endl;
        p--;

      }
    }
  }
  return 0;
}

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

char tar[53][53], pat[53][53];

bool compare(char(*tar)[53], int N, char(*pat)[53], int M) {
	bool unfind = 0;
	for (int i = 1;i <= N;++i) {
		for (int j = 1;j <= N;++j) {
			unfind = 0;
			for (int m = 1, di = i;m <= M;++m, ++di) {
				for (int n = 1, dj = j;n <= M;++n, ++dj) {
					if (tar[di][dj] != pat[m][n]) {
						unfind = 1;
						break;
					}
				}
				if (unfind)
					break;
			}
			if (!unfind)
				return true;
		}
	}
	return false;
}

int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 1;i <= N;++i)
		for (int j = 1;j <= N;++j)
			cin >> tar[i][j];
	for (int i = 1;i <= M;++i)
		for (int j = 1;j <= M;++j)
			cin >> pat[i][j];
	if (compare(tar, N, pat, M))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AOJ-1130-2
//
//  Created by Kenta Kodera on 2017/06/18.
//  Copyright ?? 2017??´ Kenta Kodera. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

int W, H;

int dfs(vector<string> &room, int h, int w){
  
  int dh[4] = {1, 0, -1, 0};
  int dw[4] = {0, 1, 0, -1};
  room[h][w] = '#';
  
  int ans = 1;
  for(int i=0; i<4; i++){
    int nh = h + dh[i];
    int nw = w + dw[i];
    if(0<=nh && nh<H && 0<=nw && nw<W && room[nh][nw] == '.'){
      ans += dfs(room, nh, nw);
    }
  }
  return ans;
}

int main(){
  
  while(cin >> W >> H, W|H){
    
    vector<string> room(H);
    for(int i=0; i<H; i++){
      cin >> room[i];
    }
    
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        if(room[h][w] == '@'){
          cout << dfs(room, h, w) << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3244
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGacha solver = new CGacha();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGacha {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TreeSet<String> h = new TreeSet<>();
            while (n-- > 0) {
                h.add(in.next());
            }
            out.println(h.size());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 62208
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#define long long ll
using namespace std;

int main()
{
	int x,y,z;
	while(cin>>x>>y>>z)
	{
		int k=(x-z)/(y+z);
		cout<<k<<endl;
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

const int maxN = 100005;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

struct Edge {
	int to, cost, time;
	Edge(int _to, int _cost, int _time){
		to = _to;
		cost = _cost;
		time = _time;
	}
};


class TaskE {
private:
	Debugger debugger;
	const int LIMIT = 4005;
	const long long INF = 1000000000000000LL;
	vector<vector<Edge>> graph;

public:

	void solveOne(int it){
		int n , m , silver;
		cin >> n >> m >> silver;
		silver = min(silver, LIMIT);
		graph.assign(n, vector<Edge>());
		for(int i = 0; i < m; i++){
			int x , y , a , b;
			cin >> x >> y >> a >> b;
			x--;
			y--;
			graph[x].push_back(Edge(y, a, b));
			graph[y].push_back(Edge(x, a, b));
		}
		vector<int> rewards(n) , time(n);
		for(int i = 0; i < n; i++){
			cin >> rewards[i] >> time[i];
		}
		priority_queue< pair<long long, pair<int,int>> > q;
		q.push({0, {0,silver} } );
		vector<vector<long long>> dist(n, vector<long long>(LIMIT + 1, INF));
		dist[0][silver] = 0;
		while(!q.empty()){
			auto curr = q.top(); q.pop();
			long long d = -curr.first;
			int u = curr.second.first;
			int coins = curr.second.second;
			for(Edge e : graph[u]){
				if(e.cost <= coins and e.time + d < dist[e.to][coins - e.cost]){
					dist[e.to][coins - e.cost] = e.time + d;
					q.push({-dist[e.to][coins - e.cost], {e.to, coins - e.cost}});
				}
			}
			if( coins + rewards[u] <= LIMIT and d + time[u] < dist[u][coins + rewards[u]]){
				dist[u][coins + rewards[u]] = d + time[u];
				q.push({-dist[u][coins + rewards[u]], {u, coins + rewards[u]}});
			}
		}
		for(int i = 1; i < n; i++){
			long long mini = INF;
			for(int c = 0; c <= LIMIT; c++){
				mini = min(mini, dist[i][c]);
			}
			cout << mini << endl;
		}

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 6972
#define NDEBUG
#include <bits/stdc++.h>
#define clean(x,y) memset(x,y,sizeof(x))
#define inc(i,s,t) for(int i=s;i<=t;++i)
#define dec(i,s,t) for(int i=s;i>=t;--i)
#define debug(x) std::cerr<<(x)<<" "
typedef long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() {
	debug("Time: ");
	debug(clock()) << " ms\n";
}
inline ll read() {
	static char c;
	static ll x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}

void ok() {puts("Yes");}
void no() {puts("No");}

ll gcd(ll x, ll y) {
	return !y ? x : gcd(y, x % y);
}

void solve() {
	ll A = read(), B = read(), C = read(), D = read();
	if (B > A || B > D)
		return no();
	if (B <= C)
		return ok();

	if ((A - C - 1) / gcd(B, D) - (A - B) / gcd(B, D) > 0)
		return no();
	return ok();
}

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif

	int T = read();
	while (T--)
		solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int N, i;
	float tmp=0;
	int V[1001];

	i_cin(N);
	i_cins(N, V);
	qsort(V, N, sizeof(int), s_asort);
	
	tmp += (float)V[0];
	for (i = 1; i < N; i++) 
		tmp = (tmp + (float)V[i]) / 2;

	f_cout(tmp);

	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
INF = 2 * 10**5 * 10**9
n = int(input())
a = map(int,input().split())
s = [0]
for x in a:
    s.append(s[-1]+x)
ans = INF
p1 = 1
p = 2
p2 = 3
def update():
    global ans
    if p1 < p and p2 < n:
        ans = min(ans , max(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) -  min(s[p1],s[p]-s[p1],s[p2]-s[p],s[n]-s[p2]) )
    if p2 < n and p1 - 1 >= 1:
        ans = min(ans , max(s[p1-1],s[p]-s[p1-1],s[p2]-s[p],s[n]-s[p2]) -  min(s[p1-1],s[p]-s[p1-1],s[p2]-s[p],s[n]-s[p2]) )
    if p1 < p and p2-1 >= p:
        ans = min(ans , max(s[p1],s[p]-s[p1],s[p2-1]-s[p],s[n]-s[p2-1]) -  min(s[p1],s[p]-s[p1],s[p2-1]-s[p],s[n]-s[p2-1]) )
    if p1-1 >= 1 and p2-1 >= p:
        ans = min(ans , max(s[p1-1],s[p]-s[p1-1],s[p2-1]-s[p],s[n]-s[p2-1]) -  min(s[p1-1],s[p]-s[p1-1],s[p2-1]-s[p],s[n]-s[p2-1]) ) 
while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
    p2 += 1
update()
while True:
    p += 1
    if p + 1 >= n:
        break
    while p1 < p and s[p1] < s[p] - s[p1]:
        p1 += 1
    while p2 < n and s[p2] - s[p] < s[n] - s[p2]:
        p2 += 1
    update()
print(ans)

Measured memory_bytes: 27340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();

		String s = scanner.next();
		String t = scanner.next();

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < n; i++) {
			sb.append(s.substring(i, i + 1));
			sb.append(t.substring(i, i + 1));
		}

		System.out.println(sb.toString());
	}

}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int r, g;

int main() {
	cin >> r >> g;
	
	cout << r + 2 * (g - r) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll n;cin>>n;
	ll a[n],ans=1,cnt=0;
	rep(i,n) cin>>a[i];
	sort(a,n+a,greater<ll>());
	rep(i,n){
		if(a[i]==a[i+1]){
			ans*=a[i];
			cnt++;
			if(cnt==2){
				cout<<ans<<"\n";
				return 0;
			}
			i++;
		}
	}
	cout<<0<<"\n";
}

Measured memory_bytes: 1024
//
// Created by yamunaku on 2020/05/03.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n, k;
    cin >> n >> k;
    vi a(n, 0);
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int x;
            cin >> x;
            a[x - 1]++;
        }
    }
    int ans = 0;
    rep(i, n){
        if(a[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
def main():
    _ = int(input())
    a = list(map(int,input().split()))
    l = [0] * 9
    for v in a :
        if v//400 >=8:
            l[-1] +=1
        else:
            l[v//400] += 1
    cnt = 0
    for i in range(len(l)-1):
        if l[i] != 0: cnt+=1

    mx = cnt + l[-1]
    mn = cnt if cnt != 0 else 1 if l[-1] != 0 else 0
    print("{} {}".format(str(mn),str(mx)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// AtCoder abc152-C

#include <algorithm>
#include <cstdio>

unsigned int getGCD(unsigned int a, unsigned int b) {
  if (a < b)
    std::swap(a, b);

  while (b != 0) {
    unsigned int mod = a % b;
    a = b;
    b = mod;
  }

  return a;
}

unsigned int getPowerOf2(unsigned int min) {
  unsigned int value = 1;
  while (value < min)
    value <<= 1; // value *= 2;
  return value;
}

unsigned int *getGCDSegmentTree(unsigned int *values, unsigned int number,
                                unsigned int *outTreeSize) {
  unsigned int numberPadded = getPowerOf2(number);
  unsigned int size = numberPadded * 2;
  unsigned int *tree = new unsigned int[size];

  for (unsigned int i = 0; i < number; i++) {
    tree[numberPadded + i] = values[i];
  }
  for (unsigned int i = numberPadded + number; i < size; i++) {
    tree[i] = 0;
  }

  for (unsigned int i = numberPadded - 1; i > 0; i--) {
    tree[i] = getGCD(tree[2 * i], tree[2 * i + 1]);
  }

  tree[0] = 0;
  *outTreeSize = size;
  return tree;
}

unsigned int getMinGCDRecursive(unsigned int *gcdTree, unsigned int treeSize,
                                unsigned int index, unsigned int restGCD) {
  if (index >= (treeSize / 2)) {
    return restGCD;
  }
  unsigned int leftIndex = 2 * index;
  unsigned int rightIndex = 2 * index + 1;
  unsigned int gcdLeft = gcdTree[leftIndex];
  unsigned int gcdRight = gcdTree[rightIndex];
  unsigned int gcdMinLeft = getMinGCDRecursive(gcdTree, treeSize, leftIndex,
                                               getGCD(gcdRight, restGCD));
  unsigned int gcdMinRight = getMinGCDRecursive(gcdTree, treeSize, rightIndex,
                                                getGCD(gcdLeft, restGCD));
  return (gcdMinLeft < gcdMinRight) ? gcdMinRight : gcdMinLeft;
}

unsigned int getMinGCD(unsigned int *gcdTree, unsigned int treeSize) {
  return getMinGCDRecursive(gcdTree, treeSize, 1, 0);
}

int main() {
  unsigned int n;
  std::scanf("%u", &n);

  unsigned int *values = new unsigned int[n];

  for (unsigned int i = 0; i < n; i++) {
    unsigned int value;
    std::scanf("%u", &value);
    values[i] = value;
  }

  unsigned int treeSize = 0;
  unsigned int *gcdTree = getGCDSegmentTree(values, n, &treeSize);

  unsigned int result = getMinGCD(gcdTree, treeSize);
  std::printf("%u\n", result);

  delete[] gcdTree;
  delete[] values;

  return 0;
}


Measured memory_bytes: 1664
#!/usr/bin/perl
use Data::Dumper;
my ($n,$m) = map { $_ - 0 } split(/[\s]+/,<STDIN>);
my @ab = ();
for(my $i=0;$i<$m;$i++){
  my ($a,$b) = map { $_ - 1 } split(/[\s]+/,<STDIN>);
  push(@ab,+[$a,$b]);
}
my @r = (); $#r = $m-1;
my @c = (); $#c = 10**6;
my @a = (); $#a = $n-1;
my $mi = 0;
my $nc = 1;
my $tot = $n * ($n - 1) / 2;
for(my $i=$m-1;$i>=0;$i--){
  $r[$i] = $tot - $mi;
  #$r[$i] = 0 if $r[$i] <= 0 or ( $i<$m-1 and $r[$i+1]==0);
  my ($a1,$b1) = @{$ab[$i]};
  if( $a[$a1] eq '' and $a[$b1] eq '' ){
    $a[$a1] = $a[$b1] = $nc;
    $c[$nc++] = +[2,+[$a1,$b1]];
    $mi += 1;
  } elsif( $a[$a1] eq '' and $a[$b1] ){
    $a[$a1] = $a[$b1];
    $mi += $c[$a[$b1]]->[0];
    $c[$a[$b1]]->[0] ++;
    push(@{$c[$a[$b1]]->[1]},$a1);
  } elsif( $a[$b1] eq '' and $a[$a1] ){
    $a[$b1] = $a[$a1];
    $mi += $c[$a[$a1]]->[0];
    $c[$a[$a1]]->[0] ++;
    push(@{$c[$a[$a1]]->[1]},$b1);
  } elsif( $a[$b1] == $a[$a1] ){
    # 変化なし
  } else {
    $mi -= ( ( $c[$a[$a1]]->[0] * ( $c[$a[$a1]]->[0] - 1 ) ) + ( $c[$a[$b1]]->[0] * ( $c[$a[$b1]]->[0] - 1 ) ) ) / 2;
    if( $c[$a[$a1]]->[0] < $c[$a[$b1]]->[0] ){
      $c[$a[$b1]]->[0] += $c[$a[$a1]]->[0];
      $c[$a[$a1]]->[0] = 0;
      $mi += ( $c[$a[$b1]]->[0] * ( $c[$a[$b1]]->[0] - 1 ) ) / 2;
      push(@{$c[$a[$b1]]->[1]},@{$c[$a[$a1]]->[1]});
      foreach my $j (@{$c[$a[$a1]]->[1]}){
        $a[$j] = $a[$b1];
      }
    } else {
      $c[$a[$a1]]->[0] += $c[$a[$b1]]->[0];
      $c[$a[$b1]]->[0] = 0;
      $mi += ( $c[$a[$a1]]->[0] * ( $c[$a[$a1]]->[0] - 1 ) ) / 2;
      push(@{$c[$a[$a1]]->[1]},@{$c[$a[$b1]]->[1]});
      foreach my $j (@{$c[$a[$b1]]->[1]}){
        $a[$j] = $a[$a1];
      }
    }
  }
}
for(my $i=0;$i<$m;$i++){
  print "$r[$i]\n";
}

exit(0);

__END__
4 5
1 2
3 4
1 3
2 3
1 4


Measured memory_bytes: 74112
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 18:45:39 2020

@author: Kanaru Sato
"""

n = int(input())
h = list(map(int, input().split()))

dp = [-1]*n

for i in range(n):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = abs(h[1]-h[0])
    else:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    int N;
    cin >> N;
    vi A(N+1, 0);
    rep(i, N) cin >> A[i];

    int res = 0;
    int sum = 0;
    rep(i, N+1) {
        if(A[i]==0) {
            res += sum/2;
            sum = 0;
        } else {
            sum += A[i];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
S = [['.'] + list(input()) + ['.'] for i in range(H)]
l = [0, -1, 1]

S = [['.'] * (W + 2)] + S + [['.'] * (W + 2)]

for i in range(H):
    for j in range(W):
        temp = 0
        if S[i + 1][j + 1] == '.':
            for k in l:
                for kk in l:
                    if S[i + 1 + k][j + 1 + kk] == '#':
                        temp += 1
            S[i + 1][j + 1] = str(temp)

for i in range(H):
    print(''.join(S[i + 1][1:W + 1]))

Measured memory_bytes: 3188
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())

    T = set()
    for A in args[2::2]:
        T |= set(map(int, A.split()))

    return str(n-len(T))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 59;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  auto f = [&](ll div) {
    return (b/div)-((a-1)/div);
  };
  ll del = f(c)+f(d)-f(c*d/__gcd(c,d));
  cout << (b-a+1)-del << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    } 
 
    int size(int x){
        return -parents[find(x)];
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    vector<int> members(int x){
        int root = find(x);
        vector<int> member;
        for(int i=0;i<n;i++){
            if(find(i)==root ){
                member.push_back(i);
            }
        }
        return member;
    }

    int group_cnt(){
        int c = 0;
        rep(i,n){
            if(parents[i] < 0) ++c;
        }
        return c;
    }
};

struct xy{
    int id,x,y;
};

int main(){
    int n;
    cin >> n;
    vector<xy> a(n);
    rep(i,n){
        a[i].id = i;
        cin >> a[i].x >> a[i].y;
    }
    sort(a.begin(),a.end(),[](const xy &l,const xy &r){ return l.x < r.x;});
    set<P> st;
    Unionfind uf(n);

    rep(i,n){
        st.insert(P(a[i].y,a[i].id));
        auto it = st.lower_bound(P(a[i].y,a[i].id));

        while(it != st.begin()){
            uf.unite(a[i].id,(*it).second);
            it = st.erase(it);
            --it;
        }

        uf.unite(a[i].id,(*it).second);
    }

    rep(i,n){
        cout << uf.size(i) << endl;
    }
    return 0;
}

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

int main()
{
    long long n,i;
    cin>>n;
    int arr[n+10];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    long long  cnt=0;
   long long maxi=0;
    for(i=0; i<n-1; i++)
    {
        if( arr[i]>=arr[i+1])
        {
            cnt++;
        }
        else
        {
           if(maxi<cnt)
                maxi = cnt;
           cnt=0;
        }
    }
   cout<<max(cnt,maxi)<<endl;

}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    a = int(input())

    res = n ** 2 - a
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
l=[0]*(n+1)
count=0
for i,a2 in enumerate(a,1):
    l[a2]=i
l=l[1:]
for j in range(n-1):
    if l[j]+1==l[j+1]:
        count+=c[j]
print(sum(b)+count)    


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
 
typedef long long ll;
const int INF = 1e9+7;
 
 
int n;
vector<int> in;
 
 
void input(){
    cin>>n;
    rep(i,n){
        int t;
        cin>>t;
        in.push_back(t);
    }
}
 
 
ll getHash(vector<int>& a){
    ll ret=0, t=1;
    rep(i,a.size()){
        ret += a[i]*t;
        t*=11;
    }
    return ret;
}
 
void reverse(vector<int>& a, int b, int c){
    while(b<c){
        swap(a[b], a[c]);
        b++; c--;
    }
}
 
map<ll,int> memo;
 
int ans = INF;
 
 
void saiki(vector<int>& a, int mode, int depth, int limit){
     
    if(mode==0){
        bool ok = true;
        rep(i,a.size()){
            if(a[i]!=i+1)ok=false;
        }
        if(ok)ans = min(ans, depth);
    }
 
    if(mode==1){
        ll h = getHash(a);
        if(memo.find(h)!=memo.end()){
            int s = memo[h] + depth;
            ans = min(ans, s);
            return;
        }
    }
 
    if(depth==limit){
        if(mode==0)memo[getHash(a)] = depth;
        return;
    }
 
 
    rep(i,a.size()){
        reps(j,i+1,a.size()){
            reverse(a, i ,j);
            saiki(a, mode, depth+1, limit);
            reverse(a,i,j);
        }
    }
}
 
int solve(){
    vector<int> tmp;
    rep(i,in.size())tmp.push_back(i+1);
 
    ans = in.size()-1;
 
    int limit = (in.size()-1)/2;
 
    saiki(in, 0, 0, limit);
    saiki(tmp, 1, 0, limit);
 
    return ans;
}
 
int main(){
    input();
    cout<<solve()<<endl;
}

Measured memory_bytes: 17100
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

def main():
    n,y = map(int,input().split())

    for i in range(n+1):
        for j in range(n+1):
            k = n - i - j
            if k < 0:
                continue
            if 10000*i + 5000*j + 1000*k == y:
                return i,j,k
                
    return -1,-1,-1

if __name__=='__main__':
    print(*main())

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long


LL prime[168]={
  2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 , 101 , 103 , 107 , 109 , 113 , 127 , 131 , 137 , 139 , 149 , 151 , 157 , 163 , 167 , 173 , 179 , 181 , 191 , 193 , 197 , 199 , 211 , 223 , 227 , 229 , 233 , 239 , 241 , 251 , 257 , 263 , 269 , 271 , 277 , 281 , 283 , 293 , 307 , 311 , 313 , 317 , 331 , 337 , 347 , 349 , 353 , 359 , 367 , 373 , 379 , 383 , 389 , 397 , 401 , 409 , 419 , 421 , 431 , 433 , 439 , 443 , 449 , 457 , 461 , 463 , 467 , 479 , 487 , 491 , 499 , 503 , 509 , 521 , 523 , 541 , 547 , 557 , 563 , 569 , 571 , 577 , 587 , 593 , 599 , 601 , 607 , 613 , 617 , 619 , 631 , 641 , 643 , 647 , 653 , 659 , 661 , 673 , 677 , 683 , 691 , 701 , 709 , 719 , 727 , 733 , 739 , 743 , 751 , 757 , 761 , 769 , 773 , 787 , 797 , 809 , 811 , 821 , 823 , 827 , 829 , 839 , 853 , 857 , 859 , 863 , 877 , 881 , 883 , 887 , 907 , 911 , 919 , 929 , 937 , 941 , 947 , 953 , 967 , 971 , 977 , 983 , 991 , 997
};

const long long N=168;
const long long M=1000000007;


void pf(LL n,LL* count){
  // cout<<n<<"=";
  REP(i,N){
    if(prime[i]/2>n) break;
    while(n%prime[i]==0){
      //  cout<<prime[i]<<"*";
      n/=prime[i];
      count[i]++;
    }
  }
  //cout<<"1\n"<<endl;
}

  

int main(){
  LL n;
  cin>>n;
  LL count[168];
  REP(i,168){
    count[i]=0;
  }

  for(LL i=2;i<=n;i++){
    pf(i,count);
  }

  LL ret=1;
  REP(i,N){
    ret=((ret%M)*((count[i]+1)%M))%M;
  }
  
  cout<<ret<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N; 
vector<int> A, ans, lis;
vector<vector<int>> graph;

void dfs(int v, int p = -1){
  int i = lower_bound(ALL(lis), A[v])-lis.begin();
  int old = lis[i];

  lis[i] = A[v];
  ans[v] = lower_bound(ALL(lis), INF)-lis.begin()-1;

  for(auto u : graph[v]){
    if(u == p) continue;
    dfs(u, v);
  }

  lis[i] = old;
}

signed main() {
  cin >> N;

  A.resize(N);
  REP(i, N) cin >> A[i];

  graph.resize(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  
  ans.resize(N);
  lis.resize(N+1, INF);
  lis[0] = -INF;

  dfs(0);

  REP(i, N){
    cout << ans[i] << "\n";
  }

  return 0;
}

Measured memory_bytes: 30340
N = int(input())
s, t = input(), input()

v = 0
for i in range(len(s)):
    # print(s[-(i + 1):], t[:i + 1])
    if s[-(i + 1):] == t[:i + 1]:
        v = i + 1
# print('v', v)
ans = N * 2 - v
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

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

    System.out.print(Math.min(a, b) + " ");

    if ((a + b) >= n) {
      System.out.println((a + b) - n);
    } else {
      System.out.println(0);
    }

  }
}

Measured memory_bytes: 38352
import java.util.Scanner;


public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		String ans = "";
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
			c-=3;
			if(c<'A'){
				c+=26;
			}
			ans+=c;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22188
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int sum,a[100010],cnt[100010];

signed main()
{
	ios::sync_with_stdio(false);
	int n;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
	for(int i=1;i<=n;i++) cnt[a[i]]++;
	int q;cin>>q; 
	for(int i=1;i<=q;i++){
		int b,c;cin>>b>>c;
		sum+=(c-b)*cnt[b];
		cnt[c]+=cnt[b];cnt[b]=0;
		cout<<sum<<'\n';
	}
	return 0;
}

Measured memory_bytes: 5196
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

mod=10**9+7

MAX_N=n+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

max_x=0
for i in range(k-1,n):
  max_x+=a[i]*nCk(i,k-1)
  max_x%=mod
#  print(a[i],nCk(i,k-1))

min_x=0
for i in range(n-k+1):
  min_x+=a[i]*nCk(n-i-1,k-1)
  min_x%=mod
#  print(a[i],nCk(n-i,k-1))

print((max_x-min_x)%mod)

Measured memory_bytes: 19544
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define N 100005
int n, l, a[N], x;
signed main()
{
	scanf("%d", &n), scanf("%d", &l);
	for(int i= 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i= 1; i < n; i++)
		if(a[i] + a[i + 1] >= l)
		{
			x= i;
			break;
		}
	if(x == 0)
	{
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	for(int i= 1; i < x; i++) printf("%d\n", i);
	for(int i= n - 1; i > x; i--) printf("%d\n", i);
	printf("%d\n", x);
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  for(int i = A; i <= B; i++){
  	if(i % N == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
      
  cout << "NG" << endl;
  
  return 0;
        
}


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

int main() {
  ll a, b, x, r;
  cin >> a >> b;

  x = a * b;

  if(a < b){
    swap(a, b);
  }

  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  } 

  cout << x / b << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, h[20];

int main() {
	cin >> n;
	inc(i, n) { cin >> h[i]; }
	
	int ma = 0, ans = 0;
	inc(i, n) { if(setmaxeq(ma, h[i])) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
def prime_factorize(x):
    a=[]
    b=[]
    while x%2==0:
        if 2 not in b:
            a.append(2)
            b.append(2)
            x/=2
        else:
            a.append(2)
            x/=2
    f=3
    while f*f<=x:
        if x%f==0:
            if f not in b:
              a.append(f)
              b.append(f)
              x/=f
            else:
              a.append(f)
              x/=f
        else:
          f+=2        
    if x!=1:
      a.append(int(x))
      if int(x) not in b:
        b.append(int(x))
    return a,b    

def comb(n, b):
    if b > n - b:
      b = n - b
    r = 1
    for k in range(n, n-b, -1):
      r = r * k
    d = 1
    for k in range(1, b+1):
      d = d * k
    return r // d 
  
ans=1
A,B=prime_factorize(m)

for i in range(len(B)):
  c=A.count(B[i])  
  ans*=comb(c+n-1,c)
  ans%=10**9+7

print(ans)
               

Measured memory_bytes: 3064
matrix = []
vector = []
n, m = gets.split.map(&:to_i)

for i in 1..n
matrix.push(gets.split.map(&:to_i))
end

for i in 1..m
vector.push(gets.to_i)
end

for i in 1..n
sum = 0
for k in 1..m
sum += matrix[i-1][k-1] * vector[k-1]
end

puts sum

end




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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  string ans = "dangerous";

  if(b<=a) ans = "delicious";
  else if(a<b && b<=a+x) ans = "safe";

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int b[125];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",b+i);
  vi v;
  while(n){
    bool ok = false;
    FORR(i,0,n)if(b[i]==i+1){
      ok = true;
      v.push_back(i+1);
      FOR(j,i,n-1)b[j] = b[j+1];
      n--;
      break;
    }
    if(!ok){
      puts("-1");
      return 0;
    }
  }
  reverse(ALL(v));
  for(int x : v){
    printf("%d\n",x);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

 
using namespace std;
const int N=601, mod= 1e9+7;
vector<int> g[N];
vector<long double> dp1(N),dp2(N);

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,m;
	
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u].pb(v);
	}
	
	for(int i=n-1;i>0;i--){
		for(auto v:g[i]){
			dp1[i]+=dp1[v]+1;
		}
		dp1[i]/=g[i].size();
	}
	
	long double ans=dp1[1];
	
	
	for(int i=1;i<n;i++){
		if(g[i].size()<2) continue;
		
		long double mx=-1;
		for(auto j:g[i]){
			if( mx<dp1[j] ){
				mx=dp1[j];
			}
		}
		
		for(auto k:g[i]){
			if( dp1[k]==mx ){
				
				dp2[n]=0;
				for(int j=n-1;j>0;j--){
					dp2[j]=0;
					int ct=0;
					for(auto v:g[j]){
						if( i==j && v==k ) continue;
						ct++;
						dp2[j]+=dp2[v]+1;
					}
					dp2[j]/=ct;
				}
				ans=min(ans,dp2[1]);
				
			}
		}
		
		
	}
	
	
	cout<<fixed<<setprecision(8)<<ans<<"\n";
	
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

    long double ans = 0;

    for (int i=1; i<=min(n, k-1); i++) {
        ans += (long double)1/(n*pow(2, ceil(log2((long double)k/i))));
    }

    if (n >= k)
        ans += (long double)(n-k+1)/n;

    // cout << setprecision(10) << ans << endl;
    printf("%.14Lf\n", ans);
}


Measured memory_bytes: 888
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn argmin<T>(u: &[T]) -> (usize)
where
    T: Copy + PartialOrd,
{
    assert!(u.len() != 0);

    let mut min_index = 0;
    let mut min = u[min_index];

    for (i, v) in u.iter().enumerate().skip(1) {
        if min > *v {
            min_index = i;
            min = *v;
        }
    }
    min_index
}

fn argmax<T>(u: &[T]) -> (usize)
where
    T: Copy + PartialOrd,
{
    assert!(u.len() != 0);

    let mut max_index = 0;
    let mut max = u[max_index];

    for (i, v) in u.iter().enumerate().skip(1) {
        if max < *v {
            max_index = i;
            max = *v;
        }
    }
    max_index
}

fn main() {
    let n: usize = read();
    let a = read_vec::<i64>();
    let a_min_idx = argmin(&a);
    let a_min = a[a_min_idx];
    let a_max_idx = argmax(&a);
    let a_max = a[a_max_idx];

    if a_min == a_max {
        println!("0");
        return;
    }

    println!("{}", 2 * n - 1);
    if a_max.abs() > a_min.abs() {
        for i in 0..n {
            println!("{0} {1}", a_max_idx + 1, i + 1);
        }
        for i in 1..n {
            println!("{0} {1}", i - 1 + 1, i + 1);
        }
    } else {
        for i in 0..n {
            println!("{0} {1}", a_min_idx + 1, i + 1);
        }
        for i in (0..n - 1).rev() {
            println!("{0} {1}", i + 1 + 1, i + 1);
        }
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] arts) {
		Scanner sc = new Scanner(System.in);
		int length = 0;
		int breadth = 0;
		int x = sc.nextInt();
		length = x;
		x = sc.nextInt();
		breadth = x;
		System.out.println((length * breadth) + " " + (2 * (length + breadth)));
		sc.close();
	}
}


Measured memory_bytes: 26132
def main():
    import numpy as np

    n = int(input())
    a = list(map(int, input().split()))
    b = np.array(a)

    cost = np.sum(b ** 2)

    for i in range(-100, 101, 1):
        cost = min(cost, np.sum((b - i) ** 2))
    print(cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12504