akhauriyash/Code-Regression huggingface dataset:
N = int(input())
AS = [int(i) for i in input().split()]

m = 10 ** 18
acc = 1
if 0 in AS:
  print(0)
  import sys
  sys.exit()

for i in AS:
  acc *= i
  if acc > m:
    print('-1')
    import sys
    sys.exit()

print(acc)


Measured memory_bytes: 21580
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか

/*signed*/int main(void) {
    int x;
    cin >> x;
    if (x == 1) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3632
/*input
46 4 40 5
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x,y;
	x=ceil(c/(double)b);
	y=ceil(a/(double)d);
	if(x<=y)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}




Measured memory_bytes: 3712
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	int m,d;
	cin>>m>>d;
	int cnt = 0;
	REP(i,22,min(d,99)) {
		int d1 = i%10;
		int d2 = i/10;
		if(d1>=2&&d2>=2&&d1*d2<=m)cnt++;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int main() {
  priority_queue<int> q;
  string cmd;
  int i;
  while (true) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> i;
      q.push(i);
    } else if (cmd == "extract") {
      auto val = q.top();
      q.pop();
      cout << val << endl;
    } else if (cmd == "end") {
      break;
    }
  }
}


Measured memory_bytes: 6976
#include <stdio.h>
int main(void)
{
  int N;
  int a[100000];
  int Flag = 0;

  int i;

  scanf("%d",&N);
  
  for ( i = 0; i < N; i++)
    scanf("%d",&a[i]);
  
  for ( i = N - 1; i > 0 && Flag == 0; i-- ){
    if ( a[i] < a[i - 1] )
      if ( a[i] != a[i-1] - 1 ){
        Flag = 1;
      }
      else{
        a[i-1] -= 1;
      }
  }

  if ( Flag == 1 )
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}

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

using ll = long long;

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

	ll W, H, X, Y; cin >> W >> H >> X >> Y;
	long double area = (W * H) / 2.0;
	int ans = (2 * X == W && 2 * Y == H);
	cout << area << ' ' << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def b_sort(alist):
    for i in range(len(alist)):
        for j in range(len(alist)-1, i, -1):
            if alist[j][1] < alist[j-1][1]:
                alist[j], alist[j-1] = alist[j-1], alist[j]
        alist[i] = alist[i][0] + alist[i][1]
    return ' '.join(alist)


def s_sort(alist):
    for x in range(len(alist)):
        currentmin = x
        for y in range(x+1, len(alist)):
            if alist[y][1] < alist[currentmin][1]:
                currentmin = y
        if x != currentmin:
            alist[x], alist[currentmin] = alist[currentmin], alist[x]
        alist[x] = alist[x][0] + alist[x][1]
    return ' '.join(alist)


if __name__ == '__main__':
    N = int(input())
    alist = [list(x) for x in list(input().split())]
    clist = alist.copy()
    ans_b = b_sort(alist)
    ans_s = s_sort(clist)
    print(ans_b)
    print('Stable')
    print(ans_s)
    print('Stable' if ans_b == ans_s else "Not stable")



Measured memory_bytes: 5612
from pprint import pprint
from collections import deque, defaultdict
 
import sys
 
# n, q = map(int, input().strip().split(" "))
n, q = map(int, sys.stdin.readline().strip().split(" "))
edges = [[] for _ in range(n)]
for _ in range(n-1):
    # a_i, b_i = map(int, input().strip().split(" "))
    a_i, b_i = map(int, sys.stdin.readline().strip().split(" "))
    edges[a_i-1].append(b_i-1)
    edges[b_i-1].append(a_i-1)
 
counter = [0] * n
p = [0] * n
for _ in range(q):
    # p_i, x_i = map(int, input().strip().split(" "))
    p_i, x_i = map(int, sys.stdin.readline().strip().split(" "))
    p[p_i-1] += x_i
    # counter[p_i-1] += x_i
 
 
parents = deque()
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    if parent in visited:
        continue
    counter[parent] += p[parent]
    visited.add(parent)
    for child in edges[parent]:
        if child in visited:
            continue
        counter[child] += counter[parent]
        # print("child")
        # print(child, counter[child])
        parents.append(child)
 
print(" ".join(list(map(str, counter))))

Measured memory_bytes: 121544
import heapq

n, m, s, t = map(int, input().split())
s, t = s-1, t-1
src = [tuple(map(int, input().split())) for i in range(m)]

es = [[] for i in range(n)]
for u, v, a, b in src:
    u, v = u-1, v-1
    es[u].append((v, a, b))
    es[v].append((u, a, b))

inf = float('inf')
cy = [inf]*n
cy[s] = 0
hq = [(0, s)]
heapq.heapify(hq)
while hq:
    cost, v = heapq.heappop(hq)
    for to, a, b in es[v]:
        if cost+a >= cy[to]:
            continue
        cy[to] = cost+a
        heapq.heappush(hq, (cy[to], to))

cs = [inf]*n
cs[t] = 0
hq = [(0, t)]
heapq.heapify(hq)
while hq:
    cost, v = heapq.heappop(hq)
    for to, a, b in es[v]:
        if cost+b >= cs[to]:
            continue
        cs[to] = cost+b
        heapq.heappush(hq, (cs[to], to))

ans = [inf]
for i in reversed(range(n)):
    tmp = cs[i]+cy[i]
    ans.append(min(ans[-1], tmp))

for a in reversed(ans[1:]):
    print(10**15-a)
    


Measured memory_bytes: 73716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

int D;
vector<int> c(26);
vector<vector<int>> s;

int scoring(const vector<int>& t) {
    int v = 0;
    vector<int> last(26, -1);
    rep(i, D) {
        v += s[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) {
            v -= c[j] * (i - last[j]);
        }
    }
    return v;
}

// int diff_scoring(const vector<int>&t, int v, int to_d, int to_t) {
//     int last = -1;
//     rep(i, D) {
//         if (t[i] == to_t) v -= s[i][t[i]], last = i;
//         v += c[to_t] * (i - last)
//     }
//     last = -1;
//     rep(i, D) {
//         if (i == to_d || t[i] == to_d) {
//             v += s[i][t[i]], last = i;
//         }
//         v -= c[to_t] * (i - last);
//     }
//     return v;
// }

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

    // auto start = chrono::system_clock::now();
    
    cin >> D;
    rep(i, 26) cin >> c[i];
    s.resize(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];

    vector<int> t(D);

    rep(i, D) {
        t[i] = max_element(all(s[i])) - s[i].begin();
    }
    // random_device rnd;
    // mt19937 mt(rnd());
    // uniform_int_distribution<> rand_d(0, D-1);
    // uniform_int_distribution<> rand_t(0, 25);
    
    // rep(i, D) t[i] = rand_t(mt);

    // int v = scoring(t);
    
    // while (true) {
    //     int to_d = rand_d(mt);
    //     int to_t = rand_t(mt);
    //     if (t[to_d] == to_t) continue;
    //     int old = t[to_d];
    //     t[to_d] = to_t;
    //     if (!chmin(v, scoring(t))) {
    //         t[to_d] = old;
    //     }
    //     auto end = chrono::system_clock::now();
    //     auto dur = end - start;
    //     auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    //     if (msec >= 1950) break;
    // }
    
    rep(i, D) cout << t[i] + 1 << '\n';
}


Measured memory_bytes: 3716
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[200008], cntl[200008], cntr[200008];
string s;

int main(){
	cin >> n >> s;
	memset(a, 0, sizeof(a));
	memset(cntl, 0, sizeof(cntl));
	memset(cntr, 0, sizeof(cntr));
	for(ll i = 1; i <= n; i++){
		if(s[i-1] == '.'){a[i] = 1;}
		cntl[i] = cntl[i-1]+a[i];
	}
	for(ll i = n; i >= 1; i--){
		cntr[i] = cntr[i+1]+a[i];
	}

	ll ans = n;
	for(ll i = 0; i <= n; i++){
    	ans = min(i-cntl[i]+cntr[i+1], ans);	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5380
n = int(input())
a = list(map(int, input().split()))

a.append(0)
s = abs(a[0])
for i in range(n):
    s += abs(a[i+1]-a[i])

for i in range(n):
    print(s + abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]) ) )

Measured memory_bytes: 64620
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

int N;
VI A;

void solve() {
  int ans = 0;
  int tmp = 0;
  int j = 0;
  REP (i, N) {
    while (j < N && tmp + A[j] == (int)(tmp ^ A[j])) {
      tmp ^= A[j];
      j++;
    }
    ans += (j - i);
    tmp ^= A[i];
  }
  cout << ans << endl;
}

signed main() {
  cin >> N;
  A = VI(N);
  REP (i, N) {
    cin >> A[i];
  }

  solve();
}


Measured memory_bytes: 1792
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k){
        cout<<min(a,k)<<endl;
    }else{
        cout<<a-(k-a-b)<<endl;
    }
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

s=input().rstrip()
t=input().rstrip()
u=Counter(s)
v=Counter(t)
for i in range(len(s)):
    if u[s[i]]!=v[t[i]]:
        print("No")
        #print(i)
        sys.exit()
print("Yes")

Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 103,mod = 1e9+7,inf=0x3f3f3f3f;
int n,a[N];

int qpow(int a,int b){
    int ret=1;
    while(b){
        if(b&1) ret=(ll)ret*a%mod;
        a=(ll)a*a%mod; b>>=1;
    }
    return ret;
}
PII solve(int l,int r,int h){
    if(l==r) {
        int x=qpow(2,a[l]-h);
        //printf("%d %d %d %d\n",l,a[l],h,x);
        return Mp(x,x);
    }
    int mnh=inf;
    rep(i,l,r) mnh=min(mnh,a[i]);
    int c=1,t=qpow(2,mnh-h);
    rep(i,l,r) if(a[i]==mnh) c=(ll)c*2%mod;
    int x=1,y=1;
    for(int i = l,j=l; i<=r; i=j+1,j=i){
        if(a[i]==mnh) continue;
        while(j<r&&a[j+1]!=mnh) j++;
        PII ret=solve(i,j,mnh);
        x=(ll)x*ret.fi%mod;
        y=(ll)y*(ret.fi+ret.se)%mod;
    }
    int f=(ll)x*t%mod;
    int s=((ll)c*y+(ll)(t-2+mod)*x)%mod;
    //printf("%d %d %d %d\n",x,y,f,s);
    return Mp(f,s);
}

int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    printf("%d\n",solve(1,n,0).se);
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 200005;
int d[maxn], f[524290], g[524290];
int h[20][maxn][2], n, m, i, j, k, LG, b[30], cnt;
inline int solve(int m)
{
	if (m == 0)
	{
		b[0] = 1;
		return 1;
	}
	int nex = solve(m >> 1);
	b[nex] = m;
	return nex + 1;
}
inline int lower(int x, int t)
{
	int l = 1, r = n;
	while (l < r - 1)
	{
		int mid = l + r >> 1;
		if (h[t][mid][1] <= x) l = mid;
		else r = mid;
	}
	if (h[t][l][1] > x) return h[t][l][1];
	else return h[t][r][1];
}
inline int upper(int x, int t)
{
	int l = 1, r = n;
	while (l < r - 1)
	{
		int mid = l + r >> 1;
		if (h[t][mid][0] < x) l = mid;
		else r = mid;
	}
	if (h[t][r][0] < x) return h[t][r][0];
	else return h[t][l][0];
}
int main()
{
	cin >> n >> m;
	LG = solve(m);
	for(i = 1; i <= n; i ++)
		scanf("%d", &d[i]);
	for(j = 0; j < LG; j ++)
	{
		int lim = b[j];
		for(i = 1; i <= n;)
		{
			k = i;
			while (d[k + 1] - d[k] <= lim && k + 1 <= n) k ++;
			for(int l = i; l <= k; l ++)
				h[j][l][0] = i, h[j][l][1] = k;
			i = k + 1;
			if (j == LG - 1) cnt ++;
		}
	}
	if (cnt >= 19)
	{
		for(i = 1; i <= n; i ++)
			puts("Impossible");
		return 0;
	}
	int all = 1 << LG - 1;
	for(int s = 0; s < all; s ++)
		g[s] = n + 1;
	for(int s = 0; s < all; s ++)
		for(i = 0; i < LG - 1; i ++)
			if (!(s >> i & 1))
			{
				int opt = s | (1 << i);
				f[opt] = max(f[opt], lower(f[s], i));
				g[opt] = min(g[opt], upper(g[s], i));
			}
	for(i = 1; i <= n;)
	{
		bool ok = 0;
		for(j = all - 1; ; j = (j - 1) & (all - 1))
		{
			if (f[j] >= i - 1 && g[(all - 1) ^ j] <= h[LG - 1][i][1] + 1) {ok = 1; break;}
			if (j == 0) break;
		}
		for(j = i; j <= h[LG - 1][i][1]; j ++)
			if (ok) puts("Possible");
			else puts("Impossible");
		i = h[LG - 1][i][1] + 1;
	}
}

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

int main() {
	int s;
	cin >> s;
	if (s % 100 <= 12 && s % 100 != 0) {
		if(s / 100 <= 12 && s / 100 != 0)
			cout << "AMBIGUOUS";
		else
			cout << "YYMM";
	}
	else if (s / 100 <= 12 && s / 100 != 0) {
		if(s % 100 <= 12 && s % 100 != 0)
			cout << "AMBIGUOUS";
		else
			cout << "MMYY";
	}
	else {
		cout << "NA";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

const long long mod=998244353;
  
int main()
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  std::vector<std::vector<long long> > dp(2,std::vector<long long>(d-b+1));
  bool F=false;
  for(int i=0;i<=c-a;i++,F=!F){
    for(int j=0;j<=d-b;j++){
      if(i==0){
	if(j==0){
	  dp[F][j]=1ll;
	}
	else{
	  dp[F][j]=dp[F][j-1]*a%mod;
	}
      }
      else{
	dp[F][j]=dp[!F][j]*(b+j)%mod;
	if(j>0){
	  dp[F][j]=(dp[F][j]+(dp[F][j-1]+mod-dp[!F][j-1]*(b+j-1)%mod)*(a+i)+dp[!F][j-1]*(b+j-1))%mod;
	}
      }
      //printf("%d %d %lld\n",i,j,dp[F][j]);
    }
  }
  printf("%lld\n",dp[!F][d-b]);
  return 0;
}


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

int main()
{
	int x, y, i;
	cin >> x >> y;
	int legs = 0, cl = 0, tl = 0, c = 0, t = 0;
	for (i=0; i<=x; i++)
	{
		c = i;
		t = x-i;
		cl = 2*c;
		tl = 4*t;
		legs = cl+tl;
		if (legs == y)
		{
			cout << "Yes" << "\n";
			return 0;
		}
	}
	cout << "No" << "\n";
}


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

signed main(void)
{
	double l;
	cin >> l;

	double a, b, c;
	cout << fixed << setprecision(12);
	cout << (l / 3) * (l / 3) * (l / 3) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,ans=0;
	int a[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
//BELIEVE IN YOURSELF
//next_permutation

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define sortr(v) sort(v.rbegin(),v.rend());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;


int main()
{
	fast;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	ll x=a*c;
	ll y=a*d;
	ll z=b*c;
	ll t=d*b;
	cout<<max(x,max(y,max(z,t)))<<endl;
	
	
	return 0;
}

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

int main()
{
    char c;
    cin >> c;
    if(c == 'a' || c=='i'||c=='u'||c=='e'||c=='o')cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    String s=gs();
	    

	    
	    System.out.println(s.substring(0,3));
//	    if (s.replaceAll("hi", "").length()==0) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35876
/*-----Deep D. Savani------------
	-------DAIICT,INDIA--------------
	*/
	#include<bits/stdc++.h>
	#define pb push_back
	#define ff first
	#define ss second
	#define mp make_pair
	#define mod 1000000007
	#define deb(x) cout<<#x<<" : "<<x<<endl;
	#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
	#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
	#define nax 1000010
	#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	typedef long long ll;
	    
	using namespace std;

	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 

	#define T ll  
	#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> 
	    
	long long modulo(long long base,long long exponent,long long modulus);
	long long choose(ll n,ll k);
	ll inverse(ll a,ll m);



	void build()
	{
	    //freopen("input.txt","r",stdin);
	    //freopen("output.txt","w",stdout);
	}
	    
	    
	int main(){

	    build();
	    string s;
	    cin>>s;

	    ll bs=0;
	    ll ans=0;

	    for(int i=0;i<s.size();i++)
	    {
	    	if(s[i]=='B')
	    		bs++;
	    	else
	    		ans+=bs;
	    }
	    cout<<ans<<endl;
	    return 0;
	}
	    
	        
	    
	long long modulo(long long base,long long exponent,long long modulus)
	{
	    if(modulus ==1)
	        return 0;
	    
	    long long result=1;
	    base=base % modulus;
	    while(exponent>0)
	    {
	        if(exponent%2==1)
	        {
	            result=(result*base) % modulus;

	        }
	        exponent=exponent>>1;
	        base = (base*base) % modulus;
	    }
	        return result;
	}
	    
	long long choose(ll n,ll k)
	{
	    if(k==0)  return 1;
	    return (n* choose(n-1,k-1))/k;
	}
	    
	void EE(ll a,ll b,ll &co1,ll &co2)
	{
	    if(a%b==0)
	    {
	        co1=0;
	        co2=1;
	        return;
	    }
	    EE(b,a%b,co1,co2);
	    ll temp=co1;
	    co1=co2;
	    co2=temp-co2*(a/b);
	}
	    
	ll inverse(ll a,ll m)
	{
	    ll x,y;
	    EE(a,m,x,y);
	    if(x<0) x+=m;
	    return x;
	}

Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;


/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define policy tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

bool check(ll arr[], ll n, ll val, ll k)
{

	ll sum = 0;


	for (int i = 0; i < n; i++)
	{
		if (arr[i] > val)
		{
			ll d = arr[i] / val;
			if (arr[i] % val == 0)
			{
				d--;
			}
			sum += d;
		}

	}

	if (sum <= k) return true;

	return false;


}

void solve(int t)
{

	ll n, k;
	cin >> n >> k;

	ll a[n];
	ll ma = -1;

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

	}

	for (int i = 0; i < n; i++)
	{
		ma = max(ma, a[i]);
	}

	ll lo = 1;
	ll hi = ma;
	ll ans = ma;



	while (lo <= hi)
	{
		ll mid = (lo + hi) / 2;

		if (check(a, n, mid, k))
		{
			hi = mid - 1;
			ans = mid;
		}
		else
		{
			lo = mid + 1;
		}
	}

	cout << ans << endl;

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);



	int t = 1;
	//cin >> t;


	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 5140
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
std::pair<string,pair<int,int>> Q[101];
    ll N,M;
    ll A[5][5],B,C;
    bool F[5][5];
    bool ad=false;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    REP(i,3)REP(j,3){cin>>A[i][j];}
    cin>>N;
    REP(k,N){
        ll a;
        cin>>a;
        REP(i,3)REP(j,3){
            if(a==A[i][j])F[i][j]=true;
        }
    }
    REP(k,3){
        if(F[k][0]&&F[k][1]&&F[k][2])ad=true;
        if(F[0][k]&&F[1][k]&&F[2][k])ad=true;
        if(F[0][0]&&F[1][1]&&F[2][2])ad=true;
        if(F[0][2]&&F[1][1]&&F[2][0])ad=true;
    }
    cout<<(ad?"Yes":"No")<<endl;
    return 0;
}


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

int main(){
	double x1, y1, x2, y2;
	double d;
	cin >> x1 >> y1 >> x2 >> y2;
	d = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
	printf( "%lf\n", d );
return 0;
}

Measured memory_bytes: 1232
#38 B - Problem Set
import collections
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

cntD = collections.Counter(D)
cntT = collections.Counter(T)

result = 'YES'
for t in cntT.keys():
    if not(t in cntD):
        result = 'NO'
        break
    if cntT[t] > cntD[t]:
        result = 'NO'
        break
print(result)

Measured memory_bytes: 57008
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2311

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

vector< vector<char> > field(8,vector<char>(8));
int dx[8] = {1,1,0,-1,-1,-1,0,1};
int dy[8] = {0,1,1,1,0,-1,-1,-1};

int check(int x, int y, char c)
{
	int res=0;
	if(field[y][x] != '.'){ return 0; }
	rep(i,8)
	{
		int nx = x;
		int ny = y;
		int cnt=0;
		while(true)
		{
			nx += dx[i];
			ny += dy[i];
			if(nx < 0 || nx >= 8 || ny < 0 || ny >= 8){ break; }
			if(field[ny][nx] == c){ res += cnt; break; }
			if(field[ny][nx] == '.'){ break; }
			cnt++;
		}
	}
	return res;
}


void put(int x, int y, char c)
{
	field[y][x] = c;
	rep(i,8)
	{
		int nx = x;
		int ny = y;
		while(true)
		{
			nx += dx[i];
			ny += dy[i];
			if(nx < 0 || nx >= 8 || ny < 0 || ny >= 8){ break; }
			if(field[ny][nx] == c){
				while(true)
				{
					nx -= dx[i];
					ny -= dy[i];
					if(nx == x && ny == y){ break; }
					field[ny][nx] = c;
				}
				break; 
			}
			if(field[ny][nx] == '.'){ break; }
		}
	}
}

bool win()
{
	int o_cnt=0;
	int x_cnt=0;
	rep(y,8){
		rep(x,8){
			if(field[y][x] == 'o'){ o_cnt++; }
			if(field[y][x] == 'x'){ x_cnt++; }
		}
	}
	return o_cnt==0 || x_cnt==0 || o_cnt+x_cnt==64;
}

int main()
{
	rep(y,8){
		rep(x,8){
			cin >> field[y][x];
		}
	}

	int turn=1;
	int max_x, max_y;
	int pass=0;
	while(true)
	{
		char player = (turn % 2) ? 'o' : 'x';
		int num=0, max_x=-1, max_y=-1;
		if(player == 'o')
		{
			rep(y,8){
				rep(x,8){
					int tmp = check(x,y,player);
					if(num < tmp){
						num = tmp;
						max_x = x;
						max_y = y;
					}
				}
			}
		}
		else
		{
			for(int y=7;y>=0;y--){
				for(int x=7;x>=0;x--){
					int tmp = check(x,y,player);
					if(num < tmp){
						num = tmp;
						max_x = x;
						max_y = y;
					}
				}
			}
		}
		if(max_x != -1)
		{ 
			pass=0;
			put(max_x, max_y, player); 
		}else{
			pass++;
		}
		turn++;
		if(pass > 1){ break; }
		if(win()){ break; }
	}

	
	rep(y,8){
		rep(x,8){
			cout << field[y][x];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
def jyanken_win(enemy, r, s, p):
    score = 0
    if enemy == 's':
            score += r
    elif enemy == 'p':
            score += s
    elif enemy == 'r':
            score += p
    
    return score


def main():
    n,k = map(int, input().split())
    r,s,p = map(int, input().split())
    t = input()

    mine = []
    final_score = 0

    for i in range(n):
        if i >= k and mine[i-k] != 'not_win' and t[i-k] == t[i]: 
            mine.append('not_win')
        
        else:
            final_score += jyanken_win(t[i],r,s,p)
            mine.append('win')

    print(final_score)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N,M;
    cin >> N >> M;

    vector<int> kugi[N+2];
    kugi[0].push_back(0);
    kugi[0].push_back(0);
    for(int i=1; i<=N+1; ++i) {
        kugi[i].resize(i+1,0);
    }
    for(int i=0; i<M; ++i) {
        int A,B,X;
        cin >> A >> B >> X;
        kugi[A][B]=max(X+1,kugi[A][B]);
    }
    int ans=0;
    for(int i=1; i<=N; ++i) {
        for(int j=1; j<=i; ++j) {
            if(kugi[i][j]>0) ++ans;
            kugi[i+1][j]=max(kugi[i+1][j],kugi[i][j]-1);
            kugi[i+1][j+1]=max(kugi[i+1][j+1],kugi[i][j]-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 52076
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

string s[1005];
int vis[1005][1005], dist[1005][1005];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void solve() {  
    int h, w;
    cin >> h >> w;
    int u, v;
    cin >> u >> v; --u; --v;
    int x, y;
    cin >> x >> y; --x; --y;
    for (int i=0;i<h;++i) {
        cin >> s[i];
        for (int j=0;j<w;++j) {
            vis[i][j] = (s[i][j] == '#');
            dist[i][j] = oo;
        }
    }
    deque<pair<int,int>> bfs;
    bfs.push_back({u, v});
    dist[u][v] = 0;
    while(!bfs.empty()) {
        auto now = bfs.front();
        bfs.pop_front();
        if (vis[now.first][now.second]) continue;
        vis[now.first][now.second] = 1;
        int d = dist[now.first][now.second];
        for (int move=0;move<4;++move) {
            int i = now.first + dx[move];
            int j = now.second + dy[move];
            if (i < 0 || i >= h || j < 0 || j >= w) continue;
            if (dist[i][j] <= d) continue;
            dist[i][j] = dist[now.first][now.second];
            bfs.push_front({i, j});
        }
        for (int dx=-2;dx<=2;++dx) for (int dy=-2;dy<=2;++dy) {
            int i = now.first + dx;
            int j = now.second + dy;
            if (i < 0 || i >= h || j < 0 || j >= w) continue;
            if (dist[i][j] <= d + 1) continue;
            dist[i][j] = d + 1;
            bfs.push_back({i, j});
        }
    }
    if (dist[x][y] >= oo) cout << "-1\n";
    else cout << dist[x][y] << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 12644
class Dice
  attr_reader :top, :bottom, :front, :back, :left, :right #dice.top????????§???????????????????????????

  def initialize(dice_numbers) #dice????????????????¨??????????
    @top = dice_numbers[0]
    @back = dice_numbers[1]
    @right = dice_numbers[2]
    @left = dice_numbers[3]
    @front = dice_numbers[4]
    @bottom = dice_numbers[5]
  end

  def execute_order(orders) #???????????????????????§????????????????????????????????????
      orders.each do |order| #??????????????????????????¨????????????????????¢?????????
        if order == "N"
          move_north
        elsif order == "S" #3???north?????¢????????¨1???south?????¢??????????????¨????????¶????????????
          3.times do
            move_north
          end
        elsif order == "W"
          move_west
        elsif order == "E" #3???east?????¢????????¨1???west?????¢??????????????¨????????¶????????????
          3.times do
            move_west
          end
        else
          puts "error!" #?????¬????????????????????????
        end
      end
  end
  # p "[#{top}, #{back}, #{right}, #{left}, #{front}, #{bottom}]"
  private #class?????§????????????????????????
  def move_north
    tmp = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = tmp
  end

  def move_west
    tmp = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = tmp
  end
end

dice_numbers = gets.chomp.split.map(&:to_i)
orders = gets.chomp.split("")
dice = Dice.new(dice_numbers)
dice.execute_order(orders)
puts dice.top

Measured memory_bytes: 8640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    int inf = -1e9;
    for(int i = 0; i < m; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> cost(m);
    for(int i = 0; i < m; i++){
        if(a[i] == 1) cost[i] = 2;
        else if(a[i] == 2 || a[i] == 3 || a[i] == 5) cost[i] = 5;
        else if(a[i] == 4) cost[i] = 4;
        else if(a[i] == 6 || a[i] == 9) cost[i] = 6;
        else if(a[i] == 7) cost[i] = 3;
        else cost[i] = 7;
    }
    vector<int> dp(n + 1, inf);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(i - cost[j] >= 0)
                dp[i] = max(dp[i], dp[i - cost[j]] + 1);
        }
    }
    int l = dp[n];
    vector<int> ans(l);
    int i = 0;
    while(n > 0){
        for(int j = m - 1; j >= 0; j--){
            if(n - cost[j] >= 0 && dp[n] == dp[n - cost[j]] + 1){
                ans[i] = a[j];
                i++;
                n -= cost[j];
                break;
            }
        }
    }
    for(int i = 0; i < l; i++)
        cout << ans[i];
    cout << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> B(N);

  for(int i=0 ; i<N ; i++)
    cin >> B.at(i);

  int n = 0;

  for(int j=0 ; n<N ; n++){
    if(B.at(j) == 2){
      n++;
      break;
    }
    else
      j = B.at(j) - 1;    
  }

  if(n == N)
    cout << -1 << endl;
  else
    cout << n << endl;  
}


Measured memory_bytes: 640
n,d = map(int,input().split())
count = 0
#print()
l = [ list(map(int,input().split())) for i in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        sum = 0
        for k in range(d):
            sum += (l[j][k] - l[i][k])**2
        #print(int(sum**(1/2)),sum**(1/2))
        sum = sum**(1/2)
        if sum == int(sum):
            count += 1
        #print(i,j)
print(count)


Measured memory_bytes: 3188
/// nyaaaaa

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int N = (int) 3e5 + 5;
const int inf = (int) 1e9 + 7;

int n, l;
int a[N];
ll p[N];
set<pii> s;
set<int> can;

ll sum(pii x) {
  return p[x.second] - p[x.first - 1];
}

int main() {
  cin >> n >> l;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    p[i] = p[i - 1] + a[i];
    s.insert(make_pair(i, i));
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] + a[i + 1] >= l) {
      can.insert(i);
    }
  }
  vector<int> ans;
  while (!can.empty()) {
    int p = *can.begin();
    can.erase(can.begin());
    auto cur = prev(s.upper_bound(make_pair(p, inf)));
    if (next(cur) != s.end()) {
      pii F = *cur;
      pii S = *next(cur);
      s.erase(F);
      s.erase(S);
      ans.push_back(F.second);
      s.insert(make_pair(F.first, S.second));
      cur = prev(s.upper_bound(make_pair(F.first, inf)));
      if (next(cur) != s.end() && sum(*cur) + sum(*next(cur)) >= l) {
        can.insert(cur -> first);
      }
      if (cur != s.begin() && sum(*cur) + sum(*prev(cur)) >= l) {
        can.insert(prev(cur) -> first);
      }
    }
  }
  if (sz(s) != 1) {
    cout << "Impossible\n";
    return 0;
  }
  reverse(ans.begin(), ans.end());
  cout << "Possible\n";
  for (int i : ans) {
    cout << i << "\n";
  }

  return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a, b, c;
    cin >> a >> b >> c;
    c -= (a-b);
    cout << ((c < 0) ? 0 : c ) << endl;
}

Measured memory_bytes: 256
n = int(input())
xy_l = [[] for i in range(n)]
cnt = 0
for i in range(n):
    a = int(input())
    for j in range(a):
        xy = list(map(int, input().split()))
        xy_l[i].append(xy)
# 　括りとして、x,yの組み合わせ、人ごとの証言の組み合わせでそれぞれ分ける
for k in range(1 << n):
    ev = [0]*n
    for l in range(n):
        if (k >> l) & 1:
            ev[l] = 1
    #         ここまでで仮定は完成
    f = True
    for p,q in enumerate(xy_l):  # 第一変数はindexで第二変数が要素
        if ev[p]:
            for r in q:  # xy_lの要素
                if r[1] != ev[r[0] - 1]:
                    f = False
    if f:
        cnt = max(cnt, ev.count(1))
 
print(cnt)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

low = 0
high = len(A) -1

def check(mid, parts,key):
    if parts[mid] > key:
        return True
    return False
cnt = 0

# for a in A:
#
#     B_low = -1
#     B_high = len(B) - 1
#     b_cnt = 0
#     if a >= B[B_high]:
#         break
#     while B_high -B_low > 1:
#         mid = (B_high + B_low)//2
#
#         if check(mid, B, a):
#             B_high = mid
#             # b_cnt = _cnt
#
#         else:
#             B_low = mid
#     for b in B[B_high::]:
#         C_high = len(C) - 1
#         C_low = -1
#         c_cnt = 0
#         if b >= C[C_high]:
#             break
#         while C_high -C_low > 1:
#             mid = (C_high + C_low) //2
#             if check(mid,C ,b):
#                 C_high = mid
#             else:
#                 C_low= mid
#         # print(b, C_high, a)
#         # print(len(C[C_high::]))
#         cnt+=len(C[C_high::])

    # b_cnt = len(B) - B_high if B[B_high] > a  else 0
    # C_high = len(C) -1
    # C_low = -1
    # c_cnt = 0
    # if b_cnt >0:

    #     while C_high -C_low >1 :
    #         mid = (C_high + C_low )//2
    #         # _cnt = check(mid,C,B_high)
    #         if check(mid,C,B[B_high]):
    #             C_high  =mid
    #             # c_cnt = _cnt
    #         else:
    #             C_low = mid
    #     c_cnt = len(C) - C_high if C[C_high] > B[B_high] else 0
    # print(a,b_cnt,c_cnt)
    #
    # cnt += b_cnt * c_cnt



for b in B:
    A_low = -1
    A_high = len(A)
    while A_high - A_low > 1:
        mid = (A_high + A_low) //2
        if A[mid] < b:
            A_low = mid
        else:
            A_high = mid

    a_cnt =  A_low + 1
    C_low = -1
    C_high = len(C)
    while C_high - C_low > 1:
        mid = (C_high + C_low) //2
        if C[mid] > b:
            C_high = mid
        else:
            C_low = mid
    c_cnt = len(C) - C_high

    cnt += a_cnt * c_cnt
print(cnt)



Measured memory_bytes: 23328
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  int ans = n/11*2; n %= 11;
  if(n==0) ; 
  else if(n <= 6) ans++;
  else ans += 2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define int ll
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=10005;
int N,X[MN],Y[MN];
int d[45],n;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const char dc[4]={'D','L','U','R'};
void get(int x,int y)
{
	reg int i,j;
	for(i=n;~i;--i)for(j=0;j<4;++j)
	{
		int xx=x+dx[j]*d[i],yy=y+dy[j]*d[i];
		if(abs(xx)+abs(yy)<d[i]){x=xx,y=yy;printf("%c",dc[j]);j=5;}
	}
}
signed main()
{
	N=read();
	reg int i,mx=0;bool fl=1;
	for(i=1;i<=N;++i)
		X[i]=read(),Y[i]=read(),fl&=(~(X[i]+Y[i]-X[1]-Y[1])&1),
		mx=max(mx,abs(X[i])+abs(Y[i])+2);
	if(!fl) return 0*puts("-1");
	fl=~(X[1]+Y[1])&1;
	for(d[1]=n=1;(d[n]<<1)<mx;++n,d[n]=d[n-1]<<1);
	printf("%d\n",n+fl);
	if(fl) printf("1 ");
	for(i=1;i<=n;++i) printf("%d ",d[n-i+1]);puts("");
	for(i=1;i<=N;++i)
	{
		if(fl) printf("R");
		get(X[i]-fl,Y[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256